devflow-toolkit 0.3.25__py3-none-any.whl → 0.3.26__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.
@@ -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
+ )
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 (
@@ -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
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.25
3
+ Version: 0.3.26
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.26`.**
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.26-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.26 |
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 |
@@ -795,7 +800,7 @@ for each item; the agent does not write it.
795
800
  8. If artifacts exist without workflow state, diagnose with
796
801
  `devflow doctor <id>` and repair with `devflow recover <id>`.
797
802
 
798
- Available commands in `0.3.25`:
803
+ Available commands in `0.3.26`:
799
804
 
800
805
  | Command | Status |
801
806
  | --- | --- |
@@ -1028,7 +1033,7 @@ devflow approve 001
1028
1033
  ```
1029
1034
 
1030
1035
  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,
1036
+ digests. For a `0.3.26` change it binds `spec.md`, `discovery.yaml` and,
1032
1037
  when a manifest applies, the architecture manifest digest. Repeating the
1033
1038
  same approval is a no-op. If an artifact changes after validation,
1034
1039
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1039,7 +1044,7 @@ and names the pending questions and assumptions. Approval also rejects a
1039
1044
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1040
1045
  changes without `discovery.yaml` remain approvable with a warning.
1041
1046
 
1042
- Only the `spec` stage is available in `0.3.25`, so `--stage` is optional
1047
+ Only the `spec` stage is available in `0.3.26`, so `--stage` is optional
1043
1048
  and defaults to `spec`. `--stage plan` and `--stage review` are
1044
1049
  rejected. There are no `plan`, `implement` or
1045
1050
  `review` commands in this release.
@@ -1246,3 +1251,22 @@ The test suite covers the core, CLI, state replay and harness adapters.
1246
1251
  Release verification additionally installs the built wheel and sdist in
1247
1252
  clean virtual environments and runs the consumer workflow from outside
1248
1253
  the repository.
1254
+
1255
+ ## Acknowledgments
1256
+
1257
+ DevFlow is built on the shoulders of open-source work.
1258
+
1259
+ **[Typer](https://typer.tiangolo.com)**, by **Sebastián Ramírez
1260
+ ([@tiangolo](https://github.com/tiangolo))**, creator of FastAPI. Every
1261
+ DevFlow command, option and help screen is built with Typer. Thank you
1262
+ for making great command-line tools this simple to build.
1263
+
1264
+ - **[Rich](https://github.com/Textualize/rich)**, by Will McGugan, for
1265
+ the terminal output.
1266
+ - **[PyYAML](https://pyyaml.org)**, for the Discovery and workflow
1267
+ records.
1268
+ - **[pre-commit](https://pre-commit.com)**, by Anthony Sottile, and the
1269
+ Semgrep, Bandit, pip-audit and gitleaks projects, for the local
1270
+ security checks.
1271
+ - **[OWASP](https://owasp.org)**, for the security standards that guide
1272
+ DevFlow's security checks.
@@ -12,19 +12,20 @@ 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
24
  devflow/commands/status.py,sha256=dLleIMLK39hRuQ3JdaUval70o0cIkMPKZOKTsNeML4Q,7407
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
30
  devflow/core/discovery.py,sha256=drquy0yxRKblEEgnOBDNYkeyPKc2SXo6SIwQyZgDB2w,60337
30
31
  devflow/core/file_types.py,sha256=5S5YywOaTESDiln4kP7qyJFEjxHoiF6tSBbwuXNpDDc,566
@@ -34,7 +35,7 @@ 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
37
  devflow/core/spec_workflow.py,sha256=Ngma_-7MLsp96gNd2avVC81_SjWTAk4jscsQinmCml4,43961
37
- devflow/core/specification.py,sha256=6AhbWSFRyPEFwn_CIbyivujZ8-zlQBA610ZQxEUdKF4,69524
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
@@ -64,8 +65,8 @@ devflow/prompts/__init__.py,sha256=DttfMavd0nfmhKkVE46VhpIHkGS-4amYfufABEM20xI,1
64
65
  devflow/prompts/discovery-repair.md,sha256=YfTfrrw5uUZvC_x6X2lrYEDkMNhanhoe0ER3Yc2-rgI,1135
65
66
  devflow/prompts/discovery.md,sha256=4eApdy5QwT9nFeXpgMA4IfPaw5uCciZysOWKgpZ4vPM,14852
66
67
  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,,
68
+ devflow_toolkit-0.3.26.dist-info/METADATA,sha256=PKCGqkfPEz1q1SrvI1i81pwS4n4LXRCckNhh7xGfC_I,52023
69
+ devflow_toolkit-0.3.26.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
70
+ devflow_toolkit-0.3.26.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
71
+ devflow_toolkit-0.3.26.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
72
+ devflow_toolkit-0.3.26.dist-info/RECORD,,