MoonshotAI / MoonshotAI/kimi-code

fix(acp-server): include full bash command in permission requests

Open Beginner friendly
#3,106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Problem

ACP session/request_permission for a Bash tool call only shows the first 50 characters of args.command, followed by if longer. Custom ACP clients (the only ACP consumers right now is the JetBrains plugin) cannot see the rest of the command before deciding to allow/deny.

Where the truncation happens

packages/agent-core-v2/src/agent/tools/os/bash/bashTool.ts builds the ToolInputDisplay:

const preview = args.command.length > 50 ? `${args.command.slice(0, 50)}…` : args.command;
return {
  description: `Running: ${preview}`, // ← 50-char preview
  display: {
    kind: 'command',
    command: args.command,                // ← full command is here
    cwd, description, language: 'bash',
  },
 ...
};

AgentToolApprovalService.requestToolApproval forwards both action (= description, with preview) and display (= full command) into ApprovalRequest.

packages/acp-server/src/approval.ts:buildPermissionToolCallUpdate builds the toolCall for the ACP client:

content.push({
  type: 'content',
  content: { type: 'text', text: `Requesting approval to ${req.action}` },
});

The req.display (which carries command: <full>) is fed through displayBlockToAcpContent in packages/acp-server/src/convert.ts, which only handles diff / file_io / plan_review. kind: 'command' returns null and is dropped.

Net effect on the wire
  • toolCall.title = "Bash"
  • toolCall.content[] = a single text entry: "Requesting approval to Running: <first 50 chars>…"

The full args.command never crosses the ACP wire. Clients cannot display it, copy it, or render it in a terminal preview.

Proposed fix

Add a kind: 'command' branch to displayBlockToAcpContent that projects block.command into a ToolCallContent text entry:

if (block.kind === 'command') {
  return { type: 'content', content: { type: 'text', text: block.command } };
}

No change to the Bash tool itself — description (the 50-char preview) stays as the one-line summary; display.command is the full form for the approval card.

Test plan
  • packages/acp-server/test/convert.test.ts: new describe('displayBlockToAcpContent') block; verify a command block renders to a text content entry whose text equals block.command; verify a command block with cwd / description does not crash and ignores those.
  • packages/acp-server/test/approval.test.ts: extend the existing buildPermissionToolCallUpdate coverage to assert content[] contains the full command.
  • packages/acp-server/test/e2e-turn.test.ts: scripted LLM issues a Bash call; the captured requestPermission payload's toolCall.content[] contains the full command.
Risk

Pure additive on the wire (a new content entry). Existing clients ignore unknown content kinds. The 50-char description in action is unchanged — only the content[] gains a new entry.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/acp-server/src/convert.ts and inspect displayBlockToAcpContent, then review the existing coverage in packages/acp-server/test/convert.test.ts. Add coverage for command displays and extend packages/acp-server/test/approval.test.ts and packages/acp-server/test/e2e-turn.test.ts to verify the full command reaches the ACP permission payload. Done means command content includes block.command while cwd and description do not cause failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.