@floydous/pi-agent-kernel 0.6.1 → 0.6.2

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.
@@ -38,7 +38,7 @@ export function registerCodeSearchTool(
38
38
  Type.Unsafe<"auto" | "full" | "preview" | "summary">({
39
39
  type: "string",
40
40
  enum: ["auto", "full", "preview", "summary"],
41
- description: "Output detail level: 'auto' (adaptive), 'full' (complete chunk bodies), 'preview' (compact snippets), or 'summary' (headers only)",
41
+ description: "Output detail level: 'auto' (adaptive, recommended), 'full' (complete bodies for top source hits, capped at 12 KB), 'preview' (compact snippets), or 'summary' (headers only)",
42
42
  }),
43
43
  ),
44
44
  rrf_k: Type.Optional(
@@ -147,38 +147,41 @@ export function registerCodeSearchTool(
147
147
  hits,
148
148
  query,
149
149
  requestedMode as CodeSearchMode,
150
+ { filePattern: params.file_pattern, separateTests: true },
150
151
  );
151
152
  const sessionId = deps.getSessionId(ctx);
152
153
  const hitById = new Map(hits.map((hit) => [hit.chunk.id, hit]));
153
154
  const visibleIds = new Set<string>();
154
- for (const range of formatted.visibleRanges) {
155
- const hit = hitById.get(range.chunkId);
156
- if (!hit) continue;
157
- visibleIds.add(range.chunkId);
158
- globalEpistemicGuard.recordFileRead(
159
- hit.chunk.absolutePath,
160
- sessionId,
161
- ctx.cwd,
162
- undefined,
163
- {
164
- coverage: {
165
- complete: false,
166
- ranges: [{ startLine: range.startLine, endLine: range.endLine }],
155
+ globalEpistemicGuard.withBatchPersist(sessionId, ctx.cwd, () => {
156
+ for (const range of formatted.visibleRanges) {
157
+ const hit = hitById.get(range.chunkId);
158
+ if (!hit) continue;
159
+ visibleIds.add(range.chunkId);
160
+ globalEpistemicGuard.recordFileRead(
161
+ hit.chunk.absolutePath,
162
+ sessionId,
163
+ ctx.cwd,
164
+ undefined,
165
+ {
166
+ coverage: {
167
+ complete: false,
168
+ ranges: [{ startLine: range.startLine, endLine: range.endLine }],
169
+ },
170
+ provenance: "code_search",
171
+ query,
167
172
  },
168
- provenance: "code_search",
169
- query,
170
- },
171
- );
172
- }
173
- for (const hit of hits) {
174
- if (visibleIds.has(hit.chunk.id)) continue;
175
- globalEpistemicGuard.recordFileSearched(
176
- hit.chunk.absolutePath,
177
- sessionId,
178
- ctx.cwd,
179
- { coverage: { complete: false, ranges: [] }, provenance: "code_search", query },
180
- );
181
- }
173
+ );
174
+ }
175
+ for (const hit of hits) {
176
+ if (visibleIds.has(hit.chunk.id)) continue;
177
+ globalEpistemicGuard.recordFileSearched(
178
+ hit.chunk.absolutePath,
179
+ sessionId,
180
+ ctx.cwd,
181
+ { coverage: { complete: false, ranges: [] }, provenance: "code_search", query },
182
+ );
183
+ }
184
+ });
182
185
 
183
186
  return {
184
187
  content: [
@@ -185,7 +185,7 @@ function preflightFileEdit(
185
185
  if (!preflight.success) {
186
186
  if (preflight.isAmbiguous) {
187
187
  return {
188
- error: `[EDIT FAILED] Ambiguous Search Block in '${relPath}': ${preflight.error} Please provide more surrounding context lines to make the match unique.`,
188
+ error: `[EDIT FAILED] Ambiguous Search Block in '${relPath}': ${preflight.error}`,
189
189
  };
190
190
  }
191
191
  return {
@@ -207,7 +207,7 @@ function preflightFileEdit(
207
207
  if (!preflight.success) {
208
208
  if (preflight.isAmbiguous) {
209
209
  return {
210
- error: `[EDIT FAILED] Block ${i + 1}/${edits.length} is ambiguous in '${relPath}': ${preflight.error} Please provide more surrounding context lines.`,
210
+ error: `[EDIT FAILED] Block ${i + 1}/${edits.length} is ambiguous in '${relPath}': ${preflight.error}`,
211
211
  };
212
212
  }
213
213
  return {
@@ -259,6 +259,7 @@ async function applyPreparedEdit(
259
259
  const editingMode = config?.editing?.mode ?? "smart_anchor";
260
260
  const autoHeal = editingMode !== "standard";
261
261
  const syntaxGate = options.syntaxGate ?? config?.editing?.syntax_gate ?? (editingMode === "standard" ? "block" : "warn");
262
+ const execTimeoutMs = config?.safety?.exec_timeout_ms;
262
263
  // The syntax check uses tree-sitter when the grammar is loaded (see checkSyntaxContent).
263
264
  await TreeSitterEngine.getInstance().loadLanguages([path.extname(resolvedPath).toLowerCase()]);
264
265
 
@@ -269,9 +270,9 @@ async function applyPreparedEdit(
269
270
 
270
271
  let patchRes: ReturnType<typeof applySurgicalPatch>;
271
272
  if (isAnchorMode) {
272
- patchRes = applySmartAnchorEdits(resolvedPath, anchorBlocks, { syntaxGate });
273
+ patchRes = applySmartAnchorEdits(resolvedPath, anchorBlocks, { syntaxGate, execTimeoutMs });
273
274
  } else if (hasMultiBlock) {
274
- patchRes = applyMultiBlockPatch(resolvedPath, item.edits, { autoHeal, syntaxGate });
275
+ patchRes = applyMultiBlockPatch(resolvedPath, item.edits, { autoHeal, syntaxGate, execTimeoutMs });
275
276
  } else if (hasSingleBlock) {
276
277
  const singleOpt = {
277
278
  startLine: item.start_line,
@@ -282,6 +283,7 @@ async function applyPreparedEdit(
282
283
  ...singleOpt,
283
284
  autoHeal,
284
285
  syntaxGate,
286
+ execTimeoutMs,
285
287
  });
286
288
  } else {
287
289
  return { success: false, mutated: false, error: `[EDIT ERROR] Must provide either smart anchors or 'search' and 'replace' strings.` };
@@ -313,7 +315,7 @@ async function applyPreparedEdit(
313
315
 
314
316
  await deps.invalidateSearchFile?.(ctx.cwd, resolvedPath);
315
317
 
316
- const verification = await verifyEditedFile(resolvedPath, undefined, patchRes.syntax);
318
+ const verification = await verifyEditedFile(resolvedPath, undefined, patchRes.syntax, execTimeoutMs);
317
319
 
318
320
  const lineSpanSummary = computeLineSpanSummary(prepared, patchRes);
319
321
  const statusText = renderPostEditVerification(verification, undefined, relPath, lineSpanSummary);
@@ -156,6 +156,24 @@ export function registerReadTool(pi: ExtensionAPI, deps: SessionDeps): void {
156
156
  }),
157
157
  ),
158
158
  }),
159
+ prepareArguments(args: any) {
160
+ if (!args || typeof args !== "object" || Array.isArray(args)) return args;
161
+ let out: Record<string, any> | null = null;
162
+ if (typeof args.paths === "string") {
163
+ const trimmed = args.paths.trim();
164
+ out = { ...args, paths: trimmed ? [trimmed] : [] };
165
+ }
166
+ if (Array.isArray(args.path)) {
167
+ const coerced = args.path.filter((p: unknown): p is string => typeof p === "string" && p.trim().length > 0);
168
+ const base = out ?? { ...args };
169
+ delete base.path;
170
+ if (!Array.isArray(base.paths) || base.paths.length === 0) {
171
+ base.paths = coerced;
172
+ }
173
+ out = base;
174
+ }
175
+ return out ?? args;
176
+ },
159
177
  async execute(
160
178
  _toolCallId: string,
161
179
  params: any,
@@ -222,6 +240,7 @@ export function registerReadTool(pi: ExtensionAPI, deps: SessionDeps): void {
222
240
  let hasAnySuccess = false;
223
241
  let cumulativeBytes = 0;
224
242
 
243
+ globalEpistemicGuard.withBatchPersist(deps.getSessionId(ctx), ctx.cwd, () => {
225
244
  for (let i = 0; i < pathsToRead.length; i++) {
226
245
  const filePath = pathsToRead[i];
227
246
  if (cumulativeBytes >= MAX_BATCH_BYTES) {
@@ -340,6 +359,7 @@ export function registerReadTool(pi: ExtensionAPI, deps: SessionDeps): void {
340
359
  results.push(`=== file: ${relPath} ===\nError reading file: ${err.message}`);
341
360
  }
342
361
  }
362
+ });
343
363
 
344
364
  if (targetPaths.length > MAX_BATCH_PATHS) {
345
365
  results.push(`[...] Note: Truncated to first ${MAX_BATCH_PATHS} files (${targetPaths.length - MAX_BATCH_PATHS} omitted).`);
package/src/ui/footer.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { isAbsolute, relative, resolve, sep } from "node:path";
9
9
  import { getSearchConfig } from "../retrieval/search_config";
10
- import { loadKernelConfig } from "../config";
10
+ import { loadKernelConfig, type KernelConfig } from "../config";
11
11
  import { truncateToWidth, visibleWidth } from "./tui_utils";
12
12
 
13
13
  export { stripAnsi, truncateToWidth, visibleWidth } from "./tui_utils";
@@ -147,11 +147,12 @@ export function renderFooter(
147
147
  footerData: FooterDataProvider,
148
148
  width: number,
149
149
  searchIndex?: any,
150
+ config?: KernelConfig,
150
151
  ): string[] {
151
152
  const parts: string[] = [];
152
153
  const rawCwd = ctx.sessionManager?.getCwd?.() || ctx.cwd || process.cwd();
153
- const config = loadKernelConfig(rawCwd);
154
- if (!config.ui.enable_pastel_footer) {
154
+ const resolvedConfig = config ?? loadKernelConfig(rawCwd);
155
+ if (!resolvedConfig.ui.enable_pastel_footer) {
155
156
  return [truncateToWidth(formatCwd(rawCwd), width, "...")];
156
157
  }
157
158