avorelo 0.1.0 → 0.2.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 (260) hide show
  1. package/LICENSE +23 -16
  2. package/README.md +91 -51
  3. package/bin/avorelo.mjs +7 -0
  4. package/dist/avorelo.mjs +14337 -0
  5. package/package.json +106 -120
  6. package/bin/avorelo +0 -9
  7. package/scripts/README.md +0 -40
  8. package/scripts/cco-dashboard.js +0 -252
  9. package/scripts/cco-status.js +0 -430
  10. package/scripts/lib/activation/account-state.js +0 -37
  11. package/scripts/lib/activation/activation-runner.js +0 -546
  12. package/scripts/lib/activation/activation-self-healing.js +0 -480
  13. package/scripts/lib/activation/activation-state.js +0 -83
  14. package/scripts/lib/activation/activation-summary.js +0 -191
  15. package/scripts/lib/activation/adapters/claude-code.js +0 -77
  16. package/scripts/lib/activation/adapters/codex-cli.js +0 -52
  17. package/scripts/lib/activation/adapters/cursor.js +0 -37
  18. package/scripts/lib/activation/adapters/github-agent.js +0 -39
  19. package/scripts/lib/activation/adapters/terminal.js +0 -42
  20. package/scripts/lib/activation/adapters/vscode.js +0 -39
  21. package/scripts/lib/activation/adapters/windsurf.js +0 -37
  22. package/scripts/lib/activation/ai-surface-detector.js +0 -151
  23. package/scripts/lib/activation/connect-account.js +0 -145
  24. package/scripts/lib/activation/detect-environment.js +0 -75
  25. package/scripts/lib/activation/detect-hosts.js +0 -62
  26. package/scripts/lib/activation/format-activation-output.js +0 -109
  27. package/scripts/lib/activation/next-action.js +0 -43
  28. package/scripts/lib/activation/repair-engine.js +0 -219
  29. package/scripts/lib/activation-distribution-readiness.js +0 -507
  30. package/scripts/lib/adapter-conformance.js +0 -176
  31. package/scripts/lib/adapter-readiness.js +0 -417
  32. package/scripts/lib/adapter-safety-boundaries.js +0 -335
  33. package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
  34. package/scripts/lib/agent-access-governance.js +0 -455
  35. package/scripts/lib/agent-enforcement.js +0 -765
  36. package/scripts/lib/agent-policy-profile.js +0 -210
  37. package/scripts/lib/agent-security/action-evaluator.js +0 -507
  38. package/scripts/lib/agent-security/adapter-registry.js +0 -98
  39. package/scripts/lib/agent-security/auto-policy.js +0 -139
  40. package/scripts/lib/agent-security/bounded-scan.js +0 -93
  41. package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
  42. package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
  43. package/scripts/lib/agent-security/file-write-adapter.js +0 -183
  44. package/scripts/lib/agent-security/file-write-rules.js +0 -178
  45. package/scripts/lib/agent-security/index.js +0 -3342
  46. package/scripts/lib/agent-security/instruction-risk.js +0 -181
  47. package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
  48. package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
  49. package/scripts/lib/agent-security/package-action-adapter.js +0 -175
  50. package/scripts/lib/agent-security/package-action-rules.js +0 -233
  51. package/scripts/lib/agent-security/performance.js +0 -148
  52. package/scripts/lib/agent-security/permission-minimizer.js +0 -403
  53. package/scripts/lib/agent-security/scan-cache.js +0 -74
  54. package/scripts/lib/agent-security/source-trust.js +0 -146
  55. package/scripts/lib/ai-install-prompt.js +0 -288
  56. package/scripts/lib/ai-workspace-hygiene.js +0 -1499
  57. package/scripts/lib/alpha-activation.js +0 -520
  58. package/scripts/lib/alpha-feedback.js +0 -263
  59. package/scripts/lib/alpha-readiness-gate.js +0 -332
  60. package/scripts/lib/anti-gaming.js +0 -169
  61. package/scripts/lib/artifact-health.js +0 -431
  62. package/scripts/lib/attribution.js +0 -180
  63. package/scripts/lib/audit.js +0 -289
  64. package/scripts/lib/avorelo-skill-registry.js +0 -810
  65. package/scripts/lib/batch-jobs.js +0 -71
  66. package/scripts/lib/brain-pack.js +0 -578
  67. package/scripts/lib/brand-boundary.js +0 -424
  68. package/scripts/lib/brand.js +0 -74
  69. package/scripts/lib/browser-capability.js +0 -1048
  70. package/scripts/lib/browser-proof-preflight.js +0 -321
  71. package/scripts/lib/cache-readiness.js +0 -187
  72. package/scripts/lib/canonical-reentry.js +0 -162
  73. package/scripts/lib/capability-packs.js +0 -314
  74. package/scripts/lib/capability-recommender.js +0 -512
  75. package/scripts/lib/capability-registry.js +0 -1059
  76. package/scripts/lib/carry-forward-surfacing.js +0 -194
  77. package/scripts/lib/ccusage-adapter.js +0 -188
  78. package/scripts/lib/company-loop.js +0 -1149
  79. package/scripts/lib/config.js +0 -637
  80. package/scripts/lib/context-acquisition-plan.js +0 -287
  81. package/scripts/lib/context-budget-guard.js +0 -170
  82. package/scripts/lib/context-budget-scanner.js +0 -257
  83. package/scripts/lib/context-optimizer.js +0 -715
  84. package/scripts/lib/context-reduction-plan.js +0 -178
  85. package/scripts/lib/context-safety.js +0 -88
  86. package/scripts/lib/context-savings-engine.js +0 -158
  87. package/scripts/lib/cost-evidence.js +0 -254
  88. package/scripts/lib/cross-host-install-plan.js +0 -308
  89. package/scripts/lib/cross-host-install-readiness.js +0 -237
  90. package/scripts/lib/cross-host-value-flow.js +0 -268
  91. package/scripts/lib/dashboard.js +0 -900
  92. package/scripts/lib/design-partner-feedback.js +0 -346
  93. package/scripts/lib/entitlements.js +0 -100
  94. package/scripts/lib/execution-packet.js +0 -559
  95. package/scripts/lib/experimentation-events.js +0 -547
  96. package/scripts/lib/external-capability-compliance.js +0 -107
  97. package/scripts/lib/external-user-simulation.js +0 -166
  98. package/scripts/lib/failure-recovery-readiness.js +0 -81
  99. package/scripts/lib/failure-recovery.js +0 -419
  100. package/scripts/lib/feedback-intelligence.js +0 -537
  101. package/scripts/lib/feedback-signals.js +0 -205
  102. package/scripts/lib/file-integrity.js +0 -68
  103. package/scripts/lib/fsx.js +0 -127
  104. package/scripts/lib/full-readiness-gate.js +0 -451
  105. package/scripts/lib/guidance-builder.js +0 -174
  106. package/scripts/lib/hook-apply.js +0 -1019
  107. package/scripts/lib/hook-baseline.js +0 -310
  108. package/scripts/lib/hook-config-preview.js +0 -275
  109. package/scripts/lib/hook-contracts.js +0 -290
  110. package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
  111. package/scripts/lib/host-capability-matrix.js +0 -351
  112. package/scripts/lib/host-support-context.js +0 -254
  113. package/scripts/lib/http-hook-action.js +0 -538
  114. package/scripts/lib/install-ai-readiness.js +0 -84
  115. package/scripts/lib/install-intake-risk.js +0 -1037
  116. package/scripts/lib/install-journey-intelligence.js +0 -329
  117. package/scripts/lib/intervention-guidance.js +0 -57
  118. package/scripts/lib/known-limitations.js +0 -115
  119. package/scripts/lib/l8-path-truth.js +0 -146
  120. package/scripts/lib/launch-hardening-gate.js +0 -436
  121. package/scripts/lib/launch-readiness.js +0 -628
  122. package/scripts/lib/learning-memory.js +0 -686
  123. package/scripts/lib/lifecycle-hooks.js +0 -802
  124. package/scripts/lib/local-package-smoke.js +0 -423
  125. package/scripts/lib/local-pricing.js +0 -299
  126. package/scripts/lib/mcp-enforcement.js +0 -311
  127. package/scripts/lib/mcp-least-privilege-policy.js +0 -303
  128. package/scripts/lib/mcp-tool-inventory.js +0 -388
  129. package/scripts/lib/mcp-tool-risk.js +0 -0
  130. package/scripts/lib/memory.js +0 -335
  131. package/scripts/lib/metrics.js +0 -699
  132. package/scripts/lib/micro-proof.js +0 -133
  133. package/scripts/lib/next-run-context.js +0 -436
  134. package/scripts/lib/operating-value.js +0 -1648
  135. package/scripts/lib/optimization-v3.js +0 -122
  136. package/scripts/lib/orchestration/adapters/_shared.js +0 -49
  137. package/scripts/lib/orchestration/adapters/aider.js +0 -18
  138. package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
  139. package/scripts/lib/orchestration/adapters/codex.js +0 -35
  140. package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
  141. package/scripts/lib/orchestration/adapters/git.js +0 -25
  142. package/scripts/lib/orchestration/adapters/index.js +0 -31
  143. package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
  144. package/scripts/lib/orchestration/adapters/ollama.js +0 -18
  145. package/scripts/lib/orchestration/adapters/opencode.js +0 -18
  146. package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
  147. package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
  148. package/scripts/lib/orchestration/cli.js +0 -438
  149. package/scripts/lib/orchestration/execution-manager.js +0 -279
  150. package/scripts/lib/orchestration/handoff.js +0 -314
  151. package/scripts/lib/orchestration/index.js +0 -456
  152. package/scripts/lib/orchestration/inventory.js +0 -47
  153. package/scripts/lib/orchestration/model-discovery.js +0 -498
  154. package/scripts/lib/orchestration/model-profiler.js +0 -170
  155. package/scripts/lib/orchestration/model-profiles.js +0 -252
  156. package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
  157. package/scripts/lib/orchestration/proof-writer.js +0 -349
  158. package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
  159. package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
  160. package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
  161. package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
  162. package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
  163. package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
  164. package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
  165. package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
  166. package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
  167. package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
  168. package/scripts/lib/orchestration/risk-classifier.js +0 -130
  169. package/scripts/lib/orchestration/routing-policy.js +0 -486
  170. package/scripts/lib/orchestration/settings.js +0 -112
  171. package/scripts/lib/orchestration/state.js +0 -165
  172. package/scripts/lib/orchestration/verification-manager.js +0 -138
  173. package/scripts/lib/output-profiles.js +0 -146
  174. package/scripts/lib/package-content-audit.js +0 -368
  175. package/scripts/lib/package-runtime.js +0 -278
  176. package/scripts/lib/plan-surface.js +0 -53
  177. package/scripts/lib/plans.js +0 -2318
  178. package/scripts/lib/policy-provider.js +0 -27
  179. package/scripts/lib/prelaunch-activation-readiness.js +0 -409
  180. package/scripts/lib/prelaunch-evidence-store.js +0 -816
  181. package/scripts/lib/prelaunch-intelligence.js +0 -869
  182. package/scripts/lib/pricing-experiment.js +0 -118
  183. package/scripts/lib/pro-moment-events.js +0 -77
  184. package/scripts/lib/pro-moment-state.js +0 -227
  185. package/scripts/lib/pro-moments.js +0 -1216
  186. package/scripts/lib/product-learning-events.js +0 -629
  187. package/scripts/lib/project-profile.js +0 -555
  188. package/scripts/lib/prompt-compiler.js +0 -280
  189. package/scripts/lib/prompt-lint.js +0 -32
  190. package/scripts/lib/prompt-suggestions.js +0 -52
  191. package/scripts/lib/proof-canonical.js +0 -398
  192. package/scripts/lib/proof-drilldown.js +0 -383
  193. package/scripts/lib/proof-events.js +0 -342
  194. package/scripts/lib/proof-history.js +0 -243
  195. package/scripts/lib/proof-metrics.js +0 -296
  196. package/scripts/lib/proof-outcome-evidence.js +0 -134
  197. package/scripts/lib/proof-receipt.js +0 -335
  198. package/scripts/lib/proof-record.js +0 -461
  199. package/scripts/lib/public-activation-distribution-gate.js +0 -258
  200. package/scripts/lib/public-cli.js +0 -3891
  201. package/scripts/lib/public-distribution-truth.js +0 -211
  202. package/scripts/lib/public-install-claim-checker.js +0 -294
  203. package/scripts/lib/publish-provenance-readiness.js +0 -283
  204. package/scripts/lib/readiness-delta.js +0 -218
  205. package/scripts/lib/readiness-evidence-closure.js +0 -196
  206. package/scripts/lib/reentry-memory-capture.js +0 -241
  207. package/scripts/lib/reentry-memory-retrieval.js +0 -302
  208. package/scripts/lib/reentry-memory-status.js +0 -146
  209. package/scripts/lib/reentry-memory-store.js +0 -178
  210. package/scripts/lib/reentry-state.js +0 -66
  211. package/scripts/lib/release-candidate-bundle.js +0 -166
  212. package/scripts/lib/remediation.js +0 -81
  213. package/scripts/lib/repo-map.js +0 -391
  214. package/scripts/lib/run-improvements-lifecycle.js +0 -330
  215. package/scripts/lib/run-improvements.js +0 -789
  216. package/scripts/lib/runtime-decision-policy.js +0 -387
  217. package/scripts/lib/safe-path-engine.js +0 -705
  218. package/scripts/lib/safe-run-controller.js +0 -887
  219. package/scripts/lib/score.js +0 -262
  220. package/scripts/lib/seamless-enforcement.js +0 -329
  221. package/scripts/lib/seamless-outcome.js +0 -689
  222. package/scripts/lib/seamless-reality-gate.js +0 -5043
  223. package/scripts/lib/security-risk-classifier.js +0 -511
  224. package/scripts/lib/security-scan.js +0 -384
  225. package/scripts/lib/session-context-optimizer.js +0 -1211
  226. package/scripts/lib/session-timing.js +0 -315
  227. package/scripts/lib/skill-hygiene.js +0 -805
  228. package/scripts/lib/skill-packs.js +0 -161
  229. package/scripts/lib/skills-operating-layer.js +0 -580
  230. package/scripts/lib/smart-work-routing.js +0 -768
  231. package/scripts/lib/source-catalog.js +0 -700
  232. package/scripts/lib/status-value-summary.js +0 -32
  233. package/scripts/lib/support-bundle.js +0 -578
  234. package/scripts/lib/task-continuation.js +0 -440
  235. package/scripts/lib/test-helpers.js +0 -15
  236. package/scripts/lib/tier.js +0 -38
  237. package/scripts/lib/token-context-quality-gate.js +0 -370
  238. package/scripts/lib/token-cost-capture.js +0 -187
  239. package/scripts/lib/token-cost-intelligence.js +0 -358
  240. package/scripts/lib/token-efficiency-evidence.js +0 -213
  241. package/scripts/lib/token-evidence.js +0 -699
  242. package/scripts/lib/tokenish.js +0 -17
  243. package/scripts/lib/tool-output-sandbox.js +0 -304
  244. package/scripts/lib/trust-audit.js +0 -136
  245. package/scripts/lib/unified-events.js +0 -396
  246. package/scripts/lib/upgrade-interruption-recovery.js +0 -407
  247. package/scripts/lib/usage-ledger.js +0 -201
  248. package/scripts/lib/value-ledger.js +0 -130
  249. package/scripts/lib/value-proof-calibration.js +0 -531
  250. package/scripts/lib/visual-qa.js +0 -231
  251. package/scripts/lib/voice-alpha.js +0 -29
  252. package/scripts/lib/work-aware-orchestration.js +0 -976
  253. package/scripts/lib/work-control-receipts.js +0 -577
  254. package/scripts/lib/work-ledger.js +0 -1123
  255. package/scripts/lib/work-panel-preview.js +0 -352
  256. package/scripts/lib/workflow-discipline.js +0 -280
  257. package/scripts/lib/workflow-signals.js +0 -419
  258. package/scripts/lib/workspace-map.js +0 -281
  259. package/scripts/lib/workspace-registry.js +0 -1367
  260. package/scripts/lib/workspace-resolver.js +0 -480
