forgedock 1.1.11 → 1.3.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 (109) hide show
  1. package/README.md +9 -3
  2. package/bin/cli-spawn-shared.mjs +25 -0
  3. package/bin/engine/phases.mjs +178 -28
  4. package/bin/engine/state.mjs +39 -7
  5. package/bin/engine-cli.mjs +85 -3
  6. package/bin/engine.mjs +71 -8
  7. package/bin/forgedock.mjs +322 -20
  8. package/bin/hooks/pre-tool-use.mjs +345 -10
  9. package/bin/init-enrich-api.mjs +12 -4
  10. package/bin/init-enrich-cli.mjs +328 -0
  11. package/bin/init-enrich.mjs +137 -0
  12. package/bin/journey.mjs +116 -15
  13. package/bin/runner.mjs +653 -10
  14. package/commands/adopt.md +1 -1
  15. package/commands/analytics.md +10 -7
  16. package/commands/audit-agents.md +29 -6
  17. package/commands/audit.md +9 -20
  18. package/commands/autopilot.md +52 -78
  19. package/commands/changelog.md +1 -1
  20. package/commands/ci-audit.md +19 -10
  21. package/commands/cleanup.md +1 -1
  22. package/commands/compat-audit.md +1 -1
  23. package/commands/deploy-info.md +1 -1
  24. package/commands/deploy-pr.md +1 -1
  25. package/commands/design-bench.md +1 -1
  26. package/commands/design-render-critique-loop.md +1 -1
  27. package/commands/diagnose.md +1 -1
  28. package/commands/forge-stats.md +6 -5
  29. package/commands/forgedock-init.md +1 -1
  30. package/commands/geo-audit.md +9 -6
  31. package/commands/incident-response.md +15 -5
  32. package/commands/issue.md +302 -15
  33. package/commands/milestone.md +45 -18
  34. package/commands/optimize.md +1 -1
  35. package/commands/orchestrate/phase-1-resolve.md +20 -5
  36. package/commands/orchestrate/phase-4-execution.md +8 -1
  37. package/commands/orchestrate/phase-5-cleanup.md +43 -2
  38. package/commands/orchestrate/phase-6-report.md +1 -0
  39. package/commands/orchestrate.md +1 -1
  40. package/commands/pipeline-health/phase-4-proposals.md +40 -10
  41. package/commands/pipeline-health/phase-5-report.md +140 -13
  42. package/commands/pipeline-health.md +1 -1
  43. package/commands/pipeline-resume.md +1 -1
  44. package/commands/pipeline-status.md +1 -1
  45. package/commands/qa-sweep.md +27 -4
  46. package/commands/recover-orphans.md +1 -1
  47. package/commands/replay.md +16 -2
  48. package/commands/review-pr-agents/protocols.md +4 -0
  49. package/commands/review-pr-agents/spec-cli.md +179 -0
  50. package/commands/review-pr-agents.md +7 -4
  51. package/commands/review-pr-staging.md +44 -15
  52. package/commands/review-pr.md +122 -28
  53. package/commands/rollback.md +15 -5
  54. package/commands/security-audit.md +14 -11
  55. package/commands/signal-planner.md +32 -12
  56. package/commands/spec-doctor.md +1 -1
  57. package/commands/sync-ecosystem.md +54 -11
  58. package/commands/test-gate.md +49 -11
  59. package/commands/upgrade-deps.md +518 -0
  60. package/commands/validate.md +16 -5
  61. package/commands/work-on/build/architect.md +1 -1
  62. package/commands/work-on/build/context.md +1 -1
  63. package/commands/work-on/build/implement.md +2 -2
  64. package/commands/work-on/build/validate.md +64 -2
  65. package/commands/work-on/build.md +10 -2
  66. package/commands/work-on/close.md +1 -1
  67. package/commands/work-on/decompose.md +35 -25
  68. package/commands/work-on/investigate.md +2 -2
  69. package/commands/work-on/remediate.md +1 -1
  70. package/commands/work-on/review.md +5 -3
  71. package/commands/work-on-monolithic.md +1 -1
  72. package/commands/work-on.md +28 -7
  73. package/docs/AIDER.md +264 -0
  74. package/docs/AUTOPILOT-CRON.md +130 -0
  75. package/docs/CI.md +18 -0
  76. package/docs/CONFIG.md +41 -2
  77. package/docs/CURSOR.md +135 -0
  78. package/docs/OPENCODE.md +312 -0
  79. package/docs/demo.gif +0 -0
  80. package/docs/eval/README.md +4 -4
  81. package/docs/launch/show-hn.md +3 -3
  82. package/docs/site/annotations-explained.md +2 -2
  83. package/docs/site/architecture.md +180 -0
  84. package/docs/site/command-reference.md +38 -0
  85. package/docs/site/configuration.md +243 -0
  86. package/docs/site/for-companies.md +4 -4
  87. package/docs/site/forge-annotation-protocol.md +1 -1
  88. package/docs/site/github-is-the-memory.md +2 -2
  89. package/docs/site/how-it-works.md +1 -1
  90. package/docs/site/public/llms-full.txt +380 -0
  91. package/docs/site/public/llms.txt +35 -0
  92. package/docs/spec/review-protocol.md +6 -0
  93. package/docs/spec-graph-schema.md +3 -3
  94. package/package.json +2 -2
  95. package/packages/protocol/README.md +75 -0
  96. package/packages/protocol/src/card.js +114 -0
  97. package/packages/protocol/src/cli.js +4 -77
  98. package/packages/protocol/src/emit.js +14 -3
  99. package/packages/protocol/src/index.js +2 -1
  100. package/packages/protocol/src/parse.js +17 -8
  101. package/packages/protocol/src/types.js +1 -1
  102. package/packages/protocol/src/validate.js +11 -0
  103. package/scripts/check-command-side-effects.sh +261 -0
  104. package/scripts/check-spec-markers.sh +273 -0
  105. package/scripts/classify-lane.sh +29 -7
  106. package/scripts/forge-run.sh +322 -0
  107. package/templates/cross-repo-trigger.yml +282 -0
  108. package/templates/cursor/forge.mdc +148 -0
  109. package/templates/github-actions/forgedock-autopilot.yml +113 -0
