@stupidloud/codegraph 0.7.15 → 0.8.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 (147) hide show
  1. package/README.md +82 -58
  2. package/dist/bin/codegraph.js +127 -24
  3. package/dist/bin/codegraph.js.map +1 -1
  4. package/dist/bin/node-version-check.d.ts +3 -0
  5. package/dist/bin/node-version-check.d.ts.map +1 -1
  6. package/dist/bin/node-version-check.js +5 -2
  7. package/dist/bin/node-version-check.js.map +1 -1
  8. package/dist/bin/uninstall.d.ts +7 -7
  9. package/dist/bin/uninstall.d.ts.map +1 -1
  10. package/dist/bin/uninstall.js +23 -135
  11. package/dist/bin/uninstall.js.map +1 -1
  12. package/dist/context/index.d.ts.map +1 -1
  13. package/dist/context/index.js +4 -2
  14. package/dist/context/index.js.map +1 -1
  15. package/dist/db/queries.d.ts.map +1 -1
  16. package/dist/db/queries.js +7 -1
  17. package/dist/db/queries.js.map +1 -1
  18. package/dist/extraction/index.d.ts +1 -1
  19. package/dist/extraction/index.d.ts.map +1 -1
  20. package/dist/extraction/index.js +63 -37
  21. package/dist/extraction/index.js.map +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +3 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/installer/claude-md-template.d.ts +10 -6
  26. package/dist/installer/claude-md-template.d.ts.map +1 -1
  27. package/dist/installer/claude-md-template.js +15 -40
  28. package/dist/installer/claude-md-template.js.map +1 -1
  29. package/dist/installer/config-writer.d.ts +17 -24
  30. package/dist/installer/config-writer.d.ts.map +1 -1
  31. package/dist/installer/config-writer.js +46 -239
  32. package/dist/installer/config-writer.js.map +1 -1
  33. package/dist/installer/index.d.ts +57 -4
  34. package/dist/installer/index.d.ts.map +1 -1
  35. package/dist/installer/index.js +286 -81
  36. package/dist/installer/index.js.map +1 -1
  37. package/dist/installer/instructions-template.d.ts +28 -0
  38. package/dist/installer/instructions-template.d.ts.map +1 -0
  39. package/dist/installer/instructions-template.js +65 -0
  40. package/dist/installer/instructions-template.js.map +1 -0
  41. package/dist/installer/targets/claude.d.ts +31 -0
  42. package/dist/installer/targets/claude.d.ts.map +1 -0
  43. package/dist/installer/targets/claude.js +308 -0
  44. package/dist/installer/targets/claude.js.map +1 -0
  45. package/dist/installer/targets/codex.d.ts +18 -0
  46. package/dist/installer/targets/codex.d.ts.map +1 -0
  47. package/dist/installer/targets/codex.js +185 -0
  48. package/dist/installer/targets/codex.js.map +1 -0
  49. package/dist/installer/targets/cursor.d.ts +35 -0
  50. package/dist/installer/targets/cursor.d.ts.map +1 -0
  51. package/dist/installer/targets/cursor.js +229 -0
  52. package/dist/installer/targets/cursor.js.map +1 -0
  53. package/dist/installer/targets/opencode.d.ts +30 -0
  54. package/dist/installer/targets/opencode.d.ts.map +1 -0
  55. package/dist/installer/targets/opencode.js +235 -0
  56. package/dist/installer/targets/opencode.js.map +1 -0
  57. package/dist/installer/targets/registry.d.ts +35 -0
  58. package/dist/installer/targets/registry.d.ts.map +1 -0
  59. package/dist/installer/targets/registry.js +83 -0
  60. package/dist/installer/targets/registry.js.map +1 -0
  61. package/dist/installer/targets/shared.d.ts +77 -0
  62. package/dist/installer/targets/shared.d.ts.map +1 -0
  63. package/dist/installer/targets/shared.js +246 -0
  64. package/dist/installer/targets/shared.js.map +1 -0
  65. package/dist/installer/targets/toml.d.ts +52 -0
  66. package/dist/installer/targets/toml.d.ts.map +1 -0
  67. package/dist/installer/targets/toml.js +147 -0
  68. package/dist/installer/targets/toml.js.map +1 -0
  69. package/dist/installer/targets/types.d.ts +116 -0
  70. package/dist/installer/targets/types.d.ts.map +1 -0
  71. package/dist/installer/targets/types.js +16 -0
  72. package/dist/installer/targets/types.js.map +1 -0
  73. package/dist/mcp/index.d.ts +12 -0
  74. package/dist/mcp/index.d.ts.map +1 -1
  75. package/dist/mcp/index.js +143 -20
  76. package/dist/mcp/index.js.map +1 -1
  77. package/dist/mcp/server-instructions.d.ts +1 -1
  78. package/dist/mcp/server-instructions.d.ts.map +1 -1
  79. package/dist/mcp/server-instructions.js +20 -5
  80. package/dist/mcp/server-instructions.js.map +1 -1
  81. package/dist/mcp/tools.d.ts +75 -5
  82. package/dist/mcp/tools.d.ts.map +1 -1
  83. package/dist/mcp/tools.js +472 -89
  84. package/dist/mcp/tools.js.map +1 -1
  85. package/dist/mcp/transport.d.ts +17 -0
  86. package/dist/mcp/transport.d.ts.map +1 -1
  87. package/dist/mcp/transport.js +63 -0
  88. package/dist/mcp/transport.js.map +1 -1
  89. package/dist/resolution/frameworks/index.d.ts +1 -0
  90. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  91. package/dist/resolution/frameworks/index.js +5 -1
  92. package/dist/resolution/frameworks/index.js.map +1 -1
  93. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  94. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  95. package/dist/resolution/frameworks/nestjs.js +374 -0
  96. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  97. package/dist/search/query-utils.d.ts.map +1 -1
  98. package/dist/search/query-utils.js +29 -26
  99. package/dist/search/query-utils.js.map +1 -1
  100. package/dist/sync/git-hooks.d.ts +45 -0
  101. package/dist/sync/git-hooks.d.ts.map +1 -0
  102. package/dist/sync/git-hooks.js +223 -0
  103. package/dist/sync/git-hooks.js.map +1 -0
  104. package/dist/sync/index.d.ts +4 -0
  105. package/dist/sync/index.d.ts.map +1 -1
  106. package/dist/sync/index.js +12 -1
  107. package/dist/sync/index.js.map +1 -1
  108. package/dist/sync/watch-policy.d.ts +48 -0
  109. package/dist/sync/watch-policy.d.ts.map +1 -0
  110. package/dist/sync/watch-policy.js +124 -0
  111. package/dist/sync/watch-policy.js.map +1 -0
  112. package/dist/sync/watcher.d.ts.map +1 -1
  113. package/dist/sync/watcher.js +10 -0
  114. package/dist/sync/watcher.js.map +1 -1
  115. package/dist/ui/glyphs.d.ts +42 -0
  116. package/dist/ui/glyphs.d.ts.map +1 -0
  117. package/dist/ui/glyphs.js +78 -0
  118. package/dist/ui/glyphs.js.map +1 -0
  119. package/dist/ui/shimmer-progress.d.ts +1 -0
  120. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  121. package/dist/ui/shimmer-progress.js +7 -0
  122. package/dist/ui/shimmer-progress.js.map +1 -1
  123. package/dist/ui/shimmer-worker.js +20 -11
  124. package/dist/ui/shimmer-worker.js.map +1 -1
  125. package/dist/ui/types.d.ts +1 -0
  126. package/dist/ui/types.d.ts.map +1 -1
  127. package/dist/vectors/embedder.d.ts +11 -1
  128. package/dist/vectors/embedder.d.ts.map +1 -1
  129. package/dist/vectors/embedder.js +48 -18
  130. package/dist/vectors/embedder.js.map +1 -1
  131. package/dist/vectors/index.d.ts +1 -1
  132. package/dist/vectors/index.d.ts.map +1 -1
  133. package/dist/vectors/index.js.map +1 -1
  134. package/dist/vectors/manager.d.ts +5 -0
  135. package/dist/vectors/manager.d.ts.map +1 -1
  136. package/dist/vectors/manager.js +44 -23
  137. package/dist/vectors/manager.js.map +1 -1
  138. package/package.json +4 -3
  139. package/scripts/agent-eval/audit.sh +68 -0
  140. package/scripts/agent-eval/itrun.sh +107 -0
  141. package/scripts/agent-eval/parse-run.mjs +45 -0
  142. package/scripts/agent-eval/parse-session.mjs +93 -0
  143. package/scripts/agent-eval/run-agent.sh +34 -0
  144. package/scripts/agent-eval/run-all.sh +67 -0
  145. package/scripts/extract-release-notes.mjs +130 -0
  146. package/scripts/local-install.sh +41 -0
  147. package/scripts/release.sh +68 -0
