devflow-toolkit 0.3.19__tar.gz → 0.3.20__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 (81) hide show
  1. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/CHANGELOG.md +18 -0
  2. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/PKG-INFO +31 -13
  3. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/README.md +30 -12
  4. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/pyproject.toml +1 -1
  5. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/spec.py +0 -1
  6. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/spec_workflow.py +8 -1
  7. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/prompts/__init__.py +7 -2
  8. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_spec_workflow.py +64 -0
  9. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/.gitignore +0 -0
  10. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/LICENSE +0 -0
  11. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/__init__.py +0 -0
  12. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/__init__.py +0 -0
  13. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/agents.py +0 -0
  14. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/antigravity.py +0 -0
  15. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/base.py +0 -0
  16. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/claude_code.py +0 -0
  17. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/codex.py +0 -0
  18. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/detector.py +0 -0
  19. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/instructions.py +0 -0
  20. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/kiro.py +0 -0
  21. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/opencode.py +0 -0
  22. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/adapters/registry.py +0 -0
  23. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/cli.py +0 -0
  24. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/__init__.py +0 -0
  25. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/approve.py +0 -0
  26. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/config.py +0 -0
  27. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/doctor.py +0 -0
  28. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/harness.py +0 -0
  29. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/init.py +0 -0
  30. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/recover.py +0 -0
  31. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/commands/status.py +0 -0
  32. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/__init__.py +0 -0
  33. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/architecture.py +0 -0
  34. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/artifacts/__init__.py +0 -0
  35. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/artifacts/errors.py +0 -0
  36. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/artifacts/models.py +0 -0
  37. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/artifacts/store.py +0 -0
  38. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/clock.py +0 -0
  39. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/config.py +0 -0
  40. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/constitution.py +0 -0
  41. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/discovery.py +0 -0
  42. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/file_types.py +0 -0
  43. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/ports.py +0 -0
  44. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/profile_manager.py +0 -0
  45. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/project.py +0 -0
  46. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/recovery.py +0 -0
  47. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/specification.py +0 -0
  48. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/__init__.py +0 -0
  49. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/errors.py +0 -0
  50. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/events.py +0 -0
  51. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/locator.py +0 -0
  52. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/lock.py +0 -0
  53. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/manager.py +0 -0
  54. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/models.py +0 -0
  55. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/core/state/transitions.py +0 -0
  56. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/models/__init__.py +0 -0
  57. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/models/profile.py +0 -0
  58. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/models/project.py +0 -0
  59. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  60. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  61. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  62. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  63. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  64. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/base/profile.yaml +0 -0
  65. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  66. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  67. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  68. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  69. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/prompts/discovery-repair.md +0 -0
  70. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/prompts/discovery.md +0 -0
  71. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/src/devflow/prompts/spec.md +0 -0
  72. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_cli.py +0 -0
  73. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_discovery.py +0 -0
  74. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_discovery_decisions.py +0 -0
  75. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_event_log.py +0 -0
  76. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_greenfield.py +0 -0
  77. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_hardening.py +0 -0
  78. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_harness_adapters.py +0 -0
  79. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_recovery.py +0 -0
  80. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_state.py +0 -0
  81. {devflow_toolkit-0.3.19 → devflow_toolkit-0.3.20}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.3.20 - 2026-11-09
6
+
7
+ ### Changed
8
+
9
+ - An interactive `devflow spec --continue` now stops at the Discovery
10
+ checkpoint when it opened a Discovery session, like a new
11
+ `devflow spec`. Without `--auto`, one command opens at most one agent
12
+ session. A continuation whose Discovery is already complete still
13
+ writes the specification.
14
+ - Interactive Discovery and specification prompts tell the agent to ask
15
+ the user to exit the session when its phase is done, and warn that
16
+ exiting before `spec.md` is written makes DevFlow use its
17
+ deterministic draft.
18
+
19
+ ### Package
20
+
21
+ - Package version is `0.3.20`.
22
+
5
23
  ## 0.3.19 - 2026-11-08
6
24
 
