devflow-toolkit 0.3.0__tar.gz → 0.3.2__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.0 → devflow_toolkit-0.3.2}/.gitignore +3 -0
  2. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/CHANGELOG.md +45 -0
  3. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/PKG-INFO +65 -7
  4. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/README.md +64 -6
  5. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/cli.py +5 -1
  7. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/approve.py +1 -1
  8. devflow_toolkit-0.3.2/src/devflow/commands/doctor.py +133 -0
  9. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/init.py +34 -0
  10. devflow_toolkit-0.3.2/src/devflow/commands/recover.py +78 -0
  11. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/spec.py +20 -0
  12. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/config.py +66 -0
  13. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/discovery.py +43 -0
  14. devflow_toolkit-0.3.2/src/devflow/core/recovery.py +259 -0
  15. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/spec_workflow.py +2 -0
  16. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/manager.py +3 -1
  17. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/prompts/__init__.py +16 -0
  18. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/prompts/spec.greenfield.md +4 -0
  19. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/prompts/spec.md +4 -0
  20. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_cli.py +40 -0
  21. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_discovery.py +59 -0
  22. devflow_toolkit-0.3.2/tests/test_recovery.py +153 -0
  23. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_spec_workflow.py +16 -0
  24. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/LICENSE +0 -0
  25. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/__init__.py +0 -0
  26. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/__init__.py +0 -0
  27. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/agents.py +0 -0
  28. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/base.py +0 -0
  29. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/claude_code.py +0 -0
  30. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/codex.py +0 -0
  31. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/detector.py +0 -0
  32. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/instructions.py +0 -0
  33. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/kiro.py +0 -0
  34. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/opencode.py +0 -0
  35. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/adapters/registry.py +0 -0
  36. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/__init__.py +0 -0
  37. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/harness.py +0 -0
  38. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/commands/status.py +0 -0
  39. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/__init__.py +0 -0
  40. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/architecture.py +0 -0
  41. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/__init__.py +0 -0
  42. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/errors.py +0 -0
  43. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/models.py +0 -0
  44. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/store.py +0 -0
  45. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/clock.py +0 -0
  46. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/constitution.py +0 -0
  47. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/ports.py +0 -0
  48. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/profile_manager.py +0 -0
  49. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/project.py +0 -0
  50. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/specification.py +0 -0
  51. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/__init__.py +0 -0
  52. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/errors.py +0 -0
  53. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/events.py +0 -0
  54. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/locator.py +0 -0
  55. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/lock.py +0 -0
  56. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/models.py +0 -0
  57. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/core/state/transitions.py +0 -0
  58. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/models/__init__.py +0 -0
  59. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/models/profile.py +0 -0
  60. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/models/project.py +0 -0
  61. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  62. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  63. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  64. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  65. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  66. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/profile.yaml +0 -0
  67. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  68. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  69. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  70. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  71. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/src/devflow/prompts/discovery.md +0 -0
  72. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_event_log.py +0 -0
  73. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_greenfield.py +0 -0
  74. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_hardening.py +0 -0
  75. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_harness_adapters.py +0 -0
  76. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_state.py +0 -0
  77. {devflow_toolkit-0.3.0 → devflow_toolkit-0.3.2}/tests/test_state_replay.py +0 -0
@@ -1,4 +1,7 @@
1
1
  .venv/
2
+ .env
3
+ .env.*
4
+ .pypirc
2
5
  __pycache__/
3
6
  *.py[cod]
4
7
  .pytest_cache/
