shipgate-cli 0.0.0-stage → 0.2.2

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +261 -2
  3. package/agents/context-builder.md +158 -0
  4. package/agents/debug-executor.md +234 -0
  5. package/assets/gates/classifier.js +245 -0
  6. package/assets/gates/dsh/index.js +767 -0
  7. package/assets/gates/dsh/policy.json +93 -0
  8. package/assets/gates/index.js +3 -0
  9. package/assets/gates/pi/index.js +1131 -0
  10. package/assets/gates/pi/policy.json +93 -0
  11. package/assets/gates/policy.js +4267 -0
  12. package/assets/gates/profiles/ai4s-dry-lab.json +64 -0
  13. package/assets/gates/profiles/ai4s-quant.json +36 -0
  14. package/assets/pi-extensions/auto-continue.ts +176 -0
  15. package/assets/pi-extensions/goal-mode.ts +313 -0
  16. package/bin/shipgate.mjs +9 -0
  17. package/commands/ai-spec.md +9 -0
  18. package/commands/api-first.md +33 -0
  19. package/commands/code-review.md +7 -0
  20. package/commands/codebase-context.md +19 -0
  21. package/commands/debug-ui.md +147 -0
  22. package/commands/debug.md +101 -0
  23. package/commands/dev-env-scan.md +18 -0
  24. package/commands/dev-host-init.md +28 -0
  25. package/commands/discover-skill-opportunities.md +33 -0
  26. package/commands/fork-sync.md +17 -0
  27. package/commands/gh-actions.md +26 -0
  28. package/commands/goal-driven-development.md +7 -0
  29. package/commands/intent-grill.md +7 -0
  30. package/commands/iteration-manager.md +7 -0
  31. package/commands/loop-engineer.md +21 -0
  32. package/commands/nodejs-npm-auto-release.md +12 -0
  33. package/commands/prd.md +7 -0
  34. package/commands/project-health-audit.md +7 -0
  35. package/commands/ralph-yolo.md +346 -0
  36. package/commands/ralph.md +226 -0
  37. package/commands/security-audit.md +7 -0
  38. package/commands/ux-experience-audit.md +133 -0
  39. package/docs/ARCHITECTURE.md +63 -0
  40. package/docs/GATES.md +106 -0
  41. package/docs/HARNESS.md +257 -0
  42. package/package.json +48 -4
  43. package/references/ADR-FORMAT.md +67 -0
  44. package/references/CONTEXT-FORMAT.md +62 -0
  45. package/references/mcp-config-template.json +54 -0
  46. package/scripts/fix-skill-frontmatter.mjs +66 -0
  47. package/scripts/migrate-skillpack.mjs +257 -0
  48. package/skills/ai-spec/SKILL.md +90 -0
  49. package/skills/api-first-modular/SKILL.md +411 -0
  50. package/skills/code-debugger/SKILL.md +379 -0
  51. package/skills/code-review/SKILL.md +62 -0
  52. package/skills/codebase-context/SKILL.md +139 -0
  53. package/skills/debug-ui/SKILL.md +220 -0
  54. package/skills/dev-env-scan/SKILL.md +147 -0
  55. package/skills/dev-host-init/SKILL.md +198 -0
  56. package/skills/dev-host-init/scripts/fill-placeholders.py +226 -0
  57. package/skills/dev-host-init/scripts/host-scan.ps1 +159 -0
  58. package/skills/dev-host-init/scripts/host-scan.sh +201 -0
  59. package/skills/dev-host-init/scripts/render-now.py +488 -0
  60. package/skills/dev-host-init/scripts/tools-catalog.py +229 -0
  61. package/skills/dev-host-init/templates/graph-first-gate.ts +291 -0
  62. package/skills/dev-host-init/templates/host-injection.template.md +725 -0
  63. package/skills/discover-skill-opportunities/SKILL.md +145 -0
  64. package/skills/discover-skill-opportunities/references/accounting-finance-ops.md +24 -0
  65. package/skills/discover-skill-opportunities/references/business-consulting.md +24 -0
  66. package/skills/discover-skill-opportunities/references/evidence-and-privacy.md +39 -0
  67. package/skills/discover-skill-opportunities/references/finance-investment.md +24 -0
  68. package/skills/discover-skill-opportunities/references/legal-and-compliance.md +24 -0
  69. package/skills/discover-skill-opportunities/references/output-contract.md +75 -0
  70. package/skills/discover-skill-opportunities/references/product-and-operations.md +24 -0
  71. package/skills/discover-skill-opportunities/references/quant-trading.md +24 -0
  72. package/skills/discover-skill-opportunities/references/scientific-research.md +24 -0
  73. package/skills/discover-skill-opportunities/references/scoring-rubric.md +45 -0
  74. package/skills/discover-skill-opportunities/references/session-skill-review.md +78 -0
  75. package/skills/discover-skill-opportunities/references/software-development.md +24 -0
  76. package/skills/fork-sync/SKILL.md +86 -0
  77. package/skills/gh-actions-architect/SKILL.md +395 -0
  78. package/skills/goal-driven-development/SKILL.md +132 -0
  79. package/skills/intent-grill/SKILL.md +46 -0
  80. package/skills/iteration-manager/SKILL.md +53 -0
  81. package/skills/loop-engineer/SKILL.md +108 -0
  82. package/skills/nodejs-npm-auto-release/SKILL.md +141 -0
  83. package/skills/prd/SKILL.md +63 -0
  84. package/skills/project-health-audit/SKILL.md +64 -0
  85. package/skills/ralph/SKILL.md +329 -0
  86. package/skills/ralph-yolo/SKILL.md +623 -0
  87. package/skills/security-audit/SKILL.md +114 -0
  88. package/skills/security-audit/references/audit-checklist.md +135 -0
  89. package/skills/security-audit/references/evidence-conventions.md +54 -0
  90. package/skills/security-audit/references/findings-schema.md +37 -0
  91. package/skills/security-audit/references/stack-signatures.md +66 -0
  92. package/skills/shipgate/SKILL.md +40 -0
  93. package/skills/shipgate-install/SKILL.md +87 -0
  94. package/skills/shipgate-quality/SKILL.md +80 -0
  95. package/skills/shipgate-security/SKILL.md +97 -0
  96. package/skills/shipgate-spec/SKILL.md +67 -0
  97. package/skills/ux-experience-audit/SKILL.md +202 -0
  98. package/src/cli.mjs +118 -0
  99. package/src/commands/ask.mjs +82 -0
  100. package/src/commands/deploy.mjs +587 -0
  101. package/src/commands/gates.mjs +83 -0
  102. package/src/commands/policy.mjs +116 -0
  103. package/src/gates/quality.mjs +123 -0
  104. package/src/gates/security.mjs +92 -0
  105. package/src/gates/ship.mjs +74 -0
  106. package/src/gates/spec.mjs +88 -0
  107. package/src/harness/index.mjs +203 -0
  108. package/src/inject/render.mjs +75 -0
  109. package/src/lib/cfg.mjs +66 -0
  110. package/src/lib/duration.mjs +41 -0
  111. package/src/lib/engines.mjs +182 -0
  112. package/src/lib/exec.mjs +80 -0
  113. package/src/lib/fsx.mjs +119 -0
  114. package/src/lib/gate.mjs +329 -0
  115. package/src/lib/log.mjs +31 -0
  116. package/src/lib/skills.mjs +347 -0
  117. package/src/lib/state.mjs +50 -0
  118. package/src/lib/update.mjs +67 -0
  119. package/src/version.mjs +14 -0
  120. package/templates/agents-snippet.md +82 -0
  121. package/templates/dev-profile.schema.json +119 -0
  122. package/templates/prd.json.example +64 -0
  123. package/templates/rule.json.example +28 -0
