devflow-toolkit 0.3.25__py3-none-any.whl → 0.3.27__py3-none-any.whl

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.
@@ -3,6 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import shlex
7
+ import sys
6
8
 
7
9
  from devflow.adapters.base import (
8
10
  FileChange,
@@ -51,10 +53,13 @@ class ClaudeCodeAdapter(HarnessAdapter):
51
53
  return SetupResult(changes=tuple(changes))
52
54
 
53
55
  def build_run(self, context: RunContext) -> Invocation:
54
- settings = json.dumps(
55
- {"permissions": self._permission_rules(context)},
56
- separators=(",", ":"),
57
- )
56
+ settings_data: dict[str, object] = {
57
+ "permissions": self._permission_rules(context),
58
+ }
59
+ hooks = self._write_guard(context)
60
+ if hooks:
61
+ settings_data["hooks"] = hooks
62
+ settings = json.dumps(settings_data, separators=(",", ":"))
58
63
  root = context.root
59
64
  permission_mode = (
60
65
  "manual" if context.mode == "interactive" else "dontAsk"
@@ -112,6 +117,31 @@ class ClaudeCodeAdapter(HarnessAdapter):
112
117
  return []
113
118
  return ["Read", "Grep", "Glob"]
114
119
 
120
+ def _write_guard(self, context: RunContext) -> dict[str, object]:
121
+ """Block writes outside the specs directory without asking the user."""
122
+ permissions = context.permissions
123
+ if permissions.allow_source_code_changes or not (
124
+ permissions.allow_spec_write
125
+ ):
126
+ return {}
127
+ allowed = context.spec_directory.parent
128
+ command = " ".join(
129
+ [
130
+ shlex.quote(sys.executable),
131
+ "-m",
132
+ "devflow.hooks.claude_guard",
133
+ shlex.quote(str(allowed)),
134
+ ]
135
+ )
136
+ return {
137
+ "PreToolUse": [
138
+ {
139
+ "matcher": "Write|Edit|MultiEdit|NotebookEdit",
140
+ "hooks": [{"type": "command", "command": command}],
141
+ }
142
+ ]
143
+ }
144
+
115
145
  def _permission_rules(
116
146
  self,
117
147
  context: RunContext,
@@ -2,11 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import sys
5
6
  from pathlib import Path
6
7
 
7
8
  import typer
8
9
  from rich.console import Console
9
10
 
11
+ from devflow.commands.security import offer_security_tools
10
12
  from devflow.core.artifacts.errors import ArtifactError
11
13
  from devflow.core.config import ConfigError, ConfigManager
12
14
  from devflow.core.discovery import DiscoveryError
@@ -99,3 +101,12 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
99
101
  "Changing an approved artifact marks it stale and blocks the "
100
102
  "workflow until it is validated again.[/dim]"
101
103
  )
104
+ if result.changed:
105
+ # Implementation starts after the first approval: this is when
106
+ # checks that review code on every commit become useful.
107
+ offer_security_tools(
108
+ config,
109
+ ProjectDetector().detect(config.root),
110
+ console,
111
+ allow_prompt=sys.stdin.isatty(),
112
+ )
devflow/commands/init.py CHANGED
@@ -37,7 +37,10 @@ from devflow.core.ports import (
37
37
  SetupResult,
38
38
  build_setup_context,
39
39
  )
40
- from devflow.core import security_tools
40
+ from devflow.commands.security import (
41
+ decline_security_tools,
42
+ install_security_tools,
43
+ )
41
44
  from devflow.core.profile_manager import ProfileError, ProfileManager
42
45
  from devflow.core.project import ProjectDetector
43
46
  from devflow.models.profile import Profile
@@ -118,8 +121,9 @@ def init(
118
121
  None,
119
122
  "--security-tools/--no-security-tools",
120
123
  help=(
121
- "Install local security checks (Semgrep, Bandit, pip-audit, "
122
- "gitleaks) with pre-commit. When omitted, an interactive init asks."
124
+ "Install now the local security checks (Semgrep, Bandit, "
125
+ "pip-audit, gitleaks) that review code on every commit. Without "
126
+ "this flag they are offered after the first spec approval."
123
127
  ),
124
128
  ),
125
129
  ) -> None:
@@ -227,12 +231,10 @@ def _initialize(
227
231
  model_override=model is not None,
228
232
  allow_prompt=not yes and sys.stdin.isatty(),
229
233
  )
230
- _offer_security_tools(
231
- config=config_manager.load(),
232
- project=project,
233
- requested=security_tools,
234
- allow_prompt=not yes and sys.stdin.isatty(),
235
- )
234
+ if security_tools:
235
+ install_security_tools(config_manager.load(), project, console)
236
+ elif security_tools is False:
237
+ decline_security_tools(config_manager.load())
236
238
  return
237
239
 
238
240
  selected = list(explicit_profiles) or detected_names
@@ -340,62 +342,15 @@ def _initialize(
340
342
  f"[green]Specifications directory:[/green] "
341
343
  f"{config.specifications_path.relative_to(root)}"
342
344
  )
343
- _offer_security_tools(
344
- config=config,
345
- project=project,
346
- requested=security_tools,
347
- allow_prompt=not yes and sys.stdin.isatty(),
348
- )
345
+ if security_tools:
346
+ install_security_tools(config, project, console)
347
+ elif security_tools is False:
348
+ decline_security_tools(config)
349
349
  console.print(
350
350
  "\nNext: [bold]devflow spec \"Describe the change\"[/bold]"
351
351
  )
352
352
 
353
353
 
354
- def _offer_security_tools(
355
- *,
356
- config: DevFlowConfig,
357
- project: Project,
358
- requested: Optional[bool],
359
- allow_prompt: bool,
360
- ) -> None:
361
- """Offer the local security checks and install them on request."""
362
- if requested is False:
363
- return
364
- root = config.root
365
- plan = security_tools.plan_for(project, root)
366
- if requested is None:
367
- if security_tools.is_configured(root):
368
- return
369
- if not allow_prompt:
370
- console.print(
371
- "[dim]Tip: add local security checks with "
372
- "'devflow init --security-tools'.[/dim]"
373
- )
374
- return
375
- console.print()
376
- for line in security_tools.describe(
377
- plan,
378
- config.documentation_language,
379
- ):
380
- console.print(line)
381
- if not typer.confirm(
382
- security_tools.confirm_prompt(config.documentation_language),
383
- default=True,
384
- ):
385
- return
386
-
387
- result = security_tools.install(root, plan)
388
- if result.config_status in {"created", "updated"}:
389
- console.print(
390
- f"[green]Security checks configured:[/green] "
391
- f"{security_tools.PRECOMMIT_CONFIG} ({', '.join(plan.tools)})"
392
- )
393
- for message in result.messages:
394
- console.print(f"[green]{message}[/green]")
395
- for warning in result.warnings:
396
- console.print(f"[yellow]Warning:[/yellow] {warning}")
397
-
398
-
399
354
  def _prompt_for_language() -> str:
400
355
  """Ask for the documentation language during interactive initialization."""
401
356
  console.print(
@@ -0,0 +1,67 @@
1
+ """Offer and install the local security checks used during implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typer
6
+ from rich.console import Console
7
+
8
+ from devflow.core import security_tools
9
+ from devflow.core.config import ConfigManager, DevFlowConfig
10
+ from devflow.models.project import Project
11
+
12
+
13
+ def install_security_tools(
14
+ config: DevFlowConfig,
15
+ project: Project,
16
+ console: Console,
17
+ ) -> None:
18
+ """Install the checks and report the result."""
19
+ plan = security_tools.plan_for(project, config.root)
20
+ result = security_tools.install(config.root, plan)
21
+ ConfigManager(config.root).mark_security_tools_offered()
22
+ if result.config_status in {"created", "updated"}:
23
+ console.print(
24
+ f"[green]Security checks configured:[/green] "
25
+ f"{security_tools.PRECOMMIT_CONFIG} ({', '.join(plan.tools)})"
26
+ )
27
+ for message in result.messages:
28
+ console.print(f"[green]{message}[/green]")
29
+ for warning in result.warnings:
30
+ console.print(f"[yellow]Warning:[/yellow] {warning}")
31
+
32
+
33
+ def decline_security_tools(config: DevFlowConfig) -> None:
34
+ """Remember that the user does not want the offer again."""
35
+ ConfigManager(config.root).mark_security_tools_offered()
36
+
37
+
38
+ def offer_security_tools(
39
+ config: DevFlowConfig,
40
+ project: Project,
41
+ console: Console,
42
+ *,
43
+ allow_prompt: bool,
44
+ ) -> None:
45
+ """Offer the checks once, when implementation is about to start."""
46
+ manager = ConfigManager(config.root)
47
+ if (
48
+ not allow_prompt
49
+ or security_tools.is_configured(config.root)
50
+ or manager.security_tools_offered()
51
+ ):
52
+ return
53
+ plan = security_tools.plan_for(project, config.root)
54
+ console.print()
55
+ for line in security_tools.describe(plan, config.documentation_language):
56
+ console.print(line)
57
+ if typer.confirm(
58
+ security_tools.confirm_prompt(config.documentation_language),
59
+ default=True,
60
+ ):
61
+ install_security_tools(config, project, console)
62
+ return
63
+ manager.mark_security_tools_offered()
64
+ console.print(
65
+ "[dim]You can add them later with "
66
+ "'devflow init --security-tools'.[/dim]"
67
+ )
@@ -245,6 +245,9 @@ def _print_discovery(
245
245
  soft_wrap=True,
246
246
  )
247
247
 
248
+ for note in discovery.notes:
249
+ console.print(f" [yellow]corrected: {note}[/yellow]", soft_wrap=True)
250
+
248
251
  suggestions = discovery.suggested_next_specs()
249
252
  if suggestions:
250
253
  console.print("\n[bold]Suggested next specifications[/bold]")
devflow/core/config.py CHANGED
@@ -624,6 +624,23 @@ class ConfigManager:
624
624
  self._write_document(data)
625
625
  return self.load()
626
626
 
627
+ def security_tools_offered(self) -> bool:
628
+ """Return whether the local security checks were already offered."""
629
+ security = self._read_document().get("security")
630
+ return isinstance(security, dict) and bool(
631
+ security.get("tools_offered")
632
+ )
633
+
634
+ def mark_security_tools_offered(self) -> None:
635
+ """Remember that the local security checks were offered once."""
636
+ data = self._read_document()
637
+ security = data.get("security")
638
+ if not isinstance(security, dict):
639
+ security = {}
640
+ data["security"] = security
641
+ security["tools_offered"] = True
642
+ self._write_document(data)
643
+
627
644
  def ensure_directories(self, config: DevFlowConfig) -> None:
628
645
  """Create the directories referenced by the configuration."""
629
646
  for path in (
devflow/core/discovery.py CHANGED
@@ -105,6 +105,50 @@ _CATEGORY_MATERIALITY = {
105
105
  "deployment": MATERIALITY_TECHNICAL,
106
106
  }
107
107
 
108
+ # Categories agents commonly invent, mapped to the closest valid one.
109
+ # Unknown categories fall back to functional_scope; the materiality the
110
+ # agent wrote is kept, so a critical decision stays critical.
111
+ _CATEGORY_ALIASES = {
112
+ "api": "functional_scope",
113
+ "api_contract": "functional_scope",
114
+ "api_design": "functional_scope",
115
+ "interface": "functional_scope",
116
+ "scope": "functional_scope",
117
+ "functional": "functional_scope",
118
+ "validation": "functional_scope",
119
+ "business_rules": "functional_scope",
120
+ "error_handling": "functional_scope",
121
+ "ui": "user_behavior",
122
+ "ux": "user_behavior",
123
+ "user_interface": "user_behavior",
124
+ "user_experience": "user_behavior",
125
+ "navigation": "user_behavior",
126
+ "i18n": "user_behavior",
127
+ "localization": "user_behavior",
128
+ "data": "data_persistence",
129
+ "data_model": "data_persistence",
130
+ "database": "data_persistence",
131
+ "persistence": "data_persistence",
132
+ "storage": "data_persistence",
133
+ "security": "security_authentication",
134
+ "authentication": "security_authentication",
135
+ "authorization": "security_authentication",
136
+ "auth": "security_authentication",
137
+ "permissions": "security_authentication",
138
+ "privacy": "security_authentication",
139
+ "integration": "external_integration",
140
+ "external": "external_integration",
141
+ "third_party": "external_integration",
142
+ "architecture": "architecture_boundary",
143
+ "performance": "architecture_boundary",
144
+ "scalability": "architecture_boundary",
145
+ "configuration": "architecture_boundary",
146
+ "dependency": "dependencies",
147
+ "libraries": "dependencies",
148
+ "infrastructure": "deployment",
149
+ "operations": "deployment",
150
+ }
151
+
108
152
  ASSUMPTION_PENDING = "pending_acceptance"
109
153
  ASSUMPTION_ACCEPTED = "accepted"
110
154
  ASSUMPTION_STATUSES = (ASSUMPTION_PENDING, ASSUMPTION_ACCEPTED)
@@ -685,6 +729,9 @@ class DiscoveryDocument:
685
729
  questions: tuple[DiscoveryQuestion, ...] = ()
686
730
  assumptions: tuple[DiscoveryAssumption, ...] = ()
687
731
  deferred: tuple[DeferredItem, ...] = ()
732
+ # Minor problems DevFlow corrected while reading the record. They are
733
+ # reported to the user and never written back by themselves.
734
+ notes: tuple[str, ...] = ()
688
735
 
689
736
  def suggested_next_specs(self) -> tuple[DeferredItem, ...]:
690
737
  """Return next-level improvements to propose as later specs.
@@ -1182,8 +1229,9 @@ class DiscoveryManager:
1182
1229
  )
1183
1230
  raise DiscoveryError(msg)
1184
1231
 
1232
+ notes: list[str] = []
1185
1233
  questions = tuple(
1186
- self._question(item, index)
1234
+ self._question(item, index, notes=notes, default_time=updated_at)
1187
1235
  for index, item in enumerate(questions_data, start=1)
1188
1236
  )
1189
1237
  question_ids = {question.id for question in questions}
@@ -1244,6 +1292,7 @@ class DiscoveryManager:
1244
1292
  questions=questions,
1245
1293
  assumptions=assumptions,
1246
1294
  deferred=deferred,
1295
+ notes=tuple(notes),
1247
1296
  )
