@yandy0725/pi-memory 1.2.0 → 1.2.1

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/index.ts CHANGED
@@ -7,7 +7,6 @@ import { runDream } from "./src/dream";
7
7
  import { runExtract } from "./src/extract";
8
8
  import {
9
9
  buildInjection,
10
- buildSurfacingPrompt,
11
10
  injectSurfacedContent,
12
11
  loadIndexSnapshot,
13
12
  runSideQuery,
@@ -98,17 +97,16 @@ export default function (pi: ExtensionAPI) {
98
97
  if (ctx.hasUI) ctx.ui.setStatus("surfacing", "Searching relevant memories…");
99
98
  const manifest = await scanTopics(memoryDir);
100
99
  if (manifest.length > 0) {
101
- const queryPrompt = buildSurfacingPrompt(manifest, event.prompt.slice(0, 4000), injectedTopics);
102
100
  const selected = await runSideQuery(
103
- queryPrompt,
104
101
  manifest,
102
+ event.prompt.slice(0, 4000),
103
+ injectedTopics,
105
104
  autoSurfacing.maxFiles,
106
105
  autoSurfacing.thinkLevel,
107
106
  autoSurfacing.model,
108
107
  ctx.modelRegistry,
109
108
  ctx.model,
110
109
  memoryDir,
111
- injectedTopics,
112
110
  );
113
111
  if (selected.length > 0) {
114
112
  const content = await injectSurfacedContent(
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.0",
6
+ "version": "1.2.1",
7
7
  "description": "File-system driven persistent memory layer for pi coding agent",
8
8
  "license": "MIT",
9
9
  "repository": {
package/src/inject.ts CHANGED
@@ -60,25 +60,15 @@ export async function scanTopics(memoryDir: string): Promise<TopicManifest[]> {
60
60
  return manifests.sort((a, b) => b.mtimeMs - a.mtimeMs);
61
61
  }
62
62
 
63
- export function buildSurfacingPrompt(
64
- manifest: TopicManifest[],
65
- userPrompt: string,
66
- injectedTopics: Set<string>,
67
- ): string {
63
+ function buildSurfacingPrompt(manifest: TopicManifest[], userPrompt: string): string {
68
64
  const lines = manifest.map((t) => {
69
- const marker = injectedTopics.has(t.filename) ? " [already injected]" : "";
70
- return `[${t.type}] ${t.filename} — ${t.description.slice(0, 80)}${marker}`;
65
+ return `[${t.type}] ${t.filename} — ${t.description.slice(0, 80)}`;
71
66
  });
72
- const alreadyInjected =
73
- injectedTopics.size > 0
74
- ? `\n\nNote: ${injectedTopics.size} topic file(s) have already been injected in this session and are marked [already injected]. Prefer selecting uninjected topics.`
75
- : "";
76
67
 
77
68
  return [
78
69
  "You are a memory relevance selector. Below is a list of memory topic files and a user message.",
79
70
  "Select up to N topic files that are relevant to the user's current query.",
80
71
  "Response format: JSON with a 'selected_files' array of filenames.",
81
- alreadyInjected,
82
72
  "",
83
73
  "=== Topic Files ===",
84
74
  ...lines,
@@ -148,19 +138,20 @@ function parseSelectedFiles(result: string, candidates: TopicManifest[], maxFile
148
138
  /** Run a lightweight headless side-query to select relevant topic files.
149
139
  * Returns [] on timeout/failure — no fallback. */
150
140
  export async function runSideQuery(
151
- prompt: string,
152
141
  manifest: TopicManifest[],
142
+ userPrompt: string,
143
+ injectedTopics: Set<string>,
153
144
  maxFiles: number,
154
145
  thinkLevel: ThinkLevel,
155
146
  model: string | undefined,
156
147
  modelRegistry: ModelRegistry,
157
148
  parentModel: Model<any> | undefined,
158
149
  memoryDir: string,
159
- injectedTopics: Set<string>,
160
150
  ): Promise<string[]> {
161
151
  const candidates = manifest.filter((t) => !injectedTopics.has(t.filename));
162
152
  if (candidates.length === 0) return [];
163
- const task = buildSideQueryTask(prompt, maxFiles);
153
+ const surfacingPrompt = buildSurfacingPrompt(candidates, userPrompt);
154
+ const task = buildSideQueryTask(surfacingPrompt, maxFiles);
164
155
  try {
165
156
  const result = await runHeadlessAgent({
166
157
  task,