pi-cc-extensions 0.7.3 → 0.7.4
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/README.md
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
2. 从 `[Session] ...` 或 `[SubAgent] ...` 补全项中选择要引用的上下文。
|
|
86
86
|
3. 提交时以 `@session:<session-id>` 引用其当前有效上下文。
|
|
87
87
|
|
|
88
|
-
Session 模糊查询默认显示
|
|
88
|
+
Session 模糊查询默认显示 3 个候选,并与文件候选按 1:2 交错排列;路径型查询优先显示文件。若已加载 `pi-subagents`,也可直接引用现有 SubAgent。一次提示词可以引用多个 Session;扩展会自动去重,并限制注入规模以避免上下文无限膨胀。更多细节见 [`extensions/session-reference/README.md`](./extensions/session-reference/README.md)。
|
|
89
89
|
|
|
90
90
|
### SubAgent `@` 补全
|
|
91
91
|
|
|
@@ -17,7 +17,7 @@ type AgentInfo = {
|
|
|
17
17
|
filePath: string;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const MAX_SUGGESTIONS =
|
|
20
|
+
const MAX_SUGGESTIONS = 2;
|
|
21
21
|
// Match `@name` but NOT `@session:` (reserved by session-reference extension).
|
|
22
22
|
const AGENT_NAME_PATTERN = /(?:^|[\t ])@((?:[^\s:@][^\s:]*)?)$/;
|
|
23
23
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
## 行为
|
|
12
12
|
|
|
13
13
|
- 搜索全部 pi 历史 Session;当前 Workspace 的 Session 优先。
|
|
14
|
-
- Session 模糊查询默认最多显示
|
|
15
|
-
- 与 pi 原有 `@`
|
|
14
|
+
- Session 模糊查询默认最多显示 3 个候选。
|
|
15
|
+
- 与 pi 原有 `@` 文件补全并存:普通查询按 1:2 交错排列 Session 与文件,路径型查询优先显示文件。
|
|
16
16
|
- 若已加载 `pi-subagents`,`@` 补全会同时显示现有 SubAgent,并引用其当前有效上下文。
|
|
17
17
|
- 支持一个 prompt 引用多个 Session,并自动去重;单次最多注入前 5 个。
|
|
18
18
|
- 跳过历史 Session 中嵌套的 Session 引用,避免递归膨胀。
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
type ReferenceSource,
|
|
23
23
|
} from "./core.ts";
|
|
24
24
|
|
|
25
|
-
const MAX_SESSION_SUGGESTIONS =
|
|
26
|
-
const MAX_FILE_SUGGESTIONS =
|
|
25
|
+
const MAX_SESSION_SUGGESTIONS = 3;
|
|
26
|
+
const MAX_FILE_SUGGESTIONS = 7;
|
|
27
27
|
const MAX_REFERENCED_SESSIONS = 5;
|
|
28
28
|
const MENTION_PATTERN = /(?:^|[\t ])@([^\s@]*)$/;
|
|
29
29
|
const SUBAGENT_MANAGER_KEY = Symbol.for("pi-subagents:manager");
|
|
@@ -166,6 +166,31 @@ function filterSessions(references: SessionReference[], query: string, currentCw
|
|
|
166
166
|
return matches.slice(0, MAX_SESSION_SUGGESTIONS).map((reference) => sessionItem(reference, currentCwd));
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
function isPathLikeQuery(query: string): boolean {
|
|
170
|
+
return /[\\/*?]/.test(query) || /\.[A-Za-z0-9_-]{1,12}$/.test(query);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function mergeSessionAndFileItems(
|
|
174
|
+
sessionItems: AutocompleteItem[],
|
|
175
|
+
fileItems: AutocompleteItem[],
|
|
176
|
+
query: string,
|
|
177
|
+
): AutocompleteItem[] {
|
|
178
|
+
const sessions = sessionItems.slice(0, MAX_SESSION_SUGGESTIONS);
|
|
179
|
+
const files = fileItems.slice(0, MAX_FILE_SUGGESTIONS);
|
|
180
|
+
if (isPathLikeQuery(query)) return [...files, ...sessions];
|
|
181
|
+
|
|
182
|
+
const merged: AutocompleteItem[] = [];
|
|
183
|
+
let sessionIndex = 0;
|
|
184
|
+
let fileIndex = 0;
|
|
185
|
+
while (sessionIndex < sessions.length || fileIndex < files.length) {
|
|
186
|
+
for (let count = 0; count < 2 && fileIndex < files.length; count++) {
|
|
187
|
+
merged.push(files[fileIndex++]!);
|
|
188
|
+
}
|
|
189
|
+
if (sessionIndex < sessions.length) merged.push(sessions[sessionIndex++]!);
|
|
190
|
+
}
|
|
191
|
+
return merged;
|
|
192
|
+
}
|
|
193
|
+
|
|
169
194
|
function liveSubagentReferences(agentIds: Set<string>, currentSessionId: string): SessionReference[] {
|
|
170
195
|
const manager = getSubagentManager();
|
|
171
196
|
if (!manager) return [];
|
|
@@ -236,9 +261,11 @@ export function createAutocompleteProvider(
|
|
|
236
261
|
if (options.signal.aborted) return null;
|
|
237
262
|
|
|
238
263
|
const sessionItems = filterSessions(references, query, currentCwd);
|
|
239
|
-
const fileItems =
|
|
240
|
-
|
|
241
|
-
|
|
264
|
+
const fileItems = baseSuggestions?.prefix === `@${query}`
|
|
265
|
+
? baseSuggestions.items
|
|
266
|
+
: [];
|
|
267
|
+
const items = mergeSessionAndFileItems(sessionItems, fileItems, query);
|
|
268
|
+
if (items.length === 0) return baseSuggestions;
|
|
242
269
|
return { prefix: `@${query}`, items };
|
|
243
270
|
},
|
|
244
271
|
|