@nerviq/cli 1.8.8 → 1.9.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/governance.js CHANGED
@@ -55,7 +55,7 @@ const HOOK_REGISTRY = [
55
55
  key: 'protect-secrets',
56
56
  file: '.claude/hooks/protect-secrets.sh',
57
57
  triggerPoint: 'PreToolUse',
58
- matcher: 'Read|Write|Edit',
58
+ matcher: 'Read|Write|Edit|Bash',
59
59
  purpose: 'Blocks direct access to secret or credential files before a tool runs.',
60
60
  filesTouched: [],
61
61
  sideEffects: ['Stops the action and returns a block decision when a secret path is targeted.'],
@@ -322,7 +322,7 @@ function buildHookConfig(hookFiles, profileKey) {
322
322
  const secretsFile = uniqueFiles.find(isSecrets);
323
323
  if (secretsFile) {
324
324
  hookConfig.PreToolUse = [{
325
- matcher: 'Read|Write|Edit',
325
+ matcher: 'Read|Write|Edit|Bash',
326
326
  hooks: [{
327
327
  type: 'command',
328
328
  command: hookCommand(secretsFile),
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,34 @@
1
+ {
2
+ "audit.title": "nerviq audit",
3
+ "audit.quickScan": "nerviq quick scan",
4
+ "audit.codexTitle": "nerviq codex audit",
5
+ "audit.codexQuickScan": "nerviq codex quick scan",
6
+ "audit.scanning": "Scanning: {dir}",
7
+ "audit.platform": "Platform: {platform} ({version})",
8
+ "audit.domainPacks": "Domain packs: {packs}",
9
+ "audit.scope": "Scope: {message}",
10
+ "audit.score": "Score: {score}/100 ({passed}/{total} checks passing)",
11
+ "audit.found": "Found: {files}",
12
+ "audit.excellent": "Excellent setup — production-ready governance",
13
+ "audit.strong": "Strong setup — {count} critical items to address",
14
+ "audit.good": "Good foundation — {count} items need attention",
15
+ "audit.basic": "Basic setup — significant gaps in {category}",
16
+ "audit.early": "Early stage — run `nerviq setup` to bootstrap your config",
17
+ "audit.solid": "Your {platform} setup looks solid.",
18
+ "audit.next": "Next: {command}",
19
+ "audit.quickWins": "Quick wins:",
20
+ "audit.topActions": "Top actions:",
21
+ "audit.platformCaveats": "Platform caveats:",
22
+ "audit.largeFile": "Large file: {file} ({size}KB)",
23
+ "audit.categoryScores": "Category scores:",
24
+ "audit.passed": "Passed",
25
+ "audit.failed": "Failed",
26
+ "audit.skipped": "Skipped",
27
+ "audit.details": "Details:",
28
+ "cli.help.description": "The intelligent governance layer for AI coding agents",
29
+ "cli.help.usage": "Usage: nerviq <command> [options]",
30
+ "cli.help.commands": "Commands:",
31
+ "cli.help.options": "Options:",
32
+ "cli.error.unknownCommand": "Unknown command: {command}",
33
+ "cli.error.requiresValue": "{flag} requires a value"
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "audit.title": "nerviq auditoría",
3
+ "audit.quickScan": "nerviq escaneo rápido",
4
+ "audit.codexTitle": "nerviq codex auditoría",
5
+ "audit.codexQuickScan": "nerviq codex escaneo rápido",
6
+ "audit.scanning": "Escaneando: {dir}",
7
+ "audit.platform": "Plataforma: {platform} ({version})",
8
+ "audit.domainPacks": "Paquetes de dominio: {packs}",
9
+ "audit.scope": "Alcance: {message}",
10
+ "audit.score": "Puntuación: {score}/100 ({passed}/{total} verificaciones aprobadas)",
11
+ "audit.found": "Encontrado: {files}",
12
+ "audit.excellent": "Configuración excelente — gobernanza lista para producción",
13
+ "audit.strong": "Configuración sólida — {count} elementos críticos por resolver",
14
+ "audit.good": "Buena base — {count} elementos necesitan atención",
15
+ "audit.basic": "Configuración básica — brechas significativas en {category}",
16
+ "audit.early": "Etapa inicial — ejecuta `nerviq setup` para iniciar tu configuración",
17
+ "audit.solid": "Tu configuración de {platform} se ve sólida.",
18
+ "audit.next": "Siguiente: {command}",
19
+ "audit.quickWins": "Mejoras rápidas:",
20
+ "audit.topActions": "Acciones principales:",
21
+ "audit.platformCaveats": "Advertencias de plataforma:",
22
+ "audit.largeFile": "Archivo grande: {file} ({size}KB)",
23
+ "audit.categoryScores": "Puntuaciones por categoría:",
24
+ "audit.passed": "Aprobado",
25
+ "audit.failed": "Fallido",
26
+ "audit.skipped": "Omitido",
27
+ "audit.details": "Detalles:",
28
+ "cli.help.description": "La capa de gobernanza inteligente para agentes de codificación IA",
29
+ "cli.help.usage": "Uso: nerviq <comando> [opciones]",
30
+ "cli.help.commands": "Comandos:",
31
+ "cli.help.options": "Opciones:",
32
+ "cli.error.unknownCommand": "Comando desconocido: {command}",
33
+ "cli.error.requiresValue": "{flag} requiere un valor"
34
+ }