@cydm/pie 4.7.0 → 4.9.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.
Files changed (49) hide show
  1. package/README.md +51 -27
  2. package/dist/builtin/extensions/ask-user/index.js +4 -4
  3. package/dist/builtin/extensions/cron/index.js +916 -162
  4. package/dist/builtin/extensions/im-forward/README.md +24 -7
  5. package/dist/builtin/extensions/im-forward/index.js +6823 -3683
  6. package/dist/builtin/extensions/memory/index.js +76 -28
  7. package/dist/builtin/extensions/pie-ipc/README.md +2 -2
  8. package/dist/builtin/extensions/pie-ipc/index.js +421 -27
  9. package/dist/builtin/extensions/pie-proc/README.md +7 -7
  10. package/dist/builtin/extensions/pie-proc/index.js +453 -97
  11. package/dist/builtin/extensions/plan-mode/index.js +5 -5
  12. package/dist/builtin/extensions/subagent/index.js +8 -8
  13. package/dist/builtin/extensions/todo/index.js +4 -4
  14. package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +35 -24
  15. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +391 -123
  16. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  17. package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +795 -0
  18. package/dist/builtin/skills/chrome-devtools-axi/{cli-NLPMVDGG.js → cli-K7ESY3XD.js} +1437 -231
  19. package/dist/builtin/skills/computer-use-axi/SKILL.md +26 -8
  20. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +465 -83
  21. package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +75 -22
  22. package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +451 -43
  23. package/dist/chunks/{chunk-3W3SXVPB.js → chunk-4UIUMTHG.js} +993 -371
  24. package/dist/chunks/chunk-6WKBQZWM.js +19 -0
  25. package/dist/chunks/{chunk-5KI4Y4LA.js → chunk-BA4Z27XT.js} +4 -3
  26. package/dist/chunks/{chunk-BLDI2GRF.js → chunk-DBDU3RRN.js} +1364 -446
  27. package/dist/chunks/{chunk-LAJXWOKS.js → chunk-EEC5PJTC.js} +11 -9
  28. package/dist/chunks/chunk-IZKHSUNQ.js +30 -0
  29. package/dist/chunks/{chunk-Y3I2UV5Y.js → chunk-LRHNAG4V.js} +349 -288
  30. package/dist/chunks/chunk-OU33ROFD.js +717 -0
  31. package/dist/chunks/{chunk-Z2FKA2ZH.js → chunk-PN6B54VT.js} +104 -22
  32. package/dist/chunks/{chunk-NHV2CALB.js → chunk-WYXUF4MP.js} +388 -32
  33. package/dist/chunks/{chunk-4PR34UZF.js → chunk-Z5KL6AO2.js} +159 -145
  34. package/dist/chunks/{host-image-fallback-N7RHNPYN.js → host-image-fallback-RASJSVZY.js} +1 -1
  35. package/dist/chunks/{manager-cli-NEZA46M5.js → manager-cli-Y6HM3MHA.js} +5 -5
  36. package/dist/chunks/{model-registry-3XAHXXTA.js → model-registry-5TLYILYR.js} +2 -2
  37. package/dist/chunks/{read-file-understanding-FMPXR6EJ.js → read-file-understanding-VPKDBV23.js} +5 -5
  38. package/dist/chunks/{src-B44QWSGM.js → src-2XI5P62J.js} +2 -2
  39. package/dist/chunks/{src-EGXFJ3WA.js → src-6QGGDHIW.js} +3 -3
  40. package/dist/chunks/{src-Q7LU27C2.js → src-CCEENRKC.js} +31 -1
  41. package/dist/chunks/{src-CLE5ILN4.js → src-DI4MCAGT.js} +20 -4
  42. package/dist/chunks/{test-stream-OR3EJBNF.js → test-stream-SYVWIPPW.js} +2 -2
  43. package/dist/cli.js +1918 -1489
  44. package/models.schema.json +271 -0
  45. package/package.json +2 -2
  46. package/dist/builtin/skills/chrome-devtools-axi/chunk-WOGAQ4P5.js +0 -399
  47. package/dist/chunks/chunk-7UAUDXZW.js +0 -1425
  48. package/dist/chunks/{chunk-CGSFBWOM.js → chunk-WBL73KRI.js} +3 -3
  49. package/dist/chunks/{manager-upgrade-CTU3ISCW.js → manager-upgrade-LSTOHBUV.js} +3 -3
