@nerviq/cli 0.0.1 → 0.9.0-beta.2

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 (148) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/LICENSE +21 -0
  3. package/README.md +447 -0
  4. package/bin/cli.js +749 -0
  5. package/content/case-study-template.md +91 -0
  6. package/content/claims-governance.md +37 -0
  7. package/content/claude-code/audit-repo/SKILL.md +20 -0
  8. package/content/claude-native-integration.md +60 -0
  9. package/content/devto-article.json +9 -0
  10. package/content/launch-posts.md +226 -0
  11. package/content/pilot-rollout-kit.md +30 -0
  12. package/content/release-checklist.md +31 -0
  13. package/package.json +53 -4
  14. package/src/activity.js +529 -0
  15. package/src/aider/activity.js +226 -0
  16. package/src/aider/config-parser.js +166 -0
  17. package/src/aider/context.js +158 -0
  18. package/src/aider/deep-review.js +316 -0
  19. package/src/aider/domain-packs.js +278 -0
  20. package/src/aider/freshness.js +168 -0
  21. package/src/aider/governance.js +253 -0
  22. package/src/aider/interactive.js +334 -0
  23. package/src/aider/mcp-packs.js +98 -0
  24. package/src/aider/patch.js +214 -0
  25. package/src/aider/plans.js +186 -0
  26. package/src/aider/premium.js +360 -0
  27. package/src/aider/setup.js +404 -0
  28. package/src/aider/techniques.js +1323 -0
  29. package/src/analyze.js +821 -0
  30. package/src/audit.js +1003 -0
  31. package/src/badge.js +13 -0
  32. package/src/benchmark.js +339 -0
  33. package/src/claudex-sync.json +7 -0
  34. package/src/codex/activity.js +324 -0
  35. package/src/codex/config-parser.js +183 -0
  36. package/src/codex/context.js +221 -0
  37. package/src/codex/deep-review.js +493 -0
  38. package/src/codex/domain-packs.js +372 -0
  39. package/src/codex/freshness.js +167 -0
  40. package/src/codex/governance.js +192 -0
  41. package/src/codex/interactive.js +618 -0
  42. package/src/codex/mcp-packs.js +660 -0
  43. package/src/codex/patch.js +209 -0
  44. package/src/codex/plans.js +251 -0
  45. package/src/codex/premium.js +614 -0
  46. package/src/codex/setup.js +603 -0
  47. package/src/codex/techniques.js +2649 -0
  48. package/src/context.js +272 -0
  49. package/src/copilot/activity.js +309 -0
  50. package/src/copilot/config-parser.js +226 -0
  51. package/src/copilot/context.js +197 -0
  52. package/src/copilot/deep-review.js +346 -0
  53. package/src/copilot/domain-packs.js +350 -0
  54. package/src/copilot/freshness.js +197 -0
  55. package/src/copilot/governance.js +222 -0
  56. package/src/copilot/interactive.js +406 -0
  57. package/src/copilot/mcp-packs.js +572 -0
  58. package/src/copilot/patch.js +238 -0
  59. package/src/copilot/plans.js +253 -0
  60. package/src/copilot/premium.js +450 -0
  61. package/src/copilot/setup.js +488 -0
  62. package/src/copilot/techniques.js +1822 -0
  63. package/src/cursor/activity.js +301 -0
  64. package/src/cursor/config-parser.js +265 -0
  65. package/src/cursor/context.js +236 -0
  66. package/src/cursor/deep-review.js +334 -0
  67. package/src/cursor/domain-packs.js +346 -0
  68. package/src/cursor/freshness.js +214 -0
  69. package/src/cursor/governance.js +229 -0
  70. package/src/cursor/interactive.js +391 -0
  71. package/src/cursor/mcp-packs.js +571 -0
  72. package/src/cursor/patch.js +243 -0
  73. package/src/cursor/plans.js +254 -0
  74. package/src/cursor/premium.js +468 -0
  75. package/src/cursor/setup.js +488 -0
  76. package/src/cursor/techniques.js +1786 -0
  77. package/src/deep-review.js +345 -0
  78. package/src/domain-packs.js +364 -0
  79. package/src/formatters/sarif.js +115 -0
  80. package/src/gemini/activity.js +402 -0
  81. package/src/gemini/config-parser.js +275 -0
  82. package/src/gemini/context.js +221 -0
  83. package/src/gemini/deep-review.js +559 -0
  84. package/src/gemini/domain-packs.js +371 -0
  85. package/src/gemini/freshness.js +204 -0
  86. package/src/gemini/governance.js +201 -0
  87. package/src/gemini/interactive.js +860 -0
  88. package/src/gemini/mcp-packs.js +658 -0
  89. package/src/gemini/patch.js +229 -0
  90. package/src/gemini/plans.js +269 -0
  91. package/src/gemini/premium.js +759 -0
  92. package/src/gemini/setup.js +692 -0
  93. package/src/gemini/techniques.js +2084 -0
  94. package/src/governance.js +523 -0
  95. package/src/harmony/advisor.js +383 -0
  96. package/src/harmony/audit.js +303 -0
  97. package/src/harmony/canon.js +444 -0
  98. package/src/harmony/cli.js +331 -0
  99. package/src/harmony/drift.js +401 -0
  100. package/src/harmony/governance.js +313 -0
  101. package/src/harmony/memory.js +238 -0
  102. package/src/harmony/sync.js +458 -0
  103. package/src/harmony/watch.js +336 -0
  104. package/src/index.js +256 -0
  105. package/src/insights.js +119 -0
  106. package/src/interactive.js +118 -0
  107. package/src/mcp-packs.js +597 -0
  108. package/src/opencode/activity.js +286 -0
  109. package/src/opencode/config-parser.js +109 -0
  110. package/src/opencode/context.js +247 -0
  111. package/src/opencode/deep-review.js +313 -0
  112. package/src/opencode/domain-packs.js +240 -0
  113. package/src/opencode/freshness.js +158 -0
  114. package/src/opencode/governance.js +159 -0
  115. package/src/opencode/interactive.js +392 -0
  116. package/src/opencode/mcp-packs.js +474 -0
  117. package/src/opencode/patch.js +184 -0
  118. package/src/opencode/plans.js +231 -0
  119. package/src/opencode/premium.js +413 -0
  120. package/src/opencode/setup.js +449 -0
  121. package/src/opencode/techniques.js +1713 -0
  122. package/src/plans.js +655 -0
  123. package/src/secret-patterns.js +30 -0
  124. package/src/setup.js +1274 -0
  125. package/src/synergy/adaptive.js +261 -0
  126. package/src/synergy/compensation.js +156 -0
  127. package/src/synergy/evidence.js +193 -0
  128. package/src/synergy/learning.js +184 -0
  129. package/src/synergy/patterns.js +227 -0
  130. package/src/synergy/ranking.js +83 -0
  131. package/src/synergy/report.js +163 -0
  132. package/src/synergy/routing.js +152 -0
  133. package/src/techniques.js +1354 -0
  134. package/src/watch.js +229 -0
  135. package/src/windsurf/activity.js +302 -0
  136. package/src/windsurf/config-parser.js +267 -0
  137. package/src/windsurf/context.js +249 -0
  138. package/src/windsurf/deep-review.js +337 -0
  139. package/src/windsurf/domain-packs.js +348 -0
  140. package/src/windsurf/freshness.js +215 -0
  141. package/src/windsurf/governance.js +231 -0
  142. package/src/windsurf/interactive.js +388 -0
  143. package/src/windsurf/mcp-packs.js +535 -0
  144. package/src/windsurf/patch.js +231 -0
  145. package/src/windsurf/plans.js +247 -0
  146. package/src/windsurf/premium.js +467 -0
  147. package/src/windsurf/setup.js +471 -0
  148. package/src/windsurf/techniques.js +1758 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Aider Proposal Families — proposal bundles for Aider setup improvements
