@swarmcraftai/cli 0.4.2 → 0.5.0

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,16 @@
2
2
 
3
3
  All notable changes to the SwarmCraft CLI are documented in this file.
4
4
 
5
+ ## 0.5.0
6
+
7
+ - Adds deterministic `operate init`, `operate validate`, and `operate status` commands for local operational work, with Codex and Copilot guidance for Work, Automate, and Formalise.
8
+ - 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.
9
+ - Supports a private stdin session handoff from VS Code for Operate initialization, with session verification before workspace mutation and content-free, retryable activity reporting.
10
+ - Validates approved operational formalisation and source digests when preparing Deep Discovery evidence, blocking stale or cancelled approvals.
11
+ - 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.
12
+ - Seeds versioned project environment requirements from structured build profiles and documents local-model execution through custom agent commands.
13
+ - Requires the matching API credit, Managed AI, and Operate telemetry contracts; deploy the coordinated API and web release before publishing this client.
14
+
5
15
  ## 0.4.2
6
16
 
7
17
  - 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,5 +1,9 @@
1
1
  # SwarmCraft CLI
2
2
 
3
+ When the reviewed discovery source selection includes `docs/discovery/sources/operation-formalisation.md`, package preparation also verifies the current operational approval, model identity and selected digests against that copied source. Missing, stale or cancelled approval blocks preparation with `DP_OPERATION_SOURCE_STALE`. This does not replace the existing curated-document, package-validation or upload-consent gates.
4
+
5
+ Editor integration: `operate init --session-stdin` accepts a bounded JSON object with `apiBaseUrl` and `accessToken` through a private stdin pipe. The VS Code extension uses this to reuse its browser session. The CLI verifies the session before mutation and neither reads nor writes its saved session file in this mode. Never put credentials in shell command text. Normal terminal use continues to use `swarmcraft auth login`.
6
+
3
7
  SwarmCraft CLI prepares a local repository for a SwarmCraft project board and runs packet-based agent workflows from the terminal.
4
8
 
5
9
  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.
@@ -23,6 +27,7 @@ Deep Discovery uses the provider-neutral `@swarmcraft/discovery-package-contract
23
27
  - `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
28
  - `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
29
  - `src/bootstrap.ts`, `src/discovery.ts`, and `src/oneShot.ts` compose the seed, immutable discovery-package, and packet execution workflows.
30
+ - `src/operation/` owns Operate filesystem/Git preflight, shared-seed reconciliation, local inspection, and content-safe status; `src/commands/operate-commands.ts` owns its session validation, cancellation, output, and exit codes.
26
31
  - `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
32
  - `src/supportBundle.ts` exposes only allow-listed delegation facts and recursively redacts secret-bearing keys.
28
33
 
@@ -43,7 +48,7 @@ One-off use is also supported:
43
48
  npx @swarmcraftai/cli --help
44
49
  ```
45
50
 
46
- Public publishing is owned by the release workflow in `.github/workflows/publish-cli.yml`. Run the local package smoke before publishing:
51
+ Public publishing is owned by the Azure pipeline in `azure-pipelines.cli-release.yml`, with staged npm publishing and final maintainer approval. See [the CLI release runbook](../../docs/runbooks/swarmcraft-cli-npm-release.md). Run the local package smoke before publishing:
47
52
 
48
53
  ```bash
49
54
  pnpm cli:release:smoke
@@ -87,11 +92,67 @@ swarmcraft status --run <run-id> --workspace <path> --delegation <delegation-id>
87
92
  swarmcraft delegation end --delegation <delegation-id>
88
93
  ```
89
94
 
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.
95
+ ## Operate Locally
96
+
97
+ Operate is a starting path for operational work, not a third application-generation route. The seeded `swarmcraft-work` skill completes useful work and maintains terminology, knowledge, systems, and domain records. `swarmcraft-automate` considers bounded repeatability, including after one suitable task; `swarmcraft-formalise` prepares a reviewed application opportunity. Seeding all three does not execute them, approve automation, upload evidence, or transfer record ownership to a generated app.
98
+
99
+ ```bash
100
+ swarmcraft auth login
101
+ swarmcraft operate init --workspace /path/to/repository --agent-provider codex
102
+ swarmcraft operate init --workspace /path/to/existing-repository --agent-provider copilot --adopt
103
+ swarmcraft operate validate --workspace /path/to/repository --json
104
+ swarmcraft operate status --workspace /path/to/repository --json
105
+ ```
106
+
107
+ `operate init` creates a new directory/Git repository or reconciles an existing Operate seed. A nonempty unseeded directory requires `--adopt`. It previews the shared seed before writing, rejects nested Git roots, unsafe filesystem links, staged changes to affected files, owner-edited generated-file conflicts, and unsupported versions. Unrelated dirty and staged work is preserved. All three Operate skills are seeded; start with Work. After validation it commits only exact seed content and approved removals as `SwarmCraft: Initialize or reconcile Operate`. Owner-edited records and ignored data are excluded; unchanged retries create no empty commit. Git identity, signing or hook failures leave files available with `OPERATE_SEED_COMMIT_FAILED`; fix Git and rerun. It never pushes, executes an agent, or writes to third-party systems.
108
+
109
+ Initialization validates the saved CLI session against `GET /auth/me` before creating or modifying the target. Expired sessions use the existing refresh flow. The API origin comes from the saved session; there is no workspace-controlled API override. Credentials remain in the existing owner-only session file. Initial session/connectivity failure leaves the target untouched.
110
+
111
+ Seed activities are reported through `POST /telemetry/operate-events` with closed classifications and a random occurrence UUID. The UUID and new/adopted classification are stored in ignored `.swarmcraft/runs/operate-init.json` so rerunning initialization reuses the same occurrence. Reporting failure produces a visible warning and does not undo local work; rerun initialization to retry. There is no background uploader or server registration. `--client-surface vscode-extension` is available for extension delegation.
112
+
113
+ Validation and status are offline and use `@swarmcraft/operation-contract` for model/record checks, reviewed knowledge links, and formalisation digests. They also report ignored authoritative files and tracked raw/scratch files without exposing file contents or ignore patterns. Inventory is capped at 20,000 paths, individual text reads at 2 MB, and loaded evidence at 20 MB. Output includes only safe codes, capabilities, version, and evidence states. Discovery/project presence indicates local artifacts, not verified server connectivity. Automation presence does not imply approved readiness; repeatability remains `NOT_ASSESSED`.
114
+
115
+ Both commands accept `--json`. Exit codes are 0 for success, 2 for sign-in required, 3 for invalid/missing operation evidence, 4 for workspace/option/conflict failures, 5 for session-verification connectivity failure, and 130 for cancellation. After interruption, rerun initialization to reconcile; seed state is written last and owner edits are preserved.
116
+
117
+ ## Agent Providers And Local Models
118
+
119
+ SwarmCraft does not require a particular hosted model. The CLI delegates each packet stage to the selected Codex or GitHub Copilot CLI, and `--agent-command` can override the default provider command to select any model that the underlying agent supports. This includes local models served by Ollama.
120
+
121
+ Before starting a local-model run, start Ollama and pull an agent-capable coding model. Local models used through GitHub Copilot CLI must support tool calling and streaming; a large context window is strongly recommended. Model capability and output quality vary, so begin with one task and a bounded request count.
122
+
123
+ Run GitHub Copilot CLI against a local Ollama model without a GitHub-hosted model request:
124
+
125
+ ```bash
126
+ swarmcraft one-shot \
127
+ --project <project-id> \
128
+ --workspace <path> \
129
+ --agent-provider copilot \
130
+ --agent-command 'COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1 COPILOT_MODEL=qwen3-coder:30b COPILOT_OFFLINE=true copilot --allow-all-tools --no-ask-user -p {command}' \
131
+ --task-limit 1 \
132
+ --max-agent-requests 1
133
+ ```
134
+
135
+ Run Codex CLI directly against Ollama:
136
+
137
+ ```bash
138
+ swarmcraft one-shot \
139
+ --project <project-id> \
140
+ --workspace <path> \
141
+ --agent-provider codex \
142
+ --agent-command 'codex exec --sandbox workspace-write --oss --local-provider ollama --model qwen3-coder:30b {command}' \
143
+ --task-limit 1 \
144
+ --max-agent-requests 1
145
+ ```
146
+
147
+ Replace `qwen3-coder:30b` with a locally installed model name from `ollama list`. The CLI intentionally gives agent subprocesses a restricted environment, so local, non-secret provider settings are included in the trusted command template above. Never place API keys or other secrets in `--agent-command`; for authenticated providers, use `--agent-env-file` with `--agent-api-key-env-name`.
148
+
149
+ ## Command Workflows
150
+
151
+ SwarmCraft Setup is the supported macOS and Windows foundation path before using this experienced terminal client. Interactive CLI login remains the explicit AAA V2 email fallback: it conceals password input, prompts for optional policy-required TOTP step-up, and keeps the restricted recovery-code path out of command history. GitHub, Google, and passkey sign-in remain browser-owned web and VS Code flows.
91
152
 
92
153
  `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.
93
154
 
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.
155
+ 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. Project seeding leaves these changes uncommitted for normal review; Operate initialization instead creates a scoped local checkpoint. New one-shot runs reconcile before agent execution; resumed runs retain their existing run guidance rather than reseeding midway through the run.
95
156
 
96
157
  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.
97
158
 
@@ -107,6 +168,14 @@ Run diagnostics contain only schema version, phase, error class, timestamps, cou
107
168
 
108
169
  `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.
109
170
 
171
+ Choose `--agent-provider managed` to use SwarmCraft-managed AI. The CLI shows the current
172
+ credit balance and estimated stage range before starting, then consumes measured credits one
173
+ provider call at a time. Provider credentials, model selection, prices, and settlement remain on
174
+ the API; prompts, repository source, and provider responses are not written to billing records.
175
+ If the next bounded call cannot be funded, the local run is marked blocked and can be resumed
176
+ after credits are added. Codex, Copilot, and custom customer-supplied providers remain outside
177
+ the Managed AI fee.
178
+
110
179
  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.
111
180
 
112
181
  Useful safety and support commands: