forgedock 1.0.5 → 1.0.7

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 (42) hide show
  1. package/README.md +7 -1
  2. package/bin/forgedock.mjs +496 -364
  3. package/bin/labels.json +152 -0
  4. package/commands/audit-agents.md +4 -2
  5. package/commands/autopilot.md +19 -11
  6. package/commands/cleanup.md +27 -12
  7. package/commands/deploy-info.md +36 -17
  8. package/commands/incident-response.md +15 -10
  9. package/commands/issue.md +8 -6
  10. package/commands/milestone.md +97 -48
  11. package/commands/orchestrate.md +109 -65
  12. package/commands/pipeline-health.md +8 -1
  13. package/commands/qa-sweep.md +14 -3
  14. package/commands/review-pr-agents.md +1 -1
  15. package/commands/review-pr-staging.md +129 -23
  16. package/commands/review-pr.md +237 -90
  17. package/commands/rollback.md +26 -7
  18. package/commands/security-audit.md +27 -25
  19. package/commands/sync-ecosystem.md +2 -2
  20. package/commands/work-on/build/architect.md +154 -2
  21. package/commands/work-on/build/context.md +131 -3
  22. package/commands/work-on/build/validate.md +32 -13
  23. package/commands/work-on/decompose.md +2 -0
  24. package/commands/work-on-monolithic.md +9 -5
  25. package/commands/work-on.md +67 -23
  26. package/docs/CONFIG.md +117 -0
  27. package/package.json +2 -1
  28. package/scripts/verify-route-registration.sh +36 -15
  29. package/scripts/verify-sops-chain.sh +18 -0
  30. package/templates/devdocs/README.md +96 -0
  31. package/templates/devdocs/agent/using-forgedock.md +245 -0
  32. package/templates/devdocs/agent/using-github.md +325 -0
  33. package/templates/devdocs/project/architecture.md +122 -0
  34. package/templates/devdocs/project/conventions.md +158 -0
  35. package/templates/devdocs/project/custom-instructions.md +73 -0
  36. package/templates/devdocs/project/glossary.md +84 -0
  37. package/templates/devdocs/project/stack.md +80 -0
  38. package/templates/devdocs/templates/commit-convention.md +147 -0
  39. package/templates/devdocs/templates/issue.md +141 -0
  40. package/templates/devdocs/templates/pull-request.md +115 -0
  41. package/templates/devdocs/templates/review-finding.md +147 -0
  42. package/bin/github-app-manifest.json +0 -24
@@ -18,8 +18,8 @@ Performs comprehensive review of `staging` before merging to `main`. Handles lar
18
18
 
19
19
  ### Diff-First Approach
20
20
  ```bash
21
- git fetch origin main staging
22
- git diff origin/main...origin/staging
21
+ git fetch origin $DEFAULT_BRANCH $STAGING_BRANCH
22
+ git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH
23
23
  ```
24
24
 
25
25
  ### Dynamic Exploration
@@ -29,9 +29,9 @@ From each changed file, follow imports and function calls. Trace data flows acro
29
29
 
30
30
  | Confidence | Criteria | Action |
31
31
  |------------|----------|--------|
32
- | CONFIRMED | Traced full code path, found specific proof | Report as P1 |
33
- | LIKELY | Pattern suggests issue, mitigations might exist | Report as P2 |
34
- | POSSIBLE | Suspicious but couldn't trace fully | Report as P3 |
32
+ | CONFIRMED | Traced full code path, found specific proof | Report as priority:P1 |
33
+ | LIKELY | Pattern suggests issue, mitigations might exist | Report as priority:P2 |
34
+ | POSSIBLE | Suspicious but couldn't trace fully | Report as priority:P3 |
35
35
  | UNFOUNDED | Found correct handling | Do NOT report |
36
36
 
37
37
  ### Severity Decision Tree
@@ -70,6 +70,22 @@ Include ALL findings (CONFIRMED, LIKELY, POSSIBLE). One line per finding, sequen
70
70
 
71
71
  ---
72
72
 
