pi-cc-extensions 0.7.3 → 0.7.5

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.
@@ -11,8 +11,8 @@
11
11
  ## 行为
12
12
 
13
13
  - 搜索全部 pi 历史 Session;当前 Workspace 的 Session 优先。
14
- - Session 模糊查询默认最多显示 5 个候选。
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 = 5;
26
- const MAX_FILE_SUGGESTIONS = 10;
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 = (baseSuggestions?.items ?? []).slice(0, MAX_FILE_SUGGESTIONS);
240
- const items = [...sessionItems, ...fileItems];
241
- if (items.length === 0) return null;
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cc-extensions",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Personal extensions for the Pi coding agent",
5
5
  "type": "module",
6
6
  "keywords": [