sequant 1.0.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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -0
  3. package/dist/bin/cli.d.ts +8 -0
  4. package/dist/bin/cli.d.ts.map +1 -0
  5. package/dist/bin/cli.js +70 -0
  6. package/dist/bin/cli.js.map +1 -0
  7. package/dist/src/commands/doctor.d.ts +8 -0
  8. package/dist/src/commands/doctor.d.ts.map +1 -0
  9. package/dist/src/commands/doctor.js +171 -0
  10. package/dist/src/commands/doctor.js.map +1 -0
  11. package/dist/src/commands/init.d.ts +11 -0
  12. package/dist/src/commands/init.d.ts.map +1 -0
  13. package/dist/src/commands/init.js +124 -0
  14. package/dist/src/commands/init.js.map +1 -0
  15. package/dist/src/commands/run.d.ts +18 -0
  16. package/dist/src/commands/run.d.ts.map +1 -0
  17. package/dist/src/commands/run.js +229 -0
  18. package/dist/src/commands/run.js.map +1 -0
  19. package/dist/src/commands/status.d.ts +5 -0
  20. package/dist/src/commands/status.d.ts.map +1 -0
  21. package/dist/src/commands/status.js +45 -0
  22. package/dist/src/commands/status.js.map +1 -0
  23. package/dist/src/commands/update.d.ts +10 -0
  24. package/dist/src/commands/update.d.ts.map +1 -0
  25. package/dist/src/commands/update.js +124 -0
  26. package/dist/src/commands/update.js.map +1 -0
  27. package/dist/src/index.d.ts +15 -0
  28. package/dist/src/index.d.ts.map +1 -0
  29. package/dist/src/index.js +13 -0
  30. package/dist/src/index.js.map +1 -0
  31. package/dist/src/lib/fs.d.ts +10 -0
  32. package/dist/src/lib/fs.d.ts.map +1 -0
  33. package/dist/src/lib/fs.js +44 -0
  34. package/dist/src/lib/fs.js.map +1 -0
  35. package/dist/src/lib/manifest.d.ts +14 -0
  36. package/dist/src/lib/manifest.d.ts.map +1 -0
  37. package/dist/src/lib/manifest.js +37 -0
  38. package/dist/src/lib/manifest.js.map +1 -0
  39. package/dist/src/lib/stacks.d.ts +22 -0
  40. package/dist/src/lib/stacks.d.ts.map +1 -0
  41. package/dist/src/lib/stacks.js +131 -0
  42. package/dist/src/lib/stacks.js.map +1 -0
  43. package/dist/src/lib/templates.d.ts +16 -0
  44. package/dist/src/lib/templates.d.ts.map +1 -0
  45. package/dist/src/lib/templates.js +118 -0
  46. package/dist/src/lib/templates.js.map +1 -0
  47. package/dist/src/lib/workflow/cli-args.d.ts +138 -0
  48. package/dist/src/lib/workflow/cli-args.d.ts.map +1 -0
  49. package/dist/src/lib/workflow/cli-args.js +210 -0
  50. package/dist/src/lib/workflow/cli-args.js.map +1 -0
  51. package/dist/src/lib/workflow/execute-issues.d.ts +42 -0
  52. package/dist/src/lib/workflow/execute-issues.d.ts.map +1 -0
  53. package/dist/src/lib/workflow/execute-issues.js +463 -0
  54. package/dist/src/lib/workflow/execute-issues.js.map +1 -0
  55. package/dist/src/lib/workflow/logger.d.ts +168 -0
  56. package/dist/src/lib/workflow/logger.d.ts.map +1 -0
  57. package/dist/src/lib/workflow/logger.js +249 -0
  58. package/dist/src/lib/workflow/logger.js.map +1 -0
  59. package/dist/src/lib/workflow/types.d.ts +89 -0
  60. package/dist/src/lib/workflow/types.d.ts.map +1 -0
  61. package/dist/src/lib/workflow/types.js +23 -0
  62. package/dist/src/lib/workflow/types.js.map +1 -0
  63. package/package.json +69 -0
  64. package/stacks/go.yaml +22 -0
  65. package/stacks/nextjs.yaml +28 -0
  66. package/stacks/python.yaml +24 -0
  67. package/stacks/rust.yaml +23 -0
  68. package/templates/hooks/post-tool.sh +301 -0
  69. package/templates/hooks/pre-tool.sh +350 -0
  70. package/templates/memory/constitution.md +60 -0
  71. package/templates/scripts/cleanup-worktree.sh +78 -0
  72. package/templates/scripts/list-worktrees.sh +50 -0
  73. package/templates/scripts/new-feature.sh +156 -0
  74. package/templates/settings.json +26 -0
  75. package/templates/skills/assess/SKILL.md +428 -0
  76. package/templates/skills/clean/SKILL.md +196 -0
  77. package/templates/skills/docs/SKILL.md +323 -0
  78. package/templates/skills/exec/SKILL.md +426 -0
  79. package/templates/skills/fullsolve/SKILL.md +479 -0
  80. package/templates/skills/loop/SKILL.md +310 -0
  81. package/templates/skills/qa/SKILL.md +261 -0
  82. package/templates/skills/qa/references/code-quality-exemplars.md +112 -0
  83. package/templates/skills/qa/references/code-review-checklist.md +77 -0
  84. package/templates/skills/qa/references/quality-gates.md +95 -0
  85. package/templates/skills/qa/references/testing-requirements.md +109 -0
  86. package/templates/skills/qa/scripts/quality-checks.sh +109 -0
  87. package/templates/skills/reflect/SKILL.md +159 -0
  88. package/templates/skills/reflect/references/documentation-tiers.md +70 -0
  89. package/templates/skills/reflect/references/phase-reflection.md +95 -0
  90. package/templates/skills/reflect/scripts/workflow-queries.ts +165 -0
  91. package/templates/skills/security-review/SKILL.md +344 -0
  92. package/templates/skills/security-review/references/security-checklists.md +377 -0
  93. package/templates/skills/solve/SKILL.md +242 -0
  94. package/templates/skills/spec/SKILL.md +169 -0
  95. package/templates/skills/spec/references/parallel-groups.md +72 -0
  96. package/templates/skills/spec/references/verification-criteria.md +104 -0
  97. package/templates/skills/test/SKILL.md +508 -0
  98. package/templates/skills/testgen/SKILL.md +561 -0
  99. package/templates/skills/verify/SKILL.md +266 -0