@@ -0,0 +1,130 @@
1
+ # Autopilot Cron Mode — GitHub Actions Setup
2
+
3
+ Run [`/autopilot`](../commands/autopilot.md) on a schedule so your repo gets better while you sleep.
4
+
5
+ ---
6
+
7
+ ## Quick Start
8
+
9
+ 1. **Copy the workflow template** into your repo:
10
+
11
+ ```bash
12
+ mkdir -p .github/workflows
13
+ curl -o .github/workflows/forgedock-autopilot.yml \
14
+ https://raw.githubusercontent.com/RapierCraftStudios/ForgeDock/milestone/developer-experience-distribution/templates/github-actions/forgedock-autopilot.yml
15
+ ```
16
+
17
+ 2. **Add your Anthropic API key** as a repository secret:
18
+ - Go to: `Settings → Secrets and variables → Actions → New repository secret`
19
+ - Name: `ANTHROPIC_API_KEY`
20
+ - Value: your key from [console.anthropic.com](https://console.anthropic.com)
21
+
22
+ 3. **Commit the workflow file** — GitHub Actions picks it up automatically.
23
+
24
+ That's it. The workflow runs every Monday at 9 AM UTC in `recon` mode (safe, read-only).
25
+
26
+ ---
27
+
28
+ ## Modes
29
+
30
+ ### `recon` (default — safe)
31
+
32
+ Runs [`/autopilot --recon-only`](../commands/autopilot.md):
33
+
34
+ - Pulls signals: production health, CI/CD, issue backlog, analytics
35
+ - Creates GitHub issues for findings
36
+ - **No branches, no PRs, no code changes**
37
+
38
+ This is the default for scheduled runs. Safe to enable immediately.
39
+
40
+ ### `fix` (explicit opt-in)
41
+
42
+ Runs [`/autopilot --fix --limit N`](../commands/autopilot.md):
43
+
44
+ - Everything in `recon` mode, plus:
45
+ - Picks up the top N open issues and runs `/work-on` on each
46
+ - Creates branches and PRs targeting `staging` (never `main`)
47
+ - **Requires explicit selection** — not available on scheduled runs without editing the workflow
48
+
49
+ To enable `fix` mode on a scheduled run, edit the `Resolve autopilot arguments` step in the workflow and change the default `MODE` to `fix`.
50
+
51
+ To run `fix` mode on demand, use the **Run workflow** button on GitHub Actions and select `fix` from the mode dropdown.
52
+
53
+ ---
54
+
55
+ ## Permissions
56
+
57
+ The workflow requires these GitHub token permissions (already set in the template):
58
+
59
+ | Permission | Required for |
60
+ |------------|-------------|
61
+ | `contents: write` | Creating branches and pushing commits (`fix` mode) |
62
+ | `issues: write` | Creating and labeling issues (both modes) |
63
+ | `pull-requests: write` | Creating PRs (`fix` mode) |
64
+
65
+ `GITHUB_TOKEN` is provided automatically — no extra setup needed.
66
+
67
+ ---
68
+
69
+ ## Adjusting the Schedule
70
+
71
+ The default cron runs every Monday at 9 AM UTC. To change it, edit the `cron` line:
72
+
73
+ ```yaml
74
+ on:
75
+ schedule:
76
+ - cron: '0 9 * * 1' # Monday 9 AM UTC
77
+ # - cron: '0 8 * * *' # Daily at 8 AM UTC
78
+ # - cron: '0 9 1 * *' # Monthly on the 1st
79
+ ```
80
+
81
+ Cron syntax: `minute hour day-of-month month day-of-week`. Use [crontab.guru](https://crontab.guru) to verify expressions.
82
+
83
+ ---
84
+
85
+ ## Changing the Fix Limit
86
+
87
+ The `limit` input controls how many issues are picked up per run in `fix` mode (default: 3). To change the default for manual runs, edit the `default` value under `inputs.limit` in the workflow file.
88
+
89
+ ---
90
+
91
+ ## Non-Interactive Confirmation Bypass
92
+
93
+ `/autopilot` Phase 4B normally requires interactive user confirmation before running `/work-on` on any issues. In GitHub Actions (a non-interactive environment), this gate is bypassed automatically when the `CI` environment variable is `true` — which is always the case in GHA.
94
+
95
+ **The `workflow_dispatch` mode input serves as the human opt-in.** When you select `fix` and click **Run workflow**, you are explicitly approving the fix run. For scheduled runs, the mode embedded in the workflow YAML is your standing approval.
96
+
97
+ This bypass is narrow: it only skips Phase 4B's interactive prompt. All other safety rules in `/autopilot` remain in force — `needs-human` issues are never picked up, milestone issues are excluded, and the `FIX_LIMIT` cap is always enforced.
98
+
99
+ ---
100
+
101
+ ## Cost Estimates
102
+
103
+ | Mode | Typical token usage | Approximate cost |
104
+ |------|--------------------|--------------------|
105
+ | `recon` | ~5,000–15,000 tokens | ~$0.02–$0.05/run |
106
+ | `fix` (1 issue) | ~50,000–150,000 tokens | ~$0.15–$0.45/run |
107
+ | `fix` (3 issues) | ~150,000–450,000 tokens | ~$0.45–$1.35/run |
108
+
109
+ Estimates based on `claude-sonnet-4` pricing ($3.00/M input, $15.00/M output). Actual usage varies by issue complexity and codebase size.
110
+
111
+ To control costs, keep `mode: recon` for scheduled runs and use `fix` mode only on demand.
112
+
113
+ ---
114
+
115
+ ## Frequently Asked Questions
116
+
117
+ **Will this merge code to `main`?**
118
+ No. `/autopilot` (and `/work-on`) never merge to `main`. All PRs target `staging` or a milestone branch. You deploy when ready.
119
+
120
+ **What if an autopilot run fails?**
121
+ The workflow exits with a non-zero status. GitHub sends a notification email (configurable). The run is logged in the Actions tab. No partial state is left — issues are only created after a full recon cycle.
122
+
123
+ **Can I run this in a private repo?**
124
+ Yes. `GITHUB_TOKEN` has full access to your repo. Only the Anthropic API key is external.
125
+
126
+ **Can I use this with Codex / OpenAI models?**
127
+ No. `/autopilot` requires Claude Code CLI, which runs Anthropic models. The `ANTHROPIC_API_KEY` is mandatory.
128
+
129
+ **What does `/autopilot` do if there are open P0 issues?**
130
+ It skips normal recon and immediately routes to `fix` mode targeting the P0 issues, regardless of the selected mode. P0 always takes priority.
package/docs/CI.md CHANGED
@@ -128,6 +128,24 @@ This is not recommended without understanding the security implications.
128
128
 
129
129
  ---
130
130
 
131
+ ## `forgedock run` Execution Backend
132
+
133
+ This guide's `forgedock-review.yml` workflow invokes `/review-pr` directly via the `claude --print` CLI, so it always needs `ANTHROPIC_API_KEY` as shown above — the CLI itself authenticates against your Anthropic account.
134
+
135
+ Separately, `npx forgedock run <command>` (the standalone, non-Claude-Code command runner in `bin/runner.mjs`) has its own **backend selection**, independent of this CI workflow:
136
+
137
+ | Backend | When used | Credential needed |
138
+ |---------|-----------|--------------------|
139
+ | `cli` (via `--backend cli` or `FORGEDOCK_BACKEND=cli`) | Explicit, or auto-selected when a working `claude` CLI is detected on PATH | None — reuses the CLI's own authentication (Pro/Max OAuth or a CLI-managed key) |
140
+ | `api` (via `--backend api` or `FORGEDOCK_BACKEND=api`) | Explicit, or auto-selected fallback when `claude` is not detected | `ANTHROPIC_API_KEY` |
141
+ | `auto` (default) | No `--backend` / `FORGEDOCK_BACKEND` given | Prefers `cli`, falls back to `api` |
142
+
143
+ **When CI still needs `ANTHROPIC_API_KEY` for `forgedock run`**: CI runners generally do not have an interactively-authenticated `claude` CLI (no browser/OAuth flow available in a headless job), so `auto` detection will typically fall back to `api` there anyway. If your CI runner does install and log in the `claude` CLI (e.g. via a headless API-key-based login), you can force `--backend cli` to skip the SDK/API path entirely. Otherwise, keep `ANTHROPIC_API_KEY` configured as a repository secret (see Setup above) and either let `auto` fall back naturally or set `--backend api` / `FORGEDOCK_BACKEND=api` explicitly for a deterministic CI backend regardless of what happens to be on the runner's PATH.
144
+
145
+ `npx forgedock run <command> --dry-run` always reports which backend it resolved to, without making any network call or requiring a key either way.
146
+
147
+ ---
148
+
131
149
  ## Customization
132
150
 
133
151
  ### Skip review for certain PRs
package/docs/CONFIG.md CHANGED
@@ -29,9 +29,12 @@ echo "forge.yaml" >> .gitignore # if your credentials path is sensitive
29
29
  |----------|----------|
30
30
  | `FORGE_NO_MOTION=1` | Same effect as `--fast` — disables animation frames. Color is unaffected. |
31
31
  | `NO_COLOR=1` | Disables ANSI color output only. Motion is unaffected (monochrome choreography). |
32
+ | `FORGEDOCK_INIT_BACKEND=cli\|api\|none\|auto` | Overrides AI-enrichment backend selection for `init` (see below). Default `auto` (or unset) preserves the CLI-first ladder. |
32
33
  | Non-TTY / piped output (or `CI=1`) | Plain sequential log: no color **and** no animation. |
33
34
 
34
- The default (no flags) is the annotated review screen: detection runs, AI enrichment fills in what it can (when an API key is available), and you review the result on a single screen — Enter accepts everything, low-confidence fields are flagged with a `# TODO(forgedock:<field>)` comment if left unedited.
35
+ The default (no flags) is the annotated review screen: detection runs, AI enrichment fills in what it can — using a local, authenticated `claude` CLI when available, otherwise falling back to the Anthropic API when `ANTHROPIC_API_KEY` is set, otherwise skipped — and you review the result on a single screen — Enter accepts everything, low-confidence fields are flagged with a `# TODO(forgedock:<field>)` comment if left unedited.
36
+
37
+ If you have both a local `claude` CLI and `ANTHROPIC_API_KEY` set and want to pin one explicitly instead of letting `init` prefer the CLI, set `FORGEDOCK_INIT_BACKEND=api` (or `=cli`, or `=none` to skip enrichment entirely). This is independent of `FORGEDOCK_BACKEND`, which controls the separate `forgedock run` engine backend.
35
38
 
36
39
  ---
37
40
 
@@ -207,6 +210,9 @@ repos:
207
210
  | `satellites[].local_path` | string | No | Absolute local path to the satellite repo's checkout |
208
211
  | `satellites[].subpaths` | map(string→string) | No | Named sub-directory paths within `local_path`, for monorepo satellites that publish multiple packages. Each key is a logical name; the value is the relative path to that package's root. Used by `/sync-ecosystem` to locate per-package version files and publish workflows. |
209
212
  | `satellites[].billing_enabled` | boolean | No | Set to `true` to run Phase 4 (Financial Integrity) of `/security-audit` against this satellite repo. Mirrors the top-level [`billing.enabled`](#billing-optional) flag but scoped per-satellite. Defaults to `false` when absent. |
213
+ | `satellites[].trigger_on_merge` | boolean | No | When `true`, fires a cross-repo trigger when a PR merges in the parent repo and touches paths matching `trigger_paths`. Set to `false` to disable triggering for this satellite. Defaults to `true` when `trigger_paths` is present; otherwise has no effect until runtime trigger support is configured. |
214
+ | `satellites[].trigger_paths` | list of strings | No | Path glob patterns that constrain when the trigger fires. Uses GitHub Actions glob syntax (same as `on: push: paths:`). The trigger fires only when at least one changed file matches a pattern in this list. When omitted, the trigger fires on every merge (if `trigger_on_merge: true`). |
215
+ | `satellites[].auto_run` | boolean | No | When `true`, automatically invokes `/work-on` on the satellite issue when the cross-repo trigger fires. Requires a running Claude Code session with ForgeDock installed in the satellite repo. Advanced opt-in — defaults to `false`. Do not set to `true` unless a persistent Claude Code session is available in the satellite repo. |
210
216
 
211
217
  **Routing syntax in commands**: `<prefix>:<issue_number>` — e.g., `mcp:5`, `sdk:12`
212
218
 
@@ -606,6 +612,39 @@ Colors are grouped by semantic meaning:
606
612
 
607
613
  ---
608
614
 
615
+ ## `branding` (OPTIONAL)
616
+
617
+ Controls attribution in FORGE annotation comments posted to GitHub issues and PRs by pipeline commands.
618
+
619
+ When `show_attribution` is `true` (the default), every annotation comment (`FORGE:INVESTIGATOR`, `FORGE:CONTRACT`, `FORGE:BUILDER`, `FORGE:TRAJECTORY`, `FORGE:DECOMPOSED`, etc.) ends with a one-line footer:
620
+
621
+ ```
622
+ > Pipeline powered by [ForgeDock](https://github.com/RapierCraftStudios/ForgeDock)
623
+ ```
624
+
625
+ This follows the pattern established by Dependabot, Renovate, and similar tools. It helps new users discover the tooling when they encounter FORGE: annotations in a public thread. Set to `false` to suppress the attribution entirely.
626
+
627
+ ```yaml
628
+ branding:
629
+ show_attribution: true
630
+ ```
631
+
632
+ | Field | Type | Required | Default | Description |
633
+ |-------|------|----------|---------|-------------|
634
+ | `show_attribution` | boolean | No | `true` | When `true`, annotation comments posted by the pipeline include a one-line attribution footer. Set to `false` to suppress it entirely. Opt-out model — attribution is on by default. |
635
+
636
+ **Commands that use this section**: `work-on` (all phases that post FORGE: annotation comments)
637
+
638
+ **Config read pattern** (yq, with default-true fallback):
639
+
640
+ ```bash
641
+ SHOW_ATTRIBUTION=$(yq '.branding.show_attribution // "true"' forge.yaml 2>/dev/null || echo "true")
642
+ [ "$SHOW_ATTRIBUTION" = "false" ] && ATTRIBUTION_LINE="" || ATTRIBUTION_LINE="
643
+ > Pipeline powered by [ForgeDock](https://github.com/RapierCraftStudios/ForgeDock)"
644
+ ```
645
+
646
+ ---
647
+
609
648
  ## GitHub App Install
610
649
 
611
650
  During `npx forgedock`, the installer prompts you to install the ForgeDock GitHub App (`rapiercraft-forgedock`) on your account or org.
@@ -741,7 +780,7 @@ const draft = await detectConfig(process.cwd());
741
780
 
742
781
  Downstream consumers read `field.value` for the raw value and `field.confidence` to decide how to handle it:
743
782
 
744
- - **`init-enrich`** (AI enrichment): passes `low`- and `medium`-confidence fields to the AI backend to raise their confidence; leaves `high`-confidence fields untouched.
783
+ - **`init-enrich`** (AI enrichment): passes `low`- and `medium`-confidence fields to the selected AI backend (a local `claude` CLI when available, otherwise the Anthropic API with `ANTHROPIC_API_KEY`) to raise their confidence; leaves `high`-confidence fields untouched.
745
784
  - **`review-render`** (TUI review screen): shows each field with its source and why; highlights `low`-confidence fields with a `# TODO(forgedock:<field>)` annotation in the generated YAML.
746
785
 
747
786
  ---
package/docs/CURSOR.md ADDED
@@ -0,0 +1,135 @@
1
+ # Cursor Support
2
+
3
+ ForgeDock has a Cursor adapter that lets Cursor Agent mode run the ForgeDock pipeline via shell commands and the `gh` CLI.
4
+
5
+ ## Architecture
6
+
7
+ Shared source:
8
+ - `commands/**/*.md` remains the canonical workflow spec for all runtimes
9
+
10
+ Cursor wrapper:
11
+ - `templates/cursor/forge.mdc` — a static Cursor rules file that instructs Cursor Agent to execute pipeline phases using shell commands, `gh` CLI, and `git`
12
+ - Users install this file into their repo's `.cursor/rules/forge.mdc`
13
+
14
+ This is a static injection model, not a dynamic skill-loading mechanism. The adapter cannot replicate Claude Code's `Skill()` invocation or Codex's installed skill wrappers. Instead, it instructs the agent to read command specs directly from `commands/` and execute them using available terminal tools.
15
+
16
+ ## Install
17
+
18
+ ### Automatic (via `npx forgedock`)
19
+
20
+ If your project already has a `.cursor/` directory, `npx forgedock` will detect it and automatically write `templates/cursor/forge.mdc` to `.cursor/rules/forge.mdc`:
21
+
22
+ ```bash
23
+ npx forgedock
24
+ ```
25
+
26
+ The installer skips this step if `.cursor/rules/forge.mdc` already exists (idempotent — never overwrites customizations).
27
+
28
+ ### Manual
29
+
30
+ Copy the template directly:
31
+
32
+ ```bash
33
+ mkdir -p .cursor/rules
34
+ cp node_modules/forgedock/templates/cursor/forge.mdc .cursor/rules/forge.mdc
35
+ # or, if installed globally:
36
+ cp "$(npx forgedock which-dir)/templates/cursor/forge.mdc" .cursor/rules/forge.mdc
37
+ ```
38
+
39
+ Commit the file to version control so all team members get it:
40
+
41
+ ```bash
42
+ git add .cursor/rules/forge.mdc
43
+ git commit -m "chore: add ForgeDock Cursor rules adapter"
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ### Running the Pipeline
49
+
50
+ Open a Cursor Agent session and describe the pipeline task:
51
+
52
+ ```
53
+ Work on GitHub issue #123 using the ForgeDock pipeline.
54
+ Read commands/work-on.md and follow all phases.
55
+ ```
56
+
57
+ The rules file will instruct Cursor Agent to:
58
+
59
+ 1. Load issue context from GitHub using `gh issue view`
60
+ 2. Follow the Universal Phase Dispatcher in `commands/work-on.md`
61
+ 3. Write FORGE annotations (HTML comments) to issue comments after each phase
62
+ 4. Transition `workflow:*` labels as phases complete
63
+ 5. Continue until a terminal label is set
64
+
65
+ ### Checking Pipeline State
66
+
67
+ ```bash
68
+ # See current workflow state
69
+ gh issue view NUMBER --json labels --jq '[.labels[].name]'
70
+
71
+ # Read existing pipeline annotations
72
+ gh api repos/OWNER/REPO/issues/NUMBER/comments \
73
+ --jq '.[] | select(.body | contains("FORGE:")) | {body: .body[:200]}'
74
+ ```
75
+
76
+ ### Continuing After a Phase
77
+
78
+ Because Cursor Agent mode does not persist between invocations, start a new session and describe the resume:
79
+
80
+ ```
81
+ Resume the ForgeDock pipeline for GitHub issue #123.
82
+ Read commands/work-on.md — it will re-read GitHub state and pick up from the current label.
83
+ ```
84
+
85
+ The pipeline is designed for compaction resilience — every phase re-reads GitHub state at the start, so a new Cursor Agent session picks up exactly where the previous session left off.
86
+
87
+ ## Limitations
88
+
89
+ | Capability | Claude Code | Cursor (this adapter) |
90
+ |------------|-------------|----------------------|
91
+ | Skill loading | Dynamic (`~/.claude/commands/`) | Static (this rules file) |
92
+ | Multi-phase pipeline | Automatic (single continuous session) | Manual (re-invoke agent per phase) |
93
+ | Sub-skill invocation | `Skill("review-pr")` | Read `commands/review-pr.md` directly |
94
+ | Session continuity | Native compaction resilience | Re-read GitHub state each invocation |
95
+ | Tool set | Claude-native (`Bash`, `Read`, `Grep`, `Glob`, `WebFetch`) | Cursor Agent terminal tools |
96
+
97
+ ### Multi-Phase Pipeline
98
+
99
+ The ForgeDock pipeline has 7 phases (investigate → build → review → merge → close → trajectory). Cursor Agent mode does not automatically advance through all phases in a single session. After each phase completes, you will need to start a new agent invocation and ask it to continue.
100
+
101
+ The pipeline's compaction resilience handles this correctly: each invocation re-reads the issue's labels and comments, determines the current phase, and continues from there. No context is lost between sessions.
102
+
103
+ ### Sub-Skill Invocation
104
+
105
+ When the pipeline spec calls `Skill("review-pr")` or `Skill("quality-gate")`, Cursor Agent should read the referenced command spec file directly:
106
+
107
+ ```bash
108
+ cat commands/review-pr.md # Then execute that spec
109
+ cat commands/quality-gate.md
110
+ ```
111
+
112
+ ### Project Board Steps
113
+
114
+ Some pipeline phases (0C: Sync to Project board) call GitHub Projects API operations. These work via `gh` CLI but require the project number and field IDs from `forge.yaml`. Verify your `forge.yaml` has the correct project configuration before running the pipeline.
115
+
116
+ ## Configuration
117
+
118
+ ForgeDock reads `forge.yaml` for project-specific settings:
119
+
120
+ ```bash
121
+ cat forge.yaml # Review before running the pipeline
122
+ ```
123
+
124
+ Key fields used by the pipeline:
125
+ - `project.github.owner` / `project.github.repo` — GitHub repo coordinates
126
+ - `branches.staging` — target branch for fast-lane PRs
127
+ - `branches.main` — default branch
128
+
129
+ ## Reference
130
+
131
+ - `commands/work-on.md` — Full pipeline spec (all phases)
132
+ - `commands/review-pr.md` — PR review spec
133
+ - `commands/quality-gate.md` — Pre-commit quality checks (14+ domains)
134
+ - `docs/FORGE-PROTOCOL.md` — FORGE annotation protocol specification
135
+ - `docs/CODEX.md` — Codex CLI adapter (dynamic skill model)
@@ -0,0 +1,312 @@
1
+ # OpenCode Support
2
+
3
+ ForgeDock has an OpenCode adapter that lets OpenCode run the ForgeDock pipeline
4
+ using its native bash tool and the `gh` CLI.
5
+
6
+ ## Architecture
7
+
8
+ Shared source:
9
+ - `commands/**/*.md` remains the workflow spec for all runtimes
10
+
11
+ Claude Code wrapper:
12
+ - `install.sh` (or `npx forgedock`) symlinks command files into `~/.claude/commands/`
13
+
14
+ Codex wrapper:
15
+ - `install-codex.sh` generates namespaced skills in `~/.codex/skills/`
16
+
17
+ Aider wrapper:
18
+ - `install-aider.sh` writes `~/.aider-forge.md` loaded via `--read`
19
+
20
+ **OpenCode wrapper** (this document):
21
+ - `install-opencode.sh` writes `~/.opencode-forge.md` — a conventions file
22
+ OpenCode loads via the `instructions` field in `opencode.json`
23
+ - `install-opencode.sh` also patches `~/.config/opencode/opencode.json` to
24
+ register ForgeDock pipeline commands as native OpenCode slash commands
25
+ (`/work-on`, `/review-pr`, `/quality-gate`, `/orchestrate`)
26
+
27
+ This is a conventions-file + command-registration architecture. The shared
28
+ `commands/` directory remains the single source of truth — the adapter
29
+ registers entry points that read from it.
30
+
31
+ ## Feasibility
32
+
33
+ OpenCode is the **highest-fidelity** non-Claude Code adapter because:
34
+
35
+ | Capability | Requirement | OpenCode support |
36
+ |-----------|-------------|-----------------|
37
+ | Load instruction files | `instructions` field in `opencode.json` | Native |
38
+ | Execute shell commands | `gh`, `git`, standard tools | Native `Bash` tool |
39
+ | Read/write files | File editing | Native `Read`/`Write`/`Edit` tools |
40
+ | GitHub API | `gh` CLI | Via `Bash("gh ...")` |
41
+ | Multi-step workflows | Follow sequential instructions | Supported |
42
+ | Compaction resilience | Re-read GitHub state at phase start | Supported (via `Bash("gh ...")`) |
43
+ | Native slash commands | `/work-on 967` in TUI | Via `command` config |
44
+ | Tool name parity | Same tool names as Claude Code | Direct — no translation needed |
45
+
46
+ **Key advantage over Aider and Cursor**: OpenCode shares Claude Code's tool
47
+ names (`Bash`, `Read`, `Write`, `Edit`, `Glob`, `Grep`, `WebFetch`) — no
48
+ translation table required for most operations. Pipeline command specs run
49
+ nearly unmodified.
50
+
51
+ ## Install
52
+
53
+ ### Option A — standalone bash installer
54
+
55
+ ```bash
56
+ cd /path/to/forgedock
57
+ ./install-opencode.sh
58
+ ```
59
+
60
+ This writes `~/.opencode-forge.md` with ForgeDock conventions and patches
61
+ `~/.config/opencode/opencode.json` with:
62
+ - `instructions`: adds `~/.opencode-forge.md` to OpenCode's system prompt
63
+ - `command`: registers `/work-on`, `/review-pr`, `/quality-gate`, `/orchestrate`
64
+
65
+ ### Option B — via npx forgedock
66
+
67
+ When `opencode` is detected on your PATH, `npx forgedock` writes
68
+ `~/.opencode-forge.md` and patches `opencode.json` as an additional install
69
+ step. No existing Claude Code files are affected.
70
+
71
+ ```bash
72
+ npx forgedock
73
+ ```
74
+
75
+ ## Usage
76
+
77
+ ### Native slash commands (recommended)
78
+
79
+ After running `install-opencode.sh`, use ForgeDock commands in the OpenCode
80
+ TUI:
81
+
82
+ ```
83
+ /work-on 967
84
+ /review-pr 123
85
+ /quality-gate
86
+ ```
87
+
88
+ Or headlessly via `opencode run`:
89
+
90
+ ```bash
91
+ opencode run --command work-on "967"
92
+ opencode run --command review-pr "123"
93
+ ```
94
+
95
+ ### Manual pipeline loading
96
+
97
+ Read a pipeline command spec directly and follow it:
98
+
99
+ ```
100
+ Read the file /path/to/forgedock/commands/work-on.md and run the pipeline for issue 967.
101
+ ```
102
+
103
+ OpenCode will load the spec and execute each phase using its native tools.
104
+
105
+ ### Phase routing with forge-run.sh
106
+
107
+ `forge-run.sh` emits JSON phase state for the current issue without invoking
108
+ an LLM. Use it to determine the current pipeline phase:
109
+
110
+ ```bash
111
+ Bash("/path/to/forgedock/scripts/forge-run.sh work-on 967 -R OWNER/REPO")
112
+ ```
113
+
114
+ Output (NDJSON):
115
+ ```json
116
+ {"event":"phase_detected","command":"work-on","issue":967,"phase":"no-comments","ts":"..."}
117
+ {"event":"phase_detail","phase":"no-comments","lane":"feature","branch":"milestone/dev-exp","labels":[]}
118
+ {"event":"action_required","phase":"no-comments","action":"No pipeline activity detected. Invoke /work-on 967 to start investigation.","ts":"..."}
119
+ ```
120
+
121
+ ## Tool Translation
122
+
123
+ OpenCode and Claude Code share the same tool names. Most pipeline operations
124
+ run without modification:
125
+
126
+ | Claude Code | OpenCode | Notes |
127
+ |-------------|----------|-------|
128
+ | `Bash("git status")` | `Bash("git status")` | Direct |
129
+ | `Read("path/to/file")` | `Read("path/to/file")` | Direct |
130
+ | `Write("path", content)` | `Write("path", content)` | Direct |
131
+ | `Edit("path", ...)` | `Edit("path", ...)` | Direct |
132
+ | `Glob("**/*.md")` | `Glob("**/*.md")` | Direct |
133
+ | `Grep(pattern, path)` | `Grep(pattern, path)` | Direct |
134
+ | `WebFetch(url)` | `WebFetch(url)` | Direct |
135
+ | `Skill("work-on", args="123")` | Read `commands/work-on.md` | No skill loader — read spec directly |
136
+ | `Skill("review-pr", args="456")` | Read `commands/review-pr.md` | No skill loader — read spec directly |
137
+ | `Agent(...)` / `Task(...)` | Continue the sub-task inline | No sub-agent model; inline it |
138
+
139
+ ### Nested Skill references
140
+
141
+ When a command spec calls `Skill("x")` or references another command, read
142
+ the referenced command spec directly:
143
+
144
+ ```
145
+ # Load the referenced command spec:
146
+ Read("/path/to/forgedock/commands/quality-gate.md")
147
+ ```
148
+
149
+ Map command names to file paths:
150
+ - `Skill("work-on")` → `commands/work-on.md`
151
+ - `Skill("review-pr")` → `commands/review-pr.md`
152
+ - `Skill("quality-gate")` → `commands/quality-gate.md`
153
+ - `Skill("orchestrate")` → `commands/orchestrate.md`
154
+
155
+ ## GitHub Operations
156
+
157
+ All FORGE annotations are written to GitHub issue/PR comments via the `gh`
158
+ CLI. Use `Bash()` for every GitHub operation.
159
+
160
+ ### Label management
161
+
162
+ ```bash
163
+ Bash("gh issue edit 123 -R OWNER/REPO --add-label 'workflow:investigating'")
164
+ Bash("gh issue edit 123 -R OWNER/REPO --remove-label 'workflow:investigating'")
165
+ ```
166
+
167
+ ### Reading existing annotations
168
+
169
+ ```bash
170
+ Bash("gh api repos/OWNER/REPO/issues/123/comments \
171
+ --jq '.[] | select(.body | contains(\"FORGE:INVESTIGATOR\")) | .body'")
172
+ ```
173
+
174
+ ### Writing a FORGE annotation comment
175
+
176
+ For multi-line comment bodies, write the content to a temp file first:
177
+
178
+ ```bash
179
+ # Write comment body to temp file (avoids shell quoting issues)
180
+ Write("/tmp/forge_comment.md", """<!-- FORGE:INVESTIGATOR -->
181
+ ## Investigation Report
182
+
183
+ **Verdict**: CONFIRMED
184
+ ...
185
+ <!-- INVESTIGATION:COMPLETE -->""")
186
+
187
+ Bash("gh issue comment 123 -R OWNER/REPO --body \"$(cat /tmp/forge_comment.md)\"")
188
+ ```
189
+
190
+ ### Creating a PR
191
+
192
+ ```bash
193
+ Write("/tmp/pr_body.md", """## Summary
194
+ ...
195
+
196
+ Closes #967""")
197
+
198
+ Bash("gh pr create -R OWNER/REPO \
199
+ --base milestone/developer-experience-distribution \
200
+ --head feat/opencode-adapter-967 \
201
+ --title 'feat: OpenCode adapter (#967)' \
202
+ --body \"$(cat /tmp/pr_body.md)\"")
203
+ ```
204
+
205
+ ## Worktrees
206
+
207
+ ForgeDock uses git worktrees to isolate branch work. Create one with:
208
+
209
+ ```bash
210
+ Bash("git fetch origin")
211
+ Bash("git worktree add .claude/worktrees/feat-my-feature-123 \
212
+ -b feat/my-feature-123 origin/staging")
213
+ ```
214
+
215
+ Work inside the worktree for all file edits and commits:
216
+
217
+ ```bash
218
+ Read("/path/to/repo/.claude/worktrees/feat-my-feature-123/file.py")
219
+ Edit("/path/to/repo/.claude/worktrees/feat-my-feature-123/file.py", ...)
220
+ Bash("git -C /path/to/repo/.claude/worktrees/feat-my-feature-123 status")
221
+ ```
222
+
223
+ ## FORGE Annotation Protocol
224
+
225
+ Every pipeline stage writes a structured annotation to GitHub. Key rules:
226
+
227
+ 1. **Idempotency**: Check for existing annotations BEFORE starting a phase.
228
+ Do not re-run a completed phase.
229
+ 2. **Compaction resilience**: Write annotations AFTER completing each
230
+ significant step. GitHub is the persistent state layer.
231
+ 3. **Restart partial annotations**: If an annotation exists without its
232
+ `:COMPLETE` sentinel, delete it and restart the phase.
233
+ 4. **Respect label state**: Labels track workflow state. Read and set them
234
+ at each phase boundary.
235
+
236
+ ### Label state machine
237
+
238
+ ```
239
+ workflow:investigating
240
+ → workflow:ready-to-build (investigation complete)
241
+ → workflow:building (build started)
242
+ → workflow:in-review (PR created)
243
+ → workflow:merged (PR merged) [TERMINAL]
244
+
245
+ workflow:invalid [TERMINAL]
246
+ workflow:decomposed [TERMINAL]
247
+ needs-human [TERMINAL]
248
+ ```
249
+
250
+ Stop the pipeline when any terminal label is set.
251
+
252
+ ## Limitations
253
+
254
+ | Capability | Claude Code | OpenCode (this adapter) |
255
+ |------------|-------------|------------------------|
256
+ | Skill loading | Dynamic (`~/.claude/commands/`) | Read `commands/*.md` directly |
257
+ | Native slash commands | `/work-on 967` | `/work-on 967` (via `command` config) |
258
+ | Tool name parity | Native | Direct (same names) |
259
+ | Sub-agent invocation | `Skill("review-pr")` | Read `commands/review-pr.md` directly |
260
+ | Session continuity | Native compaction resilience | Re-read GitHub state each session |
261
+ | Multi-phase pipeline | Automatic (single continuous session) | Supported (GitHub state is persistent) |
262
+
263
+ **Sub-skill invocation**: When a command spec calls `Skill("x")`, OpenCode
264
+ has no native skill loader. Read the referenced command spec file directly
265
+ instead.
266
+
267
+ **Parallel tasks**: When a command spec calls `Agent(...)` or `Task(...)` for
268
+ parallelism (e.g., multi-agent review in `review-pr-agents.md`), execute the
269
+ sub-tasks sequentially. OpenCode runs one agent context at a time.
270
+
271
+ ## Configuration
272
+
273
+ `install-opencode.sh` patches `~/.config/opencode/opencode.json`. Example
274
+ of what is added:
275
+
276
+ ```json
277
+ {
278
+ "instructions": [
279
+ "~/.opencode-forge.md"
280
+ ],
281
+ "command": {
282
+ "work-on": {
283
+ "description": "Run the ForgeDock full issue pipeline (investigate → build → review → merge)",
284
+ "template": "Read /path/to/forgedock/commands/work-on.md and execute the pipeline for issue {{args}}."
285
+ },
286
+ "review-pr": {
287
+ "description": "Run the ForgeDock PR review pipeline",
288
+ "template": "Read /path/to/forgedock/commands/review-pr.md and execute the PR review for PR {{args}}."
289
+ },
290
+ "quality-gate": {
291
+ "description": "Run ForgeDock pre-commit quality checks",
292
+ "template": "Read /path/to/forgedock/commands/quality-gate.md and run all quality gate checks."
293
+ },
294
+ "orchestrate": {
295
+ "description": "Run ForgeDock parallel multi-issue orchestration",
296
+ "template": "Read /path/to/forgedock/commands/orchestrate.md and orchestrate the issues: {{args}}."
297
+ }
298
+ }
299
+ }
300
+ ```
301
+
302
+ Existing config keys (provider, model, etc.) are preserved. ForgeDock only
303
+ adds to the `instructions` array and `command` object — never overwrites.
304
+
305
+ ## Reference
306
+
307
+ - [FORGE Protocol spec](FORGE-PROTOCOL.md) — annotation format, label state machine
308
+ - [Aider adapter](AIDER.md) — parallel adapter reference (Aider uses `/run` translation)
309
+ - [Codex adapter](CODEX.md) — parallel adapter reference (Codex skill model)
310
+ - [Pipeline commands](../commands/) — shared workflow specs (authoritative for all runtimes)
311
+ - [`install-opencode.sh`](../install-opencode.sh) — installer script
312
+ - [`scripts/forge-run.sh`](../scripts/forge-run.sh) — universal shell phase router
package/docs/demo.gif CHANGED
Binary file