vigthoria-cli 1.13.18 → 1.13.22

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 (185) hide show
  1. package/completions/_vigthoria +49 -0
  2. package/completions/vigthoria.bash +6 -0
  3. package/completions/vigthoria.fish +41 -0
  4. package/dist/commands/auth.d.ts +1 -0
  5. package/dist/commands/auth.js +84 -135
  6. package/dist/commands/background.d.ts +0 -2
  7. package/dist/commands/background.js +26 -34
  8. package/dist/commands/bridge.js +45 -41
  9. package/dist/commands/cancel.d.ts +1 -0
  10. package/dist/commands/cancel.js +22 -16
  11. package/dist/commands/chat.d.ts +5 -42
  12. package/dist/commands/chat.js +462 -1122
  13. package/dist/commands/coding-registration.d.ts +4 -0
  14. package/dist/commands/coding-registration.js +24 -0
  15. package/dist/commands/config.js +32 -42
  16. package/dist/commands/conversation-registration.d.ts +4 -0
  17. package/dist/commands/conversation-registration.js +122 -0
  18. package/dist/commands/deploy.d.ts +8 -2
  19. package/dist/commands/deploy.js +92 -90
  20. package/dist/commands/device.d.ts +1 -2
  21. package/dist/commands/device.js +37 -21
  22. package/dist/commands/doctor-registration.d.ts +4 -0
  23. package/dist/commands/doctor-registration.js +200 -0
  24. package/dist/commands/edit.js +22 -33
  25. package/dist/commands/explain.js +7 -10
  26. package/dist/commands/fork.d.ts +1 -2
  27. package/dist/commands/fork.js +72 -22
  28. package/dist/commands/game.d.ts +1 -1
  29. package/dist/commands/game.js +17 -6
  30. package/dist/commands/generate.js +7 -9
  31. package/dist/commands/history.js +11 -7
  32. package/dist/commands/hub.d.ts +2 -2
  33. package/dist/commands/hub.js +34 -35
  34. package/dist/commands/legion.d.ts +0 -1
  35. package/dist/commands/legion.js +62 -79
  36. package/dist/commands/music.d.ts +1 -2
  37. package/dist/commands/music.js +62 -27
  38. package/dist/commands/platform-registration.d.ts +4 -0
  39. package/dist/commands/platform-registration.js +45 -0
  40. package/dist/commands/preview.d.ts +0 -1
  41. package/dist/commands/preview.js +82 -35
  42. package/dist/commands/product-run-registration.d.ts +4 -0
  43. package/dist/commands/product-run-registration.js +490 -0
  44. package/dist/commands/replay.d.ts +1 -2
  45. package/dist/commands/replay.js +15 -11
  46. package/dist/commands/repo.d.ts +14 -7
  47. package/dist/commands/repo.js +245 -196
  48. package/dist/commands/review.js +9 -12
  49. package/dist/commands/security.d.ts +1 -2
  50. package/dist/commands/security.js +12 -6
  51. package/dist/commands/update-registration.d.ts +3 -0
  52. package/dist/commands/update-registration.js +338 -0
  53. package/dist/commands/v4-registration.d.ts +4 -0
  54. package/dist/commands/v4-registration.js +24 -0
  55. package/dist/commands/v4.d.ts +1 -1
  56. package/dist/commands/v4.js +46 -8
  57. package/dist/commands/wallet.d.ts +1 -3
  58. package/dist/commands/wallet.js +18 -45
  59. package/dist/commands/workflow.d.ts +2 -0
  60. package/dist/commands/workflow.js +52 -39
  61. package/dist/index.js +122 -1498
  62. package/dist/utils/agent-stream-state.d.ts +27 -0
  63. package/dist/utils/agent-stream-state.js +93 -0
  64. package/dist/utils/agentRoute.d.ts +2 -1
  65. package/dist/utils/agentRoute.js +22 -9
  66. package/dist/utils/agentRunOutcome.d.ts +16 -0
  67. package/dist/utils/agentRunOutcome.js +37 -2
  68. package/dist/utils/api-client-factory.d.ts +8 -0
  69. package/dist/utils/api-client-factory.js +8 -0
  70. package/dist/utils/api.d.ts +45 -269
  71. package/dist/utils/api.js +664 -3210
  72. package/dist/utils/auth-session.d.ts +41 -0
  73. package/dist/utils/auth-session.js +224 -0
  74. package/dist/utils/brain-hub-client.d.ts +0 -4
  75. package/dist/utils/brain-hub-client.js +6 -3
  76. package/dist/utils/bridge-client.js +2 -0
  77. package/dist/utils/capability-health-service.d.ts +48 -0
  78. package/dist/utils/capability-health-service.js +64 -0
  79. package/dist/utils/chat-prompt-policy.d.ts +18 -0
  80. package/dist/utils/chat-prompt-policy.js +61 -0
  81. package/dist/utils/chat-tool-call-parser.d.ts +11 -0
  82. package/dist/utils/chat-tool-call-parser.js +71 -0
  83. package/dist/utils/cli-state.d.ts +22 -4
  84. package/dist/utils/cli-state.js +105 -47
  85. package/dist/utils/code-operations-service.d.ts +104 -0
  86. package/dist/utils/code-operations-service.js +837 -0
  87. package/dist/utils/codebase-indexer.d.ts +1 -0
  88. package/dist/utils/codebase-indexer.js +28 -8
  89. package/dist/utils/command-contract.d.ts +61 -0
  90. package/dist/utils/command-contract.js +149 -0
  91. package/dist/utils/command-policy.d.ts +10 -0
  92. package/dist/utils/command-policy.js +54 -0
  93. package/dist/utils/config.d.ts +13 -5
  94. package/dist/utils/config.js +227 -99
  95. package/dist/utils/context-ranker.js +11 -2
  96. package/dist/utils/context-state.d.ts +39 -0
  97. package/dist/utils/context-state.js +52 -0
  98. package/dist/utils/deckEvents.d.ts +0 -5
  99. package/dist/utils/deckEvents.js +3 -2
  100. package/dist/utils/desktop-bridge-client.js +2 -0
  101. package/dist/utils/direct-output-policy.d.ts +3 -0
  102. package/dist/utils/direct-output-policy.js +76 -0
  103. package/dist/utils/durable-json.d.ts +57 -0
  104. package/dist/utils/durable-json.js +319 -0
  105. package/dist/utils/fastAgentRouter.d.ts +6 -7
  106. package/dist/utils/fastAgentRouter.js +21 -30
  107. package/dist/utils/files.js +21 -13
  108. package/dist/utils/frontend-preview-service.d.ts +76 -0
  109. package/dist/utils/frontend-preview-service.js +482 -0
  110. package/dist/utils/goaEvents.d.ts +0 -4
  111. package/dist/utils/goaEvents.js +5 -2
  112. package/dist/utils/logger.d.ts +2 -1
  113. package/dist/utils/logger.js +27 -20
  114. package/dist/utils/mcp-context-client.d.ts +24 -0
  115. package/dist/utils/mcp-context-client.js +58 -0
  116. package/dist/utils/model-governance.d.ts +18 -0
  117. package/dist/utils/model-governance.js +75 -0
  118. package/dist/utils/model-transport-service.d.ts +44 -0
  119. package/dist/utils/model-transport-service.js +111 -0
  120. package/dist/utils/mutation-journal.d.ts +42 -0
  121. package/dist/utils/mutation-journal.js +387 -0
  122. package/dist/utils/network-policy.d.ts +24 -0
  123. package/dist/utils/network-policy.js +202 -0
  124. package/dist/utils/operator-client.d.ts +45 -0
  125. package/dist/utils/operator-client.js +159 -0
  126. package/dist/utils/post-write-validator.js +7 -9
  127. package/dist/utils/preview-screenshot-adapter.d.ts +13 -0
  128. package/dist/utils/preview-screenshot-adapter.js +36 -0
  129. package/dist/utils/process-policy.d.ts +23 -0
  130. package/dist/utils/process-policy.js +284 -0
  131. package/dist/utils/project-memory.d.ts +13 -3
  132. package/dist/utils/project-memory.js +70 -17
  133. package/dist/utils/prompt-workspace-resolver.d.ts +14 -0
  134. package/dist/utils/prompt-workspace-resolver.js +64 -0
  135. package/dist/utils/release-install.d.ts +11 -0
  136. package/dist/utils/release-install.js +155 -0
  137. package/dist/utils/release-policy.d.ts +64 -0
  138. package/dist/utils/release-policy.js +293 -0
  139. package/dist/utils/requestIntent.js +22 -3
  140. package/dist/utils/runtime-capability.d.ts +8 -0
  141. package/dist/utils/runtime-capability.js +16 -0
  142. package/dist/utils/secret-policy.d.ts +20 -0
  143. package/dist/utils/secret-policy.js +160 -0
  144. package/dist/utils/session.d.ts +34 -2
  145. package/dist/utils/session.js +354 -110
  146. package/dist/utils/tool-approval-service.d.ts +17 -0
  147. package/dist/utils/tool-approval-service.js +78 -0
  148. package/dist/utils/tool-capability-providers.d.ts +57 -0
  149. package/dist/utils/tool-capability-providers.js +57 -0
  150. package/dist/utils/tools.d.ts +2 -23
  151. package/dist/utils/tools.js +216 -508
  152. package/dist/utils/update-policy.d.ts +18 -0
  153. package/dist/utils/update-policy.js +137 -0
  154. package/dist/utils/v3-agent-client.d.ts +40 -0
  155. package/dist/utils/v3-agent-client.js +165 -0
  156. package/dist/utils/v3-workspace-service.d.ts +28 -0
  157. package/dist/utils/v3-workspace-service.js +279 -0
  158. package/dist/utils/vigflow-client.d.ts +95 -0
  159. package/dist/utils/vigflow-client.js +105 -0
  160. package/dist/utils/workspace-boundary.d.ts +45 -0
  161. package/dist/utils/workspace-boundary.js +377 -0
  162. package/dist/utils/workspace-brain-service.d.ts +2 -0
  163. package/dist/utils/workspace-brain-service.js +11 -1
  164. package/dist/utils/workspace-cache.js +37 -15
  165. package/dist/utils/workspace-stream.js +35 -10
  166. package/install.ps1 +86 -143
  167. package/install.sh +76 -81
  168. package/package.json +44 -9
  169. package/release-policy.json +43 -0
  170. package/scripts/release/LOCAL_MACHINE_USER_VERIFICATION.md +1 -1
  171. package/scripts/release/generate-completions.mjs +24 -0
  172. package/scripts/release/install-release.mjs +10 -0
  173. package/scripts/release/publish-cli-release.mjs +116 -0
  174. package/scripts/release/publish-cli-release.sh +2 -70
  175. package/scripts/release/resolve-release-manifest.mjs +26 -0
  176. package/scripts/release/test-balanced-model-live.sh +42 -0
  177. package/scripts/release/validate-live-service-gates.sh +90 -0
  178. package/scripts/release/validate-no-go-gates.sh +135 -172
  179. package/scripts/release/verify-runtime-consistency.mjs +4 -1
  180. package/dist/commands/index.d.ts +0 -12
  181. package/dist/commands/index.js +0 -194
  182. package/dist/commands/update.d.ts +0 -9
  183. package/dist/commands/update.js +0 -301
  184. package/dist/utils/templateInstantPath.d.ts +0 -18
  185. package/dist/utils/templateInstantPath.js +0 -228
