Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/opencode/src/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ export namespace Command {
// workaround for zod not supporting async functions natively so we use getters
// https://zod.dev/v4/changelog?id=zfunction
template: z.promise(z.string()).or(z.string()),
// AGENTS: The `ignored` property marks commands whose output should not be processed by the model.
// When merging this branch, ensure `ignored` is included in ALL places where commands are loaded:
// 1. The Info schema (here)
// 2. The Config.Command schema in config/config.ts
// 3. Any command loading loops (e.g., state(), loadFreshCommands(), etc.)
// 4. The prompt.ts code that marks text parts as ignored
// DO NOT clobber or omit this property during merges!
subtask: z.boolean().optional(),
ignored: z.boolean().optional(),
hints: z.array(z.string()),
})
.meta({
Expand Down Expand Up @@ -81,6 +89,7 @@ export namespace Command {
},
}

// AGENTS: When merging, ensure ALL command loading loops include `ignored: command.ignored`
for (const [name, command] of Object.entries(cfg.command ?? {})) {
result[name] = {
name,
Expand All @@ -92,6 +101,8 @@ export namespace Command {
return command.template
},
subtask: command.subtask,
// AGENTS: DO NOT omit this line when merging! See comment above on Info schema.
ignored: command.ignored,
hints: hints(command.template),
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,11 @@ export namespace Config {
description: z.string().optional(),
agent: z.string().optional(),
model: ModelId.optional(),
// AGENTS: The `ignored` property marks commands whose output should not be processed by the model.
// When merging this branch, ensure `ignored` is included here AND in Command.Info schema.
// DO NOT clobber or omit this property during merges!
subtask: z.boolean().optional(),
ignored: z.boolean().optional(),
})
export type Command = z.infer<typeof Command>

Expand Down
12 changes: 7 additions & 5 deletions packages/opencode/src/session/message-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,13 @@ export namespace MessageV2 {
}
result.push(userMessage)
for (const part of msg.parts) {
if (part.type === "text" && !part.ignored)
userMessage.parts.push({
type: "text",
text: part.text,
})
if (part.type === "text") {
if (!part.ignored)
userMessage.parts.push({
type: "text",
text: part.text,
})
}
// text/plain and directory files are converted into text parts, ignore them
if (part.type === "file" && part.mime !== "text/plain" && part.mime !== "application/x-directory")
userMessage.parts.push({
Expand Down
8 changes: 8 additions & 0 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,13 @@ NOTE: At any point in time through this workflow you should feel free to ask the
}

const templateParts = await resolvePromptParts(template)
if (command.ignored) {
for (const part of templateParts) {
if (part.type === "text") {
part.ignored = true
}
}
}
const isSubtask = (agent.mode === "subagent" && command.subtask !== false) || command.subtask === true
const parts = isSubtask
? [
Expand Down Expand Up @@ -1873,6 +1880,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
agent: userAgent,
parts,
variant: input.variant,
noReply: command.ignored,
})) as MessageV2.WithParts

Bus.publish(Command.Event.Executed, {
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@ export type Config = {
agent?: string
model?: string
subtask?: boolean
ignored?: boolean
}
}
/**
Expand Down Expand Up @@ -1836,6 +1837,7 @@ export type Command = {
source?: "command" | "mcp" | "skill"
template: string
subtask?: boolean
ignored?: boolean
hints: Array<string>
}

Expand Down