@ryan_nookpi/pi-extension-memory-layer 0.2.1 → 0.2.3
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 +21 -5
- package/inject.ts +2 -0
- package/package.json +1 -1
- package/types.ts +9 -0
package/index.ts
CHANGED
|
@@ -283,6 +283,7 @@ export default function memoryLayerExtension(pi: ExtensionAPI) {
|
|
|
283
283
|
scope: MemoryScope,
|
|
284
284
|
ctx: ExtensionContext,
|
|
285
285
|
interactive = true,
|
|
286
|
+
topic?: string,
|
|
286
287
|
): Promise<{ topic: string; title: string; scope: MemoryScope } | { cancelled: true } | { error: string }> {
|
|
287
288
|
try {
|
|
288
289
|
const displayTitle = title ?? truncateTitle(content);
|
|
@@ -304,9 +305,19 @@ export default function memoryLayerExtension(pi: ExtensionAPI) {
|
|
|
304
305
|
topicSlug = topicChoice.slug;
|
|
305
306
|
topicHeading = topicChoice.heading;
|
|
306
307
|
} else {
|
|
307
|
-
// remember tool path:
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
// remember tool path: use caller-supplied topic when present, else fall back to "general".
|
|
309
|
+
const requested = topic?.trim();
|
|
310
|
+
if (requested) {
|
|
311
|
+
try {
|
|
312
|
+
topicSlug = normalizeTopicInput(requested);
|
|
313
|
+
} catch {
|
|
314
|
+
return { error: `Invalid topic: ${requested}` };
|
|
315
|
+
}
|
|
316
|
+
topicHeading = slugToHeading(topicSlug);
|
|
317
|
+
} else {
|
|
318
|
+
topicSlug = "general";
|
|
319
|
+
topicHeading = "General";
|
|
320
|
+
}
|
|
310
321
|
}
|
|
311
322
|
|
|
312
323
|
await saveMemory(
|
|
@@ -499,13 +510,18 @@ export default function memoryLayerExtension(pi: ExtensionAPI) {
|
|
|
499
510
|
"Defaults to 'project' when ambiguous.",
|
|
500
511
|
parameters: RememberParams,
|
|
501
512
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
502
|
-
const { content, title, scope } = params as {
|
|
513
|
+
const { content, title, scope, topic } = params as {
|
|
514
|
+
content: string;
|
|
515
|
+
title?: string;
|
|
516
|
+
scope: MemoryScope;
|
|
517
|
+
topic?: string;
|
|
518
|
+
};
|
|
503
519
|
|
|
504
520
|
if (!content?.trim()) {
|
|
505
521
|
throw new Error("content가 비어 있습니다.");
|
|
506
522
|
}
|
|
507
523
|
|
|
508
|
-
const result = await saveContent(content, title, scope, ctx, false);
|
|
524
|
+
const result = await saveContent(content, title, scope, ctx, false, topic);
|
|
509
525
|
|
|
510
526
|
if ("cancelled" in result) {
|
|
511
527
|
return { content: [{ type: "text" as const, text: "사용자가 기억 저장을 취소했습니다." }], details: undefined };
|
package/inject.ts
CHANGED
|
@@ -45,5 +45,7 @@ export async function buildMemoryPrompt(projectId?: string): Promise<string | nu
|
|
|
45
45
|
"[Memory Layer]",
|
|
46
46
|
lines.join("\n"),
|
|
47
47
|
"상세 내용은 recall({ query })로 검색 후, 결과의 ID로 recall({ id })를 호출하면 볼 수 있습니다.",
|
|
48
|
+
"새 메모리를 저장할 때는 가능하면 위 인덱스의 기존 토픽(`## xxx.md`)을 remember({ topic: 'xxx' })으로 재사용하세요. " +
|
|
49
|
+
"성격이 명확히 다른 내용일 때만 새 토픽을 만들고, 토픽명은 'coding-rules', 'tooling' 같은 짧은 영문 슬러그를 사용합니다.",
|
|
48
50
|
].join("\n");
|
|
49
51
|
}
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -17,6 +17,15 @@ export const RememberParams = Type.Object({
|
|
|
17
17
|
}),
|
|
18
18
|
title: Type.Optional(Type.String({ description: "Short title/summary for the memory (auto-generated if omitted)" })),
|
|
19
19
|
scope: MemoryScopeSchema,
|
|
20
|
+
topic: Type.Optional(
|
|
21
|
+
Type.String({
|
|
22
|
+
description:
|
|
23
|
+
"Topic slug to group this memory under (e.g. 'coding-rules', 'tooling', 'domain'). " +
|
|
24
|
+
"Strongly prefer reusing an existing topic shown in the Memory Layer index; " +
|
|
25
|
+
"only create a new short english slug when the topic is clearly different. " +
|
|
26
|
+
"Omit to default to 'general'.",
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
20
29
|
});
|
|
21
30
|
|
|
22
31
|
export const RecallParams = Type.Object({
|