@@ -3,11 +3,7 @@ import {
3
3
  distillWorkerLogPath,
4
4
  readDistillWorkerLog,
5
5
  spawnDistillWorker
6
- } from "../../../chunks/chunk-Z2FKA2ZH.js";
7
- import {
8
- getConfigDir,
9
- getSettingsPath
10
- } from "../../../chunks/chunk-CBDQJMUI.js";
6
+ } from "../../../chunks/chunk-PN6B54VT.js";
11
7
  import {
12
8
  DEFAULT_MEMORY_INJECTION_BUDGET,
13
9
  MemoryStore,
@@ -19,10 +15,14 @@ import {
19
15
  saveAttestedEntry,
20
16
  searchMemory,
21
17
  todayKey
22
- } from "../../../chunks/chunk-BLDI2GRF.js";
23
- import "../../../chunks/chunk-Y3I2UV5Y.js";
24
- import "../../../chunks/chunk-5KI4Y4LA.js";
25
- import "../../../chunks/chunk-3W3SXVPB.js";
18
+ } from "../../../chunks/chunk-DBDU3RRN.js";
19
+ import "../../../chunks/chunk-LRHNAG4V.js";
20
+ import "../../../chunks/chunk-BA4Z27XT.js";
21
+ import {
22
+ getConfigDir,
23
+ getSettingsPath
24
+ } from "../../../chunks/chunk-CBDQJMUI.js";
25
+ import "../../../chunks/chunk-4UIUMTHG.js";
26
26
  import {
27
27
  Type
28
28
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -141,6 +141,10 @@ function memoryExtension(ctx) {
141
141
  injectionMemo = null;
142
142
  ctx.log(`[memory] injection memo dropped (${reason})`);
143
143
  };
144
+ ctx.on("session:before_compact", () => {
145
+ refreshInjection("compaction");
146
+ updateFooterTag();
147
+ });
144
148
  ctx.on("agent:end", (event) => {
145
149
  const injectedIds = turnInjectedIds;
146
150
  turnInjectedIds = [];
@@ -182,7 +186,19 @@ function memoryExtension(ctx) {
182
186
  if (!injectOn) return {};
183
187
  const watermark = distillWatermark();
184
188
  if (injectionMemo === null) {
185
- const built = buildInjectionSectionWithIds(store, budget, project.key);
189
+ if (project.allKeys.length > 1) {
190
+ try {
191
+ const aliases = /* @__PURE__ */ new Map();
192
+ for (const alias of project.allKeys) {
193
+ if (alias !== project.key) aliases.set(alias, project.key);
194
+ }
195
+ if (aliases.size > 0 && store.loadEntries().some((e) => e.kind === "project" && e.projectKey !== void 0 && aliases.has(e.projectKey))) {
196
+ store.migrateProjectKeys(aliases);
197
+ }
198
+ } catch {
199
+ }
200
+ }
201
+ const built = buildInjectionSectionWithIds(store, budget, project.allKeys);
186
202
  injectionMemo = {
187
203
  text: built.text,
188
204
  watermark,
@@ -222,7 +238,8 @@ ${injectionMemo.text}` };
222
238
  Type.Literal("thread")
223
239
  ]),
224
240
  text: Type.String({ description: "The durable memory, MAX 240 characters \u2014 write one compact line and count the length before sending; over-length calls are rejected. In the user's dominant language", maxLength: 240 }),
225
- quote: Type.String({ description: "The user's verbatim phrasing that attests this memory, <= 240 chars \u2014 trim with an ellipsis if the source is longer", maxLength: 240, minLength: 1 })
241
+ quote: Type.String({ description: "The user's verbatim phrasing that attests this memory, <= 240 chars \u2014 trim with an ellipsis if the source is longer", maxLength: 240, minLength: 1 }),
242
+ replaces: Type.Optional(Type.String({ description: "Optional existing memory entry ID (from memory_search) to explicitly replace/supersede atomically." }))
226
243
  }),
227
244
  async execute(args) {
228
245
  const { ops, entryId } = saveAttestedEntry(store, {
@@ -232,7 +249,8 @@ ${injectionMemo.text}` };
232
249
  // No fabricated provenance: without a bound session the entry
233
250
  // explicitly records that its source transcript is unknown.
234
251
  sessionId: activeSessionId ?? "session-unbound",
235
- cwd: ctx.cwd
252
+ cwd: ctx.cwd,
253
+ ...args.replaces ? { replaces: args.replaces } : {}
236
254
  });
237
255
  const retired = ops.filter((op) => op.op === "retire").length;
238
256
  return {
@@ -258,14 +276,19 @@ ${injectionMemo.text}` };
258
276
  Type.Literal("thread")
259
277
  ])
260
278
  ),
279
+ projectOnly: Type.Optional(Type.Boolean({ description: "When true, restrict project-kind hits to the current project only." })),
261
280
  limit: Type.Optional(Type.Number({ minimum: 1, maximum: 50 }))
262
281
  }),
263
282
  async execute(args) {
264
- const result = searchMemory(store, args.query, { kind: args.kind, limit: args.limit });
283
+ const result = searchMemory(store, args.query, {
284
+ kind: args.kind,
285
+ limit: args.limit,
286
+ ...args.projectOnly ? { projectKey: project.allKeys } : {}
287
+ });
265
288
  if (result.hits.length === 0) {
266
289
  return { content: [{ type: "text", text: "No memory hits." }] };
267
290
  }
268
- const lines = result.hits.map((hit) => `- [${hit.kind}] ${hit.text} (${hit.path})`);
291
+ const lines = result.hits.map((hit) => `- [${hit.kind}${hit.entryId ? ` id=${hit.entryId}` : ""}] ${hit.text} (${hit.path})`);
269
292
  return {
270
293
  content: [{ type: "text", text: lines.join("\n") + (result.truncated ? "\n(truncated)" : "") }]
271
294
  };
@@ -291,6 +314,7 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
291
314
  const take = (surface, limit, extra) => {
292
315
  const pool = entries.filter((entry) => {
293
316
  if (surface === "project") return entry.kind === "project" && (!extra || extra(entry));
317
+ if (surface === "memory" && entry.kind === "project") return false;
294
318
  return entry.surface === surface && (!extra || extra(entry));
295
319
  }).sort((a, b) => Number(isLowValue(a)) - Number(isLowValue(b)) || b.usageCount - a.usageCount || b.lastAccessed - a.lastAccessed);
296
320
  const kept = [];
@@ -306,7 +330,8 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
306
330
  const user = take("user", budget.user);
307
331
  const memory = take("memory", budget.memory);
308
332
  const threads = take("threads", budget.threads);
309
- const projectLines = projectKey ? take("project", budget.project, (entry) => entry.projectKey === projectKey) : [];
333
+ const projectKeySet = projectKey ? new Set(Array.isArray(projectKey) ? projectKey : [projectKey]) : void 0;
334
+ const projectLines = projectKeySet && projectKeySet.size > 0 ? take("project", budget.project, (entry) => entry.projectKey !== void 0 && projectKeySet.has(entry.projectKey)) : [];
310
335
  const soulRaw = store.readSoul();
311
336
  let soulBudgetTokens = 0;
312
337
  let soulText;
@@ -499,10 +524,12 @@ async function handleMemoryCommand(ctx, store, args, hooks = {}) {
499
524
  case "rollback": {
500
525
  if (!rest[0]) return `snapshots: ${store.listSnapshots().slice(0, 10).join(", ") || "(none)"}`;
501
526
  store.rollback(rest[0]);
502
- return `Rolled back to ${rest[0]}.`;
527
+ hooks?.refreshInjection?.("governance-rollback");
528
+ hooks?.updateFooterTag?.();
529
+ return `Rolled back to ${rest[0]} (injection memo refreshed for next turn).`;
503
530
  }
504
531
  case "distill": {
505
- const date = rest[0] ?? todayKey(Date.now() - 24 * 60 * 60 * 1e3);
532
+ const date = rest[0] ?? yesterdayKey();
506
533
  return triggerDistillWorker(store, date);
507
534
  }
508
535
  case "diff": {
@@ -512,15 +539,29 @@ async function handleMemoryCommand(ctx, store, args, hooks = {}) {
512
539
  }
513
540
  case "status": {
514
541
  const state = store.loadState();
515
- const days = Object.entries(state.runs).sort(([a], [b]) => a < b ? 1 : -1).slice(0, 5);
516
- return days.length === 0 ? "No distillation runs recorded yet." : days.map(([date, run]) => `${date}: ${run.ops} ops at ${new Date(run.ranAt).toISOString()}${run.gated ? " (gated)" : ""}`).join("\n");
542
+ const runs = Object.entries(state.runs).sort(([a], [b]) => a < b ? 1 : -1);
543
+ if (runs.length === 0) {
544
+ return "No distillation runs recorded yet.";
545
+ }
546
+ const lines = [];
547
+ const latestOk = runs.find(([, run]) => (run.failures ?? 0) === 0);
548
+ if (latestOk) {
549
+ lines.push(`Last successful distillation: ${latestOk[0]} (${new Date(latestOk[1].ranAt).toISOString()})`);
550
+ } else {
551
+ lines.push("Last successful distillation: none recorded");
552
+ }
553
+ for (const [date, run] of runs.slice(0, 5)) {
554
+ const failSuffix = run.failures ? ` [FAILED x${run.failures}${run.lastError ? `: ${run.lastError.slice(0, 120)}` : ""}]` : "";
555
+ lines.push(`${date}: ${run.ops} ops at ${new Date(run.ranAt).toISOString()}${run.gated ? " (gated)" : ""}${failSuffix}`);
556
+ }
557
+ return lines.join("\n");
517
558
  }
518
559
  case "log": {
519
560
  const log = readDistillWorkerLog(store.dir, 20);
520
561
  return log.length === 0 ? `No worker log yet (${distillWorkerLogPath(store.dir)}).` : log.join("\n");
521
562
  }
522
563
  case "projects": {
523
- return listProjectSurfaces(store, projectKeyForDir(ctx.cwd).key);
564
+ return listProjectSurfaces(store, projectKeyForDir(ctx.cwd).allKeys);
524
565
  }
525
566
  case "purge": {
526
567
  const id = rest[0] ?? "";
@@ -528,20 +569,26 @@ async function handleMemoryCommand(ctx, store, args, hooks = {}) {
528
569
  if (!entry) return "Entry not found.";
529
570
  if (entry.retiredAt) return `Entry ${id} is already retired.`;
530
571
  store.applyEntryPatch([{ op: "retire", id, reason: "purged via /tools/memory purge" }]);
531
- return `Retired entry ${id} (${entry.kind}): ${entry.text.slice(0, 80)}`;
572
+ hooks?.refreshInjection?.("governance-purge");
573
+ hooks?.updateFooterTag?.();
574
+ return `Retired entry ${id} (${entry.kind}): ${entry.text.slice(0, 80)} (injection memo refreshed for next turn)`;
532
575
  }
533
576
  case "edit": {
534
577
  if (!rest[0] || !rest[1]) return 'Usage: edit <id> "<new text>" (quote the text)';
535
578
  const id = rest[0];
536
579
  const entry = store.entryById(id);
537
580
  if (!entry) return "Entry not found.";
538
- let text = rest.slice(1).join(" ").slice(0, 240);
581
+ let text = rest.slice(1).join(" ").trim();
539
582
  if (text.length >= 2 && (text.startsWith('"') && text.endsWith('"') || text.startsWith("'") && text.endsWith("'"))) {
540
- text = text.slice(1, -1);
583
+ text = text.slice(1, -1).trim();
541
584
  }
542
- if (!text.trim()) return "New text must not be empty.";
543
- store.applyEntryPatch([{ op: "update", id, text, evidence: entry.evidence }]);
544
- return `Updated entry ${id}: ${text}`;
585
+ if (!text) return "New text must not be empty.";
586
+ if (text.includes("\n")) return "New text must be a single line.";
587
+ if (text.length > 240) return `New text exceeds 240 chars (${text.length}); shorten it instead of silent truncation.`;
588
+ store.applyEntryPatch([{ op: "update", id, text, evidence: entry.evidence, provenance: "user-attested" }]);
589
+ hooks?.refreshInjection?.("governance-edit");
590
+ hooks?.updateFooterTag?.();
591
+ return `Updated entry ${id}: ${text} (injection memo refreshed for next turn)`;
545
592
  }
546
593
  default:
547
594
  return `Unknown subcommand: ${sub}`;
@@ -557,13 +604,14 @@ function triggerDistillWorker(store, date) {
557
604
  }
558
605
  return `Distillation worker started for ${date} (detached; progress in ${distillWorkerLogPath(store.dir)}; /tools/memory status after it finishes).`;
559
606
  }
560
- function listProjectSurfaces(store, currentKey) {
607
+ function listProjectSurfaces(store, currentKeys) {
608
+ const currentSet = new Set(Array.isArray(currentKeys) ? currentKeys : [currentKeys]);
561
609
  const keys = store.listProjectKeys();
562
610
  if (keys.length === 0) return "No project memory yet (distillation records project surfaces as projects accumulate).";
563
611
  const lines = keys.map((key) => {
564
612
  const entries = store.loadEntries().filter((entry) => entry.projectKey === key && !entry.retiredAt);
565
613
  const meta = store.readProjectMeta(key);
566
- const current = key === currentKey ? " \u2190 current" : "";
614
+ const current = currentSet.has(key) ? " \u2190 current" : "";
567
615
  return `- ${key}: ${entries.length} entr${entries.length === 1 ? "y" : "ies"}${meta?.gitUrl ? ` (${meta.gitUrl})` : ""}${current}`;
568
616
  });
569
617
  return ["Project memory surfaces:", ...lines].join("\n");
@@ -1,6 +1,6 @@
1
1
  # pie-ipc
2
2
 
3
- Experimental CLI-only local peer messaging on POSIX and verified Windows private local ACL paths. Enabled by default; no broker or core edits.
3
+ CLI-only local peer messaging and zero-LLM control plane on POSIX and verified Windows private local ACL paths. Enabled by default; no broker or core edits.
4
4
 
5
5
  No configuration is required. By default IPC trusts authenticated local clients and auto-injects their messages into interactive sessions. To opt out, create `~/.pie/ipc.json` with `{ "enabled": false }`, then restart/reload. Optional settings, shown here with a restrictive delivery policy, are:
6
6
 
@@ -16,6 +16,6 @@ Absent `allowPeers` defaults to `["*"]`, trusting authenticated local clients; a
16
16
 
17
17
  Use `/tools/ipc peers`, `/tools/ipc status <peer>`, `/tools/ipc send <peer> <text>`, `/tools/ipc result <peer> [requestId]`, `/tools/ipc poll`, `/tools/ipc name`, `/tools/ipc mute [off]`, and `/tools/ipc allow <id|*>`. Only explicit `/tools/ipc poll` submits command output to the model; other commands notify the user. Changes from commands are ephemeral.
18
18
 
19
- Tools: `ipc_list_peers`, `ipc_status`, `ipc_send_notify`, `ipc_result`, `ipc_poll`. Every send exposes a requestId. `ipc_send_notify` — the name is the contract: sending subscribes to completion by DEFAULT (returns after the receipt ack; the peer pushes one `[ipc-done]` message with outcome + bounded answer when its turn settles). On interactive AND embedded resident hosts it is injected (single wake — both are editorInjection hosts); on one-shot headless clients it lands in the pollable inbox with an informational `[ipc-done-check]` hint. A local fallback timer (`fallbackMs`) wakes a result check if no push arrives. Explicit `notify:false` opts out to fire-and-forget (no wake, receipt unconfirmed). Non-waiting requests can be polled with `ipc_result` through accepted/running/done or failed; omitting requestId lists recent results. Reads do not consume results. Results are session-scoped, bounded, retained in memory only, and unknown after eviction/restart. A receipt is not a result: waited results use the original authenticated socket after input consumption and execution settlement. Queued/muted input never receives unrelated turn output. Delivery is bounded, best-effort, not durable; uncertain busy followups are never automatically duplicated. Restart every peer after protocol changes; there is no compatibility layer. Windows uses native HANDLE-based owner checks and private discovery-directory/file ACL checks, with atomic protected directory and temporary-file creation. Ancestor write grants (including sandbox grants on the profile) no longer disable IPC: availability takes precedence over defending against hostile concurrent ancestor mutation. Owner/type checks, observed reparse rejection, and per-operation no-delete handles remain, but these are not a guarantee against path redirection races. Unsafe discovery-directory/file ACLs still fail closed without repair; no user/system ACLs are rewritten and there is no presence-only fallback. Same-user isolation, hostile ancestor mutation, and the stale-advertisement/first-send unencrypted endpoint-identity limitation remain outside this guarantee; see the complete contract below.
19
+ Tools: `ipc_list_peers`, `ipc_status`, `ipc_send_notify`, `ipc_result`, `ipc_poll`, and `self_control`. Peer discovery and control receipts advertise `supportedThinkingLevels` and `effectiveThinkingLevel` alongside `thinkingLevel` (supporting model-declared levels including `max`). Every send exposes a requestId. `ipc_send_notify` — the name is the contract: sending subscribes to completion by DEFAULT (returns after the receipt ack; the peer pushes one `[ipc-done]` message with outcome + bounded answer when its turn settles). On interactive AND embedded resident hosts it is injected (single wake — both are editorInjection hosts); on one-shot headless clients it lands in the pollable inbox with an informational `[ipc-done-check]` hint. A local fallback timer (`fallbackMs`) wakes a result check if no push arrives. Explicit `notify:false` opts out to fire-and-forget (no wake, receipt unconfirmed). Non-waiting requests can be polled with `ipc_result` through accepted/running/done or failed; omitting requestId lists recent results. Reads do not consume results. Results are session-scoped, bounded, retained in memory only, and unknown after eviction/restart. A receipt is not a result: waited results use the original authenticated socket after input consumption and execution settlement. Queued/muted input never receives unrelated turn output. Delivery is bounded, best-effort, not durable; uncertain busy followups are never automatically duplicated. Restart every peer after protocol changes; there is no compatibility layer. Windows uses native HANDLE-based owner checks and private discovery-directory/file ACL checks, with atomic protected directory and temporary-file creation. Ancestor write grants (including sandbox grants on the profile) no longer disable IPC: availability takes precedence over defending against hostile concurrent ancestor mutation. Owner/type checks, observed reparse rejection, and per-operation no-delete handles remain, but these are not a guarantee against path redirection races. Unsafe discovery-directory/file ACLs still fail closed without repair; no user/system ACLs are rewritten and there is no presence-only fallback. Same-user isolation, hostile ancestor mutation, and the stale-advertisement/first-send unencrypted endpoint-identity limitation remain outside this guarantee; see the complete contract below.
20
20
 
21
21
  See [the complete contract](../../../../../docs/pie-ipc.md) for configuration, HMAC/permissions, snapshot freshness, limits, recovery limitations, and reproducible tests including a checked-in two-process factory dogfood driver.