forgedock 1.0.22 → 1.1.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 (184) hide show
  1. package/README.md +255 -211
  2. package/bin/batch-runner.mjs +339 -0
  3. package/bin/cinema.mjs +320 -0
  4. package/bin/demo.mjs +92 -7
  5. package/bin/engine/phases.mjs +168 -0
  6. package/bin/engine/projector.mjs +32 -0
  7. package/bin/engine/reconcile.mjs +11 -0
  8. package/bin/engine/runlog.mjs +79 -0
  9. package/bin/engine/state.mjs +32 -0
  10. package/bin/engine-cli.mjs +222 -0
  11. package/bin/engine.mjs +138 -0
  12. package/bin/forgedock.mjs +896 -1540
  13. package/bin/hooks/interactive-engine.mjs +509 -0
  14. package/bin/hooks/pre-tool-use.mjs +498 -0
  15. package/bin/hooks/subagent-stop-enforce.mjs +197 -0
  16. package/bin/journey.mjs +841 -0
  17. package/bin/registry.mjs +139 -0
  18. package/bin/report.mjs +447 -0
  19. package/bin/runner.mjs +136 -20
  20. package/bin/settings-hook.mjs +346 -0
  21. package/bin/tui.mjs +6 -3
  22. package/commands/adopt.md +4 -1
  23. package/commands/analytics.md +4 -1
  24. package/commands/audit-agents.md +110 -27
  25. package/commands/audit.md +20 -1
  26. package/commands/autopilot.md +84 -12
  27. package/commands/changelog.md +2 -1
  28. package/commands/ci-audit.md +2 -1
  29. package/commands/cleanup.md +161 -1
  30. package/commands/compat-audit.md +2 -1
  31. package/commands/deploy-info.md +63 -4
  32. package/commands/design-bench.md +6 -1
  33. package/commands/design-render-critique-loop.md +2 -1
  34. package/commands/design.md +1 -0
  35. package/commands/diagnose.md +2 -1
  36. package/commands/explain.md +2 -1
  37. package/commands/forge-stats.md +122 -2
  38. package/commands/forgedock-init.md +1 -1
  39. package/commands/geo-audit.md +3 -0
  40. package/commands/incident-response.md +2 -1
  41. package/commands/issue.md +24 -3
  42. package/commands/milestone.md +77 -12
  43. package/commands/optimize.md +2 -1
  44. package/commands/orchestrate/config.md +67 -0
  45. package/commands/orchestrate/phase-1-resolve.md +159 -0
  46. package/commands/orchestrate/phase-2-triage.md +126 -0
  47. package/commands/orchestrate/phase-2.5-synthesis.md +156 -0
  48. package/commands/orchestrate/phase-3-dependency.md +591 -0
  49. package/commands/orchestrate/phase-4-execution.md +962 -0
  50. package/commands/orchestrate/phase-5-cleanup.md +47 -0
  51. package/commands/orchestrate/phase-6-report.md +198 -0
  52. package/commands/orchestrate/safety.md +62 -0
  53. package/commands/orchestrate.md +25 -2027
  54. package/commands/pipeline-health/config.md +34 -0
  55. package/commands/pipeline-health/phase-1-context.md +180 -0
  56. package/commands/pipeline-health/phase-2-metrics.md +1729 -0
  57. package/commands/pipeline-health/phase-3-analyze.md +204 -0
  58. package/commands/pipeline-health/phase-4-proposals.md +117 -0
  59. package/commands/pipeline-health/phase-5-report.md +284 -0
  60. package/commands/pipeline-health/phase-6-summary.md +52 -0
  61. package/commands/pipeline-health.md +25 -2401
  62. package/commands/pipeline-resume.md +24 -1
  63. package/commands/pipeline-status.md +65 -0
  64. package/commands/qa-sweep.md +4 -1
  65. package/commands/quality-gate.md +326 -42
  66. package/commands/replay.md +2 -1
  67. package/commands/review-pr-agents/api.md +135 -0
  68. package/commands/review-pr-agents/auth.md +137 -0
  69. package/commands/review-pr-agents/billing.md +101 -0
  70. package/commands/review-pr-agents/concurrency.md +145 -0
  71. package/commands/review-pr-agents/database.md +103 -0
  72. package/commands/review-pr-agents/frontend.md +89 -0
  73. package/commands/review-pr-agents/infra.md +385 -0
  74. package/commands/review-pr-agents/protocols.md +185 -0
  75. package/commands/review-pr-agents/scraper.md +185 -0
  76. package/commands/review-pr-agents/security.md +406 -0
  77. package/commands/review-pr-agents.md +45 -1722
  78. package/commands/review-pr-staging.md +196 -40
  79. package/commands/review-pr.md +612 -56
  80. package/commands/rollback.md +2 -1
  81. package/commands/scope.md +2 -1
  82. package/commands/security-audit.md +2 -1
  83. package/commands/signal-planner.md +623 -0
  84. package/commands/sync-ecosystem.md +1 -0
  85. package/commands/test-gate.md +17 -1
  86. package/commands/validate.md +2 -1
  87. package/commands/work-on/build/architect.md +28 -0
  88. package/commands/work-on/build/context.md +2 -0
  89. package/commands/work-on/build/implement.md +19 -5
  90. package/commands/work-on/build/validate.md +62 -6
  91. package/commands/work-on/build.md +187 -30
  92. package/commands/work-on/close.md +132 -5
  93. package/commands/work-on/decompose.md +19 -1
  94. package/commands/work-on/investigate.md +117 -2
  95. package/commands/work-on/review.md +48 -4
  96. package/commands/work-on-monolithic.md +8 -2
  97. package/commands/work-on.md +247 -7
  98. package/docs/BRAND.md +16 -5
  99. package/docs/CI.md +2 -2
  100. package/docs/CODEX.md +36 -1
  101. package/docs/CONFIG.md +44 -42
  102. package/docs/FORGE-PROTOCOL.md +15 -1064
  103. package/docs/anthropic-devrel-outreach.md +2 -2
  104. package/docs/articles/command-decomposition-token-savings.md +214 -0
  105. package/docs/articles/model-release-playbook.md +131 -0
  106. package/docs/articles/per-repo-adaptive-scripts-token-savings.md +27 -25
  107. package/docs/claude-breakpoints.json +75 -5
  108. package/docs/design/abc-benchmark.md +1 -1
  109. package/docs/design/design-spec-schema.md +1 -1
  110. package/docs/design/divergent-generation.md +1 -1
  111. package/docs/design/eval-gate-runbook.md +178 -0
  112. package/docs/design/show-hn-draft.md +26 -1
  113. package/docs/design/token-cost-baseline-1298.md +59 -0
  114. package/docs/eval/README.md +117 -0
  115. package/docs/eval/corpus/seed-v1.json +6 -0
  116. package/docs/eval/published/claude-sonnet-4-6-2026-07-04.json +33 -0
  117. package/docs/site/annotations-explained.md +24 -0
  118. package/docs/site/command-learning-path.md +51 -14
  119. package/docs/site/command-reference.md +339 -113
  120. package/docs/site/for-companies.md +95 -0
  121. package/docs/site/forge-annotation-protocol.md +12 -256
  122. package/docs/site/getting-started.md +58 -12
  123. package/docs/site/github-is-the-memory.md +113 -0
  124. package/docs/site/how-it-works.md +3 -13
  125. package/docs/site/index.md +10 -2
  126. package/docs/spec/eval-run-result.md +147 -0
  127. package/docs/spec/forge-protocol-v1.md +441 -18
  128. package/docs/spec/label-state-machine.md +55 -0
  129. package/docs/spec/review-protocol.md +158 -0
  130. package/docs/spec-graph-schema.md +28 -0
  131. package/docs/superpowers/plans/2026-07-03-cinematic-onboarding-tui.md +2339 -0
  132. package/docs/superpowers/plans/2026-07-03-durable-execution-engine.md +1223 -0
  133. package/docs/superpowers/specs/2026-07-03-cinematic-onboarding-tui-design.md +157 -0
  134. package/docs/superpowers/specs/2026-07-03-durable-execution-engine-design.md +194 -0
  135. package/docs/superpowers/specs/2026-07-04-economic-self-governance-design.md +181 -0
  136. package/docs/superpowers/specs/2026-07-04-provenance-trail-design.md +189 -0
  137. package/examples/forgedock-demo/README.md +41 -22
  138. package/examples/forgedock-demo/issues/06-bug-tags-type-validation.md +43 -0
  139. package/examples/forgedock-demo/issues/07-bug-negative-offset-pagination.md +42 -0
  140. package/examples/forgedock-demo/issues/08-bug-patch-mass-assignment.md +49 -0
  141. package/examples/forgedock-demo/issues/09-bug-count-injection.md +47 -0
  142. package/examples/forgedock-demo/issues/10-feature-sort-param.md +39 -0
  143. package/examples/forgedock-demo/issues/11-feature-patch-tags.md +37 -0
  144. package/examples/forgedock-demo/issues/12-feature-bulk-create.md +42 -0
  145. package/examples/forgedock-demo/issues/13-feature-archive-notes.md +46 -0
  146. package/examples/forgedock-demo/issues/14-refactor-extract-title-validation.md +41 -0
  147. package/examples/forgedock-demo/issues/15-refactor-protected-route-flag.md +43 -0
  148. package/examples/forgedock-demo/issues/16-refactor-extract-store.md +45 -0
  149. package/examples/forgedock-demo/issues/17-perf-tags-dedup-set.md +35 -0
  150. package/examples/forgedock-demo/issues/18-perf-remove-redundant-sort.md +37 -0
  151. package/examples/forgedock-demo/issues/19-docs-api-reference-full.md +53 -0
  152. package/examples/forgedock-demo/issues/20-docs-intentional-flaw-convention.md +46 -0
  153. package/examples/forgedock-demo/scripts/smoke.js +18 -1
  154. package/examples/forgedock-demo/src/db.js +36 -11
  155. package/examples/forgedock-demo/src/routes/notes.js +106 -9
  156. package/examples/forgedock-demo/src/server.js +4 -1
  157. package/package.json +12 -4
  158. package/packages/protocol/LICENSE +21 -0
  159. package/packages/protocol/src/cli.js +135 -0
  160. package/packages/protocol/src/emit.js +146 -0
  161. package/packages/protocol/src/index.js +43 -0
  162. package/packages/protocol/src/parse.js +229 -0
  163. package/packages/protocol/src/types.js +171 -0
  164. package/packages/protocol/src/validate.js +122 -0
  165. package/scripts/bench-topology-cost.mjs +372 -0
  166. package/scripts/check-command-docs-drift.sh +198 -0
  167. package/scripts/check-protocol-restatements.sh +176 -0
  168. package/scripts/check-registry/README.md +72 -0
  169. package/scripts/check-registry/manifest.json +6 -0
  170. package/scripts/code-index.sh +454 -0
  171. package/scripts/conformance-check.mjs +168 -0
  172. package/scripts/doctor-pipeline-state.sh +484 -0
  173. package/scripts/eval-gate-baseline.json +17 -0
  174. package/scripts/eval-gate-scorecard.mjs +242 -0
  175. package/scripts/eval-scorecard-aggregator.mjs +252 -0
  176. package/scripts/flaky-quarantine.sh +241 -0
  177. package/scripts/forge-annotation.sh +567 -0
  178. package/scripts/issue-dedup.sh +236 -0
  179. package/scripts/validate-annotation-node.mjs +233 -0
  180. package/scripts/verify-env-vars.sh +18 -2
  181. package/scripts/verify-host-headers.sh +4 -4
  182. package/scripts/verify-route-registration.sh +2 -2
  183. package/scripts/worktree-lifecycle.sh +202 -0
  184. package/templates/devdocs/agent/using-forgedock.md +14 -0
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env bash
2
+ # worktree-lifecycle.sh — Deterministic git worktree create/reuse/cleanup engine
3
+ #
4
+ # Usage:
5
+ # worktree-lifecycle.sh ensure <path> <branch> <base-ref>
6
+ # worktree-lifecycle.sh cleanup <path> <branch>
7
+ #
8
+ # Subcommands:
9
+ #
10
+ # ensure <path> <branch> <base-ref>
11
+ # Idempotent worktree provisioning — replaces the LLM judgment call in
12
+ # work-on.md Phase 3E ("If worktree already exists: verify correct
13
+ # branch, reuse or remove and recreate.").
14
+ #
15
+ # - No worktree registered at <path>:
16
+ # - Local branch <branch> already exists and is NOT checked out
17
+ # in another worktree -> attach it at <path> (preserves any
18
+ # existing commits — covers the "worktree was lost but the
19
+ # branch survived" resume case).
20
+ # - Local branch <branch> already exists and IS checked out in
21
+ # another worktree -> ERROR (exit 1). Two worktrees cannot
22
+ # share one branch; this needs human intervention, not silent
23
+ # repair.
24
+ # - Local branch <branch> does not exist
25
+ # -> git worktree add <path> -b <branch> <base-ref>
26
+ # - A worktree is already registered at <path>:
27
+ # - already on <branch> -> reuse, no destructive action (OK).
28
+ # - on a different branch -> git worktree remove <path> --force,
29
+ # then re-run the "no worktree" logic above.
30
+ #
31
+ # cleanup <path> <branch>
32
+ # Removes the worktree at <path> (tolerant of already-removed state)
33
+ # and force-deletes the local branch <branch> (tolerant of
34
+ # already-deleted state). Matches work-on.md Phase 6E exactly.
35
+ #
36
+ # Exit codes:
37
+ # 0 = success (worktree ensured / cleaned up, including no-op reuse)
38
+ # 1 = error (bad args, branch already checked out elsewhere, git failure)
39
+ #
40
+ # Notes:
41
+ # - Must be invoked from inside the target git repository (any worktree
42
+ # of it — main or linked) OR with <path> pointing at an existing
43
+ # worktree of it. `git worktree`/`git branch` subcommands operate on
44
+ # the whole repository regardless of which worktree anchors the `-C`.
45
+ #
46
+ # Examples:
47
+ # worktree-lifecycle.sh ensure /repo/.claude/worktrees/fix-123 fix/thing-123 origin/staging
48
+ # worktree-lifecycle.sh cleanup /repo/.claude/worktrees/fix-123 fix/thing-123
49
+
50
+ set -euo pipefail
51
+
52
+ # Export universal script environment so per-repo adaptive scripts can
53
+ # delegate back into universal scripts (see devdocs/project/architecture.md
54
+ # → Script Precedence).
55
+ export FORGEDOCK_SCRIPTS
56
+ FORGEDOCK_SCRIPTS="$(cd "$(dirname "$0")" && pwd)"
57
+ export FORGEDOCK_HOME
58
+ FORGEDOCK_HOME="$(cd "$(dirname "$0")/.." && pwd)"
59
+
60
+ usage() {
61
+ echo "Usage:" >&2
62
+ echo " worktree-lifecycle.sh ensure <path> <branch> <base-ref>" >&2
63
+ echo " worktree-lifecycle.sh cleanup <path> <branch>" >&2
64
+ }
65
+
66
+ # ---------------------------------------------------------------------------
67
+ # resolve_repo_anchor [fallback_path]
68
+ #
69
+ # Returns a directory suitable for `git -C <dir> worktree ...` /
70
+ # `git -C <dir> branch ...` — any directory inside the repository works,
71
+ # main or linked worktree alike, as long as it stays valid for the whole
72
+ # operation. Prefers the invoking cwd (matches the calling convention used
73
+ # throughout work-on.md — callers `cd {REPO_PATH}` before invoking scripts)
74
+ # so the anchor is never the same path that `ensure`/`cleanup` may remove
75
+ # mid-operation. Only falls back to `fallback_path` (e.g. the target
76
+ # worktree itself) when cwd is not inside a git repo at all.
77
+ # ---------------------------------------------------------------------------
78
+ resolve_repo_anchor() {
79
+ local fallback="${1:-}"
80
+ if git rev-parse --show-toplevel >/dev/null 2>&1; then
81
+ pwd
82
+ return 0
83
+ fi
84
+ if [ -n "$fallback" ] && [ -d "$fallback" ] && git -C "$fallback" rev-parse --show-toplevel >/dev/null 2>&1; then
85
+ echo "$fallback"
86
+ return 0
87
+ fi
88
+ echo "ERROR: not inside a git repository, and '$fallback' is not a valid worktree to anchor to" >&2
89
+ exit 1
90
+ }
91
+
92
+ if [ "$#" -lt 1 ]; then
93
+ echo "ERROR: subcommand required (ensure|cleanup)" >&2
94
+ usage
95
+ exit 1
96
+ fi
97
+
98
+ SUBCOMMAND="$1"
99
+ shift
100
+
101
+ case "$SUBCOMMAND" in
102
+ ensure)
103
+ if [ "$#" -ne 3 ]; then
104
+ echo "ERROR: ensure requires exactly 3 arguments: <path> <branch> <base-ref>" >&2
105
+ usage
106
+ exit 1
107
+ fi
108
+ WT_PATH="$1"
109
+ BRANCH="$2"
110
+ BASE_REF="$3"
111
+
112
+ if [ -z "$WT_PATH" ] || [ -z "$BRANCH" ] || [ -z "$BASE_REF" ]; then
113
+ echo "ERROR: <path>, <branch>, and <base-ref> must all be non-empty" >&2
114
+ exit 1
115
+ fi
116
+
117
+ ANCHOR=$(resolve_repo_anchor "$WT_PATH")
118
+
119
+ # -----------------------------------------------------------------
120
+ # attach_or_create <path> <branch> <base-ref>
121
+ # Assumes no worktree is currently registered at <path>.
122
+ # -----------------------------------------------------------------
123
+ attach_or_create() {
124
+ local path="$1" branch="$2" base_ref="$3"
125
+
126
+ if git -C "$ANCHOR" show-ref --verify --quiet "refs/heads/$branch"; then
127
+ local existing_wt
128
+ existing_wt=$(git -C "$ANCHOR" worktree list --porcelain | awk -v b="refs/heads/$branch" '
129
+ /^worktree /{wt=$2}
130
+ /^branch /{if ($2==b) print wt}
131
+ ')
132
+ if [ -n "$existing_wt" ]; then
133
+ echo "ERROR: branch '$branch' is already checked out in worktree '$existing_wt' — cannot attach it at '$path'" >&2
134
+ echo " Resolve manually: remove the stale worktree, or choose a different branch/path." >&2
135
+ exit 1
136
+ fi
137
+ echo "Branch '$branch' exists locally — attaching it at '$path' (preserving existing commits)..."
138
+ git -C "$ANCHOR" worktree add -- "$path" "$branch"
139
+ else
140
+ echo "Creating new branch '$branch' from '$base_ref' at '$path'..."
141
+ git -C "$ANCHOR" worktree add -b "$branch" -- "$path" "$base_ref"
142
+ fi
143
+ echo "OK: worktree ready at '$path' on branch '$branch'"
144
+ }
145
+
146
+ ABS_WT_PATH=$(realpath -m "$WT_PATH")
147
+ REGISTERED=$(git -C "$ANCHOR" worktree list --porcelain | awk -v p="$ABS_WT_PATH" '
148
+ /^worktree /{if ($2==p) print $2}
149
+ ')
150
+
151
+ if [ -z "$REGISTERED" ]; then
152
+ # No worktree registered at this path per git. If a stray non-worktree
153
+ # directory already exists there, fail loud rather than silently
154
+ # clobbering unrelated content.
155
+ if [ -e "$WT_PATH" ] && [ ! -e "$WT_PATH/.git" ]; then
156
+ echo "ERROR: '$WT_PATH' exists but is not a registered git worktree — refusing to overwrite it" >&2
157
+ exit 1
158
+ fi
159
+ attach_or_create "$WT_PATH" "$BRANCH" "$BASE_REF"
160
+ else
161
+ CURRENT_BRANCH=$(git -C "$REGISTERED" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
162
+ if [ "$CURRENT_BRANCH" = "$BRANCH" ]; then
163
+ echo "OK: worktree at '$REGISTERED' already on branch '$BRANCH' — reusing (no action)"
164
+ else
165
+ echo "Worktree at '$REGISTERED' is on branch '${CURRENT_BRANCH:-<detached>}', expected '$BRANCH' — removing and recreating..."
166
+ git -C "$ANCHOR" worktree remove "$REGISTERED" --force
167
+ attach_or_create "$WT_PATH" "$BRANCH" "$BASE_REF"
168
+ fi
169
+ fi
170
+ ;;
171
+
172
+ cleanup)
173
+ if [ "$#" -ne 2 ]; then
174
+ echo "ERROR: cleanup requires exactly 2 arguments: <path> <branch>" >&2
175
+ usage
176
+ exit 1
177
+ fi
178
+ WT_PATH="$1"
179
+ BRANCH="$2"
180
+
181
+ if [ -z "$WT_PATH" ] || [ -z "$BRANCH" ]; then
182
+ echo "ERROR: <path> and <branch> must both be non-empty" >&2
183
+ exit 1
184
+ fi
185
+
186
+ ANCHOR=$(resolve_repo_anchor "$WT_PATH")
187
+
188
+ echo "Removing worktree at '$WT_PATH' (if present)..."
189
+ git -C "$ANCHOR" worktree remove "$WT_PATH" --force 2>/dev/null || true
190
+
191
+ echo "Deleting local branch '$BRANCH' (if present)..."
192
+ git -C "$ANCHOR" branch -D -- "$BRANCH" 2>/dev/null || true
193
+
194
+ echo "OK: cleanup complete for '$WT_PATH' / '$BRANCH'"
195
+ ;;
196
+
197
+ *)
198
+ echo "ERROR: unknown subcommand '$SUBCOMMAND' (expected: ensure|cleanup)" >&2
199
+ usage
200
+ exit 1
201
+ ;;
202
+ esac
@@ -228,6 +228,20 @@ When `forge.yaml → repos.satellites` is configured, issue numbers can be prefi
228
228
 
229
229
  ---
230
230
 
231
+ ## Spec Compliance Rules
232
+
233
+ Command specs declare constraints that agents MUST follow. These rules are not enforced at the tool-call level — compliance depends entirely on the agent reading and obeying the spec. Violations are invisible to the pipeline and can silently skip critical safety gates.
234
+
235
+ 1. **Respect `allowed-tools` frontmatter.** When a command spec declares `allowed-tools:` in its YAML frontmatter, NEVER use a tool not in that list. In particular, NEVER use the `Agent` tool when it is not listed — use `Task` or `Skill` instead. The `Agent` tool spawns opaque subprocesses that bypass `allowed-tools` constraints and cannot post structured output.
236
+
237
+ 2. **Execute Phase 0 routing before any other phase.** Commands with Phase 0 routing conditions (e.g., `review-pr.md` routing staging PRs to `review-pr-staging`) MUST evaluate the routing check before proceeding. Skipping routing can bypass entire sub-pipelines including deploy gates, test gates, and structured finding creation.
238
+
239
+ 3. **Look for `FORGE:SPEC_LOADED` markers.** Critical command specs include a `<!-- FORGE:SPEC_LOADED -->` HTML comment near the top. If you are executing a command and do not see this marker in your context, the spec was not loaded — stop and re-read the command file before proceeding.
240
+
241
+ <!-- Added: forge#1383 — agent spec-compliance enforcement -->
242
+
243
+ ---
244
+
231
245
  ## Idempotency Rules
232
246
 
233
247
  - Re-invoking `/work-on` on a completed issue is safe — it reads the terminal label and stops