devflow-toolkit 0.4.3__tar.gz → 0.4.4__tar.gz

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 (96) hide show
  1. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/CHANGELOG.md +86 -0
  2. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/PKG-INFO +71 -17
  3. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/README.md +1 -1
  4. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/docs/REFERENCE.md +70 -16
  5. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/antigravity.py +21 -7
  7. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/claude_code.py +27 -6
  8. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/instructions.py +3 -1
  9. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/kiro.py +21 -7
  10. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/opencode.py +55 -34
  11. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/approve.py +3 -2
  12. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/config.py +2 -1
  13. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/doctor.py +2 -1
  14. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/harness.py +3 -2
  15. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/init.py +4 -3
  16. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/recover.py +2 -1
  17. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/reopen.py +2 -1
  18. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/security.py +2 -1
  19. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/spec.py +70 -4
  20. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/status.py +30 -17
  21. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/artifacts/store.py +29 -3
  22. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/config.py +27 -1
  23. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/ports.py +9 -1
  24. devflow_toolkit-0.4.4/src/devflow/core/safe_files.py +36 -0
  25. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/security_tools.py +24 -7
  26. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/spec_workflow.py +211 -5
  27. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/specification.py +20 -3
  28. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/events.py +56 -7
  29. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/lock.py +5 -1
  30. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/manager.py +61 -1
  31. devflow_toolkit-0.4.4/src/devflow/core/state/signing.py +107 -0
  32. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/hooks/claude_guard.py +10 -1
  33. devflow_toolkit-0.4.4/tests/conftest.py +18 -0
  34. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_harness_adapters.py +39 -18
  35. devflow_toolkit-0.4.4/tests/test_security_fixes.py +682 -0
  36. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/.gitignore +0 -0
  37. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/LICENSE +0 -0
  38. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/docs/PRESENTATION.md +0 -0
  39. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/docs/PUBLISHING.md +0 -0
  40. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/__init__.py +0 -0
  41. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/__init__.py +0 -0
  42. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/agents.py +0 -0
  43. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/base.py +0 -0
  44. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/codex.py +0 -0
  45. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/detector.py +0 -0
  46. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/adapters/registry.py +0 -0
  47. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/cli.py +0 -0
  48. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/commands/__init__.py +0 -0
  49. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/__init__.py +0 -0
  50. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/architecture.py +0 -0
  51. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/artifacts/__init__.py +0 -0
  52. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/artifacts/errors.py +0 -0
  53. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/artifacts/models.py +0 -0
  54. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/clock.py +0 -0
  55. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/constitution.py +0 -0
  56. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/discovery.py +0 -0
  57. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/file_types.py +0 -0
  58. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/profile_manager.py +0 -0
  59. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/project.py +0 -0
  60. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/recovery.py +0 -0
  61. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/security_baseline.py +0 -0
  62. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/__init__.py +0 -0
  63. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/errors.py +0 -0
  64. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/locator.py +0 -0
  65. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/models.py +0 -0
  66. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/core/state/transitions.py +0 -0
  67. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/hooks/__init__.py +0 -0
  68. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/models/__init__.py +0 -0
  69. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/models/profile.py +0 -0
  70. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/models/project.py +0 -0
  71. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  72. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  73. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  74. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  75. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  76. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/base/profile.yaml +0 -0
  77. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  78. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  79. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  80. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  81. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/prompts/__init__.py +0 -0
  82. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/prompts/discovery-repair.md +0 -0
  83. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/prompts/discovery.md +0 -0
  84. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/src/devflow/prompts/spec.md +0 -0
  85. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_cli.py +0 -0
  86. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_discovery.py +0 -0
  87. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_discovery_decisions.py +0 -0
  88. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_event_log.py +0 -0
  89. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_greenfield.py +0 -0
  90. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_hardening.py +0 -0
  91. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_recovery.py +0 -0
  92. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_security_baseline.py +0 -0
  93. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_security_tools.py +0 -0
  94. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_spec_workflow.py +0 -0
  95. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_state.py +0 -0
  96. {devflow_toolkit-0.4.3 → devflow_toolkit-0.4.4}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,92 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.4.4 - 2026-11-30
6
+
7
+ ### Security
8
+
9
+ Fixes from a security audit of `src/`. They protect developers who run
10
+ DevFlow inside a cloned repository they do not control.
11
+
12
+ - Installing the security tools runs `pip` and `pre-commit` with
13
+ `python -P`, so a `pip/` or `pre_commit/` folder in the project can no
14
+ longer run its own code. The Claude Code write guard is launched the
15
+ same way, so a `devflow/` folder in the project cannot replace it.
16
+ - `agent.permissions.allow_source_code_changes` in `.devflow/config.yaml`
17
+ no longer takes effect on its own. `devflow spec` asks for
18
+ confirmation (default no), or needs the new `--allow-source-changes`
19
+ option; otherwise the agent may only write specifications.
20
+ - Permission warnings are printed before the agent starts, not after it
21
+ finishes.
22
+ - DevFlow never writes through a symbolic link in a change directory.
23
+ A `spec.md`, `context.md` or `workflow.yaml` link is replaced by a
24
+ regular file and its target is left untouched.
25
+ - `events.jsonl`, `.lock` and `.devflow/.specs.lock` are opened without
26
+ following symbolic links, so a link cannot make DevFlow create files
27
+ outside the project.
28
+ - Agents cannot change workflow state: Claude Code and OpenCode rules
29
+ deny writes to `events.jsonl`, `workflow.yaml` and `.lock`, the Claude
30
+ guard blocks them, and DevFlow restores any of those files that an
31
+ agent run changed.
32
+ - Suggested `devflow spec "<title>"` commands quote the title so that
33
+ pasting them cannot run `$(...)` or backtick commands.
34
+ - Approvals are signed with a per-user key kept outside the project
35
+ (`~/.config/devflow/approval.key`). An approval that was not made with
36
+ `devflow approve` on this machine, such as one written by an agent or
37
+ committed in a cloned repository, does not count, and `devflow status`
38
+ says so. Changing an approved spec and appending events to re-approve
39
+ it no longer works.
40
+ - `specifications.path` and `constitution.path` must be real
41
+ directories: a path through a symbolic link, the project root or
42
+ anything under `.git` is rejected, and the specifications directory
43
+ may not contain `config.yaml` or the constitution.
44
+ - A leftover `.devflow-agent-output.md` (for example a committed link)
45
+ is removed before Codex writes its answer, and DevFlow never reads
46
+ the output through a link.
47
+ - OpenCode agents start from a deny-all rule. Only reads (except `.env`
48
+ files), edits in the specifications directory and, in interactive
49
+ mode, questions are allowed; MCP tools, skills, shell, web, subagents
50
+ and paths outside the project are denied.
51
+ - Claude Code runs with `--setting-sources user --strict-mcp-config`, so
52
+ hooks, permissions and MCP servers committed in the project are not
53
+ loaded. Reads are limited to the project, `.env` files and MCP tools
54
+ are denied, and reads are no longer pre-approved outside the project.
55
+ - If `.opencode/agents/`, `.kiro/agents/` or `.agents/agents/` contains a
56
+ `devflow-spec` definition that DevFlow did not write, `devflow spec`
57
+ stops instead of starting the harness with it.
58
+ - Model listings run the harness from an empty temporary directory, so
59
+ `devflow init` and `devflow harness models` do not load the project's
60
+ harness configuration.
61
+ - When source changes are not allowed, DevFlow lists any project file
62
+ outside the specifications directory that the agent changed.
63
+ - An unmanaged `.pre-commit-config.yaml` is no longer activated with
64
+ `pre-commit install`; DevFlow only recognises its own file when the
65
+ marker is the first line, and ignores a linked one.
66
+ - Repository and agent text printed by `devflow status` and in warnings
67
+ and errors is escaped, so it cannot hide or restyle output, and labels
68
+ such as `[security, critical, blocking]` are shown again.
69
+ - Managed harness files no longer keep special, executable or
70
+ world-writable permission bits from the file they replace.
71
+
72
+ ### Upgrade notes
73
+
74
+ - Approvals made with `0.4.3` or earlier are unsigned. After upgrading,
75
+ those changes show as not approved; review them and run
76
+ `devflow approve <id>` again.
77
+ - Approvals are personal: an approval made by a teammate on another
78
+ machine does not count on yours.
79
+ - Projects whose `specifications.path` is `.`, under `.git` or a
80
+ symbolic link must move it to a real directory such as
81
+ `.devflow/specs`.
82
+
83
+ ### Package
84
+
85
+ - Package version is `0.4.4`.
86
+
87
+ ### Added
88
+
89
+ - `devflow spec --allow-source-changes`.
90
+
5
91
  ## 0.4.3 - 2026-11-10
6
92
 
