devflow-toolkit 0.3.1__tar.gz → 0.3.3__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 (77) hide show
  1. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/CHANGELOG.md +43 -0
  2. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/PKG-INFO +95 -12
  3. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/README.md +94 -11
  4. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/pyproject.toml +1 -1
  5. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/cli.py +5 -1
  6. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/approve.py +1 -1
  7. devflow_toolkit-0.3.3/src/devflow/commands/doctor.py +145 -0
  8. devflow_toolkit-0.3.3/src/devflow/commands/recover.py +78 -0
  9. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/spec.py +40 -1
  10. devflow_toolkit-0.3.3/src/devflow/core/recovery.py +304 -0
  11. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/spec_workflow.py +30 -0
  12. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/manager.py +3 -1
  13. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_harness_adapters.py +66 -0
  14. devflow_toolkit-0.3.3/tests/test_recovery.py +197 -0
  15. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_spec_workflow.py +27 -0
  16. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/.gitignore +0 -0
  17. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/LICENSE +0 -0
  18. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/__init__.py +0 -0
  19. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/__init__.py +0 -0
  20. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/agents.py +0 -0
  21. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/base.py +0 -0
  22. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/claude_code.py +0 -0
  23. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/codex.py +0 -0
  24. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/detector.py +0 -0
  25. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/instructions.py +0 -0
  26. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/kiro.py +0 -0
  27. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/opencode.py +0 -0
  28. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/adapters/registry.py +0 -0
  29. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/__init__.py +0 -0
  30. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/harness.py +0 -0
  31. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/init.py +0 -0
  32. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/commands/status.py +0 -0
  33. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/__init__.py +0 -0
  34. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/architecture.py +0 -0
  35. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/artifacts/__init__.py +0 -0
  36. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/artifacts/errors.py +0 -0
  37. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/artifacts/models.py +0 -0
  38. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/artifacts/store.py +0 -0
  39. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/clock.py +0 -0
  40. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/config.py +0 -0
  41. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/constitution.py +0 -0
  42. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/discovery.py +0 -0
  43. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/ports.py +0 -0
  44. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/profile_manager.py +0 -0
  45. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/project.py +0 -0
  46. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/specification.py +0 -0
  47. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/__init__.py +0 -0
  48. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/errors.py +0 -0
  49. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/events.py +0 -0
  50. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/locator.py +0 -0
  51. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/lock.py +0 -0
  52. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/models.py +0 -0
  53. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/core/state/transitions.py +0 -0
  54. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/models/__init__.py +0 -0
  55. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/models/profile.py +0 -0
  56. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/models/project.py +0 -0
  57. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  58. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  59. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  60. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  61. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  62. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/base/profile.yaml +0 -0
  63. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  64. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  65. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  66. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  67. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/prompts/__init__.py +0 -0
  68. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/prompts/discovery.md +0 -0
  69. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/prompts/spec.greenfield.md +0 -0
  70. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/src/devflow/prompts/spec.md +0 -0
  71. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_cli.py +0 -0
  72. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_discovery.py +0 -0
  73. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_event_log.py +0 -0
  74. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_greenfield.py +0 -0
  75. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_hardening.py +0 -0
  76. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_state.py +0 -0
  77. {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.3}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,49 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.3.3 - 2026-11-04
6
+
7
+ ### Added
8
+
9
+ - Interactive `devflow spec` now stops after Discovery with a visible
10
+ checkpoint. It prints the exact `devflow spec --continue <id>
11
+ --harness <name>` command so the specification can run with a
12
+ different harness.
13
+ - `--auto` preserves the previous one-shot behavior: Discovery and the
14
+ specification run in the same invocation.
15
+ - `devflow doctor` now suggests `devflow spec --continue <id>` when
16
+ Discovery is complete but `spec.md` is missing.
17
+
18
+ ### Changed
19
+
20
+ - `devflow spec --continue` creates missing workflow state when a
21
+ complete `discovery.yaml` exists. An interrupted run no longer blocks
22
+ resume with "No workflow state found".
23
+ - Package version is `0.3.3`.
24
+
25
+ ## 0.3.2 - 2026-11-03
26
+
27
+ ### Added
28
+
29
+ - `devflow doctor <id>` to diagnose a change without modifying it. It
30
+ reports whether `workflow.yaml`, `events.jsonl`, Discovery and the
31
+ specification are present and current, lists orphan artifacts, and
32
+ exits non-zero when the change is unhealthy.
33
+ - `devflow recover <id>` to register an existing complete Discovery and
34
+ a structurally valid `spec.md` when the workflow state is missing. It
35
+ preserves the artifact bytes and digests, uses `source: existing`, and
36
+ does not approve the change.
37
+ - Idempotent recovery: running `devflow recover` again once the workflow
38
+ exists reports the current state and changes nothing.
39
+
40
+ ### Changed
41
+
42
+ - Package version is `0.3.2`.
43
+ - The missing-workflow error now suggests `devflow doctor <id>` when
44
+ `context.md`, `discovery.yaml` and `spec.md` may already exist.
45
+ - `recover` refuses to register an incomplete Discovery or an invalid
46
+ specification and names how to resolve the problem.
47
+
5
48
  ## 0.3.1 - 2026-11-03
