switchboard-cli 0.1.0-alpha.4 → 0.1.0-alpha.5

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 ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.5
4
+
5
+ - First installable release: `npm install -g switchboard-cli` now works standalone.
6
+ - `@switchboard/core` and `@switchboard/projections` are compiled into the published
7
+ bundle (`dist/index.cjs`) — no unpublished workspace dependencies in the manifest.
8
+ - Runs as plain JavaScript; `tsx` is no longer a runtime dependency.
9
+ - Runtime dependencies reduced to `commander`, `yaml`, `zod`.
10
+ - Prior published versions (alpha.1–alpha.4) were uninstallable outside the monorepo
11
+ (raw `workspace:*` or unpublished `@switchboard/*` dependencies).
12
+
13
+ ## 0.1.0-alpha.4
14
+
15
+ - Positions `switchboard-cli` as the primary CLI-first package for the portable governance substrate.
16
+ - Includes the governed pipeline: `init`, `compile`, `packet`, `run`, `ingest`, `audit`, `receipt`, and `evaluate`.
17
+ - Documents the calibration harness for blind, replay, and adversarial trust-machinery checks.
18
+ - Documents AutoAgent local, hybrid, cloud, parallel, and adaptive-governance modes as alpha surfaces.
19
+ - Aligns publish metadata so the CLI no longer advertises stale `workspace:*` dependencies.
package/README.md CHANGED
@@ -1,121 +1,177 @@
1
- # @switchboard/cli
1
+ # switchboard-cli
2
2
 
3
3
  Portable governance substrate for AI workflows.
4
4
 
5
- Compile specs, dispatch to Claude/ChatGPT/Cursor/Codex, ingest structured returns, issue trust receipts, evaluate independently, and calibrate your pipeline.
5
+ Switchboard keeps project intent, dispatch context, returns, audits, receipts, and evaluation evidence in a repo-local `.switchboard/` tree. The CLI is the primary interface; any web surface is only another view over the same governance state.
6
6
 