7
93
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.4.3
3
+ Version: 0.4.4
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.4.3`.**
35
+ **Current version: `0.4.4`.**
36
36
 
37
37
  Before any code is written, you and the AI agree on what will be built
38
38
  and approve it as a spec. The agent then implements once, on something
@@ -210,7 +210,7 @@ pip install devflow-toolkit
210
210
  To install a specific built artifact instead:
211
211
 
212
212
  ```bash
213
- pip install devflow_toolkit-0.4.3-py3-none-any.whl
213
+ pip install devflow_toolkit-0.4.4-py3-none-any.whl
214
214
  ```
215
215
 
216
216
  Verify the installation:
@@ -394,7 +394,11 @@ revisions, installs `pre-commit` with pip when it is missing and runs
394
394
  `pre-commit install` when the project is a git repository. Only the
395
395
  hooks that apply are added: Bandit and pip-audit for Python projects,
396
396
  `p/django` rules for Django. An existing, unmanaged
397
- `.pre-commit-config.yaml` is never overwritten. The first commit
397
+ `.pre-commit-config.yaml` is never overwritten, and in that case DevFlow
398
+ does not run `pre-commit install`, so the project's own hooks are not
399
+ activated until you review them. `pip` and `pre-commit` run with
400
+ `python -P`, so Python never loads modules from the project directory.
401
+ The first commit
398
402
  downloads the tools; `pre-commit run --all-files` checks the whole
399
403
  project.
400
404
 
@@ -443,6 +447,18 @@ reinitializing the project.
443
447
  `constitution.files` accepts plain file names inside the constitution
444
448
  directory. Absolute paths, `..` and nested paths are rejected.
445
449
 
450
+ `specifications.path` and `constitution.path` must be real directories
451
+ inside the project: a path that goes through a symbolic link, the
452
+ project root itself or anything under `.git` is rejected. The
453
+ specifications directory must not contain `config.yaml` or the
454
+ constitution, because agents may write there.
455
+
456
+ `agent.permissions.allow_source_code_changes: true` in a committed
457
+ `config.yaml` is not enough on its own. `devflow spec` asks you to
458
+ confirm it before the agent starts (the default answer is no), or you
459
+ pass `--allow-source-changes`. Without confirmation the run is limited
460
+ to specifications.
461
+
446
462
  Existing configurations without `project.mode` load as `existing`.
447
463
 
448
464
  ## Declared architecture
@@ -511,7 +527,7 @@ as an architectural constraint when it is present.
511
527
 
512
528
  ### Harnesses
513
529
 
514
- | Harness | Status in 0.4.3 |
530
+ | Harness | Status in 0.4.4 |
515
531
  | --- | --- |
516
532
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
517
533
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -587,21 +603,48 @@ DevFlow did not create are never added. DevFlow does not ignore
587
603
 
588
604
  `allow_workflow_write` controls writes to DevFlow artifacts.
589
605
  `allow_spec_write` is accepted as a compatibility alias.
590
- `allow_source_code_changes` is disabled by default.
606
+ `allow_source_code_changes` is disabled by default and, when a project
607
+ enables it, needs your confirmation or `--allow-source-changes` on each
608
+ `devflow spec` run.
591
609
 
592
610
  DevFlow translates these settings into technical controls where the
593
- harness exposes them. For OpenCode, the generated agents deny `edit`
594
- outside `.devflow/specs/`, deny shell execution unless source changes are
595
- explicitly allowed, and disable web access and subagents. Prompt text is
596
- not treated as the only permission boundary.
611
+ harness exposes them. For OpenCode, the generated agents start with a
612
+ rule that denies every action, then allow reads, `glob` and `grep`
613
+ (except `.env` files), edits under the specifications directory, and
614
+ the `question` tool in interactive mode. Shell, web access, subagents,
615
+ MCP tools, skills and paths outside the project stay denied unless source
616
+ changes are explicitly allowed. Prompt text is not treated as the only
617
+ permission boundary.
618
+
619
+ Workflow state is never writable by agents. Claude Code and OpenCode
620
+ deny writes to `events.jsonl`, `workflow.yaml` and `.lock`, and after
621
+ every agent run DevFlow restores any of those files that changed and
622
+ warns. When source changes are not allowed, DevFlow also lists any
623
+ project file outside the specifications directory that the agent
624
+ changed, so you can review it with `git diff`.
625
+
626
+ If `.opencode/agents/`, `.kiro/agents/` or `.agents/agents/` already
627
+ contains a `devflow-spec` or `devflow-spec-readonly` definition that
628
+ DevFlow did not write, `devflow spec` stops instead of running the
629
+ harness with it. Review the file and delete it so DevFlow can recreate
630
+ it. Model listings (`devflow harness models`, `init`, `harness use`) run
631
+ the harness from an empty temporary directory, so it does not load the
632
+ project's own configuration.
633
+
634
+ Permission warnings are printed before the agent starts.
597
635
 
598
636
  When a harness cannot enforce a restriction technically, DevFlow prints
599
637
  a warning instead of claiming that the restriction is guaranteed.
600
638
 
601
639
  For Claude Code, interactive runs use Manual mode
602
640
  (`--permission-mode manual`) so Discovery can open the
603
- `AskUserQuestion` dialog. Reads and writes under `.devflow/specs/` are
604
- pre-approved, while shell, web and task tools remain denied.
641
+ `AskUserQuestion` dialog. Writes under `.devflow/specs/` are
642
+ pre-approved, while shell, web, task and MCP tools remain denied. Reads
643
+ are limited to the project (`blockReadsOutsideWorkingDirectories`) and
644
+ `.env` files are denied. DevFlow starts Claude Code with
645
+ `--setting-sources user --strict-mcp-config`, so hooks, permissions and
646
+ MCP servers committed in the project's `.claude/` or `.mcp.json` are not
647
+ loaded.
605
648
  Non-interactive runs keep the locked `dontAsk` mode and do not allow the
606
649
  question tool.
607
650
 
@@ -609,8 +652,10 @@ Manual mode would ask you about any other write, such as a helper
609
652
  script in `/tmp`. To avoid that prompt, DevFlow also passes a
610
653
  `PreToolUse` hook (`devflow.hooks.claude_guard`) that blocks every
611
654
  `Write`, `Edit`, `MultiEdit` and `NotebookEdit` outside
612
- `.devflow/specs/` without asking, and tells the agent why. The hook is
613
- not added when `allow_source_code_changes` is enabled.
655
+ `.devflow/specs/`, and any write to `events.jsonl`, `workflow.yaml` or
656
+ `.lock`, without asking, and tells the agent why. The hook runs with
657
+ `python -P`, so a `devflow/` folder in the project cannot replace it.
658
+ The hook is not added when `allow_source_code_changes` is enabled.
614
659
 
615
660
  ## Discovery
616
661
 
@@ -939,7 +984,7 @@ reference.
939
984
  8. If artifacts exist without workflow state, diagnose with
940
985
  `devflow doctor <id>` and repair with `devflow recover <id>`.
941
986
 
942
- Available commands in `0.4.3`:
987
+ Available commands in `0.4.4`:
943
988
 
944
989
  | Command | Status |
945
990
  | --- | --- |
@@ -1172,18 +1217,27 @@ devflow approve 001
1172
1217
  ```