6
49
 
7
50
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Specification workflow toolkit for AI-assisted software changes
5
5
  Author: DevFlow contributors
6
6
  License-Expression: MIT
@@ -42,7 +42,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
42
42
  selected agent harness is only the execution backend that drafts the
43
43
  specification.
44
44
 
45
- This is the `0.3.1` MVP. It implements the **discovery and
45
+ This is the `0.3.3` MVP. It implements the **discovery and
46
46
  specification stages only**. It supports two specification contexts:
47
47
  **Existing Project** (the default) and **Greenfield**. It is not a
48
48
  complete SDD platform and does not include planning, implementation or
@@ -114,7 +114,7 @@ pip install devflow-toolkit
114
114
  To install a specific built artifact instead:
115
115
 
116
116
  ```bash
117
- pip install devflow_toolkit-0.3.1-py3-none-any.whl
117
+ pip install devflow_toolkit-0.3.3-py3-none-any.whl
118
118
  ```
119
119
 
120
120
  Verify the installation:
@@ -278,7 +278,7 @@ as an architectural constraint when it is present.
278
278
 
279
279
  ### Harnesses
280
280
 
281
- | Harness | Status in 0.3.1 |
281
+ | Harness | Status in 0.3.3 |
282
282
  | --- | --- |
283
283
  | OpenCode | Verified end-to-end in non-interactive mode |
284
284
  | Codex | Integration files are generated, but not verified for this release |
@@ -409,8 +409,10 @@ require Discovery.
409
409
  5. Review `spec.md` and resolve any remaining non-blocking questions.
410
410
  6. Record the approval.
411
411
  7. Inspect the state, artifacts and approval digests.
412
+ 8. If artifacts exist without workflow state, diagnose with
413
+ `devflow doctor <id>` and repair with `devflow recover <id>`.
412
414
 
413
- Available commands in `0.3.1`:
415
+ Available commands in `0.3.3`:
414
416
 
415
417
  | Command | Status |
416
418
  | --- | --- |
@@ -418,6 +420,8 @@ Available commands in `0.3.1`:
418
420
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
419
421
  | `devflow approve <id> --stage spec` | Implemented |
420
422
  | `devflow status <id>` | Implemented |
423
+ | `devflow doctor <id>` | Implemented: read-only diagnostics |
424
+ | `devflow recover <id>` | Implemented: register existing artifacts |
421
425
  | `devflow version` | Implemented |
422
426
  | `devflow plan` | Not implemented |
423
427
  | `devflow approve <id> --stage plan` | Rejected |
@@ -449,12 +453,32 @@ The command:
449
453
  5. writes the deterministic evidence or declared architecture to
450
454
  `context.md`;
451
455
  6. stops without `spec.md` when a blocking decision remains;
452
- 7. if Discovery is complete, invokes the selected harness with the
453
- shared DevFlow prompt, validates the returned specification, and
456
+ 7. in an interactive run, stops after Discovery is complete and prints
457
+ the next command, so you can choose the harness for the
458
+ specification;
459
+ 8. on `--continue` (or with `--auto`) invokes the selected harness with
460
+ the specification prompt, validates the returned specification, and
454
461
  binds it to the Discovery digest;
455
- 8. writes `spec.md` and registers the Discovery and specification
462
+ 9. writes `spec.md` and registers the Discovery and specification
456
463
  digests in the event log and the workflow projection.
457
464
 
