Go to file
Hongming Wang b7a3c887c0 feat(connect): M1.3 — exec + claude-code backends
After this PR `molecule connect <id>` actually does something useful:
the default `--backend claude-code` runs `claude -p` as a subprocess
per inbound message, capturing stdout as the reply. The general
`--backend exec --backend-opt cmd="..."` lets operators bridge to any
program that reads stdin and writes stdout (Ollama, custom Python,
shell pipelines).

What's in:

- `internal/backends/exec/exec.go` — generic exec backend.
  - cmd  (required): shell command, run via /bin/sh -c (or cmd /c).
  - timeout (default 60s): per-message wall clock; subprocess is
    killed on timeout and the dispatcher keeps the message queued.
  - pass_meta (default false): when true, populates env with
    MOLECULE_WORKSPACE_ID / CALLER_ID / MESSAGE_ID / TASK_ID / METHOD.
  - Stdin = joined text parts; stdout = reply text.
  - Stderr is captured + surfaced in error messages so operators can
    see what their command printed.
  - Honours ctx cancellation — SIGTERM kills the subprocess immediately.

- `internal/backends/claudecode/claudecode.go` — thin shorthand.
  Translates {bin, args, timeout, pass_meta} into the equivalent exec
  config. Defaults: bin=claude, timeout=5m, pass_meta=true.
  Reusing exec means timeout/stdin/env handling stays in one place.

- `internal/cmd/connect.go` — registers both backends so `--help`
  shows them and the default `--backend claude-code` works without
  flag tuning.

Test plan:

- exec: cmd-required, bad-timeout, zero-timeout, echo-stdin-to-stdout,
  text-only-part-concat, non-zero-exit-surfaces-stderr, timeout-kills-
  runaway, pass_meta-injects-env, no-pass_meta-leaves-env-untouched,
  parent-env-inherited-when-pass_meta-off, ctx-cancel-kills-command.
- claude-code: registered, bin/args translation produces "echo -p hello",
  bad-timeout-surfaces, default-config-builds.
- All Unix tests gated on `requireUnix(t)` — Windows-shell semantics
  diverge; cross-platform coverage is M3 work (brew/scoop/winget).
- Full suite green under -race.

UX after this PR:

  # default — Claude Code on PATH
  molecule connect ws_01HF... --token $T

  # custom handler
  molecule connect ws_01HF... --backend exec \
      --backend-opt cmd="python myhandler.py"

  # different model via Claude Code
  molecule connect ws_01HF... \
      --backend-opt args="--model claude-sonnet-4-6"

  # CI smoke
  molecule connect ws_01HF... --backend mock --backend-opt reply=ok

Out of scope (M1.4 + later):

- M1.4: GoReleaser tag-triggered release.yml workflow
- stdio backend (one persistent subprocess + line-delimited JSON-RPC)
  — moved to M2 since exec covers the common case
- openai / mcp backends — M4 per RFC

RFC: https://github.com/Molecule-AI/molecule-cli/issues/10

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 04:23:36 -07:00
.claude docs: add CLAUDE.md, known-issues.md, and .claude/settings.json (#2) 2026-04-20 23:10:40 +00:00
.github/workflows fix(ci): sync auto-promote workflow (ff-only, no-gates mode) 2026-04-24 08:35:20 -07:00
bin fix(cli): align rootCmd.Use to goreleaser binary name 2026-04-22 05:36:07 +00:00
cmd/molecule feat(cli): add --force flag to molecule init 2026-04-23 21:17:36 +00:00
internal feat(connect): M1.3 — exec + claude-code backends 2026-04-30 04:23:36 -07:00
.gitignore chore: gitignore credentials for molecule-cli 2026-04-16 09:18:55 -07:00
.goreleaser.yaml chore(cli): add .goreleaser.yaml and resolve KI-004 2026-04-21 10:33:08 +00:00
CLAUDE.md feat: implement full CLI command tree 2026-04-23 18:44:24 +00:00
go.mod feat(connect): M1.1 — Backend interface + connect skeleton + mock backend 2026-04-30 02:05:12 -07:00
go.sum feat: implement full CLI command tree 2026-04-21 01:18:24 +00:00
known-issues.md feat: implement full CLI command tree 2026-04-23 18:44:24 +00:00
pr-description-draft-cli-full.md fix(cli): align rootCmd.Use to goreleaser binary name 2026-04-22 05:36:07 +00:00
README.md feat: initial CLI (extracted from molecule-monorepo/platform/cmd/cli) 2026-04-16 03:15:58 -07:00

molecule-cli (molecli)

Go TUI dashboard for Molecule AI — real-time workspace monitoring, event log, health overview, delete/filter operations.

Install

go install github.com/Molecule-AI/molecule-cli/cmd/molecli@latest

Or download a binary from Releases.

Usage

export MOLECLI_URL=http://localhost:8080  # or your platform URL
molecli

Features

  • Real-time workspace status (online/offline/degraded/paused)
  • Event log with filtering
  • Workspace CRUD operations
  • Agent session management
  • Memory/skill inspection
  • A2A chat interface

License

Business Source License 1.1 — © Molecule AI.