Commit Graph

2 Commits

Author SHA1 Message Date
claude-ceo-assistant
76f37d928f fix(post-suspension): vanity import path go.moleculesai.app/cli (closes molecule-ai/internal#71 phase 2)
All checks were successful
Release Go binaries / test (pull_request) Successful in 1m37s
Release Go binaries / release (pull_request) Has been skipped
Migrates go.mod + 22 Go imports + README + comments + generated config
templates off the dead github.com/Molecule-AI/ identity onto the vanity
host go.moleculesai.app, owned by us.

Surfaces touched:
- go.mod module declaration: github.com/Molecule-AI/molecule-cli ->
  go.moleculesai.app/cli
- Every Go import statement under cmd/ + internal/
- README install section: rewritten to lead with the vanity install
  command (the previous text was migration-in-progress hedging)
- Comment URLs in internal/backends/backend.go + internal/cmd/connect.go
  (https://github.com/Molecule-AI/molecule-cli/issues/10) -> point at
  git.moleculesai.app/molecule-ai/molecule-cli
- Generated config templates in internal/cmd/init.go +
  internal/cmd/config.go: header URL updated so new users land on the
  live SCM
- Adds internal/lint/import_path_lint_test.go — structural test that
  walks every *.go / *.mod / Dockerfile / *.md / *.sh / *.yml in the
  module and rejects future references to github.com/Molecule-AI/ or
  Molecule-AI/molecule-monorepo. Mutation-tested before commit.

Test plan
- go build ./... clean
- go test ./... green (cmd/molecule + 5 internal packages + new lint
  gate, all pass)
- TestNoLegacyGitHubImportPaths fails on injected canary, passes on
  clean tree (no tautology)

Open dependency
- go.moleculesai.app responder must be deployed before
  'go install go.moleculesai.app/cli/cmd/molecule@latest' works
  externally. Internal builds + 'go build ./cmd/molecule' from a fresh
  clone work today (self-referential module path).
- Responder code prepared (worker.js, vendor-portable for CF Workers /
  Vercel Edge); deploy tracked separately under internal#71 phase 1.

Pairs with parallel migrations of plugin-gh-identity (#3) +
molecule-controlplane + molecule-core under the same internal#71 sweep.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 22:26:45 +00:00
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