devflow-toolkit 0.3.22__tar.gz → 0.3.23__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 (84) hide show
  1. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/CHANGELOG.md +35 -0
  2. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/PKG-INFO +59 -7
  3. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/README.md +11 -2
  4. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/docs/REFERENCE.md +58 -6
  5. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/status.py +27 -8
  7. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/discovery.py +142 -1
  8. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/spec_workflow.py +30 -8
  9. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/specification.py +70 -6
  10. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/prompts/__init__.py +23 -5
  11. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/prompts/discovery.md +58 -3
  12. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/prompts/spec.md +9 -4
  13. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_discovery_decisions.py +138 -0
  14. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_spec_workflow.py +116 -0
  15. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_state.py +51 -0
  16. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/.gitignore +0 -0
  17. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/LICENSE +0 -0
  18. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/PUBLISHING.md +0 -0
  19. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/__init__.py +0 -0
  20. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/__init__.py +0 -0
  21. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/agents.py +0 -0
  22. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/antigravity.py +0 -0
  23. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/base.py +0 -0
  24. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/claude_code.py +0 -0
  25. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/codex.py +0 -0
  26. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/detector.py +0 -0
  27. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/instructions.py +0 -0
  28. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/kiro.py +0 -0
  29. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/opencode.py +0 -0
  30. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/adapters/registry.py +0 -0
  31. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/cli.py +0 -0
  32. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/__init__.py +0 -0
  33. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/approve.py +0 -0
  34. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/config.py +0 -0
  35. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/doctor.py +0 -0
  36. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/harness.py +0 -0
  37. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/init.py +0 -0
  38. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/recover.py +0 -0
  39. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/reopen.py +0 -0
  40. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/commands/spec.py +0 -0
  41. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/__init__.py +0 -0
  42. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/architecture.py +0 -0
  43. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/artifacts/__init__.py +0 -0
  44. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/artifacts/errors.py +0 -0
  45. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/artifacts/models.py +0 -0
  46. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/artifacts/store.py +0 -0
  47. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/clock.py +0 -0
  48. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/config.py +0 -0
  49. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/constitution.py +0 -0
  50. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/file_types.py +0 -0
  51. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/ports.py +0 -0
  52. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/profile_manager.py +0 -0
  53. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/project.py +0 -0
  54. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/recovery.py +0 -0
  55. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/__init__.py +0 -0
  56. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/errors.py +0 -0
  57. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/events.py +0 -0
  58. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/locator.py +0 -0
  59. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/lock.py +0 -0
  60. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/manager.py +0 -0
  61. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/models.py +0 -0
  62. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/core/state/transitions.py +0 -0
  63. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/models/__init__.py +0 -0
  64. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/models/profile.py +0 -0
  65. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/models/project.py +0 -0
  66. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  67. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  68. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  69. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  70. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  71. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/base/profile.yaml +0 -0
  72. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  73. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  74. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  75. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  76. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/src/devflow/prompts/discovery-repair.md +0 -0
  77. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_cli.py +0 -0
  78. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_discovery.py +0 -0
  79. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_event_log.py +0 -0
  80. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_greenfield.py +0 -0
  81. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_hardening.py +0 -0
  82. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_harness_adapters.py +0 -0
  83. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_recovery.py +0 -0
  84. {devflow_toolkit-0.3.22 → devflow_toolkit-0.3.23}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,41 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.3.23 - 2026-11-09
