Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: migrate the prompt defaults off the glab flags glab rejects (#4685)

[._.]/ Adam Eivycae4c12d233c
diff --git a/server/services/gitlab.glabFlags.test.js b/server/services/gitlab.glabFlags.test.js
index 5ce1761a1f..ed8d3e7f24 100644
--- a/server/services/gitlab.glabFlags.test.js
+++ b/server/services/gitlab.glabFlags.test.js
@@ -66,16 +66,19 @@ const PATTERNS = [
['glab mr list --state argv', ARGV_MR_LIST_STATE],
];
-// Stored per-install prompt DEFAULTS, which cannot be corrected by editing the
-// string alone: each edit needs a PROMPT_VERSIONS bump plus the outgoing body
-// preserved in PREVIOUS_DEFAULT_PROMPTS, or other installs never pick the fix up
-// (CLAUDE.md "Distribution model"). Tracked in issue #4685 — removing an entry
-// here is the whole acceptance criterion for that work.
-//
// `previousDefaults.js` is frozen history: those strings must keep matching what
-// older installs actually stored, so they stay listed permanently.
+// older installs actually stored, byte for byte, or the auto-upgrade path stops
+// recognizing a stored prompt as non-customized and pins the stale body on that
+// install forever. It is the one file that must keep spelling the traps.
+//
+// `prompts.js` used to sit here too — a stored prompt default cannot be corrected
+// by editing the string alone, since each edit needs a PROMPT_VERSIONS bump plus
+// the outgoing body preserved in PREVIOUS_DEFAULT_PROMPTS (CLAUDE.md
+// "Distribution model"). Issue #4685 did that migration, so the current defaults
+// are now held to the same standard as every other server source. Prose in a
+// prompt body that merely EXPLAINS a trap still reads as an instance of it —
+// name the flag without re-spelling the subcommand ahead of it on the same line.
const EXEMPT = new Map([
- ['services/taskPromptDefaults/prompts.js', 'stored prompt defaults — needs a PROMPT_VERSIONS bump (#4685)'],
['services/taskPromptDefaults/previousDefaults.js', 'frozen historical snapshots — must match what older installs stored'],
]);
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index eaeee7211c..cc9ba8facd 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -198,13 +198,17 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(current).toContain('THROWAWAY WORKTREE');
// Rebasing the bot branch rewrites its commits, so the push needs a lease, not a ban.
expect(current).toContain('--force-with-lease');
- expect(PROMPT_VERSIONS['dependency-updates']).toBe(3);
+ // A FLOOR, not a pin — v3 introduced bot-PR triage and later revisions keep it.
+ expect(PROMPT_VERSIONS['dependency-updates']).toBeGreaterThanOrEqual(3);
+ // Located by CONTENT, not array position: later revisions append their own
+ // outgoing bodies after this one, and `findLast` picks the newest body that
+ // still predates bot-PR triage (index 0 is the older pre-genericization one).
const previous = PREVIOUS_DEFAULT_PROMPTS['dependency-updates'];
- const v2 = previous[previous.length - 1];
+ const v2 = previous.findLast((prompt) => !prompt.includes('dependabot'));
// The outgoing v2 default knew nothing about bot PRs and is preserved verbatim so
// installs holding it are recognized and upgraded.
- expect(v2).not.toContain('dependabot');
+ expect(v2).toBeDefined();
expect(v2).toContain('Only update one major version bump at a time');
expect(v2).not.toBe(current);
});
@@ -257,9 +261,12 @@ describe('taskPromptDefaults integrity snapshot', () => {
['claim-issue', 16],
['claim-issue-gitlab', 15],
['claim-issue-jira', 12],
- ])('%s v%d names the antigravity reviewer\'s `agy` binary, preserving the pre-`agy` default', (key, version) => {
+ ])('%s (v%d onward) names the antigravity reviewer\'s `agy` binary, preserving the pre-`agy` default', (key, version) => {
const current = DEFAULT_TASK_PROMPTS[key];
- expect(PROMPT_VERSIONS[key]).toBe(version);
+ // A FLOOR, not a pin: the paired number is the version that INTRODUCED the
+ // property; it must keep holding through every later bump of that key, so an
+ // unrelated revision cannot fail a property it left intact.
+ expect(PROMPT_VERSIONS[key]).toBeGreaterThanOrEqual(version);
// EVERY mention of the slug carries the binary — a bare `antigravity`
// anywhere in the body is the regression.
expect(current).not.toMatch(/`antigravity`(?! \(CLI binary: `agy`\))/);
@@ -290,9 +297,10 @@ describe('taskPromptDefaults integrity snapshot', () => {
['claim-issue', 16],
['claim-issue-gitlab', 15],
['claim-issue-jira', 12],
- ])('%s v%d reviews locally before it opens the PR/MR', (key, version) => {
+ ])('%s (v%d onward) reviews locally before it opens the PR/MR', (key, version) => {
const current = DEFAULT_TASK_PROMPTS[key];
- expect(PROMPT_VERSIONS[key]).toBe(version);
+ // A FLOOR, not a pin — see the note on the first table above.
+ expect(PROMPT_VERSIONS[key]).toBeGreaterThanOrEqual(version);
// The configured list is split by WHERE a reviewer can run.
expect(current).toContain('LOCAL reviewers');
@@ -559,4 +567,70 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(DEFAULT_TASK_PROMPTS['claim-issue']).toContain('--limit 500');
expect(DEFAULT_TASK_PROMPTS['claim-issue']).not.toContain('--limit 100');
});
+ // #4685: `glab issue list -F json` is accepted, IGNORED, and answers with the
+ // human table at exit 0 (`-F` is `--output-format` there, a different flag from
+ // `--output`), and `glab mr list --state <x>` does not exist at all. The tree
+ // guard in gitlab.glabFlags.test.js bans both spellings everywhere — including
+ // these bodies, which it used to exempt. What it cannot check is the migration:
+ // a stored prompt only picks the fix up when its PROMPT_VERSIONS entry moved AND
+ // its outgoing body is recognizable, so pin both here.
+ //
+ // claim-issue-gitlab is router-reached (no DEFAULT_TASK_INTERVALS entry), so
+ // taskSchedule.test.js's auto-upgrade walk never covers it.
+ it('claim-issue-gitlab v16 asks glab for JSON the one way that works, preserving the outgoing default', () => {
+ const current = DEFAULT_TASK_PROMPTS['claim-issue-gitlab'];
+ expect(current).toContain('glab issue list --per-page 100 --output json');
+ expect(PROMPT_VERSIONS['claim-issue-gitlab']).toBeGreaterThanOrEqual(16);
+
+ // The trap alone does not identify the OUTGOING body — every one of the 15
+ // historical claim-issue-gitlab defaults carries it, so a `find` on the flag
+ // would pass on a v1 body even if the v15 snapshot were never appended.
+ // `{issueExcludeLabels}` arrived in v15 and is what makes the match unique.
+ const previous = PREVIOUS_DEFAULT_PROMPTS['claim-issue-gitlab'];
+ const withBoth = previous.filter(
+ (prompt) => prompt.includes('glab issue list --per-page 100 -F json') && prompt.includes('{issueExcludeLabels}'),
+ );
+ expect(withBoth).toHaveLength(1);
+ // …and it is the newest entry, which is where an append lands.
+ expect(withBoth[0]).toBe(previous[previous.length - 1]);
+ expect(withBoth[0]).not.toBe(current);
+ });
+
+ // dependency-updates Phase 1 skipped its whole bot-PR triage on GitLab repos:
+ // the MR listing it depends on exited 1 with `Unknown flag: --state`.
+ it('dependency-updates v4 selects MR state the way glab does, preserving the outgoing default', () => {
+ const current = DEFAULT_TASK_PROMPTS['dependency-updates'];
+ expect(current).toContain('glab mr list --per-page 100 --page <n>');
+ expect(current).toContain('glab mr list --search "<package>"');
+ expect(PROMPT_VERSIONS['dependency-updates']).toBeGreaterThanOrEqual(4);
+
+ const outgoing = PREVIOUS_DEFAULT_PROMPTS['dependency-updates'].find(
+ (prompt) => prompt.includes('--state opened --search "<package>"'),
+ );
+ expect(outgoing).toBeDefined();
+ expect(outgoing).not.toBe(current);
+ });
+
+ // pr-reviewer-security / pr-reviewer-review carried the same wrong flags but
+ // take NO bump and NO preserved body: they are PIPELINE STAGE keys, read live
+ // from this catalog by getStagePrompt (taskPromptService.js) and never
+ // persisted, so an edit reaches every install on the next dispatch. Same
+ // treatment code-reviewer-review / code-reviewer-implement get; the versioned
+ // key for that pipeline is its SCHEDULE key, `pr-reviewer`.
+ //
+ // This pins the CONSTANTS only. The behavior it depends on — stage resolution
+ // ignoring stored state — is pinned in taskPromptService.test.js, which hands
+ // getStagePrompt an interval carrying a stale persisted prompt and asserts the
+ // catalog body still wins. Keep both: this catches a stray PROMPT_VERSIONS
+ // entry, that one catches a change in how a stage body is resolved.
+ it.each([
+ 'pr-reviewer-security',
+ 'pr-reviewer-review',
+ 'code-reviewer-review',
+ 'code-reviewer-implement',
+ ])('%s is an unversioned pipeline stage body, not a stored prompt', (stageKey) => {
+ expect(DEFAULT_TASK_PROMPTS[stageKey]).toBeTypeOf('string');
+ expect(PROMPT_VERSIONS[stageKey]).toBeUndefined();
+ expect(PREVIOUS_DEFAULT_PROMPTS[stageKey]).toBeUndefined();
+ });
});
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 74239b2196..32a4316117 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -6,7 +6,7 @@
"performance": "672bd3958b12afb0f382bcebb6dc3b33",
"accessibility": "372916803f32b82da38a5b2130a54baf",
"console-errors": "2b6ed595287f0742bed9ecba6788afe6",
- "dependency-updates": "7ed05444e2602f4895bdd1e5e0edcaa8",
+ "dependency-updates": "5c33d8c5c2106c978855bb2d00b9d79c",
"documentation": "b375f95ae2274f03d06ba5ceff5705d8",
"ui-bugs": "def9ad96bd74ab397233f234d79a1974",
"mobile-responsive": "16d8e7f63a673a2de48994c0ac08ef3d",
@@ -16,7 +16,7 @@
"feature-ideas": "d3282f16da29efe2d53595b3b34778bc",
"plan-task": "2012a0da54bdbf441911a0eed05f0cb1",
"claim-issue": "5bcaf3230a7a46ee039404943feab187",
- "claim-issue-gitlab": "eed428fc96a8a58ee94d38e6e4896932",
+ "claim-issue-gitlab": "ed2c2c9c8cd6297340b3a92666cb2c5a",
"claim-issue-jira": "9d782972b20d6b721eb44d0673315cad",
"code-reviewer-review": "1cd13ee5142d130f95cc390098d0f278",
"code-reviewer-implement": "ab2c3e16d54e195bdf856574b7702042",
@@ -31,8 +31,8 @@
"branch-reconcile": "16479f4b64395103fd222dc9608830b1",
"issue-reconcile": "6f33db6ad0b57c36909229694b78891a",
"pr-reviewer": "add27b67daa6aa2c75717ac96a6bd625",
- "pr-reviewer-security": "2050297d1cdb081a8576a781828ee44f",
- "pr-reviewer-review": "21ccd5d3a6f3eea16c479db9ed9aedaa",
+ "pr-reviewer-security": "4df29e2bf7b05dbec67e1b6198b8b9c9",
+ "pr-reviewer-review": "ec67b91468cead9c16cfcffff06f8993",
"reference-watch": "e0e20754700fb08d5159b8437d9c260b",
"pr-watcher": "53ead8e26d396849bfa78f28550bd691",
"refresh-local-llm-catalog": "ca7324a0f2251a66b46ea534940c9da8"
@@ -42,7 +42,7 @@
"feature-ideas": 10,
"plan-task": 16,
"claim-issue": 16,
- "claim-issue-gitlab": 15,
+ "claim-issue-gitlab": 16,
"claim-issue-jira": 12,
"pr-reviewer": 3,
"code-reviewer-a": 1,
@@ -57,7 +57,7 @@
"test-coverage": 2,
"performance": 2,
"accessibility": 2,
- "dependency-updates": 3,
+ "dependency-updates": 4,
"documentation": 5,
"ui-bugs": 2,
"mobile-responsive": 2,
@@ -133,7 +133,8 @@
"8e8f795bb75e996b80992883983a3c08",
"da0a8fbb33ac274a3b2efd968e302a1a",
"d8fe2bf614b465ca46108ea3295d2ec5",
- "7ff928b2560ed6bb1a96dbbc80142ed9"
+ "7ff928b2560ed6bb1a96dbbc80142ed9",
+ "eed428fc96a8a58ee94d38e6e4896932"
],
"claim-issue": [
"37949d1b1fa8d461a15658f8f4192d97",
@@ -169,7 +170,8 @@
],
"dependency-updates": [
"640a7c4214e6bdba2bbd5b9061d9d425",
- "3f461b1c111ba45b7fa5016883cfa54d"
+ "3f461b1c111ba45b7fa5016883cfa54d",
+ "7ed05444e2602f4895bdd1e5e0edcaa8"
],
"documentation": [
"074ea22140f8f6a02c7e40a6bc7b0614",
diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.js
index 58f3312ce0..43177fb9d9 100644
--- a/server/services/taskPromptDefaults/previousDefaults.js
+++ b/server/services/taskPromptDefaults/previousDefaults.js
@@ -5931,6 +5931,142 @@ If \`git branch -d\` refuses, fetch the default branch and re-check the MR's mer
- **No — the remainder is a clean, separable chunk** — close THIS issue with a summarizing note (shipped ✓ / moved to #NEW), remove \`in-progress\`, and file ONE tightly-scoped follow-up for the remainder: \`glab issue create --title "…" --label plan [--label model:<tier>] [--label effort:<level>] [--label "good first issue"] [--label "help wanted"] --description "…\\n\\nRefs #\${NUM}"\` (carry over any \`area:*\` labels the issue had; choose the optional labels independently and only when justified — a leftover mechanical sweep is not a good first issue).
- **No — the remainder is a continuation of the same scope** — keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` note, and release the claim so the queue re-picks it: \`glab issue update "\${NUM}" --unassign --unlabel in-progress\`.
+NEVER leave the issue OPEN with \`in-progress\` still on it — that strands it as a zombie (the claim queue skips \`in-progress\`, so the remaining scope is never re-picked). **Do NOT \`git pull\`** from inside this phase — the work is already integrated on GitLab via \`glab mr merge\`; leave the user's working tree alone.`,
+ // v15 default — glab recipes still passed `-F json`, which on `glab issue list` is `--output-format` (details|ids|urls), NOT `--output`; it was accepted, ignored, and answered with the human table at exit 0. Superseded by v16.
+ `[Claim Issue: {appName}] Claim and ship the next open GitLab issue
+
+Pick the next available unclaimed open GitLab issue, **create your own worktree at \`claim/issue-<num>\`**, implement the fix, ship a merge request (MR) that closes the issue, and clean up. This is the \`/claim --issues\` flow for GitLab — same in-flight scan, same branch naming, same no-local-merge cleanup, but the work source is the repo's **GitLab** issue tracker and the forge CLI is \`glab\` (not \`gh\`). **YOU pick the issue in Phase 1 — the scheduler does not reserve one for you.** Picking at execution time and immediately claiming (worktree + assignee + label) **narrows** the window for two concurrent runs to collide on the same issue — it does NOT eliminate it. Do NOT modify files in the source repo directly; ALL editing happens inside the worktree you create.
+
+{issueAuthorFilter}
+
+**How claiming works.** An issue is "in flight" when its number appears as the issue-position segment in either a \`claim/issue-<num>\` ref (the human/TUI pattern) or a \`cos/<task>/issue-<num>/<agent>\` ref (the CoS sub-agent pattern) across local branches, remote branches, or open MR source-branch refs — OR the issue is already assigned to someone OR carries an \`in-progress\` label. The \`claim/issue-<num>\` branch + the assignee/\`in-progress\` markers you set ARE the claim, visible to every other agent (including parallel machines).
+
+## Phase 1 — Pick the target issue
+
+Run steps 1–5 in order.
+
+1. cd into the repo root ({repoPath}) and confirm GitLab is the forge and \`glab\` is authenticated: \`glab auth status\` and \`glab repo view\`. If \`glab\` is not authenticated or the remote is not GitLab, exit cleanly — this task only works against GitLab issue trackers.
+2. List candidate open issues, honoring the author filter described above. Fetch a JSON page and order **oldest-first** (GitLab returns newest-first by default; sort client-side by \`created_at\` since the page is bounded):
+ \`\`\`bash
+ git fetch --prune 2>/dev/null
+ # Owner-only mode (default): add --author <owner> (resolve <owner> from the project namespace).
+ glab issue list --per-page 100 -F json
+ # Any-author mode: run the SAME command WITHOUT --author.
+ \`\`\`
+3. Build the in-flight set. Collect every branch/MR source ref:
+ \`\`\`bash
+ git branch -a --no-color --format='%(refname:short)'
+ glab mr list --per-page 100 -F json # read each MR's source_branch
+ \`\`\`
+ For each ref (after stripping any leading \`origin/\` prefix), extract the issue number **only when the ref matches** \`claim/issue-<num>\` (number after \`claim/issue-\`) or \`cos/<task>/issue-<num>/<agent>\` (the \`issue-<num>\` third segment). Do NOT flag an issue just because its bare number appears elsewhere in a ref.
+4. **Pick the target issue:** walk the candidate list oldest-first and pick the FIRST issue where ALL of the following are true:
+ - Its number (\`iid\`) is NOT in the in-flight set.
+ - It has NO assignees (an assignee means another machine/human already claimed it).
+ - It does NOT carry any of these blocking labels: {issueExcludeLabels}.
+ - It is NOT a tracking/umbrella **epic** — recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive). Leave epics for a human to split. **The bare \`plan\` label is NOT a skip signal** — it marks the claimable queue, not a blocker.
+5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure.
+
+Capture the issue number (GitLab \`iid\`) as \`NUM\`, its title, and its full description — you'll reuse them in the MR and the \`Closes #<num>\` line.
+
+## Phase 2 — Claim (worktree + markers)
+
+Detect the default branch first (forge-agnostic), then create the worktree on \`claim/issue-<num>\` and set the cross-machine claim markers. Do all editing inside the worktree, NEVER in the source repo's working tree.
+
+\`\`\`bash
+NUM=<picked-number>
+DEFAULT_BRANCH="$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@')"
+DEFAULT_BRANCH="\${DEFAULT_BRANCH:-main}"
+WORKTREE="{worktreesRoot}/claim-issue-\${NUM}"
+mkdir -p {worktreesRoot}
+git fetch origin "\${DEFAULT_BRANCH}"
+git worktree add --no-track -b "claim/issue-\${NUM}" "\${WORKTREE}" "origin/\${DEFAULT_BRANCH}"
+# Cross-machine claim markers (best-effort — do not abort the run if these fail).
+# Resolve your own username first — glab's --assignee wants a username (the
+# \`@me\` gh-ism isn't universally supported), falling back to @me if the lookup fails:
+ME="$(glab api user 2>/dev/null | sed -n 's/.*"username":"\\([^"]*\\)".*/\\1/p')"
+glab issue update "\${NUM}" --assignee "\${ME:-@me}" 2>/dev/null
+glab issue update "\${NUM}" --label in-progress 2>/dev/null
+cd "\${WORKTREE}"
+\`\`\`
+
+**If \`git worktree add\` fails because the \`claim/issue-<num>\` branch already exists** (a concurrent run won the race), do NOT force or reuse it — that branch IS another run's claim. Treat the issue as in-flight, return to Phase 1, and pick the next eligible issue; if nothing else is eligible, exit cleanly. Stash \`WORKTREE\` — you'll need it for Phase 7 cleanup.
+
+## Phase 3 — Verify still valid
+
+Read the full issue (\`glab issue view "\${NUM}"\`) before writing any code. **Every exit from this phase must leave a CONVERGING outcome on the issue — closed, or labeled \`needs-input\`.** Phase 1 step 4 skips both, so an autonomous drain stops re-picking the item. Releasing an issue OPEN and unlabeled is NOT an exit: the work detector still reports it actionable, so the next pass re-picks it and burns another no-op agent — every pass, forever.
+
+- **Already fixed, superseded, or closed-then-reopened-for-tracking** — a note says so, or the change it asks for is already on the default branch. **Close it:** post a note naming the MR/commit (or issue) that already delivered it (\`glab issue note "\${NUM}" -m "..."\`), then \`glab issue close "\${NUM}"\` and clear the markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`). Remove the worktree and return to Phase 1. **Evidence gate: if you cannot name the MR, commit, or issue that delivered it, this branch does NOT apply** — closing on a hunch destroys live work, which is far worse than one wasted pass. Treat the issue as real work and continue to Phase 4.
+- **Stale reference** — the request names a function, file, or component that no longer exists (\`grep -rn\` the named identifiers; if they're gone, the issue is stale). Post a note naming what you searched for and what you found instead, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and return to Phase 1. Re-scoping a stale issue against today's code is a human call — and the label is what keeps the drain off it in the meantime.
+
+(A too-large scope is NOT in this list — it has its own park path below.)
+
+**A genuinely too-large issue needs parking so the drain converges.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, post a brief note naming the split you'd suggest, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit — splitting an omnibus issue is a human call, and parking it stops a perpetual drain from re-picking the same un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
+
+**Ambiguity is NOT a release trigger — decide, don't defer.** If the issue is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to \`needs-input\`. Pick the most reasonable interpretation, record the approach you chose in a brief issue note (\`glab issue note "\${NUM}" -m "..."\`) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the issue parked waiting on a decision they didn't ask to make. Reserve \`needs-input\` — which pulls the issue out of the autonomous queue — for the narrow cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, post the explaining note, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit cleanly. **That label is what lets an autonomous drain converge** — Phase 1 step 4 skips \`needs-input\` issues. Never leave a half-claimed issue.
+
+## Phase 4 — Implement
+
+Write the code, tests, and any docs the issue requires. Follow the repo conventions in CLAUDE.md. Run the relevant test suite as you go.
+
+**Roll discovered backbone work INTO this MR** — small supporting helpers, refactors, and tests that the fix depends on belong here, not a follow-up. Only defer genuinely-large adjacent work; when you do, file a NEW issue (\`glab issue create\`) tagged \`plan\` that references this one (\`Related to #<num>\`). Choose independent dispatch hints (\`model:light|medium|heavy\`, \`effort:low|medium|high|xhigh|max\`) and contributor labels (\`good first issue\`, \`help wanted\`) only when justified; omit an axis rather than guessing; create each missing label immediately before applying it; use repeated \`--label\` flags; do not prefix the title with \`[category]\` / \`[model:…]\`.
+
+Commit with a conventional message referencing the issue:
+
+\`\`\`
+<type>: <one-line description> (#<num>)
+\`\`\`
+
+## Phase 5 — Review locally (BEFORE any MR exists)
+
+**Every reviewer that can read the working tree runs HERE, while there is still no MR.** Open the MR only once the branch is already review-clean: the MR then carries the finished diff, and the only things left to satisfy are CI and the reviewers that genuinely cannot start until an MR is open.
+
+The configured reviewers for this task, in order, are \`{reviewers}\`. Split that list in two, preserving its order:
+
+- **LOCAL reviewers — every token that is NOT an \`@<login>\`.** \`claude\` / \`codex\` / \`antigravity\` (CLI binary: \`agy\`) / \`grok\` / \`cursor\` invoke a local-CLI critique; \`lmstudio\` / \`ollama\` use the appended Local Reviewer Procedure. They read this branch's own diff and need no MR — run them in THIS phase.
+- **MR-SIDE reviewers — every \`@<login>\` token**, plus any review bot the project requests automatically when an MR opens. They review server-side and cannot start before the MR exists — they run in Phase 6.
+
+1. **Write the changelog entry now, not after the reviewers run** — every commit the reviewers are about to read must already be on the branch, or the MR carries work nobody reviewed. If the repo maintains a changelog, record a one-line entry **following the convention that repo documents** — read its \`CLAUDE.md\` and changelog README (e.g. \`.changelog/README.md\`) first. Some repos collect per-branch fragments in a directory (e.g. \`.changelog/next/\`) via a helper script rather than appending to one shared file, precisely so parallel agents don't conflict on every merge; use that flow when it's documented. Fall back to appending to the unreleased section (\`.changelog/NEXT.md\`, or \`## Unreleased\` in \`CHANGELOG.md\`) in the repo's existing prose style only when no convention is documented. If the repo has no changelog, skip this.
+2. **Self-review your diff for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix the findings in the same diff, before any reviewer runs. Claude Code runs this as the three-agent \`/simplify\` pass; on other CLIs, do the equivalent review by hand.
+3. **Run each LOCAL reviewer in the listed order against the BRANCH diff, not an MR diff.** No MR exists yet, so \`glab mr diff\` has nothing to read — use the CLI's own base-diff mode or \`git diff "origin/\${DEFAULT_BRANCH}...HEAD"\`. Apply the findings, run the tests, and commit the fixes — capped at 3 rounds per reviewer — then advance to the next reviewer. A missing CLI, timeout, transport failure, malformed response, or empty response is UNSATISFIED, not clean. Do NOT substitute your own self-review, and do NOT open an MR on the strength of it.
+4. **If the branch cannot be brought to a shippable state here, do NOT open an MR** — that is a local reviewer still unsatisfied after 3 rounds, or fixes that leave the build/tests red. Post a note on the ISSUE naming the reviewer and the failure (\`glab issue note "\${NUM}" -m "..."\`), leave the assignee and the \`in-progress\` label in place, remove ONLY the worktree (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`), and stop. The branch stays for a human to pick up cold. Do NOT run Phase 7.
+
+## Phase 6 — Open the merge request, satisfy MR-side review + CI, and merge
+
+Every local reviewer's fixes are already committed, so the MR opens against finished work. This flow ships GitLab issues — it does NOT touch PLAN.md. The audit trail is the merged MR + \`git log\`.
+
+1. Push the branch: \`git push -u origin "claim/issue-\${NUM}"\`. Then confirm \`git log --oneline @{u}..HEAD\` is empty — if it isn't, a Phase 5 review fix never left the machine and the MR would be opened against a stale diff; push again before continuing.
+2. Open the MR with \`glab mr create --fill --source-branch "claim/issue-\${NUM}" --target-branch "\${DEFAULT_BRANCH}" --yes\`. **Choose the issue trailer deliberately:** if this MR FULLY satisfies the issue's scope, the description MUST contain \`Closes #\${NUM}\` so the merge auto-closes it; if you deliberately shipped only PART of the issue (a valuable slice with real scope remaining), use \`Refs #\${NUM}\` instead (NOT \`Closes\`) and add a \`## Remaining\` section listing what's left — Phase 7 reconciles the issue so it is never stranded. Summarize what shipped + a short test plan (pass \`--description\` if \`--fill\` didn't capture it).
+3. **Satisfy the MR-SIDE reviewers.** For each \`@<login>\` from the Phase 5 split, request the review now (resolve \`MR_IID\` from the source branch exactly as step 5 does, then \`glab mr update "\${MR_IID}" --reviewer <login>\`, dropping the \`@\`; if glab rejects the flag, run \`glab mr update --help\` rather than guessing), poll every 5–15s, and address the findings — push fixes, capped at 3 rounds per reviewer. Their approval gates the merge. If the project auto-requests a review bot when the MR opens, wait that round out and address it the same way. With no \`@<login>\` configured and no bot review appearing, this step is a no-op.
+
+ **Review-stuck cleanup** (an MR-side reviewer still unsatisfied after 3 rounds): post one summarizing MR note (\`glab mr note\`), then run the worktree-only cleanup (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`). Leave the local branch, the open MR, the assignee, and the \`in-progress\` label in place so the human picks up cold. Do NOT run Phase 7.
+4. **Let required CI finish and go green** — inspect the MR's pipeline (\`glab ci status\` on the branch, or \`glab mr view "\${MR_IID}"\`). A red required pipeline is not merge-eligible: fix it and re-push (same 3-round cap), or, if it stays red, stop exactly as the review-stuck cleanup above does.
+5. **Merge immediately via \`glab mr merge\`** — NEVER a local \`git merge\`. \`glab mr merge\` takes the **MR IID**, which is NOT the issue number — resolve it from the source branch first, merge, then verify remote state:
+ \`\`\`bash
+ MR_IID="$(glab mr list --source-branch "claim/issue-\${NUM}" -F json | sed -n 's/.*"iid":\\([0-9]\\{1,\\}\\).*/\\1/p' | head -1)"
+ glab mr merge "\${MR_IID}" --yes --remove-source-branch || {
+ glab mr view "\${MR_IID}" -F json | jq -e 'select((.state | ascii_downcase) == "merged")' >/dev/null || glab mr merge "\${MR_IID}" --yes --squash --remove-source-branch
+ }
+ glab mr view "\${MR_IID}" -F json | jq -er 'select((.state | ascii_downcase) == "merged") | .state'
+ \`\`\`
+ The verification command must succeed and print a merged state. An opened/closed state or missing value is not success; investigate CI, review, and branch protection, then retry. Do not enter Phase 7 until the forge confirms the MR is merged.
+
+## Phase 7 — Clean up (post-merge ONLY)
+
+This phase runs only after the MR merged via Phase 6. From the **source repo** (cd back to {repoPath} first):
+
+\`\`\`bash
+cd {repoPath}
+git worktree remove "\${WORKTREE}"
+git branch -d "claim/issue-\${NUM}"
+\`\`\`
+
+If \`git branch -d\` refuses, fetch the default branch and re-check the MR's merged state. Retry \`-d\` only when Git proves the branch integrated; otherwise leave it for reconciliation. Never force-delete with \`-D\`.
+
+**Reconcile the issue — did this MR FULLY satisfy its scope?**
+- **Yes (full)** — the \`Closes #\${NUM}\` line already auto-closed it on merge to the default branch; if it's somehow still open, close it (\`glab issue close "\${NUM}"\`) and remove the label (\`glab issue update "\${NUM}" --unlabel in-progress\`).
+- **No — the remainder is a clean, separable chunk** — close THIS issue with a summarizing note (shipped ✓ / moved to #NEW), remove \`in-progress\`, and file ONE tightly-scoped follow-up for the remainder: \`glab issue create --title "…" --label plan [--label model:<tier>] [--label effort:<level>] [--label "good first issue"] [--label "help wanted"] --description "…\\n\\nRefs #\${NUM}"\` (carry over any \`area:*\` labels the issue had; choose the optional labels independently and only when justified — a leftover mechanical sweep is not a good first issue).
+- **No — the remainder is a continuation of the same scope** — keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` note, and release the claim so the queue re-picks it: \`glab issue update "\${NUM}" --unassign --unlabel in-progress\`.
+
NEVER leave the issue OPEN with \`in-progress\` still on it — that strands it as a zombie (the claim queue skips \`in-progress\`, so the remaining scope is never re-picked). **Do NOT \`git pull\`** from inside this phase — the work is already integrated on GitLab via \`glab mr merge\`; leave the user's working tree alone.`,
],
// claim-issue v1 default — excluded every `plan`-labelled issue (the entire
@@ -8007,6 +8143,124 @@ Repository: {repoPath}
7. Commit with clear changelog
+IMPORTANT: Only update one major version bump at a time.`,
+ // v3 default — Phase 1 GitLab recipes used the nonexistent `glab mr list --state <x>` flag (exit 1: Unknown flag), so bot-PR triage silently skipped on GitLab repos. Superseded by v4.
+ `[Improvement: {appName}] Dependency Updates
+
+Check {appName} dependencies for updates and security vulnerabilities:
+
+Repository: {repoPath}
+
+Open automated dependency PRs come FIRST. A Dependabot/Renovate PR is a bump already
+proposed and already isolated to one package — redoing it yourself conflicts with the bot
+branch and leaves a stale PR behind. Finish Phase 1 before you touch a manifest.
+
+## Phase 1 — Land or resolve open automated dependency PRs
+
+This phase talks to the repo's forge. Use \`gh\` on GitHub and \`glab\` on GitLab —
+the command pairs are given below, and every \`gh pr <verb> <n>\` has a \`glab mr <verb> <n>\`
+equivalent. Run the right one for this repo's origin; never run \`gh\` against a GitLab
+repo (a globally-configured \`gh\` will silently target an unrelated GitHub repository).
+
+1. List the open PRs. If the repo has no GitHub/GitLab remote, or the matching CLI is
+ unavailable or unauthenticated, say so and skip straight to Phase 2:
+ \`gh pr list --state open --limit 500 --json number,title,headRefName,author,mergeable,mergeStateStatus\`
+ (GitLab: \`glab mr list --state opened --per-page 100 --page <n>\`, paging until a page
+ comes back short.) The limit has to cover EVERY open PR, not just a first page — a bot
+ PR you never listed looks bot-uncovered to Phase 2, which then files the duplicate bump
+ this phase exists to prevent. If the result is exactly at your limit, raise it and re-run.
+ An automated dependency PR is one authored by \`dependabot[bot]\`, \`app/dependabot\`,
+ \`renovate[bot]\`, or whose head branch starts with \`dependabot/\` or \`renovate/\`.
+
+2. For EACH one, gather evidence before deciding:
+ - The version jump: patch, minor, or major (\`gh pr view <n>\` / \`glab mr view <n>\`)
+ - For a major (or a minor from a package that breaks on minors): read the release
+ notes in the PR body, then grep this codebase for the APIs that changed. A breaking
+ change the repo never calls is not a blocker.
+ - CI status: \`gh pr checks <n>\` (GitLab: \`glab ci status --branch <headRefName>\`).
+ For a failure, read the actual log (\`gh run view <run-id> --log-failed\` /
+ \`glab ci trace <job-id>\`) and identify the root cause — a real incompatibility, a
+ flaky test, or an unrelated pre-existing failure on the default branch (check that
+ before blaming the bump).
+ - Mergeability: \`CONFLICTING\` (GitLab: \`cannot_be_merged\`) almost always means
+ lockfile/manifest drift from another dependency PR that already merged.
+ - Diff sanity: the diff should be manifest + lockfile only. Source-file edits, a new
+ postinstall/prepare script, or a changed registry URL in a bot PR is a red flag —
+ do not merge it; comment what you found and leave it open.
+
+3. Then take exactly ONE verdict per PR:
+ - MERGE — patch/minor, CI green, not conflicting, diff is clean, nothing in the
+ release notes affects how this repo uses the package. Merge it, matching the repo's
+ documented merge method (\`gh pr merge <n> --merge\` / \`glab mr merge <n> --yes\`
+ unless the repo says otherwise).
+ - FIX-THEN-MERGE — the bump is wanted but the PR is stuck. Fix it:
+ * Conflicts only: ask the bot to redo it first — comment \`@dependabot rebase\`
+ (Renovate: tick the PR's rebase checkbox), move on, and re-check at the end of
+ the phase. If the bot doesn't respond, resolve it yourself.
+ * Build/test failure caused by the new version (renamed export, changed default,
+ dropped Node/engine support): make the SMALLEST adapting code change on the PR
+ branch. Keep it scoped to the breakage — never bundle unrelated work onto a
+ bot branch.
+ * Either way, work on the bot branch in a THROWAWAY WORKTREE, never by checking
+ it out in {repoPath} — this task usually runs in the app's live checkout, so a
+ \`gh pr checkout\` there hijacks whatever branch the user is on and fails outright
+ on their uncommitted work. The bot branch normally exists only on the remote, so
+ name the remote ref explicitly and let \`-b\` create the local branch. Call the
+ worktree \`dep-{appName}-pr-<n>\` (lowercase the app name and collapse anything
+ non-alphanumeric to \`-\`) — {worktreesRoot} is shared by every app this install
+ manages, so a bare \`dep-pr-<n>\` collides with another app's PR of the same number:
+ \`git -C {repoPath} fetch origin <headRefName>\`
+ \`git -C {repoPath} worktree add -b dep-{appName}-pr-<n> {worktreesRoot}/dep-{appName}-pr-<n> origin/<headRefName>\`
+ Do the work in that worktree: rebase onto the default branch if it was conflicting,
+ regenerate the lockfile with the package manager (\`npm install\` — never hand-edit
+ a lockfile), run the tests, then push back to the PR's own branch:
+ \`git push origin HEAD:<headRefName>\`. Remove the worktree and its local branch
+ when you're done with that PR
+ (\`git -C {repoPath} worktree remove {worktreesRoot}/dep-{appName}-pr-<n>\` then
+ \`git -C {repoPath} branch -D dep-{appName}-pr-<n>\`).
+ * Pushing a rebase rewrites the bot's commits, so a plain push is rejected — add
+ \`--force-with-lease=<headRefName>:origin/<headRefName>\`, which refuses if the bot
+ pushed again while you worked, so you never clobber a newer version of its branch.
+ Never a bare \`--force\`. A push you did NOT rebase needs no force at all.
+ * Merge once it is green.
+ - CLOSE — the PR is superseded (a newer bot PR bumps the same package further) or
+ targets a dependency this repo no longer uses. Close it with a comment saying why.
+ - LEAVE — a major upgrade that needs a real migration, or a bump to something
+ security- or billing-critical that warrants a human call. Comment on the PR with
+ what you found and what the migration would take, and record it in the repo's work
+ tracker (a PLAN.md item or an issue, whichever the repo uses). Do not merge it.
+
+4. Re-check anything you asked the bot to rebase, then merge or leave it accordingly.
+ Summarize each PR and its verdict at the end of the phase.
+
+## Phase 2 — Everything the bots did not cover
+
+1. Run npm audit (or equivalent package manager)
+2. Check for outdated packages — skip any package that still has an open bot PR; that PR
+ owns the bump. Phase 1's list is the first filter, and when Phase 1 had forge access,
+ confirm per package before you bump one it didn't mention
+ (\`gh pr list --state open --search "<package> in:title"\` /
+ \`glab mr list --state opened --search "<package>"\`), so a PR that fell outside the
+ listing can't still get double-bumped here. If Phase 1 was skipped for lack of a
+ working \`gh\`/\`glab\`, skip this confirmation too — there is nothing to query — and
+ say in your summary that bot-PR overlap could not be checked.
+3. Review CRITICAL and HIGH severity vulnerabilities
+4. For each vulnerability:
+ - Assess actual risk
+ - Check if update available
+ - Test updates don't break functionality
+
+5. Update dependencies carefully:
+ - Patch versions first (safest)
+ - Then minor versions
+ - Major versions need careful review
+
+6. After updating:
+ - Run tests
+ - Verify the app starts correctly
+
+7. Commit with clear changelog
+
IMPORTANT: Only update one major version bump at a time.`,
],
'documentation': [
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index 48f68c1565..83872bc975 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -175,10 +175,12 @@ repo (a globally-configured \`gh\` will silently target an unrelated GitHub repo
1. List the open PRs. If the repo has no GitHub/GitLab remote, or the matching CLI is
unavailable or unauthenticated, say so and skip straight to Phase 2:
\`gh pr list --state open --limit 500 --json number,title,headRefName,author,mergeable,mergeStateStatus\`
- (GitLab: \`glab mr list --state opened --per-page 100 --page <n>\`, paging until a page
- comes back short.) The limit has to cover EVERY open PR, not just a first page — a bot
- PR you never listed looks bot-uncovered to Phase 2, which then files the duplicate bump
- this phase exists to prevent. If the result is exactly at your limit, raise it and re-run.
+ (GitLab: \`glab mr list --per-page 100 --page <n>\`, paging until a page
+ comes back short; \`glab mr list\` lists OPEN MRs by default and has NO
+ \`--state\` flag — passing one exits 1.) The limit has to cover EVERY open PR,
+ not just a first page — a bot PR you never listed looks bot-uncovered to Phase 2,
+ which then files the duplicate bump this phase exists to prevent. If the result is
+ exactly at your limit, raise it and re-run.
An automated dependency PR is one authored by \`dependabot[bot]\`, \`app/dependabot\`,
\`renovate[bot]\`, or whose head branch starts with \`dependabot/\` or \`renovate/\`.
@@ -250,7 +252,7 @@ repo (a globally-configured \`gh\` will silently target an unrelated GitHub repo
owns the bump. Phase 1's list is the first filter, and when Phase 1 had forge access,
confirm per package before you bump one it didn't mention
(\`gh pr list --state open --search "<package> in:title"\` /
- \`glab mr list --state opened --search "<package>"\`), so a PR that fell outside the
+ \`glab mr list --search "<package>"\`), so a PR that fell outside the
listing can't still get double-bumped here. If Phase 1 was skipped for lack of a
working \`gh\`/\`glab\`, skip this confirmation too — there is nothing to query — and
say in your summary that bot-PR overlap could not be checked.
@@ -903,13 +905,13 @@ Run steps 1–5 in order.
\`\`\`bash
git fetch --prune 2>/dev/null
# Owner-only mode (default): add --author <owner> (resolve <owner> from the project namespace).
- glab issue list --per-page 100 -F json
+ glab issue list --per-page 100 --output json
# Any-author mode: run the SAME command WITHOUT --author.
\`\`\`
3. Build the in-flight set. Collect every branch/MR source ref:
\`\`\`bash
git branch -a --no-color --format='%(refname:short)'
- glab mr list --per-page 100 -F json # read each MR's source_branch
+ glab mr list --per-page 100 --output json # read each MR's source_branch
\`\`\`
For each ref (after stripping any leading \`origin/\` prefix), extract the issue number **only when the ref matches** \`claim/issue-<num>\` (number after \`claim/issue-\`) or \`cos/<task>/issue-<num>/<agent>\` (the \`issue-<num>\` third segment). Do NOT flag an issue just because its bare number appears elsewhere in a ref.
4. **Pick the target issue:** walk the candidate list oldest-first and pick the FIRST issue where ALL of the following are true:
@@ -995,12 +997,12 @@ Every local reviewer's fixes are already committed, so the MR opens against fini
4. **Let required CI finish and go green** — inspect the MR's pipeline (\`glab ci status\` on the branch, or \`glab mr view "\${MR_IID}"\`). A red required pipeline is not merge-eligible: fix it and re-push (same 3-round cap), or, if it stays red, stop exactly as the review-stuck cleanup above does.
5. **Merge immediately via \`glab mr merge\`** — NEVER a local \`git merge\`. \`glab mr merge\` takes the **MR IID**, which is NOT the issue number — resolve it from the source branch first, merge, then verify remote state:
\`\`\`bash
- MR_IID="$(glab mr list --source-branch "claim/issue-\${NUM}" -F json | sed -n 's/.*"iid":\\([0-9]\\{1,\\}\\).*/\\1/p' | head -1)"
+ MR_IID="$(glab mr list --source-branch "claim/issue-\${NUM}" --output json | sed -n 's/.*"iid":\\([0-9]\\{1,\\}\\).*/\\1/p' | head -1)"
glab mr merge "\${MR_IID}" --yes --remove-source-branch || {
- glab mr view "\${MR_IID}" -F json | jq -e 'select((.state | ascii_downcase) == "merged")' >/dev/null || \
+ glab mr view "\${MR_IID}" --output json | jq -e 'select((.state | ascii_downcase) == "merged")' >/dev/null || \
glab mr merge "\${MR_IID}" --yes --squash --remove-source-branch
}
- glab mr view "\${MR_IID}" -F json | jq -er 'select((.state | ascii_downcase) == "merged") | .state'
+ glab mr view "\${MR_IID}" --output json | jq -er 'select((.state | ascii_downcase) == "merged") | .state'
\`\`\`
The verification command must succeed and print a merged state. An opened/closed state or missing value is not success; investigate CI, review, and branch protection, then retry. Do not enter Phase 7 until the forge confirms the MR is merged.
@@ -1694,13 +1696,14 @@ Repository: {repoPath}
- Contains "gitlab" -> use \`glab\` CLI
3. List open PRs/MRs authored by others (not by atomantic):
- GitHub: \`gh pr list --state open --json number,author,headRefName,updatedAt,title\`
- - GitLab: \`glab mr list --state opened -F json\`
+ - GitLab: \`glab mr list --output json\`
+ (open is the default there; passing a \`--state\` flag exits 1 — it does not exist)
## Phase 2 — Check Review Status
4. For each PR/MR from other contributors:
- GitHub: \`gh pr view <number> --json reviews,commits\` — check if I have a review newer than the latest commit
- - GitLab: \`glab mr view <iid> -F json\` — check notes/approvals vs last commit date
+ - GitLab: \`glab mr view <iid> --output json\` — check notes/approvals vs last commit date
5. Skip PRs where I already have a review posted after the most recent commit push
## Phase 3 — Security Scan
@@ -1774,7 +1777,7 @@ Repository: {repoPath}
6. For each approved PR:
- Check CI/CD status:
- GitHub: \`gh pr checks <number>\` — wait for all checks to complete (poll every 30s, up to 10 minutes)
- - GitLab: \`glab mr view <iid> -F json\` — check pipeline status
+ - GitLab: \`glab mr view <iid> --output json\` — check pipeline status
- Run the project's test suite locally: check for a test script in package.json, Makefile, or similar and run it
- If all CI checks pass AND local tests pass (prefer a true merge commit so the branch tip stays in the default branch's history — if the repo disallows merge commits, fall back to \`--squash\`):
- GitHub: \`gh pr merge <number> --merge --delete-branch || gh pr merge <number> --squash --delete-branch\`
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index 3337f3cd5d..3c40dc9273 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -13,7 +13,7 @@ export const PROMPT_VERSIONS = {
'feature-ideas': 10, // v10: Phase 4 (Brainstorm) consults the repo's REJECTED.md and recently closed-unmerged PRs before proposing, so ideas the user already declined aren't re-proposed (mirrors idle-review's REJECTED.md contract). v9: drop DONE.md reads — use `.changelog/` + `git log` (last 50) as the completed-work signal
'plan-task': 16, // v16: every reviewer that can read the working tree runs BEFORE the PR is opened — Phase 6 splits the configured list into LOCAL reviewers (every non-`@<login>` token, reviewed against `git diff origin/main...HEAD`) and PR-SIDE reviewers (`@<login>` plus any auto-requested review bot), opens the PR only once the branch is review-clean, and then waits on those PR-side reviewers plus required CI. Previously the PR was opened first and every reviewer ran against its diff, so each round of findings landed as follow-up commits on an already-public PR. v14: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v13: Phase 5's changelog step reads the repo's documented convention FIRST (per-branch fragment directory + helper script, as PortOS now uses) and only falls back to detect-and-append when none is documented; the Phase 6 review-stuck note no longer names `.changelog/NEXT.md` as the file it wrote. v12: the reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — the bare `antigravity` slug is a command that exists nowhere, and a review-loop agent that probed for it concluded no reviewer was available and merged on its own self-review. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v11: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v10: Phase 3 "decide, don't defer" — an *ambiguous* PLAN.md item no longer jumps to the Phase 3b clarification PR; the agent picks the most reasonable reading, notes it, and implements. Phase 3b is reserved for destructive/irreversible or genuinely-human-gated items. Mirrors claim-issue v7 + CLAUDE.md. v9: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v8: Phase-6 merge fallback prefers --merge over --squash (after --auto), matching the /do:pr + review-loop default and PortOS's merge-only policy
'claim-issue': 16, // v16: Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder (resolveIssueExcludeLabelsBlock, cosTaskGenerator.js) — the fixed NON_ACTIONABLE_ISSUE_LABELS set plus any app-configured `taskMetadata.issueExcludeLabels` extras (e.g. `good first issue`), so the live claim agent honors the same per-app exclusions the perpetual-drain detector applies, not just the hardcoded set. The pinned-target constraint (`/do:next <num>` / the work-item picker) also re-checks that resolved list, not just the fixed 3, so a target that gained an excluded label after the picker snapshot still isn't force-claimed. Phase 1's candidate fetch widened to `--limit 500` (was 100), matching perpetualWork.js's detector — the label filter runs on the fetched page, so a small cap risked missing eligible work further down a busy queue. v15: Phase 5 is now the pre-PR local review (LOCAL reviewers = every non-`@<login>` token, run against the branch diff; an unsatisfied one blocks PR creation entirely) and Phase 6 opens the PR, satisfies the PR-SIDE reviewers (`@<login>` plus any auto-requested review bot) and required CI, then merges. v13: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v12: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v11: EVERY Phase-3 release now converges — the "already fixed / superseded" case CLOSES the issue (with a comment naming what delivered it) and the "stale reference" case tags `needs-input`, instead of both releasing the issue open and unlabeled. `isActionableIssue` (perpetualWork.js) can only see labels/assignees/epic/in-flight, so a body-or-comment-driven release left the issue looking actionable and the perpetual drain re-spawned a no-op agent on it every tick. v10: Phase 5's changelog step defers to the convention the repo documents (per-branch fragment directory + helper script when present) instead of prescribing an append to `.changelog/NEXT.md`. v9: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v8: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v7: Phase 3 no longer releases/parks an *ambiguous* issue to `needs-input` — the agent decides (picks the most reasonable reading, records it in an issue comment, ships) rather than punting the choice back to a human; `needs-input` is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. Mirrors the "Decide, don't defer" policy in CLAUDE.md. v6: Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix — mirrors the perpetualWork detector so a `[Epic]`-titled issue with no `epic` label stops re-spawning a claim agent that always skips it (perpetual drain now converges/parks). v5: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v4: Phase 5 chooses the issue trailer deliberately (Closes for a full ship, Refs + a `## Remaining` section for a partial one) and Phase 7 reconciles the issue with the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the `in-progress` claim — so a partial ship is never left OPEN + `in-progress` (a zombie the claim queue skips forever). v3: Phase 3 tags an ambiguous/too-large issue `needs-input` (not just a comment) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge instead of re-picking the same un-actionable issue. v2: stop treating the bare `plan` label as a skip — `plan` is the claimable-queue label (do-replan --issues labels every migrated backlog item `plan`), so v1's exclusion emptied the whole actionable queue; now skip only true epics (`epic` label or "(epic)" title)
- 'claim-issue-gitlab': 15, // v15: mirrors claim-issue v16 — Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder. v14: mirrors claim-issue v15 — Phase 5 runs the LOCAL reviewers against the branch diff before any MR exists, Phase 6 opens the MR and satisfies the MR-SIDE reviewers + pipeline before merging. v12: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v11: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v10: mirrors claim-issue v11 — every Phase-3 release converges (close the already-fixed/superseded issue, tag the stale-reference one `needs-input`) so the perpetual drain stops re-picking it. v9: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v8: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v7: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v6: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* issue (record the chosen reading in an issue note, ship) instead of parking it to `needs-input`, which is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. v5: mirrors claim-issue v6 — Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix, so the GitLab detector/agent converge on epic-titled issues too. v4: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v3: mirrors claim-issue v4 — Phase 5 chooses Closes-vs-Refs deliberately and Phase 7 reconciles the issue with the partial-ship hybrid (close + scoped follow-up when separable, else "done/remaining" note + release the `in-progress` claim) so a partial ship is never stranded. v2: Phase 3 tags an ambiguous/too-large issue `needs-input` (mirrors claim-issue v3) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge. v1: GitLab sibling of claim-issue — same 7-phase /claim --issues flow over `glab` issues + merge requests. Reached via the claim-work router when an app's resolved workTracker is 'gitlab'.
+ 'claim-issue-gitlab': 16, // v16: Phase 1/2/6 glab recipes use `--output json` instead of `-F json`. On `glab issue list`, `-F` is `--output-format` (details|ids|urls) — a DIFFERENT flag from `--output` (text|json) — so that spelling was accepted, ignored, and answered with the human table at exit 0; an agent piping that to `jq` got nothing and could not distinguish it from "no issues". `--output json` is correct on every glab subcommand, so the mr recipes are normalized to the same spelling in this bump. v15: mirrors claim-issue v16 — Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder. v14: mirrors claim-issue v15 — Phase 5 runs the LOCAL reviewers against the branch diff before any MR exists, Phase 6 opens the MR and satisfies the MR-SIDE reviewers + pipeline before merging. v12: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v11: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v10: mirrors claim-issue v11 — every Phase-3 release converges (close the already-fixed/superseded issue, tag the stale-reference one `needs-input`) so the perpetual drain stops re-picking it. v9: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v8: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v7: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v6: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* issue (record the chosen reading in an issue note, ship) instead of parking it to `needs-input`, which is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. v5: mirrors claim-issue v6 — Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix, so the GitLab detector/agent converge on epic-titled issues too. v4: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v3: mirrors claim-issue v4 — Phase 5 chooses Closes-vs-Refs deliberately and Phase 7 reconciles the issue with the partial-ship hybrid (close + scoped follow-up when separable, else "done/remaining" note + release the `in-progress` claim) so a partial ship is never stranded. v2: Phase 3 tags an ambiguous/too-large issue `needs-input` (mirrors claim-issue v3) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge. v1: GitLab sibling of claim-issue — same 7-phase /claim --issues flow over `glab` issues + merge requests. Reached via the claim-work router when an app's resolved workTracker is 'gitlab'.
'claim-issue-jira': 12, // v12: mirrors claim-issue v15 in the JIRA flow — Phase 5 runs the LOCAL reviewers against the branch diff before the MR/PR is opened (and before the In Review transition), Phase 6 keeps only the PR-side reviewers plus the worktree cleanup. v10: follow-up tickets receive equivalent hyphenated dispatch (`model-*`/`effort-*`) and contributor (`good-first-issue`/`help-wanted`) labels when independently justified. v9: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v8: mirrors claim-issue v11 in JIRA's status vocabulary — an already-fixed/superseded ticket transitions to Done/Closed and a stale-reference ticket parks on a Blocked/On Hold status behind a Review Hub todo, instead of transitioning back to a not-started status that Phase 1 immediately re-picks. v7: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v6: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v5: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of `{repoPath}/data/cos/worktrees/`, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v4: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* ticket (record the chosen reading in a ticket comment, ship) instead of parking it to a "Needs clarification" Review Hub todo, and Phase 1 no longer skips a merely-underspecified ticket; the todo is reserved for destructive/irreversible or genuinely-human-gated cases. v3: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v2: Phase 5 records remaining scope in the ticket (Done/Remaining comment) and files a follow-up ticket when a partial ship's remainder is separable, so remaining work isn't lost when a human lands the MR/PR. v1: JIRA sibling of claim-issue — claim ONE ready sprint ticket, move it To Do→In Progress→In Review around a self-managed worktree + MR/PR. Reached via the claim-work router when an app's resolved workTracker is 'jira' (replaces the prior jira→jira-sprint-manager route).
'pr-reviewer': 3, // v3: multi-stage pipeline (security scan → code review + merge)
'code-reviewer-a': 1, // v1: 2-stage pipeline (codebase review → triage & implement)
@@ -34,7 +34,7 @@ export const PROMPT_VERSIONS = {
'test-coverage': 2, // v2: generic {appName} body (older default hardcoded "PortOS")
'performance': 2, // v2: generic {appName} body (older default hardcoded "PortOS")
'accessibility': 2, // v2: generic {appName} + the app UI (older default hardcoded "PortOS" + http://localhost:5555)
- 'dependency-updates': 3, // v3: Phase 1 triages open Dependabot/Renovate PRs first (evidence → MERGE / FIX-THEN-MERGE / CLOSE / LEAVE, including conflict + CI-failure repair on the bot branch) before Phase 2 updates anything the bots didn't cover — an agent that bumped packages itself was duplicating and conflicting with open bot PRs. v2: generic {appName} body (older default hardcoded "PortOS")
+ 'dependency-updates': 4, // v4: the GitLab MR-list recipes drop `--state` — that flag does not exist (MR state is selected by presence flags `--merged`/`--closed`/`--all`, and OPEN is the default), so `--state opened` exited 1 with `Unknown flag: --state` and Phase 1 skipped its bot-PR triage entirely on GitLab repos. v3: Phase 1 triages open Dependabot/Renovate PRs first (evidence → MERGE / FIX-THEN-MERGE / CLOSE / LEAVE, including conflict + CI-failure repair on the bot branch) before Phase 2 updates anything the bots didn't cover — an agent that bumped packages itself was duplicating and conflicting with open bot PRs. v2: generic {appName} body (older default hardcoded "PortOS")
'documentation': 5, // v5: the changelog step defers to the convention the repo documents (some repos collect per-branch fragments in a directory so parallel agents don't conflict) instead of prescribing an append to `.changelog/NEXT.md`. v4: generic {appName} body (v1 hardcoded "PortOS"; v2/v3 retired DONE.md wording)
'ui-bugs': 2, // v2: generic {appName} + the app UI (older default hardcoded "PortOS" + http://localhost:5555)
'mobile-responsive': 2, // v2: generic {appName} app-UI body (older default hardcoded "PortOS" + http://localhost:5555)
diff --git a/server/services/taskPromptService.test.js b/server/services/taskPromptService.test.js
index 5a319bbdee..3414c8a020 100644
--- a/server/services/taskPromptService.test.js
+++ b/server/services/taskPromptService.test.js
@@ -1,4 +1,4 @@
-import { describe, it, expect, vi } from 'vitest';
+import { describe, it, expect, vi, afterEach } from 'vitest';
// Drive getTaskPrompt with a controlled template so the REAL
// resolvePromptPlaceholders (and the real PATHS.worktrees) do the work, without
@@ -8,7 +8,8 @@ vi.mock('./taskSchedule.js', () => ({
getTaskInterval: vi.fn(async () => ({ prompt: 'before {worktreesRoot}/claim-x after' })),
}));
-import { getTaskPrompt } from './taskPromptService.js';
+import { getTaskPrompt, getStagePrompt, DEFAULT_TASK_PROMPTS } from './taskPromptService.js';
+import { getTaskInterval } from './taskSchedule.js';
import { PATHS } from '../lib/fileUtils.js';
describe('taskPromptService {worktreesRoot} substitution', () => {
@@ -24,3 +25,57 @@ describe('taskPromptService {worktreesRoot} substitution', () => {
expect(out).not.toContain('{worktreesRoot}');
});
});
+
+// A pipeline STAGE body (pr-reviewer-security, code-reviewer-review, …) is read
+// straight out of the catalog by its promptKey — it is never persisted and never
+// versioned, which is why editing one takes no PROMPT_VERSIONS bump and no
+// PREVIOUS_DEFAULT_PROMPTS entry (see taskPromptDefaults.test.js). That decision
+// is only safe while stage resolution ignores stored schedule state, so pin the
+// behavior rather than restating the absent constant: hand getStagePrompt an
+// interval carrying a STALE persisted prompt and assert the current catalog body
+// still wins.
+describe('getStagePrompt reads stage bodies from the catalog, not from stored state', () => {
+ it('ignores a stale persisted prompt on the pipeline task and returns the current stage default', async () => {
+ getTaskInterval.mockResolvedValueOnce({
+ prompt: 'STALE PERSISTED BODY that an install upgraded past long ago',
+ promptVersion: 1,
+ taskMetadata: {
+ pipeline: {
+ stages: [
+ { name: 'Security Scan', promptKey: 'pr-reviewer-security' },
+ { name: 'Code Review & Merge', promptKey: 'pr-reviewer-review' },
+ ],
+ },
+ },
+ });
+
+ const stage = await getStagePrompt('pr-reviewer', 0);
+ expect(stage).not.toContain('STALE PERSISTED BODY');
+ // resolvePromptPlaceholders runs over it, so compare on a stable substring
+ // of the catalog body rather than the whole (placeholder-resolved) string.
+ expect(stage).toContain('PR Security Scan (Stage 1)');
+ expect(stage).toContain(DEFAULT_TASK_PROMPTS['pr-reviewer-security'].slice(-80));
+ });
+
+ it('falls back to the task prompt only when the stage carries no promptKey', async () => {
+ // Queued TWICE on purpose: the fallback path re-enters getTaskInterval via
+ // getTaskPrompt, so one …Once would be consumed before the fallback runs and
+ // the assertion would read the module-level default instead. …Once (not
+ // mockResolvedValue) keeps the override from leaking into later tests.
+ const unkeyed = {
+ prompt: 'the task-level body',
+ taskMetadata: { pipeline: { stages: [{ name: 'Unkeyed' }] } },
+ };
+ getTaskInterval.mockResolvedValueOnce(unkeyed).mockResolvedValueOnce(unkeyed);
+
+ await expect(getStagePrompt('pr-reviewer', 0)).resolves.toBe('the task-level body');
+ });
+});
+
+// Every override above is …Once, but reset anyway: a future test that reaches for
+// mockResolvedValue would otherwise silently replace the module-level default for
+// everything declared after it.
+afterEach(() => {
+ vi.mocked(getTaskInterval).mockReset();
+ vi.mocked(getTaskInterval).mockResolvedValue({ prompt: 'before {worktreesRoot}/claim-x after' });
+});
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index ca25240b11..098406d223 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -435,6 +435,9 @@ describe('taskSchedule', () => {
'claim-issue',
'release-check',
'refresh-local-llm-catalog',
+ // glab-flag revision (issue #4685): dependency-updates v3 → v4. Same
+ // contract, so it rides the same walk rather than a parallel describe.
+ 'dependency-updates',
])('%s: an install on the outgoing default auto-upgrades instead of being flagged customized', async (taskType) => {
const previous = PREVIOUS_DEFAULT_PROMPTS[taskType]
const outgoing = previous[previous.length - 1]