pi-daddy 0.32.1 → 0.35.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 (105) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/contracts/ledger-record/v1/governance-event.schema.json +46 -1
  3. package/dist/advisors/advisor.d.ts +49 -0
  4. package/dist/advisors/advisor.d.ts.map +1 -0
  5. package/dist/advisors/advisor.js +76 -0
  6. package/dist/advisors/advisor.js.map +1 -0
  7. package/dist/advisors/decider.d.ts +79 -0
  8. package/dist/advisors/decider.d.ts.map +1 -0
  9. package/dist/advisors/decider.js +29 -0
  10. package/dist/advisors/decider.js.map +1 -0
  11. package/dist/advisors/jev.d.ts +41 -0
  12. package/dist/advisors/jev.d.ts.map +1 -0
  13. package/dist/advisors/jev.js +108 -0
  14. package/dist/advisors/jev.js.map +1 -0
  15. package/dist/advisors/settings.d.ts +47 -0
  16. package/dist/advisors/settings.d.ts.map +1 -0
  17. package/dist/advisors/settings.js +98 -0
  18. package/dist/advisors/settings.js.map +1 -0
  19. package/dist/executors/activity-session.d.ts.map +1 -1
  20. package/dist/executors/activity-session.js +27 -0
  21. package/dist/executors/activity-session.js.map +1 -1
  22. package/dist/executors/herdr-stage.d.ts +1 -1
  23. package/dist/executors/herdr-stage.d.ts.map +1 -1
  24. package/dist/executors/herdr-stage.js +25 -8
  25. package/dist/executors/herdr-stage.js.map +1 -1
  26. package/dist/governance/ledger-v3-validation.d.ts.map +1 -1
  27. package/dist/governance/ledger-v3-validation.js +1 -0
  28. package/dist/governance/ledger-v3-validation.js.map +1 -1
  29. package/dist/governance/ledger.d.ts +14 -0
  30. package/dist/governance/ledger.d.ts.map +1 -1
  31. package/dist/governance/ledger.js +1 -0
  32. package/dist/governance/ledger.js.map +1 -1
  33. package/dist/kernel/capabilities.d.ts +1 -1
  34. package/dist/kernel/capabilities.d.ts.map +1 -1
  35. package/dist/kernel/capabilities.js +5 -1
  36. package/dist/kernel/capabilities.js.map +1 -1
  37. package/dist/kernel/catalog.d.ts.map +1 -1
  38. package/dist/kernel/catalog.js +6 -0
  39. package/dist/kernel/catalog.js.map +1 -1
  40. package/dist/kernel/chain.d.ts +2 -0
  41. package/dist/kernel/chain.d.ts.map +1 -1
  42. package/dist/kernel/chain.js.map +1 -1
  43. package/dist/kernel/context-handoff.d.ts +85 -0
  44. package/dist/kernel/context-handoff.d.ts.map +1 -0
  45. package/dist/kernel/context-handoff.js +177 -0
  46. package/dist/kernel/context-handoff.js.map +1 -0
  47. package/dist/kernel/delegate-types.d.ts +70 -0
  48. package/dist/kernel/delegate-types.d.ts.map +1 -1
  49. package/dist/kernel/delegate-types.js.map +1 -1
  50. package/dist/kernel/delegate.d.ts.map +1 -1
  51. package/dist/kernel/delegate.js +50 -2
  52. package/dist/kernel/delegate.js.map +1 -1
  53. package/dist/kernel/env-names.d.ts +24 -0
  54. package/dist/kernel/env-names.d.ts.map +1 -1
  55. package/dist/kernel/env-names.js +27 -0
  56. package/dist/kernel/env-names.js.map +1 -1
  57. package/dist/kernel/propagation.d.ts +1 -1
  58. package/dist/kernel/propagation.d.ts.map +1 -1
  59. package/dist/kernel/propagation.js +14 -2
  60. package/dist/kernel/propagation.js.map +1 -1
  61. package/dist/kernel/refusals.d.ts +1 -1
  62. package/dist/kernel/refusals.d.ts.map +1 -1
  63. package/dist/kernel/refusals.js +1 -0
  64. package/dist/kernel/refusals.js.map +1 -1
  65. package/dist/kernel/resolve.d.ts.map +1 -1
  66. package/dist/kernel/resolve.js +4 -0
  67. package/dist/kernel/resolve.js.map +1 -1
  68. package/dist/kernel/spawn.d.ts +21 -0
  69. package/dist/kernel/spawn.d.ts.map +1 -1
  70. package/dist/kernel/spawn.js +8 -1
  71. package/dist/kernel/spawn.js.map +1 -1
  72. package/extensions/advisor-session.ts +64 -0
  73. package/extensions/chain-plan.ts +7 -1
  74. package/extensions/context-shape.ts +30 -0
  75. package/extensions/context-staging.ts +208 -0
  76. package/extensions/delegate-chain.ts +2 -0
  77. package/extensions/delegation-ledger.ts +2 -0
  78. package/extensions/delegation.ts +4 -0
  79. package/extensions/effort-advice.ts +99 -0
  80. package/extensions/execute-child.ts +8 -0
  81. package/extensions/grants-command.ts +10 -0
  82. package/extensions/grants.ts +9 -0
  83. package/extensions/pruning-advice.ts +88 -0
  84. package/extensions/run-delegation.ts +64 -3
  85. package/extensions/session.ts +59 -1
  86. package/package.json +1 -1
  87. package/src/advisors/advisor.ts +123 -0
  88. package/src/advisors/decider.ts +68 -0
  89. package/src/advisors/jev.ts +130 -0
  90. package/src/advisors/settings.ts +113 -0
  91. package/src/executors/activity-session.ts +28 -0
  92. package/src/executors/herdr-stage.ts +26 -8
  93. package/src/governance/ledger-v3-validation.ts +1 -0
  94. package/src/governance/ledger.ts +15 -0
  95. package/src/kernel/capabilities.ts +5 -1
  96. package/src/kernel/catalog.ts +6 -0
  97. package/src/kernel/chain.ts +2 -0
  98. package/src/kernel/context-handoff.ts +231 -0
  99. package/src/kernel/delegate-types.ts +62 -0
  100. package/src/kernel/delegate.ts +56 -2
  101. package/src/kernel/env-names.ts +27 -0
  102. package/src/kernel/propagation.ts +16 -1
  103. package/src/kernel/refusals.ts +1 -0
  104. package/src/kernel/resolve.ts +4 -0
  105. package/src/kernel/spawn.ts +31 -1