@@ -2,6 +2,51 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.3.2 - 2026-11-03
6
+
7
+ ### Added
8
+
9
+ - `devflow doctor <id>` to diagnose a change without modifying it. It
10
+ reports whether `workflow.yaml`, `events.jsonl`, Discovery and the
11
+ specification are present and current, lists orphan artifacts, and
12
+ exits non-zero when the change is unhealthy.
13
+ - `devflow recover <id>` to register an existing complete Discovery and
14
+ a structurally valid `spec.md` when the workflow state is missing. It
15
+ preserves the artifact bytes and digests, uses `source: existing`, and
16
+ does not approve the change.
17
+ - Idempotent recovery: running `devflow recover` again once the workflow
18
+ exists reports the current state and changes nothing.
19
+
20
+ ### Changed
21
+
22
+ - Package version is `0.3.2`.
23
+ - The missing-workflow error now suggests `devflow doctor <id>` when
24
+ `context.md`, `discovery.yaml` and `spec.md` may already exist.
25
+ - `recover` refuses to register an incomplete Discovery or an invalid
26
+ specification and names how to resolve the problem.
27
+
28
+ ## 0.3.1 - 2026-11-03
29
+
30
+ ### Added
31
+
32
+ - Configurable language for specification prose through
33
+ `devflow init --language <code>` and `devflow spec --language <code>`.
34
+ - Persistent `documentation.language` setting in `.devflow/config.yaml`,
35
+ defaulting to `en`.
36
+ - Prompt instruction that selects the prose language while preserving
37
+ required headings, section numbers, `FR-XXX`/`AC-XXX` identifiers,
38
+ paths, commands and digests.
39
+
40
+ ### Changed
41
+
42
+ - Package version is `0.3.1`.
43
+ - Language names such as `Spanish` or `español` are normalized to their
44
+ short code.
45
+ - The deterministic `--no-agent` draft remains in English.
46
+ - Deterministic Discovery now blocks comment features until authorship,
47
+ authentication and moderation are decided. This prevents a comment
48
+ API from being marked complete when those decisions are missing.
49
+
5
50
  ## 0.3.0 - 2026-11-02
6
51
 
7
52
  First public release. Persistent Discovery decides whether a request is
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.0
3
+ Version: 0.3.2
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.0` MVP. It implements the **discovery and
45
+ This is the `0.3.2` 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.0-py3-none-any.whl
117
+ pip install devflow_toolkit-0.3.2-py3-none-any.whl
118
118
  ```
119
119
 
120
120
  Verify the installation:
@@ -144,10 +144,18 @@ Common options:
144
144
  devflow init --harness opencode --mode non-interactive
145
145
  devflow init --profile django-backend --name my-service
146
146
  devflow init --project-mode greenfield
147
+ devflow init --language es
147
148
  devflow init --no-agent
148
149
  devflow init --yes
149
150
  ```
150
151
 
152
+ `init --language <code>` sets the language used for specification
153
+ prose. The value is stored as `documentation.language` in
154
+ `.devflow/config.yaml` and defaults to `en`. Common language names such
155
+ as `Spanish` are normalized to their code (`es`). Required headings,
156
+ section numbers, `FR-XXX`/`AC-XXX` identifiers, paths, commands and
157
+ digests remain unchanged so structural validation still works.
158
+
151
159
  `init --project-mode greenfield` creates `.devflow/architecture.yaml`
152
160
  from a template when it does not exist. It never overwrites an existing
153
161
  manifest. Edit the manifest before running a Greenfield specification;
@@ -270,7 +278,7 @@ as an architectural constraint when it is present.
270
278
 
271
279
  ### Harnesses
272
280
 
273
- | Harness | Status in 0.3.0 |
281
+ | Harness | Status in 0.3.2 |
274
282
  | --- | --- |
275
283
  | OpenCode | Verified end-to-end in non-interactive mode |
276
284
  | Codex | Integration files are generated, but not verified for this release |
@@ -401,8 +409,10 @@ require Discovery.
401
409
  5. Review `spec.md` and resolve any remaining non-blocking questions.
402
410
  6. Record the approval.
403
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>`.
404
414
 
405
- Available commands in `0.3.0`:
415
+ Available commands in `0.3.2`:
406
416
 
407
417
  | Command | Status |
408
418
  | --- | --- |
@@ -410,6 +420,8 @@ Available commands in `0.3.0`:
410
420
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
411
421
  | `devflow approve <id> --stage spec` | Implemented |
412
422
  | `devflow status <id>` | Implemented |
423
+ | `devflow doctor <id>` | Implemented: read-only diagnostics |
424
+ | `devflow recover <id>` | Implemented: register existing artifacts |
413
425
  | `devflow version` | Implemented |
414
426
  | `devflow plan` | Not implemented |
415
427
  | `devflow approve <id> --stage plan` | Rejected |