465
+ An interactive `devflow spec` therefore uses two harness invocations:
466
+ one for Discovery and one for the specification. The first run stops at
467
+ the Discovery checkpoint. The second run resumes with the harness you
468
+ choose:
469
+
470
+ ```bash
471
+ devflow spec "Add a GET /patients endpoint"
472
+ devflow spec --continue 006 . --harness opencode
473
+ ```
474
+
475
+ Use `--auto` to run both phases in a single invocation, as earlier
476
+ releases did:
477
+
478
+ ```bash
479
+ devflow spec "Add a GET /patients endpoint" --auto
480
+ ```
481
+
458
482
  Resume an existing change:
459
483
 
460
484
  ```bash
@@ -465,7 +489,10 @@ devflow spec --continue 006
465
489
  and project mode, loads Discovery, and stops until blocking decisions
466
490
  are resolved. It reuses a current validated specification when the
467
491
  Discovery digest still matches; otherwise it archives the old
468
- specification and generates a new one.
492
+ specification and generates a new one. If an interrupted run left a
493
+ complete `discovery.yaml` without `workflow.yaml`, `--continue` creates
494
+ the missing state and registers Discovery before generating the
495
+ specification.
469
496
 
470
497
  For an existing project, DevFlow inspects relevant code and
471
498
  dependencies. For Greenfield, it uses the declared architecture and
@@ -475,13 +502,18 @@ Useful options:
475
502
 
476
503
  ```bash
477
504
  devflow spec "Description" --harness opencode --mode non-interactive
505
+ devflow spec "Description" --auto
478
506
  devflow spec "Description" --no-agent
479
507
  devflow spec "Description" --language es
480
508
  devflow spec "Change in a real project" --project-mode existing
481
509
  devflow spec "Create a new service" --project-mode greenfield
482
- devflow spec --continue 006
510
+ devflow spec --continue 006 --harness opencode
483
511
  ```
484
512
 
513
+ `--auto` keeps the older one-shot flow: Discovery and the specification
514
+ run in the same invocation. Without it, an interactive run stops at the
515
+ Discovery checkpoint.
516
+
485
517
  `spec --language <code>` overrides the configured language for that run
486
518
  without changing `.devflow/config.yaml`. The deterministic `--no-agent`
487
519
  draft remains in English; the language setting applies to specifications
@@ -504,6 +536,56 @@ devflow status 001-add-a-get-patients-endpoint
504
536
  approvals, stale artifacts and orphan files. It reconciles
505
537
  `workflow.yaml` from `events.jsonl` before reporting.
506
538
 
539
+ ### Diagnose and recover a change
540
+
541
+ If `context.md`, `discovery.yaml` or `spec.md` were written outside
542
+ `devflow spec`, the change can exist on disk without `workflow.yaml`,
543
+ `events.jsonl` or `runs/`. In that case `status` reports that no workflow
544
+ state was found.
545
+
546
+ Diagnose the change without changing anything:
547
+
548
+ ```bash
549
+ devflow doctor 001
550
+ ```
551
+
552
+ `doctor` checks the workflow, Discovery and specification, reports
553
+ orphan artifacts, and exits non-zero when the change is unhealthy.
554
+
555
+ If Discovery is complete but the specification is missing (for example,
556
+ an interrupted interactive run), `doctor` prints the resume command:
557
+
558
+ ```bash
559
+ devflow spec --continue 001
560
+ ```
561
+
562
+ `--continue` creates the missing workflow state, registers the existing
563
+ Discovery digest and generates the specification without repeating
564
+ Discovery.
565
+
566
+ If `discovery.yaml` is complete and `spec.md` is structurally valid,
567
+ register the existing artifacts without regenerating them:
568
+
569
+ ```bash
570
+ devflow recover 001
571
+ ```
572
+
573
+ `recover` creates the missing workflow state and registers Discovery and
574
+ the specification with `source: existing`. It preserves the artifact
575
+ bytes and their digests, does not modify `spec.md`, and does not approve
576
+ the change. Running it again after recovery is a no-op.
577
+
578
+ Recovery does not bypass review. After recovering, inspect
579
+ `devflow status 001`, then approve explicitly:
580
+
581
+ ```bash
582
+ devflow approve 001 --stage spec
583
+ ```
584
+
585
+ If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
586
+ register the artifacts and names the problem. Resolve it with
587
+ `devflow spec --continue 001` first.
588
+
507
589
  ### Approve the specification
508
590
 
509
591
  ```bash
