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,321 +0,0 @@
1
- "use strict";
2
-
3
- // ── Browser Proof Preflight ───────────────────────────────────────────────────
4
- // Contract: avorelo.browserProofPreflight.v1
5
- // Answers: "Can avorelo prove value WITHOUT a browser? Is local-first proof path
6
- // viable? Is browser an optional enhancement (not a requirement)?"
7
- // PREFLIGHT ONLY — does NOT launch a browser, does NOT start a server,
8
- // does NOT make network requests.
9
-
10
- const fs = require("fs");
11
- const path = require("path");
12
- const { nowIso } = require("./fsx");
13
- const { appendProductLearningEvent } = require("./product-learning-events");
14
-
15
- const CONTRACT = "avorelo.browserProofPreflight.v1";
16
- const SCHEMA_VERSION = 1;
17
- const ARTIFACT_DIR_REL = ".claude/cco/orchestration/adapter-readiness";
18
- const ARTIFACT_REL = ARTIFACT_DIR_REL + "/latest-browser-proof-preflight.json";
19
-
20
- function safeReadJson(absPath) {
21
- try {
22
- if (!fs.existsSync(absPath)) return null;
23
- return JSON.parse(fs.readFileSync(absPath, "utf8").replace(/^/, ""));
24
- } catch { return null; }
25
- }
26
-
27
- function pass(id, label, evidence, detail) {
28
- return { id, label, status: "pass", evidence: evidence || null, detail: detail || null, safeNextAction: null };
29
- }
30
- function warn(id, label, safeNextAction, evidence, detail) {
31
- return { id, label, status: "warn", evidence: evidence || null, detail: detail || null, safeNextAction: safeNextAction || "Review and resolve." };
32
- }
33
- function blocked(id, label, safeNextAction, evidence, detail) {
34
- return { id, label, status: "blocked", evidence: evidence || null, detail: detail || null, safeNextAction: safeNextAction || "Fix blocker before proceeding." };
35
- }
36
- function info(id, label, evidence, detail) {
37
- return { id, label, status: "info", evidence: evidence || null, detail: detail || null, safeNextAction: null };
38
- }
39
-
40
- // ── Preflight Checks ──────────────────────────────────────────────────────────
41
-
42
- function checkLocalFirstProofPathExists(cwd) {
43
- // Verify that CLI proof path exists (no browser required)
44
- const binPath = path.join(cwd, "bin", "avorelo");
45
- if (!fs.existsSync(binPath)) {
46
- return blocked("local_first_proof_path", "bin/avorelo entry point missing",
47
- "Create bin/avorelo. Local-first proof path is the primary path.",
48
- null, "bin/avorelo not found.");
49
- }
50
-
51
- // Check for proof-receipt command availability via public-cli
52
- const cliPath = path.join(cwd, "scripts/lib/public-cli.js");
53
- if (!fs.existsSync(cliPath)) {
54
- return blocked("local_first_proof_path", "public-cli.js missing",
55
- "scripts/lib/public-cli.js not found. Restore CLI before browser preflight.",
56
- null);
57
- }
58
-
59
- const cliText = fs.readFileSync(cliPath, "utf8");
60
- if (cliText.includes("proof-receipt") || cliText.includes("proof-outcome")) {
61
- return pass("local_first_proof_path", "Local-first proof path available via CLI",
62
- { binExists: true, cliHasProofCommand: true });
63
- }
64
-
65
- return warn("local_first_proof_path", "CLI proof command not found in public-cli.js",
66
- "Add proof-receipt or proof-outcome command to public-cli.js.",
67
- { cliChecked: true });
68
- }
69
-
70
- function checkProofDoesNotRequireBrowser(cwd) {
71
- // Check that existing proof artifacts were generated without browser
72
- const proofPath = path.join(cwd, ".claude/cco/orchestration/proof-outcome/latest-proof-outcome.json");
73
- const proof = safeReadJson(proofPath);
74
- if (!proof) {
75
- return info("proof_no_browser_required", "No proof artifact to inspect",
76
- null, "Proof artifact not yet generated — browser requirement not determinable.");
77
- }
78
-
79
- if (proof.requiresBrowser === true) {
80
- return blocked("proof_no_browser_required", "Proof artifact marks browser as required",
81
- "Update proof generation to work without browser. Browser is an optional enhancement.",
82
- { requiresBrowser: true });
83
- }
84
-
85
- return pass("proof_no_browser_required", "Proof artifact does not require browser",
86
- { requiresBrowser: proof.requiresBrowser || false });
87
- }
88
-
89
- function checkBrowserIsOptionalEnhancement(cwd) {
90
- // Verify documentation states browser is optional
91
- const docsToCheck = [
92
- { relPath: "docs/ACTIVATION.md", pattern: /local|cli|terminal|without.*browser/i },
93
- { relPath: "docs/INSTALL.md", pattern: /local|cli|terminal/i },
94
- { relPath: "README.md", pattern: /local.first|cli|terminal/i },
95
- ];
96
-
97
- let anyDocHasLocalFirst = false;
98
- const found = [];
99
-
100
- for (const { relPath, pattern } of docsToCheck) {
101
- const absPath = path.join(cwd, relPath);
102
- if (!fs.existsSync(absPath)) continue;
103
- try {
104
- const text = fs.readFileSync(absPath, "utf8").slice(0, 5000);
105
- if (pattern.test(text)) {
106
- anyDocHasLocalFirst = true;
107
- found.push(relPath);
108
- }
109
- } catch { /* ignore */ }
110
- }
111
-
112
- if (!anyDocHasLocalFirst) {
113
- return warn("browser_optional_enhancement", "No doc confirms local-first/CLI path without browser",
114
- "Add explicit local-first activation path in docs/ACTIVATION.md or README.md.",
115
- { docsChecked: docsToCheck.map(function(d) { return d.relPath; }) });
116
- }
117
-
118
- return pass("browser_optional_enhancement", "Docs confirm local-first/CLI path exists",
119
- { docsWithLocalFirst: found });
120
- }
121
-
122
- function checkNoBrowserRuntimeDependency(cwd) {
123
- const pkgPath = path.join(cwd, "package.json");
124
- const pkg = safeReadJson(pkgPath);
125
- if (!pkg) {
126
- return warn("no_browser_runtime_dependency", "No package.json found",
127
- "Run from a directory with package.json.",
128
- null);
129
- }
130
-
131
- const allDeps = Object.assign({},
132
- pkg.dependencies || {},
133
- pkg.devDependencies || {}
134
- );
135
-
136
- // Check for browser-specific runtime dependencies that would block local-first
137
- const browserRuntimeDeps = Object.keys(allDeps).filter(function(dep) {
138
- // playwright/puppeteer as prod dependency (not devDependency) would be a concern
139
- return /^playwright$|^puppeteer$/.test(dep) && (pkg.dependencies || {})[dep];
140
- });
141
-
142
- if (browserRuntimeDeps.length > 0) {
143
- return warn("no_browser_runtime_dependency",
144
- "Browser runtime dependencies in prod dependencies: " + browserRuntimeDeps.join(", "),
145
- "Move playwright/puppeteer to devDependencies. Browser should not be required at runtime.",
146
- { deps: browserRuntimeDeps });
147
- }
148
-
149
- return pass("no_browser_runtime_dependency", "No browser runtime dependencies in prod deps",
150
- { checked: Object.keys(allDeps).length });
151
- }
152
-
153
- function checkBrowserProofDocsOrPlanned(cwd) {
154
- // Check if browser proof is at least documented as a future enhancement
155
- const browserProofDocs = [
156
- "docs/browser-proof.md",
157
- "docs/product/browser-proof.md",
158
- "docs/Browser-Capability-Governance.md",
159
- ];
160
-
161
- for (const relPath of browserProofDocs) {
162
- if (fs.existsSync(path.join(cwd, relPath))) {
163
- return pass("browser_proof_docs_or_planned", "Browser proof documented",
164
- { path: relPath });
165
- }
166
- }
167
-
168
- // Check if mentioned in roadmap
169
- const roadmapPath = path.join(cwd, "docs/Roadmap.md");
170
- if (fs.existsSync(roadmapPath)) {
171
- try {
172
- const text = fs.readFileSync(roadmapPath, "utf8").slice(0, 10000);
173
- if (/browser.*proof|browser.*capability|browser.*enhancement/i.test(text)) {
174
- return pass("browser_proof_docs_or_planned", "Browser proof mentioned in Roadmap.md",
175
- { path: "docs/Roadmap.md" });
176
- }
177
- } catch { /* ignore */ }
178
- }
179
-
180
- return info("browser_proof_docs_or_planned", "Browser proof not yet documented as planned feature",
181
- null, "Optional — document when browser proof is on the roadmap.");
182
- }
183
-
184
- // ── Build Browser Proof Preflight ─────────────────────────────────────────────
185
-
186
- function buildBrowserProofPreflight(cwd, options) {
187
- const checks = [
188
- checkLocalFirstProofPathExists(cwd),
189
- checkProofDoesNotRequireBrowser(cwd),
190
- checkBrowserIsOptionalEnhancement(cwd),
191
- checkNoBrowserRuntimeDependency(cwd),
192
- checkBrowserProofDocsOrPlanned(cwd),
193
- ];
194
-
195
- const blockers = checks.filter(function(c) { return c.status === "blocked"; });
196
- const warnings = checks.filter(function(c) { return c.status === "warn"; });
197
-
198
- var status;
199
- if (blockers.length > 0) {
200
- status = "blocked";
201
- } else if (warnings.length > 0) {
202
- status = "warn";
203
- } else {
204
- status = "pass";
205
- }
206
-
207
- const safeNextAction = blockers.length > 0
208
- ? "Fix preflight blockers. Ensure local-first proof path works without browser."
209
- : warnings.length > 0
210
- ? "Review preflight warnings. Document local-first activation path and browser-optional stance."
211
- : "Browser proof preflight passed. Local-first proof path verified. Browser is optional enhancement.";
212
-
213
- return {
214
- contract: CONTRACT,
215
- schemaVersion: SCHEMA_VERSION,
216
- generatedAt: nowIso(),
217
- status,
218
- checks,
219
- localFirstPathVerified: !blockers.some(function(b) { return b.id === "local_first_proof_path"; }),
220
- browserRequired: false, // Preflight asserts browser is never required for core value
221
- browserOptionalEnhancement: true,
222
- blockerCount: blockers.length,
223
- warningCount: warnings.length,
224
- safeNextAction,
225
- noPublicLaunchClaim: true,
226
- noBrowserLaunch: true, // This module never launches a browser
227
- redacted: true,
228
- };
229
- }
230
-
231
- // ── Write ─────────────────────────────────────────────────────────────────────
232
-
233
- function writeBrowserProofPreflight(cwd, preflight) {
234
- const dir = path.join(cwd, ARTIFACT_DIR_REL);
235
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
236
- fs.writeFileSync(path.join(cwd, ARTIFACT_REL), JSON.stringify(preflight, null, 2));
237
- }
238
-
239
- // ── Surface ───────────────────────────────────────────────────────────────────
240
-
241
- function buildBrowserProofPreflightSurface(cwd, options) {
242
- const preflight = buildBrowserProofPreflight(cwd, options);
243
- writeBrowserProofPreflight(cwd, preflight);
244
- try {
245
- appendProductLearningEvent(cwd, {
246
- event: "browser_proof_preflight_run",
247
- contract: CONTRACT,
248
- status: preflight.status,
249
- localFirstPathVerified: preflight.localFirstPathVerified,
250
- browserRequired: false,
251
- });
252
- } catch { /* non-fatal */ }
253
- return {
254
- status: preflight.status,
255
- localFirstPathVerified: preflight.localFirstPathVerified,
256
- browserRequired: false,
257
- browserOptionalEnhancement: true,
258
- blockerCount: preflight.blockerCount,
259
- warningCount: preflight.warningCount,
260
- noPublicLaunchClaim: true,
261
- };
262
- }
263
-
264
- // ── Format ────────────────────────────────────────────────────────────────────
265
-
266
- function formatBrowserProofPreflightText(preflight) {
267
- var lines = [
268
- "Browser Proof Preflight [" + (preflight.status || "?").toUpperCase() + "] (preflight only — no browser launched)",
269
- " Local-first path verified: " + (preflight.localFirstPathVerified ? "yes" : "no"),
270
- " Browser required: " + (preflight.browserRequired ? "yes" : "no"),
271
- " Browser optional enhancement: " + (preflight.browserOptionalEnhancement ? "yes" : "no"),
272
- " Blockers: " + (preflight.blockerCount || 0),
273
- " Warnings: " + (preflight.warningCount || 0),
274
- " Next: " + (preflight.safeNextAction || "Review browser proof preflight."),
275
- ];
276
- return lines.join("\n");
277
- }
278
-
279
- // ── Detect Browser Proof Capabilities ────────────────────────────────────────
280
-
281
- function detectBrowserProofCapabilities(cwd, options) {
282
- options = options || {};
283
- const preflight = buildBrowserProofPreflight(cwd, options);
284
- return {
285
- localFirstPathVerified: preflight.localFirstPathVerified,
286
- browserRequired: preflight.browserRequired,
287
- browserOptionalEnhancement: preflight.browserOptionalEnhancement,
288
- status: preflight.status,
289
- noBrowserLaunch: preflight.noBrowserLaunch,
290
- blockerCount: preflight.blockerCount,
291
- warningCount: preflight.warningCount,
292
- };
293
- }
294
-
295
- // ── Classify Browser Proof Need ───────────────────────────────────────────────
296
- // Returns: "not_required" | "optional_enhancement" | "required_unavailable"
297
-
298
- function classifyBrowserProofNeed(cwd, options) {
299
- options = options || {};
300
- const caps = detectBrowserProofCapabilities(cwd, options);
301
- if (caps.browserRequired === true) return "required_unavailable";
302
- if (caps.localFirstPathVerified) return "not_required";
303
- return "optional_enhancement";
304
- }
305
-
306
- module.exports = {
307
- CONTRACT,
308
- SCHEMA_VERSION,
309
- ARTIFACT_REL,
310
- buildBrowserProofPreflight,
311
- writeBrowserProofPreflight,
312
- buildBrowserProofPreflightSurface,
313
- formatBrowserProofPreflightText,
314
- checkLocalFirstProofPathExists,
315
- checkProofDoesNotRequireBrowser,
316
- checkBrowserIsOptionalEnhancement,
317
- checkNoBrowserRuntimeDependency,
318
- checkBrowserProofDocsOrPlanned,
319
- detectBrowserProofCapabilities,
320
- classifyBrowserProofNeed,
321
- };
@@ -1,187 +0,0 @@
1
- "use strict";
2
-
3
- // ── Cache Readiness Checker ───────────────────────────────────────────────────
4
- //
5
- // Checks whether prompt layout is stable and cache-friendly.
6
- // Does NOT claim active caching from any provider.
7
- // Does NOT act as a caching gateway.
8
- //
9
- // Contract: avorelo.cacheReadiness.v1
10
- //
11
- // Non-goals: OpenAI/Anthropic/LiteLLM cache integration, provider-specific claims,
12
- // cache warming, cache invalidation management.
13
-
14
- const fs = require("node:fs");
15
- const path = require("node:path");
16
- const { nowIso } = require("./fsx");
17
- const { appendProductLearningEvent } = require("./product-learning-events");
18
-
19
- const CONTRACT = "avorelo.cacheReadiness.v1";
20
- const SCHEMA_VERSION = 1;
21
-
22
- const CACHE_DIR_REL = ".claude/cco/orchestration/cache-readiness";
23
- const LATEST_READINESS_REL = `${CACHE_DIR_REL}/latest-readiness.json`;
24
-
25
- // ── Prompt layout checks ──────────────────────────────────────────────────────
26
-
27
- function checkPromptLayoutStability(input, options = {}) {
28
- const checks = [];
29
- const {
30
- hasStaticInstructionsBefore = null,
31
- hasDynamicTaskAfter = null,
32
- toolDefinitionsGrouped = null,
33
- dynamicToolOutputInPrefix = null,
34
- fileSpecificContentLate = null,
35
- orderingStableAcrossRuns = null,
36
- providerConfirmed = false,
37
- } = input || {};
38
-
39
- // Static instructions before dynamic task
40
- if (hasStaticInstructionsBefore === true) {
41
- checks.push({ id: "static_before_dynamic", status: "pass", detail: "Static instructions precede dynamic task content." });
42
- } else if (hasStaticInstructionsBefore === false) {
43
- checks.push({ id: "static_before_dynamic", status: "warn", detail: "Dynamic content may appear before static instructions, reducing cache stability." });
44
- } else {
45
- checks.push({ id: "static_before_dynamic", status: "unknown", detail: "Cannot determine ordering from available signals." });
46
- }
47
-
48
- // Dynamic tool output not in cache prefix
49
- if (dynamicToolOutputInPrefix === true) {
50
- checks.push({ id: "dynamic_output_not_in_prefix", status: "warn", detail: "Dynamic tool output appears in cache prefix position. Move to suffix for cache stability." });
51
- } else if (dynamicToolOutputInPrefix === false) {
52
- checks.push({ id: "dynamic_output_not_in_prefix", status: "pass", detail: "Dynamic tool output is not in cache prefix position." });
53
- } else {
54
- checks.push({ id: "dynamic_output_not_in_prefix", status: "unknown", detail: "Tool output position not confirmed." });
55
- }
56
-
57
- // File-specific content late
58
- if (fileSpecificContentLate === true) {
59
- checks.push({ id: "file_specific_content_late", status: "pass", detail: "File-specific content appears late in prompt (after stable prefix)." });
60
- } else if (fileSpecificContentLate === false) {
61
- checks.push({ id: "file_specific_content_late", status: "warn", detail: "File-specific content appears early; may invalidate cache prefix on every file change." });
62
- } else {
63
- checks.push({ id: "file_specific_content_late", status: "unknown", detail: "File content position not confirmed." });
64
- }
65
-
66
- // Tool definitions grouped
67
- if (toolDefinitionsGrouped === true) {
68
- checks.push({ id: "tool_definitions_grouped", status: "pass", detail: "Tool definitions are grouped and stable." });
69
- } else if (toolDefinitionsGrouped === false) {
70
- checks.push({ id: "tool_definitions_grouped", status: "warn", detail: "Tool definitions appear scattered or dynamic. Group them for cache stability." });
71
- } else {
72
- checks.push({ id: "tool_definitions_grouped", status: "unknown", detail: "Tool definition grouping not confirmed." });
73
- }
74
-
75
- // Stable ordering across runs
76
- if (orderingStableAcrossRuns === true) {
77
- checks.push({ id: "ordering_stable", status: "pass", detail: "Prompt ordering is stable across runs." });
78
- } else if (orderingStableAcrossRuns === false) {
79
- checks.push({ id: "ordering_stable", status: "warn", detail: "Prompt ordering varies across runs. Randomized or unstable ordering prevents caching." });
80
- } else {
81
- checks.push({ id: "ordering_stable", status: "unknown", detail: "Ordering stability not confirmed." });
82
- }
83
-
84
- // Provider not confirmed — no active cache claim
85
- if (!providerConfirmed) {
86
- checks.push({ id: "provider_confirmed", status: "unknown", detail: "Provider not confirmed. No active cache claim can be made." });
87
- } else {
88
- checks.push({ id: "provider_confirmed", status: "pass", detail: `Provider confirmed: ${providerConfirmed}.` });
89
- }
90
-
91
- return checks;
92
- }
93
-
94
- function buildCacheReadiness(cwd, input = {}, options = {}) {
95
- const checks = checkPromptLayoutStability(input, options);
96
-
97
- const passed = checks.filter((c) => c.status === "pass").length;
98
- const warned = checks.filter((c) => c.status === "warn").length;
99
- const unknown = checks.filter((c) => c.status === "unknown").length;
100
- const failed = checks.filter((c) => c.status === "fail").length;
101
-
102
- let readinessLevel;
103
- if (failed > 0) readinessLevel = "not_ready";
104
- else if (warned > 0) readinessLevel = "partial";
105
- else if (unknown === checks.length) readinessLevel = "unknown";
106
- else if (passed > 0 && warned === 0) readinessLevel = "ready";
107
- else readinessLevel = "partial";
108
-
109
- const caveats = ["Cache readiness is a layout signal only. No provider-specific cache claim is made."];
110
- if (unknown > 0) {
111
- caveats.push(`${unknown} check(s) could not be evaluated from available signals.`);
112
- }
113
-
114
- return {
115
- contract: CONTRACT,
116
- schemaVersion: SCHEMA_VERSION,
117
- createdAt: nowIso(),
118
- readinessLevel,
119
- checksPass: passed,
120
- checksWarn: warned,
121
- checksUnknown: unknown,
122
- checksFail: failed,
123
- checks,
124
- caveats,
125
- noProviderCacheClaim: true,
126
- redacted: true,
127
- };
128
- }
129
-
130
- function writeCacheReadiness(cwd, readiness) {
131
- const dir = path.join(cwd, CACHE_DIR_REL);
132
- fs.mkdirSync(dir, { recursive: true });
133
- const abs = path.join(cwd, LATEST_READINESS_REL);
134
- fs.writeFileSync(abs, JSON.stringify(readiness, null, 2), "utf8");
135
- try {
136
- appendProductLearningEvent(cwd, "cache_readiness_checked", {
137
- readinessLevel: readiness.readinessLevel,
138
- checksPass: readiness.checksPass,
139
- checksWarn: readiness.checksWarn,
140
- noProviderCacheClaim: readiness.noProviderCacheClaim,
141
- });
142
- } catch {}
143
- return abs;
144
- }
145
-
146
- function buildCacheReadinessSurface(cwd, options = {}) {
147
- const abs = path.join(cwd, LATEST_READINESS_REL);
148
- if (!fs.existsSync(abs)) {
149
- return { status: "not_available", artifactPath: LATEST_READINESS_REL };
150
- }
151
- try {
152
- const r = JSON.parse(fs.readFileSync(abs, "utf8"));
153
- return {
154
- status: "available",
155
- readinessLevel: r.readinessLevel,
156
- checksPass: r.checksPass,
157
- checksWarn: r.checksWarn,
158
- noProviderCacheClaim: r.noProviderCacheClaim,
159
- artifactPath: LATEST_READINESS_REL,
160
- };
161
- } catch {
162
- return { status: "error", artifactPath: LATEST_READINESS_REL };
163
- }
164
- }
165
-
166
- function formatCacheReadinessText(readiness, options = {}) {
167
- const lines = [`Cache Readiness: ${readiness.readinessLevel}`];
168
- lines.push(` Pass: ${readiness.checksPass} | Warn: ${readiness.checksWarn} | Unknown: ${readiness.checksUnknown}`);
169
- lines.push(` noProviderCacheClaim: ${readiness.noProviderCacheClaim}`);
170
- for (const c of readiness.checks) {
171
- if (c.status !== "pass") lines.push(` [${c.status}] ${c.id}: ${c.detail}`);
172
- }
173
- if (readiness.caveats.length) lines.push(` Caveat: ${readiness.caveats[0]}`);
174
- return lines.join("\n");
175
- }
176
-
177
- module.exports = {
178
- CONTRACT,
179
- SCHEMA_VERSION,
180
- CACHE_DIR_REL,
181
- LATEST_READINESS_REL,
182
- checkPromptLayoutStability,
183
- buildCacheReadiness,
184
- writeCacheReadiness,
185
- buildCacheReadinessSurface,
186
- formatCacheReadinessText,
187
- };
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const { buildBoundedStateContext, formatNextBoundedAction } = require("./proof-canonical");
7
- const { loadCarryForward } = require("./carry-forward-surfacing");
8
- const { parseContinueNote } = require("./guidance-builder");
9
- const { loadReentryState } = require("./reentry-state");
10
-
11
- const CONTINUE_NOTE_REL = ".claude/cco/reports/continue-from-here.md";
12
- const REENTRY_STATE_REL = ".claude/cco/state/reentry-state.json";
13
- const CARRY_FORWARD_REL = ".claude/cco/state/reentry-carry-forward.json";
14
-
15
- function loadCanonicalReentry(cwd) {
16
- const context = buildBoundedStateContext(cwd);
17
- if (!context) {
18
- return {
19
- is_canonical_truth_available: false,
20
- artifact_refs: [],
21
- state_source: null,
22
- };
23
- }
24
-
25
- return {
26
- is_canonical_truth_available: true,
27
- artifact_refs: Array.isArray(context.artifact_refs) ? context.artifact_refs : [],
28
- state_source: context.state_source || context.artifact_path || null,
29
- where_am_i_now: context.where_am_i_now || null,
30
- what_can_i_honestly_claim: context.what_can_i_honestly_claim || context.claim_boundary || null,
31
- reentry_status: context.reentry_status || null,
32
- latest_trustworthy_run_id: context.latest_trustworthy_run_id || null,
33
- latest_trustworthy_workset_id: context.latest_trustworthy_workset_id || null,
34
- next_bounded_action: context.next_bounded_action || null,
35
- next_bounded_action_text: formatNextBoundedAction(context.next_bounded_action),
36
- rollback_available:
37
- typeof context.rollback_available === "boolean" ? context.rollback_available : null,
38
- rollback_trigger: context.rollback_trigger || null,
39
- readiness_state: context.readiness_status || null,
40
- reason_summary: context.reentry_reason_summary || null,
41
- };
42
- }
43
-
44
- function hasCanonicalReentryTruth(value) {
45
- return Boolean(value && value.is_canonical_truth_available);
46
- }
47
-
48
- function readContinueNote(cwd) {
49
- const absPath = path.join(cwd, CONTINUE_NOTE_REL);
50
- try {
51
- return parseContinueNote(fs.readFileSync(absPath, "utf8"));
52
- } catch {
53
- return null;
54
- }
55
- }
56
-
57
- function uniqueRefs(values) {
58
- return [...new Set((values || []).filter(Boolean).map((value) => String(value).trim()).filter(Boolean))];
59
- }
60
-
61
- function buildFallbackCurrentState(cwd) {
62
- const continueNote = readContinueNote(cwd);
63
- const reentryState = loadReentryState(cwd);
64
- const carryForward = loadCarryForward(cwd);
65
- const carryForwardNext =
66
- formatNextBoundedAction(carryForward?.nextBoundedAction)
67
- || formatNextBoundedAction(carryForward?.next_bounded_action);
68
- const nextAction =
69
- continueNote?.nextAction
70
- || reentryState?.nextAction
71
- || carryForwardNext
72
- || null;
73
- const artifactRefs = uniqueRefs([
74
- continueNote ? CONTINUE_NOTE_REL : null,
75
- reentryState ? REENTRY_STATE_REL : null,
76
- carryForward ? CARRY_FORWARD_REL : null,
77
- continueNote?.artifactPath || null,
78
- reentryState?.primaryArtifactPath || null,
79
- ]);
80
-
81
- if (!continueNote && !reentryState && !carryForward) {
82
- return {
83
- truthSource: "none",
84
- isCanonicalTruthAvailable: false,
85
- whereAmINow: null,
86
- whatCanIHonestlyClaim: null,
87
- nextBoundedAction: null,
88
- reentryStatus: null,
89
- latestTrustworthyRunId: null,
90
- rollbackAvailable: null,
91
- readinessState: null,
92
- stateSource: null,
93
- artifactRefs: [],
94
- limitations: [
95
- "No canonical or wrapper continuity cues are available yet.",
96
- ],
97
- };
98
- }
99
-
100
- return {
101
- truthSource: "fallback",
102
- isCanonicalTruthAvailable: false,
103
- whereAmINow: null,
104
- whatCanIHonestlyClaim: null,
105
- nextBoundedAction: nextAction,
106
- reentryStatus: carryForward ? "resume_available" : null,
107
- latestTrustworthyRunId: null,
108
- rollbackAvailable: null,
109
- readinessState: null,
110
- stateSource:
111
- continueNote ? CONTINUE_NOTE_REL
112
- : reentryState ? REENTRY_STATE_REL
113
- : carryForward ? CARRY_FORWARD_REL
114
- : null,
115
- artifactRefs,
116
- limitations: [
117
- "Canonical L8 current-state artifacts are not available; showing wrapper-derived continuity cues.",
118
- ],
119
- };
120
- }
121
-
122
- function buildCurrentStateSurface(cwd) {
123
- const canonicalReentry = loadCanonicalReentry(cwd);
124
- if (hasCanonicalReentryTruth(canonicalReentry)) {
125
- const limitations = [];
126
- if (!canonicalReentry.where_am_i_now) {
127
- limitations.push("Canonical L8 artifacts do not currently describe where the session stands.");
128
- }
129
- if (!canonicalReentry.what_can_i_honestly_claim) {
130
- limitations.push("Canonical L8 artifacts do not currently define an honest claim boundary.");
131
- }
132
- if (!canonicalReentry.next_bounded_action_text) {
133
- limitations.push("Canonical L8 artifacts do not currently define the next bounded action.");
134
- }
135
-
136
- return {
137
- truthSource: "canonical_l8",
138
- isCanonicalTruthAvailable: true,
139
- whereAmINow: canonicalReentry.where_am_i_now || null,
140
- whatCanIHonestlyClaim: canonicalReentry.what_can_i_honestly_claim || null,
141
- nextBoundedAction: canonicalReentry.next_bounded_action_text || null,
142
- reentryStatus: canonicalReentry.reentry_status || null,
143
- latestTrustworthyRunId: canonicalReentry.latest_trustworthy_run_id || null,
144
- rollbackAvailable:
145
- typeof canonicalReentry.rollback_available === "boolean"
146
- ? canonicalReentry.rollback_available
147
- : null,
148
- readinessState: canonicalReentry.readiness_state || null,
149
- stateSource: canonicalReentry.state_source || null,
150
- artifactRefs: uniqueRefs(canonicalReentry.artifact_refs || []),
151
- limitations,
152
- };
153
- }
154
-
155
- return buildFallbackCurrentState(cwd);
156
- }
157
-
158
- module.exports = {
159
- buildCurrentStateSurface,
160
- hasCanonicalReentryTruth,
161
- loadCanonicalReentry,
162
- };