devcouncil 0.2.0 → 0.2.1

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.
Files changed (205) hide show
  1. package/README.md +191 -253
  2. package/bin/devcouncil.js +130 -32
  3. package/package.json +6 -17
  4. package/pyproject.toml +0 -66
  5. package/src/devcouncil/__init__.py +0 -0
  6. package/src/devcouncil/__main__.py +0 -4
  7. package/src/devcouncil/app/__init__.py +0 -28
  8. package/src/devcouncil/app/config.py +0 -320
  9. package/src/devcouncil/app/errors.py +0 -23
  10. package/src/devcouncil/app/events.py +0 -44
  11. package/src/devcouncil/app/orchestrator.py +0 -92
  12. package/src/devcouncil/app/project_status.py +0 -29
  13. package/src/devcouncil/app/run_context.py +0 -39
  14. package/src/devcouncil/app/state_machine.py +0 -108
  15. package/src/devcouncil/artifacts/__init__.py +0 -1
  16. package/src/devcouncil/artifacts/coverage.py +0 -96
  17. package/src/devcouncil/artifacts/graph.py +0 -163
  18. package/src/devcouncil/artifacts/migrations.py +0 -20
  19. package/src/devcouncil/artifacts/schemas.py +0 -23
  20. package/src/devcouncil/artifacts/serializer.py +0 -21
  21. package/src/devcouncil/artifacts/validators.py +0 -27
  22. package/src/devcouncil/assets/__init__.py +0 -1
  23. package/src/devcouncil/assets/devcouncil-logo.svg +0 -60
  24. package/src/devcouncil/assets/devcouncil_logo_premium.png +0 -0
  25. package/src/devcouncil/cli/__init__.py +0 -0
  26. package/src/devcouncil/cli/commands/__init__.py +0 -0
  27. package/src/devcouncil/cli/commands/agents.py +0 -292
  28. package/src/devcouncil/cli/commands/artifacts.py +0 -54
  29. package/src/devcouncil/cli/commands/ast.py +0 -22
  30. package/src/devcouncil/cli/commands/baseline.py +0 -35
  31. package/src/devcouncil/cli/commands/check.py +0 -209
  32. package/src/devcouncil/cli/commands/config.py +0 -115
  33. package/src/devcouncil/cli/commands/cost.py +0 -57
  34. package/src/devcouncil/cli/commands/dashboard.py +0 -31
  35. package/src/devcouncil/cli/commands/doctor.py +0 -340
  36. package/src/devcouncil/cli/commands/evidence.py +0 -48
  37. package/src/devcouncil/cli/commands/go.py +0 -656
  38. package/src/devcouncil/cli/commands/handoff.py +0 -69
  39. package/src/devcouncil/cli/commands/hook.py +0 -237
  40. package/src/devcouncil/cli/commands/init.py +0 -289
  41. package/src/devcouncil/cli/commands/integrate.py +0 -1515
  42. package/src/devcouncil/cli/commands/lsp.py +0 -20
  43. package/src/devcouncil/cli/commands/map.py +0 -112
  44. package/src/devcouncil/cli/commands/mcp_server.py +0 -18
  45. package/src/devcouncil/cli/commands/plan.py +0 -488
  46. package/src/devcouncil/cli/commands/prompt.py +0 -61
  47. package/src/devcouncil/cli/commands/repair.py +0 -89
  48. package/src/devcouncil/cli/commands/report.py +0 -137
  49. package/src/devcouncil/cli/commands/reset_demo_state.py +0 -33
  50. package/src/devcouncil/cli/commands/rollback.py +0 -59
  51. package/src/devcouncil/cli/commands/run.py +0 -289
  52. package/src/devcouncil/cli/commands/runs.py +0 -223
  53. package/src/devcouncil/cli/commands/scaffold.py +0 -32
  54. package/src/devcouncil/cli/commands/semantic.py +0 -47
  55. package/src/devcouncil/cli/commands/setup.py +0 -362
  56. package/src/devcouncil/cli/commands/shell.py +0 -73
  57. package/src/devcouncil/cli/commands/show.py +0 -76
  58. package/src/devcouncil/cli/commands/skills.py +0 -88
  59. package/src/devcouncil/cli/commands/status.py +0 -141
  60. package/src/devcouncil/cli/commands/tasks.py +0 -55
  61. package/src/devcouncil/cli/commands/trace.py +0 -88
  62. package/src/devcouncil/cli/commands/verify.py +0 -328
  63. package/src/devcouncil/cli/commands/version.py +0 -20
  64. package/src/devcouncil/cli/commands/watch.py +0 -574
  65. package/src/devcouncil/cli/commands/watch_fs.py +0 -40
  66. package/src/devcouncil/cli/main.py +0 -137
  67. package/src/devcouncil/council/__init__.py +0 -0
  68. package/src/devcouncil/council/prompts/__init__.py +0 -0
  69. package/src/devcouncil/council/prompts/arbiter.md +0 -19
  70. package/src/devcouncil/council/prompts/critic_a.md +0 -10
  71. package/src/devcouncil/council/prompts/critic_b.md +0 -10
  72. package/src/devcouncil/council/prompts/implementation_reviewer.md +0 -16
  73. package/src/devcouncil/council/prompts/planner_a.md +0 -16
  74. package/src/devcouncil/council/prompts/planner_b.md +0 -16
  75. package/src/devcouncil/council/prompts/rebuttal.md +0 -10
  76. package/src/devcouncil/council/prompts/spec_writer.md +0 -12
  77. package/src/devcouncil/domain/__init__.py +0 -0
  78. package/src/devcouncil/domain/assumption.py +0 -17
  79. package/src/devcouncil/domain/critique.py +0 -32
  80. package/src/devcouncil/domain/evidence.py +0 -47
  81. package/src/devcouncil/domain/gap.py +0 -52
  82. package/src/devcouncil/domain/requirement.py +0 -22
  83. package/src/devcouncil/domain/task.py +0 -55
  84. package/src/devcouncil/execution/__init__.py +0 -1
  85. package/src/devcouncil/execution/checkpoints.py +0 -246
  86. package/src/devcouncil/execution/context_builder.py +0 -60
  87. package/src/devcouncil/execution/executor.py +0 -15
  88. package/src/devcouncil/execution/fs_watcher.py +0 -180
  89. package/src/devcouncil/execution/handoff.py +0 -102
  90. package/src/devcouncil/execution/hook_policy.py +0 -253
  91. package/src/devcouncil/execution/patch.py +0 -77
  92. package/src/devcouncil/execution/paths.py +0 -14
  93. package/src/devcouncil/execution/permissions.py +0 -85
  94. package/src/devcouncil/execution/policy_engine.py +0 -343
  95. package/src/devcouncil/execution/prompt_builder.py +0 -671
  96. package/src/devcouncil/execution/shell_session.py +0 -225
  97. package/src/devcouncil/execution/task_runner.py +0 -170
  98. package/src/devcouncil/executors/__init__.py +0 -1
  99. package/src/devcouncil/executors/agent_registry.py +0 -575
  100. package/src/devcouncil/executors/coding_cli.py +0 -736
  101. package/src/devcouncil/executors/mini_swe.py +0 -73
  102. package/src/devcouncil/executors/native/__init__.py +0 -0
  103. package/src/devcouncil/executors/native/agent.py +0 -208
  104. package/src/devcouncil/executors/openhands.py +0 -71
  105. package/src/devcouncil/gating/__init__.py +0 -1
  106. package/src/devcouncil/gating/checks/__init__.py +0 -0
  107. package/src/devcouncil/gating/checks/clean_git.py +0 -52
  108. package/src/devcouncil/gating/checks/planned_files_check.py +0 -32
  109. package/src/devcouncil/gating/checks/requirement_coverage.py +0 -26
  110. package/src/devcouncil/gating/checks/secret_scan_check.py +0 -53
  111. package/src/devcouncil/gating/policy.py +0 -338
  112. package/src/devcouncil/hardware.py +0 -184
  113. package/src/devcouncil/indexing/__init__.py +0 -1
  114. package/src/devcouncil/indexing/ast_matcher.py +0 -168
  115. package/src/devcouncil/indexing/graph_index.py +0 -48
  116. package/src/devcouncil/indexing/lsp.py +0 -161
  117. package/src/devcouncil/indexing/repo_mapper.py +0 -1455
  118. package/src/devcouncil/indexing/semantic_index.py +0 -205
  119. package/src/devcouncil/integrations/actions.py +0 -146
  120. package/src/devcouncil/integrations/check.py +0 -423
  121. package/src/devcouncil/integrations/code_review_graph.py +0 -163
  122. package/src/devcouncil/integrations/github.py +0 -39
  123. package/src/devcouncil/integrations/github_intent.py +0 -142
  124. package/src/devcouncil/integrations/gitnexus.py +0 -62
  125. package/src/devcouncil/integrations/graphify.py +0 -34
  126. package/src/devcouncil/integrations/mcp/__init__.py +0 -0
  127. package/src/devcouncil/integrations/mcp/server.py +0 -2122
  128. package/src/devcouncil/integrations/opencode_devcouncil_plugin.mjs +0 -24
  129. package/src/devcouncil/integrations/pr_comments.py +0 -62
  130. package/src/devcouncil/live/__init__.py +0 -2
  131. package/src/devcouncil/live/cards.py +0 -349
  132. package/src/devcouncil/live/models.py +0 -63
  133. package/src/devcouncil/live/repair_prompt.py +0 -83
  134. package/src/devcouncil/live/reviewer.py +0 -70
  135. package/src/devcouncil/live/signals.py +0 -135
  136. package/src/devcouncil/live/summary.py +0 -34
  137. package/src/devcouncil/live/tasks.py +0 -18
  138. package/src/devcouncil/live/transcripts.py +0 -141
  139. package/src/devcouncil/llm/__init__.py +0 -1
  140. package/src/devcouncil/llm/cache.py +0 -42
  141. package/src/devcouncil/llm/model_defaults.yaml +0 -44
  142. package/src/devcouncil/llm/provider.py +0 -627
  143. package/src/devcouncil/llm/router.py +0 -310
  144. package/src/devcouncil/optimization/__init__.py +0 -1
  145. package/src/devcouncil/optimization/gepa_agent.py +0 -318
  146. package/src/devcouncil/planning/__init__.py +0 -1
  147. package/src/devcouncil/planning/arbiter_service.py +0 -57
  148. package/src/devcouncil/planning/correction_manifest.py +0 -303
  149. package/src/devcouncil/planning/critique_service.py +0 -71
  150. package/src/devcouncil/planning/plan_service.py +0 -60
  151. package/src/devcouncil/planning/prompt_enhancer_service.py +0 -167
  152. package/src/devcouncil/planning/repair_service.py +0 -39
  153. package/src/devcouncil/planning/spec_service.py +0 -70
  154. package/src/devcouncil/repo/__init__.py +0 -0
  155. package/src/devcouncil/repo/ci_scaffold.py +0 -157
  156. package/src/devcouncil/repo/gitignore.py +0 -123
  157. package/src/devcouncil/repo/sca.py +0 -374
  158. package/src/devcouncil/reporting/__init__.py +0 -0
  159. package/src/devcouncil/reporting/github_check.py +0 -32
  160. package/src/devcouncil/reporting/json_report.py +0 -30
  161. package/src/devcouncil/reporting/markdown_report.py +0 -83
  162. package/src/devcouncil/reporting/report_builder.py +0 -14
  163. package/src/devcouncil/skills/__init__.py +0 -19
  164. package/src/devcouncil/skills/library/README.md +0 -46
  165. package/src/devcouncil/skills/library/ai-training.md +0 -50
  166. package/src/devcouncil/skills/library/android.md +0 -50
  167. package/src/devcouncil/skills/library/backend.md +0 -52
  168. package/src/devcouncil/skills/library/core-engineering.md +0 -95
  169. package/src/devcouncil/skills/library/data-engineering.md +0 -47
  170. package/src/devcouncil/skills/library/desktop.md +0 -46
  171. package/src/devcouncil/skills/library/devops.md +0 -48
  172. package/src/devcouncil/skills/library/game-dev.md +0 -46
  173. package/src/devcouncil/skills/library/ios.md +0 -48
  174. package/src/devcouncil/skills/library/mobile-cross-platform.md +0 -46
  175. package/src/devcouncil/skills/library/security.md +0 -48
  176. package/src/devcouncil/skills/library/systems.md +0 -48
  177. package/src/devcouncil/skills/library/web.md +0 -47
  178. package/src/devcouncil/skills/library/windows.md +0 -47
  179. package/src/devcouncil/skills/registry.py +0 -330
  180. package/src/devcouncil/storage/__init__.py +0 -0
  181. package/src/devcouncil/storage/db.py +0 -147
  182. package/src/devcouncil/storage/models.py +0 -204
  183. package/src/devcouncil/storage/native.py +0 -557
  184. package/src/devcouncil/storage/repositories.py +0 -485
  185. package/src/devcouncil/telemetry/__init__.py +0 -0
  186. package/src/devcouncil/telemetry/cost.py +0 -140
  187. package/src/devcouncil/telemetry/model_pricing.yaml +0 -48
  188. package/src/devcouncil/telemetry/pricing.py +0 -28
  189. package/src/devcouncil/telemetry/traces.py +0 -146
  190. package/src/devcouncil/telemetry/tracker.py +0 -52
  191. package/src/devcouncil/ui/__init__.py +0 -1
  192. package/src/devcouncil/ui/dashboard.py +0 -423
  193. package/src/devcouncil/utils/__init__.py +0 -1
  194. package/src/devcouncil/utils/redaction.py +0 -147
  195. package/src/devcouncil/utils/subprocess_env.py +0 -69
  196. package/src/devcouncil/verification/__init__.py +0 -1
  197. package/src/devcouncil/verification/acceptance_compiler.py +0 -125
  198. package/src/devcouncil/verification/ad_hoc_check.py +0 -129
  199. package/src/devcouncil/verification/diff_coverage.py +0 -353
  200. package/src/devcouncil/verification/implementation_reviewer.py +0 -55
  201. package/src/devcouncil/verification/next_actions.py +0 -189
  202. package/src/devcouncil/verification/sandbox.py +0 -178
  203. package/src/devcouncil/verification/test_resolver.py +0 -91
  204. package/src/devcouncil/verification/verifier.py +0 -1548
  205. package/uv.lock +0 -1226
