devflow-toolkit 0.3.20__py3-none-any.whl → 0.3.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -178,8 +178,8 @@ def render_agent_instructions(
178
178
  "Out of Scope.",
179
179
  "5. Add or update tests for every `AC-XXX` and report each one as "
180
180
  "met or not met.",
181
- f"6. Do not edit files under `{specs_dir}/`; editing an approved "
182
- "spec makes its approval stale.",
181
+ f"6. Do not edit files under `{specs_dir}/`. To change an "
182
+ "approved spec, the user runs `devflow reopen NNN`.",
183
183
  "7. If the spec is ambiguous, wrong or conflicts with the code, "
184
184
  "stop and ask. Scope changes need a new `devflow spec`.",
185
185
  "",
devflow/cli.py CHANGED
@@ -11,6 +11,7 @@ from devflow.commands.doctor import doctor as doctor_command
11
11
  from devflow.commands.harness import harness_app
12
12
  from devflow.commands.init import init as init_command
13
13
  from devflow.commands.recover import recover as recover_command
14
+ from devflow.commands.reopen import reopen as reopen_command
14
15
  from devflow.commands.spec import spec as spec_command
15
16
  from devflow.commands.status import status as status_command
16
17
 
@@ -26,6 +27,7 @@ console = Console()
26
27
  app.command("init")(init_command)
27
28
  app.command("spec")(spec_command)
28
29
  app.command("approve")(approve_command)
30
+ app.command("reopen")(reopen_command)
29
31
  app.command("status")(status_command)
30
32
  app.command("doctor")(doctor_command)
31
33
  app.command("recover")(recover_command)
@@ -34,7 +34,10 @@ def approve(
34
34
  stage: str = typer.Option(
35
35
  "spec",
36
36
  "--stage",
37
- help="Stage to approve. Only 'spec' is available in this release.",
37
+ help=(
38
+ "Stage to approve. Defaults to 'spec', the only stage available "
39
+ "in this release."
40
+ ),
38
41
  ),
39
42
  ) -> None:
40
43
  """Approve the validated artifacts of a workflow stage."""
@@ -57,7 +60,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
57
60
  normalized = stage.strip().lower()
58
61
  if normalized != "spec":
59
62
  msg = (
60
- f"Stage '{stage}' is not available in DevFlow 0.3.17. "
63
+ f"Stage '{stage}' is not available in this release. "
61
64
  "Only the 'spec' stage can be approved."
62
65
  )
63
66
  raise UnsupportedStageError(msg)
@@ -0,0 +1,105 @@
1
+ """Implementation of the devflow reopen command."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import typer
8
+ from rich.console import Console
9
+
10
+ from devflow.core.artifacts.errors import ArtifactError
11
+ from devflow.core.config import ConfigError, ConfigManager
12
+ from devflow.core.discovery import DiscoveryError
13
+ from devflow.core.project import ProjectDetector
14
+ from devflow.core.state import (
15
+ StateError,
16
+ WorkflowLocator,
17
+ WorkflowStateManager,
18
+ )
19
+
20
+ console = Console()
21
+ error_console = Console(stderr=True)
22
+
23
+
24
+ def reopen(
25
+ spec_id: str = typer.Argument(
26
+ ...,
27
+ help="Change id (001) or change directory (001-add-health).",
28
+ ),
29
+ path: Path = typer.Argument(
30
+ Path("."),
31
+ help="Project root or a path inside it.",
32
+ ),
33
+ discovery: bool = typer.Option(
34
+ False,
35
+ "--discovery",
36
+ help="Also reopen Discovery to add or change decisions.",
37
+ ),
38
+ yes: bool = typer.Option(
39
+ False,
40
+ "--yes",
41
+ "-y",
42
+ help="Do not ask for confirmation.",
43
+ ),
44
+ ) -> None:
45
+ """Reopen an approved specification so it can be changed."""
46
+ try:
47
+ _reopen(spec_id, path, discovery=discovery, yes=yes)
48
+ except (
49
+ ArtifactError,
50
+ ConfigError,
51
+ DiscoveryError,
52
+ StateError,
53
+ FileNotFoundError,
54
+ NotADirectoryError,
55
+ OSError,
56
+ ) as error:
57
+ error_console.print(f"[red]Error:[/red] {error}")
58
+ raise typer.Exit(code=1) from error
59
+
60
+
61
+ def _reopen(spec_id: str, path: Path, *, discovery: bool, yes: bool) -> None:
62
+ root = ProjectDetector().find_root(path)
63
+ config = ConfigManager(root).load()
64
+ location = WorkflowLocator(config.specifications_path).find(spec_id)
65
+
66
+ if not yes and not typer.confirm(
67
+ f"Reopen the approved specification {location.change}?",
68
+ default=False,
69
+ ):
70
+ console.print("Cancelled. Nothing was changed.")
71
+ raise typer.Exit(code=1)
72
+
73
+ manager = WorkflowStateManager(
74
+ config.specifications_path,
75
+ project_root=config.root,
76
+ )
77
+ result = manager.reopen(location, discovery=discovery)
78
+
79
+ console.print(
80
+ f"[bold green]Reopened {location.change}.[/bold green] "
81
+ "The spec approval was withdrawn."
82
+ )
83
+ if result.archived is not None:
84
+ console.print(
85
+ "Approved spec archived: "
86
+ f"{manager.store.display_path(result.archived)}"
87
+ )
88
+ console.print(f"Workflow status: {result.state.status}")
89
+
90
+ continue_command = f"devflow spec --continue {location.spec_id}"
91
+ if discovery:
92
+ console.print(
93
+ f"\n[bold]Next:[/bold] {continue_command}\n"
94
+ "[dim]Tell the agent what to add or change. Then run the same "
95
+ "command again to write the new spec, and approve it with "
96
+ f"devflow approve {location.spec_id}.[/dim]"
97
+ )
98
+ else:
99
+ console.print(
100
+ "\n[bold]Next:[/bold] edit spec.md, then "
101
+ f"{continue_command}\n"
102
+ "[dim]DevFlow validates and registers your edited spec. Approve "
103
+ f"it again with devflow approve {location.spec_id}. To change "
104
+ "decisions instead, use devflow reopen with --discovery.[/dim]"
105
+ )
@@ -8,6 +8,7 @@ import typer
8
8
  from rich.console import Console
9
9
 
10
10
  from devflow.core.artifacts.errors import ArtifactError
11
+ from devflow.core.artifacts.models import ArtifactStatus
11
12
  from devflow.core.config import (
12
13
  ConfigError,
13
14
  ConfigManager,
@@ -17,9 +18,12 @@ from devflow.core.discovery import DiscoveryError, DiscoveryManager
17
18
  from devflow.core.project import ProjectDetector
18
19
  from devflow.core.state import (
19
20
  ChangeLocation,
21
+ ChangeStatus,
20
22
  StateError,
21
23
  WorkflowLocator,
22
24
  WorkflowStateManager,
25
+ WorkflowStatus,
26
+ artifact_blockers,
23
27
  )
24
28
 
25
29
  console = Console()
@@ -64,7 +68,17 @@ def _status(spec_id: str, path: Path) -> None:
64
68
 
65
69
  console.print(f"[bold]Change:[/bold] {location.change}")
66
70
  console.print(f"[bold]Spec id:[/bold] {location.spec_id}")
67
- console.print(f"[bold]Status:[/bold] {state.status}")
71
+ blockers = (
72
+ artifact_blockers(state, state.status)
73
+ if state.status != WorkflowStatus.DRAFT.value
74
+ else ()
75
+ )
76
+ status_line = f"[bold]Status:[/bold] {state.status}"
77
+ if blockers:
78
+ status_line += (
79
+ " [yellow](blocked: " + ", ".join(blockers) + ")[/yellow]"
80
+ )
81
+ console.print(status_line)
68
82
  console.print(f"[bold]Updated:[/bold] {state.updated_at or 'unknown'}")
69
83
  if current.last_event is not None:
70
84
  console.print(
@@ -109,6 +123,49 @@ def _status(spec_id: str, path: Path) -> None:
109
123
  "They are not approved and do not advance the change.[/dim]"
110
124
  )
111
125
 
126
+ next_step = _next_step(current, location)
127
+ if next_step:
128
+ console.print(f"\n[bold]Next:[/bold] {next_step}")
129
+
130
+
131
+ def _next_step(
132
+ current: ChangeStatus,
133
+ location: ChangeLocation,
134
+ ) -> str:
135
+ """Suggest the next action for the current workflow state."""
136
+ state = current.state
137
+ spec_id = location.spec_id
138
+ artifacts = state.artifacts
139
+ stale = any(
140
+ record.status == ArtifactStatus.STALE.value
141
+ for record in artifacts.values()
142
+ )
143
+ if current.orphans:
144
+ return f"devflow doctor {spec_id}"
145
+
146
+ spec = artifacts.get("spec")
147
+ if state.status == WorkflowStatus.SPEC_APPROVED.value:
148
+ if stale:
149
+ return f"devflow reopen {spec_id}"
150
+ spec_path = (
151
+ spec.path
152
+ if spec is not None
153
+ else f"{location.change}/spec.md"
154
+ )
155
+ return f"ask your coding agent to implement `{spec_path}`"
156
+ if (
157
+ state.status == WorkflowStatus.DRAFT.value
158
+ and spec is not None
159
+ and spec.status == ArtifactStatus.VALIDATED.value
160
+ ):
161
+ return f"review spec.md, then devflow approve {spec_id}"
162
+ if state.status in {
163
+ WorkflowStatus.DRAFT.value,
164
+ WorkflowStatus.AWAITING_CLARIFICATION.value,
165
+ }:
166
+ return f"devflow spec --continue {spec_id}"
167
+ return ""
168
+
112
169
 
113
170
  def _print_discovery(
114
171
  *,
@@ -23,6 +23,7 @@ from devflow.core.constitution import (
23
23
  specification_documents,
24
24
  )
25
25
  from devflow.core.discovery import (
26
+ DISCOVERY_PENDING,
26
27
  DiscoveryDocument,
27
28
  DiscoveryError,
28
29
  DiscoveryManager,
@@ -794,6 +795,11 @@ class SpecWorkflow:
794
795
  question_budget_maximum=settings.question_budget_maximum,
795
796
  max_rounds=settings.max_rounds,
796
797
  assumptions_enabled=settings.assumptions_enabled,
798
+ reopened=(
799
+ discovery.status == DISCOVERY_PENDING
800
+ and not discovery.pending_questions
801
+ and not discovery.pending_assumptions
802
+ ),
797
803
  )
798
804
  run_context = RunContext(
799
805
  root=config.root,
@@ -24,6 +24,7 @@ from devflow.core.state.locator import (
24
24
  from devflow.core.state.manager import (
25
25
  ApprovalResult,
26
26
  ChangeStatus,
27
+ ReopenResult,
27
28
  WorkflowStateManager,
28
29
  )
29
30
  from devflow.core.state.models import (
@@ -56,6 +57,7 @@ __all__ = [
56
57
  "InvalidEventLogError",
57
58
  "InvalidStateError",
58
59
  "InvalidTransitionError",
60
+ "ReopenResult",
59
61
  "StaleArtifactError",
60
62
  "StateError",
61
63
  "UnsupportedStageError",
@@ -38,10 +38,12 @@ ARTIFACT_EVENT_SUFFIXES = frozenset(
38
38
  {"generated", "validated", "rejected", "stale"}
39
39
  )
40
40
  APPROVAL_EVENT_SUFFIX = "approved"
41
+ REOPEN_EVENT_SUFFIX = "reopened"
41
42
 
42
43
  _EVENT_KIND_WORKFLOW = "workflow"
43
44
  _EVENT_KIND_ARTIFACT = "artifact"
44
45
  _EVENT_KIND_APPROVAL = "approval"
46
+ _EVENT_KIND_REOPEN = "reopen"
45
47
 
46
48
  _EVENT_STATUSES = {
47
49
  "generated": ArtifactStatus.GENERATED.value,
@@ -190,6 +192,8 @@ def classify_event(
190
192
  return _EVENT_KIND_ARTIFACT, stage, suffix
191
193
  if suffix == APPROVAL_EVENT_SUFFIX:
192
194
  return _EVENT_KIND_APPROVAL, stage, suffix
195
+ if suffix == REOPEN_EVENT_SUFFIX and stage in STAGE_TARGETS:
196
+ return _EVENT_KIND_REOPEN, stage, suffix
193
197
 
194
198
  msg = f"Unknown workflow event type: {event_type}"
195
199
  raise InvalidEventLogError(msg)
@@ -255,6 +259,10 @@ def apply_event(state: WorkflowState, event: WorkflowEvent) -> WorkflowState:
255
259
  if stage is None or suffix is None:
256
260
  raise _event_error(event, "artifact event is missing its stage.")
257
261
  _apply_artifact_event(state, event, stage, suffix)
262
+ elif kind == _EVENT_KIND_REOPEN:
263
+ if stage is None:
264
+ raise _event_error(event, "reopen event is missing its stage.")
265
+ _apply_reopen(state, event, stage)
258
266
  else:
259
267
  if stage is None:
260
268
  raise _event_error(event, "approval event is missing its stage.")
@@ -671,6 +679,56 @@ def _apply_approval(
671
679
  state.status = target_value
672
680
 
673
681
 
682
+ _REOPEN_TARGETS = frozenset(
683
+ {
684
+ WorkflowStatus.DRAFT.value,
685
+ WorkflowStatus.AWAITING_CLARIFICATION.value,
686
+ }
687
+ )
688
+
689
+
690
+ def _apply_reopen(
691
+ state: WorkflowState,
692
+ event: WorkflowEvent,
693
+ stage: str,
694
+ ) -> None:
695
+ """Withdraw an approval and return the workflow to an editable state."""
696
+ payload = event.payload
697
+ payload_stage = payload.get("stage")
698
+ if payload_stage != stage:
699
+ raise _event_error(
700
+ event,
701
+ f"payload stage {payload_stage!r} does not match event type.",
702
+ )
703
+ approval = state.approvals.get(stage)
704
+ if approval is None:
705
+ raise _event_error(event, f"stage {stage!r} is not approved.")
706
+ if state.status != STAGE_TARGETS[stage]:
707
+ raise _event_error(
708
+ event,
709
+ f"stage {stage!r} cannot be reopened from {state.status}.",
710
+ )
711
+ target_value = payload.get("workflow_status")
712
+ if target_value not in _REOPEN_TARGETS:
713
+ raise _event_error(
714
+ event,
715
+ f"reopen target {target_value!r} is not draft or "
716
+ "awaiting_clarification.",
717
+ )
718
+
719
+ for kind in approval.artifacts:
720
+ record = state.artifacts.get(kind)
721
+ if record is not None and record.status == ArtifactStatus.APPROVED.value:
722
+ state.artifacts[kind] = replace(
723
+ record,
724
+ status=ArtifactStatus.VALIDATED.value,
725
+ approved_at="",
726
+ updated_at=event.timestamp,
727
+ )
728
+ state.approvals.pop(stage)
729
+ state.status = target_value
730
+
731
+
674
732
  def _event_error(
675
733
  event: WorkflowEvent,
676
734
  reason: str,
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from dataclasses import dataclass
5
+ from dataclasses import dataclass, replace
6
6
  from datetime import datetime, timezone
7
7
  from pathlib import Path
8
8
  from typing import Any
@@ -26,6 +26,7 @@ from devflow.core.clock import (
26
26
  )
27
27
  from devflow.core.discovery import (
28
28
  DISCOVERY_FILENAME,
29
+ DISCOVERY_PENDING,
29
30
  DiscoveryIncompleteError,
30
31
  DiscoveryManager,
31
32
  )
@@ -147,6 +148,17 @@ class ApprovalResult:
147
148
  warnings: tuple[str, ...] = ()
148
149
 
149
150
 
151
+ @dataclass(frozen=True)
152
+ class ReopenResult:
153
+ """Outcome of reopening an approved stage."""
154
+
155
+ location: ChangeLocation
156
+ state: WorkflowState
157
+ stage: str
158
+ archived: Path | None
159
+ discovery: bool
160
+
161
+
150
162
  class WorkflowStateManager:
151
163
  """Own workflow state, artifact registration and human approvals."""
152
164
 
@@ -654,6 +666,96 @@ class WorkflowStateManager:
654
666
  warnings=tuple(warnings),
655
667
  )
656
668
 
669
+ def reopen(
670
+ self,
671
+ location: ChangeLocation,
672
+ stage: str = "spec",
673
+ *,
674
+ discovery: bool = False,
675
+ by: str = "user",
676
+ ) -> ReopenResult:
677
+ """Withdraw an approval so the change can be edited again."""
678
+ normalized = stage.strip().lower()
679
+ if normalized != "spec":
680
+ msg = (
681
+ f"Stage '{stage}' cannot be reopened. Only the 'spec' stage is "
682
+ "available in this release."
683
+ )
684
+ raise UnsupportedStageError(msg)
685
+
686
+ with self._lock(location):
687
+ state = self._load_state(location, persist=True)
688
+ state = self._reconcile_locked(location, state)
689
+ if normalized not in state.approvals:
690
+ msg = (
691
+ f"Stage '{normalized}' is not approved for {location.change}; "
692
+ "there is nothing to reopen. Continue it with 'devflow spec "
693
+ f"--continue {location.spec_id}'."
694
+ )
695
+ raise StateError(msg)
696
+ if state.status != STAGE_TARGETS[normalized]:
697
+ msg = (
698
+ f"Change '{location.change}' has advanced to {state.status} "
699
+ f"and cannot reopen the '{normalized}' stage."
700
+ )
701
+ raise StateError(msg)
702
+
703
+ archived: Path | None = None
704
+ spec_path = location.directory / "spec.md"
705
+ if spec_path.is_file() and not spec_path.is_symlink():
706
+ archived = self.store.archive(spec_path)
707
+
708
+ target = (
709
+ WorkflowStatus.AWAITING_CLARIFICATION.value
710
+ if discovery
711
+ else WorkflowStatus.DRAFT.value
712
+ )
713
+ state = self._append_and_save(
714
+ location,
715
+ state,
716
+ f"{normalized}_reopened",
717
+ {
718
+ "stage": normalized,
719
+ "by": by,
720
+ "workflow_status": target,
721
+ "discovery": discovery,
722
+ },
723
+ actor=by,
724
+ run_id=None,
725
+ )
726
+
727
+ if discovery and "discovery" in state.artifacts:
728
+ manager = DiscoveryManager(self.root, clock=self.clock)
729
+ document = manager.load(location.directory, required=True)
730
+ assert document is not None
731
+ path, digest = manager.write(
732
+ location.directory,
733
+ replace(document, status=DISCOVERY_PENDING),
734
+ )
735
+ state = self._append_and_save(
736
+ location,
737
+ state,
738
+ "discovery_generated",
739
+ {
740
+ "stage": "discovery",
741
+ "kind": "discovery",
742
+ "path": self._relative_artifact_path(path),
743
+ "digest": digest,
744
+ "source": "human",
745
+ "metadata": {"stage": "discovery", "reopened": True},
746
+ },
747
+ actor=by,
748
+ run_id=None,
749
+ )
750
+
751
+ return ReopenResult(
752
+ location=location,
753
+ state=state,
754
+ stage=normalized,
755
+ archived=archived,
756
+ discovery=discovery,
757
+ )
758
+
657
759
  def _ensure_artifact_current(
658
760
  self,
659
761
  location: ChangeLocation,
@@ -112,6 +112,7 @@ def build_discovery_prompt(
112
112
  question_budget_maximum: int = 12,
113
113
  max_rounds: int = 3,
114
114
  assumptions_enabled: bool = True,
115
+ reopened: bool = False,
115
116
  ) -> str:
116
117
  """Render the interactive discovery prompt for any harness."""
117
118
  template = load_prompt("discovery.md")
@@ -151,6 +152,7 @@ def build_discovery_prompt(
151
152
  ),
152
153
  "max_rounds": str(max(1, max_rounds)),
153
154
  "assumptions_note": assumptions_note,
155
+ "reopened_note": _REOPENED_NOTE if reopened else "",
154
156
  "permission_summary": _permission_summary(permissions),
155
157
  }
156
158
  rendered = template
@@ -159,6 +161,16 @@ def build_discovery_prompt(
159
161
  return rendered
160
162
 
161
163
 
164
+ _REOPENED_NOTE = (
165
+ "## Reopened Discovery\n\n"
166
+ "The user reopened Discovery after approving the specification. "
167
+ "Start by asking the user what to add or change. Append a new question "
168
+ "with the next `Qn` identifier for every new decision. Change an "
169
+ "existing answer only when the user explicitly asks for it, and keep "
170
+ "its id. Set `status` to `complete` when nothing remains pending.\n\n"
171
+ )
172
+
173
+
162
174
  def build_discovery_repair_prompt(
163
175
  *,
164
176
  discovery_path: str,
@@ -284,7 +284,7 @@ assumption is unaccepted, and to `complete` only when nothing remains.
284
284
  - If the answer to one question raises a new decision, append a new
285
285
  question before reporting Discovery as ready.
286
286
 
287
- ## Execution Instructions
287
+ {{reopened_note}}## Execution Instructions
288
288
 
289
289
  {{mode_instructions}}
290
290
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.20
3
+ Version: 0.3.22
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.20`.**
35
+ **Current version: `0.3.22`.**
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.20-py3-none-any.whl
155
+ pip install devflow_toolkit-0.3.22-py3-none-any.whl
156
156
  ```
157
157
 
158
158
  Verify the installation:
@@ -207,7 +207,7 @@ devflow spec --continue 001
207
207
 
208
208
  ```bash
209
209
  devflow status 001
210
- devflow approve 001 --stage spec
210
+ devflow approve 001
211
211
  ```
212
212
 
213
213
  7. Start the next change. The stored language and model are reused:
@@ -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.20 |
431
+ | Harness | Status in 0.3.22 |
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 |
@@ -642,7 +642,7 @@ While any decision is pending or any assumption remains unaccepted:
642
642
 
643
643
  - `discovery.yaml` and `context.md` are written;
644
644
  - no `spec.md` is generated;
645
- - `devflow approve --stage spec` refuses the change;
645
+ - `devflow approve` refuses the change;
646
646
  - the workflow status is `awaiting_clarification`.
647
647
 
648
648
  `context.md` is the single generated context file. Its
@@ -680,7 +680,7 @@ A generated specification is valid only when section 7 is exactly
680
680
  did not cover, DevFlow rejects the generated document, archives it,
681
681
  appends the question to `discovery.yaml`, and returns the change to
682
682
  `awaiting_clarification`. The question must be answered before a new
683
- specification is generated. `devflow approve --stage spec` rejects a
683
+ specification is generated. `devflow approve` rejects a
684
684
  specification that still lists open questions.
685
685
 
686
686
  ## Workflow
@@ -696,13 +696,14 @@ 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.20`:
699
+ Available commands in `0.3.22`:
700
700
 
701
701
  | Command | Status |
702
702
  | --- | --- |
703
703
  | `devflow init` | Implemented |
704
704
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
705
- | `devflow approve <id> --stage spec` | Implemented |
705
+ | `devflow approve <id>` (stage `spec` by default) | Implemented |
706
+ | `devflow reopen <id>` | Implemented: withdraw a spec approval to change it |
706
707
  | `devflow status <id>` | Implemented |
707
708
  | `devflow doctor <id>` | Implemented: read-only diagnostics |
708
709
  | `devflow recover <id>` | Implemented: register existing artifacts |
@@ -856,6 +857,21 @@ devflow status 001-add-a-get-patients-endpoint
856
857
  approvals, stale artifacts and orphan files. It reconciles
857
858
  `workflow.yaml` from `events.jsonl` before reporting.
858
859
 
860
+ It ends with a `Next:` line:
861
+
862
+ | State | Next |
863
+ | --- | --- |
864
+ | Discovery pending | `devflow spec --continue 001` |
865
+ | Specification validated | review `spec.md`, then `devflow approve 001` |
866
+ | Specification approved | ask your coding agent to implement `spec.md` |
867
+ | Stale artifact or orphan file | `devflow doctor 001` |
868
+
869
+ A stale artifact also appears in the status line, for example
870
+ `spec_approved (blocked: spec (stale))`.
871
+
872
+ Use `status` day to day. `doctor` is for a change that `status` reports
873
+ as blocked, or that has files on disk without workflow state.
874
+
859
875
  ### Diagnose and recover a change
860
876
 
861
877
  If `context.md`, `discovery.yaml` or `spec.md` were written outside
@@ -899,7 +915,7 @@ Recovery does not bypass review. After recovering, inspect
899
915
  `devflow status 001`, then approve explicitly:
900
916
 
901
917
  ```bash
902
- devflow approve 001 --stage spec
918
+ devflow approve 001
903
919
  ```
904
920
 
905
921
  If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
@@ -909,11 +925,11 @@ register the artifacts and names the problem. Resolve it with
909
925
  ### Approve the specification
910
926
 
911
927
  ```bash
912
- devflow approve 001 --stage spec
928
+ devflow approve 001
913
929
  ```
914
930
 
915
931
  Approval is explicit and binds the decision to the current artifact
916
- digests. For a `0.3.20` change it binds `spec.md`, `discovery.yaml` and,
932
+ digests. For a `0.3.22` change it binds `spec.md`, `discovery.yaml` and,
917
933
  when a manifest applies, the architecture manifest digest. Repeating the
918
934
  same approval is a no-op. If an artifact changes after validation,
919
935
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -924,8 +940,9 @@ and names the pending questions and assumptions. Approval also rejects a
924
940
  specification whose section 7 still lists open questions. Legacy `0.2.0`
925
941
  changes without `discovery.yaml` remain approvable with a warning.
926
942
 
927
- Only the `spec` stage is available in `0.3.20`. `--stage plan` and
928
- `--stage review` are rejected. There are no `plan`, `implement` or
943
+ Only the `spec` stage is available in `0.3.22`, so `--stage` is optional
944
+ and defaults to `spec`. `--stage plan` and `--stage review` are
945
+ rejected. There are no `plan`, `implement` or
929
946
  `review` commands in this release.
930
947
 
931
948
  ### Implement an approved specification
@@ -951,6 +968,41 @@ The generated `AGENTS.md` (or `CLAUDE.md`) tells the agent to:
951
968
  this step. Discovery and specification prompts skip it to save tokens;
952
969
  the specification still lists it in section 9.
953
970
 
971
+ ### Reopen an approved specification
972
+
973
+ An approved specification is a contract. To change it, reopen it first;
974
+ editing `spec.md` directly only marks it `stale`.
975
+
976
+ ```bash
977
+ devflow reopen 001 # fix or extend the spec text yourself
978
+ devflow reopen 001 --discovery # add or change decisions with the agent
979
+ ```
980
+
981
+ `reopen` asks for confirmation (skip it with `--yes`), copies the
982
+ current `spec.md` into `history/`, records a `spec_reopened` event and
983
+ withdraws the approval. The previous approval stays in `events.jsonl`;
984
+ nothing is deleted.
985
+
986
+ Without `--discovery`, the change returns to `draft`:
987
+
988
+ ```bash
989
+ # edit spec.md
990
+ devflow spec --continue 001 # validates and registers your edited spec
991
+ devflow approve 001
992
+ ```
993
+
994
+ With `--discovery`, the change returns to `awaiting_clarification` and
995
+ Discovery is marked pending:
996
+
997
+ ```bash
998
+ devflow spec --continue 001 # Discovery session: tell the agent what changes
999
+ devflow spec --continue 001 # writes the new spec
1000
+ devflow approve 001
1001
+ ```
1002
+
1003
+ Only an approved spec can be reopened, and only while the change is in
1004
+ `spec_approved`.
1005
+
954
1006
  ## Generated files
955
1007
 
956
1008
  ```text
@@ -990,12 +1042,13 @@ DevFlow rebuilds or rejects it rather than trusting it.
990
1042
 
991
1043
  ```text
992
1044
  generated -> validated -> approved
993
- | |
994
- +-> rejected +-> stale
1045
+ | | |
1046
+ +-> rejected +-> stale +-> reopen -> validated
995
1047
  ```
996
1048
 
997
1049
  - An approval stores the artifact kind and its SHA-256 digest.
998
- - Editing an approved artifact makes it stale.
1050
+ - Editing an approved artifact makes it stale. Use `devflow reopen` to
1051
+ withdraw the approval and change it on purpose.
999
1052
  - A stale, unvalidated or orphan artifact cannot be approved.
1000
1053
  - Semantic validation rejects malformed or inconsistent histories.
1001
1054
  - Artifact and state writes are atomic; a failed write does not leave a
@@ -1,5 +1,5 @@
1
1
  devflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- devflow/cli.py,sha256=qs3XGZxEoJaxJPkAA1kxWxfPA-vdkQYtQYipMXMYu_M,1350
2
+ devflow/cli.py,sha256=jzawrjsQMjn4JfIoCAKDfXE9lQBDzydHhtBP_etuCqs,1449
3
3
  devflow/adapters/__init__.py,sha256=WcsjXQTKzHNzMAHx82-sdJQeR3ceHRVqLWTUtRlaraE,867
4
4
  devflow/adapters/agents.py,sha256=OZnz7wAJNcIojtgaQIK1iB6QKWGgv2VCmoBp8M9DUKE,1423
5
5
  devflow/adapters/antigravity.py,sha256=tbhAWUNQt5fPemN_N8zEEdaBMPDRExpcXfF6obvvXvo,9124
@@ -7,19 +7,20 @@ devflow/adapters/base.py,sha256=YggY_IwHExdybl5S9NjwZSlmmcw9Y6z7DhQsl3JLvXs,2055
7
7
  devflow/adapters/claude_code.py,sha256=El4wYuEgLMr4NAmZG58cVlpkSn_MCOAtQ7Qq2zFIOuI,3689
8
8
  devflow/adapters/codex.py,sha256=5EVBRlYg3ClYhvN1NmUfxhBrEURLryIZTpHQkyFtzx8,3616
9
9
  devflow/adapters/detector.py,sha256=92BkNAvWs2Vh8H6xJzMweBDCw6yuYVg7sV4LoSZ8KFo,3291
10
- devflow/adapters/instructions.py,sha256=lEzV03wzAFsrENDRDWwiHUyANeAqmCgfSEqmYaf12f4,10872
10
+ devflow/adapters/instructions.py,sha256=AUje2tYnyI8yxnZQ5JlUjBON8Nz_yq4_yxpCz_DQoys,10885
11
11
  devflow/adapters/kiro.py,sha256=1w9U8oP0i2un6YeiV5uOUQ8qrOYHiF1K-788iVqHzhA,7709
12
12
  devflow/adapters/opencode.py,sha256=AtIsgKam25Y3CjI4DlXqODQO_D74Cn_N-G02MIsBI44,8503
13
13
  devflow/adapters/registry.py,sha256=G1HquOcSggwT0qm8PIm_Fv5Wj354G20rnI0C7vPhrSo,1263
14
14
  devflow/commands/__init__.py,sha256=yOLtd_4R4xdlMgAzihzIT35oyV_qcz0br-aoLebRj1c,157
15
- devflow/commands/approve.py,sha256=bVWbkDc-JVnOgsTSXlUOYxzOWrMZR-K1jzFkOYAyWXA,2741
15
+ devflow/commands/approve.py,sha256=twXcP_9OIlqgJlgiAeeB32yXa-hZjyB5unAox89UGQY,2782
16
16
  devflow/commands/config.py,sha256=9EV3S_0j_OAokE2Hd1uhA3srBbTDSOInYcnULcHG3sM,1300
17
17
  devflow/commands/doctor.py,sha256=vYk2i3OksbGpHEUFsqi7c4w44mAXRmY0OeEdO8h5j_M,4161
18
18
  devflow/commands/harness.py,sha256=0IH_PPeYmW3aQ_WnUSkFzxpe3A4FtSyjWfHq-Ug7Eos,10549
19
19
  devflow/commands/init.py,sha256=G2LDYDElWDSDPk3-1DfRtv8sW_z-9ITJH1Co6C5jiyw,17188
20
20
  devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
21
+ devflow/commands/reopen.py,sha256=bZiX-dyKgmtdKdV4FHwEwRCFvuuX5jezBCI7wIpkHYU,2971
21
22
  devflow/commands/spec.py,sha256=7glxFHKuJd33mL6YayrxRJ6TViUmmQk5rijbNepsbig,16353
22
- devflow/commands/status.py,sha256=0B6ZxVst8OVsdPowZFtKte3jBSBoD1_ZQcSkP7YYW6Q,4521
23
+ devflow/commands/status.py,sha256=8xesusAw3ToCfX7aYsd-q5YnAyXU0DouQzLGoFZebwg,6082
23
24
  devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
24
25
  devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
25
26
  devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
@@ -31,18 +32,18 @@ devflow/core/ports.py,sha256=6jlqeR40MNaz-IuZIAPimXpRKew-wMUab3KzelcTXsU,4541
31
32
  devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
32
33
  devflow/core/project.py,sha256=4OnudghY5N5rCOmafWO5Hk68M7T3-mOV0j0k0dh2luE,16891
33
34
  devflow/core/recovery.py,sha256=W2If6Ymb3ISwMN8IVQYCwptDUzhxejlF-P2NvMYyZP0,8818
34
- devflow/core/spec_workflow.py,sha256=qRKWeGc90NAkMAzX7Vdzgn25o2Ry_Z5V9kioZO6ODZ4,39830
35
+ devflow/core/spec_workflow.py,sha256=ZYBCZD5Xdiw9GVsVp_M2YYzEeFQsF9IXjFEpOpw6Fzs,40013
35
36
  devflow/core/specification.py,sha256=wRFrS64YGS6YOMQeNjdD73TlEWaSSs6_mTTg7flRlHQ,64851
36
37
  devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
37
38
  devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
38
39
  devflow/core/artifacts/models.py,sha256=xJjmY8jUAHxqYN9u1JEu8CbJB-IJg1xb9P-LDaP5_Hw,2049
39
40
  devflow/core/artifacts/store.py,sha256=ZHAhWAFiqtviwhpfQ0GDkizndpcqtpU0opTbsSJKrWA,4167
40
- devflow/core/state/__init__.py,sha256=PiHKck1ZzUTSNvZBrFnk1O20godD2-Ah1hsEku1OR78,1545
41
+ devflow/core/state/__init__.py,sha256=FNjS0Qxegx8rAz1gM6hXEV49v_KLeZ6zVDupSo_3CgI,1579
41
42
  devflow/core/state/errors.py,sha256=dgF-x4TCxQTXc1OifyT8UZSU-0PBhATjO1x6OTMagac,1017
42
- devflow/core/state/events.py,sha256=IfwFCC0jbrQsH1tzADyqwm8HtWo5fR7QDD85M6JH8N0,20698
43
+ devflow/core/state/events.py,sha256=1l_9TijGE2mTw46WEoyguBTKuUrvBBaNpR8PCRlzN8A,22422
43
44
  devflow/core/state/locator.py,sha256=WD_T_a6QiXpAipKeCUm_Y72r7OcthzUnVaulXFRLqZ0,3177
44
45
  devflow/core/state/lock.py,sha256=94llvwHtCc5WOw-Uq8kDCu4iOBpRM4ccp6Q6fLZpYZ0,2089
45
- devflow/core/state/manager.py,sha256=YDe6-H-tg7iYLCFP24R1_queoRNJnQbeqO5oe_M6eLQ,28926
46
+ devflow/core/state/manager.py,sha256=o4Qo2C3pJOpOS6Id-NB4hNeKbvvoTDwbf6E2Jv_j-pE,31876
46
47
  devflow/core/state/models.py,sha256=4GTrS34ymbJIyBeZkcCi0z0e1bsq67vdxRSnSQ9O3gc,4654
47
48
  devflow/core/state/transitions.py,sha256=Go0zLhxcujWhaZEGg7JMqcC_UJU_nEFEBbpKIqrCtrs,3581
48
49
  devflow/models/__init__.py,sha256=hXX3IDZbHgklmuzVVlpiRs5SSPnrkO5kN1-k2hIEk7E,156
@@ -58,12 +59,12 @@ devflow/profiles/django-backend/profile.yaml,sha256=SNj7a3yamdJx-P69GvIJmLkC2svO
58
59
  devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOpEmgIadcaVdf6OVmll8Oec0jEjcJ4C8MfwhQ,2052
59
60
  devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
60
61
  devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
61
- devflow/prompts/__init__.py,sha256=FxVGrfvitbWHLOeKosi-5mcvjX_cj-KC0UwYTx8wq6M,16960
62
+ devflow/prompts/__init__.py,sha256=dxPxXzY5qECes_c1RuoIfIGKcdkCwg1RLGAolled1o8,17454
62
63
  devflow/prompts/discovery-repair.md,sha256=YfTfrrw5uUZvC_x6X2lrYEDkMNhanhoe0ER3Yc2-rgI,1135
63
- devflow/prompts/discovery.md,sha256=NejWiC1QU5hfgQ90M1qRHkDmIoBS4v5INPp1eUYxy44,11540
64
+ devflow/prompts/discovery.md,sha256=9ON-NvkXTSZWwia12NqY6TU9Z9yc68oqhpiFURAHSoU,11557
64
65
  devflow/prompts/spec.md,sha256=ZbZXS_76mWqihqRD4BeHpCc62Rbqoeb-F9XmkKL3_ww,7153
65
- devflow_toolkit-0.3.20.dist-info/METADATA,sha256=oNCJ7wyMeBSgFRx1oR-83xXjBYevzc835KnuIj6aF_I,44756
66
- devflow_toolkit-0.3.20.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
67
- devflow_toolkit-0.3.20.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
68
- devflow_toolkit-0.3.20.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
69
- devflow_toolkit-0.3.20.dist-info/RECORD,,
66
+ devflow_toolkit-0.3.22.dist-info/METADATA,sha256=cgK-ggOfjyYPqgHKSZg6N6X0cxZkcfZCH_xFVd9PJkI,46584
67
+ devflow_toolkit-0.3.22.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
68
+ devflow_toolkit-0.3.22.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
69
+ devflow_toolkit-0.3.22.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
70
+ devflow_toolkit-0.3.22.dist-info/RECORD,,