Compare commits

..

1 Commits

Author SHA1 Message Date
Hongming Wang
d84591e046 docs(readme): document all subcommands (was 3, actually 20+)
Previous README documented 3 subcommands and got the completion shape
wrong (`completion generate`). Code has 6 top-level commands plus init,
totalling 22 subcommands.

Add a full command reference covering every subcommand in cmd tree:

- workspace: list, create, inspect, delete, restart, audit, delegate
- agent: list, inspect, send, peers
- platform: audit, health
- config: list, get, set, init, view
- connect: bridge external workspace (existing Quick Start)
- init: scaffold molecule.yaml
- completion: bash | zsh | fish | powershell  (was: completion generate)

Each entry has a one-line purpose, key flags where applicable, and an
example. Also calls out `connect --mode push` (M4, not yet wired) and
the canvas-origin reply TODO in internal/connect/connect.go so users
know what isn't ready yet.

README-only change. No Go code edits.
2026-05-01 19:18:10 -07:00
22 changed files with 187 additions and 200 deletions

View File

@ -34,7 +34,7 @@ There is no `main.go` or `cmd/molecule/main.go` yet. Creating it is the first im
## 3. Go Module Conventions
**Module path:** `go.moleculesai.app/cli` (from `go.mod`)
**Module path:** `github.com/Molecule-AI/molecule-cli` (from `go.mod`)
**Dependency management:**
- Use `go mod tidy` after adding or removing dependencies.

175
README.md
View File

