@henryqw/pi-prompt-creator 2.0.1 → 2.0.5
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 +1 -1
- package/extensions/prompt-creator.ts +13 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Branch changes reset the input counter. Automatic analysis and candidate widgets
|
|
|
53
53
|
|
|
54
54
|
Only one analysis can run at a time. A pending candidate blocks another analysis.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Manual and automatic analysis send Pi's current model-visible session context to the child model configured through `/task-models`. Session context edits that omit or replace messages are honored; original text removed from model context is not sent to the child. Request-local `context` and `context_with_system` transformations are not included.
|
|
57
57
|
|
|
58
58
|
Its payload includes the active compaction or branch summary, user text, successfully completed assistant text, and effective prompt names and descriptions.
|
|
59
59
|
|
|
@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
|
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import {
|
|
5
5
|
BorderedLoader,
|
|
6
|
+
buildSessionContext,
|
|
6
7
|
getAgentDir,
|
|
7
8
|
type ExtensionAPI,
|
|
8
9
|
type ExtensionCommandContext,
|
|
@@ -62,6 +63,7 @@ The object must have exactly these keys. name must start with a lowercase ASCII
|
|
|
62
63
|
type Config = { automatic: boolean; inputThreshold: number };
|
|
63
64
|
export type PromptCandidate = { name: string; markdown: string };
|
|
64
65
|
type ConversationItem = { role: "summary" | "user" | "assistant"; text: string };
|
|
66
|
+
type ContextMessage = ReturnType<typeof buildSessionContext>["messages"][number];
|
|
65
67
|
type ExistingPrompt = { name: string; description: string };
|
|
66
68
|
type AnalysisPayload = { currentConversation: ConversationItem[]; existingPrompts: ExistingPrompt[] };
|
|
67
69
|
type ActiveRun = { controller: AbortController; branchGeneration: number };
|
|
@@ -133,19 +135,19 @@ function messageText(content: unknown): string {
|
|
|
133
135
|
.join("\n");
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
function conversationItem(
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
138
|
+
function conversationItem(message: ContextMessage): ConversationItem | undefined {
|
|
139
|
+
if (message.role === "compactionSummary" || message.role === "branchSummary") {
|
|
140
|
+
return message.summary.trim() ? { role: "summary", text: message.summary } : undefined;
|
|
139
141
|
}
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
const text = messageText(
|
|
143
|
-
return text.trim() ? { role:
|
|
142
|
+
if (message.role !== "user" && message.role !== "assistant") return;
|
|
143
|
+
if (message.role === "assistant" && message.stopReason !== "stop") return;
|
|
144
|
+
const text = messageText(message.content);
|
|
145
|
+
return text.trim() ? { role: message.role, text } : undefined;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
function boundedConversation(
|
|
147
|
-
const items =
|
|
148
|
-
const item = conversationItem(
|
|
148
|
+
function boundedConversation(messages: ContextMessage[], maxChars: number): ConversationItem[] {
|
|
149
|
+
const items = messages.flatMap((message, index) => {
|
|
150
|
+
const item = conversationItem(message);
|
|
149
151
|
return item ? [{ index, item, chars: JSON.stringify(item).length }] : [];
|
|
150
152
|
});
|
|
151
153
|
let summaryIndex = -1;
|
|
@@ -178,7 +180,7 @@ function analysisPayload(pi: ExtensionAPI, ctx: ExtensionContext): AnalysisPaylo
|
|
|
178
180
|
const payload: AnalysisPayload = { currentConversation: [], existingPrompts: [] };
|
|
179
181
|
const envelopeChars = JSON.stringify(payload).length;
|
|
180
182
|
payload.currentConversation = boundedConversation(
|
|
181
|
-
ctx.sessionManager.
|
|
183
|
+
buildSessionContext(ctx.sessionManager.getEntries(), ctx.sessionManager.getLeafId()).messages,
|
|
182
184
|
MAX_PAYLOAD_CHARS - envelopeChars,
|
|
183
185
|
);
|
|
184
186
|
let used = JSON.stringify(payload).length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-prompt-creator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Turn current Pi conversation signals into user-approved prompt templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@henryqw/pi-config-store": "^2.0.0",
|
|
49
|
-
"@henryqw/pi-subagent": "^
|
|
49
|
+
"@henryqw/pi-subagent": "^22.0.0",
|
|
50
50
|
"@henryqw/pi-task-models": "^7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|