@vibesdotdev/surface-cli 0.0.0-stage → 1.0.0-rc.2

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.
Files changed (51) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +62 -2
  3. package/dist/bun/external-hook-relay.d.ts +26 -0
  4. package/dist/bun/external-hook-relay.d.ts.map +1 -0
  5. package/dist/bun/external-hook-relay.js +202 -0
  6. package/dist/bun/external-hook-relay.js.map +1 -0
  7. package/dist/bun/host-argv.d.ts +63 -0
  8. package/dist/bun/host-argv.d.ts.map +1 -0
  9. package/dist/bun/host-argv.js +129 -0
  10. package/dist/bun/host-argv.js.map +1 -0
  11. package/dist/bun/host.d.ts +10 -0
  12. package/dist/bun/host.d.ts.map +1 -0
  13. package/dist/bun/host.js +116 -0
  14. package/dist/bun/host.js.map +1 -0
  15. package/dist/cli-bootstrap.d.ts +38 -0
  16. package/dist/cli-bootstrap.d.ts.map +1 -0
  17. package/dist/cli-bootstrap.js +163 -0
  18. package/dist/cli-bootstrap.js.map +1 -0
  19. package/dist/execution/index.d.ts +53 -0
  20. package/dist/execution/index.d.ts.map +1 -0
  21. package/dist/execution/index.js +58 -0
  22. package/dist/execution/index.js.map +1 -0
  23. package/dist/execution/toolchains/pinned-toolchain.d.ts +20 -0
  24. package/dist/execution/toolchains/pinned-toolchain.d.ts.map +1 -0
  25. package/dist/execution/toolchains/pinned-toolchain.js +23 -0
  26. package/dist/execution/toolchains/pinned-toolchain.js.map +1 -0
  27. package/dist/index.d.ts +22 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +22 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/relay.config.descriptor.d.ts +38 -0
  32. package/dist/relay.config.descriptor.d.ts.map +1 -0
  33. package/dist/relay.config.descriptor.js +25 -0
  34. package/dist/relay.config.descriptor.js.map +1 -0
  35. package/dist/schemas/hook-relay.d.ts +129 -0
  36. package/dist/schemas/hook-relay.d.ts.map +1 -0
  37. package/dist/schemas/hook-relay.js +71 -0
  38. package/dist/schemas/hook-relay.js.map +1 -0
  39. package/dist/schemas/host.d.ts +36 -0
  40. package/dist/schemas/host.d.ts.map +1 -0
  41. package/dist/schemas/host.js +2 -0
  42. package/dist/schemas/host.js.map +1 -0
  43. package/dist/session-lifecycle.d.ts +22 -0
  44. package/dist/session-lifecycle.d.ts.map +1 -0
  45. package/dist/session-lifecycle.js +83 -0
  46. package/dist/session-lifecycle.js.map +1 -0
  47. package/dist/workspace-effect-preparer.d.ts +14 -0
  48. package/dist/workspace-effect-preparer.d.ts.map +1 -0
  49. package/dist/workspace-effect-preparer.js +74 -0
  50. package/dist/workspace-effect-preparer.js.map +1 -0
  51. package/package.json +113 -4
