@henryqw/pi-herdr-rename 2.1.0 → 2.1.2
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/extensions/rename.ts +14 -24
- package/package.json +3 -3
package/extensions/rename.ts
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { createHerdrClient } from "@henryqw/pi-herdr";
|
|
7
7
|
import {
|
|
8
|
-
orderedProfileRoutes,
|
|
9
8
|
readTaskModelsConfig,
|
|
10
|
-
|
|
9
|
+
resolveConfiguredTaskRoutes,
|
|
11
10
|
type ResolvedTaskRoute,
|
|
11
|
+
type TaskRouteError,
|
|
12
12
|
} from "@henryqw/pi-task-models";
|
|
13
13
|
|
|
14
14
|
const WIDGET_KEY = "pi-herdr-rename";
|
|
@@ -19,7 +19,6 @@ const DISPLAY_MAX_WORDS = 4;
|
|
|
19
19
|
const DISPLAY_MAX_CHARS = 20;
|
|
20
20
|
const SEMANTIC_TYPE_MAX_CHARS = 12;
|
|
21
21
|
const RENAME_TASK = "pi-herdr-rename/rename";
|
|
22
|
-
const DEFAULT_RENAME_PROFILE = "fast" as const;
|
|
23
22
|
const TITLE_STATE_TYPE = "pi-herdr-rename/title";
|
|
24
23
|
const HERDR_DEFAULT_WORKTREE_NAME = /^(?:worktree[-/])?(?:brave|calm|clear|green|lucky|quiet|rapid|silver)-(?:river|cloud|field|forest|harbor|meadow|stone|valley)-[0-9a-f]{4}$/;
|
|
25
24
|
const SEMANTIC_BRANCH = /^[a-z][a-z0-9-]{0,11}\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -29,26 +28,18 @@ type GeneratedTitle = { display: string; branch: string };
|
|
|
29
28
|
class RenameModelError extends Error {}
|
|
30
29
|
|
|
31
30
|
function configuredRenameRoutes(ctx: ExtensionContext): ResolvedTaskRoute[] {
|
|
32
|
-
let config;
|
|
33
31
|
try {
|
|
34
|
-
|
|
35
|
-
} catch {
|
|
36
|
-
|
|
32
|
+
return resolveConfiguredTaskRoutes(ctx, RENAME_TASK);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const { taskRouteCode, profileName } = error as TaskRouteError;
|
|
35
|
+
throw new RenameModelError(
|
|
36
|
+
taskRouteCode === "profile-missing"
|
|
37
|
+
? `Rename task profile ${profileName} is not configured. Run /task-models.`
|
|
38
|
+
: taskRouteCode === "no-route"
|
|
39
|
+
? `Rename task profile ${profileName} has no available route. Run /task-models.`
|
|
40
|
+
: "Couldn't read task model config. Run /task-models.",
|
|
41
|
+
);
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
const profileName = config.tasks[RENAME_TASK] ?? DEFAULT_RENAME_PROFILE;
|
|
40
|
-
const profile = config.profiles[profileName];
|
|
41
|
-
if (!profile) {
|
|
42
|
-
throw new RenameModelError(`Rename task profile ${profileName} is not configured. Run /task-models.`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const routes = orderedProfileRoutes(profile)
|
|
46
|
-
.map((route) => resolveTaskModelRoute(ctx, route))
|
|
47
|
-
.filter((route): route is ResolvedTaskRoute => route !== undefined);
|
|
48
|
-
if (!routes.length) {
|
|
49
|
-
throw new RenameModelError(`Rename task profile ${profileName} has no available route. Run /task-models.`);
|
|
50
|
-
}
|
|
51
|
-
return routes;
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
function parseGeneratedTitle(title: string): GeneratedTitle | undefined {
|
|
@@ -209,8 +200,7 @@ async function generateTitle(text: string, ctx: ExtensionContext, signal: AbortS
|
|
|
209
200
|
}
|
|
210
201
|
|
|
211
202
|
export default function herdrRenameExtension(pi: ExtensionAPI): void {
|
|
212
|
-
const herdr = createHerdrClient<{ signal: AbortSignal }>((
|
|
213
|
-
pi.exec(command, [...args], options));
|
|
203
|
+
const herdr = createHerdrClient<{ signal: AbortSignal }>(pi.exec.bind(pi));
|
|
214
204
|
let latestUserText: string | undefined;
|
|
215
205
|
let automaticStarted = false;
|
|
216
206
|
let automaticPending = false;
|
|
@@ -338,7 +328,7 @@ export default function herdrRenameExtension(pi: ExtensionAPI): void {
|
|
|
338
328
|
latestUserText = latestSessionUserText(ctx);
|
|
339
329
|
try {
|
|
340
330
|
const taskModels = readTaskModelsConfig();
|
|
341
|
-
const profileName = taskModels.tasks[RENAME_TASK]
|
|
331
|
+
const profileName = taskModels.tasks[RENAME_TASK];
|
|
342
332
|
if (!taskModels.profiles[profileName]) {
|
|
343
333
|
ctx.ui.notify(`Configure rename task profile ${profileName} with /task-models.`, "warning");
|
|
344
334
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-herdr-rename",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Generate short Pi display titles and rename the current Herdr location.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@henryqw/pi-herdr": "^0.
|
|
49
|
-
"@henryqw/pi-task-models": "^0.
|
|
48
|
+
"@henryqw/pi-herdr": "^0.3.0",
|
|
49
|
+
"@henryqw/pi-task-models": "^0.7.0"
|
|
50
50
|
}
|
|
51
51
|
}
|