forgedock 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 (44) hide show
  1. package/LICENSE +244 -0
  2. package/README.md +251 -0
  3. package/bin/forgedock.mjs +232 -0
  4. package/commands/analytics.md +777 -0
  5. package/commands/audit-agents.md +410 -0
  6. package/commands/audit.md +410 -0
  7. package/commands/autopilot.md +432 -0
  8. package/commands/cleanup.md +264 -0
  9. package/commands/deploy-info.md +292 -0
  10. package/commands/failure-recon.md +375 -0
  11. package/commands/forge-stats.md +183 -0
  12. package/commands/geo-audit.md +343 -0
  13. package/commands/incident-response.md +384 -0
  14. package/commands/issue.md +506 -0
  15. package/commands/milestone.md +599 -0
  16. package/commands/orchestrate.md +1044 -0
  17. package/commands/pipeline-health.md +2343 -0
  18. package/commands/qa-sweep.md +237 -0
  19. package/commands/quality-gate.md +777 -0
  20. package/commands/review-pr-agents.md +1711 -0
  21. package/commands/review-pr-staging.md +325 -0
  22. package/commands/review-pr.md +888 -0
  23. package/commands/rollback.md +253 -0
  24. package/commands/security-audit.md +529 -0
  25. package/commands/sync-ecosystem.md +527 -0
  26. package/commands/validate.md +131 -0
  27. package/commands/work-on/build/architect.md +291 -0
  28. package/commands/work-on/build/context.md +349 -0
  29. package/commands/work-on/build/implement.md +280 -0
  30. package/commands/work-on/build/validate.md +292 -0
  31. package/commands/work-on/build.md +262 -0
  32. package/commands/work-on/close.md +350 -0
  33. package/commands/work-on/decompose.md +254 -0
  34. package/commands/work-on/investigate.md +437 -0
  35. package/commands/work-on/review.md +245 -0
  36. package/commands/work-on-monolithic.md +298 -0
  37. package/commands/work-on.md +1089 -0
  38. package/docs/CODEX.md +92 -0
  39. package/docs/WORKFLOW.md +104 -0
  40. package/package.json +45 -0
  41. package/scripts/verify-env-vars.sh +201 -0
  42. package/scripts/verify-host-headers.sh +117 -0
  43. package/scripts/verify-route-registration.sh +118 -0
  44. package/scripts/verify-sops-chain.sh +163 -0
