pi-crew 0.9.41 → 0.9.44

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 (170) hide show
  1. package/CHANGELOG.md +253 -0
  2. package/README.md +14 -0
  3. package/dist/build-meta.json +6450 -12419
  4. package/dist/index.mjs +57998 -68417
  5. package/dist/index.mjs.map +4 -4
  6. package/docs/migration/atomic-write-v2-migration.md +2 -0
  7. package/docs/superpowers/plans/2026-06-09-fallow-patterns-adoption.md +2 -0
  8. package/package.json +4 -2
  9. package/scripts/README.md +6 -0
  10. package/scripts/build-bundle.mjs +2 -1
  11. package/scripts/check-all-skills.ts +3 -3
  12. package/scripts/dev-runner.mjs +106 -0
  13. package/scripts/postinstall.mjs +6 -2
  14. package/scripts/verify-skill.ts +2 -2
  15. package/src/agents/agent-config.ts +1 -1
  16. package/src/config/config.ts +20 -1
  17. package/src/config/drift-detector.ts +97 -15
  18. package/src/config/resilient-parser.ts +4 -4
  19. package/src/config/types.ts +0 -2
  20. package/src/extension/crew-cleanup.ts +17 -3
  21. package/src/extension/crew-vibes/config.ts +1 -1
  22. package/src/extension/crew-vibes/font-detect.ts +16 -3
  23. package/src/extension/crew-vibes/index.ts +1 -1
  24. package/src/extension/cross-extension-rpc.ts +26 -9
  25. package/src/extension/management.ts +6 -5
  26. package/src/extension/register.ts +58 -1573
  27. package/src/extension/registration/command-registration.ts +57 -0
  28. package/src/extension/registration/commands.ts +7 -2
  29. package/src/extension/registration/context-builder.ts +131 -0
  30. package/src/extension/registration/crash-recovery-cache.ts +54 -0
  31. package/src/extension/registration/foreground-run-controller.ts +238 -0
  32. package/src/extension/registration/hook-registration.ts +119 -0
  33. package/src/extension/registration/lazy-configurers.ts +124 -0
  34. package/src/extension/registration/lifecycle-handlers.ts +731 -0
  35. package/src/extension/registration/observability.ts +33 -4
  36. package/src/extension/registration/registration-types.ts +149 -0
  37. package/src/extension/registration/runtime-cleanup.ts +230 -0
  38. package/src/extension/registration/subagent-manager-setup.ts +211 -0
  39. package/src/extension/registration/tool-registration.ts +50 -0
  40. package/src/extension/registration/wire-cross-extension.ts +37 -0
  41. package/src/extension/rpc-hmac.ts +21 -1
  42. package/src/extension/run-import.ts +3 -3
  43. package/src/extension/team-tool/auto-summarize.ts +4 -4
  44. package/src/extension/team-tool/cancel.ts +5 -5
  45. package/src/extension/team-tool/chain-executor.ts +5 -4
  46. package/src/extension/team-tool/context.ts +11 -1
  47. package/src/extension/team-tool/doctor.ts +2 -1
  48. package/src/extension/team-tool/goal-wrap.ts +2 -2
  49. package/src/extension/team-tool/goal.ts +1 -1
  50. package/src/extension/team-tool/handle-schedule.ts +25 -36
  51. package/src/extension/team-tool/orchestrate.ts +0 -1
  52. package/src/extension/team-tool/parallel-dispatch.ts +5 -0
  53. package/src/extension/team-tool/run.ts +220 -214
  54. package/src/extension/team-tool/workflow-manage.ts +1 -1
  55. package/src/extension/team-tool.ts +69 -16
  56. package/src/hooks/registry.ts +7 -2
  57. package/src/observability/correlation.ts +4 -3
  58. package/src/observability/event-bus.ts +10 -1
  59. package/src/observability/event-to-metric.ts +8 -7
  60. package/src/observability/exporters/adapter.ts +6 -9
  61. package/src/observability/exporters/otlp-exporter.ts +81 -0
  62. package/src/observability/metric-retention.ts +4 -0
  63. package/src/observability/metric-sink.ts +14 -4
  64. package/src/prompt/prompt-runtime.ts +15 -0
  65. package/src/runtime/adaptive-plan.ts +1 -1
  66. package/src/runtime/async-runner.ts +13 -4
  67. package/src/runtime/background-runner.ts +32 -23
  68. package/src/runtime/capability-inventory.ts +1 -1
  69. package/src/runtime/chain-runner.ts +5 -5
  70. package/src/runtime/checkpoint.ts +6 -16
  71. package/src/runtime/child-pi-constants.ts +42 -0
  72. package/src/runtime/child-pi-kill.ts +180 -0
  73. package/src/runtime/child-pi-spawn.ts +234 -0
  74. package/src/runtime/child-pi-steering.ts +128 -0
  75. package/src/runtime/child-pi-streams.ts +296 -0
  76. package/src/runtime/child-pi-transcript.ts +169 -0
  77. package/src/runtime/child-pi.ts +80 -822
  78. package/src/runtime/coalesce-tasks.ts +1 -1
  79. package/src/runtime/compact-stages/tail-capture-stage.ts +1 -1
  80. package/src/runtime/crash-recovery.ts +63 -47
  81. package/src/runtime/delivery-coordinator.ts +1 -1
  82. package/src/runtime/deterministic-ast.ts +2 -2
  83. package/src/runtime/diagnostic-export.ts +2 -1
  84. package/src/runtime/dwf-state-store.ts +5 -0
  85. package/src/runtime/dynamic-workflow-context.ts +78 -18
  86. package/src/runtime/dynamic-workflow-runner.ts +18 -2
  87. package/src/runtime/foreground-control.ts +3 -2
  88. package/src/runtime/goal-evaluator.ts +59 -27
  89. package/src/runtime/goal-loop-runner.ts +46 -13
  90. package/src/runtime/goal-state-store.ts +1 -1
  91. package/src/runtime/handoff-manager.ts +0 -2
  92. package/src/runtime/intercom-bridge.ts +0 -2
  93. package/src/runtime/live-agent-manager.ts +30 -5
  94. package/src/runtime/live-extension-bridge.ts +0 -2
  95. package/src/runtime/live-session-runtime.ts +65 -57
  96. package/src/runtime/manifest-cache.ts +59 -0
  97. package/src/runtime/mcp-proxy.ts +1 -1
  98. package/src/runtime/orphan-worker-registry.ts +3 -3
  99. package/src/runtime/output-validator.ts +1 -1
  100. package/src/runtime/path-overlap.ts +1 -1
  101. package/src/runtime/pi-args.ts +3 -3
  102. package/src/runtime/pi-json-output.ts +4 -3
  103. package/src/runtime/pi-spawn.ts +7 -1
  104. package/src/runtime/pipeline-runner.ts +1 -4
  105. package/src/runtime/post-checks.ts +0 -1
  106. package/src/runtime/retry-runner.ts +1 -1
  107. package/src/runtime/run-coalesced-task-group.ts +18 -23
  108. package/src/runtime/scheduler.ts +2 -0
  109. package/src/runtime/session-resources.ts +1 -1
  110. package/src/runtime/settings-store.ts +31 -1
  111. package/src/runtime/skill-effectiveness.ts +2 -2
  112. package/src/runtime/stale-reconciler.ts +23 -53
  113. package/src/runtime/subagent-manager.ts +19 -3
  114. package/src/runtime/task-output-context.ts +2 -1
  115. package/src/runtime/task-runner/prompt-builder.ts +3 -3
  116. package/src/runtime/task-runner/run-projection.ts +3 -1
  117. package/src/runtime/task-runner/state-helpers.ts +13 -1
  118. package/src/runtime/task-runner.ts +31 -6
  119. package/src/runtime/team-runner.ts +8 -2
  120. package/src/runtime/verification-gates.ts +54 -5
  121. package/src/schema/config-schema.ts +19 -1
  122. package/src/schema/team-tool-schema.ts +2 -0
  123. package/src/skills/discover-skills.ts +25 -15
  124. package/src/state/active-run-registry.ts +0 -1
  125. package/src/state/atomic-write.ts +37 -11
  126. package/src/state/blob-store.ts +3 -9
  127. package/src/state/contracts.ts +5 -1
  128. package/src/state/crew-init.ts +3 -2
  129. package/src/state/decision-ledger.ts +2 -2
  130. package/src/state/event-log-rotation.ts +1 -1
  131. package/src/state/event-log.ts +4 -3
  132. package/src/state/gitignore-manager.ts +2 -1
  133. package/src/state/health-store.ts +5 -2
  134. package/src/state/instinct-store.ts +11 -2
  135. package/src/state/locks.ts +132 -49
  136. package/src/state/mailbox.ts +3 -4
  137. package/src/state/observation-store.ts +1 -13
  138. package/src/state/run-cache.ts +12 -12
  139. package/src/state/run-graph.ts +2 -1
  140. package/src/state/run-metrics.ts +1 -1
  141. package/src/state/schedule.ts +7 -1
  142. package/src/state/state-store.ts +9 -3
  143. package/src/state/tiered-eval.ts +1 -1
  144. package/src/state/worker-atomic-writer.ts +1 -0
  145. package/src/ui/dynamic-border.ts +13 -3
  146. package/src/ui/live-conversation-overlay.ts +7 -27
  147. package/src/ui/live-duration.ts +2 -2
  148. package/src/ui/live-run-sidebar.ts +56 -32
  149. package/src/ui/mascot.ts +19 -13
  150. package/src/ui/powerbar-publisher.ts +244 -178
  151. package/src/ui/render-coalescer.ts +44 -3
  152. package/src/ui/render-diff.ts +2 -2
  153. package/src/ui/run-dashboard.ts +122 -21
  154. package/src/ui/run-event-bus.ts +66 -0
  155. package/src/ui/run-snapshot-cache.ts +84 -81
  156. package/src/ui/settings-overlay.ts +3 -3
  157. package/src/ui/status-colors.ts +24 -0
  158. package/src/ui/tool-progress-formatter.ts +1 -1
  159. package/src/ui/tool-render.ts +3 -3
  160. package/src/ui/transcript-cache.ts +5 -10
  161. package/src/ui/transcript-entries.ts +68 -72
  162. package/src/ui/transcript-viewer.ts +54 -14
  163. package/src/ui/widget/index.ts +26 -15
  164. package/src/ui/widget/widget-model.ts +18 -9
  165. package/src/ui/widget/widget-renderer.ts +2 -5
  166. package/src/utils/fingerprint.ts +1 -1
  167. package/src/utils/paths.ts +1 -1
  168. package/src/utils/project-detector.ts +1 -1
  169. package/src/worktree/worktree-manager.ts +47 -19
  170. package/src/state/atomic-write-v2.ts +0 -108
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Lazy lifecycle/observability configurers for pi-crew.
3
+ *
4
+ * These three small functions wire up the heavy runtime subsystems on
5
+ * the first session_start. They are kept as LAZY dynamic imports because:
6
+ * • `./registration/lifecycle.ts` pulls in notification-router + sink
7
+ * (~10 KB + heavy deps),
8
+ * • `./registration/observability.ts` pulls in HeartbeatWatcher +
9
+ * metric stack (~12 KB + heavy deps).
10
+ *
11
+ * Pre-loading them at register-time would force every cold start of
12
+ * pi-crew to pay the cost even if the user never opens a session.
13
+ *
14
+ * The orchestrator (`register.ts`) installs these via
15
+ * `installLazyConfigurers`, which binds them as `ctx.configureNotifications`,
16
+ * `ctx.configureObservability`, `ctx.configureDeliveryCoordinator`. The
17
+ * session_start handler invokes them via the context — see
18
+ * `lifecycle-handlers.ts`.
19
+ */
20
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
21
+ import { reconcileAllStaleRuns } from "../../runtime/crash-recovery.ts";
22
+ import { appendDeadletter } from "../../runtime/deadletter.ts";
23
+ import { cleanupLegacyOrphanTempDirs, cleanupOrphanTempDirs } from "../../runtime/pi-args.ts";
24
+ import { reconcileOrphanedTempWorkspaces } from "../../runtime/stale-reconciler.ts";
25
+ import { requestPowerbarUpdate } from "../../ui/powerbar-publisher.ts";
26
+ import { logInternalError } from "../../utils/internal-error.ts";
27
+ import type { RegistrationContext } from "./registration-types.ts";
28
+ import { sendAgentWakeUp, sendFollowUp } from "./subagent-helpers.ts";
29
+
30
+ /**
31
+ * Bind the three lazy configurers onto the registration context. After
32
+ * this call:
33
+ * • `ctx.configureNotifications(ctx)` fires the registration/lifecycle
34
+ * install with the bound deps bag.
35
+ * • `ctx.configureObservability(ctx)` fires the registration/observability
36
+ * install (metric registry, OTLP exporter, heartbeat watcher).
37
+ * • `ctx.configureDeliveryCoordinator()` wires the delivery coordinator
38
+ * + overflow tracker (no dynamic import — already loaded by the
39
+ * registration/lifecycle module).
40
+ */
41
+ export function installLazyConfigurers(pi: ExtensionAPI, ctx: RegistrationContext): void {
42
+ ctx.configureNotifications = (extCtx: ExtensionContext): void => {
43
+ void configureNotificationsImpl(pi, ctx, extCtx);
44
+ };
45
+ ctx.configureObservability = (extCtx: ExtensionContext): void => {
46
+ void configureObservabilityImpl(pi, ctx, extCtx);
47
+ };
48
+ ctx.configureDeliveryCoordinator = (): void => {
49
+ void configureDeliveryCoordinatorImpl(pi, ctx);
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Lazy-load registration/lifecycle.ts and wire its notifications system.
55
+ *
56
+ * The deps bag is built once-per-call (cheap — just object literals) so
57
+ * every session_start cycle gets a fresh closure that reads the latest
58
+ * `ctx.currentCtx` and caches.
59
+ */
60
+ async function configureNotificationsImpl(pi: ExtensionAPI, ctx: RegistrationContext, extCtx: ExtensionContext): Promise<void> {
61
+ try {
62
+ // LAZY: registration/lifecycle is heavy (notification-router + sink)
63
+ const lifecycleModule = await import("./lifecycle.ts");
64
+ await lifecycleModule.configureNotifications(extCtx, ctx.lifecycleState, {
65
+ pi,
66
+ widgetState: ctx.widgetState,
67
+ getCurrentCtx: () => ctx.currentCtx,
68
+ getManifestCache: ctx.getManifestCache,
69
+ getRunSnapshotCache: ctx.getRunSnapshotCache,
70
+ requestPowerbarUpdate,
71
+ });
72
+ } catch (error) {
73
+ logInternalError("register.configureNotifications", error);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Lazy-load registration/observability.ts and wire its metric stack.
79
+ *
80
+ * In addition to the metric registry / OTLP exporter, this is where the
81
+ * stale-reconcile and orphan-temp-dir timers are installed — see
82
+ * registration/observability.ts for details.
83
+ */
84
+ async function configureObservabilityImpl(pi: ExtensionAPI, ctx: RegistrationContext, extCtx: ExtensionContext): Promise<void> {
85
+ try {
86
+ // LAZY: registration/observability is heavy (HeartbeatWatcher + metric stack)
87
+ const observabilityModule = await import("./observability.ts");
88
+ await observabilityModule.configureObservability(extCtx, ctx.observabilityState, {
89
+ pi,
90
+ getManifestCache: ctx.getManifestCache,
91
+ notifyOperator: ctx.notifyOperator,
92
+ isCleanedUp: () => ctx.cleanedUp,
93
+ reconcileStaleRuns: (cwd, cache) => reconcileAllStaleRuns(cwd, cache),
94
+ reconcileOrphanedTempWorkspaces: (now, opts) => reconcileOrphanedTempWorkspaces(now, opts),
95
+ cleanupOrphanTempDirs,
96
+ cleanupLegacyOrphanTempDirs,
97
+ appendDeadletter: (manifest, entry) => appendDeadletter(manifest, entry as Parameters<typeof appendDeadletter>[1]),
98
+ importCrashRecovery: ctx.importCrashRecovery,
99
+ });
100
+ } catch (error) {
101
+ logInternalError("register.configureObservability", error);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Wire delivery coordinator + overflow tracker. Uses the
107
+ * registration/lifecycle module's configureDeliveryCoordinator helper.
108
+ * No dynamic import needed — lifecycle is already loaded by configureNotifications.
109
+ */
110
+ async function configureDeliveryCoordinatorImpl(pi: ExtensionAPI, ctx: RegistrationContext): Promise<void> {
111
+ try {
112
+ // LAZY: lifecycle.ts may not be loaded yet if configureNotifications hasn't fired.
113
+ const lifecycleModule = await import("./lifecycle.ts");
114
+ await lifecycleModule.configureDeliveryCoordinator(ctx.lifecycleState, {
115
+ pi,
116
+ observabilityState: ctx.observabilityState,
117
+ notifyOperator: ctx.notifyOperator,
118
+ sendFollowUp,
119
+ sendAgentWakeUp,
120
+ });
121
+ } catch (error) {
122
+ logInternalError("register.configureDeliveryCoordinator", error);
123
+ }
124
+ }