@nerviq/cli 1.29.0 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +1527 -1493
  2. package/README.md +550 -538
  3. package/SECURITY.md +82 -82
  4. package/bin/cli.js +2562 -2558
  5. package/docs/api-reference.md +356 -356
  6. package/docs/audit-fix.md +109 -0
  7. package/docs/autofix.md +3 -62
  8. package/docs/getting-started.md +1 -1
  9. package/docs/index.html +592 -592
  10. package/docs/integration-contracts.md +287 -287
  11. package/docs/maintenance.md +128 -128
  12. package/docs/new-platform-guide.md +202 -202
  13. package/docs/release-process.md +63 -0
  14. package/docs/shallow-risk.md +244 -244
  15. package/docs/why-nerviq.md +82 -82
  16. package/package.json +67 -67
  17. package/src/aider/activity.js +226 -226
  18. package/src/aider/context.js +162 -162
  19. package/src/aider/freshness.js +123 -123
  20. package/src/aider/techniques.js +3465 -3465
  21. package/src/audit/layers.js +180 -180
  22. package/src/audit.js +1032 -1032
  23. package/src/benchmark.js +299 -299
  24. package/src/codex/activity.js +324 -324
  25. package/src/codex/freshness.js +142 -142
  26. package/src/codex/techniques.js +4895 -4895
  27. package/src/context.js +326 -326
  28. package/src/continuous-ops.js +11 -1
  29. package/src/convert.js +340 -340
  30. package/src/copilot/config-parser.js +280 -280
  31. package/src/copilot/context.js +218 -218
  32. package/src/copilot/freshness.js +177 -177
  33. package/src/copilot/patch.js +238 -238
  34. package/src/copilot/techniques.js +3578 -3578
  35. package/src/cursor/freshness.js +194 -194
  36. package/src/cursor/patch.js +243 -243
  37. package/src/cursor/techniques.js +3735 -3735
  38. package/src/doctor.js +201 -201
  39. package/src/fix-engine.js +511 -8
  40. package/src/formatters/csv.js +86 -86
  41. package/src/formatters/junit.js +123 -123
  42. package/src/formatters/markdown.js +164 -164
  43. package/src/formatters/otel.js +151 -151
  44. package/src/freshness.js +156 -156
  45. package/src/gemini/activity.js +402 -402
  46. package/src/gemini/context.js +290 -290
  47. package/src/gemini/freshness.js +183 -183
  48. package/src/gemini/patch.js +229 -229
  49. package/src/gemini/techniques.js +3811 -3811
  50. package/src/governance.js +533 -533
  51. package/src/harmony/audit.js +306 -306
  52. package/src/i18n.js +63 -63
  53. package/src/insights.js +119 -119
  54. package/src/integrations.js +134 -134
  55. package/src/locales/en.json +33 -33
  56. package/src/locales/es.json +33 -33
  57. package/src/migrate.js +354 -354
  58. package/src/opencode/activity.js +286 -286
  59. package/src/opencode/freshness.js +137 -137
  60. package/src/opencode/techniques.js +3450 -3450
  61. package/src/setup/analysis.js +12 -12
  62. package/src/setup.js +7 -6
  63. package/src/shallow-risk/index.js +56 -56
  64. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +50 -50
  65. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +46 -46
  66. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +46 -46
  67. package/src/shallow-risk/patterns/agent-config-missing-file.js +317 -317
  68. package/src/shallow-risk/patterns/agent-config-secret-literal.js +49 -49
  69. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +34 -34
  70. package/src/shallow-risk/patterns/hook-script-missing.js +70 -70
  71. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +52 -52
  72. package/src/shallow-risk/shared.js +648 -648
  73. package/src/source-urls.js +295 -295
  74. package/src/state-paths.js +85 -85
  75. package/src/supplemental-checks.js +805 -805
  76. package/src/telemetry.js +160 -160
  77. package/src/windsurf/context.js +359 -359
  78. package/src/windsurf/freshness.js +194 -194
  79. package/src/windsurf/patch.js +231 -231
  80. package/src/windsurf/techniques.js +3779 -3779
