@swarmcraftai/cli 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to the SwarmCraft CLI are documented in this file.
4
4
 
5
+ ## 0.5.1
6
+
7
+ - Refreshes the npm README around customer installation and common workflows, with native PowerShell commands, Node/npm verification, managed-machine recovery and VS Code restart guidance.
8
+ - Clarifies that WSL is not required for the SwarmCraft CLI and that AI-provider prerequisites are separate.
9
+ - Command behavior and the editor/Setup capability contract remain unchanged from 0.5.0.
10
+
11
+ ## 0.5.0
12
+
13
+ - Adds deterministic `operate init`, `operate validate`, and `operate status` commands for local operational work, with Codex and Copilot guidance for Work, Automate, and Formalise.
14
+ - Seeds and reconciles operational models, records, knowledge, and bounded automation guidance while preserving owner edits; initialization validates the result and creates a scoped local Git checkpoint without pushing.
15
+ - Supports a private stdin session handoff from VS Code for Operate initialization, with session verification before workspace mutation and content-free, retryable activity reporting.
16
+ - Validates approved operational formalisation and source digests when preparing Deep Discovery evidence, blocking stale or cancelled approvals.
17
+ - Adds SwarmCraft-managed AI to one-shot workflows, including credit balance and stage estimates, measured per-call consumption, and resumable insufficient-credit outcomes. Customer-supplied Codex, Copilot, and custom providers remain supported.
18
+ - Seeds versioned project environment requirements from structured build profiles and documents local-model execution through custom agent commands.
19
+ - Requires the matching API credit, Managed AI, and Operate telemetry contracts; deploy the coordinated API and web release before publishing this client.
20
+
5
21
  ## 0.4.2
6
22
 
7
23
  - Reconciles generated repository skills through a monotonic, owner-preserving template-set contract before new one-shot runs, while retaining the recorded guidance for resumed runs.
package/README.md CHANGED
@@ -1,121 +1,150 @@
1
1
  # SwarmCraft CLI
2
2
 
