vigthoria-cli 1.13.20 → 1.13.23
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/completions/_vigthoria +49 -0
- package/completions/vigthoria.bash +6 -0
- package/completions/vigthoria.fish +41 -0
- package/dist/commands/auth.d.ts +1 -0
- package/dist/commands/auth.js +63 -128
- package/dist/commands/background.d.ts +0 -2
- package/dist/commands/background.js +26 -34
- package/dist/commands/bridge.js +45 -41
- package/dist/commands/cancel.d.ts +1 -0
- package/dist/commands/cancel.js +22 -16
- package/dist/commands/chat.d.ts +3 -42
- package/dist/commands/chat.js +378 -1123
- package/dist/commands/coding-registration.d.ts +4 -0
- package/dist/commands/coding-registration.js +24 -0
- package/dist/commands/config.js +23 -29
- package/dist/commands/conversation-registration.d.ts +4 -0
- package/dist/commands/conversation-registration.js +122 -0
- package/dist/commands/deploy.d.ts +8 -2
- package/dist/commands/deploy.js +92 -90
- package/dist/commands/device.d.ts +1 -2
- package/dist/commands/device.js +37 -21
- package/dist/commands/doctor-registration.d.ts +4 -0
- package/dist/commands/doctor-registration.js +207 -0
- package/dist/commands/edit.js +22 -33
- package/dist/commands/explain.js +7 -10
- package/dist/commands/fork.d.ts +1 -2
- package/dist/commands/fork.js +72 -22
- package/dist/commands/game.d.ts +1 -1
- package/dist/commands/game.js +17 -6
- package/dist/commands/generate.js +7 -9
- package/dist/commands/history.js +11 -7
- package/dist/commands/hub.d.ts +2 -2
- package/dist/commands/hub.js +34 -35
- package/dist/commands/legion.d.ts +0 -1
- package/dist/commands/legion.js +62 -79
- package/dist/commands/music.d.ts +1 -2
- package/dist/commands/music.js +62 -27
- package/dist/commands/platform-registration.d.ts +4 -0
- package/dist/commands/platform-registration.js +45 -0
- package/dist/commands/preview.d.ts +0 -1
- package/dist/commands/preview.js +82 -35
- package/dist/commands/product-run-registration.d.ts +4 -0
- package/dist/commands/product-run-registration.js +490 -0
- package/dist/commands/replay.d.ts +1 -2
- package/dist/commands/replay.js +15 -11
- package/dist/commands/repo.d.ts +14 -7
- package/dist/commands/repo.js +244 -198
- package/dist/commands/review.js +9 -12
- package/dist/commands/security.d.ts +1 -2
- package/dist/commands/security.js +12 -6
- package/dist/commands/update-registration.d.ts +3 -0
- package/dist/commands/update-registration.js +368 -0
- package/dist/commands/v4-registration.d.ts +4 -0
- package/dist/commands/v4-registration.js +24 -0
- package/dist/commands/v4.d.ts +1 -1
- package/dist/commands/v4.js +46 -8
- package/dist/commands/wallet.d.ts +1 -3
- package/dist/commands/wallet.js +18 -45
- package/dist/commands/workflow.d.ts +2 -0
- package/dist/commands/workflow.js +52 -39
- package/dist/index.js +124 -1589
- package/dist/utils/agent-stream-state.d.ts +27 -0
- package/dist/utils/agent-stream-state.js +93 -0
- package/dist/utils/agentRoute.d.ts +2 -1
- package/dist/utils/agentRoute.js +22 -9
- package/dist/utils/agentRunOutcome.d.ts +16 -0
- package/dist/utils/agentRunOutcome.js +37 -2
- package/dist/utils/api-client-factory.d.ts +8 -0
- package/dist/utils/api-client-factory.js +8 -0
- package/dist/utils/api.d.ts +44 -266
- package/dist/utils/api.js +647 -3180
- package/dist/utils/auth-session.d.ts +41 -0
- package/dist/utils/auth-session.js +224 -0
- package/dist/utils/brain-hub-client.d.ts +0 -4
- package/dist/utils/brain-hub-client.js +6 -3
- package/dist/utils/bridge-client.js +2 -0
- package/dist/utils/capability-health-service.d.ts +48 -0
- package/dist/utils/capability-health-service.js +64 -0
- package/dist/utils/chat-prompt-policy.d.ts +18 -0
- package/dist/utils/chat-prompt-policy.js +61 -0
- package/dist/utils/chat-tool-call-parser.d.ts +11 -0
- package/dist/utils/chat-tool-call-parser.js +71 -0
- package/dist/utils/cli-state.d.ts +22 -4
- package/dist/utils/cli-state.js +105 -47
- package/dist/utils/code-operations-service.d.ts +104 -0
- package/dist/utils/code-operations-service.js +837 -0
- package/dist/utils/codebase-indexer.d.ts +1 -0
- package/dist/utils/codebase-indexer.js +28 -8
- package/dist/utils/command-contract.d.ts +61 -0
- package/dist/utils/command-contract.js +149 -0
- package/dist/utils/command-policy.d.ts +10 -0
- package/dist/utils/command-policy.js +54 -0
- package/dist/utils/config.d.ts +13 -5
- package/dist/utils/config.js +220 -94
- package/dist/utils/context-ranker.js +11 -2
- package/dist/utils/context-state.d.ts +39 -0
- package/dist/utils/context-state.js +52 -0
- package/dist/utils/deckEvents.d.ts +0 -5
- package/dist/utils/deckEvents.js +3 -2
- package/dist/utils/desktop-bridge-client.js +2 -0
- package/dist/utils/direct-output-policy.d.ts +3 -0
- package/dist/utils/direct-output-policy.js +76 -0
- package/dist/utils/durable-json.d.ts +57 -0
- package/dist/utils/durable-json.js +319 -0
- package/dist/utils/fastAgentRouter.d.ts +5 -6
- package/dist/utils/fastAgentRouter.js +17 -25
- package/dist/utils/files.js +21 -13
- package/dist/utils/frontend-preview-service.d.ts +76 -0
- package/dist/utils/frontend-preview-service.js +482 -0
- package/dist/utils/goaEvents.d.ts +0 -4
- package/dist/utils/goaEvents.js +5 -2
- package/dist/utils/logger.d.ts +2 -1
- package/dist/utils/logger.js +27 -20
- package/dist/utils/mcp-context-client.d.ts +24 -0
- package/dist/utils/mcp-context-client.js +58 -0
- package/dist/utils/model-governance.d.ts +18 -0
- package/dist/utils/model-governance.js +75 -0
- package/dist/utils/model-transport-service.d.ts +44 -0
- package/dist/utils/model-transport-service.js +111 -0
- package/dist/utils/mutation-journal.d.ts +42 -0
- package/dist/utils/mutation-journal.js +387 -0
- package/dist/utils/network-policy.d.ts +24 -0
- package/dist/utils/network-policy.js +202 -0
- package/dist/utils/operator-client.d.ts +45 -0
- package/dist/utils/operator-client.js +159 -0
- package/dist/utils/post-write-validator.js +7 -9
- package/dist/utils/preview-screenshot-adapter.d.ts +15 -0
- package/dist/utils/preview-screenshot-adapter.js +51 -0
- package/dist/utils/process-policy.d.ts +23 -0
- package/dist/utils/process-policy.js +284 -0
- package/dist/utils/project-memory.d.ts +13 -3
- package/dist/utils/project-memory.js +70 -17
- package/dist/utils/prompt-workspace-resolver.d.ts +14 -0
- package/dist/utils/prompt-workspace-resolver.js +64 -0
- package/dist/utils/release-install.d.ts +11 -0
- package/dist/utils/release-install.js +155 -0
- package/dist/utils/release-policy.d.ts +64 -0
- package/dist/utils/release-policy.js +293 -0
- package/dist/utils/requestIntent.js +22 -3
- package/dist/utils/runtime-capability.d.ts +8 -0
- package/dist/utils/runtime-capability.js +16 -0
- package/dist/utils/runtime-temp.d.ts +76 -0
- package/dist/utils/runtime-temp.js +492 -0
- package/dist/utils/secret-policy.d.ts +20 -0
- package/dist/utils/secret-policy.js +160 -0
- package/dist/utils/session.d.ts +17 -3
- package/dist/utils/session.js +354 -110
- package/dist/utils/tool-approval-service.d.ts +17 -0
- package/dist/utils/tool-approval-service.js +78 -0
- package/dist/utils/tool-capability-providers.d.ts +57 -0
- package/dist/utils/tool-capability-providers.js +57 -0
- package/dist/utils/tools.d.ts +2 -23
- package/dist/utils/tools.js +226 -512
- package/dist/utils/update-policy.d.ts +18 -0
- package/dist/utils/update-policy.js +137 -0
- package/dist/utils/v3-agent-client.d.ts +40 -0
- package/dist/utils/v3-agent-client.js +165 -0
- package/dist/utils/v3-workspace-service.d.ts +28 -0
- package/dist/utils/v3-workspace-service.js +279 -0
- package/dist/utils/vigflow-client.d.ts +95 -0
- package/dist/utils/vigflow-client.js +105 -0
- package/dist/utils/workspace-boundary.d.ts +45 -0
- package/dist/utils/workspace-boundary.js +377 -0
- package/dist/utils/workspace-brain-service.d.ts +2 -0
- package/dist/utils/workspace-brain-service.js +11 -1
- package/dist/utils/workspace-cache.js +37 -15
- package/dist/utils/workspace-stream.js +35 -10
- package/install.ps1 +115 -142
- package/install.sh +112 -81
- package/package.json +43 -9
- package/release-policy.json +43 -0
- package/scripts/release/LOCAL_MACHINE_USER_VERIFICATION.md +1 -1
- package/scripts/release/generate-completions.mjs +24 -0
- package/scripts/release/install-release.mjs +10 -0
- package/scripts/release/publish-cli-release.mjs +116 -0
- package/scripts/release/publish-cli-release.sh +2 -70
- package/scripts/release/resolve-release-manifest.mjs +26 -0
- package/scripts/release/test-balanced-model-live.sh +45 -0
- package/scripts/release/validate-live-service-gates.sh +93 -0
- package/scripts/release/validate-no-go-gates.sh +145 -174
- package/scripts/release/verify-runtime-consistency.mjs +4 -1
- package/dist/commands/index.d.ts +0 -12
- package/dist/commands/index.js +0 -194
- package/dist/commands/update.d.ts +0 -9
- package/dist/commands/update.js +0 -301
- package/dist/utils/templateInstantPath.d.ts +0 -18
- package/dist/utils/templateInstantPath.js +0 -228
package/dist/commands/index.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { registerAuthCommands } from './auth.js';
|
|
2
|
-
import { BridgeCommand } from './bridge.js';
|
|
3
|
-
import { CancelCommand } from './cancel.js';
|
|
4
|
-
import { ChatCommand } from './chat.js';
|
|
5
|
-
import { ConfigCommand } from './config.js';
|
|
6
|
-
import { DeployCommand } from './deploy.js';
|
|
7
|
-
import { EditCommand } from './edit.js';
|
|
8
|
-
import { ExplainCommand } from './explain.js';
|
|
9
|
-
import { ForkCommand } from './fork.js';
|
|
10
|
-
import { GenerateCommand } from './generate.js';
|
|
11
|
-
import { HistoryCommand } from './history.js';
|
|
12
|
-
import { HubCommand } from './hub.js';
|
|
13
|
-
import { LegionCommand } from './legion.js';
|
|
14
|
-
import { MusicCommand } from './music.js';
|
|
15
|
-
import { PreviewCommand } from './preview.js';
|
|
16
|
-
import { ReplayCommand } from './replay.js';
|
|
17
|
-
import { RepoCommand } from './repo.js';
|
|
18
|
-
import { ReviewCommand } from './review.js';
|
|
19
|
-
import { WorkflowCommand } from './workflow.js';
|
|
20
|
-
import { V4Command } from './v4.js';
|
|
21
|
-
import { WalletCommand } from './wallet.js';
|
|
22
|
-
function isRegisterableCommand(value) {
|
|
23
|
-
return Boolean(value && typeof value === 'object');
|
|
24
|
-
}
|
|
25
|
-
function invokeRegistrar(instance, program) {
|
|
26
|
-
if (!isRegisterableCommand(instance)) {
|
|
27
|
-
throw new Error('Command instance is not registerable');
|
|
28
|
-
}
|
|
29
|
-
const registrar = instance.register ?? instance.setup ?? instance.configure;
|
|
30
|
-
if (typeof registrar !== 'function') {
|
|
31
|
-
throw new Error('Command does not expose register(), setup(), or configure()');
|
|
32
|
-
}
|
|
33
|
-
registrar.call(instance, program);
|
|
34
|
-
}
|
|
35
|
-
function createClassRegistrar(CommandClass) {
|
|
36
|
-
return (program) => {
|
|
37
|
-
invokeRegistrar(new CommandClass(), program);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function registerDoctorCommand(program) {
|
|
41
|
-
program
|
|
42
|
-
.command('doctor')
|
|
43
|
-
.description('Run local Vigthoria CLI diagnostics')
|
|
44
|
-
.action(() => {
|
|
45
|
-
const checks = [
|
|
46
|
-
['Node.js', process.version],
|
|
47
|
-
['Platform', `${process.platform} ${process.arch}`],
|
|
48
|
-
['Working directory', process.cwd()],
|
|
49
|
-
];
|
|
50
|
-
console.log('Vigthoria CLI diagnostics');
|
|
51
|
-
for (const [label, value] of checks) {
|
|
52
|
-
console.log(`- ${label}: ${value}`);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function registerVersionInfoCommand(program) {
|
|
57
|
-
program
|
|
58
|
-
.command('version-info')
|
|
59
|
-
.description('Show runtime version information')
|
|
60
|
-
.action(() => {
|
|
61
|
-
console.log(JSON.stringify({
|
|
62
|
-
node: process.version,
|
|
63
|
-
platform: process.platform,
|
|
64
|
-
arch: process.arch,
|
|
65
|
-
argv0: process.argv0,
|
|
66
|
-
}, null, 2));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const commandRegistry = [
|
|
70
|
-
{
|
|
71
|
-
name: 'auth',
|
|
72
|
-
handler: registerAuthCommands,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'chat',
|
|
76
|
-
handler: createClassRegistrar(ChatCommand),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'edit',
|
|
80
|
-
handler: createClassRegistrar(EditCommand),
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: 'generate',
|
|
84
|
-
handler: createClassRegistrar(GenerateCommand),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'explain',
|
|
88
|
-
handler: createClassRegistrar(ExplainCommand),
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'config',
|
|
92
|
-
handler: createClassRegistrar(ConfigCommand),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'review',
|
|
96
|
-
handler: createClassRegistrar(ReviewCommand),
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'hub',
|
|
100
|
-
handler: createClassRegistrar(HubCommand),
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'music',
|
|
104
|
-
aliases: ['audio'],
|
|
105
|
-
handler: createClassRegistrar(MusicCommand),
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'repo',
|
|
109
|
-
handler: createClassRegistrar(RepoCommand),
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: 'deploy',
|
|
113
|
-
handler: createClassRegistrar(DeployCommand),
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'bridge',
|
|
117
|
-
handler: createClassRegistrar(BridgeCommand),
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'v4',
|
|
121
|
-
aliases: ['v4-agent'],
|
|
122
|
-
handler: createClassRegistrar(V4Command),
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'workflow',
|
|
126
|
-
handler: createClassRegistrar(WorkflowCommand),
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'preview',
|
|
130
|
-
handler: createClassRegistrar(PreviewCommand),
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: 'legion',
|
|
134
|
-
handler: createClassRegistrar(LegionCommand),
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: 'history',
|
|
138
|
-
handler: createClassRegistrar(HistoryCommand),
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: 'wallet',
|
|
142
|
-
handler: createClassRegistrar(WalletCommand),
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: 'replay',
|
|
146
|
-
handler: createClassRegistrar(ReplayCommand),
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: 'fork',
|
|
150
|
-
handler: createClassRegistrar(ForkCommand),
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'cancel',
|
|
154
|
-
handler: createClassRegistrar(CancelCommand),
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'doctor',
|
|
158
|
-
handler: registerDoctorCommand,
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: 'version-info',
|
|
162
|
-
aliases: ['versionInfo'],
|
|
163
|
-
handler: registerVersionInfoCommand,
|
|
164
|
-
},
|
|
165
|
-
];
|
|
166
|
-
function normalizeCommandName(name) {
|
|
167
|
-
return name.trim().toLowerCase();
|
|
168
|
-
}
|
|
169
|
-
function commandNameMatches(entry, requestedName) {
|
|
170
|
-
if (normalizeCommandName(entry.name) === requestedName) {
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
return Boolean(entry.aliases?.some((alias) => normalizeCommandName(alias) === requestedName));
|
|
174
|
-
}
|
|
175
|
-
export function resolveCommand(name) {
|
|
176
|
-
const requestedName = normalizeCommandName(name);
|
|
177
|
-
if (!requestedName) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
const entry = commandRegistry.find((candidate) => commandNameMatches(candidate, requestedName));
|
|
181
|
-
return entry?.handler ?? null;
|
|
182
|
-
}
|
|
183
|
-
export function registerCommands(cli) {
|
|
184
|
-
if (!cli || typeof cli.command !== 'function') {
|
|
185
|
-
throw new Error('registerCommands requires a Commander-compatible CLI instance');
|
|
186
|
-
}
|
|
187
|
-
const program = cli;
|
|
188
|
-
for (const entry of commandRegistry) {
|
|
189
|
-
entry.handler(program);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
export const setupCommands = registerCommands;
|
|
193
|
-
export const configureCommands = registerCommands;
|
|
194
|
-
export default registerCommands;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
2
|
-
interface UpdateOptions {
|
|
3
|
-
check?: boolean;
|
|
4
|
-
packageManager?: PackageManager;
|
|
5
|
-
global?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function updateCommand(options?: UpdateOptions): Promise<void>;
|
|
8
|
-
export declare function update(): Promise<void>;
|
|
9
|
-
export default updateCommand;
|
package/dist/commands/update.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import * as path from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { promisify } from 'node:util';
|
|
9
|
-
// ESM shim — __filename is unavailable under "type": "module".
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const execFileAsync = promisify(execFile);
|
|
12
|
-
const DEFAULT_UPDATE_MANIFEST = 'https://extension.vigthoria.io/downloads/manifest.json';
|
|
13
|
-
const TRUSTED_RELEASE_HOSTS = new Set([
|
|
14
|
-
'extension.vigthoria.io',
|
|
15
|
-
'landing.vigthoria.io',
|
|
16
|
-
'cli.vigthoria.io',
|
|
17
|
-
'coder.vigthoria.io',
|
|
18
|
-
'market.vigthoria.io',
|
|
19
|
-
]);
|
|
20
|
-
function markSuccessExit() {
|
|
21
|
-
process.exitCode = 0;
|
|
22
|
-
}
|
|
23
|
-
function markErrorExit() {
|
|
24
|
-
process.exitCode = 1;
|
|
25
|
-
}
|
|
26
|
-
function findPackageJson(startDir) {
|
|
27
|
-
let currentDir = startDir;
|
|
28
|
-
for (let depth = 0; depth < 8; depth += 1) {
|
|
29
|
-
const candidate = path.join(currentDir, 'package.json');
|
|
30
|
-
if (existsSync(candidate)) {
|
|
31
|
-
return candidate;
|
|
32
|
-
}
|
|
33
|
-
const parentDir = path.join(currentDir, '..');
|
|
34
|
-
if (parentDir === currentDir) {
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
currentDir = parentDir;
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
function readOwnPackageJson() {
|
|
42
|
-
const currentFile = __filename;
|
|
43
|
-
const packagePath = findPackageJson(path.join(currentFile, '..'));
|
|
44
|
-
if (!packagePath) {
|
|
45
|
-
throw new Error('Unable to locate package.json for the Vigthoria CLI.');
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
return JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
-
throw new Error(`Unable to read package metadata: ${message}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function compareVersions(a, b) {
|
|
56
|
-
const parse = (version) => version.replace(/^v/, '').split(/[.-]/).map((part) => {
|
|
57
|
-
const value = Number.parseInt(part, 10);
|
|
58
|
-
return Number.isNaN(value) ? 0 : value;
|
|
59
|
-
});
|
|
60
|
-
const left = parse(a);
|
|
61
|
-
const right = parse(b);
|
|
62
|
-
const length = Math.max(left.length, right.length);
|
|
63
|
-
for (let index = 0; index < length; index += 1) {
|
|
64
|
-
const leftValue = left[index] ?? 0;
|
|
65
|
-
const rightValue = right[index] ?? 0;
|
|
66
|
-
if (leftValue > rightValue)
|
|
67
|
-
return 1;
|
|
68
|
-
if (leftValue < rightValue)
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
function quoteCmdArg(value) {
|
|
74
|
-
if (!/[\s"&()<>^|]/.test(value)) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
return `"${value.replace(/(\\*)"/g, '$1$1\\"')}"`;
|
|
78
|
-
}
|
|
79
|
-
function toPlatformCommand(command, args) {
|
|
80
|
-
if (process.platform !== 'win32') {
|
|
81
|
-
return { command, args };
|
|
82
|
-
}
|
|
83
|
-
const cmdPath = process.env.ComSpec || path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'cmd.exe');
|
|
84
|
-
return {
|
|
85
|
-
command: cmdPath,
|
|
86
|
-
args: ['/d', '/s', '/c', [command, ...args].map(quoteCmdArg).join(' ')],
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
async function execPackageManager(command, args, timeout) {
|
|
90
|
-
const platformCommand = toPlatformCommand(command, args);
|
|
91
|
-
const { stdout } = await execFileAsync(platformCommand.command, platformCommand.args, {
|
|
92
|
-
timeout,
|
|
93
|
-
maxBuffer: 1024 * 1024,
|
|
94
|
-
windowsHide: true,
|
|
95
|
-
});
|
|
96
|
-
return stdout;
|
|
97
|
-
}
|
|
98
|
-
async function getLatestVersion(packageName) {
|
|
99
|
-
try {
|
|
100
|
-
const stdout = await execPackageManager('npm', ['view', packageName, 'version'], 30_000);
|
|
101
|
-
const latest = stdout.trim();
|
|
102
|
-
if (!latest) {
|
|
103
|
-
throw new Error('npm returned an empty version response');
|
|
104
|
-
}
|
|
105
|
-
return latest;
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
-
throw new Error(`Unable to check the latest published version: ${message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function validateTrustedHttpsUrl(value, label) {
|
|
113
|
-
let parsed;
|
|
114
|
-
try {
|
|
115
|
-
parsed = new URL(value);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
throw new Error(`${label} is not a valid URL`);
|
|
119
|
-
}
|
|
120
|
-
if (parsed.protocol !== 'https:' || !TRUSTED_RELEASE_HOSTS.has(parsed.hostname)) {
|
|
121
|
-
throw new Error(`${label} must use HTTPS on an approved Vigthoria release host`);
|
|
122
|
-
}
|
|
123
|
-
return parsed;
|
|
124
|
-
}
|
|
125
|
-
async function getStableRelease() {
|
|
126
|
-
const manifestUrl = process.env.VIGTHORIA_UPDATE_MANIFEST_URL
|
|
127
|
-
|| DEFAULT_UPDATE_MANIFEST;
|
|
128
|
-
validateTrustedHttpsUrl(manifestUrl, 'Update manifest URL');
|
|
129
|
-
const controller = new AbortController();
|
|
130
|
-
const timeout = setTimeout(() => controller.abort(), 20_000);
|
|
131
|
-
try {
|
|
132
|
-
const response = await fetch(manifestUrl, {
|
|
133
|
-
headers: { Accept: 'application/json' },
|
|
134
|
-
redirect: 'follow',
|
|
135
|
-
signal: controller.signal,
|
|
136
|
-
});
|
|
137
|
-
if (!response.ok) {
|
|
138
|
-
throw new Error(`manifest returned HTTP ${response.status}`);
|
|
139
|
-
}
|
|
140
|
-
validateTrustedHttpsUrl(response.url || manifestUrl, 'Resolved manifest URL');
|
|
141
|
-
const document = await response.json();
|
|
142
|
-
const stable = document.channels?.stable;
|
|
143
|
-
const version = String(stable?.version || '').trim();
|
|
144
|
-
const url = String(stable?.url || '').trim();
|
|
145
|
-
const sha256 = String(stable?.sha256 || '').trim().toLowerCase();
|
|
146
|
-
if (!/^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/.test(version)) {
|
|
147
|
-
throw new Error('stable manifest version is invalid');
|
|
148
|
-
}
|
|
149
|
-
validateTrustedHttpsUrl(url, 'Stable release URL');
|
|
150
|
-
if (!/^[a-f0-9]{64}$/.test(sha256)) {
|
|
151
|
-
throw new Error('stable release SHA-256 is missing or invalid');
|
|
152
|
-
}
|
|
153
|
-
return { version, url, sha256 };
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
clearTimeout(timeout);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async function getVersionInfo() {
|
|
160
|
-
const packageJson = readOwnPackageJson();
|
|
161
|
-
const packageName = packageJson.name;
|
|
162
|
-
const current = packageJson.version;
|
|
163
|
-
if (!packageName || !current) {
|
|
164
|
-
throw new Error('The CLI package metadata must include both name and version.');
|
|
165
|
-
}
|
|
166
|
-
let release;
|
|
167
|
-
let latest;
|
|
168
|
-
try {
|
|
169
|
-
release = await getStableRelease();
|
|
170
|
-
latest = release.version;
|
|
171
|
-
}
|
|
172
|
-
catch (manifestError) {
|
|
173
|
-
const reason = manifestError instanceof Error
|
|
174
|
-
? manifestError.message
|
|
175
|
-
: String(manifestError);
|
|
176
|
-
console.warn(`Verified release manifest unavailable (${reason}); checking npm.`);
|
|
177
|
-
latest = await getLatestVersion(packageName);
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
current,
|
|
181
|
-
latest,
|
|
182
|
-
packageName,
|
|
183
|
-
updateAvailable: compareVersions(current, latest) < 0,
|
|
184
|
-
release,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function resolveInstallTargetCommand(packageManager, target, installGlobal) {
|
|
188
|
-
switch (packageManager) {
|
|
189
|
-
case 'pnpm':
|
|
190
|
-
return { command: 'pnpm', args: installGlobal ? ['add', '--global', target] : ['add', '-D', target] };
|
|
191
|
-
case 'yarn':
|
|
192
|
-
return { command: 'yarn', args: installGlobal ? ['global', 'add', target] : ['add', '--dev', target] };
|
|
193
|
-
case 'bun':
|
|
194
|
-
return { command: 'bun', args: installGlobal ? ['add', '--global', target] : ['add', '--dev', target] };
|
|
195
|
-
case 'npm':
|
|
196
|
-
default:
|
|
197
|
-
return { command: 'npm', args: installGlobal ? ['install', '--global', target] : ['install', '--save-dev', target] };
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function resolveInstallCommand(packageManager, packageName, installGlobal) {
|
|
201
|
-
return resolveInstallTargetCommand(packageManager, `${packageName}@latest`, installGlobal);
|
|
202
|
-
}
|
|
203
|
-
function formatCommand(command) {
|
|
204
|
-
return [command.command, ...command.args].map(quoteCmdArg).join(' ');
|
|
205
|
-
}
|
|
206
|
-
async function runInstall(packageManager, packageName, installGlobal) {
|
|
207
|
-
const installCommand = resolveInstallCommand(packageManager, packageName, installGlobal);
|
|
208
|
-
await execPackageManager(installCommand.command, installCommand.args, 120_000);
|
|
209
|
-
}
|
|
210
|
-
async function downloadVerifiedRelease(release) {
|
|
211
|
-
const directory = await mkdtemp(path.join(tmpdir(), 'vigthoria-cli-update-'));
|
|
212
|
-
const archive = path.join(directory, `vigthoria-cli-${release.version}.tgz`);
|
|
213
|
-
try {
|
|
214
|
-
const controller = new AbortController();
|
|
215
|
-
const timeout = setTimeout(() => controller.abort(), 60_000);
|
|
216
|
-
let response;
|
|
217
|
-
try {
|
|
218
|
-
response = await fetch(release.url, {
|
|
219
|
-
redirect: 'follow',
|
|
220
|
-
signal: controller.signal,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
finally {
|
|
224
|
-
clearTimeout(timeout);
|
|
225
|
-
}
|
|
226
|
-
if (!response.ok) {
|
|
227
|
-
throw new Error(`release download returned HTTP ${response.status}`);
|
|
228
|
-
}
|
|
229
|
-
validateTrustedHttpsUrl(response.url || release.url, 'Resolved release URL');
|
|
230
|
-
const bytes = Buffer.from(await response.arrayBuffer());
|
|
231
|
-
const digest = createHash('sha256').update(bytes).digest('hex');
|
|
232
|
-
if (digest !== release.sha256) {
|
|
233
|
-
throw new Error(`release checksum mismatch (expected ${release.sha256}, received ${digest})`);
|
|
234
|
-
}
|
|
235
|
-
await writeFile(archive, bytes, { mode: 0o600 });
|
|
236
|
-
return { directory, archive };
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
await rm(directory, { recursive: true, force: true });
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
export async function updateCommand(options = {}) {
|
|
244
|
-
try {
|
|
245
|
-
const info = await getVersionInfo();
|
|
246
|
-
console.log(`Vigthoria CLI current version: ${info.current}`);
|
|
247
|
-
console.log(`Vigthoria CLI latest version: ${info.latest}`);
|
|
248
|
-
if (!info.updateAvailable) {
|
|
249
|
-
console.log('You are already running the latest Vigthoria CLI.');
|
|
250
|
-
markSuccessExit();
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
console.log(`Update available for ${info.packageName}: ${info.current} → ${info.latest}`);
|
|
254
|
-
if (options.check) {
|
|
255
|
-
markSuccessExit();
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
const packageManager = options.packageManager ?? 'npm';
|
|
259
|
-
const installGlobal = options.global ?? true;
|
|
260
|
-
if (info.release) {
|
|
261
|
-
console.log(`Installing checksum-verified ${info.packageName}@${info.release.version} `
|
|
262
|
-
+ `with ${packageManager}...`);
|
|
263
|
-
const downloaded = await downloadVerifiedRelease(info.release);
|
|
264
|
-
try {
|
|
265
|
-
const installCommand = resolveInstallTargetCommand(packageManager, downloaded.archive, installGlobal);
|
|
266
|
-
await execPackageManager(installCommand.command, installCommand.args, 120_000);
|
|
267
|
-
}
|
|
268
|
-
finally {
|
|
269
|
-
await rm(downloaded.directory, { recursive: true, force: true });
|
|
270
|
-
}
|
|
271
|
-
console.log('Verified release installation finished successfully.');
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
console.log(`Installing ${info.packageName}@latest with ${packageManager}...`);
|
|
275
|
-
await runInstall(packageManager, info.packageName, installGlobal);
|
|
276
|
-
console.log('Package manager installation finished successfully.');
|
|
277
|
-
}
|
|
278
|
-
console.log('Vigthoria CLI update complete.');
|
|
279
|
-
markSuccessExit();
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
283
|
-
console.error(`Update failed: ${message}`);
|
|
284
|
-
markErrorExit();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
export async function update() {
|
|
288
|
-
try {
|
|
289
|
-
await updateCommand();
|
|
290
|
-
if (process.exitCode === 1) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
markSuccessExit();
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
297
|
-
console.error(`Update failed: ${message}`);
|
|
298
|
-
markErrorExit();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
export default updateCommand;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sub-second path: Template Service match → write index.html (skip V3 planner).
|
|
3
|
-
*/
|
|
4
|
-
import type { APIClient } from './api.js';
|
|
5
|
-
export type TemplateInstantResult = {
|
|
6
|
-
ok: boolean;
|
|
7
|
-
entryPath?: string;
|
|
8
|
-
templateName?: string;
|
|
9
|
-
confidence?: number;
|
|
10
|
-
processingMs?: number;
|
|
11
|
-
error?: string;
|
|
12
|
-
usedFallback?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare function runTemplateInstantPath(api: APIClient, vision: string, workspacePath: string, options?: {
|
|
15
|
-
entryPath?: string;
|
|
16
|
-
allowFallback?: boolean;
|
|
17
|
-
forceMinimalFallback?: boolean;
|
|
18
|
-
}): Promise<TemplateInstantResult>;
|