1173
1218
 
1174
1219
  Approval is explicit and binds the decision to the current artifact
1175
- digests. For a `0.4.3` change it binds `spec.md`, `discovery.yaml` and,
1220
+ digests. For a `0.4.4` change it binds `spec.md`, `discovery.yaml` and,
1176
1221
  when a manifest applies, the architecture manifest digest. Repeating the
1177
1222
  same approval is a no-op. If an artifact changes after validation,
1178
1223
  DevFlow marks it stale and refuses approval until it is regenerated and
1179
1224
  validated again.
1180
1225
 
1226
+ Each approval is signed with a key that DevFlow keeps outside the
1227
+ project, in `~/.config/devflow/approval.key` (or
1228
+ `$XDG_CONFIG_HOME/devflow/approval.key`). An approval only counts when
1229
+ it was made with `devflow approve` on your machine: an approval written
1230
+ by an agent, copied from another change or committed by someone else is
1231
+ ignored, and `devflow status` asks you to review the change and approve
1232
+ it yourself. Approvals made with DevFlow `0.4.3` or earlier are not
1233
+ signed, so approve those changes again after upgrading.
1234
+
1181
1235
  Discovery must be complete before approval. If it is not, approval fails
1182
1236
  and names the pending questions and assumptions. Approval also rejects a
1183
1237
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1184
1238
  changes without `discovery.yaml` remain approvable with a warning.
1185
1239
 
1186
- Only the `spec` stage is available in `0.4.3`, so `--stage` is optional
1240
+ Only the `spec` stage is available in `0.4.4`, so `--stage` is optional
1187
1241
  and defaults to `spec`. `--stage plan` and `--stage review` are
