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 +19 -0
- package/README.md +121 -65
- package/bin/switchboard.js +75 -0
- package/dist/index.cjs +14371 -0
- package/package.json +45 -8
- package/bin/switchboard.mjs +0 -49
- package/src/autoagent/boundary-check.spec.ts +0 -77
- package/src/autoagent/boundary-check.ts +0 -102
- package/src/autoagent/loop.ts +0 -327
- package/src/autoagent/results.spec.ts +0 -73
- package/src/autoagent/results.ts +0 -68
- package/src/autoagent/runner.spec.ts +0 -20
- package/src/autoagent/runner.ts +0 -92
- package/src/autoagent/types.ts +0 -64
- package/src/commands/audit-codex.ts +0 -266
- package/src/commands/autoagent.ts +0 -108
- package/src/commands/calibrate.ts +0 -70
- package/src/commands/compile.ts +0 -117
- package/src/commands/evaluate.ts +0 -103
- package/src/commands/ingest.ts +0 -250
- package/src/commands/init.ts +0 -133
- package/src/commands/packet.ts +0 -408
- package/src/commands/receipt.ts +0 -336
- package/src/commands/run-claude.ts +0 -355
- package/src/index.ts +0 -47
- package/src/lib/draft-return.ts +0 -278
- package/src/lib/drift-guard.ts +0 -105
- package/src/lib/errors.ts +0 -61
- package/src/lib/output.ts +0 -43
- package/src/lib/paths.ts +0 -125
- package/src/lib/proof.ts +0 -262
- package/src/lib/transport.ts +0 -276
- package/src/lib/yaml-io.ts +0 -62
- package/src/store/filesystem-store.ts +0 -326
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
|
-
#
|
|
1
|
+
# switchboard-cli
|
|
2
2
|
|
|
3
3
|
Portable governance substrate for AI workflows.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
>
|
|
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
|
|
12
|
+
npm install -g switchboard-cli
|
|
13
|
+
sb --version
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
Requires Node
|
|
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
|
-
#
|
|
35
|
+
# Scaffold repo-local governance state
|
|
21
36
|
sb init
|
|
22
37
|
|
|
23
|
-
# Compile project contract
|
|
38
|
+
# Compile the current project contract and objective
|
|
24
39
|
sb compile
|
|
25
40
|
|
|
26
|
-
# Generate a
|
|
27
|
-
sb packet claude
|
|
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
|
-
#
|
|
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
|
-
#
|
|
51
|
+
# Generate independent review context and issue a receipt
|
|
52
|
+
sb audit codex
|
|
36
53
|
sb receipt
|
|
37
54
|
|
|
38
|
-
#
|
|
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
|
-
|
|
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
|
-
|
|
65
|
+
Every step reads from or writes to `.switchboard/` in the current project root.
|
|
57
66
|
|
|
58
67
|
## Commands
|
|
59
68
|
|
|
60
|
-
| Command |
|
|
61
|
-
|
|
62
|
-
| `sb init` | Scaffold `.switchboard/`
|
|
63
|
-
| `sb compile` | Compile a loop contract
|
|
64
|
-
| `sb
|
|
65
|
-
| `sb
|
|
66
|
-
| `sb
|
|
67
|
-
| `sb
|
|
68
|
-
| `sb
|
|
69
|
-
| `sb
|
|
70
|
-
| `sb
|
|
71
|
-
| `sb
|
|
72
|
-
| `sb
|
|
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
|
-
|
|
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
|
|
100
|
+
# Default mix
|
|
86
101
|
sb calibrate
|
|
87
102
|
|
|
88
|
-
# Custom
|
|
103
|
+
# Custom seed counts
|
|
89
104
|
sb calibrate --blind 10 --adversarial 5
|
|
90
105
|
|
|
91
|
-
#
|
|
106
|
+
# Adversarial-only run
|
|
92
107
|
sb calibrate --adversarial-only 8
|
|
93
108
|
|
|
94
|
-
#
|
|
95
|
-
sb calibrate --
|
|
109
|
+
# Replay-only run
|
|
110
|
+
sb calibrate --replay-only
|
|
96
111
|
|
|
97
|
-
#
|
|
112
|
+
# Review pending escalations and trends
|
|
113
|
+
sb calibrate --review
|
|
98
114
|
sb calibrate --trends
|
|
99
115
|
```
|
|
100
116
|
|
|
101
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
166
|
+
Switchboard currently optimizes for a clear CLI-first research/showcase path:
|
|
112
167
|
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
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
|
|
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
|
+
}
|