@pellux/goodvibes-tui 0.19.24 → 0.19.26
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 +13 -0
- package/README.md +5 -5
- package/bin/goodvibes +10 -0
- package/bin/goodvibes-daemon +10 -0
- package/docs/foundation-artifacts/operator-contract.json +1 -1
- package/package.json +3 -2
- package/src/cli/bundle-command.ts +225 -0
- package/src/cli/completion.ts +90 -0
- package/src/cli/config-overrides.ts +159 -0
- package/src/cli/endpoints.ts +63 -0
- package/src/cli/entrypoint.ts +169 -0
- package/src/cli/help.ts +301 -0
- package/src/cli/index.ts +11 -0
- package/src/cli/management-commands.ts +426 -0
- package/src/cli/management.ts +719 -0
- package/src/cli/network-posture.ts +46 -0
- package/src/cli/package-verification.ts +119 -0
- package/src/cli/parser.ts +369 -0
- package/src/cli/provider-classification.ts +107 -0
- package/src/cli/redaction.ts +105 -0
- package/src/cli/service-command.ts +45 -0
- package/src/cli/service-posture.ts +247 -0
- package/src/cli/status.ts +382 -0
- package/src/cli/surface-command.ts +248 -0
- package/src/cli/tui-startup.ts +32 -0
- package/src/cli/types.ts +69 -0
- package/src/cli-flags.ts +18 -55
- package/src/config/index.ts +1 -1
- package/src/config/secrets.ts +44 -0
- package/src/daemon/cli.ts +62 -11
- package/src/input/command-registry.ts +3 -0
- package/src/input/commands/guidance-runtime.ts +9 -4
- package/src/input/commands/local-runtime.ts +21 -7
- package/src/input/commands/local-setup.ts +31 -38
- package/src/input/commands/onboarding-runtime.ts +14 -0
- package/src/input/commands/runtime-services.ts +9 -0
- package/src/input/commands.ts +2 -0
- package/src/input/feed-context-factory.ts +8 -1
- package/src/input/handler-feed.ts +13 -8
- package/src/input/handler-interactions.ts +266 -0
- package/src/input/handler-modal-stack.ts +23 -3
- package/src/input/handler-modal-token-routes.ts +23 -1
- package/src/input/handler-onboarding.ts +696 -0
- package/src/input/handler-picker-routes.ts +15 -7
- package/src/input/handler-ui-state.ts +58 -0
- package/src/input/handler.ts +120 -246
- package/src/input/onboarding/handler-onboarding-routes.ts +105 -0
- package/src/input/onboarding/onboarding-wizard-apply.ts +211 -0
- package/src/input/onboarding/onboarding-wizard-constants.ts +148 -0
- package/src/input/onboarding/onboarding-wizard-external-surfaces.ts +712 -0
- package/src/input/onboarding/onboarding-wizard-helpers.ts +218 -0
- package/src/input/onboarding/onboarding-wizard-rules.ts +224 -0
- package/src/input/onboarding/onboarding-wizard-state.ts +354 -0
- package/src/input/onboarding/onboarding-wizard-steps.ts +642 -0
- package/src/input/onboarding/onboarding-wizard-types.ts +170 -0
- package/src/input/onboarding/onboarding-wizard.ts +594 -0
- package/src/main.ts +32 -39
- package/src/panels/builtin/operations.ts +0 -10
- package/src/panels/index.ts +0 -1
- package/src/renderer/conversation-overlays.ts +6 -0
- package/src/renderer/help-overlay.ts +1 -1
- package/src/renderer/onboarding/onboarding-wizard.ts +533 -0
- package/src/runtime/bootstrap-core.ts +1 -0
- package/src/runtime/bootstrap.ts +123 -0
- package/src/runtime/onboarding/apply.ts +685 -0
- package/src/runtime/onboarding/derivation.ts +495 -0
- package/src/runtime/onboarding/index.ts +7 -0
- package/src/runtime/onboarding/markers.ts +161 -0
- package/src/runtime/onboarding/snapshot.ts +400 -0
- package/src/runtime/onboarding/state.ts +140 -0
- package/src/runtime/onboarding/types.ts +402 -0
- package/src/runtime/onboarding/verify.ts +233 -0
- package/src/runtime/ui-services.ts +16 -0
- package/src/shell/ui-openers.ts +12 -2
- package/src/version.ts +1 -1
- package/src/panels/welcome-panel.ts +0 -64
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to GoodVibes TUI.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [0.19.26] — 2026-04-24
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
- f1e0ac3 feat: harden CLI operations and support bundles
|
|
11
|
+
- 0c94095 feat: enforce readiness command exit codes
|
|
12
|
+
- 566bc34 feat: improve CLI help and listener readiness
|
|
13
|
+
- d620637 feat: harden CLI diagnostics and provider posture
|
|
14
|
+
|
|
15
|
+
## [0.19.25] — 2026-04-24
|
|
16
|
+
|
|
17
|
+
### Changes
|
|
18
|
+
- 705a19b feat: add onboarding wizard and CLI management
|
|
19
|
+
|
|
7
20
|
## [0.19.24] — 2026-04-22
|
|
8
21
|
|
|
9
22
|
Four correctness and honesty fixes from an external architecture review. No SDK change (pinned at 0.23.2).
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/mgd34msu/goodvibes-tui/actions/workflows/ci.yml)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/mgd34msu/goodvibes-tui)
|
|
6
6
|
|
|
7
7
|
A terminal-native AI coding, operations, automation, knowledge, and integration console with a typed runtime, omnichannel surfaces, structured memory/knowledge, and a raw ANSI renderer.
|
|
8
8
|
|
|
@@ -380,10 +380,10 @@ Alternatively, store keys encrypted using the `/secrets` command. Environment va
|
|
|
380
380
|
For self-hosted or external secret managers, link a GoodVibes key to a provider-backed SecretRef:
|
|
381
381
|
|
|
382
382
|
```sh
|
|
383
|
-
/secrets link OPENAI_API_KEY
|
|
384
|
-
/secrets link SLACK_BOT_TOKEN vaultwarden
|
|
385
|
-
/secrets link STRIPE_TOKEN bws
|
|
386
|
-
/secrets link OPENAI_API_KEY
|
|
383
|
+
/secrets link OPENAI_API_KEY goodvibes://secrets/bitwarden?item=GoodVibes%20OpenAI&field=password&sessionEnv=BW_SESSION
|
|
384
|
+
/secrets link SLACK_BOT_TOKEN goodvibes://secrets/vaultwarden?item=GoodVibes%20Slack&field=password&server=https%3A%2F%2Fvault.example.test
|
|
385
|
+
/secrets link STRIPE_TOKEN goodvibes://secrets/bws/00000000-0000-0000-0000-000000000000?field=value&accessTokenEnv=BWS_ACCESS_TOKEN
|
|
386
|
+
/secrets link OPENAI_API_KEY goodvibes://secrets/1password?vault=Private&item=GoodVibes%20OpenAI&field=API%20Key
|
|
387
387
|
```
|
|
388
388
|
|
|
389
389
|
Use `/secrets providers` for supported provider shapes and `/secrets test <secret-ref>` to validate a ref without printing its value.
|
package/bin/goodvibes
CHANGED
|
@@ -39,8 +39,18 @@ function run(command, args) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const artifactName = resolveArtifactName(process.platform, process.arch);
|
|
42
|
+
const localPlatformBuild = artifactName ? join(packageRoot, 'dist', artifactName) : null;
|
|
43
|
+
const localBuild = join(packageRoot, 'dist', 'goodvibes');
|
|
42
44
|
const vendoredBinary = artifactName ? join(packageRoot, 'vendor', artifactName) : null;
|
|
43
45
|
|
|
46
|
+
if (localPlatformBuild && isExecutable(localPlatformBuild)) {
|
|
47
|
+
run(localPlatformBuild, process.argv.slice(2));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isExecutable(localBuild)) {
|
|
51
|
+
run(localBuild, process.argv.slice(2));
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
if (vendoredBinary && isExecutable(vendoredBinary)) {
|
|
45
55
|
run(vendoredBinary, process.argv.slice(2));
|
|
46
56
|
}
|
package/bin/goodvibes-daemon
CHANGED
|
@@ -39,8 +39,18 @@ function run(command, args) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const artifactName = resolveArtifactName(process.platform, process.arch);
|
|
42
|
+
const localPlatformBuild = artifactName ? join(packageRoot, 'dist', artifactName) : null;
|
|
43
|
+
const localBuild = join(packageRoot, 'dist', 'goodvibes-daemon');
|
|
42
44
|
const vendoredBinary = artifactName ? join(packageRoot, 'vendor', artifactName) : null;
|
|
43
45
|
|
|
46
|
+
if (localPlatformBuild && isExecutable(localPlatformBuild)) {
|
|
47
|
+
run(localPlatformBuild, process.argv.slice(2));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isExecutable(localBuild)) {
|
|
51
|
+
run(localBuild, process.argv.slice(2));
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
if (vendoredBinary && isExecutable(vendoredBinary)) {
|
|
45
55
|
run(vendoredBinary, process.argv.slice(2));
|
|
46
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-tui",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.26",
|
|
4
4
|
"description": "Terminal-native GoodVibes product for coding, operations, automation, knowledge, channels, and daemon-backed control-plane workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.ts",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"publish:dry-run": "bun run scripts/publish-package.ts --dry-run",
|
|
50
50
|
"publish:dry-run:github": "GOODVIBES_PUBLIC_PACKAGE_NAME=@mgd34msu/goodvibes-tui GOODVIBES_PUBLISH_REGISTRY=https://npm.pkg.github.com bun run scripts/publish-package.ts --dry-run",
|
|
51
51
|
"publish:check": "bun run scripts/publish-check.ts",
|
|
52
|
+
"package:install-check": "bun run scripts/package-install-check.ts",
|
|
52
53
|
"build:prod": "bun run scripts/build.ts",
|
|
53
54
|
"build:all": "bun run scripts/build.ts --all",
|
|
54
55
|
"perf:check": "bun run scripts/perf-check.ts",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"@anthropic-ai/vertex-sdk": "^0.16.0",
|
|
91
92
|
"@ast-grep/napi": "^0.42.0",
|
|
92
93
|
"@aws/bedrock-token-generator": "^1.1.0",
|
|
93
|
-
"@pellux/goodvibes-sdk": "0.
|
|
94
|
+
"@pellux/goodvibes-sdk": "^0.25.0",
|
|
94
95
|
"bash-language-server": "^5.6.0",
|
|
95
96
|
"fuse.js": "^7.1.0",
|
|
96
97
|
"graphql": "^16.13.2",
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { RuntimeEventBus } from '@pellux/goodvibes-sdk/platform/runtime/events/index';
|
|
4
|
+
import { createShellPathService } from '@pellux/goodvibes-sdk/platform/runtime/shell-paths';
|
|
5
|
+
import { listProviderRuntimeSnapshots } from '@pellux/goodvibes-sdk/platform/providers/runtime-snapshot';
|
|
6
|
+
import { createRuntimeServices } from '../runtime/services.ts';
|
|
7
|
+
import { createRuntimeStore } from '../runtime/store/index.ts';
|
|
8
|
+
import { CONFIG_SCHEMA } from '../config/index.ts';
|
|
9
|
+
import { SecretsManager } from '../config/secrets.ts';
|
|
10
|
+
import type { ConfigKey } from '../config/index.ts';
|
|
11
|
+
import type { CliCommandRuntime } from './management.ts';
|
|
12
|
+
import type { CliCommandOutput } from './types.ts';
|
|
13
|
+
import { getPackageVersion } from './help.ts';
|
|
14
|
+
import { classifyProviderSetup } from './provider-classification.ts';
|
|
15
|
+
import { buildCliServicePosture } from './service-posture.ts';
|
|
16
|
+
import { REDACTED_VALUE, collectSensitiveConfigValues, isRedactedValue, redactConfig, redactSerializedSecrets } from './redaction.ts';
|
|
17
|
+
|
|
18
|
+
interface BundleInspectSummary {
|
|
19
|
+
readonly type: string;
|
|
20
|
+
readonly version: string;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly capturedAt: number | null;
|
|
23
|
+
readonly configKeys: number;
|
|
24
|
+
readonly redactedConfigPaths: readonly string[];
|
|
25
|
+
readonly hasDiagnostics: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function formatJsonOrText(runtime: CliCommandRuntime, value: unknown, text: string): string {
|
|
29
|
+
return runtime.cli.flags.outputFormat === 'json' ? JSON.stringify(value, null, 2) : text;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getNestedValue(source: unknown, key: string): unknown {
|
|
33
|
+
let cursor = source;
|
|
34
|
+
for (const part of key.split('.')) {
|
|
35
|
+
if (cursor == null || typeof cursor !== 'object') return undefined;
|
|
36
|
+
cursor = (cursor as Record<string, unknown>)[part];
|
|
37
|
+
}
|
|
38
|
+
return cursor;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readJsonFile(path: string): { readonly ok: true; readonly value: Record<string, unknown> } | { readonly ok: false; readonly error: string } {
|
|
42
|
+
try {
|
|
43
|
+
return { ok: true, value: JSON.parse(readFileSync(path, 'utf-8')) as Record<string, unknown> };
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function inspectBundle(path: string, parsed: Record<string, unknown>): BundleInspectSummary {
|
|
50
|
+
return {
|
|
51
|
+
type: String(parsed['type'] ?? 'unknown'),
|
|
52
|
+
version: String(parsed['version'] ?? 'unknown'),
|
|
53
|
+
path,
|
|
54
|
+
capturedAt: typeof parsed['capturedAt'] === 'number' ? parsed['capturedAt'] : null,
|
|
55
|
+
configKeys: parsed['config'] && typeof parsed['config'] === 'object'
|
|
56
|
+
? CONFIG_SCHEMA.filter((setting) => getNestedValue(parsed['config'], setting.key) !== undefined).length
|
|
57
|
+
: 0,
|
|
58
|
+
redactedConfigPaths: Array.isArray((parsed['redaction'] as { redactedConfigPaths?: unknown } | undefined)?.redactedConfigPaths)
|
|
59
|
+
? (parsed['redaction'] as { redactedConfigPaths: string[] }).redactedConfigPaths
|
|
60
|
+
: [],
|
|
61
|
+
hasDiagnostics: Boolean(parsed['diagnostics'] && typeof parsed['diagnostics'] === 'object'),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function readAuthPosture(runtime: CliCommandRuntime) {
|
|
66
|
+
const shellPaths = createShellPathService({
|
|
67
|
+
workingDirectory: runtime.workingDirectory,
|
|
68
|
+
homeDirectory: runtime.homeDirectory,
|
|
69
|
+
});
|
|
70
|
+
const userStorePath = shellPaths.resolveUserPath('tui', 'auth-users.json');
|
|
71
|
+
const bootstrapCredentialPath = shellPaths.resolveUserPath('tui', 'auth-bootstrap.txt');
|
|
72
|
+
const operatorTokenPath = join(runtime.homeDirectory, '.goodvibes', 'daemon', 'operator-tokens.json');
|
|
73
|
+
return {
|
|
74
|
+
userStorePath,
|
|
75
|
+
userStorePresent: existsSync(userStorePath),
|
|
76
|
+
bootstrapCredentialPath,
|
|
77
|
+
bootstrapCredentialPresent: existsSync(bootstrapCredentialPath),
|
|
78
|
+
operatorTokenPath,
|
|
79
|
+
operatorTokenPresent: existsSync(operatorTokenPath),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function buildProviderReadiness(runtime: CliCommandRuntime) {
|
|
84
|
+
const runtimeBus = new RuntimeEventBus();
|
|
85
|
+
const runtimeStore = createRuntimeStore();
|
|
86
|
+
const services = createRuntimeServices({
|
|
87
|
+
configManager: runtime.configManager,
|
|
88
|
+
runtimeBus,
|
|
89
|
+
runtimeStore,
|
|
90
|
+
workingDir: runtime.workingDirectory,
|
|
91
|
+
homeDirectory: runtime.homeDirectory,
|
|
92
|
+
});
|
|
93
|
+
services.providerRegistry.initModelLimits();
|
|
94
|
+
services.benchmarkStore.initBenchmarks();
|
|
95
|
+
services.providerRegistry.initCatalog();
|
|
96
|
+
try {
|
|
97
|
+
await services.providerRegistry.ready();
|
|
98
|
+
const snapshots = await listProviderRuntimeSnapshots(services.providerRegistry);
|
|
99
|
+
return snapshots.map((snapshot) => ({
|
|
100
|
+
provider: snapshot.providerId,
|
|
101
|
+
active: snapshot.active,
|
|
102
|
+
configured: snapshot.runtime.auth?.configured ?? true,
|
|
103
|
+
configuredVia: snapshot.runtime.auth?.mode ?? 'unknown',
|
|
104
|
+
models: snapshot.modelCount,
|
|
105
|
+
setup: classifyProviderSetup({
|
|
106
|
+
providerId: snapshot.providerId,
|
|
107
|
+
authMode: snapshot.runtime.auth?.mode,
|
|
108
|
+
configured: snapshot.runtime.auth?.configured ?? true,
|
|
109
|
+
modelCount: snapshot.modelCount,
|
|
110
|
+
}),
|
|
111
|
+
}));
|
|
112
|
+
} finally {
|
|
113
|
+
services.providerRegistry.stopWatching();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function handleBundleCommand(runtime: CliCommandRuntime): Promise<CliCommandOutput> {
|
|
118
|
+
const [sub = 'inspect', ...rest] = runtime.cli.commandArgs;
|
|
119
|
+
const shellPaths = createShellPathService({
|
|
120
|
+
workingDirectory: runtime.workingDirectory,
|
|
121
|
+
homeDirectory: runtime.homeDirectory,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
if (sub === 'inspect') {
|
|
125
|
+
const path = rest[0];
|
|
126
|
+
if (!path) return { output: 'Usage: goodvibes bundle inspect <path>', exitCode: 2 };
|
|
127
|
+
const sourcePath = shellPaths.resolveWorkspacePath(path);
|
|
128
|
+
const parsed = readJsonFile(sourcePath);
|
|
129
|
+
if (!parsed.ok) return { output: `Invalid bundle JSON: ${parsed.error}`, exitCode: 1 };
|
|
130
|
+
const summary = inspectBundle(sourcePath, parsed.value);
|
|
131
|
+
return {
|
|
132
|
+
output: formatJsonOrText(runtime, summary, [
|
|
133
|
+
'GoodVibes bundle',
|
|
134
|
+
` type: ${summary.type}`,
|
|
135
|
+
` version: ${summary.version}`,
|
|
136
|
+
` path: ${summary.path}`,
|
|
137
|
+
` capturedAt: ${summary.capturedAt === null ? 'n/a' : new Date(summary.capturedAt).toISOString()}`,
|
|
138
|
+
` configKeys: ${summary.configKeys}`,
|
|
139
|
+
` redactedConfigKeys: ${summary.redactedConfigPaths.length}`,
|
|
140
|
+
` diagnostics: ${summary.hasDiagnostics ? 'present' : 'missing'}`,
|
|
141
|
+
].join('\n')),
|
|
142
|
+
exitCode: 0,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (sub === 'export') {
|
|
147
|
+
const outputPath = rest[0] ?? 'goodvibes-bundle.json';
|
|
148
|
+
const secrets = new SecretsManager({
|
|
149
|
+
projectRoot: runtime.workingDirectory,
|
|
150
|
+
globalHome: runtime.homeDirectory,
|
|
151
|
+
configManager: runtime.configManager,
|
|
152
|
+
});
|
|
153
|
+
const rawConfig = runtime.configManager.getRaw();
|
|
154
|
+
const sensitiveValues = collectSensitiveConfigValues(rawConfig);
|
|
155
|
+
const redactedConfig = redactConfig(rawConfig);
|
|
156
|
+
const service = await buildCliServicePosture(runtime, { logTailBytes: 8192 });
|
|
157
|
+
const bundle = {
|
|
158
|
+
version: 2,
|
|
159
|
+
type: 'goodvibes.support',
|
|
160
|
+
capturedAt: Date.now(),
|
|
161
|
+
package: {
|
|
162
|
+
name: '@pellux/goodvibes-tui',
|
|
163
|
+
version: getPackageVersion(),
|
|
164
|
+
},
|
|
165
|
+
roots: {
|
|
166
|
+
workingDirectory: runtime.workingDirectory,
|
|
167
|
+
homeDirectory: runtime.homeDirectory,
|
|
168
|
+
},
|
|
169
|
+
config: redactedConfig.value,
|
|
170
|
+
redaction: {
|
|
171
|
+
sentinel: REDACTED_VALUE,
|
|
172
|
+
redactedConfigPaths: redactedConfig.redactedPaths,
|
|
173
|
+
},
|
|
174
|
+
diagnostics: {
|
|
175
|
+
service,
|
|
176
|
+
auth: readAuthPosture(runtime),
|
|
177
|
+
providers: await buildProviderReadiness(runtime),
|
|
178
|
+
},
|
|
179
|
+
secrets: await secrets.inspect(),
|
|
180
|
+
onboarding: {
|
|
181
|
+
projectMarker: existsSync(shellPaths.resolveProjectPath('tui', 'onboarding.json')),
|
|
182
|
+
userMarker: existsSync(shellPaths.resolveUserPath('tui', 'onboarding.json')),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
const targetPath = shellPaths.resolveWorkspacePath(outputPath);
|
|
186
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
187
|
+
writeFileSync(targetPath, redactSerializedSecrets(JSON.stringify(bundle, null, 2), sensitiveValues) + '\n', 'utf-8');
|
|
188
|
+
return {
|
|
189
|
+
output: formatJsonOrText(runtime, {
|
|
190
|
+
path: targetPath,
|
|
191
|
+
redactedConfigPaths: redactedConfig.redactedPaths,
|
|
192
|
+
serviceIssues: service.issues,
|
|
193
|
+
}, `Bundle exported: ${targetPath}\n redactedConfigKeys: ${redactedConfig.redactedPaths.length}\n serviceIssues: ${service.issues.length}`),
|
|
194
|
+
exitCode: 0,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (sub === 'import') {
|
|
199
|
+
const path = rest[0];
|
|
200
|
+
if (!path) return { output: 'Usage: goodvibes bundle import <path>', exitCode: 2 };
|
|
201
|
+
const sourcePath = shellPaths.resolveWorkspacePath(path);
|
|
202
|
+
const parsed = readJsonFile(sourcePath);
|
|
203
|
+
if (!parsed.ok) return { output: `Invalid bundle JSON: ${parsed.error}`, exitCode: 1 };
|
|
204
|
+
const config = parsed.value['config'];
|
|
205
|
+
if (!config || typeof config !== 'object') return { output: 'Bundle has no config object to import.', exitCode: 1 };
|
|
206
|
+
let count = 0;
|
|
207
|
+
let skippedRedacted = 0;
|
|
208
|
+
for (const setting of CONFIG_SCHEMA) {
|
|
209
|
+
const value = getNestedValue(config, setting.key);
|
|
210
|
+
if (value === undefined) continue;
|
|
211
|
+
if (isRedactedValue(value)) {
|
|
212
|
+
skippedRedacted++;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
runtime.configManager.setDynamic(setting.key as ConfigKey, value as never);
|
|
216
|
+
count++;
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
output: `Bundle imported: ${count} config value${count === 1 ? '' : 's'} applied.${skippedRedacted ? ` ${skippedRedacted} redacted value${skippedRedacted === 1 ? '' : 's'} skipped.` : ''}`,
|
|
220
|
+
exitCode: 0,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return { output: 'Usage: goodvibes bundle export [path]|inspect <path>|import <path>', exitCode: 2 };
|
|
225
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const COMMANDS = [
|
|
2
|
+
'tui',
|
|
3
|
+
'run',
|
|
4
|
+
'exec',
|
|
5
|
+
'serve',
|
|
6
|
+
'web',
|
|
7
|
+
'service',
|
|
8
|
+
'onboarding',
|
|
9
|
+
'setup',
|
|
10
|
+
'doctor',
|
|
11
|
+
'status',
|
|
12
|
+
'models',
|
|
13
|
+
'providers',
|
|
14
|
+
'auth',
|
|
15
|
+
'subscription',
|
|
16
|
+
'secrets',
|
|
17
|
+
'sessions',
|
|
18
|
+
'tasks',
|
|
19
|
+
'pair',
|
|
20
|
+
'qrcode',
|
|
21
|
+
'surfaces',
|
|
22
|
+
'listener',
|
|
23
|
+
'control-plane',
|
|
24
|
+
'bundle',
|
|
25
|
+
'remote',
|
|
26
|
+
'bridge',
|
|
27
|
+
'completion',
|
|
28
|
+
'version',
|
|
29
|
+
'help',
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
const OPTIONS = [
|
|
33
|
+
'--help',
|
|
34
|
+
'--version',
|
|
35
|
+
'--model',
|
|
36
|
+
'--provider',
|
|
37
|
+
'--cd',
|
|
38
|
+
'--working-dir',
|
|
39
|
+
'--daemon-home',
|
|
40
|
+
'--config',
|
|
41
|
+
'--enable',
|
|
42
|
+
'--disable',
|
|
43
|
+
'--prompt',
|
|
44
|
+
'--print',
|
|
45
|
+
'--output',
|
|
46
|
+
'--output-format',
|
|
47
|
+
'--json',
|
|
48
|
+
'--no-alt-screen',
|
|
49
|
+
'--port',
|
|
50
|
+
'--hostname',
|
|
51
|
+
'--open',
|
|
52
|
+
'--resume',
|
|
53
|
+
'--session',
|
|
54
|
+
'--continue',
|
|
55
|
+
'--fork',
|
|
56
|
+
'--password',
|
|
57
|
+
'--password-stdin',
|
|
58
|
+
'--role',
|
|
59
|
+
'--manual',
|
|
60
|
+
] as const;
|
|
61
|
+
|
|
62
|
+
export function renderCompletion(shell: string | undefined, binary = 'goodvibes'): string {
|
|
63
|
+
const normalized = (shell ?? 'bash').toLowerCase();
|
|
64
|
+
const words = [...COMMANDS, ...OPTIONS].join(' ');
|
|
65
|
+
|
|
66
|
+
if (normalized === 'zsh') {
|
|
67
|
+
return [
|
|
68
|
+
`#compdef ${binary}`,
|
|
69
|
+
`_${binary}() {`,
|
|
70
|
+
` compadd -- ${words}`,
|
|
71
|
+
'}',
|
|
72
|
+
`_${binary} "$@"`,
|
|
73
|
+
].join('\n');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (normalized === 'fish') {
|
|
77
|
+
return [...COMMANDS, ...OPTIONS]
|
|
78
|
+
.map((word) => `complete -c ${binary} -a ${JSON.stringify(word)}`)
|
|
79
|
+
.join('\n');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return [
|
|
83
|
+
`_${binary}() {`,
|
|
84
|
+
' local cur',
|
|
85
|
+
' cur="${COMP_WORDS[COMP_CWORD]}"',
|
|
86
|
+
` COMPREPLY=( $(compgen -W "${words}" -- "$cur") )`,
|
|
87
|
+
'}',
|
|
88
|
+
`complete -F _${binary} ${binary}`,
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { ConfigKey, ConfigManager, ConfigSetting, GoodVibesConfig, PersistedFlagState } from '../config/index.ts';
|
|
2
|
+
import { CONFIG_SCHEMA, ConfigError } from '../config/index.ts';
|
|
3
|
+
import type { GoodVibesCliCommand, GoodVibesCliFlags } from './types.ts';
|
|
4
|
+
import { RUNTIME_ENDPOINT_CONFIG_KEYS, hostModeForHostname } from './endpoints.ts';
|
|
5
|
+
import type { RuntimeEndpointId } from './endpoints.ts';
|
|
6
|
+
|
|
7
|
+
const CONFIG_SCHEMA_BY_KEY = new Map<string, ConfigSetting>(
|
|
8
|
+
CONFIG_SCHEMA.map((setting) => [setting.key, setting]),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
function parseConfigOverrideValue(value: string): unknown {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (trimmed.length === 0) return '';
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(trimmed) as unknown;
|
|
16
|
+
} catch {
|
|
17
|
+
if (trimmed === 'true') return true;
|
|
18
|
+
if (trimmed === 'false') return false;
|
|
19
|
+
if (/^-?\d+(?:\.\d+)?$/.test(trimmed)) return Number(trimmed);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getRuntimeConfig(configManager: ConfigManager): GoodVibesConfig {
|
|
25
|
+
const mutable = configManager as unknown as { config?: GoodVibesConfig };
|
|
26
|
+
if (!mutable.config || typeof mutable.config !== 'object') {
|
|
27
|
+
throw new ConfigError('ConfigManager runtime config is not available for CLI overrides.');
|
|
28
|
+
}
|
|
29
|
+
return mutable.config;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function validateConfigValue(setting: ConfigSetting, value: unknown): void {
|
|
33
|
+
if (setting.type === 'boolean' && typeof value !== 'boolean') {
|
|
34
|
+
throw new ConfigError(`Invalid value for ${setting.key}: expected boolean.`);
|
|
35
|
+
}
|
|
36
|
+
if (setting.type === 'number' && (typeof value !== 'number' || !Number.isFinite(value))) {
|
|
37
|
+
throw new ConfigError(`Invalid value for ${setting.key}: expected number.`);
|
|
38
|
+
}
|
|
39
|
+
if (setting.type === 'string' && typeof value !== 'string') {
|
|
40
|
+
throw new ConfigError(`Invalid value for ${setting.key}: expected string.`);
|
|
41
|
+
}
|
|
42
|
+
if (setting.type === 'enum' && setting.enumValues && !setting.enumValues.includes(String(value))) {
|
|
43
|
+
throw new ConfigError(`Invalid value for ${setting.key}: "${String(value)}". Allowed: ${setting.enumValues.join(', ')}`);
|
|
44
|
+
}
|
|
45
|
+
if (setting.validate && !setting.validate(value)) {
|
|
46
|
+
throw new ConfigError(`Invalid value for ${setting.key}: ${String(value)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function setNestedConfigValue(config: GoodVibesConfig, key: ConfigKey, value: unknown): void {
|
|
51
|
+
const parts = key.split('.');
|
|
52
|
+
let cursor: unknown = config;
|
|
53
|
+
for (const part of parts.slice(0, -1)) {
|
|
54
|
+
if (cursor == null || typeof cursor !== 'object' || !(part in cursor)) {
|
|
55
|
+
throw new ConfigError(`Invalid config path: section '${part}' does not exist`);
|
|
56
|
+
}
|
|
57
|
+
cursor = (cursor as Record<string, unknown>)[part];
|
|
58
|
+
}
|
|
59
|
+
if (cursor == null || typeof cursor !== 'object') {
|
|
60
|
+
throw new ConfigError(`Invalid config path: section '${parts.slice(0, -1).join('.')}' does not exist`);
|
|
61
|
+
}
|
|
62
|
+
(cursor as Record<string, unknown>)[parts[parts.length - 1]!] = value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function applyRuntimeConfigValue(configManager: ConfigManager, key: ConfigKey, value: unknown): void {
|
|
66
|
+
const setting = CONFIG_SCHEMA_BY_KEY.get(key);
|
|
67
|
+
if (!setting) {
|
|
68
|
+
throw new ConfigError(`Unknown config key: ${key}`);
|
|
69
|
+
}
|
|
70
|
+
validateConfigValue(setting, value);
|
|
71
|
+
setNestedConfigValue(getRuntimeConfig(configManager), key, value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function applyRuntimeConfigOverrides(
|
|
75
|
+
configManager: ConfigManager,
|
|
76
|
+
overrides: readonly string[],
|
|
77
|
+
): readonly string[] {
|
|
78
|
+
const errors: string[] = [];
|
|
79
|
+
for (const override of overrides) {
|
|
80
|
+
const index = override.indexOf('=');
|
|
81
|
+
if (index <= 0) {
|
|
82
|
+
errors.push(`Invalid --config override "${override}". Expected key=value.`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const key = override.slice(0, index) as ConfigKey;
|
|
86
|
+
const rawValue = override.slice(index + 1);
|
|
87
|
+
try {
|
|
88
|
+
applyRuntimeConfigValue(configManager, key, parseConfigOverrideValue(rawValue));
|
|
89
|
+
} catch (error) {
|
|
90
|
+
errors.push(error instanceof Error ? `Invalid --config ${override}: ${error.message}` : `Invalid --config ${override}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return errors;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function applyRuntimeFeatureFlagOverrides(
|
|
97
|
+
configManager: ConfigManager,
|
|
98
|
+
options: {
|
|
99
|
+
readonly enableFeatures: readonly string[];
|
|
100
|
+
readonly disableFeatures: readonly string[];
|
|
101
|
+
},
|
|
102
|
+
): void {
|
|
103
|
+
if (options.enableFeatures.length === 0 && options.disableFeatures.length === 0) return;
|
|
104
|
+
const config = getRuntimeConfig(configManager);
|
|
105
|
+
const flags = { ...config.featureFlags };
|
|
106
|
+
for (const feature of options.enableFeatures) {
|
|
107
|
+
flags[feature] = 'enabled' satisfies PersistedFlagState;
|
|
108
|
+
}
|
|
109
|
+
for (const feature of options.disableFeatures) {
|
|
110
|
+
flags[feature] = 'disabled' satisfies PersistedFlagState;
|
|
111
|
+
}
|
|
112
|
+
config.featureFlags = flags;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function applyRuntimeEndpointFlagOverrides(
|
|
116
|
+
configManager: ConfigManager,
|
|
117
|
+
endpoint: RuntimeEndpointId,
|
|
118
|
+
flags: Pick<GoodVibesCliFlags, 'hostname' | 'port'>,
|
|
119
|
+
): readonly string[] {
|
|
120
|
+
const keys = RUNTIME_ENDPOINT_CONFIG_KEYS[endpoint];
|
|
121
|
+
const errors: string[] = [];
|
|
122
|
+
|
|
123
|
+
if (flags.hostname !== undefined) {
|
|
124
|
+
try {
|
|
125
|
+
applyRuntimeConfigValue(configManager, keys.hostMode, hostModeForHostname(flags.hostname));
|
|
126
|
+
applyRuntimeConfigValue(configManager, keys.host, flags.hostname);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
errors.push(error instanceof Error
|
|
129
|
+
? `Invalid --hostname ${flags.hostname}: ${error.message}`
|
|
130
|
+
: `Invalid --hostname ${flags.hostname}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (flags.port !== undefined) {
|
|
135
|
+
try {
|
|
136
|
+
applyRuntimeConfigValue(configManager, keys.port, flags.port);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
errors.push(error instanceof Error
|
|
139
|
+
? `Invalid --port ${flags.port}: ${error.message}`
|
|
140
|
+
: `Invalid --port ${flags.port}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return errors;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function applyRuntimeCommandEndpointFlagOverrides(
|
|
148
|
+
configManager: ConfigManager,
|
|
149
|
+
command: GoodVibesCliCommand,
|
|
150
|
+
flags: Pick<GoodVibesCliFlags, 'hostname' | 'port'>,
|
|
151
|
+
): readonly string[] {
|
|
152
|
+
if (flags.hostname === undefined && flags.port === undefined) return [];
|
|
153
|
+
if (command === 'web') return applyRuntimeEndpointFlagOverrides(configManager, 'web', flags);
|
|
154
|
+
if (command === 'listener') return applyRuntimeEndpointFlagOverrides(configManager, 'httpListener', flags);
|
|
155
|
+
if (command === 'control-plane' || command === 'pair' || command === 'serve') {
|
|
156
|
+
return applyRuntimeEndpointFlagOverrides(configManager, 'controlPlane', flags);
|
|
157
|
+
}
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ConfigKey, ConfigManager } from '../config/index.ts';
|
|
2
|
+
|
|
3
|
+
export type RuntimeEndpointId = 'controlPlane' | 'httpListener' | 'web';
|
|
4
|
+
export type RuntimeHostMode = 'local' | 'network' | 'custom';
|
|
5
|
+
|
|
6
|
+
export const RUNTIME_ENDPOINT_DEFAULT_PORTS: Record<RuntimeEndpointId, number> = {
|
|
7
|
+
controlPlane: 3421,
|
|
8
|
+
httpListener: 3422,
|
|
9
|
+
web: 3423,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const RUNTIME_ENDPOINT_CONFIG_KEYS: Record<RuntimeEndpointId, {
|
|
13
|
+
readonly hostMode: ConfigKey;
|
|
14
|
+
readonly host: ConfigKey;
|
|
15
|
+
readonly port: ConfigKey;
|
|
16
|
+
}> = {
|
|
17
|
+
controlPlane: {
|
|
18
|
+
hostMode: 'controlPlane.hostMode',
|
|
19
|
+
host: 'controlPlane.host',
|
|
20
|
+
port: 'controlPlane.port',
|
|
21
|
+
},
|
|
22
|
+
httpListener: {
|
|
23
|
+
hostMode: 'httpListener.hostMode',
|
|
24
|
+
host: 'httpListener.host',
|
|
25
|
+
port: 'httpListener.port',
|
|
26
|
+
},
|
|
27
|
+
web: {
|
|
28
|
+
hostMode: 'web.hostMode',
|
|
29
|
+
host: 'web.host',
|
|
30
|
+
port: 'web.port',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export interface RuntimeEndpointBinding {
|
|
35
|
+
readonly hostMode: string;
|
|
36
|
+
readonly configuredHost: string;
|
|
37
|
+
readonly host: string;
|
|
38
|
+
readonly port: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function hostModeForHostname(hostname: string): RuntimeHostMode {
|
|
42
|
+
const normalized = hostname.toLowerCase();
|
|
43
|
+
if (normalized === '0.0.0.0' || normalized === '::') return 'network';
|
|
44
|
+
if (normalized === '127.0.0.1' || normalized === 'localhost' || normalized === '::1') return 'local';
|
|
45
|
+
return 'custom';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function resolveRuntimeEndpointBinding(
|
|
49
|
+
config: Pick<ConfigManager, 'get'>,
|
|
50
|
+
endpoint: RuntimeEndpointId,
|
|
51
|
+
): RuntimeEndpointBinding {
|
|
52
|
+
const keys = RUNTIME_ENDPOINT_CONFIG_KEYS[endpoint];
|
|
53
|
+
const hostMode = String(config.get(keys.hostMode) ?? 'local');
|
|
54
|
+
const configuredHost = String(config.get(keys.host) ?? '127.0.0.1');
|
|
55
|
+
const port = Number(config.get(keys.port) || RUNTIME_ENDPOINT_DEFAULT_PORTS[endpoint]);
|
|
56
|
+
if (hostMode === 'network') {
|
|
57
|
+
return { hostMode, configuredHost, host: '0.0.0.0', port };
|
|
58
|
+
}
|
|
59
|
+
if (hostMode === 'custom') {
|
|
60
|
+
return { hostMode, configuredHost, host: configuredHost || '127.0.0.1', port };
|
|
61
|
+
}
|
|
62
|
+
return { hostMode, configuredHost, host: '127.0.0.1', port };
|
|
63
|
+
}
|