devflow-toolkit 0.4.5__tar.gz → 0.4.7__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.7}/CHANGELOG.md +60 -1
  2. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/PKG-INFO +67 -7
  3. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/README.md +2 -1
  4. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/docs/REFERENCE.md +66 -6
  5. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/pyproject.toml +1 -1
  6. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/claude_code.py +11 -0
  7. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/opencode.py +15 -0
  8. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/harness.py +31 -7
  9. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/spec.py +60 -3
  10. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/discovery.py +157 -0
  11. devflow_toolkit-0.4.7/src/devflow/core/model_tiers.py +62 -0
  12. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/ports.py +10 -0
  13. devflow_toolkit-0.4.7/src/devflow/core/sessions.py +66 -0
  14. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/spec_workflow.py +73 -0
  15. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/specification.py +207 -25
  16. devflow_toolkit-0.4.7/src/devflow/prompts/discovery.md +272 -0
  17. devflow_toolkit-0.4.7/src/devflow/prompts/spec.md +230 -0
  18. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_security_fixes.py +189 -0
  19. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/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.7}/.gitignore +0 -0
  23. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/LICENSE +0 -0
  24. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/docs/PRESENTATION.md +0 -0
  25. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/docs/PUBLISHING.md +0 -0
  26. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/__init__.py +0 -0
  27. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/__init__.py +0 -0
  28. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/agents.py +0 -0
  29. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/antigravity.py +0 -0
  30. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/base.py +0 -0
  31. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/codex.py +0 -0
  32. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/detector.py +0 -0
  33. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/instructions.py +0 -0
  34. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/kiro.py +0 -0
  35. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/adapters/registry.py +0 -0
  36. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/cli.py +0 -0
  37. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/__init__.py +0 -0
  38. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/approve.py +0 -0
  39. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/config.py +0 -0
  40. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/doctor.py +0 -0
  41. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/init.py +0 -0
  42. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/recover.py +0 -0
  43. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/reopen.py +0 -0
  44. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/security.py +0 -0
  45. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/commands/status.py +0 -0
  46. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/__init__.py +0 -0
  47. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/architecture.py +0 -0
  48. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/artifacts/__init__.py +0 -0
  49. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/artifacts/errors.py +0 -0
  50. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/artifacts/models.py +0 -0
  51. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/artifacts/store.py +0 -0
  52. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/clock.py +0 -0
  53. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/config.py +0 -0
  54. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/constitution.py +0 -0
  55. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/file_types.py +0 -0
  56. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/profile_manager.py +0 -0
  57. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/project.py +0 -0
  58. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/recovery.py +0 -0
  59. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/safe_files.py +0 -0
  60. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/security_baseline.py +0 -0
  61. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/security_tools.py +0 -0
  62. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/__init__.py +0 -0
  63. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/errors.py +0 -0
  64. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/events.py +0 -0
  65. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/locator.py +0 -0
  66. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/lock.py +0 -0
  67. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/manager.py +0 -0
  68. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/models.py +0 -0
  69. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/signing.py +0 -0
  70. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/core/state/transitions.py +0 -0
  71. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/hooks/__init__.py +0 -0
  72. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/hooks/claude_guard.py +0 -0
  73. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/models/__init__.py +0 -0
  74. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/models/profile.py +0 -0
  75. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/models/project.py +0 -0
  76. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  77. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  78. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  79. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  80. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  81. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/base/profile.yaml +0 -0
  82. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  83. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  84. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  85. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  86. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/prompts/__init__.py +0 -0
  87. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/src/devflow/prompts/discovery-repair.md +0 -0
  88. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/conftest.py +0 -0
  89. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_cli.py +0 -0
  90. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_discovery.py +0 -0
  91. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_discovery_decisions.py +0 -0
  92. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_event_log.py +0 -0
  93. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_greenfield.py +0 -0
  94. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_hardening.py +0 -0
  95. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_harness_adapters.py +0 -0
  96. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_recovery.py +0 -0
  97. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_security_baseline.py +0 -0
  98. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_security_tools.py +0 -0
  99. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_state.py +0 -0
  100. {devflow_toolkit-0.4.5 → devflow_toolkit-0.4.7}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,65 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.4.7 - 2026-11-30
