devflow-toolkit 0.4.4__tar.gz → 0.4.5__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.4 → devflow_toolkit-0.4.5}/CHANGELOG.md +24 -1
  2. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/PKG-INFO +24 -13
  3. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/README.md +6 -5
  4. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/docs/REFERENCE.md +23 -12
  5. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/reopen.py +61 -24
  7. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/spec.py +7 -0
  8. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/manager.py +70 -31
  9. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/prompts/__init__.py +6 -2
  10. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_security_fixes.py +69 -0
  11. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_state.py +1 -1
  12. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/.gitignore +0 -0
  13. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/LICENSE +0 -0
  14. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/docs/PRESENTATION.md +0 -0
  15. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/docs/PUBLISHING.md +0 -0
  16. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/__init__.py +0 -0
  17. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/__init__.py +0 -0
  18. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/agents.py +0 -0
  19. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/antigravity.py +0 -0
  20. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/base.py +0 -0
  21. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/claude_code.py +0 -0
  22. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/codex.py +0 -0
  23. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/detector.py +0 -0
  24. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/instructions.py +0 -0
  25. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/kiro.py +0 -0
  26. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/opencode.py +0 -0
  27. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/adapters/registry.py +0 -0
  28. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/cli.py +0 -0
  29. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/__init__.py +0 -0
  30. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/approve.py +0 -0
  31. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/config.py +0 -0
  32. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/doctor.py +0 -0
  33. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/harness.py +0 -0
  34. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/init.py +0 -0
  35. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/recover.py +0 -0
  36. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/security.py +0 -0
  37. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/commands/status.py +0 -0
  38. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/__init__.py +0 -0
  39. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/architecture.py +0 -0
  40. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/artifacts/__init__.py +0 -0
  41. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/artifacts/errors.py +0 -0
  42. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/artifacts/models.py +0 -0
  43. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/artifacts/store.py +0 -0
  44. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/clock.py +0 -0
  45. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/config.py +0 -0
  46. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/constitution.py +0 -0
  47. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/discovery.py +0 -0
  48. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/file_types.py +0 -0
  49. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/ports.py +0 -0
  50. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/profile_manager.py +0 -0
  51. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/project.py +0 -0
  52. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/recovery.py +0 -0
  53. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/safe_files.py +0 -0
  54. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/security_baseline.py +0 -0
  55. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/security_tools.py +0 -0
  56. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/spec_workflow.py +0 -0
  57. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/specification.py +0 -0
  58. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/__init__.py +0 -0
  59. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/errors.py +0 -0
  60. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/events.py +0 -0
  61. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/locator.py +0 -0
  62. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/lock.py +0 -0
  63. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/models.py +0 -0
  64. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/signing.py +0 -0
  65. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/core/state/transitions.py +0 -0
  66. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/hooks/__init__.py +0 -0
  67. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/hooks/claude_guard.py +0 -0
  68. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/models/__init__.py +0 -0
  69. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/models/profile.py +0 -0
  70. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/models/project.py +0 -0
  71. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  72. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  73. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  74. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  75. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  76. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/base/profile.yaml +0 -0
  77. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  78. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  79. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  80. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  81. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/prompts/discovery-repair.md +0 -0
  82. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/prompts/discovery.md +0 -0
  83. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/src/devflow/prompts/spec.md +0 -0
  84. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/conftest.py +0 -0
  85. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_cli.py +0 -0
  86. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_discovery.py +0 -0
  87. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_discovery_decisions.py +0 -0
  88. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_event_log.py +0 -0
  89. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_greenfield.py +0 -0
  90. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_hardening.py +0 -0
  91. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_harness_adapters.py +0 -0
  92. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_recovery.py +0 -0
  93. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_security_baseline.py +0 -0
  94. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_security_tools.py +0 -0
  95. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_spec_workflow.py +0 -0
  96. {devflow_toolkit-0.4.4 → devflow_toolkit-0.4.5}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,29 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.4.5 - 2026-11-30