7
25
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.19
3
+ Version: 0.3.20
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.19`.**
35
+ **Current version: `0.3.20`.**
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.19-py3-none-any.whl
155
+ pip install devflow_toolkit-0.3.20-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.19 |
431
+ | Harness | Status in 0.3.20 |
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 |
@@ -696,7 +696,7 @@ specification that still lists open questions.
696
696
  8. If artifacts exist without workflow state, diagnose with
697
697
  `devflow doctor <id>` and repair with `devflow recover <id>`.
698
698
 
699
- Available commands in `0.3.19`:
699
+ Available commands in `0.3.20`:
700
700
 
701
701
  | Command | Status |
702
702
  | --- | --- |
@@ -743,12 +743,13 @@ The command:
743
743
  architecture to `context.md`;
744
744
  6. stops without `spec.md` when any question or assumption remains
745
745
  unresolved;
746
- 7. in an interactive run, stops after Discovery is complete and prints
746
+ 7. in an interactive run, stops after the Discovery session and prints
747
747
  the next command, so you can choose the harness for the
748
748
  specification;
749
- 8. on `--continue` (or with `--auto`) invokes the selected harness with
750
- the specification prompt, validates the returned specification, and
751
- binds it to the Discovery digest;
749
+ 8. on `--continue` with Discovery already complete (or with `--auto`)
750
+ invokes the selected harness with the specification prompt,
751
+ validates the returned specification, and binds it to the Discovery
752
+ digest;
752
753
  9. writes `spec.md` and registers the Discovery and specification
753
754
  digests in the event log and the workflow projection.
754
755
 
@@ -762,6 +763,20 @@ devflow spec "Add a GET /patients endpoint"
762
763
  devflow spec --continue 006 . --harness opencode
763
764
  ```
764
765
 
766
+ Without `--auto`, one interactive command opens at most one agent
767
+ session. When a session ends, exit the harness (for example with
768
+ `/exit`) so DevFlow can validate the result locally, without spending
769
+ tokens:
770
+
771
+ - after a Discovery session, DevFlow stops and prints the next command,
772
+ also when the session was opened by `--continue`;
773
+ - after a specification session, DevFlow validates and registers
774
+ `spec.md`.
775
+
776
+ Exit the specification session only after the agent says `spec.md` is
777
+ written. If the file is missing or invalid, DevFlow writes its
778
+ deterministic draft instead.
779
+
765
780
  When no `--harness` is passed, an interactive `devflow spec` asks which
766
781
  installed harness to use before starting, even if `.devflow/config.yaml`
767
782
  already names one. The configured harness is offered as the default.
@@ -783,7 +798,9 @@ devflow spec --continue 006
783
798
 
784
799
  `--continue` is not a new specification. It reuses the stored request
785
800
  and project mode, loads Discovery, and stops until no decision is
786
- pending and every assumption is accepted. It reuses a current
801
+ pending and every assumption is accepted. If it opened a Discovery
802
+ session, it stops at the Discovery checkpoint; run `--continue` again to
803
+ write the specification. It reuses a current
787
804
  validated specification when the Discovery digest still matches;
788
805
  otherwise it archives the old specification and generates a new one. If
789
806
  an interrupted run left a complete `discovery.yaml` without
@@ -808,7 +825,8 @@ devflow spec --continue 006 --harness opencode
808
825
 
809
826
  `--auto` keeps the older one-shot flow: Discovery and the specification
810
827
  run in the same invocation. Without it, an interactive run stops at the
811
- Discovery checkpoint.
828
+ Discovery checkpoint, including a `--continue` run that answered the
829
+ remaining Discovery questions.
812
830
 
813
831
  `spec --language <code>` selects the language for this run and stores it
814
832
  as the project default in `.devflow/config.yaml`, so later `--continue`
@@ -895,7 +913,7 @@ devflow approve 001 --stage spec
895
913
  ```
896
914
 
897
915
  Approval is explicit and binds the decision to the current artifact
898
- digests. For a `0.3.19` change it binds `spec.md`, `discovery.yaml` and,
916
+ digests. For a `0.3.20` change it binds `spec.md`, `discovery.yaml` and,
899
917
  when a manifest applies, the architecture manifest digest. Repeating the
900
918
  same approval is a no-op. If an artifact changes after validation,
901
919
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -906,7 +924,7 @@ and names the pending questions and assumptions. Approval also rejects a
906
924
  specification whose section 7 still lists open questions. Legacy `0.2.0`
907
925
  changes without `discovery.yaml` remain approvable with a warning.
908
926
 
909
- Only the `spec` stage is available in `0.3.19`. `--stage plan` and
927
+ Only the `spec` stage is available in `0.3.20`. `--stage plan` and
910
928
  `--stage review` are rejected. There are no `plan`, `implement` or
911
929
  `review` commands in this release.
912
930
 
@@ -1,6 +1,6 @@
1
1
  # DevFlow Toolkit
2
2
 
3
- **Current version: `0.3.19`.**
3
+ **Current version: `0.3.20`.**
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.19-py3-none-any.whl
123
+ pip install devflow_toolkit-0.3.20-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.19 |
399
+ | Harness | Status in 0.3.20 |
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 |
@@ -664,7 +664,7 @@ specification that still lists open questions.
664
664
  8. If artifacts exist without workflow state, diagnose with
665
665
  `devflow doctor <id>` and repair with `devflow recover <id>`.
666
666
 
667
- Available commands in `0.3.19`:
667
+ Available commands in `0.3.20`:
668
668
 
669
669
  | Command | Status |
670
670
  | --- | --- |
@@ -711,12 +711,13 @@ The command:
711
711
  architecture to `context.md`;
712
712
  6. stops without `spec.md` when any question or assumption remains
713
713
  unresolved;
714
- 7. in an interactive run, stops after Discovery is complete and prints
714
+ 7. in an interactive run, stops after the Discovery session and prints
715
715
  the next command, so you can choose the harness for the
716
716
  specification;
717
- 8. on `--continue` (or with `--auto`) invokes the selected harness with
718
- the specification prompt, validates the returned specification, and
719
- binds it to the Discovery digest;
717
+ 8. on `--continue` with Discovery already complete (or with `--auto`)
718
+ invokes the selected harness with the specification prompt,
719
+ validates the returned specification, and binds it to the Discovery
720
+ digest;
720
721
  9. writes `spec.md` and registers the Discovery and specification
721
722
  digests in the event log and the workflow projection.
722
723
 
@@ -730,6 +731,20 @@ devflow spec "Add a GET /patients endpoint"
730
731
  devflow spec --continue 006 . --harness opencode
731
732
  ```
732
733
 
734
+ Without `--auto`, one interactive command opens at most one agent
735
+ session. When a session ends, exit the harness (for example with
736
+ `/exit`) so DevFlow can validate the result locally, without spending
737
+ tokens:
738
+
739
+ - after a Discovery session, DevFlow stops and prints the next command,
740
+ also when the session was opened by `--continue`;
741
+ - after a specification session, DevFlow validates and registers
742
+ `spec.md`.
743
+
744
+ Exit the specification session only after the agent says `spec.md` is
745
+ written. If the file is missing or invalid, DevFlow writes its
746
+ deterministic draft instead.
747
+
733
748
  When no `--harness` is passed, an interactive `devflow spec` asks which
734
749
  installed harness to use before starting, even if `.devflow/config.yaml`
735
750
  already names one. The configured harness is offered as the default.
@@ -751,7 +766,9 @@ devflow spec --continue 006
751
766
 
752
767
  `--continue` is not a new specification. It reuses the stored request
753
768
  and project mode, loads Discovery, and stops until no decision is
754
- pending and every assumption is accepted. It reuses a current
769
+ pending and every assumption is accepted. If it opened a Discovery
770
+ session, it stops at the Discovery checkpoint; run `--continue` again to
771
+ write the specification. It reuses a current
755
772
  validated specification when the Discovery digest still matches;
756
773
  otherwise it archives the old specification and generates a new one. If
757
774
  an interrupted run left a complete `discovery.yaml` without
@@ -776,7 +793,8 @@ devflow spec --continue 006 --harness opencode
776
793
 
777
794
  `--auto` keeps the older one-shot flow: Discovery and the specification
778
795
  run in the same invocation. Without it, an interactive run stops at the
779
- Discovery checkpoint.
796
+ Discovery checkpoint, including a `--continue` run that answered the
797
+ remaining Discovery questions.
780
798
 
781
799
  `spec --language <code>` selects the language for this run and stores it
782
800
  as the project default in `.devflow/config.yaml`, so later `--continue`