@@ -1,147 +0,0 @@
1
- """Proactive secret and PII redaction for LLM-bound prompts.
2
-
3
- Two entry points:
4
- - redact_string(text) -- regex-based redaction of known secret patterns
5
- - redact_text(text, extra_patterns) -- enhanced version with custom patterns and typed labels
6
- - redact_env_vars(text) -- redact values in environment variable assignments
7
- - redact_dict(data) -- recursively redact all string values in a dict
8
- """
9
-
10
- import re
11
- from typing import Any, Dict, List, Optional, Pattern
12
-
13
- # Common patterns for sensitive data — each with a human-readable label
14
- SECRET_PATTERNS: Dict[str, Pattern] = {
15
- "aws_access_key": re.compile(r"(?i)\b(AKIA[0-9A-Z]{16})\b"),
16
- "aws_secret_key": re.compile(r"(?i)(?:aws_secret_access_key|aws_secret|secret_key)\s*[=:]\s*([0-9a-zA-Z/+]{40})"),
17
- "github_token": re.compile(r"(?i)\b(gh[pusr]_[A-Za-z0-9_]{36})\b"),
18
- # Anthropic keys are matched before the generic OpenAI-style sk- pattern so the
19
- # more specific label wins.
20
- "anthropic_key": re.compile(r"\b(sk-ant-[A-Za-z0-9_-]{20,})\b"),
21
- "openai_key": re.compile(r"\b(sk-[A-Za-z0-9_-]{20,})\b"),
22
- "google_api_key": re.compile(r"\b(AIza[0-9A-Za-z_-]{35})\b"),
23
- "stripe_live_key": re.compile(r"\b((?:sk|rk)_live_[0-9A-Za-z]{16,})\b"),
24
- "slack_token": re.compile(r"(?i)\b(xox[baprs]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})\b"),
25
- "jwt": re.compile(r"(?i)\b(ey[a-zA-Z0-9_-]{10,}\.ey[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,})\b"),
26
- "generic_api_key": re.compile(r"(?i)(api[_-]?key|secret|token|password)[\"'\s]*[:=][\"'\s]*([a-zA-Z0-9_\-\.]{16,})"),
27
- "private_key": re.compile(r"(?s)-----BEGIN [A-Z]+ PRIVATE KEY-----.*?-----END [A-Z]+ PRIVATE KEY-----"),
28
- "bearer": re.compile(r"(?i)\b(Bearer\s+)([a-zA-Z0-9_\-\.]{16,})\b"),
29
- "database_url": re.compile(r"(?i)((?:postgresql|mysql|mongodb|redis)://[^:]+:)([^@]+)(@.+)"),
30
- }
31
-
32
- # For backward compatibility
33
- def redact_string(text: str) -> str:
34
- """Redact known sensitive patterns from a string (legacy API)."""
35
- return redact_text(text)
36
-
37
-
38
- def redact_text(text: str, extra_patterns: Optional[List[str]] = None) -> str:
39
- """Redact known sensitive patterns from a string.
40
-
41
- Args:
42
- text: The input text to redact.
43
- extra_patterns: Optional list of regex patterns to additionally redact,
44
- labeled as [REDACTED:custom_N].
45
-
46
- Returns:
47
- Text with all sensitive patterns replaced with [REDACTED:type] labels.
48
- """
49
- if not isinstance(text, str):
50
- return text
51
-
52
- redacted_text = text
53
-
54
- for key_type, pattern in SECRET_PATTERNS.items():
55
- if key_type == "generic_api_key":
56
- # For the generic pattern, replace the value part (group 2)
57
- def _make_generic_replacer(kt: str):
58
- def replacer(match):
59
- prefix = match.group(1)
60
- separator = match.group(0)[len(match.group(1)):-len(match.group(2))]
61
- return f"{prefix}{separator}[REDACTED:{kt}]"
62
- return replacer
63
- redacted_text = pattern.sub(_make_generic_replacer(key_type), redacted_text)
64
- elif key_type == "bearer":
65
- # Preserve "Bearer " prefix, redact the token
66
- def _bearer_replacer(match):
67
- return f"{match.group(1)}[REDACTED:bearer]"
68
- redacted_text = pattern.sub(_bearer_replacer, redacted_text)
69
- elif key_type == "database_url":
70
- # Preserve protocol and host, redact password
71
- def _db_url_replacer(match):
72
- return f"{match.group(1)}[REDACTED:database_url]{match.group(3)}"
73
- redacted_text = pattern.sub(_db_url_replacer, redacted_text)
74
- else:
75
- redacted_text = pattern.sub(f"[REDACTED:{key_type}]", redacted_text)
76
-
77
- # Apply custom extra patterns
78
- if extra_patterns:
79
- for i, pat_str in enumerate(extra_patterns):
80
- try:
81
- pat = re.compile(pat_str)
82
- redacted_text = pat.sub(f"[REDACTED:custom_{i}]", redacted_text)
83
- except re.error:
84
- pass # Skip invalid patterns
85
-
86
- return redacted_text
87
-
88
-
89
- def redact_env_vars(text: str) -> str:
90
- """Redact values in environment variable assignments.
91
-
92
- Handles patterns like:
93
- export KEY=value
94
- KEY='value'
95
- KEY="value"
96
- """
97
- if not isinstance(text, str):
98
- return text
99
-
100
- # Match: optional export, VAR_NAME = value (with optional quotes)
101
- env_pattern = re.compile(
102
- r"(?m)^(\s*(?:export\s+)?)" # optional export
103
- r"([A-Z_][A-Z0-9_]*)" # variable name
104
- r"(\s*=\s*)" # equals sign
105
- r"(?:'([^']*)'|\"([^\"]*)\"|(\S+))" # value (quoted or unquoted)
106
- )
107
-
108
- sensitive_keys = {
109
- "api_key", "secret", "token", "password", "passwd", "credential",
110
- "private_key", "access_key", "secret_key", "auth",
111
- }
112
-
113
- def _env_replacer(match):
114
- prefix = match.group(1)
115
- var_name = match.group(2)
116
- eq_sign = match.group(3)
117
-
118
- # Check if the variable name contains a sensitive keyword
119
- var_lower = var_name.lower()
120
- is_sensitive = any(kw in var_lower for kw in sensitive_keys)
121
-
122
- if is_sensitive:
123
- return f"{prefix}{var_name}{eq_sign}[REDACTED]"
124
-
125
- return match.group(0)
126
-
127
- return env_pattern.sub(_env_replacer, text)
128
-
129
-
130
- def redact_dict(data: dict[str, Any]) -> dict[str, Any]:
131
- """Recursively redact sensitive patterns from a dictionary (e.g. JSON response)."""
132
- result: dict[str, Any] = {}
133
- for k, v in data.items():
134
- if isinstance(v, str):
135
- result[k] = redact_text(v)
136
- elif isinstance(v, dict):
137
- result[k] = redact_dict(v)
138
- elif isinstance(v, list):
139
- result[k] = [
140
- redact_dict(item) if isinstance(item, dict)
141
- else redact_text(item) if isinstance(item, str)
142
- else item
143
- for item in v
144
- ]
145
- else:
146
- result[k] = v
147
- return result
@@ -1,69 +0,0 @@
1
- """A sanitized environment for spawning *external* executables.
2
-
3
- When DevCouncil runs from a virtualenv (a project ``.venv`` or a ``uv tool
4
- install``), its interpreter exports markers — ``VIRTUAL_ENV``, ``PYTHONHOME``,
5
- ``PYTHONPATH``, ``UV_INTERNAL__PYTHONHOME`` — that any child process inherits.
6
- Those markers forcibly re-point a freshly-spawned, *differently-built* Python
7
- (e.g. the globally-installed ``devcouncil`` CLI, or a project's own
8
- interpreter) at DevCouncil's stdlib/site-packages. The classic symptoms are
9
- ``AssertionError: SRE module mismatch`` (the child loads its own ``_sre`` C
10
- extension against our ``re`` stdlib) and spurious ``No module named pytest``.
11
-
12
- This mirrors :meth:`Verifier._verification_env` but is dependency-free so the
13
- integration probes (``dev integrate check``) and any other call-site that
14
- shells out to an *external* program can share one correct implementation.
15
- """
16
-
17
- from __future__ import annotations
18
-
19
- import os
20
- import sys
21
- from pathlib import Path
22
- from typing import Dict
23
-
24
-
25
- def clean_subprocess_env() -> Dict[str, str]:
26
- """Return a copy of ``os.environ`` with DevCouncil's own virtualenv stripped.
27
-
28
- No-op (returns a plain copy) when DevCouncil is not running inside a venv,
29
- so behaviour is unchanged for system / pipx-style installs.
30
- """
31
- env = dict(os.environ)
32
- venv_prefix = Path(sys.prefix).resolve()
33
- base_prefix = Path(getattr(sys, "base_prefix", sys.prefix)).resolve()
34
- if venv_prefix == base_prefix:
35
- return env # Not inside a venv; nothing to strip.
36
-
37
- venv_dirs = {
38
- str(venv_prefix).lower(),
39
- str((venv_prefix / "Scripts").resolve()).lower(),
40
- str((venv_prefix / "bin").resolve()).lower(),
41
- }
42
- path = env.get("PATH", "")
43
- kept = []
44
- for entry in path.split(os.pathsep):
45
- if not entry:
46
- continue
47
- try:
48
- normalized = str(Path(entry).resolve()).lower()
49
- except Exception:
50
- normalized = entry.lower()
51
- if normalized in venv_dirs:
52
- continue
53
- kept.append(entry)
54
- env["PATH"] = os.pathsep.join(kept)
55
-
56
- own_prefixes = {str(venv_prefix), str(base_prefix)}
57
- for marker in ("VIRTUAL_ENV", "PYTHONHOME"):
58
- value = env.get(marker)
59
- if not value:
60
- continue
61
- try:
62
- resolved = str(Path(value).resolve())
63
- except Exception:
64
- resolved = value
65
- if resolved in own_prefixes:
66
- env.pop(marker, None)
67
- # uv stashes the interpreter home here and re-applies it to child pythons.
68
- env.pop("UV_INTERNAL__PYTHONHOME", None)
69
- return env
@@ -1,125 +0,0 @@
1
- """Compile natural-language acceptance criteria into self-contained executable
2
- checks that DevCouncil owns and runs.
3
-
4
- This is the difference between trusting the planner/agent's word and gathering
5
- real evidence: instead of running planner-authored ``expected_tests`` (which the
6
- benchmark showed often reference tools or test files that do not exist), DevCouncil
7
- derives one runnable check per acceptance criterion directly from the criterion
8
- text and the code under review, then maps each check 1:1 to its criterion.
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- import json
14
- from typing import Dict, List
15
-
16
- from pydantic import BaseModel
17
-
18
- from devcouncil.domain.requirement import Requirement
19
- from devcouncil.domain.task import Task
20
- from devcouncil.llm.router import ModelRouter
21
-
22
-
23
- class CompiledCheck(BaseModel):
24
- acceptance_criterion_id: str
25
- command: str # a single shell command that exits 0 iff the criterion holds
26
-
27
-
28
- class CompiledChecks(BaseModel):
29
- checks: List[CompiledCheck]
30
-
31
-
32
- class AcceptanceTestCompiler:
33
- def __init__(self, router: ModelRouter, role: str = "implementation_reviewer"):
34
- self.router = router
35
- self.role = role
36
-
37
- async def compile(
38
- self,
39
- task: Task,
40
- requirements: List[Requirement],
41
- code_context: str,
42
- ) -> Dict[str, List[str]]:
43
- """Return {acceptance_criterion_id: [self-contained check command(s)]}.
44
-
45
- Best-effort: returns {} if the model cannot produce usable checks, so the
46
- caller can fall back to the task's declared expected_tests.
47
- """
48
- ac_by_id = {ac.id: ac for req in requirements for ac in req.acceptance_criteria}
49
- target = [ac_by_id[i] for i in task.acceptance_criterion_ids if i in ac_by_id]
50
- if not target:
51
- return {}
52
-
53
- acs_json = json.dumps(
54
- [{"id": ac.id, "description": ac.description, "method": ac.verification_method} for ac in target],
55
- indent=2,
56
- )
57
- prompt = f"""
58
- You are DevCouncil's acceptance-test compiler. Convert each acceptance criterion
59
- below into exactly ONE shell command that EXITS 0 if and only if the BEHAVIOR
60
- described by the criterion holds for the code shown.
61
-
62
- Acceptance criteria:
63
- {acs_json}
64
-
65
- Code under review (the diff / current files):
66
- {code_context}
67
-
68
- What a check must verify — BEHAVIOR ONLY:
69
- - A check exists to confirm the code DOES what the criterion describes when its
70
- public API is exercised: import the module/symbol and call its function(s), or
71
- run its CLI/entrypoint, and assert on the observable result (return value,
72
- raised exception, stdout, exit code).
73
- - DevCouncil already enforces scope, file ownership, and append-only/orphan-diff
74
- constraints with its OWN gates. Acceptance checks must therefore NEVER re-assert
75
- repository or filesystem STATE — that is not their job and it produces false
76
- BLOCKED results because `dev` itself adds workspace files (AGENTS.md, CLAUDE.md,
77
- .gitignore, .devcouncil/config.yaml, etc.).
78
-
79
- Rules — the commands are executed verbatim by the verifier:
80
- - One command per acceptance_criterion_id (reference the id exactly).
81
- - Each command MUST be a single, SELF-CONTAINED, immediately-runnable command:
82
- import the real module/symbol from the code and assert the behavior directly.
83
- Do NOT depend on test files, fixtures, or any external setup.
84
- - Prefer: python -c "import <module>; assert <expr>". For an expected exception,
85
- use a one-line guard, e.g.
86
- python -c "import m; \\ntry: m.f([])\\nexcept ValueError: pass\\nelse: raise SystemExit(1)"
87
- (real newlines are fine; never put try/if/for after a ';').
88
- - Use the actual module name implied by the code (e.g. file 'stats.py' -> import stats).
89
-
90
- HARD PROHIBITIONS — a command that does any of these is INVALID; omit the
91
- criterion instead of emitting such a command:
92
- - NEVER assert exact git or filesystem state. Forbidden: `git status`,
93
- `git status --porcelain`, `git diff`, `git diff --name-only`, `git show`,
94
- `git ls-files`, `ls`/`find`/`os.listdir` equality checks, asserting a precise
95
- set or count of changed/created files, or asserting a file does/does not exist
96
- as the criterion's pass condition.
97
- - NEVER do append-only or byte-level file/content comparisons (e.g.
98
- `git show HEAD:file`, diffing bytes, asserting only N bytes/lines were added).
99
- Assert the resulting BEHAVIOR instead, not how the file changed.
100
- - NEVER invoke linters, type checkers, formatters, or build/package tools that
101
- may be absent: flake8, mypy, ruff, pylint, black, isort, eslint, tsc, prettier,
102
- npm, npx, yarn, pnpm, cargo, go vet, etc. Only use such a tool if the code
103
- context clearly shows it is configured for this repo (e.g. a matching config
104
- section/file is present in the context) AND it is essential to the criterion.
105
- - If a criterion cannot be checked by a behavioral command (e.g. pure 'manual'
106
- review, or it only describes repo/tooling state), OMIT it rather than inventing
107
- a state-based or bogus command.
108
- """
109
- try:
110
- result = await self.router.complete_structured(
111
- role=self.role,
112
- messages=[{"role": "user", "content": prompt}],
113
- schema=CompiledChecks,
114
- fallback=CompiledChecks(checks=[]),
115
- )
116
- except Exception:
117
- return {}
118
-
119
- out: Dict[str, List[str]] = {}
120
- valid_ids = {ac.id for ac in target}
121
- for check in result.checks:
122
- cmd = (check.command or "").strip()
123
- if check.acceptance_criterion_id in valid_ids and cmd:
124
- out.setdefault(check.acceptance_criterion_id, []).append(cmd)
125
- return out
@@ -1,129 +0,0 @@
1
- """Verify an ad-hoc working-tree diff against an inline requirement — no planning, no keys.
2
-
3
- This powers ``dev check``'s evidence-gate mode (the lite entry point): wrap whatever is
4
- in the working tree as a synthetic Requirement→Task, run the *same* deterministic
5
- :class:`~devcouncil.verification.verifier.Verifier` the full workflow uses — orphan-diff,
6
- secret scan, acceptance evidence, and the diff↔coverage gate — and return the verdict
7
- plus the typed next-actions contract. ``router=None`` keeps it provider-key-free so a
8
- newcomer can taste the evidence gate before committing to the full council flow.
9
-
10
- The logic lives here (not in the CLI command) so it is unit-testable without Typer and
11
- resilient to churn in the command module.
12
- """
13
-
14
- from __future__ import annotations
15
-
16
- import asyncio
17
- from dataclasses import dataclass, field
18
- from pathlib import Path
19
- from typing import List, Optional
20
-
21
- from devcouncil.domain.evidence import DiffCoverageEvidence
22
- from devcouncil.domain.gap import Gap
23
- from devcouncil.domain.requirement import AcceptanceCriterion, Requirement
24
- from devcouncil.domain.task import PlannedFile, Task
25
- from devcouncil.llm.router import ModelRouter
26
- from devcouncil.verification.next_actions import NextAction, build_next_actions
27
- from devcouncil.verification.verifier import Verifier
28
-
29
- _REQ_ID = "REQ-CHECK"
30
- _AC_ID = "AC-CHECK"
31
- _TASK_ID = "CHECK"
32
-
33
- _DEFAULT_CRITERION = "The working-tree changes are correct and exercised by tests."
34
-
35
-
36
- @dataclass
37
- class AdHocCheckResult:
38
- requirement: str
39
- changed_files: List[str] = field(default_factory=list)
40
- gaps: List[Gap] = field(default_factory=list)
41
- next_actions: List[NextAction] = field(default_factory=list)
42
- diff_coverage: Optional[DiffCoverageEvidence] = None
43
- passed: bool = True
44
- reason: str = ""
45
-
46
- def to_dict(self) -> dict:
47
- return {
48
- "ok": True,
49
- "verified": self.passed,
50
- "requirement": self.requirement,
51
- "changed_files": self.changed_files,
52
- "reason": self.reason,
53
- "gap_count": len(self.gaps),
54
- "blocking_gap_count": len([g for g in self.gaps if g.blocking]),
55
- "gaps": [g.model_dump() for g in self.gaps],
56
- "next_actions": [a.model_dump() for a in self.next_actions],
57
- "diff_coverage": self.diff_coverage.model_dump() if self.diff_coverage else None,
58
- }
59
-
60
-
61
- def run_working_tree_check(
62
- project_root: Path,
63
- requirement: Optional[str] = None,
64
- *,
65
- test_commands: Optional[List[str]] = None,
66
- enforce_coverage: bool = False,
67
- min_ratio: float = 0.0,
68
- router: Optional[ModelRouter] = None,
69
- verifier: Optional[Verifier] = None,
70
- ) -> AdHocCheckResult:
71
- """Verify the current working-tree diff against a one-line requirement.
72
-
73
- Builds a synthetic task whose planned files are exactly the changed files (so the
74
- result is about evidence, not scope noise) and whose expected tests are
75
- ``test_commands``. Diff coverage is always measured; pass ``enforce_coverage`` (or a
76
- positive ``min_ratio``) to make an unexercised diff blocking.
77
- """
78
- verifier = verifier or Verifier(project_root, router=router)
79
-
80
- diff = verifier.get_diff()
81
- changed_files = verifier.get_changed_files()
82
- if not diff or not changed_files:
83
- return AdHocCheckResult(requirement="", passed=True, reason="no_changes")
84
-
85
- criterion = requirement or _DEFAULT_CRITERION
86
- req = Requirement(
87
- id=_REQ_ID,
88
- title=(requirement or "Working-tree change")[:80],
89
- description=criterion,
90
- priority="high",
91
- source="user",
92
- acceptance_criteria=[
93
- AcceptanceCriterion(id=_AC_ID, description=criterion, verification_method="unit_test"),
94
- ],
95
- )
96
- untracked = set(verifier._get_untracked_files())
97
- task = Task(
98
- id=_TASK_ID,
99
- title="Ad-hoc working-tree check",
100
- description=criterion,
101
- requirement_ids=[_REQ_ID],
102
- acceptance_criterion_ids=[_AC_ID],
103
- planned_files=[
104
- PlannedFile(
105
- path=path,
106
- reason="working-tree change",
107
- allowed_change="create" if path in untracked else "modify",
108
- )
109
- for path in changed_files
110
- ],
111
- expected_tests=list(test_commands or []),
112
- )
113
-
114
- # Always measure diff coverage in lite mode; block on it only when asked. A positive
115
- # --min-coverage implies enforcement so the flag is never silently inert.
116
- enforce = enforce_coverage or min_ratio > 0
117
- verifier._diff_coverage_override = (True, enforce, float(min_ratio))
118
-
119
- gaps, evidence = asyncio.run(verifier.verify_task(task, [req]))
120
- coverage = next((ev for ev in evidence if isinstance(ev, DiffCoverageEvidence)), None)
121
- blocking = [g for g in gaps if g.blocking]
122
- return AdHocCheckResult(
123
- requirement=criterion,
124
- changed_files=changed_files,
125
- gaps=gaps,
126
- next_actions=build_next_actions(gaps),
127
- diff_coverage=coverage,
128
- passed=not blocking,
129
- )