1188
1242
  rejected. There are no `plan`, `implement` or
1189
1243
  `review` commands in this release.
@@ -32,7 +32,7 @@ tokens, which cost several times more than input tokens.
32
32
  The goal is not to generate code faster, but to decide better before
33
33
  generating it. Thinking is cheap; redoing code is expensive.
34
34
 
35
- Current version: `0.4.3` · Python 3.11+ · Linux and macOS
35
+ Current version: `0.4.4` · Python 3.11+ · Linux and macOS
36
36
 
37
37
  ## Install
38
38
 
@@ -1,6 +1,6 @@
1
1
  # DevFlow Toolkit
2
2
 
3
- **Current version: `0.4.3`.**
3
+ **Current version: `0.4.4`.**
4
4
 
5
5
  Before any code is written, you and the AI agree on what will be built
6
6
  and approve it as a spec. The agent then implements once, on something
@@ -178,7 +178,7 @@ pip install devflow-toolkit
178
178
  To install a specific built artifact instead:
179
179
 
180
180
  ```bash
181
- pip install devflow_toolkit-0.4.3-py3-none-any.whl
181
+ pip install devflow_toolkit-0.4.4-py3-none-any.whl
182
182
  ```
183
183
 
184
184
  Verify the installation:
@@ -362,7 +362,11 @@ revisions, installs `pre-commit` with pip when it is missing and runs
362
362
  `pre-commit install` when the project is a git repository. Only the
363
363
  hooks that apply are added: Bandit and pip-audit for Python projects,
364
364
  `p/django` rules for Django. An existing, unmanaged
365
- `.pre-commit-config.yaml` is never overwritten. The first commit
365
+ `.pre-commit-config.yaml` is never overwritten, and in that case DevFlow
366
+ does not run `pre-commit install`, so the project's own hooks are not
367
+ activated until you review them. `pip` and `pre-commit` run with
368
+ `python -P`, so Python never loads modules from the project directory.
369
+ The first commit
366
370
  downloads the tools; `pre-commit run --all-files` checks the whole
367
371
  project.
368
372
 
@@ -411,6 +415,18 @@ reinitializing the project.
411
415
  `constitution.files` accepts plain file names inside the constitution
412
416
  directory. Absolute paths, `..` and nested paths are rejected.
413
417
 
418
+ `specifications.path` and `constitution.path` must be real directories
419
+ inside the project: a path that goes through a symbolic link, the
420
+ project root itself or anything under `.git` is rejected. The
421
+ specifications directory must not contain `config.yaml` or the
422
+ constitution, because agents may write there.
423
+
424
+ `agent.permissions.allow_source_code_changes: true` in a committed
425
+ `config.yaml` is not enough on its own. `devflow spec` asks you to
426
+ confirm it before the agent starts (the default answer is no), or you
427
+ pass `--allow-source-changes`. Without confirmation the run is limited
428
+ to specifications.
429
+
414
430
  Existing configurations without `project.mode` load as `existing`.
415
431
 
416
432
  ## Declared architecture
@@ -479,7 +495,7 @@ as an architectural constraint when it is present.
479
495
 
480
496
  ### Harnesses
481
497
 
482
- | Harness | Status in 0.4.3 |
498
+ | Harness | Status in 0.4.4 |
483
499
  | --- | --- |
484
500
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
485
501
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -555,21 +571,48 @@ DevFlow did not create are never added. DevFlow does not ignore
555
571
 
556
572
  `allow_workflow_write` controls writes to DevFlow artifacts.
557
573
  `allow_spec_write` is accepted as a compatibility alias.
558
- `allow_source_code_changes` is disabled by default.
574
+ `allow_source_code_changes` is disabled by default and, when a project
575
+ enables it, needs your confirmation or `--allow-source-changes` on each
576
+ `devflow spec` run.
559
577
 
560
578
  DevFlow translates these settings into technical controls where the
