forgedock 1.2.0 → 1.4.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 (78) hide show
  1. package/README.md +8 -2
  2. package/bin/batch-runner.mjs +31 -2
  3. package/bin/engine/admission.mjs +294 -0
  4. package/bin/engine/admission.test.mjs +265 -0
  5. package/bin/engine/invariants.mjs +17 -4
  6. package/bin/engine/phases.mjs +358 -42
  7. package/bin/engine/resolve.mjs +256 -0
  8. package/bin/engine/resolve.test.mjs +149 -0
  9. package/bin/engine/state.mjs +31 -7
  10. package/bin/engine-cli.mjs +138 -2
  11. package/bin/engine.mjs +414 -21
  12. package/bin/forgedock.mjs +552 -44
  13. package/bin/hooks/interactive-engine.mjs +50 -24
  14. package/bin/hooks/pre-tool-use.mjs +189 -19
  15. package/bin/journey.mjs +109 -11
  16. package/bin/labels.json +5 -0
  17. package/bin/runner.mjs +321 -10
  18. package/bin/watch-utils.mjs +255 -0
  19. package/commands/cleanup.md +7 -3
  20. package/commands/forge-stats.md +5 -4
  21. package/commands/issue.md +5 -1
  22. package/commands/orchestrate/config.md +41 -1
  23. package/commands/orchestrate/phase-1-resolve.md +234 -8
  24. package/commands/orchestrate/phase-3-dependency.md +27 -18
  25. package/commands/orchestrate/phase-4-execution.md +223 -22
  26. package/commands/qa-sweep.md +17 -0
  27. package/commands/quality-gate.md +6 -6
  28. package/commands/replay.md +16 -2
  29. package/commands/review-pr-agents/spec-cli.md +179 -0
  30. package/commands/review-pr.md +65 -0
  31. package/commands/upgrade-deps.md +523 -0
  32. package/commands/work-on/build/validate.md +61 -1
  33. package/commands/work-on/build.md +9 -1
  34. package/commands/work-on/decompose.md +10 -1
  35. package/commands/work-on/investigate.md +22 -4
  36. package/commands/work-on/remediate.md +2 -0
  37. package/commands/work-on/review.md +40 -1
  38. package/commands/work-on.md +19 -4
  39. package/docs/AIDER.md +264 -0
  40. package/docs/AUTOPILOT-CRON.md +130 -0
  41. package/docs/CONFIG.md +156 -0
  42. package/docs/CURSOR.md +135 -0
  43. package/docs/OPENCODE.md +312 -0
  44. package/docs/demo.gif +0 -0
  45. package/docs/eval/README.md +4 -4
  46. package/docs/launch/show-hn.md +3 -3
  47. package/docs/site/architecture.md +180 -0
  48. package/docs/site/command-reference.md +17 -0
  49. package/docs/site/configuration.md +243 -0
  50. package/docs/site/for-companies.md +4 -4
  51. package/docs/site/forge-annotation-protocol.md +1 -1
  52. package/docs/site/github-is-the-memory.md +2 -2
  53. package/docs/site/how-it-works.md +1 -1
  54. package/docs/site/public/llms-full.txt +380 -0
  55. package/docs/site/public/llms.txt +35 -0
  56. package/docs/spec/eval-run-result.md +8 -4
  57. package/docs/spec/label-state-machine.md +9 -0
  58. package/docs/spec-graph-schema.md +3 -3
  59. package/package.json +3 -3
  60. package/packages/protocol/README.md +75 -0
  61. package/packages/protocol/src/card.js +114 -0
  62. package/packages/protocol/src/cli.js +4 -77
  63. package/packages/protocol/src/emit.js +5 -11
  64. package/packages/protocol/src/html-comment-escape.js +68 -0
  65. package/packages/protocol/src/index.js +3 -1
  66. package/packages/protocol/src/parse.js +19 -11
  67. package/packages/protocol/src/phases.js +105 -0
  68. package/packages/protocol/src/types.js +18 -1
  69. package/packages/protocol/src/validate.js +11 -0
  70. package/scripts/check-admission-parity.mjs +167 -0
  71. package/scripts/check-command-side-effects.sh +376 -0
  72. package/scripts/check-phase-registry-drift.mjs +96 -0
  73. package/scripts/check-spec-markers.sh +274 -0
  74. package/scripts/classify-lane.sh +29 -7
  75. package/scripts/forge-run.sh +353 -0
  76. package/templates/cross-repo-trigger.yml +282 -0
  77. package/templates/cursor/forge.mdc +148 -0
  78. package/templates/github-actions/forgedock-autopilot.yml +113 -0
