@nerviq/cli 1.20.0 → 1.21.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 (185) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +2 -2
  3. package/bin/cli.js +1 -0
  4. package/package.json +2 -1
  5. package/src/activity.js +1039 -1039
  6. package/src/adoption-advisor.js +299 -299
  7. package/src/aider/config-parser.js +166 -166
  8. package/src/aider/context.js +6 -2
  9. package/src/aider/deep-review.js +316 -316
  10. package/src/aider/domain-packs.js +303 -303
  11. package/src/aider/freshness.js +93 -93
  12. package/src/aider/governance.js +253 -253
  13. package/src/aider/interactive.js +334 -334
  14. package/src/aider/mcp-packs.js +329 -329
  15. package/src/aider/patch.js +214 -214
  16. package/src/aider/plans.js +186 -186
  17. package/src/aider/premium.js +360 -360
  18. package/src/aider/setup.js +404 -404
  19. package/src/aider/techniques.js +312 -67
  20. package/src/analyze.js +951 -951
  21. package/src/anti-patterns.js +485 -485
  22. package/src/audit/instruction-files.js +180 -180
  23. package/src/audit/recommendations.js +577 -577
  24. package/src/auto-suggest.js +154 -154
  25. package/src/badge.js +13 -13
  26. package/src/behavioral-drift.js +801 -801
  27. package/src/benchmark.js +67 -67
  28. package/src/catalog.js +103 -103
  29. package/src/certification.js +128 -128
  30. package/src/codex/config-parser.js +183 -183
  31. package/src/codex/context.js +223 -223
  32. package/src/codex/deep-review.js +493 -493
  33. package/src/codex/domain-packs.js +394 -394
  34. package/src/codex/freshness.js +84 -84
  35. package/src/codex/governance.js +192 -192
  36. package/src/codex/interactive.js +618 -618
  37. package/src/codex/mcp-packs.js +914 -914
  38. package/src/codex/patch.js +209 -209
  39. package/src/codex/plans.js +251 -251
  40. package/src/codex/premium.js +614 -614
  41. package/src/codex/setup.js +591 -591
  42. package/src/context.js +10 -4
  43. package/src/continuous-ops.js +681 -681
  44. package/src/copilot/activity.js +309 -309
  45. package/src/copilot/deep-review.js +346 -346
  46. package/src/copilot/domain-packs.js +372 -372
  47. package/src/copilot/freshness.js +57 -57
  48. package/src/copilot/governance.js +222 -222
  49. package/src/copilot/interactive.js +406 -406
  50. package/src/copilot/mcp-packs.js +826 -826
  51. package/src/copilot/plans.js +253 -253
  52. package/src/copilot/premium.js +451 -451
  53. package/src/copilot/setup.js +488 -488
  54. package/src/cost-tracking.js +61 -61
  55. package/src/cursor/activity.js +301 -301
  56. package/src/cursor/config-parser.js +265 -265
  57. package/src/cursor/context.js +256 -256
  58. package/src/cursor/deep-review.js +334 -334
  59. package/src/cursor/domain-packs.js +368 -368
  60. package/src/cursor/freshness.js +65 -65
  61. package/src/cursor/governance.js +229 -229
  62. package/src/cursor/interactive.js +391 -391
  63. package/src/cursor/mcp-packs.js +828 -828
  64. package/src/cursor/plans.js +254 -254
  65. package/src/cursor/premium.js +469 -469
  66. package/src/cursor/setup.js +488 -488
  67. package/src/dashboard.js +493 -493
  68. package/src/deep-review.js +428 -428
  69. package/src/deprecation.js +98 -98
  70. package/src/diff-only.js +280 -280
  71. package/src/doctor.js +119 -119
  72. package/src/domain-pack-expansion.js +1033 -1033
  73. package/src/domain-packs.js +387 -387
  74. package/src/feedback.js +178 -178
  75. package/src/fix-engine.js +783 -783
  76. package/src/fix-prompts.js +122 -122
  77. package/src/formatters/sarif.js +115 -115
  78. package/src/freshness.js +74 -74
  79. package/src/gemini/config-parser.js +275 -275
  80. package/src/gemini/deep-review.js +559 -559
  81. package/src/gemini/domain-packs.js +393 -393
  82. package/src/gemini/freshness.js +66 -66
  83. package/src/gemini/governance.js +201 -201
  84. package/src/gemini/interactive.js +860 -860
  85. package/src/gemini/mcp-packs.js +915 -915
  86. package/src/gemini/plans.js +269 -269
  87. package/src/gemini/premium.js +760 -760
  88. package/src/gemini/setup.js +692 -692
  89. package/src/governance.js +72 -72
  90. package/src/harmony/add.js +68 -68
  91. package/src/harmony/advisor.js +333 -333
  92. package/src/harmony/canon.js +565 -565
  93. package/src/harmony/cli.js +591 -591
  94. package/src/harmony/drift.js +401 -401
  95. package/src/harmony/governance.js +313 -313
  96. package/src/harmony/memory.js +239 -239
  97. package/src/harmony/sync.js +475 -475
  98. package/src/harmony/watch.js +370 -370
  99. package/src/hook-validation.js +342 -342
  100. package/src/index.js +271 -271
  101. package/src/init.js +184 -184
  102. package/src/instruction-surfaces.js +185 -185
  103. package/src/integrations.js +144 -144
  104. package/src/interactive.js +118 -118
  105. package/src/locales/en.json +1 -1
  106. package/src/locales/es.json +1 -1
  107. package/src/mcp-packs.js +830 -830
  108. package/src/mcp-server.js +726 -726
  109. package/src/mcp-validation.js +337 -337
  110. package/src/nerviq-sync.json +7 -7
  111. package/src/opencode/config-parser.js +109 -109
  112. package/src/opencode/context.js +247 -247
  113. package/src/opencode/deep-review.js +313 -313
  114. package/src/opencode/domain-packs.js +262 -262
  115. package/src/opencode/freshness.js +66 -66
  116. package/src/opencode/governance.js +159 -159
  117. package/src/opencode/interactive.js +392 -392
  118. package/src/opencode/mcp-packs.js +705 -705
  119. package/src/opencode/patch.js +184 -184
  120. package/src/opencode/plans.js +231 -231
  121. package/src/opencode/premium.js +413 -413
  122. package/src/opencode/setup.js +449 -449
  123. package/src/opencode/techniques.js +27 -27
  124. package/src/operating-profile.js +574 -574
  125. package/src/org.js +152 -152
  126. package/src/permission-rules.js +218 -218
  127. package/src/plans.js +839 -839
  128. package/src/platform-change-manifest.js +86 -86
  129. package/src/plugins.js +110 -110
  130. package/src/policy-layers.js +210 -210
  131. package/src/profiles.js +124 -124
  132. package/src/prompt-injection.js +74 -74
  133. package/src/public-api.js +173 -173
  134. package/src/recommendation-rules.js +84 -84
  135. package/src/repo-archetype.js +386 -386
  136. package/src/secret-patterns.js +39 -39
  137. package/src/server.js +527 -527
  138. package/src/setup/analysis.js +607 -607
  139. package/src/setup/runtime.js +172 -172
  140. package/src/setup.js +677 -677
  141. package/src/shared/capabilities.js +194 -194
  142. package/src/source-urls.js +132 -132
  143. package/src/stack-checks.js +565 -565
  144. package/src/supplemental-checks.js +13 -13
  145. package/src/synergy/adaptive.js +261 -261
  146. package/src/synergy/compensation.js +137 -137
  147. package/src/synergy/evidence.js +193 -193
  148. package/src/synergy/learning.js +199 -199
  149. package/src/synergy/patterns.js +227 -227
  150. package/src/synergy/ranking.js +83 -83
  151. package/src/synergy/report.js +165 -165
  152. package/src/synergy/routing.js +146 -146
  153. package/src/techniques/api.js +407 -407
  154. package/src/techniques/automation.js +316 -316
  155. package/src/techniques/compliance.js +257 -257
  156. package/src/techniques/hygiene.js +294 -294
  157. package/src/techniques/instructions.js +243 -243
  158. package/src/techniques/observability.js +226 -226
  159. package/src/techniques/optimization.js +142 -142
  160. package/src/techniques/quality.js +318 -318
  161. package/src/techniques/security.js +237 -237
  162. package/src/techniques/shared.js +443 -443
  163. package/src/techniques/stacks.js +2294 -2294
  164. package/src/techniques/tools.js +106 -106
  165. package/src/techniques/workflow.js +413 -413
  166. package/src/techniques.js +81 -81
  167. package/src/terminology.js +73 -73
  168. package/src/token-estimate.js +35 -35
  169. package/src/usage-patterns.js +99 -99
  170. package/src/verification-metadata.js +145 -145
  171. package/src/watch.js +247 -247
  172. package/src/windsurf/activity.js +302 -302
  173. package/src/windsurf/config-parser.js +267 -267
  174. package/src/windsurf/context.js +120 -10
  175. package/src/windsurf/deep-review.js +337 -337
  176. package/src/windsurf/domain-packs.js +370 -370
  177. package/src/windsurf/freshness.js +36 -36
  178. package/src/windsurf/governance.js +231 -231
  179. package/src/windsurf/interactive.js +388 -388
  180. package/src/windsurf/mcp-packs.js +792 -792
  181. package/src/windsurf/plans.js +247 -247
  182. package/src/windsurf/premium.js +468 -468
  183. package/src/windsurf/setup.js +471 -471
  184. package/src/windsurf/techniques.js +155 -33
  185. package/src/workspace.js +375 -375
