pi-naming 0.3.1 → 0.5.0
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 +4 -4
- package/src/index.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-naming",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Configurable Pi session naming and manual terminal workspace/tab renaming",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"workspace"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"pi-extensions-i18n": "^0.
|
|
61
|
-
"pi-terminal-mux": "^0.6.
|
|
60
|
+
"pi-extensions-i18n": "^0.6.0",
|
|
61
|
+
"pi-terminal-mux": "^0.6.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@earendil-works/pi-coding-agent": ">=0.80.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
69
69
|
"@types/node": "24.12.4",
|
|
70
|
-
"pi-terminal-mux": "^0.6.
|
|
70
|
+
"pi-terminal-mux": "^0.6.3",
|
|
71
71
|
"tsx": "4.23.1",
|
|
72
72
|
"typescript": "5.9.3",
|
|
73
73
|
"@earendil-works/pi-ai": "0.85.1"
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@e
|
|
|
2
2
|
import type { TerminalRenameOutcome, TerminalRenameTarget, ResolveRenameOptions } from "pi-terminal-mux";
|
|
3
3
|
import { configPath, loadConfig, parseConfig, saveConfig, type NamingConfig } from "./config.ts";
|
|
4
4
|
import { i18n } from "./i18n.ts";
|
|
5
|
+
import { installNoticeRenderer, notifyWithSource, type NoticeColor, type NoticeSource } from "pi-extensions-i18n";
|
|
6
|
+
|
|
7
|
+
/** 本扩展的提示标签;短且唯一,便于在会话里定位来源。 */
|
|
8
|
+
const NOTICE_TAG = "naming";
|
|
9
|
+
/** 提示标签颜色;与其它扩展错开,避免看起来像同一条消息。 */
|
|
10
|
+
const NOTICE_COLOR: NoticeColor = "toolTitle";
|
|
11
|
+
/** 本扩展的提示来源。 */
|
|
12
|
+
const NOTICE_SOURCE: NoticeSource = { tag: NOTICE_TAG, color: NOTICE_COLOR };
|
|
5
13
|
import { getCurrentSessionUserMessages, requestSessionNameWithTimeout, type SessionNameRequester } from "./session-name.ts";
|
|
6
14
|
|
|
7
15
|
const RENAME_COMMAND = "rename";
|
|
@@ -44,7 +52,7 @@ function errorMessage(error: unknown): string {
|
|
|
44
52
|
/** 无交互 UI 时仍通过 Pi 消息报告结果,不静默吞错。 */
|
|
45
53
|
function report(pi: ExtensionAPI, ctx: ExtensionContext, notice: { message: string; level: "info" | "warning" | "error" }): void {
|
|
46
54
|
const { message, level } = notice;
|
|
47
|
-
if (ctx.hasUI) ctx
|
|
55
|
+
if (ctx.hasUI) notifyWithSource({ ctx, source: NOTICE_SOURCE, level, message });
|
|
48
56
|
else pi.sendMessage({ customType: MESSAGE_TYPE, content: message, display: true }, { triggerTurn: false });
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -312,6 +320,8 @@ export async function registerNaming(
|
|
|
312
320
|
|
|
313
321
|
/** 配置错误在 session_start 报告,不注册不完整的命名功能。 */
|
|
314
322
|
export default async function namingExtension(pi: ExtensionAPI): Promise<void> {
|
|
323
|
+
// 提示画成会话区里的带底色消息块;渲染器在本包这个模块实例里注册一次。
|
|
324
|
+
installNoticeRenderer(pi);
|
|
315
325
|
registerNamingConfigCommand(pi);
|
|
316
326
|
let config: NamingConfig;
|
|
317
327
|
try { config = loadConfig(); }
|