6
+
7
+ ### Changed
8
+
9
+ - `devflow reopen` is clearer when you want to extend a specification:
10
+ - New `--add "what to add"`: records the new scope in Discovery and
11
+ reopens it, so the agent asks only about the new decisions and then
12
+ writes the extended spec. It implies `--discovery`.
13
+ - `--discovery` and `--add` work on a change that is not approved yet;
14
+ before, they failed with "nothing to reopen".
15
+ - The confirmation matches the state: it asks to withdraw the approval
16
+ only when there is one, and to reopen Discovery otherwise.
17
+ - A plain `reopen` on a change that is not approved explains that it is
18
+ already open and how to extend it.
19
+ - When `devflow spec --continue` finds the spec unchanged, it explains
20
+ how to extend it with `devflow reopen <id> --add`.
21
+ - The reopened-Discovery prompt starts from the added scope and keeps the
22
+ decisions already answered.
23
+
24
+ ### Package
25
+
26
+ - Package version is `0.4.5`.
27
+
5
28
  ## 0.4.4 - 2026-11-30
6
29
 
7
30
  ### Security
@@ -82,7 +105,7 @@ DevFlow inside a cloned repository they do not control.
82
105
 
83
106
  ### Package
84
107
 
85
- - Package version is `0.4.4`.
108
+ - Package version is `0.4.4`, published on TestPyPI and PyPI.
86
109
 
87
110
  ### Added
88
111
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.4.4
3
+ Version: 0.4.5
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.4`.**
35
+ **Current version: `0.4.5`.**
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.4-py3-none-any.whl
213
+ pip install devflow_toolkit-0.4.5-py3-none-any.whl
214
214
  ```
215
215
 
216
216
  Verify the installation:
@@ -527,7 +527,7 @@ as an architectural constraint when it is present.
527
527
 
528
528
  ### Harnesses
529
529
 
530
- | Harness | Status in 0.4.4 |
530
+ | Harness | Status in 0.4.5 |
531
531
  | --- | --- |
532
532
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
533
533
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -984,14 +984,14 @@ reference.
984
984
  8. If artifacts exist without workflow state, diagnose with
985
985
  `devflow doctor <id>` and repair with `devflow recover <id>`.
986
986
 
987
- Available commands in `0.4.4`:
987
+ Available commands in `0.4.5`:
988
988
 
989
989
  | Command | Status |
990
990
  | --- | --- |
991
991
  | `devflow init` | Implemented |
992
992
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
993
993
  | `devflow approve <id>` (stage `spec` by default) | Implemented |
994
- | `devflow reopen <id>` | Implemented: withdraw a spec approval to change it |
994
+ | `devflow reopen <id>` | Implemented: withdraw a spec approval, or reopen Discovery with `--discovery` / `--add` to extend the spec |
995
995
  | `devflow status <id>` | Implemented |
996
996
  | `devflow doctor <id>` | Implemented: read-only diagnostics |
997
997
  | `devflow recover <id>` | Implemented: register existing artifacts |
@@ -1217,7 +1217,7 @@ devflow approve 001
1217
1217
  ```
1218
1218
 
1219
1219
  Approval is explicit and binds the decision to the current artifact
1220
- digests. For a `0.4.4` change it binds `spec.md`, `discovery.yaml` and,
1220
+ digests. For a `0.4.5` change it binds `spec.md`, `discovery.yaml` and,
1221
1221
  when a manifest applies, the architecture manifest digest. Repeating the
1222
1222
  same approval is a no-op. If an artifact changes after validation,
1223
1223
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1237,7 +1237,7 @@ and names the pending questions and assumptions. Approval also rejects a
1237
1237
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1238
1238
  changes without `discovery.yaml` remain approvable with a warning.
1239
1239
 
1240
- Only the `spec` stage is available in `0.4.4`, so `--stage` is optional
1240
+ Only the `spec` stage is available in `0.4.5`, so `--stage` is optional
1241
1241
  and defaults to `spec`. `--stage plan` and `--stage review` are
1242
1242
  rejected. There are no `plan`, `implement` or
1243
1243
  `review` commands in this release.
@@ -1265,16 +1265,22 @@ The generated `AGENTS.md` (or `CLAUDE.md`) tells the agent to:
1265
1265
  this step. Discovery and specification prompts skip it to save tokens;
1266
1266
  the specification still lists it in section 9.
1267
1267
 
1268
- ### Reopen an approved specification
1268
+ ### Reopen a specification to change or extend it
1269
1269
 
1270
1270
  An approved specification is a contract. To change it, reopen it first;
1271
1271
  editing `spec.md` directly only marks it `stale`.
1272
1272
 
1273
1273
  ```bash
