Repository navigation
Conversation
`commonly agent attach claude` without --env now installs a sensible
default environment that wires up `@commonlyai/mcp` via stdio. Agents get
commonly_* kernel tools out of the box — parity with cloud-codex, which
boots with the same MCP server pre-wired in ~/.codex/config.toml.
Operators can still opt out by passing an explicit --env that omits the
MCP block.
- Adds buildDefaultEnvironment(adapterName) returning a minimal MCP-only
env for adapters in ADAPTERS_WITH_DEFAULT_MCP. Only `claude` qualifies
today — codex wrapper doesn't read --mcp-config (it uses
~/.codex/config.toml, which the local wrapper doesn't write yet; that
gap is a follow-up).
- ${COMMONLY_API_URL} / ${COMMONLY_AGENT_TOKEN} placeholders are
substituted at spawn-time by adapters/claude.js, so the env stays
secret-free and survives across re-attach.
- Two new attach.test.mjs cases (claude gets default, stub doesn't) +
two unit tests for buildDefaultEnvironment.
- Fixes a stale pre-existing attach.test that asserted the legacy
runtimeType='local-cli' + wrappedCli='stub' pair — runtimeType is
per-adapter ('stub' for stub, 'claude-code' for claude) post-refactor.
Closes #440.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 24, 2026
samxu01
added a commit
that referenced
this pull request
May 24, 2026
#448, closes #440) `commonly agent attach claude` without --env now installs a sensible default environment that wires up `@commonlyai/mcp` via stdio. Agents get commonly_* kernel tools out of the box — parity with cloud-codex, which boots with the same MCP server pre-wired in ~/.codex/config.toml. Operators can still opt out by passing an explicit --env that omits the MCP block. - buildDefaultEnvironment(adapterName) returns a minimal MCP-only env for adapters in ADAPTERS_WITH_DEFAULT_MCP. Only `claude` qualifies today; codex wrapper doesn't read --mcp-config (separate gap: #449). - ${COMMONLY_API_URL} / ${COMMONLY_AGENT_TOKEN} placeholders substituted at spawn-time by adapters/claude.js, so the env stays secret-free. - 4 new test cases. Drive-by fix: stale pre-existing attach.test asserting legacy runtimeType='local-cli' + wrappedCli='stub' pair. Follow-ups filed: #449 (codex wrapper MCP), #450 (CI gap: cli/ tests not run by Test & Coverage). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
Author
|
Squash-merged to main per feedback-pr-merge-pattern. |
This was referenced May 24, 2026
Closed
samxu01
added a commit
that referenced
this pull request
May 24, 2026
CLI test suite at cli/__tests__/*.test.mjs had never been part of CI. Gap surfaced live during PR #448 verification — a stale test asserting the legacy runtimeType='local-cli'+wrappedCli='stub' pair had been failing on main for weeks, undetected. - .github/workflows/tests.yml: add `cli` to the install step (npm ci --include=dev) + add a "Run CLI tests" step after the commonly-mcp tests. - cli/__tests__/adapters.timeout-env.test.mjs: replace the inline `on: () => {}` child-process stubs with a shared makeKillableChild() that captures listeners and emits close(143) on kill(). Without this the spawn promise hangs on the never-emitted 'close' event (3 tests hit jest's 5s default and reported as failures, only because the new CI step was the first time they ran in CI). - cli/__tests__/attach.test.mjs: drop the claude-adapter integration test that depended on `claude --version` succeeding on PATH (CI runners don't have claude installed). The buildDefaultEnvironment unit tests + stub-adapter test already prove the shape. After: Test & Coverage green, kind cluster smoke test green, all 8 gating checks pass. 13/13 CLI suites pass locally, 135 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
commonly agent attach claudewithout--envnow installs a sensible default environment that wires up@commonlyai/mcpvia stdio. Agents getcommonly_*kernel tools out of the box — parity with cloud-codex, which boots with the same MCP server pre-wired in~/.codex/config.toml.Why
Before this, a fresh
commonly agent attach claude --pod Xproduced an agent that couldn't call anycommonly_*tool (nocommonly_post_message, nocommonly_read_context, etc.) — the agent would receivechat.mentionevents and respond purely through text output piped back via the runtime token's/messagesPOST. That's fine for pure chat agents but blocks any agent that needs to attach a file, react, open a DM, or write memory mid-turn. Cloud-codex doesn't have this gap because its deployment template seeds~/.codex/config.tomlwith the MCP server. The local CLI wrapper was the odd one out.Changes
buildDefaultEnvironment(adapterName)incli/src/commands/agent.js— returns a minimal env spec with one MCP entry (name: commonly,command: ['npx', '-y', '@commonlyai/mcp@latest'], env placeholders for the per-attach token + instance URL).performAttach— applied only when--envis omitted, so explicit user configs are respected as-is.ADAPTERS_WITH_DEFAULT_MCP = new Set(['claude'])— codex wrapper doesn't read--mcp-config(it uses~/.codex/config.toml, which the local wrapper doesn't write yet); stub doesn't run a real CLI. Both returnnullfrombuildDefaultEnvironment.runtimeType='local-cli'+wrappedCli='stub'pair —runtimeTypeis per-adapter post-refactor.Test plan
cd cli && NODE_OPTIONS=--experimental-vm-modules npx jest __tests__/attach.test.mjs— 10/10 pass.commonly agent attach claude --pod Xshould produce an agent that can callcommonly_post_messageon its first turn without--env.Follow-ups
~/.codex/config.toml).cli/__tests__/*.test.mjsare not part ofTest & Coverage. Worth surfacing.Closes #440.
🤖 Generated with Claude Code