Repository navigation
Expand file tree
/
Copy pathcompound_gate.py
More file actions
executable file
·191 lines (169 loc) · 5.99 KB
/
Copy pathcompound_gate.py
File metadata and controls
executable file
·191 lines (169 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env python3
"""Compound Engineering lite gate — docs/solutions/ learning capture.
Inspired by:
https://theaiengineer.substack.com/p/superpowers-vs-gsd-vs-compound-engineering
https://github.com/EveryInc/compound-engineering-plugin
https://every.to/guides/compound-engineering
Does NOT install the full Compound Engineering plugin (33 skills, parallel
reviewer farm). Validates the fourth loop step: Plan → Work → Review → Compound.
"""
from __future__ import annotations
import argparse
import json
import re
from pathlib import Path
from typing import Any
REQUIRED_SECTIONS = (
"Problem",
"What worked",
"Prevention",
"Evidence",
)
PLACEHOLDERS = (
"[short problem name]",
"YYYY-MM-DD",
"What failed, for whom",
"The fix or workflow that actually resolved it",
)
SOLUTIONS_DIR = "docs/solutions"
def parse_sections(text: str) -> dict[str, str]:
sections: dict[str, str] = {}
current: str | None = None
buf: list[str] = []
for line in text.splitlines():
m = re.match(r"^##\s+(.+?)\s*$", line)
if m:
if current is not None:
sections[current] = "\n".join(buf).strip()
current = m.group(1).strip()
buf = []
else:
buf.append(line)
if current is not None:
sections[current] = "\n".join(buf).strip()
return sections
def has_frontmatter(text: str) -> bool:
if not text.startswith("---"):
return False
rest = text[3:]
end = rest.find("\n---")
return end >= 0
def assess_solution(path: Path) -> dict[str, Any]:
if not path.is_file() or path.stat().st_size == 0:
return {
"ok": False,
"path": str(path),
"missing_sections": list(REQUIRED_SECTIONS),
"placeholder_hits": [],
"has_frontmatter": False,
"reason": "missing_or_empty",
}
text = path.read_text(encoding="utf-8")
sections = parse_sections(text)
missing = [name for name in REQUIRED_SECTIONS if name not in sections or not sections[name]]
placeholders = [p for p in PLACEHOLDERS if p in text]
fm = has_frontmatter(text)
if not fm:
missing.append("frontmatter")
ok = not missing and not placeholders
return {
"ok": ok,
"path": str(path),
"missing_sections": missing,
"placeholder_hits": placeholders,
"has_frontmatter": fm,
"section_keys": sorted(sections.keys()),
"bytes": path.stat().st_size,
}
def list_solutions(root: Path) -> list[Path]:
solutions = root / SOLUTIONS_DIR
if not solutions.is_dir():
return []
return sorted(
p for p in solutions.glob("*.md") if p.name.lower() not in {"readme.md", "index.md"}
)
def evaluate(
root: Path,
slug: str | None = None,
require_any: bool = True,
) -> dict[str, Any]:
blockers: list[str] = []
solutions_root = root / SOLUTIONS_DIR
template = root / "templates" / "compound" / "SOLUTION.md"
if not template.is_file():
blockers.append("missing_templates/compound/SOLUTION.md")
files = list_solutions(root)
assessments: list[dict[str, Any]] = []
if slug:
matches = [p for p in files if slug in p.stem]
if not matches:
blockers.append(f"missing_solution:{slug}")
selected = None
else:
selected = matches[0]
info = assess_solution(selected)
assessments.append(info)
if not info["ok"]:
if info.get("missing_sections"):
blockers.append("incomplete_solution:" + ",".join(info["missing_sections"]))
if info.get("placeholder_hits"):
blockers.append("solution_placeholders")
else:
selected = None
if require_any and not files:
blockers.append("missing_docs/solutions/*.md")
for path in files:
info = assess_solution(path)
assessments.append(info)
if not info["ok"]:
blockers.append(f"invalid_solution:{path.name}")
ready = len(blockers) == 0
return {
"source": "compound-engineering-lite",
"article": "theaiengineer.substack.com/p/superpowers-vs-gsd-vs-compound-engineering",
"upstream": "EveryInc/compound-engineering-plugin",
"ready": ready,
"claim_done_allowed": ready,
"blockers": blockers,
"solutions_dir": str(solutions_root),
"solution_count": len(files),
"selected": str(selected) if selected else None,
"assessments": assessments,
"next_step": "compound" if ready else "write_docs/solutions",
"bridges": {
"superpowers": "docs/SUPERPOWERS.md",
"opengsd": "docs/GSD_OPENGSD.md",
"spec_kit": "docs/SPEC_KIT.md",
"bmad": "docs/BMAD.md",
"compound": "docs/COMPOUND_ENGINEERING.md",
"playerzero_roi": "docs/AGENT_COMPOUNDING_ROI.md",
},
"skipped": [
"full_plugin_33_skills",
"parallel_reviewer_farm_default",
"ce-lfg_50_agent_pipeline",
],
}
def main() -> int:
parser = argparse.ArgumentParser(description="Compound Engineering lite gate")
parser.add_argument("--repo-root", default=".")
parser.add_argument("--slug", default=None, help="Require a matching docs/solutions/<slug>*.md")
parser.add_argument(
"--allow-empty",
action="store_true",
help="Do not require any solution docs (template-only check)",
)
parser.add_argument("--json", action="store_true")
args = parser.parse_args()
report = evaluate(
Path(args.repo_root).resolve(),
slug=args.slug,
require_any=not args.allow_empty,
)
if args.json:
print(json.dumps(report, indent=2))
else:
print(f"ready={report['ready']} solutions={report['solution_count']} blockers={report['blockers']}")
return 0 if report["ready"] else 1
if __name__ == "__main__":
raise SystemExit(main())