pi-naming 0.5.2 → 0.5.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/package.json +5 -3
- package/src/session-name.ts +8 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-naming",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Configurable Pi session naming and manual terminal workspace/tab renaming",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"pi-extensions-i18n": "^0.8.0",
|
|
61
|
-
"pi-
|
|
61
|
+
"pi-model-request": "^0.1.1",
|
|
62
|
+
"pi-terminal-mux": "^0.6.6"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"@earendil-works/pi-coding-agent": ">=0.80.0",
|
|
@@ -67,7 +68,8 @@
|
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
69
70
|
"@types/node": "24.12.4",
|
|
70
|
-
"pi-
|
|
71
|
+
"pi-model-request": "^0.1.1",
|
|
72
|
+
"pi-terminal-mux": "^0.6.6",
|
|
71
73
|
"tsx": "4.23.1",
|
|
72
74
|
"typescript": "5.9.3",
|
|
73
75
|
"@earendil-works/pi-ai": "0.85.1"
|
package/src/session-name.ts
CHANGED
|
@@ -3,11 +3,12 @@ import type {
|
|
|
3
3
|
ExtensionContext,
|
|
4
4
|
SessionEntry,
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { createModelRequester } from "pi-model-request";
|
|
6
7
|
import { i18n } from "./i18n.ts";
|
|
7
8
|
import { DEFAULT_TITLE_CONFIG, type TitleConfig } from "./config.ts";
|
|
8
9
|
|
|
9
10
|
/** 生成标题所需的最小 session 上下文;终端消费者可复用该契约。 */
|
|
10
|
-
export type SessionNameContext = Pick<ExtensionContext, "model" | "modelRegistry">;
|
|
11
|
+
export type SessionNameContext = Pick<ExtensionContext, "model" | "modelRegistry" | "sessionManager">;
|
|
11
12
|
|
|
12
13
|
/** 可注入的标题 completion,便于终端消费者和测试复用同一套请求逻辑。 */
|
|
13
14
|
export type SessionNameCompletion = (...args: Parameters<typeof completeSimple>) => ReturnType<typeof completeSimple>;
|
|
@@ -147,12 +148,13 @@ export async function requestSessionName({
|
|
|
147
148
|
throw new Error(i18n.t("sessionNameNoModel"));
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
// 命名请求由扩展自己发出:鉴权与 provider 会话头交给共享请求器,与 Pi 核心行为一致。
|
|
152
|
+
const request = createModelRequester(ctx, {
|
|
153
|
+
base: completion,
|
|
154
|
+
authError: (error) => new Error(i18n.t("sessionNameAuthFailed", { error })),
|
|
155
|
+
});
|
|
154
156
|
|
|
155
|
-
const response = await
|
|
157
|
+
const response = await request(
|
|
156
158
|
model,
|
|
157
159
|
{
|
|
158
160
|
systemPrompt: [
|
|
@@ -171,9 +173,6 @@ export async function requestSessionName({
|
|
|
171
173
|
],
|
|
172
174
|
},
|
|
173
175
|
{
|
|
174
|
-
apiKey: auth.apiKey,
|
|
175
|
-
headers: auth.headers,
|
|
176
|
-
env: auth.env,
|
|
177
176
|
maxTokens: resolveTitleMaxTokens(model, title.maxTokens),
|
|
178
177
|
// 命名不需要高强度推理;档位可配置,降低思考占用预算的波动。
|
|
179
178
|
reasoning: title.effort,
|