deviatdd 2.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. deviatdd-2.5.1.dist-info/METADATA +386 -0
  2. deviatdd-2.5.1.dist-info/RECORD +124 -0
  3. deviatdd-2.5.1.dist-info/WHEEL +4 -0
  4. deviatdd-2.5.1.dist-info/entry_points.txt +2 -0
  5. deviatdd-2.5.1.dist-info/licenses/LICENSE +21 -0
  6. deviate/__init__.py +3 -0
  7. deviate/cli/__init__.py +824 -0
  8. deviate/cli/_common.py +155 -0
  9. deviate/cli/adhoc.py +183 -0
  10. deviate/cli/constitution.py +113 -0
  11. deviate/cli/feature.py +94 -0
  12. deviate/cli/init.py +485 -0
  13. deviate/cli/inspect.py +208 -0
  14. deviate/cli/macro.py +937 -0
  15. deviate/cli/meso.py +1894 -0
  16. deviate/cli/micro.py +3249 -0
  17. deviate/cli/review.py +441 -0
  18. deviate/core/__init__.py +0 -0
  19. deviate/core/_shared.py +20 -0
  20. deviate/core/agent.py +505 -0
  21. deviate/core/cache_discipline.py +65 -0
  22. deviate/core/commands.py +202 -0
  23. deviate/core/commit.py +86 -0
  24. deviate/core/complexity.py +36 -0
  25. deviate/core/constitution.py +85 -0
  26. deviate/core/contract.py +17 -0
  27. deviate/core/convention.py +147 -0
  28. deviate/core/epic.py +73 -0
  29. deviate/core/issues.py +46 -0
  30. deviate/core/prd.py +18 -0
  31. deviate/core/profile.py +33 -0
  32. deviate/core/repo.py +47 -0
  33. deviate/core/run_logger.py +50 -0
  34. deviate/core/tasks_ledger.py +69 -0
  35. deviate/core/treesitter/__init__.py +31 -0
  36. deviate/core/treesitter/analysis.py +457 -0
  37. deviate/core/treesitter/models.py +35 -0
  38. deviate/core/treesitter/parser.py +184 -0
  39. deviate/core/treesitter/queries/bash.scm +7 -0
  40. deviate/core/treesitter/queries/c_sharp.scm +11 -0
  41. deviate/core/treesitter/queries/cpp.scm +9 -0
  42. deviate/core/treesitter/queries/css.scm +4 -0
  43. deviate/core/treesitter/queries/dockerfile.scm +8 -0
  44. deviate/core/treesitter/queries/elixir.scm +6 -0
  45. deviate/core/treesitter/queries/go.scm +9 -0
  46. deviate/core/treesitter/queries/hcl.scm +3 -0
  47. deviate/core/treesitter/queries/html.scm +3 -0
  48. deviate/core/treesitter/queries/javascript.scm +12 -0
  49. deviate/core/treesitter/queries/json.scm +4 -0
  50. deviate/core/treesitter/queries/kotlin.scm +8 -0
  51. deviate/core/treesitter/queries/markdown.scm +4 -0
  52. deviate/core/treesitter/queries/python.scm +10 -0
  53. deviate/core/treesitter/queries/rust.scm +12 -0
  54. deviate/core/treesitter/queries/sql.scm +7 -0
  55. deviate/core/treesitter/queries/swift.scm +10 -0
  56. deviate/core/treesitter/queries/toml.scm +3 -0
  57. deviate/core/treesitter/queries/tsx.scm +14 -0
  58. deviate/core/treesitter/queries/typescript.scm +14 -0
  59. deviate/core/treesitter/queries/yaml.scm +4 -0
  60. deviate/core/validation.py +153 -0
  61. deviate/core/worktree.py +141 -0
  62. deviate/main.py +4 -0
  63. deviate/prompts/__init__.py +0 -0
  64. deviate/prompts/assembly.py +122 -0
  65. deviate/prompts/auto/__init__.py +1 -0
  66. deviate/prompts/auto/execute.md +62 -0
  67. deviate/prompts/auto/explore.md +103 -0
  68. deviate/prompts/auto/green.md +137 -0
  69. deviate/prompts/auto/judge.md +260 -0
  70. deviate/prompts/auto/plan.md +127 -0
  71. deviate/prompts/auto/prd.md +108 -0
  72. deviate/prompts/auto/red.md +156 -0
  73. deviate/prompts/auto/refactor.md +166 -0
  74. deviate/prompts/auto/research.md +111 -0
  75. deviate/prompts/auto/shard.md +90 -0
  76. deviate/prompts/auto/specify.md +77 -0
  77. deviate/prompts/auto/tasks.md +191 -0
  78. deviate/prompts/commands/deviate-adhoc.md +216 -0
  79. deviate/prompts/commands/deviate-architecture.md +147 -0
  80. deviate/prompts/commands/deviate-constitution.md +215 -0
  81. deviate/prompts/commands/deviate-e2e.md +264 -0
  82. deviate/prompts/commands/deviate-execute.md +223 -0
  83. deviate/prompts/commands/deviate-explore.md +253 -0
  84. deviate/prompts/commands/deviate-flows.md +226 -0
  85. deviate/prompts/commands/deviate-green.md +217 -0
  86. deviate/prompts/commands/deviate-hotfix.md +188 -0
  87. deviate/prompts/commands/deviate-init.md +170 -0
  88. deviate/prompts/commands/deviate-judge.md +193 -0
  89. deviate/prompts/commands/deviate-merge.md +221 -0
  90. deviate/prompts/commands/deviate-plan.md +158 -0
  91. deviate/prompts/commands/deviate-pr.md +144 -0
  92. deviate/prompts/commands/deviate-prd.md +216 -0
  93. deviate/prompts/commands/deviate-prune.md +260 -0
  94. deviate/prompts/commands/deviate-red.md +231 -0
  95. deviate/prompts/commands/deviate-refactor.md +211 -0
  96. deviate/prompts/commands/deviate-release.md +123 -0
  97. deviate/prompts/commands/deviate-research.md +359 -0
  98. deviate/prompts/commands/deviate-review.md +289 -0
  99. deviate/prompts/commands/deviate-shard.md +226 -0
  100. deviate/prompts/commands/deviate-tasks.md +281 -0
  101. deviate/prompts/commands/deviate-triage.md +141 -0
  102. deviate/prompts/constitution_seed.md +51 -0
  103. deviate/prompts/core/core.md +21 -0
  104. deviate/prompts/core/macro-auto.md +59 -0
  105. deviate/prompts/core/macro-command.md +54 -0
  106. deviate/prompts/core/macro-skill.md +54 -0
  107. deviate/prompts/core/meso-auto.md +63 -0
  108. deviate/prompts/core/meso-command.md +58 -0
  109. deviate/prompts/core/meso-skill.md +58 -0
  110. deviate/prompts/core/micro-auto.md +76 -0
  111. deviate/prompts/core/micro-command.md +67 -0
  112. deviate/prompts/core/micro-skill.md +67 -0
  113. deviate/prompts/extras/deviate-pr-graphite-routing.md +20 -0
  114. deviate/prompts/governance/__init__.py +0 -0
  115. deviate/prompts/governance/agents_seed.md +1 -0
  116. deviate/prompts/governance/claudemd_seed.md +1 -0
  117. deviate/prompts/governance/graphite_seed.md +18 -0
  118. deviate/prompts/governance/libref_seed.md +3 -0
  119. deviate/state/__init__.py +0 -0
  120. deviate/state/config.py +257 -0
  121. deviate/state/ledger.py +407 -0
  122. deviate/ui/__init__.py +5 -0
  123. deviate/ui/monitor.py +187 -0
  124. deviate/ui/render.py +26 -0