@@ -511,7 +593,7 @@ devflow approve 001 --stage spec
511
593
  ```
512
594
 
513
595
  Approval is explicit and binds the decision to the current artifact
514
- digests. For a `0.3.1` change it binds `spec.md`, `discovery.yaml` and,
596
+ digests. For a `0.3.3` change it binds `spec.md`, `discovery.yaml` and,
515
597
  when a manifest applies, the architecture manifest digest. Repeating the
516
598
  same approval is a no-op. If an artifact changes after validation,
517
599
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -521,7 +603,7 @@ Discovery must be complete before approval. If it is not, approval fails
521
603
  and names the pending questions and assumptions. Legacy `0.2.0` changes
522
604
  without `discovery.yaml` remain approvable with a warning.
523
605
 
524
- Only the `spec` stage is available in `0.3.1`. `--stage plan` and
606
+ Only the `spec` stage is available in `0.3.3`. `--stage plan` and
525
607
  `--stage review` are rejected. There are no `plan`, `implement` or
526
608
  `review` commands in this release.
527
609
 
@@ -545,6 +627,7 @@ my-project/
545
627
  │ ├── spec.md # only when Discovery is complete
546
628
  │ ├── workflow.yaml # projection of events.jsonl
547
629
  │ ├── events.jsonl # append-only source of truth
630
+ │ ├── runs/ # agent run metadata
548
631
  │ └── .lock # per-change advisory lock
549
632
  ├── AGENTS.md
550
633
  ├── opencode.json # when OpenCode is selected
@@ -10,7 +10,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
10
10
  selected agent harness is only the execution backend that drafts the
11
11
  specification.
12
12
 
13
- This is the `0.3.1` MVP. It implements the **discovery and
13
+ This is the `0.3.3` MVP. It implements the **discovery and
14
14
  specification stages only**. It supports two specification contexts:
15
15
  **Existing Project** (the default) and **Greenfield**. It is not a
16
16
  complete SDD platform and does not include planning, implementation or
@@ -82,7 +82,7 @@ pip install devflow-toolkit
82
82
  To install a specific built artifact instead:
83
83
 
84
84
  ```bash
85
- pip install devflow_toolkit-0.3.1-py3-none-any.whl
85
+ pip install devflow_toolkit-0.3.3-py3-none-any.whl
86
86
  ```
87
87
 
88
88
  Verify the installation:
@@ -246,7 +246,7 @@ as an architectural constraint when it is present.
246
246
 
247
247
  ### Harnesses
248
248
 
249
- | Harness | Status in 0.3.1 |
249
+ | Harness | Status in 0.3.3 |
250
250
  | --- | --- |
251
251
  | OpenCode | Verified end-to-end in non-interactive mode |
252
252
  | Codex | Integration files are generated, but not verified for this release |
@@ -377,8 +377,10 @@ require Discovery.
377
377
  5. Review `spec.md` and resolve any remaining non-blocking questions.
378
378
  6. Record the approval.
379
379
  7. Inspect the state, artifacts and approval digests.
380
+ 8. If artifacts exist without workflow state, diagnose with
381
+ `devflow doctor <id>` and repair with `devflow recover <id>`.
380
382
 
381
- Available commands in `0.3.1`:
383
+ Available commands in `0.3.3`:
382
384
 
383
385
  | Command | Status |
384
386
  | --- | --- |
@@ -386,6 +388,8 @@ Available commands in `0.3.1`:
386
388
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
387
389
  | `devflow approve <id> --stage spec` | Implemented |
388
390
  | `devflow status <id>` | Implemented |
391
+ | `devflow doctor <id>` | Implemented: read-only diagnostics |
392
+ | `devflow recover <id>` | Implemented: register existing artifacts |
389
393
  | `devflow version` | Implemented |
390
394
  | `devflow plan` | Not implemented |
391
395
  | `devflow approve <id> --stage plan` | Rejected |
@@ -417,12 +421,32 @@ The command:
417
421
  5. writes the deterministic evidence or declared architecture to
418
422
  `context.md`;
419
423
  6. stops without `spec.md` when a blocking decision remains;
420
- 7. if Discovery is complete, invokes the selected harness with the
421
- shared DevFlow prompt, validates the returned specification, and
424
+ 7. in an interactive run, stops after Discovery is complete and prints
425
+ the next command, so you can choose the harness for the
426
+ specification;
427
+ 8. on `--continue` (or with `--auto`) invokes the selected harness with
428
+ the specification prompt, validates the returned specification, and
422
429
  binds it to the Discovery digest;
423
- 8. writes `spec.md` and registers the Discovery and specification
430
+ 9. writes `spec.md` and registers the Discovery and specification
424
431
  digests in the event log and the workflow projection.
425
432
 
433
+ An interactive `devflow spec` therefore uses two harness invocations:
434
+ one for Discovery and one for the specification. The first run stops at
435
+ the Discovery checkpoint. The second run resumes with the harness you
436
+ choose:
437
+
438
+ ```bash
439
+ devflow spec "Add a GET /patients endpoint"
440
+ devflow spec --continue 006 . --harness opencode
441
+ ```
442
+
443
+ Use `--auto` to run both phases in a single invocation, as earlier
444
+ releases did:
445
+
446
+ ```bash
447
+ devflow spec "Add a GET /patients endpoint" --auto
448
+ ```
449
+
426
450
  Resume an existing change:
427
451
 
428
452
  ```bash
