@tdsoft-tech/aikit 0.1.32 → 0.1.34

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.
package/dist/cli.js CHANGED
@@ -150,6 +150,34 @@ var init_paths = __esm({
150
150
  */
151
151
  claudeAgents(project) {
152
152
  return join(this.claudeConfig(project ? "project" : "user"), "agents");
153
+ },
154
+ /**
155
+ * Get Cursor configuration directory
156
+ */
157
+ cursorConfig(scope) {
158
+ if (scope === "project") {
159
+ return join(process.cwd(), ".cursor");
160
+ }
161
+ const base = process.platform === "win32" ? join(homedir(), "AppData", "Local", "Cursor") : join(homedir(), ".cursor");
162
+ return base;
163
+ },
164
+ /**
165
+ * Get Cursor commands directory
166
+ */
167
+ cursorCommands(project) {
168
+ return join(this.cursorConfig(project ? "project" : "user"), "commands");
169
+ },
170
+ /**
171
+ * Get Cursor skills directory
172
+ */
173
+ cursorSkills(project) {
174
+ return join(this.cursorConfig(project ? "project" : "user"), "skills");
175
+ },
176
+ /**
177
+ * Get Cursor agents directory
178
+ */
179
+ cursorAgents(project) {
180
+ return join(this.cursorConfig(project ? "project" : "user"), "agents");
153
181
  }
154
182
  };
155
183
  }
@@ -1001,7 +1029,7 @@ var init_config = __esm({
1001
1029
  /**
1002
1030
  * Primary platform to use (affects default behavior)
1003
1031
  */
1004
- primary: z.enum(["opencode", "claude"]).default("opencode"),
1032
+ primary: z.enum(["opencode", "claude", "cursor"]).default("opencode"),
1005
1033
  /**
1006
1034
  * Enable OpenCode platform support
1007
1035
  * Default: true (OpenCode is the primary focus)
@@ -1011,7 +1039,12 @@ var init_config = __esm({
1011
1039
  * Enable Claude Code platform support
1012
1040
  * Default: false (archived, can be re-enabled later)
1013
1041
  */
1014
- claude: z.boolean().default(false)
1042
+ claude: z.boolean().default(false),
1043
+ /**
1044
+ * Enable Cursor platform support
1045
+ * Default: false (opt-in)
1046
+ */
1047
+ cursor: z.boolean().default(false)
1015
1048
  }).default({});
1016
1049
  ConfigSchema = z.object({
1017
1050
  version: z.string(),
@@ -1129,6 +1162,9 @@ var init_config = __esm({
1129
1162
  if (this.config.platform.claude) {
1130
1163
  platforms.push("claude");
1131
1164
  }
1165
+ if (this.config.platform.cursor) {
1166
+ platforms.push("cursor");
1167
+ }
1132
1168
  return platforms;
1133
1169
  }
1134
1170
  get projectPath() {
@@ -8244,6 +8280,7 @@ var CliPlatform = /* @__PURE__ */ ((CliPlatform2) => {
8244
8280
  CliPlatform2["OPENCODE"] = "opencode";
8245
8281
  CliPlatform2["CLAUDE"] = "claude";
8246
8282
  CliPlatform2["CODEX"] = "codex";
8283
+ CliPlatform2["CURSOR"] = "cursor";
8247
8284
  return CliPlatform2;
8248
8285
  })(CliPlatform || {});
8249
8286
  var CliDetector = class {
@@ -8331,6 +8368,43 @@ var CliDetector = class {
8331
8368
  };
8332
8369
  }
8333
8370
  }
8371
+ /**
8372
+ * Check if Cursor is installed
8373
+ */
8374
+ static async checkCursor() {
8375
+ try {
8376
+ const cursorPath = process.platform === "win32" ? join15(homedir3(), "AppData", "Local", "Cursor") : join15(homedir3(), ".cursor");
8377
+ let installed = existsSync6(cursorPath);
8378
+ let version;
8379
+ if (installed) {
8380
+ try {
8381
+ execSync("cursor --version", { stdio: "ignore" });
8382
+ version = "installed";
8383
+ } catch (error) {
8384
+ if (existsSync6(cursorPath)) {
8385
+ version = "installed (config exists)";
8386
+ } else {
8387
+ installed = false;
8388
+ }
8389
+ }
8390
+ }
8391
+ return {
8392
+ name: "cursor" /* CURSOR */,
8393
+ displayName: "Cursor",
8394
+ detected: true,
8395
+ installed,
8396
+ version,
8397
+ configPath: cursorPath
8398
+ };
8399
+ } catch {
8400
+ return {
8401
+ name: "cursor" /* CURSOR */,
8402
+ displayName: "Cursor",
8403
+ detected: false,
8404
+ installed: false
8405
+ };
8406
+ }
8407
+ }
8334
8408
  /**
8335
8409
  * Check all supported CLIs
8336
8410
  */
@@ -8339,6 +8413,7 @@ var CliDetector = class {
8339
8413
  results.push(await this.checkOpenCode());
8340
8414
  results.push(await this.checkClaude());
8341
8415
  results.push(await this.checkGitHub());
8416
+ results.push(await this.checkCursor());
8342
8417
  return results;
8343
8418
  }
8344
8419
  /**
@@ -8372,6 +8447,13 @@ var CliDetector = class {
8372
8447
  installed: existsSync6(claudePath),
8373
8448
  configPath: claudePath
8374
8449
  });
8450
+ const cursorPath = process.platform === "win32" ? join15(homedir3(), "AppData", "Local", "Cursor") : join15(homedir3(), ".cursor");
8451
+ platforms.push({
8452
+ platform: "cursor" /* CURSOR */,
8453
+ displayName: "Cursor",
8454
+ installed: existsSync6(cursorPath),
8455
+ configPath: cursorPath
8456
+ });
8375
8457
  return platforms;
8376
8458
  }
8377
8459
  /**
@@ -8389,6 +8471,8 @@ var CliDetector = class {
8389
8471
  return "opencode" /* OPENCODE */;
8390
8472
  } else if (normalized === "claude" || normalized === "claude-code" || normalized === "claude-code-cli") {
8391
8473
  return "claude" /* CLAUDE */;
8474
+ } else if (normalized === "cursor") {
8475
+ return "cursor" /* CURSOR */;
8392
8476
  } else if (normalized === "codex") {
8393
8477
  return "codex" /* CODEX */;
8394
8478
  }
@@ -9473,6 +9557,124 @@ ${skill.content}
9473
9557
  }
9474
9558
  };
9475
9559
 
9560
+ // src/platform/cursor-adapter.ts
9561
+ init_esm_shims();
9562
+ init_paths();
9563
+ import { readFile as readFile12, writeFile as writeFile15, mkdir as mkdir15, access as access8 } from "fs/promises";
9564
+ import { join as join20 } from "path";
9565
+ var CursorAdapter = class {
9566
+ platform = "cursor" /* CURSOR */;
9567
+ displayName = "Cursor";
9568
+ getCommandsDir() {
9569
+ return join20(process.cwd(), ".cursor", "commands");
9570
+ }
9571
+ getSkillsDir() {
9572
+ return join20(process.cwd(), ".cursor", "skills");
9573
+ }
9574
+ getAgentsDir() {
9575
+ return paths.cursorConfig("project");
9576
+ }
9577
+ async transformCommand(command) {
9578
+ const name = `aikit-${command.name.replace(/:/g, "-")}`;
9579
+ const content = this.generateCommandContent(command);
9580
+ return { name, content };
9581
+ }
9582
+ async transformSkill(skill) {
9583
+ const skillContent = this.generateSkillContent(skill);
9584
+ const result = {
9585
+ name: skill.name,
9586
+ directory: "",
9587
+ files: { [`${skill.name}.md`]: skillContent }
9588
+ };
9589
+ return result;
9590
+ }
9591
+ async transformAgent(agent) {
9592
+ const name = agent.name;
9593
+ const content = this.generateAgentContent(agent);
9594
+ return { name, content };
9595
+ }
9596
+ async installCommand(name, content) {
9597
+ const dir = this.getCommandsDir();
9598
+ await mkdir15(dir, { recursive: true });
9599
+ await writeFile15(join20(dir, `${name}.md`), content);
9600
+ }
9601
+ async installSkill(_name, directory, files) {
9602
+ const baseDir = this.getSkillsDir();
9603
+ const targetDir = directory ? join20(baseDir, directory) : baseDir;
9604
+ await mkdir15(targetDir, { recursive: true });
9605
+ for (const [filename, content] of Object.entries(files)) {
9606
+ await writeFile15(join20(targetDir, filename), content);
9607
+ }
9608
+ }
9609
+ async installAgent(name, content) {
9610
+ const dir = this.getAgentsDir();
9611
+ await mkdir15(dir, { recursive: true });
9612
+ const filePath = join20(dir, `${name}.md`);
9613
+ try {
9614
+ await access8(filePath);
9615
+ const existingContent = await readFile12(filePath, "utf-8");
9616
+ if (!existingContent.includes("name:")) {
9617
+ const updatedContent = `---
9618
+ ${content}
9619
+ ---
9620
+
9621
+ ${existingContent}`;
9622
+ await writeFile15(filePath, updatedContent, "utf-8");
9623
+ }
9624
+ } catch {
9625
+ await writeFile15(filePath, content, "utf-8");
9626
+ }
9627
+ }
9628
+ generateCommandContent(command) {
9629
+ const examples = command.examples.map((e) => {
9630
+ return `- \`${e}\``;
9631
+ }).join("\n");
9632
+ let workflow = command.content;
9633
+ workflow = workflow.replace(/\$ARGUMENTS/g, "$ARGUMENTS").replace(/\$1/g, "$1").replace(/\$2/g, "$2").replace(/\$3/g, "$3").replace(/\$4/g, "$4").replace(/\$5/g, "$5");
9634
+ return `# Command: /${command.name}
9635
+
9636
+ ## Description
9637
+ ${command.description}
9638
+
9639
+ ## Usage
9640
+ \`${command.usage}\`
9641
+
9642
+ ## Examples
9643
+ ${examples}
9644
+
9645
+ ## Workflow
9646
+ ${workflow}
9647
+
9648
+ **Category**: ${command.category}`;
9649
+ }
9650
+ generateSkillContent(skill) {
9651
+ const relativePath = skill.filePath.startsWith(process.cwd()) ? skill.filePath.replace(process.cwd(), "").replace(/\\/g, "/").replace(/^\//, "") : `.aikit/skills/${skill.name}.md`;
9652
+ return `Use the **${skill.name} skill** ${skill.useWhen.toLowerCase()}.
9653
+
9654
+ READ ${relativePath}
9655
+
9656
+ ## Description
9657
+ ${skill.description}
9658
+
9659
+ ## When to Use
9660
+ ${skill.useWhen}
9661
+
9662
+ ## Workflow
9663
+ ${skill.content.split("\n").slice(0, 20).join("\n")}${skill.content.split("\n").length > 20 ? "\n\n... (see full skill file for complete workflow)" : ""}
9664
+
9665
+ **IMPORTANT**: Follow this skill's workflow step by step. Do not skip steps.
9666
+ Complete the checklist at the end of the skill.`;
9667
+ }
9668
+ generateAgentContent(agent) {
9669
+ return `---
9670
+ name: ${agent.name}
9671
+ mode: subagent
9672
+ ---
9673
+
9674
+ ${agent.systemPrompt}`;
9675
+ }
9676
+ };
9677
+
9476
9678
  // src/platform/adapters.ts
9477
9679
  function createAdapter(platform) {
9478
9680
  switch (platform) {
@@ -9480,6 +9682,8 @@ function createAdapter(platform) {
9480
9682
  return new OpenCodeAdapter();
9481
9683
  case "claude" /* CLAUDE */:
9482
9684
  return new ClaudeAdapter();
9685
+ case "cursor" /* CURSOR */:
9686
+ return new CursorAdapter();
9483
9687
  default:
9484
9688
  throw new Error(`Unsupported platform: ${platform}`);
9485
9689
  }
@@ -9490,6 +9694,8 @@ function platformTypeToCliPlatform(type) {
9490
9694
  return "opencode" /* OPENCODE */;
9491
9695
  case "claude":
9492
9696
  return "claude" /* CLAUDE */;
9697
+ case "cursor":
9698
+ return "cursor" /* CURSOR */;
9493
9699
  }
9494
9700
  }
9495
9701
  function getEnabledAdapters(config) {
@@ -9500,22 +9706,25 @@ function getEnabledAdapters(config) {
9500
9706
  }
9501
9707
  var SUPPORTED_PLATFORMS = [
9502
9708
  { platform: "opencode" /* OPENCODE */, name: "OpenCode", configKey: "opencode" },
9503
- { platform: "claude" /* CLAUDE */, name: "Claude Code CLI", configKey: "claude" }
9709
+ { platform: "claude" /* CLAUDE */, name: "Claude Code CLI", configKey: "claude" },
9710
+ { platform: "cursor" /* CURSOR */, name: "Cursor", configKey: "cursor" }
9504
9711
  ];
9505
9712
 
9506
9713
  // src/cli/commands/init.ts
9507
9714
  function getPlatformConfig(choice) {
9508
9715
  switch (choice) {
9509
9716
  case "opencode":
9510
- return { opencode: true, claude: false, primary: "opencode" };
9717
+ return { opencode: true, claude: false, cursor: false, primary: "opencode" };
9511
9718
  case "claude":
9512
- return { opencode: false, claude: true, primary: "claude" };
9719
+ return { opencode: false, claude: true, cursor: false, primary: "claude" };
9720
+ case "cursor":
9721
+ return { opencode: false, claude: false, cursor: true, primary: "cursor" };
9513
9722
  case "both":
9514
- return { opencode: true, claude: true, primary: "opencode" };
9723
+ return { opencode: true, claude: true, cursor: false, primary: "opencode" };
9515
9724
  }
9516
9725
  }
9517
9726
  function registerInitCommand(program2) {
9518
- program2.command("init [platform]").description("Initialize AIKit configuration for a specific platform").option("-g, --global", "Initialize global configuration").option("-p, --project", "Initialize project-level configuration").option("--opencode", "Use OpenCode only").option("--claude", "Use Claude Code only").option("--both", "Use both OpenCode and Claude Code").action(async (platformArg, options) => {
9727
+ program2.command("init [platform]").description("Initialize AIKit configuration for a specific platform").option("-g, --global", "Initialize global configuration").option("-p, --project", "Initialize project-level configuration").option("--opencode", "Use OpenCode only").option("--claude", "Use Claude Code only").option("--cursor", "Use Cursor only").option("--both", "Use both OpenCode and Claude Code").action(async (platformArg, options) => {
9519
9728
  const configDir = options.global ? paths.globalConfig() : paths.projectConfig();
9520
9729
  console.log(chalk3.bold("\n\u{1F680} AIKit Setup\n"));
9521
9730
  logger.info(`Initializing AIKit in ${configDir}...`);
@@ -9525,11 +9734,19 @@ function registerInitCommand(program2) {
9525
9734
  platformChoice = "opencode";
9526
9735
  } else if (options.claude) {
9527
9736
  platformChoice = "claude";
9737
+ } else if (options.cursor) {
9738
+ platformChoice = "cursor";
9528
9739
  } else if (options.both) {
9529
9740
  platformChoice = "both";
9530
9741
  } else if (platformArg) {
9531
9742
  const mapped = CliDetector.matchPlatform(platformArg);
9532
- platformChoice = mapped === "claude" /* CLAUDE */ ? "claude" : "opencode";
9743
+ if (mapped === "cursor" /* CURSOR */) {
9744
+ platformChoice = "cursor";
9745
+ } else if (mapped === "claude" /* CLAUDE */) {
9746
+ platformChoice = "claude";
9747
+ } else {
9748
+ platformChoice = "opencode";
9749
+ }
9533
9750
  } else {
9534
9751
  console.log(chalk3.bold("\n\u{1F4E6} Select Your AI Coding Platform\n"));
9535
9752
  const { choice } = await inquirer.prompt([
@@ -9546,6 +9763,10 @@ function registerInitCommand(program2) {
9546
9763
  name: `${chalk3.yellow("\u25CF")} Claude Code ${chalk3.yellow("(Beta)")}`,
9547
9764
  value: "claude"
9548
9765
  },
9766
+ {
9767
+ name: `${chalk3.magenta("\u25CF")} Cursor ${chalk3.magenta("(Beta)")}`,
9768
+ value: "cursor"
9769
+ },
9549
9770
  {
9550
9771
  name: `${chalk3.cyan("\u25CF")} Both Platforms ${chalk3.gray("(OpenCode + Claude Code)")}`,
9551
9772
  value: "both"
@@ -9559,6 +9780,10 @@ function registerInitCommand(program2) {
9559
9780
  console.log(chalk3.yellow("\n\u26A0\uFE0F Claude Code support is in Beta"));
9560
9781
  console.log(chalk3.gray(" Some features may be limited or experimental.\n"));
9561
9782
  }
9783
+ if (platformChoice === "cursor") {
9784
+ console.log(chalk3.magenta("\n\u26A0\uFE0F Cursor support is in Beta"));
9785
+ console.log(chalk3.gray(" Some features may be limited or experimental.\n"));
9786
+ }
9562
9787
  }
9563
9788
  const platformConfig = getPlatformConfig(platformChoice);
9564
9789
  await initializeConfig(configDir, options.global, platformConfig);
@@ -9566,6 +9791,7 @@ function registerInitCommand(program2) {
9566
9791
  console.log(chalk3.bold("\n\u{1F4CB} Platform Configuration:"));
9567
9792
  console.log(` OpenCode: ${platformConfig.opencode ? chalk3.green("enabled") : chalk3.gray("disabled")}`);
9568
9793
  console.log(` Claude Code: ${platformConfig.claude ? chalk3.yellow("enabled (Beta)") : chalk3.gray("disabled")}`);
9794
+ console.log(` Cursor: ${platformConfig.cursor ? chalk3.magenta("enabled (Beta)") : chalk3.gray("disabled")}`);
9569
9795
  console.log(` Primary: ${chalk3.cyan(platformConfig.primary)}
9570
9796
  `);
9571
9797
  if (!options.global) {
@@ -9697,6 +9923,8 @@ function cliPlatformToType(platform) {
9697
9923
  return "opencode";
9698
9924
  case "claude" /* CLAUDE */:
9699
9925
  return "claude";
9926
+ case "cursor" /* CURSOR */:
9927
+ return "cursor";
9700
9928
  default:
9701
9929
  return "opencode";
9702
9930
  }
@@ -9710,6 +9938,7 @@ function registerInstallCommand(program2) {
9710
9938
  logger.info(` Primary: ${config.getPrimaryPlatform()}`);
9711
9939
  logger.info(` OpenCode: ${config.isPlatformEnabled("opencode") ? "enabled" : "disabled"}`);
9712
9940
  logger.info(` Claude Code: ${config.isPlatformEnabled("claude") ? "enabled (archived)" : "disabled (archived)"}`);
9941
+ logger.info(` Cursor: ${config.isPlatformEnabled("cursor") ? "enabled" : "disabled"}`);
9713
9942
  logger.info("");
9714
9943
  if (enabledPlatforms.length === 0) {
9715
9944
  logger.error("No platforms enabled in config!");
@@ -9848,8 +10077,8 @@ import chalk5 from "chalk";
9848
10077
 
9849
10078
  // src/core/sync-engine.ts
9850
10079
  init_esm_shims();
9851
- import { readFile as readFile15, writeFile as writeFile18, copyFile, mkdir as mkdir16 } from "fs/promises";
9852
- import { join as join23, dirname as dirname4 } from "path";
10080
+ import { readFile as readFile16, writeFile as writeFile19, copyFile, mkdir as mkdir17 } from "fs/promises";
10081
+ import { join as join24, dirname as dirname4 } from "path";
9853
10082
  import inquirer3 from "inquirer";
9854
10083
  import chalk4 from "chalk";
9855
10084
 
@@ -9857,8 +10086,8 @@ import chalk4 from "chalk";
9857
10086
  init_esm_shims();
9858
10087
  init_paths();
9859
10088
  init_logger();
9860
- import { readFile as readFile12, readdir as readdir8, writeFile as writeFile15, stat } from "fs/promises";
9861
- import { join as join20 } from "path";
10089
+ import { readFile as readFile13, readdir as readdir8, writeFile as writeFile16, stat } from "fs/promises";
10090
+ import { join as join21 } from "path";
9862
10091
  import { createHash } from "crypto";
9863
10092
  var VersionManager = class {
9864
10093
  config;
@@ -9869,9 +10098,9 @@ var VersionManager = class {
9869
10098
  * Get current installed version
9870
10099
  */
9871
10100
  async getCurrentVersion() {
9872
- const versionPath = join20(paths.globalConfig(), ".version.json");
10101
+ const versionPath = join21(paths.globalConfig(), ".version.json");
9873
10102
  try {
9874
- const content = await readFile12(versionPath, "utf-8");
10103
+ const content = await readFile13(versionPath, "utf-8");
9875
10104
  return JSON.parse(content);
9876
10105
  } catch {
9877
10106
  return null;
@@ -9882,7 +10111,7 @@ var VersionManager = class {
9882
10111
  */
9883
10112
  getPackageVersion() {
9884
10113
  try {
9885
- const packageJson = __require(join20(process.cwd(), "package.json"));
10114
+ const packageJson = __require(join21(process.cwd(), "package.json"));
9886
10115
  return packageJson.version || "0.0.0";
9887
10116
  } catch {
9888
10117
  return "0.0.0";
@@ -9940,9 +10169,9 @@ var VersionManager = class {
9940
10169
  const removedSkills = [];
9941
10170
  const conflicts = [];
9942
10171
  const installedSkills = /* @__PURE__ */ new Map();
9943
- const installedPath = join20(paths.globalConfig(), ".installed-skills.json");
10172
+ const installedPath = join21(paths.globalConfig(), ".installed-skills.json");
9944
10173
  try {
9945
- const installedData = await readFile12(installedPath, "utf-8");
10174
+ const installedData = await readFile13(installedPath, "utf-8");
9946
10175
  const installedList = JSON.parse(installedData);
9947
10176
  installedList.forEach((skill) => {
9948
10177
  installedSkills.set(skill.name, skill);
@@ -9992,7 +10221,7 @@ var VersionManager = class {
9992
10221
  const loadFromDir = async (dir) => {
9993
10222
  const files = await readdir8(dir);
9994
10223
  for (const file of files) {
9995
- const filePath = join20(dir, file);
10224
+ const filePath = join21(dir, file);
9996
10225
  const stats = await stat(filePath);
9997
10226
  if (stats.isDirectory()) {
9998
10227
  await loadFromDir(filePath);
@@ -10018,7 +10247,7 @@ var VersionManager = class {
10018
10247
  */
10019
10248
  async calculateSkillHash(filePath) {
10020
10249
  try {
10021
- const content = await readFile12(filePath, "utf-8");
10250
+ const content = await readFile13(filePath, "utf-8");
10022
10251
  return createHash("sha256").update(content).digest("hex");
10023
10252
  } catch {
10024
10253
  return "";
@@ -10039,9 +10268,9 @@ var VersionManager = class {
10039
10268
  * Save installed skills info
10040
10269
  */
10041
10270
  async saveInstalledSkills(skills) {
10042
- const installedPath = join20(paths.globalConfig(), ".installed-skills.json");
10271
+ const installedPath = join21(paths.globalConfig(), ".installed-skills.json");
10043
10272
  try {
10044
- await writeFile15(installedPath, JSON.stringify(skills, null, 2));
10273
+ await writeFile16(installedPath, JSON.stringify(skills, null, 2));
10045
10274
  } catch (error) {
10046
10275
  logger.error("Failed to save installed skills info:", error);
10047
10276
  }
@@ -10062,8 +10291,8 @@ var VersionManager = class {
10062
10291
  packageVersion: this.getPackageVersion(),
10063
10292
  migrationHistory: migration ? [...current.migrationHistory, migration] : current.migrationHistory
10064
10293
  };
10065
- const versionPath = join20(paths.globalConfig(), ".version.json");
10066
- await writeFile15(versionPath, JSON.stringify(updated, null, 2));
10294
+ const versionPath = join21(paths.globalConfig(), ".version.json");
10295
+ await writeFile16(versionPath, JSON.stringify(updated, null, 2));
10067
10296
  }
10068
10297
  /**
10069
10298
  * Check if migration is needed
@@ -10078,8 +10307,8 @@ var VersionManager = class {
10078
10307
  // src/core/backup-manager.ts
10079
10308
  init_esm_shims();
10080
10309
  init_logger();
10081
- import { readFile as readFile13, writeFile as writeFile16, readdir as readdir9, stat as stat2, unlink as unlink2, mkdir as mkdir15 } from "fs/promises";
10082
- import { join as join21, dirname as dirname3 } from "path";
10310
+ import { readFile as readFile14, writeFile as writeFile17, readdir as readdir9, stat as stat2, unlink as unlink2, mkdir as mkdir16 } from "fs/promises";
10311
+ import { join as join22, dirname as dirname3 } from "path";
10083
10312
  import { createHash as createHash2 } from "crypto";
10084
10313
  var BackupManager = class {
10085
10314
  configPath;
@@ -10087,7 +10316,7 @@ var BackupManager = class {
10087
10316
  maxBackups;
10088
10317
  constructor(configPath, maxBackups = 5) {
10089
10318
  this.configPath = configPath;
10090
- this.backupsDir = join21(configPath, ".backups");
10319
+ this.backupsDir = join22(configPath, ".backups");
10091
10320
  this.maxBackups = maxBackups;
10092
10321
  }
10093
10322
  /**
@@ -10095,10 +10324,10 @@ var BackupManager = class {
10095
10324
  */
10096
10325
  async createBackup(fromVersion, toVersion) {
10097
10326
  try {
10098
- await mkdir15(this.backupsDir, { recursive: true });
10327
+ await mkdir16(this.backupsDir, { recursive: true });
10099
10328
  const backupId = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
10100
- const backupPath = join21(this.backupsDir, `${backupId}-v${toVersion}`);
10101
- await mkdir15(backupPath, { recursive: true });
10329
+ const backupPath = join22(this.backupsDir, `${backupId}-v${toVersion}`);
10330
+ await mkdir16(backupPath, { recursive: true });
10102
10331
  logger.info(`Creating backup: ${backupPath}`);
10103
10332
  const files = [];
10104
10333
  const backupItems = [
@@ -10119,8 +10348,8 @@ var BackupManager = class {
10119
10348
  files,
10120
10349
  success: true
10121
10350
  };
10122
- const manifestPath = join21(backupPath, "backup-manifest.json");
10123
- await writeFile16(manifestPath, JSON.stringify(manifest, null, 2));
10351
+ const manifestPath = join22(backupPath, "backup-manifest.json");
10352
+ await writeFile17(manifestPath, JSON.stringify(manifest, null, 2));
10124
10353
  await this.cleanupOldBackups();
10125
10354
  logger.success(`\u2713 Backup created: ${backupId}`);
10126
10355
  return backupId;
@@ -10133,20 +10362,20 @@ var BackupManager = class {
10133
10362
  * Backup a file or directory
10134
10363
  */
10135
10364
  async backupItem(sourceDir, item, targetDir) {
10136
- const sourcePath = join21(sourceDir, item);
10137
- const targetPath = join21(targetDir, item);
10365
+ const sourcePath = join22(sourceDir, item);
10366
+ const targetPath = join22(targetDir, item);
10138
10367
  const files = [];
10139
10368
  try {
10140
10369
  const stats = await stat2(sourcePath);
10141
10370
  if (stats.isDirectory()) {
10142
- await mkdir15(targetPath, { recursive: true });
10371
+ await mkdir16(targetPath, { recursive: true });
10143
10372
  const entries = await readdir9(sourcePath);
10144
10373
  for (const entry of entries) {
10145
10374
  const entryFiles = await this.backupItem(sourcePath, entry, targetPath);
10146
10375
  files.push(...entryFiles);
10147
10376
  }
10148
10377
  } else if (stats.isFile()) {
10149
- await mkdir15(dirname3(targetPath), { recursive: true });
10378
+ await mkdir16(dirname3(targetPath), { recursive: true });
10150
10379
  await this.copyFile(sourcePath, targetPath);
10151
10380
  const hash = await this.calculateHash(targetPath);
10152
10381
  files.push({
@@ -10164,15 +10393,15 @@ var BackupManager = class {
10164
10393
  * Copy file with hash calculation
10165
10394
  */
10166
10395
  async copyFile(source, target) {
10167
- const content = await readFile13(source);
10168
- await writeFile16(target, content);
10396
+ const content = await readFile14(source);
10397
+ await writeFile17(target, content);
10169
10398
  }
10170
10399
  /**
10171
10400
  * Calculate file hash
10172
10401
  */
10173
10402
  async calculateHash(filePath) {
10174
10403
  try {
10175
- const content = await readFile13(filePath);
10404
+ const content = await readFile14(filePath);
10176
10405
  return createHash2("sha256").update(content).digest("hex");
10177
10406
  } catch {
10178
10407
  return "";
@@ -10186,10 +10415,10 @@ var BackupManager = class {
10186
10415
  const entries = await readdir9(this.backupsDir);
10187
10416
  const backups = [];
10188
10417
  for (const entry of entries) {
10189
- const backupPath = join21(this.backupsDir, entry);
10190
- const manifestPath = join21(backupPath, "backup-manifest.json");
10418
+ const backupPath = join22(this.backupsDir, entry);
10419
+ const manifestPath = join22(backupPath, "backup-manifest.json");
10191
10420
  try {
10192
- const manifestContent = await readFile13(manifestPath, "utf-8");
10421
+ const manifestContent = await readFile14(manifestPath, "utf-8");
10193
10422
  const manifest = JSON.parse(manifestContent);
10194
10423
  const size = await this.calculateBackupSize(backupPath);
10195
10424
  backups.push({
@@ -10217,7 +10446,7 @@ var BackupManager = class {
10217
10446
  const calculate = async (dir) => {
10218
10447
  const entries = await readdir9(dir);
10219
10448
  for (const entry of entries) {
10220
- const entryPath = join21(dir, entry);
10449
+ const entryPath = join22(dir, entry);
10221
10450
  const stats = await stat2(entryPath);
10222
10451
  if (stats.isDirectory()) {
10223
10452
  await calculate(entryPath);
@@ -10249,9 +10478,9 @@ var BackupManager = class {
10249
10478
  return false;
10250
10479
  }
10251
10480
  for (const file of backup.manifest.files) {
10252
- const sourcePath = join21(backup.path, file.path);
10253
- const targetPath = join21(this.configPath, file.path);
10254
- await mkdir15(dirname3(targetPath), { recursive: true });
10481
+ const sourcePath = join22(backup.path, file.path);
10482
+ const targetPath = join22(this.configPath, file.path);
10483
+ await mkdir16(dirname3(targetPath), { recursive: true });
10255
10484
  await this.copyFile(sourcePath, targetPath);
10256
10485
  }
10257
10486
  logger.success(`\u2713 Backup restored: ${backupId}`);
@@ -10266,10 +10495,10 @@ var BackupManager = class {
10266
10495
  */
10267
10496
  async validateBackup(backup) {
10268
10497
  try {
10269
- const manifestPath = join21(backup.path, "backup-manifest.json");
10270
- await readFile13(manifestPath, "utf-8");
10498
+ const manifestPath = join22(backup.path, "backup-manifest.json");
10499
+ await readFile14(manifestPath, "utf-8");
10271
10500
  for (const file of backup.manifest.files) {
10272
- const filePath = join21(backup.path, file.path);
10501
+ const filePath = join22(backup.path, file.path);
10273
10502
  await stat2(filePath);
10274
10503
  const currentHash = await this.calculateHash(filePath);
10275
10504
  if (currentHash !== file.hash) {
@@ -10295,7 +10524,7 @@ var BackupManager = class {
10295
10524
  }
10296
10525
  const entries = await readdir9(backup.path);
10297
10526
  for (const entry of entries) {
10298
- const entryPath = join21(backup.path, entry);
10527
+ const entryPath = join22(backup.path, entry);
10299
10528
  const stats = await stat2(entryPath);
10300
10529
  if (stats.isDirectory()) {
10301
10530
  await this.removeDirectory(entryPath);
@@ -10316,7 +10545,7 @@ var BackupManager = class {
10316
10545
  async removeDirectory(dirPath) {
10317
10546
  const entries = await readdir9(dirPath);
10318
10547
  for (const entry of entries) {
10319
- const entryPath = join21(dirPath, entry);
10548
+ const entryPath = join22(dirPath, entry);
10320
10549
  const stats = await stat2(entryPath);
10321
10550
  if (stats.isDirectory()) {
10322
10551
  await this.removeDirectory(entryPath);
@@ -10362,14 +10591,14 @@ var BackupManager = class {
10362
10591
  // src/core/migration-manager.ts
10363
10592
  init_esm_shims();
10364
10593
  init_logger();
10365
- import { readFile as readFile14, writeFile as writeFile17, readdir as readdir10 } from "fs/promises";
10366
- import { join as join22 } from "path";
10594
+ import { readFile as readFile15, writeFile as writeFile18, readdir as readdir10 } from "fs/promises";
10595
+ import { join as join23 } from "path";
10367
10596
  var MigrationManager = class {
10368
10597
  configPath;
10369
10598
  migrationsDir;
10370
10599
  constructor(configPath) {
10371
10600
  this.configPath = configPath;
10372
- this.migrationsDir = join22(process.cwd(), "src/core/migrations");
10601
+ this.migrationsDir = join23(process.cwd(), "src/core/migrations");
10373
10602
  }
10374
10603
  /**
10375
10604
  * Load all available migrations
@@ -10381,7 +10610,7 @@ var MigrationManager = class {
10381
10610
  for (const file of files) {
10382
10611
  if (file.endsWith(".js") && file.startsWith("migrate-")) {
10383
10612
  try {
10384
- const module = await import(join22(this.migrationsDir, file));
10613
+ const module = await import(join23(this.migrationsDir, file));
10385
10614
  const migration = module.default || module.migration;
10386
10615
  if (migration) {
10387
10616
  migrations.push(migration);
@@ -10400,9 +10629,9 @@ var MigrationManager = class {
10400
10629
  * Get applied migrations
10401
10630
  */
10402
10631
  async getAppliedMigrations() {
10403
- const migrationHistoryPath = join22(this.configPath, ".migration-history.json");
10632
+ const migrationHistoryPath = join23(this.configPath, ".migration-history.json");
10404
10633
  try {
10405
- const content = await readFile14(migrationHistoryPath, "utf-8");
10634
+ const content = await readFile15(migrationHistoryPath, "utf-8");
10406
10635
  const history = JSON.parse(content);
10407
10636
  return history.filter((m) => m.status === "completed").map((m) => m.to);
10408
10637
  } catch {
@@ -10488,16 +10717,16 @@ var MigrationManager = class {
10488
10717
  * Update migration history
10489
10718
  */
10490
10719
  async updateMigrationHistory(entries) {
10491
- const historyPath = join22(this.configPath, ".migration-history.json");
10720
+ const historyPath = join23(this.configPath, ".migration-history.json");
10492
10721
  try {
10493
10722
  let history = [];
10494
10723
  try {
10495
- const content = await readFile14(historyPath, "utf-8");
10724
+ const content = await readFile15(historyPath, "utf-8");
10496
10725
  history = JSON.parse(content);
10497
10726
  } catch {
10498
10727
  }
10499
10728
  history.push(...entries);
10500
- await writeFile17(historyPath, JSON.stringify(history, null, 2));
10729
+ await writeFile18(historyPath, JSON.stringify(history, null, 2));
10501
10730
  } catch (error) {
10502
10731
  logger.error("Failed to update migration history:", error);
10503
10732
  }
@@ -10506,14 +10735,14 @@ var MigrationManager = class {
10506
10735
  * Update migration history status
10507
10736
  */
10508
10737
  async updateMigrationHistoryStatus(version, status) {
10509
- const historyPath = join22(this.configPath, ".migration-history.json");
10738
+ const historyPath = join23(this.configPath, ".migration-history.json");
10510
10739
  try {
10511
- const content = await readFile14(historyPath, "utf-8");
10740
+ const content = await readFile15(historyPath, "utf-8");
10512
10741
  const history = JSON.parse(content);
10513
10742
  const updated = history.map(
10514
10743
  (m) => m.to === version ? { ...m, status } : m
10515
10744
  );
10516
- await writeFile17(historyPath, JSON.stringify(updated, null, 2));
10745
+ await writeFile18(historyPath, JSON.stringify(updated, null, 2));
10517
10746
  } catch (error) {
10518
10747
  logger.error("Failed to update migration history status:", error);
10519
10748
  }
@@ -10522,9 +10751,9 @@ var MigrationManager = class {
10522
10751
  * Get migration history
10523
10752
  */
10524
10753
  async getMigrationHistory() {
10525
- const historyPath = join22(this.configPath, ".migration-history.json");
10754
+ const historyPath = join23(this.configPath, ".migration-history.json");
10526
10755
  try {
10527
- const content = await readFile14(historyPath, "utf-8");
10756
+ const content = await readFile15(historyPath, "utf-8");
10528
10757
  return JSON.parse(content);
10529
10758
  } catch {
10530
10759
  return [];
@@ -10833,19 +11062,19 @@ var SyncEngine = class {
10833
11062
  * Install a skill
10834
11063
  */
10835
11064
  async installSkill(sourceDir, skill, targetDir) {
10836
- const sourcePath = join23(sourceDir, skill.category, `${skill.name}.md`);
10837
- const targetPath = join23(targetDir, skill.category, `${skill.name}.md`);
10838
- await mkdir16(dirname4(targetPath), { recursive: true });
11065
+ const sourcePath = join24(sourceDir, skill.category, `${skill.name}.md`);
11066
+ const targetPath = join24(targetDir, skill.category, `${skill.name}.md`);
11067
+ await mkdir17(dirname4(targetPath), { recursive: true });
10839
11068
  await copyFile(sourcePath, targetPath);
10840
11069
  }
10841
11070
  /**
10842
11071
  * Archive a removed skill
10843
11072
  */
10844
11073
  async archiveSkill(targetDir, skill) {
10845
- const sourcePath = join23(targetDir, skill.category, `${skill.name}.md`);
10846
- const targetPath = join23(targetDir, skill.category, `${skill.name}-deprecated.md`);
11074
+ const sourcePath = join24(targetDir, skill.category, `${skill.name}.md`);
11075
+ const targetPath = join24(targetDir, skill.category, `${skill.name}-deprecated.md`);
10847
11076
  try {
10848
- const content = await readFile15(sourcePath, "utf-8");
11077
+ const content = await readFile16(sourcePath, "utf-8");
10849
11078
  const deprecatedNotice = `---
10850
11079
  \u26A0\uFE0F DEPRECATED: This skill has been removed
10851
11080
 
@@ -10854,8 +11083,8 @@ Reason: Check release notes for replacement
10854
11083
  ---
10855
11084
 
10856
11085
  ${content}`;
10857
- await mkdir16(dirname4(targetPath), { recursive: true });
10858
- await writeFile18(targetPath, deprecatedNotice);
11086
+ await mkdir17(dirname4(targetPath), { recursive: true });
11087
+ await writeFile19(targetPath, deprecatedNotice);
10859
11088
  } catch (error) {
10860
11089
  if (error.code === "ENOENT") {
10861
11090
  console.log(chalk4.yellow(` - ${skill.name} (not found, skipping)`));
@@ -11088,8 +11317,8 @@ async function configureToolAction(toolName) {
11088
11317
  // src/cli/commands/misc.ts
11089
11318
  init_esm_shims();
11090
11319
  import chalk7 from "chalk";
11091
- import { readFile as readFile16, writeFile as writeFile19, mkdir as mkdir17 } from "fs/promises";
11092
- import { join as join24 } from "path";
11320
+ import { readFile as readFile17, writeFile as writeFile20, mkdir as mkdir18 } from "fs/promises";
11321
+ import { join as join25 } from "path";
11093
11322
  init_config();
11094
11323
  init_memory();
11095
11324
  init_beads();
@@ -11152,9 +11381,9 @@ function registerModeCommand(program2) {
11152
11381
  console.log(chalk7.red(`Invalid mode. Available modes: ${validModes.join(", ")}`));
11153
11382
  return;
11154
11383
  }
11155
- const configData = JSON.parse(await readFile16(join24(configPath, "aikit.json"), "utf-8"));
11384
+ const configData = JSON.parse(await readFile17(join25(configPath, "aikit.json"), "utf-8"));
11156
11385
  configData.mode = mode;
11157
- await writeFile19(join24(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11386
+ await writeFile20(join25(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11158
11387
  console.log(chalk7.green(`\u2713 Mode set to: ${mode}`));
11159
11388
  console.log(chalk7.gray(`Configuration updated at: ${configPath}/aikit.json`));
11160
11389
  } catch (error) {
@@ -11272,7 +11501,7 @@ function registerPlatformCommand(program2) {
11272
11501
  try {
11273
11502
  let configData = {};
11274
11503
  try {
11275
- configData = JSON.parse(await readFile16(join24(configPath, "aikit.json"), "utf-8"));
11504
+ configData = JSON.parse(await readFile17(join25(configPath, "aikit.json"), "utf-8"));
11276
11505
  } catch {
11277
11506
  }
11278
11507
  if (!configData.platform) {
@@ -11280,8 +11509,8 @@ function registerPlatformCommand(program2) {
11280
11509
  }
11281
11510
  configData.platform.primary = platform;
11282
11511
  configData.platform[platform] = true;
11283
- await mkdir17(configPath, { recursive: true });
11284
- await writeFile19(join24(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11512
+ await mkdir18(configPath, { recursive: true });
11513
+ await writeFile20(join25(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11285
11514
  console.log(chalk7.green(`\u2713 Primary platform set to: ${platform}`));
11286
11515
  console.log(chalk7.gray(`Configuration updated at: ${configPath}/aikit.json`));
11287
11516
  console.log();
@@ -11303,7 +11532,7 @@ async function togglePlatform(platform, enable) {
11303
11532
  try {
11304
11533
  let configData = {};
11305
11534
  try {
11306
- configData = JSON.parse(await readFile16(join24(configPath, "aikit.json"), "utf-8"));
11535
+ configData = JSON.parse(await readFile17(join25(configPath, "aikit.json"), "utf-8"));
11307
11536
  } catch {
11308
11537
  }
11309
11538
  if (!configData.platform) {
@@ -11314,8 +11543,8 @@ async function togglePlatform(platform, enable) {
11314
11543
  };
11315
11544
  }
11316
11545
  configData.platform[platform] = enable;
11317
- await mkdir17(configPath, { recursive: true });
11318
- await writeFile19(join24(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11546
+ await mkdir18(configPath, { recursive: true });
11547
+ await writeFile20(join25(configPath, "aikit.json"), JSON.stringify(configData, null, 2));
11319
11548
  const action = enable ? "enabled" : "disabled";
11320
11549
  const emoji = enable ? "\u2713" : "\u25CB";
11321
11550
  console.log(chalk7.green(`${emoji} Platform ${platform} ${action}`));