devflow-toolkit 0.4.5__tar.gz → 0.4.6__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 (100) hide show
  1. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/CHANGELOG.md +45 -1
  2. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/PKG-INFO +67 -7
  3. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/README.md +2 -1
  4. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/docs/REFERENCE.md +66 -6
  5. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/claude_code.py +11 -0
  7. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/opencode.py +15 -0
  8. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/harness.py +31 -7
  9. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/spec.py +13 -1
  10. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/discovery.py +157 -0
  11. devflow_toolkit-0.4.6/src/devflow/core/model_tiers.py +62 -0
  12. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/ports.py +10 -0
  13. devflow_toolkit-0.4.6/src/devflow/core/sessions.py +66 -0
  14. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/spec_workflow.py +73 -0
  15. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/specification.py +207 -25
  16. devflow_toolkit-0.4.6/src/devflow/prompts/discovery.md +272 -0
  17. devflow_toolkit-0.4.6/src/devflow/prompts/spec.md +230 -0
  18. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_security_fixes.py +150 -0
  19. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_spec_workflow.py +154 -0
  20. devflow_toolkit-0.4.5/src/devflow/prompts/discovery.md +0 -413
  21. devflow_toolkit-0.4.5/src/devflow/prompts/spec.md +0 -246
  22. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/.gitignore +0 -0
  23. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/LICENSE +0 -0
  24. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/docs/PRESENTATION.md +0 -0
  25. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/docs/PUBLISHING.md +0 -0
  26. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/__init__.py +0 -0
  27. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/__init__.py +0 -0
  28. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/agents.py +0 -0
  29. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/antigravity.py +0 -0
  30. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/base.py +0 -0
  31. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/codex.py +0 -0
  32. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/detector.py +0 -0
  33. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/instructions.py +0 -0
  34. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/kiro.py +0 -0
  35. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/adapters/registry.py +0 -0
  36. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/cli.py +0 -0
  37. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/__init__.py +0 -0
  38. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/approve.py +0 -0
  39. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/config.py +0 -0
  40. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/doctor.py +0 -0
  41. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/init.py +0 -0
  42. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/recover.py +0 -0
  43. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/reopen.py +0 -0
  44. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/security.py +0 -0
  45. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/commands/status.py +0 -0
  46. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/__init__.py +0 -0
  47. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/architecture.py +0 -0
  48. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/artifacts/__init__.py +0 -0
  49. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/artifacts/errors.py +0 -0
  50. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/artifacts/models.py +0 -0
  51. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/artifacts/store.py +0 -0
  52. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/clock.py +0 -0
  53. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/config.py +0 -0
  54. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/constitution.py +0 -0
  55. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/file_types.py +0 -0
  56. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/profile_manager.py +0 -0
  57. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/project.py +0 -0
  58. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/recovery.py +0 -0
  59. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/safe_files.py +0 -0
  60. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/security_baseline.py +0 -0
  61. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/security_tools.py +0 -0
  62. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/__init__.py +0 -0
  63. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/errors.py +0 -0
  64. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/events.py +0 -0
  65. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/locator.py +0 -0
  66. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/lock.py +0 -0
  67. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/manager.py +0 -0
  68. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/models.py +0 -0
  69. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/signing.py +0 -0
  70. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/core/state/transitions.py +0 -0
  71. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/hooks/__init__.py +0 -0
  72. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/hooks/claude_guard.py +0 -0
  73. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/models/__init__.py +0 -0
  74. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/models/profile.py +0 -0
  75. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/models/project.py +0 -0
  76. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  77. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  78. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  79. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  80. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  81. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/base/profile.yaml +0 -0
  82. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  83. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  84. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  85. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  86. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/prompts/__init__.py +0 -0
  87. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/src/devflow/prompts/discovery-repair.md +0 -0
  88. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/conftest.py +0 -0
  89. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_cli.py +0 -0
  90. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_discovery.py +0 -0
  91. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_discovery_decisions.py +0 -0
  92. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_event_log.py +0 -0
  93. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_greenfield.py +0 -0
  94. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_hardening.py +0 -0
  95. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_harness_adapters.py +0 -0
  96. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_recovery.py +0 -0
  97. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_security_baseline.py +0 -0
  98. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_security_tools.py +0 -0
  99. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_state.py +0 -0
  100. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.6}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,50 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.4.6 - 2026-11-30