6
+
7
+ ### Added
8
+
9
+ - Level-based Discovery. The spec covers level 1 (essential behavior
10
+ with existing tools plus basic security). Every question can offer a
11
+ `next_level` option with a short explanation, and advanced decisions
12
+ are recorded in a new `deferred` list instead of being asked now.
13
+ - Suggested next specifications: deferred items and every unchosen
14
+ `next_level` option. They appear in the Decision Context, in
15
+ `devflow status`, in the `Next:` line after approval and in `spec.md`
16
+ section `10.1`, which DevFlow writes itself with a ready-to-run
17
+ `devflow spec "..."` command.
18
+ - A readiness check before Discovery closes, so the specification agent
19
+ does not find new decisions.
20
+
21
+ ### Changed
22
+
23
+ - In an interactive run, the specification agent checks for missing
24
+ decisions before writing. If one is missing, it appends the question
25
+ to `discovery.yaml` and stops without writing `spec.md`, instead of
26
+ writing a full spec that DevFlow discards.
27
+ - Security decisions are still always asked and never assumed; the
28
+ prompt now asks for a recommended basic option and a one-sentence
29
+ explanation.
30
+
31
+ ### Fixed
32
+
33
+ - Nested bullets under an open question in section 7 stay part of that
34
+ question instead of becoming separate questions without context.
35
+
36
+ ### Package
37
+
38
+ - Package version is `0.3.23`.
39
+
5
40
  ## 0.3.22 - 2026-11-09
6
41
 
7
42
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.22
3
+ Version: 0.3.23
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.22`.**
35
+ **Current version: `0.3.23`.**
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.22-py3-none-any.whl
155
+ pip install devflow_toolkit-0.3.23-py3-none-any.whl
156
156
  ```
157
157
 
158
158
  Verify the installation:
@@ -428,7 +428,7 @@ as an architectural constraint when it is present.
428
428
 
429
429
  ### Harnesses
430
430
 
431
- | Harness | Status in 0.3.22 |
431
+ | Harness | Status in 0.3.23 |
432
432
  | --- | --- |
433
433
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
434
434
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -683,6 +683,58 @@ appends the question to `discovery.yaml`, and returns the change to
683
683
  specification is generated. `devflow approve` rejects a
684
684
  specification that still lists open questions.
685
685
 
686
+ In an interactive run the specification agent checks for missing
687
+ decisions **before** writing. If one is missing, it appends the question
688
+ to `discovery.yaml` and stops without writing `spec.md`, so no tokens are
689
+ spent on a document that would be discarded. When an agent lists
690
+ questions in section 7, nested bullets stay part of the same question.
691
+
692
+ ### Level-based Discovery
693
+
694
+ Discovery builds the solution level by level instead of solving
695
+ everything at once:
696
+
697
+ 1. **Level 1 first.** The spec covers the essential behavior, built with
698
+ the tools the project already has, plus basic and obvious security.
699
+ 2. **Security is always asked, never assumed.** Basic security decisions
700
+ are explicit questions with a recommended option and a short
701
+ explanation, so the user learns them by answering.
702
+ 3. **Every question offers a next level.** One option takes the decision
703
+ one level further. It is recorded in `next_level`:
704
+
705
+ ```yaml
706
+ options:
707
+ - "Token valid until logout (basic)"
708
+ - "Token that expires after 24 hours"
709
+ next_level:
710
+ option: "Token that expires after 24 hours"
711
+ why: "Limits the damage if a token leaks."
712
+ ```
713
+
714
+ If the user chooses it, the answer uses that exact text. If not,
715
+ DevFlow treats it as a suggestion for a later specification.
716
+ 4. **No deeper than this level.** More advanced decisions found along
717
+ the way, and parts of a large request left for later, are recorded in
718
+ `deferred`:
719
+
720
+ ```yaml
721
+ deferred:
722
+ - title: "Limit failed login attempts"
723
+ why: "Protects accounts from password guessing."
724
+ question_id: Q2
725
+ ```
726
+
727
+ 5. **Readiness check.** Before closing, the agent confirms a decision
728
+ exists for every flow, interface, stored data, error case and level-1
729
+ security measure, and asks what is missing in the same round.
730
+
731
+ DevFlow collects `deferred` items and every unchosen `next_level` into
732
+ **suggested next specifications**. They appear in the Decision Context,
733
+ in `devflow status`, after approval in the `Next:` line, and in
734
+ `spec.md` section `10.1 Suggested next specifications`. DevFlow writes
735
+ that subsection itself, with a ready-to-run `devflow spec "..."` command
736
+ for each item; the agent does not write it.
737
+
686
738
  ## Workflow