73
+ ## Config Resolution
74
+
75
+ Read `forge.yaml` to resolve branch names before running any commands:
76
+
77
+ ```bash
78
+ CONFIG_FILE="${FORGE_CONFIG:-forge.yaml}"
79
+ GH_REPO=$(yq '.project.owner + "/" + .project.repo' "$CONFIG_FILE")
80
+ GH_FLAG="-R $GH_REPO"
81
+ DEFAULT_BRANCH=$(yq '.branches.default' "$CONFIG_FILE")
82
+ STAGING_BRANCH=$(yq '.branches.staging' "$CONFIG_FILE")
83
+ ```
84
+
85
+ All `$DEFAULT_BRANCH` and `$STAGING_BRANCH` references below are populated from `forge.yaml`.
86
+
87
+ ---
88
+
73
89
  ## Phase 0A: Open Review-Finding Gate (BLOCKING — runs before scope analysis)
74
90
 
75
91
  **Purpose**: Prevent deploying commits that have known, unfixed review findings. The review system catches bugs before merging; this gate ensures the merge path acts on that information.
@@ -77,17 +93,17 @@ Include ALL findings (CONFIRMED, LIKELY, POSSIBLE). One line per finding, sequen
77
93
  **Why this matters**: Review findings are filed before the originating PR merges to staging. Without this gate, a staging→main bundle can include commits with known unfixed bugs — the review system caught the issue, but the deploy path ignored it. This gate closes the gap between issue discovery and deploy execution. <!-- Added: forge#303 -->
78
94
 
79
95
  ```bash
80
- git fetch origin main staging
96
+ git fetch origin $DEFAULT_BRANCH $STAGING_BRANCH
81
97
 
82
98
  # Step 1: Find all PR numbers in the staging→main bundle
83
99
  # These are the PRs whose commits are included in staging but not yet in main
84
- BUNDLE_PRS=$(git log origin/main..origin/staging --oneline \
100
+ BUNDLE_PRS=$(git log origin/$DEFAULT_BRANCH..origin/$STAGING_BRANCH --oneline \
85
101
  | grep -oP '#\d+' \
86
102
  | sort -u \
87
103
  | tr -d '#')
88
104
 
89
105
  # Also extract PR numbers from merge commit subjects (most reliable)
90
- MERGE_PRS=$(git log origin/main..origin/staging --merges --oneline \
106
+ MERGE_PRS=$(git log origin/$DEFAULT_BRANCH..origin/$STAGING_BRANCH --merges --oneline \
91
107
  | grep -oP '(?<=pull request #)\d+' \
92
108
  | sort -u)
93
109
 
@@ -178,10 +194,10 @@ If the gate exits with `RESULT: BLOCK DEPLOY` → **STOP**. Do NOT proceed to Ph
178
194
  ## Phase 0B: Scope Analysis
179
195
 
180
196
  ```bash
181
- git fetch origin main staging
182
- git diff origin/main...origin/staging --stat | tail -20
183
- git diff origin/main...origin/staging --numstat | awk '{add+=$1; del+=$2} END {print "Added:", add, "Deleted:", del, "Total:", add+del}'
184
- git diff origin/main...origin/staging --name-only | sort | uniq
197
+ git fetch origin $DEFAULT_BRANCH $STAGING_BRANCH
198
+ git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH --stat | tail -20
199
+ git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH --numstat | awk '{add+=$1; del+=$2} END {print "Added:", add, "Deleted:", del, "Total:", add+del}'
200
+ git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH --name-only | sort | uniq
185
201
  ```
186
202
 
187
203
  Categorize by service (API, Worker, Web, Shared, Infra). Identify high-risk files (billing, credits, pricing, auth, security, migration, scraper).
@@ -193,26 +209,70 @@ Create review chunks by priority: Billing/Pricing (CRITICAL) → Security/Auth (
193
209
  ## Phase 1: Automated Checks
194
210
 
195
211
  ### 1A: Python Linting
212
+
213
+ Read `forge.yaml → verification.commands.python` for project-specific tool commands:
214
+
196
215
  ```bash
