Skip to content
Merged
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
1 change: 0 additions & 1 deletion kompass.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"adapters": {
"opencode": {
"agentMode": "all",
"subtaskCommandMode": "kompass",
},
},
}
4 changes: 0 additions & 4 deletions kompass.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@
"agentMode": {
"type": "string",
"enum": ["subagent", "primary", "all"]
},
"subtaskCommandMode": {
"type": "string",
"enum": ["kompass", "all", "off"]
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/kompass.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"adapters": {
"opencode": {
"agentMode": "all",
"subtaskCommandMode": "kompass",
},
},
}
5 changes: 0 additions & 5 deletions packages/core/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export interface KompassConfig {
adapters?: {
opencode?: {
agentMode?: "subagent" | "primary" | "all";
subtaskCommandMode?: "kompass" | "all" | "off";
};
};
}
Expand Down Expand Up @@ -210,7 +209,6 @@ export interface MergedKompassConfig {
adapters: {
opencode: {
agentMode: "subagent" | "primary" | "all";
subtaskCommandMode: "kompass" | "all" | "off";
};
};
}
Expand Down Expand Up @@ -701,9 +699,6 @@ export function mergeWithDefaults(
config?.adapters?.opencode?.agentMode ??
config?.defaults?.agentMode ??
"all",
subtaskCommandMode:
config?.adapters?.opencode?.subtaskCommandMode ??
"kompass",
},
},
};
Expand Down
13 changes: 0 additions & 13 deletions packages/core/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,6 @@ describe("object-based config", () => {
assert.equal(config.agents.enabled.includes("reviewer"), false);
assert.equal(config.components.enabled.includes("dev-flow"), false);
assert.equal(config.components.paths.commit, "components/custom-commit.md");
assert.equal(config.adapters.opencode.subtaskCommandMode, "kompass");
});

test("supports adapter-specific subtask command stripping mode", () => {
const config = mergeWithDefaults({
adapters: {
opencode: {
subtaskCommandMode: "all",
},
},
});

assert.equal(config.adapters.opencode.subtaskCommandMode, "all");
});

test("supports skill entry maps", () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/opencode/.opencode/kompass.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@
},
"adapters": {
"opencode": {
"agentMode": "all",
"subtaskCommandMode": "kompass"
"agentMode": "all"
}
}
}
50 changes: 0 additions & 50 deletions packages/opencode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
type MergedKompassConfig,
type Shell,
} from "../core/index.ts";
import { DEFAULT_COMMAND_NAMES } from "../core/lib/config.ts";
import { applyAgentsConfig, applyCommandsConfig, applySkillsConfig } from "./config.ts";
import { createPluginLogger, getErrorDetails, type PluginLogger } from "./logging.ts";
import {
Expand Down Expand Up @@ -204,33 +203,6 @@ export function getCommandExecution(
};
}

export function removeSubtaskCommands(output: CommandExecuteBeforeOutput): number {
let removed = 0;

for (const part of output.parts) {
if (part.type !== "subtask") continue;
if (!("command" in part) || typeof part.command !== "string") continue;

delete (part as { command?: string }).command;
removed++;
}

return removed;
}

export function shouldRemoveSubtaskCommand(
command: string,
config: MergedKompassConfig,
kompassCommands = new Set<string>(DEFAULT_COMMAND_NAMES),
): boolean {
const mode = config.adapters.opencode.subtaskCommandMode;

if (mode === "off") return false;
if (mode === "all") return true;

return kompassCommands.has(command);
}

