@henryqw/pi-prompt-creator 2.0.6 → 2.0.7

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
@@ -32,6 +32,7 @@ The prompt is created at `~/.pi/agent/prompts/<name>.md`, then Pi reloads its re
32
32
  | Surface | Type | Purpose |
33
33
  | --- | --- | --- |
34
34
  | `/promptor [analyze|dismiss|save [name]|automatic <on\|off>]` | command | For users in the interactive TUI: start or show analysis, dismiss a pending candidate, save a reviewed prompt, or control automatic analysis. |
35
+ | `pi-prompt-creator/draft` | task | For users configuring `/task-models`: choose the child model and thinking level for drafting. |
35
36
  | Analysis status widget and candidate message | ui | Show analysis progress, readiness, or failure; a displayed candidate is marked as untrusted. |
36
37
 
37
38
  ## Flow
@@ -91,7 +92,7 @@ Package-owned: `~/.pi/agent/config/pi-prompt-creator/config.json`
91
92
  | Name | Description | Values | Default |
92
93
  | --- | --- | --- | --- |
93
94
  | `automatic` | Runs automatic analysis after enough user inputs. | Boolean. | `true` |
94
- | `inputThreshold` | Sets the number of non-empty user inputs before automatic analysis. | Positive integer. | `3` |
95
+ | `inputThreshold` | Sets the number of non-empty user inputs before automatic analysis. | Positive safe integer (`1`–`9007199254740991`). | `3` |
95
96
 
96
97
  Edit either field, then run `/reload` to apply the change. Omitted fields use their defaults.
97
98
 
@@ -121,7 +122,7 @@ Candidate and Final Prompt Draft Markdown must be non-empty and at most 16 KiB.
121
122
 
122
123
  Candidate and saved Markdown reject NUL and other terminal controls. Ordinary tabs and line feeds are allowed.
123
124
 
124
- No candidate clears the running widget without a notice. Invalid output or child failure shows `Prompt analysis failed — /promptor`.
125
+ No candidate clears the running widget without a notice. Invalid output or child failure shows `Prompt analysis failed — /promptor`. Failed analysis is not retried automatically; run `/promptor` or `/promptor analyze` to start again.
125
126
 
126
127
  The failure widget clears after the next non-empty user input. Analysis has a two-minute idle timeout and five-minute hard timeout.
127
128
 
@@ -146,34 +146,31 @@ function conversationItem(message: ContextMessage): ConversationItem | undefined
146
146
  }
147
147
 
148
148
  function boundedConversation(messages: ContextMessage[], maxChars: number): ConversationItem[] {
149
- const items = messages.flatMap((message, index) => {
149
+ const items = messages.flatMap((message) => {
150
150
  const item = conversationItem(message);
151
- return item ? [{ index, item, chars: JSON.stringify(item).length }] : [];
151
+ return item ? [item] : [];
152
152
  });
153
153
  let summaryIndex = -1;
154
154
  for (let index = items.length - 1; index >= 0; index--) {
155
- if (items[index]!.item.role === "summary") {
155
+ if (items[index]!.role === "summary") {
156
156
  summaryIndex = index;
157
157
  break;
158
158
  }
159
159
  }
160
- const selected = new Set<number>();
161
- let used = 0;
162
- if (summaryIndex >= 0 && items[summaryIndex]!.chars <= maxChars) {
163
- selected.add(items[summaryIndex]!.index);
164
- used = items[summaryIndex]!.chars;
165
- }
160
+ const summary = items[summaryIndex];
161
+ const summaryChars = summary ? JSON.stringify(summary).length : 0;
162
+ const keepSummary = !!summary && summaryChars <= maxChars;
163
+ const selected: ConversationItem[] = [];
164
+ let used = keepSummary ? summaryChars : 0;
166
165
  for (let index = items.length - 1; index > summaryIndex; index--) {
167
166
  const item = items[index]!;
168
- const cost = item.chars + (selected.size ? 1 : 0);
167
+ const cost = JSON.stringify(item).length + (used ? 1 : 0);
169
168
  if (used + cost > maxChars) continue;
170
- selected.add(item.index);
169
+ selected.push(item);
171
170
  used += cost;
172
171
  }
173
- return items
174
- .slice(summaryIndex < 0 ? 0 : summaryIndex)
175
- .filter(({ index }) => selected.has(index))
176
- .map(({ item }) => item);
172
+ selected.reverse();
173
+ return keepSummary ? [summary, ...selected] : selected;
177
174
  }
178
175
 
179
176
  function analysisPayload(pi: ExtensionAPI, ctx: ExtensionContext): AnalysisPayload {
@@ -378,10 +375,8 @@ export default function promptCreatorExtension(pi: ExtensionAPI, options: Prompt
378
375
  draft: string,
379
376
  requestedName: string | undefined,
380
377
  expectedReview: ReviewBoundary,
381
- expectedBranch: number,
382
378
  ctx: ExtensionCommandContext,
383
379
  ) => {
384
- if (expectedBranch !== branchGeneration || reviewBoundary !== expectedReview) return;
385
380
  const name = requestedName ?? candidateNameHint ?? "";
386
381
  if (!isPromptName(name)) {
387
382
  ctx.ui.notify(`Use lowercase kebab-case starting with a letter, up to ${MAX_NAME_CHARS} characters.`, "warning");
@@ -471,7 +466,6 @@ export default function promptCreatorExtension(pi: ExtensionAPI, options: Prompt
471
466
  ctx.ui.notify("/promptor requires the interactive TUI.", "warning");
472
467
  return;
473
468
  }
474
- const commandBranch = branchGeneration;
475
469
  const review = reviewBoundary;
476
470
  const draft = latestAssistantDraft(ctx, review);
477
471
  const [action = "", ...values] = args.trim().split(/\s+/);
@@ -502,7 +496,7 @@ export default function promptCreatorExtension(pi: ExtensionAPI, options: Prompt
502
496
  ctx.ui.notify("No reviewed Main draft is ready to save.", "warning");
503
497
  return;
504
498
  }
505
- await saveLatestDraft(draft, values[0], review, commandBranch, ctx);
499
+ await saveLatestDraft(draft, values[0], review, ctx);
506
500
  return;
507
501
  }
508
502
  if (action === "automatic" && values.length === 1 && (values[0] === "on" || values[0] === "off")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-prompt-creator",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Turn current Pi conversation signals into user-approved prompt templates.",
5
5
  "keywords": [
6
6
  "pi-package",