197
- cd services/api && poetry run black --check app/ && poetry run isort --check app/
198
- cd services/worker && poetry run black --check worker/ && poetry run isort --check worker/
216
+ PYTHON_FORMAT=$(awk '/^ commands:/{f=1;next} f && /^[^ \t]/{exit} f' forge.yaml 2>/dev/null | awk '/^ python:/{f=1;next} f && /^ [^ \t]/{exit} f' | grep 'format:' | head -1 | sed "s/.*format: *['\"]//;s/['\"].*//")
217
+ PYTHON_LINT=$(awk '/^ commands:/{f=1;next} f && /^[^ \t]/{exit} f' forge.yaml 2>/dev/null | awk '/^ python:/{f=1;next} f && /^ [^ \t]/{exit} f' | grep 'lint:' | head -1 | sed "s/.*lint: *['\"]//;s/['\"].*//")
218
+
219
+ if [ -n "$PYTHON_FORMAT" ]; then
220
+ eval "$PYTHON_FORMAT" 2>&1 | head -30
221
+ else
222
+ echo "SKIPPED — python.format not configured in verification.commands"
223
+ fi
224
+
225
+ if [ -n "$PYTHON_LINT" ]; then
226
+ eval "$PYTHON_LINT" 2>&1 | head -30
227
+ else
228
+ echo "SKIPPED — python.lint not configured in verification.commands"
229
+ fi
199
230
  ```
200
231
 
201
232
  ### 1B: TypeScript Type-Check + Build (MANDATORY)
233
+
234
+ Read `forge.yaml → verification.commands.typescript` for project-specific tool commands:
235
+
202
236
  ```bash
203
- cd web && npx tsc --noEmit 2>&1
204
- cd web && npx next build 2>&1 | tail -50
237
+ TS_TYPECHECK=$(awk '/^ commands:/{f=1;next} f && /^[^ \t]/{exit} f' forge.yaml 2>/dev/null | awk '/^ typescript:/{f=1;next} f && /^ [^ \t]/{exit} f' | grep 'typecheck:' | head -1 | sed "s/.*typecheck: *['\"]//;s/['\"].*//")
238
+ TS_BUILD=$(awk '/^ commands:/{f=1;next} f && /^[^ \t]/{exit} f' forge.yaml 2>/dev/null | awk '/^ typescript:/{f=1;next} f && /^ [^ \t]/{exit} f' | grep 'build:' | head -1 | sed "s/.*build: *['\"]//;s/['\"].*//")
239
+
240
+ if [ -n "$TS_TYPECHECK" ]; then
241
+ eval "$TS_TYPECHECK" 2>&1
242
+ TS_EXIT=$?
243
+ [ "$TS_EXIT" -ne 0 ] && echo "BLOCKING: typecheck failed — deploy WILL fail"
244
+ else
245
+ echo "SKIPPED — typescript.typecheck not configured in verification.commands"
246
+ TS_EXIT=0
247
+ fi
248
+
249
+ if [ -n "$TS_BUILD" ]; then
250
+ eval "$TS_BUILD" 2>&1 | tail -50
251
+ BUILD_EXIT=$?
252
+ [ "$BUILD_EXIT" -ne 0 ] && echo "BLOCKING: build failed — deploy WILL fail"
253
+ else
254
+ echo "SKIPPED — typescript.build not configured in verification.commands"
255
+ fi
205
256
  ```
206
- `next build` failure is BLOCKING — deploy WILL fail. `tsc` alone misses SSG prerender failures.
257
+ Build failure is BLOCKING — deploy WILL fail. Typecheck alone misses SSG/prerender failures — configure `typescript.build` in `verification.commands`.
207
258
 
208
259
  ### 1C: Python Tests
260
+
261
+ Read `forge.yaml → verification.commands.python.test`:
262
+
209
263
  ```bash
210
- cd services/api && poetry run pytest tests/ -x -q --tb=short 2>&1 | tail -50
264
+ PYTHON_TEST=$(awk '/^ commands:/{f=1;next} f && /^[^ \t]/{exit} f' forge.yaml 2>/dev/null | awk '/^ python:/{f=1;next} f && /^ [^ \t]/{exit} f' | grep 'test:' | head -1 | sed "s/.*test: *['\"]//;s/['\"].*//")
265
+
266
+ if [ -n "$PYTHON_TEST" ]; then
267
+ eval "$PYTHON_TEST" 2>&1 | tail -50
268
+ else
269
+ echo "SKIPPED — python.test not configured in verification.commands"
270
+ fi
211
271
  ```
212
272
 
213
273
  ### 1D: Secrets Scan
214
274
  ```bash