6
+
7
+ ### Added
8
+
9
+ - `devflow spec --scope <path>` limits a new change to one or more
10
+ directories or files: the analysis and the agent stay inside them.
11
+ - In projects with 150 or more source files, when the request does not
12
+ name a module, Discovery first asks where the change happens, offering
13
+ the directories with the strongest matches. Answering with a path
14
+ limits the analysis to it.
15
+ - The specification run resumes the Discovery session with Claude Code
16
+ (`--session-id` / `--resume`) and OpenCode (`--session`) when both
17
+ phases use the same harness, so the agent does not start from zero and
18
+ the provider can reuse its cache. A non-interactive run that cannot
19
+ resume starts a new session. Sessions are stored in
20
+ `.devflow/.local/sessions.json`, ignored by git.
21
+ - Model lists in `init`, `harness use` and `harness models` mark each
22
+ model as mid-range (recommended for Discovery and specs), most capable
23
+ (best for implementation) or small (not recommended), and show the
24
+ recommended ones first.
25
+
26
+ ### Changed
27
+
28
+ - `context.md` gives a reading plan: the ten most relevant files, each
29
+ with the matching classes or functions and their line ranges, and an
30
+ instruction to read only those ranges. Generic words (*add*, *create*,
31
+ *new*...) and `AGENTS.md`, `CLAUDE.md` and `CHANGELOG.md` no longer
32
+ count as evidence, and files matching several request terms rank
33
+ higher.
34
+ - The Discovery prompt is about a third shorter and the specification
35
+ prompt slightly shorter. Both put the request, paths and digests at the
36
+ end so the fixed part can be cached between specs, and both ask the
37
+ agent to read only the constitution sections that apply.
38
+
39
+ ### Upgrade notes
40
+
41
+ - In projects with 150 or more source files, a new change whose request
42
+ names no module now asks where the change happens. With `--no-agent`,
43
+ answer it in `discovery.yaml` or pass `--scope`.
44
+
45
+ ### Package
46
+
47
+ - Package version is `0.4.6`.
48
+
5
49
  ## 0.4.5 - 2026-11-30
6
50
 
7
51
  ### Changed
@@ -23,7 +67,7 @@ All notable changes to DevFlow Toolkit are documented in this file.
23
67
 
24
68
  ### Package
25
69
 
26
- - Package version is `0.4.5`.
70
+ - Package version is `0.4.5`, published on TestPyPI and PyPI.
27
71
 
28
72
  ## 0.4.4 - 2026-11-30
29
73
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.4.5
3
+ Version: 0.4.6
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.4.5`.**
35
+ **Current version: `0.4.6`.**
36
36
 
37
37
  Before any code is written, you and the AI agree on what will be built
38
38
  and approve it as a spec. The agent then implements once, on something
@@ -210,7 +210,7 @@ pip install devflow-toolkit
210
210
  To install a specific built artifact instead:
211
211
 
212
212
  ```bash