@@ -433,7 +457,10 @@ devflow spec --continue 006
433
457
  and project mode, loads Discovery, and stops until blocking decisions
434
458
  are resolved. It reuses a current validated specification when the
435
459
  Discovery digest still matches; otherwise it archives the old
436
- specification and generates a new one.
460
+ specification and generates a new one. If an interrupted run left a
461
+ complete `discovery.yaml` without `workflow.yaml`, `--continue` creates
462
+ the missing state and registers Discovery before generating the
463
+ specification.
437
464
 
438
465
  For an existing project, DevFlow inspects relevant code and
439
466
  dependencies. For Greenfield, it uses the declared architecture and
@@ -443,13 +470,18 @@ Useful options:
443
470
 
444
471
  ```bash
445
472
  devflow spec "Description" --harness opencode --mode non-interactive
473
+ devflow spec "Description" --auto
446
474
  devflow spec "Description" --no-agent
447
475
  devflow spec "Description" --language es
448
476
  devflow spec "Change in a real project" --project-mode existing
449
477
  devflow spec "Create a new service" --project-mode greenfield
450
- devflow spec --continue 006
478
+ devflow spec --continue 006 --harness opencode
451
479
  ```
452
480
 
481
+ `--auto` keeps the older one-shot flow: Discovery and the specification
482
+ run in the same invocation. Without it, an interactive run stops at the
483
+ Discovery checkpoint.
484
+
453
485
  `spec --language <code>` overrides the configured language for that run
454
486
  without changing `.devflow/config.yaml`. The deterministic `--no-agent`
455
487
  draft remains in English; the language setting applies to specifications
@@ -472,6 +504,56 @@ devflow status 001-add-a-get-patients-endpoint
472
504
  approvals, stale artifacts and orphan files. It reconciles
473
505
  `workflow.yaml` from `events.jsonl` before reporting.
474
506
 
507
+ ### Diagnose and recover a change
508
+
509
+ If `context.md`, `discovery.yaml` or `spec.md` were written outside
510
+ `devflow spec`, the change can exist on disk without `workflow.yaml`,
511
+ `events.jsonl` or `runs/`. In that case `status` reports that no workflow
512
+ state was found.
513
+
514
+ Diagnose the change without changing anything:
515
+
516
+ ```bash
517
+ devflow doctor 001
518
+ ```
519
+
520
+ `doctor` checks the workflow, Discovery and specification, reports
521
+ orphan artifacts, and exits non-zero when the change is unhealthy.
522
+
523
+ If Discovery is complete but the specification is missing (for example,
524
+ an interrupted interactive run), `doctor` prints the resume command:
525
+
526
+ ```bash
527
+ devflow spec --continue 001
528
+ ```
529
+
530
+ `--continue` creates the missing workflow state, registers the existing
531
+ Discovery digest and generates the specification without repeating
532
+ Discovery.
533
+
534
+ If `discovery.yaml` is complete and `spec.md` is structurally valid,
535
+ register the existing artifacts without regenerating them:
536
+
537
+ ```bash
538
+ devflow recover 001
539
+ ```
540
+
541
+ `recover` creates the missing workflow state and registers Discovery and
542
+ the specification with `source: existing`. It preserves the artifact
543
+ bytes and their digests, does not modify `spec.md`, and does not approve
544
+ the change. Running it again after recovery is a no-op.
545
+
546
+ Recovery does not bypass review. After recovering, inspect
547
+ `devflow status 001`, then approve explicitly:
548
+
549
+ ```bash
550
+ devflow approve 001 --stage spec
551
+ ```
552
+
553
+ If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
554
+ register the artifacts and names the problem. Resolve it with
555
+ `devflow spec --continue 001` first.
556
+
475
557
  ### Approve the specification
