devcouncil 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -6
- package/package.json +9 -2
- package/pyproject.toml +34 -2
- package/src/devcouncil/app/config.py +348 -12
- package/src/devcouncil/app/orchestrator.py +10 -6
- package/src/devcouncil/app/state_machine.py +4 -0
- package/src/devcouncil/artifacts/graph.py +32 -5
- package/src/devcouncil/assets/__init__.py +1 -0
- package/src/devcouncil/assets/devcouncil-logo.svg +60 -0
- package/src/devcouncil/assets/devcouncil_logo_premium.png +0 -0
- package/src/devcouncil/cli/commands/agents.py +292 -0
- package/src/devcouncil/cli/commands/artifacts.py +6 -3
- package/src/devcouncil/cli/commands/check.py +220 -0
- package/src/devcouncil/cli/commands/config.py +43 -4
- package/src/devcouncil/cli/commands/cost.py +57 -0
- package/src/devcouncil/cli/commands/dashboard.py +6 -1
- package/src/devcouncil/cli/commands/design.py +186 -0
- package/src/devcouncil/cli/commands/doctor.py +379 -22
- package/src/devcouncil/cli/commands/evidence.py +48 -0
- package/src/devcouncil/cli/commands/go.py +532 -33
- package/src/devcouncil/cli/commands/handoff.py +69 -0
- package/src/devcouncil/cli/commands/hook.py +296 -15
- package/src/devcouncil/cli/commands/init.py +161 -20
- package/src/devcouncil/cli/commands/integrate.py +1371 -124
- package/src/devcouncil/cli/commands/logs.py +106 -0
- package/src/devcouncil/cli/commands/map.py +80 -10
- package/src/devcouncil/cli/commands/okf.py +245 -0
- package/src/devcouncil/cli/commands/plan.py +256 -55
- package/src/devcouncil/cli/commands/prompt.py +18 -7
- package/src/devcouncil/cli/commands/repair.py +50 -24
- package/src/devcouncil/cli/commands/report.py +8 -0
- package/src/devcouncil/cli/commands/reset_demo_state.py +4 -2
- package/src/devcouncil/cli/commands/rollback.py +27 -28
- package/src/devcouncil/cli/commands/run.py +195 -54
- package/src/devcouncil/cli/commands/runs.py +223 -0
- package/src/devcouncil/cli/commands/scaffold.py +32 -0
- package/src/devcouncil/cli/commands/semantic.py +47 -0
- package/src/devcouncil/cli/commands/setup.py +145 -6
- package/src/devcouncil/cli/commands/shell.py +73 -0
- package/src/devcouncil/cli/commands/skills.py +267 -0
- package/src/devcouncil/cli/commands/status.py +30 -15
- package/src/devcouncil/cli/commands/trace.py +47 -3
- package/src/devcouncil/cli/commands/verify.py +144 -3
- package/src/devcouncil/cli/commands/watch.py +32 -12
- package/src/devcouncil/cli/commands/watch_fs.py +40 -0
- package/src/devcouncil/cli/main.py +91 -7
- package/src/devcouncil/domain/evidence.py +29 -2
- package/src/devcouncil/domain/gap.py +27 -1
- package/src/devcouncil/domain/task.py +31 -2
- package/src/devcouncil/execution/checkpoints.py +256 -0
- package/src/devcouncil/execution/context_builder.py +1 -1
- package/src/devcouncil/execution/fs_watcher.py +205 -0
- package/src/devcouncil/execution/handoff.py +102 -0
- package/src/devcouncil/execution/hook_policy.py +162 -74
- package/src/devcouncil/execution/patch.py +65 -10
- package/src/devcouncil/execution/permissions.py +24 -24
- package/src/devcouncil/execution/policy_engine.py +350 -0
- package/src/devcouncil/execution/prompt_builder.py +751 -23
- package/src/devcouncil/execution/shell_session.py +231 -0
- package/src/devcouncil/execution/task_runner.py +24 -9
- package/src/devcouncil/executors/agent_registry.py +596 -0
- package/src/devcouncil/executors/coding_cli.py +791 -39
- package/src/devcouncil/executors/mini_swe.py +6 -0
- package/src/devcouncil/executors/native/agent.py +135 -19
- package/src/devcouncil/executors/openhands.py +6 -0
- package/src/devcouncil/gating/checks/clean_git.py +3 -1
- package/src/devcouncil/gating/checks/secret_scan_check.py +47 -21
- package/src/devcouncil/gating/policy.py +190 -11
- package/src/devcouncil/hardware.py +184 -0
- package/src/devcouncil/indexing/ast_matcher.py +17 -7
- package/src/devcouncil/indexing/lsp.py +45 -4
- package/src/devcouncil/indexing/repo_mapper.py +1284 -15
- package/src/devcouncil/indexing/semantic_index.py +221 -0
- package/src/devcouncil/integrations/actions.py +166 -0
- package/src/devcouncil/integrations/check.py +426 -0
- package/src/devcouncil/integrations/claude_assets.py +444 -0
- package/src/devcouncil/integrations/code_review_graph.py +13 -2
- package/src/devcouncil/integrations/github_intent.py +149 -0
- package/src/devcouncil/integrations/gitnexus.py +45 -2
- package/src/devcouncil/integrations/mcp/server.py +1944 -32
- package/src/devcouncil/integrations/opencode_devcouncil_plugin.mjs +24 -0
- package/src/devcouncil/integrations/pr_comments.py +9 -0
- package/src/devcouncil/knowledge/__init__.py +23 -0
- package/src/devcouncil/knowledge/design.py +374 -0
- package/src/devcouncil/knowledge/design_conformance.py +317 -0
- package/src/devcouncil/knowledge/fetch.py +223 -0
- package/src/devcouncil/knowledge/frontmatter.py +51 -0
- package/src/devcouncil/knowledge/okf.py +202 -0
- package/src/devcouncil/knowledge/skill_bridge.py +96 -0
- package/src/devcouncil/knowledge/sources.py +239 -0
- package/src/devcouncil/live/cards.py +181 -25
- package/src/devcouncil/live/repair_prompt.py +29 -6
- package/src/devcouncil/live/reviewer.py +72 -13
- package/src/devcouncil/live/signals.py +2 -2
- package/src/devcouncil/live/summary.py +18 -8
- package/src/devcouncil/live/transcripts.py +47 -11
- package/src/devcouncil/llm/cache.py +20 -8
- package/src/devcouncil/llm/model_defaults.yaml +44 -0
- package/src/devcouncil/llm/provider.py +617 -49
- package/src/devcouncil/llm/router.py +337 -53
- package/src/devcouncil/optimization/__init__.py +1 -0
- package/src/devcouncil/optimization/gepa_agent.py +318 -0
- package/src/devcouncil/optimization/skillopt.py +673 -0
- package/src/devcouncil/planning/arbiter_service.py +10 -2
- package/src/devcouncil/planning/correction_manifest.py +346 -0
- package/src/devcouncil/planning/critique_service.py +16 -4
- package/src/devcouncil/planning/plan_service.py +86 -6
- package/src/devcouncil/planning/prompt_enhancer_service.py +206 -1
- package/src/devcouncil/planning/repair_service.py +8 -2
- package/src/devcouncil/planning/spec_service.py +37 -3
- package/src/devcouncil/repo/ci_scaffold.py +165 -0
- package/src/devcouncil/repo/gitignore.py +123 -0
- package/src/devcouncil/repo/sca.py +384 -0
- package/src/devcouncil/reporting/json_report.py +22 -1
- package/src/devcouncil/reporting/markdown_report.py +29 -1
- package/src/devcouncil/reporting/okf_bundle_writer.py +364 -0
- package/src/devcouncil/reporting/okf_html.py +323 -0
- package/src/devcouncil/reporting/report_builder.py +18 -1
- package/src/devcouncil/skills/__init__.py +19 -0
- package/src/devcouncil/skills/library/README.md +46 -0
- package/src/devcouncil/skills/library/ai-training.md +50 -0
- package/src/devcouncil/skills/library/android.md +50 -0
- package/src/devcouncil/skills/library/backend.md +52 -0
- package/src/devcouncil/skills/library/core-engineering.md +95 -0
- package/src/devcouncil/skills/library/data-engineering.md +47 -0
- package/src/devcouncil/skills/library/desktop.md +46 -0
- package/src/devcouncil/skills/library/devops.md +48 -0
- package/src/devcouncil/skills/library/game-dev.md +46 -0
- package/src/devcouncil/skills/library/ios.md +48 -0
- package/src/devcouncil/skills/library/mobile-cross-platform.md +46 -0
- package/src/devcouncil/skills/library/security.md +48 -0
- package/src/devcouncil/skills/library/systems.md +48 -0
- package/src/devcouncil/skills/library/web.md +47 -0
- package/src/devcouncil/skills/library/windows.md +47 -0
- package/src/devcouncil/skills/registry.py +408 -0
- package/src/devcouncil/storage/db.py +140 -3
- package/src/devcouncil/storage/models.py +125 -0
- package/src/devcouncil/storage/native.py +559 -0
- package/src/devcouncil/storage/repositories.py +157 -78
- package/src/devcouncil/telemetry/cost.py +123 -17
- package/src/devcouncil/telemetry/logging_setup.py +244 -0
- package/src/devcouncil/telemetry/model_pricing.yaml +48 -0
- package/src/devcouncil/telemetry/pricing.py +28 -0
- package/src/devcouncil/telemetry/stages.py +141 -0
- package/src/devcouncil/telemetry/traces.py +62 -7
- package/src/devcouncil/telemetry/tracker.py +24 -10
- package/src/devcouncil/ui/dashboard.py +393 -28
- package/src/devcouncil/utils/redaction.py +9 -3
- package/src/devcouncil/utils/subprocess_env.py +69 -0
- package/src/devcouncil/verification/acceptance_compiler.py +253 -0
- package/src/devcouncil/verification/ad_hoc_check.py +135 -0
- package/src/devcouncil/verification/diff_coverage.py +353 -0
- package/src/devcouncil/verification/implementation_reviewer.py +11 -2
- package/src/devcouncil/verification/next_actions.py +189 -0
- package/src/devcouncil/verification/sandbox.py +181 -0
- package/src/devcouncil/verification/test_resolver.py +91 -0
- package/src/devcouncil/verification/verifier.py +1549 -143
- package/uv.lock +205 -64
- package/src/devcouncil/indexing/symbol_index.py +0 -0
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
1
4
|
from pydantic import BaseModel, Field
|
|
2
5
|
|
|
3
6
|
from devcouncil.llm.router import ModelRouter
|
|
4
7
|
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
# Cap how much skill text we feed the enhancer so a repo matching many skills
|
|
11
|
+
# can't blow up the planning prompt. Domain skills are ~50 lines each.
|
|
12
|
+
_MAX_SKILLS_FOR_INTAKE = 4
|
|
13
|
+
_MAX_INTAKE_CHARS = 8000
|
|
14
|
+
|
|
5
15
|
|
|
6
16
|
class PromptEnhancement(BaseModel):
|
|
7
17
|
original_goal: str
|
|
@@ -9,6 +19,17 @@ class PromptEnhancement(BaseModel):
|
|
|
9
19
|
codebase_context: list[str] = Field(default_factory=list)
|
|
10
20
|
debate_focus: list[str] = Field(default_factory=list)
|
|
11
21
|
constraints: list[str] = Field(default_factory=list)
|
|
22
|
+
# Senior-level domain intake folded in from the skills library (android, ios,
|
|
23
|
+
# web, ...). ``applied_skills`` are the matched skill names; ``skills_brief`` is
|
|
24
|
+
# the compact title+description block the council debates with. Both are set
|
|
25
|
+
# deterministically after the model call — the LLM does not populate them.
|
|
26
|
+
applied_skills: list[str] = Field(default_factory=list)
|
|
27
|
+
skills_brief: str = ""
|
|
28
|
+
# Curated project knowledge (Open Knowledge Format bundles) and the project design
|
|
29
|
+
# system (design.md), selected from ``.devcouncil/knowledge`` for this goal. Like the
|
|
30
|
+
# skills fields, set deterministically after the model call.
|
|
31
|
+
applied_knowledge: list[str] = Field(default_factory=list)
|
|
32
|
+
knowledge_brief: str = ""
|
|
12
33
|
|
|
13
34
|
def normalized(self, original_goal: str) -> "PromptEnhancement":
|
|
14
35
|
enhanced_goal = self.enhanced_goal.strip() or original_goal
|
|
@@ -41,9 +62,74 @@ class PromptEnhancement(BaseModel):
|
|
|
41
62
|
if self.debate_focus:
|
|
42
63
|
sections.extend(["", "## Debate focus"])
|
|
43
64
|
sections.extend(f"- {item}" for item in self.debate_focus)
|
|
65
|
+
if self.skills_brief:
|
|
66
|
+
sections.extend([
|
|
67
|
+
"",
|
|
68
|
+
"## Domain engineering intake (apply current senior-level practices)",
|
|
69
|
+
"Plan to the *current* state of these domains — recommended libraries, "
|
|
70
|
+
"deprecations to avoid, and the right build/test CLI commands. The coding "
|
|
71
|
+
"agent receives the full skill text; the plan must already assume it.",
|
|
72
|
+
self.skills_brief,
|
|
73
|
+
])
|
|
74
|
+
if self.knowledge_brief:
|
|
75
|
+
sections.extend([
|
|
76
|
+
"",
|
|
77
|
+
"## Project knowledge & design system (ground the plan in these)",
|
|
78
|
+
"Curated org/domain knowledge (Open Knowledge Format) and the project's "
|
|
79
|
+
"design.md. Honor design tokens/components and reuse known facts rather than "
|
|
80
|
+
"re-deriving or contradicting them.",
|
|
81
|
+
self.knowledge_brief,
|
|
82
|
+
])
|
|
44
83
|
return "\n".join(sections)
|
|
45
84
|
|
|
46
85
|
|
|
86
|
+
# Stable copy of the enhancement that produced the CURRENTLY ACTIVE plan. Written when a
|
|
87
|
+
# plan is persisted, so the executor reads the guidance tied to the plan it is running —
|
|
88
|
+
# not whichever run happens to have the newest mtime (a later dry-run/replan would otherwise
|
|
89
|
+
# win). Lives next to the plan state under .devcouncil/.
|
|
90
|
+
_ACTIVE_ENHANCEMENT_FILE = "active_prompt_enhancement.json"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def load_latest_prompt_enhancement(project_root: Path) -> "PromptEnhancement | None":
|
|
94
|
+
"""Load the prompt-enhancement for the active plan, or None.
|
|
95
|
+
|
|
96
|
+
Prefers the stable ``.devcouncil/active_prompt_enhancement.json`` written when the plan
|
|
97
|
+
was persisted (so the executor gets the guidance tied to the plan it is running). Falls
|
|
98
|
+
back to the most recent per-run artifact for plans persisted before that file existed.
|
|
99
|
+
Best-effort: any read/parse failure returns None so prompt building never breaks."""
|
|
100
|
+
import json
|
|
101
|
+
|
|
102
|
+
def _load(path: Path) -> "PromptEnhancement | None":
|
|
103
|
+
try:
|
|
104
|
+
return PromptEnhancement.model_validate(json.loads(path.read_text(encoding="utf-8")))
|
|
105
|
+
except Exception:
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
active = project_root / ".devcouncil" / _ACTIVE_ENHANCEMENT_FILE
|
|
109
|
+
if active.is_file():
|
|
110
|
+
loaded = _load(active)
|
|
111
|
+
if loaded is not None:
|
|
112
|
+
return loaded
|
|
113
|
+
|
|
114
|
+
runs = project_root / ".devcouncil" / "runs"
|
|
115
|
+
if not runs.exists():
|
|
116
|
+
return None
|
|
117
|
+
artifacts = [d / "prompt_enhancement.json" for d in runs.iterdir() if (d / "prompt_enhancement.json").is_file()]
|
|
118
|
+
if not artifacts:
|
|
119
|
+
return None
|
|
120
|
+
return _load(max(artifacts, key=lambda p: p.stat().st_mtime))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def save_active_prompt_enhancement(project_root: Path, enhancement: "PromptEnhancement") -> None:
|
|
124
|
+
"""Persist the enhancement for the active plan to the stable path. Best-effort."""
|
|
125
|
+
try:
|
|
126
|
+
path = project_root / ".devcouncil" / _ACTIVE_ENHANCEMENT_FILE
|
|
127
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
128
|
+
path.write_text(enhancement.model_dump_json(indent=2), encoding="utf-8")
|
|
129
|
+
except Exception:
|
|
130
|
+
pass
|
|
131
|
+
|
|
132
|
+
|
|
47
133
|
class PromptEnhancerService:
|
|
48
134
|
def __init__(self, router: ModelRouter):
|
|
49
135
|
self.router = router
|
|
@@ -53,7 +139,18 @@ class PromptEnhancerService:
|
|
|
53
139
|
goal: str,
|
|
54
140
|
repo_map_json: str,
|
|
55
141
|
graph_context_json: str | None = None,
|
|
142
|
+
project_root: Path | None = None,
|
|
56
143
|
) -> PromptEnhancement:
|
|
144
|
+
skills = _select_skills(goal, project_root)
|
|
145
|
+
skills_intake = _full_intake(skills)
|
|
146
|
+
skills_brief = _compact_brief(skills)
|
|
147
|
+
if skills:
|
|
148
|
+
logger.info("Prompt enhancer matched %d skill(s): %s", len(skills), ", ".join(s.name for s in skills))
|
|
149
|
+
|
|
150
|
+
knowledge = _select_knowledge(goal, project_root)
|
|
151
|
+
knowledge_intake = _knowledge_intake(knowledge)
|
|
152
|
+
knowledge_brief = _knowledge_brief(knowledge)
|
|
153
|
+
|
|
57
154
|
prompt = f"""
|
|
58
155
|
Original user goal:
|
|
59
156
|
{goal}
|
|
@@ -64,12 +161,22 @@ Repository map:
|
|
|
64
161
|
Code review graph context:
|
|
65
162
|
{graph_context_json or "{}"}
|
|
66
163
|
|
|
164
|
+
Applicable engineering skills (senior-level domain intake for this codebase/goal):
|
|
165
|
+
{skills_intake or "(no domain skills matched; rely on general engineering judgment)"}
|
|
166
|
+
|
|
167
|
+
Project knowledge & design system (curated facts and design tokens for this codebase):
|
|
168
|
+
{knowledge_intake or "(no project knowledge ingested)"}
|
|
169
|
+
|
|
67
170
|
You are DevCouncil's codebase-specific prompt enhancer.
|
|
68
171
|
Rewrite the user goal into a better planning prompt before it is sent to the council debate.
|
|
69
172
|
|
|
70
173
|
Requirements:
|
|
71
174
|
- Preserve the user's intent exactly; do not add unrelated features.
|
|
72
175
|
- Make the goal specific to the mapped repository architecture, languages, tests, and likely ownership boundaries.
|
|
176
|
+
- Fold the relevant skill intake into the goal and constraints like a senior engineer who
|
|
177
|
+
just briefed themselves: name the *current* recommended libraries/APIs, the deprecated
|
|
178
|
+
ones to avoid, the platform/SDK/toolchain versions to target, and the exact build/test
|
|
179
|
+
CLI commands that will prove the change. Only include skill points relevant to THIS goal.
|
|
73
180
|
- Identify constraints the planners and critics must preserve.
|
|
74
181
|
- Identify debate focus areas that should force useful disagreement between pragmatic and production-readiness plans.
|
|
75
182
|
- Keep the enhanced_goal concise enough to be used as the goal for spec, planning, critique, and arbitration.
|
|
@@ -78,8 +185,106 @@ Requirements:
|
|
|
78
185
|
role="prompt_enhancer",
|
|
79
186
|
messages=[{"role": "user", "content": prompt}],
|
|
80
187
|
schema=PromptEnhancement,
|
|
188
|
+
# If enhancement fails on a weak model, fall back to the raw goal —
|
|
189
|
+
# planning proceeds with the user's original intent unchanged.
|
|
190
|
+
fallback=PromptEnhancement(original_goal=goal, enhanced_goal=goal),
|
|
81
191
|
)
|
|
82
|
-
|
|
192
|
+
# Skill provenance is deterministic, not model-decided: stamp it after the call
|
|
193
|
+
# so the artifact/report shows exactly which skills shaped this plan.
|
|
194
|
+
return enhancement.normalized(goal).model_copy(
|
|
195
|
+
update={
|
|
196
|
+
"applied_skills": [skill.name for skill in skills],
|
|
197
|
+
"skills_brief": skills_brief,
|
|
198
|
+
"applied_knowledge": [source.name for source in knowledge],
|
|
199
|
+
"knowledge_brief": knowledge_brief,
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _select_skills(goal: str, project_root: Path | None):
|
|
205
|
+
"""Codebase-aware skill selection; never raises (skills are best-effort)."""
|
|
206
|
+
try:
|
|
207
|
+
from devcouncil.skills.registry import select_skills
|
|
208
|
+
|
|
209
|
+
return select_skills(goal=goal, project_root=project_root)
|
|
210
|
+
except Exception:
|
|
211
|
+
return []
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _full_intake(skills: list) -> str:
|
|
215
|
+
"""Full skill bodies (capped) for the one-shot enhancer call."""
|
|
216
|
+
if not skills:
|
|
217
|
+
return ""
|
|
218
|
+
blocks: list[str] = []
|
|
219
|
+
total = 0
|
|
220
|
+
for skill in skills[:_MAX_SKILLS_FOR_INTAKE]:
|
|
221
|
+
body = (getattr(skill, "body", "") or "").strip()
|
|
222
|
+
if not body:
|
|
223
|
+
continue
|
|
224
|
+
block = f"### Skill: {skill.name}\n{body}"
|
|
225
|
+
total += len(block)
|
|
226
|
+
if total > _MAX_INTAKE_CHARS:
|
|
227
|
+
break
|
|
228
|
+
blocks.append(block)
|
|
229
|
+
return "\n\n".join(blocks).strip()
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _compact_brief(skills: list) -> str:
|
|
233
|
+
"""One line per skill (name + description) for the council debate prompt."""
|
|
234
|
+
lines = []
|
|
235
|
+
for skill in skills:
|
|
236
|
+
description = (getattr(skill, "description", "") or "").strip()
|
|
237
|
+
lines.append(f"- **{skill.name}** — {description}" if description else f"- **{skill.name}**")
|
|
238
|
+
return "\n".join(lines).strip()
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _select_knowledge(goal: str, project_root: Path | None):
|
|
242
|
+
"""OKF/design knowledge selection for planning; never raises (best-effort)."""
|
|
243
|
+
if project_root is None:
|
|
244
|
+
return []
|
|
245
|
+
try:
|
|
246
|
+
from devcouncil.app.config import load_config
|
|
247
|
+
from devcouncil.knowledge.sources import select_knowledge_sources
|
|
248
|
+
|
|
249
|
+
cfg = load_config(project_root).knowledge
|
|
250
|
+
if not cfg.enabled:
|
|
251
|
+
return []
|
|
252
|
+
return select_knowledge_sources(
|
|
253
|
+
goal=goal, project_root=project_root,
|
|
254
|
+
directory=cfg.directory, design_always=cfg.design_always,
|
|
255
|
+
)
|
|
256
|
+
except Exception:
|
|
257
|
+
return []
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _knowledge_intake(sources: list) -> str:
|
|
261
|
+
"""Full knowledge bodies (capped) for the one-shot enhancer call."""
|
|
262
|
+
if not sources:
|
|
263
|
+
return ""
|
|
264
|
+
blocks: list[str] = []
|
|
265
|
+
total = 0
|
|
266
|
+
for source in sources[:_MAX_SKILLS_FOR_INTAKE]:
|
|
267
|
+
body = (getattr(source, "body", "") or "").strip()
|
|
268
|
+
if not body:
|
|
269
|
+
continue
|
|
270
|
+
kind = getattr(source, "kind", "knowledge")
|
|
271
|
+
block = f"### {kind}: {getattr(source, 'name', '')}\n{body}"
|
|
272
|
+
total += len(block)
|
|
273
|
+
if total > _MAX_INTAKE_CHARS:
|
|
274
|
+
break
|
|
275
|
+
blocks.append(block)
|
|
276
|
+
return "\n\n".join(blocks).strip()
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _knowledge_brief(sources: list) -> str:
|
|
280
|
+
"""One line per knowledge source (kind + name + description) for the debate prompt."""
|
|
281
|
+
lines = []
|
|
282
|
+
for source in sources:
|
|
283
|
+
description = (getattr(source, "description", "") or "").strip()
|
|
284
|
+
kind = getattr(source, "kind", "knowledge")
|
|
285
|
+
head = f"- **{getattr(source, 'name', '')}** ({kind})"
|
|
286
|
+
lines.append(f"{head} — {description}" if description else head)
|
|
287
|
+
return "\n".join(lines).strip()
|
|
83
288
|
|
|
84
289
|
|
|
85
290
|
def _clean_items(items: list[str]) -> list[str]:
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
from typing import List
|
|
2
2
|
import json
|
|
3
|
+
import logging
|
|
3
4
|
from pydantic import BaseModel
|
|
4
5
|
from devcouncil.domain.gap import Gap
|
|
5
6
|
from devcouncil.domain.task import Task
|
|
6
7
|
from devcouncil.llm.router import ModelRouter
|
|
7
8
|
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
8
11
|
class RepairOutput(BaseModel):
|
|
9
12
|
suggested_tasks: List[Task]
|
|
10
13
|
|
|
@@ -31,9 +34,12 @@ Your task is to generate focused implementation tasks to fix these gaps.
|
|
|
31
34
|
Return a JSON object with 'suggested_tasks'.
|
|
32
35
|
"""
|
|
33
36
|
messages = [{"role": "user", "content": prompt}]
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
logger.info("Generating repair plan from %d gap(s)", len(gaps))
|
|
39
|
+
result = await self.router.complete_structured(
|
|
36
40
|
role="planner_a", # Pragmatic tech lead is best suited for repair task generation
|
|
37
41
|
messages=messages,
|
|
38
42
|
schema=RepairOutput
|
|
39
43
|
)
|
|
44
|
+
logger.info("Repair plan: %d suggested task(s)", len(result.suggested_tasks))
|
|
45
|
+
return result
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
from typing import List
|
|
2
3
|
from pydantic import BaseModel
|
|
3
4
|
from devcouncil.domain.requirement import Requirement
|
|
4
5
|
from devcouncil.domain.assumption import Assumption
|
|
5
6
|
from devcouncil.llm.router import ModelRouter
|
|
6
7
|
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
7
10
|
class BlockingQuestion(BaseModel):
|
|
8
11
|
id: str
|
|
9
12
|
question: str
|
|
@@ -30,15 +33,46 @@ Your task is to draft the initial software specification for this goal.
|
|
|
30
33
|
2. Extract any assumptions you are making about the codebase or architecture.
|
|
31
34
|
3. List any blocking questions that the user must answer before implementation can proceed.
|
|
32
35
|
|
|
33
|
-
Each requirement MUST have clear acceptance criteria with verification methods.
|
|
36
|
+
Each requirement MUST have clear, testable acceptance criteria with verification methods.
|
|
37
|
+
Be RIGOROUS about edge cases — a terse goal hides most of the real requirements.
|
|
38
|
+
For every behavior, add explicit acceptance criteria covering, where applicable:
|
|
39
|
+
- the normal/happy path with concrete example inputs and expected outputs;
|
|
40
|
+
- boundary and degenerate inputs (empty, single element, zero, negative, very large,
|
|
41
|
+
duplicate, already-sorted vs. unsorted, min/max);
|
|
42
|
+
- invalid or malformed inputs and the EXACT expected error behavior (e.g. raises
|
|
43
|
+
ValueError/TypeError) rather than silent or undefined behavior;
|
|
44
|
+
- non-mutation / no-unexpected-side-effects on inputs when the behavior is a pure
|
|
45
|
+
transformation;
|
|
46
|
+
- correct result TYPE (e.g. float vs int) when it matters.
|
|
47
|
+
Prefer several small, individually-verifiable acceptance criteria over one vague one.
|
|
48
|
+
|
|
49
|
+
Acceptance criteria MUST assert observable BEHAVIOR — return values, raised exceptions,
|
|
50
|
+
output, or side effects on supplied data — not repository state or tooling. DevCouncil's
|
|
51
|
+
own gates enforce file scope, clean diffs, and planned-file limits, so do NOT write
|
|
52
|
+
criteria about `git status`/`--porcelain` output, the exact set of changed/created files,
|
|
53
|
+
`git show HEAD` byte/append-only contents, commit shape, or whether flake8/mypy/ruff/
|
|
54
|
+
eslint/tsc/npm pass. Never require a tool the repo is not already configured for. Use the
|
|
55
|
+
`static_check` verification method ONLY for behavior expressible as a runnable assertion
|
|
56
|
+
(an importable function's result or raised exception), never to mean "a linter runs clean"
|
|
57
|
+
or "these files exist". If a criterion genuinely cannot be proven by running code
|
|
58
|
+
(architecture choices, repo scope, "works without extra configuration", subjective
|
|
59
|
+
quality), give it verification_method "manual" — it will be surfaced for human review
|
|
60
|
+
rather than block the automated gate. Prefer rewriting such a criterion as a concrete
|
|
61
|
+
behavioral one whenever possible.
|
|
62
|
+
|
|
34
63
|
Each assumption MUST have a confidence and impact level.
|
|
35
64
|
"""
|
|
36
65
|
messages = [
|
|
37
66
|
{"role": "user", "content": prompt}
|
|
38
67
|
]
|
|
39
|
-
|
|
40
|
-
|
|
68
|
+
|
|
69
|
+
result = await self.router.complete_structured(
|
|
41
70
|
role="spec_writer",
|
|
42
71
|
messages=messages,
|
|
43
72
|
schema=SpecOutput
|
|
44
73
|
)
|
|
74
|
+
logger.info(
|
|
75
|
+
"Spec generated: %d requirement(s), %d assumption(s), %d blocking question(s)",
|
|
76
|
+
len(result.requirements), len(result.assumptions), len(result.blocking_questions),
|
|
77
|
+
)
|
|
78
|
+
return result
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Scaffold a starter GitHub Actions workflow for a target repository.
|
|
2
|
+
|
|
3
|
+
DevCouncil already knows a project's test/lint/typecheck commands (config.yaml), so
|
|
4
|
+
it can emit a sensible CI starter that runs them. The workflow is a *template* the
|
|
5
|
+
user can adjust; scaffolding never overwrites an existing workflow unless forced.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from devcouncil.app.config import DevCouncilConfig, load_config
|
|
13
|
+
|
|
14
|
+
WORKFLOW_RELPATH = Path(".github") / "workflows" / "devcouncil.yml"
|
|
15
|
+
|
|
16
|
+
_PYTHON_TOOLS = {
|
|
17
|
+
"pytest", "flake8", "ruff", "mypy", "tox", "python", "python3", "uv",
|
|
18
|
+
"poetry", "black", "isort", "pyright",
|
|
19
|
+
}
|
|
20
|
+
_NODE_TOOLS = {
|
|
21
|
+
"npm", "npx", "pnpm", "yarn", "bun", "eslint", "tsc", "jest", "vitest", "node",
|
|
22
|
+
}
|
|
23
|
+
_PYTHON_MARKERS = ("pyproject.toml", "requirements.txt", "setup.py", "setup.cfg", "Pipfile")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def detect_stacks(project_root: Path) -> set[str]:
|
|
27
|
+
"""Best-effort detection of the language stacks present in the repo."""
|
|
28
|
+
stacks: set[str] = set()
|
|
29
|
+
if any((project_root / marker).exists() for marker in _PYTHON_MARKERS):
|
|
30
|
+
stacks.add("python")
|
|
31
|
+
if (project_root / "package.json").exists():
|
|
32
|
+
stacks.add("node")
|
|
33
|
+
return stacks
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _command_stack(command: str) -> str | None:
|
|
37
|
+
tool = command.split()[0] if command.strip() else ""
|
|
38
|
+
if tool in _PYTHON_TOOLS:
|
|
39
|
+
return "python"
|
|
40
|
+
if tool in _NODE_TOOLS:
|
|
41
|
+
return "node"
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _applicable_commands(commands: list[str], stacks: set[str]) -> list[str]:
|
|
46
|
+
"""Keep commands whose tool matches a detected stack; if none detected, keep all."""
|
|
47
|
+
if not stacks:
|
|
48
|
+
return list(commands)
|
|
49
|
+
kept = []
|
|
50
|
+
for command in commands:
|
|
51
|
+
stack = _command_stack(command)
|
|
52
|
+
if stack is None or stack in stacks:
|
|
53
|
+
kept.append(command)
|
|
54
|
+
return kept
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Optional dependency-audit step per stack. Emitted only when the matching stack is
|
|
58
|
+
# detected, so a Python-only repo never gets an npm audit (and vice versa). These are
|
|
59
|
+
# non-blocking (continue-on-error) starters the user can tighten.
|
|
60
|
+
_AUDIT_STEPS: dict[str, list[str]] = {
|
|
61
|
+
"python": [
|
|
62
|
+
" - name: Dependency audit (pip-audit)",
|
|
63
|
+
" continue-on-error: true",
|
|
64
|
+
" run: pip-audit",
|
|
65
|
+
],
|
|
66
|
+
"node": [
|
|
67
|
+
" - name: Dependency audit (npm audit)",
|
|
68
|
+
" continue-on-error: true",
|
|
69
|
+
" run: npm audit --audit-level=high",
|
|
70
|
+
],
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _add_audit_steps(steps: list[str], stacks: set[str]) -> None:
|
|
75
|
+
"""Append an optional SCA audit step for each detected stack (only)."""
|
|
76
|
+
for stack in sorted(stacks):
|
|
77
|
+
steps.extend(_AUDIT_STEPS.get(stack, []))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _python_version(project_root: Path) -> str:
|
|
81
|
+
version_file = project_root / ".python-version"
|
|
82
|
+
if version_file.exists():
|
|
83
|
+
first = version_file.read_text(encoding="utf-8").strip().splitlines()
|
|
84
|
+
if first and first[0].strip():
|
|
85
|
+
return first[0].strip()
|
|
86
|
+
return "3.12"
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def render_workflow(
|
|
90
|
+
project_root: Path,
|
|
91
|
+
default_branch: str = "main",
|
|
92
|
+
config: DevCouncilConfig | None = None,
|
|
93
|
+
) -> str:
|
|
94
|
+
"""Render the workflow YAML text deterministically from config + detected stacks."""
|
|
95
|
+
if config is None:
|
|
96
|
+
config = load_config(project_root)
|
|
97
|
+
stacks = detect_stacks(project_root)
|
|
98
|
+
commands = config.commands
|
|
99
|
+
|
|
100
|
+
steps: list[str] = [
|
|
101
|
+
" - name: Checkout",
|
|
102
|
+
" uses: actions/checkout@v4",
|
|
103
|
+
]
|
|
104
|
+
if "python" in stacks:
|
|
105
|
+
steps += [
|
|
106
|
+
" - name: Set up Python",
|
|
107
|
+
" uses: actions/setup-python@v5",
|
|
108
|
+
" with:",
|
|
109
|
+
f' python-version: "{_python_version(project_root)}"',
|
|
110
|
+
]
|
|
111
|
+
if "node" in stacks:
|
|
112
|
+
steps += [
|
|
113
|
+
" - name: Set up Node",
|
|
114
|
+
" uses: actions/setup-node@v4",
|
|
115
|
+
" with:",
|
|
116
|
+
' node-version: "20"',
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
def add_command_steps(label: str, raw_commands: list[str]) -> None:
|
|
120
|
+
for command in _applicable_commands(raw_commands, stacks):
|
|
121
|
+
steps.append(f" - name: {label} ({command.split()[0]})")
|
|
122
|
+
steps.append(f" run: {command}")
|
|
123
|
+
|
|
124
|
+
add_command_steps("Lint", commands.lint)
|
|
125
|
+
add_command_steps("Typecheck", commands.typecheck)
|
|
126
|
+
add_command_steps("Test", commands.test)
|
|
127
|
+
_add_audit_steps(steps, stacks)
|
|
128
|
+
|
|
129
|
+
body = "\n".join(steps)
|
|
130
|
+
return (
|
|
131
|
+
"# Starter CI workflow generated by DevCouncil from .devcouncil/config.yaml.\n"
|
|
132
|
+
"# Adjust the setup steps, dependency install, and commands for your stack.\n"
|
|
133
|
+
"name: DevCouncil CI\n"
|
|
134
|
+
"\n"
|
|
135
|
+
"on:\n"
|
|
136
|
+
" push:\n"
|
|
137
|
+
f' branches: ["{default_branch}"]\n'
|
|
138
|
+
" pull_request:\n"
|
|
139
|
+
f' branches: ["{default_branch}"]\n'
|
|
140
|
+
"\n"
|
|
141
|
+
"jobs:\n"
|
|
142
|
+
" checks:\n"
|
|
143
|
+
" runs-on: ubuntu-latest\n"
|
|
144
|
+
" steps:\n"
|
|
145
|
+
f"{body}\n"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def scaffold_ci(project_root: Path, force: bool = False) -> Path | None:
|
|
150
|
+
"""Write the starter workflow. Returns the path, or None if one already exists.
|
|
151
|
+
|
|
152
|
+
Does not overwrite an existing ``.github/workflows/devcouncil.yml`` unless
|
|
153
|
+
``force`` is set, so re-running is safe and user edits are preserved.
|
|
154
|
+
"""
|
|
155
|
+
project_root = project_root.resolve()
|
|
156
|
+
target = project_root / WORKFLOW_RELPATH
|
|
157
|
+
if target.exists() and not force:
|
|
158
|
+
return None
|
|
159
|
+
config = load_config(project_root)
|
|
160
|
+
default_branch = config.project.default_branch or "main"
|
|
161
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
162
|
+
target.write_text(
|
|
163
|
+
render_workflow(project_root, default_branch, config), encoding="utf-8"
|
|
164
|
+
)
|
|
165
|
+
return target
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
GITIGNORE_SECTIONS: tuple[tuple[str, tuple[str, ...]], ...] = (
|
|
7
|
+
(
|
|
8
|
+
"DevCouncil local state",
|
|
9
|
+
(
|
|
10
|
+
".devcouncil/*",
|
|
11
|
+
"!.devcouncil/",
|
|
12
|
+
"!.devcouncil/config.yaml",
|
|
13
|
+
"!.devcouncil/graphify.yaml",
|
|
14
|
+
),
|
|
15
|
+
),
|
|
16
|
+
(
|
|
17
|
+
"Local AI coding agents",
|
|
18
|
+
(
|
|
19
|
+
".agents/",
|
|
20
|
+
".codex/",
|
|
21
|
+
".aider*",
|
|
22
|
+
".gemini/",
|
|
23
|
+
".claude*",
|
|
24
|
+
".cursor/",
|
|
25
|
+
".openhands/",
|
|
26
|
+
".opencode/",
|
|
27
|
+
".conductor/",
|
|
28
|
+
".conducor/",
|
|
29
|
+
".antigravity/",
|
|
30
|
+
".warp/",
|
|
31
|
+
".gitnexus",
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
(
|
|
35
|
+
"Generated workspace guides (regenerated by 'dev map')",
|
|
36
|
+
(
|
|
37
|
+
"AGENTS.md",
|
|
38
|
+
"CLAUDE.md",
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
(
|
|
42
|
+
"Secrets and local databases",
|
|
43
|
+
(
|
|
44
|
+
"*.sqlite",
|
|
45
|
+
"*.sqlite-wal",
|
|
46
|
+
"*.sqlite-shm",
|
|
47
|
+
"*.db",
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
(
|
|
51
|
+
"Temporary, log, and dump artifacts",
|
|
52
|
+
(
|
|
53
|
+
"logs/",
|
|
54
|
+
"log/",
|
|
55
|
+
"tmp/",
|
|
56
|
+
"temp/",
|
|
57
|
+
".tmp/",
|
|
58
|
+
".temp/",
|
|
59
|
+
"scratch/",
|
|
60
|
+
"dumps/",
|
|
61
|
+
"dump/",
|
|
62
|
+
"*.tmp",
|
|
63
|
+
"*.temp",
|
|
64
|
+
"*.log",
|
|
65
|
+
"*.dmp",
|
|
66
|
+
"*.dump",
|
|
67
|
+
"*.bak",
|
|
68
|
+
"*.swp",
|
|
69
|
+
"*_results.txt",
|
|
70
|
+
"*_log.txt",
|
|
71
|
+
"*_output.txt",
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
|
+
(
|
|
75
|
+
"Environment, dependency, and cache directories",
|
|
76
|
+
(
|
|
77
|
+
"__pycache__/",
|
|
78
|
+
"*.py[cod]",
|
|
79
|
+
".venv/",
|
|
80
|
+
"venv/",
|
|
81
|
+
"node_modules/",
|
|
82
|
+
".env",
|
|
83
|
+
".env.local",
|
|
84
|
+
".env.*",
|
|
85
|
+
"!.env.example",
|
|
86
|
+
".pytest_cache/",
|
|
87
|
+
".mypy_cache/",
|
|
88
|
+
".ruff_cache/",
|
|
89
|
+
".DS_Store",
|
|
90
|
+
"Thumbs.db",
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def ensure_gitignore(project_root: Path) -> None:
|
|
97
|
+
gitignore_path = project_root / ".gitignore"
|
|
98
|
+
content = ""
|
|
99
|
+
if gitignore_path.exists():
|
|
100
|
+
try:
|
|
101
|
+
content = gitignore_path.read_text(encoding="utf-8")
|
|
102
|
+
except OSError:
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
existing_rules = {line.strip() for line in content.splitlines() if line.strip()}
|
|
106
|
+
chunks: list[str] = []
|
|
107
|
+
for heading, rules in GITIGNORE_SECTIONS:
|
|
108
|
+
missing_rules = [rule for rule in rules if rule not in existing_rules]
|
|
109
|
+
if missing_rules:
|
|
110
|
+
chunks.append("\n".join([f"# {heading}", *missing_rules]))
|
|
111
|
+
|
|
112
|
+
if not chunks:
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
prefix = ""
|
|
116
|
+
if content:
|
|
117
|
+
prefix = "" if content.endswith("\n") else "\n"
|
|
118
|
+
prefix += "\n"
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
gitignore_path.write_text(content + prefix + "\n\n".join(chunks) + "\n", encoding="utf-8")
|
|
122
|
+
except OSError:
|
|
123
|
+
return
|