215
- git diff origin/main...origin/staging | grep -iE "(api[_-]?key|secret|password|token|credential)" | grep -vE "(#|//|\.example|placeholder)" | head -20
275
+ git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH | grep -iE "(api[_-]?key|secret|password|token|credential)" | grep -vE "(#|//|\.example|placeholder)" | head -20
216
276
  ```
217
277
 
218
278
  ### 1E: CI Status Gate (BLOCKING)
@@ -290,9 +350,11 @@ Keep ALL findings (CONFIRMED/LIKELY/POSSIBLE). Deduplicate by file:line (keep hi
290
350
 
291
351
  ### 7C: Ensure Labels
292
352
  ```bash
293
- gh label create "review-finding" --color "D93F0B" --force 2>/dev/null
294
- gh label create "needs-validation" --color "FBCA04" --force 2>/dev/null
295
- gh label create "staging-review" --color "1D76DB" --force 2>/dev/null
353
+ # Colors match the canonical ForgeDock label manifest (bin/labels.json).
354
+ # Run `npx forgedock labels setup` to bootstrap all managed labels at once.
355
+ gh label create "review-finding" --color "D93F0B" --description "Defect or improvement found during automated PR review. Managed by ForgeDock." --force -R {GH_REPO} 2>/dev/null
356
+ gh label create "needs-validation" --color "FBCA04" --description "Review finding awaiting human validation. Managed by ForgeDock." --force -R {GH_REPO} 2>/dev/null
357
+ gh label create "staging-review" --color "1D76DB" --description "Finding from a staging branch review before deploy to main. Managed by ForgeDock." --force -R {GH_REPO} 2>/dev/null
296
358
  ```
297
359
 
298
360
  ### 7D: Milestone Detection
@@ -302,7 +364,51 @@ Only assign milestone if reviewing a milestone/* branch. Plain staging reviews g
302
364
  Check for open review-finding issues at same file:line → skip. Closed issues at same location → potential regression (elevate priority).
303
365
 
304
366
  ### 7F: Create Issues
305
- Sequential creation. Title: `Staging Review: {summary} (staging → main)`. Labels: review-finding, needs-validation, staging-review, P1/P2/P3. Body includes: source branch context (`staging`), code context, evidence, validation checklist.
367
+ Sequential creation. Title: `Staging Review: {summary} (staging → main)`. Labels: review-finding, needs-validation, staging-review, priority:P1/priority:P2/priority:P3. Body includes: source branch context (`staging`), code context, evidence, validation checklist.
368
+
369
+ **For each finding** (that passes dedup), create issue:
370
+ ```bash
371
+ ISSUE_NUM=$(gh issue create \
372
+ -R {GH_REPO} \
373
+ --title "chore: [summary] (staging review — PR #${PR_NUMBER})" \
374
+ --label "review-finding,needs-validation,staging-review,{priority}" \
375
+ --body "$(cat <<'ISSUE_EOF'
376
+ ## Problem
377
+
378
+ [One sentence: what bug or issue was found. Where it occurs (`file:line`) and what it causes.]
379
+
380
+ **Source**: PR #[PR_NUMBER] — [TITLE]
381
+ **Confidence**: [CONFIRMED/LIKELY/POSSIBLE]
382
+ **Severity**: [CRITICAL/HIGH/MEDIUM/LOW]
383
+ **Review comment**: [permalink to agent comment]
384
+
385
+ ## Affected Files
386
+
387
+ Files that need changes:
388
+ 1. `[file:line]` — [what needs to change to fix this finding]
389
+
390
+ ## Source Branch Context
391
+
392
+ **Code branch**: `staging`
393
+ **Worktree base**: `origin/staging`
394
+
395
+ > When fixing: `git worktree add ../fix-{slug} -b fix/{slug} origin/staging`
396
+
397
+ ## Code Context
398
+ [10 lines around finding]
399
+
400
+ ## Evidence
401
+ [From agent comment]
402
+
403
+ ## Acceptance Criteria
404
+
405
+ - [ ] Finding validated: VALIDATED / FALSE_POSITIVE / INCONCLUSIVE
406
+ - [ ] If VALIDATED: fix implemented and tested on correct branch
407
+ ISSUE_EOF
408
+ )" --json number --jq '.number')
409
+ ```
410
+
411
+ Labels: `review-finding` + `needs-validation` + `staging-review` + priority (`priority:P1` CONFIRMED, `priority:P2` LIKELY, `priority:P3` POSSIBLE).
306
412
 
307
413
  **No pre-filtering**: Every finding becomes an issue. Validation agents sort out false positives downstream.
308
414