213
- pip install devflow_toolkit-0.4.5-py3-none-any.whl
213
+ pip install devflow_toolkit-0.4.6-py3-none-any.whl
214
214
  ```
215
215
 
216
216
  Verify the installation:
@@ -527,7 +527,7 @@ as an architectural constraint when it is present.
527
527
 
528
528
  ### Harnesses
529
529
 
530
- | Harness | Status in 0.4.5 |
530
+ | Harness | Status in 0.4.6 |
531
531
  | --- | --- |
532
532
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
533
533
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -984,7 +984,7 @@ reference.
984
984
  8. If artifacts exist without workflow state, diagnose with
985
985
  `devflow doctor <id>` and repair with `devflow recover <id>`.
986
986
 
987
- Available commands in `0.4.5`:
987
+ Available commands in `0.4.6`:
988
988
 
989
989
  | Command | Status |
990
990
  | --- | --- |
@@ -1134,6 +1134,64 @@ remains usable in CI and on machines without an AI harness, but the draft
1134
1134
  still requires human review. A request that is not ready never receives
1135
1135
  a silent deterministic specification: Discovery stops instead.
1136
1136
 
1137
+ ### Large projects and token usage
1138
+
1139
+ Each agent session starts from zero and reads the prompt, the context,
1140
+ the constitution and the code it explores. DevFlow keeps that small:
1141
+
1142
+ - **Precise reading plan.** `context.md` lists the most relevant files
1143
+ first (at most ten), each with the classes or functions that matched
1144
+ and their line ranges, for example
1145
+ `apps/accounts/views.py — LoginView (L4-7)`. The agent reads only
1146
+ those ranges and opens other files only when a decision needs them.
1147
+ Generic words such as *add*, *create* or *new* and agent instruction
1148
+ files (`AGENTS.md`, `CLAUDE.md`) are not used as evidence.
1149
+ - **Where the change happens.** In a project with 150 or more source
1150
+ files, when the request does not name a module, Discovery first asks
1151
+ where the change goes. The options are the directories with the
1152
+ strongest matches, so the question helps even someone who does not
1153
+ know the code. Answer with a path to limit the analysis to it, or name
1154
+ a module, file, class or function.
1155
+ - **`--scope`.** Skip that question by stating the place yourself:
1156
+
1157
+ ```bash
1158
+ devflow spec "Add login with username and password" --scope apps/accounts
1159
+ ```
1160
+
1161
+ Repeat `--scope` for several places. The analysis and the agent stay
1162
+ inside them. It applies to new changes; to move an existing one, use
1163
+ `devflow reopen <id> --add`.
1164
+ - **Shorter prompts, cache-friendly.** The fixed instructions come first
1165
+ and the request, paths and digests last, so providers that cache
1166
+ prompts (Anthropic, OpenAI, Gemini) can reuse the fixed part between
1167
+ specs. DevFlow cannot force a provider to cache; this only makes it
1168
+ possible.
1169
+ - **One session for both phases.** With Claude Code and OpenCode, the
1170
+ specification run resumes the Discovery session (`--resume` /
1171
+ `--session`) when you use the same harness, so the agent keeps what it
1172
+ already read and the provider can reuse its cache. If the session
1173
+ cannot be resumed in a non-interactive run, DevFlow starts a new one.
1174
+ Codex, Kiro and Antigravity always start a new session. Sessions are
1175
+ recorded in `.devflow/.local/sessions.json`, which git ignores.
1176
+
1177
+ ### Choosing a model
1178
+
1179
+ `devflow init`, `devflow harness use` and `devflow harness models` mark
1180
+ each model with a recommendation and list the recommended ones first:
1181
+
1182
+ - **mid-range** (for example Sonnet, GPT-5 mini, Gemini Flash):
1183
+ recommended for Discovery and specs. DevFlow already provides the
1184
+ stack, the code evidence and the security baseline, and validates the
1185
+ result.
1186
+ - **most capable** (for example Opus, GPT-5, Gemini Pro): best for
1187
+ implementation.
1188
+ - **small** (for example Haiku, nano, Flash Lite): not recommended; they
1189
+ ask poor questions and miss decisions.
1190
+
1191
+ The classification comes from the model name; unknown names are shown
1192
+ without a label. Use `--model` on `devflow spec` to pick a model for one
1193
+ run.
1194
+
1137
1195
  ### Check status
1138
1196
 
1139
1197
  ```bash