7
- > **Alpha release.** Expect breaking changes. [Report issues](https://github.com/switchboard-foundation/switchboard/issues).
7
+ > Alpha release: `0.1.0-alpha.4`. Expect rough edges and breaking changes. Use it for governed experiments, demos, and research workflows before depending on it as production infrastructure.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- npm install -g @switchboard/cli
12
+ npm install -g switchboard-cli
13
+ sb --version
13
14
  ```
14
15
 
15
- Requires Node >= 18.
16
+ Requires Node.js 18 or newer.
17
+
18
+ ## What it does
19
+
20
+ Switchboard is not a chat wrapper or vendor gateway. It is a file-based governance layer around AI-assisted work:
21
+
22
+ - compile canonical project state into an execution contract
23
+ - generate SBX packets for Claude, ChatGPT, Cursor, or Codex-style surfaces
24
+ - ingest structured returns and reconcile them against the contract
25
+ - issue receipts that describe what was actually verified
26
+ - run independent evaluation against the latest receipt
27
+ - calibrate the trust machinery with blind, replay, and adversarial seeds
28
+ - run AutoAgent improvement loops with local, hybrid, cloud, parallel, and adaptive-governance modes
29
+
30
+ The core design goal is deterministic, inspectable workflow state rather than clever orchestration.
16
31
 
17
32
  ## Quick start
18
33
 
19
34
  ```bash
20
- # Initialize a governed project
35
+ # Scaffold repo-local governance state
21
36
  sb init
22
37
 
23
- # Compile project contract + spec from canonical state
38
+ # Compile the current project contract and objective
24
39
  sb compile
25
40
 
26
- # Generate a dispatch packet for a surface
27
- sb packet claude # or: chatgpt, cursor, codex
41
+ # Generate a packet for a target surface
42
+ sb packet claude
43
+ sb packet chatgpt
44
+ sb packet cursor
45
+ sb packet codex
28
46
 
29
- # Launch governed dispatch to Claude Code
47
+ # Dispatch to Claude Code, then ingest the structured return
30
48
  sb run claude
31
-
32
- # Ingest the structured return
33
49
  sb ingest
34
50
 
35
- # Issue an immutable trust receipt
51
+ # Generate independent review context and issue a receipt
52
+ sb audit codex
36
53
  sb receipt
37
54
 
38
- # Export receipt as standalone JSON
39
- sb receipt --export json
40
-
41
- # Run independent evaluation
55
+ # Evaluate the receipt independently
42
56
  sb evaluate
43
-
44
- # Run the two-layer calibration harness
45
- sb calibrate
46
57
  ```
47
58
 
48
- ## Pipeline
59
+ The normal path is:
49
60
 
50
- ```
51
- init -> compile -> packet -> run -> ingest -> receipt -> evaluate
52
- |
53
- calibrate
61
+ ```text
62
+ init -> compile -> packet -> run -> ingest -> audit -> receipt -> evaluate
54
63
  ```
55
64
 
56
- Each step reads from and writes to `.switchboard/` in your project root. All state is file-based (YAML + Markdown). No database, no hosted service.
65
+ Every step reads from or writes to `.switchboard/` in the current project root.
57
66
 
58
67
  ## Commands
59
68
 
60
- | Command | What it does |
61
- |---------|-------------|
62
- | `sb init` | Scaffold `.switchboard/` directory with contract, working state, and spec |
63
- | `sb compile` | Compile a loop contract from canonical state |
64
- | `sb packet <surface>` | Generate a governed dispatch packet (SBX bundle) |
65
- | `sb run claude` | Dispatch to Claude Code via Agent SDK with proof capture |
66
- | `sb ingest` | Ingest structured SB_RETURN.yaml, run reconciliation + gates |
67
- | `sb receipt` | Build immutable ReceiptIssuedV2 from persisted ingest artifacts |
68
- | `sb receipt --export json` | Export receipt as standalone JSON file |
69
- | `sb receipt --export yaml` | Export receipt as standalone YAML file |
70
- | `sb evaluate` | Run independent evaluation on the latest receipt |
71
- | `sb audit codex` | Generate Codex audit packet for independent review |
72
- | `sb calibrate` | Run two-layer calibration harness |
69
+ | Command | Purpose |
70
+ | --- | --- |
71
+ | `sb init` | Scaffold `.switchboard/` with project, working, routing, export, and return state |
72
+ | `sb compile` | Compile the current canonical state into a governed loop contract |
73
+ | `sb compile --objective "<text>"` | Override the loop objective for the next compile |
74
+ | `sb compile --surface <surface>` | Force a target surface: `claude-code`, `chatgpt`, `cursor`, or `codex` |
75
+ | `sb packet <surface>` | Generate an SBX dispatch bundle for `claude`, `chatgpt`, `cursor`, or `codex` |
76
+ | `sb packet <surface> --force` | Generate a packet despite blocking integrity findings |
77
+ | `sb run claude` | Dispatch the latest governed packet to Claude Code through the local transport |
78
+ | `sb run claude --dry-run` | Prepare dispatch metadata without executing |
79
+ | `sb ingest` | Ingest the expected structured return and persist reconciliation, gate, and audit inputs |
80
+ | `sb ingest --file <path>` | Ingest a specific return YAML file |
81
+ | `sb audit codex` | Generate and optionally execute Codex audit context for independent review |
82
+ | `sb receipt` | Build a receipt from the latest persisted ingest artifacts |
83
+ | `sb receipt --export json` | Export the receipt as standalone JSON |
84
+ | `sb receipt --export yaml` | Export the receipt as standalone YAML |
85
+ | `sb evaluate` | Run the independent evaluation lane against the latest audited receipt |
86
+ | `sb calibrate` | Run the two-layer calibration harness |
87
+ | `sb autoagent` | Run the governed autonomous improvement loop |
88
+
89
+ ## Receipts and evaluation
90
+
91
+ Receipts are intended to be honest evidence artifacts, not certificates. A receipt records the dispatch, ingest result, reconciliation findings, audit status, gate posture, and what the system can defensibly say about the run.
92
+
93
+ `sb evaluate` is deliberately separate from receipt generation. It reads the latest receipt and writes an independent assessment so that execution, receipt issuance, and evaluation do not collapse into one self-affirming step.
73
94
 
74
95
  ## Calibration
75
96
 
76
- The calibration harness tests the trust machinery itself:
77
-
78
- - **Layer A** (internal): Runs seeds through the real governance pipeline with full trace access
79
- - **Layer B** (external): Scores independently with zero imports from core — only sees raw output
80
- - **Blind seeds**: Fresh ideas the system has never seen
81
- - **Adversarial seeds**: Designed to break the machinery (scope traps, non-goal evasion, evidence gaps)
82
- - **Living ledger**: Every run appends to an auditable history with trends
97
+ `sb calibrate` tests the trust machinery itself.
83
98
 
84
99
  ```bash
85
- # Default run: 5 blind + 3 adversarial seeds
100
+ # Default mix
86
101
  sb calibrate
87
102
 
88
- # Custom mix
103
+ # Custom seed counts
89
104
  sb calibrate --blind 10 --adversarial 5
90
105
 
91
- # Stress test only
106
+ # Adversarial-only run
92
107
  sb calibrate --adversarial-only 8
93
108
 
94
- # Review pending escalations
95
- sb calibrate --review
109
+ # Replay-only run
110
+ sb calibrate --replay-only
96
111
 
97
- # Show calibration trends
112
+ # Review pending escalations and trends
113
+ sb calibrate --review
98
114
  sb calibrate --trends
99
115
  ```
100
116
 
101
- ## Trust machinery
117
+ The harness compares an internal pipeline verdict with an external scorer that has no imports from the core implementation. Disagreements become calibration evidence rather than hidden failures.
118
+
119
+ ## AutoAgent
120
+
121
+ AutoAgent is an alpha improvement loop for governed projects. It expects:
122
+
123
+ - `.switchboard/autoagent/program.md`: what the loop should improve
124
+ - `.switchboard/autoagent/score.ts`: a score function that returns a numeric result
125
+
126
+ Common modes:
127
+
128
+ ```bash
129
+ # Local loop; defaults to adaptive governance
130
+ sb autoagent --tier code --max-iterations 5
131
+
132
+ # Harness or full autonomy tiers
133
+ sb autoagent --tier harness
134
+ sb autoagent --tier full
135
+
136
+ # Explicit governance mode
137
+ sb autoagent --governance full
138
+ sb autoagent --governance light
139
+ sb autoagent --governance none
140
+ sb autoagent --governance adaptive
141
+
142
+ # Cloud coordinator or hybrid coordinator/local-worker modes
143
+ sb autoagent --cloud --tier code
144
+ sb autoagent --hybrid --tier code
145
+
146
+ # Cloud parallel mode: three workers test hypotheses concurrently
147
+ sb autoagent --cloud --parallel --tier code
148
+
149
+ # Inspect or control a cloud session
150
+ sb autoagent --status
151
+ sb autoagent --stream
152
+ sb autoagent --steer "focus on the highest-scoring hypothesis"
153
+ sb autoagent --stop
154
+
155
+ # Review or restore results
156
+ sb autoagent --results
157
+ sb autoagent --rollback
158
+ ```
159
+
160
+ Adaptive governance starts with low overhead, then escalates when score jumps, boundaries are crossed, research pivots occur, or enough kept iterations accumulate. Dangerous-project keywords such as financial, live, credential, deploy, and production force full governance.
102
161
 
103
- The governance pipeline enforces:
162
+ Cloud, hybrid, and parallel modes are included for showcase and research use. They may require local credentials, available vendor CLIs, and operator supervision.
104
163
 
105
- - **Honesty guardrails**: Banned terms ("certified", "guaranteed", "no issues") in receipts
106
- - **Reconciliation**: Six drift checks (scope inflation, non-goal violation, goal drift, target-user shift, untracked decisions, evidence contradiction)
107
- - **Gates**: Approval gates for scope changes, unparented decisions, weak evidence, trust boundary changes
108
- - **Claim spread**: Deterministic measurement of how far executor claims drift from proven evidence
109
- - **Receipts**: Immutable trust artifacts with claim assessments, verification results, and closure basis
164
+ ## Alpha boundaries
110
165
 
111
- ## What this is NOT
166
+ Switchboard currently optimizes for a clear CLI-first research/showcase path:
112
167
 
113
- - Not a chat wrapper
114
- - Not an LLM gateway
115
- - Not an eval platform
116
- - Not an autonomous agent
168
+ - canonical state lives in `.switchboard/`
169
+ - package internals are TypeScript source run through `tsx`
170
+ - receipts and evaluation are evidence records, not guarantees
171
+ - cloud and managed-agent paths are experimental
172
+ - public npm publication requires the internal packages to be published before the CLI
117
173
 
118
- It is a governance substrate. It preserves project coherence while you bounce work across AI surfaces.
174
+ It intentionally does not try to be an enterprise control plane, observability product, generic eval platform, or vendor-sprawl abstraction.
119
175
 
120
176
  ## License
121
177
 
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Switchboard CLI bin shim (CommonJS).
5
+ *
6
+ * CJS on purpose: npm 11.7+'s bin validation rejects .mjs bin targets
7
+ * ("script name ... was invalid") and silently strips them at publish,
8
+ * shipping a package with no executables. This package is CJS-default,
9
+ * so a .js shim is both valid and runnable.
10
+ *
11
+ * Published package: ships no src/, only the bundled CJS build at
12
+ * ../dist/index.cjs (plain JS — no tsx, no TypeScript toolchain at runtime).
13
+ *
14
+ * Monorepo dev: src/ is present, so the shim spawns tsx on the TypeScript
15
+ * entrypoint — live source always wins over a possibly stale dist/ build.
16
+ * Works from any cwd — resolves paths relative to this file, not the caller.
17
+ */
18
+
19
+ const { existsSync } = require("node:fs");
20
+ const { execFileSync } = require("node:child_process");
21
+ const { resolve } = require("node:path");
22
+
23
+ const sourceEntry = resolve(__dirname, "..", "src", "index.ts");
24
+ const bundled = resolve(__dirname, "..", "dist", "index.cjs");
25
+
26
+ function runBundled() {
27
+ // Bundled entrypoint parses process.argv itself (commander).
28
+ require(bundled);
29
+ }
30
+
31
+ if (!existsSync(sourceEntry)) {
32
+ // Published install: no src/ in the tarball — run the bundle.
33
+ if (!existsSync(bundled)) {
34
+ console.error("switchboard: corrupted install — dist/index.cjs is missing. Reinstall switchboard-cli.");
35
+ process.exit(1);
36
+ }
37
+ runBundled();
38
+ } else {
39
+ // Monorepo dev: run from TypeScript source via tsx.
40
+ const tsxPaths = [
41
+ resolve(__dirname, "..", "node_modules", ".bin", "tsx"),
42
+ "tsx",
43
+ ];
44
+
45
+ let tsxBin;
46
+ for (const candidate of tsxPaths) {
47
+ try {
48
+ execFileSync(candidate, ["--version"], { stdio: "ignore" });
49
+ tsxBin = candidate;
50
+ break;
51
+ } catch {
52
+ // try next
53
+ }
54
+ }
55
+
56
+ if (!tsxBin) {
57
+ if (existsSync(bundled)) {
58
+ // No tsx available but a build exists — better than failing.
59
+ runBundled();
60
+ } else {
61
+ console.error("switchboard: could not find tsx. Run `pnpm install` in the monorepo root.");
62
+ process.exit(1);
63
+ }
64
+ } else {
65
+ try {
66
+ execFileSync(tsxBin, [sourceEntry, ...process.argv.slice(2)], {
67
+ stdio: "inherit",
68
+ cwd: process.cwd(),
69
+ });
70
+ } catch (err) {
71
+ // execFileSync throws on non-zero exit; the child already printed output
72
+ process.exit(err.status !== undefined && err.status !== null ? err.status : 1);
73
+ }
74
+ }
75
+ }