package/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VIBES DEV LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # @vibesdotdev/surface-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ CLI composition for Vibes applications: workspace identity, action preparation,
4
+ paired session events, and disposal of the active runtime before process exit.
5
+
6
+ ## Install and use
7
+
8
+ ```sh
9
+ bun add @vibesdotdev/surface-cli @vibesdotdev/cli @vibesdotdev/host-bun
10
+ ```
11
+
12
+ ```ts
13
+ import { createVibesCliApp } from '@vibesdotdev/surface-cli';
14
+ import { bunStandardOutput } from '@vibesdotdev/host-bun/services/standard-output';
15
+
16
+ const app = await createVibesCliApp({
17
+ hostOutput: bunStandardOutput,
18
+ argv: process.argv
19
+ });
20
+ await app.cli.run(process.argv);
21
+ ```
22
+
23
+ The root exports `createVibesCliApp` and the types `VibesCliApp`,
24
+ `VibesCliAppOptions`, and `CliPluginLoader`. Additional entrypoints:
25
+
26
+ - `./execution`: `createCliExecutionSurface`, `inspectToolchain`,
27
+ `resolvePinnedToolchain`, `TOOLCHAIN_VERSION_ARGUMENTS`, and related types.
28
+ Probes use the handed runtime's `runtime/execution`; they boot no runtime.
29
+ - `./bun/host`: `runCliHost` and `RunCliHostOptions` for executable hosts.
30
+ - `./bun/host-argv`: pure repair/relay argv parsing and the shim's flag contract.
31
+
32
+ Host APIs belong to `@vibesdotdev/host-bun` and `@vibesdotdev/host-node`;
33
+ command parsing and rendering belong to `@vibesdotdev/cli`. Bun is optional for
34
+ embedding hosts that supply an environment.
35
+
36
+ The external hook relay reports unreachable daemons and timeouts but exits 0;
37
+ daemon rejection or a malformed receipt exits 1. Cleanup failures preserve the
38
+ primary outcome. Home preparation failures block the command with typed
39
+ `UNAVAILABLE` refusals; session telemetry failures preserve the command outcome.
40
+ See [SPEC.md](SPEC.md) for the public contract, refusal reasons, and proof map.
41
+
42
+ ## Verify
43
+
44
+ From this package directory:
45
+
46
+ ```sh
47
+ bun run check
48
+ bun run test
49
+ bun run test:node
50
+ bun run test:integration
51
+ bun run build
52
+ ```
53
+
54
+ `check` uses the default noEmit project, including production and test TS/TSX.
55
+ `build` uses `tsconfig.build.json` to emit production artifacts only. Default
56
+ tests run in process. The Node command proves the preparer on Node; integration
57
+ tests start real disposable CLI daemon hosts and prove execution readiness
58
+ before admission and nonportable-floor refusal without admission artifacts.
59
+ [SPEC.md](SPEC.md#verification) also lists the owning lint and runtime rules checks.
60
+
61
+ ## License
62
+
63
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The external lifecycle hook relay (`vibes dev external hooks call …`),
3
+ * moved from `@vibesdotdev/plugins` (`src/bun/external-hook-relay.ts`) beside
4
+ * the CLI host entry that runs it first. It boots no CLI: an owned finite
5
+ * runtime over the Bun environment finds the workspace daemon's socket and
6
+ * attestation claim, and the daemon runs the hook against the relay's bound
7
+ * workspace. A relay that cannot reach a daemon prints one typed line and
8
+ * answers exit 0 (fail open); a daemon that rejects the call answers exit 1.
9
+ */
10
+ import { type VibesRuntime } from '@vibesdotdev/kernel';
11
+ import { type RuntimeActor } from '@vibesdotdev/kernel/schemas';
12
+ import { type ExternalHookRelayOptions } from '../schemas/hook-relay.ts';
13
+ export type { ExternalHookRelayOptions, RuntimeDaemonInvoker } from '../schemas/hook-relay.ts';
14
+ /** The verified source of the relay's own launch identity (one seat, captured at host construction). */
15
+ export declare const HOOK_RELAY_LAUNCH_IDENTITY_SOURCE = "hook-relay-launch-identity";
16
+ /**
17
+ * Who the hook acts for (RC08): the identity its launching harness declared
18
+ * for the hook's shell (the host's `launchIdentity()` fact, captured once at
19
+ * construction). The relay is a one-seat finite host, so its own capture is
20
+ * the verified fact, admitted through the kernel's `admitInvokeCaller`. No
21
+ * declared agent is no identity: the call then presents no attestation.
22
+ */
23
+ export declare function hookLaunchActor(runtime: Pick<VibesRuntime, 'localEnvironment'>): RuntimeActor | undefined;
24
+ /** Relay one external lifecycle hook into the already-running workspace body. */
25
+ export declare function runExternalHookRelay(options: ExternalHookRelayOptions): Promise<number>;
26
+ //# sourceMappingURL=external-hook-relay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-hook-relay.d.ts","sourceRoot":"","sources":["../../src/bun/external-hook-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAoE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1H,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EAGN,KAAK,wBAAwB,EAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAE/F,wGAAwG;AACxG,eAAO,MAAM,iCAAiC,+BAA+B,CAAC;AAO9E;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,GAAG,YAAY,GAAG,SAAS,CAYzG;AAkJD,iFAAiF;AACjF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwB7F"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * The external lifecycle hook relay (`vibes dev external hooks call …`),
3
+ * moved from `@vibesdotdev/plugins` (`src/bun/external-hook-relay.ts`) beside
4
+ * the CLI host entry that runs it first. It boots no CLI: an owned finite
5
+ * runtime over the Bun environment finds the workspace daemon's socket and
6
+ * attestation claim, and the daemon runs the hook against the relay's bound
7
+ * workspace. A relay that cannot reach a daemon prints one typed line and
8
+ * answers exit 0 (fail open); a daemon that rejects the call answers exit 1.
9
+ */
10
+ import { CapabilityError, CaughtFailureSchema, settle } from '@vibesdotdev/kernel';
11
+ import { admitInvokeCaller, RuntimeActorSchema } from '@vibesdotdev/kernel/schemas';
12
+ import { HookCallRecordSchema, HookReceiptSchema, RelayConfigSchema, FailureFactsSchema, FailureCodeSchema, WaitTimeoutSchema } from "../schemas/hook-relay.js";
13
+ import { relayConfigDescriptor } from "../relay.config.descriptor.js";
14
+ /** The verified source of the relay's own launch identity (one seat, captured at host construction). */
15
+ export const HOOK_RELAY_LAUNCH_IDENTITY_SOURCE = 'hook-relay-launch-identity';
16
+ /** A trimmed, non-blank text, else absent. */
17
+ function presentText(value) {
18
+ return value?.trim() || undefined;
19
+ }
20
+ /**
21
+ * Who the hook acts for (RC08): the identity its launching harness declared
22
+ * for the hook's shell (the host's `launchIdentity()` fact, captured once at
23
+ * construction). The relay is a one-seat finite host, so its own capture is
24
+ * the verified fact, admitted through the kernel's `admitInvokeCaller`. No
25
+ * declared agent is no identity: the call then presents no attestation.
26
+ */
27
+ export function hookLaunchActor(runtime) {
28
+ const launch = runtime.localEnvironment.launchIdentity?.();
29
+ const agentId = presentText(launch?.agentId);
30
+ if (!agentId)
31
+ return undefined;
32
+ const home = RuntimeActorSchema.shape.home.safeParse(launch?.agentHome?.trim());
33
+ const sessionId = presentText(launch?.sessionId);
34
+ const participantId = presentText(launch?.participantId);
35
+ const caller = { agentId };
36
+ if (home.success)
37
+ caller.home = home.data;
38
+ if (sessionId)
39
+ caller.sessionId = sessionId;
40
+ if (participantId)
41
+ caller.participantId = participantId;
42
+ return admitInvokeCaller(caller, { source: HOOK_RELAY_LAUNCH_IDENTITY_SOURCE, caller });
43
+ }
44
+ /** A failure line that carries its typed reason and the owner's recovery hint, never a bare message. */
45
+ function describeFailure(failure) {
46
+ const facts = FailureFactsSchema.safeParse(failure);
47
+ const message = facts.success && facts.data.message ? facts.data.message : facts.data?.name ?? 'Error';
48
+ const line = facts.success && facts.data.reason ? `${message} (${facts.data.reason})` : message;
49
+ return facts.success && facts.data.recoveryHint ? `${line}. ${facts.data.recoveryHint}` : line;
50
+ }
51
+ /** A daemon this hook could not reach: no claim, no socket, no answer in time, or no workspace bound. */
52
+ const UNREACHABLE_REASONS = new Set(['local-attestation-claim-missing', 'hook-relay-timeout', 'workspace-unbound', 'workspace-inside-metadata']);
53
+ const UNREACHABLE_CODES = new Set(['ECONNREFUSED', 'ENOENT', 'ECONNRESET']);
54
+ function daemonUnreachable(failure) {
55
+ const facts = FailureCodeSchema.safeParse(failure);
56
+ if (!facts.success)
57
+ return false;
58
+ return (facts.data.reason !== undefined && UNREACHABLE_REASONS.has(facts.data.reason)) || (facts.data.code !== undefined && UNREACHABLE_CODES.has(facts.data.code));
59
+ }
60
+ /** The relay host's declaration: a finite, one-person CLI invocation on the user's device. */
61
+ function hookRelayScope() {
62
+ return {
63
+ surface: 'cli',
64
+ hardware: 'consumer',
65
+ purpose: 'direct',
66
+ lifecycle: 'finite',
67
+ hosting: { mode: 'local', owner: 'consumer', venue: 'user-device' },
68
+ capabilities: { interactiveSession: true },
69
+ qualifiers: {}
70
+ };
71
+ }
72
+ /**
73
+ * The relay's own host: this fast path runs before any CLI boots, so it boots
74
+ * an owned runtime through the one entry (rc02-rc03 §2.1), a literal
75
+ * composition over the Bun environment, which is the one reader of host facts
76
+ * (home, profile, the bound workspace, the daemon socket). The daemon runs the
77
+ * call against the relay's bound workspace; an unbound relay fails loudly
78
+ * (`workspace-unbound`). The composition carries the host's filesystem
79
+ * adapter: the daemon's local-attestation claim is read through it.
80
+ */
81
+ async function defaultTarget(stderr) {
82
+ const { createRuntimeEnvironmentBunPlugin } = await import('@vibesdotdev/host-bun');
83
+ const { bootstrapVibesRuntime, hostWorkspaceRoot } = await import('@vibesdotdev/kernel');
84
+ const { default: configPlugin } = await import('@vibesdotdev/config/plugin');
85
+ const { default: storagePlugin } = await import('@vibesdotdev/storage/plugin');
86
+ const { getVibesConfigClient } = await import('@vibesdotdev/config/client');
87
+ const { createRuntimePlugin } = await import('@vibesdotdev/kernel');
88
+ const { filesystemPlugin } = await import('@vibesdotdev/filesystem');
89
+ const { bunFileSystemAdapterPlugin } = await import('@vibesdotdev/host-node/filesystem');
90
+ const runtime = await bootstrapVibesRuntime({
91
+ environment: createRuntimeEnvironmentBunPlugin({ scope: hookRelayScope() }),
92
+ composition: { kind: 'literal', plugins: [async () => filesystemPlugin, async () => bunFileSystemAdapterPlugin,
93
+ async () => storagePlugin, async () => configPlugin,
94
+ async () => createRuntimePlugin({ id: 'surface-cli.hook-relay', dependencies: ['config'], descriptors: [relayConfigDescriptor] })] },
95
+ binding: 'owned'
96
+ });
97
+ try {
98
+ const { createRuntimeClient, getRuntimeDaemonAttestationPath, getRuntimeDaemonSocketPath } = await import('@vibesdotdev/kernel-rpc/client');
99
+ const workspaceRoot = hostWorkspaceRoot(runtime);
100
+ const explicitSocket = presentText(runtime.getEnv('VIBES_RUNTIME_DAEMON_SOCKET'));
101
+ const { timeoutMs } = await (await getVibesConfigClient(runtime)).read({ id: relayConfigDescriptor.id, schema: RelayConfigSchema });
102
+ // The socket is always named, which disables client auto-start: PM owns
103
+ // daemon liveness, and a hook must never race other hooks to launch
104
+ // another body. Unless the host names one, it is the daemon's own socket
105
+ // for the relay's bound workspace; that daemon's local-attestation claim
106
+ // comes from the same policy (RC08), and a missing claim fails typed
107
+ // rather than connecting unattested.
108
+ const actor = hookLaunchActor(runtime);
109
+ const target = {
110
+ client: createRuntimeClient(runtime, explicitSocket || getRuntimeDaemonSocketPath(runtime, workspaceRoot), explicitSocket ? {} : { attestationClaimPath: getRuntimeDaemonAttestationPath(runtime, workspaceRoot) }),
111
+ workspaceRoot,
112
+ lifecycle: runtime.lifecycle,
113
+ dispose: () => runtime.dispose()
114
+ };
115
+ if (timeoutMs)
116
+ target.timeoutMs = timeoutMs;
117
+ if (actor)
118
+ target.run = (call) => runtime.runInvocation(call, { actor, actorReplaces: true });
119
+ return target;
120
+ }
121
+ catch (error) {
122
+ // Cleanup must never replace the boot refusal.
123
+ const cleanup = await settle(() => runtime.dispose());
124
+ if (!cleanup.ok)
125
+ stderr(`[vibes:hooks] runtime relay cleanup failed: ${describeFailure(cleanup.cause)}\n`);
126
+ throw error;
127
+ }
128
+ }
129
+ /** Boot the relay's target: the caller's, else the hook host's own. */
130
+ async function targetOutcome(options) {
131
+ try {
132
+ return { kind: 'ready', target: options.target ?? (await defaultTarget(options.stderr)) };
133
+ }
134
+ catch (error) {
135
+ return { kind: 'failed', failure: CaughtFailureSchema.parse(error) };
136
+ }
137
+ }
138
+ /** Send the hook call and read the daemon's receipt. */
139
+ async function callOutcome(options, target) {
140
+ const { client } = target;
141
+ const run = target.run ?? ((call) => call());
142
+ const timeoutMs = Math.max(1, Math.min(options.timeoutMs ?? target.timeoutMs ?? RelayConfigSchema.parse({}).timeoutMs, 60_000));
143
+ try {
144
+ const params = HookCallRecordSchema.parse({ action: 'hook-call', ...options.request, stdin: options.stdin });
145
+ // The answer is bounded by the relay host's lifecycle wait (RC07), never
146
+ // a raw timer: its deadline rejects `TIMEOUT wait-timeout` and clears itself.
147
+ const receipt = await target.lifecycle.wait(() => run(() => client.invokeTool('external', params, {
148
+ timeout: timeoutMs,
149
+ source: 'external-hook-relay',
150
+ emitActivity: false,
151
+ workspace: { root: target.workspaceRoot }
152
+ })), { timeoutMs, reason: 'external-hook-relay' });
153
+ const parsed = HookReceiptSchema.safeParse(receipt);
154
+ if (!parsed.success) {
155
+ return { kind: 'failed', failure: new CapabilityError('runtime daemon returned an invalid hook receipt', 'INTERNAL', { reason: 'hook-receipt-invalid', retryable: false }) };
156
+ }
157
+ if (parsed.data.success === false) {
158
+ const { error, recoveryHint } = parsed.data;
159
+ const facts = { reason: 'hook-call-rejected', retryable: false };
160
+ if (recoveryHint)
161
+ facts.recoveryHint = recoveryHint;
162
+ return { kind: 'failed', failure: new CapabilityError(error || 'runtime daemon rejected the hook call', 'UNAVAILABLE', facts) };
163
+ }
164
+ const { stdout, rejection } = parsed.data.result.data;
165
+ return rejection ? { kind: 'answered', output: stdout, rejection } : { kind: 'answered', output: stdout };
166
+ }
167
+ catch (error) {
168
+ const failure = CaughtFailureSchema.parse(error);
169
+ if (WaitTimeoutSchema.safeParse(failure).success) {
170
+ return { kind: 'failed', failure: new CapabilityError(`runtime daemon did not answer within ${timeoutMs}ms`, 'TIMEOUT', { reason: 'hook-relay-timeout', retryable: true, cause: failure }) };
171
+ }
172
+ return { kind: 'failed', failure };
173
+ }
174
+ }
175
+ /** Relay one external lifecycle hook into the already-running workspace body. */
176
+ export async function runExternalHookRelay(options) {
177
+ const booted = await targetOutcome(options);
178
+ const outcome = booted.kind === 'ready' ? await callOutcome(options, booted.target) : booted;
179
+ if (booted.kind === 'ready') {
180
+ const cleanup = await settle(() => booted.target.dispose?.());
181
+ if (!cleanup.ok) {
182
+ options.stderr(`[vibes:hooks] runtime relay cleanup failed: ${describeFailure(cleanup.cause)}\n`);
183
+ }
184
+ }
185
+ if (outcome.kind === 'failed') {
186
+ options.stderr(`[vibes:hooks] runtime relay failed: ${describeFailure(outcome.failure)}\n`);
187
+ // A daemon the hook cannot reach fails open, as a harness's own hook timeout does: the line is
188
+ // written, the agent's tool call is neither blocked nor flagged. A running daemon that rejects
189
+ // the hook is a fault and stays loud.
190
+ return daemonUnreachable(outcome.failure) ? 0 : 1;
191
+ }
192
+ // The adapter refused the payload and rendered the harness's own fixed failure on stdout;
193
+ // its typed refusal is this hook's diagnostic, so it is kept, never dropped.
194
+ if (outcome.rejection) {
195
+ const { message, code, reason } = outcome.rejection;
196
+ options.stderr(`[vibes:hooks] hook input rejected: ${message} (${reason ?? code})\n`);
197
+ }
198
+ if (outcome.output)
199
+ options.stdout(outcome.output.endsWith('\n') ? outcome.output : `${outcome.output}\n`);
200
+ return 0;
201
+ }
202
+ //# sourceMappingURL=external-hook-relay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-hook-relay.js","sourceRoot":"","sources":["../../src/bun/external-hook-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAyC,MAAM,qBAAqB,CAAC;AAC1H,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAqB,MAAM,6BAA6B,CAAC;AACvG,OAAO,EACN,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAC1D,kBAAkB,EAAE,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,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3G,OAAO,CAAC,CAAC;AACV,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { type ExternalHookRelayArgv } from '../schemas/hook-relay.ts';
2
+ export type { ExternalHookRelayArgv } from '../schemas/hook-relay.ts';
3
+ /**
4
+ * Pure argv predicates for the CLI host entry (`./host.ts`, `runCliHost`). Moved from
5
+ * `@vibesdotdev/plugins` (`src/bun/host-argv.ts`) with the host duties.
6
+ *
7
+ * Kept in its own module because `host.ts` BOOTS the CLI as an import side
8
+ * effect — the thin shim's contract is `await import(hostEntry)`. A unit test
9
+ * must be able to assert these rules without launching a CLI.
10
+ */
11
+ /**
12
+ * argv shapes that must keep running when the SCOPE plugin lists are broken.
13
+ *
14
+ * Constitution Rule 13 in executable form: the command that repairs a broken
15
+ * plugin list is exactly the command a broken plugin list would otherwise
16
+ * block. `plugins remove <broken>`, `update --repair` and `doctor` therefore
17
+ * boot with `pluginFailurePolicy: 'report'` — the failure is printed loudly,
18
+ * registration continues, and the repair command dispatches. Every other argv
19
+ * keeps the fail-closed `'abort'` default.
20
+ *
21
+ * The VERB decides — the first token that is neither a global flag nor the
22
+ * VALUE of one. `vibes chat --plugins` is not a repair invocation, and
23
+ * `vibes --profile work plugins remove @broken/pkg` is: skipping the value of
24
+ * a value-taking global is the whole point, because otherwise the one command
25
+ * that repairs a broken scope list would abort on the broken scope list.
26
+ */
27
+ export declare function isRepairArgv(argv: readonly string[]): boolean;
28
+ /**
29
+ * Parse the one CLI operation that is already a projection into a running
30
+ * Vibes body. External hosts can emit several lifecycle hooks at once; booting
31
+ * the complete plugin graph for each event creates another body per event and
32
+ * defeats the daemon boundary. The Bun host consumes this exact argv shape
33
+ * before CLI bootstrap and relays it to the workspace runtime daemon.
34
+ *
35
+ * Unknown flags deliberately decline the fast path. Commander remains the
36
+ * authority for every general CLI invocation and for malformed input.
37
+ */
38
+ export declare function parseExternalHookRelayArgv(argv: readonly string[]): ExternalHookRelayArgv | null;
39
+ /**
40
+ * Global options whose value is a SEPARATE argv token.
41
+ *
42
+ * The list is the value-taking half of the global option block registered on
43
+ * the root Commander program (`@vibesdotdev/cli` `src/bootstrap.ts`: every
44
+ * other global — `-v`, `-q`, `--json`, `--no-color`, `--non-interactive`,
45
+ * `-y`, `--hmr`, `-h`, `-V` — is a boolean and consumes nothing). A global
46
+ * added there without being added here degrades safely in one direction only:
47
+ * its value would be mistaken for the verb, so the invocation falls back to
48
+ * the fail-closed `'abort'` policy rather than silently loosening it.
49
+ *
50
+ * Exported for the cross-package contract test in `@vibesdotdev/cli-bin`
51
+ * (`src/bin/thin/host-argv-contract.test.ts`): the thin shim keeps a
52
+ * byte-identical twin in `host-root.ts`, and a drift between the two is
53
+ * invisible to either package's own suite.
54
+ */
55
+ export declare const VALUE_TAKING_GLOBAL_FLAGS: ReadonlySet<string>;
56
+ /**
57
+ * The module specifier of the CLI host entry: `@vibesdotdev/plugins/bun/host`,
58
+ * the module the thin shim reaches through the plugins package's `host.mjs` /
59
+ * `host-start.mjs` trampolines, whose `startHost` forwards to `runCliHost`.
60
+ * Moved with this module from `@vibesdotdev/plugins`; no importer reads it today.
61
+ */
62
+ export declare const HOST_ENTRY_SPECIFIER = "@vibesdotdev/plugins/bun/host";
63
+ //# sourceMappingURL=host-argv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-argv.d.ts","sourceRoot":"","sources":["../../src/bun/host-argv.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACnG,YAAY,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAY7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,SAAS,MAAM,EAAE,GACrB,qBAAqB,GAAG,IAAI,CAmD9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAsC,CAAC;AAEjG;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,kCAAkC,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { ExternalHookRelayArgvSchema } from "../schemas/hook-relay.js";
2
+ /**
3
+ * Pure argv predicates for the CLI host entry (`./host.ts`, `runCliHost`). Moved from
4
+ * `@vibesdotdev/plugins` (`src/bun/host-argv.ts`) with the host duties.
5
+ *
6
+ * Kept in its own module because `host.ts` BOOTS the CLI as an import side
7
+ * effect — the thin shim's contract is `await import(hostEntry)`. A unit test
8
+ * must be able to assert these rules without launching a CLI.
9
+ */
10
+ /**
11
+ * argv shapes that must keep running when the SCOPE plugin lists are broken.
12
+ *
13
+ * Constitution Rule 13 in executable form: the command that repairs a broken
14
+ * plugin list is exactly the command a broken plugin list would otherwise
15
+ * block. `plugins remove <broken>`, `update --repair` and `doctor` therefore
16
+ * boot with `pluginFailurePolicy: 'report'` — the failure is printed loudly,
17
+ * registration continues, and the repair command dispatches. Every other argv
18
+ * keeps the fail-closed `'abort'` default.
19
+ *
20
+ * The VERB decides — the first token that is neither a global flag nor the
21
+ * VALUE of one. `vibes chat --plugins` is not a repair invocation, and
22
+ * `vibes --profile work plugins remove @broken/pkg` is: skipping the value of
23
+ * a value-taking global is the whole point, because otherwise the one command
24
+ * that repairs a broken scope list would abort on the broken scope list.
25
+ */
26
+ export function isRepairArgv(argv) {
27
+ const rest = argv.slice(2);
28
+ for (let index = 0; index < rest.length; index += 1) {
29
+ const token = rest[index] ?? '';
30
+ if (!token.startsWith('-')) {
31
+ return token === 'plugins' || token === 'update' || token === 'doctor';
32
+ }
33
+ // `--profile=work` carries its value inline; `--profile work` eats the
34
+ // NEXT token, which is not the verb.
35
+ if (VALUE_TAKING_GLOBAL_FLAGS.has(token))
36
+ index += 1;
37
+ }
38
+ return false;
39
+ }
40
+ /**
41
+ * Parse the one CLI operation that is already a projection into a running
42
+ * Vibes body. External hosts can emit several lifecycle hooks at once; booting
43
+ * the complete plugin graph for each event creates another body per event and
44
+ * defeats the daemon boundary. The Bun host consumes this exact argv shape
45
+ * before CLI bootstrap and relays it to the workspace runtime daemon.
46
+ *
47
+ * Unknown flags deliberately decline the fast path. Commander remains the
48
+ * authority for every general CLI invocation and for malformed input.
49
+ */
50
+ export function parseExternalHookRelayArgv(argv) {
51
+ const rest = argv.slice(2);
52
+ const event = rest[4];
53
+ if (rest[0] !== 'dev' ||
54
+ rest[1] !== 'external' ||
55
+ rest[2] !== 'hooks' ||
56
+ rest[3] !== 'call' ||
57
+ (!event || event.startsWith('-'))) {
58
+ return null;
59
+ }
60
+ let target;
61
+ let output = 'text';
62
+ let prompt;
63
+ let disableBrain = false;
64
+ let disablePrompts = false;
65
+ for (let index = 5; index < rest.length; index += 1) {
66
+ const token = rest[index] ?? '';
67
+ if (token === '--disable-brain') {
68
+ disableBrain = true;
69
+ continue;
70
+ }
71
+ if (token === '--disable-prompts') {
72
+ disablePrompts = true;
73
+ continue;
74
+ }
75
+ if (token === '--target' || token === '--output' || token === '--prompt') {
76
+ const value = rest[index + 1];
77
+ if (!value || value.startsWith('-'))
78
+ return null;
79
+ index += 1;
80
+ if (token === '--target')
81
+ target = value;
82
+ else if (token === '--prompt')
83
+ prompt = value;
84
+ else
85
+ output = value;
86
+ continue;
87
+ }
88
+ if (token.startsWith('--target='))
89
+ target = token.slice('--target='.length);
90
+ else if (token.startsWith('--prompt='))
91
+ prompt = token.slice('--prompt='.length);
92
+ else if (token.startsWith('--output=')) {
93
+ const value = token.slice('--output='.length);
94
+ output = value;
95
+ }
96
+ else {
97
+ return null;
98
+ }
99
+ }
100
+ if (!target)
101
+ return null;
102
+ const relay = { event, target, output, disableBrain, disablePrompts };
103
+ return ExternalHookRelayArgvSchema.safeParse(prompt ? { ...relay, prompt } : relay).data ?? null;
104
+ }
105
+ /**
106
+ * Global options whose value is a SEPARATE argv token.
107
+ *
108
+ * The list is the value-taking half of the global option block registered on
109
+ * the root Commander program (`@vibesdotdev/cli` `src/bootstrap.ts`: every
110
+ * other global — `-v`, `-q`, `--json`, `--no-color`, `--non-interactive`,
111
+ * `-y`, `--hmr`, `-h`, `-V` — is a boolean and consumes nothing). A global
112
+ * added there without being added here degrades safely in one direction only:
113
+ * its value would be mistaken for the verb, so the invocation falls back to
114
+ * the fail-closed `'abort'` policy rather than silently loosening it.
115
+ *
116
+ * Exported for the cross-package contract test in `@vibesdotdev/cli-bin`
117
+ * (`src/bin/thin/host-argv-contract.test.ts`): the thin shim keeps a
118
+ * byte-identical twin in `host-root.ts`, and a drift between the two is
119
+ * invisible to either package's own suite.
120
+ */
121
+ export const VALUE_TAKING_GLOBAL_FLAGS = new Set(['--format', '--profile']);
122
+ /**
123
+ * The module specifier of the CLI host entry: `@vibesdotdev/plugins/bun/host`,
124
+ * the module the thin shim reaches through the plugins package's `host.mjs` /
125
+ * `host-start.mjs` trampolines, whose `startHost` forwards to `runCliHost`.
126
+ * Moved with this module from `@vibesdotdev/plugins`; no importer reads it today.
127
+ */
128
+ export const HOST_ENTRY_SPECIFIER = '@vibesdotdev/plugins/bun/host';
129
+ //# sourceMappingURL=host-argv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-argv.js","sourceRoot":"","sources":["../../src/bun/host-argv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAA8B,MAAM,0BAA0B,CAAC;AAGnG;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,IAAuB;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACr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ACtE,OAAO,2BAA2B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;AAClG,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAEjG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type { RunCliHostOptions } from '../schemas/host.ts';
2
+ import type { RunCliHostOptions } from '../schemas/host.ts';
3
+ /**
4
+ * Boot and run the CLI for this process's argv, then exit when nothing keeps
5
+ * the process alive. An external hook call relays to the workspace daemon
6
+ * without booting a CLI. A failed boot is reported through the CLI's failure
7
+ * renderer and `--json` envelope, and exits non-zero.
8
+ */
9
+ export declare function runCliHost(options: RunCliHostOptions): Promise<void>;
10
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/bun/host.ts"],"names":[],"mappings":"AAmBA,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsF1E"}