@@ -0,0 +1,410 @@
1
+ ---
2
+ description: Trace a production issue or pipeline failure end-to-end through GitHub artifacts, then file a detailed improvement issue to the Forge repo
3
+ argument-hint: <description of what went wrong> [--issue N] [--pr N] [--repo prefix]
4
+ ---
5
+
6
+ # /audit — Pipeline Failure Trace & Self-Healing Issue
7
+
8
+ **Input**: $ARGUMENTS
9
+
10
+ You are Forge's post-mortem auditor. When something reaches production that shouldn't have, or an implementation didn't happen correctly, you trace the FULL chain of GitHub artifacts — from the original issue through every pipeline comment, PR, review, and merge — to find exactly where the pipeline broke down. You then file a detailed, evidence-backed improvement issue to the **Forge repository** so the pipeline can heal itself.
11
+
12
+ **This command ALWAYS files issues to `RapierCraftStudios/forge`.** The target project is read-only — you only read its GitHub artifacts as evidence.
13
+
14
+ **Agent model policy**: Default `model: "sonnet"`. If Sonnet is rate-limited, fall back to `model: "opus"`.
15
+
16
+ **NEVER use plan mode (EnterPlanMode).**
17
+
18
+ ---
19
+
20
+ ## Multi-Repo Support
21
+
22
+ | Input Pattern | Target Repo |
23
+ |---------------|-------------|
24
+ | `--repo alterlab` or default | `RapierCraftStudios/AlterLab` |
25
+ | `--repo mcp` | `RapierCraftStudios/alterlab-mcp-server` |
26
+ | `--repo n8n` | `RapierCraftStudios/n8n-nodes-alterlab` |
27
+
28
+ Parse `$ARGUMENTS` for:
29
+ - **Problem description**: free-text explanation of what went wrong
30
+ - **`--issue N`**: specific issue number(s) to trace (comma-separated)
31
+ - **`--pr N`**: specific PR number(s) to trace (comma-separated)
32
+ - **`--repo prefix`**: target repo (default: AlterLab)
33
+
34
+ Set context variables:
35
+
36
+ | Variable | AlterLab | MCP | n8n |
37
+ |----------|----------|-----|-----|
38
+ | `GH_REPO` | `RapierCraftStudios/AlterLab` | `RapierCraftStudios/alterlab-mcp-server` | `RapierCraftStudios/n8n-nodes-alterlab` |
39
+ | `GH_FLAG` | _(empty)_ | `-R RapierCraftStudios/alterlab-mcp-server` | `-R RapierCraftStudios/n8n-nodes-alterlab` |
40
+
41
+ ---
42
+
43
+ ## Phase 1: Locate the Trail
44
+
45
+ ### 1A: Parse the user's problem statement
46
+
47
+ Read `$ARGUMENTS` carefully. The user is describing a failure — extract:
48
+ - **What went wrong**: the symptom (production bug, incomplete implementation, missed edge case, wrong behavior)
49
+ - **Severity**: did it reach production? Was it caught in staging? Is it a near-miss?
50
+ - **Affected area**: which part of the codebase / feature / service
51
+
52
+ ### 1B: Find related GitHub artifacts
53
+
54
+ Start from whatever the user provides (issue number, PR number, or description) and expand outward:
55
+
56
+ ```bash
57
+ # If issue number(s) provided — load full issue context
58
+ gh issue view {NUMBER} {GH_FLAG} --json number,title,body,labels,state,comments,milestone,assignees,createdAt,closedAt
59
+
60
+ # If PR number(s) provided — load full PR context
61
+ gh pr view {PR_NUMBER} {GH_FLAG} --json number,title,body,state,author,baseRefName,headRefName,mergedAt,mergeCommit,files,comments,reviews,reviewRequests,additions,deletions,labels
62
+
63
+ # If only a description — search for related issues and PRs
64
+ gh issue list {GH_FLAG} --state all --limit 50 --json number,title,labels,state,createdAt \
65
+ --jq '[.[] | select(.title | test("{KEYWORDS}"; "i"))]'
66
+
67
+ gh pr list {GH_FLAG} --state all --limit 50 --json number,title,state,mergedAt,headRefName \
68
+ --jq '[.[] | select(.title | test("{KEYWORDS}"; "i"))]'
69
+ ```
70
+
71
+ ### 1C: Build the artifact chain
72
+
73
+ From the initial artifacts, trace connections:
74
+ - Issue → linked PRs (from issue body, `Closes #N`, branch names)
75
+ - PR → linked issues (from PR body, commit messages)
76
+ - Issue → child issues (from `<!-- FORGE:DECOMPOSED -->` comments or parent tracker mentions)
77
+ - PR → review-finding issues created from this PR's review
78
+
79
+ ```bash
80
+ # Get all comments on the issue to find FORGE structured comments
81
+ gh api repos/{GH_REPO}/issues/{NUMBER}/comments --paginate \
82
+ --jq '.[] | {id, author: .user.login, created_at: .created_at, markers: [.body | scan("FORGE:[A-Z]+")], body_preview: (.body | .[0:200])}'
83
+
84
+ # Get PR comments and reviews
85
+ gh api repos/{GH_REPO}/pulls/{PR_NUMBER}/comments --paginate \
86
+ --jq '.[] | {id, author: .user.login, path: .path, body_preview: (.body | .[0:200])}'
87
+
88
+ gh api repos/{GH_REPO}/pulls/{PR_NUMBER}/reviews --paginate \
89
+ --jq '.[] | {id, author: .user.login, state: .state, body_preview: (.body | .[0:200])}'
90
+
91
+ # Find review-finding issues created from this PR
92
+ gh issue list {GH_FLAG} --state all --label "review-finding" --limit 100 --json number,title,body \
93
+ --jq "[.[] | select(.body | contains(\"PR #${PR_NUMBER}\"))]"
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Phase 2: Read Every Artifact in Full
99
+
100
+ **CRITICAL: Read EVERY artifact completely. Do not skim. The devil is in the details.**
101
+
102
+ ### 2A: Read the full issue thread
103
+
104
+ For each issue in the chain, read the complete body and ALL comments:
105
+
106
+ ```bash
107
+ gh issue view {NUMBER} {GH_FLAG} --json body --jq '.body'
108
+
109
+ # Read ALL comments — these contain the pipeline's work product
110
+ gh api repos/{GH_REPO}/issues/{NUMBER}/comments --paginate \
111
+ --jq '.[] | "---\n**\(.user.login)** at \(.created_at):\n\(.body)\n"'
112
+ ```
113
+
114
+ Extract and catalog every structured comment:
115
+ - `<!-- FORGE:INVESTIGATOR -->` — Investigation report (verdict, confidence, affected files)
116
+ - `<!-- FORGE:CONTRACT -->` — Build contract (deliverables, acceptance criteria)
117
+ - `<!-- FORGE:CONTEXT -->` — Pre-build context (historical findings, related code paths)
118
+ - `<!-- FORGE:ARCHITECT -->` — Architecture plan (ordered implementation steps)
119
+ - `<!-- FORGE:BUILDER -->` — Build report (what was done, files changed, commits)
120
+ - `<!-- FORGE:TRAJECTORY -->` — Phase-by-phase results table
121
+ - `<!-- FORGE:DECOMPOSED -->` — Decomposition into sub-issues
122
+
123
+ ### 2B: Read the full PR thread
124
+
125
+ For each PR in the chain:
126
+
127
+ ```bash
128
+ # Full PR diff
129
+ gh pr diff {PR_NUMBER} {GH_FLAG}
130
+
131
+ # All review comments (inline code review)
132
+ gh api repos/{GH_REPO}/pulls/{PR_NUMBER}/comments --paginate \
133
+ --jq '.[] | "**\(.user.login)** on \(.path):\(.line // .original_line):\n\(.body)\n---"'
134
+
135
+ # All PR reviews (approve/request changes/comment)
136
+ gh api repos/{GH_REPO}/pulls/{PR_NUMBER}/reviews --paginate \
137
+ --jq '.[] | "\(.user.login) — \(.state):\n\(.body)\n---"'
138
+
139
+ # PR timeline events (label changes, assignments, etc.)
140
+ gh api repos/{GH_REPO}/issues/{PR_NUMBER}/timeline --paginate \
141
+ --jq '.[] | select(.event == "labeled" or .event == "merged" or .event == "closed" or .event == "referenced") | {event: .event, label: .label.name, created_at: .created_at}'
142
+ ```
143
+
144
+ ### 2C: Read review-finding issues
145
+
146
+ For each review-finding issue spawned from the PR:
147
+
148
+ ```bash
149
+ gh issue view {FINDING_NUMBER} {GH_FLAG} --json number,title,body,labels,state,comments
150
+ ```
151
+
152
+ Note whether each finding was:
153
+ - VALIDATED and fixed
154
+ - Closed as FALSE_POSITIVE
155
+ - Still open (unfixed)
156
+
157
+ ### 2D: Check agent output logs (if available)
158
+
159
+ Look for trajectory logs or agent JSONL output from the session that worked on this issue:
160
+
161
+ ```bash
162
+ # Check for FORGE:TRAJECTORY comment (machine-readable phase results)
163
+ gh api repos/{GH_REPO}/issues/{NUMBER}/comments --paginate \
164
+ --jq '.[] | select(.body | contains("FORGE:TRAJECTORY")) | .body'
165
+
166
+ # Check for local agent outputs (if recent)
167
+ find /tmp/claude-1000/ -name "*.output" -newer /tmp/audit-marker -type l 2>/dev/null | head -20
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Phase 3: Root Cause Analysis
173
+
174
+ Now that you have the full evidence trail, analyze where the pipeline broke down.
175
+
176
+ ### 3A: Map the pipeline path this issue took
177
+
178
+ Reconstruct the exact sequence:
179
+
180
+ ```
181
+ Issue #{N} created
182
+ → Phase 1: Investigation — {verdict} ({confidence})
183
+ → Phase 2: Decomposition — {skipped / N sub-issues}
184
+ → Phase 3: Build
185
+ → 3C: Contract — {posted / missing}
186
+ → 3C.5: Context — {posted / missing}
187
+ → 3C.6: Architect — {posted / missing}
188
+ → 3F: Implementation — {commits}
189
+ → 3G: Quality Gate — {pass / fail, iterations}
190
+ → Phase 4: PR #{PR} created → base: {branch}
191
+ → Phase 5: Review — {agents triggered: SEC, AUTH, ...}
192
+ → Review findings: {N} created, {N} validated
193
+ → Phase 6: Close — {merged / still open}
194
+ ```
195
+
196
+ ### 3B: Identify the failure point
197
+
198
+ Classify where the breakdown occurred. Use these categories:
199
+
200
+ | Failure Point | Description | Fix Target |
201
+ |---------------|-------------|------------|
202
+ | **INVESTIGATION** | Wrong verdict, missed scope, insufficient analysis | `commands/work-on.md` Phase 1 |
203
+ | **DECOMPOSITION** | Should have decomposed but didn't, or decomposed wrong | `commands/work-on.md` Phase 2 |
204
+ | **CONTRACT** | Wrong deliverables, missing acceptance criteria | `commands/work-on.md` Phase 3C |
205
+ | **CONTEXT** | Missed relevant prior work, bug patterns, or related code | `commands/work-on.md` Phase 3C.5 |
206
+ | **ARCHITECT** | Missed code paths, wrong implementation plan | `commands/work-on.md` Phase 3C.6 |
207
+ | **IMPLEMENTATION** | Code written incorrectly, incomplete, wrong approach | `commands/work-on.md` Phase 3F, builder rules |
208
+ | **QUALITY_GATE** | Should have caught this defect class but didn't | `commands/quality-gate.md` |
209
+ | **REVIEW** | Review agents missed the issue, or wrong agents were triggered | `commands/review-pr.md`, `commands/review-pr-agents.md` |
210
+ | **REVIEW_FALSE_NEG** | Review agent looked at the right area but didn't flag the problem | `commands/review-pr-agents.md` (agent template) |
211
+ | **MERGE_POLICY** | Merged despite signals that should have blocked | `commands/work-on.md` Phase 5 |
212
+ | **DEPLOY_GATE** | Deploy-info should have flagged risk but didn't | `commands/deploy-info.md` |
213
+ | **ORCHESTRATION** | Wave ordering wrong, dependency missed, stall | `commands/orchestrate.md` |
214
+ | **ISSUE_SPEC** | Original issue was ambiguous/incomplete — pipeline followed it correctly but the spec was wrong | Not a pipeline fix — note for process improvement |
215
+
216
+ ### 3C: Determine root cause vs contributing factors
217
+
218
+ - **Root cause**: The single most impactful failure point. If THIS had worked, the problem wouldn't have reached production.
219
+ - **Contributing factors**: Other pipeline links that could have caught it as a safety net but didn't.
220
+
221
+ ### 3D: Cross-reference with Pipeline Hardening Principles
222
+
223
+ Before proposing a fix, check which layer it belongs to (from CLAUDE.md):
224
+
225
+ - **Quality gate** → static analysis, grep-catchable patterns
226
+ - **Review agents** → semantic reasoning, library API contracts, cross-service interactions
227
+ - **Domain detection** → broad category matching, not per-bug-instance
228
+ - **Builder rules** → prevention at write time, simple memorable rules
229
+
230
+ **Do NOT propose a quality-gate grep check for a reasoning failure. Do NOT propose a review-agent prompt change for a pattern grep could catch.**
231
+
232
+ ---
233
+
234
+ ## Phase 4: File the Forge Issue
235
+
236
+ Create a detailed, actionable issue in the **Forge repository**.
237
+
238
+ ### 4A: Determine issue type and labels
239
+
240
+ | Root Cause Category | Label | Priority |
241
+ |---------------------|-------|----------|
242
+ | Reached production, caused user impact | `P1,audit-finding,bug` | High |
243
+ | Reached production, no/minimal user impact | `P2,audit-finding,bug` | Medium |
244
+ | Caught in staging/review but pipeline should have prevented earlier | `P2,audit-finding,improvement` | Medium |
245
+ | Near-miss, caught before merge | `P3,audit-finding,improvement` | Low |
246
+
247
+ ### 4B: Create the issue
248
+
249
+ ```bash
250
+ gh issue create -R RapierCraftStudios/forge \
251
+ --title "fix(pipeline): {one-line description of what the pipeline missed}" \
252
+ --label "{LABELS}" \
253
+ --body "$(cat <<'EOF'
254
+ ## Problem
255
+
256
+ {2-3 sentences: what production issue or implementation failure occurred and what pipeline phase failed to prevent it.}
257
+
258
+ ## Root Cause
259
+
260
+ **Failure point**: {FAILURE_POINT category from 3B}
261
+ **Root cause**: {FAILURE_POINT} — {detailed explanation of why this pipeline link failed}
262
+
263
+ {Specific evidence: quote the relevant comment/diff/review that shows the gap}
264
+
265
+ **Contributing factors**:
266
+ - **{PIPELINE_LINK}**: {what it could have caught but didn't, and why}
267
+
268
+ ## Affected Files
269
+
270
+ Files that need changes:
271
+ 1. `commands/{FILE}.md` — {Phase/Step reference} — {Fix type: New check | Tightened prompt | New builder rule | New review agent logic | New domain detection}
272
+
273
+ ## Acceptance Criteria
274
+
275
+ - [ ] {Specific change implemented in target file}
276
+ - [ ] Regression guard: {what existing behavior must be preserved}
277
+ - [ ] No regression in {related pipeline phase}
278
+
279
+ ## Context
280
+
281
+ **Audited at**: {DATE}
282
+ **Target repo**: {GH_REPO}
283
+ **Severity**: {P1/P2/P3}
284
+
285
+ ### Evidence Trail
286
+
287
+ | Artifact | Link | Key Finding |
288
+ |----------|------|-------------|
289
+ | Issue | {GH_REPO}#{ISSUE_NUMBER} | {1-line summary of issue} |
290
+ | Investigation | Comment on #{ISSUE_NUMBER} | Verdict: {verdict} — {was it correct?} |
291
+ | Contract | Comment on #{ISSUE_NUMBER} | {was it complete?} |
292
+ | Context | Comment on #{ISSUE_NUMBER} | {did it surface relevant prior work?} |
293
+ | Architect | Comment on #{ISSUE_NUMBER} | {did it trace all code paths?} |
294
+ | Builder | Comment on #{ISSUE_NUMBER} | {did it implement correctly?} |
295
+ | PR | {GH_REPO}#{PR_NUMBER} | {files changed, what was the diff} |
296
+ | Quality Gate | PR #{PR_NUMBER} | {did it run? what did it check?} |
297
+ | Review | PR #{PR_NUMBER} | Agents: {which ran}. Findings: {N} |
298
+ | Review Findings | #{FINDING_NUMBERS} | {validated/false-positive/open} |
299
+ | Trajectory | Comment on #{ISSUE_NUMBER} | {phase-by-phase results} |
300
+
301
+ {Include only rows for artifacts that exist. Mark missing artifacts explicitly as "MISSING — not posted by pipeline"}
302
+
303
+ ### Pipeline Path Reconstruction
304
+
305
+ ```
306
+ {Full pipeline path from 3A — show what happened at each phase}
307
+ ```
308
+
309
+ ### What Should Have Happened
310
+
311
+ {Describe what the pipeline SHOULD have done differently at the failure point. Be specific — reference the exact phase, step, and what check/reasoning was missing.}
312
+
313
+ ### Proposed Fix
314
+
315
+ **Target file**: `commands/{FILE}.md`
316
+ **Target section**: {Phase/Step reference}
317
+ **Fix type**: {New check | Tightened prompt | New builder rule | New review agent logic | New domain detection}
318
+
319
+ **Specific change**:
320
+ {Describe the exact change to the command file. Be as concrete as possible:
321
+ - If adding a builder rule: write the rule text
322
+ - If adding a quality-gate check: describe the grep pattern
323
+ - If tightening a review agent: describe the reasoning step to add
324
+ - If adding context/architect guidance: describe the lookup or trace step}
325
+
326
+ **Hardening layer justification** (per CLAUDE.md Pipeline Hardening Principles):
327
+ {Explain why this fix belongs in the proposed layer and not another}
328
+
329
+ ### Related Prior Work
330
+
331
+ {List any related forge issues, PRs, or CHANGELOG entries that address similar pipeline gaps}
332
+
333
+ ```bash
334
+ # Search forge for related issues
335
+ gh issue list -R RapierCraftStudios/forge --state all --limit 30 --json number,title \
336
+ --jq '[.[] | select(.title | test("{KEYWORDS}"; "i"))]'
337
+ ```
338
+
339
+ {Include results here with links}
340
+ EOF
341
+ )"
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Phase 5: Cross-Reference and Enrich
347
+
348
+ ### 5A: Search for pattern recurrence
349
+
350
+ Check if this same failure pattern has occurred before:
351
+
352
+ ```bash
353
+ # Similar audit findings in forge
354
+ gh issue list -R RapierCraftStudios/forge --state all --label "audit-finding" --limit 50 \
355
+ --json number,title,state --jq '.[] | "\(.number) | \(.title) | \(.state)"'
356
+
357
+ # Same failure point in existing issues
358
+ gh issue list -R RapierCraftStudios/forge --state all --limit 100 --json number,title,body \
359
+ --jq "[.[] | select(.body | contains(\"{FAILURE_POINT}\"))] | .[] | \"\(.number) | \(.title)\""
360
+ ```
361
+
362
+ If this is a **recurring pattern** (same failure point, same defect class, happened 2+ times):
363
+ - Elevate priority by one level (P3→P2, P2→P1)
364
+ - Add label `recurring`
365
+ - Reference all prior occurrences in the issue body
366
+ - Note in the issue that single-instance fixes haven't worked — a structural change may be needed
367
+
368
+ ### 5B: Link back to target repo
369
+
370
+ Comment on the original target repo issue (if it exists and is still open) noting the audit:
371
+
372
+ ```bash
373
+ gh issue comment {NUMBER} {GH_FLAG} --body "$(cat <<'EOF'
374
+ <!-- FORGE:AUDIT -->
375
+ ## Pipeline Audit
376
+
377
+ This issue was audited by Forge. A pipeline improvement issue has been filed:
378
+ - **Forge issue**: RapierCraftStudios/forge#{FORGE_ISSUE_NUMBER}
379
+ - **Failure point**: {FAILURE_POINT}
380
+ - **Root cause**: {1-line summary}
381
+
382
+ The pipeline will be improved to prevent this class of issue in the future.
383
+ EOF
384
+ )"
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Phase 6: Summary
390
+
391
+ Print to the user:
392
+
393
+ ```
394
+ ## Audit Complete
395
+
396
+ **Problem**: {1-line description}
397
+ **Target repo**: {GH_REPO}
398
+ **Artifacts traced**: {N} issues, {N} PRs, {N} comments, {N} review findings
399
+
400
+ ### Failure Point: {CATEGORY}
401
+ **Root cause**: {1-line}
402
+ **Fix target**: commands/{FILE}.md — {section}
403
+
404
+ ### Forge Issue Filed
405
+ {FORGE_ISSUE_URL}
406
+
407
+ ### Evidence Chain
408
+ {Issue} → {Investigation} → {Contract} → {Build} → {PR} → {Review} → {Merge}
409
+ {Mark each link as ✅ (worked correctly) or ❌ (broke here) or ⚠️ (contributing factor)}
410
+ ```