afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.3

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 (208) hide show
  1. package/.afyx-source-revision +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +377 -2
  4. package/SECURITY.md +74 -0
  5. package/afyx-context/LICENSE +21 -0
  6. package/afyx-context/README.md +155 -0
  7. package/afyx-context/afyx-context.json +30 -0
  8. package/afyx-context/contracts/integration-v1.schema.json +34 -0
  9. package/afyx-context/package-lock.json +53 -0
  10. package/afyx-context/package.json +34 -0
  11. package/afyx-context/scripts/benchmark.mjs +39 -0
  12. package/afyx-context/scripts/build.mjs +15 -0
  13. package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
  14. package/afyx-context/scripts/comparative-worker.mjs +74 -0
  15. package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
  16. package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
  17. package/afyx-context/src/budget.js +166 -0
  18. package/afyx-context/src/cli.js +110 -0
  19. package/afyx-context/src/coordination.js +343 -0
  20. package/afyx-context/src/engine.js +198 -0
  21. package/afyx-context/src/errors.js +14 -0
  22. package/afyx-context/src/graph-integration-worker.js +70 -0
  23. package/afyx-context/src/graph-integration.js +373 -0
  24. package/afyx-context/src/graph-mcp-bridge.js +103 -0
  25. package/afyx-context/src/index.js +25 -0
  26. package/afyx-context/src/integrations.js +87 -0
  27. package/afyx-context/src/memory.js +255 -0
  28. package/afyx-context/src/storage.js +364 -0
  29. package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
  30. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
  31. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
  32. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
  33. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
  34. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
  35. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
  36. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
  37. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
  38. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
  39. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
  40. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
  41. package/afyx-forge/LICENSE +55 -0
  42. package/afyx-forge/README.md +126 -0
  43. package/afyx-forge/afyx-forge.json +28 -0
  44. package/afyx-forge/bin/afyx-forge +4 -0
  45. package/afyx-forge/bin/afyx-forge.cmd +3 -0
  46. package/afyx-forge/bin/afyx-forge.js +16 -0
  47. package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
  48. package/afyx-forge/package.json +26 -0
  49. package/afyx-forge/src/classifier.js +190 -0
  50. package/afyx-forge/src/cli.js +111 -0
  51. package/afyx-forge/src/doctor.js +105 -0
  52. package/afyx-forge/src/guidance.js +120 -0
  53. package/afyx-forge/src/index.js +273 -0
  54. package/afyx-forge/src/planning.js +107 -0
  55. package/afyx-forge/src/policy.js +109 -0
  56. package/afyx-forge/src/workflow-refiner.js +151 -0
  57. package/afyx-graph/afyx-graph.json +20 -0
  58. package/afyx-graph/engine/LICENSE +21 -0
  59. package/afyx-graph/engine/README.md +104 -0
  60. package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
  61. package/afyx-graph/engine/release/SHA256SUMS +2 -0
  62. package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
  63. package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
  64. package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
  65. package/afyx-graph/engine/scripts/distribution-product.json +33 -0
  66. package/bin/afyx-engineering-kit.mjs +61 -0
  67. package/install.ps1 +1053 -0
  68. package/install.sh +617 -0
  69. package/package.json +66 -4
  70. package/scripts/afyx-capability-orchestrator.mjs +752 -0
  71. package/scripts/afyx-claude-integration.mjs +547 -0
  72. package/scripts/afyx-context-artifact.mjs +105 -0
  73. package/scripts/afyx-credential-broker.mjs +75 -0
  74. package/scripts/afyx-doctor.ps1 +152 -0
  75. package/scripts/afyx-doctor.sh +146 -0
  76. package/scripts/afyx-forge-artifact.mjs +183 -0
  77. package/scripts/afyx-global-routing-policy.md +12 -0
  78. package/scripts/afyx-global-routing.mjs +168 -0
  79. package/scripts/afyx-graph-artifact.mjs +178 -0
  80. package/scripts/afyx-host-adapters.mjs +543 -0
  81. package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
  82. package/scripts/afyx-host-bridge.mjs +288 -0
  83. package/scripts/afyx-integration-contracts.mjs +825 -0
  84. package/scripts/afyx-mcp-integration.mjs +528 -0
  85. package/scripts/afyx-modular-integration.mjs +361 -0
  86. package/scripts/afyx-modular-runtime.mjs +451 -0
  87. package/scripts/afyx-native-skill-host.mjs +124 -0
  88. package/scripts/afyx-npm-installer.mjs +486 -0
  89. package/scripts/afyx-project.ps1 +205 -0
  90. package/scripts/afyx-project.sh +207 -0
  91. package/scripts/afyx-provider-backup.mjs +1206 -0
  92. package/scripts/afyx-provider-integration.mjs +724 -0
  93. package/scripts/afyx-provider-inventory.mjs +147 -0
  94. package/scripts/afyx-security-auditor.mjs +224 -0
  95. package/scripts/afyx-skill-engineering.mjs +354 -0
  96. package/scripts/afyx-tool-family-routing.mjs +64 -0
  97. package/scripts/afyx-universal-runtime.mjs +530 -0
  98. package/scripts/alpha_acceptance_preflight.py +240 -0
  99. package/scripts/benchmark-graph-memory.mjs +96 -0
  100. package/scripts/benchmark_capability_orchestrator.mjs +64 -0
  101. package/scripts/build-windows-installer.ps1 +259 -0
  102. package/scripts/build_forge_synthetic_image.py +328 -0
  103. package/scripts/check-reference-staleness.py +71 -0
  104. package/scripts/components.json +254 -0
  105. package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
  106. package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
  107. package/scripts/dogfood_engineering_comparison.mjs +303 -0
  108. package/scripts/engineering-assurance.json +28 -0
  109. package/scripts/install-afyx-context.ps1 +142 -0
  110. package/scripts/install-afyx-context.sh +126 -0
  111. package/scripts/install-afyx-forge.ps1 +265 -0
  112. package/scripts/install-afyx-forge.sh +273 -0
  113. package/scripts/install-afyx-graph.ps1 +571 -0
  114. package/scripts/install-afyx-graph.sh +438 -0
  115. package/scripts/install-codex-usage-tracker.ps1 +172 -0
  116. package/scripts/lib/AfyxComponents.psm1 +399 -0
  117. package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
  118. package/scripts/lib/AfyxTerminal.psm1 +838 -0
  119. package/scripts/lib/afyx-components.sh +256 -0
  120. package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
  121. package/scripts/link-global-dev.ps1 +193 -0
  122. package/scripts/link-global-dev.sh +130 -0
  123. package/scripts/phase8-paired-evidence.mjs +195 -0
  124. package/scripts/phase8-representative-workload.mjs +771 -0
  125. package/scripts/phase8-session-recorder.mjs +157 -0
  126. package/scripts/phase8_event_ledger.py +248 -0
  127. package/scripts/phase8_evidence_discovery.py +189 -0
  128. package/scripts/prepare-g6-package.mjs +349 -0
  129. package/scripts/resolve-git-release-artifacts.mjs +321 -0
  130. package/scripts/stage-npm-release.mjs +94 -0
  131. package/scripts/validate-afyx-graph.py +203 -0
  132. package/scripts/validate-components.py +194 -0
  133. package/scripts/validate-engineering-assurance.py +281 -0
  134. package/scripts/verify-graph-archive.mjs +64 -0
  135. package/skills/afyx-context/SKILL.md +26 -0
  136. package/skills/afyx-engineering-expert/README.md +42 -0
  137. package/skills/afyx-engineering-expert/SKILL.md +70 -0
  138. package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
  139. package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
  140. package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
  141. package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
  142. package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
  143. package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
  144. package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
  145. package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
  146. package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
  147. package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
  148. package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
  149. package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
  150. package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
  151. package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
  152. package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
  153. package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
  154. package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
  155. package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
  156. package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
  157. package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
  158. package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
  159. package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
  160. package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
  161. package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
  162. package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
  163. package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
  164. package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
  165. package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
  166. package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
  167. package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
  168. package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
  169. package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
  170. package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
  171. package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
  172. package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
  173. package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
  174. package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
  175. package/skills/afyx-forge/SKILL.md +43 -0
  176. package/skills/afyx-forge/references/adaptive-policy.md +19 -0
  177. package/skills/efficient-coding/SKILL.md +33 -0
  178. package/skills/efficient-coding/references/investigation.md +27 -0
  179. package/skills/efficient-coding/references/token-efficiency.md +25 -0
  180. package/skills/efficient-coding/references/tool-routing.md +13 -0
  181. package/skills/odoo-engineering/SKILL.md +33 -0
  182. package/skills/odoo-engineering/references/common.md +9 -0
  183. package/skills/odoo-engineering/references/odoo-10.md +32 -0
  184. package/skills/odoo-engineering/references/odoo-11.md +26 -0
  185. package/skills/odoo-engineering/references/odoo-12.md +31 -0
  186. package/skills/odoo-engineering/references/odoo-13.md +27 -0
  187. package/skills/odoo-engineering/references/odoo-14.md +31 -0
  188. package/skills/odoo-engineering/references/odoo-15.md +34 -0
  189. package/skills/odoo-engineering/references/odoo-16.md +37 -0
  190. package/skills/odoo-engineering/references/odoo-17.md +37 -0
  191. package/skills/odoo-engineering/references/odoo-18.md +48 -0
  192. package/skills/odoo-engineering/references/odoo-19.md +43 -0
  193. package/skills/odoo-engineering/references/odoo-20.md +39 -0
  194. package/skills/odoo-engineering/references/reference-schema.md +16 -0
  195. package/skills/odoo-engineering/references/version-detection.md +13 -0
  196. package/tools/codex-usage/CodexUsage.psm1 +496 -0
  197. package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
  198. package/tools/codex-usage/codex-usage-pricing.json +25 -0
  199. package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
  200. package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
  201. package/tools/codex-usage/vscode-user-task.json +31 -0
  202. package/tools/windows-setup/SetupBootstrapper.cs +258 -0
  203. package/uninstall.ps1 +189 -0
  204. package/uninstall.sh +167 -0
  205. package/update.ps1 +95 -0
  206. package/update.sh +67 -0
  207. package/verify.ps1 +411 -0
  208. package/verify.sh +265 -0