@@ -1,394 +1,394 @@
1
- const { buildAdditionalDomainPacks, detectAdditionalDomainPacks } = require('../domain-pack-expansion');
2
-
3
- const BASE_CODEX_DOMAIN_PACKS = [
4
- {
5
- key: 'baseline-general',
6
- label: 'Baseline General',
7
- useWhen: 'General Codex repos that need a safe, reviewable baseline before deeper specialization.',
8
- adoption: 'Safe default when no stronger domain signal dominates the repo.',
9
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Review workflow starter'],
10
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
11
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
12
- benchmarkFocus: ['starter-safe improvement', 'reviewable trust posture'],
13
- },
14
- {
15
- key: 'backend-api',
16
- label: 'Backend API',
17
- useWhen: 'Service, API, or backend-heavy repos with routes, services, jobs, schemas, or data access.',
18
- adoption: 'Recommended when Codex needs stronger verification and review structure around backend changes.',
19
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Backend verification guide', 'CI / review workflow starter'],
20
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
21
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
22
- benchmarkFocus: ['test + build verification', 'reviewable API changes', 'safe rollout posture'],
23
- },
24
- {
25
- key: 'frontend-ui',
26
- label: 'Frontend UI',
27
- useWhen: 'React, Next.js, Vue, Angular, or Svelte repos with UI-heavy workflows and component work.',
28
- adoption: 'Recommended when Codex needs better component, build, and review guidance.',
29
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Frontend review workflow', 'CI / review workflow starter'],
30
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
31
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
32
- benchmarkFocus: ['build verification', 'component-safe edits', 'reviewable UI changes'],
33
- },
34
- {
35
- key: 'enterprise-governed',
36
- label: 'Enterprise Governed',
37
- useWhen: 'Repos with CI, policy files, security posture, or auditable team workflows that need stronger Codex governance.',
38
- adoption: 'Recommended for teams that need explicit approvals, review expectations, and durable rollout evidence.',
39
- recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Review workflow starter', 'Governance rollout kit'],
40
- recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
41
- recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
42
- benchmarkFocus: ['policy-aware rollout', 'approval posture', 'repeatable governance evidence'],
43
- },
44
- {
45
- key: 'monorepo',
46
- label: 'Monorepo',
47
- useWhen: 'Workspace-based repos with multiple packages sharing a root and a need for scoped Codex behavior.',
48
- adoption: 'Recommended when path-aware rules and workspace review boundaries matter.',
49
- recommendedModules: ['AGENTS.md baseline', 'Codex rules baseline', 'Workspace-aware rules', 'Review workflow starter'],
50
- recommendedProposalFamilies: ['codex-agents-md', 'codex-rules', 'codex-ci-review'],
51
- recommendedSurfaces: ['AGENTS.md', 'codex/rules/', '.github/workflows/'],
52
- benchmarkFocus: ['workspace-safe edits', 'package-scoped review', 'cross-package drift control'],
53
- },
54
- {
55
- key: 'infra-platform',
56
- label: 'Infra Platform',
57
- useWhen: 'Terraform, Docker, Kubernetes, serverless, or deployment-oriented repos with operational blast radius.',
58
- adoption: 'Recommended when Codex changes need stronger guardrails, review gates, and infra-aware verification.',
59
- recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Infra review workflow', 'CI / review workflow starter'],
60
- recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
61
- recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
62
- benchmarkFocus: ['release safety', 'infra verification', 'reviewable operational changes'],
63
- },
64
- // --- Parity expansion: 10 new packs to match Claude's 16 ---
65
- {
66
- key: 'data-pipeline',
67
- label: 'Data Pipeline',
68
- useWhen: 'Repos with workers, DAGs, ETL jobs, migrations, or analytics-heavy workflows.',
69
- adoption: 'Recommended when Codex needs pipeline-safe verification and state-aware review.',
70
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Pipeline verification guide'],
71
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
72
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
73
- benchmarkFocus: ['pipeline safety', 'repeatable task flows', 'state-aware review'],
74
- },
75
- {
76
- key: 'oss-library',
77
- label: 'OSS Library',
78
- useWhen: 'Public packages or contributor-heavy repos that need lighter governance.',
79
- adoption: 'Recommended for open-source repos where Codex should suggest, not auto-apply.',
80
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline'],
81
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
82
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
83
- benchmarkFocus: ['low-footprint adoption', 'contributor-safe defaults', 'manual review friendliness'],
84
- },
85
- {
86
- key: 'mobile',
87
- label: 'Mobile',
88
- useWhen: 'React Native, Flutter, Swift, or Kotlin repos with mobile-specific build and test workflows.',
89
- adoption: 'Recommended when Codex needs mobile build awareness and platform-specific verification.',
90
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Mobile verification guide'],
91
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
92
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
93
- benchmarkFocus: ['mobile build safety', 'platform-specific verification', 'reviewable native changes'],
94
- },
95
- {
96
- key: 'regulated-lite',
97
- label: 'Regulated Lite',
98
- useWhen: 'Repos with basic compliance needs — activity artifacts, rollback manifests, and audit trail.',
99
- adoption: 'Recommended for regulated-adjacent repos that need governance without full enterprise overhead.',
100
- recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Governance rollout kit'],
101
- recommendedProposalFamilies: ['codex-config', 'codex-rules'],
102
- recommendedSurfaces: ['.codex/config.toml', 'codex/rules/'],
103
- benchmarkFocus: ['compliance posture', 'activity artifact coverage', 'rollback readiness'],
104
- },
105
- {
106
- key: 'ecommerce',
107
- label: 'E-commerce',
108
- useWhen: 'Shopify, Stripe, or payment-heavy repos with transaction safety needs.',
109
- adoption: 'Recommended when Codex changes touch payment flows, cart logic, or sensitive data.',
110
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Security review workflow'],
111
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
112
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
113
- benchmarkFocus: ['transaction safety', 'payment flow review', 'PII-safe changes'],
114
- },
115
- {
116
- key: 'ai-ml',
117
- label: 'AI / ML',
118
- useWhen: 'Repos with ML pipelines, model training, RAG, or LLM integration workflows.',
119
- adoption: 'Recommended when Codex needs model-aware verification and experiment tracking.',
120
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'ML verification guide'],
121
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
122
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
123
- benchmarkFocus: ['model safety', 'experiment reproducibility', 'data pipeline review'],
124
- },
125
- {
126
- key: 'devops-cicd',
127
- label: 'DevOps / CI-CD',
128
- useWhen: 'Repos focused on CI/CD pipelines, deployment automation, and infrastructure-as-code.',
129
- adoption: 'Recommended when Codex manages CI workflows, deployment scripts, or release processes.',
130
- recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'CI / review workflow starter'],
131
- recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
132
- recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
133
- benchmarkFocus: ['deployment safety', 'CI pipeline review', 'release gate coverage'],
134
- },
135
- {
136
- key: 'design-system',
137
- label: 'Design System',
138
- useWhen: 'Component libraries, Storybook repos, or design token systems.',
139
- adoption: 'Recommended when Codex edits shared UI components with downstream consumers.',
140
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Component review workflow'],
141
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
142
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
143
- benchmarkFocus: ['component safety', 'visual regression awareness', 'cross-consumer impact'],
144
- },
145
- {
146
- key: 'docs-content',
147
- label: 'Docs / Content',
148
- useWhen: 'Documentation repos, blogs, or content-heavy sites with editorial workflows.',
149
- adoption: 'Recommended when Codex edits prose, docs, or content with editorial review needs.',
150
- recommendedModules: ['AGENTS.md baseline', 'Codex config baseline'],
151
- recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
152
- recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
153
- benchmarkFocus: ['content quality', 'editorial review', 'link and reference integrity'],
154
- },
155
- {
156
- key: 'security-focused',
157
- label: 'Security Focused',
158
- useWhen: 'Repos with strong security posture needs — secret management, auth, encryption.',
159
- adoption: 'Recommended for security-critical repos where every Codex change needs security review.',
160
- recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Security review workflow'],
161
- recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
162
- recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
163
- benchmarkFocus: ['secret protection', 'auth flow safety', 'security review coverage'],
164
- },
165
- ];
166
-
167
- const CODEX_DOMAIN_PACKS = [
168
- ...BASE_CODEX_DOMAIN_PACKS,
169
- ...buildAdditionalDomainPacks('codex', {
170
- existingKeys: new Set(BASE_CODEX_DOMAIN_PACKS.map((pack) => pack.key)),
171
- }),
172
- ];
173
-
174
- function uniqueByKey(items) {
175
- const seen = new Set();
176
- const result = [];
177
- for (const item of items) {
178
- if (seen.has(item.key)) continue;
179
- seen.add(item.key);
180
- result.push(item);
181
- }
182
- return result;
183
- }
184
-
185
- function detectCodexDomainPacks(ctx, stacks = [], assets = {}) {
186
- const stackKeys = new Set((stacks || []).map((stack) => stack.key));
187
- const pkg = ctx.jsonFile ? (ctx.jsonFile('package.json') || {}) : {};
188
- const deps = ctx.projectDependencies ? ctx.projectDependencies() : {
189
- ...(pkg.dependencies || {}),
190
- ...(pkg.devDependencies || {}),
191
- };
192
- const matches = [];
193
-
194
- function addMatch(key, reasons) {
195
- const pack = CODEX_DOMAIN_PACKS.find((item) => item.key === key);
196
- if (!pack) return;
197
- matches.push({
198
- ...pack,
199
- matchReasons: reasons.filter(Boolean).slice(0, 3),
200
- });
201
- }
202
-
203
- const hasFrontend = stackKeys.has('react') || stackKeys.has('nextjs') || stackKeys.has('vue') ||
204
- stackKeys.has('angular') || stackKeys.has('svelte') ||
205
- ctx.hasDir('components') || ctx.hasDir('pages') ||
206
- (ctx.hasDir('app') && (deps.next || deps.react || deps.vue || deps['@angular/core'] || deps.svelte));
207
-
208
- const hasBackend = stackKeys.has('python') || stackKeys.has('django') || stackKeys.has('fastapi') ||
209
- stackKeys.has('go') || stackKeys.has('rust') || stackKeys.has('java') ||
210
- ctx.hasDir('api') || ctx.hasDir('routes') || ctx.hasDir('services') || ctx.hasDir('controllers') ||
211
- ctx.hasDir('workers') || ctx.hasDir('jobs');
212
-
213
- const hasInfra = stackKeys.has('docker') || stackKeys.has('terraform') || stackKeys.has('kubernetes') ||
214
- ctx.files.includes('wrangler.toml') || ctx.files.includes('serverless.yml') || ctx.files.includes('serverless.yaml') ||
215
- ctx.files.includes('cdk.json') || ctx.hasDir('infra') || ctx.hasDir('deploy') || ctx.hasDir('helm');
216
-
217
- const isMonorepo = ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
218
- ctx.files.includes('lerna.json') || ctx.files.includes('pnpm-workspace.yaml') ||
219
- ctx.hasDir('packages') ||
220
- (pkg.workspaces && (Array.isArray(pkg.workspaces) ? pkg.workspaces.length > 0 : true));
221
-
222
- const hasCi = (typeof ctx.workflowFiles === 'function' ? ctx.workflowFiles().length : 0) > 0 ||
223
- ctx.hasDir('.github/workflows');
224
- const hasPolicyFiles = Boolean(ctx.fileContent('SECURITY.md') || ctx.fileContent('CODEOWNERS')) ||
225
- ctx.hasDir('compliance') || ctx.hasDir('policies') || ctx.hasDir('audit');
226
- const explicitTrust = Boolean(assets.trust && assets.trust.approvalPolicy && assets.trust.sandboxMode);
227
- const ruleCoverage = Number(assets.counts && assets.counts.rules) > 0;
228
- const workflowCoverage = Number(assets.counts && assets.counts.workflows) > 0;
229
- const isEnterpriseGoverned = (hasCi && explicitTrust) || hasPolicyFiles || (ruleCoverage && workflowCoverage);
230
-
231
- if (hasBackend) {
232
- addMatch('backend-api', [
233
- 'Detected backend stack or service-oriented directories for Codex to navigate.',
234
- ctx.hasDir('api') ? 'API-facing structure detected.' : null,
235
- ctx.hasDir('services') ? 'Service-layer directories detected.' : null,
236
- ]);
237
- }
238
-
239
- if (hasFrontend) {
240
- addMatch('frontend-ui', [
241
- 'Detected UI-heavy frontend stack or component directories.',
242
- stackKeys.has('nextjs') ? 'Next.js stack detected.' : null,
243
- ctx.hasDir('components') ? 'Component directories detected.' : null,
244
- ]);
245
- }
246
-
247
- if (isEnterpriseGoverned) {
248
- addMatch('enterprise-governed', [
249
- 'Detected team-governed rollout signals such as CI, policies, or explicit Codex trust posture.',
250
- hasCi ? 'GitHub workflow automation detected.' : null,
251
- hasPolicyFiles ? 'Security/compliance policy files detected.' : null,
252
- ]);
253
- }
254
-
255
- if (isMonorepo) {
256
- addMatch('monorepo', [
257
- 'Detected workspace or multi-package repository structure.',
258
- ctx.files.includes('pnpm-workspace.yaml') ? 'pnpm workspace detected.' : null,
259
- ctx.hasDir('packages') ? 'Packages directory detected.' : null,
260
- ]);
261
- }
262
-
263
- if (hasInfra) {
264
- addMatch('infra-platform', [
265
- 'Detected infrastructure or deployment-oriented repo signals.',
266
- ctx.files.includes('wrangler.toml') ? 'Wrangler config detected.' : null,
267
- ctx.hasDir('infra') ? 'Infrastructure directory detected.' : null,
268
- ]);
269
- }
270
-
271
- // --- Parity expansion: detect 10 new domain packs ---
272
-
273
- const hasDataPipeline = ctx.hasDir('dags') || ctx.hasDir('etl') || ctx.hasDir('pipelines') ||
274
- ctx.hasDir('marts') || ctx.hasDir('migrations') ||
275
- deps.airflow || deps.prefect || deps.dagster || deps.dbt;
276
- if (hasDataPipeline) {
277
- addMatch('data-pipeline', [
278
- 'Detected data pipeline or ETL-oriented repo signals.',
279
- ctx.hasDir('dags') ? 'DAG directory detected.' : null,
280
- ]);
281
- }
282
-
283
- const isOss = ctx.files.includes('LICENSE') && ctx.files.includes('CONTRIBUTING.md');
284
- if (isOss && !isEnterpriseGoverned) {
285
- addMatch('oss-library', [
286
- 'Detected open-source library signals (LICENSE + CONTRIBUTING.md).',
287
- ]);
288
- }
289
-
290
- const isMobile = stackKeys.has('react-native') || stackKeys.has('flutter') ||
291
- stackKeys.has('swift') || stackKeys.has('kotlin') ||
292
- deps['react-native'] || deps.flutter || ctx.files.includes('Podfile') ||
293
- ctx.files.includes('build.gradle') || ctx.hasDir('ios') || ctx.hasDir('android');
294
- if (isMobile) {
295
- addMatch('mobile', [
296
- 'Detected mobile development signals.',
297
- ctx.hasDir('ios') ? 'iOS directory detected.' : null,
298
- ctx.hasDir('android') ? 'Android directory detected.' : null,
299
- ]);
300
- }
301
-
302
- const isRegulated = hasPolicyFiles && !isEnterpriseGoverned;
303
- if (isRegulated) {
304
- addMatch('regulated-lite', [
305
- 'Detected compliance-adjacent signals without full enterprise governance.',
306
- ]);
307
- }
308
-
309
- const isEcommerce = deps.stripe || deps['@stripe/stripe-js'] ||
310
- deps.shopify || deps['@shopify/shopify-api'] ||
311
- ctx.hasDir('checkout') || ctx.hasDir('cart') || ctx.hasDir('payments');
312
- if (isEcommerce) {
313
- addMatch('ecommerce', [
314
- 'Detected e-commerce or payment-related signals.',
315
- deps.stripe ? 'Stripe dependency detected.' : null,
316
- ]);
317
- }
318
-
319
- const isAiMl = deps.tensorflow || deps.torch || deps.pytorch || deps.transformers ||
320
- deps.langchain || deps['@langchain/core'] || deps.openai || deps.anthropic ||
321
- ctx.hasDir('models') || ctx.hasDir('training') || ctx.hasDir('rag') ||
322
- ctx.files.includes('model.py') || ctx.files.includes('train.py');
323
- if (isAiMl) {
324
- addMatch('ai-ml', [
325
- 'Detected AI/ML or model training signals.',
326
- ctx.hasDir('models') ? 'Models directory detected.' : null,
327
- ]);
328
- }
329
-
330
- const isDevops = hasCi && hasInfra && !isEnterpriseGoverned;
331
- if (isDevops) {
332
- addMatch('devops-cicd', [
333
- 'Detected DevOps/CI-CD focus with both CI workflows and infrastructure.',
334
- ]);
335
- }
336
-
337
- const isDesignSystem = ctx.hasDir('stories') || ctx.hasDir('storybook') ||
338
- deps['@storybook/react'] || deps['@storybook/vue3'] ||
339
- ctx.files.includes('.storybook');
340
- if (isDesignSystem) {
341
- addMatch('design-system', [
342
- 'Detected design system or component library signals.',
343
- ctx.hasDir('stories') ? 'Storybook stories detected.' : null,
344
- ]);
345
- }
346
-
347
- const isDocsContent = ctx.hasDir('docs') && !hasBackend && !hasFrontend &&
348
- (ctx.files.includes('mkdocs.yml') || ctx.files.includes('docusaurus.config.js') ||
349
- ctx.files.includes('_config.yml') || ctx.files.includes('hugo.toml'));
350
- if (isDocsContent) {
351
- addMatch('docs-content', [
352
- 'Detected documentation or content-focused repo.',
353
- ]);
354
- }
355
-
356
- const isSecurityFocused = ctx.hasDir('security') ||
357
- deps['helmet'] || deps['csurf'] || deps['bcrypt'] ||
358
- (hasPolicyFiles && ctx.fileContent('SECURITY.md'));
359
- if (isSecurityFocused) {
360
- addMatch('security-focused', [
361
- 'Detected security-focused repo signals.',
362
- ctx.fileContent('SECURITY.md') ? 'SECURITY.md present.' : null,
363
- ]);
364
- }
365
-
366
- detectAdditionalDomainPacks({
367
- ctx,
368
- pkg,
369
- deps,
370
- stackKeys,
371
- addMatch,
372
- hasBackend,
373
- hasFrontend,
374
- hasInfra,
375
- hasCi,
376
- isEnterpriseGoverned,
377
- });
378
-
379
- if (matches.length === 0) {
380
- addMatch('baseline-general', [
381
- 'No stronger platform-specific domain dominated, so a safe general Codex baseline is the best starting point.',
382
- assets.instructionPath
383
- ? 'The repo already has Codex surfaces, but they are not yet specialized by domain.'
384
- : 'The repo needs a first Codex baseline before specialization.',
385
- ]);
386
- }
387
-
388
- return uniqueByKey(matches);
389
- }
390
-
391
- module.exports = {
392
- CODEX_DOMAIN_PACKS,
393
- detectCodexDomainPacks,
394
- };
1
+ const { buildAdditionalDomainPacks, detectAdditionalDomainPacks } = require('../domain-pack-expansion');
2
+
3
+ const BASE_CODEX_DOMAIN_PACKS = [
4
+ {
5
+ key: 'baseline-general',
6
+ label: 'Baseline General',
7
+ useWhen: 'General Codex repos that need a safe, reviewable baseline before deeper specialization.',
8
+ adoption: 'Safe default when no stronger domain signal dominates the repo.',
9
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Review workflow starter'],
10
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
11
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
12
+ benchmarkFocus: ['starter-safe improvement', 'reviewable trust posture'],
13
+ },
14
+ {
15
+ key: 'backend-api',
16
+ label: 'Backend API',
17
+ useWhen: 'Service, API, or backend-heavy repos with routes, services, jobs, schemas, or data access.',
18
+ adoption: 'Recommended when Codex needs stronger verification and review structure around backend changes.',
19
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Backend verification guide', 'CI / review workflow starter'],
20
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
21
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
22
+ benchmarkFocus: ['test + build verification', 'reviewable API changes', 'safe rollout posture'],
23
+ },
24
+ {
25
+ key: 'frontend-ui',
26
+ label: 'Frontend UI',
27
+ useWhen: 'React, Next.js, Vue, Angular, or Svelte repos with UI-heavy workflows and component work.',
28
+ adoption: 'Recommended when Codex needs better component, build, and review guidance.',
29
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Frontend review workflow', 'CI / review workflow starter'],
30
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
31
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
32
+ benchmarkFocus: ['build verification', 'component-safe edits', 'reviewable UI changes'],
33
+ },
34
+ {
35
+ key: 'enterprise-governed',
36
+ label: 'Enterprise Governed',
37
+ useWhen: 'Repos with CI, policy files, security posture, or auditable team workflows that need stronger Codex governance.',
38
+ adoption: 'Recommended for teams that need explicit approvals, review expectations, and durable rollout evidence.',
39
+ recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Review workflow starter', 'Governance rollout kit'],
40
+ recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
41
+ recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
42
+ benchmarkFocus: ['policy-aware rollout', 'approval posture', 'repeatable governance evidence'],
43
+ },
44
+ {
45
+ key: 'monorepo',
46
+ label: 'Monorepo',
47
+ useWhen: 'Workspace-based repos with multiple packages sharing a root and a need for scoped Codex behavior.',
48
+ adoption: 'Recommended when path-aware rules and workspace review boundaries matter.',
49
+ recommendedModules: ['AGENTS.md baseline', 'Codex rules baseline', 'Workspace-aware rules', 'Review workflow starter'],
50
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-rules', 'codex-ci-review'],
51
+ recommendedSurfaces: ['AGENTS.md', 'codex/rules/', '.github/workflows/'],
52
+ benchmarkFocus: ['workspace-safe edits', 'package-scoped review', 'cross-package drift control'],
53
+ },
54
+ {
55
+ key: 'infra-platform',
56
+ label: 'Infra Platform',
57
+ useWhen: 'Terraform, Docker, Kubernetes, serverless, or deployment-oriented repos with operational blast radius.',
58
+ adoption: 'Recommended when Codex changes need stronger guardrails, review gates, and infra-aware verification.',
59
+ recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Infra review workflow', 'CI / review workflow starter'],
60
+ recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
61
+ recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
62
+ benchmarkFocus: ['release safety', 'infra verification', 'reviewable operational changes'],
63
+ },
64
+ // --- Parity expansion: 10 new packs to match Claude's 16 ---
65
+ {
66
+ key: 'data-pipeline',
67
+ label: 'Data Pipeline',
68
+ useWhen: 'Repos with workers, DAGs, ETL jobs, migrations, or analytics-heavy workflows.',
69
+ adoption: 'Recommended when Codex needs pipeline-safe verification and state-aware review.',
70
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Pipeline verification guide'],
71
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
72
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
73
+ benchmarkFocus: ['pipeline safety', 'repeatable task flows', 'state-aware review'],
74
+ },
75
+ {
76
+ key: 'oss-library',
77
+ label: 'OSS Library',
78
+ useWhen: 'Public packages or contributor-heavy repos that need lighter governance.',
79
+ adoption: 'Recommended for open-source repos where Codex should suggest, not auto-apply.',
80
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline'],
81
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
82
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
83
+ benchmarkFocus: ['low-footprint adoption', 'contributor-safe defaults', 'manual review friendliness'],
84
+ },
85
+ {
86
+ key: 'mobile',
87
+ label: 'Mobile',
88
+ useWhen: 'React Native, Flutter, Swift, or Kotlin repos with mobile-specific build and test workflows.',
89
+ adoption: 'Recommended when Codex needs mobile build awareness and platform-specific verification.',
90
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Mobile verification guide'],
91
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
92
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
93
+ benchmarkFocus: ['mobile build safety', 'platform-specific verification', 'reviewable native changes'],
94
+ },
95
+ {
96
+ key: 'regulated-lite',
97
+ label: 'Regulated Lite',
98
+ useWhen: 'Repos with basic compliance needs — activity artifacts, rollback manifests, and audit trail.',
99
+ adoption: 'Recommended for regulated-adjacent repos that need governance without full enterprise overhead.',
100
+ recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Governance rollout kit'],
101
+ recommendedProposalFamilies: ['codex-config', 'codex-rules'],
102
+ recommendedSurfaces: ['.codex/config.toml', 'codex/rules/'],
103
+ benchmarkFocus: ['compliance posture', 'activity artifact coverage', 'rollback readiness'],
104
+ },
105
+ {
106
+ key: 'ecommerce',
107
+ label: 'E-commerce',
108
+ useWhen: 'Shopify, Stripe, or payment-heavy repos with transaction safety needs.',
109
+ adoption: 'Recommended when Codex changes touch payment flows, cart logic, or sensitive data.',
110
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Security review workflow'],
111
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config', 'codex-ci-review'],
112
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml', '.github/workflows/'],
113
+ benchmarkFocus: ['transaction safety', 'payment flow review', 'PII-safe changes'],
114
+ },
115
+ {
116
+ key: 'ai-ml',
117
+ label: 'AI / ML',
118
+ useWhen: 'Repos with ML pipelines, model training, RAG, or LLM integration workflows.',
119
+ adoption: 'Recommended when Codex needs model-aware verification and experiment tracking.',
120
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'ML verification guide'],
121
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
122
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
123
+ benchmarkFocus: ['model safety', 'experiment reproducibility', 'data pipeline review'],
124
+ },
125
+ {
126
+ key: 'devops-cicd',
127
+ label: 'DevOps / CI-CD',
128
+ useWhen: 'Repos focused on CI/CD pipelines, deployment automation, and infrastructure-as-code.',
129
+ adoption: 'Recommended when Codex manages CI workflows, deployment scripts, or release processes.',
130
+ recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'CI / review workflow starter'],
131
+ recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
132
+ recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
133
+ benchmarkFocus: ['deployment safety', 'CI pipeline review', 'release gate coverage'],
134
+ },
135
+ {
136
+ key: 'design-system',
137
+ label: 'Design System',
138
+ useWhen: 'Component libraries, Storybook repos, or design token systems.',
139
+ adoption: 'Recommended when Codex edits shared UI components with downstream consumers.',
140
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline', 'Component review workflow'],
141
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
142
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
143
+ benchmarkFocus: ['component safety', 'visual regression awareness', 'cross-consumer impact'],
144
+ },
145
+ {
146
+ key: 'docs-content',
147
+ label: 'Docs / Content',
148
+ useWhen: 'Documentation repos, blogs, or content-heavy sites with editorial workflows.',
149
+ adoption: 'Recommended when Codex edits prose, docs, or content with editorial review needs.',
150
+ recommendedModules: ['AGENTS.md baseline', 'Codex config baseline'],
151
+ recommendedProposalFamilies: ['codex-agents-md', 'codex-config'],
152
+ recommendedSurfaces: ['AGENTS.md', '.codex/config.toml'],
153
+ benchmarkFocus: ['content quality', 'editorial review', 'link and reference integrity'],
154
+ },
155
+ {
156
+ key: 'security-focused',
157
+ label: 'Security Focused',
158
+ useWhen: 'Repos with strong security posture needs — secret management, auth, encryption.',
159
+ adoption: 'Recommended for security-critical repos where every Codex change needs security review.',
160
+ recommendedModules: ['Codex config baseline', 'Codex rules baseline', 'Security review workflow'],
161
+ recommendedProposalFamilies: ['codex-config', 'codex-rules', 'codex-ci-review'],
162
+ recommendedSurfaces: ['.codex/config.toml', 'codex/rules/', '.github/workflows/'],
163
+ benchmarkFocus: ['secret protection', 'auth flow safety', 'security review coverage'],
164
+ },
165
+ ];
166
+
167
+ const CODEX_DOMAIN_PACKS = [
168
+ ...BASE_CODEX_DOMAIN_PACKS,
169
+ ...buildAdditionalDomainPacks('codex', {
170
+ existingKeys: new Set(BASE_CODEX_DOMAIN_PACKS.map((pack) => pack.key)),
171
+ }),
172
+ ];
173
+
174
+ function uniqueByKey(items) {
175
+ const seen = new Set();
176
+ const result = [];
177
+ for (const item of items) {
178
+ if (seen.has(item.key)) continue;
179
+ seen.add(item.key);
180
+ result.push(item);
181
+ }
182
+ return result;
183
+ }
184
+
185
+ function detectCodexDomainPacks(ctx, stacks = [], assets = {}) {
186
+ const stackKeys = new Set((stacks || []).map((stack) => stack.key));
187
+ const pkg = ctx.jsonFile ? (ctx.jsonFile('package.json') || {}) : {};
188
+ const deps = ctx.projectDependencies ? ctx.projectDependencies() : {
189
+ ...(pkg.dependencies || {}),
190
+ ...(pkg.devDependencies || {}),
191
+ };
192
+ const matches = [];
193
+
194
+ function addMatch(key, reasons) {
195
+ const pack = CODEX_DOMAIN_PACKS.find((item) => item.key === key);
196
+ if (!pack) return;
197
+ matches.push({
198
+ ...pack,
199
+ matchReasons: reasons.filter(Boolean).slice(0, 3),
200
+ });
201
+ }
202
+
203
+ const hasFrontend = stackKeys.has('react') || stackKeys.has('nextjs') || stackKeys.has('vue') ||
204
+ stackKeys.has('angular') || stackKeys.has('svelte') ||
205
+ ctx.hasDir('components') || ctx.hasDir('pages') ||
206
+ (ctx.hasDir('app') && (deps.next || deps.react || deps.vue || deps['@angular/core'] || deps.svelte));
207
+
208
+ const hasBackend = stackKeys.has('python') || stackKeys.has('django') || stackKeys.has('fastapi') ||
209
+ stackKeys.has('go') || stackKeys.has('rust') || stackKeys.has('java') ||
210
+ ctx.hasDir('api') || ctx.hasDir('routes') || ctx.hasDir('services') || ctx.hasDir('controllers') ||
211
+ ctx.hasDir('workers') || ctx.hasDir('jobs');
212
+
213
+ const hasInfra = stackKeys.has('docker') || stackKeys.has('terraform') || stackKeys.has('kubernetes') ||
214
+ ctx.files.includes('wrangler.toml') || ctx.files.includes('serverless.yml') || ctx.files.includes('serverless.yaml') ||
215
+ ctx.files.includes('cdk.json') || ctx.hasDir('infra') || ctx.hasDir('deploy') || ctx.hasDir('helm');
216
+
217
+ const isMonorepo = ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
218
+ ctx.files.includes('lerna.json') || ctx.files.includes('pnpm-workspace.yaml') ||
219
+ ctx.hasDir('packages') ||
220
+ (pkg.workspaces && (Array.isArray(pkg.workspaces) ? pkg.workspaces.length > 0 : true));
221
+
222
+ const hasCi = (typeof ctx.workflowFiles === 'function' ? ctx.workflowFiles().length : 0) > 0 ||
223
+ ctx.hasDir('.github/workflows');
224
+ const hasPolicyFiles = Boolean(ctx.fileContent('SECURITY.md') || ctx.fileContent('CODEOWNERS')) ||
225
+ ctx.hasDir('compliance') || ctx.hasDir('policies') || ctx.hasDir('audit');
226
+ const explicitTrust = Boolean(assets.trust && assets.trust.approvalPolicy && assets.trust.sandboxMode);
227
+ const ruleCoverage = Number(assets.counts && assets.counts.rules) > 0;
228
+ const workflowCoverage = Number(assets.counts && assets.counts.workflows) > 0;
229
+ const isEnterpriseGoverned = (hasCi && explicitTrust) || hasPolicyFiles || (ruleCoverage && workflowCoverage);
230
+
231
+ if (hasBackend) {
232
+ addMatch('backend-api', [
233
+ 'Detected backend stack or service-oriented directories for Codex to navigate.',
234
+ ctx.hasDir('api') ? 'API-facing structure detected.' : null,
235
+ ctx.hasDir('services') ? 'Service-layer directories detected.' : null,
236
+ ]);
237
+ }
238
+
239
+ if (hasFrontend) {
240
+ addMatch('frontend-ui', [
241
+ 'Detected UI-heavy frontend stack or component directories.',
242
+ stackKeys.has('nextjs') ? 'Next.js stack detected.' : null,
243
+ ctx.hasDir('components') ? 'Component directories detected.' : null,
244
+ ]);
245
+ }
246
+
247
+ if (isEnterpriseGoverned) {
248
+ addMatch('enterprise-governed', [
249
+ 'Detected team-governed rollout signals such as CI, policies, or explicit Codex trust posture.',
250
+ hasCi ? 'GitHub workflow automation detected.' : null,
251
+ hasPolicyFiles ? 'Security/compliance policy files detected.' : null,
252
+ ]);
253
+ }
254
+
255
+ if (isMonorepo) {
256
+ addMatch('monorepo', [
257
+ 'Detected workspace or multi-package repository structure.',
258
+ ctx.files.includes('pnpm-workspace.yaml') ? 'pnpm workspace detected.' : null,
259
+ ctx.hasDir('packages') ? 'Packages directory detected.' : null,
260
+ ]);
261
+ }
262
+
263
+ if (hasInfra) {
264
+ addMatch('infra-platform', [
265
+ 'Detected infrastructure or deployment-oriented repo signals.',
266
+ ctx.files.includes('wrangler.toml') ? 'Wrangler config detected.' : null,
267
+ ctx.hasDir('infra') ? 'Infrastructure directory detected.' : null,
268
+ ]);
269
+ }
270
+
271
+ // --- Parity expansion: detect 10 new domain packs ---
272
+
273
+ const hasDataPipeline = ctx.hasDir('dags') || ctx.hasDir('etl') || ctx.hasDir('pipelines') ||
274
+ ctx.hasDir('marts') || ctx.hasDir('migrations') ||
275
+ deps.airflow || deps.prefect || deps.dagster || deps.dbt;
276
+ if (hasDataPipeline) {
277
+ addMatch('data-pipeline', [
278
+ 'Detected data pipeline or ETL-oriented repo signals.',
279
+ ctx.hasDir('dags') ? 'DAG directory detected.' : null,
280
+ ]);
281
+ }
282
+
283
+ const isOss = ctx.files.includes('LICENSE') && ctx.files.includes('CONTRIBUTING.md');
284
+ if (isOss && !isEnterpriseGoverned) {
285
+ addMatch('oss-library', [
286
+ 'Detected open-source library signals (LICENSE + CONTRIBUTING.md).',
287
+ ]);
288
+ }
289
+
290
+ const isMobile = stackKeys.has('react-native') || stackKeys.has('flutter') ||
291
+ stackKeys.has('swift') || stackKeys.has('kotlin') ||
292
+ deps['react-native'] || deps.flutter || ctx.files.includes('Podfile') ||
293
+ ctx.files.includes('build.gradle') || ctx.hasDir('ios') || ctx.hasDir('android');
294
+ if (isMobile) {
295
+ addMatch('mobile', [
296
+ 'Detected mobile development signals.',
297
+ ctx.hasDir('ios') ? 'iOS directory detected.' : null,
298
+ ctx.hasDir('android') ? 'Android directory detected.' : null,
299
+ ]);
300
+ }
301
+
302
+ const isRegulated = hasPolicyFiles && !isEnterpriseGoverned;
303
+ if (isRegulated) {
304
+ addMatch('regulated-lite', [
305
+ 'Detected compliance-adjacent signals without full enterprise governance.',
306
+ ]);
307
+ }
308
+
309
+ const isEcommerce = deps.stripe || deps['@stripe/stripe-js'] ||
310
+ deps.shopify || deps['@shopify/shopify-api'] ||
311
+ ctx.hasDir('checkout') || ctx.hasDir('cart') || ctx.hasDir('payments');
312
+ if (isEcommerce) {
313
+ addMatch('ecommerce', [
314
+ 'Detected e-commerce or payment-related signals.',
315
+ deps.stripe ? 'Stripe dependency detected.' : null,
316
+ ]);
317
+ }
318
+
319
+ const isAiMl = deps.tensorflow || deps.torch || deps.pytorch || deps.transformers ||
320
+ deps.langchain || deps['@langchain/core'] || deps.openai || deps.anthropic ||
321
+ ctx.hasDir('models') || ctx.hasDir('training') || ctx.hasDir('rag') ||
322
+ ctx.files.includes('model.py') || ctx.files.includes('train.py');
323
+ if (isAiMl) {
324
+ addMatch('ai-ml', [
325
+ 'Detected AI/ML or model training signals.',
326
+ ctx.hasDir('models') ? 'Models directory detected.' : null,
327
+ ]);
328
+ }
329
+
330
+ const isDevops = hasCi && hasInfra && !isEnterpriseGoverned;
331
+ if (isDevops) {
332
+ addMatch('devops-cicd', [
333
+ 'Detected DevOps/CI-CD focus with both CI workflows and infrastructure.',
334
+ ]);
335
+ }
336
+
337
+ const isDesignSystem = ctx.hasDir('stories') || ctx.hasDir('storybook') ||
338
+ deps['@storybook/react'] || deps['@storybook/vue3'] ||
339
+ ctx.files.includes('.storybook');
340
+ if (isDesignSystem) {
341
+ addMatch('design-system', [
342
+ 'Detected design system or component library signals.',
343
+ ctx.hasDir('stories') ? 'Storybook stories detected.' : null,
344
+ ]);
345
+ }
346
+
347
+ const isDocsContent = ctx.hasDir('docs') && !hasBackend && !hasFrontend &&
348
+ (ctx.files.includes('mkdocs.yml') || ctx.files.includes('docusaurus.config.js') ||
349
+ ctx.files.includes('_config.yml') || ctx.files.includes('hugo.toml'));
350
+ if (isDocsContent) {
351
+ addMatch('docs-content', [
352
+ 'Detected documentation or content-focused repo.',
353
+ ]);
354
+ }
355
+
356
+ const isSecurityFocused = ctx.hasDir('security') ||
357
+ deps['helmet'] || deps['csurf'] || deps['bcrypt'] ||
358
+ (hasPolicyFiles && ctx.fileContent('SECURITY.md'));
359
+ if (isSecurityFocused) {
360
+ addMatch('security-focused', [
361
+ 'Detected security-focused repo signals.',
362
+ ctx.fileContent('SECURITY.md') ? 'SECURITY.md present.' : null,
363
+ ]);
364
+ }
365
+
366
+ detectAdditionalDomainPacks({
367
+ ctx,
368
+ pkg,
369
+ deps,
370
+ stackKeys,
371
+ addMatch,
372
+ hasBackend,
373
+ hasFrontend,
374
+ hasInfra,
375
+ hasCi,
376
+ isEnterpriseGoverned,
377
+ });
378
+
379
+ if (matches.length === 0) {
380
+ addMatch('baseline-general', [
381
+ 'No stronger platform-specific domain dominated, so a safe general Codex baseline is the best starting point.',
382
+ assets.instructionPath
383
+ ? 'The repo already has Codex surfaces, but they are not yet specialized by domain.'
384
+ : 'The repo needs a first Codex baseline before specialization.',
385
+ ]);
386
+ }
387
+
388
+ return uniqueByKey(matches);
389
+ }
390
+
391
+ module.exports = {
392
+ CODEX_DOMAIN_PACKS,
393
+ detectCodexDomainPacks,
394
+ };