6
+
7
+ ### Fixed
8
+
9
+ - The configured model is only used with the harness it belongs to.
10
+ Choosing another harness in `devflow spec` (for example Codex after
11
+ configuring OpenCode with `anthropic/claude-haiku-4-5`) no longer sends
12
+ that model id to it: in a terminal DevFlow asks for a model of the new
13
+ harness, otherwise it uses the harness default and warns. `--model`
14
+ still sets the model for one run.
15
+
16
+ ### Package
17
+
18
+ - Package version is `0.4.7`.
19
+
20
+ ## 0.4.6 - 2026-11-30
21
+
22
+ ### Added
23
+
24
+ - `devflow spec --scope <path>` limits a new change to one or more
25
+ directories or files: the analysis and the agent stay inside them.
26
+ - In projects with 150 or more source files, when the request does not
27
+ name a module, Discovery first asks where the change happens, offering
28
+ the directories with the strongest matches. Answering with a path
29
+ limits the analysis to it.
30
+ - The specification run resumes the Discovery session with Claude Code
31
+ (`--session-id` / `--resume`) and OpenCode (`--session`) when both
32
+ phases use the same harness, so the agent does not start from zero and
33
+ the provider can reuse its cache. A non-interactive run that cannot
34
+ resume starts a new session. Sessions are stored in
35
+ `.devflow/.local/sessions.json`, ignored by git.
36
+ - Model lists in `init`, `harness use` and `harness models` mark each
37
+ model as mid-range (recommended for Discovery and specs), most capable
38
+ (best for implementation) or small (not recommended), and show the
39
+ recommended ones first.
40
+
41
+ ### Changed
42
+
43
+ - `context.md` gives a reading plan: the ten most relevant files, each
44
+ with the matching classes or functions and their line ranges, and an
45
+ instruction to read only those ranges. Generic words (*add*, *create*,
46
+ *new*...) and `AGENTS.md`, `CLAUDE.md` and `CHANGELOG.md` no longer
47
+ count as evidence, and files matching several request terms rank
48
+ higher.
49
+ - The Discovery prompt is about a third shorter and the specification
50
+ prompt slightly shorter. Both put the request, paths and digests at the
51
+ end so the fixed part can be cached between specs, and both ask the
52
+ agent to read only the constitution sections that apply.
53
+
54
+ ### Upgrade notes
55
+
56
+ - In projects with 150 or more source files, a new change whose request
57
+ names no module now asks where the change happens. With `--no-agent`,
58
+ answer it in `discovery.yaml` or pass `--scope`.
59
+
60
+ ### Package
61
+
62
+ - Package version is `0.4.6`, published on TestPyPI and PyPI.
63
+
5
64
  ## 0.4.5 - 2026-11-30
6
65
 
7
66
  ### Changed
@@ -23,7 +82,7 @@ All notable changes to DevFlow Toolkit are documented in this file.
23
82
 
24
83
  ### Package
25
84
 
26
- - Package version is `0.4.5`.
85
+ - Package version is `0.4.5`, published on TestPyPI and PyPI.
27
86
 
28
87
  ## 0.4.4 - 2026-11-30
29
88
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.4.5
3
+ Version: 0.4.7
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.7`.**
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.7-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.7 |
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.7`:
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.7` 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.7`, 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.7` · 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.7`.**
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.7-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.7 |
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.7`:
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.7` 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.7`, 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.7"
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
@@ -15,6 +15,7 @@ from devflow.adapters.base import execute_invocation
15
15
  from devflow.commands.harness import (
16
16
  adapter_for,
17
17
  print_setup_result,
18
+ prompt_for_model,
18
19
  resolve_harness,
19
20
  validate_harness_name,
20
21
  )
@@ -115,6 +116,15 @@ def spec(
115
116
  "changing the configuration."
116
117
  ),
117
118
  ),
119
+ scope: Optional[List[str]] = typer.Option(
120
+ None,
121
+ "--scope",
122
+ help=(
123
+ "Directory or file where the change happens, for example "
124
+ "apps/accounts. Repeat it for several places. The analysis and "
125
+ "the agent stay inside it. Only for a new change."
126
+ ),
127
+ ),
118
128
  allow_source_changes: bool = typer.Option(
119
129
  False,
120
130
  "--allow-source-changes",
@@ -148,6 +158,7 @@ def spec(
148
158
  model,
149
159
  auto,
150
160
  allow_source_changes,
161
+ tuple(scope or ()),
151
162
  )
152
163
  except (
153
164
  ArchitectureError,
@@ -178,6 +189,7 @@ def _create_specification(
178
189
  model: Optional[str] = None,
179
190
  auto: bool = False,
180
191
  allow_source_changes: bool = False,
192
+ scope: tuple[str, ...] = (),
181
193
  ) -> None:
182
194
  request = (description or "").strip()
183
195
  resume = (continue_id or "").strip() or None
@@ -241,8 +253,6 @@ def _create_specification(
241
253
  config = ConfigManager(root).set_documentation_language(
242
254
  documentation_language
243
255
  )
244
- effective_model = (model or config.model or "").strip() or None
245
-
246
256
  allow_prompt = sys.stdin.isatty()
247
257
  selected_harness, selection_warnings = resolve_harness(
248
258
  requested_harness,
@@ -251,6 +261,14 @@ def _create_specification(
251
261
  force_prompt=not explicit_harness,
252
262
  )
253
263
  adapter = adapter_for(selected_harness) if selected_harness else None
264
+ effective_model = _model_for_run(
265
+ model,
266
+ config,
267
+ selected_harness,
268
+ adapter,
269
+ allow_prompt=allow_prompt,
270
+ warnings=selection_warnings,
271
+ )
254
272
  if adapter is not None:
255
273
  config = _confirm_source_changes(
256
274
  config,
@@ -281,6 +299,7 @@ def _create_specification(
281
299
  language=documentation_language,
282
300
  model=effective_model,
283
301
  stop_after_discovery=stop_after_discovery,
302
+ scope=scope,
284
303
  )
285
304
  )
286
305
 
@@ -543,6 +562,44 @@ def _execution_mode(mode: str) -> tuple[str, list[str]]:
543
562
  return normalized, warnings
544
563
 
545
564
 
565
+ def _model_for_run(
566
+ model: str | None,
567
+ config: DevFlowConfig,
568
+ harness: str | None,
569
+ adapter,
570
+ *,
571
+ allow_prompt: bool,
572
+ warnings: list[str],
573
+ ) -> str | None:
574
+ """Return the model for this run.
575
+
576
+ The configured model belongs to the configured harness: model ids are
577
+ harness-specific, so another harness never receives it. When the run
578
+ uses a different harness, the user picks its model or its default is
579
+ used.
580
+ """
581
+ explicit = (model or "").strip()
582
+ if explicit:
583
+ return explicit
584
+ configured = config.model.strip()
585
+ if not configured or harness == config.agent_harness:
586
+ return configured or None
587
+ if adapter is not None and allow_prompt:
588
+ console.print(
589
+ f"The configured model {escape(configured)} belongs to "
590
+ f"{escape(config.agent_harness)}; choose one for "
591
+ f"{escape(adapter.display_name)}."
592
+ )
593
+ return prompt_for_model(adapter)
594
+ warnings.append(
595
+ f"The configured model '{configured}' belongs to "
596
+ f"{config.agent_harness}, so {harness} uses its default model. Pass "
597
+ "--model to choose one, or run 'devflow harness use "
598
+ f"{harness}' to make it the configured harness."
599
+ )
600
+ return None
601
+
602
+
546
603
  def _confirm_source_changes(
547
604
  config: DevFlowConfig,
548
605
  harness_name: str,