1274
- devflow reopen 001 # fix or extend the spec text yourself
1275
- devflow reopen 001 --discovery # add or change decisions with the agent
1274
+ devflow reopen 001 # fix the spec text yourself
1275
+ devflow reopen 001 --add "password reset" # the agent extends the spec
1276
+ devflow reopen 001 --discovery # the agent asks what to change
1276
1277
  ```
1277
1278
 
1279
+ `--add` records what you want to add at the end of the Discovery request
1280
+ (`Additional scope (date): ...`) and implies `--discovery`. The agent
1281
+ starts from that text, asks only about the new decisions and keeps the
1282
+ decisions already answered unless the new scope contradicts them.
1283
+
1278
1284
  `reopen` asks for confirmation (skip it with `--yes`), copies the
1279
1285
  current `spec.md` into `history/`, records a `spec_reopened` event and
1280
1286
  withdraws the approval. The previous approval stays in `events.jsonl`;
@@ -1297,8 +1303,13 @@ devflow spec --continue 001 # writes the new spec
1297
1303
  devflow approve 001
1298
1304
  ```
1299
1305
 
1300
- Only an approved spec can be reopened, and only while the change is in
1301
- `spec_approved`.
1306
+ `--discovery` and `--add` also work on a change that is not approved
1307
+ yet: they reopen Discovery without any approval to withdraw. A plain
1308
+ `devflow reopen 001` on a change that is not approved explains that it
1309
+ is already open and how to extend it. When `spec --continue` finds the
1310
+ spec unchanged, it shows the same hint. Extending a spec through
1311
+ Discovery needs an interactive harness, because the agent asks you the
1312
+ new questions.
1302
1313
 
1303
1314
  ## Generated files
1304
1315
 
@@ -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.4` · Python 3.11+ · Linux and macOS
35
+ Current version: `0.4.5` · Python 3.11+ · Linux and macOS
36
36
 
37
37
  ## Install
38
38
 
@@ -142,11 +142,12 @@ The `AGENTS.md` file created by `devflow init` tells the agent to check
142
142
  the approval, follow your code standards, build only the listed
143
143
  requirements and report every acceptance criterion.
144
144
 
145
- ### 6. Change an approved spec (if needed)
145
+ ### 6. Change or extend a spec (if needed)
146
146
 
147
147
  ```bash
148
- devflow reopen 001 # you edit spec.md yourself
149
- devflow reopen 001 --discovery # the agent asks about the new decisions
148
+ devflow reopen 001 # you edit spec.md yourself
149
+ devflow reopen 001 --add "password reset" # the agent extends the spec
150
+ devflow reopen 001 --discovery # the agent asks what to change
150
151
  ```
151
152
 
152
153
  Then run `devflow spec --continue 001` and approve again. The previous
@@ -160,7 +161,7 @@ version is kept in `history/`.
160
161
  | `devflow spec "…"` | Start a change with Discovery |
161
162
  | `devflow spec --continue 001` | Resume Discovery or write the spec |
162
163
  | `devflow approve 001` | Approve the spec |
163
- | `devflow reopen 001` | Withdraw the approval to change the spec |
164
+ | `devflow reopen 001 --add "…"` | Extend or change the spec with the agent |
164
165
  | `devflow status 001` | Show where the change is and the next command |
165
166
 
166
167
  ## When something looks wrong
@@ -1,6 +1,6 @@
1
1
  # DevFlow Toolkit
2
2
 
3
- **Current version: `0.4.4`.**
3
+ **Current version: `0.4.5`.**
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.4-py3-none-any.whl
181
+ pip install devflow_toolkit-0.4.5-py3-none-any.whl
182
182
  ```
183
183
 
184
184
  Verify the installation:
@@ -495,7 +495,7 @@ as an architectural constraint when it is present.
495
495
 
496
496
  ### Harnesses
497
497
 
498
- | Harness | Status in 0.4.4 |
498
+ | Harness | Status in 0.4.5 |
499
499
  | --- | --- |