476
558
 
477
559
  ```bash
@@ -479,7 +561,7 @@ devflow approve 001 --stage spec
479
561
  ```
480
562
 
481
563
  Approval is explicit and binds the decision to the current artifact
482
- digests. For a `0.3.1` change it binds `spec.md`, `discovery.yaml` and,
564
+ digests. For a `0.3.3` change it binds `spec.md`, `discovery.yaml` and,
483
565
  when a manifest applies, the architecture manifest digest. Repeating the
484
566
  same approval is a no-op. If an artifact changes after validation,
485
567
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -489,7 +571,7 @@ Discovery must be complete before approval. If it is not, approval fails
489
571
  and names the pending questions and assumptions. Legacy `0.2.0` changes
490
572
  without `discovery.yaml` remain approvable with a warning.
491
573
 
492
- Only the `spec` stage is available in `0.3.1`. `--stage plan` and
574
+ Only the `spec` stage is available in `0.3.3`. `--stage plan` and
493
575
  `--stage review` are rejected. There are no `plan`, `implement` or
494
576
  `review` commands in this release.
495
577
 
@@ -513,6 +595,7 @@ my-project/
513
595
  │ ├── spec.md # only when Discovery is complete
514
596
  │ ├── workflow.yaml # projection of events.jsonl
515
597
  │ ├── events.jsonl # append-only source of truth
598
+ │ ├── runs/ # agent run metadata
516
599
  │ └── .lock # per-change advisory lock
517
600
  ├── AGENTS.md
518
601
  ├── opencode.json # when OpenCode is selected
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.3.1"
7
+ version = "0.3.3"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -6,7 +6,9 @@ import typer
6
6
  from rich.console import Console
7
7
 
8
8
  from devflow.commands.approve import approve as approve_command
9
+ from devflow.commands.doctor import doctor as doctor_command
9
10
  from devflow.commands.init import init as init_command
11
+ from devflow.commands.recover import recover as recover_command
10
12
  from devflow.commands.spec import spec as spec_command
11
13
  from devflow.commands.status import status as status_command
12
14
 
@@ -23,6 +25,8 @@ app.command("init")(init_command)
23
25
  app.command("spec")(spec_command)
24
26
  app.command("approve")(approve_command)
25
27
  app.command("status")(status_command)
28
+ app.command("doctor")(doctor_command)
29
+ app.command("recover")(recover_command)
26
30
 
27
31
 
28
32
  @app.command()
@@ -31,7 +35,7 @@ def version() -> None:
31
35
  try:
32
36
  current_version = package_version("devflow-toolkit")
33
37
  except PackageNotFoundError:
34
- current_version = "0.3.1"
38
+ current_version = "0.3.3"
35
39
  console.print(f"DevFlow v{current_version}")
36
40
 
37
41
 
@@ -57,7 +57,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
57
57
  normalized = stage.strip().lower()
58
58
  if normalized != "spec":
59
59
  msg = (
60
- f"Stage '{stage}' is not available in DevFlow 0.3.1. "
60
+ f"Stage '{stage}' is not available in DevFlow 0.3.3. "
61
61
  "Only the 'spec' stage can be approved."
62
62
  )
63
63
  raise UnsupportedStageError(msg)
