@nerviq/cli 1.20.1 → 1.22.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.
- package/LICENSE +23 -23
- package/README.md +20 -2
- package/bin/cli.js +3 -3
- package/package.json +1 -1
- package/src/activity.js +1039 -1039
- package/src/adoption-advisor.js +299 -299
- package/src/aider/config-parser.js +166 -166
- package/src/aider/context.js +4 -1
- package/src/aider/deep-review.js +316 -316
- package/src/aider/domain-packs.js +303 -303
- package/src/aider/freshness.js +93 -93
- package/src/aider/governance.js +253 -253
- package/src/aider/interactive.js +334 -334
- package/src/aider/mcp-packs.js +329 -329
- package/src/aider/patch.js +214 -214
- package/src/aider/plans.js +186 -186
- package/src/aider/premium.js +360 -360
- package/src/aider/setup.js +404 -404
- package/src/aider/techniques.js +312 -67
- package/src/analyze.js +951 -951
- package/src/anti-patterns.js +485 -485
- package/src/audit/instruction-files.js +180 -180
- package/src/audit/recommendations.js +577 -577
- package/src/audit.js +20 -0
- package/src/auto-suggest.js +154 -154
- package/src/badge.js +13 -13
- package/src/behavioral-drift.js +801 -801
- package/src/benchmark.js +67 -67
- package/src/catalog.js +103 -103
- package/src/certification.js +128 -128
- package/src/codex/config-parser.js +183 -183
- package/src/codex/context.js +223 -223
- package/src/codex/deep-review.js +493 -493
- package/src/codex/domain-packs.js +394 -394
- package/src/codex/freshness.js +84 -84
- package/src/codex/governance.js +192 -192
- package/src/codex/interactive.js +618 -618
- package/src/codex/mcp-packs.js +914 -914
- package/src/codex/patch.js +209 -209
- package/src/codex/plans.js +251 -251
- package/src/codex/premium.js +614 -614
- package/src/codex/setup.js +591 -591
- package/src/continuous-ops.js +681 -681
- package/src/copilot/activity.js +309 -309
- package/src/copilot/deep-review.js +346 -346
- package/src/copilot/domain-packs.js +372 -372
- package/src/copilot/freshness.js +57 -57
- package/src/copilot/governance.js +222 -222
- package/src/copilot/interactive.js +406 -406
- package/src/copilot/mcp-packs.js +826 -826
- package/src/copilot/plans.js +253 -253
- package/src/copilot/premium.js +451 -451
- package/src/copilot/setup.js +488 -488
- package/src/cost-tracking.js +61 -61
- package/src/cursor/activity.js +301 -301
- package/src/cursor/config-parser.js +265 -265
- package/src/cursor/context.js +256 -256
- package/src/cursor/deep-review.js +334 -334
- package/src/cursor/domain-packs.js +368 -368
- package/src/cursor/freshness.js +65 -65
- package/src/cursor/governance.js +229 -229
- package/src/cursor/interactive.js +391 -391
- package/src/cursor/mcp-packs.js +828 -828
- package/src/cursor/plans.js +254 -254
- package/src/cursor/premium.js +469 -469
- package/src/cursor/setup.js +488 -488
- package/src/dashboard.js +493 -493
- package/src/deep-review.js +428 -428
- package/src/deprecation.js +98 -98
- package/src/diff-only.js +280 -280
- package/src/doctor.js +119 -119
- package/src/domain-pack-expansion.js +1033 -1033
- package/src/domain-packs.js +387 -387
- package/src/feedback.js +178 -178
- package/src/fix-engine.js +783 -783
- package/src/fix-prompts.js +122 -122
- package/src/formatters/csv.js +69 -0
- package/src/formatters/junit.js +99 -0
- package/src/formatters/markdown.js +118 -0
- package/src/formatters/sarif.js +115 -115
- package/src/freshness.js +74 -74
- package/src/gemini/config-parser.js +275 -275
- package/src/gemini/deep-review.js +559 -559
- package/src/gemini/domain-packs.js +393 -393
- package/src/gemini/freshness.js +66 -66
- package/src/gemini/governance.js +201 -201
- package/src/gemini/interactive.js +860 -860
- package/src/gemini/mcp-packs.js +915 -915
- package/src/gemini/plans.js +269 -269
- package/src/gemini/premium.js +760 -760
- package/src/gemini/setup.js +692 -692
- package/src/governance.js +72 -72
- package/src/harmony/add.js +68 -68
- package/src/harmony/advisor.js +333 -333
- package/src/harmony/canon.js +565 -565
- package/src/harmony/cli.js +591 -591
- package/src/harmony/drift.js +401 -401
- package/src/harmony/governance.js +313 -313
- package/src/harmony/memory.js +239 -239
- package/src/harmony/sync.js +475 -475
- package/src/harmony/watch.js +370 -370
- package/src/hook-validation.js +342 -342
- package/src/index.js +271 -271
- package/src/init.js +184 -184
- package/src/instruction-surfaces.js +185 -185
- package/src/integrations.js +144 -144
- package/src/interactive.js +118 -118
- package/src/locales/en.json +1 -1
- package/src/locales/es.json +1 -1
- package/src/mcp-packs.js +830 -830
- package/src/mcp-server.js +726 -726
- package/src/mcp-validation.js +337 -337
- package/src/nerviq-sync.json +7 -7
- package/src/opencode/config-parser.js +109 -109
- package/src/opencode/context.js +247 -247
- package/src/opencode/deep-review.js +313 -313
- package/src/opencode/domain-packs.js +262 -262
- package/src/opencode/freshness.js +66 -66
- package/src/opencode/governance.js +159 -159
- package/src/opencode/interactive.js +392 -392
- package/src/opencode/mcp-packs.js +705 -705
- package/src/opencode/patch.js +184 -184
- package/src/opencode/plans.js +231 -231
- package/src/opencode/premium.js +413 -413
- package/src/opencode/setup.js +449 -449
- package/src/opencode/techniques.js +27 -27
- package/src/operating-profile.js +574 -574
- package/src/org.js +152 -152
- package/src/permission-rules.js +218 -218
- package/src/plans.js +839 -839
- package/src/platform-change-manifest.js +86 -86
- package/src/plugins.js +110 -110
- package/src/policy-layers.js +210 -210
- package/src/profiles.js +124 -124
- package/src/prompt-injection.js +74 -74
- package/src/public-api.js +173 -173
- package/src/recommendation-rules.js +84 -84
- package/src/repo-archetype.js +386 -386
- package/src/secret-patterns.js +39 -39
- package/src/server.js +527 -527
- package/src/setup/analysis.js +607 -607
- package/src/setup/runtime.js +172 -172
- package/src/setup.js +677 -677
- package/src/shared/capabilities.js +194 -194
- package/src/source-urls.js +132 -132
- package/src/stack-checks.js +565 -565
- package/src/supplemental-checks.js +13 -13
- package/src/synergy/adaptive.js +261 -261
- package/src/synergy/compensation.js +137 -137
- package/src/synergy/evidence.js +193 -193
- package/src/synergy/learning.js +199 -199
- package/src/synergy/patterns.js +227 -227
- package/src/synergy/ranking.js +83 -83
- package/src/synergy/report.js +165 -165
- package/src/synergy/routing.js +146 -146
- package/src/techniques/api.js +407 -407
- package/src/techniques/automation.js +316 -316
- package/src/techniques/compliance.js +257 -257
- package/src/techniques/hygiene.js +294 -294
- package/src/techniques/instructions.js +243 -243
- package/src/techniques/observability.js +226 -226
- package/src/techniques/optimization.js +142 -142
- package/src/techniques/quality.js +318 -318
- package/src/techniques/security.js +237 -237
- package/src/techniques/shared.js +443 -443
- package/src/techniques/stacks.js +2294 -2294
- package/src/techniques/tools.js +106 -106
- package/src/techniques/workflow.js +413 -413
- package/src/techniques.js +81 -81
- package/src/terminology.js +73 -73
- package/src/token-estimate.js +35 -35
- package/src/usage-patterns.js +99 -99
- package/src/verification-metadata.js +145 -145
- package/src/watch.js +247 -247
- package/src/windsurf/activity.js +302 -302
- package/src/windsurf/config-parser.js +267 -267
- package/src/windsurf/deep-review.js +337 -337
- package/src/windsurf/domain-packs.js +370 -370
- package/src/windsurf/freshness.js +36 -36
- package/src/windsurf/governance.js +231 -231
- package/src/windsurf/interactive.js +388 -388
- package/src/windsurf/mcp-packs.js +792 -792
- package/src/windsurf/plans.js +247 -247
- package/src/windsurf/premium.js +468 -468
- package/src/windsurf/setup.js +471 -471
- package/src/workspace.js +375 -375
|
@@ -1,577 +1,577 @@
|
|
|
1
|
-
const { getRecommendationAdjustment } = require('../activity');
|
|
2
|
-
|
|
3
|
-
const IMPACT_ORDER = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
4
|
-
const WEIGHTS = { critical: 15, high: 10, medium: 5, low: 2 };
|
|
5
|
-
const SCORE_MILESTONES = [50, 70, 90, 100];
|
|
6
|
-
const CATEGORY_MODULES = {
|
|
7
|
-
memory: 'CLAUDE.md',
|
|
8
|
-
quality: 'verification',
|
|
9
|
-
git: 'safety',
|
|
10
|
-
workflow: 'commands-agents-skills',
|
|
11
|
-
security: 'permissions',
|
|
12
|
-
automation: 'hooks',
|
|
13
|
-
design: 'design-rules',
|
|
14
|
-
devops: 'ci-devops',
|
|
15
|
-
hygiene: 'project-hygiene',
|
|
16
|
-
performance: 'context-management',
|
|
17
|
-
tools: 'mcp-tools',
|
|
18
|
-
prompting: 'prompt-structure',
|
|
19
|
-
features: 'modern-claude-features',
|
|
20
|
-
'quality-deep': 'quality-deep',
|
|
21
|
-
skills: 'skills',
|
|
22
|
-
agents: 'subagents',
|
|
23
|
-
review: 'review-workflow',
|
|
24
|
-
local: 'local-environment',
|
|
25
|
-
};
|
|
26
|
-
const ACTION_RATIONALES = {
|
|
27
|
-
noBypassPermissions: 'bypassPermissions skips the main safety layer. Explicit allow and deny rules create safer autonomy.',
|
|
28
|
-
secretsProtection: 'Without secret protection, Claude can accidentally inspect sensitive files and leak them into outputs.',
|
|
29
|
-
permissionDeny: 'Deny rules are the strongest way to prevent dangerous reads and destructive operations.',
|
|
30
|
-
settingsPermissions: 'Explicit permission settings make the workflow safer, more governable, and easier to review.',
|
|
31
|
-
testCommand: 'Without a test command, Claude cannot verify that its changes actually work before handoff.',
|
|
32
|
-
lintCommand: 'Without a lint command, Claude will miss formatting and style regressions that teams expect to catch automatically.',
|
|
33
|
-
buildCommand: 'Without a build command, compile and packaging failures stay invisible until later in the workflow.',
|
|
34
|
-
ciPipeline: 'CI is what turns a local setup improvement into a repeatable team-wide standard.',
|
|
35
|
-
securityReview: 'If you do not wire in security review guidance, high-risk changes are easier to ship without the right scrutiny.',
|
|
36
|
-
skills: 'Skills package reusable expertise so Claude does not need the same context re-explained every session.',
|
|
37
|
-
multipleAgents: 'Specialized agents unlock role-based work such as security review, implementation, and QA in parallel.',
|
|
38
|
-
multipleMcpServers: 'A richer MCP surface gives Claude access to live tools and documentation instead of stale assumptions.',
|
|
39
|
-
roleDefinition: 'A clear role definition calibrates how Claude thinks, explains, and validates work in this repo.',
|
|
40
|
-
importSyntax: 'Imported modules keep CLAUDE.md maintainable as the workflow grows more sophisticated.',
|
|
41
|
-
claudeMd: 'CLAUDE.md is the foundation of project-specific context. Without it, Claude starts every task half-blind.',
|
|
42
|
-
hooks: 'Hooks enforce the rules programmatically, which is much more reliable than relying on instructions alone.',
|
|
43
|
-
pathRules: 'Path-specific rules help Claude behave differently in different parts of the repo without global noise.',
|
|
44
|
-
context7Mcp: 'Live documentation reduces version drift and cuts down on confident but outdated answers.',
|
|
45
|
-
codexAgentsMd: 'AGENTS.md is the main Codex instruction surface. Without it, Codex starts without repo-specific guidance.',
|
|
46
|
-
codexAgentsMdSubstantive: 'A thin AGENTS.md is almost as bad as no AGENTS.md because Codex still lacks the repo context it needs.',
|
|
47
|
-
codexAgentsVerificationCommands: 'If AGENTS.md does not document how to verify work, Codex cannot reliably prove its own changes are safe.',
|
|
48
|
-
codexAgentsArchitecture: 'A small architecture map reduces navigation drift and helps Codex change the right part of the repo first.',
|
|
49
|
-
codexConfigExists: 'Without .codex/config.toml, trust and model behavior are implicit instead of explicit.',
|
|
50
|
-
codexReasoningEffortExplicit: 'Reasoning depth should be intentional for cost and latency, not left to implicit defaults.',
|
|
51
|
-
codexApprovalPolicyExplicit: 'Explicit approvals make Codex behavior predictable and reviewable across sessions.',
|
|
52
|
-
codexNoDangerFullAccess: 'danger-full-access removes the main safety boundary and should be treated as a critical risk.',
|
|
53
|
-
codexHistorySendToServerExplicit: 'History sync is a privacy and governance surface. Teams should decide it explicitly, not inherit it accidentally.',
|
|
54
|
-
codexNoSecretsInAgents: 'Secrets in AGENTS.md can leak directly into agent context, outputs, and logs.',
|
|
55
|
-
codexHooksWindowsCaveat: 'Windows does not support Codex hooks today, so relying on them there creates a false sense of runtime enforcement.',
|
|
56
|
-
codexSkillsDirPresentWhenUsed: 'Versioned repo-local skills are the safest way to keep Codex expertise reviewable and consistent across contributors.',
|
|
57
|
-
codexSkillsHaveMetadata: 'Without a usable SKILL.md, Codex cannot reliably decide when a skill should run or what it is for.',
|
|
58
|
-
codexSkillNamesKebabCase: 'Consistent skill naming improves discoverability and avoids invocation drift.',
|
|
59
|
-
codexSkillDescriptionsBounded: 'A bounded skill description helps Codex invoke the right skill without inflating prompt context.',
|
|
60
|
-
codexSkillsNoAutoRunRisk: 'Skills should guide Codex, not silently authorize risky automation or destructive actions.',
|
|
61
|
-
codexCustomAgentsRequiredFields: 'Custom agents need clear metadata and developer instructions so delegation stays predictable.',
|
|
62
|
-
codexMaxThreadsExplicit: 'Explicit fanout limits make Codex delegation safer and easier to reason about.',
|
|
63
|
-
codexMaxDepthExplicit: 'Nested delegation should be deliberate, not accidental.',
|
|
64
|
-
codexPerAgentSandboxOverridesSafe: 'Per-agent overrides can quietly bypass the main trust model if they are not constrained.',
|
|
65
|
-
codexExecUsageSafe: 'Unsafe Codex automation quickly turns small workflow mistakes into real repo damage.',
|
|
66
|
-
codexGitHubActionSafeStrategy: 'CI safety posture should be visible and intentional, especially when Codex is acting in automation.',
|
|
67
|
-
codexCiAuthUsesManagedKey: 'Managed secrets are the minimum trust boundary for Codex in CI.',
|
|
68
|
-
codexAutomationManuallyTested: 'Manual dry-runs catch automation footguns before they become scheduled failures.',
|
|
69
|
-
codexReviewWorkflowDocumented: 'A documented review path makes Codex safer to use on risky diffs and refactors.',
|
|
70
|
-
codexReviewModelOverrideExplicit: 'Explicit review model selection keeps review quality and cost predictable when automation is involved.',
|
|
71
|
-
codexWorkingTreeReviewExpectations: 'Codex reviews are much safer when the repo states how to treat staged, unstaged, and unrelated changes.',
|
|
72
|
-
codexCostAwarenessDocumented: 'Heavy workflows should be intentional, not the invisible default.',
|
|
73
|
-
codexArtifactsSharedIntentionally: 'If `.codex` is hidden from version control, the team loses a shared and reviewable Codex contract.',
|
|
74
|
-
codexLifecycleScriptsPlatformSafe: 'Local setup/teardown scripts are part of the trust model and should not surprise contributors on other platforms.',
|
|
75
|
-
codexActionsNotRedundant: 'Redundant automation expands the surface area without adding real value.',
|
|
76
|
-
codexWorktreeLifecycleDocumented: 'Parallel worktree flows need explicit setup and cleanup expectations.',
|
|
77
|
-
codexAgentsMentionModernFeatures: 'When the repo uses modern Codex surfaces, AGENTS.md should tell Codex they exist.',
|
|
78
|
-
codexNoDeprecatedPatterns: 'Deprecated Codex patterns create silent drift and confusing behavior over time.',
|
|
79
|
-
codexProfilesUsedWhenNeeded: 'Profiles become more important as Codex automation and delegation get more complex.',
|
|
80
|
-
codexPluginConfigValid: 'Broken plugin metadata creates discoverability and tooling drift.',
|
|
81
|
-
codexUndoExplicit: 'Undo is a user-facing safety feature and should be an explicit repo choice.',
|
|
82
|
-
};
|
|
83
|
-
const CODEX_HARD_FAIL_KEYS = new Set([
|
|
84
|
-
'codexAgentsMd',
|
|
85
|
-
'codexConfigValidToml',
|
|
86
|
-
'codexNoDangerFullAccess',
|
|
87
|
-
'codexApprovalPolicyExplicit',
|
|
88
|
-
'codexNoSecretsInAgents',
|
|
89
|
-
'codexHooksWindowsCaveat',
|
|
90
|
-
]);
|
|
91
|
-
const CODEX_EVIDENCE_CLASSES = {
|
|
92
|
-
'CX-A01': 'runtime',
|
|
93
|
-
'CX-A02': 'derived',
|
|
94
|
-
'CX-A03': 'derived',
|
|
95
|
-
'CX-A04': 'derived',
|
|
96
|
-
'CX-A05': 'mixed',
|
|
97
|
-
'CX-A06': 'source',
|
|
98
|
-
'CX-A07': 'derived',
|
|
99
|
-
'CX-A08': 'derived',
|
|
100
|
-
'CX-B01': 'runtime',
|
|
101
|
-
'CX-B02': 'mixed',
|
|
102
|
-
'CX-B03': 'mixed',
|
|
103
|
-
'CX-B04': 'source',
|
|
104
|
-
'CX-B05': 'source',
|
|
105
|
-
'CX-B06': 'source',
|
|
106
|
-
'CX-B07': 'source',
|
|
107
|
-
'CX-B08': 'source',
|
|
108
|
-
'CX-B09': 'source',
|
|
109
|
-
'CX-C01': 'mixed',
|
|
110
|
-
'CX-C02': 'mixed',
|
|
111
|
-
'CX-C03': 'mixed',
|
|
112
|
-
'CX-C04': 'derived',
|
|
113
|
-
'CX-C05': 'source',
|
|
114
|
-
'CX-C06': 'source',
|
|
115
|
-
'CX-C07': 'mixed',
|
|
116
|
-
'CX-C08': 'source',
|
|
117
|
-
'CX-C09': 'mixed',
|
|
118
|
-
'CX-D01': 'runtime',
|
|
119
|
-
'CX-D02': 'mixed',
|
|
120
|
-
'CX-D03': 'source',
|
|
121
|
-
'CX-D04': 'mixed',
|
|
122
|
-
'CX-D05': 'mixed',
|
|
123
|
-
'CX-E01': 'mixed',
|
|
124
|
-
'CX-E02': 'runtime',
|
|
125
|
-
'CX-E03': 'mixed',
|
|
126
|
-
'CX-E04': 'mixed',
|
|
127
|
-
'CX-E05': 'source',
|
|
128
|
-
'CX-F01': 'mixed',
|
|
129
|
-
'CX-F02': 'mixed',
|
|
130
|
-
'CX-F03': 'source',
|
|
131
|
-
'CX-F04': 'mixed',
|
|
132
|
-
'CX-F05': 'source',
|
|
133
|
-
'CX-F06': 'source',
|
|
134
|
-
'CX-G01': 'mixed',
|
|
135
|
-
'CX-G02': 'source',
|
|
136
|
-
'CX-G03': 'source',
|
|
137
|
-
'CX-G04': 'derived',
|
|
138
|
-
'CX-G05': 'derived',
|
|
139
|
-
'CX-H01': 'source',
|
|
140
|
-
'CX-H02': 'runtime',
|
|
141
|
-
'CX-H03': 'runtime',
|
|
142
|
-
'CX-H04': 'source',
|
|
143
|
-
'CX-I01': 'mixed',
|
|
144
|
-
'CX-I02': 'mixed',
|
|
145
|
-
'CX-I03': 'source',
|
|
146
|
-
'CX-I04': 'source',
|
|
147
|
-
'CX-J01': 'source',
|
|
148
|
-
'CX-J02': 'source',
|
|
149
|
-
'CX-J03': 'source',
|
|
150
|
-
'CX-J04': 'source',
|
|
151
|
-
'CX-K01': 'source',
|
|
152
|
-
'CX-K02': 'source',
|
|
153
|
-
'CX-K03': 'source',
|
|
154
|
-
'CX-K04': 'source',
|
|
155
|
-
'CX-L01': 'derived',
|
|
156
|
-
'CX-L02': 'source',
|
|
157
|
-
'CX-L03': 'derived',
|
|
158
|
-
'CX-L04': 'source',
|
|
159
|
-
'CX-L05': 'source',
|
|
160
|
-
};
|
|
161
|
-
const CODEX_QUICKWIN_CONFIG_KEYS = new Set([
|
|
162
|
-
'codexConfigExists',
|
|
163
|
-
'codexModelExplicit',
|
|
164
|
-
'codexReasoningEffortExplicit',
|
|
165
|
-
'codexWeakModelExplicit',
|
|
166
|
-
'codexProfilesUsedAppropriately',
|
|
167
|
-
'codexFullAutoErrorModeExplicit',
|
|
168
|
-
'codexHistorySendToServerExplicit',
|
|
169
|
-
'codexNetworkAccessExplicit',
|
|
170
|
-
'codexHooksDeliberate',
|
|
171
|
-
'codexMcpStartupTimeoutReasonable',
|
|
172
|
-
'codexMaxThreadsExplicit',
|
|
173
|
-
'codexMaxDepthExplicit',
|
|
174
|
-
]);
|
|
175
|
-
const CODEX_QUICKWIN_FILE_KEYS = new Set([
|
|
176
|
-
'codexAgentsMd',
|
|
177
|
-
'codexHooksJsonExistsWhenClaimed',
|
|
178
|
-
'codexSkillsDirPresentWhenUsed',
|
|
179
|
-
]);
|
|
180
|
-
const CODEX_QUICKWIN_DOC_KEYS = new Set([
|
|
181
|
-
'codexAgentsArchitecture',
|
|
182
|
-
'codexOverrideDocumented',
|
|
183
|
-
'codexNoGenericFiller',
|
|
184
|
-
'codexNoInstructionContradictions',
|
|
185
|
-
'codexRulesExamplesPresent',
|
|
186
|
-
'codexRuleWrapperRiskDocumented',
|
|
187
|
-
'codexSkillsHaveMetadata',
|
|
188
|
-
'codexSkillNamesKebabCase',
|
|
189
|
-
'codexSkillDescriptionsBounded',
|
|
190
|
-
'codexAutomationManuallyTested',
|
|
191
|
-
'codexReviewWorkflowDocumented',
|
|
192
|
-
'codexWorkingTreeReviewExpectations',
|
|
193
|
-
'codexCostAwarenessDocumented',
|
|
194
|
-
]);
|
|
195
|
-
const CODEX_QUICKWIN_POLICY_KEYS = new Set([
|
|
196
|
-
'codexRulesSpecificPatterns',
|
|
197
|
-
'codexNoBroadAllowAllRules',
|
|
198
|
-
'codexMcpWhitelistsExplicit',
|
|
199
|
-
'codexNoDeprecatedMcpTransport',
|
|
200
|
-
'codexGitHubActionSafeStrategy',
|
|
201
|
-
'codexProfilesUsedWhenNeeded',
|
|
202
|
-
'codexUndoExplicit',
|
|
203
|
-
]);
|
|
204
|
-
const CODEX_QUICKWIN_AVOID_KEYS = new Set([
|
|
205
|
-
'codexNoDangerFullAccess',
|
|
206
|
-
'codexApprovalPolicyExplicit',
|
|
207
|
-
'codexGitHubActionUnsafeJustified',
|
|
208
|
-
'codexProjectScopedMcpTrusted',
|
|
209
|
-
'codexMcpAuthDocumented',
|
|
210
|
-
'codexHooksWindowsCaveat',
|
|
211
|
-
'codexNoSecretsInAgents',
|
|
212
|
-
'codexPerAgentSandboxOverridesSafe',
|
|
213
|
-
'codexExecUsageSafe',
|
|
214
|
-
'codexCiAuthUsesManagedKey',
|
|
215
|
-
'codexLifecycleScriptsPlatformSafe',
|
|
216
|
-
]);
|
|
217
|
-
|
|
218
|
-
function riskFromImpact(impact) {
|
|
219
|
-
if (impact === 'critical') return 'high';
|
|
220
|
-
if (impact === 'high') return 'medium';
|
|
221
|
-
return 'low';
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function confidenceFromImpact(impact) {
|
|
225
|
-
return impact === 'critical' || impact === 'high' ? 'high' : 'medium';
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function confidenceLabel(confidence) {
|
|
229
|
-
if (confidence >= 0.6) return 'HIGH';
|
|
230
|
-
if (confidence >= 0.3) return 'MEDIUM';
|
|
231
|
-
return 'HEURISTIC';
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function getPrioritizedFailed(failed) {
|
|
235
|
-
const prioritized = failed.filter((item) => !(item.category === 'hygiene' && item.impact === 'low'));
|
|
236
|
-
return prioritized.length > 0 ? prioritized : failed;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function codexEvidenceClass(item) {
|
|
240
|
-
return CODEX_EVIDENCE_CLASSES[item.id] || 'derived';
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function codexCategoryBonus(category) {
|
|
244
|
-
if (category === 'trust' || category === 'config') return 12;
|
|
245
|
-
if (category === 'rules' || category === 'hooks' || category === 'mcp') return 8;
|
|
246
|
-
if (category === 'instructions') return 4;
|
|
247
|
-
return 0;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function codexEvidenceBonus(item) {
|
|
251
|
-
const evidenceClass = codexEvidenceClass(item);
|
|
252
|
-
if (evidenceClass === 'runtime') return 8;
|
|
253
|
-
if (evidenceClass === 'mixed') return 6;
|
|
254
|
-
if (evidenceClass === 'source') return 3;
|
|
255
|
-
return 0;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function codexPriorityScore(item, outcomeSummaryByKey = {}) {
|
|
259
|
-
const impactBase = item.impact === 'critical'
|
|
260
|
-
? 60
|
|
261
|
-
: item.impact === 'high'
|
|
262
|
-
? 40
|
|
263
|
-
: item.impact === 'medium'
|
|
264
|
-
? 20
|
|
265
|
-
: 8;
|
|
266
|
-
const feedbackAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, item.key) * 10;
|
|
267
|
-
const hardFailBonus = CODEX_HARD_FAIL_KEYS.has(item.key) ? 12 : 0;
|
|
268
|
-
return Math.max(0, Math.min(100, impactBase + codexCategoryBonus(item.category) + codexEvidenceBonus(item) + hardFailBonus + feedbackAdjustment));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function codexQuickWinScore(item) {
|
|
272
|
-
if (CODEX_QUICKWIN_AVOID_KEYS.has(item.key)) return -100;
|
|
273
|
-
|
|
274
|
-
let score = 0;
|
|
275
|
-
if (CODEX_QUICKWIN_CONFIG_KEYS.has(item.key)) {
|
|
276
|
-
score += 40;
|
|
277
|
-
} else if (CODEX_QUICKWIN_FILE_KEYS.has(item.key)) {
|
|
278
|
-
score += 34;
|
|
279
|
-
} else if (CODEX_QUICKWIN_DOC_KEYS.has(item.key)) {
|
|
280
|
-
score += 26;
|
|
281
|
-
} else if (CODEX_QUICKWIN_POLICY_KEYS.has(item.key)) {
|
|
282
|
-
score += 20;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
score += item.impact === 'low' ? 8 : item.impact === 'medium' ? 6 : item.impact === 'high' ? 4 : 0;
|
|
286
|
-
score -= Math.min((item.fix || '').length, 240) / 24;
|
|
287
|
-
return score;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function getQuickWins(failed, options = {}) {
|
|
291
|
-
const pool = getPrioritizedFailed(failed);
|
|
292
|
-
|
|
293
|
-
if (options.platform === 'codex') {
|
|
294
|
-
const codexPool = pool.filter((item) => !CODEX_QUICKWIN_AVOID_KEYS.has(item.key));
|
|
295
|
-
const rankedPool = (codexPool.length > 0 ? codexPool : pool)
|
|
296
|
-
.slice()
|
|
297
|
-
.sort((a, b) => codexQuickWinScore(b) - codexQuickWinScore(a));
|
|
298
|
-
return rankedPool.slice(0, 3);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return [...pool]
|
|
302
|
-
.sort((a, b) => {
|
|
303
|
-
const fixLenA = (a.fix || '').length;
|
|
304
|
-
const fixLenB = (b.fix || '').length;
|
|
305
|
-
if (fixLenA !== fixLenB) return fixLenA - fixLenB;
|
|
306
|
-
const impactA = IMPACT_ORDER[a.impact] ?? 0;
|
|
307
|
-
const impactB = IMPACT_ORDER[b.impact] ?? 0;
|
|
308
|
-
return impactB - impactA;
|
|
309
|
-
})
|
|
310
|
-
.slice(0, 3);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function getFpFeedbackMultiplier(fpFeedbackByKey, key) {
|
|
314
|
-
if (!fpFeedbackByKey) return 1.0;
|
|
315
|
-
const bucket = fpFeedbackByKey[key];
|
|
316
|
-
if (!bucket || bucket.total === 0) return 1.0;
|
|
317
|
-
|
|
318
|
-
const unhelpfulRate = bucket.unhelpful / bucket.total;
|
|
319
|
-
const helpfulRate = bucket.helpful / bucket.total;
|
|
320
|
-
|
|
321
|
-
if (unhelpfulRate > 0.5) return 0.7;
|
|
322
|
-
if (helpfulRate > 0.8) return 1.2;
|
|
323
|
-
return 1.0;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function getRecommendationPriorityScore(item, outcomeSummaryByKey = {}, fpFeedbackByKey = null) {
|
|
327
|
-
const impactScore = (IMPACT_ORDER[item.impact] ?? 0) * 100;
|
|
328
|
-
const feedbackAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, item.key);
|
|
329
|
-
const brevityPenalty = Math.min((item.fix || '').length, 240) / 20;
|
|
330
|
-
const raw = impactScore + (feedbackAdjustment * 10) - brevityPenalty;
|
|
331
|
-
return raw * getFpFeedbackMultiplier(fpFeedbackByKey, item.key);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function buildTopNextActions(failed, limit = 5, outcomeSummaryByKey = {}, options = {}) {
|
|
335
|
-
const pool = getPrioritizedFailed(failed);
|
|
336
|
-
const fpByKey = options.fpFeedbackByKey || null;
|
|
337
|
-
|
|
338
|
-
return [...pool]
|
|
339
|
-
.sort((a, b) => {
|
|
340
|
-
const scoreB = options.platform === 'codex'
|
|
341
|
-
? codexPriorityScore(b, outcomeSummaryByKey)
|
|
342
|
-
: getRecommendationPriorityScore(b, outcomeSummaryByKey, fpByKey);
|
|
343
|
-
const scoreA = options.platform === 'codex'
|
|
344
|
-
? codexPriorityScore(a, outcomeSummaryByKey)
|
|
345
|
-
: getRecommendationPriorityScore(a, outcomeSummaryByKey, fpByKey);
|
|
346
|
-
return scoreB - scoreA;
|
|
347
|
-
})
|
|
348
|
-
.slice(0, limit)
|
|
349
|
-
.map(({ key, id, name, impact, fix, category, sourceUrl }) => {
|
|
350
|
-
const feedback = outcomeSummaryByKey[key] || null;
|
|
351
|
-
const rankingAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, key);
|
|
352
|
-
const signals = [
|
|
353
|
-
`failed-check:${key}`,
|
|
354
|
-
`impact:${impact}`,
|
|
355
|
-
`category:${category}`,
|
|
356
|
-
];
|
|
357
|
-
if (feedback) {
|
|
358
|
-
signals.push(`feedback:${feedback.total}`);
|
|
359
|
-
signals.push(`ranking-adjustment:${rankingAdjustment >= 0 ? '+' : ''}${rankingAdjustment}`);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const fullItem = pool.find((item) => item.key === key) || { key, id, name, impact, fix, category };
|
|
363
|
-
const evidenceClass = options.platform === 'codex' ? codexEvidenceClass(fullItem) : (feedback ? 'measured' : 'estimated');
|
|
364
|
-
const priorityScore = options.platform === 'codex'
|
|
365
|
-
? codexPriorityScore(fullItem, outcomeSummaryByKey)
|
|
366
|
-
: Math.max(0, Math.min(100, Math.round(getRecommendationPriorityScore(fullItem, outcomeSummaryByKey, fpByKey) / 3)));
|
|
367
|
-
|
|
368
|
-
signals.push(`evidence:${evidenceClass}`);
|
|
369
|
-
if (options.platform === 'codex' && CODEX_HARD_FAIL_KEYS.has(key)) {
|
|
370
|
-
signals.push('hard-fail:true');
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return {
|
|
374
|
-
key,
|
|
375
|
-
id,
|
|
376
|
-
name,
|
|
377
|
-
impact,
|
|
378
|
-
category,
|
|
379
|
-
sourceUrl,
|
|
380
|
-
module: CATEGORY_MODULES[category] || category,
|
|
381
|
-
fix,
|
|
382
|
-
remediation_command: getRemediationCommand(key, category, options.platform),
|
|
383
|
-
priorityScore,
|
|
384
|
-
why: ACTION_RATIONALES[key] || fix,
|
|
385
|
-
risk: riskFromImpact(impact),
|
|
386
|
-
confidence: confidenceFromImpact(impact),
|
|
387
|
-
signals,
|
|
388
|
-
evidenceClass,
|
|
389
|
-
rankingAdjustment,
|
|
390
|
-
feedback: feedback ? {
|
|
391
|
-
total: feedback.total,
|
|
392
|
-
accepted: feedback.accepted,
|
|
393
|
-
rejected: feedback.rejected,
|
|
394
|
-
deferred: feedback.deferred,
|
|
395
|
-
positive: feedback.positive,
|
|
396
|
-
negative: feedback.negative,
|
|
397
|
-
avgScoreDelta: feedback.avgScoreDelta,
|
|
398
|
-
} : null,
|
|
399
|
-
};
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Map check keys/categories to a shell command an agent can run to fix the issue.
|
|
405
|
-
* Returns null when no automated fix is available.
|
|
406
|
-
*/
|
|
407
|
-
function getRemediationCommand(key, category, platform) {
|
|
408
|
-
const plat = platform || 'claude';
|
|
409
|
-
|
|
410
|
-
// Key-specific remediation commands
|
|
411
|
-
const KEY_COMMANDS = {
|
|
412
|
-
claudeMd: 'npx @nerviq/cli setup',
|
|
413
|
-
agentsMd: 'npx @nerviq/cli setup --platform codex',
|
|
414
|
-
geminiMd: 'npx @nerviq/cli setup --platform gemini',
|
|
415
|
-
copilotInstructions: 'npx @nerviq/cli setup --platform copilot',
|
|
416
|
-
cursorRules: 'npx @nerviq/cli setup --platform cursor',
|
|
417
|
-
windsurfRules: 'npx @nerviq/cli setup --platform windsurf',
|
|
418
|
-
aiderConfig: 'npx @nerviq/cli setup --platform aider',
|
|
419
|
-
opencodeConfig: 'npx @nerviq/cli setup --platform opencode',
|
|
420
|
-
settingsPermissions: 'npx @nerviq/cli plan --only permissions',
|
|
421
|
-
permissionDeny: 'npx @nerviq/cli plan --only permissions',
|
|
422
|
-
noBypassPermissions: 'npx @nerviq/cli plan --only permissions',
|
|
423
|
-
secretsProtection: 'npx @nerviq/cli plan --only permissions',
|
|
424
|
-
verificationLoop: `npx @nerviq/cli augment --platform ${plat}`,
|
|
425
|
-
lintCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
426
|
-
testCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
427
|
-
buildCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
428
|
-
hookExists: 'npx @nerviq/cli plan --only hooks',
|
|
429
|
-
preCommitHook: 'npx @nerviq/cli plan --only hooks',
|
|
430
|
-
commandsExist: 'npx @nerviq/cli plan --only commands',
|
|
431
|
-
mcpServers: 'npx @nerviq/cli plan --mcp-pack context7',
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
if (KEY_COMMANDS[key]) return KEY_COMMANDS[key];
|
|
435
|
-
|
|
436
|
-
// Category-level fallback
|
|
437
|
-
const CATEGORY_COMMANDS = {
|
|
438
|
-
memory: `npx @nerviq/cli setup --platform ${plat}`,
|
|
439
|
-
security: `npx @nerviq/cli plan --only permissions --platform ${plat}`,
|
|
440
|
-
automation: `npx @nerviq/cli plan --only hooks --platform ${plat}`,
|
|
441
|
-
workflow: `npx @nerviq/cli plan --only commands --platform ${plat}`,
|
|
442
|
-
tools: `npx @nerviq/cli plan --mcp-pack context7 --platform ${plat}`,
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
return CATEGORY_COMMANDS[category] || `npx @nerviq/cli augment --platform ${plat}`;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
function getNextScoreMilestone(score) {
|
|
449
|
-
return SCORE_MILESTONES.find((milestone) => score < milestone) || null;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function buildScoreCoaching({ score, earnedPoints, maxPoints, failed, outcomeSummaryByKey = {}, platform, fpFeedbackByKey = null }) {
|
|
453
|
-
if (!Array.isArray(failed) || failed.length === 0 || !Number.isFinite(maxPoints) || maxPoints <= 0) {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const nextMilestone = getNextScoreMilestone(score);
|
|
458
|
-
if (!nextMilestone) return null;
|
|
459
|
-
|
|
460
|
-
const targetEarnedPoints = Math.ceil((nextMilestone / 100) * maxPoints);
|
|
461
|
-
const pointsNeeded = Math.max(0, targetEarnedPoints - earnedPoints);
|
|
462
|
-
if (pointsNeeded <= 0) return null;
|
|
463
|
-
|
|
464
|
-
const rankedActions = buildTopNextActions(failed, failed.length, outcomeSummaryByKey, { platform, fpFeedbackByKey });
|
|
465
|
-
if (rankedActions.length === 0) return null;
|
|
466
|
-
|
|
467
|
-
const failedByKey = new Map(failed.map((item) => [item.key, item]));
|
|
468
|
-
const selected = [];
|
|
469
|
-
let recoveredPoints = 0;
|
|
470
|
-
|
|
471
|
-
for (const action of rankedActions) {
|
|
472
|
-
const source = failedByKey.get(action.key);
|
|
473
|
-
if (!source) continue;
|
|
474
|
-
selected.push({
|
|
475
|
-
key: source.key,
|
|
476
|
-
name: source.name,
|
|
477
|
-
impact: source.impact,
|
|
478
|
-
weight: WEIGHTS[source.impact] || 0,
|
|
479
|
-
});
|
|
480
|
-
recoveredPoints += WEIGHTS[source.impact] || 0;
|
|
481
|
-
if (recoveredPoints >= pointsNeeded) break;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
if (selected.length === 0) return null;
|
|
485
|
-
|
|
486
|
-
const fixesNeeded = selected.length;
|
|
487
|
-
const projectedScore = Math.round(((earnedPoints + recoveredPoints) / maxPoints) * 100);
|
|
488
|
-
const summary = `You're ${fixesNeeded} ${fixesNeeded === 1 ? 'fix' : 'fixes'} away from ${nextMilestone}/100.`;
|
|
489
|
-
|
|
490
|
-
return {
|
|
491
|
-
currentScore: score,
|
|
492
|
-
nextMilestone,
|
|
493
|
-
pointsNeeded,
|
|
494
|
-
fixesNeeded,
|
|
495
|
-
projectedScore: Math.min(100, projectedScore),
|
|
496
|
-
summary,
|
|
497
|
-
recommendedKeys: selected.map((item) => item.key),
|
|
498
|
-
recommendedNames: selected.map((item) => item.name),
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function computeCategoryScores(applicable, passed) {
|
|
503
|
-
const grouped = {};
|
|
504
|
-
|
|
505
|
-
for (const item of applicable) {
|
|
506
|
-
const category = item.category || 'unknown';
|
|
507
|
-
if (!grouped[category]) {
|
|
508
|
-
grouped[category] = { passed: 0, total: 0, earnedPoints: 0, maxPoints: 0 };
|
|
509
|
-
}
|
|
510
|
-
grouped[category].total += 1;
|
|
511
|
-
grouped[category].maxPoints += WEIGHTS[item.impact] || 5;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
for (const item of passed) {
|
|
515
|
-
const category = item.category || 'unknown';
|
|
516
|
-
if (!grouped[category]) continue;
|
|
517
|
-
grouped[category].passed += 1;
|
|
518
|
-
grouped[category].earnedPoints += WEIGHTS[item.impact] || 5;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
const result = {};
|
|
522
|
-
for (const [category, summary] of Object.entries(grouped)) {
|
|
523
|
-
result[category] = {
|
|
524
|
-
...summary,
|
|
525
|
-
score: summary.maxPoints > 0 ? Math.round((summary.earnedPoints / summary.maxPoints) * 100) : 0,
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return result;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function inferSuggestedNextCommand(result) {
|
|
533
|
-
if (result.platform === 'codex') {
|
|
534
|
-
if (result.failed === 0) return 'npx nerviq --platform codex augment';
|
|
535
|
-
|
|
536
|
-
const actionKeys = new Set((result.topNextActions || []).map((item) => item.key));
|
|
537
|
-
if (
|
|
538
|
-
result.score < 50 ||
|
|
539
|
-
actionKeys.has('codexAgentsMd') ||
|
|
540
|
-
actionKeys.has('codexConfigExists') ||
|
|
541
|
-
actionKeys.has('codexNoDangerFullAccess') ||
|
|
542
|
-
actionKeys.has('codexApprovalPolicyExplicit')
|
|
543
|
-
) {
|
|
544
|
-
return 'npx nerviq --platform codex suggest-only';
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
return 'npx nerviq --platform codex augment';
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
const actionKeys = new Set((result.topNextActions || []).map((item) => item.key));
|
|
551
|
-
const platFlag = result.platform && result.platform !== 'claude' ? ` --platform ${result.platform}` : '';
|
|
552
|
-
|
|
553
|
-
if (result.failed === 0) return `npx nerviq${platFlag} augment`;
|
|
554
|
-
if (
|
|
555
|
-
result.score < 50 ||
|
|
556
|
-
actionKeys.has('claudeMd') ||
|
|
557
|
-
actionKeys.has('hooks') ||
|
|
558
|
-
actionKeys.has('settingsPermissions') ||
|
|
559
|
-
actionKeys.has('permissionDeny')
|
|
560
|
-
) {
|
|
561
|
-
return `npx nerviq${platFlag} setup`;
|
|
562
|
-
}
|
|
563
|
-
if (result.score < 80) return `npx nerviq${platFlag} suggest-only`;
|
|
564
|
-
return `npx nerviq${platFlag} augment`;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
module.exports = {
|
|
568
|
-
WEIGHTS,
|
|
569
|
-
buildScoreCoaching,
|
|
570
|
-
buildTopNextActions,
|
|
571
|
-
confidenceLabel,
|
|
572
|
-
computeCategoryScores,
|
|
573
|
-
getFpFeedbackMultiplier,
|
|
574
|
-
getQuickWins,
|
|
575
|
-
getRecommendationPriorityScore,
|
|
576
|
-
inferSuggestedNextCommand,
|
|
577
|
-
};
|
|
1
|
+
const { getRecommendationAdjustment } = require('../activity');
|
|
2
|
+
|
|
3
|
+
const IMPACT_ORDER = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
4
|
+
const WEIGHTS = { critical: 15, high: 10, medium: 5, low: 2 };
|
|
5
|
+
const SCORE_MILESTONES = [50, 70, 90, 100];
|
|
6
|
+
const CATEGORY_MODULES = {
|
|
7
|
+
memory: 'CLAUDE.md',
|
|
8
|
+
quality: 'verification',
|
|
9
|
+
git: 'safety',
|
|
10
|
+
workflow: 'commands-agents-skills',
|
|
11
|
+
security: 'permissions',
|
|
12
|
+
automation: 'hooks',
|
|
13
|
+
design: 'design-rules',
|
|
14
|
+
devops: 'ci-devops',
|
|
15
|
+
hygiene: 'project-hygiene',
|
|
16
|
+
performance: 'context-management',
|
|
17
|
+
tools: 'mcp-tools',
|
|
18
|
+
prompting: 'prompt-structure',
|
|
19
|
+
features: 'modern-claude-features',
|
|
20
|
+
'quality-deep': 'quality-deep',
|
|
21
|
+
skills: 'skills',
|
|
22
|
+
agents: 'subagents',
|
|
23
|
+
review: 'review-workflow',
|
|
24
|
+
local: 'local-environment',
|
|
25
|
+
};
|
|
26
|
+
const ACTION_RATIONALES = {
|
|
27
|
+
noBypassPermissions: 'bypassPermissions skips the main safety layer. Explicit allow and deny rules create safer autonomy.',
|
|
28
|
+
secretsProtection: 'Without secret protection, Claude can accidentally inspect sensitive files and leak them into outputs.',
|
|
29
|
+
permissionDeny: 'Deny rules are the strongest way to prevent dangerous reads and destructive operations.',
|
|
30
|
+
settingsPermissions: 'Explicit permission settings make the workflow safer, more governable, and easier to review.',
|
|
31
|
+
testCommand: 'Without a test command, Claude cannot verify that its changes actually work before handoff.',
|
|
32
|
+
lintCommand: 'Without a lint command, Claude will miss formatting and style regressions that teams expect to catch automatically.',
|
|
33
|
+
buildCommand: 'Without a build command, compile and packaging failures stay invisible until later in the workflow.',
|
|
34
|
+
ciPipeline: 'CI is what turns a local setup improvement into a repeatable team-wide standard.',
|
|
35
|
+
securityReview: 'If you do not wire in security review guidance, high-risk changes are easier to ship without the right scrutiny.',
|
|
36
|
+
skills: 'Skills package reusable expertise so Claude does not need the same context re-explained every session.',
|
|
37
|
+
multipleAgents: 'Specialized agents unlock role-based work such as security review, implementation, and QA in parallel.',
|
|
38
|
+
multipleMcpServers: 'A richer MCP surface gives Claude access to live tools and documentation instead of stale assumptions.',
|
|
39
|
+
roleDefinition: 'A clear role definition calibrates how Claude thinks, explains, and validates work in this repo.',
|
|
40
|
+
importSyntax: 'Imported modules keep CLAUDE.md maintainable as the workflow grows more sophisticated.',
|
|
41
|
+
claudeMd: 'CLAUDE.md is the foundation of project-specific context. Without it, Claude starts every task half-blind.',
|
|
42
|
+
hooks: 'Hooks enforce the rules programmatically, which is much more reliable than relying on instructions alone.',
|
|
43
|
+
pathRules: 'Path-specific rules help Claude behave differently in different parts of the repo without global noise.',
|
|
44
|
+
context7Mcp: 'Live documentation reduces version drift and cuts down on confident but outdated answers.',
|
|
45
|
+
codexAgentsMd: 'AGENTS.md is the main Codex instruction surface. Without it, Codex starts without repo-specific guidance.',
|
|
46
|
+
codexAgentsMdSubstantive: 'A thin AGENTS.md is almost as bad as no AGENTS.md because Codex still lacks the repo context it needs.',
|
|
47
|
+
codexAgentsVerificationCommands: 'If AGENTS.md does not document how to verify work, Codex cannot reliably prove its own changes are safe.',
|
|
48
|
+
codexAgentsArchitecture: 'A small architecture map reduces navigation drift and helps Codex change the right part of the repo first.',
|
|
49
|
+
codexConfigExists: 'Without .codex/config.toml, trust and model behavior are implicit instead of explicit.',
|
|
50
|
+
codexReasoningEffortExplicit: 'Reasoning depth should be intentional for cost and latency, not left to implicit defaults.',
|
|
51
|
+
codexApprovalPolicyExplicit: 'Explicit approvals make Codex behavior predictable and reviewable across sessions.',
|
|
52
|
+
codexNoDangerFullAccess: 'danger-full-access removes the main safety boundary and should be treated as a critical risk.',
|
|
53
|
+
codexHistorySendToServerExplicit: 'History sync is a privacy and governance surface. Teams should decide it explicitly, not inherit it accidentally.',
|
|
54
|
+
codexNoSecretsInAgents: 'Secrets in AGENTS.md can leak directly into agent context, outputs, and logs.',
|
|
55
|
+
codexHooksWindowsCaveat: 'Windows does not support Codex hooks today, so relying on them there creates a false sense of runtime enforcement.',
|
|
56
|
+
codexSkillsDirPresentWhenUsed: 'Versioned repo-local skills are the safest way to keep Codex expertise reviewable and consistent across contributors.',
|
|
57
|
+
codexSkillsHaveMetadata: 'Without a usable SKILL.md, Codex cannot reliably decide when a skill should run or what it is for.',
|
|
58
|
+
codexSkillNamesKebabCase: 'Consistent skill naming improves discoverability and avoids invocation drift.',
|
|
59
|
+
codexSkillDescriptionsBounded: 'A bounded skill description helps Codex invoke the right skill without inflating prompt context.',
|
|
60
|
+
codexSkillsNoAutoRunRisk: 'Skills should guide Codex, not silently authorize risky automation or destructive actions.',
|
|
61
|
+
codexCustomAgentsRequiredFields: 'Custom agents need clear metadata and developer instructions so delegation stays predictable.',
|
|
62
|
+
codexMaxThreadsExplicit: 'Explicit fanout limits make Codex delegation safer and easier to reason about.',
|
|
63
|
+
codexMaxDepthExplicit: 'Nested delegation should be deliberate, not accidental.',
|
|
64
|
+
codexPerAgentSandboxOverridesSafe: 'Per-agent overrides can quietly bypass the main trust model if they are not constrained.',
|
|
65
|
+
codexExecUsageSafe: 'Unsafe Codex automation quickly turns small workflow mistakes into real repo damage.',
|
|
66
|
+
codexGitHubActionSafeStrategy: 'CI safety posture should be visible and intentional, especially when Codex is acting in automation.',
|
|
67
|
+
codexCiAuthUsesManagedKey: 'Managed secrets are the minimum trust boundary for Codex in CI.',
|
|
68
|
+
codexAutomationManuallyTested: 'Manual dry-runs catch automation footguns before they become scheduled failures.',
|
|
69
|
+
codexReviewWorkflowDocumented: 'A documented review path makes Codex safer to use on risky diffs and refactors.',
|
|
70
|
+
codexReviewModelOverrideExplicit: 'Explicit review model selection keeps review quality and cost predictable when automation is involved.',
|
|
71
|
+
codexWorkingTreeReviewExpectations: 'Codex reviews are much safer when the repo states how to treat staged, unstaged, and unrelated changes.',
|
|
72
|
+
codexCostAwarenessDocumented: 'Heavy workflows should be intentional, not the invisible default.',
|
|
73
|
+
codexArtifactsSharedIntentionally: 'If `.codex` is hidden from version control, the team loses a shared and reviewable Codex contract.',
|
|
74
|
+
codexLifecycleScriptsPlatformSafe: 'Local setup/teardown scripts are part of the trust model and should not surprise contributors on other platforms.',
|
|
75
|
+
codexActionsNotRedundant: 'Redundant automation expands the surface area without adding real value.',
|
|
76
|
+
codexWorktreeLifecycleDocumented: 'Parallel worktree flows need explicit setup and cleanup expectations.',
|
|
77
|
+
codexAgentsMentionModernFeatures: 'When the repo uses modern Codex surfaces, AGENTS.md should tell Codex they exist.',
|
|
78
|
+
codexNoDeprecatedPatterns: 'Deprecated Codex patterns create silent drift and confusing behavior over time.',
|
|
79
|
+
codexProfilesUsedWhenNeeded: 'Profiles become more important as Codex automation and delegation get more complex.',
|
|
80
|
+
codexPluginConfigValid: 'Broken plugin metadata creates discoverability and tooling drift.',
|
|
81
|
+
codexUndoExplicit: 'Undo is a user-facing safety feature and should be an explicit repo choice.',
|
|
82
|
+
};
|
|
83
|
+
const CODEX_HARD_FAIL_KEYS = new Set([
|
|
84
|
+
'codexAgentsMd',
|
|
85
|
+
'codexConfigValidToml',
|
|
86
|
+
'codexNoDangerFullAccess',
|
|
87
|
+
'codexApprovalPolicyExplicit',
|
|
88
|
+
'codexNoSecretsInAgents',
|
|
89
|
+
'codexHooksWindowsCaveat',
|
|
90
|
+
]);
|
|
91
|
+
const CODEX_EVIDENCE_CLASSES = {
|
|
92
|
+
'CX-A01': 'runtime',
|
|
93
|
+
'CX-A02': 'derived',
|
|
94
|
+
'CX-A03': 'derived',
|
|
95
|
+
'CX-A04': 'derived',
|
|
96
|
+
'CX-A05': 'mixed',
|
|
97
|
+
'CX-A06': 'source',
|
|
98
|
+
'CX-A07': 'derived',
|
|
99
|
+
'CX-A08': 'derived',
|
|
100
|
+
'CX-B01': 'runtime',
|
|
101
|
+
'CX-B02': 'mixed',
|
|
102
|
+
'CX-B03': 'mixed',
|
|
103
|
+
'CX-B04': 'source',
|
|
104
|
+
'CX-B05': 'source',
|
|
105
|
+
'CX-B06': 'source',
|
|
106
|
+
'CX-B07': 'source',
|
|
107
|
+
'CX-B08': 'source',
|
|
108
|
+
'CX-B09': 'source',
|
|
109
|
+
'CX-C01': 'mixed',
|
|
110
|
+
'CX-C02': 'mixed',
|
|
111
|
+
'CX-C03': 'mixed',
|
|
112
|
+
'CX-C04': 'derived',
|
|
113
|
+
'CX-C05': 'source',
|
|
114
|
+
'CX-C06': 'source',
|
|
115
|
+
'CX-C07': 'mixed',
|
|
116
|
+
'CX-C08': 'source',
|
|
117
|
+
'CX-C09': 'mixed',
|
|
118
|
+
'CX-D01': 'runtime',
|
|
119
|
+
'CX-D02': 'mixed',
|
|
120
|
+
'CX-D03': 'source',
|
|
121
|
+
'CX-D04': 'mixed',
|
|
122
|
+
'CX-D05': 'mixed',
|
|
123
|
+
'CX-E01': 'mixed',
|
|
124
|
+
'CX-E02': 'runtime',
|
|
125
|
+
'CX-E03': 'mixed',
|
|
126
|
+
'CX-E04': 'mixed',
|
|
127
|
+
'CX-E05': 'source',
|
|
128
|
+
'CX-F01': 'mixed',
|
|
129
|
+
'CX-F02': 'mixed',
|
|
130
|
+
'CX-F03': 'source',
|
|
131
|
+
'CX-F04': 'mixed',
|
|
132
|
+
'CX-F05': 'source',
|
|
133
|
+
'CX-F06': 'source',
|
|
134
|
+
'CX-G01': 'mixed',
|
|
135
|
+
'CX-G02': 'source',
|
|
136
|
+
'CX-G03': 'source',
|
|
137
|
+
'CX-G04': 'derived',
|
|
138
|
+
'CX-G05': 'derived',
|
|
139
|
+
'CX-H01': 'source',
|
|
140
|
+
'CX-H02': 'runtime',
|
|
141
|
+
'CX-H03': 'runtime',
|
|
142
|
+
'CX-H04': 'source',
|
|
143
|
+
'CX-I01': 'mixed',
|
|
144
|
+
'CX-I02': 'mixed',
|
|
145
|
+
'CX-I03': 'source',
|
|
146
|
+
'CX-I04': 'source',
|
|
147
|
+
'CX-J01': 'source',
|
|
148
|
+
'CX-J02': 'source',
|
|
149
|
+
'CX-J03': 'source',
|
|
150
|
+
'CX-J04': 'source',
|
|
151
|
+
'CX-K01': 'source',
|
|
152
|
+
'CX-K02': 'source',
|
|
153
|
+
'CX-K03': 'source',
|
|
154
|
+
'CX-K04': 'source',
|
|
155
|
+
'CX-L01': 'derived',
|
|
156
|
+
'CX-L02': 'source',
|
|
157
|
+
'CX-L03': 'derived',
|
|
158
|
+
'CX-L04': 'source',
|
|
159
|
+
'CX-L05': 'source',
|
|
160
|
+
};
|
|
161
|
+
const CODEX_QUICKWIN_CONFIG_KEYS = new Set([
|
|
162
|
+
'codexConfigExists',
|
|
163
|
+
'codexModelExplicit',
|
|
164
|
+
'codexReasoningEffortExplicit',
|
|
165
|
+
'codexWeakModelExplicit',
|
|
166
|
+
'codexProfilesUsedAppropriately',
|
|
167
|
+
'codexFullAutoErrorModeExplicit',
|
|
168
|
+
'codexHistorySendToServerExplicit',
|
|
169
|
+
'codexNetworkAccessExplicit',
|
|
170
|
+
'codexHooksDeliberate',
|
|
171
|
+
'codexMcpStartupTimeoutReasonable',
|
|
172
|
+
'codexMaxThreadsExplicit',
|
|
173
|
+
'codexMaxDepthExplicit',
|
|
174
|
+
]);
|
|
175
|
+
const CODEX_QUICKWIN_FILE_KEYS = new Set([
|
|
176
|
+
'codexAgentsMd',
|
|
177
|
+
'codexHooksJsonExistsWhenClaimed',
|
|
178
|
+
'codexSkillsDirPresentWhenUsed',
|
|
179
|
+
]);
|
|
180
|
+
const CODEX_QUICKWIN_DOC_KEYS = new Set([
|
|
181
|
+
'codexAgentsArchitecture',
|
|
182
|
+
'codexOverrideDocumented',
|
|
183
|
+
'codexNoGenericFiller',
|
|
184
|
+
'codexNoInstructionContradictions',
|
|
185
|
+
'codexRulesExamplesPresent',
|
|
186
|
+
'codexRuleWrapperRiskDocumented',
|
|
187
|
+
'codexSkillsHaveMetadata',
|
|
188
|
+
'codexSkillNamesKebabCase',
|
|
189
|
+
'codexSkillDescriptionsBounded',
|
|
190
|
+
'codexAutomationManuallyTested',
|
|
191
|
+
'codexReviewWorkflowDocumented',
|
|
192
|
+
'codexWorkingTreeReviewExpectations',
|
|
193
|
+
'codexCostAwarenessDocumented',
|
|
194
|
+
]);
|
|
195
|
+
const CODEX_QUICKWIN_POLICY_KEYS = new Set([
|
|
196
|
+
'codexRulesSpecificPatterns',
|
|
197
|
+
'codexNoBroadAllowAllRules',
|
|
198
|
+
'codexMcpWhitelistsExplicit',
|
|
199
|
+
'codexNoDeprecatedMcpTransport',
|
|
200
|
+
'codexGitHubActionSafeStrategy',
|
|
201
|
+
'codexProfilesUsedWhenNeeded',
|
|
202
|
+
'codexUndoExplicit',
|
|
203
|
+
]);
|
|
204
|
+
const CODEX_QUICKWIN_AVOID_KEYS = new Set([
|
|
205
|
+
'codexNoDangerFullAccess',
|
|
206
|
+
'codexApprovalPolicyExplicit',
|
|
207
|
+
'codexGitHubActionUnsafeJustified',
|
|
208
|
+
'codexProjectScopedMcpTrusted',
|
|
209
|
+
'codexMcpAuthDocumented',
|
|
210
|
+
'codexHooksWindowsCaveat',
|
|
211
|
+
'codexNoSecretsInAgents',
|
|
212
|
+
'codexPerAgentSandboxOverridesSafe',
|
|
213
|
+
'codexExecUsageSafe',
|
|
214
|
+
'codexCiAuthUsesManagedKey',
|
|
215
|
+
'codexLifecycleScriptsPlatformSafe',
|
|
216
|
+
]);
|
|
217
|
+
|
|
218
|
+
function riskFromImpact(impact) {
|
|
219
|
+
if (impact === 'critical') return 'high';
|
|
220
|
+
if (impact === 'high') return 'medium';
|
|
221
|
+
return 'low';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function confidenceFromImpact(impact) {
|
|
225
|
+
return impact === 'critical' || impact === 'high' ? 'high' : 'medium';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function confidenceLabel(confidence) {
|
|
229
|
+
if (confidence >= 0.6) return 'HIGH';
|
|
230
|
+
if (confidence >= 0.3) return 'MEDIUM';
|
|
231
|
+
return 'HEURISTIC';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function getPrioritizedFailed(failed) {
|
|
235
|
+
const prioritized = failed.filter((item) => !(item.category === 'hygiene' && item.impact === 'low'));
|
|
236
|
+
return prioritized.length > 0 ? prioritized : failed;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function codexEvidenceClass(item) {
|
|
240
|
+
return CODEX_EVIDENCE_CLASSES[item.id] || 'derived';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function codexCategoryBonus(category) {
|
|
244
|
+
if (category === 'trust' || category === 'config') return 12;
|
|
245
|
+
if (category === 'rules' || category === 'hooks' || category === 'mcp') return 8;
|
|
246
|
+
if (category === 'instructions') return 4;
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function codexEvidenceBonus(item) {
|
|
251
|
+
const evidenceClass = codexEvidenceClass(item);
|
|
252
|
+
if (evidenceClass === 'runtime') return 8;
|
|
253
|
+
if (evidenceClass === 'mixed') return 6;
|
|
254
|
+
if (evidenceClass === 'source') return 3;
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function codexPriorityScore(item, outcomeSummaryByKey = {}) {
|
|
259
|
+
const impactBase = item.impact === 'critical'
|
|
260
|
+
? 60
|
|
261
|
+
: item.impact === 'high'
|
|
262
|
+
? 40
|
|
263
|
+
: item.impact === 'medium'
|
|
264
|
+
? 20
|
|
265
|
+
: 8;
|
|
266
|
+
const feedbackAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, item.key) * 10;
|
|
267
|
+
const hardFailBonus = CODEX_HARD_FAIL_KEYS.has(item.key) ? 12 : 0;
|
|
268
|
+
return Math.max(0, Math.min(100, impactBase + codexCategoryBonus(item.category) + codexEvidenceBonus(item) + hardFailBonus + feedbackAdjustment));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function codexQuickWinScore(item) {
|
|
272
|
+
if (CODEX_QUICKWIN_AVOID_KEYS.has(item.key)) return -100;
|
|
273
|
+
|
|
274
|
+
let score = 0;
|
|
275
|
+
if (CODEX_QUICKWIN_CONFIG_KEYS.has(item.key)) {
|
|
276
|
+
score += 40;
|
|
277
|
+
} else if (CODEX_QUICKWIN_FILE_KEYS.has(item.key)) {
|
|
278
|
+
score += 34;
|
|
279
|
+
} else if (CODEX_QUICKWIN_DOC_KEYS.has(item.key)) {
|
|
280
|
+
score += 26;
|
|
281
|
+
} else if (CODEX_QUICKWIN_POLICY_KEYS.has(item.key)) {
|
|
282
|
+
score += 20;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
score += item.impact === 'low' ? 8 : item.impact === 'medium' ? 6 : item.impact === 'high' ? 4 : 0;
|
|
286
|
+
score -= Math.min((item.fix || '').length, 240) / 24;
|
|
287
|
+
return score;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function getQuickWins(failed, options = {}) {
|
|
291
|
+
const pool = getPrioritizedFailed(failed);
|
|
292
|
+
|
|
293
|
+
if (options.platform === 'codex') {
|
|
294
|
+
const codexPool = pool.filter((item) => !CODEX_QUICKWIN_AVOID_KEYS.has(item.key));
|
|
295
|
+
const rankedPool = (codexPool.length > 0 ? codexPool : pool)
|
|
296
|
+
.slice()
|
|
297
|
+
.sort((a, b) => codexQuickWinScore(b) - codexQuickWinScore(a));
|
|
298
|
+
return rankedPool.slice(0, 3);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return [...pool]
|
|
302
|
+
.sort((a, b) => {
|
|
303
|
+
const fixLenA = (a.fix || '').length;
|
|
304
|
+
const fixLenB = (b.fix || '').length;
|
|
305
|
+
if (fixLenA !== fixLenB) return fixLenA - fixLenB;
|
|
306
|
+
const impactA = IMPACT_ORDER[a.impact] ?? 0;
|
|
307
|
+
const impactB = IMPACT_ORDER[b.impact] ?? 0;
|
|
308
|
+
return impactB - impactA;
|
|
309
|
+
})
|
|
310
|
+
.slice(0, 3);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function getFpFeedbackMultiplier(fpFeedbackByKey, key) {
|
|
314
|
+
if (!fpFeedbackByKey) return 1.0;
|
|
315
|
+
const bucket = fpFeedbackByKey[key];
|
|
316
|
+
if (!bucket || bucket.total === 0) return 1.0;
|
|
317
|
+
|
|
318
|
+
const unhelpfulRate = bucket.unhelpful / bucket.total;
|
|
319
|
+
const helpfulRate = bucket.helpful / bucket.total;
|
|
320
|
+
|
|
321
|
+
if (unhelpfulRate > 0.5) return 0.7;
|
|
322
|
+
if (helpfulRate > 0.8) return 1.2;
|
|
323
|
+
return 1.0;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function getRecommendationPriorityScore(item, outcomeSummaryByKey = {}, fpFeedbackByKey = null) {
|
|
327
|
+
const impactScore = (IMPACT_ORDER[item.impact] ?? 0) * 100;
|
|
328
|
+
const feedbackAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, item.key);
|
|
329
|
+
const brevityPenalty = Math.min((item.fix || '').length, 240) / 20;
|
|
330
|
+
const raw = impactScore + (feedbackAdjustment * 10) - brevityPenalty;
|
|
331
|
+
return raw * getFpFeedbackMultiplier(fpFeedbackByKey, item.key);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function buildTopNextActions(failed, limit = 5, outcomeSummaryByKey = {}, options = {}) {
|
|
335
|
+
const pool = getPrioritizedFailed(failed);
|
|
336
|
+
const fpByKey = options.fpFeedbackByKey || null;
|
|
337
|
+
|
|
338
|
+
return [...pool]
|
|
339
|
+
.sort((a, b) => {
|
|
340
|
+
const scoreB = options.platform === 'codex'
|
|
341
|
+
? codexPriorityScore(b, outcomeSummaryByKey)
|
|
342
|
+
: getRecommendationPriorityScore(b, outcomeSummaryByKey, fpByKey);
|
|
343
|
+
const scoreA = options.platform === 'codex'
|
|
344
|
+
? codexPriorityScore(a, outcomeSummaryByKey)
|
|
345
|
+
: getRecommendationPriorityScore(a, outcomeSummaryByKey, fpByKey);
|
|
346
|
+
return scoreB - scoreA;
|
|
347
|
+
})
|
|
348
|
+
.slice(0, limit)
|
|
349
|
+
.map(({ key, id, name, impact, fix, category, sourceUrl }) => {
|
|
350
|
+
const feedback = outcomeSummaryByKey[key] || null;
|
|
351
|
+
const rankingAdjustment = getRecommendationAdjustment(outcomeSummaryByKey, key);
|
|
352
|
+
const signals = [
|
|
353
|
+
`failed-check:${key}`,
|
|
354
|
+
`impact:${impact}`,
|
|
355
|
+
`category:${category}`,
|
|
356
|
+
];
|
|
357
|
+
if (feedback) {
|
|
358
|
+
signals.push(`feedback:${feedback.total}`);
|
|
359
|
+
signals.push(`ranking-adjustment:${rankingAdjustment >= 0 ? '+' : ''}${rankingAdjustment}`);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const fullItem = pool.find((item) => item.key === key) || { key, id, name, impact, fix, category };
|
|
363
|
+
const evidenceClass = options.platform === 'codex' ? codexEvidenceClass(fullItem) : (feedback ? 'measured' : 'estimated');
|
|
364
|
+
const priorityScore = options.platform === 'codex'
|
|
365
|
+
? codexPriorityScore(fullItem, outcomeSummaryByKey)
|
|
366
|
+
: Math.max(0, Math.min(100, Math.round(getRecommendationPriorityScore(fullItem, outcomeSummaryByKey, fpByKey) / 3)));
|
|
367
|
+
|
|
368
|
+
signals.push(`evidence:${evidenceClass}`);
|
|
369
|
+
if (options.platform === 'codex' && CODEX_HARD_FAIL_KEYS.has(key)) {
|
|
370
|
+
signals.push('hard-fail:true');
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
key,
|
|
375
|
+
id,
|
|
376
|
+
name,
|
|
377
|
+
impact,
|
|
378
|
+
category,
|
|
379
|
+
sourceUrl,
|
|
380
|
+
module: CATEGORY_MODULES[category] || category,
|
|
381
|
+
fix,
|
|
382
|
+
remediation_command: getRemediationCommand(key, category, options.platform),
|
|
383
|
+
priorityScore,
|
|
384
|
+
why: ACTION_RATIONALES[key] || fix,
|
|
385
|
+
risk: riskFromImpact(impact),
|
|
386
|
+
confidence: confidenceFromImpact(impact),
|
|
387
|
+
signals,
|
|
388
|
+
evidenceClass,
|
|
389
|
+
rankingAdjustment,
|
|
390
|
+
feedback: feedback ? {
|
|
391
|
+
total: feedback.total,
|
|
392
|
+
accepted: feedback.accepted,
|
|
393
|
+
rejected: feedback.rejected,
|
|
394
|
+
deferred: feedback.deferred,
|
|
395
|
+
positive: feedback.positive,
|
|
396
|
+
negative: feedback.negative,
|
|
397
|
+
avgScoreDelta: feedback.avgScoreDelta,
|
|
398
|
+
} : null,
|
|
399
|
+
};
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Map check keys/categories to a shell command an agent can run to fix the issue.
|
|
405
|
+
* Returns null when no automated fix is available.
|
|
406
|
+
*/
|
|
407
|
+
function getRemediationCommand(key, category, platform) {
|
|
408
|
+
const plat = platform || 'claude';
|
|
409
|
+
|
|
410
|
+
// Key-specific remediation commands
|
|
411
|
+
const KEY_COMMANDS = {
|
|
412
|
+
claudeMd: 'npx @nerviq/cli setup',
|
|
413
|
+
agentsMd: 'npx @nerviq/cli setup --platform codex',
|
|
414
|
+
geminiMd: 'npx @nerviq/cli setup --platform gemini',
|
|
415
|
+
copilotInstructions: 'npx @nerviq/cli setup --platform copilot',
|
|
416
|
+
cursorRules: 'npx @nerviq/cli setup --platform cursor',
|
|
417
|
+
windsurfRules: 'npx @nerviq/cli setup --platform windsurf',
|
|
418
|
+
aiderConfig: 'npx @nerviq/cli setup --platform aider',
|
|
419
|
+
opencodeConfig: 'npx @nerviq/cli setup --platform opencode',
|
|
420
|
+
settingsPermissions: 'npx @nerviq/cli plan --only permissions',
|
|
421
|
+
permissionDeny: 'npx @nerviq/cli plan --only permissions',
|
|
422
|
+
noBypassPermissions: 'npx @nerviq/cli plan --only permissions',
|
|
423
|
+
secretsProtection: 'npx @nerviq/cli plan --only permissions',
|
|
424
|
+
verificationLoop: `npx @nerviq/cli augment --platform ${plat}`,
|
|
425
|
+
lintCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
426
|
+
testCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
427
|
+
buildCommand: `npx @nerviq/cli augment --platform ${plat}`,
|
|
428
|
+
hookExists: 'npx @nerviq/cli plan --only hooks',
|
|
429
|
+
preCommitHook: 'npx @nerviq/cli plan --only hooks',
|
|
430
|
+
commandsExist: 'npx @nerviq/cli plan --only commands',
|
|
431
|
+
mcpServers: 'npx @nerviq/cli plan --mcp-pack context7',
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
if (KEY_COMMANDS[key]) return KEY_COMMANDS[key];
|
|
435
|
+
|
|
436
|
+
// Category-level fallback
|
|
437
|
+
const CATEGORY_COMMANDS = {
|
|
438
|
+
memory: `npx @nerviq/cli setup --platform ${plat}`,
|
|
439
|
+
security: `npx @nerviq/cli plan --only permissions --platform ${plat}`,
|
|
440
|
+
automation: `npx @nerviq/cli plan --only hooks --platform ${plat}`,
|
|
441
|
+
workflow: `npx @nerviq/cli plan --only commands --platform ${plat}`,
|
|
442
|
+
tools: `npx @nerviq/cli plan --mcp-pack context7 --platform ${plat}`,
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
return CATEGORY_COMMANDS[category] || `npx @nerviq/cli augment --platform ${plat}`;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function getNextScoreMilestone(score) {
|
|
449
|
+
return SCORE_MILESTONES.find((milestone) => score < milestone) || null;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function buildScoreCoaching({ score, earnedPoints, maxPoints, failed, outcomeSummaryByKey = {}, platform, fpFeedbackByKey = null }) {
|
|
453
|
+
if (!Array.isArray(failed) || failed.length === 0 || !Number.isFinite(maxPoints) || maxPoints <= 0) {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const nextMilestone = getNextScoreMilestone(score);
|
|
458
|
+
if (!nextMilestone) return null;
|
|
459
|
+
|
|
460
|
+
const targetEarnedPoints = Math.ceil((nextMilestone / 100) * maxPoints);
|
|
461
|
+
const pointsNeeded = Math.max(0, targetEarnedPoints - earnedPoints);
|
|
462
|
+
if (pointsNeeded <= 0) return null;
|
|
463
|
+
|
|
464
|
+
const rankedActions = buildTopNextActions(failed, failed.length, outcomeSummaryByKey, { platform, fpFeedbackByKey });
|
|
465
|
+
if (rankedActions.length === 0) return null;
|
|
466
|
+
|
|
467
|
+
const failedByKey = new Map(failed.map((item) => [item.key, item]));
|
|
468
|
+
const selected = [];
|
|
469
|
+
let recoveredPoints = 0;
|
|
470
|
+
|
|
471
|
+
for (const action of rankedActions) {
|
|
472
|
+
const source = failedByKey.get(action.key);
|
|
473
|
+
if (!source) continue;
|
|
474
|
+
selected.push({
|
|
475
|
+
key: source.key,
|
|
476
|
+
name: source.name,
|
|
477
|
+
impact: source.impact,
|
|
478
|
+
weight: WEIGHTS[source.impact] || 0,
|
|
479
|
+
});
|
|
480
|
+
recoveredPoints += WEIGHTS[source.impact] || 0;
|
|
481
|
+
if (recoveredPoints >= pointsNeeded) break;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (selected.length === 0) return null;
|
|
485
|
+
|
|
486
|
+
const fixesNeeded = selected.length;
|
|
487
|
+
const projectedScore = Math.round(((earnedPoints + recoveredPoints) / maxPoints) * 100);
|
|
488
|
+
const summary = `You're ${fixesNeeded} ${fixesNeeded === 1 ? 'fix' : 'fixes'} away from ${nextMilestone}/100.`;
|
|
489
|
+
|
|
490
|
+
return {
|
|
491
|
+
currentScore: score,
|
|
492
|
+
nextMilestone,
|
|
493
|
+
pointsNeeded,
|
|
494
|
+
fixesNeeded,
|
|
495
|
+
projectedScore: Math.min(100, projectedScore),
|
|
496
|
+
summary,
|
|
497
|
+
recommendedKeys: selected.map((item) => item.key),
|
|
498
|
+
recommendedNames: selected.map((item) => item.name),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function computeCategoryScores(applicable, passed) {
|
|
503
|
+
const grouped = {};
|
|
504
|
+
|
|
505
|
+
for (const item of applicable) {
|
|
506
|
+
const category = item.category || 'unknown';
|
|
507
|
+
if (!grouped[category]) {
|
|
508
|
+
grouped[category] = { passed: 0, total: 0, earnedPoints: 0, maxPoints: 0 };
|
|
509
|
+
}
|
|
510
|
+
grouped[category].total += 1;
|
|
511
|
+
grouped[category].maxPoints += WEIGHTS[item.impact] || 5;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
for (const item of passed) {
|
|
515
|
+
const category = item.category || 'unknown';
|
|
516
|
+
if (!grouped[category]) continue;
|
|
517
|
+
grouped[category].passed += 1;
|
|
518
|
+
grouped[category].earnedPoints += WEIGHTS[item.impact] || 5;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const result = {};
|
|
522
|
+
for (const [category, summary] of Object.entries(grouped)) {
|
|
523
|
+
result[category] = {
|
|
524
|
+
...summary,
|
|
525
|
+
score: summary.maxPoints > 0 ? Math.round((summary.earnedPoints / summary.maxPoints) * 100) : 0,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return result;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function inferSuggestedNextCommand(result) {
|
|
533
|
+
if (result.platform === 'codex') {
|
|
534
|
+
if (result.failed === 0) return 'npx nerviq --platform codex augment';
|
|
535
|
+
|
|
536
|
+
const actionKeys = new Set((result.topNextActions || []).map((item) => item.key));
|
|
537
|
+
if (
|
|
538
|
+
result.score < 50 ||
|
|
539
|
+
actionKeys.has('codexAgentsMd') ||
|
|
540
|
+
actionKeys.has('codexConfigExists') ||
|
|
541
|
+
actionKeys.has('codexNoDangerFullAccess') ||
|
|
542
|
+
actionKeys.has('codexApprovalPolicyExplicit')
|
|
543
|
+
) {
|
|
544
|
+
return 'npx nerviq --platform codex suggest-only';
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return 'npx nerviq --platform codex augment';
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const actionKeys = new Set((result.topNextActions || []).map((item) => item.key));
|
|
551
|
+
const platFlag = result.platform && result.platform !== 'claude' ? ` --platform ${result.platform}` : '';
|
|
552
|
+
|
|
553
|
+
if (result.failed === 0) return `npx nerviq${platFlag} augment`;
|
|
554
|
+
if (
|
|
555
|
+
result.score < 50 ||
|
|
556
|
+
actionKeys.has('claudeMd') ||
|
|
557
|
+
actionKeys.has('hooks') ||
|
|
558
|
+
actionKeys.has('settingsPermissions') ||
|
|
559
|
+
actionKeys.has('permissionDeny')
|
|
560
|
+
) {
|
|
561
|
+
return `npx nerviq${platFlag} setup`;
|
|
562
|
+
}
|
|
563
|
+
if (result.score < 80) return `npx nerviq${platFlag} suggest-only`;
|
|
564
|
+
return `npx nerviq${platFlag} augment`;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
module.exports = {
|
|
568
|
+
WEIGHTS,
|
|
569
|
+
buildScoreCoaching,
|
|
570
|
+
buildTopNextActions,
|
|
571
|
+
confidenceLabel,
|
|
572
|
+
computeCategoryScores,
|
|
573
|
+
getFpFeedbackMultiplier,
|
|
574
|
+
getQuickWins,
|
|
575
|
+
getRecommendationPriorityScore,
|
|
576
|
+
inferSuggestedNextCommand,
|
|
577
|
+
};
|