@@ -42,6 +42,7 @@ export declare class CodebaseIndexer {
42
42
  static metaPath(workspaceRoot: string): string;
43
43
  static loadMeta(workspaceRoot: string): IndexMeta | null;
44
44
  private saveMeta;
45
+ private static metaStore;
45
46
  hasLocalIndex(): boolean;
46
47
  countCandidateFiles(): number;
47
48
  countIndexableFiles(): number;
@@ -4,6 +4,8 @@
4
4
  import * as crypto from 'crypto';
5
5
  import * as fs from 'fs';
6
6
  import * as path from 'path';
7
+ import { containsHighConfidenceSecret, isSensitivePath } from './secret-policy.js';
8
+ import { DurableJsonStore } from './durable-json.js';
7
9
  export class CodebaseIndexer {
8
10
  workspaceRoot;
9
11
  index = new Map();
@@ -32,7 +34,7 @@ export class CodebaseIndexer {
32
34
  '.html', '.css', '.scss', '.less', '.sass',
33
35
  '.json', '.yaml', '.yml', '.toml', '.xml',
34
36
  '.md', '.txt', '.rst', '.sh', '.bash', '.zsh',
35
- '.sql', '.graphql', '.prisma', '.env',
37
+ '.sql', '.graphql', '.prisma',
36
38
  '.dockerfile', '.tf', '.hcl',
37
39
  ]);
38
40
  constructor(workspaceRoot) {
@@ -51,9 +53,7 @@ export class CodebaseIndexer {
51
53
  static loadMeta(workspaceRoot) {
52
54
  try {
53
55
  const metaPath = CodebaseIndexer.metaPath(workspaceRoot);
54
- if (fs.existsSync(metaPath)) {
55
- return JSON.parse(fs.readFileSync(metaPath, 'utf8'));
56
- }
56
+ return CodebaseIndexer.metaStore(metaPath).read();
57
57
  }
58
58
  catch {
59
59
  // fresh workspace
@@ -62,8 +62,24 @@ export class CodebaseIndexer {
62
62
  }
63
63
  saveMeta(meta) {
64
64
  const dir = path.join(this.workspaceRoot, '.vigthoria', 'index');
65
- fs.mkdirSync(dir, { recursive: true });
66
- fs.writeFileSync(CodebaseIndexer.metaPath(this.workspaceRoot), `${JSON.stringify(meta, null, 2)}\n`);
65
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
66
+ const metaPath = CodebaseIndexer.metaPath(this.workspaceRoot);
67
+ CodebaseIndexer.metaStore(metaPath).write(meta);
68
+ }
69
+ static metaStore(metaPath) {
70
+ const isMeta = (value) => value === null || Boolean(value && typeof value === 'object'
71
+ && typeof value.indexedFileCount === 'number'
72
+ && typeof value.totalChunks === 'number'
73
+ && typeof value.indexHash === 'string'
74
+ && Array.isArray(value.topFiles)
75
+ && typeof value.indexedAt === 'string');
76
+ return new DurableJsonStore({
77
+ filePath: metaPath,
78
+ schemaVersion: 1,
79
+ defaultValue: () => null,
80
+ validate: isMeta,
81
+ migrate: (value) => isMeta(value) ? value : null,
82
+ });
67
83
  }
68
84
  hasLocalIndex() {
69
85
  const meta = CodebaseIndexer.loadMeta(this.workspaceRoot);
@@ -114,7 +130,7 @@ export class CodebaseIndexer {
114
130
  }
115
131
  // Empty workspaces still receive a deterministic, valid SHA-256 value.
116
132
  const indexHash = contentHasher.digest('hex');
117
- const topFiles = files.slice(0, 12).map((filePath) => path.relative(this.workspaceRoot, filePath));
133
+ const topFiles = contentEntries.slice(0, 12).map(([relativePath]) => relativePath);
118
134
  const meta = {
119
135
  indexedFileCount: this.indexedFileCount,
120
136
  totalChunks: this.totalChunks,
@@ -239,6 +255,8 @@ export class CodebaseIndexer {
239
255
  if (!stat.isFile() || stat.size > this.maxFileSize || stat.size === 0)
240
256
  return;
241
257
  const content = fs.readFileSync(filePath, 'utf8');
258
+ if (containsHighConfidenceSecret(content))
259
+ return;
242
260
  const hash = crypto.createHash('md5').update(content).digest('hex');
243
261
  if (this.fileHashes.get(filePath) === hash)
244
262
  return;
@@ -320,9 +338,11 @@ export class CodebaseIndexer {
320
338
  return map[ext] || 'text';
321
339
  }
322
340
  shouldIgnore(name, fullPath) {
323
- if (name.startsWith('.') && name !== '.env')
341
+ if (name.startsWith('.'))
324
342
  return true;
325
343
  const relativePath = path.relative(this.workspaceRoot, fullPath);
344
+ if (isSensitivePath(relativePath))
345
+ return true;
326
346
  const segments = relativePath.split(path.sep).map((segment) => segment.toLowerCase());
327
347
  const fileName = segments.at(-1) || '';
328
348
  const suffixPatterns = new Set(['.vsix', '.map', '.min.js', '.min.css']);
@@ -0,0 +1,61 @@
1
+ export type CliErrorCategory = 'usage' | 'configuration' | 'authentication' | 'authorization' | 'network' | 'execution' | 'partial_mutation' | 'cancelled' | 'internal';
2
+ export declare const CLI_EXIT: {
3
+ readonly success: 0;
4
+ readonly failure: 1;
5
+ readonly usage: 2;
6
+ readonly partialMutation: 3;
7
+ readonly cancelled: 130;
8
+ };
9
+ export interface NormalizedCliError {
10
+ code: string;
11
+ category: CliErrorCategory;
12
+ message: string;
13
+ exitCode: number;
14
+ status?: number;
15
+ details?: unknown;
16
+ partialMutation: boolean | 'unknown';
17
+ }
18
+ export interface CliJsonEnvelope<T = unknown> {
19
+ success: boolean;
20
+ command: string;
21
+ data: T | null;
22
+ error: null | {
23
+ code: string;
24
+ category: CliErrorCategory;
25
+ message: string;
26
+ details?: unknown;
27
+ };
28
+ warnings: string[];
29
+ metadata: Record<string, unknown>;
30
+ partialMutation: boolean | 'unknown';
31
+ }
32
+ export declare class CliCommandError extends Error {
33
+ readonly code: string;
34
+ readonly category: CliErrorCategory;
35
+ readonly exitCode: number;
36
+ readonly status?: number;
37
+ readonly details?: unknown;
38
+ readonly partialMutation: boolean | 'unknown';
39
+ constructor(message: string, options?: {
40
+ code?: string;
41
+ category?: CliErrorCategory;
42
+ exitCode?: number;
43
+ status?: number;
44
+ details?: unknown;
45
+ partialMutation?: boolean | 'unknown';
46
+ cause?: unknown;
47
+ });
48
+ }
49
+ export declare function commandFailure(error: unknown, options: {
50
+ code: string;
51
+ category?: CliErrorCategory;
52
+ message?: string;
53
+ details?: unknown;
54
+ partialMutation?: boolean | 'unknown';
55
+ }): CliCommandError;
56
+ export declare function exitCodeForCategory(category: CliErrorCategory): number;
57
+ export declare function normalizeCommandError(error: unknown, sanitizeMessage?: (message: string) => string): NormalizedCliError;
58
+ export declare function commandNameFromArgv(argv: readonly string[]): string;
59
+ export declare function failureEnvelope(command: string, error: NormalizedCliError): CliJsonEnvelope;
60
+ export declare function successEnvelope<T>(command: string, data: T, metadata?: Record<string, unknown>, warnings?: string[]): CliJsonEnvelope<T>;
61
+ export declare function formatSuccessJson<T>(command: string, data: T, metadata?: Record<string, unknown>, warnings?: string[]): string;
@@ -0,0 +1,149 @@
1
+ import { redactSensitiveText, redactSensitiveValue } from './secret-policy.js';
2
+ export const CLI_EXIT = {
3
+ success: 0,
4
+ failure: 1,
5
+ usage: 2,
6
+ partialMutation: 3,
7
+ cancelled: 130,
8
+ };
9
+ export class CliCommandError extends Error {
10
+ code;
11
+ category;
12
+ exitCode;
13
+ status;
14
+ details;
15
+ partialMutation;
16
+ constructor(message, options = {}) {
17
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
18
+ this.name = 'CliCommandError';
19
+ this.code = options.code || 'CLI_EXECUTION_FAILED';
20
+ this.category = options.category || 'execution';
21
+ this.exitCode = options.exitCode ?? exitCodeForCategory(this.category);
22
+ this.status = options.status;
23
+ this.details = options.details;
24
+ this.partialMutation = options.partialMutation ?? false;
25
+ }
26
+ }
27
+ export function commandFailure(error, options) {
28
+ if (error instanceof CliCommandError)
29
+ return error;
30
+ const normalized = normalizeCommandError(error);
31
+ return new CliCommandError(options.message || normalized.message, {
32
+ code: options.code,
33
+ category: options.category || normalized.category,
34
+ status: normalized.status,
35
+ details: options.details ?? normalized.details,
36
+ partialMutation: options.partialMutation ?? normalized.partialMutation,
37
+ cause: error,
38
+ });
39
+ }
40
+ export function exitCodeForCategory(category) {
41
+ if (category === 'usage' || category === 'configuration')
42
+ return CLI_EXIT.usage;
43
+ if (category === 'partial_mutation')
44
+ return CLI_EXIT.partialMutation;
45
+ if (category === 'cancelled')
46
+ return CLI_EXIT.cancelled;
47
+ return CLI_EXIT.failure;
48
+ }
49
+ function inferCategory(code, status) {
50
+ const normalized = code.toLowerCase();
51
+ if (normalized.startsWith('commander.') || /usage|invalid_(?:argument|option|command)/.test(normalized))
52
+ return 'usage';
53
+ if (/config|endpoint/.test(normalized))
54
+ return 'configuration';
55
+ if (status === 401 || /auth(?:entication)?|token/.test(normalized))
56
+ return 'authentication';
57
+ if (status === 403 || /authorization|forbidden|permission/.test(normalized))
58
+ return 'authorization';
59
+ if (/offline|network|timeout|untrusted_endpoint|unsafe_redirect|credential_audience/.test(normalized))
60
+ return 'network';
61
+ if (/partial/.test(normalized))
62
+ return 'partial_mutation';
63
+ if (/cancel/.test(normalized))
64
+ return 'cancelled';
65
+ return 'execution';
66
+ }
67
+ export function normalizeCommandError(error, sanitizeMessage = redactSensitiveText) {
68
+ if (error instanceof CliCommandError) {
69
+ return {
70
+ code: error.code,
71
+ category: error.category,
72
+ message: sanitizeMessage(error.message),
73
+ exitCode: error.exitCode,
74
+ status: error.status,
75
+ details: redactSensitiveValue(error.details),
76
+ partialMutation: error.partialMutation,
77
+ };
78
+ }
79
+ const value = error && typeof error === 'object' ? error : {};
80
+ const response = value.response && typeof value.response === 'object' ? value.response : {};
81
+ const responseData = response.data && typeof response.data === 'object' ? response.data : {};
82
+ const rawCode = value.code;
83
+ const code = typeof rawCode === 'string' && rawCode.trim() ? rawCode : 'CLI_EXECUTION_FAILED';
84
+ const statusCandidate = value.status ?? value.statusCode ?? response.status;
85
+ const status = typeof statusCandidate === 'number' ? statusCandidate : undefined;
86
+ const responseMessage = typeof responseData.error === 'string'
87
+ ? responseData.error
88
+ : typeof responseData.message === 'string' ? responseData.message : undefined;
89
+ const rawMessage = responseMessage
90
+ || (error instanceof Error
91
+ ? error.message
92
+ : typeof error === 'string'
93
+ ? error
94
+ : typeof value.message === 'string'
95
+ ? value.message
96
+ : '')
97
+ || 'An unexpected CLI error occurred.';
98
+ const partialMutation = value.partialMutation === true || value.partialMutation === 'unknown'
99
+ ? value.partialMutation
100
+ : false;
101
+ const category = partialMutation === true || partialMutation === 'unknown'
102
+ ? 'partial_mutation'
103
+ : inferCategory(code, status);
104
+ return {
105
+ code,
106
+ category,
107
+ message: sanitizeMessage(rawMessage),
108
+ // Only CliCommandError may override the public exit contract. Foreign
109
+ // errors (including Commander's historical exitCode=1 usage errors) are
110
+ // classified here so implementation details cannot leak into the shell API.
111
+ exitCode: exitCodeForCategory(category),
112
+ status,
113
+ details: redactSensitiveValue(value.details ?? response.data),
114
+ partialMutation: partialMutation || category === 'partial_mutation',
115
+ };
116
+ }
117
+ export function commandNameFromArgv(argv) {
118
+ return argv.slice(2).find((entry) => !entry.startsWith('-')) || 'vigthoria';
119
+ }
120
+ export function failureEnvelope(command, error) {
121
+ return {
122
+ success: false,
123
+ command,
124
+ data: null,
125
+ error: {
126
+ code: error.code,
127
+ category: error.category,
128
+ message: error.message,
129
+ ...(error.details === undefined ? {} : { details: error.details }),
130
+ },
131
+ warnings: [],
132
+ metadata: error.status === undefined ? {} : { httpStatus: error.status },
133
+ partialMutation: error.partialMutation,
134
+ };
135
+ }
136
+ export function successEnvelope(command, data, metadata = {}, warnings = []) {
137
+ return {
138
+ success: true,
139
+ command,
140
+ data,
141
+ error: null,
142
+ warnings,
143
+ metadata,
144
+ partialMutation: false,
145
+ };
146
+ }
147
+ export function formatSuccessJson(command, data, metadata = {}, warnings = []) {
148
+ return JSON.stringify(successEnvelope(command, data, metadata, warnings), null, 2);
149
+ }
@@ -0,0 +1,10 @@
1
+ export type CommandAuthRequirement = 'none' | 'optional-session' | 'required-session';
2
+ export declare const KNOWN_COMMAND_AUTH_PATHS: Set<string>;
3
+ export declare function commandAuthRequirement(commandPath: string): CommandAuthRequirement;
4
+ export declare function commanderCommandPath(command: {
5
+ name(): string;
6
+ parent?: {
7
+ name(): string;
8
+ parent?: unknown;
9
+ } | null;
10
+ }): string;
@@ -0,0 +1,54 @@
1
+ const REQUIRED_SESSION_PATHS = new Set([
2
+ 'chat', 'chat-resume', 'agent', 'operator',
3
+ 'edit', 'generate', 'explain', 'fix', 'review',
4
+ 'workflow templates', 'workflow list', 'workflow use-template', 'workflow run', 'workflow status',
5
+ 'hub activate', 'hub active',
6
+ 'repo push', 'repo review', 'repo pull', 'repo list', 'repo status', 'repo share', 'repo delete', 'repo open-in',
7
+ 'background start', 'background list', 'background status', 'background apply', 'background cancel', 'background approve',
8
+ 'deploy', 'deploy preview', 'deploy subdomain', 'deploy custom', 'deploy list', 'deploy status', 'deploy verify', 'deploy remove',
9
+ 'history', 'replay', 'fork', 'cancel',
10
+ ]);
11
+ const OPTIONAL_SESSION_PATHS = new Set([
12
+ 'legion',
13
+ ]);
14
+ const NO_SESSION_PATHS = new Set([
15
+ 'v4', 'v4-menu', 'bridge', 'bridge status',
16
+ 'device', 'device status', 'device list', 'device screenshot', 'device install', 'device launch', 'device logs', 'device tcpip', 'device connect', 'device disconnect',
17
+ 'security', 'security scan', 'security score', 'security fix',
18
+ 'workflow',
19
+ 'hub', 'hub discover', 'hub list', 'hub search', 'hub info',
20
+ 'music', 'music generate', 'music status',
21
+ 'repo', 'repo clone',
22
+ 'background',
23
+ 'deploy plans', 'preview',
24
+ 'game', 'game init', 'game run', 'game validate',
25
+ 'login', 'logout', 'status', 'auth', 'auth login', 'auth logout', 'auth whoami',
26
+ 'wallet', 'wallet balance', 'wallet history', 'wallet cloud-status',
27
+ 'doctor', 'config', 'update',
28
+ 'hyper-loop', 'hyper-loop status', 'devtools', 'devtools status',
29
+ 'init', 'menu', 'commands',
30
+ ]);
31
+ export const KNOWN_COMMAND_AUTH_PATHS = new Set([
32
+ ...REQUIRED_SESSION_PATHS,
33
+ ...OPTIONAL_SESSION_PATHS,
34
+ ...NO_SESSION_PATHS,
35
+ ]);
36
+ export function commandAuthRequirement(commandPath) {
37
+ const normalized = String(commandPath || '').trim().replace(/\s+/g, ' ');
38
+ if (REQUIRED_SESSION_PATHS.has(normalized))
39
+ return 'required-session';
40
+ if (OPTIONAL_SESSION_PATHS.has(normalized))
41
+ return 'optional-session';
42
+ if (NO_SESSION_PATHS.has(normalized))
43
+ return 'none';
44
+ throw new Error(`Missing authentication policy for command path: ${normalized || '<empty>'}`);
45
+ }
46
+ export function commanderCommandPath(command) {
47
+ const parts = [];
48
+ let current = command;
49
+ while (current?.parent) {
50
+ parts.unshift(current.name());
51
+ current = current.parent;
52
+ }
53
+ return parts.join(' ');
54
+ }
@@ -42,20 +42,26 @@ export interface AvailableModelDescriptor {
42
42
  tier: string;
43
43
  backendModel: string;
44
44
  }
45
+ export interface ConfigOptions {
46
+ stateRoot?: string;
47
+ legacyConfPath?: string;
48
+ }
45
49
  export declare class Config {
46
50
  private store;
47
51
  private static readonly OPERATOR_PLANS;
48
- private static readonly CLOUD_PLANS;
49
- constructor();
52
+ constructor(options?: ConfigOptions);
53
+ private retireLegacyConfStore;
50
54
  /**
51
55
  * Re-apply secure POSIX permissions to the on-disk config file. Safe
52
56
  * to call repeatedly; no-op on Windows.
53
57
  */
54
58
  secureOnDisk(): void;
59
+ private validateEndpointValue;
55
60
  get<K extends keyof VigthoriaCLIConfig>(key: K): VigthoriaCLIConfig[K];
56
61
  set<K extends keyof VigthoriaCLIConfig>(key: K, value: VigthoriaCLIConfig[K]): void;
57
62
  getAll(): VigthoriaCLIConfig;
58
63
  reset(): void;
64
+ resetPreservingAuth(): void;
59
65
  isAuthenticated(): boolean;
60
66
  hasValidSubscription(): boolean;
61
67
  getNormalizedPlan(): string;
@@ -64,9 +70,11 @@ export declare class Config {
64
70
  getConfigPath(): string;
65
71
  setAuth(data: {
66
72
  token: string;
67
- refreshToken?: string;
68
- userId: string;
69
- email: string;
73
+ refreshToken?: string | null;
74
+ userId?: string | null;
75
+ email?: string | null;
76
+ apiUrl?: string;
77
+ v3ServiceKey?: string | null;
70
78
  }): void;
71
79
  clearAuth(): void;
72
80
  setSubscription(data: {