1248
1297
  return document
1249
1298
 
@@ -1251,18 +1300,26 @@ class DiscoveryManager:
1251
1300
  self,
1252
1301
  data: object,
1253
1302
  index: int,
1303
+ *,
1304
+ notes: list[str] | None = None,
1305
+ default_time: str = "",
1254
1306
  ) -> DiscoveryQuestion:
1255
1307
  mapping = _mapping(data, f"questions[{index}]")
1256
1308
  identifier = _text(mapping.get("id"), "question id")
1257
1309
  if not _QUESTION_ID.fullmatch(identifier):
1258
1310
  msg = f"Invalid discovery question id: {identifier!r}"
1259
1311
  raise DiscoveryError(msg)
1312
+ if notes is None:
1313
+ notes = []
1260
1314
  category = _text(mapping.get("category"), "question category")
1261
1315
  if category not in QUESTION_CATEGORIES:
1262
- msg = (
1263
- f"Invalid discovery question category: {category!r}"
1316
+ key = category.strip().lower().replace("-", "_").replace(" ", "_")
1317
+ corrected = _CATEGORY_ALIASES.get(key, "functional_scope")
1318
+ notes.append(
1319
+ f"{identifier}: unknown category {category!r} read as "
1320
+ f"{corrected!r}."
1264
1321
  )
1265
- raise DiscoveryError(msg)
1322
+ category = corrected
1266
1323
  question = _limited_text(
1267
1324
  mapping.get("question"),
1268
1325
  f"{identifier}.question",
@@ -1277,11 +1334,11 @@ class DiscoveryManager:
1277
1334
  f"{identifier}.materiality",
1278
1335
  ) or ""
1279
1336
  if materiality and materiality not in MATERIALITIES:
1280
- msg = (
1281
- f"Invalid materiality for {identifier}: {materiality!r}. "
1282
- f"Expected one of: {', '.join(MATERIALITIES)}."
1337
+ notes.append(
1338
+ f"{identifier}: unknown materiality {materiality!r} ignored; "
1339
+ "the category default applies."
1283
1340
  )
1284
- raise DiscoveryError(msg)
1341
+ materiality = ""
1285
1342
  status = _text(mapping.get("status"), f"{identifier}.status")
1286
1343
  if status in QUESTION_PENDING_ALIASES:
1287
1344
  status = QUESTION_PENDING
@@ -1380,12 +1437,16 @@ class DiscoveryManager:
1380
1437
  f"{identifier} is resolved but has no answer."
1381
1438
  )
1382
1439
  if not answered_by:
1383
- raise DiscoveryError(
1384
- f"{identifier} is resolved but has no answered_by."
1385
- )
1440
+ answered_by = "user"
1441
+ notes.append(f"{identifier}: missing answered_by read as user.")
1386
1442
  if not answered_at:
1387
- raise DiscoveryError(
1388
- f"{identifier} is resolved but has no answered_at."
1443
+ if not default_time:
1444
+ raise DiscoveryError(
1445
+ f"{identifier} is resolved but has no answered_at."
1446
+ )
1447
+ answered_at = default_time
1448
+ notes.append(
1449
+ f"{identifier}: missing answered_at read as {default_time}."
1389
1450
  )
1390
1451
  elif resolution_source == RESOLUTION_ASSUMPTION:
1391
1452
  raise DiscoveryError(
@@ -932,6 +932,7 @@ class SpecWorkflow:
932
932
  updated, digest = repaired_result
933
933
  repaired = True
934
934
  self._discard_unexpected_spec(prepared, spec_existed, warnings)
935
+ warnings.extend(f"discovery.yaml: {note}" for note in updated.notes)
935
936
  if not repaired:
936
937
  digest = self._discovery_digest(
937
938
  discovery_manager,
@@ -22,6 +22,7 @@ from devflow.core.constitution import (
22
22
  Constitution,
23
23
  implementation_documents,
24
24
  )
25
+ from devflow.core import security_tools
25
26
  from devflow.core.discovery import DiscoveryDocument
26
27
  from devflow.core.file_types import ANALYSIS_EXTENSIONS
27
28
  from devflow.core.project import (
@@ -1607,6 +1608,7 @@ class SpecificationManager:
1607
1608
  "",
1608
1609
  f"- Source files: {len(project.source_files)}",
1609
1610
  f"- Manifests: {', '.join(project.manifests) or 'none'}",
1611
+ *_quality_gate_lines(config.root),
1610
1612
  "",
1611
1613
  "### Constitution",
1612
1614
  "",
@@ -2041,6 +2043,7 @@ class SpecificationManager:
2041
2043
  "",
2042
2044
  f"- Source files: {len(project.source_files)}",
2043
2045
  f"- Manifests: {', '.join(project.manifests) or 'none'}",
2046
+ *_quality_gate_lines(config.root),
2044
2047
  "",
2045
2048
  "### Constitution",
2046
2049
  "",
@@ -2534,3 +2537,14 @@ def _approval_note(spec_id: str, language: str) -> str:
2534
2537
  base = (language or "en").split("-")[0].lower()
2535
2538
  template = _APPROVAL_NOTES.get(base, _APPROVAL_NOTES["en"])
2536
2539
  return template.format(spec_id=spec_id)
2540
+
2541
+
2542
+ def _quality_gate_lines(root: Path) -> list[str]:
2543
+ """Tell the spec writer about the security checks run on every commit."""
2544
+ if not security_tools.is_configured(root):
2545
+ return []
2546
+ return [
2547
+ f"- Security checks: `{security_tools.PRECOMMIT_CONFIG}` runs local "
2548
+ "security tools on every commit. Record `pre-commit run "
2549
+ "--all-files` as a quality gate in section 6.",
2550
+ ]
@@ -0,0 +1 @@
1
+ """Guards that DevFlow installs into agent harness sessions."""
@@ -0,0 +1,76 @@
1
+ """Claude Code PreToolUse hook that keeps writes inside a directory.
2
+
3
+ DevFlow passes this hook to specification sessions. Claude Code asks
4
+ the user about any write that is neither allowed nor denied, and a deny
5
+ rule for writes would also block `.devflow/specs/`. The hook decides
6
+ instead: a write outside the allowed directory is blocked without a
7
+ prompt, and the reason is returned to the agent.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import sys
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ BLOCKED_EXIT_CODE = 2
18
+ _PATH_KEYS = ("file_path", "notebook_path", "path")
19
+
20
+
21
+ def blocked_reason(payload: dict[str, Any], allowed: Path) -> str | None:
22
+ """Return why a tool call must be blocked, or None to let it run."""
23
+ tool_input = payload.get("tool_input")
24
+ if not isinstance(tool_input, dict):
25
+ tool_input = {}
26
+ raw = next(
27
+ (
28
+ tool_input[key]
29
+ for key in _PATH_KEYS
30
+ if isinstance(tool_input.get(key), str) and tool_input[key]
31
+ ),
32
+ None,
33
+ )
34
+ if raw is None:
35
+ return (
36
+ "DevFlow: this session may only write files under "
37
+ f"{allowed}. The write has no file path, so it was blocked."
38
+ )
39
+ cwd = payload.get("cwd")
40
+ base = Path(cwd) if isinstance(cwd, str) and cwd else Path.cwd()
41
+ target = Path(raw)
42
+ if not target.is_absolute():
43
+ target = base / target
44
+ try:
45
+ target.resolve().relative_to(allowed.resolve())
46
+ except ValueError:
47
+ return (
48
+ f"DevFlow: this session may only write files under {allowed}. "
49
+ f"Writing {raw} was blocked. Do not create scripts or helper "
50
+ "files: DevFlow validates discovery.yaml and spec.md itself when "
51
+ "the session ends."
52
+ )
53
+ return None
54
+
55
+
56
+ def main(argv: list[str] | None = None) -> int:
57
+ args = sys.argv[1:] if argv is None else argv
58
+ if len(args) != 1:
59
+ print("usage: claude_guard <allowed-directory>", file=sys.stderr)
60
+ return BLOCKED_EXIT_CODE
61
+ try:
62
+ payload = json.load(sys.stdin)
63
+ except (OSError, ValueError):
64
+ print("DevFlow: unreadable hook input; write blocked.", file=sys.stderr)
65
+ return BLOCKED_EXIT_CODE
66
+ if not isinstance(payload, dict):
67
+ payload = {}
68
+ reason = blocked_reason(payload, Path(args[0]))
69
+ if reason is None:
70
+ return 0
71
+ print(reason, file=sys.stderr)
72
+ return BLOCKED_EXIT_CODE
73
+
74
+
75
+ if __name__ == "__main__":
76
+ raise SystemExit(main())
@@ -1,23 +1,22 @@
1
- # Discovery YAML Repair
1
+ # Discovery Record Repair
2
+
3
+ {{language_note}}
2
4
 
3
5
  You are repairing the DevFlow Discovery record `{{discovery_path}}`.
4
6
 
5
- DevFlow could not parse the file as valid YAML:
7
+ DevFlow could not accept the file:
6
8
 
7
9
  ```text
8
10
  {{error}}
9
11
  ```
10
12
 
11
- ## Language
12
-
13
- {{language_note}}
14
-
15
13
  ## Task
16
14
 
17
- Fix only the YAML syntax. Do not change the request, decisions, answers,
18
- categories, materiality, statuses, evidence, options or assumptions.
19
- Do not add, remove or re-scope a decision. Do not write or modify
20
- `spec.md` or any application source file.
15
+ Fix only what the error above describes: the YAML syntax or the invalid
16
+ field it names. Do not change the request or the meaning of any
17
+ decision, answer, evidence, option or assumption. Do not add, remove or
18
+ re-scope a decision. Do not write or modify `spec.md` or any application
19
+ source file.
21
20
 
22
21
  ## YAML Safety Rules
23
22
 
@@ -27,10 +26,12 @@ Do not add, remove or re-scope a decision. Do not write or modify
27
26
  - Use a block scalar (`|` or `>`) for long prose instead of leaving it
28
27
  unquoted.
29
28
  - Preserve the existing indentation, list structure and field names.
30
- - Re-read the complete file after editing and verify that every scalar
31
- and list item is valid YAML.
29
+ - Re-read the complete file after editing. Do not create scripts or run
30
+ commands to validate it: DevFlow validates the record when this
31
+ session ends.
32
32
  - Keep all text in the language already used by the record unless the
33
33
  task prompt asks for another language.
34
34
 
35
- When you finish, report that the file is valid YAML and list the lines
36
- you repaired. Do not generate a specification.
35
+ When you finish, list the lines you repaired and tell the user to exit
36
+ this session so DevFlow can validate the file. Do not generate a
37
+ specification.
@@ -273,9 +273,10 @@ it is a real improvement.
273
273
  multi-line value unquoted.
274
274
  - Keep one root mapping and preserve the existing indentation. Do not
275
275
  write duplicate keys.
276
- - Before finishing, re-read the complete `discovery.yaml` file and
277
- verify that it parses as YAML. Never leave a partially written or
278
- unquoted value in the file.
276
+ - Before finishing, re-read the complete `discovery.yaml` file. Never
277
+ leave a partially written or unquoted value in it. Do not create
278
+ scripts or run commands to validate it: DevFlow validates the record
279
+ when the session ends.
279
280
 
280
281
  Valid question categories are `functional_scope`, `user_behavior`,
281
282
  `data_persistence`, `security_authentication`,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.25
3
+ Version: 0.3.27
4
4
  Summary: Specification workflow toolkit for AI-assisted software changes
5
5
  Author: DevFlow contributors
6
6
  License-Expression: MIT
@@ -32,7 +32,7 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  # DevFlow Toolkit
34
34
 
35
- **Current version: `0.3.25`.**
35
+ **Current version: `0.3.27`.**
36
36
 
37
37
  DevFlow is a command-line toolkit for leading AI models and coding
38
38
  agents through specification-driven changes in real software projects.
@@ -152,7 +152,7 @@ pip install devflow-toolkit
152
152
  To install a specific built artifact instead:
153
153
 
154
154
  ```bash
155
- pip install devflow_toolkit-0.3.25-py3-none-any.whl
155
+ pip install devflow_toolkit-0.3.27-py3-none-any.whl
156
156
  ```
157
157
 
158
158
  Verify the installation:
@@ -317,8 +317,9 @@ explicitly.
317
317
 
318
318
  ### Local security checks
319
319
 
320
- `devflow init` offers tools that run locally on every commit, without
321
- tokens:
320
+ Semgrep, Bandit, pip-audit and gitleaks review code, so they belong to
321
+ implementation. DevFlow offers them once, right after the first
322
+ `devflow approve`, in an interactive terminal:
322
323
 
323
324
  - Semgrep, with rules for Django (or Python) and OWASP;
324
325
  - Bandit, for Python code;
@@ -326,9 +327,9 @@ tokens:
326
327
  - gitleaks, for secrets in the code.
327
328
 
328
329
  pre-commit (pre-commit.com) runs these tools automatically on every
329
- commit. In an interactive terminal `init` describes them and asks; use
330
- `--security-tools` to install them without asking, or
331
- `--no-security-tools` to skip the offer.
330
+ commit, without tokens. `devflow init --security-tools` installs them at
331
+ any time; `devflow init --no-security-tools` turns the offer off. The
332
+ answer is remembered in `.devflow/config.yaml` (`security.tools_offered`).
332
333
 
333
334
  Accepting writes a managed `.pre-commit-config.yaml` with pinned hook
334
335
  revisions, installs `pre-commit` with pip when it is missing and runs
@@ -339,6 +340,10 @@ hooks that apply are added: Bandit and pip-audit for Python projects,
339
340
  downloads the tools; `pre-commit run --all-files` checks the whole
340
341
  project.
341
342
 
343
+ When the checks are configured, `context.md` tells the specification
344
+ writer to record `pre-commit run --all-files` as a quality gate in
345
+ section 6.
346
+
342
347
  ## Configuration
343
348
 
344
349
  `.devflow/config.yaml` stores project settings. It references the
@@ -452,7 +457,7 @@ as an architectural constraint when it is present.
452
457
 
453
458
  ### Harnesses
454
459
 
455
- | Harness | Status in 0.3.25 |
460
+ | Harness | Status in 0.3.27 |
456
461
  | --- | --- |
457
462
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
458
463
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -546,6 +551,13 @@ pre-approved, while shell, web and task tools remain denied.
546
551
  Non-interactive runs keep the locked `dontAsk` mode and do not allow the
547
552
  question tool.
548
553
 
554
+ Manual mode would ask you about any other write, such as a helper
555
+ script in `/tmp`. To avoid that prompt, DevFlow also passes a
556
+ `PreToolUse` hook (`devflow.hooks.claude_guard`) that blocks every
557
+ `Write`, `Edit`, `MultiEdit` and `NotebookEdit` outside
558
+ `.devflow/specs/` without asking, and tells the agent why. The hook is
559
+ not added when `allow_source_code_changes` is enabled.
560
+
549
561
  ## Discovery
550
562
 
551
563
  Discovery is separate from specification. The project context decides
@@ -726,6 +738,17 @@ specification and asks you to run `devflow spec --continue`, which
726
738
  repairs the file first. When an agent lists questions in section 7,
727
739
  nested bullets stay part of the same question.
728
740
 
741
+ DevFlow corrects minor mistakes instead of starting a repair session,
742
+ and lists each correction as a warning and in `devflow status`: an
743
+ unknown category is read as the closest valid one (for example
744
+ `api_contract` as `functional_scope`, `security` as
745
+ `security_authentication`), an unknown materiality falls back to the
746
+ category default, and a user answer without `answered_by` or
747
+ `answered_at` is read as `user` at the record's `updated_at`. The
748
+ materiality the agent wrote is kept, so a `critical` decision can still
749
+ never be assumed. Unreadable YAML, answers on pending decisions and
750
+ assumed critical decisions still require a repair.
751
+
729
752
  DevFlow derives completeness from the decisions themselves: a record
730
753
  marked `complete` with pending questions is treated as
731
754
  `awaiting_clarification`, and a question written with
@@ -795,7 +818,7 @@ for each item; the agent does not write it.
795
818
  8. If artifacts exist without workflow state, diagnose with
796
819
  `devflow doctor <id>` and repair with `devflow recover <id>`.
797
820
 
798
- Available commands in `0.3.25`:
821
+ Available commands in `0.3.27`:
799
822
 
800
823
  | Command | Status |
801
824
  | --- | --- |
@@ -1028,7 +1051,7 @@ devflow approve 001
1028
1051
  ```
1029
1052
 
1030
1053
  Approval is explicit and binds the decision to the current artifact
1031
- digests. For a `0.3.25` change it binds `spec.md`, `discovery.yaml` and,
1054
+ digests. For a `0.3.27` change it binds `spec.md`, `discovery.yaml` and,
1032
1055
  when a manifest applies, the architecture manifest digest. Repeating the
1033
1056
  same approval is a no-op. If an artifact changes after validation,
1034
1057
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1039,7 +1062,7 @@ and names the pending questions and assumptions. Approval also rejects a
1039
1062
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1040
1063
  changes without `discovery.yaml` remain approvable with a warning.
1041
1064
 
1042
- Only the `spec` stage is available in `0.3.25`, so `--stage` is optional
1065
+ Only the `spec` stage is available in `0.3.27`, so `--stage` is optional
1043
1066
  and defaults to `spec`. `--stage plan` and `--stage review` are
1044
1067
  rejected. There are no `plan`, `implement` or
1045
1068
  `review` commands in this release.
@@ -1246,3 +1269,22 @@ The test suite covers the core, CLI, state replay and harness adapters.
1246
1269
  Release verification additionally installs the built wheel and sdist in
1247
1270
  clean virtual environments and runs the consumer workflow from outside
1248
1271
  the repository.
1272
+
1273
+ ## Acknowledgments
1274
+
1275
+ DevFlow is built on the shoulders of open-source work.
1276
+
1277
+ **[Typer](https://typer.tiangolo.com)**, by **Sebastián Ramírez
1278
+ ([@tiangolo](https://github.com/tiangolo))**, creator of FastAPI. Every
1279
+ DevFlow command, option and help screen is built with Typer. Thank you
1280
+ for making great command-line tools this simple to build.
1281
+
1282
+ - **[Rich](https://github.com/Textualize/rich)**, by Will McGugan, for
1283
+ the terminal output.
1284
+ - **[PyYAML](https://pyyaml.org)**, for the Discovery and workflow
1285
+ records.
1286
+ - **[pre-commit](https://pre-commit.com)**, by Anthony Sottile, and the
1287
+ Semgrep, Bandit, pip-audit and gitleaks projects, for the local
1288
+ security checks.
1289
+ - **[OWASP](https://owasp.org)**, for the security standards that guide
1290
+ DevFlow's security checks.
@@ -4,7 +4,7 @@ devflow/adapters/__init__.py,sha256=WcsjXQTKzHNzMAHx82-sdJQeR3ceHRVqLWTUtRlaraE,
4
4
  devflow/adapters/agents.py,sha256=OZnz7wAJNcIojtgaQIK1iB6QKWGgv2VCmoBp8M9DUKE,1423
5
5
  devflow/adapters/antigravity.py,sha256=tbhAWUNQt5fPemN_N8zEEdaBMPDRExpcXfF6obvvXvo,9124
6
6
  devflow/adapters/base.py,sha256=YggY_IwHExdybl5S9NjwZSlmmcw9Y6z7DhQsl3JLvXs,2055
7
- devflow/adapters/claude_code.py,sha256=El4wYuEgLMr4NAmZG58cVlpkSn_MCOAtQ7Qq2zFIOuI,3689
7
+ devflow/adapters/claude_code.py,sha256=Z43hjVFTcWh3OAGn2mVECpg425XCRptLZ_dyMoEhrtQ,4548
8
8
  devflow/adapters/codex.py,sha256=5EVBRlYg3ClYhvN1NmUfxhBrEURLryIZTpHQkyFtzx8,3616
9
9
  devflow/adapters/detector.py,sha256=92BkNAvWs2Vh8H6xJzMweBDCw6yuYVg7sV4LoSZ8KFo,3291
10
10
  devflow/adapters/instructions.py,sha256=AUje2tYnyI8yxnZQ5JlUjBON8Nz_yq4_yxpCz_DQoys,10885
@@ -12,29 +12,30 @@ devflow/adapters/kiro.py,sha256=1w9U8oP0i2un6YeiV5uOUQ8qrOYHiF1K-788iVqHzhA,7709
12
12
  devflow/adapters/opencode.py,sha256=AtIsgKam25Y3CjI4DlXqODQO_D74Cn_N-G02MIsBI44,8503
13
13
  devflow/adapters/registry.py,sha256=G1HquOcSggwT0qm8PIm_Fv5Wj354G20rnI0C7vPhrSo,1263
14
14
  devflow/commands/__init__.py,sha256=yOLtd_4R4xdlMgAzihzIT35oyV_qcz0br-aoLebRj1c,157
15
- devflow/commands/approve.py,sha256=twXcP_9OIlqgJlgiAeeB32yXa-hZjyB5unAox89UGQY,2782
15
+ devflow/commands/approve.py,sha256=-illY4CTzOo8fN7TfYNwq6K5ZkVMWDDJxBySe_hH6NU,3146
16
16
  devflow/commands/config.py,sha256=9EV3S_0j_OAokE2Hd1uhA3srBbTDSOInYcnULcHG3sM,1300
17
17
  devflow/commands/doctor.py,sha256=vYk2i3OksbGpHEUFsqi7c4w44mAXRmY0OeEdO8h5j_M,4161
18
18
  devflow/commands/harness.py,sha256=0IH_PPeYmW3aQ_WnUSkFzxpe3A4FtSyjWfHq-Ug7Eos,10549
19
- devflow/commands/init.py,sha256=yIA1r5_qbWod2WsglQBGb-vGcP8sFTji9niqABYxtSM,19143
19
+ devflow/commands/init.py,sha256=Yb2zd0lchqyvrPuywY5ELL-Cfp4SnGFv_N_93rJeMKE,17994
20
20
  devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
21
21
  devflow/commands/reopen.py,sha256=bZiX-dyKgmtdKdV4FHwEwRCFvuuX5jezBCI7wIpkHYU,2971
22
+ devflow/commands/security.py,sha256=lZlbMo34JHX46kBHRTSsZd4ANZ1mvxh6I-Nc6jNzuLI,2049
22
23
  devflow/commands/spec.py,sha256=7glxFHKuJd33mL6YayrxRJ6TViUmmQk5rijbNepsbig,16353
23
- devflow/commands/status.py,sha256=dLleIMLK39hRuQ3JdaUval70o0cIkMPKZOKTsNeML4Q,7407
24
+ devflow/commands/status.py,sha256=2rIPAZZnFvS3aAsHUNw8JaBrFq_l_8UGbURrKHIgXCo,7514
24
25
  devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
25
26
  devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
26
27
  devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
27
- devflow/core/config.py,sha256=VsR2ezH1toydLVyniy-BXtC843vDIstxI2-8vh4VmnU,26455
28
+ devflow/core/config.py,sha256=g_9ocRsrDLSsZZ5Sy1qlI7gi8WA2WlyiLUOZhcID2Ig,27065
28
29
  devflow/core/constitution.py,sha256=rPLc8Puv9nUMC_GZwzOqvr1B-4urdxAISr655od2IPM,5333
29
- devflow/core/discovery.py,sha256=drquy0yxRKblEEgnOBDNYkeyPKc2SXo6SIwQyZgDB2w,60337
30
+ devflow/core/discovery.py,sha256=YxCUvyfA0HLp2xEAI4frCks-5APNyTP0yBNCuVHDWZc,62649
30
31
  devflow/core/file_types.py,sha256=5S5YywOaTESDiln4kP7qyJFEjxHoiF6tSBbwuXNpDDc,566
31
32
  devflow/core/ports.py,sha256=6jlqeR40MNaz-IuZIAPimXpRKew-wMUab3KzelcTXsU,4541
32
33
  devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
33
34
  devflow/core/project.py,sha256=4OnudghY5N5rCOmafWO5Hk68M7T3-mOV0j0k0dh2luE,16891
34
35
  devflow/core/recovery.py,sha256=W2If6Ymb3ISwMN8IVQYCwptDUzhxejlF-P2NvMYyZP0,8818
35
36
  devflow/core/security_tools.py,sha256=F-JdGzycS-Vov_1SE5qciNVi31DqnnJXVqHqoDocSAA,8912
36
- devflow/core/spec_workflow.py,sha256=Ngma_-7MLsp96gNd2avVC81_SjWTAk4jscsQinmCml4,43961
37
- devflow/core/specification.py,sha256=6AhbWSFRyPEFwn_CIbyivujZ8-zlQBA610ZQxEUdKF4,69524
37
+ devflow/core/spec_workflow.py,sha256=CTBDdKX8EkfHfrhUpjXY1r3QYwN-w5Du9cjSiViIhZg,44034
38
+ devflow/core/specification.py,sha256=6b1-MRJjlPyzTwk5FzWCZJneAe0xy-xpnsmLZgMcA6Y,70036
38
39
  devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
39
40
  devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
40
41
  devflow/core/artifacts/models.py,sha256=xJjmY8jUAHxqYN9u1JEu8CbJB-IJg1xb9P-LDaP5_Hw,2049
@@ -47,6 +48,8 @@ devflow/core/state/lock.py,sha256=94llvwHtCc5WOw-Uq8kDCu4iOBpRM4ccp6Q6fLZpYZ0,20
47
48
  devflow/core/state/manager.py,sha256=o4Qo2C3pJOpOS6Id-NB4hNeKbvvoTDwbf6E2Jv_j-pE,31876
48
49
  devflow/core/state/models.py,sha256=4GTrS34ymbJIyBeZkcCi0z0e1bsq67vdxRSnSQ9O3gc,4654
49
50
  devflow/core/state/transitions.py,sha256=Go0zLhxcujWhaZEGg7JMqcC_UJU_nEFEBbpKIqrCtrs,3581
51
+ devflow/hooks/__init__.py,sha256=WM0gYOH-p2ZFvJhE351jkPi7wXKduskvj5Mw_LUQqnY,64
52
+ devflow/hooks/claude_guard.py,sha256=VL4KKVR-GNqFo8S2fmpsod65zXcZyFJ0IOus_pRWeQY,2325
50
53
  devflow/models/__init__.py,sha256=hXX3IDZbHgklmuzVVlpiRs5SSPnrkO5kN1-k2hIEk7E,156
51
54
  devflow/models/profile.py,sha256=j8KifeDQSN-wvzDJe1GGQQN9Vw7S2oncj75NNHpwpZs,2001
52
55
  devflow/models/project.py,sha256=fbxNk2db6Tsa8DXPzAFf8OqgbbY6gWJ7e07_kBO_QHw,973
@@ -61,11 +64,11 @@ devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOp
61
64
  devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
62
65
  devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
63
66
  devflow/prompts/__init__.py,sha256=DttfMavd0nfmhKkVE46VhpIHkGS-4amYfufABEM20xI,19120
64
- devflow/prompts/discovery-repair.md,sha256=YfTfrrw5uUZvC_x6X2lrYEDkMNhanhoe0ER3Yc2-rgI,1135
65
- devflow/prompts/discovery.md,sha256=4eApdy5QwT9nFeXpgMA4IfPaw5uCciZysOWKgpZ4vPM,14852
67
+ devflow/prompts/discovery-repair.md,sha256=hpw8pFaUC8OiHK_KTI2nMF45f77CqcFuDYzn9o6X5ao,1240
68
+ devflow/prompts/discovery.md,sha256=QDwfcjmb76yJH4DKMyoZ4QRtrdkDwljrWr3gn2MYCn8,14920
66
69
  devflow/prompts/spec.md,sha256=Kze_ZvE5yn0tfncvr98Nw6GQLEZlJmcZFWDNUpLMnlc,7689
67
- devflow_toolkit-0.3.25.dist-info/METADATA,sha256=l10VriUZ2uFgJ9sp7UO2GN-5OG3fmSwOIB_AAduncRQ,50944
68
- devflow_toolkit-0.3.25.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
69
- devflow_toolkit-0.3.25.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
70
- devflow_toolkit-0.3.25.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
71
- devflow_toolkit-0.3.25.dist-info/RECORD,,
70
+ devflow_toolkit-0.3.27.dist-info/METADATA,sha256=C5fdX_sRXh7QwCc1XDJG7fKAHRpknvIAzsx8cIB2gj0,53041
71
+ devflow_toolkit-0.3.27.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
72
+ devflow_toolkit-0.3.27.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
73
+ devflow_toolkit-0.3.27.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
74
+ devflow_toolkit-0.3.27.dist-info/RECORD,,