500
500
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
501
501
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -952,14 +952,14 @@ reference.
952
952
  8. If artifacts exist without workflow state, diagnose with
953
953
  `devflow doctor <id>` and repair with `devflow recover <id>`.
954
954
 
955
- Available commands in `0.4.4`:
955
+ Available commands in `0.4.5`:
956
956
 
957
957
  | Command | Status |
958
958
  | --- | --- |
959
959
  | `devflow init` | Implemented |
960
960
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
961
961
  | `devflow approve <id>` (stage `spec` by default) | Implemented |
962
- | `devflow reopen <id>` | Implemented: withdraw a spec approval to change it |
962
+ | `devflow reopen <id>` | Implemented: withdraw a spec approval, or reopen Discovery with `--discovery` / `--add` to extend the spec |
963
963
  | `devflow status <id>` | Implemented |
964
964
  | `devflow doctor <id>` | Implemented: read-only diagnostics |
965
965
  | `devflow recover <id>` | Implemented: register existing artifacts |
@@ -1185,7 +1185,7 @@ devflow approve 001
1185
1185
  ```
1186
1186
 
1187
1187
  Approval is explicit and binds the decision to the current artifact
1188
- digests. For a `0.4.4` change it binds `spec.md`, `discovery.yaml` and,
1188
+ digests. For a `0.4.5` change it binds `spec.md`, `discovery.yaml` and,
1189
1189
  when a manifest applies, the architecture manifest digest. Repeating the
1190
1190
  same approval is a no-op. If an artifact changes after validation,
1191
1191
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1205,7 +1205,7 @@ and names the pending questions and assumptions. Approval also rejects a
1205
1205
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1206
1206
  changes without `discovery.yaml` remain approvable with a warning.
1207
1207
 
1208
- Only the `spec` stage is available in `0.4.4`, so `--stage` is optional
1208
+ Only the `spec` stage is available in `0.4.5`, so `--stage` is optional
1209
1209
  and defaults to `spec`. `--stage plan` and `--stage review` are
1210
1210
  rejected. There are no `plan`, `implement` or
1211
1211
  `review` commands in this release.
@@ -1233,16 +1233,22 @@ The generated `AGENTS.md` (or `CLAUDE.md`) tells the agent to:
1233
1233
  this step. Discovery and specification prompts skip it to save tokens;
1234
1234
  the specification still lists it in section 9.
1235
1235
 
1236
- ### Reopen an approved specification
1236
+ ### Reopen a specification to change or extend it
1237
1237
 
1238
1238
  An approved specification is a contract. To change it, reopen it first;
1239
1239
  editing `spec.md` directly only marks it `stale`.
1240
1240
 
1241
1241
  ```bash
1242
- devflow reopen 001 # fix or extend the spec text yourself
1243
- devflow reopen 001 --discovery # add or change decisions with the agent
1242
+ devflow reopen 001 # fix the spec text yourself
1243
+ devflow reopen 001 --add "password reset" # the agent extends the spec
1244
+ devflow reopen 001 --discovery # the agent asks what to change
1244
1245
  ```
1245
1246
 
1247
+ `--add` records what you want to add at the end of the Discovery request
1248
+ (`Additional scope (date): ...`) and implies `--discovery`. The agent
1249
+ starts from that text, asks only about the new decisions and keeps the
1250
+ decisions already answered unless the new scope contradicts them.
1251
+
1246
1252
  `reopen` asks for confirmation (skip it with `--yes`), copies the
1247
1253
  current `spec.md` into `history/`, records a `spec_reopened` event and
1248
1254
  withdraws the approval. The previous approval stays in `events.jsonl`;
@@ -1265,8 +1271,13 @@ devflow spec --continue 001 # writes the new spec
1265
1271
  devflow approve 001
1266
1272
  ```
1267
1273
 
1268
- Only an approved spec can be reopened, and only while the change is in
1269
- `spec_approved`.
1274
+ `--discovery` and `--add` also work on a change that is not approved
1275
+ yet: they reopen Discovery without any approval to withdraw. A plain
1276
+ `devflow reopen 001` on a change that is not approved explains that it
1277
+ is already open and how to extend it. When `spec --continue` finds the
1278
+ spec unchanged, it shows the same hint. Extending a spec through
1279
+ Discovery needs an interactive harness, because the agent asks you the
1280
+ new questions.
1270
1281
 