@@ -0,0 +1,148 @@
1
+ ---
2
+ description: ForgeDock pipeline adapter for Cursor Agent mode
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # ForgeDock Pipeline — Cursor Adapter
7
+
8
+ This file is part of the [ForgeDock](https://github.com/RapierCraftStudios/ForgeDock) autonomous AI development pipeline. It adapts the ForgeDock pipeline for execution within Cursor's Agent mode.
9
+
10
+ ## What ForgeDock Is
11
+
12
+ ForgeDock is a structured development pipeline that uses GitHub as a knowledge graph. Each pipeline phase (investigate → build → review → merge) writes machine-readable annotations (FORGE: HTML comments) to GitHub issue and PR comments. Downstream phases read those annotations to reconstruct context — without relying on conversation history.
13
+
14
+ **Key principle**: GitHub issues/PRs are the persistent context layer. All state lives there, not in this conversation.
15
+
16
+ ## Prerequisites
17
+
18
+ Before running any pipeline phase, verify these tools are available in the terminal:
19
+
20
+ ```bash
21
+ gh auth status # GitHub CLI — authenticated
22
+ git --version # Git — available
23
+ ```
24
+
25
+ ForgeDock command specs live in the repo at `commands/` (if this repo uses ForgeDock) or are available globally after `npx forgedock` install.
26
+
27
+ ## Running the Pipeline
28
+
29
+ ### Start a Pipeline Run
30
+
31
+ To work on a GitHub issue, invoke the `work-on` command spec directly:
32
+
33
+ ```bash
34
+ # Read the full work-on spec first
35
+ cat commands/work-on.md
36
+
37
+ # Then execute the pipeline for issue #NUMBER following the spec exactly
38
+ # Phase sequence: Phase 0 (load) → Phase 1 (investigate) → Phase 3 (build) → Phase 4 (PR) → Phase 5 (review) → Phase 6 (close)
39
+ ```
40
+
41
+ **Critical**: After reading `commands/work-on.md`, follow the Universal Phase Dispatcher section exactly. Execute all phases in sequence — do not stop between phases unless a terminal label is set (`workflow:merged`, `workflow:invalid`, `needs-human`).
42
+
43
+ ### Load Issue Context
44
+
45
+ ```bash
46
+ # Load issue state (always do this first — GitHub is the source of truth)
47
+ gh issue view NUMBER -R OWNER/REPO --json number,title,body,labels,state,comments,milestone
48
+
49
+ # Read existing pipeline annotations
50
+ gh api repos/OWNER/REPO/issues/NUMBER/comments \
51
+ --jq '.[] | {id: .id, author: .user.login, body: .body}'
52
+ ```
53
+
54
+ ### Check Terminal State
55
+
56
+ After every phase, check whether a terminal label is set before continuing:
57
+
58
+ ```bash
59
+ gh issue view NUMBER -R OWNER/REPO --json labels --jq '[.labels[].name]'
60
+ ```
61
+
62
+ **Terminal labels** (stop if any are present):
63
+ - `workflow:merged`
64
+ - `workflow:invalid`
65
+ - `needs-human`
66
+ - `workflow:decomposed`
67
+
68
+ ### Write FORGE Annotations
69
+
70
+ Each pipeline phase writes a structured annotation to GitHub. Use exact format from `docs/FORGE-PROTOCOL.md`:
71
+
72
+ ```bash
73
+ # Post investigation report (Phase 1C)
74
+ gh issue comment NUMBER -R OWNER/REPO --body "<!-- FORGE:INVESTIGATOR -->
75
+ ## Investigation Report
76
+ ...
77
+ <!-- INVESTIGATION:COMPLETE -->"
78
+
79
+ # Post builder report (Phase 3M)
80
+ gh issue comment NUMBER -R OWNER/REPO --body "<!-- FORGE:BUILDER -->
81
+ ## Implementation Complete
82
+ ...
83
+ <!-- FORGE:BUILDER:COMPLETE -->"
84
+ ```
85
+
86
+ ### Git Workflow
87
+
88
+ ```bash
89
+ # Create a worktree for the branch (Phase 3E)
90
+ git fetch origin
91
+ git worktree add .claude/worktrees/BRANCH_NAME -b BRANCH_NAME origin/STAGING_OR_MILESTONE_BRANCH
92
+
93
+ # Commit changes (Phase 3K)
94
+ cd .claude/worktrees/BRANCH_NAME
95
+ git add -u
96
+ git commit -m "feat(scope): description (#NUMBER)"
97
+
98
+ # Push and create PR (Phase 4B-4D)
99
+ git push -u origin BRANCH_NAME
100
+ gh pr create -R OWNER/REPO --base PR_BASE --head BRANCH_NAME \
101
+ --title "Feat: description" --body "..."
102
+ ```
103
+
104
+ ### Labels
105
+
106
+ ForgeDock uses `workflow:*` labels to track pipeline state:
107
+
108
+ ```bash
109
+ # Transition labels as you progress through phases
110
+ gh issue edit NUMBER -R OWNER/REPO --add-label "workflow:investigating"
111
+ gh issue edit NUMBER -R OWNER/REPO --add-label "workflow:ready-to-build" --remove-label "workflow:investigating"
112
+ gh issue edit NUMBER -R OWNER/REPO --add-label "workflow:building" --remove-label "workflow:ready-to-build"
113
+ gh issue edit NUMBER -R OWNER/REPO --add-label "workflow:in-review" --remove-label "workflow:building"
114
+ gh issue edit NUMBER -R OWNER/REPO --add-label "workflow:merged" --remove-label "workflow:in-review"
115
+ ```
116
+
117
+ ## Limitations vs. Claude Code
118
+
119
+ | Capability | Claude Code | Cursor (this adapter) |
120
+ |------------|-------------|----------------------|
121
+ | Skill loading | Dynamic (`~/.claude/commands/`) | Static (this rules file) |
122
+ | Multi-phase pipeline | Automatic (single session) | Manual (re-invoke agent per phase) |
123
+ | Sub-skill invocation | `Skill("review-pr")` | Read `commands/review-pr.md` directly |
124
+ | Session continuity | Native compaction resilience | Re-read GitHub state each invocation |
125
+
126
+ **Multi-phase pipeline**: Cursor Agent mode does not persist between invocations. After each phase completes, you must manually re-invoke the agent for the next phase. The pipeline's compaction resilience (reading GitHub state at the start of each phase) handles this correctly — each new agent invocation re-reads the issue and picks up from the current label state.
127
+
128
+ **Sub-skill invocation**: When the pipeline spec calls `Skill("review-pr")` or similar, read the referenced command spec file directly:
129
+
130
+ ```bash
131
+ cat commands/review-pr.md # Then follow the spec
132
+ ```
133
+
134
+ ## Configuration
135
+
136
+ Your project's ForgeDock configuration is in `forge.yaml`. The pipeline reads `project.github.repo`, `project.github.owner`, and `branches.staging` from this file.
137
+
138
+ ```bash
139
+ cat forge.yaml # Review project configuration
140
+ ```
141
+
142
+ ## Reference
143
+
144
+ - `commands/work-on.md` — Full pipeline spec (investigate → build → review → merge)
145
+ - `commands/review-pr.md` — PR review spec
146
+ - `commands/quality-gate.md` — Pre-commit quality checks
147
+ - `docs/FORGE-PROTOCOL.md` — FORGE annotation protocol reference
148
+ - `docs/CURSOR.md` — Cursor-specific installation and usage guide
@@ -0,0 +1,113 @@
1
+ # ForgeDock Autopilot — Scheduled Cron Workflow Template
2
+ #
3
+ # Copy this file into your repo at:
4
+ # .github/workflows/forgedock-autopilot.yml
5
+ #
6
+ # Required secrets (set in your repo's Settings → Secrets → Actions):
7
+ # ANTHROPIC_API_KEY — Your Anthropic API key (https://console.anthropic.com)
8
+ #
9
+ # GITHUB_TOKEN is provided automatically by GitHub Actions.
10
+ #
11
+ # See docs/AUTOPILOT-CRON.md for full setup guide.
12
+
13
+ name: ForgeDock Autopilot
14
+
15
+ on:
16
+ schedule:
17
+ # Every Monday at 9 AM UTC — adjust to your preferred cadence
18
+ - cron: '0 9 * * 1'
19
+
20
+ workflow_dispatch:
21
+ # Manual trigger — allows you to run autopilot on demand with custom options
22
+ inputs:
23
+ mode:
24
+ description: 'Run mode: recon (safe, read-only) or fix (creates branches + PRs)'
25
+ required: false
26
+ default: 'recon'
27
+ type: choice
28
+ options:
29
+ - recon
30
+ - fix
31
+ limit:
32
+ description: 'Max issues to fix per run (fix mode only)'
33
+ required: false
34
+ default: '3'
35
+ type: string
36
+
37
+ jobs:
38
+ autopilot:
39
+ name: Run /autopilot
40
+ runs-on: ubuntu-latest
41
+
42
+ permissions:
43
+ contents: write # Required: create branches, push commits (fix mode)
44
+ issues: write # Required: create and label issues
45
+ pull-requests: write # Required: create PRs (fix mode)
46
+
47
+ steps:
48
+ - name: Checkout repository
49
+ uses: actions/checkout@v4
50
+ with:
51
+ # Fetch full history so git log commands in /autopilot work correctly
52
+ fetch-depth: 0
53
+
54
+ - name: Set up Node.js
55
+ uses: actions/setup-node@v4
56
+ with:
57
+ node-version: 24
58
+
59
+ - name: Install ForgeDock
60
+ run: npx --yes forgedock
61
+
62
+ - name: Install Claude Code CLI
63
+ run: npm install -g @anthropic-ai/claude-code
64
+
65
+ - name: Resolve autopilot arguments
66
+ id: args
67
+ env:
68
+ # Pass workflow_dispatch inputs through env: indirection rather than
69
+ # interpolating ${{ inputs.* }} directly into the run: script text.
70
+ # inputs.limit is free-text (type: string) — splicing it straight into
71
+ # the shell would let a crafted value break out of the assignment and
72
+ # inject arbitrary commands. inputs.mode is a `type: choice` enum and
73
+ # isn't exploitable the same way, but is routed the same way for
74
+ # consistency/defense-in-depth.
75
+ MODE_INPUT: ${{ inputs.mode }}
76
+ LIMIT_INPUT: ${{ inputs.limit }}
77
+ run: |
78
+ # On scheduled runs: always recon mode (safe default)
79
+ # On workflow_dispatch: use the selected mode input
80
+ if [ "${{ github.event_name }}" = "schedule" ]; then
81
+ MODE="recon"
82
+ LIMIT="3"
83
+ else
84
+ MODE="$MODE_INPUT"
85
+ LIMIT="$LIMIT_INPUT"
86
+ fi
87
+
88
+ if [ "$MODE" = "fix" ]; then
89
+ ARGS="--fix --limit $LIMIT"
90
+ else
91
+ ARGS="--recon-only"
92
+ fi
93
+
94
+ echo "mode=$MODE" >> "$GITHUB_OUTPUT"
95
+ echo "args=$ARGS" >> "$GITHUB_OUTPUT"
96
+ echo "Autopilot mode: $MODE (args: $ARGS)"
97
+
98
+ - name: Run /autopilot
99
+ env:
100
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
101
+ GH_TOKEN: ${{ github.token }}
102
+ # CI=true tells /autopilot Phase 4B to skip the interactive confirmation
103
+ # gate. The workflow_dispatch mode=fix input serves as the human opt-in.
104
+ CI: "true"
105
+ # AUTOPILOT_ARGS is derived (one step upstream) from the free-text
106
+ # inputs.limit workflow_dispatch input. Route it through env:
107
+ # indirection here too — splicing it directly via ${{ }} into this
108
+ # run: block would reopen the same script-injection vector one hop
109
+ # later, in a step that also carries ANTHROPIC_API_KEY/GH_TOKEN.
110
+ AUTOPILOT_ARGS: ${{ steps.args.outputs.args }}
111
+ run: |
112
+ claude --dangerously-skip-permissions \
113
+ -p "/autopilot $AUTOPILOT_ARGS"