Skip to content

feat: alice workspace CLI adapter + chat-cli template#250

Merged
luokerenx4 merged 4 commits into
masterfrom
tool-issue
Jun 2, 2026
Merged

feat: alice workspace CLI adapter + chat-cli template#250
luokerenx4 merged 4 commits into
masterfrom
tool-issue

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

Adds a third adapter over the tool registry — a workspace-local alice CLI — alongside the existing HTTP routes (UI) and MCP tools (in-proc AI). It's the adapter that fits the workspace consumer (a native unix-CLI agent), which was never built — so news had been faking it inside the MCP surface.

  • alice CLI (src/server/cli.ts + src/server/cli-commands.ts + src/workspaces/cli/bin/alice): a capability-agnostic argv → JSON → HTTP forwarder. The /cli/:wsId/{manifest,invoke} gateway mounts on the MCP server (open port, identity-by-URL, no token) and reuses extractMcpShape/wrapToolExecute, so CLI and MCP are two front-ends over one ToolCenter. Surface = alice <group> <verb> --flags, manifest-driven --help, JSON to stdout, unix exit codes. Trading + cron deliberately excluded (still MCP-reachable) pending a boundary review.
  • PATH injection via cliBinPath() in buildSpawnEnv — one shared script, never written into a workspace (no bootstrap.sh change, no git pollution). Couples to a runtime only through "has a shell + PATH", so it applies to any future agent runtime for free.
  • chat-cli template: routes data tools through the CLI while keeping the stateful inbox on MCP. Realized by widening the launcher's injectMcp flag to a tri-state (true / 'inbox' / false) in context-injector.ts; 'inbox' writes only the workspace inbox server. Bundles a new openalice-cli skill. The standard chat template is untouched and injectMcp: true output stays byte-identical.
  • Two tool-layer fixes surfaced while dogfooding the CLI:
    • news readNews now addresses by stable id (NewsItem.id = seq) — kills the index/lookback coupling bug.
    • equity ratios returns TTM + history (defaults ttm:'include', exposes a ttm flag) instead of a single TTM snapshot with dead period/limit.

Test plan

  • npx tsc --noEmit clean
  • pnpm test — 1728 passing (incl. new cli.spec.ts, cli-commands.spec.ts, and the inbox-mode injector golden)
  • Live: real /cli gateway over HTTP driven by the real alice client — group/verb listing, --help, invoke (think calc → 42), and every failure path (bad args / unknown group / unknown workspace / backend down → clean stderr + non-zero exit)
  • Live: chat-cli end-to-end — discovered + parsed (injectMcp:'inbox'), injection produces an inbox-only .mcp.json (no global tool server) with persona + the openalice-cli skill in both .claude/ and .agents/

Boundary touch

Touches the workspace launcher (context-injector injectMcp tri-state, spawn-env PATH) and the tool layer (news addressing, equity ratios). No trading / auth / broker-credential / migration changes — and trading + cron are deliberately kept off the new CLI surface.

🤖 Generated with Claude Code

Ame and others added 4 commits June 2, 2026 12:10
The third adapter over domain/ (after HTTP routes + MCP tools): the one
that fits the workspace consumer — a native unix-CLI agent — which was
never built, so `news` faked it inside the MCP surface (the readNews
index/lookback coupling bug).

- src/server/cli.ts: /cli/:wsId/{manifest,invoke} mounted in McpPlugin
  (same open port, identity-by-URL, no token), reusing extractMcpShape +
  wrapToolExecute — CLI and MCP are two front-ends over one ToolCenter.
- src/server/cli-commands.ts: the `alice <group> <verb>` alias map = the
  CLI's public contract; invoke is gated to it. trading/cron deliberately
  excluded (still MCP-reachable) pending boundary review.
- src/workspaces/cli/bin/alice: zero-import, build-free node forwarder;
  manifest-driven --help; JSON stdout; unix exit codes.
- PATH injection via cliBinPath() in buildSpawnEnv — shared script, never
  written into a workspace (no bootstrap.sh change, no git pollution).
- Documented `alice` in chat + finance-research CLAUDE.md.
- News: NewsItem.id = seq; readNews({id}) resolves by stable id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…a MCP

An experimental workspace template that routes OpenAlice's market/data tools
through the `alice` CLI instead of MCP, while keeping the stateful inbox
channel on MCP. A testbed for CLI-mode context injection that generalizes to
any future agent runtime with a shell (no per-runtime MCP wiring).

- context-injector: `injectMcp` gains an 'inbox' mode that writes ONLY the
  workspace inbox server (drops the global tool server); the `true` output
  stays byte-identical. TemplateMeta.injectMcp widened to `boolean | 'inbox'`.
- default/skills/openalice-cli: a skill teaching the agent to use `alice`
  (discover with --help, JSON out, exit codes, inbox stays MCP).
- templates/chat-cli: template.json (injectMcp:'inbox', bundles openalice-cli
  + the tool-agnostic research skills), instruction.md, README, bootstrap.sh.
- chat template untouched; existing injector behavior unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
equityGetRatios forwarded no `ttm`, so the FMP fetcher's default (ttm:'only')
returned a single TTM row with `period`/`limit` effectively dead — which
surfaced as a "thin" result when poked via the `alice` CLI.

- Default to ttm:'include' so the historical series (and therefore
  period/limit) actually come through (TTM + `limit` periods).
- Expose `ttm` as an enum flag (include/exclude/only) so the agent can pick
  snapshot-only vs history-only. Manifest is schema-derived, so
  `alice equity ratios --help` picks it up automatically.
- Correct the description (it claimed "default: 5 periods" while returning 1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 2, 2026 6:29am

Request Review

@luokerenx4 luokerenx4 merged commit a724057 into master Jun 2, 2026
3 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.

1 participant