@@ -1217,7 +1275,7 @@ devflow approve 001
1217
1275
  ```
1218
1276
 
1219
1277
  Approval is explicit and binds the decision to the current artifact
1220
- digests. For a `0.4.5` change it binds `spec.md`, `discovery.yaml` and,
1278
+ digests. For a `0.4.6` change it binds `spec.md`, `discovery.yaml` and,
1221
1279
  when a manifest applies, the architecture manifest digest. Repeating the
1222
1280
  same approval is a no-op. If an artifact changes after validation,
1223
1281
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1237,7 +1295,7 @@ and names the pending questions and assumptions. Approval also rejects a
1237
1295
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1238
1296
  changes without `discovery.yaml` remain approvable with a warning.
1239
1297
 
1240
- Only the `spec` stage is available in `0.4.5`, so `--stage` is optional
1298
+ Only the `spec` stage is available in `0.4.6`, so `--stage` is optional
1241
1299
  and defaults to `spec`. `--stage plan` and `--stage review` are
1242
1300
  rejected. There are no `plan`, `implement` or
1243
1301
  `review` commands in this release.
@@ -1319,6 +1377,8 @@ my-project/
1319
1377
  │ ├── config.yaml
1320
1378
  │ ├── architecture.yaml # declared architecture (Greenfield)
1321
1379
  │ ├── .specs.lock # serializes specification id assignment
1380
+ │ ├── .local/ # machine-local, ignored by git
1381
+ │ │ └── sessions.json # harness session of each change
1322
1382
  │ ├── constitution/
1323
1383
  │ │ ├── constitution.md
1324
1384
  │ │ ├── code-standards.md
@@ -32,7 +32,7 @@ tokens, which cost several times more than input tokens.
32
32
  The goal is not to generate code faster, but to decide better before
33
33
  generating it. Thinking is cheap; redoing code is expensive.
34
34
 
35
- Current version: `0.4.5` · Python 3.11+ · Linux and macOS
35
+ Current version: `0.4.6` · Python 3.11+ · Linux and macOS
36
36
 
37
37
  ## Install
38
38
 
@@ -160,6 +160,7 @@ version is kept in `history/`.
160
160
  | `devflow init` | Prepare the project and the agent integration |
161
161
  | `devflow spec "…"` | Start a change with Discovery |
162
162
  | `devflow spec --continue 001` | Resume Discovery or write the spec |
163
+ | `devflow spec "…" --scope apps/accounts` | Limit a new change to a module (large projects) |
163
164
  | `devflow approve 001` | Approve the spec |
164
165
  | `devflow reopen 001 --add "…"` | Extend or change the spec with the agent |
165
166
  | `devflow status 001` | Show where the change is and the next command |
@@ -1,6 +1,6 @@
1
1
  # DevFlow Toolkit
2
2
 
3
- **Current version: `0.4.5`.**
3
+ **Current version: `0.4.6`.**
4
4
 
5
5
  Before any code is written, you and the AI agree on what will be built
6
6
  and approve it as a spec. The agent then implements once, on something
@@ -178,7 +178,7 @@ pip install devflow-toolkit
178
178
  To install a specific built artifact instead:
179
179
 
180
180
  ```bash
181
- pip install devflow_toolkit-0.4.5-py3-none-any.whl
181
+ pip install devflow_toolkit-0.4.6-py3-none-any.whl
182
182
  ```
183
183
 
184
184
  Verify the installation:
@@ -495,7 +495,7 @@ as an architectural constraint when it is present.
495
495
 
496
496
  ### Harnesses
497
497
 
498
- | Harness | Status in 0.4.5 |
498
+ | Harness | Status in 0.4.6 |
499
499
  | --- | --- |
500
500
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
501
501
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -952,7 +952,7 @@ reference.
952
952
  8. If artifacts exist without workflow state, diagnose with
953
953
  `devflow doctor <id>` and repair with `devflow recover <id>`.
954
954
 
955
- Available commands in `0.4.5`:
955
+ Available commands in `0.4.6`:
956
956
 
957
957
  | Command | Status |
958
958
  | --- | --- |
@@ -1102,6 +1102,64 @@ remains usable in CI and on machines without an AI harness, but the draft
1102
1102
  still requires human review. A request that is not ready never receives
1103
1103
  a silent deterministic specification: Discovery stops instead.
1104
1104
 
1105
+ ### Large projects and token usage
1106
+
1107
+ Each agent session starts from zero and reads the prompt, the context,
1108
+ the constitution and the code it explores. DevFlow keeps that small:
1109
+
1110
+ - **Precise reading plan.** `context.md` lists the most relevant files
1111
+ first (at most ten), each with the classes or functions that matched
1112
+ and their line ranges, for example
1113
+ `apps/accounts/views.py — LoginView (L4-7)`. The agent reads only
1114
+ those ranges and opens other files only when a decision needs them.
1115
+ Generic words such as *add*, *create* or *new* and agent instruction
1116
+ files (`AGENTS.md`, `CLAUDE.md`) are not used as evidence.
1117
+ - **Where the change happens.** In a project with 150 or more source
1118
+ files, when the request does not name a module, Discovery first asks
1119
+ where the change goes. The options are the directories with the
1120
+ strongest matches, so the question helps even someone who does not
1121
+ know the code. Answer with a path to limit the analysis to it, or name
1122
+ a module, file, class or function.
1123
+ - **`--scope`.** Skip that question by stating the place yourself:
1124
+
1125
+ ```bash
1126
+ devflow spec "Add login with username and password" --scope apps/accounts
1127
+ ```
1128
+
1129
+ Repeat `--scope` for several places. The analysis and the agent stay
1130
+ inside them. It applies to new changes; to move an existing one, use
1131
+ `devflow reopen <id> --add`.
1132
+ - **Shorter prompts, cache-friendly.** The fixed instructions come first
1133
+ and the request, paths and digests last, so providers that cache
1134
+ prompts (Anthropic, OpenAI, Gemini) can reuse the fixed part between
1135
+ specs. DevFlow cannot force a provider to cache; this only makes it
1136
+ possible.
1137
+ - **One session for both phases.** With Claude Code and OpenCode, the
1138
+ specification run resumes the Discovery session (`--resume` /
1139
+ `--session`) when you use the same harness, so the agent keeps what it
1140
+ already read and the provider can reuse its cache. If the session
1141
+ cannot be resumed in a non-interactive run, DevFlow starts a new one.
1142
+ Codex, Kiro and Antigravity always start a new session. Sessions are
1143
+ recorded in `.devflow/.local/sessions.json`, which git ignores.
1144
+
1145
+ ### Choosing a model
1146
+
1147
+ `devflow init`, `devflow harness use` and `devflow harness models` mark
1148
+ each model with a recommendation and list the recommended ones first:
1149
+
1150
+ - **mid-range** (for example Sonnet, GPT-5 mini, Gemini Flash):
1151
+ recommended for Discovery and specs. DevFlow already provides the
1152
+ stack, the code evidence and the security baseline, and validates the
1153
+ result.
1154
+ - **most capable** (for example Opus, GPT-5, Gemini Pro): best for
1155
+ implementation.
1156
+ - **small** (for example Haiku, nano, Flash Lite): not recommended; they
1157
+ ask poor questions and miss decisions.
1158
+
1159
+ The classification comes from the model name; unknown names are shown
1160
+ without a label. Use `--model` on `devflow spec` to pick a model for one
1161
+ run.
1162
+
1105
1163
  ### Check status
1106
1164
 
1107
1165
  ```bash