@@ -468,11 +480,17 @@ Useful options:
468
480
  ```bash
469
481
  devflow spec "Description" --harness opencode --mode non-interactive
470
482
  devflow spec "Description" --no-agent
483
+ devflow spec "Description" --language es
471
484
  devflow spec "Change in a real project" --project-mode existing
472
485
  devflow spec "Create a new service" --project-mode greenfield
473
486
  devflow spec --continue 006
474
487
  ```
475
488
 
489
+ `spec --language <code>` overrides the configured language for that run
490
+ without changing `.devflow/config.yaml`. The deterministic `--no-agent`
491
+ draft remains in English; the language setting applies to specifications
492
+ written by an agent.
493
+
476
494
  If the harness is unavailable, fails, or returns an invalid document,
477
495
  DevFlow writes a deterministic draft and reports the reason. The command
478
496
  remains usable in CI and on machines without an AI harness, but the draft
@@ -490,6 +508,45 @@ devflow status 001-add-a-get-patients-endpoint
490
508
  approvals, stale artifacts and orphan files. It reconciles
491
509
  `workflow.yaml` from `events.jsonl` before reporting.
492
510
 
511
+ ### Diagnose and recover a change
512
+
513
+ If `context.md`, `discovery.yaml` or `spec.md` were written outside
514
+ `devflow spec`, the change can exist on disk without `workflow.yaml`,
515
+ `events.jsonl` or `runs/`. In that case `status` reports that no workflow
516
+ state was found.
517
+
518
+ Diagnose the change without changing anything:
519
+
520
+ ```bash
521
+ devflow doctor 001
522
+ ```
523
+
524
+ `doctor` checks the workflow, Discovery and specification, reports
525
+ orphan artifacts, and exits non-zero when the change is unhealthy.
526
+
527
+ If `discovery.yaml` is complete and `spec.md` is structurally valid,
528
+ register the existing artifacts without regenerating them:
529
+
530
+ ```bash
531
+ devflow recover 001
532
+ ```
533
+
534
+ `recover` creates the missing workflow state and registers Discovery and
535
+ the specification with `source: existing`. It preserves the artifact
536
+ bytes and their digests, does not modify `spec.md`, and does not approve
537
+ the change. Running it again after recovery is a no-op.
538
+
539
+ Recovery does not bypass review. After recovering, inspect
540
+ `devflow status 001`, then approve explicitly:
541
+
542
+ ```bash
543
+ devflow approve 001 --stage spec
544
+ ```
545
+
546
+ If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
547
+ register the artifacts and names the problem. Resolve it with
548
+ `devflow spec --continue 001` first.
549
+
493
550
  ### Approve the specification
494
551
 
495
552
  ```bash
@@ -497,7 +554,7 @@ devflow approve 001 --stage spec
497
554
  ```
498
555
 
499
556
  Approval is explicit and binds the decision to the current artifact
500
- digests. For a `0.3.0` change it binds `spec.md`, `discovery.yaml` and,
557
+ digests. For a `0.3.2` change it binds `spec.md`, `discovery.yaml` and,
501
558
  when a manifest applies, the architecture manifest digest. Repeating the
502
559
  same approval is a no-op. If an artifact changes after validation,
503
560
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -507,7 +564,7 @@ Discovery must be complete before approval. If it is not, approval fails
507
564
  and names the pending questions and assumptions. Legacy `0.2.0` changes
508
565
  without `discovery.yaml` remain approvable with a warning.
509
566
 
510
- Only the `spec` stage is available in `0.3.0`. `--stage plan` and
567
+ Only the `spec` stage is available in `0.3.2`. `--stage plan` and
511
568
  `--stage review` are rejected. There are no `plan`, `implement` or
512
569
  `review` commands in this release.
513
570
 
@@ -531,6 +588,7 @@ my-project/
531
588
  │ ├── spec.md # only when Discovery is complete
532
589
  │ ├── workflow.yaml # projection of events.jsonl
533
590
  │ ├── events.jsonl # append-only source of truth
591
+ │ ├── runs/ # agent run metadata
534
592
  │ └── .lock # per-change advisory lock
535
593
  ├── AGENTS.md
536
594
  ├── 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.0` MVP. It implements the **discovery and
13
+ This is the `0.3.2` 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.0-py3-none-any.whl
85
+ pip install devflow_toolkit-0.3.2-py3-none-any.whl
86
86
  ```
87
87
 
88
88
  Verify the installation:
@@ -112,10 +112,18 @@ Common options:
112
112
  devflow init --harness opencode --mode non-interactive
113
113
  devflow init --profile django-backend --name my-service
114
114
  devflow init --project-mode greenfield
115
+ devflow init --language es
115
116
  devflow init --no-agent
116
117
  devflow init --yes
117
118
  ```
118
119
 
120
+ `init --language <code>` sets the language used for specification
121
+ prose. The value is stored as `documentation.language` in
122
+ `.devflow/config.yaml` and defaults to `en`. Common language names such
123
+ as `Spanish` are normalized to their code (`es`). Required headings,
124
+ section numbers, `FR-XXX`/`AC-XXX` identifiers, paths, commands and
125
+ digests remain unchanged so structural validation still works.
126
+
119
127
  `init --project-mode greenfield` creates `.devflow/architecture.yaml`
120
128
  from a template when it does not exist. It never overwrites an existing
121
129
  manifest. Edit the manifest before running a Greenfield specification;
@@ -238,7 +246,7 @@ as an architectural constraint when it is present.
238
246
 
239
247
  ### Harnesses
240
248
 
241
- | Harness | Status in 0.3.0 |
249
+ | Harness | Status in 0.3.2 |
242
250
  | --- | --- |
243
251
  | OpenCode | Verified end-to-end in non-interactive mode |
244
252
  | Codex | Integration files are generated, but not verified for this release |
@@ -369,8 +377,10 @@ require Discovery.
369
377
  5. Review `spec.md` and resolve any remaining non-blocking questions.
370
378
  6. Record the approval.
371
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>`.
372
382
 
373
- Available commands in `0.3.0`:
383
+ Available commands in `0.3.2`:
374
384
 
375
385
  | Command | Status |
376
386
  | --- | --- |
@@ -378,6 +388,8 @@ Available commands in `0.3.0`:
378
388
  | `devflow spec` | Implemented: Discovery, specification, and `--continue` |
379
389
  | `devflow approve <id> --stage spec` | Implemented |
380
390
  | `devflow status <id>` | Implemented |
391
+ | `devflow doctor <id>` | Implemented: read-only diagnostics |
392
+ | `devflow recover <id>` | Implemented: register existing artifacts |
381
393
  | `devflow version` | Implemented |
382
394
  | `devflow plan` | Not implemented |
383
395
  | `devflow approve <id> --stage plan` | Rejected |
@@ -436,11 +448,17 @@ Useful options:
436
448
  ```bash
437
449
  devflow spec "Description" --harness opencode --mode non-interactive
438
450
  devflow spec "Description" --no-agent
451
+ devflow spec "Description" --language es
439
452
  devflow spec "Change in a real project" --project-mode existing
440
453
  devflow spec "Create a new service" --project-mode greenfield
441
454
  devflow spec --continue 006
442
455
  ```
443
456
 
457
+ `spec --language <code>` overrides the configured language for that run
458
+ without changing `.devflow/config.yaml`. The deterministic `--no-agent`
459
+ draft remains in English; the language setting applies to specifications
460
+ written by an agent.
461
+
444
462
  If the harness is unavailable, fails, or returns an invalid document,
445
463
  DevFlow writes a deterministic draft and reports the reason. The command
446
464
  remains usable in CI and on machines without an AI harness, but the draft
@@ -458,6 +476,45 @@ devflow status 001-add-a-get-patients-endpoint
458
476
  approvals, stale artifacts and orphan files. It reconciles
459
477
  `workflow.yaml` from `events.jsonl` before reporting.
460
478
 
479
+ ### Diagnose and recover a change
480
+
481
+ If `context.md`, `discovery.yaml` or `spec.md` were written outside
482
+ `devflow spec`, the change can exist on disk without `workflow.yaml`,
483
+ `events.jsonl` or `runs/`. In that case `status` reports that no workflow
484
+ state was found.
485
+
486
+ Diagnose the change without changing anything:
487
+
488
+ ```bash
489
+ devflow doctor 001
490
+ ```
491
+
492
+ `doctor` checks the workflow, Discovery and specification, reports
493
+ orphan artifacts, and exits non-zero when the change is unhealthy.
494
+
495
+ If `discovery.yaml` is complete and `spec.md` is structurally valid,
496
+ register the existing artifacts without regenerating them:
497
+
498
+ ```bash
499
+ devflow recover 001
500
+ ```
501
+
502
+ `recover` creates the missing workflow state and registers Discovery and
503
+ the specification with `source: existing`. It preserves the artifact
504
+ bytes and their digests, does not modify `spec.md`, and does not approve
505
+ the change. Running it again after recovery is a no-op.
506
+
507
+ Recovery does not bypass review. After recovering, inspect
508
+ `devflow status 001`, then approve explicitly:
509
+
510
+ ```bash
511
+ devflow approve 001 --stage spec
512
+ ```
513
+
514
+ If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
515
+ register the artifacts and names the problem. Resolve it with
516
+ `devflow spec --continue 001` first.
517
+
461
518
  ### Approve the specification