@@ -1,802 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("node:fs");
4
- const path = require("node:path");
5
-
6
- const CONTRACT = "avorelo.lifecycleHookHandler.v1";
7
- const SCHEMA_VERSION = 1;
8
-
9
- const HOOKS_DIR_REL = ".claude/cco/orchestration/lifecycle-hooks";
10
-
11
- const DESTRUCTIVE_KEYWORDS = Object.freeze([
12
- "deploy",
13
- "publish",
14
- "delete database",
15
- "drop table",
16
- "rm -rf",
17
- "git clean",
18
- "force push",
19
- "reset --hard",
20
- "secret",
21
- "password",
22
- "api key",
23
- "prod",
24
- "production",
25
- "staging push",
26
- ]);
27
-
28
- function ensureDir(dir) {
29
- fs.mkdirSync(dir, { recursive: true });
30
- }
31
-
32
- function nowIso() {
33
- return new Date().toISOString();
34
- }
35
-
36
- function makeHandlerId() {
37
- return `lh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
38
- }
39
-
40
- function safeWriteJson(filePath, data) {
41
- ensureDir(path.dirname(filePath));
42
- fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
43
- }
44
-
45
- function safeReadJson(filePath) {
46
- try {
47
- return JSON.parse(fs.readFileSync(filePath, "utf8"));
48
- } catch {
49
- return null;
50
- }
51
- }
52
-
53
- function containsDestructiveIntent(text) {
54
- if (!text) return false;
55
- const lower = text.toLowerCase();
56
- return DESTRUCTIVE_KEYWORDS.some((kw) => lower.includes(kw));
57
- }
58
-
59
- function writeReceipt(cwd, event, result) {
60
- const eventSlug = event.toLowerCase().replace(/[^a-z0-9]/g, "-");
61
- const relPath = `${HOOKS_DIR_REL}/latest-${eventSlug}.json`;
62
- const absPath = path.join(cwd, relPath);
63
- safeWriteJson(absPath, result);
64
- return relPath;
65
- }
66
-
67
- function writeLedgerEntry(cwd, event, result) {
68
- try {
69
- const { appendProductLearningEvent } = require("./product-learning-events");
70
- appendProductLearningEvent(cwd, {
71
- eventName: "lifecycle_hook_handler_invoked",
72
- payload: {
73
- event,
74
- handlerId: result.handlerId,
75
- status: result.status,
76
- blocking: result.blocking,
77
- reasonCodes: result.reasonCodes || [],
78
- },
79
- });
80
- } catch {
81
- // product-learning not available — non-fatal
82
- }
83
- }
84
-
85
- // ── SessionStart ─────────────────────────────────────────────────────────────
86
-
87
- function handleSessionStart(cwd, input = {}, options = {}) {
88
- const handlerId = makeHandlerId();
89
- const result = {
90
- contract: CONTRACT,
91
- schemaVersion: SCHEMA_VERSION,
92
- handlerId,
93
- event: "SessionStart",
94
- blocking: false,
95
- status: "ok",
96
- createdAt: nowIso(),
97
- actions: [],
98
- summary: null,
99
- redacted: true,
100
- };
101
-
102
- // Load project profile (cheap, local)
103
- try {
104
- const profilePath = path.join(cwd, ".claude/cco/orchestration/project-profile/latest-profile.json");
105
- const profile = safeReadJson(profilePath);
106
- if (profile) {
107
- result.actions.push({ action: "project_profile_loaded", status: "ok" });
108
- result.projectProfile = {
109
- framework: profile.framework || null,
110
- packageManager: profile.packageManager || null,
111
- allowedActions: profile.allowedActions ? profile.allowedActions.slice(0, 5) : [],
112
- redacted: true,
113
- };
114
- } else {
115
- result.actions.push({ action: "project_profile_loaded", status: "not_found" });
116
- }
117
- } catch {
118
- result.actions.push({ action: "project_profile_loaded", status: "error" });
119
- }
120
-
121
- // Workspace hygiene summary (status only, no heavy scan)
122
- try {
123
- const hygienePath = path.join(cwd, ".claude/cco/orchestration/ai-workspace-hygiene/latest-report.json");
124
- const hygiene = safeReadJson(hygienePath);
125
- if (hygiene) {
126
- result.actions.push({ action: "workspace_hygiene_checked", status: "ok" });
127
- result.workspaceStatus = {
128
- status: hygiene.status || "unknown",
129
- redacted: true,
130
- };
131
- } else {
132
- result.actions.push({ action: "workspace_hygiene_checked", status: "not_found" });
133
- }
134
- } catch {
135
- result.actions.push({ action: "workspace_hygiene_checked", status: "skipped" });
136
- }
137
-
138
- // Auto-inject next-run context if available and not expired
139
- try {
140
- const { loadNextRunContext, buildCompactContextText, updateNextRunContextStatus, emitNextRunContextEvent } = require("./next-run-context");
141
- const nrc = loadNextRunContext(cwd);
142
- if (nrc && nrc.status !== "not_available" && nrc.status !== "expired" && nrc.status !== "insufficient_evidence" && nrc.status !== "error") {
143
- const compactText = buildCompactContextText(nrc);
144
- result.actions.push({ action: "next_run_context_loaded", status: "ok" });
145
- result.nextRunContext = {
146
- status: nrc.status,
147
- defaultsCount: (nrc.appliedDefaults || []).length,
148
- decisionsCount: nrc.activeDecisionCount || 0,
149
- risksCount: nrc.activeRiskCount || 0,
150
- sourceRunFingerprint: nrc.sourceRunFingerprint,
151
- compactText: compactText || null,
152
- artifactPath: ".claude/cco/state/next-run-context.json",
153
- redacted: true,
154
- };
155
- // Mark as injected if it was applied (session-start is the real injection point)
156
- if (nrc.status === "applied") {
157
- const now = nowIso();
158
- updateNextRunContextStatus(cwd, "injected", { injectedAt: now });
159
- emitNextRunContextEvent(cwd, { ...nrc, status: "injected", injectedSurface: "session_start" }, "next_run_context.injected");
160
- result.nextRunContext.status = "injected";
161
- }
162
- } else {
163
- result.actions.push({ action: "next_run_context_loaded", status: nrc ? nrc.status : "not_found" });
164
- }
165
- } catch {
166
- result.actions.push({ action: "next_run_context_loaded", status: "skipped" });
167
- }
168
-
169
- result.summary = "Session state prepared. Project profile, workspace status, and next-run context loaded.";
170
- result.safeNextAction = "Continue session. Avorelo has prepared project/workspace state.";
171
- result.reasonCodes = ["SESSION_STATE_PREPARED", "NON_BLOCKING"];
172
-
173
- const receiptPath = writeReceipt(cwd, "SessionStart", result);
174
- result.receiptPath = receiptPath;
175
- writeLedgerEntry(cwd, "SessionStart", result);
176
-
177
- return result;
178
- }
179
-
180
- // ── UserPromptSubmit ──────────────────────────────────────────────────────────
181
-
182
- function handleUserPromptSubmit(cwd, input = {}, options = {}) {
183
- const handlerId = makeHandlerId();
184
- const taskText = input.prompt || input.taskText || input.task || "";
185
-
186
- const result = {
187
- contract: CONTRACT,
188
- schemaVersion: SCHEMA_VERSION,
189
- handlerId,
190
- event: "UserPromptSubmit",
191
- blocking: false,
192
- status: "ok",
193
- createdAt: nowIso(),
194
- actions: [],
195
- decision: "allow",
196
- summary: null,
197
- redacted: true,
198
- };
199
-
200
- // Check for prohibited intent
201
- if (containsDestructiveIntent(taskText)) {
202
- result.blocking = true;
203
- result.decision = "block";
204
- result.status = "blocked";
205
- result.summary = "Prompt contains prohibited intent (destructive/deploy/secrets/prod). Blocked before routing.";
206
- result.safeNextAction = "Rephrase the task to avoid destructive, deployment, or secrets-related actions.";
207
- result.reasonCodes = ["BLOCKING_PROHIBITED_INTENT", "DESTRUCTIVE_KEYWORDS_DETECTED"];
208
- result.actions.push({ action: "prompt_classified", status: "blocked", reason: "prohibited_intent" });
209
- const receiptPath = writeReceipt(cwd, "UserPromptSubmit", result);
210
- result.receiptPath = receiptPath;
211
- writeLedgerEntry(cwd, "UserPromptSubmit", result);
212
- try {
213
- const { appendProductLearningEvent } = require("./product-learning-events");
214
- appendProductLearningEvent(cwd, {
215
- eventName: "lifecycle_pre_tool_use_blocked",
216
- payload: { event: "UserPromptSubmit", reason: "prohibited_intent", redacted: true },
217
- });
218
- } catch {}
219
- return result;
220
- }
221
-
222
- result.actions.push({ action: "prompt_classified", status: "ok", reason: "safe" });
223
-
224
- // Build safe-run plan (prepare-only, no execution)
225
- if (taskText) {
226
- try {
227
- const { buildSafeRunPlan } = require("./safe-run-controller");
228
- const plan = buildSafeRunPlan(cwd, taskText, { prepareOnly: true });
229
- result.actions.push({ action: "safe_run_plan_built", status: "ok" });
230
- result.safeRunPlan = {
231
- runId: plan.runId || null,
232
- taskType: plan.taskType || null,
233
- riskLevel: plan.riskLevel || null,
234
- steps: plan.steps ? plan.steps.length : 0,
235
- redacted: true,
236
- };
237
- } catch {
238
- result.actions.push({ action: "safe_run_plan_built", status: "skipped" });
239
- }
240
-
241
- // Smart-route
242
- try {
243
- const { classifyTaskForRouting, decideExecutionPath } = require("./smart-work-routing");
244
- const classification = classifyTaskForRouting(taskText);
245
- result.actions.push({ action: "smart_route_classified", status: "ok" });
246
- result.routeClassification = {
247
- taskType: classification.taskType || null,
248
- riskLevel: classification.riskLevel || null,
249
- redacted: true,
250
- };
251
- } catch {
252
- result.actions.push({ action: "smart_route_classified", status: "skipped" });
253
- }
254
-
255
- // Compile execution packet (prepare only)
256
- try {
257
- const { compileExecutionPacket } = require("./execution-packet");
258
- if (typeof compileExecutionPacket === "function") {
259
- const packet = compileExecutionPacket(cwd, { task: taskText, prepareOnly: true });
260
- result.actions.push({ action: "execution_packet_compiled", status: "ok" });
261
- result.executionPacket = {
262
- packetId: packet.packetId || null,
263
- mode: packet.mode || null,
264
- riskLevel: packet.riskLevel || null,
265
- redacted: true,
266
- };
267
- }
268
- } catch {
269
- result.actions.push({ action: "execution_packet_compiled", status: "skipped" });
270
- }
271
- }
272
-
273
- result.summary = "Task classified and safe run plan prepared. No code modified.";
274
- result.safeNextAction = "Continue with the prepared execution plan.";
275
- result.reasonCodes = ["NON_BLOCKING", "TASK_CLASSIFIED", "SAFE_RUN_PLAN_PREPARED"];
276
-
277
- const receiptPath = writeReceipt(cwd, "UserPromptSubmit", result);
278
- result.receiptPath = receiptPath;
279
- writeLedgerEntry(cwd, "UserPromptSubmit", result);
280
-
281
- return result;
282
- }
283
-
284
- // ── PreToolUse ────────────────────────────────────────────────────────────────
285
-
286
- const BLOCKED_TOOL_PATTERNS = Object.freeze([
287
- /deploy/i,
288
- /publish/i,
289
- /drop[_\s]table/i,
290
- /delete[_\s]database/i,
291
- /rm\s+-rf/i,
292
- /git\s+clean/i,
293
- /force[_\s]push/i,
294
- /reset\s+--hard/i,
295
- ]);
296
-
297
- const BLOCKED_INPUT_PATTERNS = Object.freeze([
298
- { key: "command", patterns: [/deploy/i, /publish/i, /rm\s+-rf/i, /git\s+clean/i, /reset\s+--hard/i, /force.*push/i] },
299
- { key: "file_path", patterns: [/\.env$/, /\.pem$/, /\.key$/, /secrets?\./i] },
300
- { key: "path", patterns: [/\.env$/, /\.pem$/, /\.key$/, /secrets?\./i] },
301
- ]);
302
-
303
- function evaluateToolSafety(toolName, toolInput) {
304
- const toolStr = String(toolName || "").toLowerCase();
305
-
306
- // Check tool name for blocked patterns
307
- for (const pat of BLOCKED_TOOL_PATTERNS) {
308
- if (pat.test(toolStr)) {
309
- return {
310
- decision: "block",
311
- reason: `Tool name matches blocked pattern: ${pat}`,
312
- reasonCode: "TOOL_NAME_BLOCKED",
313
- };
314
- }
315
- }
316
-
317
- // Check input fields
318
- const inputObj = typeof toolInput === "object" && toolInput !== null ? toolInput : {};
319
- for (const { key, patterns } of BLOCKED_INPUT_PATTERNS) {
320
- const val = String(inputObj[key] || "");
321
- if (!val) continue;
322
- for (const pat of patterns) {
323
- if (pat.test(val)) {
324
- return {
325
- decision: "block",
326
- reason: `Input field '${key}' matches blocked pattern`,
327
- reasonCode: "INPUT_FIELD_BLOCKED",
328
- };
329
- }
330
- }
331
- }
332
-
333
- // Check for secrets in input values
334
- const inputStr = JSON.stringify(inputObj).toLowerCase();
335
- if (/password|api_key|apikey|secret|token/.test(inputStr)) {
336
- return {
337
- decision: "warn",
338
- reason: "Input may reference sensitive fields (secrets/tokens). Review before proceeding.",
339
- reasonCode: "SENSITIVE_INPUT_DETECTED",
340
- };
341
- }
342
-
343
- return { decision: "allow", reason: "Tool and input appear safe.", reasonCode: "SAFE_TOOL_INPUT" };
344
- }
345
-
346
- function handlePreToolUse(cwd, input = {}, options = {}) {
347
- const handlerId = makeHandlerId();
348
- const toolName = input.tool_name || input.toolName || input.tool || "";
349
- const toolInput = input.tool_input || input.toolInput || input.input || {};
350
-
351
- const result = {
352
- contract: CONTRACT,
353
- schemaVersion: SCHEMA_VERSION,
354
- handlerId,
355
- event: "PreToolUse",
356
- blocking: true,
357
- status: "ok",
358
- createdAt: nowIso(),
359
- actions: [],
360
- decision: "allow",
361
- toolName,
362
- summary: null,
363
- redacted: true,
364
- };
365
-
366
- const safety = evaluateToolSafety(toolName, toolInput);
367
- result.actions.push({ action: "tool_safety_evaluated", status: safety.decision, reason: safety.reason });
368
- result.decision = safety.decision;
369
- result.reasonCode = safety.reasonCode;
370
-
371
- // MCP governance: apply least-privilege policy if tool signal present
372
- if (result.decision !== "block") {
373
- try {
374
- const { decideMcpPreToolUse, writeMcpPreToolUseDecision } = require("./mcp-enforcement");
375
- const mcpDecision = decideMcpPreToolUse(cwd, input, options);
376
- writeMcpPreToolUseDecision(cwd, mcpDecision);
377
- result.actions.push({ action: "mcp_governance_evaluated", status: mcpDecision.decision });
378
- if (mcpDecision.decision === "block" || mcpDecision.decision === "approval_required") {
379
- if (result.decision !== "block") {
380
- result.decision = mcpDecision.decision === "block" ? "block" : "warn";
381
- result.reasonCode = "MCP_GOVERNANCE_DECISION";
382
- result.mcpGovernance = {
383
- decision: mcpDecision.decision,
384
- reasonCodes: (mcpDecision.reasonCodes || []).slice(0, 5),
385
- safeNextAction: mcpDecision.safeNextAction,
386
- };
387
- }
388
- }
389
- } catch {
390
- result.actions.push({ action: "mcp_governance_evaluated", status: "skipped" });
391
- }
392
- }
393
-
394
- if (result.decision === "block") {
395
- result.status = "blocked";
396
- result.summary = `Tool use blocked: ${safety.reason}`;
397
- result.safeNextAction = result.mcpGovernance?.safeNextAction || "Use a safe, whitelisted tool. Avoid destructive/deploy/secrets/prod actions.";
398
- result.reasonCodes = ["BLOCKING_HOOK", "DESTRUCTIVE_OR_SENSITIVE_BLOCKED", safety.reasonCode];
399
-
400
- try {
401
- const { appendProductLearningEvent } = require("./product-learning-events");
402
- appendProductLearningEvent(cwd, {
403
- eventName: "lifecycle_pre_tool_use_blocked",
404
- payload: { event: "PreToolUse", toolName, reasonCode: safety.reasonCode, redacted: true },
405
- });
406
- } catch {}
407
- } else if (safety.decision === "warn") {
408
- result.status = "warn";
409
- result.summary = `Tool use allowed with warning: ${safety.reason}`;
410
- result.safeNextAction = "Proceed with caution. Verify input does not contain secrets or sensitive data.";
411
- result.reasonCodes = ["BLOCKING_HOOK", "ALLOWED_WITH_WARNING", safety.reasonCode];
412
- } else {
413
- result.status = "ok";
414
- result.summary = "Tool use allowed.";
415
- result.safeNextAction = null;
416
- result.reasonCodes = ["BLOCKING_HOOK", "ALLOWED", safety.reasonCode];
417
- }
418
-
419
- // Enforce packet boundaries if packet exists
420
- try {
421
- const packetPath = path.join(cwd, ".claude/cco/orchestration/execution-packet/latest-packet.json");
422
- const packet = safeReadJson(packetPath);
423
- if (packet && packet.blockedScope && Array.isArray(packet.blockedScope)) {
424
- const toolLower = toolName.toLowerCase();
425
- const blocked = packet.blockedScope.some((s) => toolLower.includes(String(s).toLowerCase()));
426
- if (blocked && result.decision !== "block") {
427
- result.decision = "block";
428
- result.status = "blocked";
429
- result.summary = `Tool '${toolName}' is in the blocked scope of the current execution packet.`;
430
- result.safeNextAction = "Review the execution packet blocked scope. This action is not allowed for the current task.";
431
- result.reasonCodes = ["BLOCKING_HOOK", "PACKET_BOUNDARY_ENFORCED"];
432
- result.actions.push({ action: "packet_boundary_checked", status: "blocked", reason: "in_blocked_scope" });
433
- } else {
434
- result.actions.push({ action: "packet_boundary_checked", status: "ok" });
435
- }
436
- } else {
437
- result.actions.push({ action: "packet_boundary_checked", status: "no_packet" });
438
- }
439
- } catch {
440
- result.actions.push({ action: "packet_boundary_checked", status: "skipped" });
441
- }
442
-
443
- const receiptPath = writeReceipt(cwd, "PreToolUse", result);
444
- result.receiptPath = receiptPath;
445
- writeLedgerEntry(cwd, "PreToolUse", result);
446
-
447
- return result;
448
- }
449
-
450
- // ── PostToolUse ───────────────────────────────────────────────────────────────
451
-
452
- function handlePostToolUse(cwd, input = {}, options = {}) {
453
- const handlerId = makeHandlerId();
454
- const toolName = input.tool_name || input.toolName || input.tool || "";
455
-
456
- const result = {
457
- contract: CONTRACT,
458
- schemaVersion: SCHEMA_VERSION,
459
- handlerId,
460
- event: "PostToolUse",
461
- blocking: false,
462
- status: "ok",
463
- createdAt: nowIso(),
464
- actions: [],
465
- summary: null,
466
- redacted: true,
467
- };
468
-
469
- // Record tool result summary (no raw output)
470
- result.actions.push({
471
- action: "tool_result_recorded",
472
- status: "ok",
473
- toolName,
474
- note: "Raw tool output not stored. Status and metadata only.",
475
- });
476
-
477
- // Write product-learning event
478
- try {
479
- const { appendProductLearningEvent } = require("./product-learning-events");
480
- appendProductLearningEvent(cwd, {
481
- eventName: "lifecycle_hook_handler_invoked",
482
- payload: {
483
- event: "PostToolUse",
484
- handlerId,
485
- toolName,
486
- status: "ok",
487
- redacted: true,
488
- },
489
- });
490
- result.actions.push({ action: "product_learning_event_written", status: "ok" });
491
- } catch {
492
- result.actions.push({ action: "product_learning_event_written", status: "skipped" });
493
- }
494
-
495
- result.summary = `Tool '${toolName}' post-use recorded. Ledger and product-learning updated.`;
496
- result.safeNextAction = null;
497
- result.reasonCodes = ["NON_BLOCKING", "LEDGER_UPDATED", "PRODUCT_LEARNING_RECORDED"];
498
-
499
- const receiptPath = writeReceipt(cwd, "PostToolUse", result);
500
- result.receiptPath = receiptPath;
501
- writeLedgerEntry(cwd, "PostToolUse", result);
502
-
503
- return result;
504
- }
505
-
506
- // ── Stop ─────────────────────────────────────────────────────────────────────
507
-
508
- function handleStop(cwd, input = {}, options = {}) {
509
- const handlerId = makeHandlerId();
510
-
511
- const result = {
512
- contract: CONTRACT,
513
- schemaVersion: SCHEMA_VERSION,
514
- handlerId,
515
- event: "Stop",
516
- blocking: true,
517
- status: "ok",
518
- createdAt: nowIso(),
519
- actions: [],
520
- decision: "allow",
521
- proofRequired: false,
522
- proofFound: false,
523
- summary: null,
524
- redacted: true,
525
- };
526
-
527
- // Check execution packet for proof requirements
528
- let proofRequired = false;
529
- try {
530
- const packetPath = path.join(cwd, ".claude/cco/orchestration/execution-packet/latest-packet.json");
531
- const packet = safeReadJson(packetPath);
532
- if (packet) {
533
- proofRequired = !!(packet.proofRequired || (packet.requirements && packet.requirements.proofRequired));
534
- result.actions.push({ action: "execution_packet_checked", status: "ok", proofRequired });
535
- } else {
536
- result.actions.push({ action: "execution_packet_checked", status: "not_found" });
537
- }
538
- } catch {
539
- result.actions.push({ action: "execution_packet_checked", status: "skipped" });
540
- }
541
-
542
- // Check safe-run result for proof
543
- let proofFound = false;
544
- try {
545
- const runPath = path.join(cwd, ".claude/cco/orchestration/safe-run/latest-run.json");
546
- const run = safeReadJson(runPath);
547
- if (run) {
548
- proofFound = !!(run.proofSummary || run.status === "completed" || run.proofGenerated);
549
- result.actions.push({ action: "safe_run_checked", status: "ok", proofFound });
550
- } else {
551
- result.actions.push({ action: "safe_run_checked", status: "not_found" });
552
- }
553
- } catch {
554
- result.actions.push({ action: "safe_run_checked", status: "skipped" });
555
- }
556
-
557
- result.proofRequired = proofRequired;
558
- result.proofFound = proofFound;
559
-
560
- if (proofRequired && !proofFound) {
561
- result.decision = "block";
562
- result.status = "blocked";
563
- result.summary = "Proof required by execution packet but not found. Cannot stop until proof is generated.";
564
- result.safeNextAction = "Run `avorelo run <task>` to generate proof, then stop.";
565
- result.reasonCodes = ["BLOCKING_HOOK", "PROOF_REQUIRED", "PROOF_MISSING"];
566
-
567
- try {
568
- const { appendProductLearningEvent } = require("./product-learning-events");
569
- appendProductLearningEvent(cwd, {
570
- eventName: "lifecycle_stop_proof_required",
571
- payload: { event: "Stop", proofRequired, proofFound, redacted: true },
572
- });
573
- } catch {}
574
- } else {
575
- result.decision = "allow";
576
- result.status = "ok";
577
- if (proofRequired && proofFound) {
578
- result.summary = "Proof found. Stop allowed.";
579
- } else {
580
- result.summary = "Proof not required for this task. Stop allowed.";
581
- }
582
- result.safeNextAction = null;
583
- result.reasonCodes = ["BLOCKING_HOOK", "STOP_ALLOWED"];
584
- }
585
-
586
- const receiptPath = writeReceipt(cwd, "Stop", result);
587
- result.receiptPath = receiptPath;
588
- writeLedgerEntry(cwd, "Stop", result);
589
-
590
- return result;
591
- }
592
-
593
- // ── SessionEnd ────────────────────────────────────────────────────────────────
594
-
595
- function handleSessionEnd(cwd, input = {}, options = {}) {
596
- const handlerId = makeHandlerId();
597
-
598
- const result = {
599
- contract: CONTRACT,
600
- schemaVersion: SCHEMA_VERSION,
601
- handlerId,
602
- event: "SessionEnd",
603
- blocking: false,
604
- status: "ok",
605
- createdAt: nowIso(),
606
- actions: [],
607
- summary: null,
608
- redacted: true,
609
- };
610
-
611
- // Run outcome summary
612
- try {
613
- const outcomePath = path.join(cwd, ".claude/cco/orchestration/seamless-outcome/latest-outcome.json");
614
- const outcome = safeReadJson(outcomePath);
615
- if (outcome) {
616
- result.actions.push({ action: "outcome_summary_read", status: "ok" });
617
- result.outcomeSummary = {
618
- status: outcome.status || "unknown",
619
- redacted: true,
620
- };
621
- } else {
622
- result.actions.push({ action: "outcome_summary_read", status: "not_found" });
623
- }
624
- } catch {
625
- result.actions.push({ action: "outcome_summary_read", status: "skipped" });
626
- }
627
-
628
- // Update ledger (via product-learning event)
629
- try {
630
- const { appendProductLearningEvent } = require("./product-learning-events");
631
- appendProductLearningEvent(cwd, {
632
- eventName: "lifecycle_session_end_summary_written",
633
- payload: {
634
- event: "SessionEnd",
635
- handlerId,
636
- status: "ok",
637
- redacted: true,
638
- },
639
- });
640
- result.actions.push({ action: "ledger_updated", status: "ok" });
641
- } catch {
642
- result.actions.push({ action: "ledger_updated", status: "skipped" });
643
- }
644
-
645
- // Read company-loop status
646
- try {
647
- const loopPath = path.join(cwd, ".claude/cco/orchestration/company-loop/latest-report.json");
648
- const loop = safeReadJson(loopPath);
649
- if (loop) {
650
- result.actions.push({ action: "company_loop_read", status: "ok" });
651
- result.companyLoopStatus = {
652
- status: loop.status || "unknown",
653
- nextPrRecommendation: (loop.surface && loop.surface.recommendedNextPr) || null,
654
- redacted: true,
655
- };
656
- } else {
657
- result.actions.push({ action: "company_loop_read", status: "not_found" });
658
- }
659
- } catch {
660
- result.actions.push({ action: "company_loop_read", status: "skipped" });
661
- }
662
-
663
- // Prepare handoff summary
664
- try {
665
- const handoffPath = path.join(cwd, ".claude/cco/orchestration/worker-handoff/latest-handoff.json");
666
- const handoff = safeReadJson(handoffPath);
667
- if (handoff) {
668
- result.actions.push({ action: "handoff_summary_prepared", status: "ok" });
669
- result.handoffStatus = { available: true, redacted: true };
670
- } else {
671
- result.actions.push({ action: "handoff_summary_prepared", status: "not_found" });
672
- result.handoffStatus = { available: false, redacted: true };
673
- }
674
- } catch {
675
- result.actions.push({ action: "handoff_summary_prepared", status: "skipped" });
676
- result.handoffStatus = { available: false, redacted: true };
677
- }
678
-
679
- result.summary = "Session end: outcome, ledger, company-loop, and handoff updated.";
680
- result.safeNextAction = null;
681
- result.reasonCodes = ["NON_BLOCKING", "OUTCOME_WRITTEN", "LEDGER_UPDATED", "HANDOFF_PREPARED"];
682
-
683
- const receiptPath = writeReceipt(cwd, "SessionEnd", result);
684
- result.receiptPath = receiptPath;
685
- writeLedgerEntry(cwd, "SessionEnd", result);
686
-
687
- return result;
688
- }
689
-
690
- // ── Dispatcher ────────────────────────────────────────────────────────────────
691
-
692
- // ── Recursion guard ───────────────────────────────────────────────────────────
693
- // Prevents Avorelo lifecycle hooks from re-entering when a hook-triggered
694
- // command itself calls another Avorelo command (e.g. lifecycle-hook → run →
695
- // lifecycle-hook). The environment variable is set by the shell hook wrapper
696
- // and checked here before any handler runs.
697
-
698
- const RECURSION_GUARD_ENV = "AVORELO_HOOK_ACTIVE";
699
-
700
- function isRecursionGuardActive() {
701
- return process.env[RECURSION_GUARD_ENV] === "1";
702
- }
703
-
704
- function buildRecursionSkippedResult(event) {
705
- return {
706
- contract: CONTRACT,
707
- schemaVersion: SCHEMA_VERSION,
708
- event,
709
- status: "ok",
710
- recursionSkipped: true,
711
- blocking: false,
712
- decision: "allow",
713
- summary: "Recursion guard active. Lifecycle re-entry skipped.",
714
- reasonCodes: ["RECURSION_GUARD_ACTIVE", "AVORELO_HOOK_ACTIVE_SET"],
715
- redacted: true,
716
- };
717
- }
718
-
719
- function handleLifecycleHook(cwd, event, input = {}, options = {}) {
720
- // Recursion guard: if a hook-triggered command calls us again, skip silently
721
- if (isRecursionGuardActive()) {
722
- return buildRecursionSkippedResult(event);
723
- }
724
-
725
- switch (event) {
726
- case "SessionStart":
727
- case "session-start":
728
- return handleSessionStart(cwd, input, options);
729
- case "UserPromptSubmit":
730
- case "user-prompt-submit":
731
- return handleUserPromptSubmit(cwd, input, options);
732
- case "PreToolUse":
733
- case "pre-tool-use":
734
- return handlePreToolUse(cwd, input, options);
735
- case "PostToolUse":
736
- case "post-tool-use":
737
- return handlePostToolUse(cwd, input, options);
738
- case "Stop":
739
- case "stop":
740
- return handleStop(cwd, input, options);
741
- case "SessionEnd":
742
- case "session-end":
743
- return handleSessionEnd(cwd, input, options);
744
- default:
745
- return {
746
- contract: CONTRACT,
747
- schemaVersion: SCHEMA_VERSION,
748
- event,
749
- status: "error",
750
- error: `Unknown lifecycle event: ${event}`,
751
- reasonCodes: ["UNKNOWN_EVENT"],
752
- redacted: true,
753
- };
754
- }
755
- }
756
-
757
- function formatLifecycleHookText(result, options = {}) {
758
- const debug = options.debug || false;
759
- const lines = [];
760
-
761
- const statusLabel = result.status === "ok" ? "ok" : result.status === "blocked" ? "BLOCKED" : result.status;
762
- lines.push(`Lifecycle hook [${result.event}]: ${statusLabel}`);
763
-
764
- if (result.decision && result.decision !== "allow") {
765
- lines.push(`Decision: ${result.decision}`);
766
- }
767
- if (result.summary) {
768
- lines.push(`Summary: ${result.summary}`);
769
- }
770
- if (result.safeNextAction) {
771
- lines.push(`Next: ${result.safeNextAction}`);
772
- }
773
-
774
- if (debug && result.actions && result.actions.length > 0) {
775
- lines.push("", "Actions:");
776
- for (const a of result.actions) {
777
- lines.push(` - ${a.action}: ${a.status}${a.reason ? ` (${a.reason})` : ""}`);
778
- }
779
- if (result.reasonCodes) {
780
- lines.push("", `Reason codes: ${result.reasonCodes.join(", ")}`);
781
- }
782
- }
783
-
784
- return lines.join("\n");
785
- }
786
-
787
- module.exports = {
788
- CONTRACT,
789
- SCHEMA_VERSION,
790
- HOOKS_DIR_REL,
791
- RECURSION_GUARD_ENV,
792
- handleLifecycleHook,
793
- handleSessionStart,
794
- handleUserPromptSubmit,
795
- handlePreToolUse,
796
- handlePostToolUse,
797
- handleStop,
798
- handleSessionEnd,
799
- formatLifecycleHookText,
800
- isRecursionGuardActive,
801
- buildRecursionSkippedResult,
802
- };