@tothemax/tasking 0.0.0-stage → 0.6.16

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 (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -2
  3. package/README.zh-CN.md +122 -0
  4. package/assets/skills/install-glab/SKILL.md +70 -0
  5. package/assets/skills/land/SKILL.md +63 -0
  6. package/assets/skills/land/land_watch.py +312 -0
  7. package/assets/skills/openspec-archive-change/SKILL.md +114 -0
  8. package/assets/skills/opsx-grill-with-docs/SKILL.md +193 -0
  9. package/assets/skills/opsx-implement/SKILL.md +258 -0
  10. package/assets/skills/opsx-propose-with-tdd/SKILL.md +271 -0
  11. package/assets/workflows/WORKFLOW.code-mr.en.md.example +345 -0
  12. package/assets/workflows/WORKFLOW.code-mr.md.example +339 -0
  13. package/assets/workflows/WORKFLOW.feishu-direct.en.md.example +267 -0
  14. package/assets/workflows/WORKFLOW.feishu-direct.md.example +258 -0
  15. package/assets/workflows/WORKFLOW.grill-openspec.en.md.example +362 -0
  16. package/assets/workflows/WORKFLOW.grill-openspec.md.example +356 -0
  17. package/assets/workflows/WORKFLOW.minimal.en.md.example +296 -0
  18. package/assets/workflows/WORKFLOW.minimal.md.example +289 -0
  19. package/dist/adapters/feishu/events.d.ts +55 -0
  20. package/dist/adapters/feishu/events.d.ts.map +1 -0
  21. package/dist/adapters/feishu/events.js +184 -0
  22. package/dist/adapters/feishu/events.js.map +1 -0
  23. package/dist/adapters/feishu/index.d.ts +2 -0
  24. package/dist/adapters/feishu/index.d.ts.map +1 -0
  25. package/dist/adapters/feishu/index.js +2 -0
  26. package/dist/adapters/feishu/index.js.map +1 -0
  27. package/dist/adapters/feishu/probe.d.ts +31 -0
  28. package/dist/adapters/feishu/probe.d.ts.map +1 -0
  29. package/dist/adapters/feishu/probe.js +179 -0
  30. package/dist/adapters/feishu/probe.js.map +1 -0
  31. package/dist/adapters/feishu/source.d.ts +124 -0
  32. package/dist/adapters/feishu/source.d.ts.map +1 -0
  33. package/dist/adapters/feishu/source.js +715 -0
  34. package/dist/adapters/feishu/source.js.map +1 -0
  35. package/dist/adapters/jira/index.d.ts +2 -0
  36. package/dist/adapters/jira/index.d.ts.map +1 -0
  37. package/dist/adapters/jira/index.js +2 -0
  38. package/dist/adapters/jira/index.js.map +1 -0
  39. package/dist/adapters/jira/tracker.d.ts +63 -0
  40. package/dist/adapters/jira/tracker.d.ts.map +1 -0
  41. package/dist/adapters/jira/tracker.js +402 -0
  42. package/dist/adapters/jira/tracker.js.map +1 -0
  43. package/dist/bridge/binding-store.d.ts +93 -0
  44. package/dist/bridge/binding-store.d.ts.map +1 -0
  45. package/dist/bridge/binding-store.js +365 -0
  46. package/dist/bridge/binding-store.js.map +1 -0
  47. package/dist/bridge/commands.d.ts +45 -0
  48. package/dist/bridge/commands.d.ts.map +1 -0
  49. package/dist/bridge/commands.js +197 -0
  50. package/dist/bridge/commands.js.map +1 -0
  51. package/dist/bridge/comment-bridge.d.ts +116 -0
  52. package/dist/bridge/comment-bridge.d.ts.map +1 -0
  53. package/dist/bridge/comment-bridge.js +1473 -0
  54. package/dist/bridge/comment-bridge.js.map +1 -0
  55. package/dist/cli/daemon-info.d.ts +17 -0
  56. package/dist/cli/daemon-info.d.ts.map +1 -0
  57. package/dist/cli/daemon-info.js +64 -0
  58. package/dist/cli/daemon-info.js.map +1 -0
  59. package/dist/cli/daemon.d.ts +27 -0
  60. package/dist/cli/daemon.d.ts.map +1 -0
  61. package/dist/cli/daemon.js +77 -0
  62. package/dist/cli/daemon.js.map +1 -0
  63. package/dist/cli/doctor.d.ts +7 -0
  64. package/dist/cli/doctor.d.ts.map +1 -0
  65. package/dist/cli/doctor.js +156 -0
  66. package/dist/cli/doctor.js.map +1 -0
  67. package/dist/cli/event-channel.d.ts +16 -0
  68. package/dist/cli/event-channel.d.ts.map +1 -0
  69. package/dist/cli/event-channel.js +51 -0
  70. package/dist/cli/event-channel.js.map +1 -0
  71. package/dist/cli/help.d.ts +3 -0
  72. package/dist/cli/help.d.ts.map +1 -0
  73. package/dist/cli/help.js +155 -0
  74. package/dist/cli/help.js.map +1 -0
  75. package/dist/cli/index.d.ts +3 -0
  76. package/dist/cli/index.d.ts.map +1 -0
  77. package/dist/cli/index.js +774 -0
  78. package/dist/cli/index.js.map +1 -0
  79. package/dist/cli/init.d.ts +64 -0
  80. package/dist/cli/init.d.ts.map +1 -0
  81. package/dist/cli/init.js +1296 -0
  82. package/dist/cli/init.js.map +1 -0
  83. package/dist/cli/instance-lock.d.ts +13 -0
  84. package/dist/cli/instance-lock.d.ts.map +1 -0
  85. package/dist/cli/instance-lock.js +53 -0
  86. package/dist/cli/instance-lock.js.map +1 -0
  87. package/dist/cli/prompts.d.ts +13 -0
  88. package/dist/cli/prompts.d.ts.map +1 -0
  89. package/dist/cli/prompts.js +26 -0
  90. package/dist/cli/prompts.js.map +1 -0
  91. package/dist/cli/style.d.ts +26 -0
  92. package/dist/cli/style.d.ts.map +1 -0
  93. package/dist/cli/style.js +58 -0
  94. package/dist/cli/style.js.map +1 -0
  95. package/dist/cli/tui-helpers.d.ts +5 -0
  96. package/dist/cli/tui-helpers.d.ts.map +1 -0
  97. package/dist/cli/tui-helpers.js +124 -0
  98. package/dist/cli/tui-helpers.js.map +1 -0
  99. package/dist/cli/workflow-path.d.ts +12 -0
  100. package/dist/cli/workflow-path.d.ts.map +1 -0
  101. package/dist/cli/workflow-path.js +37 -0
  102. package/dist/cli/workflow-path.js.map +1 -0
  103. package/dist/config/config-types.d.ts +180 -0
  104. package/dist/config/config-types.d.ts.map +1 -0
  105. package/dist/config/config-types.js +71 -0
  106. package/dist/config/config-types.js.map +1 -0
  107. package/dist/config/dotenv.d.ts +2 -0
  108. package/dist/config/dotenv.d.ts.map +1 -0
  109. package/dist/config/dotenv.js +10 -0
  110. package/dist/config/dotenv.js.map +1 -0
  111. package/dist/config/index.d.ts +6 -0
  112. package/dist/config/index.d.ts.map +1 -0
  113. package/dist/config/index.js +6 -0
  114. package/dist/config/index.js.map +1 -0
  115. package/dist/config/loader.d.ts +5 -0
  116. package/dist/config/loader.d.ts.map +1 -0
  117. package/dist/config/loader.js +304 -0
  118. package/dist/config/loader.js.map +1 -0
  119. package/dist/config/manager.d.ts +31 -0
  120. package/dist/config/manager.d.ts.map +1 -0
  121. package/dist/config/manager.js +110 -0
  122. package/dist/config/manager.js.map +1 -0
  123. package/dist/config/resolver.d.ts +6 -0
  124. package/dist/config/resolver.d.ts.map +1 -0
  125. package/dist/config/resolver.js +267 -0
  126. package/dist/config/resolver.js.map +1 -0
  127. package/dist/config/validator.d.ts +9 -0
  128. package/dist/config/validator.d.ts.map +1 -0
  129. package/dist/config/validator.js +70 -0
  130. package/dist/config/validator.js.map +1 -0
  131. package/dist/direct/card.d.ts +49 -0
  132. package/dist/direct/card.d.ts.map +1 -0
  133. package/dist/direct/card.js +274 -0
  134. package/dist/direct/card.js.map +1 -0
  135. package/dist/direct/command.d.ts +12 -0
  136. package/dist/direct/command.d.ts.map +1 -0
  137. package/dist/direct/command.js +23 -0
  138. package/dist/direct/command.js.map +1 -0
  139. package/dist/direct/manager.d.ts +159 -0
  140. package/dist/direct/manager.d.ts.map +1 -0
  141. package/dist/direct/manager.js +1862 -0
  142. package/dist/direct/manager.js.map +1 -0
  143. package/dist/mcp/inject.d.ts +5 -0
  144. package/dist/mcp/inject.d.ts.map +1 -0
  145. package/dist/mcp/inject.js +51 -0
  146. package/dist/mcp/inject.js.map +1 -0
  147. package/dist/mcp/jira-server.d.ts +29 -0
  148. package/dist/mcp/jira-server.d.ts.map +1 -0
  149. package/dist/mcp/jira-server.js +288 -0
  150. package/dist/mcp/jira-server.js.map +1 -0
  151. package/dist/observability/activity-store.d.ts +29 -0
  152. package/dist/observability/activity-store.d.ts.map +1 -0
  153. package/dist/observability/activity-store.js +32 -0
  154. package/dist/observability/activity-store.js.map +1 -0
  155. package/dist/observability/config-view.d.ts +19 -0
  156. package/dist/observability/config-view.d.ts.map +1 -0
  157. package/dist/observability/config-view.js +61 -0
  158. package/dist/observability/config-view.js.map +1 -0
  159. package/dist/observability/http-dashboard.d.ts +36 -0
  160. package/dist/observability/http-dashboard.d.ts.map +1 -0
  161. package/dist/observability/http-dashboard.js +297 -0
  162. package/dist/observability/http-dashboard.js.map +1 -0
  163. package/dist/observability/log-buffer.d.ts +21 -0
  164. package/dist/observability/log-buffer.d.ts.map +1 -0
  165. package/dist/observability/log-buffer.js +69 -0
  166. package/dist/observability/log-buffer.js.map +1 -0
  167. package/dist/observability/logger.d.ts +37 -0
  168. package/dist/observability/logger.d.ts.map +1 -0
  169. package/dist/observability/logger.js +114 -0
  170. package/dist/observability/logger.js.map +1 -0
  171. package/dist/observability/snapshot.d.ts +11 -0
  172. package/dist/observability/snapshot.d.ts.map +1 -0
  173. package/dist/observability/snapshot.js +59 -0
  174. package/dist/observability/snapshot.js.map +1 -0
  175. package/dist/observability/terminal-dashboard.d.ts +155 -0
  176. package/dist/observability/terminal-dashboard.d.ts.map +1 -0
  177. package/dist/observability/terminal-dashboard.js +1598 -0
  178. package/dist/observability/terminal-dashboard.js.map +1 -0
  179. package/dist/observability/wrap.d.ts +4 -0
  180. package/dist/observability/wrap.d.ts.map +1 -0
  181. package/dist/observability/wrap.js +80 -0
  182. package/dist/observability/wrap.js.map +1 -0
  183. package/dist/scheduler/index.d.ts +2 -0
  184. package/dist/scheduler/index.d.ts.map +1 -0
  185. package/dist/scheduler/index.js +2 -0
  186. package/dist/scheduler/index.js.map +1 -0
  187. package/dist/scheduler/scheduler.d.ts +52 -0
  188. package/dist/scheduler/scheduler.d.ts.map +1 -0
  189. package/dist/scheduler/scheduler.js +535 -0
  190. package/dist/scheduler/scheduler.js.map +1 -0
  191. package/dist/shared/agent-resolver.d.ts +11 -0
  192. package/dist/shared/agent-resolver.d.ts.map +1 -0
  193. package/dist/shared/agent-resolver.js +20 -0
  194. package/dist/shared/agent-resolver.js.map +1 -0
  195. package/dist/shared/errors.d.ts +14 -0
  196. package/dist/shared/errors.d.ts.map +1 -0
  197. package/dist/shared/errors.js +24 -0
  198. package/dist/shared/errors.js.map +1 -0
  199. package/dist/shared/index.d.ts +4 -0
  200. package/dist/shared/index.d.ts.map +1 -0
  201. package/dist/shared/index.js +4 -0
  202. package/dist/shared/index.js.map +1 -0
  203. package/dist/shared/info-card.d.ts +24 -0
  204. package/dist/shared/info-card.d.ts.map +1 -0
  205. package/dist/shared/info-card.js +46 -0
  206. package/dist/shared/info-card.js.map +1 -0
  207. package/dist/shared/types.d.ts +148 -0
  208. package/dist/shared/types.d.ts.map +1 -0
  209. package/dist/shared/types.js +15 -0
  210. package/dist/shared/types.js.map +1 -0
  211. package/dist/translate/card.d.ts +2 -0
  212. package/dist/translate/card.d.ts.map +1 -0
  213. package/dist/translate/card.js +17 -0
  214. package/dist/translate/card.js.map +1 -0
  215. package/dist/translate/dict.d.ts +7 -0
  216. package/dist/translate/dict.d.ts.map +1 -0
  217. package/dist/translate/dict.js +895 -0
  218. package/dist/translate/dict.js.map +1 -0
  219. package/dist/translate/locale.d.ts +8 -0
  220. package/dist/translate/locale.d.ts.map +1 -0
  221. package/dist/translate/locale.js +75 -0
  222. package/dist/translate/locale.js.map +1 -0
  223. package/dist/translate/normalize.d.ts +4 -0
  224. package/dist/translate/normalize.d.ts.map +1 -0
  225. package/dist/translate/normalize.js +38 -0
  226. package/dist/translate/normalize.js.map +1 -0
  227. package/dist/translate/output.d.ts +3 -0
  228. package/dist/translate/output.d.ts.map +1 -0
  229. package/dist/translate/output.js +16 -0
  230. package/dist/translate/output.js.map +1 -0
  231. package/dist/worker/prompt.d.ts +11 -0
  232. package/dist/worker/prompt.d.ts.map +1 -0
  233. package/dist/worker/prompt.js +153 -0
  234. package/dist/worker/prompt.js.map +1 -0
  235. package/dist/worker/runner.d.ts +101 -0
  236. package/dist/worker/runner.d.ts.map +1 -0
  237. package/dist/worker/runner.js +448 -0
  238. package/dist/worker/runner.js.map +1 -0
  239. package/dist/workspace/index.d.ts +2 -0
  240. package/dist/workspace/index.d.ts.map +1 -0
  241. package/dist/workspace/index.js +2 -0
  242. package/dist/workspace/index.js.map +1 -0
  243. package/dist/workspace/manager.d.ts +37 -0
  244. package/dist/workspace/manager.d.ts.map +1 -0
  245. package/dist/workspace/manager.js +157 -0
  246. package/dist/workspace/manager.js.map +1 -0
  247. package/package.json +70 -4
@@ -0,0 +1,258 @@
1
+ ---
2
+ name: opsx-implement
3
+ description: Implement a piece of work based on an OpenSpec change, spec, or tickets — with code review built in.
4
+ ---
5
+
6
+ Implement the work described by the user in the spec or tickets. If from an OpenSpec change, follow the OpenSpec apply workflow below.
7
+
8
+ Run typechecking regularly, single test files regularly, and the full test suite once at the end.
9
+
10
+ Once done, review the work — see the code-review reference below.
11
+
12
+ Commit your work to the current branch. If from an OpenSpec change, mark completed tasks in `tasks.md`.
13
+
14
+ ---
15
+
16
+ # OpenSpec Apply Workflow
17
+
18
+ Implement tasks from an OpenSpec change.
19
+
20
+ **Input**: Optionally specify a change name (e.g., `/opsx-implement add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
21
+
22
+ **Steps**
23
+
24
+ 1. **Select the change**
25
+
26
+ If a name is provided, use it. Otherwise:
27
+ - Infer from conversation context if the user mentioned a change
28
+ - Auto-select if only one active change exists
29
+ - If ambiguous, run `openspec list --json` to get available changes and use the **question tool** to let the user select
30
+
31
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx-implement <other>`).
32
+
33
+ 2. **Check status to understand the schema**
34
+ ```bash
35
+ openspec status --change "<name>" --json
36
+ ```
37
+ Parse the JSON to understand:
38
+ - `schemaName`: The workflow being used (e.g., "spec-driven")
39
+ - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
40
+
41
+ 3. **Get apply instructions**
42
+
43
+ ```bash
44
+ openspec instructions apply --change "<name>" --json
45
+ ```
46
+
47
+ This returns:
48
+ - `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
49
+ - Progress (total, complete, remaining)
50
+ - Task list with status
51
+ - Dynamic instruction based on current state
52
+
53
+ **Handle states:**
54
+ - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx-continue`
55
+ - If `state: "all_done"`: congratulate, suggest archive
56
+ - Otherwise: proceed to implementation
57
+
58
+ 4. **Read context files**
59
+
60
+ Read every file path listed under `contextFiles` from the apply instructions output.
61
+ The files depend on the schema being used:
62
+ - **spec-driven**: proposal, specs, design, tasks
63
+ - Other schemas: follow the contextFiles from CLI output
64
+
65
+ 5. **Show current progress**
66
+
67
+ Display:
68
+ - Schema being used
69
+ - Progress: "N/M tasks complete"
70
+ - Remaining tasks overview
71
+ - Dynamic instruction from CLI
72
+
73
+ 6. **Implement tasks (loop until done or blocked)**
74
+
75
+ For each pending task:
76
+ - Show which task is being worked on
77
+ - If the task involves testable code (functions, modules, APIs): write the failing test first (red), then implement minimum code to pass it (green). Skip for non-code tasks (docs, config).
78
+ - Make the code changes required
79
+ - Keep changes minimal and focused
80
+ - Mark task complete in the tasks file: `- [ ]` → `- [x]`
81
+ - Continue to next task
82
+
83
+ **Pause if:**
84
+ - Task is unclear → ask for clarification
85
+ - Implementation reveals a design issue → suggest updating artifacts
86
+ - Error or blocker encountered → report and wait for guidance
87
+ - User interrupts
88
+
89
+ 7. **Run code review (if code was changed)**
90
+
91
+ Follow the "# Code Review" reference below in full — every step applies on every review.
92
+
93
+ Skip this step for docs-only or config-only changes.
94
+
95
+ 8. **On completion or pause, show status**
96
+
97
+ Display:
98
+ - Tasks completed this session
99
+ - Overall progress: "N/M tasks complete"
100
+ - If all done: suggest archive
101
+ - If paused: explain why and wait for guidance
102
+
103
+ **Output During Implementation**
104
+
105
+ ```
106
+ ## Implementing: <change-name> (schema: <schema-name>)
107
+
108
+ Working on task 3/7: <task description>
109
+ [...implementation happening...]
110
+ ✓ Task complete
111
+
112
+ Working on task 4/7: <task description>
113
+ [...implementation happening......]
114
+ ✓ Task complete
115
+ ```
116
+
117
+ **Output On Completion**
118
+
119
+ ```
120
+ ## Implementation Complete
121
+
122
+ **Change:** <change-name>
123
+ **Schema:** <schema-name>
124
+ **Progress:** 7/7 tasks complete ✓
125
+ **Code Review:** ✓ Complete (N findings, all addressed)
126
+
127
+ ### Completed This Session
128
+ - [x] Task 1
129
+ - [x] Task 2
130
+ ...
131
+
132
+ All tasks complete! You can archive this change with `/opsx-archive`.
133
+ ```
134
+
135
+ **Output On Pause (Issue Encountered)**
136
+
137
+ ```
138
+ ## Implementation Paused
139
+
140
+ **Change:** <change-name>
141
+ **Schema:** <schema-name>
142
+ **Progress:** 4/7 tasks complete
143
+
144
+ ### Issue Encountered
145
+ <description of the issue>
146
+
147
+ **Options:**
148
+ 1. <option 1>
149
+ 2. <option 2>
150
+ 3. Other approach
151
+
152
+ What would you like to do?
153
+ ```
154
+
155
+ **Guardrails**
156
+ - Keep going through tasks until done or blocked
157
+ - Always read context files before starting (from the apply instructions output)
158
+ - If task is ambiguous, pause and ask before implementing
159
+ - If implementation reveals issues, pause and suggest artifact updates
160
+ - Keep code changes minimal and scoped to each task
161
+ - Update task checkbox immediately after completing each task
162
+ - Pause on errors, blockers, or unclear requirements - don't guess
163
+ - Use contextFiles from CLI output, don't assume specific file names
164
+
165
+ **Fluid Workflow Integration**
166
+
167
+ This skill supports the "actions on a change" model:
168
+
169
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
170
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
171
+
172
+ ---
173
+
174
+ # Code Review
175
+
176
+ Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
177
+
178
+ - **Standards** — does the code conform to this repo's documented coding standards?
179
+ - **Spec** — does the code faithfully implement the originating issue / PRD / spec?
180
+
181
+ Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
182
+
183
+ ## Process
184
+
185
+ ### 1. Pin the fixed point
186
+
187
+ Whatever the user said is the fixed point — a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. If they didn't specify one, ask for it.
188
+
189
+ Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
190
+
191
+ Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here — not inside two parallel sub-agents.
192
+
193
+ ### 2. Identify the spec source
194
+
195
+ Look for the originating spec, in this order:
196
+
197
+ 1. An active OpenSpec change folder under `openspec/changes/` matching the branch name — spec is `proposal.md`, `specs/`, `design.md`, and `tasks.md`.
198
+ 2. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.) — fetch the issue body.
199
+ 3. A path the user passed as an argument.
200
+ 4. A PRD/spec file under `docs/`, `specs/`, or `.scratch/` matching the branch name or feature.
201
+ 5. If nothing is found, ask the user where the spec is. If they say there isn't one, the **Spec** sub-agent will skip and report "no spec available".
202
+
203
+ ### 3. Identify the standards sources
204
+
205
+ Anything in the repo that documents how code should be written, such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`.
206
+
207
+ On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
208
+
209
+ - **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
210
+ - **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation — and, like any standard here, skip anything tooling already enforces.
211
+
212
+ Each smell reads *what it is* → *how to fix*; match it against the diff:
213
+
214
+ - **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
215
+ - **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
216
+ - **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
217
+ - **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
218
+ - **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
219
+ - **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
220
+ - **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
221
+ - **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
222
+ - **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
223
+ - **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
224
+ - **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
225
+ - **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
226
+
227
+ ### 4. Spawn both sub-agents in parallel
228
+
229
+ Send a single message with two **Task** tool calls. Use the `general` subagent for both.
230
+
231
+ **Standards sub-agent prompt** — include:
232
+
233
+ - The full diff command and commit list.
234
+ - The list of standards-source files you found in step 3, **plus the smell baseline from step 3** pasted in full — the sub-agent has no other access to it.
235
+ - The brief: "Report — per file/hunk where relevant — (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls — documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
236
+
237
+ **Spec sub-agent prompt** — include:
238
+
239
+ - The diff command and commit list.
240
+ - The path or fetched contents of the spec — for an OpenSpec change, paste the contents of `proposal.md`, `specs/`, `design.md`, and `tasks.md`.
241
+ - The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
242
+
243
+ If the spec is missing, skip the Spec sub-agent and note this in the final report.
244
+
245
+ ### 5. Aggregate
246
+
247
+ Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings — the two axes are deliberately separate (see _Why two axes_).
248
+
249
+ End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes — that's the reranking the separation exists to prevent.
250
+
251
+ ## Why two axes
252
+
253
+ A change can pass one axis and fail the other:
254
+
255
+ - Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
256
+ - Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
257
+
258
+ Reporting them separately stops one axis from masking the other.
@@ -0,0 +1,271 @@
1
+ ---
2
+ name: opsx-propose-with-tdd
3
+ description: Propose a new change - create it and generate all artifacts in one step, with TDD guidance for task structure
4
+ ---
5
+
6
+ Propose a new change - create the change and generate all artifacts in one step.
7
+
8
+ I'll create a change with artifacts:
9
+ - proposal.md (what & why)
10
+ - design.md (how)
11
+ - tasks.md (implementation steps)
12
+
13
+ When ready to implement, run /opsx-implement
14
+
15
+ ---
16
+
17
+ **Input**: The argument after `/opsx-propose-with-tdd` is the change name (kebab-case), OR a description of what the user wants to build.
18
+
19
+ **Steps**
20
+
21
+ 1. **If no input provided, ask what they want to build**
22
+
23
+ Use the **question tool** (open-ended, no preset options) to ask:
24
+ > "What change do you want to work on? Describe what you want to build or fix."
25
+
26
+ From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
27
+
28
+ **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
29
+
30
+ 2. **Create the change directory**
31
+ ```bash
32
+ openspec new change "<name>"
33
+ ```
34
+ This creates a scaffolded change at `openspec/changes/<name>/` with `.openspec.yaml`.
35
+
36
+ 3. **Get the artifact build order**
37
+ ```bash
38
+ openspec status --change "<name>" --json
39
+ ```
40
+ Parse the JSON to get:
41
+ - `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
42
+ - `artifacts`: list of all artifacts with their status and dependencies
43
+
44
+ 4. **Create artifacts in sequence until apply-ready**
45
+
46
+ Use the **TodoWrite tool** to track progress through the artifacts.
47
+
48
+ Loop through artifacts in dependency order (artifacts with no pending dependencies first):
49
+
50
+ a. **For each artifact that is `ready` (dependencies satisfied)**:
51
+ - Get instructions:
52
+ ```bash
53
+ openspec instructions <artifact-id> --change "<name>" --json
54
+ ```
55
+ - The instructions JSON includes:
56
+ - `context`: Project background (constraints for you - do NOT include in output)
57
+ - `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
58
+ - `template`: The structure to use for your output file
59
+ - `instruction`: Schema-specific guidance for this artifact type
60
+ - `outputPath`: Where to write the artifact
61
+ - `dependencies`: Completed artifacts to read for context
62
+ - Read any completed dependency files for context
63
+ - Create the artifact file using `template` as the structure
64
+ - Apply `context` and `rules` as constraints - but do NOT copy them into the file
65
+ - Show brief progress: "Created <artifact-id>"
66
+
67
+ b. **Continue until all `applyRequires` artifacts are complete**
68
+ - After creating each artifact, re-run `openspec status --change "<name>" --json`
69
+ - Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
70
+ - Stop when all `applyRequires` artifacts are done
71
+
72
+ c. **If an artifact requires user input** (unclear context):
73
+ - Use **question tool** to clarify
74
+ - Then continue with creation
75
+
76
+ 5. **Show final status**
77
+ ```bash
78
+ openspec status --change "<name>"
79
+ ```
80
+
81
+ **Output**
82
+
83
+ After completing all artifacts, summarize:
84
+ - Change name and location
85
+ - List of artifacts created with brief descriptions
86
+ - What's ready: "All artifacts created! Ready for implementation."
87
+ - Prompt: "Run `/opsx-implement` to start implementing."
88
+
89
+ **Artifact Creation Guidelines**
90
+
91
+ - Follow the `instruction` field from `openspec instructions` for each artifact type
92
+ - The schema defines what each artifact should contain - follow it
93
+ - Read dependency artifacts for context before creating new ones
94
+ - Use `template` as the structure for your output file - fill in its sections
95
+ - **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
96
+ - Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
97
+ - These guide what you write, but should never appear in the output
98
+ - **When creating tasks.md**: Follow the TDD reference below. Each testable task MUST combine test and implementation in one task — do not separate into "implementation tasks" and "test tasks". Task descriptions should reflect the red → green flow (e.g., "Implement X (write failing test first, then implement)"). This ensures the apply phase executes TDD naturally by following tasks.
99
+
100
+ **Guardrails**
101
+ - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`)
102
+ - Always read dependency artifacts before creating a new one
103
+ - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
104
+ - If a change with that name already exists, ask if user wants to continue it or create a new one
105
+ - Verify each artifact file exists after writing before proceeding to next
106
+
107
+ ---
108
+
109
+ # Test-Driven Development
110
+
111
+ TDD is the red → green loop. This reference makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies when writing tasks — consult them before and during task creation, not after.
112
+
113
+ When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
114
+
115
+ ## What a good test is
116
+
117
+ Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists — and survives refactors because it doesn't care about internal structure.
118
+
119
+ ### Good and Bad Tests
120
+
121
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
122
+
123
+ ```typescript
124
+ // GOOD: Tests observable behavior
125
+ test("user can checkout with valid cart", async () => {
126
+ const cart = createCart();
127
+ cart.add(product);
128
+ const result = await checkout(cart, paymentMethod);
129
+ expect(result.status).toBe("confirmed");
130
+ });
131
+ ```
132
+
133
+ Characteristics:
134
+
135
+ - Tests behavior users/callers care about
136
+ - Uses public API only
137
+ - Survives internal refactors
138
+ - Describes WHAT, not HOW
139
+ - One logical assertion per test
140
+
141
+ **Implementation-detail tests**: Coupled to internal structure.
142
+
143
+ ```typescript
144
+ // BAD: Tests implementation details
145
+ test("checkout calls paymentService.process", async () => {
146
+ const mockPayment = jest.mock(paymentService);
147
+ await checkout(cart, payment);
148
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
149
+ });
150
+ ```
151
+
152
+ Red flags:
153
+
154
+ - Mocking internal collaborators
155
+ - Testing private methods
156
+ - Asserting on call counts/order
157
+ - Test breaks when refactoring without behavior change
158
+ - Test name describes HOW not WHAT
159
+ - Verifying through external means instead of interface
160
+
161
+ ```typescript
162
+ // BAD: Bypasses interface to verify
163
+ test("createUser saves to database", async () => {
164
+ await createUser({ name: "Alice" });
165
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
166
+ expect(row).toBeDefined();
167
+ });
168
+
169
+ // GOOD: Verifies through interface
170
+ test("createUser makes user retrievable", async () => {
171
+ const user = await createUser({ name: "Alice" });
172
+ const retrieved = await getUser(user.id);
173
+ expect(retrieved.name).toBe("Alice");
174
+ });
175
+ ```
176
+
177
+ **Tautological tests**: Expected value restates the implementation, so the test passes by construction.
178
+
179
+ ```typescript
180
+ // BAD: Expected value is recomputed the way the code computes it
181
+ test("calculateTotal sums line items", () => {
182
+ const items = [{ price: 10 }, { price: 5 }];
183
+ const expected = items.reduce((sum, i) => sum + i.price, 0);
184
+ expect(calculateTotal(items)).toBe(expected);
185
+ });
186
+
187
+ // GOOD: Expected value is an independent, known literal
188
+ test("calculateTotal sums line items", () => {
189
+ expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
190
+ });
191
+ ```
192
+
193
+ ## Seams — where tests go
194
+
195
+ A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
196
+
197
+ **Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything — agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
198
+
199
+ Ask: "What's the public interface, and which seams should we test?"
200
+
201
+ ## When to Mock
202
+
203
+ Mock at **system boundaries** only:
204
+
205
+ - External APIs (payment, email, etc.)
206
+ - Databases (sometimes - prefer test DB)
207
+ - Time/randomness
208
+ - File system (sometimes)
209
+
210
+ Don't mock:
211
+
212
+ - Your own classes/modules
213
+ - Internal collaborators
214
+ - Anything you control
215
+
216
+ ### Designing for Mockability
217
+
218
+ At system boundaries, design interfaces that are easy to mock:
219
+
220
+ **1. Use dependency injection**
221
+
222
+ Pass external dependencies in rather than creating them internally:
223
+
224
+ ```typescript
225
+ // Easy to mock
226
+ function processPayment(order, paymentClient) {
227
+ return paymentClient.charge(order.total);
228
+ }
229
+
230
+ // Hard to mock
231
+ function processPayment(order) {
232
+ const client = new StripeClient(process.env.STRIPE_KEY);
233
+ return client.charge(order.total);
234
+ }
235
+ ```
236
+
237
+ **2. Prefer SDK-style interfaces over generic fetchers**
238
+
239
+ Create specific functions for each external operation instead of one generic function with conditional logic:
240
+
241
+ ```typescript
242
+ // GOOD: Each function is independently mockable
243
+ const api = {
244
+ getUser: (id) => fetch(`/users/${id}`),
245
+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
246
+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
247
+ };
248
+
249
+ // BAD: Mocking requires conditional logic inside the mock
250
+ const api = {
251
+ fetch: (endpoint, options) => fetch(endpoint, options),
252
+ };
253
+ ```
254
+
255
+ The SDK approach means:
256
+ - Each mock returns one specific shape
257
+ - No conditional logic in test setup
258
+ - Easier to see which endpoints a test exercises
259
+ - Type safety per endpoint
260
+
261
+ ## Anti-patterns
262
+
263
+ - **Implementation-coupled** — mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
264
+ - **Tautological** — the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth — a known-good literal, a worked example, the spec.
265
+ - **Horizontal slicing** — writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead — one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
266
+
267
+ ## Rules of the loop
268
+
269
+ - **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
270
+ - **One slice at a time.** One seam, one test, one minimal implementation per cycle.
271
+ - **Refactoring is not part of the loop.** It belongs to the review stage, not the red → green implementation cycle.