Skip to content

Cli - Support remote slash command discovery and execution#12169

Open
eshurakov wants to merge 1 commit into
mainfrom
subsequent-animal
Open

Cli - Support remote slash command discovery and execution#12169
eshurakov wants to merge 1 commit into
mainfrom
subsequent-animal

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

What

Adds remote slash command support to the session WebSocket protocol so remote clients (VS Code extension, Agent Manager) can discover and run workspace slash commands — including session compaction.

Why

Remote sessions previously had no way to list or invoke slash commands defined in the workspace. This wires the existing Command service into the remote protocol via two new commands: list_commands and send_command.

How

  • New RemoteCommand module (packages/opencode/src/kilo-sessions/remote-command.ts): defines the protocol schemas (with per-field size caps), builds a safe catalog response (skipping malformed entries, truncating by count/byte budget), and resolves execution against real services. compact is handled as a local alias for the compaction flow.
  • RemoteSender dispatches list_commands/send_command, running each against the exact session directory via the existing provide boundary.
  • send_command validates the command still exists in the catalog before ACKing; failures after the ACK are logged with only the error class (no message leakage), while pre-ACK failures return a safe error string.
  • Covered by new tests in remote-command.test.ts and extended remote-sender.test.ts (directory isolation, stale-command rejection, missing-session, post-ACK leak prevention).

A changeset (minor) is included.

Comment thread packages/opencode/src/kilo-sessions/remote-command.ts Outdated
Comment thread packages/opencode/src/kilo-sessions/remote-command.ts Outdated
Comment thread packages/opencode/src/kilo-sessions/remote-command.ts Outdated
Comment thread packages/opencode/src/kilo-sessions/remote-command.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilo-sessions/remote-command.ts 199 Remote commands discard the client's selected agent
packages/opencode/src/kilo-sessions/remote-command.ts 201 Slash-delimited conversion corrupts provider IDs containing /
packages/opencode/src/kilo-sessions/remote-command.ts 203 Remote slash commands cannot forward attached file parts
packages/opencode/src/kilo-sessions/remote-sender.ts 81 Post-ACK logging trusts the writable, potentially secret-bearing Error.name

Fix these issues in Kilo Cloud

Files Reviewed (5 files)
  • .changeset/remote-session-slash-commands.md - 0 issues
  • packages/opencode/src/kilo-sessions/remote-command.ts - 3 issues
  • packages/opencode/src/kilo-sessions/remote-sender.ts - 1 issues
  • packages/opencode/test/kilocode/sessions/remote-command.test.ts - 0 issues
  • packages/opencode/test/kilocode/sessions/remote-sender.test.ts - 0 issues
Previous Review Summaries (3 snapshots, latest commit 918194b)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 918194b)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/kilo-sessions/remote-command.ts
  • packages/opencode/test/kilocode/sessions/remote-command.test.ts

Previous review (commit b2f1c53)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilo-sessions/remote-command.ts 160 Malformed registered compact commands can make discovery and execution disagree

Fix these issues in Kilo Cloud

Files Reviewed (2 files)
  • packages/opencode/src/kilo-sessions/remote-command.ts - 1 issues
  • packages/opencode/test/kilocode/sessions/remote-command.test.ts - 0 issues

Previous review (commit bde06ff)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilo-sessions/remote-command.ts 25 Remote arguments and message IDs are unbounded, enabling disproportionate resource use
packages/opencode/src/kilo-sessions/remote-command.ts 106 Catalog truncation can remove the built-in compact command
packages/opencode/src/kilo-sessions/remote-command.ts 107 Byte truncation performs quadratic serialization and transient allocation
packages/opencode/src/kilo-sessions/remote-command.ts 143 A configured /compact command is listed but executes built-in compaction instead

Fix these issues in Kilo Cloud

Files Reviewed (5 files)
  • .changeset/remote-session-slash-commands.md - 0 issues
  • packages/opencode/src/kilo-sessions/remote-command.ts - 4 issues
  • packages/opencode/src/kilo-sessions/remote-sender.ts - 0 issues
  • packages/opencode/test/kilocode/sessions/remote-command.test.ts - 0 issues
  • packages/opencode/test/kilocode/sessions/remote-sender.test.ts - 0 issues

Reviewed by gpt-5.6-sol · Input: 112.8K · Output: 17.4K · Cached: 935.3K

Review guidance: REVIEW.md from base branch main

@eshurakov
eshurakov force-pushed the subsequent-animal branch from bde06ff to b2f1c53 Compare July 13, 2026 12:50
Comment thread packages/opencode/src/kilo-sessions/remote-command.ts Outdated
@eshurakov
eshurakov force-pushed the subsequent-animal branch from b2f1c53 to 918194b Compare July 13, 2026 13:55
@eshurakov
eshurakov force-pushed the subsequent-animal branch from 918194b to 1ad95c0 Compare July 13, 2026 18:23
await services.command({
sessionID: input.sessionID,
command: input.command,
arguments: input.arguments,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Preserve the client's selected agent

The request schema has no agent, and this call consequently leaves SessionPrompt.command() to use cmd.agent ?? input.agent; for commands without a configured agent that means the default agent, not the agent active in the remote session. A remote /review or other generic command submitted from Plan mode can therefore run with different tools and permissions than the same command through the existing VS Code path, which explicitly forwards agent. Please carry a bounded agent identity through this protocol (or resolve the session's active agent server-side).


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

command: input.command,
arguments: input.arguments,
...(input.messageID ? { messageID: MessageID.make(input.messageID) } : {}),
...(input.model ? { model: `${input.model.providerID}/${input.model.modelID}` } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Do not flatten an unrestricted structured provider ID

The wire model deliberately keeps providerID and modelID separate, but this conversion joins them with / and SessionPrompt.command() later splits at the first slash. RemoteModelCatalog and ProviderV2.ID accept arbitrary non-empty provider IDs, so a catalog entry such as { providerID: "gateway/team", modelID: "deployment/v1" } is reinterpreted as provider gateway and model team/deployment/v1. Please either preserve the structured identity through execution or reject provider IDs containing the delimiter at the protocol boundary.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

...(input.messageID ? { messageID: MessageID.make(input.messageID) } : {}),
...(input.model ? { model: `${input.model.providerID}/${input.model.modelID}` } : {}),
...(input.variant !== undefined ? { variant: input.variant } : {}),
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Forward attached file parts with slash commands

The strict request schema cannot represent CommandInput.parts, and this execution object never forwards them. The established VS Code command path includes selected file/image parts, while SessionPrompt.command() appends those parts to every non-subtask command; remote clients must therefore either fail strict validation when they send attachments or silently run the command without the context the user selected. Please include a bounded file-parts field in the remote contract and pass it through here.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

}

function errorName(error: unknown) {
return error instanceof Error ? error.name : typeof error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Do not treat Error.name as redacted metadata

Error.name is writable and can contain arbitrary plugin/provider data, so a thrower can set it to a credential-bearing value and this helper will log that value after the ACK. The new test only puts the secret in message while assigning a fixed safe name, so it does not exercise this leak path. Please log a fixed generic label or another value that is not controlled by the thrown instance.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant