@nerviq/cli 0.0.1 → 0.9.0-beta.1
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.
- package/CHANGELOG.md +181 -0
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/bin/cli.js +749 -0
- package/content/case-study-template.md +91 -0
- package/content/claims-governance.md +37 -0
- package/content/claude-code/audit-repo/SKILL.md +20 -0
- package/content/claude-native-integration.md +60 -0
- package/content/devto-article.json +9 -0
- package/content/launch-posts.md +226 -0
- package/content/pilot-rollout-kit.md +30 -0
- package/content/release-checklist.md +31 -0
- package/package.json +53 -4
- package/src/activity.js +529 -0
- package/src/aider/activity.js +226 -0
- package/src/aider/config-parser.js +166 -0
- package/src/aider/context.js +158 -0
- package/src/aider/deep-review.js +316 -0
- package/src/aider/domain-packs.js +278 -0
- package/src/aider/freshness.js +168 -0
- package/src/aider/governance.js +253 -0
- package/src/aider/interactive.js +334 -0
- package/src/aider/mcp-packs.js +98 -0
- package/src/aider/patch.js +214 -0
- package/src/aider/plans.js +186 -0
- package/src/aider/premium.js +360 -0
- package/src/aider/setup.js +404 -0
- package/src/aider/techniques.js +1323 -0
- package/src/analyze.js +821 -0
- package/src/audit.js +1003 -0
- package/src/badge.js +13 -0
- package/src/benchmark.js +339 -0
- package/src/claudex-sync.json +7 -0
- package/src/codex/activity.js +324 -0
- package/src/codex/config-parser.js +183 -0
- package/src/codex/context.js +221 -0
- package/src/codex/deep-review.js +493 -0
- package/src/codex/domain-packs.js +372 -0
- package/src/codex/freshness.js +167 -0
- package/src/codex/governance.js +192 -0
- package/src/codex/interactive.js +618 -0
- package/src/codex/mcp-packs.js +660 -0
- package/src/codex/patch.js +209 -0
- package/src/codex/plans.js +251 -0
- package/src/codex/premium.js +614 -0
- package/src/codex/setup.js +603 -0
- package/src/codex/techniques.js +2649 -0
- package/src/context.js +272 -0
- package/src/copilot/activity.js +309 -0
- package/src/copilot/config-parser.js +226 -0
- package/src/copilot/context.js +197 -0
- package/src/copilot/deep-review.js +346 -0
- package/src/copilot/domain-packs.js +350 -0
- package/src/copilot/freshness.js +197 -0
- package/src/copilot/governance.js +222 -0
- package/src/copilot/interactive.js +406 -0
- package/src/copilot/mcp-packs.js +572 -0
- package/src/copilot/patch.js +238 -0
- package/src/copilot/plans.js +253 -0
- package/src/copilot/premium.js +450 -0
- package/src/copilot/setup.js +488 -0
- package/src/copilot/techniques.js +1822 -0
- package/src/cursor/activity.js +301 -0
- package/src/cursor/config-parser.js +265 -0
- package/src/cursor/context.js +236 -0
- package/src/cursor/deep-review.js +334 -0
- package/src/cursor/domain-packs.js +346 -0
- package/src/cursor/freshness.js +214 -0
- package/src/cursor/governance.js +229 -0
- package/src/cursor/interactive.js +391 -0
- package/src/cursor/mcp-packs.js +571 -0
- package/src/cursor/patch.js +243 -0
- package/src/cursor/plans.js +254 -0
- package/src/cursor/premium.js +468 -0
- package/src/cursor/setup.js +488 -0
- package/src/cursor/techniques.js +1786 -0
- package/src/deep-review.js +345 -0
- package/src/domain-packs.js +364 -0
- package/src/formatters/sarif.js +115 -0
- package/src/gemini/activity.js +402 -0
- package/src/gemini/config-parser.js +275 -0
- package/src/gemini/context.js +221 -0
- package/src/gemini/deep-review.js +559 -0
- package/src/gemini/domain-packs.js +371 -0
- package/src/gemini/freshness.js +204 -0
- package/src/gemini/governance.js +201 -0
- package/src/gemini/interactive.js +860 -0
- package/src/gemini/mcp-packs.js +658 -0
- package/src/gemini/patch.js +229 -0
- package/src/gemini/plans.js +269 -0
- package/src/gemini/premium.js +759 -0
- package/src/gemini/setup.js +692 -0
- package/src/gemini/techniques.js +2084 -0
- package/src/governance.js +523 -0
- package/src/harmony/advisor.js +383 -0
- package/src/harmony/audit.js +303 -0
- package/src/harmony/canon.js +444 -0
- package/src/harmony/cli.js +331 -0
- package/src/harmony/drift.js +401 -0
- package/src/harmony/governance.js +313 -0
- package/src/harmony/memory.js +238 -0
- package/src/harmony/sync.js +458 -0
- package/src/harmony/watch.js +336 -0
- package/src/index.js +256 -0
- package/src/insights.js +119 -0
- package/src/interactive.js +118 -0
- package/src/mcp-packs.js +597 -0
- package/src/opencode/activity.js +286 -0
- package/src/opencode/config-parser.js +109 -0
- package/src/opencode/context.js +247 -0
- package/src/opencode/deep-review.js +313 -0
- package/src/opencode/domain-packs.js +240 -0
- package/src/opencode/freshness.js +158 -0
- package/src/opencode/governance.js +159 -0
- package/src/opencode/interactive.js +392 -0
- package/src/opencode/mcp-packs.js +474 -0
- package/src/opencode/patch.js +184 -0
- package/src/opencode/plans.js +231 -0
- package/src/opencode/premium.js +413 -0
- package/src/opencode/setup.js +449 -0
- package/src/opencode/techniques.js +1713 -0
- package/src/plans.js +655 -0
- package/src/secret-patterns.js +30 -0
- package/src/setup.js +1274 -0
- package/src/synergy/adaptive.js +261 -0
- package/src/synergy/compensation.js +156 -0
- package/src/synergy/evidence.js +193 -0
- package/src/synergy/learning.js +184 -0
- package/src/synergy/patterns.js +227 -0
- package/src/synergy/ranking.js +83 -0
- package/src/synergy/report.js +163 -0
- package/src/synergy/routing.js +152 -0
- package/src/techniques.js +1354 -0
- package/src/watch.js +229 -0
- package/src/windsurf/activity.js +302 -0
- package/src/windsurf/config-parser.js +267 -0
- package/src/windsurf/context.js +249 -0
- package/src/windsurf/deep-review.js +337 -0
- package/src/windsurf/domain-packs.js +348 -0
- package/src/windsurf/freshness.js +215 -0
- package/src/windsurf/governance.js +231 -0
- package/src/windsurf/interactive.js +388 -0
- package/src/windsurf/mcp-packs.js +535 -0
- package/src/windsurf/patch.js +231 -0
- package/src/windsurf/plans.js +247 -0
- package/src/windsurf/premium.js +467 -0
- package/src/windsurf/setup.js +471 -0
- package/src/windsurf/techniques.js +1758 -0
package/src/analyze.js
ADDED
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project scanner + recommendation layer for augment and suggest-only modes.
|
|
3
|
+
* Produces a structured repo-aware analysis without writing files.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { audit } = require('./audit');
|
|
8
|
+
const { ProjectContext } = require('./context');
|
|
9
|
+
const { CodexProjectContext } = require('./codex/context');
|
|
10
|
+
const { STACKS } = require('./techniques');
|
|
11
|
+
const { detectDomainPacks } = require('./domain-packs');
|
|
12
|
+
const { detectCodexDomainPacks } = require('./codex/domain-packs');
|
|
13
|
+
const { recommendMcpPacks } = require('./mcp-packs');
|
|
14
|
+
|
|
15
|
+
const COLORS = {
|
|
16
|
+
reset: '\x1b[0m',
|
|
17
|
+
bold: '\x1b[1m',
|
|
18
|
+
dim: '\x1b[2m',
|
|
19
|
+
red: '\x1b[31m',
|
|
20
|
+
green: '\x1b[32m',
|
|
21
|
+
yellow: '\x1b[33m',
|
|
22
|
+
blue: '\x1b[36m',
|
|
23
|
+
magenta: '\x1b[35m',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function c(text, color) {
|
|
27
|
+
return `${COLORS[color] || ''}${text}${COLORS.reset}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function escapeRegex(value) {
|
|
31
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function extractTomlSection(content, sectionName) {
|
|
35
|
+
const pattern = new RegExp(`\\[${escapeRegex(sectionName)}\\]([\\s\\S]*?)(?:\\n\\s*\\[|$)`);
|
|
36
|
+
const match = content.match(pattern);
|
|
37
|
+
return match ? match[1] : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function extractTomlValue(sectionContent, key) {
|
|
41
|
+
if (!sectionContent) return null;
|
|
42
|
+
const pattern = new RegExp(`^\\s*${escapeRegex(key)}\\s*=\\s*["']([^"']+)["']`, 'm');
|
|
43
|
+
const match = sectionContent.match(pattern);
|
|
44
|
+
return match ? match[1].trim() : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function detectProjectMetadata(ctx) {
|
|
48
|
+
const pkg = ctx.jsonFile('package.json');
|
|
49
|
+
if (pkg && (pkg.name || pkg.description)) {
|
|
50
|
+
return {
|
|
51
|
+
name: pkg.name || path.basename(ctx.dir),
|
|
52
|
+
description: pkg.description || '',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const pyproject = ctx.fileContent('pyproject.toml') || '';
|
|
57
|
+
if (pyproject) {
|
|
58
|
+
const projectSection = extractTomlSection(pyproject, 'project');
|
|
59
|
+
const poetrySection = extractTomlSection(pyproject, 'tool.poetry');
|
|
60
|
+
const name = extractTomlValue(projectSection, 'name') ||
|
|
61
|
+
extractTomlValue(poetrySection, 'name');
|
|
62
|
+
const description = extractTomlValue(projectSection, 'description') ||
|
|
63
|
+
extractTomlValue(poetrySection, 'description');
|
|
64
|
+
|
|
65
|
+
if (name || description) {
|
|
66
|
+
return {
|
|
67
|
+
name: name || path.basename(ctx.dir),
|
|
68
|
+
description: description || '',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
name: path.basename(ctx.dir),
|
|
75
|
+
description: '',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function detectMainDirs(ctx) {
|
|
80
|
+
const candidates = [
|
|
81
|
+
'src', 'lib', 'app', 'pages', 'components', 'api', 'routes', 'utils', 'helpers',
|
|
82
|
+
'services', 'models', 'controllers', 'views', 'public', 'assets', 'config', 'tests',
|
|
83
|
+
'test', '__tests__', 'spec', 'scripts', 'prisma', 'db', 'middleware', 'hooks',
|
|
84
|
+
'agents', 'chains', 'workers', 'jobs', 'dags', 'macros', 'migrations',
|
|
85
|
+
'src/components', 'src/app', 'src/pages', 'src/api', 'src/lib', 'src/hooks',
|
|
86
|
+
'src/utils', 'src/services', 'src/models', 'src/middleware', 'src/agents',
|
|
87
|
+
'src/chains', 'src/workers', 'src/jobs', 'src/app/api', 'app/api',
|
|
88
|
+
'models/staging', 'models/marts'
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const dirs = [];
|
|
92
|
+
for (const dir of candidates) {
|
|
93
|
+
if (ctx.hasDir(dir)) {
|
|
94
|
+
dirs.push(dir);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return dirs;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function collectClaudeAssets(ctx) {
|
|
101
|
+
const sharedSettings = ctx.jsonFile('.claude/settings.json');
|
|
102
|
+
const localSettings = ctx.jsonFile('.claude/settings.local.json');
|
|
103
|
+
const settings = sharedSettings || localSettings || null;
|
|
104
|
+
|
|
105
|
+
const assetFiles = {
|
|
106
|
+
claudeMd: ctx.fileContent('CLAUDE.md') ? 'CLAUDE.md' : (ctx.fileContent('.claude/CLAUDE.md') ? '.claude/CLAUDE.md' : null),
|
|
107
|
+
settings: sharedSettings ? '.claude/settings.json' : (localSettings ? '.claude/settings.local.json' : null),
|
|
108
|
+
commands: ctx.hasDir('.claude/commands') ? ctx.dirFiles('.claude/commands') : [],
|
|
109
|
+
rules: ctx.hasDir('.claude/rules') ? ctx.dirFiles('.claude/rules') : [],
|
|
110
|
+
hooks: ctx.hasDir('.claude/hooks') ? ctx.dirFiles('.claude/hooks') : [],
|
|
111
|
+
agents: ctx.hasDir('.claude/agents') ? ctx.dirFiles('.claude/agents') : [],
|
|
112
|
+
skills: ctx.hasDir('.claude/skills') ? ctx.dirFiles('.claude/skills') : [],
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
label: 'Claude',
|
|
117
|
+
instructionLabel: 'CLAUDE.md',
|
|
118
|
+
configLabel: 'Settings',
|
|
119
|
+
instructionPath: assetFiles.claudeMd,
|
|
120
|
+
configPath: assetFiles.settings,
|
|
121
|
+
files: assetFiles,
|
|
122
|
+
counts: {
|
|
123
|
+
commands: assetFiles.commands.length,
|
|
124
|
+
rules: assetFiles.rules.length,
|
|
125
|
+
hooks: assetFiles.hooks.length,
|
|
126
|
+
agents: assetFiles.agents.length,
|
|
127
|
+
skills: assetFiles.skills.length,
|
|
128
|
+
mcpServers: settings && settings.mcpServers ? Object.keys(settings.mcpServers).length : 0,
|
|
129
|
+
},
|
|
130
|
+
permissions: settings && settings.permissions ? {
|
|
131
|
+
defaultMode: settings.permissions.defaultMode || null,
|
|
132
|
+
hasDenyRules: Array.isArray(settings.permissions.deny) && settings.permissions.deny.length > 0,
|
|
133
|
+
} : null,
|
|
134
|
+
settingsSource: assetFiles.settings,
|
|
135
|
+
summaryLine: `Commands: ${assetFiles.commands.length} | Rules: ${assetFiles.rules.length} | Hooks: ${assetFiles.hooks.length} | Agents: ${assetFiles.agents.length} | Skills: ${assetFiles.skills.length} | MCP servers: ${settings && settings.mcpServers ? Object.keys(settings.mcpServers).length : 0}`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function collectCodexAssets(ctx) {
|
|
140
|
+
const agentsMd = ctx.agentsMdPath ? ctx.agentsMdPath() : null;
|
|
141
|
+
const configPath = ctx.fileContent('.codex/config.toml') ? '.codex/config.toml' : null;
|
|
142
|
+
const hooksJson = ctx.hooksJsonContent ? ctx.hooksJsonContent() : null;
|
|
143
|
+
const rules = ctx.ruleFiles ? ctx.ruleFiles() : [];
|
|
144
|
+
const skills = ctx.skillDirs ? ctx.skillDirs().map((name) => `.agents/skills/${name}`) : [];
|
|
145
|
+
const agents = ctx.customAgentFiles ? ctx.customAgentFiles().map((file) => `.codex/agents/${file}`) : [];
|
|
146
|
+
const workflows = ctx.workflowFiles ? ctx.workflowFiles() : [];
|
|
147
|
+
const mcpServers = ctx.mcpServers ? Object.keys(ctx.mcpServers() || {}).length : 0;
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
label: 'Codex',
|
|
151
|
+
instructionLabel: 'AGENTS.md',
|
|
152
|
+
configLabel: 'Config',
|
|
153
|
+
instructionPath: agentsMd,
|
|
154
|
+
configPath,
|
|
155
|
+
files: {
|
|
156
|
+
agentsMd,
|
|
157
|
+
config: configPath,
|
|
158
|
+
rules,
|
|
159
|
+
hooks: hooksJson ? ['.codex/hooks.json'] : [],
|
|
160
|
+
skills,
|
|
161
|
+
agents,
|
|
162
|
+
workflows,
|
|
163
|
+
},
|
|
164
|
+
counts: {
|
|
165
|
+
rules: rules.length,
|
|
166
|
+
hooks: hooksJson ? 1 : 0,
|
|
167
|
+
skills: skills.length,
|
|
168
|
+
agents: agents.length,
|
|
169
|
+
workflows: workflows.length,
|
|
170
|
+
mcpServers,
|
|
171
|
+
},
|
|
172
|
+
trust: {
|
|
173
|
+
approvalPolicy: ctx.configValue ? (ctx.configValue('approval_policy') || null) : null,
|
|
174
|
+
sandboxMode: ctx.configValue ? (ctx.configValue('sandbox_mode') || null) : null,
|
|
175
|
+
isTrustedProject: ctx.isProjectTrusted ? ctx.isProjectTrusted() : false,
|
|
176
|
+
},
|
|
177
|
+
summaryLine: `Rules: ${rules.length} | Hooks: ${hooksJson ? 1 : 0} | Skills: ${skills.length} | Subagents: ${agents.length} | Workflows: ${workflows.length} | MCP servers: ${mcpServers}`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function detectMaturity(platform, assets) {
|
|
182
|
+
if (platform === 'codex') {
|
|
183
|
+
let score = 0;
|
|
184
|
+
if (assets.instructionPath) score += 2;
|
|
185
|
+
if (assets.configPath) score += 2;
|
|
186
|
+
if (assets.counts.rules > 0) score += 1;
|
|
187
|
+
if (assets.counts.hooks > 0) score += 1;
|
|
188
|
+
if (assets.counts.skills > 0) score += 1;
|
|
189
|
+
if (assets.counts.agents > 0) score += 1;
|
|
190
|
+
if (assets.counts.workflows > 0) score += 1;
|
|
191
|
+
if (assets.counts.mcpServers > 0) score += 1;
|
|
192
|
+
|
|
193
|
+
if (score === 0) return 'none';
|
|
194
|
+
if (score <= 2) return 'starter';
|
|
195
|
+
if (score <= 5) return 'developing';
|
|
196
|
+
return 'mature';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let score = 0;
|
|
200
|
+
if (assets.files.claudeMd) score += 2;
|
|
201
|
+
if (assets.files.settings) score += 1;
|
|
202
|
+
if (assets.counts.rules > 0) score += 1;
|
|
203
|
+
if (assets.counts.commands > 0) score += 1;
|
|
204
|
+
if (assets.counts.hooks > 0) score += 1;
|
|
205
|
+
if (assets.counts.agents > 0) score += 1;
|
|
206
|
+
if (assets.counts.skills > 0) score += 1;
|
|
207
|
+
|
|
208
|
+
if (score === 0) return 'none';
|
|
209
|
+
if (score <= 2) return 'starter';
|
|
210
|
+
if (score <= 5) return 'developing';
|
|
211
|
+
return 'mature';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function riskFromImpact(impact) {
|
|
215
|
+
if (impact === 'critical') return 'high';
|
|
216
|
+
if (impact === 'high') return 'medium';
|
|
217
|
+
return 'low';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function moduleFromCategory(category) {
|
|
221
|
+
const map = {
|
|
222
|
+
memory: 'CLAUDE.md',
|
|
223
|
+
instructions: 'AGENTS.md / instructions',
|
|
224
|
+
config: 'config.toml',
|
|
225
|
+
trust: 'trust-and-safety',
|
|
226
|
+
rules: 'rules',
|
|
227
|
+
hooks: 'hooks',
|
|
228
|
+
mcp: 'mcp',
|
|
229
|
+
skills: 'skills',
|
|
230
|
+
agents: 'subagents',
|
|
231
|
+
review: 'review',
|
|
232
|
+
automation: 'automation',
|
|
233
|
+
local: 'local-environments',
|
|
234
|
+
quality: 'verification',
|
|
235
|
+
git: 'safety',
|
|
236
|
+
workflow: 'commands-agents-skills',
|
|
237
|
+
security: 'permissions',
|
|
238
|
+
automation: 'hooks',
|
|
239
|
+
design: 'design-rules',
|
|
240
|
+
devops: 'ci-devops',
|
|
241
|
+
hygiene: 'project-hygiene',
|
|
242
|
+
performance: 'context-management',
|
|
243
|
+
tools: 'mcp-tools',
|
|
244
|
+
prompting: 'prompt-structure',
|
|
245
|
+
features: 'modern-claude-features',
|
|
246
|
+
'quality-deep': 'quality-deep',
|
|
247
|
+
};
|
|
248
|
+
return map[category] || category;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const STRENGTH_REASONS = {
|
|
252
|
+
claudeMd: 'Foundation of Claude workflow. Every session benefits from this.',
|
|
253
|
+
mermaidArchitecture: 'Architecture diagram saves 73% tokens vs prose — high-value asset.',
|
|
254
|
+
verificationLoop: 'Claude can self-verify, catching errors before human review.',
|
|
255
|
+
hooks: 'Automated enforcement (100% vs 80% from instructions alone).',
|
|
256
|
+
hooksInSettings: 'Hook registration in settings ensures consistent automation.',
|
|
257
|
+
preToolUseHook: 'Pre-execution validation adds a safety layer.',
|
|
258
|
+
postToolUseHook: 'Post-execution automation catches issues immediately.',
|
|
259
|
+
sessionStartHook: 'Session initialization ensures consistent starting state.',
|
|
260
|
+
customCommands: 'Reusable workflows encoded as one-liner commands.',
|
|
261
|
+
settingsPermissions: 'Explicit permissions prevent accidental dangerous operations.',
|
|
262
|
+
permissionDeny: 'Deny rules block risky operations at the system level.',
|
|
263
|
+
pathRules: 'Scoped rules ensure different code areas get appropriate guidance.',
|
|
264
|
+
fewShotExamples: 'Code examples guide Claude to match your conventions.',
|
|
265
|
+
constraintBlocks: 'XML constraint blocks improve rule adherence by 40%.',
|
|
266
|
+
xmlTags: 'Structured prompt sections improve consistency.',
|
|
267
|
+
context7Mcp: 'Real-time docs eliminate version-mismatch hallucinations.',
|
|
268
|
+
mcpServers: 'External tool integration extends Claude capabilities.',
|
|
269
|
+
compactionAwareness: 'Context management keeps sessions efficient.',
|
|
270
|
+
agents: 'Specialized agents delegate complex tasks effectively.',
|
|
271
|
+
noSecretsInClaude: 'No secrets in config — good security hygiene.',
|
|
272
|
+
gitIgnoreEnv: 'Environment files are properly excluded from git.',
|
|
273
|
+
codexAgentsMd: 'Codex has a repo-native instruction surface instead of starting cold.',
|
|
274
|
+
codexAgentsMdSubstantive: 'A substantive AGENTS.md reduces drift and gives Codex a stable repo contract.',
|
|
275
|
+
codexAgentsVerificationCommands: 'Codex can verify its changes because the repo states how to test and build.',
|
|
276
|
+
codexAgentsArchitecture: 'Codex has a repo map to orient itself before editing.',
|
|
277
|
+
codexConfigExists: 'Codex runtime posture is reviewable because the project config is versioned.',
|
|
278
|
+
codexModelExplicit: 'The primary Codex model is explicit instead of silently inheriting defaults.',
|
|
279
|
+
codexReasoningEffortExplicit: 'Reasoning depth is explicit and reviewable.',
|
|
280
|
+
codexWeakTaskModelExplicit: 'Delegation for weaker tasks is explicit and cost-aware.',
|
|
281
|
+
codexApprovalPolicyExplicit: 'Approval behavior is explicit, predictable, and reviewable.',
|
|
282
|
+
codexSandboxExplicit: 'Sandbox posture is explicit instead of accidental.',
|
|
283
|
+
codexHistorySendToServerExplicit: 'History sync posture is reviewable in version control.',
|
|
284
|
+
codexRulesForRiskyCommands: 'Risky command classes are governed by Codex-native rules.',
|
|
285
|
+
codexHooksFeatureExplicit: 'Hook posture is explicit instead of implied.',
|
|
286
|
+
codexMcpExternalToolsConfigured: 'Codex has live MCP context instead of relying only on static repo files.',
|
|
287
|
+
codexSkillsDirPresentWhenUsed: 'Repo-local skills keep specialization versioned and reviewable.',
|
|
288
|
+
codexSkillsHaveMetadata: 'Skill metadata is explicit enough for reliable invocation.',
|
|
289
|
+
codexCustomAgentsRequiredFields: 'Custom subagents are structured and reviewable.',
|
|
290
|
+
codexExecUsageSafe: 'Codex automation posture is documented and safer to operate.',
|
|
291
|
+
codexGitHubActionSafeStrategy: 'CI posture is explicit and safer for Codex in automation.',
|
|
292
|
+
codexReviewWorkflowDocumented: 'A documented review path makes risky Codex changes easier to control.',
|
|
293
|
+
codexArtifactsSharedIntentionally: 'Codex repo artifacts are shared intentionally instead of being hidden from the team.',
|
|
294
|
+
codexAgentsMentionModernFeatures: 'AGENTS.md acknowledges the modern Codex surfaces the repo actually uses.',
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
function toStrengths(results) {
|
|
298
|
+
return results
|
|
299
|
+
.filter(r => r.passed === true)
|
|
300
|
+
.sort((a, b) => {
|
|
301
|
+
const order = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
302
|
+
return (order[b.impact] || 0) - (order[a.impact] || 0);
|
|
303
|
+
})
|
|
304
|
+
.slice(0, 8)
|
|
305
|
+
.map(r => ({
|
|
306
|
+
key: r.key,
|
|
307
|
+
name: r.name,
|
|
308
|
+
category: r.category,
|
|
309
|
+
why: STRENGTH_REASONS[r.key] || `Already configured and working: ${r.name}.`,
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const GAP_REASONS = {
|
|
314
|
+
noBypassPermissions: 'bypassPermissions skips all safety checks. Use explicit allow rules for control without risk.',
|
|
315
|
+
secretsProtection: 'Without deny rules for .env, Claude can read secrets and potentially expose them in outputs.',
|
|
316
|
+
testCommand: 'Without a test command, Claude cannot verify its changes work before you review them.',
|
|
317
|
+
lintCommand: 'Without a lint command, Claude may produce inconsistently formatted code.',
|
|
318
|
+
buildCommand: 'Without a build command, Claude cannot catch compilation errors early.',
|
|
319
|
+
ciPipeline: 'CI ensures every change is automatically tested. Without it, bugs reach main branch faster.',
|
|
320
|
+
securityReview: 'Claude Code has built-in OWASP Top 10 scanning. Not using it leaves vulnerabilities undetected.',
|
|
321
|
+
skills: 'Skills encode domain expertise as reusable components. Without them, you repeat context every session.',
|
|
322
|
+
multipleAgents: 'Multiple agents enable parallel specialized work (security review + code writing simultaneously).',
|
|
323
|
+
multipleMcpServers: 'More MCP servers give Claude access to more external context (docs, databases, APIs).',
|
|
324
|
+
roleDefinition: 'A role definition helps Claude calibrate response depth and technical level.',
|
|
325
|
+
importSyntax: '@import keeps CLAUDE.md lean while still providing deep instructions in focused modules.',
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
function toGaps(results) {
|
|
329
|
+
return results
|
|
330
|
+
.filter(r => r.passed === false)
|
|
331
|
+
.sort((a, b) => {
|
|
332
|
+
const order = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
333
|
+
return (order[b.impact] || 0) - (order[a.impact] || 0);
|
|
334
|
+
})
|
|
335
|
+
.slice(0, 8)
|
|
336
|
+
.map(r => ({
|
|
337
|
+
key: r.key,
|
|
338
|
+
name: r.name,
|
|
339
|
+
impact: r.impact,
|
|
340
|
+
category: r.category,
|
|
341
|
+
fix: r.fix,
|
|
342
|
+
why: GAP_REASONS[r.key] || r.fix,
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function toRecommendations(auditResult) {
|
|
347
|
+
const failed = auditResult.results.filter(r => r.passed === false);
|
|
348
|
+
const topActionOrder = new Map((auditResult.topNextActions || []).map((item, index) => [item.key, index]));
|
|
349
|
+
failed.sort((a, b) => {
|
|
350
|
+
const rankedA = topActionOrder.has(a.key) ? topActionOrder.get(a.key) : Number.MAX_SAFE_INTEGER;
|
|
351
|
+
const rankedB = topActionOrder.has(b.key) ? topActionOrder.get(b.key) : Number.MAX_SAFE_INTEGER;
|
|
352
|
+
if (rankedA !== rankedB) return rankedA - rankedB;
|
|
353
|
+
const order = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
354
|
+
return (order[b.impact] || 0) - (order[a.impact] || 0);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return failed.slice(0, 10).map((r, index) => ({
|
|
358
|
+
priority: index + 1,
|
|
359
|
+
key: r.key,
|
|
360
|
+
name: r.name,
|
|
361
|
+
impact: r.impact,
|
|
362
|
+
module: moduleFromCategory(r.category),
|
|
363
|
+
risk: riskFromImpact(r.impact),
|
|
364
|
+
why: r.fix,
|
|
365
|
+
evidenceClass: (auditResult.topNextActions || []).find(item => item.key === r.key)?.evidenceClass || 'estimated',
|
|
366
|
+
rankingAdjustment: (auditResult.topNextActions || []).find(item => item.key === r.key)?.rankingAdjustment || 0,
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function buildOptionalModules(platform, stacks, assets, recommendedDomainPacks = []) {
|
|
371
|
+
if (platform === 'codex') {
|
|
372
|
+
const modules = [];
|
|
373
|
+
|
|
374
|
+
if (!assets.instructionPath) modules.push('AGENTS.md baseline');
|
|
375
|
+
if (!assets.configPath) modules.push('Codex config baseline');
|
|
376
|
+
if (assets.counts.rules === 0) modules.push('Codex rules baseline');
|
|
377
|
+
if (assets.counts.hooks === 0) modules.push('Hooks scaffold');
|
|
378
|
+
if (assets.counts.skills === 0) modules.push('Repo-local skills starter');
|
|
379
|
+
if (assets.counts.agents === 0) modules.push('Subagents starter');
|
|
380
|
+
if (assets.counts.mcpServers === 0) modules.push('MCP baseline');
|
|
381
|
+
if (assets.counts.workflows === 0) modules.push('CI / review workflow starter');
|
|
382
|
+
for (const pack of recommendedDomainPacks) {
|
|
383
|
+
for (const moduleName of pack.recommendedModules || []) {
|
|
384
|
+
modules.push(moduleName);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return [...new Set(modules)].slice(0, 8);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const stackKeys = stacks.map(s => s.key);
|
|
392
|
+
const modules = [];
|
|
393
|
+
|
|
394
|
+
if (!assets.files.claudeMd) modules.push('CLAUDE.md baseline');
|
|
395
|
+
if (assets.counts.commands === 0) modules.push('Slash commands');
|
|
396
|
+
if (assets.counts.hooks === 0) modules.push('Hooks automation');
|
|
397
|
+
if (!assets.permissions || !assets.permissions.hasDenyRules) modules.push('Permission safety profile');
|
|
398
|
+
if (assets.counts.rules === 0) modules.push('Path-specific rules');
|
|
399
|
+
if (stackKeys.some(k => ['react', 'nextjs', 'vue', 'angular', 'svelte'].includes(k))) modules.push('Frontend pack');
|
|
400
|
+
if (stackKeys.some(k => ['node', 'python', 'django', 'fastapi', 'go', 'rust', 'java'].includes(k))) modules.push('Backend pack');
|
|
401
|
+
if (stackKeys.some(k => ['docker', 'terraform', 'kubernetes'].includes(k))) modules.push('DevOps pack');
|
|
402
|
+
if (assets.counts.agents === 0) modules.push('Specialized agents');
|
|
403
|
+
|
|
404
|
+
return [...new Set(modules)].slice(0, 8);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function buildRiskNotes(platform, auditResult, assets, maturity) {
|
|
408
|
+
if (platform === 'codex') {
|
|
409
|
+
const notes = [];
|
|
410
|
+
if (!assets.instructionPath) notes.push('No AGENTS.md exists yet, so Codex starts without repo-specific instructions.');
|
|
411
|
+
if (!assets.configPath) notes.push('No .codex/config.toml exists yet, so approval, sandbox, and history posture are implicit.');
|
|
412
|
+
if (assets.trust && assets.trust.approvalPolicy === 'never') {
|
|
413
|
+
notes.push('approval_policy is set to `never`; make sure that autonomy level is truly intended for this repo.');
|
|
414
|
+
}
|
|
415
|
+
if (assets.trust && assets.trust.sandboxMode === 'danger-full-access') {
|
|
416
|
+
notes.push('sandbox_mode is `danger-full-access`, which removes Codex runtime guardrails and should stay exceptional.');
|
|
417
|
+
}
|
|
418
|
+
if (assets.counts.mcpServers > 0 && assets.trust && !assets.trust.isTrustedProject) {
|
|
419
|
+
notes.push('This repo appears to rely on project-scoped MCP, but the project trust path is not clearly established.');
|
|
420
|
+
}
|
|
421
|
+
if (maturity === 'mature') {
|
|
422
|
+
notes.push('This repo already has meaningful Codex assets, so advisory mode should preserve and extend them instead of flattening them.');
|
|
423
|
+
}
|
|
424
|
+
for (const caveat of auditResult.platformCaveats || []) {
|
|
425
|
+
if (caveat && caveat.message) {
|
|
426
|
+
notes.push(caveat.message);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return [...new Set(notes)].slice(0, 5);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const notes = [];
|
|
433
|
+
if (!assets.files.claudeMd) notes.push('No CLAUDE.md exists yet, so Claude has no persistent project-specific guidance.');
|
|
434
|
+
if (assets.permissions && assets.permissions.defaultMode === 'bypassPermissions') {
|
|
435
|
+
notes.push('Current settings use bypassPermissions, which is risky for broader team adoption.');
|
|
436
|
+
}
|
|
437
|
+
if (!assets.permissions || !assets.permissions.hasDenyRules) {
|
|
438
|
+
notes.push('Permissions lack deny rules, so secret access and destructive commands are not strongly guarded.');
|
|
439
|
+
}
|
|
440
|
+
if (maturity === 'mature') {
|
|
441
|
+
notes.push('This repo already has meaningful Claude assets, so augment mode should preserve existing structure instead of overwriting it.');
|
|
442
|
+
}
|
|
443
|
+
if (auditResult.results.some(r => r.key === 'ciPipeline' && r.passed === false)) {
|
|
444
|
+
notes.push('Without CI enforcement, readiness can drift after setup.');
|
|
445
|
+
}
|
|
446
|
+
return notes.slice(0, 5);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function buildRolloutOrder(report) {
|
|
450
|
+
if (report.platform === 'codex') {
|
|
451
|
+
const steps = [];
|
|
452
|
+
if (!report.existingPlatformAssets.instructionPath) steps.push('Create a project-specific AGENTS.md baseline');
|
|
453
|
+
if (!report.existingPlatformAssets.configPath) steps.push('Create a safe `.codex/config.toml` baseline with explicit trust settings');
|
|
454
|
+
if (report.recommendedDomainPacks.length > 0) {
|
|
455
|
+
steps.push(`Start from the ${report.recommendedDomainPacks.map((pack) => pack.label).join(' + ')} pack guidance before adding optional Codex surfaces`);
|
|
456
|
+
}
|
|
457
|
+
if (report.gapsIdentified.some(g => g.category === 'trust' || g.category === 'config')) steps.push('Make approval, sandbox, history, and network posture explicit');
|
|
458
|
+
if (report.gapsIdentified.some(g => g.category === 'rules')) steps.push('Add Codex rules for risky command classes before expanding automation');
|
|
459
|
+
if (report.gapsIdentified.some(g => g.category === 'mcp')) steps.push('Add MCP only where the repo really needs live external context and the trust boundary is clear');
|
|
460
|
+
if (report.gapsIdentified.some(g => g.category === 'skills' || g.category === 'agents')) steps.push('Add skills and subagents only after the baseline contract is stable');
|
|
461
|
+
if (report.gapsIdentified.some(g => g.category === 'review' || g.category === 'automation')) steps.push('Add review and CI automation after local verification is explicit');
|
|
462
|
+
return steps.length > 0 ? steps : ['Preserve the current Codex baseline and tighten remaining quality-deep items'];
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const steps = [];
|
|
466
|
+
if (!report.existingClaudeAssets.claudeMd) steps.push('Create a project-specific CLAUDE.md baseline');
|
|
467
|
+
if (report.gapsIdentified.some(g => g.category === 'security')) steps.push('Add safe settings and deny rules');
|
|
468
|
+
if (report.gapsIdentified.some(g => g.category === 'automation')) steps.push('Add hooks and automate verification');
|
|
469
|
+
if (report.gapsIdentified.some(g => g.category === 'workflow')) steps.push('Add commands, rules, and specialization modules');
|
|
470
|
+
if (report.gapsIdentified.some(g => g.category === 'devops')) steps.push('Connect CI threshold enforcement');
|
|
471
|
+
if (steps.length === 0) steps.push('Tighten quality-deep items and preserve the current setup');
|
|
472
|
+
return steps;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Analyze a project's Claude Code setup and produce a structured recommendation report.
|
|
477
|
+
* @param {Object} options - Analysis options.
|
|
478
|
+
* @param {string} options.dir - Project directory to analyze.
|
|
479
|
+
* @param {string} [options.mode='augment'] - Analysis mode ('augment' or 'suggest-only').
|
|
480
|
+
* @returns {Promise<Object>} Structured report with project summary, gaps, strengths, and recommendations.
|
|
481
|
+
*/
|
|
482
|
+
async function analyzeProject(options) {
|
|
483
|
+
const mode = options.mode || 'augment';
|
|
484
|
+
const platform = options.platform === 'codex' ? 'codex' : 'claude';
|
|
485
|
+
const platformLabel = platform === 'codex' ? 'Codex' : 'Claude';
|
|
486
|
+
const ContextClass = platform === 'codex' ? CodexProjectContext : ProjectContext;
|
|
487
|
+
const ctx = new ContextClass(options.dir);
|
|
488
|
+
const stacks = ctx.detectStacks(STACKS);
|
|
489
|
+
const auditResult = await audit({ ...options, silent: true, platform });
|
|
490
|
+
const assets = platform === 'codex' ? collectCodexAssets(ctx) : collectClaudeAssets(ctx);
|
|
491
|
+
const metadata = detectProjectMetadata(ctx);
|
|
492
|
+
const maturity = detectMaturity(platform, assets);
|
|
493
|
+
const mainDirs = detectMainDirs(ctx);
|
|
494
|
+
const recommendedDomainPacks = platform === 'codex'
|
|
495
|
+
? detectCodexDomainPacks(ctx, stacks, assets)
|
|
496
|
+
: detectDomainPacks(ctx, stacks, assets);
|
|
497
|
+
const recommendedMcpPacks = platform === 'claude' ? recommendMcpPacks(stacks, recommendedDomainPacks, { ctx, assets }) : [];
|
|
498
|
+
|
|
499
|
+
const report = {
|
|
500
|
+
platform,
|
|
501
|
+
platformLabel,
|
|
502
|
+
mode,
|
|
503
|
+
writeBehavior: 'No files are written in this mode.',
|
|
504
|
+
projectSummary: {
|
|
505
|
+
name: metadata.name,
|
|
506
|
+
description: metadata.description,
|
|
507
|
+
directory: options.dir,
|
|
508
|
+
stacks: stacks.map(s => s.label),
|
|
509
|
+
domains: recommendedDomainPacks.map(pack => pack.label),
|
|
510
|
+
maturity,
|
|
511
|
+
score: auditResult.score,
|
|
512
|
+
organicScore: auditResult.organicScore,
|
|
513
|
+
checkCount: auditResult.checkCount,
|
|
514
|
+
},
|
|
515
|
+
platformScopeNote: auditResult.platformScopeNote || null,
|
|
516
|
+
platformCaveats: auditResult.platformCaveats || [],
|
|
517
|
+
detectedArchitecture: {
|
|
518
|
+
repoType: stacks.length > 0 ? 'stack-detected repo' : 'generic repo',
|
|
519
|
+
mainDirectories: mainDirs,
|
|
520
|
+
stackSignals: stacks.map(s => s.key),
|
|
521
|
+
},
|
|
522
|
+
existingPlatformAssets: assets,
|
|
523
|
+
strengthsPreserved: toStrengths(auditResult.results),
|
|
524
|
+
gapsIdentified: toGaps(auditResult.results),
|
|
525
|
+
topNextActions: auditResult.topNextActions || auditResult.quickWins,
|
|
526
|
+
recommendedImprovements: toRecommendations(auditResult),
|
|
527
|
+
recommendedDomainPacks,
|
|
528
|
+
recommendedMcpPacks,
|
|
529
|
+
riskNotes: buildRiskNotes(platform, auditResult, assets, maturity),
|
|
530
|
+
optionalModules: buildOptionalModules(platform, stacks, assets, recommendedDomainPacks),
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
if (platform === 'claude') {
|
|
534
|
+
report.existingClaudeAssets = {
|
|
535
|
+
claudeMd: assets.files.claudeMd,
|
|
536
|
+
settings: assets.settingsSource,
|
|
537
|
+
commands: assets.files.commands,
|
|
538
|
+
rules: assets.files.rules,
|
|
539
|
+
hooks: assets.files.hooks,
|
|
540
|
+
agents: assets.files.agents,
|
|
541
|
+
skills: assets.files.skills,
|
|
542
|
+
mcpServers: assets.counts.mcpServers,
|
|
543
|
+
};
|
|
544
|
+
} else {
|
|
545
|
+
report.existingCodexAssets = {
|
|
546
|
+
agentsMd: assets.instructionPath,
|
|
547
|
+
config: assets.configPath,
|
|
548
|
+
rules: assets.files.rules,
|
|
549
|
+
hooks: assets.files.hooks,
|
|
550
|
+
skills: assets.files.skills,
|
|
551
|
+
agents: assets.files.agents,
|
|
552
|
+
workflows: assets.files.workflows,
|
|
553
|
+
mcpServers: assets.counts.mcpServers,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
report.suggestedRolloutOrder = buildRolloutOrder(report);
|
|
558
|
+
return report;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function printAnalysis(report, options = {}) {
|
|
562
|
+
if (options.json) {
|
|
563
|
+
console.log(JSON.stringify(report, null, 2));
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const modeLabel = report.mode === 'suggest-only' ? 'suggest-only' : report.mode;
|
|
568
|
+
console.log('');
|
|
569
|
+
console.log(c(` nerviq ${report.platform === 'codex' ? 'codex ' : ''}${modeLabel}`, 'bold'));
|
|
570
|
+
console.log(c(' ═══════════════════════════════════════', 'dim'));
|
|
571
|
+
console.log(c(` ${report.writeBehavior}`, 'dim'));
|
|
572
|
+
if (report.platformScopeNote) {
|
|
573
|
+
console.log(c(` ${report.platformScopeNote.message}`, 'dim'));
|
|
574
|
+
}
|
|
575
|
+
console.log('');
|
|
576
|
+
|
|
577
|
+
console.log(c(' Project Summary', 'blue'));
|
|
578
|
+
console.log(` ${report.projectSummary.name}${report.projectSummary.description ? ` — ${report.projectSummary.description}` : ''}`);
|
|
579
|
+
console.log(c(` Stack: ${report.projectSummary.stacks.join(', ') || 'Unknown'}`, 'dim'));
|
|
580
|
+
if (report.platform === 'claude') {
|
|
581
|
+
console.log(c(` Domain packs: ${report.projectSummary.domains.join(', ') || 'Baseline General'}`, 'dim'));
|
|
582
|
+
} else {
|
|
583
|
+
console.log(c(` Platform: ${report.platformLabel}`, 'dim'));
|
|
584
|
+
}
|
|
585
|
+
console.log(c(` Maturity: ${report.projectSummary.maturity} | Score: ${report.projectSummary.score}/100 | Organic: ${report.projectSummary.organicScore}/100`, 'dim'));
|
|
586
|
+
console.log('');
|
|
587
|
+
|
|
588
|
+
console.log(c(' Detected Architecture', 'blue'));
|
|
589
|
+
console.log(c(` Main directories: ${report.detectedArchitecture.mainDirectories.join(', ') || 'No strong structure detected yet'}`, 'dim'));
|
|
590
|
+
console.log('');
|
|
591
|
+
|
|
592
|
+
console.log(c(` Existing ${report.existingPlatformAssets.label} Assets`, 'blue'));
|
|
593
|
+
console.log(c(` ${report.existingPlatformAssets.instructionLabel}: ${report.existingPlatformAssets.instructionPath || 'missing'}`, 'dim'));
|
|
594
|
+
console.log(c(` ${report.existingPlatformAssets.configLabel}: ${report.existingPlatformAssets.configPath || 'missing'}`, 'dim'));
|
|
595
|
+
console.log(c(` ${report.existingPlatformAssets.summaryLine}`, 'dim'));
|
|
596
|
+
if (report.platform === 'codex' && report.existingPlatformAssets.trust) {
|
|
597
|
+
const trustBits = [
|
|
598
|
+
`Approval: ${report.existingPlatformAssets.trust.approvalPolicy || 'implicit'}`,
|
|
599
|
+
`Sandbox: ${report.existingPlatformAssets.trust.sandboxMode || 'implicit'}`,
|
|
600
|
+
`Trusted path: ${report.existingPlatformAssets.trust.isTrustedProject ? 'yes' : 'no'}`,
|
|
601
|
+
];
|
|
602
|
+
console.log(c(` ${trustBits.join(' | ')}`, 'dim'));
|
|
603
|
+
}
|
|
604
|
+
console.log('');
|
|
605
|
+
|
|
606
|
+
if (report.strengthsPreserved.length > 0) {
|
|
607
|
+
console.log(c(' Strengths Preserved', 'green'));
|
|
608
|
+
for (const item of report.strengthsPreserved) {
|
|
609
|
+
console.log(` ${c('✓', 'green')} ${item.name}`);
|
|
610
|
+
if (item.why) {
|
|
611
|
+
console.log(c(` ${item.why}`, 'dim'));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
console.log('');
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (report.gapsIdentified.length > 0) {
|
|
618
|
+
console.log(c(' Gaps Identified', 'yellow'));
|
|
619
|
+
for (const item of report.gapsIdentified.slice(0, 5)) {
|
|
620
|
+
console.log(` - [${item.impact}] ${item.name}`);
|
|
621
|
+
console.log(c(` ${item.fix}`, 'dim'));
|
|
622
|
+
}
|
|
623
|
+
console.log('');
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (report.topNextActions.length > 0) {
|
|
627
|
+
console.log(c(' Top 5 Next Actions', 'magenta'));
|
|
628
|
+
report.topNextActions.slice(0, 5).forEach((item, index) => {
|
|
629
|
+
console.log(` ${index + 1}. ${item.name}`);
|
|
630
|
+
console.log(c(` Why: ${item.why || item.fix}`, 'dim'));
|
|
631
|
+
if (Array.isArray(item.signals) && item.signals.length > 0) {
|
|
632
|
+
console.log(c(` Trace: ${item.signals.join(' | ')}`, 'dim'));
|
|
633
|
+
}
|
|
634
|
+
if (item.risk || item.confidence) {
|
|
635
|
+
console.log(c(` Risk: ${item.risk || 'low'} | Confidence: ${item.confidence || 'medium'}`, 'dim'));
|
|
636
|
+
}
|
|
637
|
+
if (item.fix && item.fix !== item.why) {
|
|
638
|
+
console.log(c(` Fix: ${item.fix}`, 'dim'));
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
console.log('');
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (report.recommendedDomainPacks.length > 0) {
|
|
645
|
+
console.log(c(' Recommended Domain Packs', 'blue'));
|
|
646
|
+
for (const pack of report.recommendedDomainPacks) {
|
|
647
|
+
console.log(` - ${pack.label}`);
|
|
648
|
+
console.log(c(` ${pack.useWhen}`, 'dim'));
|
|
649
|
+
}
|
|
650
|
+
console.log('');
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (report.recommendedMcpPacks.length > 0) {
|
|
654
|
+
console.log(c(' Recommended MCP Packs', 'blue'));
|
|
655
|
+
for (const pack of report.recommendedMcpPacks) {
|
|
656
|
+
console.log(` - ${pack.label}`);
|
|
657
|
+
console.log(c(` ${pack.adoption}`, 'dim'));
|
|
658
|
+
}
|
|
659
|
+
console.log('');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (report.platformCaveats && report.platformCaveats.length > 0) {
|
|
663
|
+
console.log(c(' Platform Caveats', 'yellow'));
|
|
664
|
+
for (const item of report.platformCaveats) {
|
|
665
|
+
console.log(` - ${item.title}`);
|
|
666
|
+
console.log(c(` ${item.message}`, 'dim'));
|
|
667
|
+
}
|
|
668
|
+
console.log('');
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (report.riskNotes.length > 0) {
|
|
672
|
+
console.log(c(' Risk Notes', 'red'));
|
|
673
|
+
for (const note of report.riskNotes) {
|
|
674
|
+
console.log(` - ${note}`);
|
|
675
|
+
}
|
|
676
|
+
console.log('');
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (report.optionalModules.length > 0) {
|
|
680
|
+
console.log(c(' Optional Modules', 'blue'));
|
|
681
|
+
console.log(c(` ${report.optionalModules.join(' | ')}`, 'dim'));
|
|
682
|
+
console.log('');
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (report.suggestedRolloutOrder.length > 0) {
|
|
686
|
+
console.log(c(' Suggested Rollout Order', 'blue'));
|
|
687
|
+
report.suggestedRolloutOrder.forEach((item, index) => {
|
|
688
|
+
console.log(` ${index + 1}. ${item}`);
|
|
689
|
+
});
|
|
690
|
+
console.log('');
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Export an analysis report as a formatted markdown string.
|
|
696
|
+
* @param {Object} report - The report object returned by analyzeProject().
|
|
697
|
+
* @returns {string} Markdown-formatted report content.
|
|
698
|
+
*/
|
|
699
|
+
function exportMarkdown(report) {
|
|
700
|
+
const lines = [];
|
|
701
|
+
lines.push(`# Claudex Setup Analysis Report`);
|
|
702
|
+
lines.push(`## ${report.platformLabel} ${report.mode === 'suggest-only' ? 'Suggest-Only' : 'Augment'} Mode`);
|
|
703
|
+
lines.push('');
|
|
704
|
+
lines.push(`**Project:** ${report.projectSummary.name}${report.projectSummary.description ? ` — ${report.projectSummary.description}` : ''}`);
|
|
705
|
+
lines.push(`**Date:** ${new Date().toISOString().split('T')[0]}`);
|
|
706
|
+
lines.push(`**Platform:** ${report.platformLabel}`);
|
|
707
|
+
lines.push(`**Score:** ${report.projectSummary.score}/100 | **Organic:** ${report.projectSummary.organicScore}/100`);
|
|
708
|
+
lines.push(`**Stacks:** ${report.projectSummary.stacks.join(', ') || 'None detected'}`);
|
|
709
|
+
if (report.platform === 'claude') {
|
|
710
|
+
lines.push(`**Domain Packs:** ${report.projectSummary.domains.join(', ') || 'Baseline General'}`);
|
|
711
|
+
}
|
|
712
|
+
lines.push(`**Maturity:** ${report.projectSummary.maturity}`);
|
|
713
|
+
lines.push('');
|
|
714
|
+
|
|
715
|
+
if (report.platformScopeNote) {
|
|
716
|
+
lines.push(`> ${report.platformScopeNote.message}`);
|
|
717
|
+
lines.push('');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
lines.push(`## Existing ${report.existingPlatformAssets.label} Assets`);
|
|
721
|
+
lines.push('');
|
|
722
|
+
lines.push(`- **${report.existingPlatformAssets.instructionLabel}:** ${report.existingPlatformAssets.instructionPath || 'missing'}`);
|
|
723
|
+
lines.push(`- **${report.existingPlatformAssets.configLabel}:** ${report.existingPlatformAssets.configPath || 'missing'}`);
|
|
724
|
+
lines.push(`- **Summary:** ${report.existingPlatformAssets.summaryLine}`);
|
|
725
|
+
if (report.platform === 'codex' && report.existingPlatformAssets.trust) {
|
|
726
|
+
lines.push(`- **Approval policy:** ${report.existingPlatformAssets.trust.approvalPolicy || 'implicit'}`);
|
|
727
|
+
lines.push(`- **Sandbox mode:** ${report.existingPlatformAssets.trust.sandboxMode || 'implicit'}`);
|
|
728
|
+
lines.push(`- **Trusted project path:** ${report.existingPlatformAssets.trust.isTrustedProject ? 'yes' : 'no'}`);
|
|
729
|
+
}
|
|
730
|
+
lines.push('');
|
|
731
|
+
|
|
732
|
+
if (report.strengthsPreserved.length > 0) {
|
|
733
|
+
lines.push('## Strengths Preserved');
|
|
734
|
+
lines.push('');
|
|
735
|
+
for (const item of report.strengthsPreserved) {
|
|
736
|
+
lines.push(`- **${item.name}** — ${item.why || 'Already configured.'}`);
|
|
737
|
+
}
|
|
738
|
+
lines.push('');
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
if (report.gapsIdentified.length > 0) {
|
|
742
|
+
lines.push('## Gaps Identified');
|
|
743
|
+
lines.push('');
|
|
744
|
+
lines.push('| Gap | Impact | Fix |');
|
|
745
|
+
lines.push('|-----|--------|-----|');
|
|
746
|
+
for (const item of report.gapsIdentified) {
|
|
747
|
+
lines.push(`| ${item.name} | ${item.impact} | ${item.fix} |`);
|
|
748
|
+
}
|
|
749
|
+
lines.push('');
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (report.topNextActions.length > 0) {
|
|
753
|
+
lines.push('## Top Next Actions');
|
|
754
|
+
lines.push('');
|
|
755
|
+
report.topNextActions.slice(0, 5).forEach((item, index) => {
|
|
756
|
+
lines.push(`${index + 1}. **${item.name}**`);
|
|
757
|
+
lines.push(` - Why: ${item.why || item.fix}`);
|
|
758
|
+
if (Array.isArray(item.signals) && item.signals.length > 0) {
|
|
759
|
+
lines.push(` - Trace: ${item.signals.join(' | ')}`);
|
|
760
|
+
}
|
|
761
|
+
if (item.risk || item.confidence) {
|
|
762
|
+
lines.push(` - Risk / Confidence: ${item.risk || 'low'} / ${item.confidence || 'medium'}`);
|
|
763
|
+
}
|
|
764
|
+
if (item.fix && item.fix !== item.why) {
|
|
765
|
+
lines.push(` - Fix: ${item.fix}`);
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
lines.push('');
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (report.recommendedDomainPacks.length > 0) {
|
|
772
|
+
lines.push('## Recommended Domain Packs');
|
|
773
|
+
lines.push('');
|
|
774
|
+
for (const pack of report.recommendedDomainPacks) {
|
|
775
|
+
lines.push(`- **${pack.label}**: ${pack.useWhen}`);
|
|
776
|
+
}
|
|
777
|
+
lines.push('');
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (report.recommendedMcpPacks.length > 0) {
|
|
781
|
+
lines.push('## Recommended MCP Packs');
|
|
782
|
+
lines.push('');
|
|
783
|
+
for (const pack of report.recommendedMcpPacks) {
|
|
784
|
+
lines.push(`- **${pack.label}**: ${pack.useWhen}`);
|
|
785
|
+
}
|
|
786
|
+
lines.push('');
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (report.platformCaveats && report.platformCaveats.length > 0) {
|
|
790
|
+
lines.push('## Platform Caveats');
|
|
791
|
+
lines.push('');
|
|
792
|
+
for (const item of report.platformCaveats) {
|
|
793
|
+
lines.push(`- **${item.title}**: ${item.message}`);
|
|
794
|
+
}
|
|
795
|
+
lines.push('');
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if (report.riskNotes.length > 0) {
|
|
799
|
+
lines.push('## Risk Notes');
|
|
800
|
+
lines.push('');
|
|
801
|
+
for (const note of report.riskNotes) {
|
|
802
|
+
lines.push(`- ⚠️ ${note}`);
|
|
803
|
+
}
|
|
804
|
+
lines.push('');
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (report.suggestedRolloutOrder.length > 0) {
|
|
808
|
+
lines.push('## Suggested Rollout Order');
|
|
809
|
+
lines.push('');
|
|
810
|
+
report.suggestedRolloutOrder.forEach((item, index) => {
|
|
811
|
+
lines.push(`${index + 1}. ${item}`);
|
|
812
|
+
});
|
|
813
|
+
lines.push('');
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
lines.push('---');
|
|
817
|
+
lines.push(`*Generated by nerviq v${require('../package.json').version}*`);
|
|
818
|
+
return lines.join('\n');
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
module.exports = { analyzeProject, printAnalysis, exportMarkdown };
|