@floydous/pi-agent-kernel 0.4.3 → 0.5.0
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/AGENT_KERNEL_SYS_PROMPT.md +1 -7
- package/CHANGELOG.md +36 -0
- package/README.md +6 -53
- package/config.example.toml +0 -8
- package/docs/README.md +1 -2
- package/docs/architecture.md +2 -3
- package/docs/configuration.md +10 -9
- package/docs/editing-and-verification.md +1 -3
- package/docs/retrieval.md +6 -11
- package/docs/testing.md +3 -3
- package/package.json +4 -2
- package/src/config/agent_kernel_command.ts +8 -39
- package/src/config/kernel_config.ts +30 -68
- package/src/config/toml.ts +6 -1
- package/src/editing/auto_heal.ts +1 -1
- package/src/editing/patch.ts +27 -16
- package/src/editing/post_edit_verification.ts +12 -10
- package/src/editing/smart_anchor.ts +7 -5
- package/src/editing/syntax-verify.ts +9 -5
- package/src/index.ts +15 -257
- package/src/retrieval/search_bm25.ts +4 -2
- package/src/retrieval/search_chunker.ts +1 -1
- package/src/retrieval/search_config.ts +4 -6
- package/src/retrieval/search_embedder.ts +3 -2
- package/src/retrieval/search_index.ts +82 -35
- package/src/retrieval/search_modal.ts +7 -8
- package/src/retrieval/{repomap.ts → tag_extractor.ts} +5 -292
- package/src/retrieval/tree_sitter_engine.ts +70 -34
- package/src/retrieval/workspace_walker.ts +6 -2
- package/src/safety/atomic_write.ts +1 -1
- package/src/safety/epistemic_guard.ts +105 -31
- package/src/safety/output_clamper.ts +14 -8
- package/src/tools/code_search_output.ts +2 -1
- package/src/tools/code_search_tool.ts +2 -5
- package/src/tools/context.ts +0 -14
- package/src/tools/edit_tool.ts +82 -115
- package/src/tools/read_tool.ts +42 -178
- package/src/ui/footer.ts +7 -7
- package/docs/lsp.md +0 -31
- package/src/lsp/adapters/base.ts +0 -42
- package/src/lsp/adapters/index.ts +0 -21
- package/src/lsp/adapters/python.ts +0 -37
- package/src/lsp/adapters/rust.ts +0 -35
- package/src/lsp/adapters/typescript.ts +0 -40
- package/src/lsp/index.ts +0 -13
- package/src/lsp/lsp_client.ts +0 -765
- package/src/lsp/lsp_detector.ts +0 -52
- package/src/lsp/lsp_formatter.ts +0 -323
- package/src/lsp/lsp_installer.ts +0 -320
- package/src/lsp/lsp_manager.ts +0 -202
- package/src/lsp/lsp_modal.ts +0 -675
- package/src/lsp/lsp_registry.ts +0 -600
- package/src/lsp/lsp_types.ts +0 -143
- package/src/retrieval/ast_search.ts +0 -999
- package/src/retrieval/symbol_reader.ts +0 -228
- package/src/tools/ast_search_formatter.ts +0 -161
- package/src/tools/ast_search_tool.ts +0 -146
- package/src/tools/lsp_tool.ts +0 -794
- package/src/tools/repo_map_tool.ts +0 -56
|
@@ -7,11 +7,7 @@ import { writeFileSyncAtomic } from "../safety/atomic_write";
|
|
|
7
7
|
|
|
8
8
|
export interface RetrievalConfig {
|
|
9
9
|
default_profile: "auto" | "lean" | "hybrid" | "full" | "off";
|
|
10
|
-
repo_map_budget: number;
|
|
11
|
-
repo_map_min_files: number;
|
|
12
|
-
repo_map_min_bytes: number;
|
|
13
10
|
max_search_results: number;
|
|
14
|
-
enable_tools?: boolean;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
export interface SafetyConfig {
|
|
@@ -33,19 +29,10 @@ export interface KernelConfigOverrides {
|
|
|
33
29
|
retrieval?: Partial<RetrievalConfig>;
|
|
34
30
|
safety?: Partial<SafetyConfig>;
|
|
35
31
|
editing?: Partial<EditingConfig>;
|
|
36
|
-
lsp?: Partial<LspConfig>;
|
|
37
32
|
ui?: Partial<UiConfig>;
|
|
38
33
|
instructions?: Partial<InstructionsConfig>;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
export interface LspConfig {
|
|
42
|
-
idle_timeout_ms: number;
|
|
43
|
-
diagnostic_timeout_ms: number;
|
|
44
|
-
init_timeout_ms: number;
|
|
45
|
-
spinner_interval_ms: number;
|
|
46
|
-
disabled_servers: string[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
36
|
export interface UiConfig {
|
|
50
37
|
enable_pastel_footer: boolean;
|
|
51
38
|
}
|
|
@@ -59,7 +46,6 @@ export interface KernelConfig {
|
|
|
59
46
|
retrieval: RetrievalConfig;
|
|
60
47
|
safety: SafetyConfig;
|
|
61
48
|
editing: EditingConfig;
|
|
62
|
-
lsp: LspConfig;
|
|
63
49
|
ui: UiConfig;
|
|
64
50
|
instructions: InstructionsConfig;
|
|
65
51
|
}
|
|
@@ -67,11 +53,7 @@ export interface KernelConfig {
|
|
|
67
53
|
const DEFAULT_CONFIG: KernelConfig = {
|
|
68
54
|
retrieval: {
|
|
69
55
|
default_profile: "lean",
|
|
70
|
-
repo_map_budget: 1024,
|
|
71
|
-
repo_map_min_files: 10,
|
|
72
|
-
repo_map_min_bytes: 50 * 1024,
|
|
73
56
|
max_search_results: 5,
|
|
74
|
-
enable_tools: false,
|
|
75
57
|
},
|
|
76
58
|
safety: {
|
|
77
59
|
enable_epistemic_guard: true,
|
|
@@ -86,13 +68,6 @@ const DEFAULT_CONFIG: KernelConfig = {
|
|
|
86
68
|
read_mode: "plain",
|
|
87
69
|
syntax_gate: "warn",
|
|
88
70
|
},
|
|
89
|
-
lsp: {
|
|
90
|
-
idle_timeout_ms: 5 * 60 * 1000, // 5 minutes
|
|
91
|
-
diagnostic_timeout_ms: 8000, // 8s for type-checking on large workspaces
|
|
92
|
-
init_timeout_ms: 25000, // 25s for heavy servers like rust-analyzer/vtsls/gopls
|
|
93
|
-
spinner_interval_ms: 80,
|
|
94
|
-
disabled_servers: [],
|
|
95
|
-
},
|
|
96
71
|
ui: {
|
|
97
72
|
enable_pastel_footer: true,
|
|
98
73
|
},
|
|
@@ -107,11 +82,7 @@ export class KernelConfigError extends Error {}
|
|
|
107
82
|
const ALLOWED_CONFIG_KEYS: Record<keyof KernelConfig, ReadonlySet<string>> = {
|
|
108
83
|
retrieval: new Set([
|
|
109
84
|
"default_profile",
|
|
110
|
-
"repo_map_budget",
|
|
111
|
-
"repo_map_min_files",
|
|
112
|
-
"repo_map_min_bytes",
|
|
113
85
|
"max_search_results",
|
|
114
|
-
"enable_tools",
|
|
115
86
|
]),
|
|
116
87
|
safety: new Set([
|
|
117
88
|
"enable_epistemic_guard",
|
|
@@ -121,17 +92,17 @@ const ALLOWED_CONFIG_KEYS: Record<keyof KernelConfig, ReadonlySet<string>> = {
|
|
|
121
92
|
"exec_timeout_ms",
|
|
122
93
|
]),
|
|
123
94
|
editing: new Set(["mode", "default_anchors", "read_mode", "syntax_gate"]),
|
|
124
|
-
lsp: new Set([
|
|
125
|
-
"idle_timeout_ms",
|
|
126
|
-
"diagnostic_timeout_ms",
|
|
127
|
-
"init_timeout_ms",
|
|
128
|
-
"spinner_interval_ms",
|
|
129
|
-
"disabled_servers",
|
|
130
|
-
]),
|
|
131
95
|
ui: new Set(["enable_pastel_footer"]),
|
|
132
96
|
instructions: new Set(["enabled", "pi_docs"]),
|
|
133
97
|
};
|
|
134
98
|
|
|
99
|
+
const DEPRECATED_RETRIEVAL_KEYS = new Set([
|
|
100
|
+
"enable_tools",
|
|
101
|
+
"repo_map_budget",
|
|
102
|
+
"repo_map_min_files",
|
|
103
|
+
"repo_map_min_bytes",
|
|
104
|
+
]);
|
|
105
|
+
|
|
135
106
|
function configPath(parts: string[]): string {
|
|
136
107
|
return parts.join(".");
|
|
137
108
|
}
|
|
@@ -167,11 +138,7 @@ export function validateKernelConfig(config: KernelConfig): KernelConfig {
|
|
|
167
138
|
|
|
168
139
|
const retrieval = config.retrieval;
|
|
169
140
|
requireEnum(retrieval.default_profile, "retrieval.default_profile", ["auto", "lean", "hybrid", "full", "off"]);
|
|
170
|
-
requireSafeInt(retrieval.repo_map_budget, "retrieval.repo_map_budget", 64, 32_768);
|
|
171
|
-
requireSafeInt(retrieval.repo_map_min_files, "retrieval.repo_map_min_files", 0, 10_000);
|
|
172
|
-
requireSafeInt(retrieval.repo_map_min_bytes, "retrieval.repo_map_min_bytes", 0, 1024 * 1024 * 1024);
|
|
173
141
|
requireSafeInt(retrieval.max_search_results, "retrieval.max_search_results", 1, 15);
|
|
174
|
-
requireBoolean(retrieval.enable_tools, "retrieval.enable_tools");
|
|
175
142
|
|
|
176
143
|
const safety = config.safety;
|
|
177
144
|
requireBoolean(safety.enable_epistemic_guard, "safety.enable_epistemic_guard");
|
|
@@ -187,20 +154,6 @@ export function validateKernelConfig(config: KernelConfig): KernelConfig {
|
|
|
187
154
|
requireEnum(config.editing.syntax_gate, "editing.syntax_gate", ["warn", "block"]);
|
|
188
155
|
}
|
|
189
156
|
|
|
190
|
-
requireSafeInt(config.lsp.idle_timeout_ms, "lsp.idle_timeout_ms", 1_000, 60 * 60 * 1_000);
|
|
191
|
-
requireSafeInt(config.lsp.diagnostic_timeout_ms, "lsp.diagnostic_timeout_ms", 100, 120_000);
|
|
192
|
-
requireSafeInt(config.lsp.init_timeout_ms, "lsp.init_timeout_ms", 100, 5 * 60 * 1_000);
|
|
193
|
-
requireSafeInt(config.lsp.spinner_interval_ms, "lsp.spinner_interval_ms", 16, 1_000);
|
|
194
|
-
if (
|
|
195
|
-
!Array.isArray(config.lsp.disabled_servers) ||
|
|
196
|
-
config.lsp.disabled_servers.length > 64 ||
|
|
197
|
-
config.lsp.disabled_servers.some(
|
|
198
|
-
(server) => typeof server !== "string" || !/^[a-z0-9._-]{1,64}$/i.test(server),
|
|
199
|
-
)
|
|
200
|
-
) {
|
|
201
|
-
throw new KernelConfigError("lsp.disabled_servers must be an array of up to 64 safe server keys");
|
|
202
|
-
}
|
|
203
|
-
|
|
204
157
|
requireBoolean(config.ui.enable_pastel_footer, "ui.enable_pastel_footer");
|
|
205
158
|
requireBoolean(config.instructions.enabled, "instructions.enabled");
|
|
206
159
|
requireBoolean(config.instructions.pi_docs, "instructions.pi_docs");
|
|
@@ -212,20 +165,26 @@ export function mergeKernelConfig(target: KernelConfig, source: unknown): Kernel
|
|
|
212
165
|
if (!source || typeof source !== "object" || Array.isArray(source)) {
|
|
213
166
|
throw new KernelConfigError("Configuration root must be a table");
|
|
214
167
|
}
|
|
168
|
+
const sanitizedSource: Record<string, unknown> = {};
|
|
215
169
|
for (const [section, value] of Object.entries(source as Record<string, unknown>)) {
|
|
170
|
+
if (section === "lsp") continue; // Deprecated legacy section: accepted and ignored
|
|
216
171
|
if (!ALLOWED_CONFIG_KEYS[section as keyof KernelConfig]) {
|
|
217
172
|
throw new KernelConfigError(`Unknown configuration section: ${section}`);
|
|
218
173
|
}
|
|
219
174
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
220
175
|
throw new KernelConfigError(`${section} must be a table`);
|
|
221
176
|
}
|
|
222
|
-
|
|
177
|
+
const sectionObj: Record<string, unknown> = {};
|
|
178
|
+
for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
|
|
179
|
+
if (section === "retrieval" && DEPRECATED_RETRIEVAL_KEYS.has(key)) continue; // Deprecated legacy setting: accepted and ignored
|
|
223
180
|
if (!ALLOWED_CONFIG_KEYS[section as keyof KernelConfig].has(key)) {
|
|
224
181
|
throw new KernelConfigError(`Unknown configuration key: ${configPath([section, key])}`);
|
|
225
182
|
}
|
|
183
|
+
sectionObj[key] = val;
|
|
226
184
|
}
|
|
185
|
+
sanitizedSource[section] = sectionObj;
|
|
227
186
|
}
|
|
228
|
-
mergeDeep(candidate,
|
|
187
|
+
mergeDeep(candidate, sanitizedSource);
|
|
229
188
|
validateKernelConfig(candidate);
|
|
230
189
|
for (const key of Object.keys(target) as Array<keyof KernelConfig>) {
|
|
231
190
|
delete (target as any)[key];
|
|
@@ -323,15 +282,10 @@ export function loadKernelConfig(
|
|
|
323
282
|
}
|
|
324
283
|
|
|
325
284
|
// 3. Environment Variable Overrides
|
|
326
|
-
if (process.env.PI_REPO_MAP_BUDGET) {
|
|
327
|
-
const b = parseInt(process.env.PI_REPO_MAP_BUDGET, 10);
|
|
328
|
-
if (!isNaN(b)) config.retrieval.repo_map_budget = b;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
285
|
if (process.env.PI_RETRIEVAL_PROFILE) {
|
|
332
286
|
const p = process.env.PI_RETRIEVAL_PROFILE.toLowerCase();
|
|
333
287
|
if (p === "lean" || p === "hybrid" || p === "full") {
|
|
334
|
-
config.retrieval.default_profile = p
|
|
288
|
+
config.retrieval.default_profile = p;
|
|
335
289
|
}
|
|
336
290
|
}
|
|
337
291
|
|
|
@@ -366,10 +320,11 @@ export function removeGlobalKernelConfigKey(section: string, key: string): void
|
|
|
366
320
|
if (!fs.existsSync(globalPath)) return;
|
|
367
321
|
|
|
368
322
|
try {
|
|
369
|
-
const existing
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
323
|
+
const existing = parseToml(fs.readFileSync(globalPath, "utf-8"));
|
|
324
|
+
const sec = existing[section];
|
|
325
|
+
if (sec && typeof sec === "object" && !Array.isArray(sec) && (sec as Record<string, TomlValue>)[key] !== undefined) {
|
|
326
|
+
delete (sec as Record<string, TomlValue>)[key];
|
|
327
|
+
if (Object.keys(sec).length === 0) {
|
|
373
328
|
delete existing[section];
|
|
374
329
|
}
|
|
375
330
|
validateConfigDocument(existing);
|
|
@@ -384,11 +339,18 @@ export function removeGlobalKernelConfigKey(section: string, key: string): void
|
|
|
384
339
|
/**
|
|
385
340
|
* Read raw global configuration TOML if it exists
|
|
386
341
|
*/
|
|
387
|
-
export function getGlobalRawConfig(): Record<string,
|
|
342
|
+
export function getGlobalRawConfig(): Record<string, Record<string, TomlValue>> {
|
|
388
343
|
const globalPath = getGlobalConfigPath();
|
|
389
344
|
if (fs.existsSync(globalPath)) {
|
|
390
345
|
try {
|
|
391
|
-
|
|
346
|
+
const parsed = parseToml(fs.readFileSync(globalPath, "utf-8"));
|
|
347
|
+
const result: Record<string, Record<string, TomlValue>> = {};
|
|
348
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
349
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
350
|
+
result[key] = value as Record<string, TomlValue>;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
392
354
|
} catch (e) {
|
|
393
355
|
kernelDebug(e);
|
|
394
356
|
}
|
package/src/config/toml.ts
CHANGED
|
@@ -77,7 +77,12 @@ export function parseToml(tomlStr: string): Record<string, TomlValue> {
|
|
|
77
77
|
// Strip inline comment if not inside quote
|
|
78
78
|
rawValue = stripInlineComment(rawValue);
|
|
79
79
|
|
|
80
|
-
currentTable
|
|
80
|
+
Object.defineProperty(currentTable, cleanKey, {
|
|
81
|
+
value: parseTomlValue(rawValue),
|
|
82
|
+
writable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true,
|
|
85
|
+
});
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
return root;
|
package/src/editing/auto_heal.ts
CHANGED
|
@@ -78,7 +78,7 @@ export function getUnclosedDelimiters(text: string): string[] {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const map: Record<string, string> = { "{": "}", "(": ")", "[": "]" };
|
|
81
|
-
return stack.reverse().map((ch) => map[ch]);
|
|
81
|
+
return [...stack].reverse().map((ch) => map[ch] ?? "");
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
package/src/editing/patch.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { resolveUserPath } from "../safety/epistemic_guard";
|
|
4
4
|
import * as diff from "diff";
|
|
@@ -10,7 +10,7 @@ import { getUnclosedDelimiters, healJsonContent } from "./auto_heal";
|
|
|
10
10
|
*
|
|
11
11
|
* `success: true` means the requested block was located, the complete
|
|
12
12
|
* candidate content passed the local syntax gate, and the target was written.
|
|
13
|
-
* It does not imply type correctness, semantic correctness, or
|
|
13
|
+
* It does not imply type correctness, semantic correctness, or project-wide
|
|
14
14
|
* diagnostics; those checks remain the caller's responsibility.
|
|
15
15
|
*/
|
|
16
16
|
export interface PatchResult {
|
|
@@ -337,7 +337,7 @@ export function preflightSurgicalPatchBlock(
|
|
|
337
337
|
const resolvedPath = resolvePatchPath(filePath);
|
|
338
338
|
const target = readPatchTarget(resolvedPath);
|
|
339
339
|
if ("error" in target) {
|
|
340
|
-
const err =
|
|
340
|
+
const err = target.error.error || "Could not read target file";
|
|
341
341
|
return { success: false, error: err };
|
|
342
342
|
}
|
|
343
343
|
const result = applySingleBlock(target.content, search, "", options);
|
|
@@ -515,11 +515,12 @@ export function applySurgicalPatch(
|
|
|
515
515
|
return writeError;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
518
|
+
let finalStrategy = result.strategy;
|
|
519
|
+
if (autoHealed) {
|
|
520
|
+
finalStrategy = `${result.strategy} (auto-healed syntax)`;
|
|
521
|
+
} else if (!syntax.valid) {
|
|
522
|
+
finalStrategy = `${result.strategy} (applied with syntax warning)`;
|
|
523
|
+
}
|
|
523
524
|
|
|
524
525
|
return {
|
|
525
526
|
success: true,
|
|
@@ -588,10 +589,19 @@ export function applyMultiBlockPatch(
|
|
|
588
589
|
};
|
|
589
590
|
}
|
|
590
591
|
|
|
592
|
+
const targetRange = located.targetRange;
|
|
593
|
+
if (!targetRange) {
|
|
594
|
+
return {
|
|
595
|
+
success: false,
|
|
596
|
+
filePath: resolvedPath,
|
|
597
|
+
strategy: "none",
|
|
598
|
+
error: `Block ${i + 1}/${blocks.length} missing target range in ${resolvedPath}`,
|
|
599
|
+
};
|
|
600
|
+
}
|
|
591
601
|
const overlaps = plannedRanges.some(
|
|
592
602
|
(range) =>
|
|
593
|
-
range.startLine <=
|
|
594
|
-
|
|
603
|
+
range.startLine <= targetRange.endLine &&
|
|
604
|
+
targetRange.startLine <= range.endLine,
|
|
595
605
|
);
|
|
596
606
|
if (overlaps) {
|
|
597
607
|
return {
|
|
@@ -601,7 +611,7 @@ export function applyMultiBlockPatch(
|
|
|
601
611
|
error: `Block ${i + 1}/${blocks.length} overlaps another patch target in ${resolvedPath}.`,
|
|
602
612
|
};
|
|
603
613
|
}
|
|
604
|
-
plannedRanges.push({ ...
|
|
614
|
+
plannedRanges.push({ ...targetRange });
|
|
605
615
|
}
|
|
606
616
|
|
|
607
617
|
let currentContent = originalContent;
|
|
@@ -671,11 +681,12 @@ export function applyMultiBlockPatch(
|
|
|
671
681
|
return writeError;
|
|
672
682
|
}
|
|
673
683
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
684
|
+
let finalStrategy = appliedStrategies.join(", ");
|
|
685
|
+
if (autoHealed) {
|
|
686
|
+
finalStrategy = `${appliedStrategies.join(", ")} (auto-healed syntax)`;
|
|
687
|
+
} else if (!syntax.valid) {
|
|
688
|
+
finalStrategy = `${appliedStrategies.join(", ")} (applied with syntax warning)`;
|
|
689
|
+
}
|
|
679
690
|
|
|
680
691
|
return {
|
|
681
692
|
success: true,
|
|
@@ -53,10 +53,12 @@ function diagnosticValue(result: DiagnosticVerification): string {
|
|
|
53
53
|
counts.set(severity, (counts.get(severity) || 0) + 1);
|
|
54
54
|
}
|
|
55
55
|
return Array.from(counts.entries())
|
|
56
|
-
.map(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
.map(([severity, count]) => {
|
|
57
|
+
let label = "err";
|
|
58
|
+
if (severity === "warning") label = "warn";
|
|
59
|
+
else if (severity === "info") label = "info";
|
|
60
|
+
return `${count} ${label}`;
|
|
61
|
+
})
|
|
60
62
|
.join(",");
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -128,12 +130,12 @@ export function renderPostEditVerification(
|
|
|
128
130
|
const header = hasDiagnosticError ? "Diagnostics (errors):" : "Diagnostics (warnings):";
|
|
129
131
|
lines.push(header);
|
|
130
132
|
for (const finding of result.diagnostic.findings.slice(0, 5)) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
let pos = "";
|
|
134
|
+
if (finding.line !== undefined) {
|
|
135
|
+
pos = finding.column !== undefined
|
|
136
|
+
? `[${finding.line}:${finding.column}] `
|
|
137
|
+
: `[${finding.line}] `;
|
|
138
|
+
}
|
|
137
139
|
lines.push(` - ${pos}${compactMessage(finding.message)}`);
|
|
138
140
|
}
|
|
139
141
|
if (result.diagnostic.findings.length > 5) {
|
|
@@ -44,9 +44,9 @@ function fnvHash(prev: string, curr: string, next: string): string {
|
|
|
44
44
|
*/
|
|
45
45
|
export function computeLineHash(fileLines: readonly string[], index: number): string {
|
|
46
46
|
if (index < 0 || index >= fileLines.length) return "";
|
|
47
|
-
const prev = index > 0 ? normalizeLine(fileLines[index - 1]
|
|
48
|
-
const curr = normalizeLine(fileLines[index]
|
|
49
|
-
const next = index < fileLines.length - 1 ? normalizeLine(fileLines[index + 1]
|
|
47
|
+
const prev = index > 0 ? normalizeLine(fileLines[index - 1] ?? "") : "";
|
|
48
|
+
const curr = normalizeLine(fileLines[index] ?? "");
|
|
49
|
+
const next = index < fileLines.length - 1 ? normalizeLine(fileLines[index + 1] ?? "") : "";
|
|
50
50
|
return fnvHash(prev, curr, next);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -282,9 +282,11 @@ export function preflightSmartAnchorEdits(
|
|
|
282
282
|
|
|
283
283
|
// Check for conflicting / overlapping spans
|
|
284
284
|
for (let j = 0; j < resolvedSpans.length; j++) {
|
|
285
|
-
const left = resolvedSpans[j]
|
|
285
|
+
const left = resolvedSpans[j];
|
|
286
|
+
if (!left) continue;
|
|
286
287
|
for (let k = j + 1; k < resolvedSpans.length; k++) {
|
|
287
|
-
const right = resolvedSpans[k]
|
|
288
|
+
const right = resolvedSpans[k];
|
|
289
|
+
if (!right) continue;
|
|
288
290
|
if (left.startLine <= right.endLine && right.startLine <= left.endLine) {
|
|
289
291
|
return {
|
|
290
292
|
success: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { execFileSync } from "child_process";
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
4
|
|
|
5
5
|
export interface VerificationResult {
|
|
6
6
|
valid: boolean;
|
|
@@ -17,7 +17,7 @@ export interface VerificationResult {
|
|
|
17
17
|
* balanced. This deterministically catches the dominant per-edit failure
|
|
18
18
|
* class: truncated replacements, missing closing braces/parens, unterminated
|
|
19
19
|
* strings or block comments. It is NOT a full parse; type errors remain the
|
|
20
|
-
*
|
|
20
|
+
* domain of project-native typechecks (e.g. tsc, cargo check).
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
23
|
* Decides whether a '/' at the current position starts a regex literal
|
|
@@ -182,6 +182,8 @@ function checkTsStructure(content: string): string | null {
|
|
|
182
182
|
else if (ch === "]") inCharClass = false;
|
|
183
183
|
else if (ch === "/" && !inCharClass) state = "code";
|
|
184
184
|
break;
|
|
185
|
+
default:
|
|
186
|
+
break;
|
|
185
187
|
}
|
|
186
188
|
i++;
|
|
187
189
|
}
|
|
@@ -228,7 +230,9 @@ export function resolveNodeExecutable(): { bin: string; env?: Record<string, str
|
|
|
228
230
|
cachedNodeExec = cand;
|
|
229
231
|
return cand;
|
|
230
232
|
}
|
|
231
|
-
} catch {
|
|
233
|
+
} catch (error) {
|
|
234
|
+
void error;
|
|
235
|
+
}
|
|
232
236
|
}
|
|
233
237
|
|
|
234
238
|
cachedNodeExec = null;
|