@urielsh/prodify 0.1.0

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 (273) hide show
  1. package/.prodify/AGENTS.md +56 -0
  2. package/.prodify/README.md +10 -0
  3. package/.prodify/artifacts/01-understand.md +28 -0
  4. package/.prodify/artifacts/02-diagnose.md +26 -0
  5. package/.prodify/artifacts/03-architecture.md +30 -0
  6. package/.prodify/artifacts/04-plan.md +35 -0
  7. package/.prodify/artifacts/05-refactor.md +24 -0
  8. package/.prodify/artifacts/06-validate.md +17 -0
  9. package/.prodify/artifacts/README.md +6 -0
  10. package/.prodify/artifacts/architecture_spec.md +29 -0
  11. package/.prodify/artifacts/artifact-validation-design.md +276 -0
  12. package/.prodify/artifacts/cli-command-design.md +299 -0
  13. package/.prodify/artifacts/completed-steps-tracking.md +201 -0
  14. package/.prodify/artifacts/diagnostic_report.md +45 -0
  15. package/.prodify/artifacts/hardening-patch-summary.md +57 -0
  16. package/.prodify/artifacts/hardening-verification-report.md +48 -0
  17. package/.prodify/artifacts/implementation_summary.md +19 -0
  18. package/.prodify/artifacts/improvement-evaluation-spec.md +148 -0
  19. package/.prodify/artifacts/next-step-resolver-design.md +570 -0
  20. package/.prodify/artifacts/orientation_map.md +32 -0
  21. package/.prodify/artifacts/persona-removal-audit.md +106 -0
  22. package/.prodify/artifacts/planning-alignment-report.md +189 -0
  23. package/.prodify/artifacts/refactor-plan-template-hardening.md +83 -0
  24. package/.prodify/artifacts/refactor-validate-loop-design.md +231 -0
  25. package/.prodify/artifacts/refactor_plan.md +21 -0
  26. package/.prodify/artifacts/refactor_plan.strict-example.md +31 -0
  27. package/.prodify/artifacts/run-state-design.md +292 -0
  28. package/.prodify/artifacts/run-summary-spec.md +149 -0
  29. package/.prodify/artifacts/run_state.json +14 -0
  30. package/.prodify/artifacts/sample-repo-test-plan.md +129 -0
  31. package/.prodify/artifacts/status-output-spec.md +349 -0
  32. package/.prodify/artifacts/step-selection-design.md +251 -0
  33. package/.prodify/artifacts/task-dispatcher-design.md +266 -0
  34. package/.prodify/artifacts/task-header-audit.md +42 -0
  35. package/.prodify/artifacts/task-log-enhancement-spec.md +264 -0
  36. package/.prodify/artifacts/task-protocol-hardening-plan.md +68 -0
  37. package/.prodify/artifacts/task-self-validation-spec.md +171 -0
  38. package/.prodify/artifacts/task_log.json +160 -0
  39. package/.prodify/artifacts/template-usage-audit.md +20 -0
  40. package/.prodify/artifacts/validation_report.md +22 -0
  41. package/.prodify/contracts/README.md +3 -0
  42. package/.prodify/contracts/architecture.contract.json +42 -0
  43. package/.prodify/contracts/diagnose.contract.json +42 -0
  44. package/.prodify/contracts/plan.contract.json +42 -0
  45. package/.prodify/contracts/refactor.contract.json +45 -0
  46. package/.prodify/contracts/understand.contract.json +42 -0
  47. package/.prodify/contracts/validate.contract.json +52 -0
  48. package/.prodify/contracts-src/README.md +4 -0
  49. package/.prodify/contracts-src/architecture.contract.md +29 -0
  50. package/.prodify/contracts-src/diagnose.contract.md +29 -0
  51. package/.prodify/contracts-src/plan.contract.md +29 -0
  52. package/.prodify/contracts-src/refactor.contract.md +32 -0
  53. package/.prodify/contracts-src/understand.contract.md +29 -0
  54. package/.prodify/contracts-src/validate.contract.md +35 -0
  55. package/.prodify/metrics/README.md +4 -0
  56. package/.prodify/planning.md +13 -0
  57. package/.prodify/project.md +15 -0
  58. package/.prodify/rules/01-global-operating-rules.md +21 -0
  59. package/.prodify/rules/02-analysis-discipline.md +17 -0
  60. package/.prodify/rules/03-diagnosis-severity-rules.md +42 -0
  61. package/.prodify/rules/04-architecture-rules.md +27 -0
  62. package/.prodify/rules/05-planning-rules.md +23 -0
  63. package/.prodify/rules/06-refactor-rules.md +20 -0
  64. package/.prodify/rules/07-validation-rules.md +25 -0
  65. package/.prodify/rules/08-output-format-rules.md +20 -0
  66. package/.prodify/rules/09-template-usage-rules.md +11 -0
  67. package/.prodify/rules/10-artifact-flow-and-orchestration-rules.md +40 -0
  68. package/.prodify/rules/README.md +3 -0
  69. package/.prodify/rules/example-rule.md +4 -0
  70. package/.prodify/runtime-commands.md +57 -0
  71. package/.prodify/skills/README.md +8 -0
  72. package/.prodify/skills/domain/react-frontend.skill.json +34 -0
  73. package/.prodify/skills/domain/typescript-backend.skill.json +34 -0
  74. package/.prodify/skills/quality-policy/maintainability-review.skill.json +25 -0
  75. package/.prodify/skills/quality-policy/security-hardening.skill.json +32 -0
  76. package/.prodify/skills/quality-policy/test-hardening.skill.json +23 -0
  77. package/.prodify/skills/registry.json +16 -0
  78. package/.prodify/skills/stage-method/architecture-method.skill.json +22 -0
  79. package/.prodify/skills/stage-method/codebase-scanning.skill.json +22 -0
  80. package/.prodify/skills/stage-method/diagnosis-method.skill.json +22 -0
  81. package/.prodify/skills/stage-method/planning-method.skill.json +22 -0
  82. package/.prodify/skills/stage-method/refactoring-method.skill.json +22 -0
  83. package/.prodify/skills/stage-method/validation-method.skill.json +22 -0
  84. package/.prodify/state.json +30 -0
  85. package/.prodify/tasks/01-understand.md +83 -0
  86. package/.prodify/tasks/02-diagnose.md +67 -0
  87. package/.prodify/tasks/03-architecture.md +70 -0
  88. package/.prodify/tasks/04-plan.md +71 -0
  89. package/.prodify/tasks/05-refactor.md +61 -0
  90. package/.prodify/tasks/06-validate.md +69 -0
  91. package/.prodify/tasks/README.md +3 -0
  92. package/.prodify/tasks/example-task.md +13 -0
  93. package/.prodify/templates/01-understand.template.md +18 -0
  94. package/.prodify/templates/02-diagnose.template.md +18 -0
  95. package/.prodify/templates/03-architecture.template.md +18 -0
  96. package/.prodify/templates/04-plan.template.md +22 -0
  97. package/.prodify/templates/05-refactor.template.md +19 -0
  98. package/.prodify/templates/06-validate.template.md +16 -0
  99. package/.prodify/templates/README.md +3 -0
  100. package/.prodify/templates/architecture_spec.template.md +29 -0
  101. package/.prodify/templates/diagnostic_report.template.md +45 -0
  102. package/.prodify/templates/example.template.md +5 -0
  103. package/.prodify/templates/implementation_summary.template.md +19 -0
  104. package/.prodify/templates/orientation_map.template.md +32 -0
  105. package/.prodify/templates/refactor_plan.template.md +24 -0
  106. package/.prodify/templates/validation_report.template.md +22 -0
  107. package/.prodify/version.json +5 -0
  108. package/AGENTS.md +305 -0
  109. package/LICENSE +201 -0
  110. package/README.md +118 -0
  111. package/assets/presets/default/canonical/AGENTS.md +54 -0
  112. package/assets/presets/default/canonical/artifacts/README.md +6 -0
  113. package/assets/presets/default/canonical/contracts-src/README.md +4 -0
  114. package/assets/presets/default/canonical/contracts-src/architecture.contract.md +56 -0
  115. package/assets/presets/default/canonical/contracts-src/diagnose.contract.md +49 -0
  116. package/assets/presets/default/canonical/contracts-src/plan.contract.md +42 -0
  117. package/assets/presets/default/canonical/contracts-src/refactor.contract.md +54 -0
  118. package/assets/presets/default/canonical/contracts-src/understand.contract.md +56 -0
  119. package/assets/presets/default/canonical/contracts-src/validate.contract.md +64 -0
  120. package/assets/presets/default/canonical/metrics/README.md +4 -0
  121. package/assets/presets/default/canonical/planning.md +13 -0
  122. package/assets/presets/default/canonical/project.md +15 -0
  123. package/assets/presets/default/canonical/rules/README.md +3 -0
  124. package/assets/presets/default/canonical/rules/example-rule.md +4 -0
  125. package/assets/presets/default/canonical/runtime-commands.md +57 -0
  126. package/assets/presets/default/canonical/skills/README.md +8 -0
  127. package/assets/presets/default/canonical/skills/domain/react-frontend.skill.json +34 -0
  128. package/assets/presets/default/canonical/skills/domain/typescript-backend.skill.json +34 -0
  129. package/assets/presets/default/canonical/skills/quality-policy/maintainability-review.skill.json +25 -0
  130. package/assets/presets/default/canonical/skills/quality-policy/security-hardening.skill.json +32 -0
  131. package/assets/presets/default/canonical/skills/quality-policy/test-hardening.skill.json +23 -0
  132. package/assets/presets/default/canonical/skills/registry.json +16 -0
  133. package/assets/presets/default/canonical/skills/stage-method/architecture-method.skill.json +22 -0
  134. package/assets/presets/default/canonical/skills/stage-method/codebase-scanning.skill.json +22 -0
  135. package/assets/presets/default/canonical/skills/stage-method/diagnosis-method.skill.json +22 -0
  136. package/assets/presets/default/canonical/skills/stage-method/planning-method.skill.json +22 -0
  137. package/assets/presets/default/canonical/skills/stage-method/refactoring-method.skill.json +22 -0
  138. package/assets/presets/default/canonical/skills/stage-method/validation-method.skill.json +22 -0
  139. package/assets/presets/default/canonical/state.json +30 -0
  140. package/assets/presets/default/canonical/tasks/README.md +3 -0
  141. package/assets/presets/default/canonical/tasks/example-task.md +13 -0
  142. package/assets/presets/default/canonical/templates/README.md +3 -0
  143. package/assets/presets/default/canonical/templates/example.template.md +5 -0
  144. package/assets/presets/default/preset.json +5 -0
  145. package/dist/cli.js +53 -0
  146. package/dist/commands/doctor.js +16 -0
  147. package/dist/commands/init.js +30 -0
  148. package/dist/commands/install.js +27 -0
  149. package/dist/commands/setup-agent.js +23 -0
  150. package/dist/commands/status.js +28 -0
  151. package/dist/commands/sync.js +29 -0
  152. package/dist/commands/update.js +18 -0
  153. package/dist/contracts/compiled-schema.js +37 -0
  154. package/dist/contracts/compiler.js +83 -0
  155. package/dist/contracts/freshness.js +52 -0
  156. package/dist/contracts/index.js +5 -0
  157. package/dist/contracts/parser.js +201 -0
  158. package/dist/contracts/schema.js +138 -0
  159. package/dist/contracts/source-schema.js +111 -0
  160. package/dist/core/agent-runtime.js +36 -0
  161. package/dist/core/agent-setup.js +111 -0
  162. package/dist/core/doctor.js +155 -0
  163. package/dist/core/errors.js +19 -0
  164. package/dist/core/flow-state.js +262 -0
  165. package/dist/core/fs.js +50 -0
  166. package/dist/core/install.js +44 -0
  167. package/dist/core/managed-files.js +106 -0
  168. package/dist/core/paths.js +56 -0
  169. package/dist/core/preset-validation.js +43 -0
  170. package/dist/core/prompt-builder.js +63 -0
  171. package/dist/core/repo-context.js +77 -0
  172. package/dist/core/repo-root.js +55 -0
  173. package/dist/core/skill-resolution.js +123 -0
  174. package/dist/core/state.js +220 -0
  175. package/dist/core/status.js +293 -0
  176. package/dist/core/sync.js +63 -0
  177. package/dist/core/targets.js +48 -0
  178. package/dist/core/upgrade.js +57 -0
  179. package/dist/core/validation.js +138 -0
  180. package/dist/core/version-checks.js +35 -0
  181. package/dist/generators/claude.js +14 -0
  182. package/dist/generators/codex.js +14 -0
  183. package/dist/generators/copilot.js +29 -0
  184. package/dist/generators/header.js +13 -0
  185. package/dist/generators/opencode.js +14 -0
  186. package/dist/generators/shared.js +37 -0
  187. package/dist/index.js +9 -0
  188. package/dist/legacy/targets.js +55 -0
  189. package/dist/presets/default.js +3 -0
  190. package/dist/presets/loader.js +34 -0
  191. package/dist/presets/version.js +18 -0
  192. package/dist/scoring/model.js +262 -0
  193. package/dist/skills/loader.js +40 -0
  194. package/dist/skills/schema.js +159 -0
  195. package/dist/types.js +1 -0
  196. package/docs/canonical-prodify-layout.md +87 -0
  197. package/docs/claude-support.md +22 -0
  198. package/docs/cli-doctor-spec.md +52 -0
  199. package/docs/cli-init-spec.md +70 -0
  200. package/docs/cli-install-agent-spec.md +48 -0
  201. package/docs/cli-sync-spec.md +40 -0
  202. package/docs/codex-support.md +24 -0
  203. package/docs/compatibility-targets.md +59 -0
  204. package/docs/copilot-support.md +30 -0
  205. package/docs/default-preset.md +47 -0
  206. package/docs/generated-file-headers.md +45 -0
  207. package/docs/generation-rules.md +94 -0
  208. package/docs/idempotency-guarantees.md +31 -0
  209. package/docs/managed-file-detection.md +45 -0
  210. package/docs/manual-edit-conflicts.md +37 -0
  211. package/docs/opencode-support.md +27 -0
  212. package/docs/ownership-rules.md +39 -0
  213. package/docs/path-resolution-rules.md +40 -0
  214. package/docs/preset-structure.md +49 -0
  215. package/docs/skill-system.md +67 -0
  216. package/docs/versioning-and-upgrade-strategy.md +40 -0
  217. package/package.json +22 -0
  218. package/src/README.md +11 -0
  219. package/src/cli.ts +61 -0
  220. package/src/commands/doctor.ts +20 -0
  221. package/src/commands/init.ts +37 -0
  222. package/src/commands/setup-agent.ts +28 -0
  223. package/src/commands/status.ts +34 -0
  224. package/src/commands/update.ts +23 -0
  225. package/src/contracts/README.md +10 -0
  226. package/src/contracts/compiled-schema.ts +42 -0
  227. package/src/contracts/compiler.ts +111 -0
  228. package/src/contracts/freshness.ts +58 -0
  229. package/src/contracts/index.ts +11 -0
  230. package/src/contracts/parser.ts +253 -0
  231. package/src/contracts/source-schema.ts +141 -0
  232. package/src/core/agent-runtime.ts +53 -0
  233. package/src/core/agent-setup.ts +147 -0
  234. package/src/core/doctor.ts +171 -0
  235. package/src/core/errors.ts +28 -0
  236. package/src/core/flow-state.ts +333 -0
  237. package/src/core/fs.ts +59 -0
  238. package/src/core/paths.ts +63 -0
  239. package/src/core/preset-validation.ts +47 -0
  240. package/src/core/prompt-builder.ts +73 -0
  241. package/src/core/repo-context.ts +93 -0
  242. package/src/core/repo-root.ts +74 -0
  243. package/src/core/skill-resolution.ts +151 -0
  244. package/src/core/state.ts +264 -0
  245. package/src/core/status.ts +372 -0
  246. package/src/core/targets.ts +53 -0
  247. package/src/core/upgrade.ts +66 -0
  248. package/src/core/validation.ts +233 -0
  249. package/src/core/version-checks.ts +40 -0
  250. package/src/index.ts +13 -0
  251. package/src/presets/default.ts +7 -0
  252. package/src/presets/loader.ts +46 -0
  253. package/src/presets/version.ts +31 -0
  254. package/src/scoring/model.ts +332 -0
  255. package/src/skills/loader.ts +58 -0
  256. package/src/skills/schema.ts +197 -0
  257. package/src/types.ts +329 -0
  258. package/tests/integration/cli-flows.test.js +347 -0
  259. package/tests/unit/agent-setup.test.js +81 -0
  260. package/tests/unit/cli.test.js +28 -0
  261. package/tests/unit/contracts.test.js +61 -0
  262. package/tests/unit/helpers.js +28 -0
  263. package/tests/unit/paths.test.js +52 -0
  264. package/tests/unit/preset-loader.test.js +37 -0
  265. package/tests/unit/scoring.test.js +65 -0
  266. package/tests/unit/self-hosted-workspace.test.js +22 -0
  267. package/tests/unit/skills.test.js +115 -0
  268. package/tests/unit/state-and-flow.test.js +120 -0
  269. package/tests/unit/targets.test.js +13 -0
  270. package/tests/unit/validation.test.js +73 -0
  271. package/tests/unit/version.test.js +24 -0
  272. package/tsconfig.json +23 -0
  273. package/urielsh-prodify-0.1.0.tgz +0 -0
