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.
- package/LICENSE +244 -0
- package/README.md +251 -0
- package/bin/forgedock.mjs +232 -0
- package/commands/analytics.md +777 -0
- package/commands/audit-agents.md +410 -0
- package/commands/audit.md +410 -0
- package/commands/autopilot.md +432 -0
- package/commands/cleanup.md +264 -0
- package/commands/deploy-info.md +292 -0
- package/commands/failure-recon.md +375 -0
- package/commands/forge-stats.md +183 -0
- package/commands/geo-audit.md +343 -0
- package/commands/incident-response.md +384 -0
- package/commands/issue.md +506 -0
- package/commands/milestone.md +599 -0
- package/commands/orchestrate.md +1044 -0
- package/commands/pipeline-health.md +2343 -0
- package/commands/qa-sweep.md +237 -0
- package/commands/quality-gate.md +777 -0
- package/commands/review-pr-agents.md +1711 -0
- package/commands/review-pr-staging.md +325 -0
- package/commands/review-pr.md +888 -0
- package/commands/rollback.md +253 -0
- package/commands/security-audit.md +529 -0
- package/commands/sync-ecosystem.md +527 -0
- package/commands/validate.md +131 -0
- package/commands/work-on/build/architect.md +291 -0
- package/commands/work-on/build/context.md +349 -0
- package/commands/work-on/build/implement.md +280 -0
- package/commands/work-on/build/validate.md +292 -0
- package/commands/work-on/build.md +262 -0
- package/commands/work-on/close.md +350 -0
- package/commands/work-on/decompose.md +254 -0
- package/commands/work-on/investigate.md +437 -0
- package/commands/work-on/review.md +245 -0
- package/commands/work-on-monolithic.md +298 -0
- package/commands/work-on.md +1089 -0
- package/docs/CODEX.md +92 -0
- package/docs/WORKFLOW.md +104 -0
- package/package.json +45 -0
- package/scripts/verify-env-vars.sh +201 -0
- package/scripts/verify-host-headers.sh +117 -0
- package/scripts/verify-route-registration.sh +118 -0
- package/scripts/verify-sops-chain.sh +163 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review subcommand — push branch, create PR, invoke /review-pr with --auto-merge
|
|
3
|
+
argument-hint: [issue number] [--repo GH_REPO] [--gh-flag GH_FLAG] [--worktree PATH] [--branch BRANCH] [--base PR_BASE]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# work-on/review — Review & PR Creation Subcommand
|
|
7
|
+
|
|
8
|
+
**Input**: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
**Invoked by**: `work-on.md` Phase 4–5, after `build/validate.md` returns `GATE_PASSED: true`.
|
|
11
|
+
**Output**: Push branch, create PR, invoke /review-pr --auto-merge, return result to caller.
|
|
12
|
+
|
|
13
|
+
**Agent model policy**: Default `model: "sonnet"`. If Sonnet is rate-limited, fall back to `model: "opus"`.
|
|
14
|
+
**NEVER use plan mode (EnterPlanMode).**
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Inputs
|
|
19
|
+
|
|
20
|
+
Parse from $ARGUMENTS:
|
|
21
|
+
- `{NUMBER}` — issue number (required)
|
|
22
|
+
- `--repo {GH_REPO}` — GitHub repo (e.g. `RapierCraftStudios/forge`)
|
|
23
|
+
- `--gh-flag {GH_FLAG}` — gh CLI repo flag (e.g. `-R RapierCraftStudios/forge`)
|
|
24
|
+
- `--worktree {WORKTREE_PATH}` — absolute path to the git worktree
|
|
25
|
+
- `--branch {BRANCH}` — feature branch name (e.g. `feat/my-feature`)
|
|
26
|
+
- `--base {PR_BASE}` — PR target branch (e.g. `milestone/modular-pipeline-architecture` or `staging`)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Phase R0: Load State from GitHub (MANDATORY)
|
|
31
|
+
|
|
32
|
+
Re-read current state before doing anything:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
gh issue view {NUMBER} {GH_FLAG} --json number,title,body,labels,state,milestone
|
|
36
|
+
|
|
37
|
+
# Get builder comment (for branch + commit info)
|
|
38
|
+
gh api repos/{GH_REPO}/issues/{NUMBER}/comments \
|
|
39
|
+
--jq '.[] | select(.body | (contains("FORGE:BUILDER") or contains("ALTERLAB:BUILDER"))) | .body'
|
|
40
|
+
|
|
41
|
+
# Check if PR already exists for this branch
|
|
42
|
+
gh pr list {GH_FLAG} --head {BRANCH} --json number,state,url 2>/dev/null
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Resume check**:
|
|
46
|
+
- If PR already exists AND is OPEN → skip to Phase R3 (invoke /review-pr)
|
|
47
|
+
- If PR already exists AND is MERGED → return `REVIEW_RESULT: status: ALREADY_MERGED`
|
|
48
|
+
- If no `<!-- FORGE:BUILDER -->` or `<!-- ALTERLAB:BUILDER -->` comment exists → EXIT with `REVIEW_RESULT: status: BLOCKED`, blocker: "FORGE:BUILDER comment not found — implement phase may not have completed"
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Phase R1: Pre-Push Ancestry Guard
|
|
53
|
+
|
|
54
|
+
Before pushing, verify the branch contains no merge commits from branches outside the PR base ancestry. This is the final defense against milestone-code-onto-staging contamination.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd {WORKTREE_PATH}
|
|
58
|
+
# Skip if PR_BASE does not exist on origin yet (new branch — no contamination possible)
|
|
59
|
+
if git ls-remote --exit-code origin {PR_BASE} >/dev/null 2>&1; then
|
|
60
|
+
MERGE_COMMITS=$(git log --merges {BRANCH} ^origin/{PR_BASE} 2>/dev/null)
|
|
61
|
+
if [ -n "$MERGE_COMMITS" ]; then
|
|
62
|
+
echo "PRE-PUSH ANCESTRY GUARD FAILED: merge commits from outside {PR_BASE} detected"
|
|
63
|
+
gh issue comment {NUMBER} {GH_FLAG} --body "## Pre-Push Ancestry Guard Failed
|
|
64
|
+
|
|
65
|
+
Branch \`{BRANCH}\` contains merge commits from branches outside the PR base (\`{PR_BASE}\`). Pushing this branch risks contaminating \`{PR_BASE}\` with unapproved code (e.g. milestone code leaking onto staging).
|
|
66
|
+
|
|
67
|
+
**Detected merge commits**:
|
|
68
|
+
\`\`\`
|
|
69
|
+
${MERGE_COMMITS}
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
Do NOT push this branch. Human review required to identify the source of the merge commits and clean the branch history (e.g. via \`git rebase\` to replay only the intended commits onto \`origin/{PR_BASE}\`).
|
|
73
|
+
|
|
74
|
+
<!-- FORGE:PUSH_BLOCKED -->"
|
|
75
|
+
gh issue edit {NUMBER} {GH_FLAG} --add-label "needs-human"
|
|
76
|
+
# Return REVIEW_RESULT: status: BLOCKED — do not push
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
79
|
+
fi
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Phase R1: Push Branch
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cd {WORKTREE_PATH}
|
|
86
|
+
git push origin {BRANCH}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If push fails, retry with `--force-with-lease`:
|
|
90
|
+
```bash
|
|
91
|
+
git push origin {BRANCH} --force-with-lease
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If still fails:
|
|
95
|
+
```bash
|
|
96
|
+
gh issue comment {NUMBER} {GH_FLAG} --body "## Push Failed
|
|
97
|
+
|
|
98
|
+
Branch \`{BRANCH}\` could not be pushed to origin.
|
|
99
|
+
|
|
100
|
+
**Error**: {ERROR_OUTPUT}
|
|
101
|
+
|
|
102
|
+
This may indicate a merge conflict or remote rejection. Human review required.
|
|
103
|
+
|
|
104
|
+
<!-- FORGE:PUSH_FAILED -->"
|
|
105
|
+
|
|
106
|
+
gh issue edit {NUMBER} {GH_FLAG} --add-label "needs-human"
|
|
107
|
+
```
|
|
108
|
+
Return `REVIEW_RESULT: status: BLOCKED`, blocker: "git push failed".
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Phase R2: Create PR
|
|
113
|
+
|
|
114
|
+
### R2A: Determine PR title
|
|
115
|
+
|
|
116
|
+
Derive from issue title:
|
|
117
|
+
- `fix(...):` → `Fix: {description}`
|
|
118
|
+
- `feat(...):` → `Feat: {description}`
|
|
119
|
+
- `refactor(...):` → `Refactor: {description}`
|
|
120
|
+
- `docs(...):` → `Docs: {description}`
|
|
121
|
+
- fallback: use issue title as-is
|
|
122
|
+
|
|
123
|
+
### R2B: Create PR
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
gh pr create {GH_FLAG} \
|
|
127
|
+
--base {PR_BASE} \
|
|
128
|
+
--head {BRANCH} \
|
|
129
|
+
--title "{PR_TITLE}" \
|
|
130
|
+
--body "## Summary
|
|
131
|
+
|
|
132
|
+
{BRIEF_DESCRIPTION_FROM_ISSUE_BODY}
|
|
133
|
+
|
|
134
|
+
## Changes
|
|
135
|
+
|
|
136
|
+
{BULLETED_LIST_OF_KEY_CHANGES_FROM_BUILDER_COMMENT}
|
|
137
|
+
|
|
138
|
+
## Testing
|
|
139
|
+
|
|
140
|
+
{TESTING_CHECKLIST_FROM_BUILDER_COMMENT}
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
Closes #{NUMBER}
|
|
145
|
+
|
|
146
|
+
**Implementation branch**: \`{BRANCH}\`
|
|
147
|
+
**Base**: \`{PR_BASE}\`"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Note**: `Closes #{NUMBER}` documents intent but does NOT auto-close for non-default-branch PRs. The close subcommand handles explicit closure after merge.
|
|
151
|
+
|
|
152
|
+
If PR creation fails because a PR already exists for this branch:
|
|
153
|
+
```bash
|
|
154
|
+
gh pr list {GH_FLAG} --head {BRANCH} --json number,url --jq '.[0]'
|
|
155
|
+
```
|
|
156
|
+
Use the existing PR number and continue.
|
|
157
|
+
|
|
158
|
+
### R2C: Update labels
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
gh issue edit {NUMBER} {GH_FLAG} \
|
|
162
|
+
--add-label "workflow:in-review" \
|
|
163
|
+
--remove-label "workflow:building"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Phase R3: Invoke /review-pr with --auto-merge
|
|
169
|
+
|
|
170
|
+
Re-read the PR number (from creation or from resume check):
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
PR_NUMBER=$(gh pr list {GH_FLAG} --head {BRANCH} --json number --jq '.[0].number')
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Post a progress comment before delegating:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
gh issue comment {NUMBER} {GH_FLAG} --body "## Submitting for Review
|
|
180
|
+
|
|
181
|
+
PR #${PR_NUMBER} created targeting \`{PR_BASE}\`. Invoking /review-pr with --auto-merge.
|
|
182
|
+
|
|
183
|
+
Review will: analyze changes → spawn domain agents → post findings → merge → close issue → clean up worktree.
|
|
184
|
+
|
|
185
|
+
<!-- FORGE:REVIEW_STARTED -->"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Invoke the review command:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
Skill(skill="review-pr", args="{PR_NUMBER} --auto-merge --issue {NUMBER} --base {PR_BASE} --gh-flag {GH_FLAG}")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
/review-pr handles: full domain-agent review → post findings as separate issues (non-blocking) → merge the PR → close the issue → clean up worktree.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Phase R4: Verify Review Outcome
|
|
199
|
+
|
|
200
|
+
After /review-pr returns, verify the outcome:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Check PR state
|
|
204
|
+
gh pr view {PR_NUMBER} {GH_FLAG} --json state,mergedAt --jq '{state: .state, mergedAt: .mergedAt}'
|
|
205
|
+
|
|
206
|
+
# Check issue state
|
|
207
|
+
gh issue view {NUMBER} {GH_FLAG} --json state --jq '.state'
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Cases**:
|
|
211
|
+
- PR MERGED (issue OPEN or CLOSED) → `REVIEW_RESULT: status: COMPLETE` — do NOT close the issue or add labels here; the router will route to `work-on:close` which handles issue closure, label updates, project board, trajectory log, and worktree cleanup.
|
|
212
|
+
- PR NOT MERGED → attempt manual merge:
|
|
213
|
+
```bash
|
|
214
|
+
gh pr merge {PR_NUMBER} {GH_FLAG} --merge --auto
|
|
215
|
+
```
|
|
216
|
+
If merge fails: post comment, add `needs-human`, return `REVIEW_RESULT: status: BLOCKED`
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Output
|
|
221
|
+
|
|
222
|
+
Output this structured block — the routing loop in `work-on.md` will read this result, re-evaluate state, and continue to the next phase. This subcommand is complete; control returns to the router's loop iteration.
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
REVIEW_RESULT:
|
|
226
|
+
status: COMPLETE | ALREADY_MERGED | BLOCKED
|
|
227
|
+
pr_number: {PR_NUMBER}
|
|
228
|
+
pr_url: {PR_URL}
|
|
229
|
+
merged_to: {PR_BASE}
|
|
230
|
+
blocker: {description if status=BLOCKED}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Integration Point in work-on.md
|
|
236
|
+
|
|
237
|
+
This module runs at **Phases 4–5** — after validate returns `GATE_PASSED: true`, before close:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
3F.5 → Validate (by build/validate.md) — gate passed
|
|
241
|
+
4 → [THIS MODULE] Push + PR creation + /review-pr invocation + merge verification
|
|
242
|
+
5 → Close (by close.md) — trajectory, parent tracker, summary
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
/review-pr is invoked within this module (not by the router). The router waits for REVIEW_RESULT before invoking close.md.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "[BENCHMARK] Monolithic work-on — single-prompt pipeline with no Skill sub-phase boundaries"
|
|
3
|
+
argument-hint: [issue number]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /work-on-monolithic — Full Issue Pipeline (Single Prompt)
|
|
7
|
+
|
|
8
|
+
**Input**: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
Orchestrator for the full issue lifecycle: investigate → build → review → merge → close. GitHub issues are the persistent context layer — read existing comments before starting, write structured reports back, use `workflow:*` labels to track state.
|
|
11
|
+
|
|
12
|
+
**Agent model policy**: Default `model: "sonnet"`. Fallback: `model: "opus"` if Sonnet is rate-limited.
|
|
13
|
+
**NEVER use plan mode (EnterPlanMode).**
|
|
14
|
+
|
|
15
|
+
### Compaction Resilience
|
|
16
|
+
|
|
17
|
+
1. Write state to GitHub after EVERY significant step
|
|
18
|
+
2. Re-read GitHub state at the START of each phase (don't rely on in-memory context)
|
|
19
|
+
3. After compaction: re-read issue (body + comments + labels) to reconstruct state
|
|
20
|
+
4. Key principle: A NEW session running this command should pick up where the last left off by reading GitHub state alone
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Pipeline Rules
|
|
25
|
+
|
|
26
|
+
- **NEVER merge to main.** PRs target `staging` (fast lane) or `milestone/{slug}` (feature lane).
|
|
27
|
+
- **`Closes #N` does not auto-close for non-default-branch PRs.** You MUST explicitly `gh issue close`.
|
|
28
|
+
- **Review findings are NOT merge blockers.** They become separate issues.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Multi-Repo Support
|
|
33
|
+
|
|
34
|
+
| Input | Resolves To |
|
|
35
|
+
|-------|-------------|
|
|
36
|
+
| `123` / `#123` | AlterLab (default): `RapierCraftStudios/AlterLab` |
|
|
37
|
+
| `mcp:5` | MCP Server: `RapierCraftStudios/alterlab-mcp-server` |
|
|
38
|
+
| `n8n:12` | n8n Node: `RapierCraftStudios/n8n-nodes-alterlab` |
|
|
39
|
+
|
|
40
|
+
**Context Variables** (set after resolving project):
|
|
41
|
+
|
|
42
|
+
| Variable | AlterLab | MCP | n8n |
|
|
43
|
+
|----------|----------|-----|-----|
|
|
44
|
+
| `GH_REPO` | `RapierCraftStudios/AlterLab` | `RapierCraftStudios/alterlab-mcp-server` | `RapierCraftStudios/n8n-nodes-alterlab` |
|
|
45
|
+
| `REPO_PATH` | `/home/mrdubey/projects/ScraperAPI/alterlab` | `/home/mrdubey/projects/ScraperAPI/alterlab-mcp-server` | `/home/mrdubey/projects/ScraperAPI/n8n-nodes-alterlab` |
|
|
46
|
+
| `STAGING_BRANCH` | `staging` | `main` | `main` |
|
|
47
|
+
| `GH_FLAG` | _(empty)_ | `-R RapierCraftStudios/alterlab-mcp-server` | `-R RapierCraftStudios/n8n-nodes-alterlab` |
|
|
48
|
+
|
|
49
|
+
Satellite repos (MCP, n8n) have no staging — fast-lane PRs go to `main`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Phase 0: Resolve Issue & Load Context
|
|
54
|
+
|
|
55
|
+
### 0A: Parse input
|
|
56
|
+
Extract project prefix and issue number.
|
|
57
|
+
|
|
58
|
+
### 0B: Load issue + existing context
|
|
59
|
+
```bash
|
|
60
|
+
gh issue view {NUMBER} {GH_FLAG} --json number,title,body,labels,state,comments,milestone
|
|
61
|
+
gh api repos/{GH_REPO}/issues/{NUMBER}/comments --jq '.[] | {id: .id, author: .user.login, body: .body}'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Check**: state (closed → STOP), terminal labels (`workflow:merged`/`workflow:invalid` → STOP), existing agent comments (`FORGE:INVESTIGATOR`, `FORGE:CONTRACT`, `FORGE:BUILDER`, `FORGE:TRAJECTORY`), parent tracker status.
|
|
65
|
+
|
|
66
|
+
**Determine resume point**: No comments → Phase 1. Investigation exists + ready-to-build → Phase 3. Builder + no PR → Phase 4. Builder + PR open → Phase 5. PR merged + issue open → close issue.
|
|
67
|
+
|
|
68
|
+
**Classify lane**: Milestone → feature lane (`milestone/{slug}`). No milestone → fast lane (`staging`).
|
|
69
|
+
|
|
70
|
+
**Source branch for review-findings**: Parse `**Code branch**: \`{branch}\`` from body. Branch from there, not main.
|
|
71
|
+
|
|
72
|
+
### 0C: Sync to Project board
|
|
73
|
+
Add issue to project, set Status=In Progress, Lane, Component, Priority, Workflow=Investigating.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Phase 1: Investigation
|
|
78
|
+
|
|
79
|
+
**Skip if**: `<!-- FORGE:INVESTIGATOR -->` exists with `<!-- INVESTIGATION:COMPLETE -->`.
|
|
80
|
+
|
|
81
|
+
### 1A: Set label
|
|
82
|
+
```bash
|
|
83
|
+
gh issue edit {NUMBER} {GH_FLAG} --add-label "workflow:investigating"
|
|
84
|
+
gh issue edit {NUMBER} {GH_FLAG} --remove-label "workflow:ready-to-build,workflow:building,workflow:in-review" 2>/dev/null || true
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 1B: Investigate the issue
|
|
88
|
+
|
|
89
|
+
Mission: Validate whether the issue is real. Assume description is wrong until proven otherwise.
|
|
90
|
+
|
|
91
|
+
**Domain file hints** (start search here):
|
|
92
|
+
|
|
93
|
+
| Domain | Key files |
|
|
94
|
+
|--------|-----------|
|
|
95
|
+
| BILLING | `routers/billing.py`, `core/pricing.py`, `services/credit_service.py` |
|
|
96
|
+
| SCRAPING | `unified_consumer.py`, `queues.py`, `domain_playbooks.json` |
|
|
97
|
+
| AUTH | `core/auth.py`, `routers/auth.py`, `dependencies.py` |
|
|
98
|
+
| DATABASE | `infra/migrations/`, `models/`, `db/` |
|
|
99
|
+
| FRONTEND | `web/src/app/`, `web/src/components/`, `web/src/lib/` |
|
|
100
|
+
| CORTEX | `cortex_client.py`, `routers/cortex.py` |
|
|
101
|
+
| INFRA | `.github/workflows/`, `docker-compose.yml`, `infra/traefik/` |
|
|
102
|
+
|
|
103
|
+
**Steps**: Check right branch → read domain files → verify claims → git blame → determine root cause → identify affected files → validate proposed fixes against full system stack.
|
|
104
|
+
|
|
105
|
+
**Fix-Approach Validation**: If issue proposes a fix, don't adopt it as spec. Trace through target system's middleware, auth, routing.
|
|
106
|
+
|
|
107
|
+
**Domain Context Discovery** (narrow scope, max 5 files):
|
|
108
|
+
```bash
|
|
109
|
+
git log --oneline --all -30 -- {affected_files} | grep -oP '#\d+' | sort -u
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Output format**: Verdict (CONFIRMED/PARTIAL/INVALID), Confidence, Severity, Task Type, What Was Claimed, What We Found, Root Cause, Affected Files, Evidence, Recommendation.
|
|
113
|
+
|
|
114
|
+
### 1C: Post investigation comment
|
|
115
|
+
```bash
|
|
116
|
+
gh issue comment {NUMBER} {GH_FLAG} --body "<!-- FORGE:INVESTIGATOR -->
|
|
117
|
+
<!-- INVESTIGATION:COMPLETE -->
|
|
118
|
+
## Investigation Report
|
|
119
|
+
{report}"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 1D: Update labels
|
|
123
|
+
CONFIRMED/PARTIAL → add `workflow:ready-to-build`, continue to Phase 3.
|
|
124
|
+
INVALID → close issue, add `workflow:invalid`, STOP.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Phase 3: Build
|
|
129
|
+
|
|
130
|
+
**Skip if**: `<!-- FORGE:BUILDER -->` exists.
|
|
131
|
+
|
|
132
|
+
### 3A: Re-read state from GitHub (MANDATORY)
|
|
133
|
+
```bash
|
|
134
|
+
gh issue view {NUMBER} {GH_FLAG} --json body,labels
|
|
135
|
+
gh api repos/{GH_REPO}/issues/{NUMBER}/comments --jq '.[] | select(.body | contains("FORGE:INVESTIGATOR")) | .body'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3B: Classify task type
|
|
139
|
+
|
|
140
|
+
| Signal | Type | Approach |
|
|
141
|
+
|--------|------|----------|
|
|
142
|
+
| UI/UX, feature + web/ files | UI/UX | `frontend-design` skill |
|
|
143
|
+
| Feature + services/ | Backend Feature | Implement directly |
|
|
144
|
+
| Feature + both | Full-Stack | Backend first, then frontend-design |
|
|
145
|
+
| Bug + web/ | Frontend Fix | Direct |
|
|
146
|
+
| Bug + services/ | Backend Fix | Direct |
|
|
147
|
+
| Refactor/docs | Maintenance | Direct |
|
|
148
|
+
|
|
149
|
+
### 3C: Builder Contract (MANDATORY)
|
|
150
|
+
Post `<!-- FORGE:CONTRACT -->` comment with: task type, proposed approach, deliverables table (file/change/why), acceptance criteria, quality considerations.
|
|
151
|
+
|
|
152
|
+
### 3C.5: Context Gathering (max 2 minutes)
|
|
153
|
+
|
|
154
|
+
Surface institutional memory before writing code. For each affected file:
|
|
155
|
+
```bash
|
|
156
|
+
# Recent agent work on these files
|
|
157
|
+
git log --oneline --all -30 -- {affected_files} | grep -oP '#\d+' | sort -u | head -5
|
|
158
|
+
# Check for review findings on same files
|
|
159
|
+
for ISSUE_NUM in {related_issue_numbers}; do
|
|
160
|
+
gh api repos/{GH_REPO}/issues/${ISSUE_NUM}/comments --jq '.[] | select(.body | contains("FORGE:")) | .body' 2>/dev/null | head -20
|
|
161
|
+
done
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Post `<!-- FORGE:CONTEXT -->` comment with findings (or skip if no relevant history).
|
|
165
|
+
|
|
166
|
+
### 3C.6: Architecture Plan
|
|
167
|
+
|
|
168
|
+
For multi-file changes, trace ALL affected code paths before writing code:
|
|
169
|
+
- Map the call chain: entry point → middleware → handler → service → model → response
|
|
170
|
+
- Identify every file that needs to change
|
|
171
|
+
- Order implementation steps to avoid broken intermediate states
|
|
172
|
+
|
|
173
|
+
Post `<!-- FORGE:ARCHITECT -->` comment with the implementation plan.
|
|
174
|
+
|
|
175
|
+
For single-file or trivial changes, skip this step.
|
|
176
|
+
|
|
177
|
+
### 3D: Set building label
|
|
178
|
+
```bash
|
|
179
|
+
gh issue edit {NUMBER} {GH_FLAG} --add-label "workflow:building" --remove-label "workflow:ready-to-build,workflow:investigating"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 3E: Create worktree
|
|
183
|
+
Branch slug from title (lowercase, hyphenated, max 40 chars). Prefix: `fix/` (bugs) or `feat/` (features).
|
|
184
|
+
- Review-finding → branch from `origin/{SOURCE_BRANCH}`
|
|
185
|
+
- Fast lane → branch from `origin/{STAGING_BRANCH}`
|
|
186
|
+
- Feature lane → branch from `origin/milestone/{slug}`
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
cd {REPO_PATH}
|
|
190
|
+
git fetch origin
|
|
191
|
+
BRANCH="fix/{slug}-{NUMBER}"
|
|
192
|
+
git worktree add /home/mrdubey/projects/ScraperAPI/{WT_PREFIX}-worktrees/{BRANCH} -b {BRANCH} origin/{PR_BASE}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 3F: Implement
|
|
196
|
+
Route by task type. Read the investigation report and contract. Implement the fix/feature.
|
|
197
|
+
|
|
198
|
+
### 3F.5: Quality Gate
|
|
199
|
+
Invoke quality-gate on changed files:
|
|
200
|
+
```
|
|
201
|
+
Skill(skill="quality-gate", args="{changed_files} --worktree {WORKTREE_PATH}")
|
|
202
|
+
```
|
|
203
|
+
Fix HIGH/MEDIUM findings. Max 2 iterations. Skip for 1-file config/docs edits.
|
|
204
|
+
|
|
205
|
+
### 3G: Format and verify
|
|
206
|
+
- Python: `black` + `isort` + `py_compile`
|
|
207
|
+
- TypeScript (AlterLab): `prettier --write` + `tsc --noEmit` (BLOCKING if fails)
|
|
208
|
+
- TypeScript (satellite): `npm run build` + `prettier --write`
|
|
209
|
+
|
|
210
|
+
### 3H: Frontend proxy wiring check (MANDATORY)
|
|
211
|
+
All client-side fetch/useSWR/apiFetch must use `/api/...` proxy routes, NEVER `/api/v1/...` directly.
|
|
212
|
+
|
|
213
|
+
### 3I: Deployment completeness check (MANDATORY)
|
|
214
|
+
New env vars must be in: `.env.example` + SOPS `prod.enc.yaml` + `decrypt-secrets.sh` ENV_MAPPING + `env_validation.py` (if API).
|
|
215
|
+
|
|
216
|
+
### 3J: Commit
|
|
217
|
+
Conventional prefix (fix/feat/refactor/docs). Reference #{NUMBER} in the commit message.
|
|
218
|
+
|
|
219
|
+
### 3K: Post implementation comment
|
|
220
|
+
Post `<!-- FORGE:BUILDER -->` with: branch, commit, files changed, approach, changes list, testing checklist.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Phase 4: PR Creation
|
|
225
|
+
|
|
226
|
+
### 4A: Push branch
|
|
227
|
+
```bash
|
|
228
|
+
cd {WORKTREE_PATH} && git push -u origin {BRANCH}
|
|
229
|
+
```
|
|
230
|
+
If fails: try `--force-with-lease`. If still fails: post comment, add `needs-human`, STOP.
|
|
231
|
+
|
|
232
|
+
### 4B: Determine PR target
|
|
233
|
+
No milestone → `staging`. Has milestone → `milestone/{slug}`. NEVER `main`.
|
|
234
|
+
|
|
235
|
+
### 4C: Create PR
|
|
236
|
+
```bash
|
|
237
|
+
gh pr create {GH_FLAG} --base {PR_BASE} --title "{Fix|Feat}: {description} (#{NUMBER})" --body "..."
|
|
238
|
+
```
|
|
239
|
+
Include `Closes #{NUMBER}`.
|
|
240
|
+
|
|
241
|
+
### 4D: Update labels
|
|
242
|
+
```bash
|
|
243
|
+
gh issue edit {NUMBER} {GH_FLAG} --add-label "workflow:in-review" --remove-label "workflow:building"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Phase 5: Auto-Review
|
|
249
|
+
|
|
250
|
+
### 5A: Re-read state from GitHub (MANDATORY)
|
|
251
|
+
### 5B: Invoke /review-pr with --auto-merge
|
|
252
|
+
```
|
|
253
|
+
Skill(skill="review-pr", args="{PR_NUMBER} --auto-merge --issue {NUMBER} --base {PR_BASE} --gh-flag {GH_FLAG}")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 5C: Verify merge and close (recovery)
|
|
257
|
+
- PR MERGED + issue CLOSED → proceed to Phase 6/7
|
|
258
|
+
- PR MERGED + issue OPEN → close issue manually
|
|
259
|
+
- PR NOT MERGED → `gh pr merge --merge {GH_FLAG}`, close issue. If merge fails → post comment, add `needs-human`, STOP.
|
|
260
|
+
|
|
261
|
+
### 5D: Project board update (Workflow=Merged, Status=Done)
|
|
262
|
+
|
|
263
|
+
### 5E: Final issue body update
|
|
264
|
+
Check off remaining items.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Phase 6: Parent Tracker Update (Sub-Issues Only)
|
|
269
|
+
|
|
270
|
+
**Skip if**: Not a sub-issue.
|
|
271
|
+
|
|
272
|
+
Check off this sub-issue in parent body. If ALL sub-issues closed → close parent with `workflow:merged`.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Phase 7: Summary & Trajectory
|
|
277
|
+
|
|
278
|
+
### 7A: Report
|
|
279
|
+
```
|
|
280
|
+
## Done: #{NUMBER} — {TITLE}
|
|
281
|
+
- Investigation: {verdict} ({confidence})
|
|
282
|
+
- Lane: {FAST/FEATURE}
|
|
283
|
+
- Fix: {branch} → PR #{PR_NUMBER} → merged to `{PR_BASE}`
|
|
284
|
+
- Files changed: {count}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 7B: Trajectory Log (MANDATORY)
|
|
288
|
+
Post `<!-- FORGE:TRAJECTORY -->` comment with phase-by-phase results table, decisions, anomalies.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Error Handling
|
|
293
|
+
|
|
294
|
+
- Worktree exists: reuse or clean up
|
|
295
|
+
- PR creation fails: check if branch pushed, if PR already exists
|
|
296
|
+
- Merge conflicts: report to user, do NOT auto-resolve
|
|
297
|
+
- gh CLI fails: check `gh auth status`
|
|
298
|
+
- Label missing: create it
|