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: replace generic CoS quick templates with slashdo workflow templates

[._.]/ Adam Eivy6ee358c18ead
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 689951207e..4e3bc9c3c3 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -22,3 +22,11 @@
## Universe art references
- **[issue-3099] Adding or removing an art reference no longer flickers back when you navigate away and return mid-save** — if you changed a universe's art references and switched to another universe and back before the change finished saving, a slower page refresh could briefly restore the pre-change list on screen, making the next add or remove operate on the wrong set. The saved change now always wins over the older refresh it raced.
+
+## CoS quick task templates
+
+- [issue-3089] The Quick Templates row on the CoS task form now launches real workflows instead of sentence fragments. The eight generic stubs ("Fix the bug where", "Refactor", "Add tests for") only seeded text you had to finish typing anyway; they're replaced by the bundled slashdo workflows an agent can run end to end — Plan a Task, Ship Next Issue, Replan Backlog, Review Changes, Cut a Release, DevSecOps Audit, Prune Dependencies, and Safety Scan.
+- Each template also carries the run shape its workflow implies, so picking one sets the worktree/PR/simplify toggles correctly: these workflows either write no code at all or manage their own worktrees and PRs, and wrapping another PortOS worktree around one would nest it. You can still override any toggle afterward, and a template that doesn't specify a toggle leaves your current setting alone.
+- The workflow is invoked correctly no matter which agent runs it. Because the provider dropdown defaults to Auto, the template stores the workflow's name rather than a literal `/do:` string — at launch, a Claude Code agent gets `/do:plan-task`, OpenCode gets `/do-plan-task`, and Codex/Grok/Antigravity agents get it named as an Agent Skill. The workflow's full procedure travels with the task in every case, so it also works when the agent is running against one of your other apps rather than PortOS itself, where those slash commands aren't installed.
+- Applying a template no longer clears the target application you'd already selected — which had also silently reset that app's worktree and PR defaults.
+- `/do:plan-task` and `/do:config` are now available as project slash commands in this repo; they were the only two bundled commands missing a link.
diff --git a/.claude/commands/do/config.md b/.claude/commands/do/config.md
new file mode 120000
index 0000000000..62fc04e12d
--- /dev/null
+++ b/.claude/commands/do/config.md
@@ -0,0 +1 @@
+../../../lib/slashdo/commands/do/config.md
\ No newline at end of file
diff --git a/.claude/commands/do/plan-task.md b/.claude/commands/do/plan-task.md
new file mode 120000
index 0000000000..6aaf774698
--- /dev/null
+++ b/.claude/commands/do/plan-task.md
@@ -0,0 +1 @@
+../../../lib/slashdo/commands/do/plan-task.md
\ No newline at end of file
diff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsx
index 81d96809f9..a91bc12665 100644
--- a/client/src/components/cos/TaskAddForm.jsx
+++ b/client/src/components/cos/TaskAddForm.jsx
@@ -37,7 +37,15 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
const [templateNameInput, setTemplateNameInput] = useState('');
const [showTemplateSave, setShowTemplateSave] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
+ // Bare slashdo command a quick-template pinned (`plan-task`), never a rendered
+ // `/do:x` string — see server/lib/slashdoInvocation.js for why.
+ const [slashdoCommand, setSlashdoCommand] = useState('');
const submittingRef = useRef(false);
+ const descriptionRef = useRef(null);
+ // Set by applyTemplate only when a template changes BOTH the app and the
+ // run-shape toggles, so the app-defaults effect skips the single run that
+ // change triggers. See that effect for why.
+ const templateAppChangeRef = useRef(false);
// Fetch templates
useEffect(() => {
@@ -109,6 +117,15 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
[selectedApp, newTask.app]
);
useEffect(() => {
+ // A template that pins BOTH an app and a `settings` block would otherwise
+ // lose: applyTemplate sets the toggles synchronously, then the app change it
+ // also made re-fires this effect and stomps them with the app's defaults.
+ // The template's explicit choice is the more specific one, so skip exactly
+ // the one run its own app change triggered.
+ if (templateAppChangeRef.current) {
+ templateAppChangeRef.current = false;
+ return;
+ }
const defaultOpenPR = !!selectedApp?.defaultOpenPR;
const defaultUseWorktree = !!selectedApp?.defaultUseWorktree || defaultOpenPR;
setCreateJiraTicket(!!selectedApp?.jira?.enabled);
@@ -129,18 +146,40 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
return 'No models are configured. PortOS will use the provider default.';
})();
- // Apply template to form
+ // Apply template to form. A slashdo-backed template also pins the workflow
+ // (`slashdoCommand`) and applies its implied run-shape `settings`.
+ //
+ // `settings` keys are tri-state: a key ABSENT leaves the current toggle
+ // untouched, `false` turns it off. Collapsing absent to false would make a
+ // plain user template silently clear toggles it never meant to touch.
const applyTemplate = useCallback(async (template) => {
- setNewTask({
+ setNewTask(t => ({
+ ...t,
description: template.description,
- model: template.model || '',
- provider: template.provider || '',
- effort: template.effort || '',
- app: template.app || ''
- });
+ // A template that pins no app must not clear the one the user already
+ // chose — and the built-ins pin none. Same absent-vs-empty rule as
+ // `settings` below. Provider/model/effort move as a unit: pinning a
+ // provider without a model would otherwise strand a model from a
+ // different provider in the form.
+ ...(template.app ? { app: template.app } : {}),
+ ...(template.provider
+ ? { provider: template.provider, model: template.model || '', effort: template.effort || '' }
+ : {})
+ }));
+ setSlashdoCommand(template.slashdoCommand || '');
+ const settings = template.settings;
+ if (settings && typeof settings === 'object') {
+ // Only when the template also moves the app — otherwise the effect never
+ // fires and a stale flag would swallow the user's next app change.
+ if (template.app && template.app !== newTask.app) templateAppChangeRef.current = true;
+ if (settings.useWorktree !== undefined) setUseWorktree(settings.useWorktree);
+ if (settings.openPR !== undefined) setOpenPR(settings.openPR);
+ if (settings.simplify !== undefined) setSimplify(settings.simplify);
+ }
+ descriptionRef.current?.focus();
await api.useCosTaskTemplate(template.id).catch(() => {});
toast.success(`Template applied: ${template.name}`);
- }, []);
+ }, [newTask.app]);
// Save current form as template (inline input instead of window.prompt)
const saveAsTemplate = useCallback(async () => {
@@ -257,6 +296,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
provider: newTask.provider || undefined,
effort: newTask.effort || undefined,
app: newTask.app || undefined,
+ slashdoCommand: slashdoCommand || undefined,
createJiraTicket,
useWorktree,
openPR: useWorktree && openPR,
@@ -289,6 +329,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
// Only clear form inputs after successful submission
setNewTask(t => ({ ...t, description: '' }));
+ setSlashdoCommand('');
setScreenshots([]);
setAttachments([]);
@@ -376,10 +417,15 @@ 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.description}
+ title={template.slashdoCommand ? `/do:${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>
+ )}
{template.useCount > 0 && (
<span className="text-xs text-gray-600">({template.useCount})</span>
)}
@@ -404,6 +450,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
<label htmlFor="task-description" className="sr-only">Task description (required)</label>
<input
id="task-description"
+ ref={descriptionRef}
type="text"
placeholder="Task description *"
value={newTask.description}
diff --git a/client/src/components/cos/TaskAddForm.test.jsx b/client/src/components/cos/TaskAddForm.test.jsx
index 8fa9ebc54c..6e65332321 100644
--- a/client/src/components/cos/TaskAddForm.test.jsx
+++ b/client/src/components/cos/TaskAddForm.test.jsx
@@ -1,10 +1,12 @@
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import TaskAddForm from './TaskAddForm';
const api = vi.hoisted(() => ({
getCosPopularTemplates: vi.fn(),
- getCodeReviewDefaults: vi.fn()
+ getCodeReviewDefaults: vi.fn(),
+ useCosTaskTemplate: vi.fn()
}));
vi.mock('../../services/api', () => api);
@@ -14,6 +16,7 @@ describe('TaskAddForm responsive layout', () => {
vi.clearAllMocks();
api.getCosPopularTemplates.mockResolvedValue({ templates: [] });
api.getCodeReviewDefaults.mockResolvedValue(null);
+ api.useCosTaskTemplate.mockResolvedValue({ success: true });
});
it('keeps PR completion controls full-width on mobile', async () => {
@@ -39,3 +42,74 @@ describe('TaskAddForm responsive layout', () => {
expect(options).not.toHaveClass('grid-cols-2');
});
});
+
+// A slashdo quick-template carries the run shape its workflow implies (#3089).
+// `settings` keys are tri-state: absent means "leave the toggle alone", `false`
+// means "turn it off" — collapsing the two would make a plain user template
+// silently clear toggles it never meant to touch.
+describe('TaskAddForm quick templates', () => {
+ const worktreeToggle = () => screen.getByTitle(/isolated git worktree/i).closest('label').querySelector('input');
+ const openTemplates = async (user) => {
+ await waitFor(() => expect(screen.getByText('Quick Templates')).toBeInTheDocument());
+ await user.click(screen.getByText('Quick Templates'));
+ };
+ const renderForm = () => render(
+ <TaskAddForm
+ providers={[]}
+ apps={[{ id: 'example-app', name: 'Example App', repoPath: 'example.com/repo', defaultOpenPR: true, defaultUseWorktree: true }]}
+ defaultApp="example-app"
+ onTaskAdded={vi.fn()}
+ />
+ );
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ api.getCodeReviewDefaults.mockResolvedValue(null);
+ api.useCosTaskTemplate.mockResolvedValue({ success: true });
+ });
+
+ it('applies a slashdo template settings block to the run-shape toggles', async () => {
+ const user = userEvent.setup();
+ api.getCosPopularTemplates.mockResolvedValue({
+ templates: [{
+ id: 'builtin-do-plan-task',
+ name: 'Plan a Task',
+ icon: '📋',
+ slashdoCommand: 'plan-task',
+ description: 'Investigate and file an issue for: ',
+ settings: { useWorktree: false, openPR: false, simplify: false },
+ isBuiltin: true
+ }]
+ });
+
+ renderForm();
+ await openTemplates(user);
+
+ // The app defaults turned the worktree on; the template turns it back off.
+ expect(worktreeToggle()).toBeChecked();
+ await user.click(screen.getByText('Plan a Task'));
+
+ await waitFor(() => expect(worktreeToggle()).not.toBeChecked());
+ expect(screen.getByPlaceholderText('Task description *')).toHaveValue('Investigate and file an issue for: ');
+ expect(api.useCosTaskTemplate).toHaveBeenCalledWith('builtin-do-plan-task');
+ });
+
+ it('leaves the toggles as-is for a template with no settings block', async () => {
+ const user = userEvent.setup();
+ api.getCosPopularTemplates.mockResolvedValue({
+ templates: [{ id: 'user-abc', name: 'My Template', description: 'Do the thing', isBuiltin: false }]
+ });
+
+ renderForm();
+ await openTemplates(user);
+
+ expect(worktreeToggle()).toBeChecked();
+ await user.click(screen.getByText('My Template'));
+
+ await waitFor(() => expect(screen.getByPlaceholderText('Task description *')).toHaveValue('Do the thing'));
+ expect(worktreeToggle()).toBeChecked();
+ // A template that pins no app must not clear the one already selected —
+ // clearing it also silently reset the app's worktree/PR defaults.
+ expect(screen.getByLabelText(/target application/i)).toHaveValue('example-app');
+ });
+});
diff --git a/server/lib/README.md b/server/lib/README.md
index 8856462e8e..5303eba797 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -286,6 +286,7 @@ 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})` → `{style, invocation, skillName, needsInlineBody}` 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. |
| `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/cosValidation.js b/server/lib/cosValidation.js
index 9d556bdcc6..51b68db807 100644
--- a/server/lib/cosValidation.js
+++ b/server/lib/cosValidation.js
@@ -11,6 +11,7 @@
import { z } from 'zod';
import { emptyToUndefined, emptyToNull } from './zodCompat.js';
import { EFFORT_LEVELS } from './providerModels.js';
+import { isValidSlashdoCommand } from './slashdoInvocation.js';
import { PR_COMPLETION_VALUES } from './prDisposition.js';
// =============================================================================
@@ -294,6 +295,13 @@ const cosTaskDiagnosticsSchema = z.object({
const effortInputSchema = z.preprocess(emptyToUndefined, z.enum(EFFORT_LEVELS).optional());
const effortUpdateSchema = z.preprocess(emptyToNull, z.enum(EFFORT_LEVELS).nullable().optional());
+// A bare slashdo command name (`plan-task`, `pr-better`). Shared by the task
+// schema and the quick-template schemas. `isValidSlashdoCommand` is the single
+// definition of the shape — it also gates `loadSlashdoFile`'s path join.
+const slashdoCommandSchema = z.string().refine(isValidSlashdoCommand, {
+ message: 'must be a bare slashdo command name (lowercase, digits, hyphens)',
+});
+
export const createCosTaskSchema = z.object({
description: z.string().min(1),
diagnostics: cosTaskDiagnosticsSchema.optional(),
@@ -359,6 +367,12 @@ export const createCosTaskSchema = z.object({
v => Array.isArray(v) ? normalizeOptionalReviewers(v) : undefined,
z.array(z.string()).optional()
),
+ // Bundled slashdo workflow this task runs (#3089) — the BARE command name,
+ // never a rendered `/do:x` string (see slashdoInvocation.js).
+ slashdoCommand: z.preprocess(emptyToUndefined, slashdoCommandSchema.optional()),
+ // Explicit arguments for the workflow. Absent → the prompt builder falls back
+ // to the task description, which is what the task form sends.
+ slashdoArgs: z.preprocess(emptyToUndefined, z.string().max(4000).optional()),
});
export const updateCosTaskSchema = z.object({
@@ -504,6 +518,51 @@ export const generateWeeklyDigestSchema = z.object({
weekId: z.string().optional(),
});
+// =============================================================================
+// QUICK TASK TEMPLATE SCHEMAS (#3089)
+// =============================================================================
+
+// Run-shape defaults a template implies. Every key is optional and each one is
+// a tri-state: ABSENT means "leave the form's current toggle alone", `false`
+// means "turn it off". Collapsing absent to false would make every template
+// silently clear toggles it never intended to touch.
+export const taskTemplateSettingsSchema = z.object({
+ useWorktree: z.boolean().optional(),
+ openPR: z.boolean().optional(),
+ simplify: z.boolean().optional(),
+}).strict();
+
+export const createTaskTemplateSchema = z.object({
+ name: z.string().trim().min(1).max(120),
+ description: z.string().min(1).max(4000),
+ icon: z.string().max(16).optional(),
+ context: z.string().max(4000).optional(),
+ category: z.string().max(60).optional(),
+ provider: z.string().max(120).optional(),
+ model: z.string().max(200).optional(),
+ effort: z.preprocess(emptyToUndefined, z.enum(EFFORT_LEVELS).optional()),
+ app: z.string().max(200).optional(),
+ slashdoCommand: z.preprocess(emptyToUndefined, slashdoCommandSchema.optional()),
+ settings: taskTemplateSettingsSchema.optional(),
+}).strict();
+
+// PUT accepts any subset — the route only forwards the keys actually present.
+export const updateTaskTemplateSchema = createTaskTemplateSchema.partial();
+
+// POST /templates/from-task snapshots a live task into a user template. Only the
+// fields createTemplateFromTask actually reads are accepted.
+export const taskTemplateFromTaskSchema = z.object({
+ task: z.object({
+ description: z.string().min(1).max(4000),
+ context: z.string().max(4000).optional(),
+ provider: z.string().max(120).optional(),
+ model: z.string().max(200).optional(),
+ effort: z.preprocess(emptyToUndefined, z.enum(EFFORT_LEVELS).optional()),
+ app: z.string().max(200).optional(),
+ }),
+ templateName: z.string().trim().min(1).max(120).optional(),
+});
+
// Global Code Review Loop defaults (settings.codeReview). Surfaced on the AI
// Providers page; TaskAddForm + ScheduleTab seed from this when the user
// hasn't already chosen a per-task / per-task-type reviewer list. The follow-
diff --git a/server/lib/index.js b/server/lib/index.js
index 6d09c9134e..b1a7f4295e 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -257,6 +257,7 @@ export * from './openapiSpec.js';
export * from './prDisposition.js';
export * from './shellQuote.js';
export * from './sidecarProcess.js';
+export * from './slashdoInvocation.js';
export * from './singleFlight.js';
export * from './staticImportGraph.js';
export * from './streamBackpressure.js';
diff --git a/server/lib/providerModels.js b/server/lib/providerModels.js
index cf311c8e90..87676fefe9 100644
--- a/server/lib/providerModels.js
+++ b/server/lib/providerModels.js
@@ -78,6 +78,36 @@ export function isCodexProvider(provider) {
return id === 'codex' || id === 'codex-tui' || commandBasename(provider?.command) === 'codex';
}
+/**
+ * True when a provider is Claude-Code-flavored — a `claude-code*` provider id or
+ * any provider whose launch command basename is `claude` (path/exe tolerant).
+ *
+ * Unlike `isClaudeCommand`, a BLANK command does not count: this identifies a
+ * provider positively, and callers that gate a Claude-only capability on it must
+ * not treat "unknown" as Claude. Same posture as `effortLevelsForProvider`, which
+ * this replaces the inline copy of.
+ * @param {{id?:string, command?:string}|null|undefined} provider
+ * @returns {boolean}
+ */
+export function isClaudeProvider(provider) {
+ if (!provider) return false;
+ return String(provider.id || '').toLowerCase().startsWith('claude-code')
+ || commandBasename(provider.command) === 'claude';
+}
+
+/**
+ * True when a provider is OpenCode-flavored — the shipped `opencode`/`opencode-tui`
+ * ids or any provider whose launch command basename is `opencode`. The
+ * provider-shaped companion to `isOpencodeCommand`, same posture as
+ * `isCodexProvider`.
+ * @param {{id?:string, command?:string}|null|undefined} provider
+ * @returns {boolean}
+ */
+export function isOpencodeProvider(provider) {
+ const id = String(provider?.id || '').toLowerCase();
+ return id === 'opencode' || id === 'opencode-tui' || isOpencodeCommand(provider?.command);
+}
+
/**
* True when a provider is Kimi-Code-flavored — the shipped `kimi-cli`/`kimi-tui`
* ids or any provider whose launch command basename is `kimi` (path/exe tolerant).
@@ -105,8 +135,7 @@ export function isKimiProvider(provider) {
export function effortLevelsForProvider(provider) {
if (!provider) return null;
if (isCodexProvider(provider)) return CODEX_EFFORT_LEVELS;
- const id = String(provider.id || '').toLowerCase();
- if (id.startsWith('claude-code') || commandBasename(provider.command) === 'claude') return CLAUDE_EFFORT_LEVELS;
+ if (isClaudeProvider(provider)) return CLAUDE_EFFORT_LEVELS;
return null;
}
diff --git a/server/lib/slashdoInvocation.js b/server/lib/slashdoInvocation.js
new file mode 100644
index 0000000000..32498a5ed8
--- /dev/null
+++ b/server/lib/slashdoInvocation.js
@@ -0,0 +1,181 @@
+/**
+ * Slashdo invocation resolver (#3089).
+ *
+ * A CoS task can name a bundled slashdo workflow (`plan-task`, `next`, `review`,
+ * …) instead of hand-written prose. How an agent actually *invokes* that workflow
+ * is NOT a prefix swap — slashdo installs itself differently per host CLI
+ * (`lib/slashdo/src/environments.js`), so the same command lands in three shapes:
+ *
+ * | Host CLI | namespacing | invocation |
+ * |--------------------------|---------------|--------------------------------|
+ * | Claude Code | `subdirectory`| `/do:<cmd> <args>` |
+ * | OpenCode | `flat` | `/do-<cmd> <args>` |
+ * | Codex / Grok / Antigravity | `directory` | Agent Skill, selected by NAME |
+ *
+ * There is no `$do:<cmd>` form. Because the provider is only known at spawn
+ * time (the task form's provider select defaults to "Auto"), a task persists the
+ * bare command name in `metadata.slashdoCommand` and this module resolves the
+ * concrete invocation when the prompt is built.
+ *
+ * Skill-style hosts (and any provider we can't positively identify) get the
+ * command's markdown body inlined into the prompt instead — the provider-agnostic
+ * fallback that works even when that environment has no slashdo install at all.
+ */
+import { isClaudeProvider, isOpencodeProvider } from './providerModels.js';
+
+/** slashdo's command namespace — `commands/do/<cmd>.md` in the submodule. */
+export const SLASHDO_NAMESPACE = 'do';
+
+/**
+ * The three invocation shapes slashdo's installer produces. `slash-namespaced`
+ * and `slash-flat` are typed as a slash command by the host CLI; `skill` is an
+ * Agent Skill the model selects by name/description (no prefix, nothing to type).
+ */
+export const SLASHDO_INVOCATION_STYLES = Object.freeze({
+ SLASH_NAMESPACED: 'slash-namespaced',
+ SLASH_FLAT: 'slash-flat',
+ SKILL: 'skill',
+});
+
+/** Bare slashdo command names are file-path segments — keep them inert. */
+const COMMAND_NAME_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;
+
+/**
+ * True when `name` is a well-formed bare slashdo command (`plan-task`, `pr-better`).
+ * Rejects anything that could escape `commands/do/` — the value reaches
+ * `loadSlashdoFile`, which joins it into a path.
+ * @param {unknown} name
+ * @returns {boolean}
+ */
+export function isValidSlashdoCommand(name) {
+ return typeof name === 'string' && COMMAND_NAME_RE.test(name);
+}
+
+/**
+ * The flat/skill name slashdo's installer gives a command in `flat` and
+ * `directory` environments: `do/plan-task` → `do-plan-task`. Mirrors
+ * `getSkillName` in `lib/slashdo/src/transformer.js`.
+ * @param {string} command - bare command name (`plan-task`)
+ * @returns {string}
+ */
+export function slashdoSkillName(command) {
+ return `${SLASHDO_NAMESPACE}-${command}`;
+}
+
+/**
+ * Which invocation shape a provider gets — the single home for the
+ * provider→slashdo-shape decision (`hasSlashdo` / `tuiSlashdoFree` in
+ * `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.
+ *
+ * `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.
+ *
+ * @param {Object} [opts]
+ * @param {string|null} [opts.providerId]
+ * @param {string|null} [opts.providerCommand]
+ * @param {boolean} [opts.leanMode]
+ * @returns {string} one of SLASHDO_INVOCATION_STYLES
+ */
+export function resolveSlashdoStyle({ providerId = null, providerCommand = null, leanMode = false } = {}) {
+ const provider = { id: providerId, command: providerCommand };
+ if (isOpencodeProvider(provider)) return SLASHDO_INVOCATION_STYLES.SLASH_FLAT;
+ if (!leanMode && 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;
+}
+
+/**
+ * Resolve the concrete invocation for a slashdo-backed task.
+ *
+ * @param {Object} opts
+ * @param {string} opts.command - bare command name (`plan-task`)
+ * @param {string} [opts.args] - free-form arguments (the task description)
+ * @param {string|null} [opts.providerId]
+ * @param {string|null} [opts.providerCommand] - the provider's launch command
+ * @param {boolean} [opts.leanMode]
+ * @returns {{ command: string, skillName: string, style: string, args: string,
+ * invocation: string }|null} null when `command` is missing or not a
+ * well-formed slashdo command name.
+ */
+export function resolveSlashdoInvocation({
+ command,
+ args = '',
+ providerId = null,
+ providerCommand = null,
+ leanMode = false,
+} = {}) {
+ if (!isValidSlashdoCommand(command)) return null;
+
+ const style = resolveSlashdoStyle({ providerId, providerCommand, leanMode });
+ const skillName = slashdoSkillName(command);
+ const trimmedArgs = typeof args === 'string' ? args.trim() : '';
+ const suffix = trimmedArgs ? ` ${trimmedArgs}` : '';
+
+ const invocation = style === SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED
+ ? `/${SLASHDO_NAMESPACE}:${command}${suffix}`
+ : style === SLASHDO_INVOCATION_STYLES.SLASH_FLAT
+ ? `/${skillName}${suffix}`
+ : `Use the \`${skillName}\` skill${trimmedArgs ? ` on: ${trimmedArgs}` : ''}`;
+
+ return { command, skillName, style, args: trimmedArgs, invocation };
+}
+
+/**
+ * Render the prompt section for a resolved slashdo invocation. Pure — the
+ * caller loads `body` (via `loadSlashdoFile`) and passes it in, so this module
+ * stays side-effect free.
+ *
+ * The body is inlined for EVERY style, not just `skill`. PortOS bundles slashdo
+ * as a submodule and only exposes it as slash commands through the repo-local
+ * `.claude/commands/do/` symlinks — which exist in the PortOS checkout, not in
+ * the managed-app workspaces most CoS tasks run in, and only for Claude Code.
+ * So a typed invocation is a shortcut for hosts that happen to have slashdo
+ * installed, never the thing the prompt depends on. Same posture as every other
+ * slashdo consumer here (`loadSlashdoCommand`, the `/do:rpr` and review-loop
+ * inlining), which is why the submodule exists at all: no global install required.
+ *
+ * @param {ReturnType<typeof resolveSlashdoInvocation>} resolved
+ * @param {string|null} [body] - the command's markdown
+ * @returns {string} markdown section, or '' when `resolved` is null
+ */
+export function buildSlashdoSection(resolved, body = null) {
+ if (!resolved) return '';
+
+ // Without explicit args the workflow operates on the task described above —
+ // say so rather than re-printing the whole description inside the invocation.
+ const target = resolved.args ? '' : ' Apply it to the task described above.';
+
+ const lines = ['### Slashdo Workflow'];
+ if (resolved.style === SLASHDO_INVOCATION_STYLES.SKILL) {
+ lines.push(
+ `This task runs the bundled slashdo **${resolved.skillName}** workflow. ${resolved.invocation}.${target}`,
+ 'Your CLI exposes slashdo as Agent Skills — selected by name, with no slash-command form to type.'
+ );
+ } else {
+ lines.push(
+ `This task runs the bundled slashdo **${resolved.skillName}** workflow.${target} If your CLI has slashdo installed you can invoke it directly:`,
+ '',
+ '```',
+ resolved.invocation,
+ '```'
+ );
+ }
+ if (body) {
+ lines.push(
+ '',
+ 'The full procedure is inlined below — follow it exactly rather than improvising:',
+ '',
+ body.trim()
+ );
+ }
+ return lines.join('\n');
+}
diff --git a/server/lib/slashdoInvocation.test.js b/server/lib/slashdoInvocation.test.js
new file mode 100644
index 0000000000..a19c266925
--- /dev/null
+++ b/server/lib/slashdoInvocation.test.js
@@ -0,0 +1,140 @@
+import { describe, it, expect } from 'vitest';
+import {
+ SLASHDO_INVOCATION_STYLES,
+ buildSlashdoSection,
+ isValidSlashdoCommand,
+ resolveSlashdoInvocation,
+ resolveSlashdoStyle,
+ slashdoSkillName,
+} from './slashdoInvocation.js';
+
+describe('isValidSlashdoCommand', () => {
+ it('accepts bare command names', () => {
+ expect(isValidSlashdoCommand('next')).toBe(true);
+ expect(isValidSlashdoCommand('plan-task')).toBe(true);
+ expect(isValidSlashdoCommand('pr-better')).toBe(true);
+ });
+
+ it('rejects anything that could escape commands/do/', () => {
+ expect(isValidSlashdoCommand('../../etc/passwd')).toBe(false);
+ expect(isValidSlashdoCommand('do/plan-task')).toBe(false);
+ expect(isValidSlashdoCommand('plan task')).toBe(false);
+ expect(isValidSlashdoCommand('Plan-Task')).toBe(false);
+ expect(isValidSlashdoCommand('-leading')).toBe(false);
+ expect(isValidSlashdoCommand('trailing-')).toBe(false);
+ expect(isValidSlashdoCommand('')).toBe(false);
+ expect(isValidSlashdoCommand(null)).toBe(false);
+ expect(isValidSlashdoCommand(undefined)).toBe(false);
+ expect(isValidSlashdoCommand(42)).toBe(false);
+ });
+});
+
+describe('slashdoSkillName', () => {
+ it('mirrors the installer getSkillName mapping', () => {
+ expect(slashdoSkillName('plan-task')).toBe('do-plan-task');
+ });
+});
+
+describe('resolveSlashdoStyle', () => {
+ it('gives Claude Code the namespaced slash command', () => {
+ expect(resolveSlashdoStyle({ providerId: 'claude-code' })).toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ expect(resolveSlashdoStyle({ providerId: 'claude-code-bedrock' })).toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ });
+
+ it('recognises a path-configured or renamed claude binary', () => {
+ expect(resolveSlashdoStyle({ providerId: 'my-custom-agent', providerCommand: '/opt/homebrew/bin/claude' }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ expect(resolveSlashdoStyle({ providerId: 'my-custom-agent', providerCommand: 'C:\\tools\\claude.exe' }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_NAMESPACED);
+ });
+
+ it('gives OpenCode the flat slash command, path-configured included', () => {
+ expect(resolveSlashdoStyle({ providerId: 'opencode' })).toBe(SLASHDO_INVOCATION_STYLES.SLASH_FLAT);
+ expect(resolveSlashdoStyle({ providerId: 'renamed', providerCommand: '/usr/local/bin/opencode' }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SLASH_FLAT);
+ });
+
+ it('gives every skill-based CLI the skill style', () => {
+ for (const providerId of ['codex', 'codex-tui', 'grok-cli', 'grok-tui', 'antigravity']) {
+ expect(resolveSlashdoStyle({ providerId })).toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ }
+ expect(resolveSlashdoStyle({ providerId: 'renamed', providerCommand: '/usr/bin/codex' }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+
+ it('falls back to skill for an unidentified provider (inlining works everywhere)', () => {
+ expect(resolveSlashdoStyle({})).toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(resolveSlashdoStyle({ providerId: 'mystery-cli', providerCommand: '' }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+
+ it('falls back to skill in lean mode — a --bare claude session has no project commands', () => {
+ expect(resolveSlashdoStyle({ providerId: 'claude-ollama', providerCommand: 'claude', leanMode: true }))
+ .toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ });
+});
+
+describe('resolveSlashdoInvocation', () => {
+ it('returns null without a valid command', () => {
+ expect(resolveSlashdoInvocation({})).toBeNull();
+ expect(resolveSlashdoInvocation({ command: '' })).toBeNull();
+ expect(resolveSlashdoInvocation({ command: '../secrets' })).toBeNull();
+ });
+
+ it('renders the Claude Code invocation with args', () => {
+ const r = resolveSlashdoInvocation({ command: 'plan-task', args: 'add a widget', providerId: 'claude-code' });
+ expect(r.invocation).toBe('/do:plan-task add a widget');
+ });
+
+ it('renders the OpenCode invocation', () => {
+ const r = resolveSlashdoInvocation({ command: 'plan-task', args: 'add a widget', providerCommand: 'opencode' });
+ expect(r.invocation).toBe('/do-plan-task add a widget');
+ });
+
+ it('renders a skill directive with no slash-command form', () => {
+ const r = resolveSlashdoInvocation({ command: 'plan-task', args: 'add a widget', providerId: 'codex' });
+ expect(r.style).toBe(SLASHDO_INVOCATION_STYLES.SKILL);
+ expect(r.invocation).toContain('do-plan-task');
+ expect(r.invocation).not.toContain('/do:');
+ });
+
+ it('omits the argument suffix when there are no args', () => {
+ expect(resolveSlashdoInvocation({ command: 'next', providerId: 'claude-code' }).invocation).toBe('/do:next');
+ expect(resolveSlashdoInvocation({ command: 'next', args: ' ', providerId: 'claude-code' }).invocation).toBe('/do:next');
+ });
+});
+
+describe('buildSlashdoSection', () => {
+ it('returns empty for an unresolved command', () => {
+ expect(buildSlashdoSection(null)).toBe('');
+ });
+
+ it('emits the slash invocation in a code block and points at the task above', () => {
+ const section = buildSlashdoSection(resolveSlashdoInvocation({ command: 'review', providerId: 'claude-code' }));
+ expect(section).toContain('/do:review');
+ expect(section).toContain('Apply it to the task described above.');
+ });
+
+ // PortOS only exposes slashdo as slash commands through the repo-local
+ // `.claude/commands/do/` symlinks, which don't exist in a managed app's
+ // workspace — so the procedure travels with the prompt for EVERY host, and a
+ // typed invocation is only a shortcut for the ones that happen to have it.
+ it.each([
+ ['claude-code', '/do:review'],
+ ['opencode', '/do-review'],
+ ['codex', 'do-review'],
+ ])('inlines the command body for %s', (providerId, expectedInvocation) => {
+ const section = buildSlashdoSection(
+ resolveSlashdoInvocation({ command: 'review', providerId }),
+ '# Example Procedure\n\nStep one.'
+ );
+ expect(section).toContain(expectedInvocation);
+ expect(section).toContain('# Example Procedure');
+ });
+
+ it('still renders a usable directive when the body could not be loaded', () => {
+ const section = buildSlashdoSection(resolveSlashdoInvocation({ command: 'review', providerId: 'codex' }), null);
+ expect(section).toContain('do-review');
+ expect(section.trim()).not.toBe('');
+ });
+});
diff --git a/server/routes/cosTemplateRoutes.js b/server/routes/cosTemplateRoutes.js
index b2c07883dd..e984342ca6 100644
--- a/server/routes/cosTemplateRoutes.js
+++ b/server/routes/cosTemplateRoutes.js
@@ -5,6 +5,12 @@
import { Router } from 'express';
import * as taskTemplates from '../services/taskTemplates.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
+import { validateRequest } from '../lib/validation.js';
+import {
+ createTaskTemplateSchema,
+ updateTaskTemplateSchema,
+ taskTemplateFromTaskSchema
+} from '../lib/cosValidation.js';
const router = Router();
@@ -29,26 +35,13 @@ router.get('/templates/categories', asyncHandler(async (req, res) => {
// POST /api/cos/templates - Create a new template
router.post('/templates', asyncHandler(async (req, res) => {
- const { name, icon, description, context, category, provider, model, effort, app } = req.body;
-
- if (!name || !description) {
- throw new ServerError('name and description are required', { status: 400, code: 'VALIDATION_ERROR' });
- }
-
- const template = await taskTemplates.createTemplate({
- name, icon, description, context, category, provider, model, effort, app
- });
+ const template = await taskTemplates.createTemplate(validateRequest(createTaskTemplateSchema, req.body));
res.json({ success: true, template });
}));
// POST /api/cos/templates/from-task - Create template from task
router.post('/templates/from-task', asyncHandler(async (req, res) => {
- const { task, templateName } = req.body;
-
- if (!task || !task.description) {
- throw new ServerError('task with description is required', { status: 400, code: 'VALIDATION_ERROR' });
- }
-
+ const { task, templateName } = validateRequest(taskTemplateFromTaskSchema, req.body);
const template = await taskTemplates.createTemplateFromTask(task, templateName);
res.json({ success: true, template });
}));
@@ -61,17 +54,10 @@ router.post('/templates/:id/use', asyncHandler(async (req, res) => {
// PUT /api/cos/templates/:id - Update a template
router.put('/templates/:id', asyncHandler(async (req, res) => {
- const { name, icon, description, context, category, provider, model, effort, app } = req.body;
- const updates = {};
- if (name !== undefined) updates.name = name;
- if (icon !== undefined) updates.icon = icon;
- if (description !== undefined) updates.description = description;
- if (context !== undefined) updates.context = context;
- if (category !== undefined) updates.category = category;
- if (provider !== undefined) updates.provider = provider;
- if (model !== undefined) updates.model = model;
- if (effort !== undefined) updates.effort = effort;
- if (app !== undefined) updates.app = app;
+ // Only forward keys the caller actually sent — an absent field must leave the
+ // stored value alone rather than overwrite it with undefined.
+ const parsed = validateRequest(updateTaskTemplateSchema, req.body);
+ const updates = Object.fromEntries(Object.entries(parsed).filter(([, v]) => v !== undefined));
const result = await taskTemplates.updateTemplate(req.params.id, updates);
if (result.error) {
throw new ServerError(result.error, { status: 400, code: 'BAD_REQUEST' });
diff --git a/server/routes/cosTemplateRoutes.test.js b/server/routes/cosTemplateRoutes.test.js
index 83809959d9..f12f24f38d 100644
--- a/server/routes/cosTemplateRoutes.test.js
+++ b/server/routes/cosTemplateRoutes.test.js
@@ -97,6 +97,45 @@ describe('CoS Template Routes', () => {
expect(response.status).toBe(400);
});
+
+ // The bare command name is joined into a `commands/do/<name>.md` path by
+ // loadSlashdoFile, so the schema is the boundary that keeps it inert (#3089).
+ it('rejects a slashdoCommand that is not a bare command name', async () => {
+ const response = await request(app)
+ .post('/api/cos/templates')
+ .send({ name: 'Escape', description: 'nope', slashdoCommand: '../../etc/passwd' });
+
+ expect(response.status).toBe(400);
+ expect(taskTemplates.createTemplate).not.toHaveBeenCalled();
+ });
+
+ it('rejects a settings block with an unknown toggle', async () => {
+ const response = await request(app)
+ .post('/api/cos/templates')
+ .send({ name: 'Odd', description: 'nope', settings: { autoMerge: true } });
+
+ expect(response.status).toBe(400);
+ expect(taskTemplates.createTemplate).not.toHaveBeenCalled();
+ });
+
+ it('accepts a valid slashdo binding and forwards it to the service', async () => {
+ taskTemplates.createTemplate.mockResolvedValue({ id: 't3' });
+
+ const response = await request(app)
+ .post('/api/cos/templates')
+ .send({
+ name: 'Plan',
+ description: 'Plan a task',
+ slashdoCommand: 'plan-task',
+ settings: { useWorktree: false, openPR: false, simplify: false }
+ });
+
+ expect(response.status).toBe(200);
+ expect(taskTemplates.createTemplate).toHaveBeenCalledWith(expect.objectContaining({
+ slashdoCommand: 'plan-task',
+ settings: { useWorktree: false, openPR: false, simplify: false }
+ }));
+ });
});
describe('POST /api/cos/templates/from-task', () => {
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 3903178148..1dfcc6c509 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -19,6 +19,7 @@ import { readJSONFile, loadSlashdoFile, loadSlashdoLib, PATHS, tryReadFile } fro
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 { shellQuote } from '../lib/shellQuote.js';
import { detectForgeCli } from '../lib/gitForge.js';
import { PR_COMPLETIONS, leavesPrForHuman, resolvePrCompletion } from '../lib/prDisposition.js';
@@ -295,6 +296,42 @@ export function reconcileSplitContext(task) {
return { ...task, description: context, metadata: restMeta };
}
+/**
+ * Fold a slashdo-backed task's invocation + procedure into its description (#3089).
+ *
+ * A task that names a bundled workflow persists only the BARE command
+ * (`metadata.slashdoCommand`) because the form's provider select defaults to
+ * "Auto" — the concrete shape (`/do:x`, `/do-x`, or an Agent Skill selected by
+ * name) is only knowable here, once the scheduler has picked a provider.
+ *
+ * The command body is inlined for every provider, not just the skill-style ones:
+ * PortOS ships slashdo as a submodule and only surfaces it as slash commands via
+ * the repo-local `.claude/commands/do/` symlinks, which don't exist in the
+ * managed-app workspaces most CoS tasks run in. See `buildSlashdoSection`.
+ *
+ * Applied to the description (on a COPY — the stored task is untouched) rather
+ * than emitted as its own template slot, because the briefing template renders
+ * `{{task.description}}`: a new `{{slashdoSection}}` placeholder would be
+ * silently dropped by every install whose customized template predates it.
+ *
+ * @returns {Promise<Object>} the task, or a copy carrying the invocation
+ */
+async function applySlashdoInvocation(task, { providerId = null, providerCommand = null, leanMode = false } = {}) {
+ const command = task.metadata?.slashdoCommand;
+ const resolved = resolveSlashdoInvocation({
+ command,
+ args: task.metadata?.slashdoArgs || '',
+ providerId,
+ providerCommand,
+ leanMode,
+ });
+ if (!resolved) return task;
+
+ const body = await loadSlashdoFile(command, { stripFrontmatter: true }).catch(() => null);
+ if (!body) console.log(`⚠️ Slashdo command body unavailable, sending invocation only: ${command}`);
+ return { ...task, description: `${task.description}\n\n${buildSlashdoSection(resolved, body)}` };
+}
+
/**
* True when a follow-up task is a **merge-only** run: it has a PR to land but no
* reviewer to run (Review Loop off, or every configured reviewer was stripped —
@@ -883,6 +920,11 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo
const providerId = options.providerId || null;
const providerCommand = options.providerCommand || null;
const isTui = providerType === PROVIDER_TYPES.TUI;
+ const leanMode = options.leanMode === true;
+
+ // Render a slashdo-backed task's invocation now that the provider is known —
+ // before the light-path branch below, so both paths carry it.
+ task = await applySlashdoInvocation(task, { providerId, providerCommand, leanMode });
// Install-wide default reviewer list (Code Review Defaults panel →
// `settings.codeReview.reviewers`). Threaded as the `normalizeReviewers`
@@ -909,7 +951,7 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo
: null;
if (LIGHT_CONTEXT_PROVIDER_TYPES.has(providerType)) {
- const lightOptions = { isTui, providerId, providerCommand, leanMode: options.leanMode === true, defaultReviewers, codeReviewDefaults, localAgentLoopBody };
+ const lightOptions = { isTui, providerId, providerCommand, leanMode, defaultReviewers, codeReviewDefaults, localAgentLoopBody };
return options.split === true
? buildLightContextPromptParts(task, workspaceDir, worktreeInfo, isTruthyMetaFn, lightOptions)
: buildLightContextPrompt(task, workspaceDir, worktreeInfo, isTruthyMetaFn, lightOptions);
@@ -1316,6 +1358,13 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
// (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
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 072f1881e6..fe3d89e229 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -13,7 +13,7 @@
* autonomous agent…" preamble are gone from BOTH paths.
*/
-import { describe, it, expect, vi } from 'vitest';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
import { join } from 'path';
import { PATHS } from '../lib/fileUtils.js';
@@ -67,6 +67,7 @@ import { buildLightContextPrompt, buildAgentPrompt, buildCompletionGuidelineBull
import { getCodeReviewDefaults } from './codeReview.js'; // mocked above — control the configured default
import { isTruthyMeta } from './agentState.js';
import { buildPrompt } from './promptService.js'; // mocked above — inspect call args
+import { loadSlashdoFile } from '../lib/fileUtils.js'; // mocked above — control the inlined body
function makeTask(overrides = {}) {
return {
@@ -1499,3 +1500,95 @@ describe('buildReviewLoopFollowUpSection — CLI reviewer procedure inlining', (
expect(out).toMatch(/codex/);
});
});
+
+// -----------------------------------------------------------------------------
+// Slashdo-backed tasks (#3089)
+// -----------------------------------------------------------------------------
+// A quick-template task persists only the BARE command name; the invocation is
+// resolved here, where the provider is finally known. Assertions are on SHAPE
+// (invocation line present, body non-empty) — never on the vendored submodule's
+// exact text, which is upstream's to change.
+describe('buildAgentPrompt — slashdo-backed tasks', () => {
+ const slashdoTask = (metadata = {}) => makeTask({
+ description: 'Add rate limiting to the widget API',
+ metadata: { slashdoCommand: 'plan-task', ...metadata },
+ });
+
+ beforeEach(() => {
+ vi.mocked(loadSlashdoFile).mockResolvedValue(null);
+ });
+
+ it('renders the Claude Code invocation for a claude-code provider', async () => {
+ const prompt = await buildAgentPrompt(
+ slashdoTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'claude-code' });
+ expect(prompt).toContain('/do:plan-task');
+ expect(prompt).toContain('Add rate limiting to the widget API');
+ });
+
+ it('renders the flat invocation for OpenCode', async () => {
+ const prompt = await buildAgentPrompt(
+ slashdoTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'tui', providerId: 'opencode-tui', providerCommand: 'opencode' });
+ expect(prompt).toContain('/do-plan-task');
+ expect(prompt).not.toContain('/do:plan-task');
+ });
+
+ it('names the skill instead of a slash command for a skill-style CLI', async () => {
+ const prompt = await buildAgentPrompt(
+ slashdoTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'codex' });
+ expect(prompt).toContain('do-plan-task');
+ expect(prompt).not.toContain('/do:plan-task');
+ });
+
+ // PortOS surfaces slashdo as slash commands only via the repo-local
+ // `.claude/commands/do/` symlinks, which a managed app's workspace doesn't
+ // have — so the procedure ships with the prompt for every provider, and the
+ // typed invocation is a shortcut, not the thing the prompt relies on.
+ it.each(['claude-code', 'opencode', 'codex'])('inlines the command body for %s', async (providerId) => {
+ vi.mocked(loadSlashdoFile).mockResolvedValue('# Plan Task\n\nInvestigate, then file the issue.');
+ const prompt = await buildAgentPrompt(
+ slashdoTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId });
+ expect(prompt).toContain('Investigate, then file the issue.');
+ expect(vi.mocked(loadSlashdoFile)).toHaveBeenCalledWith('plan-task', { stripFrontmatter: true });
+ });
+
+ it('still emits the invocation when the body cannot be loaded', async () => {
+ vi.mocked(loadSlashdoFile).mockResolvedValue(null);
+ const prompt = await buildAgentPrompt(
+ slashdoTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'claude-code' });
+ expect(prompt).toContain('/do:plan-task');
+ });
+
+ it('uses explicit slashdoArgs when present', async () => {
+ const prompt = await buildAgentPrompt(
+ slashdoTask({ slashdoArgs: '--issues 42' }), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'claude-code' });
+ expect(prompt).toContain('/do:plan-task --issues 42');
+ });
+
+ it('reaches the api-path briefing template through task.description', async () => {
+ vi.mocked(buildPrompt).mockClear();
+ await buildAgentPrompt(slashdoTask(), {}, '/r', null, isTruthyMeta, { providerType: 'api', providerId: 'claude-code' });
+ const [, context] = vi.mocked(buildPrompt).mock.calls.at(-1);
+ expect(context.task.description).toContain('/do:plan-task');
+ });
+
+ it('leaves a task with no slashdoCommand untouched', async () => {
+ const prompt = await buildAgentPrompt(
+ makeTask(), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'claude-code' });
+ expect(prompt).not.toContain('Slashdo Workflow');
+ });
+
+ it('ignores an invalid command rather than joining it into a path', async () => {
+ const prompt = await buildAgentPrompt(
+ slashdoTask({ slashdoCommand: '../../etc/passwd' }), {}, '/r', null, isTruthyMeta,
+ { providerType: 'cli', providerId: 'codex' });
+ expect(prompt).not.toContain('Slashdo Workflow');
+ expect(vi.mocked(loadSlashdoFile)).not.toHaveBeenCalledWith('../../etc/passwd', expect.anything());
+ });
+});
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 8d2e072cb5..a162a717ce 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -304,6 +304,11 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
if (REVIEW_STOP_MODES.includes(taskData.reviewStopMode)) metadata.reviewStopMode = taskData.reviewStopMode;
if (taskData.reviewerApplies === true) metadata.reviewerApplies = true;
else if (taskData.reviewerApplies === false) metadata.reviewerApplies = false;
+ // Bundled slashdo workflow this task runs (#3089), as the BARE command name
+ // — the prompt builder renders the invocation shape once the provider is
+ // known (see server/lib/slashdoInvocation.js).
+ if (taskData.slashdoCommand) metadata.slashdoCommand = taskData.slashdoCommand;
+ if (taskData.slashdoArgs) metadata.slashdoArgs = taskData.slashdoArgs;
if (taskData.jiraTicketId) metadata.jiraTicketId = taskData.jiraTicketId;
if (taskData.jiraTicketUrl) metadata.jiraTicketUrl = taskData.jiraTicketUrl;
if (taskData.screenshots?.length > 0) metadata.screenshots = taskData.screenshots;
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 7a8d7cf20a..102bb85cf4 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -238,6 +238,25 @@ describe('cosTaskStore.addTask', () => {
expect(reloaded.metadata.affectedTasks).toEqual(['task-abc']);
});
+ it('persists a slashdo workflow as the BARE command name, never a rendered invocation (#3089)', async () => {
+ const created = await addTask({ description: 'Plan the widget API', slashdoCommand: 'plan-task' }, 'user');
+ expect(created.metadata.slashdoCommand).toBe('plan-task');
+ // A literal `/do:plan-task` frozen in at form time would be Claude-only —
+ // the provider select defaults to Auto, so the invocation shape must stay
+ // unresolved until the scheduler picks one.
+ expect(created.description).not.toContain('/do:');
+ expect(JSON.stringify(created.metadata)).not.toContain('/do:');
+
+ const { tasks } = await getUserTasks();
+ expect(tasks.find(t => t.id === created.id).metadata.slashdoCommand).toBe('plan-task');
+ });
+
+ it('omits slashdo metadata when no workflow is pinned', async () => {
+ const created = await addTask({ description: 'ordinary prose task' }, 'user');
+ expect(created.metadata.slashdoCommand).toBeUndefined();
+ expect(created.metadata.slashdoArgs).toBeUndefined();
+ });
+
it('omits investigation guard metadata when not supplied', async () => {
const created = await addTask({ description: 'ordinary task' }, 'user');
expect(created.metadata.isInvestigation).toBeUndefined();
diff --git a/server/services/taskTemplates.js b/server/services/taskTemplates.js
index e9b1ea3e45..1c76b61128 100644
--- a/server/services/taskTemplates.js
+++ b/server/services/taskTemplates.js
@@ -11,82 +11,118 @@ import { atomicWrite, ensureDir, readJSONFile, PATHS } from '../lib/fileUtils.js
const DATA_DIR = PATHS.cos;
const TEMPLATES_FILE = join(DATA_DIR, 'task-templates.json');
-// Built-in templates based on common task patterns
+// 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).
+//
+// `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-mobile-fix',
- name: 'Fix Mobile Responsiveness',
- icon: '📱',
- description: 'Make this page mobile-friendly',
- context: 'Check viewport sizes 375px, 768px, and 1024px. Fix Tailwind responsive classes.',
- category: 'ui',
+ 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-add-feature',
- name: 'Add New Feature',
- icon: '✨',
- description: 'Add a new feature to',
- context: 'Follow existing patterns in the codebase. Write tests for new functionality.',
- category: 'feature',
+ 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-fix-bug',
- name: 'Fix Bug',
- icon: '🐛',
- description: 'Fix the bug where',
- context: 'Investigate root cause, implement fix, add test to prevent regression.',
- category: 'bugfix',
+ 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-refactor',
- name: 'Refactor Code',
- icon: '🔧',
- description: 'Refactor',
- context: 'Improve code quality while maintaining existing behavior. Ensure tests pass.',
- category: 'refactor',
+ 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-add-test',
- name: 'Add Tests',
- icon: '🧪',
- description: 'Add tests for',
- context: 'Write unit tests with good coverage. Follow existing test patterns.',
- category: 'testing',
+ 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-improve-ux',
- name: 'Improve UX',
- icon: '🎨',
- description: 'Improve the user experience of',
- context: 'Focus on usability, accessibility, and visual polish.',
- category: 'ui',
+ 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-add-api',
- name: 'Add API Endpoint',
- icon: '🔌',
- description: 'Add API endpoint for',
- context: 'Add route with Zod validation, service function, and API tests.',
- category: 'feature',
+ 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-security-fix',
- name: 'Security Fix',
+ id: 'builtin-do-scan',
+ name: 'Safety Scan',
icon: '🔒',
- description: 'Fix security issue in',
- context: 'Address vulnerability with proper input validation and sanitization.',
- category: 'security',
+ 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_IDS = new Set(BUILT_IN_TEMPLATES.map(t => t.id));
+
// Default empty state
const DEFAULT_STATE = {
version: 1,
@@ -101,7 +137,29 @@ const DEFAULT_STATE = {
async function loadState() {
const data = await readJSONFile(TEMPLATES_FILE);
if (!data) return { ...DEFAULT_STATE };
- return { ...DEFAULT_STATE, ...data, userTemplates: data.userTemplates || [], usage: data.usage || {} };
+ return {
+ ...DEFAULT_STATE,
+ ...data,
+ userTemplates: data.userTemplates || [],
+ usage: pruneOrphanBuiltinUsage(data.usage || {})
+ };
+}
+
+/**
+ * Drop `usage` counters for `builtin-*` ids that no longer exist. Built-in
+ * templates are code, not data — when the shipped set changes (#3089 swapped the
+ * eight generic stubs for slashdo workflows) their counters would otherwise
+ * linger in `data/cos/task-templates.json` forever, inflating nothing and
+ * confusing anyone reading the file. User-template counters (`user-*`) are
+ * untouched — those ids are only removed by deleteTemplate.
+ */
+function pruneOrphanBuiltinUsage(usage) {
+ const kept = {};
+ for (const [id, count] of Object.entries(usage)) {
+ if (id.startsWith('builtin-') && !BUILT_IN_IDS.has(id)) continue;
+ kept[id] = count;
+ }
+ return kept;
}
/**
@@ -181,6 +239,11 @@ export async function createTemplate(templateData) {
createdAt: new Date().toISOString()
};
+ // Optional slashdo binding. Omitted (not blanked) when absent so applyTemplate's
+ // "key absent = leave the toggle alone" contract holds for user templates too.
+ if (templateData.slashdoCommand) newTemplate.slashdoCommand = templateData.slashdoCommand;
+ if (templateData.settings && typeof templateData.settings === 'object') newTemplate.settings = templateData.settings;
+
state.userTemplates.push(newTemplate);
await saveState(state);
diff --git a/server/services/taskTemplates.test.js b/server/services/taskTemplates.test.js
index ebf402a78d..e317226791 100644
--- a/server/services/taskTemplates.test.js
+++ b/server/services/taskTemplates.test.js
@@ -91,7 +91,7 @@ describe('taskTemplates service', () => {
],
usage: {
'user-abc123': 5,
- 'builtin-mobile-fix': 3
+ 'builtin-do-plan-task': 3
},
lastUpdated: '2025-01-01T00:00:00.000Z'
});
@@ -99,7 +99,7 @@ describe('taskTemplates service', () => {
const templates = await getAllTemplates();
const userTemplate = templates.find(t => t.id === 'user-abc123');
- const builtinTemplate = templates.find(t => t.id === 'builtin-mobile-fix');
+ const builtinTemplate = templates.find(t => t.id === 'builtin-do-plan-task');
expect(userTemplate.useCount).toBe(5);
expect(builtinTemplate.useCount).toBe(3);
@@ -151,7 +151,7 @@ describe('taskTemplates service', () => {
lastUpdated: null
});
- const result = await deleteTemplate('builtin-mobile-fix');
+ const result = await deleteTemplate('builtin-do-plan-task');
expect(result.error).toBe('Cannot delete built-in templates');
expect(writeFile).not.toHaveBeenCalled();
@@ -192,18 +192,18 @@ describe('taskTemplates service', () => {
readJSONFile.mockResolvedValue({
userTemplates: [],
usage: {
- 'builtin-mobile-fix': 3
+ 'builtin-do-plan-task': 3
},
lastUpdated: '2025-01-01T00:00:00.000Z'
});
- const count = await recordTemplateUsage('builtin-mobile-fix');
+ const count = await recordTemplateUsage('builtin-do-plan-task');
expect(count).toBe(4);
expect(writeFile).toHaveBeenCalled();
const savedState = JSON.parse(writeFile.mock.calls[0][1]);
- expect(savedState.usage['builtin-mobile-fix']).toBe(4);
+ expect(savedState.usage['builtin-do-plan-task']).toBe(4);
});
});
@@ -222,8 +222,8 @@ describe('taskTemplates service', () => {
],
usage: {
'user-abc123': 10,
- 'builtin-mobile-fix': 3,
- 'builtin-add-feature': 7
+ 'builtin-do-plan-task': 3,
+ 'builtin-do-next': 7
},
lastUpdated: '2025-01-01T00:00:00.000Z'
});
@@ -233,10 +233,64 @@ describe('taskTemplates service', () => {
expect(popular.length).toBe(3);
expect(popular[0].id).toBe('user-abc123');
expect(popular[0].useCount).toBe(10);
- expect(popular[1].id).toBe('builtin-add-feature');
+ expect(popular[1].id).toBe('builtin-do-next');
expect(popular[1].useCount).toBe(7);
- expect(popular[2].id).toBe('builtin-mobile-fix');
+ expect(popular[2].id).toBe('builtin-do-plan-task');
expect(popular[2].useCount).toBe(3);
});
});
+
+ describe('slashdo built-ins (#3089)', () => {
+ it('ships one template per bundled slashdo 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']
+ );
+ // 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) {
+ expect(t.settings).toEqual({ useWorktree: false, openPR: false, simplify: false });
+ }
+ // 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);
+ });
+
+ it('drops the generic phrase stubs the slashdo set replaced', async () => {
+ readJSONFile.mockResolvedValue(null);
+
+ const templates = await getAllTemplates();
+ expect(templates.find(t => t.description === 'Fix the bug where')).toBeUndefined();
+ expect(templates.find(t => t.description === 'Refactor')).toBeUndefined();
+ });
+ });
+
+ describe('orphaned built-in usage counters', () => {
+ it('drops usage entries for builtin-* ids that no longer exist', async () => {
+ readJSONFile.mockResolvedValue({
+ userTemplates: [{ id: 'user-abc123', name: 'Mine', description: 'Custom', isBuiltin: false }],
+ usage: {
+ 'builtin-fix-bug': 12, // removed in #3089
+ 'builtin-improve-ux': 4, // removed in #3089
+ 'builtin-do-plan-task': 2, // still shipped
+ 'user-abc123': 9 // user counters are never pruned here
+ },
+ lastUpdated: '2025-01-01T00:00:00.000Z'
+ });
+
+ const count = await recordTemplateUsage('builtin-do-plan-task');
+ expect(count).toBe(3);
+
+ const savedState = JSON.parse(writeFile.mock.calls[0][1]);
+ expect(savedState.usage['builtin-fix-bug']).toBeUndefined();
+ expect(savedState.usage['builtin-improve-ux']).toBeUndefined();
+ expect(savedState.usage['builtin-do-plan-task']).toBe(3);
+ expect(savedState.usage['user-abc123']).toBe(9);
+ expect(savedState.userTemplates.length).toBe(1);
+ });
+ });
});