687
739
 
688
740
  1. Initialize the project with `devflow init`.
@@ -696,7 +748,7 @@ specification that still lists open questions.
696
748
  8. If artifacts exist without workflow state, diagnose with
697
749
  `devflow doctor <id>` and repair with `devflow recover <id>`.
698
750
 
699
- Available commands in `0.3.22`:
751
+ Available commands in `0.3.23`:
700
752
 
701
753
  | Command | Status |
702
754
  | --- | --- |
@@ -929,7 +981,7 @@ devflow approve 001
929
981
  ```
930
982
 
931
983
  Approval is explicit and binds the decision to the current artifact
932
- digests. For a `0.3.22` change it binds `spec.md`, `discovery.yaml` and,
984
+ digests. For a `0.3.23` change it binds `spec.md`, `discovery.yaml` and,
933
985
  when a manifest applies, the architecture manifest digest. Repeating the
934
986
  same approval is a no-op. If an artifact changes after validation,
935
987
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -940,7 +992,7 @@ and names the pending questions and assumptions. Approval also rejects a
940
992
  specification whose section 7 still lists open questions. Legacy `0.2.0`
941
993
  changes without `discovery.yaml` remain approvable with a warning.
942
994
 
943
- Only the `spec` stage is available in `0.3.22`, so `--stage` is optional
995
+ Only the `spec` stage is available in `0.3.23`, so `--stage` is optional
944
996
  and defaults to `spec`. `--stage plan` and `--stage review` are
945
997
  rejected. There are no `plan`, `implement` or
946
998
  `review` commands in this release.
@@ -10,7 +10,7 @@ approved specification instead of a vague chat request.
10
10
  approval live in `.devflow/`, so any agent or teammate can pick up
11
11
  the work.
12
12
 
13
- Current version: `0.3.22` · Python 3.11+ · Linux and macOS
13
+ Current version: `0.3.23` · Python 3.11+ · Linux and macOS
14
14
 
15
15
  ## Install
16
16
 
@@ -63,6 +63,12 @@ agent says Discovery is done, **exit the chat** (for example `/exit`).
63
63
  DevFlow then checks the answers on your machine, without spending
64
64
  tokens.
65
65
 
66
+ Discovery works **level by level**. This spec covers the essentials
67
+ with the tools your project already has, plus basic security, which is
68
+ always asked, never assumed. Each question also offers a "next level"
69
+ option with a short explanation. Whatever you don't choose now becomes a
70
+ suggested next spec.
71
+
66
72
  ### 3. Continue until the spec is written
67
73
 
68
74
  ```bash
@@ -78,7 +84,8 @@ Prefer one command for both phases? Add `--auto` to the first command:
78
84
 
79
85
  ### 4. Review and approve
80
86
 
81
- Read `.devflow/specs/001-…/spec.md`, then:
87
+ Read `.devflow/specs/001-…/spec.md`. Section 10.1 lists the suggested
88
+ next specs, each with its `devflow spec "..."` command. Then:
82
89
 
83
90
  ```bash
84
91
  devflow approve 001
@@ -131,6 +138,8 @@ written outside the normal flow.
131
138
  - **Fewer wasted tokens.** Questions are cheap; rewriting code after a
132
139
  misunderstanding is expensive. An approved spec avoids most of those
133
140
  rewrites.
141
+ - **Grow step by step.** After approval, `devflow status 001` suggests
142
+ the next level as a new spec.
134
143
  - **Small changes don't need DevFlow.** Use it when a change involves
135
144
  decisions: new features, integrations, refactors.
136
145
  - **Without a chat.** `--mode non-interactive` runs the agent in the
@@ -1,6 +1,6 @@
1
1
  # DevFlow Toolkit
2
2
 
3
- **Current version: `0.3.22`.**
3
+ **Current version: `0.3.23`.**
4
4
 
5
5
  DevFlow is a command-line toolkit for leading AI models and coding
6
6
  agents through specification-driven changes in real software projects.
@@ -120,7 +120,7 @@ pip install devflow-toolkit
120
120
  To install a specific built artifact instead:
121
121
 
122
122
  ```bash