462
519
 
463
520
  ```bash
@@ -465,7 +522,7 @@ devflow approve 001 --stage spec
465
522
  ```
466
523
 
467
524
  Approval is explicit and binds the decision to the current artifact
468
- digests. For a `0.3.0` change it binds `spec.md`, `discovery.yaml` and,
525
+ digests. For a `0.3.2` change it binds `spec.md`, `discovery.yaml` and,
469
526
  when a manifest applies, the architecture manifest digest. Repeating the
470
527
  same approval is a no-op. If an artifact changes after validation,
471
528
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -475,7 +532,7 @@ Discovery must be complete before approval. If it is not, approval fails
475
532
  and names the pending questions and assumptions. Legacy `0.2.0` changes
476
533
  without `discovery.yaml` remain approvable with a warning.
477
534
 
478
- Only the `spec` stage is available in `0.3.0`. `--stage plan` and
535
+ Only the `spec` stage is available in `0.3.2`. `--stage plan` and
479
536
  `--stage review` are rejected. There are no `plan`, `implement` or
480
537
  `review` commands in this release.
481
538
 
@@ -499,6 +556,7 @@ my-project/
499
556
  │ ├── spec.md # only when Discovery is complete
500
557
  │ ├── workflow.yaml # projection of events.jsonl
501
558
  │ ├── events.jsonl # append-only source of truth
559
+ │ ├── runs/ # agent run metadata
502
560
  │ └── .lock # per-change advisory lock
503
561
  ├── AGENTS.md
504
562
  ├── 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.0"
7
+ version = "0.3.2"
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.0"
38
+ current_version = "0.3.2"
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.0. "
60
+ f"Stage '{stage}' is not available in DevFlow 0.3.2. "
61
61
  "Only the 'spec' stage can be approved."
62
62
  )
63
63
  raise UnsupportedStageError(msg)
@@ -0,0 +1,133 @@
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
+ else:
95
+ console.print(
96
+ "\n[bold yellow]Diagnosis: needs attention.[/bold yellow]"
97
+ )
98
+ console.print(
99
+ "[dim]Resolve the issues above before approving or continuing "
100
+ "this change.[/dim]"
101
+ )
102
+ return False
103
+
104
+
105
+ def _print_discovery(inspection: ChangeInspection) -> None:
106
+ console.print("\n[bold]Discovery[/bold]")
107
+ if not inspection.discovery_present:
108
+ console.print(" [yellow]missing discovery.yaml[/yellow]")
109
+ return
110
+ if inspection.discovery_error:
111
+ console.print(
112
+ f" [yellow]invalid: {inspection.discovery_error}[/yellow]"
113
+ )
114
+ return
115
+ console.print(
116
+ f" status: {inspection.discovery_status} · "
117
+ f"digest: {inspection.discovery_digest}"
118
+ )
119
+
120
+
121
+ def _print_spec(inspection: ChangeInspection) -> None:
122
+ console.print("\n[bold]Specification[/bold]")
123
+ if not inspection.spec_present:
124
+ console.print(" [yellow]missing spec.md[/yellow]")
125
+ return
126
+ if inspection.spec_valid:
127
+ console.print(
128
+ f" valid · digest: {inspection.spec_digest}"
129
+ )
130
+ else:
131
+ console.print(
132
+ f" [yellow]invalid: {inspection.spec_error}[/yellow]"
133
+ )
@@ -22,10 +22,12 @@ from devflow.core.architecture import (
22
22
  create_architecture_template,
23
23
  )