561
- harness exposes them. For OpenCode, the generated agents deny `edit`
562
- outside `.devflow/specs/`, deny shell execution unless source changes are
563
- explicitly allowed, and disable web access and subagents. Prompt text is
564
- not treated as the only permission boundary.
579
+ harness exposes them. For OpenCode, the generated agents start with a
580
+ rule that denies every action, then allow reads, `glob` and `grep`
581
+ (except `.env` files), edits under the specifications directory, and
582
+ the `question` tool in interactive mode. Shell, web access, subagents,
583
+ MCP tools, skills and paths outside the project stay denied unless source
584
+ changes are explicitly allowed. Prompt text is not treated as the only
585
+ permission boundary.
586
+
587
+ Workflow state is never writable by agents. Claude Code and OpenCode
588
+ deny writes to `events.jsonl`, `workflow.yaml` and `.lock`, and after
589
+ every agent run DevFlow restores any of those files that changed and
590
+ warns. When source changes are not allowed, DevFlow also lists any
591
+ project file outside the specifications directory that the agent
592
+ changed, so you can review it with `git diff`.
593
+
594
+ If `.opencode/agents/`, `.kiro/agents/` or `.agents/agents/` already
595
+ contains a `devflow-spec` or `devflow-spec-readonly` definition that
596
+ DevFlow did not write, `devflow spec` stops instead of running the
597
+ harness with it. Review the file and delete it so DevFlow can recreate
598
+ it. Model listings (`devflow harness models`, `init`, `harness use`) run
599
+ the harness from an empty temporary directory, so it does not load the
600
+ project's own configuration.
601
+
602
+ Permission warnings are printed before the agent starts.
565
603
 
566
604
  When a harness cannot enforce a restriction technically, DevFlow prints
567
605
  a warning instead of claiming that the restriction is guaranteed.
568
606
 
569
607
  For Claude Code, interactive runs use Manual mode
570
608
  (`--permission-mode manual`) so Discovery can open the
571
- `AskUserQuestion` dialog. Reads and writes under `.devflow/specs/` are
572
- pre-approved, while shell, web and task tools remain denied.
609
+ `AskUserQuestion` dialog. Writes under `.devflow/specs/` are
610
+ pre-approved, while shell, web, task and MCP tools remain denied. Reads
611
+ are limited to the project (`blockReadsOutsideWorkingDirectories`) and
612
+ `.env` files are denied. DevFlow starts Claude Code with
613
+ `--setting-sources user --strict-mcp-config`, so hooks, permissions and
614
+ MCP servers committed in the project's `.claude/` or `.mcp.json` are not
615
+ loaded.
573
616
  Non-interactive runs keep the locked `dontAsk` mode and do not allow the
574
617
  question tool.
575
618
 
@@ -577,8 +620,10 @@ Manual mode would ask you about any other write, such as a helper
577
620
  script in `/tmp`. To avoid that prompt, DevFlow also passes a
578
621
  `PreToolUse` hook (`devflow.hooks.claude_guard`) that blocks every
579
622
  `Write`, `Edit`, `MultiEdit` and `NotebookEdit` outside
580
- `.devflow/specs/` without asking, and tells the agent why. The hook is
581
- not added when `allow_source_code_changes` is enabled.
623
+ `.devflow/specs/`, and any write to `events.jsonl`, `workflow.yaml` or
624
+ `.lock`, without asking, and tells the agent why. The hook runs with
625
+ `python -P`, so a `devflow/` folder in the project cannot replace it.
626
+ The hook is not added when `allow_source_code_changes` is enabled.
582
627
 
583
628
  ## Discovery
584
629
 
@@ -907,7 +952,7 @@ reference.
907
952
  8. If artifacts exist without workflow state, diagnose with
908
953
  `devflow doctor <id>` and repair with `devflow recover <id>`.
909
954
 
910
- Available commands in `0.4.3`:
955
+ Available commands in `0.4.4`:
911
956
 
912
957
  | Command | Status |
913
958
  | --- | --- |