@@ -17,6 +17,23 @@ export interface SpawnPlanInput {
17
17
  thinking?: string;
18
18
  /** Session file path, or omit for an ephemeral child. */
19
19
  sessionFile?: string;
20
+ /**
21
+ * `context: fork` (ADR-0078): the parent session to fork, and the private directory the fork is written to.
22
+ *
23
+ * These replace `sessionFile` rather than joining it, because pi refuses `--fork` beside `--session` or
24
+ * `--no-session` (measured in its own argument validation). `--session-id` is accepted beside `--fork`, and it is
25
+ * what makes the forked file findable afterwards: pi names it `<timestamp>_<id>.jsonl` inside the session
26
+ * directory, and only the id half is ours to choose.
27
+ */
28
+ forkFrom?: { sessionPath: string; sessionDir: string; sessionId: string };
29
+ /**
30
+ * Fenced context from the parent, appended to the child's system prompt after the definition body (ADR-0078).
31
+ *
32
+ * Separate from `systemPrompt` because the two have different provenance and the child is told so: a definition
33
+ * body is operator-authored text the grant names, this is what the parent chose to pass on. Kept as its own
34
+ * `--append-system-prompt`, which pi accepts more than once.
35
+ */
36
+ contextPrompt?: string;
20
37
  /** Non-interactive by default: a governed child should not prompt a human. */
21
38
  print?: boolean;
22
39
  /**
@@ -68,7 +85,17 @@ export function planSpawn(input: SpawnPlanInput): SpawnPlan {
68
85
  if (input.provider) args.push("--provider", input.provider);
69
86
  if (input.model) args.push("--model", input.model);
70
87
  if (input.thinking) args.push("--thinking", input.thinking);
71
- if (input.sessionFile) args.push("--session", input.sessionFile);
88
+ // `--fork` is exclusive with both session flags, so the three cases are one decision rather than two.
89
+ if (input.forkFrom)
90
+ args.push(
91
+ "--fork",
92
+ input.forkFrom.sessionPath,
93
+ "--session-dir",
94
+ input.forkFrom.sessionDir,
95
+ "--session-id",
96
+ input.forkFrom.sessionId,
97
+ );
98
+ else if (input.sessionFile) args.push("--session", input.sessionFile);
72
99
  else args.push("--no-session");
73
100
 
74
101
  // Disable discovery so ambient user extensions cannot widen a governed child's surface. Explicit
@@ -116,6 +143,9 @@ export function planSpawn(input: SpawnPlanInput): SpawnPlan {
116
143
  // picks WHICH definition, never its contents. That is what keeps it out of `neutralisePrompt`'s
117
144
  // remit: the G1 hazard is a model-controlled string reaching a parser, and this is not one.
118
145
  if (input.systemPrompt) args.push("--append-system-prompt", input.systemPrompt);
146
+ // After the definition body, so a child reads what it IS before what it was told (ADR-0078). Operator- and
147
+ // parent-authored text, never a model-chosen argv position, so `neutralisePrompt` has no remit here either.
148
+ if (input.contextPrompt) args.push("--append-system-prompt", input.contextPrompt);
119
149
 
120
150
  if (allowlist) args.push("--tools", allowlist.join(","));
121
151
  else args.push("--no-tools");