24
24
  from devflow.core.config import (
25
+ DEFAULT_DOCUMENTATION_LANGUAGE,
25
26
  EXECUTION_MODES,
26
27
  ConfigError,
27
28
  ConfigManager,
28
29
  DevFlowConfig,
30
+ canonical_documentation_language,
29
31
  canonical_execution_mode,
30
32
  )
31
33
  from devflow.core.constitution import Constitution, ConstitutionLoader
@@ -94,6 +96,13 @@ def init(
94
96
  "Default specification context: existing or greenfield."
95
97
  ),
96
98
  ),
99
+ language: Optional[str] = typer.Option(
100
+ None,
101
+ "--language",
102
+ help=(
103
+ "Language for specification prose, for example en, es or es-MX."
104
+ ),
105
+ ),
97
106
  ) -> None:
98
107
  """Initialize DevFlow in a project."""
99
108
  try:
@@ -106,6 +115,7 @@ def init(
106
115
  mode,
107
116
  no_agent,
108
117
  project_mode,
118
+ language,
109
119
  )
110
120
  except (
111
121
  ArchitectureError,
@@ -128,10 +138,19 @@ def _initialize(
128
138
  mode: Optional[str],
129
139
  no_agent: bool,
130
140
  project_mode: Optional[str],
141
+ language: Optional[str],
131
142
  ) -> None:
132
143
  requested_harness = _requested_harness(harness, no_agent)
133
144
  execution_mode = _requested_mode(mode)
134
145
  requested_project_mode = _requested_project_mode(project_mode)
146
+ requested_language = (
147
+ canonical_documentation_language(language)
148
+ if language is not None
149
+ else DEFAULT_DOCUMENTATION_LANGUAGE
150
+ )
151
+ if not requested_language:
152
+ msg = "The documentation language cannot be empty."
153
+ raise ConfigError(msg)
135
154
 
136
155
  root = path.resolve()
137
156
  if not root.exists():
@@ -176,6 +195,8 @@ def _initialize(
176
195
  mode_override=mode is not None,
177
196
  project_mode=requested_project_mode,
178
197
  project_mode_override=project_mode is not None,
198
+ language=requested_language,
199
+ language_override=language is not None,
179
200
  allow_prompt=not yes and sys.stdin.isatty(),
180
201
  )
181
202
  return
@@ -209,6 +230,7 @@ def _initialize(
209
230
  project_mode=requested_project_mode,
210
231
  agent_harness=requested_harness,
211
232
  execution_mode=execution_mode,
233
+ documentation_language=requested_language,
212
234
  )
213
235
  config_manager.ensure_directories(config)
214
236
  _ensure_architecture_template(config, requested_project_mode)
@@ -231,6 +253,10 @@ def _initialize(
231
253
  console.print(
232
254
  f"[bold]Project mode:[/bold] {config.project_mode}"
233
255
  )
256
+ console.print(
257
+ f"[bold]Documentation language:[/bold] "
258
+ f"{config.documentation_language}"
259
+ )
234
260
  console.print(
235
261
  "[bold]Detected profiles:[/bold] "
236
262
  + (", ".join(detected_names) or "none")
@@ -290,6 +316,8 @@ def _refresh_existing(
290
316
  mode_override: bool,
291
317
  project_mode: str,
292
318
  project_mode_override: bool,
319
+ language: str,
320
+ language_override: bool,
293
321
  allow_prompt: bool,
294
322
  ) -> None:
295
323
  if explicit_profiles:
@@ -316,6 +344,8 @@ def _refresh_existing(
316
344
  )
317
345
  if project_mode_override:
318
346
  config = config_manager.set_project_mode(project_mode)
347
+ if language_override:
348
+ config = config_manager.set_documentation_language(language)
319
349
 
320
350
  profiles = profile_manager.resolve(configured)
321
351
  installed = profile_manager.install_constitution(
@@ -344,6 +374,10 @@ def _refresh_existing(
344
374
  console.print(
345
375
  f"[bold]Project mode:[/bold] {config.project_mode}"
346
376
  )
377
+ console.print(
378
+ f"[bold]Documentation language:[/bold] "
379
+ f"{config.documentation_language}"
380
+ )
347
381
  if installed.copied:
348
382
  console.print(
349
383
  "[green]Missing constitution files restored:[/green] "