@@ -0,0 +1,329 @@
1
+ ---
2
+ name: ralph
3
+ description: "Legacy compatibility harness for classic Ralph PRD execution. Use only when explicitly required; new approved-SPEC work should use goal-driven-development."
4
+ ---
5
+
6
+ # Ralph - Autonomous Agent Loop
7
+
8
+ > **Legacy compatibility:** The default path is `PRD → ai-spec → goal-driven-development → code-review → iteration-manager`.
9
+
10
+ Ralph is an autonomous AI agent loop that implements PRDs by repeatedly spawning fresh AI instances to complete user stories one by one.
11
+
12
+ ---
13
+
14
+ ## What This Skill Does
15
+
16
+ This skill handles two phases:
17
+
18
+ 1. **PRD Conversion**: Converts a markdown PRD to `prd.json` format
19
+ 2. **Ralph Execution**: Launches the autonomous loop that implements each story
20
+
21
+ ---
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ /ralph [path-to-prd.md]
27
+ ```
28
+
29
+ If no path is provided, looks for `prd.json` in the project root and runs directly.
30
+
31
+ Examples:
32
+ - `/ralph tasks/prd-my-feature.md` - Convert PRD and run Ralph
33
+ - `/ralph prd.json` - Run Ralph with existing prd.json
34
+ - `/ralph` - Run Ralph (looks for prd.json)
35
+
36
+ ---
37
+
38
+ ## Phase 1: PRD Conversion (if markdown provided)
39
+
40
+ ### Step 1: Read the PRD
41
+
42
+ Read the provided markdown PRD file.
43
+
44
+ ### Step 2: Archive Previous Run (if needed)
45
+
46
+ Check if `prd.json` exists with a different `branchName`. If so:
47
+ 1. Read current `prd.json` and extract `branchName`
48
+ 2. Check if it differs from the new feature's branch
49
+ 3. If different AND `prd-progress.txt` has content:
50
+ - Create archive folder: `.claude/archive/YYYY-MM-DD-[feature-name]/`
51
+ - Copy current `prd.json` and `prd-progress.txt` to archive
52
+ - Reset `prd-progress.txt` with fresh header
53
+
54
+ ### Step 3: Convert to prd.json
55
+
56
+ Parse the PRD and generate `prd.json` in the project root:
57
+
58
+ ```json
59
+ {
60
+ "project": "[Project Name from PRD or auto-detected]",
61
+ "branchName": "ralph/[feature-name-kebab-case]",
62
+ "description": "[Feature description from PRD]",
63
+ "userStories": [
64
+ {
65
+ "id": "US-001",
66
+ "title": "[Story title]",
67
+ "description": "As a [user], I want [feature] so that [benefit]",
68
+ "acceptanceCriteria": [
69
+ "Criterion 1",
70
+ "Criterion 2",
71
+ "Typecheck passes"
72
+ ],
73
+ "priority": 1,
74
+ "passes": false,
75
+ "notes": ""
76
+ }
77
+ ]
78
+ }
79
+ ```
80
+
81
+ ### Conversion Rules
82
+
83
+ 1. **Each user story becomes one JSON entry**
84
+ 2. **IDs**: Sequential (US-001, US-002, etc.)
85
+ 3. **Priority**: Based on dependency order (schema → backend → UI)
86
+ 4. **All stories**: `passes: false` and empty `notes`
87
+ 5. **branchName**: Derive from feature name, kebab-case, prefixed with `ralph/`
88
+ 6. **Always add**: "Typecheck passes" to every story
89
+ 7. **For UI stories**: Add "Verify in browser using dev-browser skill"
90
+
91
+ ### Story Sizing is Critical
92
+
93
+ Each story MUST be completable in ONE Ralph iteration.
94
+
95
+ **Right-sized stories:**
96
+ - Add a database column and migration
97
+ - Add a UI component to an existing page
98
+ - Update a server action with new logic
99
+ - Add a filter dropdown to a list
100
+
101
+ **Too big (must split):**
102
+ - "Build the entire dashboard" → Split into: schema, queries, UI components, filters
103
+ - "Add authentication" → Split into: schema, middleware, login UI, session handling
104
+
105
+ **Rule of thumb:** If you cannot describe the change in 2-3 sentences, it is too big.
106
+
107
+ ### Story Ordering
108
+
109
+ Stories execute in `priority` order. Earlier stories must NOT depend on later ones.
110
+
111
+ **Correct order:**
112
+ 1. Schema/database changes (migrations)
113
+ 2. Server actions / backend logic
114
+ 3. UI components that use the backend
115
+ 4. Dashboard/summary views that aggregate data
116
+
117
+ ### Verification Before Proceeding
118
+
119
+ Before running Ralph, verify:
120
+ - [ ] Previous run archived (if applicable)
121
+ - [ ] Each story is completable in one iteration
122
+ - [ ] Stories are ordered by dependencies
123
+ - [ ] Every story has "Typecheck passes"
124
+ - [ ] UI stories have "Verify in browser using dev-browser skill"
125
+ - [ ] Acceptance criteria are verifiable (not vague)
126
+
127
+ ---
128
+
129
+ ## Phase 2: Ralph Execution
130
+
131
+ ### Step 1: Pre-flight Checks
132
+
133
+ Verify the following before starting:
134
+
135
+ 1. **Amp CLI installed**
136
+ ```bash
137
+ which amp
138
+ ```
139
+ If not found, instruct user to install from https://ampcode.com
140
+
141
+ 2. **jq installed**
142
+ ```bash
143
+ which jq
144
+ ```
145
+ If not found, instruct user to install (brew install jq on macOS)
146
+
147
+ 3. **Git working directory clean**
148
+ ```bash
149
+ git status --porcelain
150
+ ```
151
+ If not clean, ask user to commit or stash changes
152
+
153
+ 4. **prd.json exists and is valid**
154
+ ```bash
155
+ cat prd.json | jq .
156
+ ```
157
+ If invalid, show error and exit
158
+
159
+ ### Step 2: Create or Checkout Feature Branch
160
+
161
+ Read `branchName` from `prd.json`:
162
+ ```bash
163
+ jq -r '.branchName' prd.json
164
+ ```
165
+
166
+ If branch doesn't exist, create it from main:
167
+ ```bash
168
+ git checkout -b $(jq -r '.branchName' prd.json)
169
+ ```
170
+
171
+ If branch exists, checkout it:
172
+ ```bash
173
+ git checkout $(jq -r '.branchName' prd.json)
174
+ ```
175
+
176
+ ### Step 3: Run Ralph Loop
177
+
178
+ Execute the Ralph script:
179
+ ```bash
180
+ bash .claude/scripts/ralph.sh [max_iterations]
181
+ ```
182
+
183
+ Default is 10 iterations. The script will:
184
+
185
+ 1. Spawn a fresh Amp instance with `.claude/scripts/prompt.md`
186
+ 2. Amp picks the highest priority story with `passes: false`
187
+ 3. Amp implements that single story
188
+ 4. Amp runs quality checks (typecheck, lint, test)
189
+ 5. If checks pass, Amp commits with message: `feat: [Story ID] - [Story Title]`
190
+ 6. Amp updates `prd.json` to set `passes: true` for the story
191
+ 7. Amp appends progress to `prd-progress.txt`
192
+ 8. Loop repeats until all stories pass or max iterations reached
193
+
194
+ ### Step 4: Monitor Progress
195
+
196
+ Show the user how to monitor:
197
+ ```bash
198
+ # See which stories are done
199
+ cat prd.json | jq '.userStories[] | {id, title, passes}'
200
+
201
+ # See learnings from previous iterations
202
+ cat prd-progress.txt
203
+
204
+ # Check git history
205
+ git log --oneline -10
206
+ ```
207
+
208
+ ### Step 5: Completion
209
+
210
+ When ALL stories have `passes: true`, Ralph will output:
211
+ ```
212
+ <promise>COMPLETE</promise>
213
+ ```
214
+
215
+ And the loop exits successfully.
216
+
217
+ ---
218
+
219
+ ## Ralph's Inner Loop (What Happens During Execution)
220
+
221
+ Each iteration spawns a fresh Amp instance with instructions from `.claude/scripts/prompt.md`.
222
+
223
+ The Amp instance:
224
+
225
+ 1. Reads `prd.json` to pick the next story
226
+ 2. Reads `prd-progress.txt` for context
227
+ 3. Implements that ONE story
228
+ 4. Runs quality checks
229
+ 5. Updates `AGENTS.md` files if patterns are discovered
230
+ 6. Commits if checks pass
231
+ 7. Updates `prd.json` to mark story complete
232
+ 8. Appends learnings to `prd-progress.txt`
233
+
234
+ ### Memory Between Iterations
235
+
236
+ The only memory between iterations:
237
+ - Git history (commits from previous iterations)
238
+ - `prd-progress.txt` (learnings and context)
239
+ - `prd.json` (which stories are done)
240
+
241
+ Each iteration is a **fresh Amp instance** with clean context.
242
+
243
+ ---
244
+
245
+ ## Key Files
246
+
247
+ | File | Purpose |
248
+ |------|---------|
249
+ | `.claude/scripts/ralph.sh` | The bash loop that spawns Amp instances |
250
+ | `.claude/scripts/prompt.md` | Instructions given to each Amp instance |
251
+ | `prd.json` | User stories with `passes` status |
252
+ | `prd-progress.txt` | Append-only learnings log |
253
+ | `.claude/archive/` | Previous run archives |
254
+
255
+ ---
256
+
257
+ ## Troubleshooting
258
+
259
+ ### Ralph stops mid-execution
260
+
261
+ Check `prd-progress.txt` for the last completed story, then resume:
262
+ ```bash
263
+ # Just run ralph again, it will continue from where it left off
264
+ bash .claude/scripts/ralph.sh
265
+ ```
266
+
267
+ ### Amp context fills up
268
+
269
+ Enable auto-handoff in `~/.config/amp/settings.json`:
270
+ ```json
271
+ {
272
+ "amp.experimental.autoHandoff": { "context": 90 }
273
+ }
274
+ ```
275
+
276
+ ### Story fails quality checks
277
+
278
+ Ralph won't commit broken code. Check:
279
+ - `prd-progress.txt` for errors
280
+ - Git working directory for uncommitted changes
281
+ - Fix the issue and run Ralph again
282
+
283
+ ---
284
+
285
+ ## Tips for Best Results
286
+
287
+ 1. **Keep stories small** - Each must complete in one context window
288
+ 2. **Order by dependencies** - Schema before backend before UI
289
+ 3. **Verifiable criteria** - "Typecheck passes" not "Works correctly"
290
+ 4. **Clean git state** - Start with a clean working directory
291
+ 5. **Monitor progress** - Check `prd-progress.txt` and git log regularly
292
+
293
+ ## 关联 Skill(网络调度协议)
294
+
295
+ | 关系 | Skill | 场景 |
296
+ |------|-------|------|
297
+ | 可调用 | code-debugger | 自动开发遇到错误时 |
298
+ | 可调用 | code-review | 每轮实现后作为质量门审查 |
299
+ | 可调用 | codebase-context | 开发前理解架构约束 |
300
+ | 可调用 | nodejs-npm-auto-release | 开发完成需要发布 |
301
+ | 被调用 | ai-spec | 主调度路由到自动开发 |
302
+ | 被调用 | prd | PRD 完成后启动开发循环 |
303
+ | 被调用 | api-first | API 设计完成进入实现 |
304
+
305
+ ---
306
+
307
+ ## Example Session
308
+
309
+ ```
310
+ User: /ralph tasks/prd-task-priority.md
311
+
312
+ Ralph Skill:
313
+ - Converting PRD to prd.json...
314
+ - Created prd.json with 4 user stories
315
+ - Checking prerequisites...
316
+ - Creating branch ralph/task-priority...
317
+ - Starting Ralph loop...
318
+
319
+ [Ralph executes iterations...]
320
+
321
+ Iteration 1: US-001 - Add priority field to database ✓
322
+ Iteration 2: US-002 - Display priority indicator on task cards ✓
323
+ Iteration 3: US-003 - Add priority selector to task edit ✓
324
+ Iteration 4: US-004 - Filter tasks by priority ✓
325
+
326
+ <promise>COMPLETE</promise>
327
+
328
+ All stories completed! Check prd-progress.txt for details.
329
+ ```