@@ -0,0 +1,426 @@
1
+ ---
2
+ name: exec
3
+ description: "Phase 2 - Implementation loop for a single GitHub issue until Acceptance Criteria are satisfied (or as close as practical)."
4
+ license: MIT
5
+ metadata:
6
+ author: sequant
7
+ version: "1.0"
8
+ allowed-tools:
9
+ # File operations (required for implementation)
10
+ - Read
11
+ - Glob
12
+ - Grep
13
+ - Edit
14
+ - Write
15
+ # Build and test
16
+ - Bash(npm test:*)
17
+ - Bash(npm run build:*)
18
+ - Bash(npm install:*)
19
+ - Bash(npx tsc:*)
20
+ # Git operations
21
+ - Bash(git status:*)
22
+ - Bash(git diff:*)
23
+ - Bash(git add:*)
24
+ - Bash(git commit:*)
25
+ - Bash(git log:*)
26
+ - Bash(git worktree:*)
27
+ # Worktree management
28
+ - Bash(./scripts/dev/new-feature.sh:*)
29
+ - Bash(./scripts/dev/cleanup-worktree.sh:*)
30
+ # GitHub CLI
31
+ - Bash(gh issue view:*)
32
+ - Bash(gh issue comment:*)
33
+ - Bash(gh issue edit:*)
34
+ - Bash(gh pr create:*)
35
+ - Bash(gh pr view:*)
36
+ # MCP tools for implementation
37
+ - mcp__supabase__list_tables
38
+ - mcp__supabase__execute_sql
39
+ - mcp__supabase__apply_migration
40
+ - mcp__context7__resolve-library-id
41
+ - mcp__context7__query-docs
42
+ # Task management
43
+ - Task
44
+ - TodoWrite
45
+ ---
46
+
47
+ # Implementation Command
48
+
49
+ You are the Phase 2 "Implementation Agent" for the current repository.
50
+
51
+ ## Purpose
52
+
53
+ When invoked as `/exec`, your job is to:
54
+
55
+ 1. Take an existing, agreed plan and AC (often created by `/spec`).
56
+ 2. Create a feature worktree for the issue.
57
+ 3. Implement the changes in small, safe steps.
58
+ 4. Run checks via `npm test` and, when appropriate, `npm run build`.
59
+ 5. Iterate until the AC appear satisfied or clear blockers are reached.
60
+ 6. Draft a progress update for the GitHub issue.
61
+
62
+ ## Behavior
63
+
64
+ Invocation:
65
+
66
+ - `/exec 123`:
67
+ - Treat `123` as the GitHub issue number.
68
+ - Assume a plan may already exist in the issue or from `/spec`.
69
+ - `/exec <freeform description>`:
70
+ - Treat the text as a lightweight description + AC if no issue context is available.
71
+
72
+ ### 1. Check Implementation Readiness
73
+
74
+ **FIRST STEP:** Review the issue readiness and proceed with implementation.
75
+
76
+ **Read the latest GitHub comment** (especially from `/spec`) and look for:
77
+ ```markdown
78
+ ## Implementation Readiness
79
+
80
+ **Status:** [READY / NOT READY]
81
+ ```
82
+
83
+ **Implementation Policy:**
84
+ - Always proceed with implementation when invoked via `/exec`
85
+ - Log any warnings or concerns about readiness
86
+ - Add notes to progress update if implementing despite blockers
87
+
88
+ **Readiness Notes to Include in Progress Update:**
89
+ - If P2/P3/P4 priority: Note that this is a non-critical issue being implemented
90
+ - If technical blockers exist: Note the blockers and explain workarounds/stubs used
91
+ - If dependencies are open: Note which issues block full integration
92
+
93
+ **Only stop implementation if:**
94
+ - Issue is labeled `planning`, `research`, or `rfc` (not for implementation)
95
+ - Issue is already closed
96
+ - No acceptance criteria exist and cannot be inferred
97
+
98
+ ### 2. Re-establish Context
99
+
100
+ - **Read all GitHub issue comments** to gather complete context:
101
+ - Comments often contain clarifications, updates, or additional AC added after the initial issue description
102
+ - Look for discussion about implementation details, edge cases, or requirements mentioned in comments
103
+ - Review feedback from previous implementation cycles or review comments
104
+ - Summarize briefly:
105
+ - The AC checklist (AC-1, AC-2, ...) from the issue and all comments
106
+ - The current implementation plan (from issue comments or `/spec`)
107
+ - If there is no plan:
108
+ - Ask whether to quickly propose one (or suggest using `/spec` first).
109
+
110
+ ### Feature Worktree Workflow
111
+
112
+ **Execution Phase:** Create and work in a feature worktree.
113
+
114
+ 1. **Check if worktree already exists:**
115
+ - Check if you're already in a worktree: `git worktree list` or check if `../worktrees/` contains a directory for this issue
116
+ - If worktree exists, navigate to it and continue work there
117
+
118
+ 2. **Create worktree if needed:**
119
+ - From the main repository directory, run: `./scripts/dev/new-feature.sh <issue-number>`
120
+ - This will:
121
+ - Fetch issue details from GitHub
122
+ - Create branch: `feature/<issue-number>-<issue-title-slug>`
123
+ - Create worktree in: `../worktrees/feature/<branch-name>/`
124
+ - Install dependencies
125
+ - Copy `.env.local` if it exists
126
+ - Navigate to the worktree directory: `cd ../worktrees/feature/<branch-name>/`
127
+
128
+ 3. **Work in the worktree:**
129
+ - All implementation work happens in the worktree directory
130
+ - Run `npm test` and `npm run build` from the worktree
131
+ - Make commits in the worktree (they'll be on the feature branch)
132
+
133
+ 4. **After implementation is complete:**
134
+ - Push the branch: `git push -u origin feature/<branch-name>`
135
+ - Create PR (manually or via script)
136
+ - The worktree will be cleaned up after PR merge using `./scripts/dev/cleanup-worktree.sh <branch-name>`
137
+
138
+ **Important:** Always work in the worktree directory, not the main repository, once the worktree is created.
139
+
140
+ ### Check Patterns Catalog Before Implementing
141
+
142
+ **IMPORTANT:** Before creating any new utility functions, components, or types:
143
+
144
+ 1. Read `docs/patterns/README.md` for quick lookup
145
+ 2. Check `docs/patterns/HELPERS.md` for existing helper functions
146
+ 3. Check `docs/patterns/COMPONENTS.md` for existing React components
147
+ 4. Check `docs/patterns/TYPES.md` for existing TypeScript types
148
+
149
+ **Do NOT create duplicates.** If a similar utility exists:
150
+ - Use the existing one
151
+ - If it needs modification, extend it rather than creating a new one
152
+ - Document why existing utilities don't meet requirements before creating new ones
153
+
154
+ ### Using Sequential Thinking, Context7, or Supabase MCP
155
+
156
+ Use these specialized tools when appropriate:
157
+
158
+ **Sequential Thinking** - For complex problem-solving requiring multi-step reasoning:
159
+ - Novel algorithms or data structures
160
+ - Ambiguous requirements needing exploration
161
+ - Complex business logic with multiple edge cases
162
+ - Multi-step reasoning with dependencies
163
+ - **NOT for:** Standard CRUD operations, UI implementation following existing patterns, straightforward feature additions
164
+
165
+ **Context7** - For understanding external libraries and packages:
166
+ - Learning unfamiliar npm package APIs (react-query, zod, framer-motion, etc.)
167
+ - Understanding third-party library patterns
168
+ - Resolving library-specific type issues
169
+ - **NOT for:** Project's own codebase (use Glob/Grep instead), Next.js patterns (documented in CLAUDE.md)
170
+
171
+ **Supabase MCP** - For any database-related implementation:
172
+ - **ALWAYS USE** before writing database queries or migrations
173
+ - Verify table schemas and column types
174
+ - Check RLS policies before data access code
175
+ - Understand table relationships
176
+ - Validate data models match TypeScript types
177
+ - **USE for:** Every feature touching `content_updates`, `shops`, `pending_shops`, etc.
178
+
179
+ **General Rule:** If you're implementing a feature similar to an existing one (e.g., new admin card component, new validation function), use Glob/Grep to find patterns rather than Sequential Thinking.
180
+
181
+ ### 3. Checks-first Mindset
182
+
183
+ - Before and after meaningful changes, plan to run:
184
+ - `npm test`
185
+ - For larger changes or anything that might impact build/runtime:
186
+ - Suggest running `npm run build` and interpret any errors.
187
+
188
+ Do NOT silently skip checks. Always state which commands you intend to run and why.
189
+
190
+ ### 4. Implementation Loop
191
+
192
+ - Implement in **small, incremental diffs**.
193
+ - Prefer touching the minimal number of files required.
194
+ - Align with repository conventions described in CLAUDE.md (naming, patterns, etc.).
195
+ - After each meaningful change:
196
+ 1. Run `npm test` (and optionally `npm run build`).
197
+ 2. If checks fail:
198
+ - Inspect the failure output.
199
+ - Identify the root cause.
200
+ - Apply small, targeted fixes.
201
+ - Repeat until checks pass or a clear blocker appears.
202
+
203
+ ### 4a. Parallel Execution (for multi-task issues)
204
+
205
+ When the `/spec` output includes a `## Parallel Groups` section, you can execute independent tasks in parallel using background agents to reduce execution time by 50-70%.
206
+
207
+ **Check for Parallel Groups:**
208
+ Look in the issue comments (especially from `/spec`) for:
209
+ ```markdown
210
+ ## Parallel Groups
211
+
212
+ ### Group 1 (no dependencies)
213
+ - [ ] Task A
214
+ - [ ] Task B
215
+
216
+ ### Group 2 (depends on Group 1)
217
+ - [ ] Task C
218
+ ```
219
+
220
+ **If Parallel Groups exist:**
221
+
222
+ 1. **Create group marker before spawning agents:**
223
+ ```bash
224
+ touch /tmp/claude-parallel-group-1.marker
225
+ ```
226
+
227
+ 2. **Determine model for each task:**
228
+
229
+ Check for model annotations in the task line: `[model: haiku]` or `[model: sonnet]`
230
+
231
+ **Model Selection Priority:**
232
+ 1. `CLAUDE_PARALLEL_MODEL` env var (if set, overrides all)
233
+ 2. `[model: X]` annotation from the task line
234
+ 3. Default to `haiku` if no annotation
235
+
236
+ 3. **Spawn parallel agents with the appropriate model in a SINGLE message:**
237
+ ```
238
+ Task(subagent_type="general-purpose",
239
+ model="haiku",
240
+ run_in_background=true,
241
+ prompt="Implement: Create types/metrics.ts with MetricEvent interface.
242
+ Working directory: [worktree path]
243
+ After completion, report what files were created/modified.")
244
+ ```
245
+
246
+ 4. **Wait for all agents to complete:**
247
+ ```
248
+ TaskOutput(task_id="...", block=true)
249
+ ```
250
+
251
+ 5. **Clean up marker and run post-group formatting:**
252
+ ```bash
253
+ rm /tmp/claude-parallel-group-1.marker
254
+ npx prettier --write [files modified by agents]
255
+ ```
256
+
257
+ 6. **Proceed to next group or sequential tasks**
258
+
259
+ **If no Parallel Groups section exists:**
260
+ Fall back to sequential execution (standard implementation loop).
261
+
262
+ **Parallel Execution Rules:**
263
+ - Maximum 3 agents per group (prevents resource exhaustion)
264
+ - Create marker file BEFORE spawning agents
265
+ - Delete marker file AFTER all agents complete
266
+ - Run Prettier on all modified files after each group (agents skip auto-format)
267
+ - On any agent failure: stop remaining agents, log error, continue with sequential
268
+ - File locking prevents concurrent edits to the same file
269
+
270
+ **Error Handling with Automatic Retry:**
271
+
272
+ When an agent fails, automatic retry kicks in before marking the agent as failed:
273
+
274
+ 1. **Retry Configuration:**
275
+ - Default: 1 retry attempt
276
+ - Configurable via: `CLAUDE_PARALLEL_RETRIES=N` (N = max retry attempts)
277
+ - Exponential backoff: 1s, 2s, 4s between retries
278
+ - After max retries: mark agent as failed
279
+
280
+ 2. **Enhanced Retry Prompt:**
281
+ When retrying a failed agent, add this context to the original prompt:
282
+ ```markdown
283
+ ## RETRY CONTEXT
284
+
285
+ **Previous attempt failed with error:**
286
+ [Original error message from TaskOutput]
287
+
288
+ **CRITICAL CONSTRAINTS (re-emphasized):**
289
+ - You MUST use the worktree path: /path/to/worktrees/feature/XXX/
290
+ - Do NOT edit files outside the worktree
291
+ - Complete the task in fewer tool calls
292
+ ```
293
+
294
+ ### 4b. Detecting Agent Failures
295
+
296
+ **Important:** `TaskOutput.status` may show `"completed"` even when an agent failed due to hook blocks or other issues. The actual failure is reported in the output text, not the status field.
297
+
298
+ **Failure Detection Keywords:**
299
+ Parse the agent's output text for these patterns to detect failures:
300
+
301
+ | Pattern | Meaning |
302
+ |---------|---------|
303
+ | `HOOK_BLOCKED:` | Hook prevented the operation (most reliable) |
304
+ | `unable to proceed` | Agent could not complete the task |
305
+ | `blocked by hook` | Operation was blocked by pre-tool hook |
306
+ | `I'm unable to` | Agent hit a blocking constraint |
307
+
308
+ ## Implementation Quality Standards
309
+
310
+ Before each commit, self-check against these standards:
311
+
312
+ ### 1. Scope Check
313
+ Does this change directly address an AC item?
314
+ - **Yes** → Proceed
315
+ - **No** → Is this refactor necessary for the AC? If not, skip it.
316
+
317
+ ### 2. Type Safety Check
318
+ Am I maintaining or improving types?
319
+ - **Avoid:** Adding `any`, removing type annotations, using `as any`
320
+ - **Good:** Adding types, making types more specific, proper type inference
321
+
322
+ ### 3. Test Coverage Check
323
+ Am I preserving existing test coverage?
324
+ - **Never** delete tests to "make build pass"
325
+ - **Always** update tests when behavior changes, add tests for new behavior
326
+
327
+ ### 4. Size Check
328
+ Is this change proportional to the AC?
329
+ - **Simple AC** (display, button, styling): <100 LOC
330
+ - **Medium AC** (CRUD, admin page, form): 100-300 LOC
331
+ - **Complex AC** (major feature, multi-component): 300-500 LOC
332
+ - **If larger:** Break into smaller, focused commits
333
+
334
+ ### 5. Integration Check
335
+ Are new files actually used?
336
+ - **Never** create components that aren't imported anywhere
337
+ - **Never** create utility functions that aren't called
338
+ - **Never** create API routes that aren't used from UI
339
+ - **Always** verify new exports are imported in at least one location
340
+
341
+ **Quick verification:**
342
+ ```bash
343
+ # Check for unused exports in new files
344
+ npm run knip 2>/dev/null | grep -E "unused|Unused" || echo "No unused exports"
345
+ ```
346
+
347
+ ### 6. Test Impact Check (File Conversions)
348
+
349
+ When converting files to stubs, deleting content, or significantly changing file structure:
350
+
351
+ ```bash
352
+ # Check if any tests depend on the modified file's content
353
+ grep -r "filename.md" __tests__/
354
+ grep -r "filename" __tests__/ | grep -v ".snap"
355
+ ```
356
+
357
+ **If tests are found:**
358
+ 1. Review what the tests are checking (file existence vs. content)
359
+ 2. Update tests to check the new location if content moved
360
+ 3. Run `npm test` after ALL file conversions are complete
361
+
362
+ **Why this matters:** Tests may pass during implementation but fail after final changes if they depend on content that was converted to a stub or moved elsewhere.
363
+
364
+ ### Red Flags to Avoid
365
+
366
+ These patterns indicate scope creep or over-engineering:
367
+ - Renaming functions/variables not related to AC
368
+ - Reformatting files you didn't otherwise modify
369
+ - "While I was here" improvements
370
+ - Converting JS to TS as a side effect
371
+ - Changing linting rules or config
372
+ - Adding abstractions for one-time use
373
+ - Creating utilities not required by AC
374
+
375
+ ### Quality Commitment
376
+
377
+ When in doubt, choose:
378
+ - **Minimal** over comprehensive
379
+ - **Explicit** over clever
380
+ - **Focused** over thorough
381
+ - **Working** over perfect
382
+
383
+ The goal is to satisfy AC with the smallest, safest change possible.
384
+
385
+ ### 5. Progress Summary and Draft Issue Update
386
+
387
+ At the end of a session:
388
+
389
+ 1. Summarize:
390
+ - Which AC items appear satisfied (AC-1, AC-2, ...).
391
+ - Which AC items are partially or not yet satisfied.
392
+ - Which checks were run and their outcomes (`npm test`, `npm run build`, etc.).
393
+ - Any remaining TODOs or recommended follow-ups.
394
+
395
+ 2. Draft a Markdown snippet as a **progress update** for the GitHub issue:
396
+
397
+ - Include:
398
+ - AC coverage summary
399
+ - Brief list of key files changed
400
+ - Any known gaps or open questions
401
+
402
+ - Label it clearly as:
403
+
404
+ ```md
405
+ --- DRAFT GITHUB ISSUE COMMENT (PROGRESS UPDATE) ---
406
+
407
+ ...
408
+
409
+ ```
410
+
411
+ 3. **Update GitHub Issue**
412
+
413
+ - After drafting the progress update comment, post it to the GitHub issue:
414
+ ```bash
415
+ gh issue comment <issue-number> --body "$(cat <<'EOF'
416
+ [draft comment content]
417
+ EOF
418
+ )"
419
+ ```
420
+ - Include the AC coverage summary, files changed, and any gaps or questions in the comment.
421
+ - If the issue has status fields or labels, update them appropriately based on progress (e.g., mark as "in progress"):
422
+ ```bash
423
+ gh issue edit <issue-number> --add-label "in-progress"
424
+ ```
425
+
426
+ You may be invoked multiple times for the same issue. Each time, re-establish context, ensure you're in the correct worktree, and continue iterating until we are as close as practical to meeting the AC.