@@ -1185,7 +1243,7 @@ devflow approve 001
1185
1243
  ```
1186
1244
 
1187
1245
  Approval is explicit and binds the decision to the current artifact
1188
- digests. For a `0.4.5` change it binds `spec.md`, `discovery.yaml` and,
1246
+ digests. For a `0.4.6` change it binds `spec.md`, `discovery.yaml` and,
1189
1247
  when a manifest applies, the architecture manifest digest. Repeating the
1190
1248
  same approval is a no-op. If an artifact changes after validation,
1191
1249
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1205,7 +1263,7 @@ and names the pending questions and assumptions. Approval also rejects a
1205
1263
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1206
1264
  changes without `discovery.yaml` remain approvable with a warning.
1207
1265
 
1208
- Only the `spec` stage is available in `0.4.5`, so `--stage` is optional
1266
+ Only the `spec` stage is available in `0.4.6`, so `--stage` is optional
1209
1267
  and defaults to `spec`. `--stage plan` and `--stage review` are
1210
1268
  rejected. There are no `plan`, `implement` or
1211
1269
  `review` commands in this release.
@@ -1287,6 +1345,8 @@ my-project/
1287
1345
  │ ├── config.yaml
1288
1346
  │ ├── architecture.yaml # declared architecture (Greenfield)
1289
1347
  │ ├── .specs.lock # serializes specification id assignment
1348
+ │ ├── .local/ # machine-local, ignored by git
1349
+ │ │ └── sessions.json # harness session of each change
1290
1350
  │ ├── constitution/
1291
1351
  │ │ ├── constitution.md
1292
1352
  │ │ ├── code-standards.md
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.4.5"
7
+ version = "0.4.6"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "docs/REFERENCE.md"
10
10
  license = "MIT"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import uuid
6
7
  import shlex
7
8
  import sys
8
9
 
@@ -66,6 +67,10 @@ class ClaudeCodeAdapter(HarnessAdapter):
66
67
  "manual" if context.mode == "interactive" else "dontAsk"
67
68
  )
68
69
  model = ("--model", context.model) if context.model else ()
70
+ session: tuple[str, ...] = ()
71
+ if context.session_id:
72
+ flag = "--resume" if context.resume_session else "--session-id"
73
+ session = (flag, context.session_id)
69
74
  # Load only the user's own settings and no MCP servers: hooks,
70
75
  # permissions and MCP servers committed in the project's .claude/ or
71
76
  # .mcp.json must not run with DevFlow's agent session.
@@ -75,6 +80,7 @@ class ClaudeCodeAdapter(HarnessAdapter):
75
80
  argv = (
76
81
  self.executable,
77
82
  *model,
83
+ *session,
78
84
  *isolation,
79
85
  "--permission-mode",
80
86
  permission_mode,
@@ -91,6 +97,7 @@ class ClaudeCodeAdapter(HarnessAdapter):
91
97
  self.executable,
92
98
  "-p",
93
99
  *model,
100
+ *session,
94
101
  *isolation,
95
102
  "--output-format",
96
103
  "text",
@@ -104,6 +111,10 @@ class ClaudeCodeAdapter(HarnessAdapter):
104
111
  )
105
112
  return Invocation(argv=argv, cwd=root, interactive=False)
106
113
 
114
+ def new_session_id(self) -> str:
115
+ """Claude Code accepts a UUID chosen by the caller (--session-id)."""
116
+ return str(uuid.uuid4())
117
+
107
118
  def permission_warnings(
108
119
  self,
109
120
  context: RunContext,
@@ -3,6 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
+ import secrets
7
+ import string
6
8
  import subprocess
7
9
  import tempfile
8
10
 
@@ -126,11 +128,14 @@ class OpenCodeAdapter(HarnessAdapter):
126
128
  def build_run(self, context: RunContext) -> Invocation:
127
129
  root = context.root
128
130
  model = ("--model", context.model) if context.model else ()
131
+ # `--session` continues the session, or creates it with this id.
132
+ session = ("--session", context.session_id) if context.session_id else ()
129
133
  if context.mode == "interactive":
130
134
  argv = (
131
135
  self.executable,
132
136
  "mini",
133
137
  *model,
138
+ *session,
134
139
  "--agent",
135
140
  INTERACTIVE_AGENT,
136
141
  "--prompt",
@@ -147,12 +152,22 @@ class OpenCodeAdapter(HarnessAdapter):
147
152
  self.executable,
148
153
  "run",
149
154
  *model,
155
+ *session,
150
156
  "--agent",
151
157
  agent,
152
158
  context.prompt,
153
159
  )
154
160
  return Invocation(argv=argv, cwd=root, interactive=False)
155
161
 
162
+ def new_session_id(self) -> str:
163
+ """Return an id in OpenCode's format: ``ses_`` + 12 hex + 14 base62."""
164
+ alphabet = string.ascii_letters + string.digits
165
+ return (
166
+ "ses_"
167
+ + secrets.token_hex(6)
168
+ + "".join(secrets.choice(alphabet) for _ in range(14))
169
+ )
170
+
156
171
  def list_models(self) -> tuple[ModelOption, ...]:
157
172
  """Return models reported by ``opencode models``."""
158
173
  if not self.is_available():
@@ -25,8 +25,17 @@ from devflow.core.constitution import (
25
25
  ConstitutionError,
26
26
  ConstitutionLoader,
27
27
  )
28
+ from devflow.core.model_tiers import (
29
+ RECOMMENDATION_TEXT,
30
+ TIER_LARGE,
31
+ TIER_MEDIUM,
32
+ TIER_SMALL,
33
+ model_tier,
34
+ tier_label,
35
+ )
28
36
  from devflow.core.ports import (
29
37
  HarnessPort,
38
+ ModelOption,
30
39
  SetupResult,
31
40
  build_setup_context,
32
41
  )
@@ -57,13 +66,12 @@ def prompt_for_model(adapter: HarnessPort) -> str | None:
57
66
  )
58
67
  return answer.strip() or None
59
68
 
69
+ models = _by_recommendation(models)
60
70
  typer.echo(f"Models available for {adapter.display_name}:")
61
71
  typer.echo(" 0. Use the harness default")
62
72
  for index, model in enumerate(models, start=1):
63
- label = ""
64
- if model.label and model.label != model.id:
65
- label = f" — {model.label}"
66
- typer.echo(f" {index}. {model.id}{label}")
73
+ typer.echo(f" {index}. {_model_line(model)}")
74
+ typer.echo(RECOMMENDATION_TEXT)
67
75
  while True:
68
76
  answer = typer.prompt("Model number or id", default="0")
69
77
  value = answer.strip()
@@ -78,6 +86,22 @@ def prompt_for_model(adapter: HarnessPort) -> str | None:
78
86
  typer.echo("Choose a listed number or type a model id.")
79
87
 
80
88
 
89
+ def _by_recommendation(models: tuple[ModelOption, ...]) -> list[ModelOption]:
90
+ """Put the models recommended for specs first, keeping their order."""
91
+ order = {TIER_MEDIUM: 0, TIER_LARGE: 1, None: 2, TIER_SMALL: 3}
92
+ return sorted(models, key=lambda item: order[model_tier(item.id)])
93
+
94
+
95
+ def _model_line(model: ModelOption) -> str:
96
+ label = ""
97
+ if model.label and model.label != model.id:
98
+ label = f" — {model.label}"
99
+ recommendation = tier_label(model.id)
100
+ if recommendation:
101
+ label += f" [{recommendation}]"
102
+ return f"{model.id}{label}"
103
+
104
+
81
105
  def validate_harness_name(value: str) -> str:
82
106
  """Validate and normalize a harness name from the CLI."""
83
107
  canonical = canonical_harness_name(value)
@@ -278,9 +302,9 @@ def models(
278
302
  "Use --model with a model id supported by the harness."
279
303
  )
280
304
  return
281
- for option in options:
282
- label = f" — {option.label}" if option.label else ""
283
- console.print(f"- {option.id}{label}")
305
+ for option in _by_recommendation(options):
306
+ console.print(escape(f"- {_model_line(option)}"), soft_wrap=True)
307
+ console.print(RECOMMENDATION_TEXT)
284
308
 
285
309
 
286
310
  @harness_app.command("use")
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import sys
6
6
  from dataclasses import replace
7
7
  from pathlib import Path
8
- from typing import Optional
8
+ from typing import List, Optional
9
9
 
10
10
  import typer
11
11
  from rich.console import Console
@@ -115,6 +115,15 @@ def spec(
115
115
  "changing the configuration."
116
116
  ),
117
117
  ),
118
+ scope: Optional[List[str]] = typer.Option(
119
+ None,
120
+ "--scope",
121
+ help=(
122
+ "Directory or file where the change happens, for example "
123
+ "apps/accounts. Repeat it for several places. The analysis and "
124
+ "the agent stay inside it. Only for a new change."
125
+ ),
126
+ ),
118
127
  allow_source_changes: bool = typer.Option(
119
128
  False,
120
129
  "--allow-source-changes",
@@ -148,6 +157,7 @@ def spec(
148
157
  model,
149
158
  auto,
150
159
  allow_source_changes,
160
+ tuple(scope or ()),
151
161
  )
152
162
  except (
153
163
  ArchitectureError,
@@ -178,6 +188,7 @@ def _create_specification(
178
188
  model: Optional[str] = None,
179
189
  auto: bool = False,
180
190
  allow_source_changes: bool = False,
191
+ scope: tuple[str, ...] = (),
181
192
  ) -> None:
182
193
  request = (description or "").strip()
183
194
  resume = (continue_id or "").strip() or None
@@ -281,6 +292,7 @@ def _create_specification(
281
292
  language=documentation_language,
282
293
  model=effective_model,
283
294
  stop_after_discovery=stop_after_discovery,
295
+ scope=scope,
284
296
  )
285
297
  )
286
298