@@ -0,0 +1,145 @@
1
+ """Implementation of the devflow doctor 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.recovery import ChangeInspection, inspect_change
15
+ from devflow.core.state import StateError, WorkflowLocator
16
+
17
+ console = Console()
18
+ error_console = Console(stderr=True)
19
+
20
+
21
+ def doctor(
22
+ spec_id: str = typer.Argument(
23
+ ...,
24
+ help="Change id (001) or change directory (001-add-health).",
25
+ ),
26
+ path: Path = typer.Argument(
27
+ Path("."),
28
+ help="Project root or a path inside it.",
29
+ ),
30
+ ) -> None:
31
+ """Diagnose a change, including artifacts written without state."""
32
+ try:
33
+ healthy = _doctor(spec_id, path)
34
+ except (
35
+ ArtifactError,
36
+ ConfigError,
37
+ DiscoveryError,
38
+ StateError,
39
+ FileNotFoundError,
40
+ NotADirectoryError,
41
+ OSError,
42
+ ) as error:
43
+ error_console.print(f"[red]Error:[/red] {error}")
44
+ raise typer.Exit(code=1) from error
45
+ if not healthy:
46
+ raise typer.Exit(code=1)
47
+
48
+
49
+ def _doctor(spec_id: str, path: Path) -> bool:
50
+ root = ProjectDetector().find_root(path)
51
+ config = ConfigManager(root).load()
52
+ location = WorkflowLocator(config.specifications_path).find(spec_id)
53
+ inspection = inspect_change(config, location)
54
+
55
+ console.print(f"[bold]Change:[/bold] {location.change}")
56
+ console.print(f"[bold]Directory:[/bold] {location.directory}")
57
+ console.print(
58
+ "[bold]Workflow:[/bold] "
59
+ + (
60
+ f"present ({inspection.workflow_status})"
61
+ if inspection.workflow_present
62
+ else "[yellow]missing[/yellow]"
63
+ )
64
+ )
65
+ console.print(
66
+ "[bold]Events:[/bold] "
67
+ + ("present" if inspection.events_present else "[yellow]missing[/yellow]")
68
+ )
69
+ _print_discovery(inspection)
70
+ _print_spec(inspection)
71
+
72
+ if inspection.warnings:
73
+ console.print("\n[bold]Warnings[/bold]")
74
+ for warning in inspection.warnings:
75
+ console.print(f"[yellow]- {warning}[/yellow]")
76
+ if inspection.orphans:
77
+ console.print("\n[bold]Orphan artifacts[/bold]")
78
+ for orphan in inspection.orphans:
79
+ console.print(f"[yellow]- {orphan} is not registered[/yellow]")
80
+
81
+ if inspection.healthy:
82
+ console.print("\n[bold green]Diagnosis: healthy.[/bold green]")
83
+ return True
84
+
85
+ if inspection.can_recover:
86
+ console.print(
87
+ "\n[bold yellow]Diagnosis: recoverable without regenerating the "
88
+ "artifacts.[/bold yellow]"
89
+ )
90
+ console.print(
91
+ "[bold]Next:[/bold] "
92
+ f"devflow recover {location.spec_id} {root}"
93
+ )
94
+ elif inspection.can_resume:
95
+ console.print(
96
+ "\n[bold yellow]Diagnosis: Discovery is complete but the "
97
+ "specification is missing.[/bold yellow]"
98
+ )
99
+ console.print(
100
+ "[bold]Next:[/bold] "
101
+ f"devflow spec --continue {location.spec_id} {root}"
102
+ )
103
+ console.print(
104
+ "[dim]The existing Discovery record will be reused.[/dim]"
105
+ )
106
+ else:
107
+ console.print(
108
+ "\n[bold yellow]Diagnosis: needs attention.[/bold yellow]"
109
+ )
110
+ console.print(
111
+ "[dim]Resolve the issues above before approving or continuing "
112
+ "this change.[/dim]"
113
+ )
114
+ return False
115
+
116
+
117
+ def _print_discovery(inspection: ChangeInspection) -> None:
118
+ console.print("\n[bold]Discovery[/bold]")
119
+ if not inspection.discovery_present:
120
+ console.print(" [yellow]missing discovery.yaml[/yellow]")
121
+ return
122
+ if inspection.discovery_error:
123
+ console.print(
124
+ f" [yellow]invalid: {inspection.discovery_error}[/yellow]"
125
+ )
126
+ return
127
+ console.print(
128
+ f" status: {inspection.discovery_status} · "
129
+ f"digest: {inspection.discovery_digest}"
130
+ )
131
+
132
+
133
+ def _print_spec(inspection: ChangeInspection) -> None:
134
+ console.print("\n[bold]Specification[/bold]")
135
+ if not inspection.spec_present:
136
+ console.print(" [yellow]missing spec.md[/yellow]")
137
+ return
138
+ if inspection.spec_valid:
139
+ console.print(
140
+ f" valid · digest: {inspection.spec_digest}"
141
+ )
142
+ else:
143
+ console.print(
144
+ f" [yellow]invalid: {inspection.spec_error}[/yellow]"
145
+ )