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,368 +0,0 @@
1
- "use strict";
2
-
3
- // ── Package Content Audit ─────────────────────────────────────────────────────
4
- // Contract: avorelo.packageContentAudit.v1
5
- // Answers: "What files would npm publish include, and are any forbidden/suspicious?"
6
- // Uses npm pack --dry-run. Never runs npm publish.
7
-
8
- const fs = require("fs");
9
- const path = require("path");
10
- const { nowIso } = require("./fsx");
11
- const { appendProductLearningEvent } = require("./product-learning-events");
12
- const {
13
- readPackageJson,
14
- getBinEntries,
15
- getPublishConfig,
16
- runNpm,
17
- normalizeRelativePath,
18
- collectRuntimeDependencyGraph,
19
- findMissingRuntimeDependencies,
20
- getPublicRuntimeEntryFiles,
21
- } = require("./package-runtime");
22
-
23
- const CONTRACT = "avorelo.packageContentAudit.v1";
24
- const SCHEMA_VERSION = 1;
25
- const ARTIFACT_DIR_REL = ".claude/cco/orchestration/public-distribution";
26
- const ARTIFACT_REL = ARTIFACT_DIR_REL + "/latest-package-content-audit.json";
27
-
28
- const FORBIDDEN_PATTERNS = [
29
- // .env files — but NOT .example files (those are safe templates)
30
- { pattern: /^\.env($|\.[^e]|\.[e][^x]|\.[ex][^a])/i, reason: "env file (not example)" },
31
- // Actual secret stores — NOT source files that merely mention secrets
32
- { pattern: /\.env\.local$/i, reason: ".env.local file" },
33
- { pattern: /\.env\.production$/i, reason: ".env.production file" },
34
- { pattern: /\.env\.development$/i, reason: ".env.development file" },
35
- { pattern: /npm-token/i, reason: "npm token file" },
36
- { pattern: /\.npmtoken$/i, reason: "npm token file" },
37
- { pattern: /\.npmrc$/, reason: ".npmrc (may contain tokens)" },
38
- { pattern: /^\.claude\//i, reason: "claude runtime state" },
39
- { pattern: /^\.avorelo\//i, reason: "avorelo runtime state" },
40
- { pattern: /^\.wuz\//i, reason: "wuz runtime state (internal)" },
41
- { pattern: /^artifacts\//i, reason: "runtime artifacts" },
42
- { pattern: /^apps\/public-web\//i, reason: "public website source" },
43
- { pattern: /^tests?\//i, reason: "test files" },
44
- { pattern: /^docs\//i, reason: "docs not required at runtime" },
45
- { pattern: /^deferred\//i, reason: "deferred sources" },
46
- { pattern: /^dist\//i, reason: "build output" },
47
- { pattern: /^screenshots?\//i, reason: "screenshots" },
48
- { pattern: /^reports?\//i, reason: "generated reports" },
49
- { pattern: /^\.git\//i, reason: "git internals" },
50
- /^node_modules\//i,
51
- /\.tgz$/i,
52
- ];
53
-
54
- const SUSPICIOUS_PATTERNS = [
55
- /^tests?\//i,
56
- /^spec\//i,
57
- /^e2e-tests?\//i,
58
- /^\.github\//i,
59
- /\.log$/i,
60
- /^screenshots?\//i,
61
- /^videos?\//i,
62
- /\.backup$/i,
63
- /^docs\/dogfood\//i,
64
- /^docs\/feedback\//i,
65
- ];
66
-
67
- const REQUIRED_FILES = [
68
- "package.json",
69
- "bin/avorelo",
70
- "scripts/lib/public-cli.js",
71
- ];
72
-
73
- function safeReadJson(absPath) {
74
- try {
75
- if (!fs.existsSync(absPath)) return null;
76
- return JSON.parse(fs.readFileSync(absPath, "utf8").replace(/^/, ""));
77
- } catch { return null; }
78
- }
79
-
80
- // ── npm pack --dry-run ────────────────────────────────────────────────────────
81
-
82
- function runNpmPackDryRun(cwd, options) {
83
- const result = runNpm(["pack", "--dry-run", "--json"], {
84
- cwd,
85
- timeoutMs: 30000,
86
- cacheLabel: "package-audit",
87
- });
88
- return {
89
- success: result.success,
90
- output: result.stdout || "",
91
- stderr: result.stderr || "",
92
- combinedOutput: result.combinedOutput || "",
93
- errorSummary: result.errorSummary || "",
94
- };
95
- }
96
-
97
- // ── Parse npm pack output ─────────────────────────────────────────────────────
98
-
99
- function parseNpmPackOutput(output, options) {
100
- const trimmedOutput = (output || "").trim();
101
- if (trimmedOutput.startsWith("[")) {
102
- try {
103
- const parsedJson = JSON.parse(trimmedOutput);
104
- const firstEntry = Array.isArray(parsedJson) ? parsedJson[0] : parsedJson;
105
- const files = Array.isArray(firstEntry && firstEntry.files)
106
- ? firstEntry.files.map(function(entry) { return entry.path; })
107
- : [];
108
- return {
109
- files,
110
- totalFiles: firstEntry && typeof firstEntry.entryCount === "number" ? firstEntry.entryCount : files.length,
111
- totalSizeEstimate: firstEntry && typeof firstEntry.size === "number" ? String(firstEntry.size) + " bytes" : "unknown",
112
- };
113
- } catch {
114
- // Fall through to legacy npm notice parsing below.
115
- }
116
- }
117
-
118
- // npm pack --dry-run format (npm v7+):
119
- // npm notice === Tarball Contents ===
120
- // npm notice 1.2kB package.json
121
- // npm notice 12.3kB bin/avorelo
122
- // ...
123
- // npm notice === Tarball Details ===
124
- // npm notice total files: N
125
- // npm notice bundled size: X bytes
126
- const files = [];
127
- let totalSizeEstimate = null;
128
- let totalFiles = null;
129
-
130
- const lines = output.split("\n");
131
- let inContents = false;
132
-
133
- for (const line of lines) {
134
- // Detect section header
135
- if (/tarball contents/i.test(line)) { inContents = true; continue; }
136
- if (/tarball details/i.test(line)) { inContents = false; continue; }
137
-
138
- if (inContents) {
139
- // Match: "npm notice 1.2kB some/path/file.js"
140
- const m = line.match(/npm\s+notice\s+[\d.]+\s*[kKmMbB]+\s+(.+)/);
141
- if (m) {
142
- files.push(m[1].trim());
143
- }
144
- }
145
-
146
- // Also look for "total files:" line
147
- const totalM = line.match(/total files:\s*(\d+)/i);
148
- if (totalM) totalFiles = parseInt(totalM[1], 10);
149
-
150
- const sizeM = line.match(/package size:\s*(.+)/i);
151
- if (sizeM) totalSizeEstimate = sizeM[1].trim();
152
- }
153
-
154
- // Fallback: if npm pack outputs lines without "npm notice" prefix
155
- if (files.length === 0) {
156
- for (const line of lines) {
157
- const trimmed = line.trim();
158
- if (trimmed && !trimmed.startsWith("npm") && !trimmed.startsWith("{") && trimmed.includes("/")) {
159
- files.push(trimmed);
160
- }
161
- }
162
- }
163
-
164
- // Deduplicate (combined stderr+stdout can have dupes)
165
- const uniqueFiles = Array.from(new Set(files));
166
- return { files: uniqueFiles, totalFiles: totalFiles || uniqueFiles.length, totalSizeEstimate: totalSizeEstimate || "unknown" };
167
- }
168
-
169
- // ── Audit the file list ───────────────────────────────────────────────────────
170
-
171
- function auditPackFileList(fileList, options) {
172
- const forbiddenFiles = [];
173
- const suspiciousFiles = [];
174
- const requiredPresent = [];
175
- const requiredMissing = [];
176
-
177
- for (const f of fileList) {
178
- const normalized = normalizeRelativePath(f);
179
-
180
- // .example files are safe templates, never forbidden
181
- if (/\.example$/i.test(normalized)) { /* skip forbidden check */ }
182
- else {
183
- for (const entry of FORBIDDEN_PATTERNS) {
184
- const pat = entry.pattern || entry;
185
- if (pat.test(normalized)) {
186
- forbiddenFiles.push(f);
187
- break;
188
- }
189
- }
190
- }
191
-
192
- for (const pat of SUSPICIOUS_PATTERNS) {
193
- if (pat.test(normalized)) {
194
- suspiciousFiles.push(f);
195
- break;
196
- }
197
- }
198
- }
199
-
200
- for (const req of REQUIRED_FILES) {
201
- const found = fileList.some(function(f) {
202
- return f.replace(/\\/g, "/") === req || f.replace(/\\/g, "/").endsWith("/" + req);
203
- });
204
- if (found) {
205
- requiredPresent.push(req);
206
- } else {
207
- requiredMissing.push(req);
208
- }
209
- }
210
-
211
- return { forbiddenFiles, suspiciousFiles, requiredPresent, requiredMissing };
212
- }
213
-
214
- // ── Build audit ───────────────────────────────────────────────────────────────
215
-
216
- function buildPackageContentAudit(cwd, options) {
217
- const pkg = readPackageJson(cwd);
218
- const binEntries = getBinEntries(pkg);
219
- const publishConfig = getPublishConfig(pkg);
220
- const filesAllowlist = Array.isArray(pkg && pkg.files) ? pkg.files.slice() : [];
221
- const runtimeGraph = collectRuntimeDependencyGraph(cwd, {
222
- entryFiles: getPublicRuntimeEntryFiles(cwd),
223
- });
224
- const missingRuntimeDependencies = findMissingRuntimeDependencies(pkg, runtimeGraph);
225
- const runResult = options && options.npmPackResult ? options.npmPackResult : runNpmPackDryRun(cwd, options);
226
- const metadataProblems = [];
227
-
228
- if (!pkg) metadataProblems.push("package.json missing or invalid");
229
- if (pkg && pkg.name !== "avorelo") metadataProblems.push("package name must be avorelo");
230
- if (pkg && !pkg.version) metadataProblems.push("package version missing");
231
- if (pkg && pkg.private !== false) metadataProblems.push("package private flag must be false for ready_to_publish");
232
- if (!publishConfig || publishConfig.access !== "public") metadataProblems.push("publishConfig.access must be public");
233
- if (!binEntries.avorelo || binEntries.avorelo !== "bin/avorelo") metadataProblems.push("bin.avorelo must point to bin/avorelo");
234
- if (filesAllowlist.length === 0) metadataProblems.push("package files allowlist missing");
235
- if (missingRuntimeDependencies.length > 0) metadataProblems.push("runtime dependencies must be present in dependencies: " + missingRuntimeDependencies.join(", "));
236
- if (runtimeGraph.missingLocalFiles.length > 0) metadataProblems.push("runtime graph references missing local files: " + runtimeGraph.missingLocalFiles.join(", "));
237
-
238
- if (!runResult.success) {
239
- return {
240
- contract: CONTRACT,
241
- schemaVersion: SCHEMA_VERSION,
242
- generatedAt: nowIso(),
243
- status: "not_available",
244
- ok: false,
245
- packageName: pkg && pkg.name ? pkg.name : null,
246
- version: pkg && pkg.version ? pkg.version : null,
247
- private: pkg ? pkg.private : null,
248
- publishConfig,
249
- binEntries,
250
- filesAllowlist,
251
- runtimeExternalDependencies: runtimeGraph.externalPackages,
252
- runtimeDependenciesOk: missingRuntimeDependencies.length === 0 && runtimeGraph.missingLocalFiles.length === 0,
253
- missingRuntimeDependencies,
254
- missingLocalRuntimeFiles: runtimeGraph.missingLocalFiles,
255
- runtimeFilesMissingFromPack: runtimeGraph.localFiles,
256
- distributionState: "publish_blocked",
257
- npmPackDryRunAvailable: false,
258
- packageFiles: [],
259
- fileCount: 0,
260
- totalSizeEstimate: "unknown",
261
- forbiddenFiles: [],
262
- suspiciousFiles: [],
263
- requiredFiles: { present: [], missing: REQUIRED_FILES },
264
- missingRequiredFiles: REQUIRED_FILES,
265
- metadataProblems,
266
- safeNextAction: "npm pack --dry-run failed. Verify npm is available and package.json is valid.",
267
- noPublicLaunchClaim: true,
268
- redacted: true,
269
- };
270
- }
271
-
272
- const combined = runResult.combinedOutput || [runResult.output, runResult.stderr].filter(Boolean).join("\n");
273
- const parsed = parseNpmPackOutput(combined, options);
274
- const { forbiddenFiles, suspiciousFiles, requiredPresent, requiredMissing } = auditPackFileList(parsed.files, options);
275
- const packedFiles = new Set(parsed.files.map((entry) => normalizeRelativePath(entry)));
276
- const runtimeFilesMissingFromPack = runtimeGraph.localFiles.filter((filePath) => !packedFiles.has(filePath));
277
-
278
- let status;
279
- if (metadataProblems.length > 0 || forbiddenFiles.length > 0 || runtimeFilesMissingFromPack.length > 0) {
280
- status = "fail";
281
- } else if (suspiciousFiles.length > 0 || requiredMissing.length > 0) {
282
- status = "warn";
283
- } else {
284
- status = "pass";
285
- }
286
-
287
- const safeNextAction = metadataProblems.length > 0
288
- ? "Fix package metadata before publish. Name/bin/private/publishConfig/files must all be explicit."
289
- : forbiddenFiles.length > 0
290
- ? "Add forbidden files to .npmignore immediately. Do not publish until resolved."
291
- : runtimeFilesMissingFromPack.length > 0
292
- ? "Ensure all runtime files required by the packed public CLI are included in the publish surface."
293
- : requiredMissing.length > 0
294
- ? "Verify required files (" + requiredMissing.join(", ") + ") will be included in the published package."
295
- : suspiciousFiles.length > 0
296
- ? "Review suspicious files and add to .npmignore if not needed in published package."
297
- : "Package content audit passed. Proceed to local package smoke test.";
298
-
299
- return {
300
- contract: CONTRACT,
301
- schemaVersion: SCHEMA_VERSION,
302
- generatedAt: nowIso(),
303
- status,
304
- ok: status === "pass",
305
- packageName: pkg && pkg.name ? pkg.name : null,
306
- version: pkg && pkg.version ? pkg.version : null,
307
- private: pkg ? pkg.private : null,
308
- publishConfig,
309
- binEntries,
310
- filesAllowlist,
311
- runtimeExternalDependencies: runtimeGraph.externalPackages,
312
- runtimeDependenciesOk: missingRuntimeDependencies.length === 0 && runtimeGraph.missingLocalFiles.length === 0,
313
- missingRuntimeDependencies,
314
- missingLocalRuntimeFiles: runtimeGraph.missingLocalFiles,
315
- runtimeFilesMissingFromPack,
316
- distributionState: status === "pass" ? "ready_to_publish" : "publish_blocked",
317
- npmPackDryRunAvailable: true,
318
- packageFiles: parsed.files,
319
- fileCount: parsed.totalFiles,
320
- totalSizeEstimate: parsed.totalSizeEstimate,
321
- forbiddenFiles,
322
- suspiciousFiles,
323
- requiredFiles: { present: requiredPresent, missing: requiredMissing },
324
- missingRequiredFiles: requiredMissing,
325
- metadataProblems,
326
- safeNextAction,
327
- noPublicLaunchClaim: true,
328
- redacted: true,
329
- };
330
- }
331
-
332
- // ── Write ─────────────────────────────────────────────────────────────────────
333
-
334
- function writePackageContentAudit(cwd, audit) {
335
- const dir = path.join(cwd, ARTIFACT_DIR_REL);
336
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
337
- fs.writeFileSync(path.join(cwd, ARTIFACT_REL), JSON.stringify(audit, null, 2));
338
- }
339
-
340
- // ── Format ────────────────────────────────────────────────────────────────────
341
-
342
- function formatPackageContentAuditText(audit, options) {
343
- if (!audit.npmPackDryRunAvailable) {
344
- return "Package Content Audit [NOT_AVAILABLE]\n npm pack --dry-run failed. Cannot audit file list.";
345
- }
346
- const lines = [
347
- "Package Content Audit [" + audit.status.toUpperCase() + "]",
348
- " Package: " + (audit.packageName || "?") + "@" + (audit.version || "?"),
349
- " Private: " + audit.private,
350
- " publishConfig: " + JSON.stringify(audit.publishConfig || null),
351
- " Files: " + audit.fileCount + " (" + audit.totalSizeEstimate + ")",
352
- " Forbidden: " + audit.forbiddenFiles.length,
353
- " Suspicious: " + audit.suspiciousFiles.length,
354
- " Required present: " + audit.requiredFiles.present.length + "/" + REQUIRED_FILES.length,
355
- " Missing required: " + (audit.missingRequiredFiles.join(", ") || "none"),
356
- " Next: " + audit.safeNextAction,
357
- ];
358
- return lines.join("\n");
359
- }
360
-
361
- module.exports = {
362
- runNpmPackDryRun,
363
- parseNpmPackOutput,
364
- auditPackFileList,
365
- buildPackageContentAudit,
366
- writePackageContentAudit,
367
- formatPackageContentAuditText,
368
- };
@@ -1,278 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const os = require("os");
5
- const path = require("path");
6
- const { spawnSync } = require("child_process");
7
- const { builtinModules } = require("module");
8
-
9
- const BUILTIN_MODULES = new Set([
10
- ...builtinModules,
11
- ...builtinModules.map((name) => name.replace(/^node:/, "")),
12
- ...builtinModules.map((name) => (name.startsWith("node:") ? name : `node:${name}`)),
13
- ]);
14
- const REQUIRE_PATTERN = /require\((["'])([^"']+)\1\)/g;
15
- const OPTIONAL_REQUIRE_LOOKAROUND = 240;
16
-
17
- function ensureDir(dirPath) {
18
- if (!dirPath) return dirPath;
19
- fs.mkdirSync(dirPath, { recursive: true });
20
- return dirPath;
21
- }
22
-
23
- function readJson(absPath) {
24
- try {
25
- if (!fs.existsSync(absPath)) return null;
26
- return JSON.parse(fs.readFileSync(absPath, "utf8").replace(/^\uFEFF/, ""));
27
- } catch {
28
- return null;
29
- }
30
- }
31
-
32
- function readPackageJson(cwd) {
33
- return readJson(path.join(cwd, "package.json"));
34
- }
35
-
36
- function getBinEntries(pkg) {
37
- if (!pkg || !pkg.bin) return {};
38
- return typeof pkg.bin === "string" ? { [pkg.name || "avorelo"]: pkg.bin } : { ...pkg.bin };
39
- }
40
-
41
- function getPublishConfig(pkg) {
42
- return pkg && pkg.publishConfig && typeof pkg.publishConfig === "object"
43
- ? { ...pkg.publishConfig }
44
- : null;
45
- }
46
-
47
- function createCacheDir(label = "default") {
48
- const safeLabel = String(label).replace(/[^a-z0-9_-]+/gi, "-").toLowerCase();
49
- return ensureDir(path.join(os.tmpdir(), "avorelo-npm-cache", safeLabel));
50
- }
51
-
52
- function createTempDir(prefix) {
53
- return fs.mkdtempSync(path.join(os.tmpdir(), prefix || "avorelo-"));
54
- }
55
-
56
- function buildPackageManagerEnv(options = {}) {
57
- const env = {
58
- ...process.env,
59
- ...(options.env || {}),
60
- };
61
- env.npm_config_cache = options.cacheDir || createCacheDir(options.cacheLabel || "default");
62
- env.npm_config_update_notifier = "false";
63
- env.npm_config_fund = "false";
64
- env.npm_config_audit = "false";
65
- env.npm_config_loglevel = env.npm_config_loglevel || "warn";
66
- return env;
67
- }
68
-
69
- function runPackageManagerCommand(tool, args, options = {}) {
70
- const commandArgs = Array.isArray(args) ? args.slice() : [];
71
- const env = buildPackageManagerEnv(options);
72
- const spawnCommand = process.platform === "win32" ? "cmd" : tool;
73
- const spawnArgs = process.platform === "win32" ? ["/c", tool, ...commandArgs] : commandArgs;
74
- const result = spawnSync(spawnCommand, spawnArgs, {
75
- cwd: options.cwd || process.cwd(),
76
- env,
77
- encoding: "utf8",
78
- timeout: options.timeoutMs || 120000,
79
- stdio: "pipe",
80
- });
81
-
82
- const stdout = result.stdout || "";
83
- const stderr = result.stderr || "";
84
- return {
85
- success: result.status === 0,
86
- status: result.status,
87
- signal: result.signal || null,
88
- stdout,
89
- stderr,
90
- combinedOutput: [stdout, stderr].filter(Boolean).join("\n").trim(),
91
- errorSummary: [stderr, stdout].find(Boolean) || (result.error ? String(result.error) : ""),
92
- cacheDir: env.npm_config_cache,
93
- };
94
- }
95
-
96
- function runNpm(args, options = {}) {
97
- return runPackageManagerCommand("npm", args, options);
98
- }
99
-
100
- function runNpx(args, options = {}) {
101
- return runPackageManagerCommand("npx", args, options);
102
- }
103
-
104
- function normalizeRelativePath(filePath) {
105
- return String(filePath || "").replace(/\\/g, "/").replace(/^\.\//, "");
106
- }
107
-
108
- function packageNameFromSpecifier(specifier) {
109
- const normalized = String(specifier || "").replace(/^node:/, "");
110
- if (!normalized || normalized.startsWith(".") || normalized.startsWith("/")) return null;
111
- if (normalized.startsWith("@")) {
112
- const parts = normalized.split("/");
113
- return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : normalized;
114
- }
115
- return normalized.split("/")[0];
116
- }
117
-
118
- function isFile(candidate) {
119
- try {
120
- return fs.existsSync(candidate) && fs.statSync(candidate).isFile();
121
- } catch {
122
- return false;
123
- }
124
- }
125
-
126
- function resolveLocalModule(fromFile, specifier) {
127
- const absoluteBase = path.resolve(path.dirname(fromFile), specifier);
128
- const candidates = [
129
- `${absoluteBase}.js`,
130
- `${absoluteBase}.json`,
131
- path.join(absoluteBase, "index.js"),
132
- path.join(absoluteBase, "index.json"),
133
- absoluteBase,
134
- ];
135
- return candidates.find((candidate) => isFile(candidate)) || null;
136
- }
137
-
138
- function isLikelyOptionalRequire(source, matchIndex) {
139
- const start = Math.max(0, matchIndex - OPTIONAL_REQUIRE_LOOKAROUND);
140
- const end = Math.min(source.length, matchIndex + OPTIONAL_REQUIRE_LOOKAROUND);
141
- const before = source.slice(start, matchIndex);
142
- const after = source.slice(matchIndex, end);
143
- return /\btry\s*\{[^{}]*$/s.test(before) && /\}\s*catch\b/s.test(after);
144
- }
145
-
146
- function getPublicRuntimeEntryFiles(cwd) {
147
- const root = path.resolve(cwd);
148
- return [
149
- path.join(root, "scripts", "lib", "alpha-activation.js"),
150
- path.join(root, "scripts", "cco-status.js"),
151
- path.join(root, "scripts", "cco-dashboard.js"),
152
- ].filter((filePath) => fs.existsSync(filePath));
153
- }
154
-
155
- function collectRuntimeDependencyGraph(cwd, options = {}) {
156
- const root = path.resolve(cwd);
157
- const entryFiles = (options.entryFiles || [path.join(root, "bin", "avorelo")]).map((filePath) => path.resolve(filePath));
158
- const visited = new Set();
159
- const externalPackages = new Set();
160
- const localFiles = new Set();
161
- const missingLocalFiles = new Set();
162
- const queue = entryFiles.slice();
163
-
164
- while (queue.length > 0) {
165
- const current = queue.shift();
166
- if (!current || visited.has(current) || !fs.existsSync(current)) continue;
167
- visited.add(current);
168
- localFiles.add(normalizeRelativePath(path.relative(root, current)));
169
-
170
- let source = "";
171
- try {
172
- source = fs.readFileSync(current, "utf8");
173
- } catch {
174
- continue;
175
- }
176
-
177
- REQUIRE_PATTERN.lastIndex = 0;
178
- let match;
179
- while ((match = REQUIRE_PATTERN.exec(source)) !== null) {
180
- const specifier = match[2];
181
- const optionalRequire = isLikelyOptionalRequire(source, match.index);
182
- if (!specifier) continue;
183
- if (specifier.startsWith(".")) {
184
- const resolved = resolveLocalModule(current, specifier);
185
- if (resolved) {
186
- queue.push(resolved);
187
- } else if (!optionalRequire) {
188
- missingLocalFiles.add(normalizeRelativePath(path.relative(root, path.resolve(path.dirname(current), specifier))));
189
- }
190
- continue;
191
- }
192
-
193
- const packageName = packageNameFromSpecifier(specifier);
194
- if (!packageName || BUILTIN_MODULES.has(packageName) || BUILTIN_MODULES.has(specifier) || optionalRequire) continue;
195
- externalPackages.add(packageName);
196
- }
197
- }
198
-
199
- return {
200
- entryFiles: entryFiles.map((filePath) => normalizeRelativePath(path.relative(root, filePath))),
201
- localFiles: Array.from(localFiles).sort(),
202
- externalPackages: Array.from(externalPackages).sort(),
203
- missingLocalFiles: Array.from(missingLocalFiles).sort(),
204
- };
205
- }
206
-
207
- function findMissingRuntimeDependencies(pkg, runtimeGraph) {
208
- const dependencies = pkg && pkg.dependencies && typeof pkg.dependencies === "object" ? pkg.dependencies : {};
209
- return (runtimeGraph && Array.isArray(runtimeGraph.externalPackages) ? runtimeGraph.externalPackages : [])
210
- .filter((packageName) => !Object.prototype.hasOwnProperty.call(dependencies, packageName))
211
- .sort();
212
- }
213
-
214
- function buildPathRedactions(paths = []) {
215
- const redactions = [];
216
- for (const value of paths) {
217
- if (!value) continue;
218
- const normalized = String(value);
219
- redactions.push([normalized, "<redacted-temp-path>"]);
220
- redactions.push([normalized.replace(/\\/g, "/"), "<redacted-temp-path>"]);
221
- redactions.push([normalized.replace(/\\/g, "\\\\"), "<redacted-temp-path>"]);
222
- }
223
- return redactions.sort((left, right) => right[0].length - left[0].length);
224
- }
225
-
226
- function redactPathsInText(text, paths = []) {
227
- if (typeof text !== "string" || !text) return text;
228
- let redacted = text;
229
- for (const [target, replacement] of buildPathRedactions(paths)) {
230
- redacted = redacted.split(target).join(replacement);
231
- }
232
- return redacted;
233
- }
234
-
235
- function redactPathsInValue(value, paths = []) {
236
- if (typeof value === "string") return redactPathsInText(value, paths);
237
- if (Array.isArray(value)) return value.map((entry) => redactPathsInValue(entry, paths));
238
- if (!value || typeof value !== "object") return value;
239
- const next = {};
240
- for (const [key, entry] of Object.entries(value)) {
241
- next[key] = redactPathsInValue(entry, paths);
242
- }
243
- return next;
244
- }
245
-
246
- function mapDistributionStateToStatus(distributionState) {
247
- switch (distributionState) {
248
- case "publish_blocked":
249
- return "blocked";
250
- case "private_local_only":
251
- case "local_verified":
252
- return "local_only";
253
- case "ready_to_publish":
254
- case "published_verified":
255
- return "pass";
256
- default:
257
- return "warn";
258
- }
259
- }
260
-
261
- module.exports = {
262
- ensureDir,
263
- readJson,
264
- readPackageJson,
265
- getBinEntries,
266
- getPublishConfig,
267
- createCacheDir,
268
- createTempDir,
269
- runNpm,
270
- runNpx,
271
- normalizeRelativePath,
272
- collectRuntimeDependencyGraph,
273
- findMissingRuntimeDependencies,
274
- getPublicRuntimeEntryFiles,
275
- redactPathsInText,
276
- redactPathsInValue,
277
- mapDistributionStateToStatus,
278
- };
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- const { PLAN_ENV, getCurrentPlan, getHistoryRetention, canExportReports } = require("./entitlements");
4
- const { getPlan, listBucketsForPlan, comparePlans } = require("./plans");
5
- const { buildVisualQaSurface } = require("./visual-qa");
6
- const { buildPlanSecuritySurface } = require("./agent-enforcement");
7
-
8
- function buildIncludedLine(planName, visualQaSurface) {
9
- if (planName === "pro") {
10
- return "Included: Better AI Coding Tasks, Advanced Context Optimization, more Visual QA, and advanced Agent Security.";
11
- }
12
- const quota = visualQaSurface?.quota;
13
- const visualQaLabel = quota?.tracked ? `${quota.limit} Visual QA/${quota.period}` : "Visual QA";
14
- return `Included: Better AI Coding Tasks, Basic Context Optimization, ${visualQaLabel}, and Basic Agent Security.`;
15
- }
16
-
17
- function buildUpgradeLine() {
18
- return "Pro unlocks advanced task compilation, deeper context optimization, more Visual QA, least-privilege protection, and evidence history/export.";
19
- }
20
-
21
- function buildPlanSurface(cwd) {
22
- const planName = getCurrentPlan({ cwd });
23
- const plan = getPlan(planName) || getPlan("free");
24
- const buckets = listBucketsForPlan(planName);
25
- const visualQa = buildVisualQaSurface(cwd, { plan: planName });
26
- const security = buildPlanSecuritySurface(cwd, { plan: planName });
27
- const comparison = comparePlans();
28
- const overrideValue = String(process.env[PLAN_ENV] || "").trim().toLowerCase();
29
- const overrideNote = overrideValue === planName
30
- ? `${PLAN_ENV}=${overrideValue} override active for local development/testing.`
31
- : null;
32
- return {
33
- plan: planName,
34
- planLabel: plan.name,
35
- planSource: overrideNote ? "env_override" : "default_resolution",
36
- overrideNote,
37
- subtitle: plan.subtitle,
38
- promise: plan.promise,
39
- buckets: buckets.map((bucket) => bucket.label),
40
- bucketDetails: buckets,
41
- includedLine: buildIncludedLine(planName, visualQa),
42
- upgradeLine: buildUpgradeLine(),
43
- historyRetention: getHistoryRetention(planName),
44
- canExportReports: canExportReports(planName),
45
- visualQa,
46
- security,
47
- upgradeUnlocks: comparison.upgradeUnlocks,
48
- };
49
- }
50
-
51
- module.exports = {
52
- buildPlanSurface,
53
- };