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,252 +0,0 @@
1
- "use strict";
2
-
3
- const { normalizeModelIdLower, inferProfilesFromModelId } = require("./model-profiler");
4
-
5
- const PROFILE_CATALOG = {
6
- claude_code: [
7
- {
8
- id: "haiku",
9
- provider: "anthropic",
10
- label: "Haiku / cheap profile",
11
- modelHints: ["haiku"],
12
- costTier: "low",
13
- qualityTier: "medium",
14
- trustTier: "trusted",
15
- privacyTier: "trusted_remote",
16
- supportedRoles: ["planning", "docs", "tests"],
17
- },
18
- {
19
- id: "sonnet",
20
- provider: "anthropic",
21
- label: "Sonnet profile",
22
- modelHints: ["sonnet", "standard_quality"],
23
- costTier: "medium",
24
- qualityTier: "high",
25
- trustTier: "trusted",
26
- privacyTier: "trusted_remote",
27
- supportedRoles: ["planning", "implementation", "review", "security", "ui", "cli", "tests", "docs"],
28
- },
29
- {
30
- id: "opus",
31
- provider: "anthropic",
32
- label: "Opus profile",
33
- modelHints: ["opus", "deep_reasoning"],
34
- costTier: "high",
35
- qualityTier: "highest",
36
- trustTier: "trusted",
37
- privacyTier: "trusted_remote",
38
- supportedRoles: ["implementation", "review", "security", "refactor"],
39
- },
40
- ],
41
- codex: [
42
- {
43
- id: "fast_mini",
44
- provider: "openai",
45
- label: "Fast / mini profile",
46
- modelHints: ["mini", "nano", "fast", "fast_low_cost"],
47
- costTier: "low",
48
- qualityTier: "medium",
49
- trustTier: "trusted",
50
- privacyTier: "trusted_remote",
51
- supportedRoles: ["planning", "docs", "tests"],
52
- },
53
- {
54
- id: "default_coding",
55
- provider: "openai",
56
- label: "Default coding profile",
57
- modelHints: ["gpt-5", "codex", "o4", "default", "standard_quality", "coding_candidate"],
58
- costTier: "medium",
59
- qualityTier: "high",
60
- trustTier: "trusted",
61
- privacyTier: "trusted_remote",
62
- supportedRoles: ["planning", "implementation", "review", "ui", "cli", "tests", "refactor", "docs"],
63
- },
64
- {
65
- id: "high_reasoning",
66
- provider: "openai",
67
- label: "Higher-reasoning profile",
68
- modelHints: ["reason", "o3", "high", "deep_reasoning"],
69
- costTier: "high",
70
- qualityTier: "highest",
71
- trustTier: "trusted",
72
- privacyTier: "trusted_remote",
73
- supportedRoles: ["implementation", "review", "security", "refactor"],
74
- },
75
- ],
76
- gemini_cli: [
77
- {
78
- id: "flash",
79
- provider: "google",
80
- label: "Flash / cheap profile",
81
- modelHints: ["flash", "fast_low_cost"],
82
- costTier: "low",
83
- qualityTier: "medium",
84
- trustTier: "external",
85
- privacyTier: "external_remote",
86
- supportedRoles: ["planning", "docs", "tests", "ui"],
87
- },
88
- {
89
- id: "pro",
90
- provider: "google",
91
- label: "Pro / long-context profile",
92
- modelHints: ["pro", "standard_quality", "deep_reasoning"],
93
- costTier: "medium",
94
- qualityTier: "high",
95
- trustTier: "external",
96
- privacyTier: "external_remote",
97
- supportedRoles: ["planning", "implementation", "tests", "ui", "docs"],
98
- },
99
- ],
100
- lm_studio: [
101
- {
102
- id: "local_summary",
103
- provider: "lm_studio",
104
- label: "Local/private summary profile",
105
- modelHints: ["chat_candidate", "standard_quality"],
106
- costTier: "free_local",
107
- qualityTier: "unknown",
108
- trustTier: "local",
109
- privacyTier: "local_only",
110
- supportedRoles: ["planning", "docs", "tests", "summaries"],
111
- },
112
- {
113
- id: "local_coding",
114
- provider: "lm_studio",
115
- label: "Local/private coding profile",
116
- modelHints: ["coding_candidate"],
117
- costTier: "free_local",
118
- qualityTier: "medium",
119
- trustTier: "local",
120
- privacyTier: "local_only",
121
- supportedRoles: ["planning", "docs", "tests", "implementation", "refactor", "cli", "summaries"],
122
- },
123
- ],
124
- opencode: [
125
- {
126
- id: "cheap_coding",
127
- provider: "opencode",
128
- label: "Cheap coding profile",
129
- modelHints: ["cheap", "mini", "flash", "fast_low_cost"],
130
- costTier: "low",
131
- qualityTier: "medium",
132
- trustTier: "external",
133
- privacyTier: "external_remote",
134
- supportedRoles: ["planning", "docs", "tests"],
135
- },
136
- {
137
- id: "standard_coding",
138
- provider: "opencode",
139
- label: "Standard coding profile",
140
- modelHints: ["sonnet", "gpt", "default", "standard", "coding_candidate", "standard_quality"],
141
- costTier: "medium",
142
- qualityTier: "high",
143
- trustTier: "external",
144
- privacyTier: "external_remote",
145
- supportedRoles: ["planning", "implementation", "tests", "docs", "ui", "cli"],
146
- },
147
- ],
148
- aider: [
149
- {
150
- id: "repo_edit",
151
- provider: "aider",
152
- label: "Repo editing profile",
153
- modelHints: ["aider", "default", "coding_candidate"],
154
- costTier: "medium",
155
- qualityTier: "high",
156
- trustTier: "external",
157
- privacyTier: "external_remote",
158
- supportedRoles: ["implementation", "refactor", "tests", "cli"],
159
- },
160
- ],
161
- ollama: [
162
- {
163
- id: "local_private",
164
- provider: "ollama",
165
- label: "Local/private profile",
166
- modelHints: ["chat_candidate", "standard_quality"],
167
- costTier: "free_local",
168
- qualityTier: "unknown",
169
- trustTier: "local",
170
- privacyTier: "local_only",
171
- supportedRoles: ["planning", "docs", "tests", "summaries"],
172
- },
173
- {
174
- id: "local_private_coding",
175
- provider: "ollama",
176
- label: "Local/private coding profile",
177
- modelHints: ["coding_candidate"],
178
- costTier: "free_local",
179
- qualityTier: "medium",
180
- trustTier: "local",
181
- privacyTier: "local_only",
182
- supportedRoles: ["planning", "docs", "tests", "implementation", "summaries"],
183
- },
184
- ],
185
- openrouter_api: [
186
- {
187
- id: "cheap_external",
188
- provider: "openrouter",
189
- label: "Cheap external profile",
190
- modelHints: ["cheap", "mini", "free", "fast_low_cost"],
191
- costTier: "low",
192
- qualityTier: "medium",
193
- trustTier: "external",
194
- privacyTier: "external_remote",
195
- supportedRoles: ["planning", "docs", "tests"],
196
- },
197
- {
198
- id: "fallback_external",
199
- provider: "openrouter",
200
- label: "Fallback external profile",
201
- modelHints: ["sonnet", "gpt", "claude", "coder", "coding_candidate", "standard_quality"],
202
- costTier: "medium",
203
- qualityTier: "high",
204
- trustTier: "external",
205
- privacyTier: "external_remote",
206
- supportedRoles: ["planning", "implementation", "docs", "tests"],
207
- },
208
- ],
209
- litellm_requesty: [
210
- {
211
- id: "gateway_candidate",
212
- provider: "gateway",
213
- label: "Gateway candidate profile",
214
- modelHints: ["gateway", "router", "proxy", "standard_quality"],
215
- costTier: "medium",
216
- qualityTier: "unknown",
217
- trustTier: "unknown",
218
- privacyTier: "gateway_remote",
219
- supportedRoles: ["planning", "implementation", "docs", "tests"],
220
- },
221
- ],
222
- };
223
-
224
- function getProfiles(toolId) {
225
- return (PROFILE_CATALOG[toolId] || []).map((profile) => ({ ...profile }));
226
- }
227
-
228
- function detectProfile(toolId, modelId) {
229
- const normalized = normalizeModelIdLower(modelId);
230
- if (!normalized) return null;
231
- const inferred = inferProfilesFromModelId(modelId);
232
- return getProfiles(toolId).find((profile) => {
233
- const hints = (profile.modelHints || []).map((hint) => String(hint).toLowerCase());
234
- return hints.some((hint) => normalized.includes(hint) || inferred.includes(hint));
235
- }) || null;
236
- }
237
-
238
- function buildProfileSummary(toolId, activeModel) {
239
- const profiles = getProfiles(toolId);
240
- const active = detectProfile(toolId, activeModel);
241
- return profiles.map((profile) => ({
242
- ...profile,
243
- availability: active && active.id === profile.id ? "confirmed" : "candidate",
244
- }));
245
- }
246
-
247
- module.exports = {
248
- PROFILE_CATALOG,
249
- getProfiles,
250
- detectProfile,
251
- buildProfileSummary,
252
- };
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const { getCurrentPaths, safeReadJson, writeJson } = require("./state");
5
-
6
- const INVENTORY_SCHEMA_VERSION = 3;
7
- const DEFAULT_FULL_REFRESH_INTERVAL_HOURS = 72;
8
- const LOCK_TTL_MS = 10 * 60 * 1000;
9
-
10
- function defaultRefreshPolicy(settings = {}) {
11
- return {
12
- fullRefreshIntervalHours: Number(settings?.refreshPolicy?.fullRefreshIntervalHours || DEFAULT_FULL_REFRESH_INTERVAL_HOURS),
13
- singleModelRefreshOnNewUsage: settings?.refreshPolicy?.singleModelRefreshOnNewUsage !== false,
14
- };
15
- }
16
-
17
- function nextRefreshAfter(lastFullModelRefreshAt, policy) {
18
- const date = Date.parse(lastFullModelRefreshAt || "");
19
- if (!Number.isFinite(date)) return null;
20
- return new Date(date + (policy.fullRefreshIntervalHours * 60 * 60 * 1000)).toISOString();
21
- }
22
-
23
- function tryAcquireRefreshLock(cwd) {
24
- const paths = getCurrentPaths(cwd);
25
- const existing = safeReadJson(paths.inventoryRefreshLock, null);
26
- const now = Date.now();
27
- if (existing?.acquiredAt) {
28
- const age = now - Date.parse(existing.acquiredAt);
29
- if (Number.isFinite(age) && age < LOCK_TTL_MS) return { ok: false, staleRecovered: false };
30
- }
31
- if (existing?.acquiredAt) {
32
- try { fs.unlinkSync(paths.inventoryRefreshLock); } catch {}
33
- }
34
- writeJson(paths.inventoryRefreshLock, { lockVersion: 1, acquiredAt: new Date(now).toISOString() });
35
- return { ok: true, staleRecovered: Boolean(existing) };
36
- }
37
-
38
- function releaseRefreshLock(cwd) {
39
- const paths = getCurrentPaths(cwd);
40
- try { fs.unlinkSync(paths.inventoryRefreshLock); } catch {}
41
- }
42
-
43
- function determineRefreshDecision(cached, settings, options = {}) {
44
- const policy = defaultRefreshPolicy(settings);
45
- if (options.deepRefresh === true) {
46
- return { refreshLevel: "deep", inventorySource: "rebuilt", lastRefreshReason: "explicit_deep_refresh", policy };
47
- }
48
- if (options.refresh === true) {
49
- return { refreshLevel: "full", inventorySource: "rebuilt", lastRefreshReason: "explicit_refresh", policy };
50
- }
51
- if (!cached || cached.schemaVersion !== INVENTORY_SCHEMA_VERSION) {
52
- return { refreshLevel: "full", inventorySource: cached ? "repaired" : "rebuilt", lastRefreshReason: cached ? "schema_upgrade" : "missing_cache", policy };
53
- }
54
- const lastFull = Date.parse(cached.lastFullModelRefreshAt || "");
55
- if (!Number.isFinite(lastFull)) {
56
- return { refreshLevel: "full", inventorySource: "repaired", lastRefreshReason: "invalid_timestamp", policy };
57
- }
58
- if (Date.now() >= lastFull + (policy.fullRefreshIntervalHours * 60 * 60 * 1000)) {
59
- return { refreshLevel: "full", inventorySource: "rebuilt", lastRefreshReason: "scheduled_full_refresh", policy };
60
- }
61
- return { refreshLevel: "cache", inventorySource: "cache", lastRefreshReason: "fresh_cache", policy };
62
- }
63
-
64
- module.exports = {
65
- INVENTORY_SCHEMA_VERSION,
66
- DEFAULT_FULL_REFRESH_INTERVAL_HOURS,
67
- defaultRefreshPolicy,
68
- nextRefreshAfter,
69
- determineRefreshDecision,
70
- tryAcquireRefreshLock,
71
- releaseRefreshLock,
72
- };
@@ -1,349 +0,0 @@
1
- "use strict";
2
-
3
- const path = require("path");
4
- const {
5
- ensureOrchestrationDirs,
6
- getCurrentPaths,
7
- getRunPaths,
8
- writeJson,
9
- writeText,
10
- relativeFromCwd,
11
- } = require("./state");
12
-
13
- function redactText(value) {
14
- return String(value || "")
15
- .replace(/(OPENROUTER_API_KEY|ANTHROPIC_AUTH_TOKEN|OPENAI_API_KEY|GEMINI_API_KEY|REQUESTY_API_KEY|LITELLM_API_KEY)=\S+/gi, "$1=[REDACTED]")
16
- .replace(/sk-[A-Za-z0-9_-]+/g, "[REDACTED]");
17
- }
18
-
19
- function sanitizeValue(value) {
20
- if (typeof value === "string") return redactText(value);
21
- if (Array.isArray(value)) return value.map((item) => sanitizeValue(item));
22
- if (value && typeof value === "object") {
23
- return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sanitizeValue(entry)]));
24
- }
25
- return value;
26
- }
27
-
28
- function renderRouteMarkdown(route) {
29
- const lines = [
30
- "# Avorelo Route",
31
- "",
32
- `State: ${route.state}`,
33
- `Selected route: ${route.selectedRoute}`,
34
- `Inventory source: ${route.inventorySource || "cache"}`,
35
- `Refresh level: ${route.refreshLevel || "cache"}`,
36
- `Last full model refresh: ${route.lastFullModelRefreshAt || "unknown"}`,
37
- `Next full model refresh after: ${route.nextFullModelRefreshAfter || "unknown"}`,
38
- `Task type: ${route.task.taskType}`,
39
- `Risk: ${route.task.risk}`,
40
- `Sensitivity: ${route.task.sensitivity}`,
41
- `Chosen worker: ${route.chosenTool || "none"}`,
42
- `Chosen model: ${route.selectedModel || "none"}`,
43
- `Chosen model/profile: ${route.chosenModelProfile || "none"}`,
44
- `Fallback worker: ${route.fallbackTool || "none"}`,
45
- `Fallback model: ${route.fallbackModel || "none"}`,
46
- `Fallback model/profile: ${route.fallbackModelProfile || "none"}`,
47
- "",
48
- "Why chosen:",
49
- ...(route.whyChosen || []).map((item) => `- ${item}`),
50
- "",
51
- "Why not chosen:",
52
- ...(route.whyNotChosen || []).map((item) => `- ${item}`),
53
- "",
54
- "Safety notes:",
55
- ...(route.safetyNotes || []).map((item) => `- ${item}`),
56
- "",
57
- "Stages:",
58
- ...(route.stageList || []).map((stage) => `- ${stage.id}: ${stage.chosenLabel} (${stage.chosenModelProfile}) via ${stage.executionMode}`),
59
- ];
60
- return lines.join("\n").trim() + "\n";
61
- }
62
-
63
- function renderTaskMarkdown(taskContext) {
64
- return [
65
- "# Avorelo Current Task",
66
- "",
67
- redactText(taskContext.taskText),
68
- "",
69
- `Surface: ${taskContext.surface}`,
70
- `Task type: ${taskContext.classification.taskType}`,
71
- `Risk: ${taskContext.classification.risk}`,
72
- `Sensitivity: ${taskContext.classification.sensitivity}`,
73
- "",
74
- "Signals:",
75
- ...(taskContext.classification.signals || []).map((item) => `- ${item}`),
76
- ].join("\n").trim() + "\n";
77
- }
78
-
79
- function renderProofMarkdown(proof, options = {}) {
80
- const debug = options.debug === true || options.verbose === true;
81
- const blockedOptions = proof.blockedOptions || [];
82
- const skippedOptions = proof.skippedOptions || [];
83
-
84
- const workerSummaryLines = debug
85
- ? [
86
- "",
87
- "Blocked options:",
88
- ...(blockedOptions.length
89
- ? blockedOptions.map((item) => `- ${item.label}: ${(item.reasons || []).join(", ")}`)
90
- : ["- none"]),
91
- "",
92
- "Skipped workers/models:",
93
- ...(skippedOptions.length
94
- ? skippedOptions.map((item) => `- ${item.label}: ${(item.reasons || []).join(", ")}`)
95
- : ["- none"]),
96
- ]
97
- : [
98
- "",
99
- `Workers: ${blockedOptions.length} blocked · ${skippedOptions.length} unavailable · details: avorelo proof --debug`,
100
- ];
101
-
102
- const lines = [
103
- "# Avorelo Proof",
104
- "",
105
- `Run: ${proof.runId}`,
106
- `Status: ${proof.finalStatus}`,
107
- `Surface: ${proof.surface}`,
108
- `Task: ${proof.task}`,
109
- `Chosen route: ${proof.route.selectedRoute}`,
110
- `Inventory source: ${proof.inventorySource || "cache"}`,
111
- `Refresh level: ${proof.refreshLevel || "cache"}`,
112
- `Last full model refresh: ${proof.lastFullModelRefreshAt || "unknown"}`,
113
- `Next full model refresh after: ${proof.nextFullModelRefreshAfter || "unknown"}`,
114
- `Selected worker: ${proof.selectedWorker || "none"}`,
115
- `Selected model: ${proof.selectedModel || "none"}`,
116
- `Selected profile: ${proof.selectedProfile || "none"}`,
117
- `Premium used: ${proof.premiumUsed ? "yes" : "no"}`,
118
- `Premium avoided: ${proof.premiumAvoided ? "yes" : "no"}`,
119
- `External model involved: ${proof.externalModelInvolved ? "yes" : "no"}`,
120
- `Verification: ${proof.verification.status}`,
121
- "",
122
- "Tools used:",
123
- ...(proof.toolsUsed || []).map((item) => `- ${item.toolId}: ${item.selectedModel || item.modelProfile || "unknown"} / ${item.modelProfile || "unknown"} (${item.executionMode})`),
124
- ...workerSummaryLines,
125
- "",
126
- "Failures / fallbacks:",
127
- ...((proof.failures || []).length
128
- ? proof.failures.map((item) => `- ${item.stepId}: ${item.reason}`)
129
- : ["- none"]),
130
- ];
131
- return redactText(lines.join("\n").trim() + "\n");
132
- }
133
-
134
- function buildProof({ runId, taskContext, route, execution, verification }) {
135
- const toolsUsed = (execution.steps || [])
136
- .filter((step) => step.toolId)
137
- .map((step) => ({
138
- stepId: step.stepId,
139
- toolId: step.toolId,
140
- selectedModel: step.selectedModel || null,
141
- modelProfile: step.modelProfile || null,
142
- executionMode: step.executionMode || "unknown",
143
- status: step.status,
144
- }));
145
-
146
- return {
147
- proofVersion: 1,
148
- runId,
149
- task: taskContext.taskText,
150
- surface: taskContext.surface,
151
- finalStatus: execution.finalStatus,
152
- failureReason: execution.failureReason || null,
153
- route,
154
- inventorySource: route.inventorySource || "cache",
155
- cacheUsed: route.cacheUsed === true,
156
- lastFullModelRefreshAt: route.lastFullModelRefreshAt || null,
157
- nextFullModelRefreshAfter: route.nextFullModelRefreshAfter || null,
158
- refreshLevel: route.refreshLevel || "cache",
159
- selectedWorker: route.chosenTool || null,
160
- selectedModel: route.selectedModel || null,
161
- selectedProfile: route.chosenModelProfile || null,
162
- selectionReason: route.selectionReason || route.whyChosen || [],
163
- toolsUsed,
164
- toolsNotUsed: route.whyNotChosen || [],
165
- skippedOptions: route.blockedOptions || [],
166
- blockedOptions: route.blockedOptions || [],
167
- reasons: route.whyChosen || [],
168
- safetyDecisions: route.safetyNotes || [],
169
- premiumAvoided: route.premiumUseInvolved !== true,
170
- premiumUsed: route.premiumUseInvolved === true,
171
- externalModelInvolved: route.externalModelInvolved === true,
172
- verification,
173
- failures: execution.failures || [],
174
- diffSummary: execution.diffSummary || null,
175
- createdAt: new Date().toISOString(),
176
- };
177
- }
178
-
179
- function writeHostContracts(cwd, route, taskContext, proof = null) {
180
- ensureOrchestrationDirs(cwd);
181
- const current = getCurrentPaths(cwd);
182
- const claudePath = path.join(current.hostContractsDir, "claude-code.md");
183
- const codexPath = path.join(current.hostContractsDir, "codex-vscode.md");
184
- const common = [
185
- `Task: ${taskContext.taskText}`,
186
- `Risk: ${taskContext.classification.risk}`,
187
- `Selected worker: ${route.chosenTool || "none"} (${route.chosenModelProfile || "unknown"})`,
188
- `Verification: ${(route.expectedVerification || []).join("; ") || "none"}`,
189
- `Current route file: ${relativeFromCwd(cwd, current.currentRouteMd)}`,
190
- `Current proof file: ${relativeFromCwd(cwd, current.currentProofMd)}`,
191
- ];
192
-
193
- writeText(claudePath, [
194
- "# Claude Code Orchestration Contract",
195
- "",
196
- "Avorelo routes the task quietly and keeps the state local-first. Continue the task normally inside Claude Code and use the route/proof files as the bounded contract.",
197
- "",
198
- ...common,
199
- "",
200
- "If the route is blocked, prefer a trusted premium path before changing safety settings.",
201
- ].join("\n"));
202
-
203
- writeText(codexPath, [
204
- "# Codex / VS Code Orchestration Contract",
205
- "",
206
- "Use the Avorelo route/proof files as the local handoff contract. This path is extension-ready and avoids depending on private Codex UI internals.",
207
- "",
208
- ...common,
209
- "",
210
- "Recommended commands:",
211
- "- avorelo route \"<task>\"",
212
- "- avorelo run \"<task>\" --dry-run",
213
- "- avorelo proof",
214
- ].join("\n"));
215
-
216
- return {
217
- claudeCodeContract: relativeFromCwd(cwd, claudePath),
218
- codexVsCodeContract: relativeFromCwd(cwd, codexPath),
219
- currentProofAvailable: Boolean(proof),
220
- };
221
- }
222
-
223
- function writeCurrentArtifacts(cwd, taskContext, route, proof) {
224
- ensureOrchestrationDirs(cwd);
225
- const current = getCurrentPaths(cwd);
226
- writeText(current.currentTask, renderTaskMarkdown(taskContext));
227
- writeJson(current.currentRouteJson, sanitizeValue(route));
228
- writeText(current.currentRouteMd, renderRouteMarkdown(sanitizeValue(route)));
229
- if (proof) {
230
- writeJson(current.currentProofJson, sanitizeValue(proof));
231
- writeText(current.currentProofMd, renderProofMarkdown(sanitizeValue(proof)));
232
- }
233
- }
234
-
235
- function writeRunArtifacts(cwd, runId, taskContext, route, execution, verification, proof) {
236
- ensureOrchestrationDirs(cwd);
237
- const runPaths = getRunPaths(cwd, runId);
238
- writeJson(runPaths.task, {
239
- taskText: redactText(taskContext.taskText),
240
- surface: taskContext.surface,
241
- classification: sanitizeValue(taskContext.classification),
242
- });
243
- writeJson(runPaths.route, sanitizeValue(route));
244
- writeText(runPaths.diffSummary, redactText(execution.diffSummary || "No diff summary captured.\n"));
245
- writeJson(runPaths.verification, sanitizeValue(verification));
246
- writeJson(runPaths.proof, sanitizeValue(proof));
247
- return runPaths;
248
- }
249
-
250
- const ORCHESTRATION_RECEIPT_SCHEMA_VERSION = 1;
251
-
252
- function buildAgentModelOrchestrationReceipt({ route, proof, handoffPath = null, cwd = null }) {
253
- const paths = cwd ? getCurrentPaths(cwd) : null;
254
- const stageList = Array.isArray(route?.stageList) ? route.stageList : [];
255
- const blockedOptions = Array.isArray(route?.blockedOptions) ? route.blockedOptions : [];
256
- const limitedWorkers = Array.isArray(route?.limitedWorkers) ? route.limitedWorkers : [];
257
- const localWorkersAvailable = Array.isArray(route?.localWorkersAvailable) ? route.localWorkersAvailable : [];
258
-
259
- const selectedWorkers = stageList
260
- .filter((s) => s.chosenTool && s.chosenTool !== "avorelo_handoff")
261
- .map((s) => ({ stageId: s.id, toolId: s.chosenTool, label: s.chosenLabel || s.chosenTool, model: s.chosenModel || s.chosenModelProfile || null }));
262
-
263
- const fallbackWorkers = stageList
264
- .filter((s) => s.fallbackTool)
265
- .map((s) => ({ stageId: s.id, toolId: s.fallbackTool, model: s.fallbackModel || s.fallbackModelProfile || null }));
266
-
267
- const skippedWorkers = (route?.whyNotChosen || []).slice(0, 6).map((reason) => ({ reason }));
268
-
269
- return {
270
- schemaVersion: ORCHESTRATION_RECEIPT_SCHEMA_VERSION,
271
- contract: "avorelo.agentModelOrchestration.v1",
272
- routeId: proof?.runId || `route-${Date.now()}`,
273
- generatedAt: new Date().toISOString(),
274
- taskSummary: redactText(String(route?.taskText || proof?.task || "")).slice(0, 200),
275
- routeState: route?.state || "unknown",
276
- selectedRoute: route?.selectedRoute || null,
277
- stagePlan: stageList.map((s) => ({
278
- id: s.id,
279
- role: s.role,
280
- worker: s.chosenLabel || s.chosenTool,
281
- model: s.chosenModel || s.chosenModelProfile || null,
282
- executionMode: s.executionMode,
283
- quotaSignal: s.quotaSignal || "unknown",
284
- fallback: s.fallbackTool || null,
285
- })),
286
- stageCount: stageList.length,
287
- selectedWorkers,
288
- fallbackWorkers,
289
- skippedWorkers,
290
- blockedWorkers: blockedOptions.map((b) => ({ toolId: b.toolId, label: b.label, reasons: b.reasons })),
291
- quotaSignals: {
292
- limitedWorkers: limitedWorkers.map((w) => ({ toolId: w.toolId, label: w.label, reasonCode: w.reasonCode })),
293
- localWorkersAvailable,
294
- fallbackReasonCodes: route?.fallbackReasonCodes || [],
295
- },
296
- localWorkerUse: localWorkersAvailable.length > 0,
297
- localWorkerRecommendation: route?.localWorkerRecommendation || null,
298
- premiumUse: Boolean(route?.premiumUseInvolved),
299
- premiumAvoided: Boolean(proof?.premiumAvoided),
300
- escalationRecommendations: (route?.fallbackReasonCodes || []).includes("ESCALATION_RECOMMENDED")
301
- ? ["High-risk task detected — trusted higher-quality worker recommended for implementation/review"]
302
- : [],
303
- handoffAvailable: Boolean(route?.handoffAvailable),
304
- handoffPromptPath: handoffPath || null,
305
- expectedVerification: route?.expectedVerification || [],
306
- safetyNotes: route?.safetyNotes || [],
307
- nextAction: limitedWorkers.length
308
- ? `Use fallback worker (${route?.fallbackTool || "local"}) — primary worker is recently limited`
309
- : localWorkersAvailable.length
310
- ? `Use local worker (${localWorkersAvailable[0]}) for inspect/plan, premium worker for implementation`
311
- : `Run: avorelo route "<task>" --json for updated plan`,
312
- redacted: true,
313
- notAGateway: true,
314
- foundationOnly: true,
315
- };
316
- }
317
-
318
- function writeOrchestrationReceipt(cwd, receipt) {
319
- const current = getCurrentPaths(cwd);
320
- const receiptDir = path.join(current.root, "receipts");
321
- const latestPath = path.join(receiptDir, "current-orchestration-receipt.json");
322
- writeJson(latestPath, receipt);
323
- return relativeFromCwd(cwd, latestPath);
324
- }
325
-
326
- function readOrchestrationReceipt(cwd) {
327
- const current = getCurrentPaths(cwd);
328
- const latestPath = path.join(current.root, "receipts", "current-orchestration-receipt.json");
329
- try {
330
- return JSON.parse(require("fs").readFileSync(latestPath, "utf8"));
331
- } catch {
332
- return null;
333
- }
334
- }
335
-
336
- module.exports = {
337
- redactText,
338
- sanitizeValue,
339
- renderRouteMarkdown,
340
- renderProofMarkdown,
341
- buildProof,
342
- buildAgentModelOrchestrationReceipt,
343
- writeOrchestrationReceipt,
344
- readOrchestrationReceipt,
345
- writeCurrentArtifacts,
346
- writeRunArtifacts,
347
- writeHostContracts,
348
- ORCHESTRATION_RECEIPT_SCHEMA_VERSION,
349
- };