@@ -2,7 +2,14 @@
2
2
  /**
3
3
  * CodeGraph Interactive Installer
4
4
  *
5
- * Uses @clack/prompts for a polished interactive CLI experience.
5
+ * Multi-target: writes MCP server config + instructions for the
6
+ * agents the user picks (Claude Code, Cursor, Codex CLI, opencode).
7
+ * Defaults to the Claude-only behavior for backwards compatibility
8
+ * when no targets are explicitly chosen and nothing else is detected.
9
+ *
10
+ * Uses @clack/prompts for the interactive UI; `runInstallerWithOptions`
11
+ * is the non-interactive entry point used by the `--target` /
12
+ * `--print-config` CLI flags.
6
13
  */
7
14
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
15
  if (k2 === undefined) k2 = k;
@@ -38,24 +45,38 @@ var __importStar = (this && this.__importStar) || (function () {
38
45
  };
39
46
  })();
40
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.hasClaudeMdSection = exports.hasPermissions = exports.hasMcpConfig = exports.writeClaudeMd = exports.writePermissions = exports.writeMcpConfig = void 0;
41
49
  exports.runInstaller = runInstaller;
50
+ exports.runInstallerWithOptions = runInstallerWithOptions;
51
+ exports.wireProjectSurfacesForGlobalAgents = wireProjectSurfacesForGlobalAgents;
52
+ exports.offerWatchFallback = offerWatchFallback;
42
53
  const child_process_1 = require("child_process");
43
54
  const path = __importStar(require("path"));
44
55
  const fs = __importStar(require("fs"));
45
- const config_writer_1 = require("./config-writer");
56
+ const registry_1 = require("./targets/registry");
57
+ const glyphs_1 = require("../ui/glyphs");
58
+ // Import the lightweight submodules directly (not the ../sync barrel, which
59
+ // re-exports FileWatcher and would transitively pull in ../extraction — the
60
+ // installer must stay importable even when native modules can't load).
61
+ const watch_policy_1 = require("../sync/watch-policy");
62
+ const git_hooks_1 = require("../sync/git-hooks");
63
+ // Backwards-compat: keep these named exports — downstream code may
64
+ // import them. The shim in `config-writer.ts` continues to re-export
65
+ // them too.
66
+ var config_writer_1 = require("./config-writer");
67
+ Object.defineProperty(exports, "writeMcpConfig", { enumerable: true, get: function () { return config_writer_1.writeMcpConfig; } });
68
+ Object.defineProperty(exports, "writePermissions", { enumerable: true, get: function () { return config_writer_1.writePermissions; } });
69
+ Object.defineProperty(exports, "writeClaudeMd", { enumerable: true, get: function () { return config_writer_1.writeClaudeMd; } });
70
+ Object.defineProperty(exports, "hasMcpConfig", { enumerable: true, get: function () { return config_writer_1.hasMcpConfig; } });
71
+ Object.defineProperty(exports, "hasPermissions", { enumerable: true, get: function () { return config_writer_1.hasPermissions; } });
72
+ Object.defineProperty(exports, "hasClaudeMdSection", { enumerable: true, get: function () { return config_writer_1.hasClaudeMdSection; } });
46
73
  // Dynamic import helper — tsc compiles import() to require() in CJS mode,
47
74
  // which fails for ESM-only packages. This bypasses the transformation.
48
75
  // eslint-disable-next-line @typescript-eslint/no-implied-eval
49
76
  const importESM = new Function('specifier', 'return import(specifier)');
50
- /**
51
- * Format a number with commas
52
- */
53
77
  function formatNumber(n) {
54
78
  return n.toLocaleString();
55
79
  }
56
- /**
57
- * Get the package version
58
- */
59
80
  function getVersion() {
60
81
  try {
61
82
  const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');
@@ -67,103 +88,226 @@ function getVersion() {
67
88
  }
68
89
  }
69
90
  /**
70
- * Run the interactive installer
91
+ * Interactive entry point — preserves the historical UX (`codegraph
92
+ * install` with no args goes through the prompts), but now starts
93
+ * the targets multi-select pre-populated with detected agents.
71
94
  */
72
95
  async function runInstaller() {
96
+ return runInstallerWithOptions({});
97
+ }
98
+ async function runInstallerWithOptions(opts) {
73
99
  const clack = await importESM('@clack/prompts');
74
100
  clack.intro(`CodeGraph v${getVersion()}`);
75
- // Step 1: Install globally
76
- const shouldInstallGlobally = await clack.confirm({
77
- message: 'Install codegraph globally? (Required for MCP server)',
78
- initialValue: true,
79
- });
80
- if (clack.isCancel(shouldInstallGlobally)) {
81
- clack.cancel('Installation cancelled.');
82
- process.exit(0);
101
+ // --yes implies all defaults; explicit flags still win.
102
+ const useDefaults = opts.yes === true;
103
+ // Step 1: which agent targets? Asked FIRST so the user knows what
104
+ // they're committing to before we touch npm or disk. Detection
105
+ // probes the user-provided location if known, else 'global' as the
106
+ // most common default — labels are a hint, not load-bearing.
107
+ const detectionLocation = opts.location ?? 'global';
108
+ const targets = await resolveTargets(clack, opts, detectionLocation, useDefaults);
109
+ if (targets.length === 0) {
110
+ clack.outro('No agent targets selected — nothing to do.');
111
+ return;
83
112
  }
84
- if (shouldInstallGlobally) {
85
- const s = clack.spinner();
86
- s.start('Installing codegraph globally...');
87
- try {
88
- (0, child_process_1.execSync)('npm install -g @stupidloud/codegraph', { stdio: 'pipe' });
89
- s.stop('Installed codegraph globally');
113
+ // Step 2: install the codegraph npm package on PATH (always offered;
114
+ // matches existing behavior). Skipped when --yes (assume present).
115
+ if (!useDefaults) {
116
+ const shouldInstallGlobally = await clack.confirm({
117
+ message: 'Install the codegraph CLI on your PATH? (Required so agents can launch the MCP server)',
118
+ initialValue: true,
119
+ });
120
+ if (clack.isCancel(shouldInstallGlobally)) {
121
+ clack.cancel('Installation cancelled.');
122
+ process.exit(0);
90
123
  }
91
- catch {
92
- s.stop('Could not install globally (permission denied)');
93
- clack.log.warn('Try: sudo npm install -g @stupidloud/codegraph');
124
+ if (shouldInstallGlobally) {
125
+ const s = clack.spinner();
126
+ s.start('Installing codegraph CLI...');
127
+ try {
128
+ (0, child_process_1.execSync)('npm install -g @stupidloud/codegraph', { stdio: 'pipe' });
129
+ s.stop('Installed codegraph CLI on PATH');
130
+ }
131
+ catch {
132
+ s.stop('Could not install (permission denied)');
133
+ clack.log.warn('Try: sudo npm install -g @stupidloud/codegraph');
134
+ }
94
135
  }
136
+ else {
137
+ clack.log.info('Skipped CLI install — agents will not be able to launch the MCP server without it');
138
+ }
139
+ }
140
+ // Step 3: where the per-agent config files should land.
141
+ let location;
142
+ if (opts.location) {
143
+ location = opts.location;
144
+ }
145
+ else if (useDefaults) {
146
+ location = 'global';
95
147
  }
96
148
  else {
97
- clack.log.info('Skipped global install MCP server may not work without it');
98
- }
99
- // Step 2: Installation location
100
- const location = await clack.select({
101
- message: 'Where would you like to install?',
102
- options: [
103
- { value: 'global', label: 'Global', hint: '~/.claude available in all projects' },
104
- { value: 'local', label: 'Local', hint: './.claude — this project only' },
105
- ],
106
- initialValue: 'global',
107
- });
108
- if (clack.isCancel(location)) {
109
- clack.cancel('Installation cancelled.');
110
- process.exit(0);
149
+ // If every selected target is global-only (e.g. Codex), skip the
150
+ // prompt and force user-wide — project-local would just produce
151
+ // skip warnings.
152
+ const allGlobalOnly = targets.every((t) => !t.supportsLocation('local'));
153
+ if (allGlobalOnly) {
154
+ location = 'global';
155
+ clack.log.info('Writing user-wide configs (selected agents have no project-local config).');
156
+ }
157
+ else {
158
+ const sel = await clack.select({
159
+ message: 'Apply agent configs to all your projects, or just this one?',
160
+ options: [
161
+ { value: 'global', label: 'All projects', hint: '~/.claude, ~/.cursor, etc.' },
162
+ { value: 'local', label: 'Just this project', hint: './.claude, ./.cursor, etc.' },
163
+ ],
164
+ initialValue: 'global',
165
+ });
166
+ if (clack.isCancel(sel)) {
167
+ clack.cancel('Installation cancelled.');
168
+ process.exit(0);
169
+ }
170
+ location = sel;
171
+ }
111
172
  }
112
- // Step 3: Auto-allow permissions
113
- const autoAllow = await clack.confirm({
114
- message: 'Auto-allow CodeGraph commands? (Skips permission prompts)',
115
- initialValue: true,
116
- });
117
- if (clack.isCancel(autoAllow)) {
118
- clack.cancel('Installation cancelled.');
119
- process.exit(0);
173
+ // Step 4: auto-allow permissions (only meaningful for Claude;
174
+ // skipped silently by other targets).
175
+ let autoAllow;
176
+ if (opts.autoAllow !== undefined) {
177
+ autoAllow = opts.autoAllow;
178
+ }
179
+ else if (useDefaults) {
180
+ autoAllow = true;
181
+ }
182
+ else if (targets.some((t) => t.id === 'claude')) {
183
+ const ans = await clack.confirm({
184
+ message: 'Auto-allow CodeGraph commands? (Skips permission prompts in Claude Code)',
185
+ initialValue: true,
186
+ });
187
+ if (clack.isCancel(ans)) {
188
+ clack.cancel('Installation cancelled.');
189
+ process.exit(0);
190
+ }
191
+ autoAllow = ans;
192
+ }
193
+ else {
194
+ autoAllow = false;
195
+ }
196
+ // Step 5: per-target install loop.
197
+ for (const target of targets) {
198
+ if (!target.supportsLocation(location)) {
199
+ clack.log.warn(`${target.displayName}: skipped — does not support --location=${location}.`);
200
+ continue;
201
+ }
202
+ const result = target.install(location, { autoAllow });
203
+ for (const file of result.files) {
204
+ const verb = file.action === 'unchanged'
205
+ ? 'Unchanged'
206
+ : file.action === 'created' ? 'Created' : 'Updated';
207
+ clack.log.success(`${target.displayName}: ${verb} ${tildify(file.path)}`);
208
+ }
209
+ for (const note of result.notes ?? []) {
210
+ clack.log.info(`${target.displayName}: ${note}`);
211
+ }
120
212
  }
121
- // Step 4: Write configuration files
122
- writeConfigs(clack, location, autoAllow);
123
- // Step 5: For local install, initialize the project
213
+ // Step 6: for local install, initialize the project.
124
214
  if (location === 'local') {
125
- await initializeLocalProject(clack);
215
+ await initializeLocalProject(clack, useDefaults);
126
216
  }
127
- // Done
128
217
  if (location === 'global') {
129
218
  clack.note('cd your-project\ncodegraph init -i', 'Quick start');
130
219
  }
131
- clack.outro('Done! Restart Claude Code to use CodeGraph.');
220
+ const finalNote = targets.length > 0
221
+ ? `Done! Restart your agent${targets.length > 1 ? 's' : ''} to use CodeGraph.`
222
+ : 'Done!';
223
+ clack.outro(finalNote);
132
224
  }
133
225
  /**
134
- * Write all configuration files and log results
226
+ * For every target that has a global config and exposes
227
+ * `wireProjectSurfaces`, write its project-local surfaces (e.g.
228
+ * Cursor's `.cursor/rules/codegraph.mdc`). Idempotent — runs
229
+ * silently when there's nothing to write.
230
+ *
231
+ * Called by `codegraph init` so that a user who ran
232
+ * `codegraph install` once globally doesn't have to re-run it per
233
+ * project to get full agent support.
234
+ *
235
+ * Returns the list of `(target, file)` pairs that were created or
236
+ * updated — caller decides how to surface them.
135
237
  */
136
- function writeConfigs(clack, location, autoAllow) {
137
- const locationLabel = location === 'global' ? '~/.claude' : './.claude';
138
- // MCP config
139
- const mcpAction = (0, config_writer_1.hasMcpConfig)(location) ? 'Updated' : 'Added';
140
- (0, config_writer_1.writeMcpConfig)(location);
141
- clack.log.success(`${mcpAction} MCP server in ${locationLabel}.json`);
142
- // Permissions
143
- if (autoAllow) {
144
- const permAction = (0, config_writer_1.hasPermissions)(location) ? 'Updated' : 'Added';
145
- (0, config_writer_1.writePermissions)(location);
146
- clack.log.success(`${permAction} permissions in ${locationLabel}/settings.json`);
147
- }
148
- // CLAUDE.md
149
- const claudeMdResult = (0, config_writer_1.writeClaudeMd)(location);
150
- const claudeMdPath = `${locationLabel}/CLAUDE.md`;
151
- if (claudeMdResult.created) {
152
- clack.log.success(`Created ${claudeMdPath}`);
153
- }
154
- else if (claudeMdResult.updated) {
155
- clack.log.success(`Updated ${claudeMdPath}`);
238
+ function wireProjectSurfacesForGlobalAgents() {
239
+ const written = [];
240
+ for (const target of registry_1.ALL_TARGETS) {
241
+ if (typeof target.wireProjectSurfaces !== 'function')
242
+ continue;
243
+ const detection = target.detect('global');
244
+ if (!detection.alreadyConfigured)
245
+ continue;
246
+ const result = target.wireProjectSurfaces();
247
+ for (const file of result.files) {
248
+ if (file.action === 'created' || file.action === 'updated') {
249
+ written.push({ target, file });
250
+ }
251
+ }
156
252
  }
157
- else {
158
- clack.log.success(`Added CodeGraph instructions to ${claudeMdPath}`);
253
+ return written;
254
+ }
255
+ /**
256
+ * Replace home-directory prefix in a path with `~/` for cleaner log
257
+ * lines. Pure cosmetic.
258
+ */
259
+ function tildify(p) {
260
+ const home = require('os').homedir();
261
+ if (p.startsWith(home + path.sep))
262
+ return '~' + p.substring(home.length);
263
+ return p;
264
+ }
265
+ async function resolveTargets(clack, opts, location, useDefaults) {
266
+ // Explicit --target flag wins.
267
+ if (opts.target !== undefined) {
268
+ return (0, registry_1.resolveTargetFlag)(opts.target, location);
159
269
  }
270
+ // --yes implies auto-detect.
271
+ if (useDefaults) {
272
+ return (0, registry_1.resolveTargetFlag)('auto', location);
273
+ }
274
+ // Interactive multi-select.
275
+ const detected = (0, registry_1.detectAll)(location);
276
+ const initialValues = detected
277
+ .filter(({ detection }) => detection.installed)
278
+ .map(({ target }) => target.id);
279
+ // If nothing detected, default to Claude alone (matches the
280
+ // historical default and the smallest-surprise outcome).
281
+ const initial = initialValues.length > 0 ? initialValues : ['claude'];
282
+ const choice = await clack.multiselect({
283
+ message: 'Which agents should CodeGraph configure?',
284
+ options: registry_1.ALL_TARGETS.map((t) => {
285
+ const det = detected.find(({ target }) => target.id === t.id).detection;
286
+ const flag = det.installed ? '(detected)' : '(not found)';
287
+ const globalOnly = !t.supportsLocation('local') ? ' — global only' : '';
288
+ return {
289
+ value: t.id,
290
+ label: `${t.displayName} ${flag}${globalOnly}`,
291
+ };
292
+ }),
293
+ initialValues: initial,
294
+ required: false,
295
+ });
296
+ if (clack.isCancel(choice)) {
297
+ clack.cancel('Installation cancelled.');
298
+ process.exit(0);
299
+ }
300
+ return choice
301
+ .map((id) => (0, registry_1.getTarget)(id))
302
+ .filter((t) => t !== undefined);
160
303
  }
161
304
  /**
162
- * Initialize CodeGraph in the current project (for local installs)
305
+ * Initialize CodeGraph in the current project (for local installs), then
306
+ * offer the watch fallback when the live watcher won't run here (see
307
+ * offerWatchFallback). Agent-agnostic by nature.
163
308
  */
164
- async function initializeLocalProject(clack) {
309
+ async function initializeLocalProject(clack, useDefaults = false) {
165
310
  const projectPath = process.cwd();
166
- // Lazy-load CodeGraph (requires native modules)
167
311
  let CodeGraph;
168
312
  try {
169
313
  CodeGraph = (await Promise.resolve().then(() => __importStar(require('../index')))).default;
@@ -177,6 +321,7 @@ async function initializeLocalProject(clack) {
177
321
  // Check if already initialized
178
322
  if (CodeGraph.isInitialized(projectPath)) {
179
323
  clack.log.info('CodeGraph already initialized in this project');
324
+ await offerWatchFallback(clack, projectPath, { yes: useDefaults });
180
325
  return;
181
326
  }
182
327
  // Initialize
@@ -186,7 +331,7 @@ async function initializeLocalProject(clack) {
186
331
  clack.log.success('Created .codegraph/ directory');
187
332
  // Index the project with shimmer progress (worker thread for smooth animation)
188
333
  const { createShimmerProgress } = await Promise.resolve().then(() => __importStar(require('../ui/shimmer-progress')));
189
- process.stdout.write(`\x1b[2m│\x1b[0m\n`);
334
+ process.stdout.write(`\x1b[2m${(0, glyphs_1.getGlyphs)().rail}\x1b[0m\n`);
190
335
  const progress = createShimmerProgress();
191
336
  const result = await cg.indexAll({
192
337
  onProgress: progress.onProgress,
@@ -199,5 +344,65 @@ async function initializeLocalProject(clack) {
199
344
  clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files (${formatNumber(result.nodesCreated)} symbols)`);
200
345
  }
201
346
  cg.close();
347
+ await offerWatchFallback(clack, projectPath, { yes: useDefaults });
348
+ }
349
+ /**
350
+ * When the live file watcher will be disabled for this project (e.g. WSL2
351
+ * /mnt drives, or CODEGRAPH_NO_WATCH), the index would silently go stale.
352
+ * Explain that, and offer to keep it fresh automatically via git hooks
353
+ * (commit / pull / checkout) instead of manual `codegraph sync`.
354
+ *
355
+ * No-op on environments where the watcher runs normally, so it's safe to
356
+ * call unconditionally after init.
357
+ */
358
+ async function offerWatchFallback(clack, projectPath, opts = {}) {
359
+ const reason = (0, watch_policy_1.watchDisabledReason)(projectPath);
360
+ if (!reason)
361
+ return; // Watcher runs normally — nothing to set up.
362
+ clack.log.warn(`Live file watching is disabled here — ${reason}.`);
363
+ clack.log.info('Until you re-sync, the CodeGraph index stays frozen — it will not pick up edits on its own.');
364
+ // No git repo → the commit-hook path doesn't apply; point at manual sync.
365
+ if (!(0, git_hooks_1.isGitRepo)(projectPath)) {
366
+ clack.log.info('Run `codegraph sync` after changing files to refresh the index.');
367
+ return;
368
+ }
369
+ // Already wired up on a previous run — confirm and move on without nagging.
370
+ if ((0, git_hooks_1.isSyncHookInstalled)(projectPath)) {
371
+ clack.log.info('Git sync hooks are already installed — the index refreshes after commit / pull / checkout.');
372
+ return;
373
+ }
374
+ let choice;
375
+ if (opts.yes) {
376
+ choice = 'hook';
377
+ }
378
+ else {
379
+ const sel = await clack.select({
380
+ message: 'How should CodeGraph keep its index fresh?',
381
+ options: [
382
+ { value: 'hook', label: 'Sync on git commit / pull / checkout', hint: 'installs git hooks (recommended)' },
383
+ { value: 'manual', label: 'I\'ll run `codegraph sync` myself', hint: 'fully manual' },
384
+ ],
385
+ initialValue: 'hook',
386
+ });
387
+ if (clack.isCancel(sel)) {
388
+ clack.log.info('Skipped — run `codegraph sync` after changes to refresh the index.');
389
+ return;
390
+ }
391
+ choice = sel;
392
+ }
393
+ if (choice === 'manual') {
394
+ clack.log.info('Run `codegraph sync` after changing files to refresh the index.');
395
+ return;
396
+ }
397
+ const result = (0, git_hooks_1.installGitSyncHook)(projectPath);
398
+ if (result.installed.length > 0) {
399
+ clack.log.success(`Installed git ${result.installed.join(', ')} hook${result.installed.length > 1 ? 's' : ''} — ` +
400
+ 'the index refreshes in the background after each.');
401
+ clack.log.info('Run `codegraph sync` anytime to refresh immediately.');
402
+ }
403
+ else {
404
+ clack.log.warn(`Could not install git hooks${result.skipped ? ` (${result.skipped})` : ''}. ` +
405
+ 'Run `codegraph sync` after changes instead.');
406
+ }
202
407
  }
203
408
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/installer/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCH,oCAyEC;AAhHD,iDAAyC;AACzC,2CAA6B;AAC7B,uCAAyB;AACzB,mDAGyB;AAIzB,0EAA0E;AAC1E,uEAAuE;AACvE,8DAA8D;AAC9D,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CACL,CAAC;AAElE;;GAEG;AACH,SAAS,YAAY,CAAC,CAAS;IAC7B,OAAO,CAAC,CAAC,cAAc,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,C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nH,EAAE,KAAK,EAAE,QAAiB,EAAE,KAAK,EAAE,mCAAmC,EAAE,IAAI,EAAE,cAAc,EAAE;aAC/F;YACD,YAAY,EAAE,MAAe;SAC9B,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;YACrF,OAAO;QACT,CAAC;QACD,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IAED,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;QAClF,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,8BAAkB,EAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,iBAAiB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK;YAC/F,mDAAmD,CACpD,CAAC;QACF,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8BAA8B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI;YAC9E,6CAA6C,CAC9C,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Agent-instructions template — the markdown body each agent target
3
+ * writes into its conventional instructions file (CLAUDE.md /
4
+ * AGENTS.md / codegraph.mdc / etc.).
5
+ *
6
+ * The body content is identical across agents because the codegraph
7
+ * usage advice is agent-agnostic — only the destination filename and
8
+ * any optional frontmatter (Cursor `.mdc`) varies per target.
9
+ *
10
+ * The legacy `claude-md-template.ts` re-exports these names for
11
+ * backwards compatibility with downstream importers.
12
+ */
13
+ /** Markers used by the marker-based section replacement. */
14
+ export declare const CODEGRAPH_SECTION_START = "<!-- CODEGRAPH_START -->";
15
+ export declare const CODEGRAPH_SECTION_END = "<!-- CODEGRAPH_END -->";
16
+ /**
17
+ * The full marker-delimited block written into each agent's
18
+ * instructions file. Includes the start/end markers so the section
19
+ * can be detected and replaced on re-install.
20
+ */
21
+ export declare const INSTRUCTIONS_TEMPLATE = "<!-- CODEGRAPH_START -->\n## CodeGraph\n\nThis project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.\n\n### When to prefer codegraph over native search\n\nUse codegraph for **structural** questions \u2014 what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.\n\n| Question | Tool |\n|---|---|\n| \"How does X work? / trace X / explain a system / architecture\" | `codegraph_explore` (seed with symbol names) |\n| \"Where is X defined?\" / \"Find symbol named X\" | `codegraph_search` |\n| \"What calls function Y?\" | `codegraph_callers` |\n| \"What does Y call?\" | `codegraph_callees` |\n| \"What would break if I changed Z?\" | `codegraph_impact` |\n| \"Show me Y's signature / source / docstring\" | `codegraph_node` |\n| \"Give me focused context for a task/area\" | `codegraph_context` |\n| \"See several related symbols' source at once\" | `codegraph_explore` |\n| \"What files exist under path/\" | `codegraph_files` |\n| \"Is the index healthy?\" | `codegraph_status` |\n\n### Rules of thumb\n\n- **Answer directly \u2014 don't delegate exploration.** For \"how does X work\" / architecture / trace questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent \u2014 or running a grep + read loop \u2014 repeats work codegraph already did and costs more for the same answer.\n- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep \u2014 that's slower, less accurate, and wastes context.\n- **Don't grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.\n- **Don't chain `codegraph_search` + `codegraph_node`** when you just want context \u2014 `codegraph_context` is one call.\n- **Don't loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns several symbols' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.\n- **Index lag**: the file watcher debounces ~500ms behind writes; don't re-query immediately after editing a file in the same turn.\n\n### If `.codegraph/` doesn't exist\n\nThe MCP server returns \"not initialized.\" Ask the user: *\"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?\"*\n<!-- CODEGRAPH_END -->";
22
+ /**
23
+ * Backwards-compat alias. Existing downstream code may import
24
+ * `CLAUDE_MD_TEMPLATE` from this module via the re-export shim in
25
+ * `claude-md-template.ts`.
26
+ */
27
+ export declare const CLAUDE_MD_TEMPLATE = "<!-- CODEGRAPH_START -->\n## CodeGraph\n\nThis project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.\n\n### When to prefer codegraph over native search\n\nUse codegraph for **structural** questions \u2014 what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.\n\n| Question | Tool |\n|---|---|\n| \"How does X work? / trace X / explain a system / architecture\" | `codegraph_explore` (seed with symbol names) |\n| \"Where is X defined?\" / \"Find symbol named X\" | `codegraph_search` |\n| \"What calls function Y?\" | `codegraph_callers` |\n| \"What does Y call?\" | `codegraph_callees` |\n| \"What would break if I changed Z?\" | `codegraph_impact` |\n| \"Show me Y's signature / source / docstring\" | `codegraph_node` |\n| \"Give me focused context for a task/area\" | `codegraph_context` |\n| \"See several related symbols' source at once\" | `codegraph_explore` |\n| \"What files exist under path/\" | `codegraph_files` |\n| \"Is the index healthy?\" | `codegraph_status` |\n\n### Rules of thumb\n\n- **Answer directly \u2014 don't delegate exploration.** For \"how does X work\" / architecture / trace questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent \u2014 or running a grep + read loop \u2014 repeats work codegraph already did and costs more for the same answer.\n- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep \u2014 that's slower, less accurate, and wastes context.\n- **Don't grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.\n- **Don't chain `codegraph_search` + `codegraph_node`** when you just want context \u2014 `codegraph_context` is one call.\n- **Don't loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns several symbols' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.\n- **Index lag**: the file watcher debounces ~500ms behind writes; don't re-query immediately after editing a file in the same turn.\n\n### If `.codegraph/` doesn't exist\n\nThe MCP server returns \"not initialized.\" Ask the user: *\"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?\"*\n<!-- CODEGRAPH_END -->";
28
+ //# sourceMappingURL=instructions-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions-template.d.ts","sourceRoot":"","sources":["../../src/installer/instructions-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,wwFAkCT,CAAC;AAE1B;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,wwFAAwB,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Agent-instructions template — the markdown body each agent target
4
+ * writes into its conventional instructions file (CLAUDE.md /
5
+ * AGENTS.md / codegraph.mdc / etc.).
6
+ *
7
+ * The body content is identical across agents because the codegraph
8
+ * usage advice is agent-agnostic — only the destination filename and
9
+ * any optional frontmatter (Cursor `.mdc`) varies per target.
10
+ *
11
+ * The legacy `claude-md-template.ts` re-exports these names for
12
+ * backwards compatibility with downstream importers.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CLAUDE_MD_TEMPLATE = exports.INSTRUCTIONS_TEMPLATE = exports.CODEGRAPH_SECTION_END = exports.CODEGRAPH_SECTION_START = void 0;
16
+ /** Markers used by the marker-based section replacement. */
17
+ exports.CODEGRAPH_SECTION_START = '<!-- CODEGRAPH_START -->';
18
+ exports.CODEGRAPH_SECTION_END = '<!-- CODEGRAPH_END -->';
19
+ /**
20
+ * The full marker-delimited block written into each agent's
21
+ * instructions file. Includes the start/end markers so the section
22
+ * can be detected and replaced on re-install.
23
+ */
24
+ exports.INSTRUCTIONS_TEMPLATE = `${exports.CODEGRAPH_SECTION_START}
25
+ ## CodeGraph
26
+
27
+ This project has a CodeGraph MCP server (\`codegraph_*\` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.
28
+
29
+ ### When to prefer codegraph over native search
30
+
31
+ Use codegraph for **structural** questions — what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.
32
+
33
+ | Question | Tool |
34
+ |---|---|
35
+ | "How does X work? / trace X / explain a system / architecture" | \`codegraph_explore\` (seed with symbol names) |
36
+ | "Where is X defined?" / "Find symbol named X" | \`codegraph_search\` |
37
+ | "What calls function Y?" | \`codegraph_callers\` |
38
+ | "What does Y call?" | \`codegraph_callees\` |
39
+ | "What would break if I changed Z?" | \`codegraph_impact\` |
40
+ | "Show me Y's signature / source / docstring" | \`codegraph_node\` |
41
+ | "Give me focused context for a task/area" | \`codegraph_context\` |
42
+ | "See several related symbols' source at once" | \`codegraph_explore\` |
43
+ | "What files exist under path/" | \`codegraph_files\` |
44
+ | "Is the index healthy?" | \`codegraph_status\` |
45
+
46
+ ### Rules of thumb
47
+
48
+ - **Answer directly — don't delegate exploration.** For "how does X work" / architecture / trace questions, answer with 2-3 codegraph calls: \`codegraph_context\` first, then ONE \`codegraph_explore\` for the source of the symbols it surfaces. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent — or running a grep + read loop — repeats work codegraph already did and costs more for the same answer.
49
+ - **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep — that's slower, less accurate, and wastes context.
50
+ - **Don't grep first** when looking up a symbol by name. \`codegraph_search\` is faster and returns kind + location + signature in one call.
51
+ - **Don't chain \`codegraph_search\` + \`codegraph_node\`** when you just want context — \`codegraph_context\` is one call.
52
+ - **Don't loop \`codegraph_node\` over many symbols** — one \`codegraph_explore\` call returns several symbols' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.
53
+ - **Index lag**: the file watcher debounces ~500ms behind writes; don't re-query immediately after editing a file in the same turn.
54
+
55
+ ### If \`.codegraph/\` doesn't exist
56
+
57
+ The MCP server returns "not initialized." Ask the user: *"I notice this project doesn't have CodeGraph initialized. Want me to run \`codegraph init -i\` to build the index?"*
58
+ ${exports.CODEGRAPH_SECTION_END}`;
59
+ /**
60
+ * Backwards-compat alias. Existing downstream code may import
61
+ * `CLAUDE_MD_TEMPLATE` from this module via the re-export shim in
62
+ * `claude-md-template.ts`.
63
+ */
64
+ exports.CLAUDE_MD_TEMPLATE = exports.INSTRUCTIONS_TEMPLATE;
65
+ //# sourceMappingURL=instructions-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions-template.js","sourceRoot":"","sources":["../../src/installer/instructions-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,4DAA4D;AAC/C,QAAA,uBAAuB,GAAG,0BAA0B,CAAC;AACrD,QAAA,qBAAqB,GAAG,wBAAwB,CAAC;AAE9D;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,GAAG,+BAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC7D,6BAAqB,EAAE,CAAC;AAE1B;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,6BAAqB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Claude Code target. Writes:
3
+ *
4
+ * - MCP server entry to `~/.claude.json` (global = user scope, loads
5
+ * in every project) or `./.mcp.json` (local = project scope, the
6
+ * file Claude Code actually reads for a single project). See the
7
+ * scope table at https://code.claude.com/docs/en/mcp.
8
+ * - Permissions to `~/.claude/settings.json` (global) or
9
+ * `./.claude/settings.json` (local), gated on `autoAllow`.
10
+ * - Instructions to `~/.claude/CLAUDE.md` (global) or
11
+ * `./.claude/CLAUDE.md` (local).
12
+ *
13
+ * Earlier versions wrote the local MCP entry to `./.claude.json` — a
14
+ * file Claude Code never reads — so the server silently never loaded
15
+ * until the user manually renamed it to `.mcp.json` (issue #207). We
16
+ * now write `./.mcp.json` and migrate any stale `./.claude.json` entry
17
+ * out of the way on install and uninstall.
18
+ */
19
+ import { AgentTarget, Location, WriteResult } from './types';
20
+ /**
21
+ * Per-file write helpers, exported so the legacy `config-writer.ts`
22
+ * shim can call only the named operation (writeMcpConfig writes ONLY
23
+ * the MCP entry, etc.) instead of `claudeTarget.install()` which
24
+ * writes all three files. Without this split the shims silently
25
+ * cause side effects callers don't expect.
26
+ */
27
+ export declare function writeMcpEntry(loc: Location): WriteResult['files'][number];
28
+ export declare function writePermissionsEntry(loc: Location): WriteResult['files'][number];
29
+ export declare function writeInstructionsEntry(loc: Location): WriteResult['files'][number];
30
+ export declare const claudeTarget: AgentTarget;
31
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../src/installer/targets/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EACL,WAAW,EAGX,QAAQ,EACR,WAAW,EACZ,MAAM,SAAS,CAAC;AAiKjB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAsBzE;AAyBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAoBjF;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CA0ClF;AAED,eAAO,MAAM,YAAY,EAAE,WAAoC,CAAC"}