@nerviq/cli 1.8.9 → 1.10.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.
@@ -1,204 +1,204 @@
1
- /**
2
- * Gemini Freshness Operationalization
3
- *
4
- * Release gates, recurring probes, propagation checklists,
5
- * and staleness blocking for Gemini CLI surfaces.
6
- */
7
-
8
- const { version } = require('../../package.json');
9
-
10
- /**
11
- * P0 sources that must be fresh before any Gemini release claim.
12
- * Each source has a staleness threshold in days.
13
- * From the watchlist: 62 sources, 18 P0 — main ones listed here.
14
- */
15
- const P0_SOURCES = [
16
- {
17
- key: 'gemini-cli-docs',
18
- label: 'Gemini CLI Official Docs',
19
- url: 'https://ai.google.dev/gemini-api/docs/cli',
20
- stalenessThresholdDays: 30,
21
- verifiedAt: null,
22
- },
23
- {
24
- key: 'gemini-config-reference',
25
- label: 'Gemini Config Reference',
26
- url: 'https://ai.google.dev/gemini-api/docs/cli/config',
27
- stalenessThresholdDays: 30,
28
- verifiedAt: null,
29
- },
30
- {
31
- key: 'gemini-md-guide',
32
- label: 'GEMINI.md Guide',
33
- url: 'https://ai.google.dev/gemini-api/docs/cli/gemini-md',
34
- stalenessThresholdDays: 30,
35
- verifiedAt: null,
36
- },
37
- {
38
- key: 'gemini-hooks-docs',
39
- label: 'Gemini Hooks Documentation',
40
- url: 'https://ai.google.dev/gemini-api/docs/cli/hooks',
41
- stalenessThresholdDays: 30,
42
- verifiedAt: null,
43
- },
44
- {
45
- key: 'gemini-sandbox-docs',
46
- label: 'Gemini Sandbox Documentation',
47
- url: 'https://ai.google.dev/gemini-api/docs/cli/sandbox',
48
- stalenessThresholdDays: 30,
49
- verifiedAt: null,
50
- },
51
- {
52
- key: 'gemini-policy-engine-docs',
53
- label: 'Gemini Policy Engine Documentation',
54
- url: 'https://ai.google.dev/gemini-api/docs/cli/policy',
55
- stalenessThresholdDays: 30,
56
- verifiedAt: null,
57
- },
58
- {
59
- key: 'gemini-mcp-docs',
60
- label: 'Gemini MCP Documentation',
61
- url: 'https://ai.google.dev/gemini-api/docs/cli/mcp',
62
- stalenessThresholdDays: 30,
63
- verifiedAt: null,
64
- },
65
- {
66
- key: 'gemini-changelog',
67
- label: 'Gemini CLI Changelog',
68
- url: 'https://github.com/google/gemini-cli/releases',
69
- stalenessThresholdDays: 14,
70
- verifiedAt: null,
71
- },
72
- {
73
- key: 'gemini-github-action-docs',
74
- label: 'Gemini GitHub Action Docs',
75
- url: 'https://github.com/google/gemini-action',
76
- stalenessThresholdDays: 30,
77
- verifiedAt: null,
78
- },
79
- ];
80
-
81
- /**
82
- * Propagation checklist: when a Gemini source changes, these must update.
83
- */
84
- const PROPAGATION_CHECKLIST = [
85
- {
86
- trigger: 'Gemini CLI release with config or sandbox changes',
87
- targets: [
88
- 'src/gemini/techniques.js — update LEGACY patterns, sandbox options, policy syntax',
89
- 'src/gemini/config-parser.js — update validation rules',
90
- 'src/gemini/domain-packs.js — update pack projections if schema changed',
91
- 'test/gemini-check-matrix.js — update check expectations',
92
- ],
93
- },
94
- {
95
- trigger: 'New Gemini hook event type added',
96
- targets: [
97
- 'src/gemini/techniques.js — add to SUPPORTED_HOOK_EVENTS',
98
- 'src/gemini/governance.js — add to GEMINI_HOOK_REGISTRY',
99
- 'src/gemini/setup.js — update hooks starter template',
100
- ],
101
- },
102
- {
103
- trigger: 'New Gemini MCP transport or field',
104
- targets: [
105
- 'src/gemini/mcp-packs.js — update pack JSON projections',
106
- 'src/gemini/techniques.js — update MCP checks',
107
- ],
108
- },
109
- {
110
- trigger: 'New sandbox option or isolation mode added',
111
- targets: [
112
- 'src/gemini/techniques.js — update sandbox checks',
113
- 'src/gemini/governance.js — update governance profiles with new sandbox options',
114
- 'src/gemini/setup.js — update sandbox starter template',
115
- ],
116
- },
117
- {
118
- trigger: 'Policy engine syntax or rule format change',
119
- targets: [
120
- 'src/gemini/techniques.js — update policy validation checks',
121
- 'src/gemini/governance.js — update policy templates and caveats',
122
- 'src/gemini/config-parser.js — update policy parsing rules',
123
- ],
124
- },
125
- ];
126
-
127
- /**
128
- * Release gate: check if all P0 sources are within staleness threshold.
129
- * Returns { ready, stale, fresh } arrays.
130
- */
131
- function checkReleaseGate(sourceVerifications = {}) {
132
- const now = new Date();
133
- const results = P0_SOURCES.map(source => {
134
- const verifiedAt = sourceVerifications[source.key]
135
- ? new Date(sourceVerifications[source.key])
136
- : source.verifiedAt ? new Date(source.verifiedAt) : null;
137
-
138
- if (!verifiedAt) {
139
- return { ...source, status: 'unverified', daysStale: null };
140
- }
141
-
142
- const daysSince = Math.floor((now - verifiedAt) / (1000 * 60 * 60 * 24));
143
- const isStale = daysSince > source.stalenessThresholdDays;
144
-
145
- return {
146
- ...source,
147
- verifiedAt: verifiedAt.toISOString(),
148
- daysStale: daysSince,
149
- status: isStale ? 'stale' : 'fresh',
150
- };
151
- });
152
-
153
- return {
154
- ready: results.every(r => r.status === 'fresh'),
155
- stale: results.filter(r => r.status === 'stale' || r.status === 'unverified'),
156
- fresh: results.filter(r => r.status === 'fresh'),
157
- results,
158
- };
159
- }
160
-
161
- /**
162
- * Format the release gate results for display.
163
- */
164
- function formatReleaseGate(gateResult) {
165
- const lines = [
166
- `Gemini Freshness Gate (nerviq v${version})`,
167
- '═══════════════════════════════════════',
168
- '',
169
- `Status: ${gateResult.ready ? 'READY' : 'BLOCKED'}`,
170
- `Fresh: ${gateResult.fresh.length}/${gateResult.results.length}`,
171
- '',
172
- ];
173
-
174
- for (const result of gateResult.results) {
175
- const icon = result.status === 'fresh' ? '✓' : result.status === 'stale' ? '✗' : '?';
176
- const age = result.daysStale !== null ? ` (${result.daysStale}d ago)` : ' (unverified)';
177
- lines.push(` ${icon} ${result.label}${age} — threshold: ${result.stalenessThresholdDays}d`);
178
- }
179
-
180
- if (!gateResult.ready) {
181
- lines.push('');
182
- lines.push('Action required: verify stale/unverified sources before claiming release freshness.');
183
- }
184
-
185
- return lines.join('\n');
186
- }
187
-
188
- /**
189
- * Get the propagation checklist for a given trigger.
190
- */
191
- function getPropagationTargets(triggerKeyword) {
192
- const keyword = triggerKeyword.toLowerCase();
193
- return PROPAGATION_CHECKLIST.filter(item =>
194
- item.trigger.toLowerCase().includes(keyword)
195
- );
196
- }
197
-
198
- module.exports = {
199
- P0_SOURCES,
200
- PROPAGATION_CHECKLIST,
201
- checkReleaseGate,
202
- formatReleaseGate,
203
- getPropagationTargets,
204
- };
1
+ /**
2
+ * Gemini Freshness Operationalization
3
+ *
4
+ * Release gates, recurring probes, propagation checklists,
5
+ * and staleness blocking for Gemini CLI surfaces.
6
+ */
7
+
8
+ const { version } = require('../../package.json');
9
+
10
+ /**
11
+ * P0 sources that must be fresh before any Gemini release claim.
12
+ * Each source has a staleness threshold in days.
13
+ * From the watchlist: 62 sources, 18 P0 — main ones listed here.
14
+ */
15
+ const P0_SOURCES = [
16
+ {
17
+ key: 'gemini-cli-docs',
18
+ label: 'Gemini CLI Official Docs',
19
+ url: 'https://google-gemini.github.io/gemini-cli/',
20
+ stalenessThresholdDays: 30,
21
+ verifiedAt: '2026-04-07',
22
+ },
23
+ {
24
+ key: 'gemini-config-reference',
25
+ label: 'Gemini Config Reference',
26
+ url: 'https://google-gemini.github.io/gemini-cli/docs/get-started/configuration.html',
27
+ stalenessThresholdDays: 30,
28
+ verifiedAt: '2026-04-07',
29
+ },
30
+ {
31
+ key: 'gemini-md-guide',
32
+ label: 'GEMINI.md Guide',
33
+ url: 'https://google-gemini.github.io/gemini-cli/docs/cli/gemini-md.html',
34
+ stalenessThresholdDays: 30,
35
+ verifiedAt: '2026-04-07',
36
+ },
37
+ {
38
+ key: 'gemini-hooks-docs',
39
+ label: 'Gemini Hooks Documentation',
40
+ url: 'https://google-gemini.github.io/gemini-cli/docs/hooks/',
41
+ stalenessThresholdDays: 30,
42
+ verifiedAt: '2026-04-07',
43
+ },
44
+ {
45
+ key: 'gemini-sandbox-docs',
46
+ label: 'Gemini Sandbox Documentation',
47
+ url: 'https://google-gemini.github.io/gemini-cli/docs/cli/sandbox.html',
48
+ stalenessThresholdDays: 30,
49
+ verifiedAt: '2026-04-07',
50
+ },
51
+ {
52
+ key: 'gemini-policy-engine-docs',
53
+ label: 'Gemini Enterprise / Policy Guide',
54
+ url: 'https://google-gemini.github.io/gemini-cli/docs/cli/enterprise.html',
55
+ stalenessThresholdDays: 30,
56
+ verifiedAt: '2026-04-07',
57
+ },
58
+ {
59
+ key: 'gemini-mcp-docs',
60
+ label: 'Gemini MCP Documentation',
61
+ url: 'https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html',
62
+ stalenessThresholdDays: 30,
63
+ verifiedAt: '2026-04-07',
64
+ },
65
+ {
66
+ key: 'gemini-changelog',
67
+ label: 'Gemini CLI Changelog',
68
+ url: 'https://github.com/google-gemini/gemini-cli/releases',
69
+ stalenessThresholdDays: 14,
70
+ verifiedAt: '2026-04-07',
71
+ },
72
+ {
73
+ key: 'gemini-github-action-docs',
74
+ label: 'Gemini GitHub Action',
75
+ url: 'https://github.com/google-github-actions/run-gemini-cli',
76
+ stalenessThresholdDays: 30,
77
+ verifiedAt: '2026-04-07',
78
+ },
79
+ ];
80
+
81
+ /**
82
+ * Propagation checklist: when a Gemini source changes, these must update.
83
+ */
84
+ const PROPAGATION_CHECKLIST = [
85
+ {
86
+ trigger: 'Gemini CLI release with config or sandbox changes',
87
+ targets: [
88
+ 'src/gemini/techniques.js — update LEGACY patterns, sandbox options, policy syntax',
89
+ 'src/gemini/config-parser.js — update validation rules',
90
+ 'src/gemini/domain-packs.js — update pack projections if schema changed',
91
+ 'test/gemini-check-matrix.js — update check expectations',
92
+ ],
93
+ },
94
+ {
95
+ trigger: 'New Gemini hook event type added',
96
+ targets: [
97
+ 'src/gemini/techniques.js — add to SUPPORTED_HOOK_EVENTS',
98
+ 'src/gemini/governance.js — add to GEMINI_HOOK_REGISTRY',
99
+ 'src/gemini/setup.js — update hooks starter template',
100
+ ],
101
+ },
102
+ {
103
+ trigger: 'New Gemini MCP transport or field',
104
+ targets: [
105
+ 'src/gemini/mcp-packs.js — update pack JSON projections',
106
+ 'src/gemini/techniques.js — update MCP checks',
107
+ ],
108
+ },
109
+ {
110
+ trigger: 'New sandbox option or isolation mode added',
111
+ targets: [
112
+ 'src/gemini/techniques.js — update sandbox checks',
113
+ 'src/gemini/governance.js — update governance profiles with new sandbox options',
114
+ 'src/gemini/setup.js — update sandbox starter template',
115
+ ],
116
+ },
117
+ {
118
+ trigger: 'Policy engine syntax or rule format change',
119
+ targets: [
120
+ 'src/gemini/techniques.js — update policy validation checks',
121
+ 'src/gemini/governance.js — update policy templates and caveats',
122
+ 'src/gemini/config-parser.js — update policy parsing rules',
123
+ ],
124
+ },
125
+ ];
126
+
127
+ /**
128
+ * Release gate: check if all P0 sources are within staleness threshold.
129
+ * Returns { ready, stale, fresh } arrays.
130
+ */
131
+ function checkReleaseGate(sourceVerifications = {}) {
132
+ const now = new Date();
133
+ const results = P0_SOURCES.map(source => {
134
+ const verifiedAt = sourceVerifications[source.key]
135
+ ? new Date(sourceVerifications[source.key])
136
+ : source.verifiedAt ? new Date(source.verifiedAt) : null;
137
+
138
+ if (!verifiedAt) {
139
+ return { ...source, status: 'unverified', daysStale: null };
140
+ }
141
+
142
+ const daysSince = Math.floor((now - verifiedAt) / (1000 * 60 * 60 * 24));
143
+ const isStale = daysSince > source.stalenessThresholdDays;
144
+
145
+ return {
146
+ ...source,
147
+ verifiedAt: verifiedAt.toISOString(),
148
+ daysStale: daysSince,
149
+ status: isStale ? 'stale' : 'fresh',
150
+ };
151
+ });
152
+
153
+ return {
154
+ ready: results.every(r => r.status === 'fresh'),
155
+ stale: results.filter(r => r.status === 'stale' || r.status === 'unverified'),
156
+ fresh: results.filter(r => r.status === 'fresh'),
157
+ results,
158
+ };
159
+ }
160
+
161
+ /**
162
+ * Format the release gate results for display.
163
+ */
164
+ function formatReleaseGate(gateResult) {
165
+ const lines = [
166
+ `Gemini Freshness Gate (nerviq v${version})`,
167
+ '═══════════════════════════════════════',
168
+ '',
169
+ `Status: ${gateResult.ready ? 'READY' : 'BLOCKED'}`,
170
+ `Fresh: ${gateResult.fresh.length}/${gateResult.results.length}`,
171
+ '',
172
+ ];
173
+
174
+ for (const result of gateResult.results) {
175
+ const icon = result.status === 'fresh' ? '✓' : result.status === 'stale' ? '✗' : '?';
176
+ const age = result.daysStale !== null ? ` (${result.daysStale}d ago)` : ' (unverified)';
177
+ lines.push(` ${icon} ${result.label}${age} — threshold: ${result.stalenessThresholdDays}d`);
178
+ }
179
+
180
+ if (!gateResult.ready) {
181
+ lines.push('');
182
+ lines.push('Action required: verify stale/unverified sources before claiming release freshness.');
183
+ }
184
+
185
+ return lines.join('\n');
186
+ }
187
+
188
+ /**
189
+ * Get the propagation checklist for a given trigger.
190
+ */
191
+ function getPropagationTargets(triggerKeyword) {
192
+ const keyword = triggerKeyword.toLowerCase();
193
+ return PROPAGATION_CHECKLIST.filter(item =>
194
+ item.trigger.toLowerCase().includes(keyword)
195
+ );
196
+ }
197
+
198
+ module.exports = {
199
+ P0_SOURCES,
200
+ PROPAGATION_CHECKLIST,
201
+ checkReleaseGate,
202
+ formatReleaseGate,
203
+ getPropagationTargets,
204
+ };
package/src/i18n.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Minimal i18n module for nerviq CLI.
3
+ *
4
+ * Supports locale files in src/locales/<lang>.json.
5
+ * Falls back to English for missing keys.
6
+ */
7
+
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ const SUPPORTED_LOCALES = ['en', 'es'];
12
+ const DEFAULT_LOCALE = 'en';
13
+
14
+ let currentLocale = DEFAULT_LOCALE;
15
+ let messages = {};
16
+ let fallbackMessages = {};
17
+
18
+ function loadLocale(locale) {
19
+ const file = path.join(__dirname, 'locales', `${locale}.json`);
20
+ try {
21
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
22
+ } catch {
23
+ return {};
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Initialize i18n with a locale string (e.g. 'en', 'es').
29
+ * Call this once at CLI startup.
30
+ */
31
+ function init(locale) {
32
+ const lang = (locale || process.env.NERVIQ_LANG || DEFAULT_LOCALE).toLowerCase().slice(0, 2);
33
+ currentLocale = SUPPORTED_LOCALES.includes(lang) ? lang : DEFAULT_LOCALE;
34
+ fallbackMessages = loadLocale(DEFAULT_LOCALE);
35
+ messages = currentLocale === DEFAULT_LOCALE ? fallbackMessages : loadLocale(currentLocale);
36
+ }
37
+
38
+ /**
39
+ * Translate a key with optional interpolation.
40
+ *
41
+ * Usage:
42
+ * t('audit.score', { score: 85, passed: 20, total: 25 })
43
+ * // => "Score: 85/100 (20/25 checks passing)"
44
+ */
45
+ function t(key, params = {}) {
46
+ let msg = messages[key] || fallbackMessages[key] || key;
47
+ for (const [k, v] of Object.entries(params)) {
48
+ msg = msg.replace(new RegExp(`\\{${k}\\}`, 'g'), String(v));
49
+ }
50
+ return msg;
51
+ }
52
+
53
+ /**
54
+ * Get current locale.
55
+ */
56
+ function getLocale() {
57
+ return currentLocale;
58
+ }
59
+
60
+ // Auto-init with default on first require
61
+ init();
62
+
63
+ module.exports = { init, t, getLocale, SUPPORTED_LOCALES };
@@ -0,0 +1,185 @@
1
+ const path = require('path');
2
+
3
+ const TEST_COMMAND_PATTERNS = [
4
+ /\b(?:npm|pnpm|yarn|bun)(?:\s+run)?\s+test\b/i,
5
+ /\b(?:python\s+-m\s+)?pytest\b/i,
6
+ /\bpython\s+manage\.py\s+test\b/i,
7
+ /\bdjango-admin\s+test\b/i,
8
+ /\bpython\s+-m\s+unittest\b/i,
9
+ /\bgo\s+test(?:\s|$)/i,
10
+ /\bcargo\s+test\b/i,
11
+ /\bmake\s+test\b/i,
12
+ /\bmix\s+test\b/i,
13
+ /\bbundle\s+exec\s+rspec\b/i,
14
+ /\brspec\b/i,
15
+ /\bphpunit\b/i,
16
+ /\bdotnet\s+test(?:\s|$)/i,
17
+ /\bflutter\s+test\b/i,
18
+ /\bswift\s+test\b/i,
19
+ /\bxcodebuild\b[^\n\r`]{0,200}\btest\b/i,
20
+ /\bgradlew?\s+test\b/i,
21
+ /\bmvn(?:w)?\s+test\b/i,
22
+ /\bplaywright\s+test\b/i,
23
+ /\bcypress\s+run\b/i,
24
+ ];
25
+
26
+ const LINT_COMMAND_PATTERNS = [
27
+ /\b(?:npm|pnpm|yarn|bun)(?:\s+run)?\s+lint\b/i,
28
+ /\beslint\b/i,
29
+ /\bprettier\b/i,
30
+ /\bruff(?:\s+(?:check|format))?\b/i,
31
+ /\bblack\b/i,
32
+ /\bflake8\b/i,
33
+ /\bpylint\b/i,
34
+ /\bmypy\b/i,
35
+ /\bpyright\b/i,
36
+ /\bgo\s+vet\b/i,
37
+ /\bgofmt\b/i,
38
+ /\bgofumpt\b/i,
39
+ /\bstaticcheck\b/i,
40
+ /\bgolangci-lint\b/i,
41
+ /\bcargo\s+clippy\b/i,
42
+ /\bflutter\s+analyze\b/i,
43
+ /\bdart\s+analyze\b/i,
44
+ /\bswiftlint\b/i,
45
+ /\bswift(?:-|\s+)format\b/i,
46
+ /\bdotnet\s+format(?:\s|$)/i,
47
+ /\bgradlew?\s+lint\b/i,
48
+ /\bmvn(?:w)?\s+(?:checkstyle:check|spotbugs:check|verify)\b/i,
49
+ ];
50
+
51
+ const BUILD_COMMAND_PATTERNS = [
52
+ /\b(?:npm|pnpm|yarn|bun)(?:\s+run)?\s+build\b/i,
53
+ /\btsc(?:\s|$)/i,
54
+ /\bgo\s+build(?:\s|$)/i,
55
+ /\bcargo\s+(?:build|check)\b/i,
56
+ /\bmake\s+build\b/i,
57
+ /\bdotnet\s+(?:build|publish)(?:\s|$)/i,
58
+ /\bmsbuild\b/i,
59
+ /\bflutter\s+build(?:\s|$)/i,
60
+ /\bswift\s+build\b/i,
61
+ /\bxcodebuild\b/i,
62
+ /\bgradlew?\s+(?:build|assemble)\b/i,
63
+ /\bmvn(?:w)?\s+(?:compile|package|verify|install)\b/i,
64
+ /\bpython\s+-m\s+build\b/i,
65
+ /\bpoetry\s+build\b/i,
66
+ ];
67
+
68
+ function normalizePath(filePath) {
69
+ return String(filePath || '').replace(/\\/g, '/').replace(/^\.\//, '');
70
+ }
71
+
72
+ function addSurface(ctx, surfaces, seen, filePath) {
73
+ const normalized = normalizePath(filePath);
74
+ if (!normalized || seen.has(normalized)) return;
75
+ const content = typeof ctx.fileContent === 'function' ? (ctx.fileContent(normalized) || '') : '';
76
+ if (!content.trim()) return;
77
+ seen.add(normalized);
78
+ surfaces.push({ path: normalized, content });
79
+ }
80
+
81
+ function addDirSurfaces(ctx, surfaces, seen, dirPath, filter) {
82
+ if (typeof ctx.dirFiles !== 'function') return;
83
+ for (const entry of ctx.dirFiles(dirPath) || []) {
84
+ if (filter && !filter.test(entry)) continue;
85
+ addSurface(ctx, surfaces, seen, path.join(dirPath, entry));
86
+ }
87
+ }
88
+
89
+ function buildSurfaceList(ctx, scope) {
90
+ const surfaces = [];
91
+ const seen = new Set();
92
+ const includeReadme = scope === 'repo';
93
+
94
+ addSurface(ctx, surfaces, seen, 'CLAUDE.md');
95
+ addSurface(ctx, surfaces, seen, '.claude/CLAUDE.md');
96
+ addDirSurfaces(ctx, surfaces, seen, '.claude/rules', /\.md$/i);
97
+ addDirSurfaces(ctx, surfaces, seen, '.claude/commands', /\.md$/i);
98
+ addDirSurfaces(ctx, surfaces, seen, '.claude/agents', /\.md$/i);
99
+
100
+ if (scope === 'repo') {
101
+ addSurface(ctx, surfaces, seen, 'AGENTS.md');
102
+ addSurface(ctx, surfaces, seen, 'AGENTS.override.md');
103
+ addSurface(ctx, surfaces, seen, '.cursorrules');
104
+ addSurface(ctx, surfaces, seen, '.windsurfrules');
105
+ addSurface(ctx, surfaces, seen, 'GEMINI.md');
106
+ addSurface(ctx, surfaces, seen, '.gemini/GEMINI.md');
107
+ addSurface(ctx, surfaces, seen, '.github/copilot-instructions.md');
108
+ addDirSurfaces(ctx, surfaces, seen, '.cursor/rules', /\.(md|mdc)$/i);
109
+ addDirSurfaces(ctx, surfaces, seen, '.cursor/commands', /\.md$/i);
110
+ addDirSurfaces(ctx, surfaces, seen, '.windsurf/rules', /\.md$/i);
111
+ addDirSurfaces(ctx, surfaces, seen, '.windsurf/workflows', /\.md$/i);
112
+ addDirSurfaces(ctx, surfaces, seen, '.github/instructions', /\.instructions\.md$/i);
113
+ addDirSurfaces(ctx, surfaces, seen, '.github/prompts', /\.prompt\.md$/i);
114
+ addDirSurfaces(ctx, surfaces, seen, '.opencode/commands', /\.(md|markdown|ya?ml)$/i);
115
+ addDirSurfaces(ctx, surfaces, seen, '.gemini/agents', /\.md$/i);
116
+ }
117
+
118
+ if (includeReadme) {
119
+ addSurface(ctx, surfaces, seen, 'README.md');
120
+ addSurface(ctx, surfaces, seen, 'CONTRIBUTING.md');
121
+ }
122
+
123
+ return surfaces;
124
+ }
125
+
126
+ function getSurfaceBundle(ctx, scope) {
127
+ const cacheKey = scope === 'repo' ? '__nerviqRepoInstructionBundle' : '__nerviqClaudeInstructionBundle';
128
+ if (ctx && ctx[cacheKey] !== undefined) return ctx[cacheKey];
129
+ const bundle = buildSurfaceList(ctx, scope)
130
+ .map((surface) => surface.content)
131
+ .join('\n\n');
132
+ if (ctx) ctx[cacheKey] = bundle;
133
+ return bundle;
134
+ }
135
+
136
+ function matchesAny(text, patterns) {
137
+ const normalized = String(text || '');
138
+ return patterns.some((pattern) => {
139
+ pattern.lastIndex = 0;
140
+ return pattern.test(normalized);
141
+ });
142
+ }
143
+
144
+ function hasDocumentedTestCommand(text) {
145
+ return matchesAny(text, TEST_COMMAND_PATTERNS);
146
+ }
147
+
148
+ function hasDocumentedLintCommand(text) {
149
+ return matchesAny(text, LINT_COMMAND_PATTERNS);
150
+ }
151
+
152
+ function hasDocumentedBuildCommand(text) {
153
+ return matchesAny(text, BUILD_COMMAND_PATTERNS);
154
+ }
155
+
156
+ function hasDocumentedVerificationGuidance(text) {
157
+ const normalized = String(text || '');
158
+ if (!normalized.trim()) return false;
159
+ return hasDocumentedTestCommand(normalized) ||
160
+ hasDocumentedLintCommand(normalized) ||
161
+ hasDocumentedBuildCommand(normalized) ||
162
+ (/\b(?:verification|verify|self-check|quality gate)\b/i.test(normalized) &&
163
+ matchesAny(normalized, [
164
+ ...TEST_COMMAND_PATTERNS,
165
+ ...LINT_COMMAND_PATTERNS,
166
+ ...BUILD_COMMAND_PATTERNS,
167
+ ]));
168
+ }
169
+
170
+ function getClaudeInstructionBundle(ctx) {
171
+ return getSurfaceBundle(ctx, 'claude');
172
+ }
173
+
174
+ function getRepoInstructionBundle(ctx) {
175
+ return getSurfaceBundle(ctx, 'repo');
176
+ }
177
+
178
+ module.exports = {
179
+ getClaudeInstructionBundle,
180
+ getRepoInstructionBundle,
181
+ hasDocumentedVerificationGuidance,
182
+ hasDocumentedTestCommand,
183
+ hasDocumentedLintCommand,
184
+ hasDocumentedBuildCommand,
185
+ };