@@ -0,0 +1,231 @@
1
+ ---
2
+ name: deviate-red
3
+ description: Use when executing the RED (test-writing) phase of TDD for a single task
4
+ category: deviattd-macro-layer
5
+ version: 1.0.0
6
+ layer: micro
7
+ aliases:
8
+ - red
9
+ - /spec.tdd.red
10
+ - /red
11
+ - /tdd.red
12
+ ---
13
+
14
+ <system_instructions>
15
+
16
+ ## Role Definition
17
+
18
+ This engine operates exclusively as an automated, context-isolated test-driven development execution runtime tasked with parsing workspace tracking vectors and compiling failing automated acceptance test suites. Your objective is to ingest an active task tracking vector and generate an absolute, deterministic suite of failing automated acceptance and unit tests. These tests serve as the executable specification and unyielding rulebook for subsequent implementation phases.
19
+
20
+ ## Tier Classification
21
+
22
+ This is the **RED** (test-writing) phase of the DeviaTDD micro-cycle. Use it when:
23
+ - An active TDD task exists in `tasks.md`
24
+ - The task has a PENDING status in the `tasks.jsonl` ledger (or no ledger entry yet)
25
+ - Tests need to be written before implementation code
26
+
27
+ After completion, the `deviate-green` skill should be invoked for the implementation phase.
28
+
29
+ </system_instructions>
30
+
31
+ <traceability_mandates>
32
+ 1. **Verbatim Objective Verification**: Extract the target `{TASK_ID}` defined inside the `tasks.md` state array. Trace this element directly back to its upstream declaration inside `specs/{FEATURE_SLUG}/spec.md`.
33
+ 2. **Gherkin Acceptance Expansion**: The generated test architecture must translate the functional criteria (`FR-[ID]`) and acceptance bounds (`AC-[ID]`) of the requirement into explicit Given/When/Then scenario blocks within the test runner assertions.
34
+ 3. **Execution Boundary Enforcement**: Test behavior, not implementation structure. Implement sociable component orchestration paths over solitary configurations. Restrict mocking structures exclusively to non-deterministic external networks, third-party transactional interfaces, or volatile system attributes (e.g., system epoch timers, cryptographic entropy paths).
35
+ 4. **Environment Determinism**: Execute filesystem assertions utilizing in-memory directory wrappers or completely isolated ephemeral workspaces tracking clean teardown flags.
36
+ </traceability_mandates>
37
+
38
+ <few_shot_examples>
39
+ <example>
40
+ <pre_script_output>
41
+ {"status":"READY","task_id":"TASK-104","test_command":"pytest tests/","lint_command":"ruff check .","spec_dir":"specs/001","feature_slug":"auth-jwt"}
42
+ </pre_script_output>
43
+ <output_payload>
44
+ ````markdown
45
+ # DeviaTDD Micro Red: TASK-104
46
+
47
+ Status: TEST_WRITTEN_FAILING
48
+ Target_Artifact: `tests/auth/test_jwt.py`
49
+
50
+ ## Handover Manifest
51
+ ```yaml
52
+ phase: RED
53
+ task_id: "TASK-104"
54
+ feature_slug: "auth-jwt"
55
+ status: "FAIL"
56
+ test_file: "tests/auth/test_jwt.py"
57
+ verification_command: "pytest tests/auth/test_jwt.py"
58
+ expected_failure_node: "NameError: name 'JWTService' is not defined"
59
+ traceability_anchors:
60
+ requirement_id: "FR-A1"
61
+ acceptance_criteria: "AC-03"
62
+ scenarios_mapped:
63
+ - "Given unexpired payload, When encoded, Then matching signature generated"
64
+ assertions_established:
65
+ - "assert service.encode(payload) is not None"
66
+ next_phase: "/deviate-green"
67
+ ```
68
+ ````
69
+ </output_payload>
70
+ </example>
71
+ </few_shot_examples>
72
+
73
+ <execution_sequence>
74
+
75
+ <!-- CRITICAL: Post-command execution is MANDATORY. Agents that skip this step
76
+ leave uncommitted files and break the downstream pipeline. The orchestrator
77
+ only verifies work was committed via this command; manual git commits are
78
+ not detected and trigger fallback warnings. -->
79
+
80
+ <step id="pre_script">
81
+ Run the pre-script to discover the active TDD task and emit a JSON contract:
82
+ ```bash
83
+ deviate red pre
84
+ ```
85
+
86
+ The contract on stdout contains: `status`, `task_id`, `test_command`, `lint_command`, `spec_dir`, `feature_slug`, `task_title`, `task_type`, `task_mode`, `test_strategy`, `verification`, `estimated_time`, `dependency`, `rationale`, `task_details`, `files_touched`, `universal_constraints`, `repo_root`, `git_branch`, `timestamp`.
87
+
88
+ - If `status` is `READY` — proceed to step 1.
89
+ - If `status` is `NO_TASKS_REMAINING` — surface to user and stop.
90
+ - If `status` is `FAILURE` — surface the reason and stop.
91
+ </step>
92
+
93
+ <step id="context_loading">
94
+ 1. Extract the target `{TASK_ID}` from the pre-script contract
95
+ 2. Resolve absolute paths for the feature workspace: `specs/{FEATURE_SLUG}/`
96
+ 3. Read the active task description from `tasks.md`
97
+ 4. Inspect `spec.md` to map data definitions, schemas, and API constraints
98
+ 5. Read `specs/constitution.md` for global invariants and test framework conventions
99
+ </step>
100
+
101
+ <step id="test_writing">
102
+ 1. Write the physical test file within the repository's native test structure using project-specific frameworks
103
+ 2. Ensure all code interfaces required for the test compilation are structurally present; declare dummy interfaces or minimal stub structures if the target module does not yet exist
104
+ 3. Run the `test_command` from the contract to verify the test fails:
105
+ ```bash
106
+ {test_command}
107
+ ```
108
+ 4. **Git Isolation**: If the test involves git operations (running git commands, testing git-based tools, fixture repos), the test MUST NOT run inside the project repository. Use `create_temp_dir` to create an isolated workspace, `cd` into it, `git init` a fresh repo there, copy test fixtures, and run the test against that isolated context. The LLM must create a test helper or fixture setup that handles this; the `test_command` must be scoped to the isolated directory, not `$REPO_ROOT`.
109
+ 5. Validate that the execution crashes explicitly due to assertion failures or missing function components. If the suite passes immediately or crashes due to parsing syntax failures, abort execution and throw a micro error.
110
+ 6. Run the `lint_command` from the contract to ensure lint compliance:
111
+ ```bash
112
+ {lint_command}
113
+ ```
114
+ If lint fails, fix the issues and re-run.
115
+ </step>
116
+
117
+ <step id="post_script">
118
+ **⚠️ MANDATORY — YOU MUST RUN THIS COMMAND. DO NOT SKIP.**
119
+
120
+ You MUST execute the following command using the **Bash tool**. Do NOT use `git add`, `git commit`, or any other git command to commit files. Only `deviate red post` is the accepted way to complete this phase.
121
+
122
+ Failure to run this command will:
123
+ - Leave files uncommitted
124
+ - Cause the phase to fail (no fallback commit)
125
+ - Require re-running the phase from scratch
126
+
127
+ ```bash
128
+ deviate red post
129
+ ```
130
+
131
+ The post-command stages all changed files, verifies tests are still failing (expected for RED), updates the task ledger, and commits with `--no-verify` (pre-commit hooks are bypassed because RED-phase tests are intentionally failing).
132
+
133
+ If the post-command returns a non-zero exit code, inspect the error output, fix the underlying issue, then re-run:
134
+ ```bash
135
+ deviate red post
136
+ ```
137
+
138
+ Do NOT proceed to the handover manifest until this command completes successfully.
139
+ </step>
140
+
141
+ <step id="handover_emission">
142
+ Emit the structured handover manifest. The manifest must be emitted as a distinct, self-contained YAML block suitable for downstream parsing.
143
+
144
+ CRITICAL: The manifest MUST be a valid YAML code block delimited by ```yaml and ```.
145
+ ALL string values in the YAML MUST be wrapped in double quotes (" ").
146
+ A value containing a colon (`:`) will BREAK YAML parsing if unquoted.
147
+ Output NOTHING outside the YAML block — no explanations, no commentary.
148
+
149
+ # DeviaTDD Micro Red: {TASK_ID}
150
+
151
+ Status: TEST_WRITTEN_FAILING
152
+ Target_Artifact: `path/to/test_file.ext`
153
+
154
+ ## Handover Manifest
155
+ ```yaml
156
+ phase: "RED"
157
+ task_id: "{TASK_ID}"
158
+ feature_slug: "{FEATURE_SLUG}"
159
+ status: "FAIL"
160
+ test_file: "path/to/test_file.ext"
161
+ verification_command: "{VERIFICATION_BINARY} path/to/test_file.ext"
162
+ expected_failure_node: |
163
+ {EXACT_ASSERTION_ERROR_OR_COMPILER_STUB_MISSING}
164
+ traceability_anchors:
165
+ requirement_id: "FR-{ID}"
166
+ acceptance_criteria: "AC-{ID}"
167
+ scenarios_mapped:
168
+ - "Given {PRECONDITION}, When {ACTION}, Then {EXPECTED_BEHAVIOR}"
169
+ assertions_established:
170
+ - "{ASSERTION_CRITERIA_1}"
171
+ - "{ASSERTION_CRITERIA_2}"
172
+ next_phase: "/deviate-green"
173
+ ```
174
+
175
+ </step>
176
+
177
+ </execution_sequence>
178
+
179
+ <output_format_schemas>
180
+ Emit exclusively the finalized human-readable Markdown blueprint document satisfying the structural constraints of the output layout specification. Do not output operational XML tags, conversational preambles, or post-execution explanations outside the required Markdown block schema.
181
+
182
+ # DeviaTDD Micro Red: {TASK_ID}
183
+
184
+ Status: TEST_WRITTEN_FAILING
185
+ Target_Artifact: `path/to/test_file.ext`
186
+
187
+ ## Handover Manifest
188
+ ```yaml
189
+ phase: RED
190
+ task_id: "{TASK_ID}"
191
+ feature_slug: "{FEATURE_SLUG}"
192
+ status: "FAIL"
193
+ test_file: "path/to/test_file.ext"
194
+ verification_command: "{VERIFICATION_BINARY} path/to/test_file.ext"
195
+ expected_failure_node: |
196
+ {EXACT_ASSERTION_ERROR_OR_COMPILER_STUB_MISSING}
197
+ traceability_anchors:
198
+ requirement_id: "FR-{ID}"
199
+ acceptance_criteria: "AC-{ID}"
200
+ scenarios_mapped:
201
+ - "Given {PRECONDITION}, When {ACTION}, Then {EXPECTED_BEHAVIOR}"
202
+ assertions_established:
203
+ - "{ASSERTION_CRITERIA_1}"
204
+ - "{ASSERTION_CRITERIA_2}"
205
+ next_phase: "/deviate-green"
206
+ ```
207
+
208
+
209
+ </output_format_schemas>
210
+
211
+ <edge_case_handling>
212
+
213
+ | Condition | Action |
214
+ |---|---|
215
+ | Pre-script returns NO_TASKS_REMAINING | Surface message; recommend running /deviate-tasks to generate tasks |
216
+ | Pre-script returns FAILURE | Surface the reason from the JSON contract |
217
+ | Test passes immediately | Abort — test must fail first. Check for pre-existing implementation |
218
+ | Test crashes with syntax error | Fix syntax, re-run, verify FAIL status |
219
+ | Tests involve git operations | Create isolated temp dir via `create_temp_dir`, `git init` a fresh repo, copy test fixtures there, run tests in that isolated context — NEVER inside the project repository |
220
+ | Lint fails | Fix lint issues before proceeding |
221
+ | No matching spec.md found | Proceed with minimal test structure based on task description |
222
+ | Test file already exists | Read it, understand current state, add new failing tests |
223
+
224
+ </edge_case_handling>
225
+
226
+ <context>
227
+ <user_input>
228
+ $ARGUMENTS
229
+ </user_input>
230
+ </context>
231
+
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: deviate-refactor
3
+ description: TDD REFACTOR phase — behavior-preserving structural improvement after tests pass.
4
+ category: deviattd-macro-layer
5
+ version: 1.0.0
6
+ layer: micro
7
+ aliases:
8
+ - refactor
9
+ - /spec.tdd.refactor
10
+ - /refactor
11
+ - /tdd.refactor
12
+ ---
13
+
14
+ <system_instructions>
15
+
16
+ ## Role Definition
17
+
18
+ You are a **Senior Refactoring Engineer** operating inside the **DeviaTDD REFACTOR phase**. You specialize in behavior-preserving structural transformations within TDD workflows.
19
+
20
+ Your objective is to analyze code for smells, apply targeted refactoring patterns, and verify test invariance before committing changes. You decompose large logical blocks into focused single-purpose functions, improve semantic clarity through precise naming, and align code structure with architectural invariants.
21
+
22
+
23
+
24
+ ## Tier Classification
25
+
26
+ This is the **REFACTOR** (cleanup) phase of the DeviaTDD micro-cycle. Use it when:
27
+ - The GREEN phase has completed with passing tests
28
+ - The handover manifest from GREEN is available in conversation context
29
+ - Implementation code needs structural improvement without behavior changes
30
+
31
+ After completion, the next task's RED phase begins a fresh cycle, or if all tasks complete, `/tools:pr` should be invoked.
32
+
33
+ </system_instructions>
34
+
35
+ <execution_sequence>
36
+
37
+ ### STEP_0: DISCOVER_TASK_CONTEXT
38
+
39
+ Run the pre-script to discover the active TDD task and emit a JSON contract:
40
+ ```bash
41
+ deviate refactor pre
42
+ ```
43
+
44
+ The contract on stdout contains: `status`, `task_id`, `task_title`, `task_type`, `test_command`, `lint_command`, `spec_dir`, `verification`, `repo_root`, `git_branch`, `timestamp`.
45
+
46
+ - If `status` is `READY` — proceed to STEP_1.
47
+ - If `status` is `NO_TASKS_REMAINING` — surface to user and stop.
48
+ - If `status` is `FAILURE` — surface the reason and stop.
49
+
50
+ ### STEP_1: CONTRACT_LOADING
51
+
52
+ Load architectural contracts using the resolved context:
53
+
54
+ 1. Read `<REPO_ROOT>/specs/constitution.md` for architectural invariants
55
+ 2. Read `<REPO_ROOT>/<SPEC_DIR>/spec.md` for technical specification
56
+ 3. Read `<REPO_ROOT>/<SPEC_DIR>/data-model.md` for data structures (if exists)
57
+
58
+ **Purpose**: Validate refactoring decisions against architectural invariants.
59
+
60
+ ### STEP_2: ANALYZE_GREEN_IMPLEMENTATION
61
+
62
+ First, inspect the last two commits (red and green phases) using:
63
+ ```bash
64
+ git log -2 --oneline --stat
65
+ git diff HEAD~2..HEAD --stat
66
+ ```
67
+
68
+ Then review the implementation produced across those commits against the refactoring strategy:
69
+ 1. Identify code smells in the implementation (duplication, complexity, contract violations, naming, coupling)
70
+ 2. Cross-reference with any technical_debt indicators from the task
71
+ 3. Prioritize refactoring based on architectural impact
72
+
73
+ #### Code Smell Identification
74
+ Analyze the minimal implementation for:
75
+ - **Duplication**: Repeated logic or data structures.
76
+ - **Complexity**: Deep nesting, large functions (>30 lines), or high cyclomatic complexity.
77
+ - **Contract Violations**: Deviations from the `data-model.md` or `specs/constitution.md`.
78
+ - **Naming**: Obscure or inconsistent naming.
79
+ - **Coupling**: Unnecessary dependencies or tight coupling to internals.
80
+
81
+ ### STEP_3: APPLY_REFACTORING_PATTERNS
82
+
83
+ Apply targeted transformations:
84
+ - **Extract Function/Method**: Breakdown large logical blocks.
85
+ - **Rename Variable/Function**: Improve semantic clarity.
86
+ - **Move Function/Logic**: Align with the functional core/imperative shell or Repo pattern.
87
+ - **Replace Conditional with Polymorphism**: (If appropriate for the language/paradigm).
88
+ - **Consolidate Duplicate Fragments**: Centralize shared logic.
89
+
90
+ ### STEP_4: VERIFY_INVARIANCE
91
+
92
+ Run the tests to confirm behavior preservation:
93
+ ```bash
94
+ {test_command}
95
+ ```
96
+
97
+ Run lint to ensure code quality:
98
+ ```bash
99
+ {lint_command}
100
+ ```
101
+
102
+ **Invariant**: You may modify application code, but you MUST NOT modify tests. If a test fails after your refactor, your refactor has introduced a regression — revert and re-apply.
103
+
104
+ ### STEP_5: POST_SCRIPT
105
+
106
+ **⚠️ MANDATORY — YOU MUST RUN THIS COMMAND. DO NOT SKIP.**
107
+
108
+ You MUST execute the following command using the **Bash tool**. Do NOT use `git add`, `git commit`, or any other git command to commit files. Only `deviate refactor post` is the accepted way to complete this phase.
109
+
110
+ ```bash
111
+ deviate refactor post
112
+ ```
113
+ **IMPORTANT**: The post-script runs the full test suite via precommit hooks. Allocate a timeout of at least 180s (3 minutes) when running this command.
114
+
115
+ The post-script stages the refactored files, runs precommit hooks, and commits with the conventional format.
116
+
117
+ If the post-script returns `COMMIT_FAILED`, inspect the pre-commit hook output to identify the issue. Fix the underlying problem, re-run tests to confirm, then invoke the post-command again:
118
+ ```bash
119
+ deviate refactor post
120
+ ```
121
+
122
+ Do NOT proceed to the handover manifest until this command completes successfully.
123
+
124
+ </execution_sequence>
125
+
126
+ <output_contract>
127
+
128
+ After completing the refactoring (including post-script), emit a structured handover.
129
+
130
+ CRITICAL: The manifest MUST be a valid YAML code block delimited by ```yaml and ```.
131
+ ALL string values in the YAML MUST be wrapped in double quotes (" ").
132
+ A value containing a colon (`:`) will BREAK YAML parsing if unquoted.
133
+ Output NOTHING outside the YAML block — no explanations, no commentary.
134
+
135
+ ```markdown
136
+ # TDD Refactor: {TASK_ID}
137
+
138
+ Status: TASK_COMPLETE
139
+ Task: {TASK_ID} refactored and committed
140
+
141
+ ## Handover Manifest
142
+ ```yaml
143
+ phase: "REFACTOR"
144
+ task_id: "{TASK_ID}"
145
+ spec_dir: "{SPEC_DIR}"
146
+ status: "PASS"
147
+ files:
148
+ - path: "path/to/source_file.ext"
149
+ action: "modified"
150
+ purpose: "<REFACTOR_PURPOSE>"
151
+ refactoring:
152
+ smells_addressed:
153
+ - "<SMELL_1>"
154
+ - "<SMELL_2>"
155
+ patterns_applied:
156
+ - "<PATTERN_1>"
157
+ - "<PATTERN_2>"
158
+ verification_command: "{test_command}"
159
+ constraints_preserved:
160
+ - "<ALL_CONSTRAINTS_MAINTAINED>"
161
+ reasoning:
162
+ approach: "<REFACTORING_APPROACH>"
163
+ key_decisions:
164
+ - decision: "<DECISION_1>"
165
+ rationale: "<WHY_THIS_PATTERN>"
166
+ artifacts:
167
+ - "<FUNCTIONS_ADDED_OR_MODIFIED>"
168
+ previous_phase: "/deviate-green"
169
+ next_phase: "/deviate-red (fresh cycle) | /tools:pr (all complete)"
170
+ ```
171
+ ```
172
+
173
+
174
+
175
+ </output_contract>
176
+
177
+ <quality_indicators>
178
+ Refactor is successful if:
179
+ 1. **Behavior Invariance**: All existing tests pass without modification.
180
+ 2. **Readability**: Code intent is clear without comments.
181
+ 3. **SNR Maximization**: Low filler, high logical density.
182
+ 4. **Architectural Fidelity**: Matches the project's established patterns.
183
+ </quality_indicators>
184
+
185
+ <edge_case_handling>
186
+
187
+ | Condition | Action |
188
+ |---|---|
189
+ | Refactor breaks tests | Revert to Green implementation; identify why behavior changed |
190
+ | New smell discovered during refactor | Apply secondary pattern; do not expand scope beyond task |
191
+ | Test command empty | Skip verification and proceed |
192
+ | Lint fails | Fix lint issues, re-run tests until both pass |
193
+ | No active task found | Surface NO_TASKS_REMAINING message and stop |
194
+ | Post-script returns COMMIT_FAILED | Inspect pre-commit hook output, fix issues (lint/format/test), re-run `deviate refactor post` |
195
+
196
+ </edge_case_handling>
197
+
198
+ <constraints>
199
+ - Preserve externally observable behavior (no behavior changes).
200
+ - Modifying tests is prohibited in the Refactor phase.
201
+ - Ensure 100% test pass before concluding.
202
+ - Commit automatically after refactoring via post-script.
203
+ - Preserve all existing architectural invariants.
204
+ </constraints>
205
+
206
+ <context>
207
+ <user_input>
208
+ $ARGUMENTS
209
+ </user_input>
210
+ </context>
211
+
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: deviate-release
3
+ description: Plan the next coherent release — compile from existing flows and architecture and write specs/_product/release-next.md.
4
+ category: deviatdd-product-layer
5
+ version: 1.0.0
6
+ aliases:
7
+ - release
8
+ - /deviate-release
9
+ - spec:release
10
+ - spec.release
11
+ ---
12
+
13
+ <system_instructions>
14
+
15
+ This engine operates exclusively as an isolated, context-bounded Product-layer
16
+ release planning assistant for the DeviaTDD framework. Your objective is to
17
+ accept a release-goal description from the user, compile the next coherent
18
+ product release from existing flows and architecture, and write or override
19
+ `specs/_product/release-next.md` as the guiding compass for downstream
20
+ exploration phases.
21
+
22
+ CRITICAL INVARIANTS:
23
+
24
+ 1. **Architecture + Flows Precondition Gate**: This skill MUST refuse to run
25
+ unless both `specs/_product/architecture.md` and at least one flow file
26
+ under `specs/_product/flows/` exist (per FLOW-03 Preconditions at
27
+ `specs/_product/flows/flows-product.md:77-79`). If either is absent, surface
28
+ `[red]ARCH_OR_FLOWS_MISSING[/]` and recommend `/deviate-architecture` or
29
+ `/deviate-flows` respectively.
30
+ 2. **Goal-First Composition**: The release MUST be expressed as a coherent
31
+ slice of flows and epics that makes sense to users and to the business. The
32
+ user supplies a release-goal description; the agent derives the Included
33
+ Flows table, the Included Work table, and the Acceptance Criteria from that
34
+ goal plus the existing flow and architecture artifacts.
35
+ 3. **Acceptance Criteria Mandate**: `specs/_product/release-next.md` MUST end
36
+ with an `## Acceptance Criteria` section enumerating concrete, testable
37
+ statements. The first criterion MUST cite `deviate setup` installation
38
+ semantics when Product-layer skills are part of the release scope (per
39
+ `specs/_product/release-next.md:26`).
40
+ 4. **Flow Reference Discipline**: Every entry in the Included Work table MUST
41
+ carry a `Flow Refs` column listing the `FLOW-NN` IDs the work touches (or
42
+ `none` for enabling/infrastructure slices). This column is the contract
43
+ downstream `deviate shard` and `deviate adhoc` use to populate
44
+ `flow_refs:` frontmatter.
45
+ 5. **Override Semantics**: Re-running `/deviate-release` for the same release
46
+ target OVERRIDES the prior `specs/_product/release-next.md`. Surface a
47
+ `[yellow]RELEASE_OVERRIDE[/]` banner before writing; preserve a
48
+ `[yellow]WARN[/]` if the prior release had any non-trivial Acceptance
49
+ Criteria that the new release omits.
50
+ 6. **Cross-Layer Compass**: After writing `release-next.md`, this skill does
51
+ NOT trigger downstream exploration itself. It surfaces the file path to the
52
+ user and recommends `/deviate-explore` as the next step.
53
+ 7. **Relative Path Discipline**: Every path written into the release file MUST
54
+ be relative to `repo_root`. No absolute paths.
55
+ 8. **No Product-Layer Command Modification**: This skill MUST NOT create, edit,
56
+ or delete any file under `src/deviate/prompts/commands/`. Commands are the
57
+ agent invocation surface, not the release artifact surface.
58
+
59
+ </system_instructions>
60
+
61
+ <workflow>
62
+
63
+ ## 1. Precondition Check
64
+ Verify `specs/_product/architecture.md` exists and at least one flow file
65
+ exists under `specs/_product/flows/`. Refuse with `[red]ARCH_OR_FLOWS_MISSING[/]`
66
+ if either is missing.
67
+
68
+ ## 2. Read Catalogs
69
+ Load the full flow catalog from `specs/_product/flows/index.md` and the
70
+ component→flow map from `specs/_product/architecture.md`. Build a unified
71
+ flow-to-component lookup.
72
+
73
+ ## 3. Accept Release Goal
74
+ The user supplies a release-goal description. If absent, prompt for one with
75
+ focus questions (what user-facing capability, what business outcome, what
76
+ constraints).
77
+
78
+ ## 4. Compile Release
79
+ Derive from the goal:
80
+ - **Goal section** — one to three sentences restating the release purpose.
81
+ - **Constraints section** — derived from the constitution and the user's
82
+ stated constraints (e.g., "Minimal cli implementation").
83
+ - **Included Flows table** — flow IDs directly served by the release.
84
+ - **Included Work table** — epics, ADHOCs, or infra items, each with a
85
+ `Flow Refs` column.
86
+ - **Deferred Epics section** — epics the user explicitly defers (default
87
+ `N/A`).
88
+ - **Acceptance Criteria section** — concrete, testable statements.
89
+
90
+ ## 5. Override or Create
91
+ If `specs/_product/release-next.md` exists, surface `[yellow]RELEASE_OVERRIDE[/]`
92
+ before overwriting. Compare Acceptance Criteria and surface any omissions.
93
+
94
+ ## 6. Write Release File
95
+ Write the composed content to `specs/_product/release-next.md`. Use the
96
+ schema established at `specs/_product/release-next.md:1-26` as the canonical
97
+ structure (Goal, Constraints, Included Flows, Included Work, Deferred Epics,
98
+ Acceptance Criteria).
99
+
100
+ ## 7. Recommend Next Step
101
+ Inform the user that `/deviate-explore` should now be invoked against the
102
+ release file as the guiding compass. Do NOT trigger exploration automatically.
103
+
104
+ </workflow>
105
+
106
+ <edge_case_handling>
107
+
108
+ | Condition | Action |
109
+ |---|---|
110
+ | `architecture.md` missing | Refuse with `[red]ARCH_OR_FLOWS_MISSING[/]`; recommend `/deviate-architecture` |
111
+ | No flow files under `specs/_product/flows/` | Refuse with `[red]ARCH_OR_FLOWS_MISSING[/]`; recommend `/deviate-flows` |
112
+ | Release file already exists | Surface `[yellow]RELEASE_OVERRIDE[/]`; show diff before write |
113
+ | Prior release had non-trivial ACs that new release omits | Surface `[yellow]WARN[/]` listing dropped ACs |
114
+ | User goal references no flows | Surface clarifying question: "Which flows should this release serve?" |
115
+ | Included Work item has no flow refs | Default `Flow Refs: none` for enabling/infrastructure slices |
116
+
117
+ </edge_case_handling>
118
+
119
+ <context>
120
+ <user_input>
121
+ $ARGUMENTS
122
+ </user_input>
123
+ </context>