xonecas.io
64875
Mc

mini-coder / commit 0ee1a29

feat: support inline custom command execution

Sean2026-03-05 0ee1a29817b855049eb0b8de58ee8528c0e29cdd parent e6fada2

6 files changed

.agents/commands/release.md+25−9
@@ -1,16 +1,32 @@
11 ---
22 description: Create a new tagged npm release (patch/minor/major)
3+execution: inline
34 ---
45
56 Create a new npm release for this repo. The bump type is: $1 (default to "patch" if not provided).
67
78 Steps to follow exactly:
8-1. Run `bun run typecheck && bun run format && bun run lint && bun test` — stop and report any failures before proceeding.
9-2. Read `package.json` and determine the current version.
10-3. Compute the next version by bumping the $1 part of the semver (patch/minor/major). Default to "patch" if $1 is empty.
11-4. Update the `version` field in `package.json` to the new version.
12-5. Run `bun run build` to produce a fresh `dist/mc.js`.
13-6. Commit all staged and unstaged changes with the message: `chore: release v<new-version>`.
14-7. Create a git tag `v<new-version>` on that commit, make sure to use `-m "<version>"` to avoid interactive message editing.
15-8. Push the commit and the tag: `git push && git push --tags`.
16-9. Ask the user to run `npm publish` to publish to npm to complete the push with passkey auth.
9+1. Normalize bump type to one of `patch|minor|major`; if empty, use `patch`.
10+2. Verify git state before doing anything:
11+ - current branch must be `main`
12+ - working tree must be clean
13+ - run `git fetch origin --tags` and ensure `HEAD` equals `origin/main`
14+ If any check fails, stop and report.
15+3. Run `bun run typecheck && bun run format && bun run lint && bun test` — stop and report failures.
16+4. Read `package.json` and capture both `name` and current `version`.
17+5. Compute the next semver version by bumping the selected part.
18+6. Guardrails before mutating files:
19+ - ensure git tag `v<new-version>` does not exist locally or on origin
20+ - ensure npm version does not already exist: `npm view <package-name>@<new-version> version`
21+ If either exists, stop and report.
22+7. Update the `version` field in `package.json` to `<new-version>`.
23+8. Run `bun run build`.
24+9. Commit all staged and unstaged changes with message: `chore: release v<new-version>`.
25+10. Create annotated tag: `git tag -a v<new-version> -m "<new-version>"`.
26+11. Push explicitly to main and the exact tag:
27+ - `git push origin main`
28+ - `git push origin v<new-version>`
29+12. Post-push verification: run `npm view <package-name>@<new-version> version`.
30+ - If it already exists, report that publish already happened and do **not** ask user to publish again.
31+ - If it does not exist, ask user to run `npm publish` (passkey auth step).
32+
docs/custom-commands.md+24−1
@@ -38,7 +38,9 @@ Then in the REPL:
3838 | Field | Required | Description |
3939 |---|---|---|
4040 | `description` | No | Shown in `/help`. Defaults to the command name. |
41-| `model` | No | Override the active model for this command. |
41+| `model` | No | Override the active model for this command (subagent execution). |
42+| `execution` | No | Where the command runs: `subagent` (default) or `inline`. |
43+
4244
4345 ## Arguments
4446
@@ -118,6 +120,27 @@ List each occurrence with file path and line number. No explanations needed.
118120
119121 Large models for deep analysis, small models for search and lookup.
120122
123+## Execution mode
124+
125+By default, commands run with `execution: subagent` (even if `execution`
126+is omitted).
127+
128+Use `execution: inline` to run the command in the main agent context
129+instead of spawning a subagent worktree.
130+
131+```md
132+---
133+description: Safe release flow
134+execution: inline
135+---
136+
137+Run the release steps in this main repo checkout.
138+```
139+
140+Use `inline` for repo-sensitive workflows (like release flows) where branch
141+context must be exactly the current session branch.
142+
143+
121144 ## Precedence
122145
123146 Custom commands shadow built-ins. If you create `.agents/commands/review.md`
src/cli/commands.ts+4−0
@@ -403,6 +403,10 @@ async function handleCustomCommand(
403403 writeln(`${PREFIX.info} ${label} ${src}`);
404404 writeln();
405405
406+ if (cmd.execution === "inline") {
407+ return { type: "inject-user-message", text: prompt };
408+ }
409+
406410 try {
407411 const output = await ctx.runSubagent(prompt, cmd.model);
408412 assertSubagentMerged(output);
src/cli/custom-commands.test.ts+11−0
@@ -40,6 +40,17 @@ describe("loadCustomCommands", () => {
4040 expect(cmd?.model).toBe("zen/claude-3-5-haiku");
4141 expect(cmd?.template).toBe("Hello $ARGUMENTS");
4242 expect(cmd?.source).toBe("local");
43+ expect(cmd?.execution).toBe("subagent");
44+ });
45+
46+ test("supports inline execution via frontmatter", () => {
47+ writeCmd(
48+ dir,
49+ "release",
50+ "---\ndescription: Release\nexecution: inline\n---\n\nShip it",
51+ );
52+ const cmd = loadCustomCommands(dir).get("release");
53+ expect(cmd?.execution).toBe("inline");
4354 });
4455
4556 test("falls back to name as description when frontmatter has none", () => {
src/cli/custom-commands.ts+3−0
@@ -11,6 +11,8 @@ export interface CustomCommand {
1111 template: string;
1212 /** "global" (~/.agents/) or "local" (./.agents/) — local wins on conflict */
1313 source: "global" | "local";
14+ /** Where this command should execute */
15+ execution: "subagent" | "inline";
1416 }
1517
1618 // ─── Load all custom commands (global + local, local wins) ───────────────────
@@ -27,6 +29,7 @@ export function loadCustomCommands(cwd: string): Map<string, CustomCommand> {
2729 ...(meta.model ? { model: meta.model } : {}),
2830 template: body,
2931 source,
32+ execution: meta.execution === "inline" ? "inline" : "subagent",
3033 }),
3134 });
3235 }
src/cli/frontmatter.ts+2−0
@@ -4,6 +4,7 @@ export interface Frontmatter {
44 description?: string;
55 model?: string;
66 name?: string;
7+ execution?: string;
78 }
89
910 const FM_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
@@ -28,6 +29,7 @@ export function parseFrontmatter(raw: string): {
2829 if (key === "name") meta.name = val;
2930 if (key === "description") meta.description = val;
3031 if (key === "model") meta.model = val;
32+ if (key === "execution") meta.execution = val;
3133 }
3234
3335 return { meta, body: (m[2] ?? "").trim() };