123
- pip install devflow_toolkit-0.3.22-py3-none-any.whl
123
+ pip install devflow_toolkit-0.3.23-py3-none-any.whl
124
124
  ```
125
125
 
126
126
  Verify the installation:
@@ -396,7 +396,7 @@ as an architectural constraint when it is present.
396
396
 
397
397
  ### Harnesses
398
398
 
399
- | Harness | Status in 0.3.22 |
399
+ | Harness | Status in 0.3.23 |
400
400
  | --- | --- |
401
401
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
402
402
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -651,6 +651,58 @@ appends the question to `discovery.yaml`, and returns the change to
651
651
  specification is generated. `devflow approve` rejects a
652
652
  specification that still lists open questions.
653
653
 
654
+ In an interactive run the specification agent checks for missing
655
+ decisions **before** writing. If one is missing, it appends the question
656
+ to `discovery.yaml` and stops without writing `spec.md`, so no tokens are
657
+ spent on a document that would be discarded. When an agent lists
658
+ questions in section 7, nested bullets stay part of the same question.
659
+
660
+ ### Level-based Discovery
661
+
662
+ Discovery builds the solution level by level instead of solving
663
+ everything at once:
664
+
665
+ 1. **Level 1 first.** The spec covers the essential behavior, built with
666
+ the tools the project already has, plus basic and obvious security.
667
+ 2. **Security is always asked, never assumed.** Basic security decisions
668
+ are explicit questions with a recommended option and a short
669
+ explanation, so the user learns them by answering.
670
+ 3. **Every question offers a next level.** One option takes the decision
671
+ one level further. It is recorded in `next_level`:
672
+
673
+ ```yaml
674
+ options:
675
+ - "Token valid until logout (basic)"
676
+ - "Token that expires after 24 hours"
677
+ next_level:
678
+ option: "Token that expires after 24 hours"
679
+ why: "Limits the damage if a token leaks."
680
+ ```
681
+
682
+ If the user chooses it, the answer uses that exact text. If not,
683
+ DevFlow treats it as a suggestion for a later specification.
684
+ 4. **No deeper than this level.** More advanced decisions found along
685
+ the way, and parts of a large request left for later, are recorded in
686
+ `deferred`:
687
+
688
+ ```yaml
689
+ deferred:
690
+ - title: "Limit failed login attempts"
691
+ why: "Protects accounts from password guessing."
692
+ question_id: Q2
693
+ ```
694
+
695
+ 5. **Readiness check.** Before closing, the agent confirms a decision
696
+ exists for every flow, interface, stored data, error case and level-1
697
+ security measure, and asks what is missing in the same round.
698
+
699
+ DevFlow collects `deferred` items and every unchosen `next_level` into
700
+ **suggested next specifications**. They appear in the Decision Context,
701
+ in `devflow status`, after approval in the `Next:` line, and in
702
+ `spec.md` section `10.1 Suggested next specifications`. DevFlow writes
703
+ that subsection itself, with a ready-to-run `devflow spec "..."` command
704
+ for each item; the agent does not write it.
705
+
654
706
  ## Workflow
655
707
 
656
708
  1. Initialize the project with `devflow init`.
@@ -664,7 +716,7 @@ specification that still lists open questions.
664
716
  8. If artifacts exist without workflow state, diagnose with
665
717
  `devflow doctor <id>` and repair with `devflow recover <id>`.
666
718
 
667
- Available commands in `0.3.22`:
719
+ Available commands in `0.3.23`:
668
720
 
669
721
  | Command | Status |
670
722
  | --- | --- |
@@ -897,7 +949,7 @@ devflow approve 001
897
949
  ```
898
950
 
899
951
  Approval is explicit and binds the decision to the current artifact
