@ryan_nookpi/pi-extension-auto-name 0.1.1 → 0.1.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/README.md +2 -2
- package/index.ts +3 -3
- package/package.json +11 -1
- package/utils/auto-name-utils.test.ts +1 -1
- package/utils/auto-name-utils.ts +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This extension automatically names a pi session based on the first user message.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It helps you quickly recognize what each session is about when many tasks are open at once.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -25,4 +25,4 @@ pi install npm:@ryan_nookpi/pi-extension-auto-name
|
|
|
25
25
|
|
|
26
26
|
## Example
|
|
27
27
|
|
|
28
|
-
If the first request is something like
|
|
28
|
+
If the first request is something like `Prepare a pre-release checklist`, pi can automatically turn that into a short session title.
|
package/index.ts
CHANGED
|
@@ -65,13 +65,13 @@ export default function autoSessionName(pi: ExtensionAPI) {
|
|
|
65
65
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
66
66
|
if (isSubagentSession(ctx)) return;
|
|
67
67
|
|
|
68
|
-
//
|
|
68
|
+
// name이 이미 있으면 스킵
|
|
69
69
|
if (pi.getSessionName()) return;
|
|
70
70
|
|
|
71
71
|
const text = event.prompt.trim();
|
|
72
72
|
if (!text) return;
|
|
73
73
|
|
|
74
|
-
// Fire-and-forget:
|
|
74
|
+
// Fire-and-forget: 비동기로 name 감지 후 설정
|
|
75
75
|
(async () => {
|
|
76
76
|
try {
|
|
77
77
|
const detected = await detectNameFromMessage(text, ctx);
|
|
@@ -80,7 +80,7 @@ export default function autoSessionName(pi: ExtensionAPI) {
|
|
|
80
80
|
updateStatus(ctx);
|
|
81
81
|
}
|
|
82
82
|
} catch {
|
|
83
|
-
//
|
|
83
|
+
// 실패 시 무시
|
|
84
84
|
}
|
|
85
85
|
})();
|
|
86
86
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryan_nookpi/pi-extension-auto-name",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Auto session name extension for pi.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Jonghakseo/pi-extension.git",
|
|
9
|
+
"directory": "packages/auto-name"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Jonghakseo/pi-extension/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Jonghakseo/pi-extension/tree/main/packages/auto-name#readme",
|
|
5
15
|
"type": "module",
|
|
6
16
|
"keywords": [
|
|
7
17
|
"pi-package"
|
|
@@ -46,7 +46,7 @@ describe("auto-name utils", () => {
|
|
|
46
46
|
it("builds the name context with truncation", () => {
|
|
47
47
|
const message = "m".repeat(MAX_MESSAGE_LENGTH + 25);
|
|
48
48
|
const context = buildNameContext(message);
|
|
49
|
-
expect(context).toBe(
|
|
49
|
+
expect(context).toBe(`사용자 메시지: ${message.slice(0, MAX_MESSAGE_LENGTH)}`);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it("extracts text-only content and clips the result length", () => {
|
package/utils/auto-name-utils.ts
CHANGED
|
@@ -12,7 +12,7 @@ import * as path from "node:path";
|
|
|
12
12
|
export const SUBAGENT_SESSION_DIR = path.join(os.homedir(), ".pi", "agent", "sessions", "subagents");
|
|
13
13
|
|
|
14
14
|
export const NAME_SYSTEM_PROMPT =
|
|
15
|
-
"
|
|
15
|
+
"사용자 메시지를 분석해서 세션의 목적을 20자 이내 한 줄로 추출해. 오직 목적 텍스트만 출력하고, 설명이나 다른 텍스트는 절대 출력하지 마.";
|
|
16
16
|
|
|
17
17
|
/** Max chars for the user message sent to the LLM. */
|
|
18
18
|
export const MAX_MESSAGE_LENGTH = 500;
|
|
@@ -74,7 +74,7 @@ export function formatNameStatus(name: string): string {
|
|
|
74
74
|
* Truncates to MAX_MESSAGE_LENGTH.
|
|
75
75
|
*/
|
|
76
76
|
export function buildNameContext(userMessage: string): string {
|
|
77
|
-
return
|
|
77
|
+
return `사용자 메시지: ${userMessage.slice(0, MAX_MESSAGE_LENGTH)}`;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|