@henryqw/pi-herdr-rename 5.0.2 → 5.0.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 CHANGED
@@ -44,7 +44,7 @@ A semantic branch is a Git-safe branch name made from a task type and the displa
44
44
 
45
45
  ### Model route
46
46
 
47
- The task `pi-herdr-rename/rename` defaults to the `fast` profile. The shared [`pi-task-models` config](https://pi.henry.wang/extensions/pi-task-models#config) at `~/.pi/agent/config/pi-task-models/config.json` can explicitly override that assignment.
47
+ The task `pi-herdr-rename/rename` uses `fast` only when it has no explicit assignment. To use another configured profile, assign the task to that profile in `/task-models`; the shared [`pi-task-models` config](https://pi.henry.wang/extensions/pi-task-models#config) stores the assignment under `tasks` at `~/.pi/agent/config/pi-task-models/config.json`.
48
48
 
49
49
  The extension tries the assigned profile's primary route, then its fallback, while honoring the configured thinking level. It never substitutes the current session model.
50
50
 
@@ -124,15 +124,18 @@ function latestSessionUserText(ctx: ExtensionContext): string | undefined {
124
124
  }
125
125
 
126
126
  function recentUserMessages(ctx: ExtensionContext, fallback?: string): string | undefined {
127
- const messages = ctx.sessionManager.getBranch().flatMap((entry) => {
128
- if (entry.type !== "message" || entry.message.role !== "user") return [];
127
+ const branch = ctx.sessionManager.getBranch();
128
+ const recentMessages: string[] = [];
129
+ for (let index = branch.length - 1; index >= 0 && recentMessages.length < MAX_CONTEXT_MESSAGES; index--) {
130
+ const entry = branch[index];
131
+ if (entry.type !== "message" || entry.message.role !== "user") continue;
129
132
  const text = messageText(entry.message.content).trim();
130
- return text ? [`user: ${text.slice(0, MAX_MESSAGE_CHARS)}`] : [];
131
- });
132
- if (!messages.length && fallback?.trim()) messages.push(`user: ${fallback.trim().slice(0, MAX_MESSAGE_CHARS)}`);
133
- if (!messages.length) return undefined;
133
+ if (text) recentMessages.push(`user: ${text.slice(0, MAX_MESSAGE_CHARS)}`);
134
+ }
135
+ if (!recentMessages.length && fallback?.trim()) recentMessages.push(`user: ${fallback.trim().slice(0, MAX_MESSAGE_CHARS)}`);
136
+ if (!recentMessages.length) return undefined;
134
137
 
135
- const recentMessages = messages.slice(-MAX_CONTEXT_MESSAGES);
138
+ recentMessages.reverse();
136
139
  const selected: string[] = [];
137
140
  let remaining = MAX_CONTEXT_CHARS;
138
141
  for (let index = recentMessages.length - 1; index >= 0 && remaining > 0; index--) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-herdr-rename",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "Generate short Pi display titles and rename the current Herdr location.",
5
5
  "keywords": [
6
6
  "pi-package",