@@ -0,0 +1,299 @@
1
+ # CLI Command Design
2
+
3
+ Date: 2026-03-29
4
+ Scope: `./.prodify/`
5
+
6
+ ## Purpose
7
+
8
+ Define the operator-facing CLI surface for running, advancing, and inspecting Prodify.
9
+
10
+ This command set must:
11
+
12
+ - use the runtime state and resolver design as the control source
13
+ - expose a minimal, understandable interface
14
+ - separate state-changing commands from read-only commands
15
+
16
+ ## Command List
17
+
18
+ The initial CLI surface contains exactly three commands:
19
+
20
+ - `prodify run`
21
+ - `prodify next`
22
+ - `prodify status`
23
+
24
+ ## Shared Inputs
25
+
26
+ All three commands may read:
27
+
28
+ - `.prodify/artifacts/run_state.json`
29
+ - `.prodify/artifacts/task_log.json`
30
+ - `.prodify/artifacts/validation_report.md`
31
+
32
+ Supporting design references:
33
+
34
+ - `.prodify/artifacts/run-state-design.md`
35
+ - `.prodify/artifacts/next-step-resolver-design.md`
36
+
37
+ ## Command Boundaries
38
+
39
+ ### `prodify run`
40
+ - mutates workflow state by executing work
41
+ - may write runtime artifacts and update task history
42
+ - uses the resolver to decide what to execute now
43
+
44
+ ### `prodify next`
45
+ - does not execute work
46
+ - does not mutate workflow state
47
+ - shows the resolver's current next-step decision
48
+
49
+ ### `prodify status`
50
+ - does not execute work
51
+ - does not mutate workflow state
52
+ - shows a concise human-readable snapshot of progress
53
+
54
+ ## Command Behavior
55
+
56
+ ### `prodify run`
57
+
58
+ #### Goal
59
+ Execute the next allowed unit of work from the current runtime state.
60
+
61
+ #### Inputs
62
+ - required:
63
+ - `.prodify/artifacts/run_state.json`
64
+ - optional but normally present:
65
+ - `.prodify/artifacts/task_log.json`
66
+ - `.prodify/artifacts/validation_report.md`
67
+ - runtime task files under `.prodify/tasks/`
68
+ - runtime templates under `.prodify/templates/`
69
+
70
+ #### Behavior
71
+ 1. Load and validate `run_state.json`.
72
+ 2. Invoke the next-step resolver.
73
+ 3. If the resolver returns:
74
+ - `dispatch`:
75
+ - dispatch the resolved task
76
+ - `resume`:
77
+ - resume the interrupted task
78
+ - `retry`:
79
+ - rerun the required retry task only
80
+ - `stop_blocked`:
81
+ - stop without mutation and print the blocker
82
+ - `stop_failed`:
83
+ - stop without mutation and print the failure
84
+ - `stop_complete`:
85
+ - stop without mutation and print completion
86
+ 4. If a task runs:
87
+ - perform pre-run validation
88
+ - execute the task
89
+ - validate the output artifact
90
+ - update `run_state.json`
91
+ - append to `task_log.json`
92
+ 5. Exit after one deterministic run cycle.
93
+
94
+ #### Output
95
+ Machine-oriented summary plus concise human feedback:
96
+
97
+ - resolved decision
98
+ - task executed or resumed, if any
99
+ - artifact written, if any
100
+ - state result
101
+ - next recommended action
102
+
103
+ #### Mutation Rule
104
+ `prodify run` is the only command in this initial CLI surface that may advance workflow state.
105
+
106
+ ### `prodify next`
107
+
108
+ #### Goal
109
+ Show what Prodify would do next if asked to run now.
110
+
111
+ #### Inputs
112
+ - `.prodify/artifacts/run_state.json`
113
+ - `.prodify/artifacts/task_log.json`
114
+ - `.prodify/artifacts/validation_report.md`
115
+
116
+ #### Behavior
117
+ 1. Load runtime state.
118
+ 2. Invoke the next-step resolver in read-only mode.
119
+ 3. Return the resolver decision without executing any task.
120
+
121
+ #### Output
122
+ Return:
123
+
124
+ - decision
125
+ - resolved task or stop outcome
126
+ - reason
127
+ - resume condition
128
+ - required repair items if blocked or failed
129
+
130
+ #### Mutation Rule
131
+ `prodify next` must not change:
132
+
133
+ - `run_state.json`
134
+ - `task_log.json`
135
+ - any artifact
136
+
137
+ ### `prodify status`
138
+
139
+ #### Goal
140
+ Show a concise operator summary of current workflow progress.
141
+
142
+ #### Inputs
143
+ - `.prodify/artifacts/run_state.json`
144
+ - `.prodify/artifacts/task_log.json`
145
+ - `.prodify/artifacts/validation_report.md`
146
+
147
+ #### Behavior
148
+ 1. Read current runtime state.
149
+ 2. Summarize current progress and latest known validation posture.
150
+ 3. Optionally call the resolver to enrich status with the current next-step decision.
151
+ 4. Print a concise human-readable view.
152
+
153
+ #### Output
154
+ Must include at minimum:
155
+
156
+ - current status
157
+ - current task or next task
158
+ - last completed task
159
+ - selected refactor step, if any
160
+ - completed step count or IDs when relevant
161
+ - latest validation posture
162
+
163
+ Detailed formatting is deferred to Task `52-add-status-output`.
164
+
165
+ #### Mutation Rule
166
+ `prodify status` is strictly read-only.
167
+
168
+ ## Mapping To Workflow State
169
+
170
+ | State condition | `prodify run` | `prodify next` | `prodify status` |
171
+ | --- | --- | --- | --- |
172
+ | `ready` with valid `next_task` | execute the resolved task | show the task to be run | show runnable state and upcoming task |
173
+ | `running` with valid `current_task` | resume current task | show resume target | show interrupted task and resumable state |
174
+ | `awaiting_validation` | execute `06-validate` | show validation-required next step | show validation pending |
175
+ | `blocked` | stop and print blocker | show blocked decision | show blocker notes |
176
+ | `failed` with retryable target | retry only the required task | show retry target | show failed state and retry context |
177
+ | `complete` | stop and print completion | show complete stop | show completed run |
178
+
179
+ ## State-Specific Command Notes
180
+
181
+ ### Ready
182
+ - `run` should advance one step.
183
+ - `next` should expose the exact resolver choice.
184
+ - `status` should communicate that the system is runnable.
185
+
186
+ ### Running
187
+ - `run` should resume, not skip ahead.
188
+ - `next` should report `resume`.
189
+ - `status` should show the interrupted task clearly.
190
+
191
+ ### Awaiting Validation
192
+ - `run` must execute `06-validate` immediately.
193
+ - `next` must not suggest `05-refactor`.
194
+ - `status` should make validation urgency visible.
195
+
196
+ ### Blocked
197
+ - `run` must not guess or auto-repair.
198
+ - `next` should report the blocker and repair condition.
199
+ - `status` should surface the blocker note plainly.
200
+
201
+ ### Failed
202
+ - `run` should only retry the deterministic retry target after failure conditions are corrected.
203
+ - `next` should expose whether retry is possible or state reconciliation is needed.
204
+ - `status` should show the failed step or task and the failure note.
205
+
206
+ ### Complete
207
+ - `run` should exit cleanly without further work.
208
+ - `next` should return a stop-complete decision.
209
+ - `status` should show terminal completion.
210
+
211
+ ## Current-State Compatibility Rules
212
+
213
+ The current repo still contains partial runtime artifacts. The CLI design must account for that.
214
+
215
+ ### Missing `completed_step_ids`
216
+ If `run_state.json` is missing required resolver fields:
217
+
218
+ - `run` must stop blocked
219
+ - `next` must report schema incompleteness
220
+ - `status` must show that state is incomplete rather than pretending the run is healthy
221
+
222
+ ### Template-Only `validation_report.md`
223
+ If the validation report is still placeholder-shaped:
224
+
225
+ - `run` must treat validation-dependent decisions as blocked or inconclusive when resolver rules require it
226
+ - `next` must report `validation_inconclusive`
227
+ - `status` should show latest validation as unknown or inconclusive, not PASS
228
+
229
+ ## Example Command Outputs
230
+
231
+ ### Example 1 - `prodify next`
232
+ Input condition:
233
+ - `status: ready`
234
+ - `next_task: "04-plan"`
235
+
236
+ Example output:
237
+
238
+ ```text
239
+ decision: dispatch
240
+ resolved_task: 04-plan
241
+ reason: linear_pipeline_ready
242
+ resume_condition: state already runnable
243
+ ```
244
+
245
+ ### Example 2 - `prodify run`
246
+ Input condition:
247
+ - `status: awaiting_validation`
248
+ - `next_task: "06-validate"`
249
+
250
+ Example output:
251
+
252
+ ```text
253
+ decision: dispatch
254
+ executed_task: 06-validate
255
+ artifact_written: .prodify/artifacts/validation_report.md
256
+ state_result: ready
257
+ next_action: evaluate remaining refactor steps
258
+ ```
259
+
260
+ ### Example 3 - `prodify status`
261
+ Input condition:
262
+ - `status: failed`
263
+ - `next_task: "05-refactor"`
264
+ - `selected_refactor_step: "step-03-extract-service"`
265
+
266
+ Example output:
267
+
268
+ ```text
269
+ Status: failed
270
+ Current task: none
271
+ Next task: 05-refactor
272
+ Last completed task: 05-refactor
273
+ Selected refactor step: step-03-extract-service
274
+ Latest validation: FAIL
275
+ Note: retry the selected step after correcting the regression
276
+ ```
277
+
278
+ ## Minimal Interface Contract
279
+
280
+ ### `prodify run`
281
+ - input: current runtime artifacts
282
+ - output: one execution-cycle result
283
+ - side effects: yes
284
+
285
+ ### `prodify next`
286
+ - input: current runtime artifacts
287
+ - output: one resolver decision
288
+ - side effects: no
289
+
290
+ ### `prodify status`
291
+ - input: current runtime artifacts
292
+ - output: one concise status summary
293
+ - side effects: no
294
+
295
+ ## Implementation Notes
296
+
297
+ - Keep the first CLI version narrow and deterministic.
298
+ - Route all execution intent through the resolver instead of duplicating branching logic inside commands.
299
+ - Let Task `52-add-status-output` refine formatting, while this task defines command semantics and command/state boundaries.
@@ -0,0 +1,201 @@
1
+ # Completed Steps Tracking
2
+
3
+ Date: 2026-03-28
4
+ Scope: `./.prodify/artifacts/run_state.json`
5
+
6
+ ## Purpose
7
+ Define how completed refactor steps are recorded, reused, protected from duplicate execution, and safely overridden when recovery is necessary.
8
+
9
+ ## Storage Model
10
+
11
+ ### Canonical Store
12
+ Use `completed_step_ids` in `.prodify/artifacts/run_state.json` as the canonical source of truth for completed refactor steps.
13
+
14
+ Field shape:
15
+ ```json
16
+ {
17
+ "completed_step_ids": [
18
+ "step-01-rename-module",
19
+ "step-02-add-guard-clause"
20
+ ]
21
+ }
22
+ ```
23
+
24
+ ### Meaning
25
+ - Each entry represents one refactor-plan step that:
26
+ - was executed by Task `05-refactor`
27
+ - was validated successfully by Task `06-validate`
28
+ - A step is not complete merely because Task `05-refactor` ran.
29
+ - A step becomes complete only after validation PASS.
30
+
31
+ ### Scope Constraint
32
+ - `completed_step_ids` applies only to steps parsed from `refactor_plan.md`.
33
+ - IDs not present in the current parsed plan are invalid and must trigger state repair.
34
+
35
+ ## Update Rules
36
+
37
+ ### Add Rule
38
+ Append a step ID to `completed_step_ids` only when all of the following are true:
39
+ - `selected_refactor_step` is non-null
40
+ - Task `06-validate` completed with PASS for that step
41
+ - the step exists in the current parsed `refactor_plan.md`
42
+ - the step ID is not already present in `completed_step_ids`
43
+
44
+ ### Do Not Add Rule
45
+ Do not append the step ID when:
46
+ - Task `05-refactor` finished but Task `06-validate` has not run yet
47
+ - Task `06-validate` failed
48
+ - Task `06-validate` was inconclusive
49
+ - the selected step is missing from the plan
50
+ - the plan is malformed or unpopulated
51
+
52
+ ### Remove Rule
53
+ Remove a step ID only through an explicit manual override or state-repair action.
54
+
55
+ Automatic execution must not silently remove completed steps.
56
+
57
+ ### Reconciliation Rule
58
+ On every step-selection or resume pass:
59
+ - compare `completed_step_ids` against the current parsed plan
60
+ - if any completed ID is absent from the plan:
61
+ - stop execution
62
+ - mark the state invalid or failed
63
+ - require reconciliation before continuing
64
+
65
+ ## Duplicate Prevention
66
+
67
+ ### Storage-Level Prevention
68
+ - `completed_step_ids` must behave as a set, even though it is stored as an ordered array.
69
+ - The same step ID must not appear more than once.
70
+
71
+ ### Execution-Level Prevention
72
+ Before selecting or dispatching a step:
73
+ - exclude every ID already present in `completed_step_ids`
74
+ - do not re-run a step that is already marked complete unless a manual override explicitly removed it from the completed list
75
+
76
+ ### Append Guard
77
+ Before appending a step on validation PASS:
78
+ - check whether the step ID already exists in `completed_step_ids`
79
+ - if it already exists:
80
+ - do not append it again
81
+ - treat the situation as a stale-state warning rather than creating a duplicate
82
+
83
+ ### Order Rule
84
+ - Preserve completion order in the array for traceability.
85
+ - Duplicate prevention takes priority over preserving attempted append order.
86
+
87
+ ## Override Behavior
88
+
89
+ ### Override Types
90
+ Supported manual overrides:
91
+ 1. **Remove one completed step**
92
+ - used when a previously completed step must be rerun
93
+ 2. **Reset all completed steps**
94
+ - used when the loop must restart from the beginning
95
+ 3. **Add a completed step manually**
96
+ - allowed only for explicit recovery/migration scenarios, never as the normal execution path
97
+
98
+ ### Override Requirements
99
+ Every override must:
100
+ - be explicit and operator-driven
101
+ - name the exact step IDs affected
102
+ - leave a high-signal note in `run_state.json`
103
+ - trigger a consistency check against the current parsed plan
104
+
105
+ ### Safe Remove Override
106
+ When removing a completed step:
107
+ - remove the step ID from `completed_step_ids`
108
+ - clear or reset `selected_refactor_step` if it points to an inconsistent step
109
+ - set `next_task` to `05-refactor`
110
+ - set `status` to `ready` or `blocked` depending on whether more repair is needed
111
+
112
+ ### Safe Reset Override
113
+ When resetting all completed steps:
114
+ - set `completed_step_ids` to `[]`
115
+ - set `selected_refactor_step` to `null`
116
+ - set `next_task` to `05-refactor` only if a valid step can be reselected
117
+ - otherwise block until planning/state repair is complete
118
+
119
+ ### Manual Add Override
120
+ Manual addition is the riskiest override and should be rare.
121
+
122
+ Allowed only when:
123
+ - the operator is reconciling known-good historical state
124
+ - the step exists in the current parsed plan
125
+ - a note explains why the system is trusting this completion without the current loop replay
126
+
127
+ After a manual add:
128
+ - re-run consistency checks
129
+ - ensure the step selector excludes the step
130
+
131
+ ## Override Safety Rules
132
+ - Overrides must never create duplicates.
133
+ - Overrides must never reference step IDs absent from the current plan.
134
+ - Overrides must never silently skip required validation for new work.
135
+ - After any override, the system must re-evaluate:
136
+ - `selected_refactor_step`
137
+ - `completed_step_ids`
138
+ - `next_task`
139
+ - `status`
140
+
141
+ ## Reuse Rules
142
+
143
+ ### Normal Reuse
144
+ Completed steps are reused by exclusion:
145
+ - the step-selection layer subtracts `completed_step_ids` from the parsed plan steps
146
+ - only remaining steps are considered selectable
147
+
148
+ ### Loop Reuse
149
+ After Task `06-validate` PASS:
150
+ - append the just-validated step
151
+ - select the next remaining step if any exist
152
+ - stop complete if none remain
153
+
154
+ ### Resume Reuse
155
+ On resume:
156
+ - trust `completed_step_ids` only after verifying all IDs still exist in the current plan
157
+ - if verification fails, block execution until repaired
158
+
159
+ ## Invalid States
160
+
161
+ ### Invalid Completed-Step States
162
+ The following states are invalid:
163
+ - duplicate step IDs in `completed_step_ids`
164
+ - a completed step ID not present in `refactor_plan.md`
165
+ - a completed step ID that is also the active `selected_refactor_step` for retry
166
+ - marking a step complete before validation PASS
167
+
168
+ ### Invalid-State Behavior
169
+ If any invalid state is detected:
170
+ - stop execution
171
+ - set the workflow to `failed` or `blocked`
172
+ - record a precise repair note
173
+ - require reconciliation before the next step may be selected
174
+
175
+ ## Integration Notes
176
+
177
+ ### Integration With Run-State Logic
178
+ - `completed_step_ids` lives in `run_state.json`.
179
+ - The run-state layer owns the actual write/update mechanics.
180
+ - This document defines when updates are valid.
181
+
182
+ ### Integration With Step Selection
183
+ - Step selection must exclude completed IDs from candidate selection.
184
+ - If completed IDs contradict the parsed plan, step selection must stop.
185
+
186
+ ### Integration With Refactor/Validate Loop
187
+ - The refactor/validate loop may add a step only after validation PASS.
188
+ - FAIL or inconclusive validation must leave `completed_step_ids` unchanged.
189
+
190
+ ## Suggested Consistency Check
191
+ Before dispatching or resuming Task `05-refactor`:
192
+ 1. Parse valid step IDs from `refactor_plan.md`.
193
+ 2. Confirm `completed_step_ids` contains unique values only.
194
+ 3. Confirm every completed ID exists in the parsed plan.
195
+ 4. Confirm `selected_refactor_step` is not simultaneously treated as completed unless state repair explicitly requires it.
196
+ 5. Stop on any inconsistency.
197
+
198
+ ## Implementation Notes
199
+ - Treat `completed_step_ids` as append-only during normal successful execution.
200
+ - Reserve deletions for explicit override or reconciliation flows.
201
+ - Prefer blocking on ambiguous state over guessing which steps are complete.
@@ -0,0 +1,45 @@
1
+ # Diagnostic Report
2
+
3
+ ## Top 5 Priorities
4
+ 1.
5
+ 2.
6
+ 3.
7
+ 4.
8
+ 5.
9
+
10
+ ## Critical Issues
11
+ - Issue:
12
+ - File:
13
+ - Category:
14
+ - Impact:
15
+ - Evidence:
16
+
17
+ ## High Issues
18
+ - Issue:
19
+ - File:
20
+ - Category:
21
+ - Impact:
22
+ - Evidence:
23
+
24
+ ## Medium Issues
25
+ - Issue:
26
+ - File:
27
+ - Category:
28
+ - Impact:
29
+ - Evidence:
30
+
31
+ ## Low Issues
32
+ - Issue:
33
+ - File:
34
+ - Category:
35
+ - Impact:
36
+ - Evidence:
37
+
38
+ ## Reliability Risks
39
+ -
40
+
41
+ ## Technical Debt Score
42
+ - Score:
43
+
44
+ ## Notes
45
+ -
@@ -0,0 +1,57 @@
1
+ # Hardening Patch Summary
2
+
3
+ ## Scope
4
+ This patch applied the hardening changes defined by Tasks 81 through 84 to the canonical runtime at `.prodify/` and the root `AGENTS.md`.
5
+
6
+ ## Files Changed
7
+ - `AGENTS.md`
8
+ - `.prodify/tasks/01-understand.md`
9
+ - `.prodify/tasks/02-diagnose.md`
10
+ - `.prodify/tasks/03-architecture.md`
11
+ - `.prodify/tasks/04-plan.md`
12
+ - `.prodify/tasks/05-refactor.md`
13
+ - `.prodify/tasks/06-validate.md`
14
+ - `.prodify/templates/refactor_plan.template.md`
15
+
16
+ ## Changes Applied
17
+ ### Persona and role language removal
18
+ - Removed persona-style sections such as `## Identity & Mandate`.
19
+ - Removed role labels and identity framing from the core task suite.
20
+ - Replaced persona framing with operational sections:
21
+ - `## Goal`
22
+ - `## Scope`
23
+ - `## Inputs`
24
+ - `## Execution Instructions`
25
+ - `## Output Specification`
26
+ - `## Failure Conditions`
27
+ - `## Definition of Done`
28
+
29
+ ### Task protocol hardening
30
+ - Added explicit failure conditions to every core task.
31
+ - Added explicit template conformance requirements for every task output.
32
+ - Added explicit non-modification constraints to Tasks `01` through `04` and `06`.
33
+ - Tightened Task `05` so it must execute exactly one selected refactor step and stop on ambiguous or widened scope.
34
+ - Tightened Task `06` so it must run after Task `05` for the same step and must emit an explicit `PASS` or `FAIL` verdict.
35
+
36
+ ### Refactor plan template hardening
37
+ - Replaced the loose plan structure with a fixed repeated step block.
38
+ - Added `Total steps` to the summary section.
39
+ - Standardized each step block to:
40
+ - `### Step: <ID>`
41
+ - `- Status: pending`
42
+ - `- Description:`
43
+ - `- Files:`
44
+ - `- Risk:`
45
+ - `- Expected outcome:`
46
+ - `- Validation command:`
47
+
48
+ ### Runtime rule alignment
49
+ - Updated `AGENTS.md` to use `completed_step_ids` as the canonical completed-step field.
50
+ - Updated the refactor/validate loop wording so a failed validation retries or repairs the same selected step before continuing.
51
+ - Updated the stop condition so a passed validation continues only when more steps remain.
52
+
53
+ ## Deviations From Plan
54
+ - `AGENTS.md` required a targeted update in addition to the task docs and template so the runtime contract would match the hardened task suite. This was necessary to avoid leaving conflicting loop and state semantics in the root protocol.
55
+
56
+ ## Unresolved Items
57
+ - None identified in the hardening patch itself.
@@ -0,0 +1,48 @@
1
+ # Hardening Verification Report
2
+
3
+ ## Verification Scope
4
+ Verify that the runtime hardening changes from Tasks 81 through 85 were applied consistently across the canonical runtime under `.prodify/` and the root `AGENTS.md`.
5
+
6
+ ## Results
7
+ ### Check 1: Persona language removed from core tasks
8
+ - Result: PASS
9
+ - Evidence: No remaining matches for persona or role markers in `.prodify/tasks/01-understand.md` through `.prodify/tasks/06-validate.md`.
10
+
11
+ ### Check 2: Explicit failure conditions present in all core tasks
12
+ - Result: PASS
13
+ - Evidence: Every core task now includes a `## Failure Conditions` section with explicit stop criteria.
14
+
15
+ ### Check 3: Source-modification constraints preserved
16
+ - Result: PASS
17
+ - Evidence:
18
+ - Tasks `01` through `04` explicitly state `MUST NOT modify source code`.
19
+ - Task `06` explicitly states `MUST NOT modify source code`.
20
+ - Task `05` explicitly restricts scope to one selected step and forbids unrelated file edits.
21
+
22
+ ### Check 4: Refactor execution discipline enforced
23
+ - Result: PASS
24
+ - Evidence: Task `05` explicitly requires execution of exactly one selected refactor step and requires stopping when the selected step is ambiguous, missing, malformed, or overly broad.
25
+
26
+ ### Check 5: Validation verdict discipline enforced
27
+ - Result: PASS
28
+ - Evidence: Task `06` explicitly requires a `PASS` or `FAIL` verdict and treats unsupported verdicts as a stop condition.
29
+
30
+ ### Check 6: Refactor plan template hardened
31
+ - Result: PASS
32
+ - Evidence: `.prodify/templates/refactor_plan.template.md` now uses a fixed repeated step block with `### Step: <ID>` and `- Status: pending`.
33
+
34
+ ### Check 7: Runtime contract aligned
35
+ - Result: PASS
36
+ - Evidence:
37
+ - `AGENTS.md` now refers to `completed_step_ids`.
38
+ - `AGENTS.md` loop behavior now matches the hardened refactor/validate semantics.
39
+
40
+ ## Commands Used
41
+ - `rg -n "Identity & Mandate|Role:|@Repository-Explorer|@Security-Auditor|@Principal-Architect|@DevOps-Planner|@Implementation-Specialist|@Quality-Gatekeeper|## Data Contract" .prodify/tasks`
42
+ - `rg -n "MUST NOT modify source code|MUST STOP|MUST execute exactly one selected refactor step|MUST explicitly report PASS or FAIL|### Step: <ID>|- Status: pending|completed_step_ids|retry or repair the same selected step" .prodify/tasks .prodify/templates/refactor_plan.template.md AGENTS.md`
43
+
44
+ ## Verdict
45
+ - PASS
46
+
47
+ ## Notes
48
+ - The verification covered the canonical runtime locations only: `.prodify/...` and root `AGENTS.md`.
@@ -0,0 +1,19 @@
1
+ # Implementation Summary
2
+
3
+ ## Step Executed
4
+ - Step ID:
5
+
6
+ ## Objective Achieved
7
+ - Yes/No:
8
+
9
+ ## Files Changed
10
+ -
11
+
12
+ ## Diff Summary
13
+ -
14
+
15
+ ## Behavior Change Expected
16
+ - Yes/No:
17
+
18
+ ## Notes
19
+ -