@@ -1,290 +1,290 @@
1
- /**
2
- * Gemini CLI project context.
3
- *
4
- * Extends the shared ProjectContext with Gemini-specific file lookups,
5
- * settings.json parsing (JSON), and command/policy TOML parsing.
6
- */
7
-
8
- const fs = require('fs');
9
- const os = require('os');
10
- const path = require('path');
11
- const { spawnSync } = require('child_process');
12
- const { ProjectContext } = require('../context');
13
- const { tryParseJson, tryParseToml, getValueByPath } = require('./config-parser');
14
-
15
- let geminiVersionCache = null;
16
-
17
- function detectGeminiVersion() {
18
- if (geminiVersionCache !== null) {
19
- return geminiVersionCache;
20
- }
21
-
22
- try {
23
- const result = spawnSync('gemini', ['--version'], { encoding: 'utf8' });
24
- const output = `${result.stdout || ''} ${result.stderr || ''}`.trim();
25
- const match = output.match(/gemini(?:-cli)?\s+([^\s]+)/i);
26
- geminiVersionCache = match ? match[1] : (output || null);
27
- return geminiVersionCache;
28
- } catch {
29
- geminiVersionCache = null;
30
- return null;
31
- }
32
- }
33
-
34
- function listDirs(fullPath) {
35
- try {
36
- return fs.readdirSync(fullPath, { withFileTypes: true }).filter(entry => entry.isDirectory());
37
- } catch {
38
- return [];
39
- }
40
- }
41
-
42
- function listFiles(fullPath, filter) {
43
- try {
44
- const entries = fs.readdirSync(fullPath).filter(f => !f.startsWith('.'));
45
- return filter ? entries.filter(filter) : entries;
46
- } catch {
47
- return [];
48
- }
49
- }
50
-
51
- class GeminiProjectContext extends ProjectContext {
52
-
53
- // ─── GEMINI.md content ───────────────────────────────────────────────
54
-
55
- geminiMdContent() {
56
- const direct = this.fileContent('GEMINI.md');
57
- if (direct) return this._expandGeminiMdImports(direct);
58
-
59
- // Fallback: use context.fileName from settings if configured.
60
- // Per Gemini CLI spec, context.fileName may be a string or an array of strings.
61
- const contextFileName = this.configValue('context.fileName');
62
- const candidates = Array.isArray(contextFileName)
63
- ? contextFileName.filter(n => typeof n === 'string' && n.length > 0)
64
- : (typeof contextFileName === 'string' && contextFileName ? [contextFileName] : []);
65
- for (const name of candidates) {
66
- const content = this.fileContent(name);
67
- if (content) return this._expandGeminiMdImports(content);
68
- }
69
-
70
- // Further fallback: recognise common alternate instruction surfaces
71
- // (AGENTS.md, CLAUDE.md) and Gemini Code Assist styleguides
72
- // (.gemini/styleguide.md) even when not explicitly declared in settings,
73
- // mirroring how real Gemini-using repos document guidance.
74
- for (const alt of ['AGENTS.md', 'CLAUDE.md', '.gemini/styleguide.md']) {
75
- const content = this.fileContent(alt);
76
- if (content) return this._expandGeminiMdImports(content);
77
- }
78
-
79
- return null;
80
- }
81
-
82
- /**
83
- * Expand Gemini CLI-style imports inside an instructions file. Gemini CLI
84
- * supports `@path/to/file.md` imports and treats GEMINI.md files that are
85
- * a single pointer line as an alias for the referenced file. For audit
86
- * purposes we concatenate the referenced bodies so substance/architecture/
87
- * command checks see the effective instructions bundle.
88
- */
89
- _expandGeminiMdImports(content, depth = 0) {
90
- if (!content || depth > 3) return content || '';
91
- let out = content;
92
- const importRe = /@([^\s@]+\.(?:md|markdown|MD))/g;
93
- const seen = new Set();
94
- let m;
95
- while ((m = importRe.exec(content)) !== null) {
96
- const ref = m[1].replace(/^\.\//, '');
97
- if (seen.has(ref)) continue;
98
- seen.add(ref);
99
- const body = this.fileContent(ref);
100
- if (body) out += '\n\n' + this._expandGeminiMdImports(body, depth + 1);
101
- }
102
- // "Pointer" GEMINI.md: the whole file is a single relative path to another
103
- // markdown doc (no @ prefix). Observed in google/dotprompt.
104
- const trimmed = content.trim();
105
- if (/^[\w./-]+\.(md|markdown)$/.test(trimmed) && !trimmed.includes('\n')) {
106
- const body = this.fileContent(trimmed);
107
- if (body) out += '\n\n' + this._expandGeminiMdImports(body, depth + 1);
108
- }
109
- return out;
110
- }
111
-
112
- /**
113
- * Returns true when the repo exposes any Gemini-recognisable instruction
114
- * surface — GEMINI.md (directly or via context.fileName override), an
115
- * imported pointer, AGENTS.md, or CLAUDE.md. Used to gate checks that
116
- * would otherwise hard-fail on repos that use alternative conventions.
117
- */
118
- hasAnyInstructionsSurface() {
119
- return Boolean(this.geminiMdContent());
120
- }
121
-
122
- /**
123
- * Returns true when the repo exposes any evidence of Gemini CLI usage.
124
- * This is deliberately narrower than `isGeminiRepo`: it also counts
125
- * `.idx/airules.md` (Project IDX) and Gemini-specific settings keys.
126
- */
127
- hasGeminiCliSurface() {
128
- if (this.fileContent('.gemini/settings.json')) return true;
129
- if (this.fileContent('GEMINI.md')) return true;
130
- const extDirs = this.extensionDirs ? this.extensionDirs() : [];
131
- if (extDirs.length > 0) return true;
132
- const cmdFiles = this.commandFiles ? this.commandFiles() : [];
133
- if (cmdFiles.length > 0) return true;
134
- if (this.fileContent('.idx/airules.md')) return true;
135
- return false;
136
- }
137
-
138
- globalGeminiMdContent() {
139
- const homeDir = os.homedir();
140
- const globalPath = path.join(homeDir, '.gemini', 'GEMINI.md');
141
- try {
142
- return fs.readFileSync(globalPath, 'utf8');
143
- } catch {
144
- return null;
145
- }
146
- }
147
-
148
- componentGeminiMd(dirPath) {
149
- const fullPath = path.join(this.dir, dirPath, 'GEMINI.md');
150
- try {
151
- return fs.readFileSync(fullPath, 'utf8');
152
- } catch {
153
- return null;
154
- }
155
- }
156
-
157
- // ─── settings.json parsing ───────────────────────────────────────────
158
-
159
- settingsJson() {
160
- const content = this.fileContent('.gemini/settings.json');
161
- if (!content) {
162
- return { ok: false, data: null, error: 'missing project settings', source: '.gemini/settings.json' };
163
- }
164
- const parsed = tryParseJson(content);
165
- return { ...parsed, source: '.gemini/settings.json' };
166
- }
167
-
168
- globalSettingsJson() {
169
- const homeDir = os.homedir();
170
- const globalPath = path.join(homeDir, '.gemini', 'settings.json');
171
- try {
172
- const content = fs.readFileSync(globalPath, 'utf8');
173
- const parsed = tryParseJson(content);
174
- return { ...parsed, source: globalPath };
175
- } catch {
176
- return { ok: false, data: null, error: 'missing global settings', source: globalPath };
177
- }
178
- }
179
-
180
- // ─── Config value with precedence (project > global) ─────────────────
181
-
182
- configValue(key) {
183
- const project = this.settingsJson();
184
- if (project.ok) {
185
- const projectValue = getValueByPath(project.data, key);
186
- if (projectValue !== undefined) return projectValue;
187
- }
188
-
189
- const globalSettings = this.globalSettingsJson();
190
- if (globalSettings.ok) {
191
- return getValueByPath(globalSettings.data, key);
192
- }
193
-
194
- return undefined;
195
- }
196
-
197
- // ─── Hooks ────────────────────────────────────────────────────────────
198
-
199
- hooksConfig() {
200
- const hooks = this.configValue('hooks');
201
- if (!hooks || typeof hooks !== 'object') return null;
202
- return hooks;
203
- }
204
-
205
- // ─── MCP servers ──────────────────────────────────────────────────────
206
-
207
- mcpServers() {
208
- return this.configValue('mcpServers') || {};
209
- }
210
-
211
- // ─── Command files (.gemini/commands/*.toml) ──────────────────────────
212
-
213
- commandFiles() {
214
- const commandsDir = path.join(this.dir, '.gemini', 'commands');
215
- return listFiles(commandsDir, f => f.endsWith('.toml'))
216
- .map(f => path.join('.gemini', 'commands', f).replace(/\\/g, '/'));
217
- }
218
-
219
- commandConfig(fileName) {
220
- const content = this.fileContent(fileName);
221
- if (!content) return { ok: false, data: null, error: 'missing command file' };
222
- return tryParseToml(content);
223
- }
224
-
225
- // ─── Agent files (.gemini/agents/*.md) ────────────────────────────────
226
-
227
- agentFiles() {
228
- const agentsDir = path.join(this.dir, '.gemini', 'agents');
229
- return listFiles(agentsDir, f => f.endsWith('.md'))
230
- .map(f => path.join('.gemini', 'agents', f).replace(/\\/g, '/'));
231
- }
232
-
233
- // ─── Skill directories (.gemini/skills/*) ─────────────────────────────
234
-
235
- skillDirs() {
236
- const skillsDir = path.join(this.dir, '.gemini', 'skills');
237
- return listDirs(skillsDir).map(entry => entry.name);
238
- }
239
-
240
- // ─── Extension directories ────────────────────────────────────────────
241
-
242
- extensionDirs() {
243
- const extDir = path.join(this.dir, '.gemini', 'extensions');
244
- return listDirs(extDir).map(entry => entry.name);
245
- }
246
-
247
- // ─── Policy files (.gemini/policy/*.toml or .gemini/policies/*.toml) ──
248
-
249
- policyFiles() {
250
- const candidates = ['.gemini/policy', '.gemini/policies'];
251
- const files = [];
252
-
253
- for (const dirPath of candidates) {
254
- const fullPath = path.join(this.dir, dirPath);
255
- for (const f of listFiles(fullPath, fn => fn.endsWith('.toml'))) {
256
- files.push(path.join(dirPath, f).replace(/\\/g, '/'));
257
- }
258
- }
259
-
260
- return files;
261
- }
262
-
263
- policyConfig(fileName) {
264
- const content = this.fileContent(fileName);
265
- if (!content) return { ok: false, data: null, error: 'missing policy file' };
266
- return tryParseToml(content);
267
- }
268
-
269
- // ─── Static detection ─────────────────────────────────────────────────
270
-
271
- static isGeminiRepo(dir) {
272
- try {
273
- return fs.existsSync(path.join(dir, 'GEMINI.md')) ||
274
- fs.existsSync(path.join(dir, '.gemini'));
275
- } catch {
276
- return false;
277
- }
278
- }
279
-
280
- // ─── Stack detection (reuse shared) ───────────────────────────────────
281
-
282
- detectStacks(STACKS) {
283
- return super.detectStacks(STACKS);
284
- }
285
- }
286
-
287
- module.exports = {
288
- GeminiProjectContext,
289
- detectGeminiVersion,
290
- };
1
+ /**
2
+ * Gemini CLI project context.
3
+ *
4
+ * Extends the shared ProjectContext with Gemini-specific file lookups,
5
+ * settings.json parsing (JSON), and command/policy TOML parsing.
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const os = require('os');
10
+ const path = require('path');
11
+ const { spawnSync } = require('child_process');
12
+ const { ProjectContext } = require('../context');
13
+ const { tryParseJson, tryParseToml, getValueByPath } = require('./config-parser');
14
+
15
+ let geminiVersionCache = null;
16
+
17
+ function detectGeminiVersion() {
18
+ if (geminiVersionCache !== null) {
19
+ return geminiVersionCache;
20
+ }
21
+
22
+ try {
23
+ const result = spawnSync('gemini', ['--version'], { encoding: 'utf8' });
24
+ const output = `${result.stdout || ''} ${result.stderr || ''}`.trim();
25
+ const match = output.match(/gemini(?:-cli)?\s+([^\s]+)/i);
26
+ geminiVersionCache = match ? match[1] : (output || null);
27
+ return geminiVersionCache;
28
+ } catch {
29
+ geminiVersionCache = null;
30
+ return null;
31
+ }
32
+ }
33
+
34
+ function listDirs(fullPath) {
35
+ try {
36
+ return fs.readdirSync(fullPath, { withFileTypes: true }).filter(entry => entry.isDirectory());
37
+ } catch {
38
+ return [];
39
+ }
40
+ }
41
+
42
+ function listFiles(fullPath, filter) {
43
+ try {
44
+ const entries = fs.readdirSync(fullPath).filter(f => !f.startsWith('.'));
45
+ return filter ? entries.filter(filter) : entries;
46
+ } catch {
47
+ return [];
48
+ }
49
+ }
50
+
51
+ class GeminiProjectContext extends ProjectContext {
52
+
53
+ // ─── GEMINI.md content ───────────────────────────────────────────────
54
+
55
+ geminiMdContent() {
56
+ const direct = this.fileContent('GEMINI.md');
57
+ if (direct) return this._expandGeminiMdImports(direct);
58
+
59
+ // Fallback: use context.fileName from settings if configured.
60
+ // Per Gemini CLI spec, context.fileName may be a string or an array of strings.
61
+ const contextFileName = this.configValue('context.fileName');
62
+ const candidates = Array.isArray(contextFileName)
63
+ ? contextFileName.filter(n => typeof n === 'string' && n.length > 0)
64
+ : (typeof contextFileName === 'string' && contextFileName ? [contextFileName] : []);
65
+ for (const name of candidates) {
66
+ const content = this.fileContent(name);
67
+ if (content) return this._expandGeminiMdImports(content);
68
+ }
69
+
70
+ // Further fallback: recognise common alternate instruction surfaces
71
+ // (AGENTS.md, CLAUDE.md) and Gemini Code Assist styleguides
72
+ // (.gemini/styleguide.md) even when not explicitly declared in settings,
73
+ // mirroring how real Gemini-using repos document guidance.
74
+ for (const alt of ['AGENTS.md', 'CLAUDE.md', '.gemini/styleguide.md']) {
75
+ const content = this.fileContent(alt);
76
+ if (content) return this._expandGeminiMdImports(content);
77
+ }
78
+
79
+ return null;
80
+ }
81
+
82
+ /**
83
+ * Expand Gemini CLI-style imports inside an instructions file. Gemini CLI
84
+ * supports `@path/to/file.md` imports and treats GEMINI.md files that are
85
+ * a single pointer line as an alias for the referenced file. For audit
86
+ * purposes we concatenate the referenced bodies so substance/architecture/
87
+ * command checks see the effective instructions bundle.
88
+ */
89
+ _expandGeminiMdImports(content, depth = 0) {
90
+ if (!content || depth > 3) return content || '';
91
+ let out = content;
92
+ const importRe = /@([^\s@]+\.(?:md|markdown|MD))/g;
93
+ const seen = new Set();
94
+ let m;
95
+ while ((m = importRe.exec(content)) !== null) {
96
+ const ref = m[1].replace(/^\.\//, '');
97
+ if (seen.has(ref)) continue;
98
+ seen.add(ref);
99
+ const body = this.fileContent(ref);
100
+ if (body) out += '\n\n' + this._expandGeminiMdImports(body, depth + 1);
101
+ }
102
+ // "Pointer" GEMINI.md: the whole file is a single relative path to another
103
+ // markdown doc (no @ prefix). Observed in google/dotprompt.
104
+ const trimmed = content.trim();
105
+ if (/^[\w./-]+\.(md|markdown)$/.test(trimmed) && !trimmed.includes('\n')) {
106
+ const body = this.fileContent(trimmed);
107
+ if (body) out += '\n\n' + this._expandGeminiMdImports(body, depth + 1);
108
+ }
109
+ return out;
110
+ }
111
+
112
+ /**
113
+ * Returns true when the repo exposes any Gemini-recognisable instruction
114
+ * surface — GEMINI.md (directly or via context.fileName override), an
115
+ * imported pointer, AGENTS.md, or CLAUDE.md. Used to gate checks that
116
+ * would otherwise hard-fail on repos that use alternative conventions.
117
+ */
118
+ hasAnyInstructionsSurface() {
119
+ return Boolean(this.geminiMdContent());
120
+ }
121
+
122
+ /**
123
+ * Returns true when the repo exposes any evidence of Gemini CLI usage.
124
+ * This is deliberately narrower than `isGeminiRepo`: it also counts
125
+ * `.idx/airules.md` (Project IDX) and Gemini-specific settings keys.
126
+ */
127
+ hasGeminiCliSurface() {
128
+ if (this.fileContent('.gemini/settings.json')) return true;
129
+ if (this.fileContent('GEMINI.md')) return true;
130
+ const extDirs = this.extensionDirs ? this.extensionDirs() : [];
131
+ if (extDirs.length > 0) return true;
132
+ const cmdFiles = this.commandFiles ? this.commandFiles() : [];
133
+ if (cmdFiles.length > 0) return true;
134
+ if (this.fileContent('.idx/airules.md')) return true;
135
+ return false;
136
+ }
137
+
138
+ globalGeminiMdContent() {
139
+ const homeDir = os.homedir();
140
+ const globalPath = path.join(homeDir, '.gemini', 'GEMINI.md');
141
+ try {
142
+ return fs.readFileSync(globalPath, 'utf8');
143
+ } catch {
144
+ return null;
145
+ }
146
+ }
147
+
148
+ componentGeminiMd(dirPath) {
149
+ const fullPath = path.join(this.dir, dirPath, 'GEMINI.md');
150
+ try {
151
+ return fs.readFileSync(fullPath, 'utf8');
152
+ } catch {
153
+ return null;
154
+ }
155
+ }
156
+
157
+ // ─── settings.json parsing ───────────────────────────────────────────
158
+
159
+ settingsJson() {
160
+ const content = this.fileContent('.gemini/settings.json');
161
+ if (!content) {
162
+ return { ok: false, data: null, error: 'missing project settings', source: '.gemini/settings.json' };
163
+ }
164
+ const parsed = tryParseJson(content);
165
+ return { ...parsed, source: '.gemini/settings.json' };
166
+ }
167
+
168
+ globalSettingsJson() {
169
+ const homeDir = os.homedir();
170
+ const globalPath = path.join(homeDir, '.gemini', 'settings.json');
171
+ try {
172
+ const content = fs.readFileSync(globalPath, 'utf8');
173
+ const parsed = tryParseJson(content);
174
+ return { ...parsed, source: globalPath };
175
+ } catch {
176
+ return { ok: false, data: null, error: 'missing global settings', source: globalPath };
177
+ }
178
+ }
179
+
180
+ // ─── Config value with precedence (project > global) ─────────────────
181
+
182
+ configValue(key) {
183
+ const project = this.settingsJson();
184
+ if (project.ok) {
185
+ const projectValue = getValueByPath(project.data, key);
186
+ if (projectValue !== undefined) return projectValue;
187
+ }
188
+
189
+ const globalSettings = this.globalSettingsJson();
190
+ if (globalSettings.ok) {
191
+ return getValueByPath(globalSettings.data, key);
192
+ }
193
+
194
+ return undefined;
195
+ }
196
+
197
+ // ─── Hooks ────────────────────────────────────────────────────────────
198
+
199
+ hooksConfig() {
200
+ const hooks = this.configValue('hooks');
201
+ if (!hooks || typeof hooks !== 'object') return null;
202
+ return hooks;
203
+ }
204
+
205
+ // ─── MCP servers ──────────────────────────────────────────────────────
206
+
207
+ mcpServers() {
208
+ return this.configValue('mcpServers') || {};
209
+ }
210
+
211
+ // ─── Command files (.gemini/commands/*.toml) ──────────────────────────
212
+
213
+ commandFiles() {
214
+ const commandsDir = path.join(this.dir, '.gemini', 'commands');
215
+ return listFiles(commandsDir, f => f.endsWith('.toml'))
216
+ .map(f => path.join('.gemini', 'commands', f).replace(/\\/g, '/'));
217
+ }
218
+
219
+ commandConfig(fileName) {
220
+ const content = this.fileContent(fileName);
221
+ if (!content) return { ok: false, data: null, error: 'missing command file' };
222
+ return tryParseToml(content);
223
+ }
224
+
225
+ // ─── Agent files (.gemini/agents/*.md) ────────────────────────────────
226
+
227
+ agentFiles() {
228
+ const agentsDir = path.join(this.dir, '.gemini', 'agents');
229
+ return listFiles(agentsDir, f => f.endsWith('.md'))
230
+ .map(f => path.join('.gemini', 'agents', f).replace(/\\/g, '/'));
231
+ }
232
+
233
+ // ─── Skill directories (.gemini/skills/*) ─────────────────────────────
234
+
235
+ skillDirs() {
236
+ const skillsDir = path.join(this.dir, '.gemini', 'skills');
237
+ return listDirs(skillsDir).map(entry => entry.name);
238
+ }
239
+
240
+ // ─── Extension directories ────────────────────────────────────────────
241
+
242
+ extensionDirs() {
243
+ const extDir = path.join(this.dir, '.gemini', 'extensions');
244
+ return listDirs(extDir).map(entry => entry.name);
245
+ }
246
+
247
+ // ─── Policy files (.gemini/policy/*.toml or .gemini/policies/*.toml) ──
248
+
249
+ policyFiles() {
250
+ const candidates = ['.gemini/policy', '.gemini/policies'];
251
+ const files = [];
252
+
253
+ for (const dirPath of candidates) {
254
+ const fullPath = path.join(this.dir, dirPath);
255
+ for (const f of listFiles(fullPath, fn => fn.endsWith('.toml'))) {
256
+ files.push(path.join(dirPath, f).replace(/\\/g, '/'));
257
+ }
258
+ }
259
+
260
+ return files;
261
+ }
262
+
263
+ policyConfig(fileName) {
264
+ const content = this.fileContent(fileName);
265
+ if (!content) return { ok: false, data: null, error: 'missing policy file' };
266
+ return tryParseToml(content);
267
+ }
268
+
269
+ // ─── Static detection ─────────────────────────────────────────────────
270
+
271
+ static isGeminiRepo(dir) {
272
+ try {
273
+ return fs.existsSync(path.join(dir, 'GEMINI.md')) ||
274
+ fs.existsSync(path.join(dir, '.gemini'));
275
+ } catch {
276
+ return false;
277
+ }
278
+ }
279
+
280
+ // ─── Stack detection (reuse shared) ───────────────────────────────────
281
+
282
+ detectStacks(STACKS) {
283
+ return super.detectStacks(STACKS);
284
+ }
285
+ }
286
+
287
+ module.exports = {
288
+ GeminiProjectContext,
289
+ detectGeminiVersion,
290
+ };