900
- digests. For a `0.3.22` change it binds `spec.md`, `discovery.yaml` and,
952
+ digests. For a `0.3.23` change it binds `spec.md`, `discovery.yaml` and,
901
953
  when a manifest applies, the architecture manifest digest. Repeating the
902
954
  same approval is a no-op. If an artifact changes after validation,
903
955
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -908,7 +960,7 @@ and names the pending questions and assumptions. Approval also rejects a
908
960
  specification whose section 7 still lists open questions. Legacy `0.2.0`
909
961
  changes without `discovery.yaml` remain approvable with a warning.
910
962
 
911
- Only the `spec` stage is available in `0.3.22`, so `--stage` is optional
963
+ Only the `spec` stage is available in `0.3.23`, so `--stage` is optional
912
964
  and defaults to `spec`. `--stage plan` and `--stage review` are
913
965
  rejected. There are no `plan`, `implement` or
914
966
  `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.3.22"
7
+ version = "0.3.23"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "docs/REFERENCE.md"
10
10
  license = "MIT"
@@ -14,7 +14,11 @@ from devflow.core.config import (
14
14
  ConfigManager,
15
15
  DevFlowConfig,
16
16
  )
17
- from devflow.core.discovery import DiscoveryError, DiscoveryManager
17
+ from devflow.core.discovery import (
18
+ DiscoveryDocument,
19
+ DiscoveryError,
20
+ DiscoveryManager,
21
+ )
18
22
  from devflow.core.project import ProjectDetector
19
23
  from devflow.core.state import (
20
24
  ChangeLocation,
@@ -99,7 +103,7 @@ def _status(spec_id: str, path: Path) -> None:
99
103
  else:
100
104
  console.print("\n[yellow]No artifacts are registered.[/yellow]")
101
105
 
102
- _print_discovery(config=config, location=location)
106
+ discovery = _print_discovery(config=config, location=location)
103
107
 
104
108
  if state.approvals:
105
109
  console.print("\n[bold]Approvals[/bold]")
@@ -123,7 +127,7 @@ def _status(spec_id: str, path: Path) -> None:
123
127
  "They are not approved and do not advance the change.[/dim]"
124
128
  )
125
129
 
126
- next_step = _next_step(current, location)
130
+ next_step = _next_step(current, location, discovery)
127
131
  if next_step:
128
132
  console.print(f"\n[bold]Next:[/bold] {next_step}")
129
133
 
@@ -131,6 +135,7 @@ def _status(spec_id: str, path: Path) -> None:
131
135
  def _next_step(
132
136
  current: ChangeStatus,
133
137
  location: ChangeLocation,
138
+ discovery: DiscoveryDocument | None = None,
134
139
  ) -> str:
135
140
  """Suggest the next action for the current workflow state."""
136
141
  state = current.state
@@ -152,7 +157,14 @@ def _next_step(
152
157
  if spec is not None
153
158
  else f"{location.change}/spec.md"
154
159
  )
155
- return f"ask your coding agent to implement `{spec_path}`"
160
+ step = f"ask your coding agent to implement `{spec_path}`"
161
+ suggestions = (
162
+ discovery.suggested_next_specs() if discovery is not None else ()
163
+ )
164
+ if suggestions:
165
+ title = suggestions[0].title.replace('"', "'")
166
+ step += f'. Next level: devflow spec "{title}"'
167
+ return step
156
168
  if (
157
169
  state.status == WorkflowStatus.DRAFT.value
158
170
  and spec is not None
@@ -171,18 +183,18 @@ def _print_discovery(
171
183
  *,
172
184
  config: DevFlowConfig,
173
185
  location: ChangeLocation,
174
- ) -> None:
186
+ ) -> DiscoveryDocument | None:
175
187
  manager = DiscoveryManager(config.root)
176
188
  if not manager.exists(location.directory):
177
- return
189
+ return None
178
190
  console.print("\n[bold]Discovery[/bold]")
179
191
  try:
180
192
  discovery = manager.load(location.directory, required=True)
181
193
  except DiscoveryError as error:
182
194
  console.print(f"[yellow]- invalid discovery: {error}[/yellow]")
183
- return
195
+ return None
184
196
  if discovery is None:
185
- return
197
+ return None
186
198
  console.print(
187
199
  f" status: {discovery.status} · "
188
200
  f"{len(discovery.pending_questions)} pending · "
@@ -214,3 +226,10 @@ def _print_discovery(
214
226
  f"{assumption.value}",
215
227
  soft_wrap=True,
216
228
  )
229
+
230
+ suggestions = discovery.suggested_next_specs()
231
+ if suggestions:
232
+ console.print("\n[bold]Suggested next specifications[/bold]")
233
+ for index, item in enumerate(suggestions, start=1):
234
+ console.print(f" {index}. {item.title}: {item.why}", soft_wrap=True)
235
+ return discovery
@@ -29,6 +29,7 @@ MAX_QUESTIONS = 100
29
29
  MAX_ASSUMPTIONS = 100
30
30
  MAX_TEXT_LENGTH = 4_000
31
31
  MAX_OPTIONS = 10
32
+ MAX_DEFERRED = 30
32
33
 
33
34
  DISCOVERY_PENDING = "pending"
34
35
  DISCOVERY_AWAITING = "awaiting_clarification"
@@ -479,6 +480,45 @@ class DiscoveryIncompleteError(DiscoveryError):
479
480
  """Raised when a workflow requires a complete discovery."""
480
481
 
481
482
 
483
+ @dataclass(frozen=True)
484
+ class NextLevel:
485
+ """The option that would take a decision one level further."""
486
+
487
+ option: str
488
+ why: str
489
+
490
+ def to_dict(self) -> dict[str, Any]:
491
+ return {"option": self.option, "why": self.why}
492
+
493
+
494
+ @dataclass(frozen=True)
495
+ class DeferredItem:
496
+ """A next-level improvement suggested for a later specification."""
497
+
498
+ title: str
499
+ why: str
500
+ question_id: str | None = None
501
+
502
+ def to_dict(self) -> dict[str, Any]:
503
+ data: dict[str, Any] = {"title": self.title, "why": self.why}
504
+ if self.question_id:
505
+ data["question_id"] = self.question_id
506
+ return data
507
+
508
+
509
+ def _same_choice(answer: str | None, option: str) -> bool:
510
+ """Return whether an answer selects the given option."""
511
+ if not answer:
512
+ return False
513
+
514
+ def normalized(value: str) -> str:
515
+ return " ".join(value.split()).casefold().rstrip(" .")
516
+
517
+ chosen = normalized(answer)
518
+ expected = normalized(option)
519
+ return bool(expected) and chosen.startswith(expected)
520
+
521
+
482
522
  @dataclass(frozen=True)
483
523
  class DiscoveryQuestion:
484
524
  """One decision that may block specification generation."""
@@ -496,6 +536,16 @@ class DiscoveryQuestion:
496
536
  materiality: str = ""
497
537
  resolution_source: str | None = None
498
538
  evidence: tuple[str, ...] = ()
539
+ next_level: NextLevel | None = None
540
+
541
+ @property
542
+ def chose_next_level(self) -> bool:
543
+ """Return whether the user selected the next-level option."""
544
+ return (
545
+ self.next_level is not None
546
+ and self.is_resolved
547
+ and _same_choice(self.answer, self.next_level.option)
548
+ )
499
549
 
500
550
  @property
501
551
  def effective_materiality(self) -> str:
@@ -563,9 +613,11 @@ class DiscoveryQuestion:
563
613
  data["resolution_source"] = self.resolution_source
564
614
  if self.evidence:
565
615
  data["evidence"] = list(self.evidence)
616
+ data["options"] = list(self.options)
617
+ if self.next_level is not None:
618
+ data["next_level"] = self.next_level.to_dict()
566
619
  data.update(
567
620
  {
568
- "options": list(self.options),
569
621
  "answer": self.answer,
570
622
  "answered_by": self.answered_by,
571
623
  "answered_at": self.answered_at,
@@ -618,6 +670,39 @@ class DiscoveryDocument:
618
670
  updated_at: str
619
671
  questions: tuple[DiscoveryQuestion, ...] = ()
620
672
  assumptions: tuple[DiscoveryAssumption, ...] = ()
673
+ deferred: tuple[DeferredItem, ...] = ()
674
+
675
+ def suggested_next_specs(self) -> tuple[DeferredItem, ...]:
676
+ """Return next-level improvements to propose as later specs.
677
+
678
+ Explicitly deferred items come first. A decided question whose
679
+ next-level option was not selected adds that option.
680
+ """
681
+ items: list[DeferredItem] = []
682
+ seen: set[str] = set()
683
+
684
+ def add(item: DeferredItem) -> None:
685
+ key = " ".join(item.title.split()).casefold()
686
+ if key in seen:
687
+ return
688
+ seen.add(key)
689
+ items.append(item)
690
+
691
+ for item in self.deferred:
692
+ add(item)
693
+ for question in self.questions:
694
+ if question.next_level is None or question.is_pending:
695
+ continue
696
+ if question.chose_next_level:
697
+ continue
698
+ add(
699
+ DeferredItem(
700
+ title=question.next_level.option,
701
+ why=question.next_level.why,
702
+ question_id=question.id,
703
+ )
704
+ )
705
+ return tuple(items)
621
706
 
622
707
  @property
623
708
  def pending_blocking(self) -> tuple[DiscoveryQuestion, ...]:
@@ -747,6 +832,11 @@ class DiscoveryDocument:
747
832
  "assumptions": [
748
833
  assumption.to_dict() for assumption in self.assumptions
749
834
  ],
835
+ **(
836
+ {"deferred": [item.to_dict() for item in self.deferred]}
837
+ if self.deferred
838
+ else {}
839
+ ),
750
840
  }
751
841
 
752
842
 
@@ -1129,6 +1219,15 @@ class DiscoveryManager:
1129
1219
  )
1130
1220
  raise DiscoveryError(msg)
1131
1221
 
1222
+ deferred_data = _list(mapping.get("deferred"), "deferred")
1223
+ if len(deferred_data) > MAX_DEFERRED:
1224
+ msg = f"At most {MAX_DEFERRED} deferred items are allowed."
1225
+ raise DiscoveryError(msg)
1226
+ deferred = tuple(
1227
+ self._deferred(item, index, question_ids)
1228
+ for index, item in enumerate(deferred_data, start=1)
1229
+ )
1230
+
1132
1231
  document = DiscoveryDocument(
1133
1232
  version=version,
1134
1233
  spec_id=spec_id,
@@ -1140,6 +1239,7 @@ class DiscoveryManager:
1140
1239
  updated_at=updated_at,
1141
1240
  questions=questions,
1142
1241
  assumptions=assumptions,
1242
+ deferred=deferred,
1143
1243
  )
1144
1244
  if (
1145
1245
  document.status == DISCOVERY_COMPLETE
@@ -1210,6 +1310,23 @@ class DiscoveryManager:
1210
1310
  if len(options) > MAX_OPTIONS:
1211
1311
  msg = f"{identifier} has too many options."
1212
1312
  raise DiscoveryError(msg)
1313
+ next_level = None
1314
+ next_level_data = mapping.get("next_level")
1315
+ if next_level_data is not None:
1316
+ next_level_mapping = _mapping(
1317
+ next_level_data,
1318
+ f"{identifier}.next_level",
1319
+ )
1320
+ next_level = NextLevel(
1321
+ option=_limited_text(
1322
+ next_level_mapping.get("option"),
1323
+ f"{identifier}.next_level.option",
1324
+ ),
1325
+ why=_limited_text(
1326
+ next_level_mapping.get("why"),
1327
+ f"{identifier}.next_level.why",
1328
+ ),
1329
+ )
1213
1330
  resolution_source = _optional_text(
1214
1331
  mapping.get("resolution_source"),
1215
1332
  f"{identifier}.resolution_source",
@@ -1316,6 +1433,30 @@ class DiscoveryManager:
1316
1433
  materiality=materiality,
1317
1434
  resolution_source=resolution_source,
1318
1435
  evidence=evidence,
1436
+ next_level=next_level,
1437
+ )
1438
+
1439
+ def _deferred(
1440
+ self,
1441
+ data: object,
1442
+ index: int,
1443
+ question_ids: set[str],
1444
+ ) -> DeferredItem:
1445
+ mapping = _mapping(data, f"deferred[{index}]")
1446
+ question_id = _optional_text(
1447
+ mapping.get("question_id"),
1448
+ f"deferred[{index}].question_id",
1449
+ )
1450
+ if question_id is not None and question_id not in question_ids:
1451
+ msg = (
1452
+ f"deferred[{index}] references unknown question "
1453
+ f"{question_id!r}."
1454
+ )
1455
+ raise DiscoveryError(msg)
1456
+ return DeferredItem(
1457
+ title=_limited_text(mapping.get("title"), f"deferred[{index}].title"),
1458
+ why=_limited_text(mapping.get("why"), f"deferred[{index}].why"),
1459
+ question_id=question_id,
1319
1460
  )
1320
1461
 
1321
1462
  def _assumption(
@@ -637,14 +637,15 @@ class SpecWorkflow:
637
637
  if prepared.path.is_file():
638
638
  ArtifactStore(prepared.root).archive(prepared.path)
639
639
  prepared.path.unlink(missing_ok=True)
640
- discovery = discovery_manager.add_questions(
641
- discovery,
642
- error.questions,
643
- )
644
- discovery_path, discovery_digest = discovery_manager.write(
645
- prepared.directory,
646
- discovery,
647
- )
640
+ if error.questions:
641
+ discovery = discovery_manager.add_questions(
642
+ discovery,
643
+ error.questions,
644
+ )
645
+ discovery_path, discovery_digest = discovery_manager.write(
646
+ prepared.directory,
647
+ discovery,
648
+ )
648
649
  discovery = discovery_manager.load(
649
650
  prepared.directory,
650
651
  required=True,
@@ -1058,6 +1059,7 @@ class SpecWorkflow:
1058
1059
  run_warnings,
1059
1060
  )
1060
1061
  if prepared.path.is_file():
1062
+ self._raise_if_returned_to_discovery(prepared, run_warnings)
1061
1063
  content = prepared.path.read_text(encoding="utf-8")
1062
1064
  self._raise_if_open_questions(
1063
1065
  content,
@@ -1089,6 +1091,7 @@ class SpecWorkflow:
1089
1091
  run_warnings,
1090
1092
  )
1091
1093
 
1094
+ self._raise_if_returned_to_discovery(prepared, run_warnings)
1092
1095
  run_warnings.append(
1093
1096
  "the interactive agent did not write the specification. "
1094
1097
  "Using deterministic DevFlow output."
@@ -1149,6 +1152,25 @@ class SpecWorkflow:
1149
1152
  if output_path is not None:
1150
1153
  output_path.unlink(missing_ok=True)
1151
1154
 
1155
+ def _raise_if_returned_to_discovery(
1156
+ self,
1157
+ prepared: PreparedSpec,
1158
+ run_warnings: list[str],
1159
+ ) -> None:
1160
+ """Stop when the agent recorded new decisions instead of a spec."""
1161
+ try:
1162
+ current = DiscoveryManager(prepared.root).load(
1163
+ prepared.directory,
1164
+ required=True,
1165
+ )
1166
+ except DiscoveryError as error:
1167
+ run_warnings.append(
1168
+ f"the specification agent left an invalid discovery.yaml: {error}"
1169
+ )
1170
+ return
1171
+ if current is not None and not current.is_complete:
1172
+ raise SpecOpenQuestionsError((), tuple(run_warnings))
1173
+
1152
1174
  def _raise_if_open_questions(
1153
1175
  self,
1154
1176
  content: str,