@@ -1140,18 +1185,27 @@ devflow approve 001
1140
1185
  ```
1141
1186
 
1142
1187
  Approval is explicit and binds the decision to the current artifact
1143
- digests. For a `0.4.3` change it binds `spec.md`, `discovery.yaml` and,
1188
+ digests. For a `0.4.4` change it binds `spec.md`, `discovery.yaml` and,
1144
1189
  when a manifest applies, the architecture manifest digest. Repeating the
1145
1190
  same approval is a no-op. If an artifact changes after validation,
1146
1191
  DevFlow marks it stale and refuses approval until it is regenerated and
1147
1192
  validated again.
1148
1193
 
1194
+ Each approval is signed with a key that DevFlow keeps outside the
1195
+ project, in `~/.config/devflow/approval.key` (or
1196
+ `$XDG_CONFIG_HOME/devflow/approval.key`). An approval only counts when
1197
+ it was made with `devflow approve` on your machine: an approval written
1198
+ by an agent, copied from another change or committed by someone else is
1199
+ ignored, and `devflow status` asks you to review the change and approve
1200
+ it yourself. Approvals made with DevFlow `0.4.3` or earlier are not
1201
+ signed, so approve those changes again after upgrading.
1202
+
1149
1203
  Discovery must be complete before approval. If it is not, approval fails
1150
1204
  and names the pending questions and assumptions. Approval also rejects a
1151
1205
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1152
1206
  changes without `discovery.yaml` remain approvable with a warning.
1153
1207
 
1154
- Only the `spec` stage is available in `0.4.3`, so `--stage` is optional
1208
+ Only the `spec` stage is available in `0.4.4`, so `--stage` is optional
1155
1209
  and defaults to `spec`. `--stage plan` and `--stage review` are
1156
1210
  rejected. There are no `plan`, `implement` or
1157
1211
  `review` commands in this release.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.4.3"
7
+ version = "0.4.4"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "docs/REFERENCE.md"
10
10
  license = "MIT"
@@ -3,7 +3,9 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import os
6
7
  import subprocess
8
+ import tempfile
7
9
  from pathlib import Path
8
10
  from typing import Any
9
11
 
@@ -39,6 +41,10 @@ class AntigravityAdapter(HarnessAdapter):
39
41
  name = "antigravity"
40
42
  display_name = "Antigravity"
41
43
  executable = "agy"
44
+ agent_definition_files = (
45
+ f".agents/agents/{INTERACTIVE_AGENT}.md",
46
+ f".agents/agents/{READONLY_AGENT}.md",
47
+ )
42
48
 
43
49
  def setup(self, context: SetupContext) -> SetupResult:
44
50
  changes: list[FileChange] = []
@@ -157,14 +163,22 @@ class AntigravityAdapter(HarnessAdapter):
157
163
 
158
164
  def list_models(self) -> tuple[ModelOption, ...]:
159
165
  """Return models reported by ``agy models``."""
166
+ if not self.is_available():
167
+ return ()
160
168
  try:
161
- result = subprocess.run( # noqa: S603
162
- [self.executable, "models"],
163
- capture_output=True,
164
- text=True,
165
- timeout=30,
166
- check=False,
167
- )
169
+ # Run outside the project so the harness does not load the
170
+ # repository's own configuration, plugins or MCP servers.
171
+ with tempfile.TemporaryDirectory() as neutral:
172
+ result = subprocess.run( # noqa: S603
173
+ [self.executable, "models"],
174
+ capture_output=True,
175
+ text=True,
176
+ timeout=30,
177
+ check=False,
178
+ cwd=neutral,
179
+ # OpenCode resolves the project from PWD, not the cwd.
180
+ env={**os.environ, "PWD": neutral},
181
+ )
168
182
  except (OSError, subprocess.SubprocessError):
169
183
  return ()
170
184
  if result.returncode != 0:
@@ -19,6 +19,7 @@ from devflow.adapters.instructions import (
19
19
  write_gitignore_entries,
20
20
  write_text_managed,
21
21
  )
22
+ from devflow.core.safe_files import WORKFLOW_STATE_FILES
22
23
 
23
24
 
24
25
  class ClaudeCodeAdapter(HarnessAdapter):
@@ -65,11 +66,16 @@ class ClaudeCodeAdapter(HarnessAdapter):
65
66
  "manual" if context.mode == "interactive" else "dontAsk"
66
67
  )
67
68
  model = ("--model", context.model) if context.model else ()
69
+ # Load only the user's own settings and no MCP servers: hooks,
70
+ # permissions and MCP servers committed in the project's .claude/ or
71
+ # .mcp.json must not run with DevFlow's agent session.
72
+ isolation = ("--setting-sources", "user", "--strict-mcp-config")
68
73
 
69
74
  if context.mode == "interactive":
70
75
  argv = (
71
76
  self.executable,
72
77
  *model,
78
+ *isolation,
73
79
  "--permission-mode",
74
80
  permission_mode,
75
81
  "--settings",
@@ -85,6 +91,7 @@ class ClaudeCodeAdapter(HarnessAdapter):
85
91
  self.executable,
86
92
  "-p",
87
93
  *model,
94
+ *isolation,
88
95
  "--output-format",
89
96
  "text",
90
97
  "--permission-mode",
@@ -125,9 +132,12 @@ class ClaudeCodeAdapter(HarnessAdapter):
125
132
  ):
126
133
  return {}
127
134
  allowed = context.spec_directory.parent
135
+ # Claude Code runs the hook from the project directory; `-P` keeps a
136
+ # `devflow/` package in an untrusted project from replacing the guard.
128
137
  command = " ".join(
129
138
  [
130
139
  shlex.quote(sys.executable),
140
+ "-P",
131
141
  "-m",
132
142
  "devflow.hooks.claude_guard",
133
143
  shlex.quote(str(allowed)),
@@ -145,12 +155,11 @@ class ClaudeCodeAdapter(HarnessAdapter):
145
155
  def _permission_rules(
146
156
  self,
147
157
  context: RunContext,
148
- ) -> dict[str, list[str]]:
158
+ ) -> dict[str, object]:
159
+ # Reads inside the project need no rule. A bare "Read" allow would
160
+ # also pre-approve reads anywhere on disk, so none is added.
149
161
  allow: list[str] = []
150
- deny: list[str] = []
151
-
152
- if context.permissions.allow_project_read:
153
- allow.extend(["Read", "Grep", "Glob"])
162
+ deny: list[str] = ["mcp__*", "Read(./**/.env)", "Read(./**/.env.*)"]
154
163
 
155
164
  if context.permissions.allow_source_code_changes:
156
165
  allow.extend(["Edit", "Write", "Bash"])
@@ -163,7 +172,19 @@ class ClaudeCodeAdapter(HarnessAdapter):
163
172
  )
164
173
 
165
174
  deny.extend(["WebFetch", "WebSearch", "Task"])
175
+ for name in WORKFLOW_STATE_FILES:
176
+ deny.extend(
177
+ [
178
+ f"Edit(.devflow/specs/**/{name})",
179
+ f"Write(.devflow/specs/**/{name})",
180
+ ]
181
+ )
166
182
  if not context.permissions.allow_source_code_changes:
167
183
  deny.extend(["Bash", "NotebookEdit"])
168
184
 
169
- return {"allow": allow, "deny": deny}
185
+ return {
186
+ "allow": allow,
187
+ "deny": deny,
188
+ "blockReadsOutsideWorkingDirectories": True,
189
+ "blockWritesOutsideWorkingDirectories": True,
190
+ }
@@ -76,7 +76,9 @@ def _write_atomic(path: Path, content: str) -> None:
76
76
 
77
77
  mode = 0o644
78
78
  try:
79
- mode = stat.S_IMODE(path.stat().st_mode)
79
+ # Keep the owner's read/write choice, but never carry over special,
80
+ # executable or world-writable bits from the file being replaced.
81
+ mode = stat.S_IMODE(path.stat().st_mode) & 0o664
80
82
  except OSError:
81
83
  pass
82
84
  os.chmod(temporary, mode)
@@ -2,7 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import os
5
6
  import subprocess
7
+ import tempfile
6
8
 
7
9
  from devflow.adapters.base import (
8
10
  FileChange,
@@ -31,6 +33,10 @@ class KiroAdapter(HarnessAdapter):
31
33
  name = "kiro"
32
34
  display_name = "Kiro"
33
35
  executable = "kiro-cli"
36
+ agent_definition_files = (
37
+ f".kiro/agents/{INTERACTIVE_AGENT}.json",
38
+ f".kiro/agents/{READONLY_AGENT}.json",
39
+ )
34
40
 
35
41
  def setup(self, context: SetupContext) -> SetupResult:
36
42
  changes: list[FileChange] = []
@@ -154,14 +160,22 @@ class KiroAdapter(HarnessAdapter):
154
160
 
155
161
  def list_models(self) -> tuple[ModelOption, ...]:
156
162
  """Return models reported by ``kiro-cli chat --list-models``."""
163
+ if not self.is_available():
164
+ return ()
157
165
  try:
158
- result = subprocess.run( # noqa: S603
159
- [self.executable, "chat", "--list-models"],
160
- capture_output=True,
161
- text=True,
162
- timeout=30,
163
- check=False,
164
- )
166
+ # Run outside the project so the harness does not load the
167
+ # repository's own configuration, plugins or MCP servers.
168
+ with tempfile.TemporaryDirectory() as neutral:
169
+ result = subprocess.run( # noqa: S603
170
+ [self.executable, "chat", "--list-models"],
171
+ capture_output=True,
172
+ text=True,
173
+ timeout=30,
174
+ check=False,
175
+ cwd=neutral,
176
+ # OpenCode resolves the project from PWD, not the cwd.
177
+ env={**os.environ, "PWD": neutral},
178
+ )
165
179
  except (OSError, subprocess.SubprocessError):
166
180
  return ()
167
181
  if result.returncode != 0: