@oh-my-pi/pi-coding-agent 12.2.1 → 12.3.0

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.
@@ -0,0 +1,7 @@
1
+ rollout_path: {{rollout_path}}
2
+ cwd: {{cwd}}
3
+
4
+ Persistable response items (JSON):
5
+ {{response_items_json}}
6
+
7
+ Extract durable memory now.
@@ -0,0 +1,21 @@
1
+ You are memory-stage-one extractor.
2
+
3
+ Return strict JSON only, no markdown, no commentary.
4
+
5
+ Extraction goals:
6
+ - Distill reusable durable knowledge from rollout history.
7
+ - Keep concrete technical signal (constraints, decisions, workflows, pitfalls, resolved failures).
8
+ - Exclude transient chatter and low-signal noise.
9
+
10
+ Output contract (required keys):
11
+ {
12
+ "rollout_summary": "string",
13
+ "rollout_slug": "string | null",
14
+ "raw_memory": "string"
15
+ }
16
+
17
+ Rules:
18
+ - rollout_summary: compact synopsis of what future runs should remember.
19
+ - rollout_slug: short lowercase slug (letters/numbers/_), or null.
20
+ - raw_memory: detailed durable memory blocks with enough context to reuse.
21
+ - If no durable signal exists, return empty strings for rollout_summary/raw_memory and null rollout_slug.
package/src/sdk.ts CHANGED
@@ -46,6 +46,7 @@ import {
46
46
  } from "./internal-urls";
47
47
  import { disposeAllKernelSessions } from "./ipy/executor";
48
48
  import { discoverAndLoadMCPTools, type MCPManager, type MCPToolsLoadResult } from "./mcp";
49
+ import { buildMemoryToolDeveloperInstructions, startMemoryStartupTask } from "./memories";
49
50
  import { AgentSession } from "./session/agent-session";
50
51
  import { AuthStorage } from "./session/auth-storage";
51
52
  import { convertToLlm } from "./session/messages";
@@ -914,6 +915,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
914
915
 
915
916
  const rebuildSystemPrompt = async (toolNames: string[], tools: Map<string, AgentTool>): Promise<string> => {
916
917
  toolContextStore.setToolNames(toolNames);
918
+ const memoryInstructions = await buildMemoryToolDeveloperInstructions(agentDir, settings);
917
919
  const defaultPrompt = await buildSystemPromptInternal({
918
920
  cwd,
919
921
  skills,
@@ -923,6 +925,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
923
925
  toolNames,
924
926
  rules: rulebookRules,
925
927
  skillsSettings: settings.getGroup("skills") as SkillsSettings,
928
+ appendSystemPrompt: memoryInstructions,
926
929
  });
927
930
 
928
931
  if (options.systemPrompt === undefined) {
@@ -939,6 +942,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
939
942
  rules: rulebookRules,
940
943
  skillsSettings: settings.getGroup("skills") as SkillsSettings,
941
944
  customPrompt: options.systemPrompt,
945
+ appendSystemPrompt: memoryInstructions,
942
946
  });
943
947
  }
944
948
  return options.systemPrompt(defaultPrompt);
@@ -1133,6 +1137,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1133
1137
  }
1134
1138
  }
1135
1139
 
1140
+ startMemoryStartupTask({
1141
+ session,
1142
+ settings,
1143
+ modelRegistry,
1144
+ agentDir,
1145
+ taskDepth,
1146
+ });
1147
+
1136
1148
  debugStartup("sdk:return");
1137
1149
  return {
1138
1150
  session,
@@ -998,6 +998,14 @@ export class AgentSession {
998
998
  }
999
999
  }
1000
1000
 
1001
+ /** Rebuild the base system prompt using the current active tool set. */
1002
+ async refreshBaseSystemPrompt(): Promise<void> {
1003
+ if (!this.#rebuildSystemPrompt) return;
1004
+ const activeToolNames = this.getActiveToolNames();
1005
+ this.#baseSystemPrompt = await this.#rebuildSystemPrompt(activeToolNames, this.#toolRegistry);
1006
+ this.agent.setSystemPrompt(this.#baseSystemPrompt);
1007
+ }
1008
+
1001
1009
  /**
1002
1010
  * Replace MCP tools in the registry and activate the latest MCP tool set immediately.
1003
1011
  * This allows /mcp add/remove/reauth to take effect without restarting the session.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as os from "node:os";
5
5
  import { getSystemInfo as getNativeSystemInfo, type SystemInfo } from "@oh-my-pi/pi-natives";
6
- import { $env, logger } from "@oh-my-pi/pi-utils";
6
+ import { $env, hasFsCode, isEnoent, logger } from "@oh-my-pi/pi-utils";
7
7
  import { getGpuCachePath, getProjectDir } from "@oh-my-pi/pi-utils/dirs";
8
8
  import { $ } from "bun";
9
9
  import { contextFileCapability } from "./capability/context-file";
@@ -346,19 +346,18 @@ async function getEnvironmentInfo(): Promise<Array<{ label: string; value: strin
346
346
  export async function resolvePromptInput(input: string | undefined, description: string): Promise<string | undefined> {
347
347
  if (!input) {
348
348
  return undefined;
349
+ } else if (input.includes("\n")) {
350
+ return input;
349
351
  }
350
352
 
351
- const file = Bun.file(input);
352
- if (await file.exists()) {
353
- try {
354
- return await file.text();
355
- } catch (error) {
353
+ try {
354
+ return await Bun.file(input).text();
355
+ } catch (error) {
356
+ if (!hasFsCode(error, "ENAMETOOLONG") && !isEnoent(error)) {
356
357
  logger.warn(`Could not read ${description} file`, { path: input, error: String(error) });
357
- return input;
358
358
  }
359
+ return input;
359
360
  }
360
-
361
- return input;
362
361
  }
363
362
 
364
363
  export interface LoadContextFilesOptions {