3
- SwarmCraft CLI prepares a local repository for a SwarmCraft project board and runs packet-based agent workflows from the terminal.
3
+ [SwarmCraft](https://swarmcraft.ai) helps you use AI to get operational work done, automate repeatable tasks, and build applications. It gives your AI assistant shared skills and structured workflows while you keep control of your knowledge, records, and code.
4
4
 
5
- Use it to authenticate with SwarmCraft, list available projects, seed workspace guidance files, materialize task packets, run one-shot implementation passes, resume or inspect runs, and create support bundles.
5
+ The CLI brings SwarmCraft workflows to your terminal. Use it to prepare a local repository for operational work or run implementation tasks from your SwarmCraft project board with an AI coding agent. You can inspect progress, resume interrupted runs, and collect support diagnostics.
6
6
 
7
- Deep Discovery uses the provider-neutral `@swarmcraft/discovery-package-contract` for exact-text packaging, canonical hashing, and local validation. The CLI never asks an AI provider to generate transport JSON or tasks and never contains SwarmCraft's private server-side catalogue compiler.
7
+ ## Prerequisites
8
8
 
9
- ## Package Shape
9
+ - Node.js 20.19 or newer, npm, and Git.
10
+ - A SwarmCraft account and a project with tasks ready to implement.
11
+ - A local Git repository with unrelated changes committed or stashed.
12
+ - Codex CLI or GitHub Copilot CLI installed and configured, or SwarmCraft Managed AI credits.
10
13
 
11
- - Package name: `@swarmcraftai/cli`
12
- - Installed command: `swarmcraft`
13
- - Supported runtime target: Node.js 20.19 or newer
14
- - Local run artifact location: `.swarmcraft/runs/<run-id>` inside the selected customer workspace
15
- - Public package contents: bundled CLI runtime, README, package metadata, and license
16
- - Shared workspace packages are bundled into the CLI artifact; customers do not install `@swarmcraft/packet-workflow` or `@swarmcraft/repo-seed` directly.
14
+ On macOS and Windows, start with [SwarmCraft Setup](https://swarmcraft.ai/docs/set-up-and-connect/use-swarmcraft-setup) to prepare your environment.
17
15
 
18
- ## Implemented Module Ownership
16
+ ## Install
19
17
 
20
- - `src/main.ts` is the executable composition root: it dispatches parsed commands, prompts where compatibility requires it, prints outcomes, and selects exit behavior.
21
- - `src/commands/command-catalog.ts` owns stable command names, usage text, and help lookup; `src/commands/arguments.ts` owns syntax-only argument parsing and repeated option access.
22
- - `src/apiClient.ts` maps API transport contracts; `src/sessionStore.ts` is the only owner of the owner-only local credential file.
23
- - `src/workspace.ts` owns workspace validation and contained file/git operations. `src/runtime/workspace-paths.ts` rejects absolute, traversal, escaped run, manifest, log, and support-artifact targets.
24
- - `src/runtime/process.ts` provides shell-free argument-array execution. Only `runTrustedShellAgentCommand` may invoke a shell for a deliberately supplied custom-agent template; API content and credentials must never be interpolated into it.
25
- - `src/bootstrap.ts`, `src/discovery.ts`, and `src/oneShot.ts` compose the seed, immutable discovery-package, and packet execution workflows.
26
- - `src/workflows/agent-execution.ts` owns approved credential injection, trusted template quoting, and optional cost capture. `src/artifacts/run-manifest.ts` owns contained paths and atomic resume-manifest persistence.
27
- - `src/supportBundle.ts` exposes only allow-listed delegation facts and recursively redacts secret-bearing keys.
18
+ ```bash
19
+ npm install -g @swarmcraftai/cli
20
+ swarmcraft --help
21
+ ```
28
22
 
29
- All customer run artifacts remain below `.swarmcraft/runs/<run-id>`. Workspace-relative reads, writes, removals, packet paths, discovery sources, logs, manifests, diagnostics, and support bundles are resolved through the containment boundary before access.
23
+ For one-off use, run `npx @swarmcraftai/cli --help`.
30
24
 
31
- ## Distribution
25
+ ## Native Windows installation
32
26
 
33
- The first public distribution channel is npm:
27
+ WSL is not required for the SwarmCraft CLI. In PowerShell:
34
28
 
35
- ```bash
36
- npm install -g @swarmcraftai/cli
37
- swarmcraft --help
29
+ ```powershell
30
+ node --version
31
+ npm.cmd --version
32
+ npm.cmd install -g @swarmcraftai/cli
33
+ swarmcraft.cmd --version
34
+ swarmcraft.cmd operate init --help
35
+ Get-Command node, npm.cmd, swarmcraft.cmd
36
+ npm.cmd prefix -g
38
37
  ```
39
38
 
40
- One-off use is also supported:
39
+ Use a supported Node.js LTS release meeting the minimum above. Confirm the npm global prefix is on your user PATH, then fully quit and reopen VS Code. A window reload may retain the old PATH. Use `.cmd` commands instead of changing PowerShell execution policy. If software installation or the prefix is restricted, use your organisation's approved installation or user-writable prefix; preserve managed runtimes and npm registry/authentication settings.
41
40
 
42
- ```bash
43
- npx @swarmcraftai/cli --help
41
+ The extension needs an installed CLI; one-off `npx` execution does not satisfy that requirement. See the [manual setup checklist](https://swarmcraft.ai/docs/set-up-and-connect/manual-setup-checklist). AI providers have separate platform and authentication requirements.
42
+
43
+ PowerShell uses different line continuation from Bash. Run the multiline examples below on one line, using `swarmcraft.cmd`, for example:
44
+
45
+ ```powershell
46
+ swarmcraft.cmd one-shot --project YOUR_PROJECT_ID --workspace . --agent-provider codex --task-limit 1 --max-agent-requests 100 --commit-policy done
44
47
  ```
45
48
 
46
- Public publishing is owned by the release workflow in `.github/workflows/publish-cli.yml`. Run the local package smoke before publishing:
49
+ ## Run your first task
50
+
51
+ Sign in and find your project ID:
47
52
 
48
53
  ```bash
49
- pnpm cli:release:smoke
54
+ swarmcraft auth login --email you@example.com
55
+ swarmcraft projects list
50
56
  ```
51
57
 
52
- ## Local Development
58
+ Login prompts for your password and any required verification code. Your CLI session is saved in `~/.swarmcraft/cli-session.json`; keep this file private.
53
59
 
54
- From the repo root:
60
+ From your project's local Git repository, check your setup:
55
61
 
56
62
  ```bash
57
- pnpm cli:dev -- --help
58
- pnpm cli:check
63
+ swarmcraft doctor --workspace . --agent-provider codex
59
64
  ```
60
65
 
61
- From this package:
66
+ Replace `<project-id>` with an ID from the project list, then run one task:
62
67
 
63
68
  ```bash
64
- pnpm dev -- --help
65
- pnpm check
66
- pnpm release:smoke
69
+ swarmcraft one-shot \
70
+ --project <project-id> \
71
+ --workspace . \
72
+ --agent-provider codex \
73
+ --task-limit 1 \
74
+ --max-agent-requests 100 \
75
+ --commit-policy done
67
76
  ```
68
77
 
69
- `pnpm check` is the package ready-for-review gate and includes lint, type checking, unit tests, a production bundle, and the bundled help smoke. Before release, also run `pnpm release:smoke`; the root `pnpm standards:cli` alias runs both.
78
+ This prepares repository guidance and task files, runs the agent, and syncs task updates to SwarmCraft. Accepted tasks move to `done`; `--commit-policy done` creates a local commit for each completed task. Omit that option to leave changes uncommitted. Review the resulting changes before sharing them.
70
79
 
71
- ## Current Commands
80
+ The CLI refuses a dirty workspace by default. Use `--allow-dirty` only when you intend to include existing local changes in the run. The request limit bounds agent calls, not monetary cost.
72
81
 
73
- Core commands:
82
+ For preparation without running an agent:
74
83
 
75
84
  ```bash
76
- swarmcraft auth login --email <email>
77
- swarmcraft delegation start --user <customer-email-or-id> --reason <text> --expires-in-minutes 600
78
- swarmcraft projects list --delegation <delegation-id>
79
- swarmcraft discovery prepare --workspace <path>
80
- swarmcraft discovery validate --workspace <path>
81
- swarmcraft discovery support-bundle --workspace <path> --run <run-id>
82
- swarmcraft init --project <project-id> --workspace <path> --agent-provider codex --delegation <delegation-id>
83
- swarmcraft one-shot --project <project-id> --workspace <path> --agent-provider codex --delegation <delegation-id>
84
- swarmcraft one-shot --project <project-id> --workspace <path> --agent-provider codex --run-id <known-run-id>
85
- swarmcraft resume --run <run-id> --workspace <path> --delegation <delegation-id>
86
- swarmcraft status --run <run-id> --workspace <path> --delegation <delegation-id>
87
- swarmcraft delegation end --delegation <delegation-id>
85
+ swarmcraft init --project <project-id> --workspace . --agent-provider codex
88
86
  ```
89
87
 
90
- Interactive login conceals password input. When MFA is enrolled, the same command securely prompts for the current authenticator code and offers a recovery-code fallback; secrets do not need to be placed in the command line.
88
+ `init` writes guidance and task files for review and leaves those changes uncommitted. Commit or otherwise resolve them before starting a run that requires a clean workspace. Updates preserve your edits to generated guidance and report conflicts that need attention.
89
+
90
+ ## Choose an agent
91
+
92
+ - **Codex:** use `--agent-provider codex`.
93
+ - **GitHub Copilot:** use `--agent-provider copilot`.
94
+ - **SwarmCraft Managed AI:** use `--agent-provider managed` with `one-shot`. The CLI shows your credit balance and an estimated stage range before starting. If credits run out, add credits and resume the blocked run.
95
+ - **Custom commands and local models:** `--agent-command` overrides the provider command and supports models available through your agent, including local models. The template is executed through a shell, so use only commands you trust. Keep secrets out of command text; use `--agent-env-file` with `--agent-api-key-env-name` for provider credentials.
96
+
97
+ Codex, Copilot, and custom providers use your own provider setup and are outside the Managed AI fee.
91
98
 
92
- `swarmcraft init` validates the workspace git state, seeds the shared SwarmCraft repo guidance files, materializes non-done task packets, links those packets back to SwarmCraft, and prints the next commands.
99
+ ## Inspect and resume work
93
100
 
94
- Repository seeding uses the same monotonic template-set contract as the VS Code extension. A newer CLI adds missing skills and updates unchanged generated guidance, preserves owner edits as conflicts, removes only unchanged retired files, and never downgrades guidance written by a newer client. The CLI leaves these repository changes uncommitted for normal review. New one-shot runs reconcile before agent execution; resumed runs retain their existing run guidance rather than reseeding midway through the run.
101
+ Use the run ID printed by the CLI:
95
102
 
96
- The task contract is a clean cutover from the earlier project-ticket format. Upgrade the API, CLI, and VS Code extension together; old `ticketId` packet files and `--ticket` flags are not accepted. Preserve any owner-authored notes, remove the retired generated packet files, and run `swarmcraft init` again to materialize current `taskId` packets from the board.
103
+ ```bash
104
+ swarmcraft status --run <run-id> --workspace .
105
+ swarmcraft resume --run <run-id> --workspace .
106
+ ```
107
+
108
+ Run records and agent logs are stored in `.swarmcraft/runs/<run-id>/`, including `manifest.json` and the `logs/` directory. Treat these files as potentially sensitive.
109
+
110
+ If a run reached its request limit, raise the total ceiling when resuming:
111
+
112
+ ```bash
113
+ swarmcraft resume --run <run-id> --workspace . --max-agent-requests 200
114
+ ```
97
115
 
98
- `swarmcraft discovery prepare` is projectless and deterministic. It requires the versioned discovery binding, `.swarmcraft/discovery.sources.json`, current selected-source digests, and all nine curated documents to be reviewed or explicitly not applicable. Repeated `--source` arguments must exactly match the aggregate owner-confirmed text projection when supplied by the extension. Empty, draft, unresolved, stale-sidecar, binary, secret-bearing, oversized, or mismatched preparation is blocked before upload.
116
+ ## Other workflows
99
117
 
100
- Preparation prints content-safe milestones as review state is checked, selected inputs are frozen, safety checks pass, the immutable digest is created, and the preview becomes ready. It normally completes in seconds and does not show a provider timer or artificial percentage.
118
+ For local operational work, initialize Work, Automate, and Formalise skills:
101
119
 
102
- The CLI freezes the nine reviewed curated documents plus the exact selected `.md`/`.txt` sources and valid Markdown sidecars. It preserves the exact text and records roles, review states, sizes, SHA-256 digests, and sidecar provenance, then publishes atomically under `.swarmcraft/discovery-packages/<digest>/`. The preview lists exactly what may leave the machine. Reviewed curated documents are authoritative; selected sources are supporting evidence.
120
+ ```bash
121
+ swarmcraft operate init --workspace /path/to/repository --agent-provider codex
122
+ swarmcraft operate validate --workspace /path/to/repository
123
+ swarmcraft operate status --workspace /path/to/repository
124
+ ```
103
125
 
104
- Run diagnostics contain only schema version, phase, error class, timestamps, counts, byte/token estimates, and support codes—never document text or source paths. Durable feedback distinguishes incomplete discovery, stale input, cancellation, invalid packages, and internal failures. Support bundles exclude paths and Discovery Package content.
126
+ Use `--adopt` to initialize an existing nonempty repository. Initialization previews the files and creates a local commit containing the seed changes. It preserves owner edits and does not push or run an agent. Validation and status work offline; both accept `--json`.
105
127
 
106
- `swarmcraft discovery validate` reruns deterministic package and local-staleness checks without launching a provider. Untracked and ignored owner-selected text is preserved and allowed but remains the owner's backup responsibility. A failed run never truncates, summarizes, or silently drops content: correct the reported review/source issue and prepare again.
128
+ For a workspace that has completed [Deep Discovery review](https://swarmcraft.ai/docs/discover-and-plan/complete-deep-discovery), prepare and validate its package:
107
129
 
108
- `swarmcraft one-shot` bootstraps the workspace, runs the doing lane through the selected agent provider, syncs packet updates back to SwarmCraft, writes `.swarmcraft/runs/<run-id>/manifest.json`, streams progress to the terminal, writes agent logs under `.swarmcraft/runs/<run-id>/logs/`, and moves accepted work to `done` by default. With checking off, the driver ignores the reusable implementation skill's normal checking handoff, syncs its evidence, moves the task directly to `done`, commits when requested, and continues. Before synchronization, the CLI reloads the server-authoritative board and retries bounded optimistic-revision conflicts, allowing one-shot to run while the VS Code extension is open and observing the same packets. Customer one-shots should normally pair this with `--commit-policy done` so each completed task creates a local commit. Use `--checking on` or `--reviewing on` only for internal validation runs that deliberately need those extra lanes.
130
+ ```bash
131
+ swarmcraft discovery prepare --workspace .
132
+ swarmcraft discovery validate --workspace .
133
+ ```
109
134
 
110
- For interface-bearing packets, the generated `swarmcraft-do` contract owns design conformance even when checking is off: it resolves the owner-controlled locator, uses applicable system capabilities, covers relevant states, runs existing required design commands, and records exact evidence in packet notes. A failing required deterministic design gate must leave doing incomplete. One-shot does not install design tooling, infer authority to mutate the design system, or treat unavailable visual evidence as passing.
135
+ Preparation requires reviewed discovery documents and confirmed source selections. It creates a local package and a preview of the selected content; upload requires separate consent. If review or source checks fail, correct the reported issue and prepare again.
111
136
 
112
- Useful safety and support commands:
137
+ ## Help and troubleshooting
113
138
 
114
139
  ```bash
115
- swarmcraft one-shot --project <project-id> --workspace <path> --agent-provider codex --max-agent-requests 100
116
- swarmcraft one-shot --project <project-id> --workspace <path> --agent-provider custom --agent-command '<command with {command}>' --agent-api-key-env-name MY_AGENT_KEY
117
- swarmcraft doctor --workspace <path> --agent-provider codex
118
- swarmcraft support-bundle --run <run-id> --workspace <path>
140
+ swarmcraft --help
141
+ swarmcraft one-shot --help
142
+ swarmcraft doctor --workspace . --agent-provider codex
143
+ swarmcraft support-bundle --run <run-id> --workspace .
119
144
  ```
120
145
 
121
- VS Code uses a 100-request default and checks the unfinished board before launch. When the selected lane policy could require more, it asks the operator to approve a sufficient limit before starting. A stopped run can extend its recorded ceiling with `swarmcraft resume --run <run-id> --workspace <path> --max-agent-requests <n>`.
146
+ Run `swarmcraft auth login` again if your session has expired. For Discovery diagnostics, use `swarmcraft discovery support-bundle --workspace . --run <run-id>`.
147
+
148
+ Support bundles redact credentials; Discovery bundles exclude source and package content. Review any diagnostic files before sharing them.
149
+
150
+ See the [one-shot walkthrough](https://swarmcraft.ai/docs/build-and-ship/deliver-with-the-one-shot-cli), [troubleshooting guide](https://swarmcraft.ai/docs/help-and-reference/troubleshoot-swarmcraft), or [contact support](https://swarmcraft.ai/login?next=%2Fapp%2Fsupport).