@ -8,23 +8,12 @@ command, or a mock for CI).
## Install
```bash
go install go.moleculesai.app/cli/cmd/molecule@latest
go install github.com/Molecule-AI/molecule-cli/cmd/molecule@latest
```
The vanity import path `go.moleculesai.app/cli` resolves via the
Molecules AI go-get responder (issue [internal#71][i71]) to our
canonical SCM at git.moleculesai.app. It is independent of any specific
SCM host — when we move SCMs again, no install command changes.
Alternatively, build from source:
```bash
git clone https://git.moleculesai.app/molecule-ai/molecule-cli.git
cd molecule-cli
go build -o molecule ./cmd/molecule
```
[i71]: https://git.moleculesai.app/molecule-ai/internal/issues/71
Or download a binary from [Releases](https://github.com/Molecule-AI/molecule-cli/releases).
Releases ship Linux/macOS/Windows × amd64/arm64 archives plus a sha256
checksums file (see `.goreleaser.yaml`).
## Quick start — connect an external workspace
@ -70,7 +59,7 @@ molecule connect ws_abc \
### Other useful flags
```
--mode poll|push delivery mode (default: poll)
--mode poll|push delivery mode (default: poll; push is M4, not yet implemented)
--interval-ms 2000 poll cadence
--since-secs 60 initial activity cursor lookback
--token TOKEN override MOLECULE_WORKSPACE_TOKEN
@ -81,15 +70,159 @@ State (the activity cursor) is persisted to
`~/.config/molecule/state/<workspace-id>.json` (mode 0600) so a restart
resumes from the last delivered message.
## Other subcommands
> Note: poll-mode dispatch into backends works end-to-end. Posting the
> backend's reply back to the canvas-origin sender is still wired as a
> TODO (see `internal/connect/connect.go` — M1.3); platform-API replies
> for non-canvas A2A flow correctly.
## Command reference
The full top-level tree:
```
molecule agent list / inspect agent sessions
molecule config view / set CLI defaults
molecule completion generate shell completions
molecule
├── workspace list / create / inspect / delete / restart / audit / delegate
├── agent list / inspect / send / peers
├── platform audit / health
├── config list / get / set / init / view
├── connect bridge an external workspace to a local backend
├── init scaffold a molecule.yaml in the current directory
└── completion emit shell completion script (bash | zsh | fish | powershell)
```
The full M1 design is in [RFC #10](https://git.moleculesai.app/molecule-ai/molecule-cli/issues/10) (originally filed on the suspended GitHub org; the issue may be re-filed on Gitea — check the issue tracker for the live discussion).
Global flags (apply to every subcommand): `--api-url`, `--config`,
`-o/--output table|json|yaml`, `-v/--verbose`.
### `molecule workspace`
Manage Molecule AI workspaces.
- **`workspace list`** — list all workspaces in the org.
```bash
molecule workspace list
molecule workspace list -o json
```
- **`workspace create --name <name> [flags]`** — create a workspace.
Flags: `--role`, `--runtime`, `--template`, `--parent-id`,
`--workspace-dir`, `--tier`.
```bash
molecule workspace create --name pm-bot --role pm --runtime claude-code
```
- **`workspace inspect <workspace-id>`** — show full details for a workspace.
```bash
molecule workspace inspect ws_01HF2K...
```
- **`workspace delete <workspace-id>`** — delete a workspace (irreversible).
```bash
molecule workspace delete ws_01HF2K...
```
- **`workspace restart <workspace-id>`** — trigger a restart.
```bash
molecule workspace restart ws_01HF2K...
```
- **`workspace audit`** — workspaces + agents report grouped by status.
```bash
molecule workspace audit -o yaml
```
- **`workspace delegate <workspace-id> <target-workspace-id> <task>`** —
enqueue a non-blocking delegation from one workspace to another.
```bash
molecule workspace delegate ws_pm ws_research "summarize last week"
```
### `molecule agent`
Inspect and interact with agents.
- **`agent list [workspace-id]`** — list all agents, optionally scoped
to one workspace.
```bash
molecule agent list
molecule agent list ws_01HF2K...
```
- **`agent inspect <agent-id>`** — show full details for an agent.
```bash
molecule agent inspect agent_abc
```
- **`agent send <agent-id> <message>`** — send a one-shot A2A message
to an agent and print the reply.
```bash
molecule agent send agent_abc "what's the deploy status?"
```
- **`agent peers <workspace-id>`** — list peer workspaces reachable
from the given workspace.
```bash
molecule agent peers ws_01HF2K...
```
### `molecule platform`
Platform-level operations.
- **`platform audit`** — full audit: workspaces, agents, delegation
counts per workspace.
```bash
molecule platform audit -o json
```
- **`platform health`** — check `/health` and version (falls back to
raw probe on older platforms).
```bash
molecule platform health
```
### `molecule config`
View and manage CLI configuration. Values resolve in order: env vars >
config file > defaults.
- **`config list`** — list all known config keys + effective values + source.
- **`config get <key>`** — print a single config value.
- **`config set <key> <value>`** — write a key to `~/.config/molecule.yaml`.
- **`config init`** — scaffold a default `molecule.yaml` in the current dir.
- **`config view`** — print the active config file with annotations.
```bash
molecule config set api_url https://your-tenant.staging.moleculesai.app
molecule config get api_url
molecule config list
```
### `molecule connect`
See [Quick start](#quick-start--connect-an-external-workspace) above.
Push mode (`--mode push`) is reserved for M4 and currently exits with a
clear error — use the default `--mode poll`.
### `molecule init`
Bootstrap a workspace by scaffolding `molecule.yaml` in the current
directory. Use `--force` to replace an existing file.
```bash
molecule init
molecule init --force
```
### `molecule completion`
Emit a shell completion script. The shell name is a positional arg —
one of `bash`, `zsh`, `fish`, `powershell`.
```bash
# bash
source <(molecule completion bash)
# zsh
source <(molecule completion zsh)
# fish
molecule completion fish | source
# PowerShell
molecule completion powershell | Out-String | Invoke-Expression
```
The full M1 design is in [RFC #10](https://github.com/Molecule-AI/molecule-cli/issues/10).
## License

View File

@ -6,7 +6,7 @@ package main
import (
"os"
"go.moleculesai.app/cli/internal/cmd"
"github.com/Molecule-AI/molecule-cli/internal/cmd"
)
func main() {

2
go.mod
View File

@ -1,4 +1,4 @@
module go.moleculesai.app/cli
module github.com/Molecule-AI/molecule-cli
go 1.25.0

View File

@ -5,7 +5,7 @@
// that registers itself via `Register()` from an `init()` block.
// Runtime selection is done via the --backend flag.
//
// See RFC: https://git.moleculesai.app/molecule-ai/molecule-cli/issues/10
// See RFC: https://github.com/Molecule-AI/molecule-cli/issues/10
package backends
import (

View File

@ -5,8 +5,8 @@ import (
"strings"
"testing"
"go.moleculesai.app/cli/internal/backends"
_ "go.moleculesai.app/cli/internal/backends/mock" // register
"github.com/Molecule-AI/molecule-cli/internal/backends"
_ "github.com/Molecule-AI/molecule-cli/internal/backends/mock" // register
)
func TestRegister_DuplicatePanics(t *testing.T) {

View File

@ -29,8 +29,8 @@ package claudecode
import (
"strings"
"go.moleculesai.app/cli/internal/backends"
exec "go.moleculesai.app/cli/internal/backends/exec"
"github.com/Molecule-AI/molecule-cli/internal/backends"
exec "github.com/Molecule-AI/molecule-cli/internal/backends/exec"
)
func init() {

View File

@ -6,8 +6,8 @@ import (
"strings"
"testing"
"go.moleculesai.app/cli/internal/backends"
_ "go.moleculesai.app/cli/internal/backends/claudecode" // register
"github.com/Molecule-AI/molecule-cli/internal/backends"
_ "github.com/Molecule-AI/molecule-cli/internal/backends/claudecode" // register
)
func requireUnix(t *testing.T) {

View File

@ -41,7 +41,7 @@ import (
"strings"
"time"
"go.moleculesai.app/cli/internal/backends"
"github.com/Molecule-AI/molecule-cli/internal/backends"
)
func init() {

View File

@ -7,8 +7,8 @@ import (
"strings"
"testing"
"go.moleculesai.app/cli/internal/backends"
_ "go.moleculesai.app/cli/internal/backends/exec" // register
"github.com/Molecule-AI/molecule-cli/internal/backends"
_ "github.com/Molecule-AI/molecule-cli/internal/backends/exec" // register
)
// requireUnix skips Windows tests that depend on /bin/sh shell semantics.

View File

@ -14,7 +14,7 @@ import (
"context"
"strings"
"go.moleculesai.app/cli/internal/backends"
"github.com/Molecule-AI/molecule-cli/internal/backends"
)
func init() {

View File

@ -7,7 +7,7 @@ import (
"os"
"text/tabwriter"
"go.moleculesai.app/cli/internal/client"
"github.com/Molecule-AI/molecule-cli/internal/client"
"github.com/spf13/cobra"
)

View File

@ -121,7 +121,7 @@ var configInitCmd = &cobra.Command{
}
func runConfigInit(cmd *cobra.Command, _ []string) error {
const defaultConfig = `# molecule CLI config https://git.moleculesai.app/molecule-ai/molecule-cli
const defaultConfig = `# molecule CLI config https://github.com/Molecule-AI/molecule-cli
#
# All values can be overridden by environment variables:
# MOLECULE_API_URL, MOLECULE_RUNTIME_URL, MOL_OUTPUT, MOL_VERBOSE, etc.

View File

@ -9,11 +9,11 @@ import (
"syscall"
"time"
"go.moleculesai.app/cli/internal/backends"
_ "go.moleculesai.app/cli/internal/backends/claudecode" // register backend
_ "go.moleculesai.app/cli/internal/backends/exec" // register backend
_ "go.moleculesai.app/cli/internal/backends/mock" // register backend
"go.moleculesai.app/cli/internal/connect"
"github.com/Molecule-AI/molecule-cli/internal/backends"
_ "github.com/Molecule-AI/molecule-cli/internal/backends/claudecode" // register backend
_ "github.com/Molecule-AI/molecule-cli/internal/backends/exec" // register backend
_ "github.com/Molecule-AI/molecule-cli/internal/backends/mock" // register backend
"github.com/Molecule-AI/molecule-cli/internal/connect"
"github.com/spf13/cobra"
)
@ -21,7 +21,7 @@ import (
// molecule connect — bridge an external-runtime workspace to a local backend.
//
// The full M1+ design lives in the RFC at
// https://git.moleculesai.app/molecule-ai/molecule-cli/issues/10. This file owns the
// https://github.com/Molecule-AI/molecule-cli/issues/10. This file owns the
// command surface; the wiring (heartbeat, activity poll, dispatch) lands in
// internal/connect/ in subsequent PRs.
// ---------------------------------------------------------------------------
@ -68,7 +68,7 @@ Examples:
molecule connect ws_01HF2K... --backend exec \
--backend-opt cmd="python myhandler.py"
See full design: https://git.moleculesai.app/molecule-ai/molecule-cli/issues/10`,
See full design: https://github.com/Molecule-AI/molecule-cli/issues/10`,
Args: cobra.ExactArgs(1),
RunE: runConnect,
}

View File

@ -40,7 +40,7 @@ func runInit(cmd *cobra.Command, _ []string) error {
if _, err := os.Stat(cfgPath); err == nil {
if initForce {
content := `# molecule CLI configuration https://git.moleculesai.app/molecule-ai/molecule-cli
content := `# molecule CLI configuration https://github.com/Molecule-AI/molecule-cli
#
# All values can be overridden by environment variables:
# MOLECULE_API_URL, MOLECULE_RUNTIME_URL, MOL_OUTPUT, MOL_VERBOSE, etc.
@ -69,7 +69,7 @@ func runInit(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("init: %s already exists — not overwriting (use --force to replace)", cfgPath)
}
content := `# molecule CLI configuration https://git.moleculesai.app/molecule-ai/molecule-cli
content := `# molecule CLI configuration https://github.com/Molecule-AI/molecule-cli
#
# All values can be overridden by environment variables:
# MOLECULE_API_URL, MOLECULE_RUNTIME_URL, MOL_OUTPUT, MOL_VERBOSE, etc.

View File

@ -8,7 +8,7 @@ import (
"os"
"text/tabwriter"
"go.moleculesai.app/cli/internal/client"
"github.com/Molecule-AI/molecule-cli/internal/client"
"github.com/spf13/cobra"
)

View File

@ -7,7 +7,7 @@ import (
"os"
"text/tabwriter"
"go.moleculesai.app/cli/internal/client"
"github.com/Molecule-AI/molecule-cli/internal/client"
"github.com/spf13/cobra"
)

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"go.moleculesai.app/cli/internal/backends"
"github.com/Molecule-AI/molecule-cli/internal/backends"
)
// Options carries the runtime knobs Run needs. Constructed by the cmd

View File

@ -13,9 +13,9 @@ import (
"testing"
"time"
"go.moleculesai.app/cli/internal/backends"
_ "go.moleculesai.app/cli/internal/backends/mock" // register mock for tests
"go.moleculesai.app/cli/internal/connect"
"github.com/Molecule-AI/molecule-cli/internal/backends"
_ "github.com/Molecule-AI/molecule-cli/internal/backends/mock" // register mock for tests
"github.com/Molecule-AI/molecule-cli/internal/connect"
)
// fakeServer is the minimum workspace-server stub the loops need:

View File

@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"
"go.moleculesai.app/cli/internal/connect"
"github.com/Molecule-AI/molecule-cli/internal/connect"
)
func TestState_LoadMissingReturnsZero(t *testing.T) {

View File

@ -1,146 +0,0 @@
// Issue molecule-ai/internal#71 lint gate.
//
// Walks every *.go file in the module + the go.mod declaration + any
// Dockerfile in the repo, and rejects any reference to the dead
// github.com/Molecule-AI/* identity (or the historical
// Molecule-AI/molecule-monorepo path).
//
// We had a 374+131+30+1-line "github.com/Molecule-AI/" footprint across
// the org pre-migration. The class of bug this gate prevents:
//
// - copy-pastes from old branches re-introducing the dead path
// - Dockerfile -ldflags strings drifting back to github.com on a
// refactor (the path has to match the module declaration to inject
// buildinfo correctly; if they disagree the binary builds but
// reports a wrong / stale GitSHA)
// - new modules added to the repo with the wrong import root because
// someone copied an old go.mod without thinking
//
// Why not just a CI shell grep: a Go test runs everywhere `go test ./...`
// runs, including local pre-push hooks and contributor IDEs. The gate
// fires immediately, with a per-file message that points at the line —
// CI shell grep failures are silent until the runner picks them up.
package lint
import (
"os"
"path/filepath"
"strings"
"testing"
)
// forbiddenSubstrings is the literal-match list. Each string MUST NOT
// appear anywhere under the module root. Entries are checked with
// substring matching, not regex — keep the patterns specific enough
// that a false-positive needs an explicit allowlist entry.
var forbiddenSubstrings = []string{
"github.com/Molecule-AI/",
"Molecule-AI/molecule-monorepo",
}
// allowlistedFiles is the per-file escape hatch. Empty by default —
// add an entry only when there is a documented reason a forbidden
// string MUST appear (e.g. a regression-test fixture that asserts
// the lint gate itself rejects the string). Each entry MUST be
// accompanied by a comment explaining why.
var allowlistedFiles = map[string]bool{
// (intentionally empty — add only with justification)
}
func TestNoLegacyGitHubImportPaths(t *testing.T) {
moduleRoot, err := findModuleRoot()
if err != nil {
t.Fatalf("findModuleRoot: %v", err)
}
checkExt := map[string]bool{
".go": true,
".mod": true,
".sum": false, // go.sum is auto-generated, refs flow from go.mod
".sh": true,
".yml": true,
".yaml": true,
".toml": true,
".md": true,
".json": true, // package.json / tsconfig.json — catches ref drift in package metadata
}
checkBasename := map[string]bool{
"Dockerfile": true,
"Dockerfile.tenant": true,
}
violations := 0
walkErr := filepath.Walk(moduleRoot, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
// Skip vendor + .git + node_modules — not our code.
base := info.Name()
if base == "vendor" || base == ".git" || base == "node_modules" || base == "testdata" {
return filepath.SkipDir
}
return nil
}
ext := filepath.Ext(path)
base := filepath.Base(path)
if !checkExt[ext] && !checkBasename[base] {
return nil
}
rel, _ := filepath.Rel(moduleRoot, path)
if allowlistedFiles[rel] {
return nil
}
// Skip the lint test itself — it legitimately names the forbidden
// strings as match patterns.
if strings.HasSuffix(rel, "import_path_lint_test.go") {
return nil
}
data, err := os.ReadFile(path)
if err != nil {
return err
}
text := string(data)
for _, bad := range forbiddenSubstrings {
if strings.Contains(text, bad) {
// Find the line number for a useful error message.
for lineNo, line := range strings.Split(text, "\n") {
if strings.Contains(line, bad) {
t.Errorf("%s:%d — forbidden substring %q (use go.moleculesai.app/<area>/... per molecule-ai/internal#71)", rel, lineNo+1, bad)
violations++
break
}
}
}
}
return nil
})
if walkErr != nil {
t.Fatalf("walk: %v", walkErr)
}
if violations > 0 {
t.Logf("Total violations: %d. Add to allowlistedFiles ONLY with a documented justification.", violations)
}
}
// findModuleRoot walks up from the test's CWD to find go.mod. The Go
// test harness sets CWD to the package directory; the module root may
// be one or more parents up.
func findModuleRoot() (string, error) {
cwd, err := os.Getwd()
if err != nil {
return "", err
}
dir := cwd
for {
if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
return dir, nil
}
parent := filepath.Dir(dir)
if parent == dir {
return "", os.ErrNotExist
}
dir = parent
}
}

View File

@ -93,7 +93,7 @@ entries may cause CI divergence or checksum mismatches.
### Impact
`go mod verify` in CI may fail if `go.sum` has extra entries not in the
lock file. Additionally, if the module path (`go.moleculesai.app/cli`)
lock file. Additionally, if the module path (`github.com/Molecule-AI/molecule-cli`)
is referenced via `replace` directives from other repos, those references may
persist stale entries.