feat: added ordered systemPrompt arrays and normalized context prompts

- Converted systemPrompt APIs and state types to ordered `string[]` across agent, AI, and coding-agent surfaces.
- Added `normalizeSystemPrompts` and applied it to context normalization before building provider request payloads.
- Updated AI providers to emit separate normalized prompt blocks/messages instead of a single merged system prompt.
- Removed dedicated `projectPrompt` state and remapped that context into system-context buckets in session, dump, and token accounting.
- Aligned tests and changelogs to pass and assert `systemPrompt` as arrays with ordered prompt semantics.
This commit is contained in:
can1357
2026-05-04 05:34:22 +02:00
parent 1cce2ee96b
commit 8c323666be
110 changed files with 1106 additions and 522 deletions
@@ -94,7 +94,7 @@ export default function (pi: HookAPI) {
const response = await complete(
ctx.model!,
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
{ systemPrompt: [SYSTEM_PROMPT], messages: [userMessage] },
{ apiKey, signal: loader.signal },
);
+1 -1
View File
@@ -85,7 +85,7 @@ export default function (pi: HookAPI) {
const response = await complete(
ctx.model!,
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
{ systemPrompt: [SYSTEM_PROMPT], messages: [userMessage] },
{ apiKey, signal: loader.signal },
);
@@ -7,8 +7,10 @@ import { createAgentSession, SessionManager } from "@oh-my-pi/pi-coding-agent";
// Option 1: Replace prompt entirely
const { session: session1 } = await createAgentSession({
systemPrompt: `You are a helpful assistant that speaks like a pirate.
systemPrompt: [
`You are a helpful assistant that speaks like a pirate.
Always end responses with "Arrr!"`,
],
sessionManager: SessionManager.inMemory(),
});
@@ -24,11 +26,12 @@ console.log("\n");
// Option 2: Modify default prompt (receives default, returns modified)
const { session: session2 } = await createAgentSession({
systemPrompt: defaultPrompt => `${defaultPrompt}
## Additional Instructions
systemPrompt: defaultPrompt => [
...defaultPrompt,
`## Additional Instructions
- Always be concise
- Use bullet points when listing things`,
],
sessionManager: SessionManager.inMemory(),
});
+1 -1
View File
@@ -87,7 +87,7 @@ const { session } = await createAgentSession({
model,
authStorage: customAuth,
modelRegistry: customRegistry,
systemPrompt: "You are helpful.",
systemPrompt: ["You are helpful."],
toolNames: ["read", "bash"],
customTools: [{ tool: myTool }],
hooks: [{ factory: myHook }],