Skip to content

[Coda] Add structured workspace command action - #2972

Merged
George Ng (GeorgeNgMsft) merged 8 commits into
mainfrom
georgengmsft-structured-command-execution
Sep 5, 2026
Merged

[Coda] Add structured workspace command action#2972
George Ng (GeorgeNgMsft) merged 8 commits into
mainfrom
georgengmsft-structured-command-execution

Conversation

@GeorgeNgMsft

@GeorgeNgMsft George Ng (GeorgeNgMsft) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an action to directly run structured commands for the VS Code Coda integration and MCP clients. Allows the user to conveniently run their build commands quickly and in the same window as TypeAgent.
Structured command: run command pnpm run build or execute command pnpm run lint uses the new grammar and structured runner.

Examples :
image
image
image

  • Exposes typed
    un_workspace_command and cancel_workspace_command MCP tools with structured output.
  • Runs bounded focused build, test, lint, and diagnostic commands in exactly one connected workspace.
  • Returns stdout, stderr, exit code, duration, timeout, cancellation, and truncation metadata; includes safe cancellation and process cleanup.
  • Preserves the existing integrated-terminal behavior while adding schema, grammar, documentation, and focused tests.

Validation

  • pnpm --filter agent-coda run build && pnpm --filter agent-coda run test:local
  • pnpm --filter @typeagent/code-agent run build plus targeted result-relay test
  • pnpm --filter command-executor-mcp run build plus targeted MCP schema test
  • Prettier and lint, complexity, circular-dependency, and debt ratchets

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title Add structured workspace command action [Code Agent] Add action for running workspace commands Sep 4, 2026
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title [Code Agent] Add action for running workspace commands [Coda] Add structured workspace command action Sep 4, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread ts/packages/coda/src/workspaceCommandPolicy.ts Outdated
Comment thread ts/packages/coda/src/workspaceCommandRunner.ts
Comment thread ts/packages/coda/package.json Outdated
Comment thread ts/.gitignore
Comment thread ts/packages/agents/code/src/vscode/workbenchCommandActionsSchema.ts
Comment thread ts/packages/agents/code/src/codeActionHandler.ts Outdated
@TalZaccai

Copy link
Copy Markdown
Contributor

George Ng (@GeorgeNgMsft) - I opened an issue regarding the silent keyword-file drift. If you have some time and can address it - that'd be great! :) #2978

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ontract

Scope the command-result failure shape to the two workspace-command
actions. Every other code action failing in the websocket handler was
answering with a stdout/stderr/exitCode payload, which displayCodaResult
rendered as a fake command result.

Only runWorkspaceCommand skips the await in the message loop. Making
every action fire-and-forget let unrelated editor mutations interleave;
cancellation only needs the long-running action to be non-blocking.

Make executionId optional in the MCP input schema. It was required
there while the action schema and the .agr grammar both omit it, so
grammar-sourced actions failed validation. The Command Executor now
resolves one up front and forwards it, so the result and any
cancellation refer to the same command.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb716021-4cea-41f8-9b92-36508a78285b
…config

Move the cancellation-control routing table out of codeActionHandler into
cancellationControl.ts behind a minimal sendToClient interface, and cover
it with tests. The table's invariant is that every entry is removed
exactly once, on a response, either side disconnecting, a delivery
failure, the timeout, or teardown. That is the most stateful code in the
feature and had no coverage; each path now asserts the table drains.

Correct the command-risk documentation. commandRiskLevel is declared by
the caller and is advisory. The enforced boundary is the focused-tool
allowlist plus workspace-root path confinement, not a classification
Coda performs. Regenerate the workbench keyword file for the changed
schema comment.

Collapse the two duplicated workspace-command failure literals in the
Command Executor into one builder, and note the timeout constants that
are duplicated across packages and the two unrelated 5s constants.

Replace the hardcoded test file list in coda's test:local with a
tsconfig, so adding a test file no longer means editing package.json.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb716021-4cea-41f8-9b92-36508a78285b
The run_workspace_command tool description now states that the tool holds
the Command Executor for the whole run, so callers know to use a separate
MCP connection for concurrent work.

cancelWorkspaceCommand gains a comment explaining why it talks to the Code
Agent websocket directly instead of going through the dispatcher, and notes
the known agent-discovery limitation.

Also renames workspaceCommandNonRunResult to unexecutedWorkspaceCommandResult.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb716021-4cea-41f8-9b92-36508a78285b
Comment thread ts/packages/coda/src/workspaceCommandPolicy.ts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft
George Ng (GeorgeNgMsft) added this pull request to the merge queue Sep 5, 2026
Merged via the queue into main with commit f3e4308 Sep 5, 2026
27 checks passed
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.

2 participants