caik-cli 0.1.1 → 0.6.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.
Files changed (55) hide show
  1. package/README.md +8 -7
  2. package/dist/api-6OX4ICXN.js +9 -0
  3. package/dist/auto-improve-skills-2COKTU5C.js +8 -0
  4. package/dist/autoresearch-Y7WW6L4O.js +24 -0
  5. package/dist/chunk-2YHUDOJL.js +54 -0
  6. package/dist/chunk-3TXNZINH.js +775 -0
  7. package/dist/chunk-5MHNQAV4.js +317 -0
  8. package/dist/chunk-7AIZTHHZ.js +152 -0
  9. package/dist/chunk-D4IM3YRX.js +166 -0
  10. package/dist/chunk-DJJHS7KK.js +62 -0
  11. package/dist/chunk-DKZBQRR3.js +91 -0
  12. package/dist/chunk-FLSHJZLC.js +613 -0
  13. package/dist/chunk-H2ZKCXMJ.js +202 -0
  14. package/dist/chunk-ILMOSMD3.js +83 -0
  15. package/dist/chunk-KYTHKH6V.js +79 -0
  16. package/dist/chunk-LTKHLRM4.js +272 -0
  17. package/dist/chunk-T32AEP3O.js +146 -0
  18. package/dist/chunk-T73Z5UMA.js +14437 -0
  19. package/dist/chunk-TFKT7V7H.js +1545 -0
  20. package/dist/chunk-US4CYDNS.js +524 -0
  21. package/dist/chunk-ZLRN7Q7C.js +27 -0
  22. package/dist/claude-code-6DF4YARB.js +8 -0
  23. package/dist/config-CS7734SA.js +24 -0
  24. package/dist/correction-classifier-TLPKRNLI.js +93 -0
  25. package/dist/cursor-Z4XXDCAM.js +8 -0
  26. package/dist/daemon/autoresearch-2MAEM2YI.js +272 -0
  27. package/dist/daemon/chunk-545XA5CB.js +77 -0
  28. package/dist/daemon/chunk-HEYFAUHL.js +90 -0
  29. package/dist/daemon/chunk-MLKGABMK.js +9 -0
  30. package/dist/daemon/chunk-NJICGNCK.js +150 -0
  31. package/dist/daemon/chunk-OD5NUFH2.js +181 -0
  32. package/dist/daemon/chunk-SM2FSXIP.js +60 -0
  33. package/dist/daemon/chunk-UMDJFPN6.js +163 -0
  34. package/dist/daemon/config-F7HE3JRY.js +23 -0
  35. package/dist/daemon/db-QEXVVTAL.js +15 -0
  36. package/dist/daemon/eval-generator-OR2FAYLB.js +316 -0
  37. package/dist/daemon/improver-TGEK6MPE.js +186 -0
  38. package/dist/daemon/llm-FUJ2TBYT.js +11 -0
  39. package/dist/daemon/nudge-detector-NFRHWZY6.js +140 -0
  40. package/dist/daemon/platform-7N3LQDIB.js +16381 -0
  41. package/dist/daemon/registry-FI4GTO3H.js +20 -0
  42. package/dist/daemon/server.js +356 -0
  43. package/dist/daemon/trace-store-T7XFGQSX.js +19 -0
  44. package/dist/daemon-UXYMG46V.js +85 -0
  45. package/dist/db-TLNRIXLK.js +18 -0
  46. package/dist/eval-generator-GGMRPO3K.js +21 -0
  47. package/dist/eval-runner-EF4K6T5Y.js +15 -0
  48. package/dist/index.js +8033 -568
  49. package/dist/llm-3UUZX6PX.js +12 -0
  50. package/dist/platform-52NREMBS.js +33 -0
  51. package/dist/repo-installer-K6ADOW3E.js +25 -0
  52. package/dist/setup-P744STZE.js +16 -0
  53. package/dist/test-loop-Y7QQE55P.js +127 -0
  54. package/dist/trace-store-FVLMNNDK.js +20 -0
  55. package/package.json +9 -3
@@ -0,0 +1,524 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/platform/claude-code.ts
4
+ import {
5
+ existsSync,
6
+ readFileSync,
7
+ writeFileSync,
8
+ mkdirSync,
9
+ readdirSync,
10
+ rmSync,
11
+ cpSync,
12
+ symlinkSync
13
+ } from "fs";
14
+ import { join, dirname } from "path";
15
+ import { homedir } from "os";
16
+ var MCP_KEY = "caik";
17
+ var PLUGIN_NAME = "caik";
18
+ var PLUGIN_MARKETPLACE = "caikdev";
19
+ var PLUGIN_REPO = "caikdev/plugins";
20
+ var PLUGIN_KEY = `${PLUGIN_NAME}@${PLUGIN_MARKETPLACE}`;
21
+ var _pluginDetectedLogged = false;
22
+ var PLUGIN_MANAGED_SKILLS = [
23
+ "caik",
24
+ "caik-discover",
25
+ "caik-observe",
26
+ "caik-improve",
27
+ "caik-status"
28
+ ];
29
+ var ClaudeCodeAdapter = class {
30
+ name = "claude-code";
31
+ tier = "full-plugin";
32
+ get claudeDir() {
33
+ return join(homedir(), ".claude");
34
+ }
35
+ get mcpPath() {
36
+ return join(this.claudeDir, "mcp.json");
37
+ }
38
+ get settingsPath() {
39
+ return join(this.claudeDir, "settings.json");
40
+ }
41
+ get skillsDir() {
42
+ return join(this.claudeDir, "skills");
43
+ }
44
+ get localSkillsDir() {
45
+ return join(process.cwd(), ".claude", "skills");
46
+ }
47
+ get pluginsCacheDir() {
48
+ return join(this.claudeDir, "plugins", "cache");
49
+ }
50
+ // ---------------------------------------------------------------------------
51
+ // JSON helpers
52
+ // ---------------------------------------------------------------------------
53
+ readJson(path) {
54
+ if (!existsSync(path)) return {};
55
+ try {
56
+ const raw = readFileSync(path, "utf-8");
57
+ const parsed = JSON.parse(raw);
58
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
59
+ return parsed;
60
+ }
61
+ return {};
62
+ } catch {
63
+ return {};
64
+ }
65
+ }
66
+ writeJson(path, data) {
67
+ const dir = join(path, "..");
68
+ if (!existsSync(dir)) {
69
+ mkdirSync(dir, { recursive: true });
70
+ }
71
+ writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf-8");
72
+ }
73
+ // ---------------------------------------------------------------------------
74
+ // Plugin detection
75
+ // ---------------------------------------------------------------------------
76
+ /**
77
+ * Check if CAIK is installed as a Claude Code plugin.
78
+ * Looks for "caik" in enabledPlugins in settings.json, or for a caik
79
+ * directory in the plugins cache.
80
+ */
81
+ isPluginInstalled() {
82
+ const settings = this.readJson(this.settingsPath);
83
+ const enabledPlugins = settings.enabledPlugins;
84
+ if (enabledPlugins) {
85
+ for (const key of Object.keys(enabledPlugins)) {
86
+ if (key.toLowerCase().includes("caik") && enabledPlugins[key] !== false) {
87
+ return true;
88
+ }
89
+ }
90
+ }
91
+ if (existsSync(this.pluginsCacheDir)) {
92
+ try {
93
+ const publishers = readdirSync(this.pluginsCacheDir);
94
+ for (const publisher of publishers) {
95
+ const publisherDir = join(this.pluginsCacheDir, publisher);
96
+ const caikDir = join(publisherDir, "caik");
97
+ if (existsSync(caikDir)) {
98
+ return true;
99
+ }
100
+ }
101
+ } catch {
102
+ }
103
+ }
104
+ return false;
105
+ }
106
+ /**
107
+ * Returns the current install method:
108
+ * - "plugin" if CAIK plugin is installed via marketplace
109
+ * - "manual" if CAIK is registered in mcp.json manually
110
+ * - "none" if not installed
111
+ */
112
+ getInstallMethod() {
113
+ if (this.isPluginInstalled()) return "plugin";
114
+ if (existsSync(this.mcpPath)) {
115
+ const config = this.readJson(this.mcpPath);
116
+ const servers = config.mcpServers;
117
+ if (servers && MCP_KEY in servers) return "manual";
118
+ }
119
+ return "none";
120
+ }
121
+ // ---------------------------------------------------------------------------
122
+ // Plugin installation
123
+ // ---------------------------------------------------------------------------
124
+ /**
125
+ * Resolve the path to the plugin source directory.
126
+ * In local dev, this is `packages/claude-code-plugin/` in the monorepo.
127
+ * Falls back to null if not found.
128
+ */
129
+ resolvePluginSource() {
130
+ const candidates = [
131
+ // Running from packages/cli/dist/ or packages/cli/src/
132
+ join(dirname(new URL(import.meta.url).pathname), "..", "..", "..", "claude-code-plugin"),
133
+ // Running via npx or global install — check cwd-based monorepo
134
+ join(process.cwd(), "packages", "claude-code-plugin")
135
+ ];
136
+ for (const candidate of candidates) {
137
+ const pluginJson = join(candidate, ".claude-plugin", "plugin.json");
138
+ if (existsSync(pluginJson)) {
139
+ return candidate;
140
+ }
141
+ }
142
+ return null;
143
+ }
144
+ /**
145
+ * Programmatically install the CAIK plugin into Claude Code.
146
+ *
147
+ * This replicates what `/plugin marketplace add caikdev/caik` + `/plugin install caik`
148
+ * would do:
149
+ *
150
+ * 1. Register the `caikdev` marketplace in `known_marketplaces.json`
151
+ * 2. Copy the plugin files into `~/.claude/plugins/cache/caikdev/caik/<version>/`
152
+ * 3. Register the plugin in `installed_plugins.json`
153
+ * 4. Enable the plugin in `settings.json` under `enabledPlugins`
154
+ *
155
+ * Returns true if successful, false if plugin source files could not be found.
156
+ */
157
+ installPlugin() {
158
+ const source = this.resolvePluginSource();
159
+ if (!source) {
160
+ return false;
161
+ }
162
+ let version = "0.1.0";
163
+ try {
164
+ const pluginMeta = JSON.parse(
165
+ readFileSync(join(source, ".claude-plugin", "plugin.json"), "utf-8")
166
+ );
167
+ if (typeof pluginMeta.version === "string") {
168
+ version = pluginMeta.version;
169
+ }
170
+ } catch {
171
+ }
172
+ const pluginsDir = join(this.claudeDir, "plugins");
173
+ const now = (/* @__PURE__ */ new Date()).toISOString();
174
+ const marketplacesPath = join(pluginsDir, "known_marketplaces.json");
175
+ const marketplaces = this.readJson(marketplacesPath);
176
+ if (!marketplaces[PLUGIN_MARKETPLACE]) {
177
+ marketplaces[PLUGIN_MARKETPLACE] = {
178
+ source: {
179
+ source: "github",
180
+ repo: PLUGIN_REPO
181
+ },
182
+ installLocation: join(pluginsDir, "marketplaces", PLUGIN_MARKETPLACE),
183
+ lastUpdated: now
184
+ };
185
+ this.writeJson(marketplacesPath, marketplaces);
186
+ }
187
+ const marketplaceDir = join(pluginsDir, "marketplaces", PLUGIN_MARKETPLACE);
188
+ const marketplaceCatalogDir = join(marketplaceDir, ".claude-plugin");
189
+ if (!existsSync(join(marketplaceCatalogDir, "marketplace.json"))) {
190
+ mkdirSync(marketplaceCatalogDir, { recursive: true });
191
+ const catalog = {
192
+ name: PLUGIN_MARKETPLACE,
193
+ description: "CAIK \u2014 The package manager for AI agents",
194
+ plugins: [
195
+ {
196
+ name: PLUGIN_NAME,
197
+ description: "Search, install, and share AI artifacts from the CAIK community registry",
198
+ source: `./${PLUGIN_NAME}`
199
+ }
200
+ ]
201
+ };
202
+ writeFileSync(join(marketplaceCatalogDir, "marketplace.json"), JSON.stringify(catalog, null, 2), "utf-8");
203
+ }
204
+ const marketplacePluginDir = join(marketplaceDir, PLUGIN_NAME);
205
+ if (!existsSync(marketplacePluginDir)) {
206
+ try {
207
+ symlinkSync(source, marketplacePluginDir);
208
+ } catch {
209
+ cpSync(source, marketplacePluginDir, { recursive: true, force: true });
210
+ }
211
+ }
212
+ const installPath = join(this.pluginsCacheDir, PLUGIN_MARKETPLACE, PLUGIN_NAME, version);
213
+ if (!existsSync(installPath)) {
214
+ mkdirSync(installPath, { recursive: true });
215
+ }
216
+ try {
217
+ cpSync(source, installPath, { recursive: true, force: true });
218
+ } catch (err) {
219
+ const essentialDirs = [".claude-plugin", "hooks", "skills"];
220
+ const essentialFiles = [".mcp.json"];
221
+ for (const dir of essentialDirs) {
222
+ const srcDir = join(source, dir);
223
+ const destDir = join(installPath, dir);
224
+ if (existsSync(srcDir)) {
225
+ try {
226
+ cpSync(srcDir, destDir, { recursive: true, force: true });
227
+ } catch {
228
+ }
229
+ }
230
+ }
231
+ for (const file of essentialFiles) {
232
+ const srcFile = join(source, file);
233
+ const destFile = join(installPath, file);
234
+ if (existsSync(srcFile)) {
235
+ try {
236
+ const content = readFileSync(srcFile, "utf-8");
237
+ const destDir = join(destFile, "..");
238
+ if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
239
+ writeFileSync(destFile, content, "utf-8");
240
+ } catch {
241
+ }
242
+ }
243
+ }
244
+ if (!existsSync(join(installPath, ".claude-plugin", "plugin.json"))) {
245
+ throw err;
246
+ }
247
+ }
248
+ const installedPath = join(pluginsDir, "installed_plugins.json");
249
+ const installedData = this.readJson(installedPath);
250
+ if (!installedData.version) installedData.version = 2;
251
+ if (!installedData.plugins) installedData.plugins = {};
252
+ installedData.plugins[PLUGIN_KEY] = [
253
+ {
254
+ scope: "user",
255
+ installPath,
256
+ version,
257
+ installedAt: now,
258
+ lastUpdated: now,
259
+ gitCommitSha: ""
260
+ }
261
+ ];
262
+ this.writeJson(installedPath, installedData);
263
+ const settings = this.readJson(this.settingsPath);
264
+ const enabledPlugins = settings.enabledPlugins ?? {};
265
+ enabledPlugins[PLUGIN_KEY] = true;
266
+ settings.enabledPlugins = enabledPlugins;
267
+ const extraMarketplaces = settings.extraKnownMarketplaces ?? {};
268
+ if (!extraMarketplaces[PLUGIN_MARKETPLACE]) {
269
+ extraMarketplaces[PLUGIN_MARKETPLACE] = {
270
+ source: {
271
+ source: "github",
272
+ repo: PLUGIN_REPO
273
+ }
274
+ };
275
+ settings.extraKnownMarketplaces = extraMarketplaces;
276
+ }
277
+ this.writeJson(this.settingsPath, settings);
278
+ return true;
279
+ }
280
+ // ---------------------------------------------------------------------------
281
+ // Manual registration cleanup (when plugin is installed)
282
+ // ---------------------------------------------------------------------------
283
+ /**
284
+ * Remove manual CAIK registrations that are superseded by the plugin.
285
+ * Returns a summary of what was cleaned up.
286
+ */
287
+ cleanupManualRegistration() {
288
+ const cleaned = [];
289
+ if (existsSync(this.settingsPath)) {
290
+ const settings = this.readJson(this.settingsPath);
291
+ const hooks = settings.hooks;
292
+ if (hooks) {
293
+ let removedHooks = 0;
294
+ for (const event of Object.keys(hooks)) {
295
+ const entries = hooks[event];
296
+ if (!Array.isArray(entries)) continue;
297
+ const before = entries.length;
298
+ hooks[event] = entries.filter((group) => {
299
+ if (typeof group === "object" && group !== null) {
300
+ const g = group;
301
+ if (Array.isArray(g.hooks)) {
302
+ const hasCAIK = g.hooks.some(
303
+ (h) => typeof h.command === "string" && h.command.toLowerCase().includes("caik")
304
+ );
305
+ if (hasCAIK) return false;
306
+ }
307
+ if ("command" in g) {
308
+ return !g.command.toLowerCase().includes("caik");
309
+ }
310
+ }
311
+ return true;
312
+ });
313
+ removedHooks += before - hooks[event].length;
314
+ if (hooks[event].length === 0) {
315
+ delete hooks[event];
316
+ }
317
+ }
318
+ if (removedHooks > 0) {
319
+ if (Object.keys(hooks).length === 0) {
320
+ delete settings.hooks;
321
+ } else {
322
+ settings.hooks = hooks;
323
+ }
324
+ this.writeJson(this.settingsPath, settings);
325
+ cleaned.push(`Removed ${removedHooks} CAIK hook(s) from settings.json`);
326
+ }
327
+ }
328
+ }
329
+ if (existsSync(this.mcpPath)) {
330
+ const config = this.readJson(this.mcpPath);
331
+ const servers = config.mcpServers;
332
+ if (servers && MCP_KEY in servers) {
333
+ delete servers[MCP_KEY];
334
+ config.mcpServers = servers;
335
+ this.writeJson(this.mcpPath, config);
336
+ cleaned.push("Removed CAIK entry from mcp.json");
337
+ }
338
+ }
339
+ for (const slug of PLUGIN_MANAGED_SKILLS) {
340
+ const skillDir = join(this.skillsDir, slug);
341
+ if (existsSync(skillDir)) {
342
+ try {
343
+ rmSync(skillDir, { recursive: true, force: true });
344
+ cleaned.push(`Removed old skill directory: ${slug}`);
345
+ } catch {
346
+ }
347
+ }
348
+ }
349
+ return cleaned;
350
+ }
351
+ // ---------------------------------------------------------------------------
352
+ // PlatformAdapter implementation
353
+ // ---------------------------------------------------------------------------
354
+ async detect() {
355
+ if (!existsSync(this.claudeDir)) return null;
356
+ const hasSettings = existsSync(this.settingsPath);
357
+ const hasMcp = existsSync(this.mcpPath);
358
+ const hasStatsig = existsSync(join(this.claudeDir, "statsig"));
359
+ if (!hasSettings && !hasMcp && !hasStatsig) return null;
360
+ const configPaths = [];
361
+ if (hasSettings) configPaths.push(this.settingsPath);
362
+ if (hasMcp) configPaths.push(this.mcpPath);
363
+ return {
364
+ name: this.name,
365
+ tier: this.tier,
366
+ configPaths,
367
+ capabilities: { hooks: true, mcp: true, skills: true }
368
+ };
369
+ }
370
+ async registerMcp(serverConfig) {
371
+ if (this.isPluginInstalled()) {
372
+ if (!_pluginDetectedLogged) {
373
+ console.log("CAIK plugin detected \u2014 hooks, MCP, and skills managed by plugin.");
374
+ _pluginDetectedLogged = true;
375
+ }
376
+ return;
377
+ }
378
+ const config = this.readJson(this.mcpPath);
379
+ const servers = config.mcpServers ?? {};
380
+ const serverKey = serverConfig.key ?? MCP_KEY;
381
+ servers[serverKey] = {
382
+ command: serverConfig.command,
383
+ args: serverConfig.args,
384
+ ...serverConfig.env && Object.keys(serverConfig.env).length > 0 ? { env: serverConfig.env } : {}
385
+ };
386
+ config.mcpServers = servers;
387
+ this.writeJson(this.mcpPath, config);
388
+ }
389
+ async unregisterMcp() {
390
+ if (!existsSync(this.mcpPath)) return;
391
+ const config = this.readJson(this.mcpPath);
392
+ const servers = config.mcpServers;
393
+ if (!servers || !(MCP_KEY in servers)) return;
394
+ delete servers[MCP_KEY];
395
+ config.mcpServers = servers;
396
+ this.writeJson(this.mcpPath, config);
397
+ }
398
+ async registerHooks(hookConfig) {
399
+ if (this.isPluginInstalled()) {
400
+ if (!_pluginDetectedLogged) {
401
+ console.log("CAIK plugin detected \u2014 hooks, MCP, and skills managed by plugin.");
402
+ _pluginDetectedLogged = true;
403
+ }
404
+ return;
405
+ }
406
+ const settings = this.readJson(this.settingsPath);
407
+ const existingHooks = settings.hooks ?? {};
408
+ for (const [event, entries] of Object.entries(hookConfig.hooks)) {
409
+ const newEntries = Array.isArray(entries) ? entries : [entries];
410
+ const existing = Array.isArray(existingHooks[event]) ? existingHooks[event] : [];
411
+ const filtered = existing.filter((group) => {
412
+ if (typeof group === "object" && group !== null) {
413
+ const g = group;
414
+ if (Array.isArray(g.hooks)) {
415
+ const hasCAIK = g.hooks.some(
416
+ (h) => typeof h.command === "string" && h.command.toLowerCase().includes("caik")
417
+ );
418
+ if (hasCAIK) return false;
419
+ }
420
+ if ("command" in g) {
421
+ return !g.command.toLowerCase().includes("caik");
422
+ }
423
+ }
424
+ return true;
425
+ });
426
+ const wrappedEntries = newEntries.map((entry) => {
427
+ if (typeof entry === "object" && entry !== null) {
428
+ const e = entry;
429
+ const hookEntry = {
430
+ type: "command",
431
+ timeout: 10,
432
+ ...e
433
+ };
434
+ return { hooks: [hookEntry] };
435
+ }
436
+ return entry;
437
+ });
438
+ existingHooks[event] = [...filtered, ...wrappedEntries];
439
+ }
440
+ settings.hooks = existingHooks;
441
+ this.writeJson(this.settingsPath, settings);
442
+ }
443
+ async unregisterHooks() {
444
+ if (!existsSync(this.settingsPath)) return;
445
+ const settings = this.readJson(this.settingsPath);
446
+ const hooks = settings.hooks;
447
+ if (!hooks) return;
448
+ for (const event of Object.keys(hooks)) {
449
+ const entries = hooks[event];
450
+ if (!Array.isArray(entries)) continue;
451
+ hooks[event] = entries.filter((group) => {
452
+ if (typeof group === "object" && group !== null) {
453
+ const g = group;
454
+ if (Array.isArray(g.hooks)) {
455
+ const hasCAIK = g.hooks.some(
456
+ (h) => typeof h.command === "string" && h.command.includes("caik")
457
+ );
458
+ if (hasCAIK) return false;
459
+ }
460
+ if ("command" in g) {
461
+ return !g.command.includes("caik");
462
+ }
463
+ }
464
+ return true;
465
+ });
466
+ if (hooks[event].length === 0) {
467
+ delete hooks[event];
468
+ }
469
+ }
470
+ if (Object.keys(hooks).length === 0) {
471
+ delete settings.hooks;
472
+ } else {
473
+ settings.hooks = hooks;
474
+ }
475
+ this.writeJson(this.settingsPath, settings);
476
+ }
477
+ async installSkill(slug, content, files, local) {
478
+ if (!local && this.isPluginInstalled() && PLUGIN_MANAGED_SKILLS.includes(slug)) {
479
+ return;
480
+ }
481
+ const baseDir = local ? this.localSkillsDir : this.skillsDir;
482
+ const skillDir = join(baseDir, slug);
483
+ if (!existsSync(skillDir)) {
484
+ mkdirSync(skillDir, { recursive: true });
485
+ }
486
+ writeFileSync(join(skillDir, "SKILL.md"), content, "utf-8");
487
+ if (files) {
488
+ for (const file of files) {
489
+ const filePath = join(skillDir, file.path);
490
+ const fileDir = join(filePath, "..");
491
+ if (!existsSync(fileDir)) {
492
+ mkdirSync(fileDir, { recursive: true });
493
+ }
494
+ writeFileSync(filePath, file.content, "utf-8");
495
+ }
496
+ }
497
+ }
498
+ async uninstallSkill(slug, local) {
499
+ const baseDir = local ? this.localSkillsDir : this.skillsDir;
500
+ const skillDir = join(baseDir, slug);
501
+ if (!existsSync(skillDir)) return;
502
+ try {
503
+ rmSync(skillDir, { recursive: true, force: true });
504
+ } catch {
505
+ }
506
+ }
507
+ getConfigPath() {
508
+ return this.mcpPath;
509
+ }
510
+ async readConfig() {
511
+ return this.readJson(this.mcpPath);
512
+ }
513
+ async isRegistered() {
514
+ if (this.isPluginInstalled()) return true;
515
+ if (!existsSync(this.mcpPath)) return false;
516
+ const config = this.readJson(this.mcpPath);
517
+ const servers = config.mcpServers;
518
+ return !!servers && MCP_KEY in servers;
519
+ }
520
+ };
521
+
522
+ export {
523
+ ClaudeCodeAdapter
524
+ };
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __esm = (fn, res) => function __init() {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+
23
+ export {
24
+ __esm,
25
+ __export,
26
+ __toCommonJS
27
+ };
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ClaudeCodeAdapter
4
+ } from "./chunk-US4CYDNS.js";
5
+ import "./chunk-ZLRN7Q7C.js";
6
+ export {
7
+ ClaudeCodeAdapter
8
+ };
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CONTRIBUTION_LEVELS,
4
+ getApiKey,
5
+ getConfigDir,
6
+ getConfigPath,
7
+ getOrCreateInstallationId,
8
+ readConfig,
9
+ resolveConfig,
10
+ setApiKey,
11
+ writeConfig
12
+ } from "./chunk-KYTHKH6V.js";
13
+ import "./chunk-ZLRN7Q7C.js";
14
+ export {
15
+ CONTRIBUTION_LEVELS,
16
+ getApiKey,
17
+ getConfigDir,
18
+ getConfigPath,
19
+ getOrCreateInstallationId,
20
+ readConfig,
21
+ resolveConfig,
22
+ setApiKey,
23
+ writeConfig
24
+ };
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import "./chunk-ZLRN7Q7C.js";
3
+
4
+ // src/correction-classifier.ts
5
+ var MIN_LENGTH = 2;
6
+ var MAX_LENGTH = 500;
7
+ function shouldClassify(prompt) {
8
+ if (!prompt || prompt.length < MIN_LENGTH) return false;
9
+ if (prompt.length > MAX_LENGTH) return false;
10
+ if (prompt.includes("```")) return false;
11
+ return true;
12
+ }
13
+ var POSITIVE_PREFIXES = [
14
+ "yes",
15
+ "perfect",
16
+ "looks good",
17
+ "thanks",
18
+ "thank you",
19
+ "great",
20
+ "awesome",
21
+ "nice",
22
+ "good",
23
+ "correct",
24
+ "exactly",
25
+ "that works",
26
+ "that's right",
27
+ "lgtm"
28
+ ];
29
+ function isPositive(lower) {
30
+ return POSITIVE_PREFIXES.some((p) => lower.startsWith(p));
31
+ }
32
+ function isQuestion(prompt) {
33
+ return prompt.trimEnd().endsWith("?");
34
+ }
35
+ function looksLikeCode(lower) {
36
+ if (/\b\w+_(?:wrong|no|bad|fail)\b/.test(lower)) return true;
37
+ if (/\b(?:wrong|no|bad|fail)_\w+\b/.test(lower)) return true;
38
+ if (/[=(){}[\];]/.test(lower) && lower.length < 100) return true;
39
+ return false;
40
+ }
41
+ var PATTERNS = [
42
+ // ── HIGH confidence: explicit rejection ───────────────────────────
43
+ { regex: /\bthat'?s\s+(?:not\s+)?wrong\b/, correctionType: "output_rejected", confidence: "high" },
44
+ { regex: /\bthat\s+is\s+(?:not\s+)?wrong\b/, correctionType: "output_rejected", confidence: "high" },
45
+ { regex: /\bnot\s+what\s+i\s+(?:asked|wanted|meant|need)\b/, correctionType: "output_rejected", confidence: "high" },
46
+ { regex: /\bi\s+said\b/, correctionType: "output_rejected", confidence: "high" },
47
+ { regex: /\bi\s+already\s+told\s+you\b/, correctionType: "output_rejected", confidence: "high" },
48
+ { regex: /\bthat'?s\s+not\s+(?:right|correct)\b/, correctionType: "output_rejected", confidence: "high" },
49
+ // ── MEDIUM confidence: redirection → approach_changed ─────────────
50
+ { regex: /\binstead\b/, correctionType: "approach_changed", confidence: "medium" },
51
+ { regex: /\bactually[\s,]/, correctionType: "approach_changed", confidence: "medium" },
52
+ { regex: /\bdon'?t\s+use\b/, correctionType: "approach_changed", confidence: "medium" },
53
+ { regex: /\buse\s+a\s+different\b/, correctionType: "approach_changed", confidence: "medium" },
54
+ { regex: /\bdifferent\s+approach\b/, correctionType: "approach_changed", confidence: "medium" },
55
+ { regex: /\bnot\s+like\s+that\b/, correctionType: "approach_changed", confidence: "medium" },
56
+ // ── MEDIUM confidence: retry → output_rejected ────────────────────
57
+ { regex: /\btry\s+again\b/, correctionType: "output_rejected", confidence: "medium" },
58
+ { regex: /\bredo\s+(?:this|that|it)\b/, correctionType: "output_rejected", confidence: "medium" },
59
+ { regex: /\bstart\s+over\b/, correctionType: "output_rejected", confidence: "medium" },
60
+ // ── MEDIUM confidence: modification → output_modified ─────────────
61
+ { regex: /\bmake\s+it\s+\w+/, correctionType: "output_modified", confidence: "medium" },
62
+ { regex: /\bfix\s+(?:the|this|that|it)\b/, correctionType: "output_modified", confidence: "medium" },
63
+ // ── MEDIUM confidence: scope → scope_adjusted ─────────────────────
64
+ { regex: /\btoo\s+(?:verbose|much|long|detailed)\b/, correctionType: "scope_adjusted", confidence: "medium" },
65
+ { regex: /\bi\s+only\s+need\b/, correctionType: "scope_adjusted", confidence: "medium" },
66
+ { regex: /\bkeep\s+it\s+(?:concise|brief|short|simple)\b/, correctionType: "scope_adjusted", confidence: "medium" },
67
+ // ── MEDIUM confidence: format → format_changed ────────────────────
68
+ { regex: /\bformat\s+(?:it|the|as|this|that)\b/, correctionType: "format_changed", confidence: "medium" },
69
+ // ── LOW confidence: bare negatives (too ambiguous to log) ─────────
70
+ { regex: /^no[.,!]?\s*$/i, correctionType: "output_rejected", confidence: "low" },
71
+ { regex: /^wrong[.,!]?\s*$/i, correctionType: "output_rejected", confidence: "low" }
72
+ ];
73
+ function classifyPrompt(prompt) {
74
+ if (!shouldClassify(prompt)) return null;
75
+ const lower = prompt.toLowerCase().trim();
76
+ if (isPositive(lower)) return null;
77
+ if (isQuestion(prompt)) return null;
78
+ if (looksLikeCode(lower)) return null;
79
+ for (const pattern of PATTERNS) {
80
+ if (pattern.regex.test(lower)) {
81
+ if (pattern.confidence === "low") return null;
82
+ return {
83
+ correctionType: pattern.correctionType,
84
+ confidence: pattern.confidence
85
+ };
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ export {
91
+ classifyPrompt,
92
+ shouldClassify
93
+ };
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CursorAdapter
4
+ } from "./chunk-T73Z5UMA.js";
5
+ import "./chunk-ZLRN7Q7C.js";
6
+ export {
7
+ CursorAdapter
8
+ };