export function removeSyntheticAgentHandoff(output: ChatMessageOutput): boolean {
const filteredParts = output.parts.filter((part) => !(
part.type === "text" &&
Expand Down Expand Up @@ -437,16 +409,6 @@ export const OpenCodeCompassPlugin: Plugin = async (input: PluginInput) => {
}

const tools = await createToolsSafely();
let config = mergeWithDefaults(null);
try {
config = mergeWithDefaults(await loadKompassConfig(worktree));
} catch (error) {
await logger.warn("Falling back to default Kompass runtime config", {
worktree,
...getErrorDetails(error),
});
}
const kompassCommands = new Set<string>(DEFAULT_COMMAND_NAMES);

return {
tool: tools,
Expand Down Expand Up @@ -476,20 +438,8 @@ export const OpenCodeCompassPlugin: Plugin = async (input: PluginInput) => {
},
async "command.execute.before"(input, output) {
try {
const removedSubtaskCommands = shouldRemoveSubtaskCommand(input.command, config, kompassCommands)
? removeSubtaskCommands(output)
: 0;
const commandExecution = getCommandExecution(input, output);

if (removedSubtaskCommands > 0) {
await logger.info("Removed subtask command payload", {
command: input.command,
arguments: input.arguments,
sessionID: input.sessionID,
removedSubtaskCommands,
});
}

if (!commandExecution) return;

await logger.info("Executing Kompass command", commandExecution as Record<string, unknown>);
Expand Down
1 change: 0 additions & 1 deletion packages/opencode/kompass.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"adapters": {
"opencode": {
"agentMode": "all",
"subtaskCommandMode": "kompass",
},
},
}
67 changes: 0 additions & 67 deletions packages/opencode/test/task-hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
getCommandExecution,
getTaskToolExecution,
removeSyntheticAgentHandoff,
removeSubtaskCommands,
shouldRemoveSubtaskCommand,
} from "../index.ts";
import { mergeWithDefaults } from "../../core/lib/config.ts";

describe("getTaskToolExecution", () => {
test("expands slash commands for task tool calls", async () => {
Expand Down Expand Up @@ -170,70 +167,6 @@ describe("getCommandExecution", () => {
});
});

describe("removeSubtaskCommands", () => {
test("removes command from subtask parts", () => {
const output = {
parts: [
{
id: "part-1",
sessionID: "session-3",
messageID: "message-1",
type: "subtask",
prompt: "expanded command prompt",
description: "Run review command",
agent: "general",
command: "review",
},
{
id: "part-2",
sessionID: "session-3",
messageID: "message-1",
type: "text",
text: "keep this",
},
],
};

const removed = removeSubtaskCommands(output as never);

assert.equal(removed, 1);
assert.equal("command" in output.parts[0], false);
});
});

describe("shouldRemoveSubtaskCommand", () => {
test("defaults to stripping commands only for Kompass commands", () => {
const config = mergeWithDefaults(null);

assert.equal(shouldRemoveSubtaskCommand("review", config), true);
assert.equal(shouldRemoveSubtaskCommand("third-party", config), false);
});

test("supports enabling stripping for all commands", () => {
const config = mergeWithDefaults({
adapters: {
opencode: {
subtaskCommandMode: "all",
},
},
});

assert.equal(shouldRemoveSubtaskCommand("third-party", config), true);
});

test("supports disabling stripping entirely", () => {
const config = mergeWithDefaults({
adapters: {
opencode: {
subtaskCommandMode: "off",
},
},
});

assert.equal(shouldRemoveSubtaskCommand("review", config), false);
});
});

describe("removeSyntheticAgentHandoff", () => {
test("removes the legacy synthetic agent handoff text", () => {
const output = {
Expand Down
121 changes: 0 additions & 121 deletions packages/opencode/test/tool-registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,125 +254,4 @@ describe("createOpenCodeTools", () => {
});
});

test("strips subtask command payload only for Kompass commands by default", async () => {
await withTempHome(async () => {
const plugin = await OpenCodeCompassPlugin({
$: (() => {
throw new Error("not implemented");
}) as never,
client: createMockClient() as never,
directory: process.cwd(),
worktree: process.cwd(),
} as never);

const kompassOutput = {
parts: [
{
id: "part-1",
sessionID: "session-1",
messageID: "message-1",
type: "subtask",
prompt: "expanded",
description: "Run review command",
agent: "reviewer",
command: "review",
},
],
};

await plugin["command.execute.before"]?.(
{
command: "review",
sessionID: "session-1",
arguments: "",
} as never,
kompassOutput as never,
);

assert.equal("command" in kompassOutput.parts[0], false);

const thirdPartyOutput = {
parts: [
{
id: "part-2",
sessionID: "session-1",
messageID: "message-2",
type: "subtask",
prompt: "expanded",
description: "Run external command",
agent: "reviewer",
command: "third-party",
},
],
};

await plugin["command.execute.before"]?.(
{
command: "third-party",
sessionID: "session-1",
arguments: "",
} as never,
thirdPartyOutput as never,
);

assert.equal((thirdPartyOutput.parts[0] as { command?: string }).command, "third-party");
});
});

test("supports stripping subtask command payload for all commands via config", async () => {
await withTempHome(async () => {
const tempDir = await mkdtemp(path.join(os.tmpdir(), "kompass-tools-subtask-mode-"));

try {
await mkdir(path.join(tempDir, ".opencode"), { recursive: true });
await writeFile(
path.join(tempDir, ".opencode", "kompass.jsonc"),
`{
"adapters": {
"opencode": {
"subtaskCommandMode": "all"
}
}
}`,
);

const plugin = await OpenCodeCompassPlugin({
$: (() => {
throw new Error("not implemented");
}) as never,
client: createMockClient() as never,
directory: tempDir,
worktree: tempDir,
} as never);

const output = {
parts: [
{
id: "part-1",
sessionID: "session-1",
messageID: "message-1",
type: "subtask",
prompt: "expanded",
description: "Run external command",
agent: "reviewer",
command: "third-party",
},
],
};

await plugin["command.execute.before"]?.(
{
command: "third-party",
sessionID: "session-1",
arguments: "",
} as never,
output as never,
);

assert.equal("command" in output.parts[0], false);
} finally {
await rm(tempDir, { recursive: true, force: true });
}
});
});
});
Loading