avorelo 0.1.0 → 0.3.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 +90 -51
  3. package/bin/avorelo.mjs +7 -0
  4. package/dist/avorelo.mjs +19741 -0
  5. package/package.json +135 -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,628 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { spawnSync } = require("child_process");
6
- const { validateInstallClaims } = require("./public-install-claim-checker");
7
-
8
- const LAUNCH_READINESS_CONTRACT = "avorelo.launchReadiness.v1";
9
- const LAUNCH_READINESS_SCHEMA_VERSION = 1;
10
- const DISTRIBUTION_STATES = new Set([
11
- "private_local_only",
12
- "local_verified",
13
- "ready_to_publish",
14
- "published_verified",
15
- "publish_blocked",
16
- ]);
17
-
18
- // Files that must exist for a valid CLI install
19
- const REQUIRED_BIN_ENTRIES = ["bin/avorelo"];
20
-
21
- // Patterns that must not appear in committed config files (clone-specific paths)
22
- const ABSOLUTE_PATH_PATTERNS = [
23
- /\/mnt\/[a-z]\/[A-Za-z]/,
24
- /^[A-Z]:\\[A-Za-z]/,
25
- /\/home\/[a-zA-Z0-9_-]+\/[A-Za-z]/,
26
- ];
27
-
28
- // Runtime artifact dirs that must not be in a shipped package
29
- const RUNTIME_ARTIFACT_PATTERNS = [
30
- /^\.claude\/cco\//,
31
- /^\.avorelo\//,
32
- /^\.codex-worktree-/,
33
- /^\.tmp-/,
34
- /^_wasp_build_tmp\//,
35
- /^\.wasp\/out\//,
36
- /handoff-local-state\.txt$/,
37
- /handoff-worktree-locator\.txt$/,
38
- /^avorelo-activation-smoke\//,
39
- ];
40
-
41
- const WORKS_EVERYWHERE_PATTERNS = [
42
- /works everywhere/i,
43
- /works on every machine/i,
44
- /works in every repo/i,
45
- /works in every environment/i,
46
- ];
47
-
48
- // Config files tracked in git that should not contain absolute paths
49
- const CHECKED_CONFIG_FILES = [".codex/config.toml", ".cursor/rules/wuz-project.mdc"];
50
-
51
- function safeReadJson(absPath) {
52
- try {
53
- if (!fs.existsSync(absPath)) return null;
54
- return JSON.parse(fs.readFileSync(absPath, "utf8"));
55
- } catch {
56
- return null;
57
- }
58
- }
59
-
60
- function safeReadText(absPath) {
61
- try {
62
- if (!fs.existsSync(absPath)) return null;
63
- return fs.readFileSync(absPath, "utf8");
64
- } catch {
65
- return null;
66
- }
67
- }
68
-
69
- function collectMarkdownFiles(dir, collected = [], limit = 200) {
70
- if (!fs.existsSync(dir) || collected.length >= limit) return collected;
71
- let entries = [];
72
- try {
73
- entries = fs.readdirSync(dir, { withFileTypes: true });
74
- } catch {
75
- return collected;
76
- }
77
- for (const entry of entries) {
78
- if (collected.length >= limit) break;
79
- const absPath = path.join(dir, entry.name);
80
- if (entry.isDirectory()) {
81
- if (/node_modules|\.git|\.tmp|artifacts|vendor/i.test(entry.name)) continue;
82
- collectMarkdownFiles(absPath, collected, limit);
83
- continue;
84
- }
85
- if (entry.isFile() && entry.name.endsWith(".md")) {
86
- collected.push(absPath);
87
- }
88
- }
89
- return collected;
90
- }
91
-
92
- function scanWorksEverywhereClaims(repoRoot, opts = {}) {
93
- if (Array.isArray(opts.worksEverywhereClaims)) {
94
- return { claims: opts.worksEverywhereClaims };
95
- }
96
-
97
- const claims = [];
98
- const filesToScan = [];
99
- const readmePath = path.join(repoRoot, "README.md");
100
- if (fs.existsSync(readmePath)) filesToScan.push(readmePath);
101
- collectMarkdownFiles(path.join(repoRoot, "docs"), filesToScan);
102
-
103
- for (const absPath of filesToScan) {
104
- const text = safeReadText(absPath);
105
- if (!text) continue;
106
- const lines = text.split(/\r?\n/);
107
- for (let i = 0; i < lines.length; i++) {
108
- const line = lines[i];
109
- if (!WORKS_EVERYWHERE_PATTERNS.some((pattern) => pattern.test(line))) continue;
110
- claims.push({
111
- file: path.relative(repoRoot, absPath).replace(/\\/g, "/"),
112
- line: i + 1,
113
- text: line.trim(),
114
- });
115
- }
116
- }
117
-
118
- return { claims };
119
- }
120
-
121
- function buildLaunchDistributionEvidence(repoRoot, opts = {}) {
122
- const pkgPath = path.join(repoRoot, "package.json");
123
- const pkg = safeReadJson(pkgPath);
124
- const hasPackageJson = !!pkg;
125
- const hasNpmIgnore = fs.existsSync(path.join(repoRoot, ".npmignore"));
126
- const hasFilesField = !!(pkg && Array.isArray(pkg.files) && pkg.files.length > 0);
127
- const distributionEvidence = opts.distributionEvidence || {};
128
- const explicitState = distributionEvidence.state
129
- || (pkg && typeof pkg.avoreloDistributionState === "string" ? pkg.avoreloDistributionState : null);
130
- const packagePrivate = !!(pkg && pkg.private === true);
131
- const packagePublic = !!(pkg && pkg.private === false);
132
- const claimsReport = opts.installClaimsReport || validateInstallClaims(repoRoot);
133
- const worksEverywhere = scanWorksEverywhereClaims(repoRoot, opts);
134
- const localSmokePassed = distributionEvidence.localSmokePassed === true;
135
- const publicSmokePassed = distributionEvidence.publicSmokePassed === true;
136
- const publishAuthAvailable = distributionEvidence.publishAuthAvailable === true;
137
- const publishApproved = distributionEvidence.publishApproved === true;
138
- const packageContentSafe = distributionEvidence.packageContentSafe !== undefined
139
- ? distributionEvidence.packageContentSafe === true
140
- : (hasNpmIgnore || hasFilesField);
141
-
142
- const reasons = [];
143
- let state = explicitState;
144
-
145
- if (explicitState && !DISTRIBUTION_STATES.has(explicitState)) {
146
- reasons.push(`Unknown distribution state '${explicitState}'.`);
147
- state = "publish_blocked";
148
- }
149
-
150
- if (!state) {
151
- state = packagePrivate ? "private_local_only" : "publish_blocked";
152
- if (!packagePrivate) {
153
- reasons.push("package.json is public-ready but no explicit distribution state evidence is present.");
154
- }
155
- }
156
-
157
- if (state === "private_local_only" && !packagePrivate) {
158
- reasons.push("private_local_only requires package.json private: true.");
159
- state = "publish_blocked";
160
- }
161
-
162
- if (state === "local_verified" && packagePublic && !localSmokePassed) {
163
- reasons.push("local_verified needs explicit local smoke evidence before a public-ready package can pass.");
164
- state = "publish_blocked";
165
- }
166
-
167
- if (state === "ready_to_publish") {
168
- if (!packagePublic) {
169
- reasons.push("ready_to_publish requires package.json private: false.");
170
- state = "publish_blocked";
171
- }
172
- if (!packageContentSafe) {
173
- reasons.push("ready_to_publish requires package exclusion control or equivalent package-content evidence.");
174
- state = "publish_blocked";
175
- }
176
- }
177
-
178
- if (state === "published_verified") {
179
- if (!packagePublic) {
180
- reasons.push("published_verified requires package.json private: false.");
181
- state = "publish_blocked";
182
- }
183
- if (!publicSmokePassed) {
184
- reasons.push("published_verified requires verified public npx smoke evidence.");
185
- state = "publish_blocked";
186
- }
187
- if (!publishAuthAvailable || !publishApproved) {
188
- reasons.push("published_verified requires explicit publish auth and approval evidence.");
189
- state = "publish_blocked";
190
- }
191
- }
192
-
193
- if (state === "publish_blocked" && reasons.length === 0) {
194
- reasons.push("Distribution state is blocked until public distribution evidence is made explicit.");
195
- }
196
-
197
- const effectiveBlockedClaims = (claimsReport.blockedClaims || []).filter((claim) => {
198
- if (state !== "published_verified") return true;
199
- const reason = String(claim.reason || "");
200
- return !/not verified|private\/not on npm/i.test(reason);
201
- });
202
-
203
- if (effectiveBlockedClaims.length > 0) {
204
- reasons.push("Blocked public install claims detected.");
205
- state = "publish_blocked";
206
- }
207
-
208
- if (worksEverywhere.claims.length > 0) {
209
- reasons.push("Works-everywhere claims are not allowed.");
210
- state = "publish_blocked";
211
- }
212
-
213
- const publicClaimChecksPass = effectiveBlockedClaims.length === 0;
214
- const worksEverywherePass = worksEverywhere.claims.length === 0;
215
- const packageStateAligned = state !== "publish_blocked";
216
- const checkDetails = {
217
- explicitState: explicitState || null,
218
- packagePrivate,
219
- packagePublic,
220
- packageContentSafe,
221
- localSmokePassed,
222
- publicSmokePassed,
223
- publishAuthAvailable,
224
- publishApproved,
225
- };
226
-
227
- return {
228
- state,
229
- explicitState: explicitState || null,
230
- packagePrivate,
231
- packagePublic,
232
- packageContentSafe,
233
- hasNpmIgnore,
234
- hasFilesField,
235
- localSmokePassed,
236
- publicSmokePassed,
237
- publishAuthAvailable,
238
- publishApproved,
239
- installClaimsReport: claimsReport,
240
- effectiveBlockedClaims,
241
- worksEverywhereClaims: worksEverywhere.claims,
242
- hasPackageJson,
243
- reasons,
244
- checks: [
245
- {
246
- id: "package_distribution_state_alignment",
247
- pass: packageStateAligned,
248
- blocking: true,
249
- detail: packageStateAligned
250
- ? `Distribution state ${state} is compatible with launch readiness.`
251
- : reasons.join(" "),
252
- evidence: checkDetails,
253
- },
254
- {
255
- id: "public_install_claims_honest",
256
- pass: publicClaimChecksPass,
257
- blocking: true,
258
- detail: publicClaimChecksPass
259
- ? `Blocked claims: ${claimsReport.blockedCount}. Caveated claims: ${claimsReport.caveatedCount}.`
260
- : `Blocked claims: ${effectiveBlockedClaims.length}. Public install claims require published_verified.`,
261
- evidence: {
262
- blockedCount: effectiveBlockedClaims.length,
263
- caveatedCount: claimsReport.caveatedCount,
264
- allowedCount: claimsReport.allowedCount,
265
- },
266
- },
267
- {
268
- id: "no_works_everywhere_claim",
269
- pass: worksEverywherePass,
270
- blocking: true,
271
- detail: worksEverywherePass
272
- ? "No works-everywhere claims detected."
273
- : `Works-everywhere claim found in ${worksEverywhere.claims[0].file}:${worksEverywhere.claims[0].line}.`,
274
- evidence: {
275
- claimCount: worksEverywhere.claims.length,
276
- },
277
- },
278
- {
279
- id: "published_verified_requires_public_smoke",
280
- pass: state !== "published_verified" || publicSmokePassed,
281
- blocking: true,
282
- detail: state === "published_verified" && !publicSmokePassed
283
- ? "published_verified requires public smoke evidence."
284
- : "Public smoke evidence gate is aligned with distribution state.",
285
- },
286
- {
287
- id: "published_verified_requires_publish_approval",
288
- pass: state !== "published_verified" || (publishAuthAvailable && publishApproved),
289
- blocking: true,
290
- detail: state === "published_verified" && (!publishAuthAvailable || !publishApproved)
291
- ? "Publish auth/approval evidence is required before launch readiness can treat the package as published."
292
- : "Publish approval gate is aligned with distribution state.",
293
- },
294
- ],
295
- };
296
- }
297
-
298
- function evaluatePackageDistributionState(repoRoot, opts = {}) {
299
- return buildLaunchDistributionEvidence(repoRoot, opts).state;
300
- }
301
-
302
- function buildPackageAudit(repoRoot, opts = {}) {
303
- const pkgPath = path.join(repoRoot, "package.json");
304
- const checks = [];
305
- let runtimeArtifactsFound = [];
306
- let absolutePathViolations = [];
307
-
308
- if (!fs.existsSync(pkgPath)) {
309
- checks.push({ id: "package_json_exists", pass: false, blocking: true, detail: "package.json not found" });
310
- return {
311
- checks,
312
- runtimeArtifactsFound,
313
- absolutePathViolations,
314
- distributionState: "publish_blocked",
315
- distributionEvidence: buildLaunchDistributionEvidence(repoRoot, opts),
316
- };
317
- }
318
-
319
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
320
- checks.push({ id: "package_json_exists", pass: true, blocking: true });
321
-
322
- const binEntries = pkg.bin || {};
323
- const missingBin = REQUIRED_BIN_ENTRIES.filter(
324
- (rel) => !Object.values(binEntries).some((value) => value === rel || value.replace(/\\/g, "/") === rel)
325
- );
326
- checks.push({
327
- id: "bin_entry_exists",
328
- pass: missingBin.length === 0,
329
- blocking: true,
330
- detail: missingBin.length ? `Missing bin entries: ${missingBin.join(", ")}` : "bin/avorelo present",
331
- });
332
-
333
- for (const [name, rel] of Object.entries(binEntries)) {
334
- const absPath = path.join(repoRoot, rel);
335
- checks.push({
336
- id: `bin_file_${name}`,
337
- pass: fs.existsSync(absPath),
338
- blocking: true,
339
- detail: fs.existsSync(absPath) ? `${rel} exists` : `${rel} not found on disk`,
340
- });
341
- }
342
-
343
- const gitLsResult = spawnSync("git", ["ls-files", "--cached"], {
344
- cwd: repoRoot,
345
- encoding: "utf8",
346
- });
347
-
348
- if (gitLsResult.status === 0) {
349
- const trackedFiles = gitLsResult.stdout.trim().split("\n").filter(Boolean);
350
- runtimeArtifactsFound = trackedFiles.filter((file) =>
351
- RUNTIME_ARTIFACT_PATTERNS.some((pattern) => pattern.test(file))
352
- );
353
- checks.push({
354
- id: "no_runtime_artifacts_committed",
355
- pass: runtimeArtifactsFound.length === 0,
356
- blocking: true,
357
- detail: runtimeArtifactsFound.length === 0
358
- ? "No runtime artifacts in tracked files"
359
- : `Runtime artifacts tracked: ${runtimeArtifactsFound.slice(0, 5).join(", ")}`,
360
- });
361
- } else {
362
- checks.push({
363
- id: "no_runtime_artifacts_committed",
364
- pass: null,
365
- blocking: true,
366
- detail: "Could not run git ls-files",
367
- });
368
- }
369
-
370
- for (const relPath of CHECKED_CONFIG_FILES) {
371
- const absPath = path.join(repoRoot, relPath);
372
- if (!fs.existsSync(absPath)) continue;
373
- const content = fs.readFileSync(absPath, "utf8");
374
- const lines = content.split("\n");
375
- for (let i = 0; i < lines.length; i++) {
376
- for (const pattern of ABSOLUTE_PATH_PATTERNS) {
377
- if (pattern.test(lines[i])) {
378
- absolutePathViolations.push({ file: relPath, line: i + 1, content: lines[i].trim() });
379
- }
380
- }
381
- }
382
- }
383
- checks.push({
384
- id: "no_absolute_paths_in_config",
385
- pass: absolutePathViolations.length === 0,
386
- blocking: true,
387
- detail: absolutePathViolations.length === 0
388
- ? "No absolute paths in committed config files"
389
- : `Absolute paths found: ${absolutePathViolations.map((violation) => `${violation.file}:${violation.line}`).join(", ")}`,
390
- });
391
-
392
- const hasNpmIgnore = fs.existsSync(path.join(repoRoot, ".npmignore"));
393
- const hasFilesField = Array.isArray(pkg.files) && pkg.files.length > 0;
394
- checks.push({
395
- id: "package_exclusion_control",
396
- pass: hasNpmIgnore || hasFilesField,
397
- blocking: true,
398
- detail: hasNpmIgnore
399
- ? ".npmignore present"
400
- : hasFilesField
401
- ? "package.json files field present"
402
- : "Neither .npmignore nor files field - npm pack falls back to .gitignore",
403
- });
404
-
405
- const distributionEvidence = buildLaunchDistributionEvidence(repoRoot, opts);
406
- checks.push(...distributionEvidence.checks);
407
-
408
- if (opts.skipInstallDeliveryValidation !== true) {
409
- const verifyResult = spawnSync(
410
- "node",
411
- ["app-scripts/validate-install-delivery.mjs"],
412
- { cwd: repoRoot, encoding: "utf8" }
413
- );
414
- checks.push({
415
- id: "install_delivery_validates",
416
- pass: verifyResult.status === 0,
417
- blocking: false,
418
- detail: verifyResult.status === 0
419
- ? "validate-install-delivery passed"
420
- : (verifyResult.stderr || verifyResult.stdout || "").trim(),
421
- });
422
- }
423
-
424
- return {
425
- checks,
426
- runtimeArtifactsFound,
427
- absolutePathViolations,
428
- distributionState: distributionEvidence.state,
429
- distributionEvidence,
430
- };
431
- }
432
-
433
- function buildExternalRepoCheck(repoRoot, externalCwd) {
434
- const checks = [];
435
-
436
- if (!fs.existsSync(externalCwd)) {
437
- checks.push({ id: "external_dir_exists", pass: false, blocking: true, detail: `External dir not found: ${externalCwd}` });
438
- return { checks };
439
- }
440
-
441
- const pkgPath = path.join(externalCwd, "package.json");
442
- if (!fs.existsSync(pkgPath)) {
443
- fs.writeFileSync(pkgPath, JSON.stringify({ name: "external-dogfood-repo", version: "0.0.1" }, null, 2), "utf8");
444
- }
445
-
446
- const activateResult = spawnSync(
447
- "node",
448
- [path.join(repoRoot, "bin/avorelo"), "activate", "--json"],
449
- { cwd: externalCwd, encoding: "utf8", timeout: 30000 }
450
- );
451
-
452
- let activationData = null;
453
- try {
454
- activationData = JSON.parse(activateResult.stdout);
455
- } catch {}
456
-
457
- const isAlphaContract = activationData?.contract === "avorelo.alphaActivation.v1";
458
- const activationOk = activateResult.status === 0 && (
459
- activationData?.ready === true ||
460
- (isAlphaContract && activationData?.status !== "blocked" && activationData?.status != null)
461
- );
462
- checks.push({
463
- id: "external_activation_ready",
464
- pass: activationOk,
465
- blocking: true,
466
- detail: activationOk
467
- ? `activation ready from external cwd (${activationData?.contract || "unknown contract"})`
468
- : `activation failed: ${activateResult.stderr?.slice(0, 200) || "unknown"}`,
469
- });
470
-
471
- if (activationData) {
472
- const noFakeSavings = isAlphaContract
473
- ? true
474
- : activationData.valueClaimsShown === false;
475
- checks.push({
476
- id: "external_no_fake_savings",
477
- pass: noFakeSavings,
478
- blocking: true,
479
- detail: noFakeSavings
480
- ? "no fake savings in activation output"
481
- : "valueClaimsShown is not false - savings shown without evidence",
482
- });
483
-
484
- const firstValueReady = isAlphaContract
485
- ? activationData.firstValuePath != null
486
- : activationData.firstValueReadiness?.ready === true;
487
- checks.push({
488
- id: "external_first_value_readiness",
489
- pass: firstValueReady,
490
- blocking: true,
491
- detail: firstValueReady
492
- ? "first value path/readiness present"
493
- : isAlphaContract
494
- ? "firstValuePath is null in alphaActivation response"
495
- : `firstValueReadiness.ready=${activationData.firstValueReadiness?.ready}`,
496
- });
497
- }
498
-
499
- const pinnedEnv = { ...process.env, AVORELO_WORKSPACE: externalCwd };
500
-
501
- const tokenResult = spawnSync(
502
- "node",
503
- [path.join(repoRoot, "bin/avorelo"), "token-evidence", "--json"],
504
- { cwd: externalCwd, env: pinnedEnv, encoding: "utf8", timeout: 15000 }
505
- );
506
- checks.push({
507
- id: "external_token_evidence_safe",
508
- pass: tokenResult.status === 0,
509
- blocking: false,
510
- detail: tokenResult.status === 0 ? "token-evidence exits 0" : `token-evidence failed: ${tokenResult.stderr?.slice(0, 200) || "unknown"}`,
511
- });
512
-
513
- const hygieneResult = spawnSync(
514
- "node",
515
- [path.join(repoRoot, "bin/avorelo"), "skills", "hygiene", "--json"],
516
- { cwd: externalCwd, env: pinnedEnv, encoding: "utf8", timeout: 15000 }
517
- );
518
- checks.push({
519
- id: "external_skills_hygiene_safe",
520
- pass: hygieneResult.status === 0,
521
- blocking: false,
522
- detail: hygieneResult.status === 0 ? "skills hygiene exits 0" : `skills hygiene failed: ${hygieneResult.stderr?.slice(0, 200) || "unknown"}`,
523
- });
524
-
525
- const operatingValueResult = spawnSync(
526
- "node",
527
- [path.join(repoRoot, "bin/avorelo"), "operating-value", "--json"],
528
- { cwd: externalCwd, env: pinnedEnv, encoding: "utf8", timeout: 15000 }
529
- );
530
- checks.push({
531
- id: "external_operating_value_safe",
532
- pass: operatingValueResult.status === 0,
533
- blocking: false,
534
- detail: operatingValueResult.status === 0 ? "operating-value exits 0" : `operating-value failed: ${operatingValueResult.stderr?.slice(0, 200) || "unknown"}`,
535
- });
536
-
537
- return { checks };
538
- }
539
-
540
- function buildLaunchReadiness(repoRoot, opts = {}) {
541
- const { runExternalDogfood = false, externalCwd = null } = opts;
542
- const startedAt = new Date().toISOString();
543
-
544
- const packageAudit = buildPackageAudit(repoRoot, opts);
545
- const externalCheck = runExternalDogfood && externalCwd
546
- ? buildExternalRepoCheck(repoRoot, externalCwd)
547
- : { checks: [], skipped: true };
548
-
549
- const allChecks = [...packageAudit.checks, ...externalCheck.checks];
550
- const passingChecks = allChecks.filter((check) => check.pass === true);
551
- const failingChecks = allChecks.filter((check) => check.pass === false);
552
- const skippedChecks = allChecks.filter((check) => check.pass === null);
553
- const blockingFailure = failingChecks.some((check) => check.blocking === true);
554
-
555
- let verdict;
556
- if (failingChecks.length === 0) {
557
- verdict = "LAUNCH_GATE_PASS";
558
- } else if (blockingFailure) {
559
- verdict = "LAUNCH_GATE_BLOCKED";
560
- } else {
561
- verdict = "LAUNCH_GATE_PARTIAL";
562
- }
563
-
564
- return {
565
- schemaVersion: LAUNCH_READINESS_SCHEMA_VERSION,
566
- contract: LAUNCH_READINESS_CONTRACT,
567
- generatedAt: startedAt,
568
- verdict,
569
- summary: {
570
- total: allChecks.length,
571
- pass: passingChecks.length,
572
- fail: failingChecks.length,
573
- skip: skippedChecks.length,
574
- },
575
- packageAudit: {
576
- checks: packageAudit.checks,
577
- runtimeArtifactsFound: packageAudit.runtimeArtifactsFound,
578
- absolutePathViolations: packageAudit.absolutePathViolations,
579
- distributionState: packageAudit.distributionState,
580
- distributionEvidence: packageAudit.distributionEvidence,
581
- },
582
- externalRepoCheck: externalCheck,
583
- failingChecks,
584
- passingChecks: passingChecks.map((check) => check.id),
585
- };
586
- }
587
-
588
- function formatLaunchReadinessText(result) {
589
- const lines = [];
590
- lines.push("Avorelo Launch Readiness Gate");
591
- lines.push("");
592
- lines.push(`Verdict: ${result.verdict}`);
593
- lines.push(`Checks: ${result.summary.pass} pass, ${result.summary.fail} fail, ${result.summary.skip} skip`);
594
- if (result.packageAudit?.distributionState) {
595
- lines.push(`Distribution state: ${result.packageAudit.distributionState}`);
596
- }
597
- lines.push("");
598
-
599
- if (result.failingChecks.length > 0) {
600
- lines.push("Failing:");
601
- for (const check of result.failingChecks) {
602
- lines.push(` FAIL ${check.id}: ${check.detail || ""}`);
603
- }
604
- lines.push("");
605
- }
606
-
607
- lines.push("Passing:");
608
- for (const id of result.passingChecks) {
609
- lines.push(` pass ${id}`);
610
- }
611
-
612
- if (result.externalRepoCheck.skipped) {
613
- lines.push("");
614
- lines.push("External repo check: skipped (run with --external-cwd <path> to enable)");
615
- }
616
-
617
- return lines.join("\n");
618
- }
619
-
620
- module.exports = {
621
- buildLaunchDistributionEvidence,
622
- buildLaunchReadiness,
623
- buildPackageAudit,
624
- buildExternalRepoCheck,
625
- evaluatePackageDistributionState,
626
- formatLaunchReadinessText,
627
- LAUNCH_READINESS_CONTRACT,
628
- };