1271
1282
  ## Generated files
1272
1283
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.4.4"
7
+ version = "0.4.5"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "docs/REFERENCE.md"
10
10
  license = "MIT"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from pathlib import Path
6
+ from typing import Optional
6
7
 
7
8
  import typer
8
9
  from rich.console import Console
@@ -34,7 +35,18 @@ def reopen(
34
35
  discovery: bool = typer.Option(
35
36
  False,
36
37
  "--discovery",
37
- help="Also reopen Discovery to add or change decisions.",
38
+ help=(
39
+ "Reopen Discovery so the agent asks about new or changed "
40
+ "decisions. Works on approved and not-yet-approved changes."
41
+ ),
42
+ ),
43
+ add: Optional[str] = typer.Option(
44
+ None,
45
+ "--add",
46
+ help=(
47
+ "What to add or change, for example \"password recovery by "
48
+ "email\". Implies --discovery."
49
+ ),
38
50
  ),
39
51
  yes: bool = typer.Option(
40
52
  False,
@@ -43,9 +55,9 @@ def reopen(
43
55
  help="Do not ask for confirmation.",
44
56
  ),
45
57
  ) -> None:
46
- """Reopen an approved specification so it can be changed."""
58
+ """Reopen a specification to change or extend it."""
47
59
  try:
48
- _reopen(spec_id, path, discovery=discovery, yes=yes)
60
+ _reopen(spec_id, path, discovery=discovery, add=add or "", yes=yes)
49
61
  except (
50
62
  ArtifactError,
51
63
  ConfigError,
@@ -59,48 +71,73 @@ def reopen(
59
71
  raise typer.Exit(code=1) from error
60
72
 
61
73
 
62
- def _reopen(spec_id: str, path: Path, *, discovery: bool, yes: bool) -> None:
74
+ def _reopen(
75
+ spec_id: str,
76
+ path: Path,
77
+ *,
78
+ discovery: bool,
79
+ add: str,
80
+ yes: bool,
81
+ ) -> None:
63
82
  root = ProjectDetector().find_root(path)
64
83
  config = ConfigManager(root).load()
65
84
  location = WorkflowLocator(config.specifications_path).find(spec_id)
66
-
67
- if not yes and not typer.confirm(
68
- f"Reopen the approved specification {location.change}?",
69
- default=False,
70
- ):
71
- console.print("Cancelled. Nothing was changed.")
72
- raise typer.Exit(code=1)
73
-
74
85
  manager = WorkflowStateManager(
75
86
  config.specifications_path,
76
87
  project_root=config.root,
77
88
  )
78
- result = manager.reopen(location, discovery=discovery)
89
+ discovery = discovery or bool(add.strip())
90
+ approved = "spec" in manager.load(location).approvals
79
91
 
80
- console.print(
81
- f"[bold green]Reopened {location.change}.[/bold green] "
82
- "The spec approval was withdrawn."
83
- )
92
+ if approved:
93
+ question = (
94
+ f"Withdraw the approval of {location.change} so it can be changed?"
95
+ )
96
+ elif discovery:
97
+ question = (
98
+ f"Reopen Discovery of {location.change} to add or change decisions?"
99
+ )
100
+ else:
101
+ question = ""
102
+ if question and not yes and not typer.confirm(question, default=False):
103
+ console.print("Cancelled. Nothing was changed.")
104
+ raise typer.Exit(code=1)
105
+
106
+ result = manager.reopen(location, discovery=discovery, addition=add)
107
+
108
+ if result.approval_withdrawn:
109
+ console.print(
110
+ f"[bold green]Reopened {location.change}.[/bold green] "
111
+ "The spec approval was withdrawn."
112
+ )
113
+ else:
114
+ console.print(
115
+ f"[bold green]Reopened Discovery of {location.change}."
116
+ "[/bold green]"
117
+ )
84
118
  if result.archived is not None:
85
119
  console.print(
86
120
  "Approved spec archived: "
87
121
  f"{manager.store.display_path(result.archived)}"
88
122
  )
123
+ if add.strip():
124
+ console.print(f"Recorded what to add: {escape(add.strip())}")
89
125
  console.print(f"Workflow status: {result.state.status}")
90
126
 
91
127
  continue_command = f"devflow spec --continue {location.spec_id}"
92
128
  if discovery:
93
129
  console.print(
94
130
  f"\n[bold]Next:[/bold] {continue_command}\n"
95
- "[dim]Tell the agent what to add or change. Then run the same "
96
- "command again to write the new spec, and approve it with "
97
- f"devflow approve {location.spec_id}.[/dim]"
131
+ "[dim]The agent asks you about the new decisions (interactive "
132
+ "mode). Run the same command again to write the extended spec, "
133
+ f"then approve it with devflow approve {location.spec_id}.[/dim]"
98
134
  )
99
135
  else:
100
136
  console.print(
101
- "\n[bold]Next:[/bold] edit spec.md, then "
137
+ "\n[bold]Next:[/bold] edit spec.md yourself, then "
102
138
  f"{continue_command}\n"
103
- "[dim]DevFlow validates and registers your edited spec. Approve "
104
- f"it again with devflow approve {location.spec_id}. To change "
105
- "decisions instead, use devflow reopen with --discovery.[/dim]"
139
+ "[dim]DevFlow validates and registers your edited spec; approve it "
140
+ f"again with devflow approve {location.spec_id}. To have the agent "
141
+ f"extend it instead, run devflow reopen {location.spec_id} --add "
142
+ '"what to add".[/dim]'
106
143
  )
@@ -345,6 +345,13 @@ def _create_specification(
345
345
  f"{result.spec.path.relative_to(config.root)}",
346
346
  soft_wrap=True,
347
347
  )
348
+ spec_id = result.spec.spec_id
349
+ console.print(
350
+ "[dim]To have the agent extend or change it, run "
351
+ f'devflow reopen {spec_id} --add "what to add" and then '
352
+ f"devflow spec --continue {spec_id}. To approve it as it is, run "
353
+ f"devflow approve {spec_id}.[/dim]"
354
+ )
348
355
  else:
349
356
  _print_result(result=result, config=config)
350
357
 
@@ -159,6 +159,7 @@ class ReopenResult:
159
159
  stage: str
160
160
  archived: Path | None
161
161
  discovery: bool
162
+ approval_withdrawn: bool = True
162
163
 
163
164
 
164
165
  class WorkflowStateManager:
@@ -695,8 +696,15 @@ class WorkflowStateManager:
695
696
  *,
696
697
  discovery: bool = False,
697
698
  by: str = "user",
699
+ addition: str = "",
698
700
  ) -> ReopenResult:
699
- """Withdraw an approval so the change can be edited again."""
701
+ """Open a change again so its specification can be extended.
702
+
703
+ An approved spec loses its approval and is archived. ``discovery``
704
+ also reopens Discovery so the agent asks about new decisions; it works
705
+ on a change that is not approved as well. ``addition`` records what
706
+ the user wants to add, and implies ``discovery``.
707
+ """
700
708
  normalized = stage.strip().lower()
701
709
  if normalized != "spec":
702
710
  msg = (
@@ -704,55 +712,85 @@ class WorkflowStateManager:
704
712
  "available in this release."
705
713
  )
706
714
  raise UnsupportedStageError(msg)
715
+ addition = " ".join(addition.split())
716
+ discovery = discovery or bool(addition)
707
717
 
708
718
  with self._lock(location):
709
719
  state = self._load_state(location, persist=True)
710
720
  state = self._reconcile_locked(location, state)
711
- if normalized not in state.approvals:
721
+ approved = normalized in state.approvals
722
+ editable = {
723
+ WorkflowStatus.DRAFT.value,
724
+ WorkflowStatus.AWAITING_CLARIFICATION.value,
725
+ }
726
+ if approved and state.status != STAGE_TARGETS[normalized]:
712
727
  msg = (
713
- f"Stage '{normalized}' is not approved for {location.change}; "
714
- "there is nothing to reopen. Continue it with 'devflow spec "
715
- f"--continue {location.spec_id}'."
728
+ f"Change '{location.change}' has advanced to {state.status} "
729
+ f"and cannot reopen the '{normalized}' stage."
716
730
  )
717
731
  raise StateError(msg)
718
- if state.status != STAGE_TARGETS[normalized]:
732
+ if not approved and state.status not in editable:
719
733
  msg = (
720
- f"Change '{location.change}' has advanced to {state.status} "
721
- f"and cannot reopen the '{normalized}' stage."
734
+ f"Change '{location.change}' is {state.status} and cannot be "
735
+ "reopened."
736
+ )
737
+ raise StateError(msg)
738
+ if not approved and not discovery:
739
+ msg = (
740
+ f"{location.change} is not approved, so it is already open. "
741
+ "Edit spec.md and run 'devflow spec --continue "
742
+ f"{location.spec_id}', or let the agent extend it with "
743
+ f"'devflow reopen {location.spec_id} --add \"what to add\"'."
722
744
  )
723
745
  raise StateError(msg)
724
746
 
725
747
  archived: Path | None = None
726
- spec_path = location.directory / "spec.md"
727
- if spec_path.is_file() and not spec_path.is_symlink():
728
- archived = self.store.archive(spec_path)
729
-
730
- target = (
731
- WorkflowStatus.AWAITING_CLARIFICATION.value
732
- if discovery
733
- else WorkflowStatus.DRAFT.value
734
- )
735
- state = self._append_and_save(
736
- location,
737
- state,
738
- f"{normalized}_reopened",
739
- {
740
- "stage": normalized,
741
- "by": by,
742
- "workflow_status": target,
743
- "discovery": discovery,
744
- },
745
- actor=by,
746
- run_id=None,
747
- )
748
+ if approved:
749
+ spec_path = location.directory / "spec.md"
750
+ if spec_path.is_file() and not spec_path.is_symlink():
751
+ archived = self.store.archive(spec_path)
752
+ target = (
753
+ WorkflowStatus.AWAITING_CLARIFICATION.value
754
+ if discovery
755
+ else WorkflowStatus.DRAFT.value
756
+ )
757
+ state = self._append_and_save(
758
+ location,
759
+ state,
760
+ f"{normalized}_reopened",
761
+ {
762
+ "stage": normalized,
763
+ "by": by,
764
+ "workflow_status": target,
765
+ "discovery": discovery,
766
+ },
767
+ actor=by,
768
+ run_id=None,
769
+ )
770
+ elif state.status == WorkflowStatus.DRAFT.value:
771
+ state = self._append_and_save(
772
+ location,
773
+ state,
774
+ WORKFLOW_TRANSITION,
775
+ {"to": WorkflowStatus.AWAITING_CLARIFICATION.value},
776
+ actor=by,
777
+ run_id=None,
778
+ )
748
779
 
749
780
  if discovery and "discovery" in state.artifacts:
750
781
  manager = DiscoveryManager(self.root, clock=self.clock)
751
782
  document = manager.load(location.directory, required=True)
752
783
  assert document is not None
784
+ request = document.request
785
+ if addition:
786
+ today = format_timestamp(self.clock.now())[:10]
787
+ request = (
788
+ f"{request.rstrip()}\n\nAdditional scope ({today}): "
789
+ f"{addition}"
790
+ )
753
791
  path, digest = manager.write(
754
792
  location.directory,
755
- replace(document, status=DISCOVERY_PENDING),
793
+ replace(document, status=DISCOVERY_PENDING, request=request),
756
794
  )
757
795
  state = self._append_and_save(
758
796
  location,
@@ -776,6 +814,7 @@ class WorkflowStateManager:
776
814
  stage=normalized,
777
815
  archived=archived,
778
816
  discovery=discovery,
817
+ approval_withdrawn=approved,
779
818
  )
780
819
 
781
820
  def _ensure_artifact_current(
@@ -166,8 +166,12 @@ def build_discovery_prompt(
166
166
 
167
167
  _REOPENED_NOTE = (
168
168
  "## Reopened Discovery\n\n"
169
- "The user reopened Discovery after approving the specification. "
170
- "Start by asking the user what to add or change. Append a new question "
169
+ "The user reopened Discovery to extend or change the specification. "
170
+ "If the request ends with an `Additional scope` line, that is what the "
171
+ "user wants to add: identify the new decisions it needs and ask about "
172
+ "them. Otherwise, start by asking the user what to add or change. "
173
+ "Answered decisions stay valid unless the new scope contradicts them. "
174
+ "Append a new question "
171
175
  "with the next `Qn` identifier for every new decision. Change an "
172
176
  "existing answer only when the user explicitly asks for it, and keep "
173
177
  "its id. Set `status` to `complete` when nothing remains pending.\n\n"
@@ -680,3 +680,72 @@ def test_unmanaged_precommit_config_is_not_activated(tmp_path: Path) -> None:
680
680
  assert calls == []
681
681
  assert config.read_text(encoding="utf-8") == "repos: []\n# devflow:managed\n"
682
682
  assert not security_tools.is_configured(tmp_path)
683
+
684
+
685
+ # Reopening to extend a specification.
686
+
687
+
688
+ def _approved_change(root: Path) -> Path:
689
+ _project(root)
690
+ created = runner.invoke(
691
+ app, ["spec", "Add a health endpoint", str(root), "--no-agent"]
692
+ )
693
+ assert created.exit_code == 0, created.output
694
+ return next((root / ".devflow" / "specs").iterdir())
695
+
696
+
697
+ def _discovery(change: Path) -> dict:
698
+ return yaml.safe_load((change / "discovery.yaml").read_text())
699
+
700
+
701
+ def test_reopen_add_records_the_new_scope_after_approval(
702
+ tmp_path: Path,
703
+ ) -> None:
704
+ change = _approved_change(tmp_path)
705
+ assert runner.invoke(app, ["approve", "001", str(tmp_path)]).exit_code == 0
706
+
707
+ result = runner.invoke(
708
+ app,
709
+ ["reopen", "001", str(tmp_path), "--add", "password reset", "-y"],
710
+ )
711
+
712
+ assert result.exit_code == 0, result.output
713
+ assert "approval was withdrawn" in result.output
714
+ data = _discovery(change)
715
+ assert "Additional scope" in data["request"]
716
+ assert data["request"].endswith("password reset")
717
+ assert data["status"] == "pending"
718
+
719
+
720
+ def test_reopen_discovery_works_on_a_change_that_is_not_approved(
721
+ tmp_path: Path,
722
+ ) -> None:
723
+ change = _approved_change(tmp_path)
724
+ plain = runner.invoke(app, ["reopen", "001", str(tmp_path), "-y"])
725
+ assert plain.exit_code == 1
726
+ assert "already open" in plain.output
727
+ assert "--add" in plain.output
728
+
729
+ result = runner.invoke(
730
+ app,
731
+ ["reopen", "001", str(tmp_path), "--add", "rate limiting", "-y"],
732
+ )
733
+
734
+ assert result.exit_code == 0, result.output
735
+ assert "Reopened Discovery" in result.output
736
+ assert _discovery(change)["request"].endswith("rate limiting")
737
+ status = runner.invoke(app, ["status", "001", str(tmp_path)])
738
+ assert "awaiting_clarification" in status.output
739
+
740
+
741
+ def test_continue_on_an_unchanged_spec_explains_how_to_extend_it(
742
+ tmp_path: Path,
743
+ ) -> None:
744
+ _approved_change(tmp_path)
745
+
746
+ result = runner.invoke(
747
+ app, ["spec", "--continue", "001", str(tmp_path), "--no-agent"]
748
+ )
749
+
750
+ assert result.exit_code == 0, result.output
751
+ assert "devflow reopen 001 --add" in result.output.replace("\n", " ")
@@ -484,7 +484,7 @@ def test_reopen_returns_an_approved_spec_to_draft(tmp_path: Path) -> None:
484
484
  ["reopen", "001", str(tmp_path), "--yes"],
485
485
  )
486
486
  assert not_approved.exit_code == 1
487
- assert "nothing to reopen" in not_approved.output
487
+ assert "already open" in not_approved.output
488
488
 
489
489
  assert runner.invoke(app, ["approve", "001", str(tmp_path)]).exit_code == 0
490
490
  spec_path = change / "spec.md"
File without changes