@trim21/personal-pi-extensions 0.0.301 → 0.0.302
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/package.json +1 -1
- package/src/aft/bridge.ts +12 -1
- package/src/aft/tools.ts +9 -2
package/package.json
CHANGED
package/src/aft/bridge.ts
CHANGED
|
@@ -50,6 +50,9 @@ export interface AftPool {
|
|
|
50
50
|
projectRoot: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** semantic_search 等待索引构建完成的上限(与 Rust 侧 AFT_WAIT_FOR_SEMANTIC_READY_MS 一致)。 */
|
|
54
|
+
export const SEMANTIC_INDEX_WAIT_TIMEOUT_MS = 600_000;
|
|
55
|
+
|
|
53
56
|
/** 创建 transport pool。每个项目根一个常驻 aft 进程,跨 session 共享。 */
|
|
54
57
|
export async function createAftPool(cwd: string): Promise<AftPool> {
|
|
55
58
|
const binaryPath = await resolveAftBinary();
|
|
@@ -57,7 +60,15 @@ export async function createAftPool(cwd: string): Promise<AftPool> {
|
|
|
57
60
|
const pool = await createAftTransportPool({
|
|
58
61
|
harness: "pi",
|
|
59
62
|
binaryPath,
|
|
60
|
-
poolOptions: {
|
|
63
|
+
poolOptions: {
|
|
64
|
+
childEnv: {
|
|
65
|
+
// Rust 侧 semantic_search 在索引 Building 时阻塞等待构建完成
|
|
66
|
+
// (main.rs wait_for_semantic_index_before_search),避免首次搜索拿到
|
|
67
|
+
// 词法 fallback 的部分结果。语义搜索未启用时该逻辑直接跳过。
|
|
68
|
+
AFT_WAIT_FOR_SEMANTIC_READY: "1",
|
|
69
|
+
AFT_WAIT_FOR_SEMANTIC_READY_MS: String(SEMANTIC_INDEX_WAIT_TIMEOUT_MS),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
61
72
|
configOverrides: {
|
|
62
73
|
storage_dir: resolveCortexKitStorageRoot(),
|
|
63
74
|
cortexkit_user_config_path: paths.userConfigPath,
|
package/src/aft/tools.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
21
21
|
import { Type } from "typebox";
|
|
22
22
|
|
|
23
|
-
import { callAftTool } from "./bridge.js";
|
|
23
|
+
import { callAftTool, SEMANTIC_INDEX_WAIT_TIMEOUT_MS } from "./bridge.js";
|
|
24
24
|
|
|
25
25
|
/** 解析 `~` 前缀与相对路径(相对 session cwd)。URL 与绝对路径原样返回。 */
|
|
26
26
|
export function resolvePathArg(cwd: string, input: string): string {
|
|
@@ -336,6 +336,7 @@ export function registerSearchTool(pi: ExtensionAPI, ctx: AftToolContext): void
|
|
|
336
336
|
"精确名字、字符串、正则保持简短('^export'、'Cargo.lock')。",
|
|
337
337
|
"需要语义索引可用(aft.jsonc 中 semantic_search: true 且 embedding 后端就绪);",
|
|
338
338
|
"否则退化为词法/正则匹配通道。",
|
|
339
|
+
"启用语义索引时,首次调用会阻塞到索引构建完成,避免返回部分结果。",
|
|
339
340
|
].join("\n"),
|
|
340
341
|
promptSnippet: "Search code by meaning or exact text",
|
|
341
342
|
parameters: SearchParams,
|
|
@@ -350,7 +351,13 @@ export function registerSearchTool(pi: ExtensionAPI, ctx: AftToolContext): void
|
|
|
350
351
|
rawArgs.path = resolvePathArg(extCtx.cwd, params.path);
|
|
351
352
|
}
|
|
352
353
|
|
|
353
|
-
const { text, response } = await callAftTool(bridgeFor(ctx), "search", rawArgs, extCtx
|
|
354
|
+
const { text, response } = await callAftTool(bridgeFor(ctx), "search", rawArgs, extCtx, {
|
|
355
|
+
// 默认 search 传输超时仅 60s,会早于索引等待(600s)触发;覆盖为等待
|
|
356
|
+
// 上限 + 常规执行预算。超时只说明响应被挤掉而非 bridge 挂死,保留
|
|
357
|
+
// 常驻的语义索引/LSP 状态。
|
|
358
|
+
transportTimeoutMs: SEMANTIC_INDEX_WAIT_TIMEOUT_MS + 60_000,
|
|
359
|
+
keepBridgeOnTimeout: true,
|
|
360
|
+
});
|
|
354
361
|
return {
|
|
355
362
|
content: [{ type: "text", text }],
|
|
356
363
|
details: { input: params, truncated: response.truncated === true },
|