Skip to content

Commit a7c0270

Browse files
Use OpenCode commands instead of templates (anomalyco#250)
* feat: move workflows to native opencode commands * feat: show opencode commands in slash menu
1 parent 858b265 commit a7c0270

31 files changed

Lines changed: 1180 additions & 1005 deletions

‎MOTIVATIONS-PHILOSOPHY.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ These are all opencode primitives you can read the docs to find out exactly how
5757
## Core Concepts of OpenWork
5858

5959
- uses all these primitives
60-
- adds new concept of "template" simple files stored in .openwork/templates in markdown (look at repo to see how)
60+
- uses native OpenCode commands for reusable flows (markdown files in `.opencode/commands`)
6161
- adds a new abstraction "workspace" is a project fodler and a simple .json file that includes a list of opencode primitives that map perfectly to an opencode workdir (not fully implemented)
6262
- openwork can open a workpace.json and decide where to populate a folder with thse settings (not implemented today
6363

@@ -404,14 +404,14 @@ Every run provides an exportable audit log:
404404
- allow once/session
405405
- audit of decisions
406406

407-
### Templates
407+
### Commands
408408

409-
- save a task as template
410-
- variables + quick run
409+
- save a task as a command
410+
- arguments + quick run
411411

412412
### Scheduling (Future)
413413

414-
- schedule template runs
414+
- schedule command runs
415415
- notify on completion
416416

417417
---
@@ -434,7 +434,7 @@ Every run provides an exportable audit log:
434434
4. Provider/model configuration.
435435
5. `global.health()` check.
436436
6. Run a test session using `session.create()` + `session.prompt()`.
437-
7. Success + sample templates.
437+
7. Success + sample commands.
438438

439439
### 2. Pairing Onboarding (Client / Mobile)
440440

@@ -506,10 +506,10 @@ Every run provides an exportable audit log:
506506
2. Open file: `file.read()`.
507507
3. Show changed files: `file.status()`.
508508

509-
### 12. Templates
509+
### 12. Commands
510510

511-
1. Save a plan + prompt as a template.
512-
2. Re-run template creates a new session.
511+
1. Save a plan + prompt as a command.
512+
2. Re-run command creates a new session.
513513

514514
### 13. Multi-user (Future)
515515

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It’s a native desktop app that runs **OpenCode** under the hood, but presents
1616
- start a run
1717
- watch progress + plan updates
1818
- approve permissions when needed
19-
- reuse what works (templates + skills)
19+
- reuse what works (commands + skills)
2020

2121
The goal: make “agentic work” feel like a product, not a terminal.
2222

‎packages/app/src/app/app.tsx‎

Lines changed: 80 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { parse } from "jsonc-parser";
1818

1919
import ModelPickerModal from "./components/model-picker-modal";
2020
import ResetModal from "./components/reset-modal";
21-
import TemplateModal from "./components/template-modal";
21+
import CommandModal from "./components/command-modal";
22+
import CommandRunModal from "./components/command-run-modal";
2223
import WorkspacePicker from "./components/workspace-picker";
2324
import WorkspaceSwitchOverlay from "./components/workspace-switch-overlay";
2425
import CreateRemoteWorkspaceModal from "./components/create-remote-workspace-modal";
@@ -59,7 +60,7 @@ import type {
5960
WorkspaceDisplay,
6061
McpServerEntry,
6162
McpStatusMap,
62-
WorkspaceTemplate,
63+
WorkspaceCommand,
6364
UpdateHandle,
6465
} from "./types";
6566
import {
@@ -91,7 +92,7 @@ import {
9192
type ThemeMode,
9293
} from "./theme";
9394
import { createDemoState } from "./demo-state";
94-
import { createTemplateState } from "./template-state";
95+
import { createCommandState } from "./command-state";
9596
import { createSystemState } from "./system-state";
9697
import { relaunch } from "@tauri-apps/plugin-process";
9798
import { createSessionStore } from "./context/session";
@@ -683,7 +684,7 @@ export default function App() {
683684
const [showThinking, setShowThinking] = createSignal(false);
684685
const [modelVariant, setModelVariant] = createSignal<string | null>(null);
685686

686-
let loadWorkspaceTemplatesRef: (options?: { workspaceRoot?: string; quiet?: boolean }) => Promise<void> = async () => {};
687+
let loadCommandsRef: (options?: { workspaceRoot?: string; quiet?: boolean }) => Promise<void> = async () => {};
687688

688689
const workspaceStore = createWorkspaceStore({
689690
mode,
@@ -706,7 +707,7 @@ export default function App() {
706707
setBusy,
707708
setBusyLabel,
708709
setBusyStartedAt,
709-
loadWorkspaceTemplates: (options) => loadWorkspaceTemplatesRef(options),
710+
loadCommands: (options) => loadCommandsRef(options),
710711
loadSessions,
711712
refreshPendingPermissions,
712713
selectedSessionId,
@@ -727,14 +728,15 @@ export default function App() {
727728
isWindowsPlatform,
728729
});
729730

730-
const templateState = createTemplateState({
731+
const commandState = createCommandState({
731732
client,
732733
selectedSession,
733734
prompt,
734735
lastPromptSent,
735736
loadSessions,
736737
selectSession,
737738
setSessionModelById,
739+
setSessionAgent,
738740
defaultModel,
739741
modelVariant,
740742
setView,
@@ -747,32 +749,38 @@ export default function App() {
747749
});
748750

749751
const {
750-
templates,
751-
setTemplates,
752-
workspaceTemplatesLoaded,
753-
setWorkspaceTemplatesLoaded,
754-
globalTemplatesLoaded,
755-
setGlobalTemplatesLoaded,
756-
templateModalOpen,
757-
setTemplateModalOpen,
758-
templateDraftTitle,
759-
setTemplateDraftTitle,
760-
templateDraftDescription,
761-
setTemplateDraftDescription,
762-
templateDraftPrompt,
763-
setTemplateDraftPrompt,
764-
templateDraftScope,
765-
setTemplateDraftScope,
766-
workspaceTemplates,
767-
globalTemplates,
768-
openTemplateModal,
769-
saveTemplate,
770-
deleteTemplate,
771-
runTemplate,
772-
loadWorkspaceTemplates,
773-
} = templateState;
774-
775-
loadWorkspaceTemplatesRef = loadWorkspaceTemplates;
752+
commands,
753+
setCommands,
754+
commandsLoaded,
755+
setCommandsLoaded,
756+
commandModalOpen,
757+
setCommandModalOpen,
758+
commandDraftName,
759+
setCommandDraftName,
760+
commandDraftDescription,
761+
setCommandDraftDescription,
762+
commandDraftTemplate,
763+
setCommandDraftTemplate,
764+
commandDraftScope,
765+
setCommandDraftScope,
766+
runModalOpen,
767+
runModalCommand,
768+
runModalDetails,
769+
setRunModalDetails,
770+
workspaceCommands,
771+
globalCommands,
772+
otherCommands,
773+
openCommandModal,
774+
saveCommand,
775+
deleteCommand,
776+
runCommand,
777+
loadCommands,
778+
openRunModal,
779+
confirmRunModal,
780+
closeRunModal,
781+
} = commandState;
782+
783+
loadCommandsRef = loadCommands;
776784

777785
const systemState = createSystemState({
778786
client,
@@ -1658,9 +1666,6 @@ export default function App() {
16581666
// ignore
16591667
}
16601668

1661-
// Mark global templates as loaded even if nothing was stored.
1662-
setGlobalTemplatesLoaded(true);
1663-
16641669
try {
16651670
setUpdateEnv(await updaterEnvironment());
16661671
} catch {
@@ -1848,31 +1853,6 @@ export default function App() {
18481853
}
18491854
});
18501855

1851-
createEffect(() => {
1852-
if (typeof window === "undefined") return;
1853-
if (!globalTemplatesLoaded()) return;
1854-
1855-
try {
1856-
const payload = templates()
1857-
.filter((t) => t.scope === "global")
1858-
.map((t) => ({
1859-
id: t.id,
1860-
title: t.title,
1861-
description: t.description,
1862-
prompt: t.prompt,
1863-
createdAt: t.createdAt,
1864-
scope: t.scope,
1865-
}));
1866-
1867-
window.localStorage.setItem(
1868-
"openwork.templates",
1869-
JSON.stringify(payload)
1870-
);
1871-
} catch {
1872-
// ignore
1873-
}
1874-
});
1875-
18761856
createEffect(() => {
18771857
if (typeof window === "undefined") return;
18781858
try {
@@ -2124,21 +2104,22 @@ export default function App() {
21242104
activeWorkspaceRoot: isDemoMode()
21252105
? demoActiveWorkspaceDisplay().path
21262106
: workspaceStore.activeWorkspaceRoot().trim(),
2127-
workspaceTemplates: workspaceTemplates(),
2128-
globalTemplates: globalTemplates(),
2129-
setTemplateDraftTitle,
2130-
setTemplateDraftDescription,
2131-
setTemplateDraftPrompt,
2132-
setTemplateDraftScope,
2133-
resetTemplateDraft: (scope: "workspace" | "global" = "workspace") => {
2134-
setTemplateDraftTitle("");
2135-
setTemplateDraftDescription("");
2136-
setTemplateDraftPrompt("");
2137-
setTemplateDraftScope(scope);
2107+
workspaceCommands: workspaceCommands(),
2108+
globalCommands: globalCommands(),
2109+
otherCommands: otherCommands(),
2110+
setCommandDraftName,
2111+
setCommandDraftDescription,
2112+
setCommandDraftTemplate,
2113+
setCommandDraftScope,
2114+
resetCommandDraft: (scope: "workspace" | "global" = "workspace") => {
2115+
setCommandDraftName("");
2116+
setCommandDraftDescription("");
2117+
setCommandDraftTemplate("");
2118+
setCommandDraftScope(scope);
21382119
},
2139-
openTemplateModal,
2140-
runTemplate,
2141-
deleteTemplate,
2120+
openCommandModal,
2121+
runCommand: openRunModal,
2122+
deleteCommand,
21422123
refreshSkills: (options?: { force?: boolean }) => refreshSkills(options).catch(() => undefined),
21432124
refreshPlugins: (scopeOverride?: PluginScope) =>
21442125
refreshPlugins(scopeOverride).catch(() => undefined),
@@ -2290,6 +2271,9 @@ export default function App() {
22902271
setSessionAgent: setSessionAgent,
22912272
saveSession: saveSessionExport,
22922273
sessionStatusById: activeSessionStatusById(),
2274+
commands: commands(),
2275+
runCommand: runCommand,
2276+
openCommandRunModal: openRunModal,
22932277
onTryNotionPrompt: () => {
22942278
setPrompt("setup my crm");
22952279
setTryNotionPromptVisible(false);
@@ -2308,7 +2292,7 @@ export default function App() {
23082292
const dashboardTabs = new Set<DashboardTab>([
23092293
"home",
23102294
"sessions",
2311-
"templates",
2295+
"commands",
23122296
"skills",
23132297
"plugins",
23142298
"mcp",
@@ -2460,18 +2444,27 @@ export default function App() {
24602444
onReloadEngine={() => reloadWorkspaceEngine()}
24612445
/>
24622446

2463-
<TemplateModal
2464-
open={templateModalOpen()}
2465-
title={templateDraftTitle()}
2466-
description={templateDraftDescription()}
2467-
prompt={templateDraftPrompt()}
2468-
scope={templateDraftScope()}
2469-
onClose={() => setTemplateModalOpen(false)}
2470-
onSave={saveTemplate}
2471-
onTitleChange={setTemplateDraftTitle}
2472-
onDescriptionChange={setTemplateDraftDescription}
2473-
onPromptChange={setTemplateDraftPrompt}
2474-
onScopeChange={setTemplateDraftScope}
2447+
<CommandModal
2448+
open={commandModalOpen()}
2449+
name={commandDraftName()}
2450+
description={commandDraftDescription()}
2451+
template={commandDraftTemplate()}
2452+
scope={commandDraftScope()}
2453+
onClose={() => setCommandModalOpen(false)}
2454+
onSave={saveCommand}
2455+
onNameChange={setCommandDraftName}
2456+
onDescriptionChange={setCommandDraftDescription}
2457+
onTemplateChange={setCommandDraftTemplate}
2458+
onScopeChange={setCommandDraftScope}
2459+
/>
2460+
2461+
<CommandRunModal
2462+
open={runModalOpen()}
2463+
command={runModalCommand()}
2464+
details={runModalDetails()}
2465+
onDetailsChange={setRunModalDetails}
2466+
onClose={closeRunModal}
2467+
onRun={confirmRunModal}
24752468
/>
24762469

24772470
<ReloadWorkspaceToast

0 commit comments

Comments
 (0)