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

feat(cos): derive slashdo capability and the launchable-workflow list from one source each

[._.]/ Adam Eivyeb61b707021a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index bfc3efb415..fedc4c3f4d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -19,6 +19,12 @@
- When the system already knows why a run ended — the idle watchdog fired, the runtime budget ran out, the provider CLI wasn't installed — that is now what gets reported. Only a genuine provider or system error in the transcript can override it.
- Failure snippets shown on an agent's record are now short, readable excerpts centered on the actual error instead of raw terminal escape codes. One failed run had been writing an 816KB blob of control characters into its own record.
+## Agent Operations — one workflow catalog
+
+- **[issue-3114] Every bundled slashdo workflow is now offered everywhere it should be.** An app's Overview and the CoS quick templates kept separate lists of which workflows you could launch, and they had drifted: Overview was missing Plan Task, Prune Dependencies, Safety Scan and Replan, while the quick templates were missing Commit and Push and the SwiftUI audit. Both surfaces now read one list, so all ten workflows appear in both.
+- **A non-Claude agent is no longer told to run a command it can't type.** A Codex, Antigravity, Grok, or Kimi terminal agent was handed `/do:pr` in its completion instructions even though those CLIs expose the workflows as skills rather than slash commands — so the last step of its run pointed at nothing. Those agents now get the plain `git`/`gh` finish sequence instead.
+- **A custom-named agent running the real Claude binary now gets the workflow it was denied.** If you configured a provider under your own name (or pointed it at a `claude` install by path), it was treated as a non-Claude CLI: told to just commit and let PortOS push. It now correctly drives its own `/simplify` and PR, and — importantly — the cleanup step agrees, so PortOS no longer tries to open a second pull request for the one the agent already opened.
+
## Agent Operations — `/do:next` run settings
- **`/do:next` on a managed app now asks before it runs.** Clicking it on an app's Overview opens a settings drawer instead of queuing immediately: let the agent pick the next eligible item as before, or **pick a specific one** from a live list of that app's claimable work — PLAN.md items, GitHub or GitLab issues, or current-sprint JIRA tickets, whichever the app's Work Tracker resolves to. A picked item is pinned into the claim prompt, which still honors every safety check (already assigned, blocked, in flight, an epic → exit cleanly).
diff --git a/client/src/components/apps/SlashDoPanel.jsx b/client/src/components/apps/SlashDoPanel.jsx
index 317e4404cf..ed56d1a3ca 100644
--- a/client/src/components/apps/SlashDoPanel.jsx
+++ b/client/src/components/apps/SlashDoPanel.jsx
@@ -3,20 +3,14 @@ import { useNavigate } from 'react-router-dom';
import { Terminal, Loader2 } from 'lucide-react';
import toast from '../ui/Toast';
import { NON_PM2_TYPES } from './constants';
+import { slashdoLabel, slashdoWorkflowsForApp } from '../../lib/slashdoCatalog';
import SlashDoRunDrawer from './SlashDoRunDrawer';
import * as api from '../../services/api';
-const SLASHDO_COMMANDS = [
- { id: 'push', label: '/do:push', description: 'Commit and push all work', classes: 'bg-port-success/20 text-port-success hover:bg-port-success/30 border-port-success/30' },
- { id: 'review', label: '/do:review', description: 'Deep code review', classes: 'bg-port-accent/20 text-port-accent hover:bg-port-accent/30 border-port-accent/30' },
- { id: 'replan', label: '/do:replan', description: 'Audit and prune PLAN.md, removing completed items', classes: 'bg-cyan-500/20 text-cyan-400 hover:bg-cyan-500/30 border-cyan-500/30' },
- // `configurable` routes the click to the pre-flight settings drawer instead of
- // queuing straight away.
- { id: 'next', label: '/do:next', description: "Claim a work item (per this app's Work Tracker) and ship a PR — opens run settings", classes: 'bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 border-blue-500/30', configurable: true },
- { id: 'release', label: '/do:release', description: 'Create a release PR', classes: 'bg-purple-500/20 text-purple-400 hover:bg-purple-500/30 border-purple-500/30' },
- { id: 'better', label: '/do:better', description: 'DevSecOps audit', classes: 'bg-port-warning/20 text-port-warning hover:bg-port-warning/30 border-port-warning/30', hideForSwift: true },
- { id: 'better-swift', label: '/do:better-swift', description: 'SwiftUI DevSecOps audit', classes: 'bg-port-warning/20 text-port-warning hover:bg-port-warning/30 border-port-warning/30', swiftOnly: true }
-];
+// The launchable set comes from `client/src/lib/slashdoCatalog.js` — the mirror of
+// the server catalog that also backs the CoS quick templates and the
+// `POST /api/cos/tasks/slashdo` allowlist (#3114). Adding a workflow there lights
+// it up in every surface at once.
export default function SlashDoPanel({ appId, appName, appType }) {
const [loading, setLoading] = useState(null);
@@ -29,11 +23,7 @@ export default function SlashDoPanel({ appId, appName, appType }) {
const navigate = useNavigate();
const isSwiftApp = NON_PM2_TYPES.has(appType);
- const commands = SLASHDO_COMMANDS.filter(cmd => {
- if (cmd.swiftOnly && !isSwiftApp) return false;
- if (cmd.hideForSwift && isSwiftApp) return false;
- return true;
- });
+ const commands = slashdoWorkflowsForApp(isSwiftApp);
const goToQueue = (label) => {
toast.success(`Queued ${label} agent task`);
@@ -45,13 +35,14 @@ export default function SlashDoPanel({ appId, appName, appType }) {
setDrawerCommand(command);
return;
}
- setLoading(command.id);
- const result = await api.createSlashdoTask(command.id, appId, {}, { silent: true }).catch(err => {
- toast.error(err.message || `Failed to queue ${command.label}`);
+ const label = slashdoLabel(command.command);
+ setLoading(command.command);
+ const result = await api.createSlashdoTask(command.command, appId, {}, { silent: true }).catch(err => {
+ toast.error(err.message || `Failed to queue ${label}`);
return null;
});
setLoading(null);
- if (result) goToQueue(command.label);
+ if (result) goToQueue(label);
};
return (
@@ -60,14 +51,14 @@ export default function SlashDoPanel({ appId, appName, appType }) {
<div className="flex flex-wrap gap-2">
{commands.map(cmd => (
<button
- key={cmd.id}
+ key={cmd.command}
onClick={() => handleRun(cmd)}
disabled={!!loading}
- title={cmd.description}
+ title={cmd.configurable ? `${cmd.description} — opens run settings` : cmd.description}
className={`px-3 py-1.5 ${cmd.classes} rounded-lg text-xs flex items-center gap-1.5 disabled:opacity-50 transition-colors border`}
>
- {loading === cmd.id ? <Loader2 size={14} className="animate-spin" /> : <Terminal size={14} />}
- {cmd.label}
+ {loading === cmd.command ? <Loader2 size={14} className="animate-spin" /> : <Terminal size={14} />}
+ {slashdoLabel(cmd.command)}
</button>
))}
</div>
@@ -76,13 +67,13 @@ export default function SlashDoPanel({ appId, appName, appType }) {
{drawerCommand && (
<SlashDoRunDrawer
open
- command={drawerCommand.id}
- label={drawerCommand.label}
+ command={drawerCommand.command}
+ label={slashdoLabel(drawerCommand.command)}
appId={appId}
appName={appName}
onClose={() => setDrawerCommand(null)}
onQueued={() => {
- const { label } = drawerCommand;
+ const label = slashdoLabel(drawerCommand.command);
setDrawerCommand(null);
goToQueue(label);
}}
diff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsx
index e90deabac9..8721820684 100644
--- a/client/src/components/cos/TaskAddForm.jsx
+++ b/client/src/components/cos/TaskAddForm.jsx
@@ -9,6 +9,7 @@ import { formatBytes } from '../../utils/formatters';
import { filterSelectableModels, isTuiProvider, isCliProvider, isProcessProvider, isCodexProvider } from '../../utils/providers';
import { DEFAULT_PR_COMPLETION, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, PR_COMPLETION_OPTIONS } from './constants';
import { clickableProps } from '../../lib/a11yKeyboard';
+import { slashdoLabel } from '../../lib/slashdoCatalog';
import ReviewerPicker from './ReviewerPicker';
import EffortSelect from './EffortSelect';
@@ -417,14 +418,14 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
onClick={() => applyTemplate(template)}
{...clickableProps(() => applyTemplate(template))}
className="group relative flex items-center gap-1.5 px-3 py-1.5 bg-port-card border border-port-border rounded-lg text-sm text-gray-300 hover:text-white hover:border-port-accent/50 transition-colors cursor-pointer"
- title={template.slashdoCommand ? `/do:${template.slashdoCommand} \u2014 ${template.context || template.description}` : template.description}
+ title={template.slashdoCommand ? `${slashdoLabel(template.slashdoCommand)} \u2014 ${template.context || template.description}` : template.description}
>
<span>{template.icon || '\ud83d\udcdd'}</span>
<span className="max-w-[120px] truncate">{template.name}</span>
{/* The Claude-Code form of the command, as a recognizable label.
The actual invocation is resolved server-side per provider. */}
{template.slashdoCommand && (
- <span className="hidden sm:inline text-xs text-port-accent/80 font-mono">/do:{template.slashdoCommand}</span>
+ <span className="hidden sm:inline text-xs text-port-accent/80 font-mono">{slashdoLabel(template.slashdoCommand)}</span>
)}
{template.useCount > 0 && (
<span className="text-xs text-gray-600">({template.useCount})</span>
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index a419a9b482..83b2d4fa6d 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -44,6 +44,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `grokVideoClip.js` | Mirror of `server/lib/grokVideoClip.js` — `GROK_VIDEO_DURATIONS` (`[6, 10]`) + `GROK_VIDEO_DEFAULT_DURATION`, the clip lengths grok's `image_to_video` actually delivers. |
| `imageCleaners.js` | Mirror of `resolveCleanersFromConfig` from `server/lib/imageClean.js`. Reads `{cleanC2PA, denoise}` off a per-mode settings record. `cleanC2PA` defaults are mode-aware (on for `codex` + `external` — the backends that emit C2PA chunks today — off otherwise, as an allow-list rather than a deny-list); `denoise` defaults off everywhere (lossy, opt-in only). |
| `runnerFamilies.js` | Mirror of `server/lib/runners.js`. |
+| `slashdoCatalog.js` | Mirror of `server/lib/slashdoCatalog.js` — the launchable slashdo workflows (`SLASHDO_WORKFLOWS`, `slashdoWorkflowsForApp(isSwiftApp)`, `SLASHDO_APP_TYPES`) driving the app-overview Agent Operations buttons. Adds only the per-button Tailwind classes; pinned by `server/lib/slashdoCatalog.test.js`. |
| `issueLength.js` | Mirror of `server/lib/issueLength.js`. |
## Pipeline / image-gen defaults
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 76de64bd18..2479275475 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -37,6 +37,7 @@ export * from './muscriptorModels.js';
export * from './pipelineImageDefaults.js';
export * from './reverseOutlineGrid.js';
export * from './runnerFamilies.js';
+export * from './slashdoCatalog.js';
export * from './videoGenParams.js';
export * from './videoGenResolutions.js';
export * from './videoTilingOptions.js';
diff --git a/client/src/lib/slashdoCatalog.js b/client/src/lib/slashdoCatalog.js
new file mode 100644
index 0000000000..ec912f90bb
--- /dev/null
+++ b/client/src/lib/slashdoCatalog.js
@@ -0,0 +1,140 @@
+/**
+ * Client mirror of `server/lib/slashdoCatalog.js` — which bundled slashdo
+ * workflows PortOS offers as a one-click agent run (#3114).
+ *
+ * The server is the source of truth for WHICH workflows exist and what each one
+ * does; this mirror carries only what the client renders (description, app-type
+ * gate, drawer flag) plus the button styling the server has no business knowing.
+ * A parity test in `server/lib/slashdoCatalog.test.js` asserts the two lists agree
+ * on command / description / appTypes / configurable — so adding a workflow
+ * server-side without mirroring it fails the suite rather than silently leaving
+ * the Agent Operations panel a workflow short.
+ *
+ * (The import direction is one-way, matching the `constants.js` app-type mirror:
+ * this module is dependency-free so a server test can import it, while the server
+ * catalog isn't reachable from a Vite client build.)
+ */
+
+/**
+ * slashdo's command namespace. Mirrors `SLASHDO_NAMESPACE` in
+ * `server/lib/slashdoInvocation.js`.
+ */
+export const SLASHDO_NAMESPACE = 'do';
+
+/**
+ * How a slashdo workflow is SPELLED in PortOS UI — `/do:review`. Users know these
+ * workflows by their Claude Code slash-command form, so that's what buttons,
+ * chips, and tooltips show. This is a UI string only: the shape actually sent to
+ * an agent is resolved per provider server-side (`resolveSlashdoInvocation`), and
+ * for a codex/grok host it is a skill name, not a slash command.
+ * @param {string} command - bare command name (`plan-task`)
+ * @returns {string}
+ */
+export function slashdoLabel(command) {
+ return `/${SLASHDO_NAMESPACE}:${command}`;
+}
+
+/** App-type gates — mirrors SLASHDO_APP_TYPES on the server. */
+export const SLASHDO_APP_TYPES = Object.freeze({
+ ANY: 'any',
+ SWIFT: 'swift',
+ NON_SWIFT: 'non-swift',
+});
+
+const CLASSES = {
+ success: 'bg-port-success/20 text-port-success hover:bg-port-success/30 border-port-success/30',
+ accent: 'bg-port-accent/20 text-port-accent hover:bg-port-accent/30 border-port-accent/30',
+ cyan: 'bg-cyan-500/20 text-cyan-400 hover:bg-cyan-500/30 border-cyan-500/30',
+ blue: 'bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 border-blue-500/30',
+ purple: 'bg-purple-500/20 text-purple-400 hover:bg-purple-500/30 border-purple-500/30',
+ warning: 'bg-port-warning/20 text-port-warning hover:bg-port-warning/30 border-port-warning/30',
+ slate: 'bg-slate-500/20 text-slate-300 hover:bg-slate-500/30 border-slate-500/30',
+};
+
+/**
+ * @typedef {Object} SlashdoWorkflowButton
+ * @property {string} command - bare slashdo command name (`plan-task`)
+ * @property {string} description - button tooltip
+ * @property {string} appTypes - one of SLASHDO_APP_TYPES
+ * @property {boolean} [configurable] - opens the run-settings drawer instead of
+ * queuing immediately
+ * @property {string} classes - Tailwind classes for the button
+ */
+
+/** @type {ReadonlyArray<SlashdoWorkflowButton>} */
+export const SLASHDO_WORKFLOWS = Object.freeze([
+ {
+ command: 'plan-task',
+ description: 'Investigate the codebase and file a decision-complete issue',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.slate,
+ },
+ {
+ command: 'next',
+ description: "Claim the next unclaimed work item (per the app's Work Tracker) and ship a PR",
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ configurable: true,
+ classes: CLASSES.blue,
+ },
+ {
+ command: 'replan',
+ description: 'Audit the backlog, archive completed items, prune stale work',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.cyan,
+ },
+ {
+ command: 'review',
+ description: 'Deep code review of the changed files',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.accent,
+ },
+ {
+ command: 'push',
+ description: 'Commit and push all work with a changelog entry',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.success,
+ },
+ {
+ command: 'release',
+ description: 'Create a release PR',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.purple,
+ },
+ {
+ command: 'better',
+ description: 'Run a DevSecOps audit and remediation pass',
+ appTypes: SLASHDO_APP_TYPES.NON_SWIFT,
+ classes: CLASSES.warning,
+ },
+ {
+ command: 'better-swift',
+ description: 'Run a SwiftUI DevSecOps audit and remediation pass',
+ appTypes: SLASHDO_APP_TYPES.SWIFT,
+ classes: CLASSES.warning,
+ },
+ {
+ command: 'depfree',
+ description: 'Audit dependencies and remove the unnecessary ones',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.slate,
+ },
+ {
+ command: 'scan',
+ description: 'Read-only safety audit — malware patterns, network calls, vulnerable deps',
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ classes: CLASSES.slate,
+ },
+]);
+
+/**
+ * The workflows launchable for one app, filtered by its Swift-ness. `better` and
+ * `better-swift` are the same audit for different stacks, so exactly one of them
+ * shows per app.
+ * @param {boolean} isSwiftApp
+ * @returns {SlashdoWorkflowButton[]}
+ */
+export function slashdoWorkflowsForApp(isSwiftApp) {
+ return SLASHDO_WORKFLOWS.filter(w =>
+ w.appTypes === SLASHDO_APP_TYPES.ANY
+ || (isSwiftApp ? w.appTypes === SLASHDO_APP_TYPES.SWIFT : w.appTypes === SLASHDO_APP_TYPES.NON_SWIFT));
+}
diff --git a/server/lib/README.md b/server/lib/README.md
index ddfc7f7fb7..016b462839 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -287,7 +287,8 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `prDisposition.js` | `resolvePrCompletion(metadata)` resolves the explicit `review-then-merge` / `merge-on-green` / `leave-open` policy, with legacy `reviewLoop` fallback; `leavesPrForHuman(task)` + `PR_STAYS_OPEN_TASK_TYPES` keep JIRA hand-offs open. Shared by the agent prompt builder and `agentWorktreeCleanup` so both halves agree. |
| `shellQuote.js` | `shellQuote(value)` — POSIX single-quote escaping for values interpolated into shell command strings (display command lines, copy-paste blocks in agent prompts). Bare-safe tokens pass through; everything else is single-quoted. Canonical escaper — don't hand-roll. |
| `sidecarProcess.js` | `runSidecarProcess({bin,args,env,signal,onStage,onProcess})` + `parseSidecarResult(stdout)` — the shared Python-sidecar STAGE:/RESULT: wire-protocol runner (spawn, tail-capped stdout/stderr, per-STAGE-line callback, abort/SIGTERM → `canceled`, non-zero exit → stderr-tail reason). Used by `pipeline/musicGen.js` (all music backends) and `audioMidiTranscription.js` (MuScriptor). |
-| `slashdoInvocation.js` | Resolves how a bundled slashdo workflow is invoked on a given host CLI. `resolveSlashdoInvocation({command, args, providerId, providerCommand, leanMode})` → `{command, args, style, invocation, skillName}` for the three shapes slashdo's installer produces (`slash-namespaced` `/do:x` for Claude Code, `slash-flat` `/do-x` for OpenCode, `skill` — an Agent Skill selected by name — for codex/grok/antigravity and any unidentified provider). Plus `buildSlashdoSection(resolved, body)` (pure renderer; the caller loads the body via `loadSlashdoFile`), `slashdoSkillName`, and `isValidSlashdoCommand` (the one definition of the safe bare-command shape, also gating the Zod schemas). Provider is only known at spawn time, so a task persists the BARE command name — never a rendered `/do:x` string. |
+| `slashdoCatalog.js` | The single catalog of which bundled slashdo workflows PortOS offers as a one-click agent run — `SLASHDO_WORKFLOWS` (`{command, label, description, icon, templateName, templatePrompt?, settings, appTypes, configurable?}`), `getSlashdoWorkflow()` (the allowlist gate for `POST /api/cos/tasks/slashdo`), `SLASHDO_COMMAND_NAMES`, `slashdoWorkflowsForApp(isSwiftApp)`, `SLASHDO_APP_TYPES`, and `WORKFLOW_OWNS_ITS_OWN_GIT` (the shared run-shape defaults). Backs the Agent Operations buttons, the CoS quick templates (`taskTemplates.js`), and the route allowlist, replacing two catalogs that had drifted. Mirrored in `client/src/lib/slashdoCatalog.js` (button styling only), pinned by `slashdoCatalog.test.js`. |
+| `slashdoInvocation.js` | Resolves how a bundled slashdo workflow is invoked on a given host CLI. `resolveSlashdoInvocation({command, args, providerId, providerCommand, leanMode})` → `{command, args, style, invocation, skillName}` for the three shapes slashdo's installer produces (`slash-namespaced` `/do:x` for Claude Code, `slash-flat` `/do-x` for OpenCode, `skill` — an Agent Skill selected by name — for codex/grok/antigravity and any unidentified provider). Plus `buildSlashdoSection(resolved, body)` (pure renderer; the caller loads the body via `loadSlashdoFile`), `slashdoSkillName`, `isValidSlashdoCommand` (the one definition of the safe bare-command shape, also gating the Zod schemas), and `canTypeSlashCommands()` — the single predicate behind `agentPromptBuilder.js`'s completion-workflow gates (can this session TYPE `/do:pr` / `/simplify`?), which reads `resolveSlashdoStyle`'s `assumeClaudeWhenUnknown` posture because the spawners resolve a blank command to `claude`. Provider is only known at spawn time, so a task persists the BARE command name — never a rendered `/do:x` string. |
| `singleFlight.js` | `createSingleFlight()` → `run(key, fn)` — keyed in-flight coalescer: concurrent calls for the same key share one `fn()` execution and result; the slot auto-clears on settle. Minimal by design (no TTL/result cache layered on top, doesn't reject concurrent callers). Used by `promptRunner.js`'s fallback mark-and-pick. |
| `staticImportGraph.js` | Static ES-module import scanning for structural test guards. `staticImportSpecifiers(file)` → every specifier a file statically imports (verbatim, source order); `staticImportClosure(entry)` → `{files, packages}` for the whole reachable graph; `specifierMatchesPackage(spec, pkg)` matches a package or any subpath. Static imports only — `await import()` is deferred and can't create a load-time cycle or drag a native dep into an init graph. Shared by `agentImportCycles.test.js` (acyclicity) and `sprites/animationTracks.test.js` (the request-validation graph reaches no sharp/ffmpeg). |
| `sseUtils.js` | Per-job SSE stream helpers (imageGen + others) plus `createSseRunner` — the shared batch-runner lifecycle (runs map, terminal-frame replay, cancel, fire-and-forget coordinator) used by the pipeline completeness/analysis/checks runners. |
diff --git a/server/lib/index.js b/server/lib/index.js
index ca613bc1b4..1fe407b9bf 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -258,6 +258,7 @@ export * from './openapiSpec.js';
export * from './prDisposition.js';
export * from './shellQuote.js';
export * from './sidecarProcess.js';
+export * from './slashdoCatalog.js';
export * from './slashdoInvocation.js';
export * from './singleFlight.js';
export * from './staticImportGraph.js';
diff --git a/server/lib/slashdoCatalog.js b/server/lib/slashdoCatalog.js
new file mode 100644
index 0000000000..391dbcf81b
--- /dev/null
+++ b/server/lib/slashdoCatalog.js
@@ -0,0 +1,212 @@
+/**
+ * Launchable slashdo workflows — the single catalog of which bundled
+ * `lib/slashdo/commands/do/*.md` workflows PortOS offers as a one-click agent run
+ * (#3114).
+ *
+ * Before this module there were two catalogs that had already drifted:
+ * `SLASHDO_COMMANDS` in `server/routes/cosTaskRoutes.js` (feeding the app
+ * overview's Agent Operations buttons) and `BUILT_IN_TEMPLATES` in
+ * `server/services/taskTemplates.js` (feeding the CoS quick templates).
+ * `push` / `better-swift` existed only in the first; `plan-task` / `depfree` /
+ * `scan` / `replan` only in the second — so a workflow added to one surface was
+ * silently missing from the other.
+ *
+ * Add a workflow HERE and it appears in every surface: the Agent Operations
+ * buttons, the CoS quick templates, and the `POST /api/cos/tasks/slashdo`
+ * allowlist. `command` is the BARE slashdo command name — never a rendered
+ * `/do:x` string, because the invocation shape is only knowable once a provider
+ * is picked (see `slashdoInvocation.js`).
+ *
+ * Companion to `slashdoInvocation.js`: that module answers "how do I phrase this
+ * workflow for this host", this one answers "which workflows can be launched".
+ */
+
+/**
+ * The run-shape defaults every catalog entry implies. All ten workflows set
+ * `useWorktree`/`openPR`/`simplify` to false, for two distinct reasons:
+ * - plan-task / replan / review / scan write no code at all, so there is
+ * nothing to isolate, PR, or simplify.
+ * - next / better / better-swift / depfree / release / push MANAGE THEIR OWN
+ * worktrees and PRs — a PortOS-level worktree would nest one inside another,
+ * and `release` must run from `main` in the primary checkout.
+ * A key absent from `settings` means "leave the current toggle alone" (the
+ * absent-vs-empty rule) — it does NOT mean false.
+ */
+export const WORKFLOW_OWNS_ITS_OWN_GIT = Object.freeze({ useWorktree: false, openPR: false, simplify: false });
+
+/** App-type gates for the Agent Operations buttons. */
+export const SLASHDO_APP_TYPES = Object.freeze({
+ ANY: 'any',
+ SWIFT: 'swift',
+ NON_SWIFT: 'non-swift',
+});
+
+/**
+ * @typedef {Object} SlashdoWorkflow
+ * @property {string} command - bare slashdo command name (`plan-task`)
+ * @property {string} label - short human name for a button/heading
+ * @property {string} description - one line, shown as button tooltip + task text
+ * @property {string} detail - what the workflow actually does, phrased to follow
+ * "Runs the slashdo <cmd> workflow: …" in a queued task's context
+ * @property {string} icon - emoji for the quick-template chip
+ * @property {string} templateName - quick-template display name
+ * @property {string} [templatePrompt] - trailing fragment appended to the
+ * template's description when the workflow needs a user-typed target
+ * (`Safety scan of: `). Absent ⇒ the description stands alone.
+ * @property {Object} settings - implied run-shape toggles (see WORKFLOW_OWNS_ITS_OWN_GIT)
+ * @property {string} appTypes - one of SLASHDO_APP_TYPES; gates the button only
+ * @property {boolean} [configurable] - the button opens the run-settings drawer
+ * instead of queuing immediately
+ */
+
+/** @type {ReadonlyArray<SlashdoWorkflow>} */
+export const SLASHDO_WORKFLOWS = Object.freeze([
+ {
+ command: 'plan-task',
+ detail: 'investigate the codebase, then file a ready-to-work issue',
+ label: 'Plan Task',
+ description: 'Investigate the codebase and file a decision-complete issue',
+ icon: '📋',
+ templateName: 'Plan a Task',
+ templatePrompt: 'Investigate and file a decision-complete issue for: ',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'next',
+ detail: 'claim an unclaimed item, do the work in its own worktree, ship a PR',
+ label: 'Next',
+ description: "Claim the next unclaimed work item (per the app's Work Tracker) and ship a PR",
+ icon: '🎯',
+ templateName: 'Ship Next Issue',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ // Routes the button to the pre-flight run-settings drawer (which work item
+ // to claim, provider pin, reviewers) instead of queuing straight away.
+ configurable: true,
+ },
+ {
+ command: 'replan',
+ detail: 'prune completed items, suggest new work, keep the plan lean',
+ label: 'Replan',
+ description: 'Audit the backlog, archive completed items, prune stale work',
+ icon: '🗺️',
+ templateName: 'Replan Backlog',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'review',
+ detail: 'review the changed files against software engineering best practices',
+ label: 'Review',
+ description: 'Deep code review of the changed files',
+ icon: '🔍',
+ templateName: 'Review Changes',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'push',
+ detail: 'stage the files you changed, write a conventional commit and changelog entry, push safely',
+ label: 'Push',
+ description: 'Commit and push all work with a changelog entry',
+ icon: '📤',
+ templateName: 'Commit and Push',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'release',
+ detail: 'follow the project\'s documented release process to open a release PR',
+ label: 'Release',
+ description: 'Create a release PR',
+ icon: '🚀',
+ templateName: 'Cut a Release',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'better',
+ detail: 'audit, remediate, enhance tests, open per-category PRs',
+ label: 'Better',
+ description: 'Run a DevSecOps audit and remediation pass',
+ icon: '🛡️',
+ templateName: 'DevSecOps Audit',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.NON_SWIFT,
+ },
+ {
+ command: 'better-swift',
+ detail: 'audit and remediate a multi-platform Swift/SwiftUI app, enhance tests, open per-category PRs',
+ label: 'Better Swift',
+ description: 'Run a SwiftUI DevSecOps audit and remediation pass',
+ icon: '🛡️',
+ templateName: 'SwiftUI DevSecOps Audit',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.SWIFT,
+ },
+ {
+ command: 'depfree',
+ detail: 'audit third-party deps and replace the removable ones with code',
+ label: 'Depfree',
+ description: 'Audit dependencies and remove the unnecessary ones',
+ icon: '📦',
+ templateName: 'Prune Dependencies',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+ {
+ command: 'scan',
+ detail: 'flag malware patterns, network calls, and vulnerable deps without executing anything',
+ label: 'Scan',
+ description: 'Read-only safety audit — malware patterns, network calls, vulnerable deps',
+ icon: '🔒',
+ templateName: 'Safety Scan',
+ templatePrompt: 'Read-only safety audit of: ',
+ settings: WORKFLOW_OWNS_ITS_OWN_GIT,
+ appTypes: SLASHDO_APP_TYPES.ANY,
+ },
+]);
+
+/** Bare command name → catalog entry. */
+const BY_COMMAND = new Map(SLASHDO_WORKFLOWS.map(w => [w.command, w]));
+
+/**
+ * The catalog entry for a bare command name, or null when the command isn't a
+ * launchable workflow. Callers use this as the allowlist gate — a command that
+ * resolves to null must not be queued. A `Map` lookup (not a plain object) so
+ * prototype keys like `constructor` can't resolve.
+ * @param {unknown} command
+ * @returns {SlashdoWorkflow|null}
+ */
+export function getSlashdoWorkflow(command) {
+ return BY_COMMAND.get(command) || null;
+}
+
+/**
+ * True when `workflow` applies to an app of this stack. `better` and
+ * `better-swift` are the same audit for different stacks, so exactly one of the
+ * two applies per app — every other workflow applies to both.
+ * @param {SlashdoWorkflow} workflow
+ * @param {boolean} isSwiftApp
+ * @returns {boolean}
+ */
+export function slashdoWorkflowAppliesTo(workflow, isSwiftApp) {
+ if (workflow?.appTypes === SLASHDO_APP_TYPES.ANY) return true;
+ return workflow?.appTypes === (isSwiftApp ? SLASHDO_APP_TYPES.SWIFT : SLASHDO_APP_TYPES.NON_SWIFT);
+}
+
+/**
+ * The workflows launchable for one app. Mirrored in
+ * `client/src/lib/slashdoCatalog.js`, which drives the Agent Operations buttons;
+ * the route uses `slashdoWorkflowAppliesTo` to reject a mismatched command rather
+ * than trusting the client to only offer applicable ones.
+ * @param {boolean} isSwiftApp
+ * @returns {SlashdoWorkflow[]}
+ */
+export function slashdoWorkflowsForApp(isSwiftApp) {
+ return SLASHDO_WORKFLOWS.filter(w => slashdoWorkflowAppliesTo(w, isSwiftApp));
+}
+
+/** Every launchable command name, in catalog order. */
+export const SLASHDO_COMMAND_NAMES = Object.freeze(SLASHDO_WORKFLOWS.map(w => w.command));
diff --git a/server/lib/slashdoCatalog.test.js b/server/lib/slashdoCatalog.test.js
new file mode 100644
index 0000000000..4feaf23588
--- /dev/null
+++ b/server/lib/slashdoCatalog.test.js
@@ -0,0 +1,152 @@
+import { describe, it, expect } from 'vitest';
+import { readdir } from 'fs/promises';
+import { join } from 'path';
+import {
+ SLASHDO_APP_TYPES,
+ SLASHDO_COMMAND_NAMES,
+ SLASHDO_WORKFLOWS,
+ WORKFLOW_OWNS_ITS_OWN_GIT,
+ getSlashdoWorkflow,
+ slashdoWorkflowAppliesTo,
+ slashdoWorkflowsForApp,
+} from './slashdoCatalog.js';
+import { isValidSlashdoCommand, SLASHDO_NAMESPACE } from './slashdoInvocation.js';
+import { PATHS } from './fileUtils.js';
+
+describe('SLASHDO_WORKFLOWS', () => {
+ it('carries every field the consuming surfaces read', () => {
+ for (const w of SLASHDO_WORKFLOWS) {
+ expect(isValidSlashdoCommand(w.command)).toBe(true);
+ expect(w.label).toBeTruthy();
+ expect(w.description).toBeTruthy();
+ expect(w.detail).toBeTruthy();
+ expect(w.icon).toBeTruthy();
+ expect(w.templateName).toBeTruthy();
+ expect(w.settings).toBe(WORKFLOW_OWNS_ITS_OWN_GIT);
+ expect(Object.values(SLASHDO_APP_TYPES)).toContain(w.appTypes);
+ }
+ });
+
+ it('has no duplicate commands', () => {
+ expect(new Set(SLASHDO_COMMAND_NAMES).size).toBe(SLASHDO_COMMAND_NAMES.length);
+ });
+
+ // The pre-#3114 drift: `push`/`better-swift` existed only in the route registry,
+ // `plan-task`/`depfree`/`scan`/`replan` only in the quick templates. The union is
+ // now one list, so both surfaces offer all ten.
+ it('is the union of the two pre-convergence catalogs', () => {
+ for (const command of [
+ 'plan-task', 'next', 'replan', 'review', 'push',
+ 'release', 'better', 'better-swift', 'depfree', 'scan',
+ ]) {
+ expect(SLASHDO_COMMAND_NAMES).toContain(command);
+ }
+ });
+
+ it('names only commands the bundled slashdo submodule actually ships', async () => {
+ // A catalog entry with no `commands/do/<cmd>.md` would queue a task whose body
+ // can never load. Skipped when the submodule isn't checked out. `readdir` (not
+ // `loadSlashdoFile`) because that helper can't distinguish "submodule absent"
+ // from "command missing".
+ const files = await readdir(join(PATHS.slashdo, 'commands/do')).catch(() => null);
+ if (!files) return;
+ const shipped = new Set(files.filter(f => f.endsWith('.md')).map(f => f.replace(/\.md$/, '')));
+ for (const command of SLASHDO_COMMAND_NAMES) {
+ expect(shipped, `slashdo ships commands/do/${command}.md`).toContain(command);
+ }
+ });
+});
+
+describe('getSlashdoWorkflow', () => {
+ it('resolves a launchable command', () => {
+ expect(getSlashdoWorkflow('next')?.label).toBe('Next');
+ });
+
+ it('applies the app-type gate', () => {
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('review'), false)).toBe(true);
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('review'), true)).toBe(true);
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('better'), false)).toBe(true);
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('better'), true)).toBe(false);
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('better-swift'), true)).toBe(true);
+ expect(slashdoWorkflowAppliesTo(getSlashdoWorkflow('better-swift'), false)).toBe(false);
+ // A null workflow (unknown command) applies to nothing.
+ expect(slashdoWorkflowAppliesTo(null, false)).toBe(false);
+ });
+
+ it('returns null for anything not in the catalog — it is the allowlist gate', () => {
+ // `rpr`/`config`/`help` ship with slashdo but are not one-click launchable.
+ expect(getSlashdoWorkflow('rpr')).toBeNull();
+ expect(getSlashdoWorkflow('help')).toBeNull();
+ expect(getSlashdoWorkflow('../../etc/passwd')).toBeNull();
+ expect(getSlashdoWorkflow('')).toBeNull();
+ expect(getSlashdoWorkflow(null)).toBeNull();
+ // A `Map` lookup is what makes prototype keys safe (a plain object would
+ // resolve these to Object.prototype members).
+ expect(getSlashdoWorkflow('constructor')).toBeNull();
+ expect(getSlashdoWorkflow('__proto__')).toBeNull();
+ });
+});
+
+describe('slashdoWorkflowsForApp', () => {
+ it('offers better to a non-Swift app and better-swift to a Swift app, never both', () => {
+ const nonSwift = slashdoWorkflowsForApp(false).map(w => w.command);
+ expect(nonSwift).toContain('better');
+ expect(nonSwift).not.toContain('better-swift');
+
+ const swift = slashdoWorkflowsForApp(true).map(w => w.command);
+ expect(swift).toContain('better-swift');
+ expect(swift).not.toContain('better');
+ });
+
+ it('keeps every ANY workflow for both app kinds', () => {
+ const anyCommands = SLASHDO_WORKFLOWS
+ .filter(w => w.appTypes === SLASHDO_APP_TYPES.ANY).map(w => w.command);
+ for (const isSwift of [false, true]) {
+ const offered = slashdoWorkflowsForApp(isSwift).map(w => w.command);
+ expect(offered).toEqual(expect.arrayContaining(anyCommands));
+ }
+ });
+});
+
+// The client mirror drives the Agent Operations buttons. The assertion lives HERE
+// (not in a client test) and the import direction is one-way, matching the
+// app-type mirror in streamingDetect.test.js: the client module is
+// dependency-free so a server test can import it, while this catalog isn't
+// reachable from a Vite client build.
+describe('client mirror of the launchable-workflow catalog', () => {
+ // Only the fields the client actually renders — the mirror deliberately drops
+ // `icon`/`templateName`/`settings` (server-only) rather than carrying unread
+ // copies of them.
+ it('agrees on the command list and every field the client renders', async () => {
+ const client = await import('../../client/src/lib/slashdoCatalog.js');
+ const strip = (w) => ({
+ command: w.command,
+ description: w.description,
+ appTypes: w.appTypes,
+ configurable: w.configurable === true,
+ });
+ expect(client.SLASHDO_WORKFLOWS.map(strip)).toEqual(SLASHDO_WORKFLOWS.map(strip));
+ });
+
+ it('agrees on the slash-command spelling used in the UI', async () => {
+ const client = await import('../../client/src/lib/slashdoCatalog.js');
+ expect(client.SLASHDO_NAMESPACE).toBe(SLASHDO_NAMESPACE);
+ for (const command of SLASHDO_COMMAND_NAMES) {
+ expect(client.slashdoLabel(command)).toBe(`/${SLASHDO_NAMESPACE}:${command}`);
+ }
+ });
+
+ it('agrees on the app-type vocabulary and the per-app filter', async () => {
+ const client = await import('../../client/src/lib/slashdoCatalog.js');
+ expect(client.SLASHDO_APP_TYPES).toEqual(SLASHDO_APP_TYPES);
+ for (const isSwift of [false, true]) {
+ expect(client.slashdoWorkflowsForApp(isSwift).map(w => w.command))
+ .toEqual(slashdoWorkflowsForApp(isSwift).map(w => w.command));
+ }
+ });
+
+ it('gives every button a style class', async () => {
+ const client = await import('../../client/src/lib/slashdoCatalog.js');
+ for (const w of client.SLASHDO_WORKFLOWS) expect(w.classes).toBeTruthy();
+ });
+});
diff --git a/server/lib/slashdoInvocation.js b/server/lib/slashdoInvocation.js
index 32498a5ed8..b781a8e6e4 100644
--- a/server/lib/slashdoInvocation.js
+++ b/server/lib/slashdoInvocation.js
@@ -22,6 +22,7 @@
* fallback that works even when that environment has no slashdo install at all.
*/
import { isClaudeProvider, isOpencodeProvider } from './providerModels.js';
+import { inferTuiCommand } from './tuiHandshake.js';
/** slashdo's command namespace — `commands/do/<cmd>.md` in the submodule. */
export const SLASHDO_NAMESPACE = 'do';
@@ -68,31 +69,94 @@ export function slashdoSkillName(command) {
* `agentPromptBuilder.js` derive from this rather than re-deriving it).
*
* Detection reuses the shared provider predicates, so a path-configured or
- * renamed binary is recognised. An unidentified provider — including a blank
- * command, which `isClaudeProvider` deliberately does NOT treat as Claude —
- * falls through to `skill`; guessing `/do:<cmd>` for an unknown host would hand
- * it a line of prose it can't run, while `skill` always works because the
- * caller inlines the procedure.
+ * renamed binary is recognised. An unidentified provider falls through to
+ * `skill`; guessing `/do:<cmd>` for an unknown host would hand it a line of
+ * prose it can't run, while `skill` always works because the caller inlines the
+ * procedure.
*
* `leanMode` (small local models behind `claude --bare`) also resolves to
* `skill`: the lean session skips project command discovery, so `/do:<cmd>`
* would resolve to nothing.
*
+ * **Unknown-command posture (`assumeClaudeWhenUnknown`).** A provider with no
+ * launch command is genuinely ambiguous, and the two kinds of caller want
+ * opposite answers:
+ * - **Rendering an invocation for a task** (default, `false`): stay strict, like
+ * `isClaudeProvider`. Printing `/do:next` for a host that turns out not to be
+ * Claude hands the agent an uninvokable line; `skill` + the inlined body works
+ * everywhere, so "unknown" must not read as Claude.
+ * - **Deciding whether a spawned agent may TYPE `/do:pr`** (`true`): the answer
+ * must match the command the spawners will ACTUALLY launch, which for a blank
+ * `provider.command` is `inferTuiCommand(provider.id)` — the same fallback
+ * `agentTuiSpawning.js` and `buildCliSpawnConfig` both apply. So this posture
+ * resolves the command the spawner would pick rather than guessing: a custom
+ * provider id with no command launches `claude` and IS slashdo-capable, while
+ * `codex-tui` with no command launches `codex` and is not.
+ * Only the blank-command case is affected — a provider that names its command
+ * resolves the same under either posture.
+ *
* @param {Object} [opts]
* @param {string|null} [opts.providerId]
* @param {string|null} [opts.providerCommand]
* @param {boolean} [opts.leanMode]
+ * @param {boolean} [opts.assumeClaudeWhenUnknown=false] - when the provider names
+ * no command, resolve the one the spawners would infer from its id instead of
+ * falling through to `skill`.
* @returns {string} one of SLASHDO_INVOCATION_STYLES
*/
-export function resolveSlashdoStyle({ providerId = null, providerCommand = null, leanMode = false } = {}) {
- const provider = { id: providerId, command: providerCommand };
+export function resolveSlashdoStyle({
+ providerId = null,
+ providerCommand = null,
+ leanMode = false,
+ assumeClaudeWhenUnknown = false,
+} = {}) {
+ // A blank command is only resolved for the spawner posture; the strict default
+ // deliberately leaves it blank so `isClaudeProvider` won't read it as Claude.
+ const command = (assumeClaudeWhenUnknown && !providerCommand)
+ ? inferTuiCommand(providerId)
+ : providerCommand;
+ const provider = { id: providerId, command };
if (isOpencodeProvider(provider)) return SLASHDO_INVOCATION_STYLES.SLASH_FLAT;
- if (!leanMode && isClaudeProvider(provider)) return SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED;
+ if (leanMode) return SLASHDO_INVOCATION_STYLES.SKILL;
+ if (isClaudeProvider(provider)) return SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED;
// Codex / Grok / Antigravity install Agent Skills, not slash commands — as
// does anything we can't positively identify.
return SLASHDO_INVOCATION_STYLES.SKILL;
}
+/**
+ * True when a session can be handed a typed Claude Code slash command — both the
+ * slashdo ones (`/do:pr`, `/do:push`) and Claude's own built-ins (`/simplify`).
+ * `SLASH_NAMESPACED` is exactly the Claude-Code-with-project-commands case, so
+ * one predicate answers both: OpenCode gets `SLASH_FLAT` (no `/do:pr`, no
+ * `/simplify`), codex/grok/antigravity get `SKILL`, and a lean `--bare` session
+ * gets `SKILL` because it skips command discovery entirely.
+ *
+ * This is the single home for the completion-workflow gates in
+ * `agentPromptBuilder.js` (formerly three inline provider-id allowlists:
+ * `hasSlashdo`, `tuiSlashdoFree`, and the guideline-bullet `slashdoFree`). It
+ * uses the `assumeClaudeWhenUnknown` posture because those gates describe a
+ * session the spawners are about to launch, and every spawner resolves a blank
+ * command to `claude`.
+ *
+ * `assumeClaudeWhenUnknown` defaults to `true` here (unlike `resolveSlashdoStyle`)
+ * because the callers are describing a CLI/TUI session about to be spawned. An
+ * HTTP-API provider is never spawned as a local CLI, so the API path passes
+ * `false` — a blank provider there is not a latent `claude`.
+ *
+ * @param {Object} [opts] - same shape as `resolveSlashdoStyle`
+ * @returns {boolean}
+ */
+export function canTypeSlashCommands({
+ providerId = null,
+ providerCommand = null,
+ leanMode = false,
+ assumeClaudeWhenUnknown = true,
+} = {}) {
+ return resolveSlashdoStyle({ providerId, providerCommand, leanMode, assumeClaudeWhenUnknown })
+ === SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED;
+}
+
/**
* Resolve the concrete invocation for a slashdo-backed task.
*
diff --git a/server/lib/slashdoInvocation.test.js b/server/lib/slashdoInvocation.test.js
index a19c266925..a1dcdc698b 100644
--- a/server/lib/slashdoInvocation.test.js
+++ b/server/lib/slashdoInvocation.test.js
@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
import {
SLASHDO_INVOCATION_STYLES,
buildSlashdoSection,
+ canTypeSlashCommands,
isValidSlashdoCommand,
resolveSlashdoInvocation,
resolveSlashdoStyle,
@@ -72,6 +73,76 @@ describe('resolveSlashdoStyle', () => {
expect(resolveSlashdoStyle({ providerId: 'claude-ollama', providerCommand: 'claude', leanMode: true }))
.toBe(SLASHDO_INVOCATION_STYLES.SKILL);
});
+
+ describe('assumeClaudeWhenUnknown (#3114)', () => {
+ // The posture resolves the command the SPAWNERS would infer from a blank
+ // `provider.command` (inferTuiCommand — the same fallback agentTuiSpawning.js
+ // and buildCliSpawnConfig apply), rather than guessing "blank means Claude".
+ it('resolves a blank command through the spawner fallback', () => {
+ expect(resolveSlashdoStyle({ assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ // A custom provider id with no command launches `claude`, so it IS
+ // slashdo-capable — the case a naive `!providerId && !providerCommand`
+ // check would have missed.
+ expect(resolveSlashdoStyle({ providerId: 'my-custom-agent', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ });
+
+ it('honors the id when the spawner fallback resolves a non-Claude command', () => {
+ // `codex-tui` with no command launches `codex`, which gets skills.
+ expect(resolveSlashdoStyle({ providerId: 'codex-tui', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerId: 'antigravity-tui', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerId: 'kimi-tui', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+
+ it('never overrides a command the provider actually names', () => {
+ expect(resolveSlashdoStyle({ providerCommand: 'agy', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerCommand: 'codex', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerId: 'opencode-tui', providerCommand: 'opencode', assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_FLAT);
+ });
+
+ it('lean mode still wins over the spawner-inferred command', () => {
+ expect(resolveSlashdoStyle({ leanMode: true, assumeClaudeWhenUnknown: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+
+ it('leaves the strict default untouched — a blank command is never read as Claude', () => {
+ expect(resolveSlashdoStyle({})).toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerId: 'my-custom-agent' })).toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+ });
+});
+
+describe('canTypeSlashCommands', () => {
+ it('is true only for a Claude session that loaded its project commands', () => {
+ expect(canTypeSlashCommands({ providerId: 'claude-code' })).toBe(true);
+ expect(canTypeSlashCommands({ providerId: 'claude-code-tui', providerCommand: 'claude' })).toBe(true);
+ // Path-configured / renamed claude under a custom id — the case the old
+ // inline id allowlist in agentPromptBuilder.js missed.
+ expect(canTypeSlashCommands({ providerId: 'my-agent', providerCommand: '/opt/homebrew/bin/claude' })).toBe(true);
+ });
+
+ it('is false for every host that gets skills or flat commands', () => {
+ for (const providerId of ['codex', 'codex-tui', 'grok-tui', 'antigravity-tui', 'kimi-tui']) {
+ expect(canTypeSlashCommands({ providerId })).toBe(false);
+ }
+ expect(canTypeSlashCommands({ providerId: 'opencode-ollama-tui', providerCommand: 'opencode' })).toBe(false);
+ expect(canTypeSlashCommands({ providerId: 'claude-ollama-tui', providerCommand: 'claude', leanMode: true })).toBe(false);
+ });
+
+ it('defaults to the spawner posture but honors an explicit opt-out', () => {
+ expect(canTypeSlashCommands({})).toBe(true);
+ expect(canTypeSlashCommands({ providerId: 'my-custom-agent' })).toBe(true);
+ // The api path opts out: an unidentified HTTP-API provider is not a latent
+ // local `claude` the way a blank CLI/TUI provider is.
+ expect(canTypeSlashCommands({ assumeClaudeWhenUnknown: false })).toBe(false);
+ });
});
describe('resolveSlashdoInvocation', () => {
diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.js
index 6bbb2ddebd..6169c4da68 100644
--- a/server/lib/tuiHandshake.js
+++ b/server/lib/tuiHandshake.js
@@ -761,12 +761,27 @@ export const RAW_SPOOL_MAX_BYTES = 256 * 1024 * 1024;
// ─── Command + args helpers ───────────────────────────────────────────────
+/**
+ * The launch command a TUI provider gets when it names none — the spawners'
+ * blank-`provider.command` fallback (`buildTuiSpawnConfig`, and mirrored by
+ * `buildCliSpawnConfig`'s default branch). An unrecognized id resolves to
+ * `claude`, matching `isClaudeCommand`'s blank-is-Claude policy.
+ *
+ * Also read by `resolveSlashdoStyle`'s `assumeClaudeWhenUnknown` posture, which
+ * asks "which command will actually be spawned?" before deciding whether the
+ * session can type `/do:pr` — so a missing signature here means a provider is
+ * told to run slash commands its real binary doesn't have.
+ * @param {string|null|undefined} id - provider id
+ * @returns {string}
+ */
export function inferTuiCommand(id) {
if (!id) return 'claude';
if (id.includes('codex')) return 'codex';
if (id.includes('antigravity')) return 'agy';
if (id.includes('gemini')) return 'gemini';
if (id.includes('kimi')) return 'kimi';
+ if (id.includes('grok')) return 'grok';
+ if (id.includes('opencode')) return 'opencode';
return 'claude';
}
diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.js
index b49d4764af..b9700c7761 100644
--- a/server/lib/tuiHandshake.test.js
+++ b/server/lib/tuiHandshake.test.js
@@ -456,6 +456,14 @@ describe('tuiHandshake.inferTuiCommand', () => {
['anthropic-claude-code', 'claude'],
['kimi-tui', 'kimi'],
['moonshot-kimi-2', 'kimi'],
+ // grok / opencode were missing, so a blank-command provider under either id
+ // silently resolved to `claude` — which also told it (via
+ // resolveSlashdoStyle's spawner posture) to type `/do:pr` commands its real
+ // binary doesn't have.
+ ['grok-tui', 'grok'],
+ ['xai-grok-2', 'grok'],
+ ['opencode-tui', 'opencode'],
+ ['opencode-ollama-tui', 'opencode'],
])('inferTuiCommand(%p) → %p', (id, expected) => {
expect(inferTuiCommand(id)).toBe(expected);
});
diff --git a/server/routes/brainLinks.js b/server/routes/brainLinks.js
index 8bea2873b4..dfb11b5713 100644
--- a/server/routes/brainLinks.js
+++ b/server/routes/brainLinks.js
@@ -21,7 +21,6 @@ import {
bucketReorderSchema
} from '../lib/brainValidation.js';
import * as githubCloner from '../services/githubCloner.js';
-import { loadSlashdoCommand } from '../services/subAgentSpawner.js';
import * as cos from '../services/cos.js';
const router = Router();
@@ -273,26 +272,20 @@ router.post('/links/:id/scan', asyncHandler(async (req, res) => {
});
}
- const scanCommand = await loadSlashdoCommand('scan');
- if (!scanCommand) {
- throw new ServerError('Failed to load do:scan command', {
- status: 500,
- code: 'COMMAND_LOAD_FAILED'
- });
- }
-
const repoLabel = link.title || link.url;
- const description = `Malware scan: ${repoLabel} (do:scan)`;
- const context = `Run the /do:scan workflow against the cloned repository at: \`${link.localPath}\`
-
-Use that path as SCAN_DIR. Adhere to every Operational Invariant in the command body — this is a hostile-until-proven-safe audit. The full markdown report will be written to ~/.claude/scans/. When complete, summarize the verdict (CLEAN / CAUTION / DANGEROUS) and the top findings in your final response so the report can be surfaced in the UI.
-
----
+ const description = `Malware scan: ${repoLabel}`;
+ // Carry the BARE command (`metadata.slashdoCommand`) rather than inlining the
+ // ~65KB expanded body here: the prompt builder renders the right invocation
+ // shape once the provider is known AND inlines the body then (a codex host gets
+ // a skill, not `/do:scan`). Inlining here also persisted the whole body as one
+ // line of TASKS.md, rewritten on every task mutation and shipped in each
+ // peer-sync payload. Matches POST /api/cos/tasks/slashdo (#3114).
+ const context = `Run the scan workflow against the cloned repository at: \`${link.localPath}\`
-${scanCommand}`;
+Use that path as SCAN_DIR. Adhere to every Operational Invariant in the workflow body — this is a hostile-until-proven-safe audit. The full markdown report will be written to ~/.claude/scans/. When complete, summarize the verdict (CLEAN / CAUTION / DANGEROUS) and the top findings in your final response so the report can be surfaced in the UI.`;
const result = await cos.addTask(
- { description, context, useWorktree: false, openPR: false, simplify: false, reviewLoop: false },
+ { description, context, slashdoCommand: 'scan', useWorktree: false, openPR: false, simplify: false, reviewLoop: false },
'user'
);
if (result?.duplicate) {
diff --git a/server/routes/cos.test.js b/server/routes/cos.test.js
index 7b9e9a8b8e..d1b300b4b5 100644
--- a/server/routes/cos.test.js
+++ b/server/routes/cos.test.js
@@ -909,15 +909,20 @@ describe('CoS Routes', () => {
});
describe('POST /api/cos/tasks/slashdo', () => {
+ // The catalog's full launchable set (#3114) — `push`/`better-swift` used to
+ // exist only in this route's registry and `plan-task`/`depfree`/`scan` only in
+ // the quick templates; both surfaces now read one list.
it.each([
+ 'plan-task',
'push',
'review',
'replan',
'release',
'better',
- 'better-swift'
+ 'depfree',
+ 'scan'
])('should create a task from slashdo command %s', async (command) => {
- loadSlashdoCommand.mockResolvedValue('command content');
+ getAppById.mockResolvedValue({ id: 'my-app', name: 'MyApp', type: 'web', repoPath: '/repo' });
cos.addTask.mockResolvedValue({ id: `task-sd-${command}`, status: 'pending' });
const response = await request(app)
@@ -926,7 +931,58 @@ describe('CoS Routes', () => {
expect(response.status).toBe(200);
expect(response.body.id).toBe(`task-sd-${command}`);
- expect(loadSlashdoCommand).toHaveBeenCalledWith(command);
+ // The route persists the BARE command and lets the prompt builder render
+ // the invocation + inline the body once the provider is known — it no
+ // longer eagerly loads the body or hardcodes `/do:` into the description
+ // (both assumed a Claude host that can type slash commands).
+ const [taskData] = cos.addTask.mock.calls.at(-1);
+ expect(taskData.slashdoCommand).toBe(command);
+ expect(taskData.context).toBeUndefined();
+ expect(taskData.description).not.toContain('/do:');
+ // The app's display NAME, not its id slug — matching the `next` branch.
+ expect(taskData.description).toContain('MyApp');
+ expect(loadSlashdoCommand).not.toHaveBeenCalled();
+ });
+
+ it('queues the SwiftUI audit for a Swift app', async () => {
+ getAppById.mockResolvedValue({ id: 'my-ios', name: 'MyPhone', type: 'ios-native', repoPath: '/repo' });
+ cos.addTask.mockResolvedValue({ id: 'task-sd-swift', status: 'pending' });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/slashdo')
+ .send({ command: 'better-swift', app: 'my-ios' });
+
+ expect(response.status).toBe(200);
+ expect(cos.addTask.mock.calls.at(-1)[0].slashdoCommand).toBe('better-swift');
+ });
+
+ // The panel only offers the applicable one of better / better-swift, but the
+ // API must not trust that — a mismatched audit burns an agent run on a
+ // workflow that can't apply to the app's stack.
+ it.each([
+ ['better-swift', 'web'],
+ ['better', 'ios-native']
+ ])('rejects %s against an app of type %s', async (command, type) => {
+ getAppById.mockResolvedValue({ id: 'a', name: 'App', type, repoPath: '/repo' });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/slashdo')
+ .send({ command, app: 'a' });
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('WORKFLOW_APP_TYPE_MISMATCH');
+ expect(cos.addTask).not.toHaveBeenCalled();
+ });
+
+ it('404s an unknown app for every command, not just next', async () => {
+ getAppById.mockResolvedValue(null);
+
+ const response = await request(app)
+ .post('/api/cos/tasks/slashdo')
+ .send({ command: 'push', app: 'ghost-app' });
+
+ expect(response.status).toBe(404);
+ expect(cos.addTask).not.toHaveBeenCalled();
});
it('routes /do:next through the app Work Tracker instead of the raw command', async () => {
@@ -952,6 +1008,11 @@ describe('CoS Routes', () => {
const [taskData] = cos.addTask.mock.calls.at(-1);
expect(taskData.context).toBe('CLAIM ISSUE PROMPT');
expect(taskData.description).toContain('GitHub Issues');
+ // `next` is the one genuinely special command: its claim prompt IS the
+ // context, so it must NOT also carry a slashdoCommand (which would make the
+ // prompt builder append the whole /do:next body on top of the claim prompt).
+ expect(taskData.slashdoCommand).toBeUndefined();
+ expect(taskData.description).not.toContain('/do:');
});
it('threads the run drawer settings — target/author-filter/reviewers into the claim prompt, provider/model/effort/simplify onto the task', async () => {
@@ -1033,7 +1094,7 @@ describe('CoS Routes', () => {
});
it('should return 409 for duplicate task', async () => {
- loadSlashdoCommand.mockResolvedValue('command content');
+ getAppById.mockResolvedValue({ id: 'my-app', name: 'MyApp', type: 'web', repoPath: '/repo' });
cos.addTask.mockResolvedValue({ duplicate: true, status: 'pending' });
const response = await request(app)
diff --git a/server/routes/cosTaskRoutes.js b/server/routes/cosTaskRoutes.js
index c559bc2187..3a05431448 100644
--- a/server/routes/cosTaskRoutes.js
+++ b/server/routes/cosTaskRoutes.js
@@ -7,10 +7,11 @@ import { z } from 'zod';
import * as cos from '../services/cos.js';
import * as taskWatcher from '../services/taskWatcher.js';
import { enhanceTaskPrompt } from '../services/taskEnhancer.js';
-import { loadSlashdoCommand } from '../services/subAgentSpawner.js';
import { buildClaimWorkTask, buildJiraTicketTask } from '../services/cosTaskGenerator.js';
import { getAppById } from '../services/apps.js';
import { workTrackerLabel } from '../lib/workTracker.js';
+import { getSlashdoWorkflow, slashdoWorkflowAppliesTo, SLASHDO_COMMAND_NAMES } from '../lib/slashdoCatalog.js';
+import { NON_PM2_TYPES } from '../services/streamingDetect.js';
import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.js';
import {
createCosTaskSchema,
@@ -35,16 +36,6 @@ const jiraTicketTaskSchema = z.object({
ticketKey: z.string().trim().regex(/^[A-Za-z][A-Za-z0-9]*-\d+$/, 'Invalid JIRA ticket key'),
});
-const SLASHDO_COMMANDS = {
- push: { label: 'Push', description: 'Commit and push all work with changelog' },
- review: { label: 'Review', description: 'Deep code review of changed files' },
- replan: { label: 'Replan', description: 'Audit PLAN.md, archive completed items, prune stale work' },
- next: { label: 'Next', description: 'Claim the next unclaimed work item (per the app\'s Work Tracker) and ship a PR' },
- release: { label: 'Release', description: 'Create a release PR' },
- better: { label: 'Better', description: 'Unified DevSecOps audit and remediation' },
- 'better-swift': { label: 'Better Swift', description: 'SwiftUI DevSecOps audit and remediation' }
-};
-
const router = Router();
// GET /api/cos/tasks - Get all tasks (user + internal), grouped by source.
@@ -124,55 +115,93 @@ router.post('/tasks/enhance', asyncHandler(async (req, res) => {
// provider/model/effort pin and `simplify` apply to every command; `target`,
// `issueAuthorFilter`, and the reviewer choices are `/do:next`-only (they shape
// the claim prompt, which self-manages its own PR + review loop).
+//
+// The launchable-command allowlist is the shared catalog in
+// `server/lib/slashdoCatalog.js` (#3114) — the CoS quick templates read the same
+// source, so the two surfaces can't drift.
router.post('/tasks/slashdo', asyncHandler(async (req, res) => {
const {
command, app, provider, model, effort, simplify,
target, issueAuthorFilter, reviewers, usernames, optionalReviewers
} = validateRequest(slashdoTaskSchema, req.body);
- if (!SLASHDO_COMMANDS[command]) {
- throw new ServerError(`Invalid slashdo command. Allowed: ${Object.keys(SLASHDO_COMMANDS).join(', ')}`, { status: 400, code: 'VALIDATION_ERROR' });
+ const workflow = getSlashdoWorkflow(command);
+ if (!workflow) {
+ throw new ServerError(`Invalid slashdo command. Allowed: ${SLASHDO_COMMAND_NAMES.join(', ')}`, { status: 400, code: 'VALIDATION_ERROR' });
}
- const meta = SLASHDO_COMMANDS[command];
+ // Resolved for EVERY command, not just `next` — so the queue row names the app
+ // the way the user does, and an unknown app 404s uniformly instead of only on
+ // the `next` branch.
+ const appObj = await getAppById(app);
+ if (!appObj) {
+ throw new ServerError(`App not found: ${app}`, { status: 404, code: 'APP_NOT_FOUND' });
+ }
- // `/do:next` is the work-claim consumer: route it through the same
- // workTracker-aware logic the scheduled `claim-work` flow uses, so the manual
- // button honors the app's per-app Work Tracker (PLAN.md / GitHub / GitLab /
- // JIRA) instead of always draining PLAN.md. Every other command inlines its
- // raw slashdo body verbatim.
- let context;
- let taskMetadata = { useWorktree: false, openPR: false };
- let description;
+ // Enforce the catalog's stack gate server-side. The Agent Operations panel only
+ // offers the applicable one of `better` / `better-swift`, but the API must not
+ // trust that — queuing a SwiftUI audit against a web app (or vice versa) burns
+ // an agent run on a workflow that can't apply.
+ if (!slashdoWorkflowAppliesTo(workflow, NON_PM2_TYPES.has(appObj.type))) {
+ throw new ServerError(
+ `${workflow.label} does not apply to ${appObj.name} (app type: ${appObj.type || 'unknown'})`,
+ { status: 400, code: 'WORKFLOW_APP_TYPE_MISMATCH' }
+ );
+ }
+
+ // Two task shapes, produced whole so the either/or is visible rather than
+ // assembled from separately-mutated locals:
+ //
+ // - `/do:next` is the work-claim consumer and is genuinely special: it routes
+ // through the same workTracker-aware logic the scheduled `claim-work` flow
+ // uses, so the manual button honors the app's per-app Work Tracker (PLAN.md /
+ // GitHub / GitLab / JIRA) instead of always draining PLAN.md. Its assembled
+ // claim prompt IS the context, so it carries NO `slashdoCommand` — adding one
+ // would append the whole `/do:next` body on top of the claim prompt.
+ // - Every other command carries only the bare `slashdoCommand` and lets the
+ // prompt builder render the invocation + inline the body once the provider is
+ // known (`applySlashdoInvocation`). Eagerly inlining the body here — and
+ // hardcoding `Run /do:<cmd>` into the description — assumed a Claude host that
+ // can type slash commands; a codex/grok agent gets Agent Skills instead, so
+ // the rendered string was wrong for it (#3089's whole point).
+ //
+ // `workflow.settings` is the catalog's run-shape posture (see
+ // WORKFLOW_OWNS_ITS_OWN_GIT) — read from it rather than restating false/false,
+ // so a future entry that genuinely wants a PortOS-managed worktree gets one.
+ // `simplify` comes from the request (the run drawer's toggle), not the catalog.
+ const { useWorktree, openPR } = workflow.settings;
+ let shape;
if (command === 'next') {
- const appObj = await getAppById(app);
- if (!appObj) {
- throw new ServerError(`App not found: ${app}`, { status: 404, code: 'APP_NOT_FOUND' });
- }
const claim = await buildClaimWorkTask(appObj, { target, issueAuthorFilter, reviewers, usernames, optionalReviewers });
- context = claim.prompt;
- // claim.taskMetadata overrides the false/false default only where it carries
- // a key. All current claim flows (plan-task / claim-issue / claim-issue-gitlab
- // / claim-issue-jira) self-manage their worktree + MR/PR, so false/false
- // stands; the spread stays for a future delegated type that needs CoS-managed
- // isolation.
- taskMetadata = { ...taskMetadata, ...claim.taskMetadata };
const scope = claim.target
? `claim ${workTrackerLabel(claim.tracker)} item ${claim.target}`
: `claim next ${workTrackerLabel(claim.tracker)} item`;
- description = `Run /do:next for ${appObj.name} — ${scope} and ship a PR`;
+ shape = {
+ description: `${workflow.label} for ${appObj.name} — ${scope} and ship a PR`,
+ context: claim.prompt,
+ // claim.taskMetadata overrides the catalog posture only where it carries a
+ // key. All current claim flows (plan-task / claim-issue / claim-issue-gitlab
+ // / claim-issue-jira) self-manage their worktree + MR/PR, so false/false
+ // stands; the spread stays for a future delegated type that needs
+ // CoS-managed isolation.
+ taskMetadata: { useWorktree, openPR, ...claim.taskMetadata },
+ };
} else {
- context = await loadSlashdoCommand(command);
- if (!context) {
- throw new ServerError(`Failed to load slashdo command: ${command}`, { status: 500, code: 'COMMAND_LOAD_FAILED' });
- }
- description = `Run /do:${command} for ${app} — ${meta.description}`;
+ shape = {
+ description: `${workflow.label} for ${appObj.name} — ${workflow.description}`,
+ slashdoCommand: command,
+ taskMetadata: { useWorktree, openPR },
+ };
}
// `reviewLoop` stays off for every slashdo task: each `/do:*` body owns its own
// review/PR sequence, so a CoS-managed loop on top would double-review.
const taskData = {
- description, app, context, ...taskMetadata,
+ description: shape.description,
+ app,
+ context: shape.context,
+ slashdoCommand: shape.slashdoCommand,
+ ...shape.taskMetadata,
provider, model, effort,
simplify: simplify === true,
reviewLoop: false
diff --git a/server/services/agentCompletionCleanup.js b/server/services/agentCompletionCleanup.js
index 1a18daeffc..6607a418ac 100644
--- a/server/services/agentCompletionCleanup.js
+++ b/server/services/agentCompletionCleanup.js
@@ -29,6 +29,7 @@ import { isTruthyMeta } from './agentState.js';
import { resolveReviewLoopOptions } from './codeReview.js';
import { cleanupAgentWorktree, spawnMergeRecoveryTask } from './agentWorktreeCleanup.js';
import { resolvePrCompletion } from '../lib/prDisposition.js';
+import { canTypeSlashCommands } from '../lib/slashdoInvocation.js';
const ROOT_DIR = PATHS.root;
@@ -307,7 +308,21 @@ export async function runAgentCompletionCleanup({ agentId, task, agent, effectiv
// branch and open the PR on their own. Mirror the TUI cleanup contract
// so PortOS doesn't double-fire `gh pr create` ("a pull request already
// exists" would preserve the worktree as a false-positive failure).
- const agentOwnsPR = taskOpenPR && (agent.providerId === 'claude-code' || agent.providerId === 'claude-code-bedrock');
+ //
+ // Derived from the SAME `canTypeSlashCommands` predicate the prompt's
+ // `hasSlashdo` gate uses (#3114) — these two must agree or the double-fire
+ // this comment describes is exactly what happens. An id allowlist here would
+ // miss a path-configured `claude` under a custom provider id (told to run
+ // `/do:pr`, then PortOS opens a second PR) and would wrongly claim a lean
+ // `--bare` session owns a PR it was never told to open. `providerCommand` /
+ // `leanMode` are persisted on the agent record for this; a pre-upgrade record
+ // carries neither, and a blank command reads as `claude` — which is what the
+ // old id allowlist effectively assumed for the claude-code ids anyway.
+ const agentOwnsPR = taskOpenPR && canTypeSlashCommands({
+ providerId: agent.providerId,
+ providerCommand: agent.providerCommand,
+ leanMode: agent.leanMode === true,
+ });
// Merge per-task reviewer metadata with the user's Code Review Defaults
// (AI Providers → Code Review Defaults panel). Settings I/O is cached
// inside the resolver, so this is effectively free even when invoked
diff --git a/server/services/agentCompletionCleanup.test.js b/server/services/agentCompletionCleanup.test.js
index a362afa8b7..4425fb1d84 100644
--- a/server/services/agentCompletionCleanup.test.js
+++ b/server/services/agentCompletionCleanup.test.js
@@ -25,8 +25,9 @@ vi.mock('./codeReview.js', () => ({ resolveReviewLoopOptions: vi.fn().mockResolv
vi.mock('./agentWorktreeCleanup.js', () => ({ cleanupAgentWorktree: vi.fn().mockResolvedValue([]), spawnMergeRecoveryTask: vi.fn() }));
vi.mock('./taskPromptService.js', () => ({ getStagePrompt: vi.fn().mockResolvedValue('do stage work in {appName}') }));
-import { handlePipelineProgression } from './agentCompletionCleanup.js';
+import { handlePipelineProgression, runAgentCompletionCleanup } from './agentCompletionCleanup.js';
import { updateTask, addTask, reviveBlockedTask } from './cos.js';
+import { cleanupAgentWorktree } from './agentWorktreeCleanup.js';
const runningPipeline = (overrides = {}) => ({
id: 'p1',
@@ -125,3 +126,55 @@ describe('handlePipelineProgression', () => {
expect(updateTask).not.toHaveBeenCalled();
});
});
+
+// #3114 — `agentOwnsPR` decides whether PortOS skips its own push+PR because the
+// agent was told to run `/do:pr` itself. It MUST derive from the same
+// `canTypeSlashCommands` predicate the prompt's `hasSlashdo` gate used: when the
+// two disagree, PortOS fires `gh pr create` on a branch that already has a PR
+// ("a pull request already exists" preserves the worktree as a false-positive
+// failure), or conversely never opens the PR the agent was told not to open.
+describe('runAgentCompletionCleanup — agentOwnsPR mirrors the prompt gate', () => {
+ const prTask = { id: 't', taskType: 'user', metadata: { openPR: true } };
+
+ const cleanupCallFor = async (agent) => {
+ await runAgentCompletionCleanup({
+ agentId: 'a1', task: prTask, agent, effectiveSuccess: true, outputBuffer: '',
+ });
+ // cleanupAgentWorktree(agentId, success, options) — options is the 3rd arg.
+ return cleanupAgentWorktree.mock.calls.at(-1)[2];
+ };
+
+ it.each([
+ ['claude-code', 'claude', false],
+ ['claude-code-bedrock', 'claude', false],
+ // The case an id allowlist missed: a path-configured claude under a custom id
+ // IS told to run /do:pr, so PortOS must not open a second PR.
+ ['my-custom-agent', '/opt/homebrew/bin/claude', false],
+ ])('%s does not double-fire the PR (agent owns it)', async (providerId, providerCommand) => {
+ const opts = await cleanupCallFor({ providerId, providerCommand, leanMode: false });
+ expect(opts.openPR).toBe(false);
+ expect(opts.skipMerge).toBe(true);
+ });
+
+ it.each([
+ ['codex', 'codex'],
+ ['antigravity-cli', 'agy'],
+ ])('%s still gets PortOS post-exit push+PR (agent cannot run /do:pr)', async (providerId, providerCommand) => {
+ const opts = await cleanupCallFor({ providerId, providerCommand, leanMode: false });
+ expect(opts.openPR).toBe(true);
+ expect(opts.skipMerge).toBe(false);
+ });
+
+ it('a lean --bare claude session does NOT own its PR (it has no project commands)', async () => {
+ const opts = await cleanupCallFor({ providerId: 'claude-ollama', providerCommand: 'claude', leanMode: true });
+ expect(opts.openPR).toBe(true);
+ });
+
+ it('a pre-upgrade agent record with only providerId still resolves', async () => {
+ // Records written before providerCommand/leanMode were persisted: a blank
+ // command reads as `claude`, which is what the old id allowlist effectively
+ // assumed for the claude-code ids anyway.
+ expect((await cleanupCallFor({ providerId: 'claude-code' })).openPR).toBe(false);
+ expect((await cleanupCallFor({ providerId: 'codex-tui' })).openPR).toBe(true);
+ });
+});
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index 8267008b31..e8d5b674ea 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -425,6 +425,13 @@ async function runAgentSpawn(task) {
taskType: task.taskType,
priority: task.priority,
providerId: provider.id,
+ // Persisted alongside the id because the cleanup path's `agentOwnsPR` gate
+ // must derive from the SAME `canTypeSlashCommands` predicate the prompt used
+ // to decide whether the agent opens its own PR (#3114). An id alone can't
+ // answer that — a path-configured `claude` under a custom id is slashdo-
+ // capable, and a lean `--bare` session is not.
+ providerCommand: provider.command || null,
+ leanMode,
model: selectedModel,
modelTier: modelSelection.tier,
modelReason: modelSelection.reason,
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 1dfcc6c509..5fa5addb89 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -18,8 +18,7 @@ import { runPromptThroughProvider } from '../lib/promptRunner.js';
import { readJSONFile, loadSlashdoFile, loadSlashdoLib, PATHS, tryReadFile } from '../lib/fileUtils.js';
import { DEFAULT_REVIEWER, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, LOCAL_LLM_REVIEWERS, MODEL_CAPABLE_CLI_REVIEWERS, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, resolveReviewUsernames, resolveOptionalReviewers, resolveKeyedReviewers, buildReviewWithArgs } from '../lib/validation.js';
import { PROVIDER_TYPES } from '../lib/aiToolkit/constants.js';
-import { isOpencodeCommand } from '../lib/providerModels.js';
-import { resolveSlashdoInvocation, buildSlashdoSection } from '../lib/slashdoInvocation.js';
+import { canTypeSlashCommands, resolveSlashdoInvocation, buildSlashdoSection } from '../lib/slashdoInvocation.js';
import { shellQuote } from '../lib/shellQuote.js';
import { detectForgeCli } from '../lib/gitForge.js';
import { PR_COMPLETIONS, leavesPrForHuman, resolvePrCompletion } from '../lib/prDisposition.js';
@@ -893,14 +892,19 @@ export function buildActionOutputCompletionSection({ isTui = false, sentinelPath
* @param {Function} isTruthyMetaFn - isTruthyMeta function (passed to avoid circular dep)
* @param {Object} options
* @param {string} [options.providerType='api'] - `'tui' | 'cli' | 'api'`
- * @param {string} [options.providerId] - Provider id (e.g. `'claude-code'`). When the
- * CLI provider has access to the project's slashdo commands (Claude Code), the
- * light prompt instructs the agent to run `/simplify` and `/do:pr` itself
- * instead of relying on PortOS's post-exit push+PR. The spawner must then
- * pass `openPR: false` to `cleanupAgentWorktree` to avoid double-firing.
- * @param {string} [options.providerCommand] - Provider launch command (e.g. `'opencode'`).
- * Used to detect a slashdo-free TUI (OpenCode): such a TUI can't run `/do:pr` / `/do:push`,
- * so its completion workflow falls back to plain `git`/`gh` commands.
+ * `providerId` + `providerCommand` + `leanMode` together decide whether the
+ * session can TYPE a Claude Code slash command (`canTypeSlashCommands`, #3114):
+ * a capable session is instructed to drive its own `/simplify` + `/do:pr` /
+ * `/do:push`, and everything else gets plain `git`/`gh` (TUI) or PortOS's
+ * post-exit push+PR (CLI). `agentCompletionCleanup.js` derives the same predicate
+ * from the agent record so it passes `openPR: false` and avoids double-firing.
+ *
+ * @param {string} [options.providerId] - Provider id (e.g. `'claude-code'`). Not an
+ * allowlist: it only matters when `providerCommand` is blank, where the
+ * spawners' `inferTuiCommand` fallback resolves the command from it.
+ * @param {string} [options.providerCommand] - Provider launch command (e.g.
+ * `'claude'`, `'codex'`, `'opencode'`) — the primary signal, so a
+ * path-configured or renamed binary is recognised.
* @param {boolean} [options.leanMode] - Ollama-backed Claude session launched with
* `--bare` (see `applyLeanClaudeArgs`): the completion workflow drops slashdo
* commands (bare mode skips command discovery) in favor of plain `git`/`gh`.
@@ -1023,10 +1027,17 @@ Use the findings from the previous stage to inform your work. If the previous st
// section above. TUI agents own the full simplify+push+PR sequence in the
// Completion Workflow section below, so this section is suppressed for TUI.
const simplifyEnabled = isTruthyMetaFn(task.metadata?.simplify);
- // `/simplify` is a Claude Code built-in slash command — only Claude providers
- // can run it. Everyone else (API/CLI) gets the inline equivalent describing the
- // same reuse/quality/efficiency self-review so the pass still happens.
- const canRunSlashCommands = providerId === 'claude-code' || providerId === 'claude-code-bedrock';
+ // `/simplify` is a Claude Code built-in slash command — only a Claude session
+ // that loaded its commands can run it. Everyone else (API/CLI) gets the inline
+ // equivalent describing the same reuse/quality/efficiency self-review so the
+ // pass still happens. Same predicate as the `/do:pr` gates (#3114) — a
+ // path-configured `claude` binary qualifies; a lean `--bare` session doesn't.
+ // `assumeClaudeWhenUnknown: false` because only HTTP-API providers reach this
+ // path (tui/cli return early above): an unidentified API provider is not a
+ // latent local `claude` the way a blank CLI/TUI provider is.
+ const canRunSlashCommands = canTypeSlashCommands({
+ providerId, providerCommand, leanMode, assumeClaudeWhenUnknown: false,
+ });
const simplifyInstruction = canRunSlashCommands
? 'run `/simplify` to review the changed code for reuse, quality, and efficiency'
: SIMPLIFY_INLINE_REVIEW;
@@ -1074,7 +1085,17 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an
? buildActionOutputCompletionSection({ isTui, sentinelPath })
: isTui
? buildTuiCompletionSection({
- willOpenPR, prCompletion, simplifyEnabled, providerId,
+ willOpenPR, prCompletion, simplifyEnabled,
+ // Unreachable today — every `tui`/`cli` provider returns early at the
+ // LIGHT_CONTEXT gate above, so `isTui` is always false on this path
+ // (same situation as buildCompletionGuidelineBullet's `isTui` arm).
+ // Kept provider-aware anyway so it can't be the ONE call site that
+ // silently promises `/do:pr` to a host that can't type it if the
+ // routing ever changes — this arm previously passed no slashdoFree at
+ // all, which is how gates like this drift (#3114).
+ slashdoFree: !canRunSlashCommands,
+ branchName: worktreeInfo?.branchName || null,
+ baseBranch: worktreeInfo?.baseBranch || null,
sentinelPath,
leavePrOpen: leavesPrForHuman(task),
reviewers: taskReviewers,
@@ -1252,7 +1273,7 @@ ${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${too
${(() => {
const bullet = buildCompletionGuidelineBullet({
isReadOnly: isTruthyMetaFn(task.metadata?.readOnly),
- isTui, tuiCompletionCommand, slashdoFree: isTui && isOpencodeCommand(providerCommand),
+ isTui, tuiCompletionCommand, slashdoFree: isTui && !canRunSlashCommands,
worktreeInfo, willOpenPR, prCompletion, discardWorktree, noCodeOutput,
leavePrOpen: leavesPrForHuman(task),
isPrFollowUp: isReviewLoopFollowUp,
@@ -1354,26 +1375,25 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
const lightReviewerApplies = task.metadata?.reviewerApplies !== undefined
? isTruthyMetaFn(task.metadata?.reviewerApplies)
: (codeReviewDefaults?.reviewerApplies === true);
- // Claude Code CLI providers can drive `/simplify` + `/do:pr` themselves
- // (the slashdo submodule mounts those as project-level slash commands).
- // Other CLI providers (codex, antigravity) can't — they get the legacy
- // commit-only block where PortOS handles push+PR on exit.
- //
- // Deliberately NOT `resolveSlashdoStyle` (slashdoInvocation.js): that resolver
- // refuses to read a blank command as Claude, while these two gates depend on
- // the opposite posture — the TUI spawner's `inferTuiCommand` resolves a blank
- // command to `claude`, so an unidentified TUI is slashdo-capable here. The two
- // questions ("can this host TYPE /do:pr" vs "how do I PHRASE a workflow
- // invocation") only look alike. Converging them is issue #3114.
- const hasSlashdo = !isTui && (providerId === 'claude-code' || providerId === 'claude-code-bedrock');
- // A TUI that does NOT load Claude Code slash commands can't run `/do:pr` /
- // `/do:push`, so its completion workflow uses plain git/gh instead. Two ways
- // to land here: an OpenCode TUI (keyed on the launch command, not the id, so
- // a path-configured or renamed OpenCode provider is still recognised —
- // mirrors the arg-builder gate), or a lean-mode Claude session (`--bare`
- // skips project command discovery, and the small local models lean mode
- // targets fumble multi-step slashdo flows anyway).
- const tuiSlashdoFree = isTui && (isOpencodeCommand(providerCommand) || leanMode);
+ // Can this session TYPE a Claude Code slash command (`/do:pr`, `/do:push`,
+ // `/simplify`)? One predicate, both prompt paths (#3114): `canTypeSlashCommands`
+ // derives from `resolveSlashdoStyle` with the spawners' blank-command posture,
+ // replacing three inline provider-id allowlists that had already drifted apart
+ // (a codex TUI used to be told to run `/do:pr`, which it cannot; a
+ // path-configured `claude` binary under a custom provider id used to be denied
+ // the slashdo workflow).
+ const canTypeSlash = canTypeSlashCommands({ providerId, providerCommand, leanMode });
+ // CLI (non-TUI): a Claude Code session drives `/simplify` + `/do:pr` itself
+ // (the slashdo submodule mounts those as project-level slash commands). Other
+ // CLI providers (codex, antigravity, grok, opencode) get the legacy commit-only
+ // block where PortOS handles push+PR on exit.
+ const hasSlashdo = !isTui && canTypeSlash;
+ // TUI: a session that does NOT load Claude Code slash commands can't run
+ // `/do:pr` / `/do:push`, so its completion workflow uses plain git/gh instead
+ // — an OpenCode TUI, a codex/antigravity/grok TUI, or a lean-mode Claude
+ // session (`--bare` skips project command discovery, and the small local models
+ // lean mode targets fumble multi-step slashdo flows anyway).
+ const tuiSlashdoFree = isTui && !canTypeSlash;
const taskSections = [];
const contractSections = [];
@@ -1464,7 +1484,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
sections.push(buildReviewLoopFollowUpSection(task.metadata || {}, { verbose: false, localAgentLoopBody }));
} else if (isTui) {
sections.push(buildTuiCompletionSection({
- willOpenPR, prCompletion, simplifyEnabled, providerId, slashdoFree: tuiSlashdoFree,
+ willOpenPR, prCompletion, simplifyEnabled, slashdoFree: tuiSlashdoFree,
sentinelPath: `${worktreeInfo?.worktreePath || workspaceDir}/.agent-done`,
branchName: worktreeInfo?.branchName || null,
baseBranch: worktreeInfo?.baseBranch || null,
@@ -1558,11 +1578,15 @@ function buildPostPRMergeSteps(startStep, { prCompletion = PR_COMPLETIONS.REVIEW
* TUI completion-workflow block. The TUI owns its own commit → push → PR
* pipeline via slashdo commands and signals "done" with a sentinel file.
*
- * When `slashdoFree` is set (an OpenCode TUI, which does not load Claude Code
- * slash commands), the agent can't run `/do:pr` / `/do:push`, so it delegates to
- * the plain-git/`gh` variant below — same sentinel handshake, no slashdo.
+ * When `slashdoFree` is set — any TUI that does NOT load Claude Code slash
+ * commands: OpenCode, codex/antigravity/grok/kimi, or a lean `--bare` Claude
+ * session — the agent can't run `/do:pr` / `/do:push`, so it delegates to the
+ * plain-git/`gh` variant below (same sentinel handshake, no slashdo). The caller
+ * resolves that flag once via `canTypeSlashCommands` (#3114); past the early
+ * return this IS a Claude session, so `/simplify` and `/do:pr` are both safe to
+ * emit without a second provider check.
*/
-function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, providerId = null, slashdoFree = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
+function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, slashdoFree = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
if (slashdoFree) {
@@ -1591,13 +1615,9 @@ function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.M
? ' — `/do:pr` runs the Copilot review loop after the PR opens.'
: ` — \`/do:pr\` runs the review loop for ${reviewerListLabel} in order after the PR opens.`)
: (willOpenPR ? ' — external review is disabled for this task.' : '');
- // `/simplify` is a Claude Code TUI built-in. Non-Claude TUI providers
- // (codex-tui, antigravity-tui) can't run it, so give them the inline equivalent.
- // Default (no providerId) stays Claude-shaped for backward compatibility.
- const canRunSimplifyCommand = !providerId || /claude/i.test(providerId);
- const simplifyStep = simplifyEnabled
- ? (canRunSimplifyCommand ? '1. `/simplify`' : `1. Before committing, ${SIMPLIFY_INLINE_REVIEW} and fix any findings.`)
- : '1. (simplify disabled — skip)';
+ // Reached only for a Claude TUI (a non-Claude one took the slashdoFree branch
+ // above), so `/simplify` — a Claude Code built-in — is invokable here.
+ const simplifyStep = simplifyEnabled ? '1. `/simplify`' : '1. (simplify disabled — skip)';
const sentinelTail = willOpenPR ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
// A PR gets merge steps — gated on the review verdict when a loop runs, on CI
// alone when it doesn't (nothing else merges a no-review-loop PR). The one
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index fe3d89e229..4a1867784f 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -542,6 +542,57 @@ describe('buildLightContextPrompt', () => {
expect(prompt).not.toMatch(/git push -u origin weird;rm/);
});
+ // #3114 acceptance criteria — the completion gates derive from
+ // `resolveSlashdoStyle`, so the two behaviors the old inline provider-id
+ // allowlists got wrong are now asserted.
+ it('a codex TUI gets the plain git/gh completion workflow, never /do:pr', () => {
+ // codex installs slashdo as Agent Skills, not slash commands, so telling it
+ // to run `/do:pr` handed it an uninvokable line. The old `tuiSlashdoFree`
+ // gate only recognized OpenCode + lean mode, so codex fell through to the
+ // slashdo path.
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: { openPR: true, reviewLoop: true } }),
+ '/r',
+ { branchName: 'claim/x', worktreePath: '/tmp/wt', baseBranch: 'main' },
+ isTruthyMeta,
+ { isTui: true, providerId: 'codex-tui', providerCommand: 'codex' });
+ expect(prompt).toMatch(/## Completion Workflow/);
+ expect(prompt).toMatch(/does NOT have slashdo/);
+ expect(prompt).not.toMatch(/`\/do:pr`/);
+ expect(prompt).not.toMatch(/`\/do:push`/);
+ // Plain git + forge CLI instead.
+ expect(prompt).toMatch(/git push -u origin claim\/x/);
+ expect(prompt).toMatch(/gh pr create --fill --base main/);
+ expect(prompt).toMatch(/\.agent-done/);
+ });
+
+ it('a path-configured claude binary under a custom provider id gets the slashdo workflow', () => {
+ // The old `hasSlashdo` gate was an id allowlist (`claude-code` /
+ // `claude-code-bedrock`), so a renamed or path-configured claude provider
+ // was denied `/simplify` + `/do:pr` even though it launches claude.
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: { openPR: true, simplify: true } }),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: false, providerId: 'my-custom-agent', providerCommand: '/opt/homebrew/bin/claude' });
+ expect(prompt).toMatch(/^## Completion$/m);
+ expect(prompt).toMatch(/`\/simplify`/);
+ expect(prompt).toMatch(/`\/do:pr/);
+ expect(prompt).not.toMatch(/PortOS will push and open the PR/);
+ });
+
+ it('an antigravity TUI also drops out of the slashdo workflow', () => {
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: { openPR: false } }),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: true, providerId: 'antigravity-tui', providerCommand: 'agy' });
+ expect(prompt).not.toMatch(/`\/do:push`/);
+ expect(prompt).toMatch(/git push -u origin b/);
+ });
+
it('a non-OpenCode TUI (claude-code-tui) keeps the slashdo /do:pr workflow', () => {
// providerCommand is the gate — a claude TUI must NOT fall into the manual path.
const prompt = buildLightContextPrompt(
@@ -561,7 +612,7 @@ describe('buildLightContextPrompt', () => {
'/r',
{ branchName: 'b', worktreePath: '/tmp/wt' },
isTruthyMeta,
- { isTui: false });
+ { isTui: false, providerId: 'codex', providerCommand: 'codex' });
expect(prompt).toMatch(/^## Completion$/m);
expect(prompt).not.toMatch(/`\/do:pr`/);
expect(prompt).not.toMatch(/`\/quit`/);
@@ -577,13 +628,28 @@ describe('buildLightContextPrompt', () => {
'/r',
{ branchName: 'b', worktreePath: '/tmp/wt' },
isTruthyMeta,
- { isTui: false }); // no providerId → not Claude → no slashdo
+ { isTui: false, providerId: 'antigravity-cli', providerCommand: 'agy' });
expect(prompt).toMatch(/^## Completion$/m);
expect(prompt).not.toMatch(/`\/simplify`/);
expect(prompt).toMatch(/review your changed code for reuse, quality, and efficiency/i);
expect(prompt).toMatch(/PortOS will push and open the PR/);
});
+ // #3114 — the gates now derive from `resolveSlashdoStyle` with the spawners'
+ // blank-command posture, so a CLI provider with NO id and NO command reads as
+ // Claude: `buildCliSpawnConfig`'s default branch launches `claude`, and the
+ // session that actually runs does have `/do:pr` / `/simplify`.
+ it('treats a blank CLI provider as Claude Code, matching what the spawner launches', () => {
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: { openPR: true, simplify: true } }),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: false });
+ expect(prompt).toMatch(/`\/simplify`/);
+ expect(prompt).toMatch(/`\/do:pr/);
+ });
+
it('emits a slashdo Completion block (/simplify + /do:pr) for Claude Code CLI + openPR', () => {
const prompt = buildLightContextPrompt(
makeTask({ metadata: { openPR: true, reviewLoop: true, simplify: true } }),
diff --git a/server/services/taskTemplates.js b/server/services/taskTemplates.js
index 1c76b61128..dfd7cd6dda 100644
--- a/server/services/taskTemplates.js
+++ b/server/services/taskTemplates.js
@@ -7,119 +7,36 @@
import { join } from 'path';
import { atomicWrite, ensureDir, readJSONFile, PATHS } from '../lib/fileUtils.js';
+import { SLASHDO_WORKFLOWS } from '../lib/slashdoCatalog.js';
const DATA_DIR = PATHS.cos;
const TEMPLATES_FILE = join(DATA_DIR, 'task-templates.json');
// Built-in templates: one per bundled slashdo workflow worth launching
-// unattended (`lib/slashdo/commands/do/*.md`). These replaced eight generic
-// phrase stubs ("Fix the bug where", "Refactor", …) which only seeded a
-// sentence fragment the user had to finish typing anyway (#3089).
+// unattended. These replaced eight generic phrase stubs ("Fix the bug where",
+// "Refactor", …) which only seeded a sentence fragment the user had to finish
+// typing anyway (#3089).
+//
+// DERIVED from the shared launchable-workflow catalog (#3114) rather than a
+// hand-maintained second list — the route's Agent Operations registry reads the
+// same source, so a workflow added there shows up in BOTH surfaces. Add or
+// change a workflow in `server/lib/slashdoCatalog.js`, not here.
//
// `slashdoCommand` is the BARE command name — never a rendered `/do:x` string
// (see `server/lib/slashdoInvocation.js` for why).
-//
-// `settings` are the run-shape defaults a workflow implies. Every entry sets
-// `useWorktree`/`openPR`/`simplify` to false, for two distinct reasons:
-// - plan-task / replan / review / scan write no code at all, so there is
-// nothing to isolate, PR, or simplify.
-// - next / better / depfree / release MANAGE THEIR OWN worktrees and PRs — a
-// PortOS-level worktree would nest one inside another, and `release` must
-// run from `main` in the primary checkout.
-// A key absent from `settings` means "leave the current toggle alone" (the
-// absent-vs-empty rule) — it does NOT mean false.
-const WORKFLOW_OWNS_ITS_OWN_GIT = { useWorktree: false, openPR: false, simplify: false };
-
-const BUILT_IN_TEMPLATES = [
- {
- id: 'builtin-do-plan-task',
- name: 'Plan a Task',
- icon: '📋',
- slashdoCommand: 'plan-task',
- description: 'Investigate and file a decision-complete issue for: ',
- context: 'Runs the slashdo plan-task workflow: investigate the codebase, then file a ready-to-work issue.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-next',
- name: 'Ship Next Issue',
- icon: '🎯',
- slashdoCommand: 'next',
- description: 'Claim and ship the next open issue',
- context: 'Runs the slashdo next workflow: claim an unclaimed item, do the work in its own worktree, ship a PR.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-replan',
- name: 'Replan Backlog',
- icon: '🗺️',
- slashdoCommand: 'replan',
- description: 'Audit and triage the backlog',
- context: 'Runs the slashdo replan workflow: prune completed items, suggest new work, keep the plan lean.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-review',
- name: 'Review Changes',
- icon: '🔍',
- slashdoCommand: 'review',
- description: 'Deep code review of the changed files',
- context: 'Runs the slashdo review workflow: review changed files against software engineering best practices.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-release',
- name: 'Cut a Release',
- icon: '🚀',
- slashdoCommand: 'release',
- description: 'Create a release PR',
- context: "Runs the slashdo release workflow using the project's documented release process.",
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-better',
- name: 'DevSecOps Audit',
- icon: '🛡️',
- slashdoCommand: 'better',
- description: 'Run a DevSecOps audit and remediation pass',
- context: 'Runs the slashdo better workflow: audit, remediate, enhance tests, open per-category PRs.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-depfree',
- name: 'Prune Dependencies',
- icon: '📦',
- slashdoCommand: 'depfree',
- description: 'Audit dependencies and remove unnecessary ones',
- context: 'Runs the slashdo depfree workflow: audit third-party deps and replace the removable ones with code.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- },
- {
- id: 'builtin-do-scan',
- name: 'Safety Scan',
- icon: '🔒',
- slashdoCommand: 'scan',
- description: 'Read-only safety audit of: ',
- context: 'Runs the slashdo scan workflow: flag malware patterns, network calls, and vulnerable deps.',
- category: 'slashdo',
- settings: WORKFLOW_OWNS_ITS_OWN_GIT,
- isBuiltin: true
- }
-];
+const BUILT_IN_TEMPLATES = SLASHDO_WORKFLOWS.map(w => ({
+ id: `builtin-do-${w.command}`,
+ name: w.templateName,
+ icon: w.icon,
+ slashdoCommand: w.command,
+ // `templatePrompt` is the trailing fragment for a workflow that needs a typed
+ // target ("Safety scan of: "); everything else states what the run does.
+ description: w.templatePrompt || w.description,
+ context: `Runs the slashdo ${w.command} workflow: ${w.detail}.`,
+ category: 'slashdo',
+ settings: w.settings,
+ isBuiltin: true
+}));
const BUILT_IN_IDS = new Set(BUILT_IN_TEMPLATES.map(t => t.id));
diff --git a/server/services/taskTemplates.test.js b/server/services/taskTemplates.test.js
index e317226791..9783a455c1 100644
--- a/server/services/taskTemplates.test.js
+++ b/server/services/taskTemplates.test.js
@@ -23,6 +23,9 @@ vi.mock('fs', () => ({
existsSync: vi.fn().mockReturnValue(true)
}));
+// Not mocked — the shared launchable-workflow catalog is a pure constant list.
+const { SLASHDO_COMMAND_NAMES } = await import('../lib/slashdoCatalog.js');
+
// Import after mocking
const { readJSONFile } = await import('../lib/fileUtils.js');
const { writeFile } = await import('fs/promises');
@@ -241,15 +244,16 @@ describe('taskTemplates service', () => {
});
describe('slashdo built-ins (#3089)', () => {
- it('ships one template per bundled slashdo workflow, with implied settings', async () => {
+ it('ships one template per catalog workflow, with implied settings', async () => {
readJSONFile.mockResolvedValue(null);
const templates = await getAllTemplates();
const slashdo = templates.filter(t => t.slashdoCommand);
- expect(slashdo.map(t => t.slashdoCommand).sort()).toEqual(
- ['better', 'depfree', 'next', 'plan-task', 'release', 'replan', 'review', 'scan']
- );
+ // Derived from the shared catalog (#3114), so the assertion is convergence
+ // with it — not a hand-copied list that can drift the way the route's
+ // registry and this set already had (`push`/`better-swift` were missing here).
+ expect(slashdo.map(t => t.slashdoCommand)).toEqual([...SLASHDO_COMMAND_NAMES]);
// Every one of these either writes no code at all or manages its own
// worktree/PR, so none of them want PortOS to wrap another one around it.
for (const t of slashdo) {
@@ -258,6 +262,15 @@ describe('taskTemplates service', () => {
// The BARE command name is what is stored — a rendered `/do:x` string
// would be Claude-only, and the provider is unknown at pick time.
expect(slashdo.every(t => !t.slashdoCommand.includes('/'))).toBe(true);
+ // Each carries the display fields the quick-template chips render.
+ for (const t of slashdo) {
+ expect(t.id).toBe(`builtin-do-${t.slashdoCommand}`);
+ expect(t.name).toBeTruthy();
+ expect(t.icon).toBeTruthy();
+ expect(t.description).toBeTruthy();
+ expect(t.category).toBe('slashdo');
+ expect(t.isBuiltin).toBe(true);
+ }
});
it('drops the generic phrase stubs the slashdo set replaced', async () => {