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.
- 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 +84 -135
- 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 +5 -42
- package/dist/commands/chat.js +462 -1122
- package/dist/commands/coding-registration.d.ts +4 -0
- package/dist/commands/coding-registration.js +24 -0
- package/dist/commands/config.js +32 -42
- 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 +200 -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 +245 -196
- 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 +338 -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 +122 -1498
- 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 +45 -269
- package/dist/utils/api.js +664 -3210
- 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 +227 -99
- 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 +6 -7
- package/dist/utils/fastAgentRouter.js +21 -30
- 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 +13 -0
- package/dist/utils/preview-screenshot-adapter.js +36 -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/secret-policy.d.ts +20 -0
- package/dist/utils/secret-policy.js +160 -0
- package/dist/utils/session.d.ts +34 -2
- 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 +216 -508
- 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 +86 -143
- package/install.sh +76 -81
- package/package.json +44 -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 +42 -0
- package/scripts/release/validate-live-service-gates.sh +90 -0
- package/scripts/release/validate-no-go-gates.sh +135 -172
- 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/utils/cli-state.js
CHANGED
|
@@ -14,28 +14,50 @@
|
|
|
14
14
|
import * as fs from 'fs';
|
|
15
15
|
import * as os from 'os';
|
|
16
16
|
import * as path from 'path';
|
|
17
|
+
import { createHash, randomUUID } from 'crypto';
|
|
18
|
+
import { DurableJsonStore } from './durable-json.js';
|
|
17
19
|
const STATE_DIR = path.join(os.homedir(), '.vigthoria');
|
|
18
20
|
const STATE_FILE = path.join(STATE_DIR, 'cli-state.json');
|
|
19
21
|
/** 24h is plenty for an update-check ping. */
|
|
20
22
|
export const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
21
23
|
/** 60s gateway-preflight cache so back-to-back CLI invocations stay fast. */
|
|
22
24
|
export const GATEWAY_PREFLIGHT_TTL_MS = 60 * 1000;
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
function isCliState(value) {
|
|
26
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
27
|
+
return false;
|
|
28
|
+
const state = value;
|
|
29
|
+
if (state.updateCheck !== undefined && (!state.updateCheck || typeof state.updateCheck.checkedAt !== 'number' || typeof state.updateCheck.latestVersion !== 'string'))
|
|
30
|
+
return false;
|
|
31
|
+
if (state.lastSeenVersion !== undefined && typeof state.lastSeenVersion !== 'string')
|
|
32
|
+
return false;
|
|
33
|
+
if (state.gatewayPreflight !== undefined && (!state.gatewayPreflight || typeof state.gatewayPreflight !== 'object' || Array.isArray(state.gatewayPreflight)))
|
|
34
|
+
return false;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const stateStore = new DurableJsonStore({
|
|
38
|
+
filePath: STATE_FILE,
|
|
39
|
+
schemaVersion: 2,
|
|
40
|
+
defaultValue: () => ({}),
|
|
41
|
+
validate: isCliState,
|
|
42
|
+
migrate: (value) => {
|
|
43
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
30
44
|
return {};
|
|
45
|
+
const legacy = value;
|
|
46
|
+
// A legacy preflight boolean has no credential, endpoint, or capability
|
|
47
|
+
// audience and is intentionally invalidated during migration.
|
|
48
|
+
const migrated = {};
|
|
49
|
+
if (legacy.updateCheck && typeof legacy.updateCheck === 'object') {
|
|
50
|
+
const entry = legacy.updateCheck;
|
|
51
|
+
if (entry && typeof entry.checkedAt === 'number' && typeof entry.latestVersion === 'string')
|
|
52
|
+
migrated.updateCheck = entry;
|
|
31
53
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
if (typeof legacy.lastSeenVersion === 'string')
|
|
55
|
+
migrated.lastSeenVersion = legacy.lastSeenVersion;
|
|
56
|
+
return migrated;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
function readStateUnchecked() {
|
|
60
|
+
return stateStore.read();
|
|
39
61
|
}
|
|
40
62
|
export function ensureStateDir() {
|
|
41
63
|
try {
|
|
@@ -74,8 +96,15 @@ export function atomicWriteJson(targetPath, value, mode = 0o600) {
|
|
|
74
96
|
fs.mkdirSync(parent, { recursive: true });
|
|
75
97
|
}
|
|
76
98
|
catch { /* ignore */ }
|
|
77
|
-
const tmpPath = `${targetPath}.${process.pid}.${
|
|
78
|
-
fs.
|
|
99
|
+
const tmpPath = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
100
|
+
const descriptor = fs.openSync(tmpPath, 'wx', mode);
|
|
101
|
+
try {
|
|
102
|
+
fs.writeFileSync(descriptor, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
103
|
+
fs.fsyncSync(descriptor);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
fs.closeSync(descriptor);
|
|
107
|
+
}
|
|
79
108
|
if (process.platform !== 'win32') {
|
|
80
109
|
try {
|
|
81
110
|
fs.chmodSync(tmpPath, mode);
|
|
@@ -88,7 +117,7 @@ export function loadCliState() {
|
|
|
88
117
|
return readStateUnchecked();
|
|
89
118
|
}
|
|
90
119
|
export function saveCliState(state) {
|
|
91
|
-
|
|
120
|
+
stateStore.write(state);
|
|
92
121
|
}
|
|
93
122
|
export function getCliStateFile() {
|
|
94
123
|
return STATE_FILE;
|
|
@@ -129,39 +158,73 @@ export function readCachedLatestVersion(maxAgeMs = UPDATE_CHECK_TTL_MS) {
|
|
|
129
158
|
return entry.latestVersion;
|
|
130
159
|
}
|
|
131
160
|
export function writeCachedLatestVersion(latestVersion, notifiedFor) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
161
|
+
stateStore.update((state) => ({
|
|
162
|
+
...state,
|
|
163
|
+
updateCheck: {
|
|
135
164
|
checkedAt: Date.now(),
|
|
136
165
|
latestVersion,
|
|
137
166
|
notifiedFor: notifiedFor || state.updateCheck?.notifiedFor,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
167
|
+
},
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
function normalizeEndpoint(endpoint) {
|
|
171
|
+
const parsed = new URL(String(endpoint));
|
|
172
|
+
parsed.hash = '';
|
|
173
|
+
parsed.search = '';
|
|
174
|
+
parsed.hostname = parsed.hostname.toLowerCase();
|
|
175
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, '') || '/';
|
|
176
|
+
return parsed.toString().replace(/\/$/, '');
|
|
144
177
|
}
|
|
145
|
-
|
|
178
|
+
function fingerprint(value) {
|
|
179
|
+
const serialized = typeof value === 'string' ? value : JSON.stringify(value ?? null);
|
|
180
|
+
return createHash('sha256').update(serialized).digest('hex');
|
|
181
|
+
}
|
|
182
|
+
export function createGatewayPreflightCacheKey(input) {
|
|
183
|
+
const endpoint = normalizeEndpoint(input.endpoint);
|
|
184
|
+
const credentialFingerprint = fingerprint(String(input.credential || ''));
|
|
185
|
+
const capability = String(input.capability || '').trim().toLowerCase();
|
|
186
|
+
if (!capability)
|
|
187
|
+
throw new Error('Gateway preflight capability is required.');
|
|
188
|
+
const configurationFingerprint = fingerprint(input.relevantConfiguration ?? null);
|
|
189
|
+
return {
|
|
190
|
+
id: fingerprint({ endpoint, credentialFingerprint, capability, configurationFingerprint }),
|
|
191
|
+
endpoint,
|
|
192
|
+
credentialFingerprint,
|
|
193
|
+
capability,
|
|
194
|
+
configurationFingerprint,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function readGatewayPreflightCache(key, maxAgeMs = GATEWAY_PREFLIGHT_TTL_MS) {
|
|
146
198
|
const state = readStateUnchecked();
|
|
147
|
-
const entry = state.gatewayPreflight;
|
|
199
|
+
const entry = state.gatewayPreflight?.[key.id];
|
|
148
200
|
if (!entry || typeof entry.checkedAt !== 'number' || typeof entry.valid !== 'boolean') {
|
|
149
201
|
return null;
|
|
150
202
|
}
|
|
203
|
+
if (entry.endpoint !== key.endpoint
|
|
204
|
+
|| entry.credentialFingerprint !== key.credentialFingerprint
|
|
205
|
+
|| entry.capability !== key.capability
|
|
206
|
+
|| entry.configurationFingerprint !== key.configurationFingerprint)
|
|
207
|
+
return null;
|
|
151
208
|
if (Date.now() - entry.checkedAt > maxAgeMs) {
|
|
152
209
|
return null;
|
|
153
210
|
}
|
|
154
211
|
return entry.valid;
|
|
155
212
|
}
|
|
156
|
-
export function writeGatewayPreflightCache(valid) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
213
|
+
export function writeGatewayPreflightCache(key, valid) {
|
|
214
|
+
stateStore.update((state) => ({
|
|
215
|
+
...state,
|
|
216
|
+
gatewayPreflight: {
|
|
217
|
+
...(state.gatewayPreflight || {}),
|
|
218
|
+
[key.id]: {
|
|
219
|
+
checkedAt: Date.now(),
|
|
220
|
+
valid,
|
|
221
|
+
endpoint: key.endpoint,
|
|
222
|
+
credentialFingerprint: key.credentialFingerprint,
|
|
223
|
+
capability: key.capability,
|
|
224
|
+
configurationFingerprint: key.configurationFingerprint,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
}));
|
|
165
228
|
}
|
|
166
229
|
/**
|
|
167
230
|
* Invalidate any cached gateway-preflight result. Must be called on
|
|
@@ -170,16 +233,11 @@ export function writeGatewayPreflightCache(valid) {
|
|
|
170
233
|
* command run right after a fresh, successful login.
|
|
171
234
|
*/
|
|
172
235
|
export function clearGatewayPreflightCache() {
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
// Best-effort.
|
|
182
|
-
}
|
|
236
|
+
stateStore.update((state) => {
|
|
237
|
+
const next = { ...state };
|
|
238
|
+
delete next.gatewayPreflight;
|
|
239
|
+
return next;
|
|
240
|
+
});
|
|
183
241
|
}
|
|
184
242
|
/**
|
|
185
243
|
* Validate an npm package spec used by `vigthoria update --from <spec>`.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export type CodeCompletionPort = (systemPrompt: string, userPrompt: string, model?: string, maxTokens?: number) => Promise<string>;
|
|
2
|
+
export declare class CodeOperationsService {
|
|
3
|
+
private readonly complete;
|
|
4
|
+
constructor(complete: CodeCompletionPort);
|
|
5
|
+
private chatComplete;
|
|
6
|
+
generateCode(prompt: string, language: string, model: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Ensure code has balanced curly braces by appending missing closing braces.
|
|
9
|
+
*/
|
|
10
|
+
private ensureBalancedBraces;
|
|
11
|
+
/**
|
|
12
|
+
* Quick JS/TS syntax validation using Node's built-in parser.
|
|
13
|
+
* Returns true if the code parses without errors.
|
|
14
|
+
*/
|
|
15
|
+
private validateJsSyntax;
|
|
16
|
+
/**
|
|
17
|
+
* Extract the first complete function/class from code.
|
|
18
|
+
* Used as last-resort when the model keeps over-producing.
|
|
19
|
+
*/
|
|
20
|
+
private extractFirstFunction;
|
|
21
|
+
/**
|
|
22
|
+
* Detect if code is excessively over-engineered for a short prompt.
|
|
23
|
+
* E.g. a "multiply function" request producing 20+ lines.
|
|
24
|
+
*/
|
|
25
|
+
private codeIsOverEngineered;
|
|
26
|
+
/**
|
|
27
|
+
* Detect if generated code contains DOM/HTML pollution inappropriate
|
|
28
|
+
* for a pure programming language like JavaScript, Python, etc.
|
|
29
|
+
*/
|
|
30
|
+
private codeContainsDomPollution;
|
|
31
|
+
/**
|
|
32
|
+
* Strip DOM pollution from generated code, keeping only the pure logic.
|
|
33
|
+
* Used as last-resort fallback when the model repeatedly ignores constraints.
|
|
34
|
+
*/
|
|
35
|
+
private stripDomPollution;
|
|
36
|
+
generateProject(prompt: string, projectType: string, model: string): Promise<{
|
|
37
|
+
code: string;
|
|
38
|
+
plan?: any;
|
|
39
|
+
quality?: {
|
|
40
|
+
lineCount: number;
|
|
41
|
+
score: number;
|
|
42
|
+
checks: {
|
|
43
|
+
hasAnimations: boolean;
|
|
44
|
+
hasNeonEffects: boolean;
|
|
45
|
+
hasResponsive: boolean;
|
|
46
|
+
hasFontAwesome: boolean;
|
|
47
|
+
hasGoogleFonts: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
explainCode(code: string, language: string): Promise<string>;
|
|
52
|
+
reviewCode(code: string, language: string): Promise<{
|
|
53
|
+
score: number;
|
|
54
|
+
issues: {
|
|
55
|
+
type: string;
|
|
56
|
+
line: number;
|
|
57
|
+
message: string;
|
|
58
|
+
severity: string;
|
|
59
|
+
}[];
|
|
60
|
+
suggestions: string[];
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Lightweight client-side heuristic scan: catches common code smells
|
|
64
|
+
* AND logic/arithmetic bugs so review never returns "score 30, no issues".
|
|
65
|
+
*/
|
|
66
|
+
heuristicCodeIssues(code: string, _language: string): {
|
|
67
|
+
type: string;
|
|
68
|
+
line: number;
|
|
69
|
+
message: string;
|
|
70
|
+
severity: string;
|
|
71
|
+
}[];
|
|
72
|
+
fixCode(code: string, language: string, fixType: string): Promise<{
|
|
73
|
+
fixed: string;
|
|
74
|
+
changes: {
|
|
75
|
+
line: number;
|
|
76
|
+
before: string;
|
|
77
|
+
after: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
}[];
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Compute a semantic diff between original and fixed code using
|
|
83
|
+
* Longest Common Subsequence (LCS) to avoid the line-shift inflation
|
|
84
|
+
* bug where inserting one line flags all subsequent lines as changed.
|
|
85
|
+
*/
|
|
86
|
+
private computeSemanticDiff;
|
|
87
|
+
/**
|
|
88
|
+
* Lightweight client-side syntax error detection.
|
|
89
|
+
* Returns a human-readable description of obvious errors, or empty string.
|
|
90
|
+
*/
|
|
91
|
+
detectSyntaxErrors(code: string, language: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Strip comment lines that the model added during a fix but were not
|
|
94
|
+
* present in the original code. Used for syntax-only fixes where the
|
|
95
|
+
* model tends to annotate its changes with "// Fixed ..." comments.
|
|
96
|
+
*/
|
|
97
|
+
stripInjectedComments(original: string, fixed: string, language: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Ensure the fixed code hasn't lost closing delimiters relative to the
|
|
100
|
+
* original. Counts {, }, (, ), [, ] outside strings/comments and if
|
|
101
|
+
* the fix has fewer closers than the original, appends the missing ones.
|
|
102
|
+
*/
|
|
103
|
+
repairBracketBalance(original: string, fixed: string): string;
|
|
104
|
+
}
|