3
+ *
4
+ * Simpler than IDE-based platforms since Aider has:
5
+ * - No hooks, MCP, skills, or agents to configure
6
+ * - Config: .aider.conf.yml, .env, conventions, .gitignore, .aiderignore
7
+ */
8
+
9
+ const path = require('path');
10
+ const { version } = require('../../package.json');
11
+ const { audit } = require('../audit');
12
+ const { analyzeProject } = require('../analyze');
13
+ const { buildAiderSetupFiles } = require('./setup');
14
+ const { getAiderMcpPreflight } = require('./mcp-packs');
15
+
16
+ function maturityFromScore(score) {
17
+ if (score >= 81) return 'mature';
18
+ if (score >= 61) return 'solid';
19
+ if (score >= 41) return 'developing';
20
+ if (score >= 21) return 'weak';
21
+ return 'raw';
22
+ }
23
+
24
+ function triggerMatchesFile(result, filePath) {
25
+ if (filePath === '.aider.conf.yml') {
26
+ return result.file === '.aider.conf.yml' || ['config', 'model-config', 'git-safety', 'advanced-config'].includes(result.category);
27
+ }
28
+ if (filePath === 'CONVENTIONS.md') {
29
+ return result.file === 'CONVENTIONS.md' || result.category === 'conventions' || result.category === 'quality';
30
+ }
31
+ if (filePath === '.env') {
32
+ return result.file === '.env' || result.category === 'model-config';
33
+ }
34
+ if (filePath === '.gitignore') {
35
+ return result.file === '.gitignore' || result.category === 'security';
36
+ }
37
+ if (filePath === '.aiderignore') {
38
+ return result.file === '.aiderignore' || result.category === 'architecture';
39
+ }
40
+ return result.file === filePath;
41
+ }
42
+
43
+ function uniqueValues(items = []) {
44
+ return [...new Set(items.filter(Boolean))];
45
+ }
46
+
47
+ function buildDomainPackGuidance(report) {
48
+ return (report.recommendedDomainPacks || []).map((pack) => ({
49
+ key: pack.key,
50
+ label: pack.label,
51
+ useWhen: pack.useWhen,
52
+ matchReasons: pack.matchReasons || [],
53
+ recommendedModules: pack.recommendedModules || [],
54
+ recommendedProposalFamilies: pack.recommendedProposalFamilies || [],
55
+ recommendedSurfaces: pack.recommendedSurfaces || [],
56
+ benchmarkFocus: pack.benchmarkFocus || [],
57
+ }));
58
+ }
59
+
60
+ const PROPOSAL_FAMILIES = {
61
+ '.aider.conf.yml': {
62
+ id: 'aider-conf-yml',
63
+ label: 'Aider Configuration',
64
+ surface: '.aider.conf.yml',
65
+ reason: 'Core Aider config — model selection, git safety, verification loop.',
66
+ overwriteDefault: false,
67
+ },
68
+ 'CONVENTIONS.md': {
69
+ id: 'aider-conventions',
70
+ label: 'Aider Conventions',
71
+ surface: 'CONVENTIONS.md',
72
+ reason: 'Project conventions that Aider reads via --read (no auto-discovery).',
73
+ overwriteDefault: false,
74
+ },
75
+ '.env': {
76
+ id: 'aider-env',
77
+ label: 'Environment Config',
78
+ surface: '.env',
79
+ reason: 'API keys and model configuration via environment variables.',
80
+ overwriteDefault: false,
81
+ },
82
+ '.aiderignore': {
83
+ id: 'aider-aiderignore',
84
+ label: 'Aider Ignore',
85
+ surface: '.aiderignore',
86
+ reason: 'File exclusion to keep Aider focused on relevant code.',
87
+ overwriteDefault: false,
88
+ },
89
+ '.gitignore': {
90
+ id: 'aider-gitignore',
91
+ label: 'Git Ignore Additions',
92
+ surface: '.gitignore',
93
+ reason: 'Exclude .aider* artifacts and .env from git.',
94
+ overwriteDefault: false,
95
+ },
96
+ };
97
+
98
+ function buildProposalsFromAudit(auditResult, setupFiles, domainPackGuidance) {
99
+ const proposals = [];
100
+
101
+ for (const file of setupFiles) {
102
+ const family = PROPOSAL_FAMILIES[file.path];
103
+ if (!family) continue;
104
+
105
+ const triggers = auditResult.results
106
+ .filter(r => !r.passed && triggerMatchesFile(r, file.path))
107
+ .map(r => ({ id: r.id, name: r.name, impact: r.impact }));
108
+
109
+ if (triggers.length === 0) continue;
110
+
111
+ const packContext = domainPackGuidance
112
+ .filter(pack => {
113
+ if (!pack.recommendedSurfaces || pack.recommendedSurfaces.length === 0) return true;
114
+ return pack.recommendedSurfaces.some(s => file.path === s || file.path.startsWith(s));
115
+ })
116
+ .map(pack => ({
117
+ key: pack.key,
118
+ label: pack.label,
119
+ why: pack.matchReasons[0] || pack.useWhen,
120
+ }));
121
+
122
+ proposals.push({
123
+ id: family.id,
124
+ label: family.label,
125
+ surface: family.surface,
126
+ reason: family.reason,
127
+ triggers,
128
+ packContext,
129
+ content: file.content,
130
+ overwriteDefault: family.overwriteDefault,
131
+ });
132
+ }
133
+
134
+ return proposals;
135
+ }
136
+
137
+ /**
138
+ * Build a full Aider proposal bundle.
139
+ */
140
+ function buildAiderProposalBundle(options = {}) {
141
+ const dir = options.dir || process.cwd();
142
+ const auditResult = options.auditResult;
143
+ const analysisReport = options.analysisReport;
144
+
145
+ if (!auditResult || !analysisReport) {
146
+ throw new Error('buildAiderProposalBundle requires auditResult and analysisReport');
147
+ }
148
+
149
+ const domainPackGuidance = buildDomainPackGuidance(analysisReport);
150
+ const setupFiles = options.setupFiles || [];
151
+ const mcpPreflight = getAiderMcpPreflight();
152
+ const proposals = buildProposalsFromAudit(auditResult, setupFiles, domainPackGuidance);
153
+
154
+ return {
155
+ nerviqVersion: version,
156
+ createdAt: new Date().toISOString(),
157
+ platform: 'aider',
158
+ directory: dir,
159
+ projectSummary: {
160
+ name: path.basename(dir),
161
+ score: auditResult.score,
162
+ organicScore: auditResult.organicScore,
163
+ maturity: maturityFromScore(auditResult.score),
164
+ domains: analysisReport.projectSummary.domains || [],
165
+ },
166
+ strengthsPreserved: auditResult.results
167
+ .filter((item) => item.passed === true)
168
+ .slice(0, 5)
169
+ .map((item) => item.name),
170
+ topNextActions: auditResult.topNextActions,
171
+ recommendedDomainPacks: domainPackGuidance,
172
+ proposalFamilies: [...new Set(proposals.map(p => p.id))],
173
+ optionalModules: analysisReport.optionalModules || [],
174
+ riskNotes: uniqueValues([
175
+ ...(analysisReport.riskNotes || []),
176
+ 'Aider has no native MCP — use /web and editor extensions.',
177
+ 'Git is the ONLY undo mechanism — ensure auto-commits is true.',
178
+ ]),
179
+ mcpPreflightWarnings: mcpPreflight.warnings,
180
+ proposals,
181
+ };
182
+ }
183
+
184
+ module.exports = {
185
+ buildAiderProposalBundle,
186
+ };
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Aider Premium Operator UX
3
+ *
4
+ * Three subsystems:
5
+ * 1. Multi-Pack Composition Engine — merge domain packs with dedup and conflict resolution
6
+ * 2. CI Template Library — GitHub Actions workflow templates for Aider automation
7
+ * 3. Adoption Signal Gate — activate features based on local usage telemetry
8
+ */
9
+
10
+ const path = require('path');
11
+ const { AIDER_DOMAIN_PACKS } = require('./domain-packs');
12
+ const { AIDER_MCP_PACKS } = require('./mcp-packs');
13
+ const { getAiderHistory } = require('./activity');
14
+
15
+ // ---------------------------------------------------------------------------
16
+ // 1. Multi-Pack Composition Engine
17
+ // ---------------------------------------------------------------------------
18
+
19
+ const PACK_DEPENDENCY_ORDER = [
20
+ 'baseline-general',
21
+ 'backend-api',
22
+ 'frontend-ui',
23
+ 'infra-platform',
24
+ 'monorepo',
25
+ 'enterprise-governed',
26
+ ];
27
+
28
+ const PACK_SPECIFICITY = {
29
+ 'baseline-general': 0,
30
+ 'backend-api': 2,
31
+ 'frontend-ui': 2,
32
+ 'infra-platform': 3,
33
+ 'monorepo': 3,
34
+ 'enterprise-governed': 4,
35
+ };
36
+
37
+ const DEFAULT_SIZE_BUDGET = 16000;
38
+
39
+ function lookupDomainPack(key) {
40
+ return AIDER_DOMAIN_PACKS.find(p => p.key === key) || null;
41
+ }
42
+
43
+ function lookupMcpPack(key) {
44
+ return AIDER_MCP_PACKS.find(p => p.key === key) || null;
45
+ }
46
+
47
+ /**
48
+ * Compose domain packs into a unified, deduplicated, ordered result.
49
+ */
50
+ function composePacks(domainPackKeys = [], mcpPackKeys = [], options = {}) {
51
+ const sizeBudget = options.sizeBudget || DEFAULT_SIZE_BUDGET;
52
+ const warnings = [];
53
+
54
+ // Resolve domain packs
55
+ const seenDomainKeys = new Set();
56
+ const rawDomainPacks = [];
57
+ for (const key of domainPackKeys) {
58
+ if (seenDomainKeys.has(key)) continue;
59
+ seenDomainKeys.add(key);
60
+ const pack = lookupDomainPack(key);
61
+ if (!pack) {
62
+ warnings.push(`Domain pack "${key}" not found, skipped.`);
63
+ continue;
64
+ }
65
+ rawDomainPacks.push(pack);
66
+ }
67
+
68
+ // Order by dependency
69
+ rawDomainPacks.sort((a, b) => {
70
+ const orderA = PACK_DEPENDENCY_ORDER.indexOf(a.key);
71
+ const orderB = PACK_DEPENDENCY_ORDER.indexOf(b.key);
72
+ return (orderA === -1 ? 99 : orderA) - (orderB === -1 ? 99 : orderB);
73
+ });
74
+
75
+ // Deduplicate recommended modules
76
+ const seenModules = new Set();
77
+ const mergedModules = [];
78
+ for (const pack of rawDomainPacks) {
79
+ for (const mod of pack.recommendedModules || []) {
80
+ if (!seenModules.has(mod)) {
81
+ seenModules.add(mod);
82
+ mergedModules.push(mod);
83
+ }
84
+ }
85
+ }
86
+
87
+ // Deduplicate recommended surfaces
88
+ const seenSurfaces = new Set();
89
+ const mergedSurfaces = [];
90
+ for (const pack of rawDomainPacks) {
91
+ for (const surface of pack.recommendedSurfaces || []) {
92
+ if (!seenSurfaces.has(surface)) {
93
+ seenSurfaces.add(surface);
94
+ mergedSurfaces.push(surface);
95
+ }
96
+ }
97
+ }
98
+
99
+ // Deduplicate proposal families
100
+ const seenFamilies = new Set();
101
+ const mergedFamilies = [];
102
+ for (const pack of rawDomainPacks) {
103
+ for (const family of pack.recommendedProposalFamilies || []) {
104
+ if (!seenFamilies.has(family)) {
105
+ seenFamilies.add(family);
106
+ mergedFamilies.push(family);
107
+ }
108
+ }
109
+ }
110
+
111
+ // MCP packs (minimal for Aider)
112
+ const resolvedMcpPacks = mcpPackKeys
113
+ .map(key => lookupMcpPack(key))
114
+ .filter(Boolean);
115
+
116
+ // Size check
117
+ const estimatedSize = mergedModules.join('\n').length + mergedSurfaces.join('\n').length;
118
+ if (estimatedSize > sizeBudget) {
119
+ warnings.push(`Combined content (~${estimatedSize} chars) exceeds budget of ${sizeBudget}.`);
120
+ }
121
+
122
+ return {
123
+ domainPacks: rawDomainPacks.map(p => p.key),
124
+ mcpPacks: resolvedMcpPacks.map(p => p.key),
125
+ mergedModules,
126
+ mergedSurfaces,
127
+ mergedFamilies,
128
+ warnings,
129
+ estimatedSize,
130
+ withinBudget: estimatedSize <= sizeBudget,
131
+ };
132
+ }
133
+
134
+ // ---------------------------------------------------------------------------
135
+ // 2. CI Template Library
136
+ // ---------------------------------------------------------------------------
137
+
138
+ const CI_TEMPLATES = {
139
+ 'aider-lint-test': {
140
+ key: 'aider-lint-test',
141
+ label: 'Lint & Test on PR',
142
+ description: 'Run lint and test checks on Aider-generated PRs.',
143
+ template: `name: Aider PR Checks
144
+ on:
145
+ pull_request:
146
+ branches: [main]
147
+
148
+ jobs:
149
+ check:
150
+ runs-on: ubuntu-latest
151
+ steps:
152
+ - uses: actions/checkout@v4
153
+ - name: Setup
154
+ run: npm ci
155
+ - name: Lint
156
+ run: npm run lint
157
+ - name: Test
158
+ run: npm test
159
+ `,
160
+ },
161
+
162
+ 'aider-auto-pr': {
163
+ key: 'aider-auto-pr',
164
+ label: 'Aider Auto PR',
165
+ description: 'Run Aider in CI to generate PRs from issues.',
166
+ template: `name: Aider Auto PR
167
+ on:
168
+ issues:
169
+ types: [labeled]
170
+
171
+ jobs:
172
+ aider-fix:
173
+ if: contains(github.event.label.name, 'aider')
174
+ runs-on: ubuntu-latest
175
+ steps:
176
+ - uses: actions/checkout@v4
177
+ - name: Install Aider
178
+ run: pip install aider-chat
179
+ - name: Run Aider
180
+ env:
181
+ ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }}
182
+ run: |
183
+ aider --yes --message "Fix issue #\${{ github.event.issue.number }}: \${{ github.event.issue.title }}"
184
+ - name: Create PR
185
+ uses: peter-evans/create-pull-request@v6
186
+ with:
187
+ title: "aider: Fix #\${{ github.event.issue.number }}"
188
+ branch: aider/fix-\${{ github.event.issue.number }}
189
+ commit-message: "aider: address issue #\${{ github.event.issue.number }}"
190
+ `,
191
+ },
192
+
193
+ 'aider-review-gate': {
194
+ key: 'aider-review-gate',
195
+ label: 'Aider Review Gate',
196
+ description: 'Require reviews on AI-authored PRs (detected by commit prefix).',
197
+ template: `name: Aider Review Gate
198
+ on:
199
+ pull_request:
200
+ branches: [main]
201
+
202
+ jobs:
203
+ check-ai-authored:
204
+ runs-on: ubuntu-latest
205
+ steps:
206
+ - uses: actions/checkout@v4
207
+ with:
208
+ fetch-depth: 0
209
+ - name: Check for AI commits
210
+ id: ai-check
211
+ run: |
212
+ AI_COMMITS=\$(git log --format='%s' origin/main..HEAD | grep -c '^aider:' || true)
213
+ echo "ai_commits=\$AI_COMMITS" >> \$GITHUB_OUTPUT
214
+ - name: Require review for AI commits
215
+ if: steps.ai-check.outputs.ai_commits > 0
216
+ run: |
217
+ echo "This PR contains \${{ steps.ai-check.outputs.ai_commits }} AI-authored commit(s)."
218
+ echo "Manual review required before merge."
219
+ `,
220
+ },
221
+
222
+ 'aider-audit': {
223
+ key: 'aider-audit',
224
+ label: 'Aider Setup Audit',
225
+ description: 'Run nerviq audit on Aider config in CI.',
226
+ template: `name: Aider Config Audit
227
+ on:
228
+ push:
229
+ paths:
230
+ - '.aider.conf.yml'
231
+ - 'CONVENTIONS.md'
232
+ - '.aiderignore'
233
+ pull_request:
234
+ paths:
235
+ - '.aider.conf.yml'
236
+ - 'CONVENTIONS.md'
237
+ - '.aiderignore'
238
+
239
+ jobs:
240
+ audit:
241
+ runs-on: ubuntu-latest
242
+ steps:
243
+ - uses: actions/checkout@v4
244
+ - name: Run Aider Audit
245
+ run: npx nerviq --platform aider --ci
246
+ `,
247
+ },
248
+
249
+ 'aider-scheduled': {
250
+ key: 'aider-scheduled',
251
+ label: 'Scheduled Aider Tasks',
252
+ description: 'Run Aider on a schedule for maintenance tasks.',
253
+ template: `name: Scheduled Aider Maintenance
254
+ on:
255
+ schedule:
256
+ - cron: '0 6 * * 1' # Every Monday at 6am UTC
257
+
258
+ jobs:
259
+ maintenance:
260
+ runs-on: ubuntu-latest
261
+ steps:
262
+ - uses: actions/checkout@v4
263
+ - name: Install Aider
264
+ run: pip install aider-chat
265
+ - name: Run maintenance
266
+ env:
267
+ ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }}
268
+ run: |
269
+ aider --yes --message "Run weekly dependency update and lint fixes"
270
+ - name: Create PR
271
+ uses: peter-evans/create-pull-request@v6
272
+ with:
273
+ title: "aider: Weekly maintenance"
274
+ branch: aider/weekly-maintenance
275
+ `,
276
+ },
277
+ };
278
+
279
+ function getCiTemplate(key) {
280
+ return CI_TEMPLATES[key] || null;
281
+ }
282
+
283
+ // ---------------------------------------------------------------------------
284
+ // 3. Adoption Signal Gate
285
+ // ---------------------------------------------------------------------------
286
+
287
+ const GATE_THRESHOLDS = {
288
+ 'deep-review': {
289
+ threshold: 3,
290
+ description: 'Activate deep review after 3 audit snapshots.',
291
+ metric: 'snapshotCount',
292
+ },
293
+ 'ci-templates': {
294
+ threshold: 5,
295
+ description: 'Suggest CI templates after 5 audits with score > 50.',
296
+ metric: 'qualifyingAudits',
297
+ },
298
+ 'composition': {
299
+ threshold: 2,
300
+ description: 'Enable pack composition after using 2+ domain packs.',
301
+ metric: 'domainPackCount',
302
+ },
303
+ 'trend-export': {
304
+ threshold: 5,
305
+ description: 'Enable trend export after 5 snapshots.',
306
+ metric: 'snapshotCount',
307
+ },
308
+ };
309
+
310
+ function checkAdoptionGate(dir, gateKey) {
311
+ const gate = GATE_THRESHOLDS[gateKey];
312
+ if (!gate) return { activated: false, current: 0, threshold: 0, gate: gateKey, description: 'Unknown gate' };
313
+
314
+ const history = getAiderHistory(dir, 50);
315
+ let current = 0;
316
+
317
+ switch (gate.metric) {
318
+ case 'snapshotCount':
319
+ current = history.length;
320
+ break;
321
+ case 'qualifyingAudits':
322
+ current = history.filter(e => (e.summary?.score ?? 0) > 50).length;
323
+ break;
324
+ case 'domainPackCount': {
325
+ const packs = new Set();
326
+ for (const entry of history) {
327
+ for (const pack of (entry.summary?.domainPacks || [])) {
328
+ packs.add(pack);
329
+ }
330
+ }
331
+ current = packs.size;
332
+ break;
333
+ }
334
+ default:
335
+ current = 0;
336
+ }
337
+
338
+ return {
339
+ activated: current >= gate.threshold,
340
+ current,
341
+ threshold: gate.threshold,
342
+ gate: gateKey,
343
+ description: gate.description,
344
+ };
345
+ }
346
+
347
+ // ---------------------------------------------------------------------------
348
+ // Exports
349
+ // ---------------------------------------------------------------------------
350
+
351
+ module.exports = {
352
+ composePacks,
353
+ getCiTemplate,
354
+ CI_TEMPLATES,
355
+ checkAdoptionGate,
356
+ GATE_THRESHOLDS,
357
+ PACK_DEPENDENCY_ORDER,
358
+ PACK_SPECIFICITY,
359
+ DEFAULT_SIZE_BUDGET,
360
+ };