@@ -0,0 +1,361 @@
1
+ /**
2
+ * Afyx Modular Integration & Capability Routing Foundation (v1)
3
+ *
4
+ * Governing Principle:
5
+ * "Standalone by Design, Integrated by Contract, Activated by Need."
6
+ *
7
+ * Every Afyx-owned component operates independently and exposes compatible
8
+ * integration contracts when multiple components are installed.
9
+ *
10
+ * Integration is available, but execution is selective:
11
+ * - Prevents duplicate domain responsibilities
12
+ * - Prevents redundant context loading
13
+ * - Prevents unnecessary tool invocation
14
+ * - Prevents unjustified token consumption
15
+ *
16
+ * Boundary Note:
17
+ * This module defines deterministic capability planning. Live runtime tool
18
+ * invocation and execution monitoring remain separate host integration boundaries.
19
+ */
20
+
21
+ export const AFYX_MODULAR_INTEGRATION_CONTRACT = 'AfyxModularIntegration/v1';
22
+
23
+ export const GOVERNING_PRINCIPLE = 'Standalone by Design, Integrated by Contract, Activated by Need.';
24
+
25
+ /**
26
+ * Explicit product maturity classifications.
27
+ */
28
+ export const PRODUCT_MATURITY_LEVELS = Object.freeze([
29
+ 'SOURCE_READY', // Code verified in source; formal acceptance pending
30
+ 'STANDALONE_ACCEPTED', // Independently accepted in standalone runtime
31
+ 'INTEGRATION_ACCEPTED', // Verified in multi-component integrated suite
32
+ 'RELEASE_READY', // Promoted for public release distribution
33
+ ]);
34
+
35
+ /**
36
+ * The 8 explicit lifecycle states of capability discovery, selection, and execution.
37
+ */
38
+ export const CAPABILITY_LIFECYCLE_STATES = Object.freeze([
39
+ 'INSTALLED', // File / binary present on host system
40
+ 'AVAILABLE', // Installed, compatible, and verified healthy
41
+ 'ELIGIBLE', // Relevant to current task intent and project scope
42
+ 'SELECTED', // Chosen by routing policy for the task execution plan
43
+ 'ACTIVATED', // Initialized and session context prepared
44
+ 'EXECUTED', // Invoked during actual task processing
45
+ 'DEGRADED', // Operating with reduced scope due to missing optional component
46
+ 'UNAVAILABLE', // Absent, unsupported, disabled, or pending gate acceptance
47
+ ]);
48
+
49
+ /**
50
+ * 10 Canonical Modular Integration Principles
51
+ */
52
+ export const INTEGRATION_PRINCIPLES = Object.freeze([
53
+ 'Every installed component remains independently usable.',
54
+ 'Compatible installed components are discoverable and available for cooperation.',
55
+ 'Installation does not imply automatic activation.',
56
+ 'Activation is based on task intent, available evidence, supported capabilities, and declared user preferences.',
57
+ 'A component owns its domain and must not duplicate another component\'s authoritative responsibility.',
58
+ 'Optional component absence must result in safe degradation rather than failure of unrelated components.',
59
+ 'Expensive context loading, indexing, tool execution, and additional validation require justified demand.',
60
+ 'Existing user-authorized behavior and manual overrides take precedence over automatic optimization.',
61
+ 'Unsupported capabilities and missing evidence must be reported explicitly.',
62
+ 'Security, correctness, and authorization requirements always take priority over efficiency.',
63
+ ]);
64
+
65
+ /**
66
+ * Canonical Afyx Product Inventory & Domain Authority Matrix
67
+ */
68
+ export const PRODUCT_INVENTORY = Object.freeze({
69
+ 'afyx-graph': Object.freeze({
70
+ id: 'afyx-graph',
71
+ canonicalName: 'Afyx Graph',
72
+ type: 'runtime',
73
+ primaryCapability: 'repository-graph-evidence',
74
+ domainAuthority: 'Authoritative supported repository structure, relationships, and impact evidence.',
75
+ cooperatingComponents: Object.freeze(['afyx-context', 'odoo-engineering', 'efficient-coding']),
76
+ ownershipClass: 'AFYX',
77
+ maturity: 'SOURCE_READY',
78
+ productionReady: false,
79
+ activationMode: 'ON_DEMAND',
80
+ }),
81
+ 'afyx-context': Object.freeze({
82
+ id: 'afyx-context',
83
+ canonicalName: 'Afyx Context Engine',
84
+ type: 'runtime',
85
+ primaryCapability: 'bounded-context-optimization',
86
+ domainAuthority: 'Bounded context optimization, exact recovery, and fallback.',
87
+ cooperatingComponents: Object.freeze(['afyx-graph', 'efficient-coding']),
88
+ ownershipClass: 'AFYX',
89
+ maturity: 'SOURCE_READY',
90
+ productionReady: false,
91
+ activationMode: 'ON_DEMAND_DEFAULT_ENABLED', // Installed and healthy; selected only for relevant tasks
92
+ }),
93
+ 'afyx-engineering-expert': Object.freeze({
94
+ id: 'afyx-engineering-expert',
95
+ canonicalName: 'Afyx Engineering Expert',
96
+ type: 'skill',
97
+ primaryCapability: 'cross-disciplinary-expertise',
98
+ domainAuthority: 'Cross-disciplinary expertise selection and workflow routing.',
99
+ cooperatingComponents: Object.freeze(['odoo-engineering', 'afyx-graph']),
100
+ ownershipClass: 'AFYX',
101
+ maturity: 'SOURCE_READY',
102
+ productionReady: false,
103
+ activationMode: 'ON_DEMAND',
104
+ }),
105
+ 'odoo-engineering': Object.freeze({
106
+ id: 'odoo-engineering',
107
+ canonicalName: 'Afyx Odoo Engineering',
108
+ type: 'skill',
109
+ primaryCapability: 'odoo-framework-authority',
110
+ domainAuthority: 'Odoo-specific technical and framework authority.',
111
+ cooperatingComponents: Object.freeze(['afyx-graph', 'afyx-engineering-expert']),
112
+ ownershipClass: 'AFYX',
113
+ maturity: 'SOURCE_READY',
114
+ productionReady: false,
115
+ activationMode: 'DOMAIN_SPECIFIC', // Only for Odoo repositories/tasks
116
+ }),
117
+ 'efficient-coding': Object.freeze({
118
+ id: 'efficient-coding',
119
+ canonicalName: 'Afyx Efficient Coding',
120
+ type: 'skill',
121
+ primaryCapability: 'focused-coding-discipline',
122
+ domainAuthority: 'Focused coding discipline and proportional implementation guidance.',
123
+ cooperatingComponents: Object.freeze(['afyx-graph', 'afyx-context']),
124
+ ownershipClass: 'AFYX',
125
+ maturity: 'SOURCE_READY',
126
+ productionReady: false,
127
+ activationMode: 'ALWAYS_AVAILABLE',
128
+ }),
129
+ 'codex-usage-tracking': Object.freeze({
130
+ id: 'codex-usage-tracking',
131
+ canonicalName: 'Afyx Codex Usage Tracking',
132
+ type: 'toolset',
133
+ primaryCapability: 'codex-usage-telemetry',
134
+ domainAuthority: 'Optional Codex-specific usage telemetry.',
135
+ cooperatingComponents: Object.freeze([]),
136
+ ownershipClass: 'AFYX',
137
+ maturity: 'STANDALONE_ACCEPTED',
138
+ productionReady: false,
139
+ activationMode: 'OPTIONAL',
140
+ }),
141
+ 'afyx-forge': Object.freeze({
142
+ id: 'afyx-forge',
143
+ canonicalName: 'Afyx Forge',
144
+ type: 'runtime',
145
+ primaryCapability: 'adaptive-engineering-policy',
146
+ domainAuthority: 'Adaptive engineering execution policy, context/tool/validation allocation.',
147
+ cooperatingComponents: Object.freeze(['efficient-coding', 'afyx-engineering-expert', 'afyx-graph', 'afyx-context']),
148
+ ownershipClass: 'AFYX',
149
+ maturity: 'SOURCE_READY',
150
+ productionReady: false,
151
+ activationMode: 'GATED_EVALUATION',
152
+ gateStatus: 'UNAVAILABLE_PENDING_A8',
153
+ }),
154
+ 'afyx-skill-engineering': Object.freeze({
155
+ id: 'afyx-skill-engineering', canonicalName: 'Afyx Skill Engineering',
156
+ type: 'toolset', primaryCapability: 'skill-authoring-lifecycle',
157
+ domainAuthority: 'Skill creation, validation, packaging and provider-scoped installation.',
158
+ cooperatingComponents: Object.freeze([]), ownershipClass: 'AFYX', maturity: 'SOURCE_READY',
159
+ productionReady: false, activationMode: 'ON_DEMAND',
160
+ providers: Object.freeze(['codex', 'antigravity', 'claude']),
161
+ }),
162
+ 'afyx-credential-broker': Object.freeze({
163
+ id: 'afyx-credential-broker', canonicalName: 'Afyx Credential Broker',
164
+ type: 'toolset', primaryCapability: 'credential-use-authorization',
165
+ domainAuthority: 'Host authorization and consent for scoped credential use.',
166
+ cooperatingComponents: Object.freeze([]), ownershipClass: 'AFYX', maturity: 'SOURCE_READY',
167
+ productionReady: false, activationMode: 'ON_DEMAND',
168
+ providers: Object.freeze(['codex', 'antigravity', 'claude']),
169
+ }),
170
+ });
171
+
172
+ /**
173
+ * Pure non-coding task types where implementation engineering discipline (efficient-coding)
174
+ * is deterministically suppressed to prevent redundant guidance. Technical configuration
175
+ * and automation tasks (such as 'devops-config', CI/CD workflows, Dockerfiles, and provisioning)
176
+ * are classified as implementation tasks and retain efficient-coding selection for quality-first
177
+ * scoped changes and validation.
178
+ */
179
+ const NON_CODING_TASK_TYPES = new Set([
180
+ 'documentation',
181
+ 'document-review',
182
+ 'general-inquiry',
183
+ 'conversation',
184
+ 'prompt-writing',
185
+ 'plain-question',
186
+ ]);
187
+
188
+ /**
189
+ * Resolves an explicit, deterministic capability integration plan for an engineering task.
190
+ *
191
+ * @param {Object} task
192
+ * @param {string} task.taskType - e.g. 'simple-fix', 'odoo-issue', 'architecture', 'large-context', 'documentation'
193
+ * @param {string} [task.intent] - descriptive intent
194
+ * @param {Object} [task.project] - project facts e.g. { isOdoo: boolean, language: string }
195
+ * @param {boolean} [task.explicitOdooEvidence] - justified explicit Odoo evidence even if repo is undetected
196
+ * @param {boolean} [task.needsRelationalEvidence] - whether relational/impact analysis is required
197
+ * @param {boolean} [task.optInContextEngine] - true forces eligible selection; false explicitly disables Context
198
+ * @param {Object} [installedComponents] - map of { [componentId]: { installed: boolean, healthy: boolean } }
199
+ * @param {Object} [userPreferences] - user overrides e.g. { forceDirectSource: boolean, disableContext: boolean }
200
+ * @returns {Object} Deterministic capability plan
201
+ */
202
+ export function resolveModularCapabilityPlan(task = {}, installedComponents = {}, userPreferences = {}) {
203
+ const plan = {
204
+ contract: AFYX_MODULAR_INTEGRATION_CONTRACT,
205
+ governingPrinciple: GOVERNING_PRINCIPLE,
206
+ taskType: task.taskType || 'generic',
207
+ selectedComponents: [],
208
+ componentStates: {},
209
+ suppressedRedundancies: [],
210
+ degradations: [],
211
+ reasons: {},
212
+ };
213
+
214
+ const isOdooDetected = Boolean(task.project?.isOdoo);
215
+ const isExplicitOdooTask = Boolean(
216
+ task.explicitOdooEvidence ||
217
+ task.taskType?.startsWith('odoo-') ||
218
+ (typeof task.intent === 'string' && /\bodoo\b/i.test(task.intent))
219
+ );
220
+ const isOdooRelevant = isOdooDetected || isExplicitOdooTask;
221
+
222
+ const isNonCoding = NON_CODING_TASK_TYPES.has(task.taskType);
223
+ const needsRelational = Boolean(task.needsRelationalEvidence);
224
+ const contextEnabled = task.optInContextEngine !== false && !userPreferences.disableContext;
225
+ const contextNeeded = task.optInContextEngine === true || task.taskType === 'large-context' || task.needsContextOptimization === true;
226
+ const forceDirectSource = Boolean(userPreferences.forceDirectSource);
227
+
228
+ for (const [id, meta] of Object.entries(PRODUCT_INVENTORY)) {
229
+ const installInfo = installedComponents[id] || { installed: false, healthy: false };
230
+ const isInstalled = Boolean(installInfo.installed);
231
+ const isHealthy = Boolean(installInfo.healthy);
232
+
233
+ // 1. Forge is strictly blocked pending formal A8 gate
234
+ if (id === 'afyx-forge') {
235
+ plan.componentStates[id] = 'UNAVAILABLE';
236
+ plan.reasons[id] = 'Production activation unavailable pending formal A8 acceptance.';
237
+ continue;
238
+ }
239
+
240
+ // 2. Base installation check
241
+ if (!isInstalled) {
242
+ plan.componentStates[id] = 'UNAVAILABLE';
243
+ plan.reasons[id] = 'Not installed on host.';
244
+ continue;
245
+ }
246
+
247
+ // 3. Health check: installed but unhealthy degrades
248
+ if (!isHealthy) {
249
+ plan.componentStates[id] = 'DEGRADED';
250
+ plan.reasons[id] = 'Installed but reported unhealthy; safe degradation to direct source.';
251
+ plan.degradations.push({ component: id, fallback: 'DIRECT_SOURCE', reason: 'COMPONENT_UNHEALTHY' });
252
+ continue;
253
+ }
254
+
255
+ // 4. Component is physically INSTALLED and AVAILABLE on host.
256
+ // If not selected, it remains AVAILABLE (never marked UNAVAILABLE when merely irrelevant).
257
+ plan.componentStates[id] = 'AVAILABLE';
258
+
259
+ // 5. Domain eligibility and selection
260
+ switch (id) {
261
+ case 'efficient-coding':
262
+ if (isNonCoding) {
263
+ plan.reasons[id] = 'Task is non-coding; implementation discipline suppressed to avoid redundant guidance.';
264
+ plan.suppressedRedundancies.push({ component: id, reason: 'NON_CODING_TASK' });
265
+ } else {
266
+ plan.componentStates[id] = 'SELECTED';
267
+ plan.selectedComponents.push(id);
268
+ plan.reasons[id] = 'Primary authority for proportional implementation and quality-first discipline.';
269
+ }
270
+ break;
271
+
272
+ case 'odoo-engineering':
273
+ if (isOdooRelevant) {
274
+ plan.componentStates[id] = 'SELECTED';
275
+ plan.selectedComponents.push(id);
276
+ plan.reasons[id] = 'Primary domain authority for Odoo models, ORM, views, and version release rules.';
277
+ } else {
278
+ plan.reasons[id] = 'Repository/task is non-Odoo; Odoo Engineering remains available but unselected.';
279
+ plan.suppressedRedundancies.push({ component: id, reason: 'NON_ODOO_WORKSPACE' });
280
+ }
281
+ break;
282
+
283
+ case 'afyx-engineering-expert':
284
+ if (task.taskType === 'architecture' || task.taskType === 'multi-disciplinary' || task.taskType === 'system-design') {
285
+ plan.componentStates[id] = 'SELECTED';
286
+ plan.selectedComponents.push(id);
287
+ plan.reasons[id] = 'Primary authority for multi-disciplinary architecture and workflow orchestration.';
288
+ } else if (task.taskType === 'simple-fix') {
289
+ plan.reasons[id] = 'Simple fix task; expert orchestration suppressed to prevent token waste and deep persona overhead.';
290
+ plan.suppressedRedundancies.push({ component: id, reason: 'SIMPLE_FIX_DISCIPLINE' });
291
+ } else {
292
+ plan.reasons[id] = 'Available on host; activated on demand for ambiguous or system-level tasks.';
293
+ }
294
+ break;
295
+
296
+ case 'afyx-graph':
297
+ if (forceDirectSource) {
298
+ plan.reasons[id] = 'User explicitly requested direct source; Graph invocation bypassed.';
299
+ } else if (needsRelational || task.taskType === 'impact-analysis' || task.taskType === 'cross-asset') {
300
+ plan.componentStates[id] = 'SELECTED';
301
+ plan.selectedComponents.push(id);
302
+ plan.reasons[id] = 'Authoritative provider of relational repository evidence and cross-asset dependencies.';
303
+ } else {
304
+ plan.reasons[id] = 'Direct source sufficient for task; Graph index invocation suppressed to save resources.';
305
+ plan.suppressedRedundancies.push({ component: id, reason: 'EXACT_SOURCE_SUFFICIENT' });
306
+ }
307
+ break;
308
+
309
+ case 'afyx-context':
310
+ if (contextEnabled && contextNeeded) {
311
+ plan.componentStates[id] = 'SELECTED';
312
+ plan.selectedComponents.push(id);
313
+ plan.reasons[id] = 'Installed Context Engine is enabled and the task warrants bounded optimization.';
314
+ } else if (!contextEnabled) {
315
+ plan.reasons[id] = 'Context Engine explicitly disabled by task or user preference.';
316
+ plan.suppressedRedundancies.push({ component: id, reason: 'USER_CONTEXT_DISABLED' });
317
+ } else {
318
+ plan.reasons[id] = 'Context Engine available by default; no optimization needed for this task.';
319
+ plan.suppressedRedundancies.push({ component: id, reason: 'CONTEXT_NOT_NEEDED' });
320
+ }
321
+ break;
322
+
323
+ case 'codex-usage-tracking':
324
+ plan.reasons[id] = 'Passive telemetry utility; available without task-level intervention.';
325
+ break;
326
+
327
+ default:
328
+ break;
329
+ }
330
+ }
331
+
332
+ // 6. Handle safe degradation for Graph when relational evidence is required but Graph is not selected
333
+ if (needsRelational || task.taskType === 'impact-analysis') {
334
+ if (forceDirectSource) {
335
+ plan.degradations.push({
336
+ component: 'afyx-graph',
337
+ fallback: 'DIRECT_SOURCE',
338
+ reason: 'BYPASSED_BY_USER',
339
+ });
340
+ } else if (!plan.selectedComponents.includes('afyx-graph')) {
341
+ const graphInfo = installedComponents['afyx-graph'] || { installed: false, healthy: false };
342
+ const reasonCode = !graphInfo.installed ? 'COMPONENT_ABSENT' : (!graphInfo.healthy ? 'COMPONENT_UNHEALTHY' : 'UNSUPPORTED_CAPABILITY');
343
+ plan.degradations.push({
344
+ component: 'afyx-graph',
345
+ fallback: 'DIRECT_SOURCE',
346
+ reason: reasonCode,
347
+ });
348
+ }
349
+ }
350
+
351
+ return Object.freeze(plan);
352
+ }
353
+
354
+ export {
355
+ AFYX_MODULAR_RUNTIME_CONTRACT,
356
+ ACCEPTED_PROVIDERS,
357
+ DOMAIN_AUTHORITY_MATRIX,
358
+ PROVIDER_CAPABILITY_SUPPORT,
359
+ resolveModularRuntimeActivation,
360
+ } from './afyx-modular-runtime.mjs';
361
+