@@ -863,7 +881,7 @@ devflow approve 001 --stage spec
863
881
  ```
864
882
 
865
883
  Approval is explicit and binds the decision to the current artifact
866
- digests. For a `0.3.19` change it binds `spec.md`, `discovery.yaml` and,
884
+ digests. For a `0.3.20` change it binds `spec.md`, `discovery.yaml` and,
867
885
  when a manifest applies, the architecture manifest digest. Repeating the
868
886
  same approval is a no-op. If an artifact changes after validation,
869
887
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -874,7 +892,7 @@ and names the pending questions and assumptions. Approval also rejects a
874
892
  specification whose section 7 still lists open questions. Legacy `0.2.0`
875
893
  changes without `discovery.yaml` remain approvable with a warning.
876
894
 
877
- Only the `spec` stage is available in `0.3.19`. `--stage plan` and
895
+ Only the `spec` stage is available in `0.3.20`. `--stage plan` and
878
896
  `--stage review` are rejected. There are no `plan`, `implement` or
879
897
  `review` commands in this release.
880
898
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.3.19"
7
+ version = "0.3.20"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -230,7 +230,6 @@ def _create_specification(
230
230
 
231
231
  stop_after_discovery = (
232
232
  not auto
233
- and resume is None
234
233
  and selected_harness is not None
235
234
  and execution_mode == "interactive"
236
235
  )
@@ -326,11 +326,13 @@ class SpecWorkflow:
326
326
 
327
327
  adapter = request.adapter
328
328
  setup_result: SetupResult | None = None
329
+ discovery_session = False
329
330
  if (
330
331
  not discovery.is_complete
331
332
  and self._can_run_discovery(adapter, request, config)
332
333
  ):
333
334
  assert adapter is not None
335
+ discovery_session = True
334
336
  setup_result = self._setup_adapter(
335
337
  adapter=adapter,
336
338
  config=config,
@@ -430,7 +432,12 @@ class SpecWorkflow:
430
432
  directory=prepared.directory,
431
433
  )
432
434
 
433
- if request.stop_after_discovery:
435
+ # A new change always pauses after Discovery. A continuation pauses
436
+ # only when it opened a Discovery session, so one command never
437
+ # chains two agent sessions unless --auto is used.
438
+ if request.stop_after_discovery and (
439
+ discovery_session or not continuation
440
+ ):
434
441
  return self._build_result(
435
442
  spec=None,
436
443
  harness_name=(
@@ -425,7 +425,9 @@ def _discovery_mode_instructions(
425
425
  "a new question with the next `Qn` identifier. Update "
426
426
  f"`{discovery_path}` in place. Do not write or modify `spec.md` in "
427
427
  "this phase. Stop and report only when DevFlow can validate "
428
- "Discovery as complete."
428
+ "Discovery as complete. Then tell the user that Discovery is "
429
+ "recorded and that they must exit this session so DevFlow can "
430
+ "validate it."
429
431
  )
430
432
 
431
433
 
@@ -444,7 +446,10 @@ def _mode_instructions(
444
446
  "genuinely missing, do not write the specification: report it as "
445
447
  "a numbered item in section 7 so DevFlow can return it to "
446
448
  "Discovery. Do not finish until the file exists and contains the "
447
- "complete document."
449
+ "complete document. Then tell the user that the specification is "
450
+ "written and that they must exit this session so DevFlow can "
451
+ "validate it. Exiting earlier makes DevFlow replace it with a "
452
+ "deterministic draft."
448
453
  )
449
454
  return (
450
455
  "You are running interactively, but specification writes are "
@@ -295,6 +295,70 @@ def test_workflow_stops_after_discovery_when_requested(
295
295
  ).exists()
296
296
 
297
297
 
298
+ def test_continue_pauses_after_discovery_session_then_writes_spec(
299
+ tmp_path: Path,
300
+ ) -> None:
301
+ config = _config(tmp_path)
302
+ adapter = FakeAdapter()
303
+ prompts: list[str] = []
304
+
305
+ def idle(invocation: Invocation) -> InvocationResult:
306
+ return InvocationResult(returncode=0, stdout="", stderr="")
307
+
308
+ def answer(invocation: Invocation) -> InvocationResult:
309
+ assert adapter.run_context is not None
310
+ prompts.append(adapter.run_context.prompt)
311
+ if "Discovery Task" in adapter.run_context.prompt:
312
+ manager = DiscoveryManager(invocation.cwd)
313
+ directory = adapter.run_context.spec_directory
314
+ document = manager.load(directory, required=True)
315
+ for question in document.pending_questions:
316
+ document = manager.answer(
317
+ document,
318
+ question.id,
319
+ "Use the existing project behavior.",
320
+ )
321
+ manager.write(directory, document)
322
+ return InvocationResult(returncode=0, stdout="", stderr="")
323
+
324
+ created = _run(
325
+ config,
326
+ adapter=adapter,
327
+ executor=idle,
328
+ mode="interactive",
329
+ stop_after_discovery=True,
330
+ )
331
+ assert created.blocked is True
332
+
333
+ resumed = _run(
334
+ config,
335
+ adapter=adapter,
336
+ executor=answer,
337
+ mode="interactive",
338
+ stop_after_discovery=True,
339
+ description="",
340
+ continue_spec_id="001",
341
+ )
342
+ assert resumed.stopped_after_discovery is True
343
+ assert resumed.spec is None
344
+ assert len(prompts) == 1
345
+ assert "Discovery Task" in prompts[0]
346
+
347
+ finished = _run(
348
+ config,
349
+ adapter=adapter,
350
+ executor=answer,
351
+ mode="interactive",
352
+ stop_after_discovery=True,
353
+ description="",
354
+ continue_spec_id="001",
355
+ )
356
+ assert finished.stopped_after_discovery is False
357
+ assert finished.spec is not None
358
+ assert len(prompts) == 2
359
+ assert "Specification Task" in prompts[1]
360
+
361
+
298
362
  def test_workflow_falls_back_when_agent_output_is_invalid(
299
363
  tmp_path: Path,
300
364
  ) -> None: