@deepstorm/cli 0.6.6 → 0.7.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 (2) hide show
  1. package/dist/cli.js +495 -405
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -1187,13 +1187,13 @@ var require_ast = __commonJS({
1187
1187
  helperExpression: function helperExpression(node) {
1188
1188
  return node.type === "SubExpression" || (node.type === "MustacheStatement" || node.type === "BlockStatement") && !!(node.params && node.params.length || node.hash);
1189
1189
  },
1190
- scopedId: function scopedId(path22) {
1191
- return /^\.|this\b/.test(path22.original);
1190
+ scopedId: function scopedId(path23) {
1191
+ return /^\.|this\b/.test(path23.original);
1192
1192
  },
1193
1193
  // an ID is simple if it only has one part, and that part is not
1194
1194
  // `..` or `this`.
1195
- simpleId: function simpleId(path22) {
1196
- return path22.parts.length === 1 && !AST.helpers.scopedId(path22) && !path22.depth;
1195
+ simpleId: function simpleId(path23) {
1196
+ return path23.parts.length === 1 && !AST.helpers.scopedId(path23) && !path23.depth;
1197
1197
  }
1198
1198
  }
1199
1199
  };
@@ -2263,12 +2263,12 @@ var require_helpers2 = __commonJS({
2263
2263
  loc
2264
2264
  };
2265
2265
  }
2266
- function prepareMustache(path22, params, hash, open, strip, locInfo) {
2266
+ function prepareMustache(path23, params, hash, open, strip, locInfo) {
2267
2267
  var escapeFlag = open.charAt(3) || open.charAt(2), escaped = escapeFlag !== "{" && escapeFlag !== "&";
2268
2268
  var decorator = /\*/.test(open);
2269
2269
  return {
2270
2270
  type: decorator ? "Decorator" : "MustacheStatement",
2271
- path: path22,
2271
+ path: path23,
2272
2272
  params,
2273
2273
  hash,
2274
2274
  escaped,
@@ -2586,9 +2586,9 @@ var require_compiler = __commonJS({
2586
2586
  },
2587
2587
  DecoratorBlock: function DecoratorBlock(decorator) {
2588
2588
  var program2 = decorator.program && this.compileProgram(decorator.program);
2589
- var params = this.setupFullMustacheParams(decorator, program2, void 0), path22 = decorator.path;
2589
+ var params = this.setupFullMustacheParams(decorator, program2, void 0), path23 = decorator.path;
2590
2590
  this.useDecorators = true;
2591
- this.opcode("registerDecorator", params.length, path22.original);
2591
+ this.opcode("registerDecorator", params.length, path23.original);
2592
2592
  },
2593
2593
  PartialStatement: function PartialStatement(partial) {
2594
2594
  this.usePartial = true;
@@ -2652,46 +2652,46 @@ var require_compiler = __commonJS({
2652
2652
  }
2653
2653
  },
2654
2654
  ambiguousSexpr: function ambiguousSexpr(sexpr, program2, inverse) {
2655
- var path22 = sexpr.path, name = path22.parts[0], isBlock = program2 != null || inverse != null;
2656
- this.opcode("getContext", path22.depth);
2655
+ var path23 = sexpr.path, name = path23.parts[0], isBlock = program2 != null || inverse != null;
2656
+ this.opcode("getContext", path23.depth);
2657
2657
  this.opcode("pushProgram", program2);
2658
2658
  this.opcode("pushProgram", inverse);
2659
- path22.strict = true;
2660
- this.accept(path22);
2659
+ path23.strict = true;
2660
+ this.accept(path23);
2661
2661
  this.opcode("invokeAmbiguous", name, isBlock);
2662
2662
  },
2663
2663
  simpleSexpr: function simpleSexpr(sexpr) {
2664
- var path22 = sexpr.path;
2665
- path22.strict = true;
2666
- this.accept(path22);
2664
+ var path23 = sexpr.path;
2665
+ path23.strict = true;
2666
+ this.accept(path23);
2667
2667
  this.opcode("resolvePossibleLambda");
2668
2668
  },
2669
2669
  helperSexpr: function helperSexpr(sexpr, program2, inverse) {
2670
- var params = this.setupFullMustacheParams(sexpr, program2, inverse), path22 = sexpr.path, name = path22.parts[0];
2670
+ var params = this.setupFullMustacheParams(sexpr, program2, inverse), path23 = sexpr.path, name = path23.parts[0];
2671
2671
  if (this.options.knownHelpers[name]) {
2672
2672
  this.opcode("invokeKnownHelper", params.length, name);
2673
2673
  } else if (this.options.knownHelpersOnly) {
2674
2674
  throw new _exception2["default"]("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
2675
2675
  } else {
2676
- path22.strict = true;
2677
- path22.falsy = true;
2678
- this.accept(path22);
2679
- this.opcode("invokeHelper", params.length, path22.original, _ast2["default"].helpers.simpleId(path22));
2676
+ path23.strict = true;
2677
+ path23.falsy = true;
2678
+ this.accept(path23);
2679
+ this.opcode("invokeHelper", params.length, path23.original, _ast2["default"].helpers.simpleId(path23));
2680
2680
  }
2681
2681
  },
2682
- PathExpression: function PathExpression(path22) {
2683
- this.addDepth(path22.depth);
2684
- this.opcode("getContext", path22.depth);
2685
- var name = path22.parts[0], scoped = _ast2["default"].helpers.scopedId(path22), blockParamId = !path22.depth && !scoped && this.blockParamIndex(name);
2682
+ PathExpression: function PathExpression(path23) {
2683
+ this.addDepth(path23.depth);
2684
+ this.opcode("getContext", path23.depth);
2685
+ var name = path23.parts[0], scoped = _ast2["default"].helpers.scopedId(path23), blockParamId = !path23.depth && !scoped && this.blockParamIndex(name);
2686
2686
  if (blockParamId) {
2687
- this.opcode("lookupBlockParam", blockParamId, path22.parts);
2687
+ this.opcode("lookupBlockParam", blockParamId, path23.parts);
2688
2688
  } else if (!name) {
2689
2689
  this.opcode("pushContext");
2690
- } else if (path22.data) {
2690
+ } else if (path23.data) {
2691
2691
  this.options.data = true;
2692
- this.opcode("lookupData", path22.depth, path22.parts, path22.strict);
2692
+ this.opcode("lookupData", path23.depth, path23.parts, path23.strict);
2693
2693
  } else {
2694
- this.opcode("lookupOnContext", path22.parts, path22.falsy, path22.strict, scoped);
2694
+ this.opcode("lookupOnContext", path23.parts, path23.falsy, path23.strict, scoped);
2695
2695
  }
2696
2696
  },
2697
2697
  StringLiteral: function StringLiteral(string) {
@@ -3041,16 +3041,16 @@ var require_util = __commonJS({
3041
3041
  }
3042
3042
  exports2.urlGenerate = urlGenerate;
3043
3043
  function normalize(aPath) {
3044
- var path22 = aPath;
3044
+ var path23 = aPath;
3045
3045
  var url = urlParse(aPath);
3046
3046
  if (url) {
3047
3047
  if (!url.path) {
3048
3048
  return aPath;
3049
3049
  }
3050
- path22 = url.path;
3050
+ path23 = url.path;
3051
3051
  }
3052
- var isAbsolute = exports2.isAbsolute(path22);
3053
- var parts = path22.split(/\/+/);
3052
+ var isAbsolute = exports2.isAbsolute(path23);
3053
+ var parts = path23.split(/\/+/);
3054
3054
  for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
3055
3055
  part = parts[i];
3056
3056
  if (part === ".") {
@@ -3067,18 +3067,18 @@ var require_util = __commonJS({
3067
3067
  }
3068
3068
  }
3069
3069
  }
3070
- path22 = parts.join("/");
3071
- if (path22 === "") {
3072
- path22 = isAbsolute ? "/" : ".";
3070
+ path23 = parts.join("/");
3071
+ if (path23 === "") {
3072
+ path23 = isAbsolute ? "/" : ".";
3073
3073
  }
3074
3074
  if (url) {
3075
- url.path = path22;
3075
+ url.path = path23;
3076
3076
  return urlGenerate(url);
3077
3077
  }
3078
- return path22;
3078
+ return path23;
3079
3079
  }
3080
3080
  exports2.normalize = normalize;
3081
- function join20(aRoot, aPath) {
3081
+ function join21(aRoot, aPath) {
3082
3082
  if (aRoot === "") {
3083
3083
  aRoot = ".";
3084
3084
  }
@@ -3110,7 +3110,7 @@ var require_util = __commonJS({
3110
3110
  }
3111
3111
  return joined;
3112
3112
  }
3113
- exports2.join = join20;
3113
+ exports2.join = join21;
3114
3114
  exports2.isAbsolute = function(aPath) {
3115
3115
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
3116
3116
  };
@@ -3283,7 +3283,7 @@ var require_util = __commonJS({
3283
3283
  parsed.path = parsed.path.substring(0, index + 1);
3284
3284
  }
3285
3285
  }
3286
- sourceURL = join20(urlGenerate(parsed), sourceURL);
3286
+ sourceURL = join21(urlGenerate(parsed), sourceURL);
3287
3287
  }
3288
3288
  return normalize(sourceURL);
3289
3289
  }
@@ -5858,8 +5858,8 @@ var require_printer = __commonJS({
5858
5858
  return this.accept(sexpr.path) + " " + params + hash;
5859
5859
  };
5860
5860
  PrintVisitor.prototype.PathExpression = function(id) {
5861
- var path22 = id.parts.join("/");
5862
- return (id.data ? "@" : "") + "PATH:" + path22;
5861
+ var path23 = id.parts.join("/");
5862
+ return (id.data ? "@" : "") + "PATH:" + path23;
5863
5863
  };
5864
5864
  PrintVisitor.prototype.StringLiteral = function(string) {
5865
5865
  return '"' + string.value + '"';
@@ -5898,8 +5898,8 @@ var require_lib = __commonJS({
5898
5898
  handlebars.print = printer.print;
5899
5899
  module2.exports = handlebars;
5900
5900
  function extension(module3, filename) {
5901
- var fs27 = require("fs");
5902
- var templateString = fs27.readFileSync(filename, "utf8");
5901
+ var fs28 = require("fs");
5902
+ var templateString = fs28.readFileSync(filename, "utf8");
5903
5903
  module3.exports = handlebars.compile(templateString);
5904
5904
  }
5905
5905
  if (typeof require !== "undefined" && require.extensions) {
@@ -5911,12 +5911,12 @@ var require_lib = __commonJS({
5911
5911
 
5912
5912
  // src/index.ts
5913
5913
  var import_commander = require("commander");
5914
- var fs26 = __toESM(require("node:fs"));
5915
- var path21 = __toESM(require("node:path"));
5914
+ var fs27 = __toESM(require("node:fs"));
5915
+ var path22 = __toESM(require("node:path"));
5916
5916
 
5917
5917
  // src/commands/setup.ts
5918
- var path8 = __toESM(require("node:path"));
5919
- var fs12 = __toESM(require("node:fs"));
5918
+ var path9 = __toESM(require("node:path"));
5919
+ var fs13 = __toESM(require("node:fs"));
5920
5920
 
5921
5921
  // src/engine/registry.ts
5922
5922
  var RegistryReader = class {
@@ -7065,7 +7065,7 @@ __pycache__/
7065
7065
  .vscode/
7066
7066
  *.iml
7067
7067
  `);
7068
- writeTemplate(projectDir, ".env.example", `# \u6570\u636E\u5E93\u914D\u7F6E
7068
+ writeEnvFile(projectDir, `# \u6570\u636E\u5E93\u914D\u7F6E
7069
7069
  DB_URL=jdbc:postgresql://localhost:5432/${ctx.packageName}
7070
7070
  DB_USERNAME=postgres
7071
7071
  DB_PASSWORD=change-me
@@ -7130,6 +7130,16 @@ function writeTemplate(baseDir, relativePath, content) {
7130
7130
  ensureDir2(path2.dirname(fullPath));
7131
7131
  fs2.writeFileSync(fullPath, content, "utf-8");
7132
7132
  }
7133
+ function writeEnvFile(baseDir, content) {
7134
+ const envPath = path2.join(baseDir, ".env");
7135
+ ensureDir2(path2.dirname(envPath));
7136
+ if (fs2.existsSync(envPath)) {
7137
+ const existing = fs2.readFileSync(envPath, "utf-8").trimEnd();
7138
+ fs2.writeFileSync(envPath, existing + "\n\n" + content, "utf-8");
7139
+ } else {
7140
+ fs2.writeFileSync(envPath, content, "utf-8");
7141
+ }
7142
+ }
7133
7143
  function printProjectTree(projectDir, hasFrontend, hasBackend) {
7134
7144
  console.log("\u76EE\u5F55\u7ED3\u6784:");
7135
7145
  console.log(` ${path2.basename(projectDir)}/`);
@@ -7160,13 +7170,90 @@ function printProjectTree(projectDir, hasFrontend, hasBackend) {
7160
7170
  }
7161
7171
  }
7162
7172
 
7163
- // src/merger/mcp.ts
7173
+ // src/utils/auto-install.ts
7164
7174
  var fs3 = __toESM(require("node:fs"));
7175
+ var path3 = __toESM(require("node:path"));
7176
+ var import_node_child_process = require("node:child_process");
7177
+ var EXEC_OPTIONS = { encoding: "utf-8", timeout: 12e4, stdio: "pipe" };
7178
+ function execSafe(command) {
7179
+ try {
7180
+ const output = (0, import_node_child_process.execSync)(command, EXEC_OPTIONS);
7181
+ return { success: true, output: output.toString() };
7182
+ } catch (error) {
7183
+ const message = error instanceof Error ? error.message : String(error);
7184
+ return { success: false, output: message };
7185
+ }
7186
+ }
7187
+ function isBmadInstalled() {
7188
+ const result = execSafe("npx bmad-method status");
7189
+ return result.success && result.output.includes("Version:");
7190
+ }
7191
+ function isGrillMeInstalled(targetDir) {
7192
+ return fs3.existsSync(path3.join(targetDir, ".claude", "skills", "grill-me", "SKILL.md"));
7193
+ }
7194
+ function installBmadMethod() {
7195
+ if (isBmadInstalled()) {
7196
+ console.log("\u2139 BMAD Method \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u5B89\u88C5");
7197
+ return;
7198
+ }
7199
+ const result = execSafe("npx bmad-method install");
7200
+ if (result.success) {
7201
+ console.log("\u2714 BMAD Method \u5DF2\u5B89\u88C5");
7202
+ } else {
7203
+ console.log("\u26A0 BMAD Method \u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C npx bmad-method install");
7204
+ }
7205
+ }
7206
+ function installGrillMe(targetDir) {
7207
+ if (isGrillMeInstalled(targetDir)) {
7208
+ console.log("\u2139 grill-me \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u5B89\u88C5");
7209
+ return;
7210
+ }
7211
+ const skillDir = path3.join(targetDir, ".claude", "skills", "grill-me");
7212
+ fs3.mkdirSync(skillDir, { recursive: true });
7213
+ try {
7214
+ (0, import_node_child_process.execSync)(
7215
+ "curl -fsSL https://raw.githubusercontent.com/mattpocock/skills/main/grill-me/SKILL.md -o SKILL.md",
7216
+ { ...EXEC_OPTIONS, cwd: skillDir }
7217
+ );
7218
+ console.log("\u2714 grill-me skill \u5DF2\u5B89\u88C5");
7219
+ } catch {
7220
+ console.log("\u26A0 grill-me \u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u5B89\u88C5 https://github.com/mattpocock/skills");
7221
+ }
7222
+ }
7223
+ function isPlaywrightInstalled(targetDir) {
7224
+ const result = execSafe("npx playwright install --dry-run");
7225
+ return result.success && !result.output.toLowerCase().includes("to install");
7226
+ }
7227
+ function installPlaywright(config, targetDir) {
7228
+ if (config["sweep.e2eFramework"] !== "playwright") return;
7229
+ if (isPlaywrightInstalled(targetDir)) {
7230
+ console.log("\u2139 Playwright \u6D4F\u89C8\u5668\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u5B89\u88C5");
7231
+ return;
7232
+ }
7233
+ const result = execSafe("npx playwright install");
7234
+ if (result.success) {
7235
+ console.log("\u2714 Playwright \u6D4F\u89C8\u5668\u5DF2\u5B89\u88C5");
7236
+ } else {
7237
+ console.log("\u26A0 Playwright \u6D4F\u89C8\u5668\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C npx playwright install");
7238
+ }
7239
+ }
7240
+ function step9AutoInstallDeps(tools, config, targetDir) {
7241
+ if (tools.includes("tide")) {
7242
+ installBmadMethod();
7243
+ installGrillMe(targetDir);
7244
+ }
7245
+ if (tools.includes("sweep")) {
7246
+ installPlaywright(config, targetDir);
7247
+ }
7248
+ }
7249
+
7250
+ // src/merger/mcp.ts
7251
+ var fs4 = __toESM(require("node:fs"));
7165
7252
  function mergeMcpServers(mcpPath, servers) {
7166
7253
  let mcp = {};
7167
7254
  try {
7168
- if (fs3.existsSync(mcpPath)) {
7169
- const raw = fs3.readFileSync(mcpPath, "utf-8");
7255
+ if (fs4.existsSync(mcpPath)) {
7256
+ const raw = fs4.readFileSync(mcpPath, "utf-8");
7170
7257
  mcp = JSON.parse(raw);
7171
7258
  }
7172
7259
  } catch {
@@ -7174,31 +7261,31 @@ function mergeMcpServers(mcpPath, servers) {
7174
7261
  }
7175
7262
  const existingServers = mcp.mcpServers || {};
7176
7263
  mcp.mcpServers = deepMerge(existingServers, servers);
7177
- fs3.writeFileSync(mcpPath, JSON.stringify(mcp, null, 2) + "\n", "utf-8");
7264
+ fs4.writeFileSync(mcpPath, JSON.stringify(mcp, null, 2) + "\n", "utf-8");
7178
7265
  }
7179
7266
 
7180
7267
  // src/merger/hooks.ts
7181
- var fs4 = __toESM(require("node:fs"));
7268
+ var fs5 = __toESM(require("node:fs"));
7182
7269
  function mergeHooks(hooksPath, hooks) {
7183
7270
  let existing = {};
7184
7271
  try {
7185
- if (fs4.existsSync(hooksPath)) {
7186
- const raw = fs4.readFileSync(hooksPath, "utf-8");
7272
+ if (fs5.existsSync(hooksPath)) {
7273
+ const raw = fs5.readFileSync(hooksPath, "utf-8");
7187
7274
  existing = JSON.parse(raw);
7188
7275
  }
7189
7276
  } catch {
7190
7277
  existing = {};
7191
7278
  }
7192
7279
  const merged = deepMerge(existing, hooks);
7193
- fs4.writeFileSync(hooksPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
7280
+ fs5.writeFileSync(hooksPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
7194
7281
  }
7195
7282
 
7196
7283
  // src/wizard/mcp-env.ts
7197
- var fs5 = __toESM(require("node:fs"));
7198
- var path3 = __toESM(require("node:path"));
7284
+ var fs6 = __toESM(require("node:fs"));
7285
+ var path4 = __toESM(require("node:path"));
7199
7286
  function parseEnvExampleFile(filePath) {
7200
- if (!fs5.existsSync(filePath)) return [];
7201
- const content = fs5.readFileSync(filePath, "utf-8");
7287
+ if (!fs6.existsSync(filePath)) return [];
7288
+ const content = fs6.readFileSync(filePath, "utf-8");
7202
7289
  const lines = content.split("\n");
7203
7290
  const entries = [];
7204
7291
  let lastComment = "";
@@ -7224,7 +7311,7 @@ function getMcpEnvStubs(selectedTools, examplesDir) {
7224
7311
  if (!examplesDir) return [];
7225
7312
  const result = [];
7226
7313
  for (const tool of selectedTools) {
7227
- const filePath = path3.join(examplesDir, `${tool}.env-example`);
7314
+ const filePath = path4.join(examplesDir, `${tool}.env-example`);
7228
7315
  const entries = parseEnvExampleFile(filePath);
7229
7316
  result.push(...entries);
7230
7317
  }
@@ -7233,9 +7320,9 @@ function getMcpEnvStubs(selectedTools, examplesDir) {
7233
7320
  function collectEnvSections(selectedTools, examplesDir, existingKeys) {
7234
7321
  const sections = [];
7235
7322
  for (const tool of selectedTools) {
7236
- const filePath = path3.join(examplesDir, `${tool}.env-example`);
7237
- if (!fs5.existsSync(filePath)) continue;
7238
- const content = fs5.readFileSync(filePath, "utf-8").trimEnd();
7323
+ const filePath = path4.join(examplesDir, `${tool}.env-example`);
7324
+ if (!fs6.existsSync(filePath)) continue;
7325
+ const content = fs6.readFileSync(filePath, "utf-8").trimEnd();
7239
7326
  const entries = parseEnvExampleFile(filePath);
7240
7327
  const allExist = entries.every((e) => existingKeys.has(e.key));
7241
7328
  if (allExist) continue;
@@ -7271,7 +7358,7 @@ function filterExistingKeys(content, existingKeys) {
7271
7358
 
7272
7359
  // src/wizard/wizard-flow.ts
7273
7360
  var p4 = __toESM(require("@clack/prompts"));
7274
- var fs7 = __toESM(require("node:fs"));
7361
+ var fs8 = __toESM(require("node:fs"));
7275
7362
 
7276
7363
  // src/wizard/tool-select.ts
7277
7364
  var p = __toESM(require("@clack/prompts"));
@@ -7663,7 +7750,7 @@ function parseFrontmatter(content) {
7663
7750
  }
7664
7751
 
7665
7752
  // src/template/registry.ts
7666
- var fs6 = __toESM(require("node:fs"));
7753
+ var fs7 = __toESM(require("node:fs"));
7667
7754
  function buildMcpCapabilities(mcpCapabilities, installedMcpServers, mcpTools) {
7668
7755
  const installedSet = new Set(installedMcpServers);
7669
7756
  const result = {};
@@ -7688,8 +7775,8 @@ function deriveVariableName(frontmatter) {
7688
7775
  return "tide_capabilities";
7689
7776
  }
7690
7777
  function injectSkillCapabilities(tmplFilePath, baseVariables, installedMcpServers, mcpTools, variableName) {
7691
- if (!fs6.existsSync(tmplFilePath)) return baseVariables;
7692
- const content = fs6.readFileSync(tmplFilePath, "utf-8");
7778
+ if (!fs7.existsSync(tmplFilePath)) return baseVariables;
7779
+ const content = fs7.readFileSync(tmplFilePath, "utf-8");
7693
7780
  const fm = parseFrontmatter(content);
7694
7781
  if (!fm) return baseVariables;
7695
7782
  const mcpCapabilities = fm.mcpCapabilities;
@@ -7783,9 +7870,9 @@ function buildTemplateVariables(registry2, config, installedMcpTools = []) {
7783
7870
  // src/wizard/wizard-flow.ts
7784
7871
  function loadExistingConfigKeys(targetDir) {
7785
7872
  const settingsPath = getDeepStormConfigPath(targetDir);
7786
- if (!fs7.existsSync(settingsPath)) return /* @__PURE__ */ new Set();
7873
+ if (!fs8.existsSync(settingsPath)) return /* @__PURE__ */ new Set();
7787
7874
  try {
7788
- const raw = fs7.readFileSync(settingsPath, "utf-8");
7875
+ const raw = fs8.readFileSync(settingsPath, "utf-8");
7789
7876
  const config = JSON.parse(raw);
7790
7877
  if (!config || Object.keys(config).length === 0) return /* @__PURE__ */ new Set();
7791
7878
  const keys = /* @__PURE__ */ new Set();
@@ -7844,16 +7931,16 @@ async function runWizardFlow(reader, registry2, initialMcpValues, targetDir) {
7844
7931
  }
7845
7932
 
7846
7933
  // src/wizard/reconfigure.ts
7847
- var fs8 = __toESM(require("node:fs"));
7848
- var path4 = __toESM(require("node:path"));
7934
+ var fs9 = __toESM(require("node:fs"));
7935
+ var path5 = __toESM(require("node:path"));
7849
7936
  function cleanInstalled(targetDir) {
7850
7937
  const settingsPath = getDeepStormConfigPath(targetDir);
7851
- if (!fs8.existsSync(settingsPath)) {
7938
+ if (!fs9.existsSync(settingsPath)) {
7852
7939
  return;
7853
7940
  }
7854
7941
  let config;
7855
7942
  try {
7856
- config = JSON.parse(fs8.readFileSync(settingsPath, "utf-8"));
7943
+ config = JSON.parse(fs9.readFileSync(settingsPath, "utf-8"));
7857
7944
  } catch {
7858
7945
  return;
7859
7946
  }
@@ -7861,41 +7948,41 @@ function cleanInstalled(targetDir) {
7861
7948
  const installedSkills = config.installedSkills;
7862
7949
  if (installedSkills) {
7863
7950
  for (const skillId of installedSkills) {
7864
- const skillDir = path4.join(targetDir, ".claude", "skills", skillId);
7865
- if (fs8.existsSync(skillDir)) {
7866
- fs8.rmSync(skillDir, { recursive: true, force: true });
7951
+ const skillDir = path5.join(targetDir, ".claude", "skills", skillId);
7952
+ if (fs9.existsSync(skillDir)) {
7953
+ fs9.rmSync(skillDir, { recursive: true, force: true });
7867
7954
  }
7868
7955
  }
7869
7956
  }
7870
7957
  const installedAgents = config.installedAgents;
7871
7958
  if (installedAgents) {
7872
7959
  for (const agent of installedAgents) {
7873
- const agentDir = path4.join(targetDir, ".claude", "agents", agent);
7874
- if (fs8.existsSync(agentDir)) {
7875
- fs8.rmSync(agentDir, { recursive: true, force: true });
7960
+ const agentDir = path5.join(targetDir, ".claude", "agents", agent);
7961
+ if (fs9.existsSync(agentDir)) {
7962
+ fs9.rmSync(agentDir, { recursive: true, force: true });
7876
7963
  }
7877
7964
  }
7878
7965
  }
7879
- const hooksJson = path4.join(targetDir, ".claude", "hooks.json");
7880
- if (fs8.existsSync(hooksJson)) {
7881
- fs8.rmSync(hooksJson, { force: true });
7966
+ const hooksJson = path5.join(targetDir, ".claude", "hooks.json");
7967
+ if (fs9.existsSync(hooksJson)) {
7968
+ fs9.rmSync(hooksJson, { force: true });
7882
7969
  }
7883
- const hooksDir = path4.join(targetDir, ".claude", "hooks");
7884
- if (fs8.existsSync(hooksDir)) {
7885
- fs8.rmSync(hooksDir, { recursive: true, force: true });
7970
+ const hooksDir = path5.join(targetDir, ".claude", "hooks");
7971
+ if (fs9.existsSync(hooksDir)) {
7972
+ fs9.rmSync(hooksDir, { recursive: true, force: true });
7886
7973
  }
7887
7974
  const installedMcp = config.installedMcpServers;
7888
7975
  if (installedMcp) {
7889
- const mcpPath = path4.join(targetDir, ".mcp.json");
7890
- if (fs8.existsSync(mcpPath)) {
7976
+ const mcpPath = path5.join(targetDir, ".mcp.json");
7977
+ if (fs9.existsSync(mcpPath)) {
7891
7978
  try {
7892
- const mcp = JSON.parse(fs8.readFileSync(mcpPath, "utf-8"));
7979
+ const mcp = JSON.parse(fs9.readFileSync(mcpPath, "utf-8"));
7893
7980
  if (mcp.mcpServers) {
7894
7981
  for (const serverName of installedMcp) {
7895
7982
  delete mcp.mcpServers[`deepstorm-${serverName}`];
7896
7983
  }
7897
7984
  }
7898
- fs8.writeFileSync(mcpPath, JSON.stringify(mcp, null, 2) + "\n", "utf-8");
7985
+ fs9.writeFileSync(mcpPath, JSON.stringify(mcp, null, 2) + "\n", "utf-8");
7899
7986
  } catch {
7900
7987
  }
7901
7988
  }
@@ -7922,8 +8009,8 @@ function parseNonInteractiveArgs(toolsStr, setValues) {
7922
8009
  }
7923
8010
 
7924
8011
  // src/wizard/guide.ts
7925
- var fs9 = __toESM(require("node:fs"));
7926
- var path5 = __toESM(require("node:path"));
8012
+ var fs10 = __toESM(require("node:fs"));
8013
+ var path6 = __toESM(require("node:path"));
7927
8014
  var import_prompts = require("@clack/prompts");
7928
8015
  function printMcpEnvStatus(mcpTools, installedMcpServices, examplesDir, targetDir) {
7929
8016
  const allMcp = [.../* @__PURE__ */ new Set([...mcpTools, ...installedMcpServices])];
@@ -7931,8 +8018,8 @@ function printMcpEnvStatus(mcpTools, installedMcpServices, examplesDir, targetDi
7931
8018
  console.log("");
7932
8019
  console.log(" \u73AF\u5883\u53D8\u91CF\u914D\u7F6E\u72B6\u6001\uFF1A");
7933
8020
  for (const mcp of allMcp) {
7934
- const filePath = path5.join(examplesDir, `${mcp}.env-example`);
7935
- if (!fs9.existsSync(filePath)) {
8021
+ const filePath = path6.join(examplesDir, `${mcp}.env-example`);
8022
+ if (!fs10.existsSync(filePath)) {
7936
8023
  console.log(` \u2139 ${mcp}: \u65E0\u9700\u73AF\u5883\u53D8\u91CF\u914D\u7F6E`);
7937
8024
  continue;
7938
8025
  }
@@ -7941,10 +8028,10 @@ function printMcpEnvStatus(mcpTools, installedMcpServices, examplesDir, targetDi
7941
8028
  console.log(` \u2139 ${mcp}: \u65E0\u9700\u73AF\u5883\u53D8\u91CF\u914D\u7F6E`);
7942
8029
  continue;
7943
8030
  }
7944
- const dotEnvPath = path5.join(targetDir, ".env");
8031
+ const dotEnvPath = path6.join(targetDir, ".env");
7945
8032
  const dotEnvMap = /* @__PURE__ */ new Map();
7946
- if (fs9.existsSync(dotEnvPath)) {
7947
- const content = fs9.readFileSync(dotEnvPath, "utf-8");
8033
+ if (fs10.existsSync(dotEnvPath)) {
8034
+ const content = fs10.readFileSync(dotEnvPath, "utf-8");
7948
8035
  for (const line of content.split("\n")) {
7949
8036
  const trimmed = line.trim();
7950
8037
  if (trimmed.includes("=") && !trimmed.startsWith("#")) {
@@ -7957,7 +8044,7 @@ function printMcpEnvStatus(mcpTools, installedMcpServices, examplesDir, targetDi
7957
8044
  }
7958
8045
  }
7959
8046
  }
7960
- const envDefaultContent = fs9.readFileSync(filePath, "utf-8");
8047
+ const envDefaultContent = fs10.readFileSync(filePath, "utf-8");
7961
8048
  const defaults = /* @__PURE__ */ new Map();
7962
8049
  for (const line of envDefaultContent.split("\n")) {
7963
8050
  const trimmed = line.trim();
@@ -8017,17 +8104,17 @@ async function printGuide(options) {
8017
8104
  console.log(" \u4E0B\u4E00\u6B65\uFF1A");
8018
8105
  console.log(" \u8FD0\u884C Claude Code\uFF0C\u8F93\u5165 /help \u67E5\u770B\u6240\u6709\u53EF\u7528\u7684 DeepStorm \u547D\u4EE4");
8019
8106
  console.log("");
8020
- const gitDir = path5.join(options.targetDir, ".git");
8021
- if (fs9.existsSync(gitDir)) {
8107
+ const gitDir = path6.join(options.targetDir, ".git");
8108
+ if (fs10.existsSync(gitDir)) {
8022
8109
  const shouldAdd = await (0, import_prompts.confirm)({
8023
8110
  message: "\u662F\u5426\u5C06 .claude/ \u914D\u7F6E\u63D0\u4EA4\u5230 Git\uFF1F(.gitignore \u9700\u8981\u5FFD\u7565 .claude/)",
8024
8111
  initialValue: false
8025
8112
  });
8026
8113
  if (!(0, import_prompts.isCancel)(shouldAdd) && shouldAdd) {
8027
- const gitignorePath = path5.join(options.targetDir, ".gitignore");
8114
+ const gitignorePath = path6.join(options.targetDir, ".gitignore");
8028
8115
  let isIgnored = false;
8029
- if (fs9.existsSync(gitignorePath)) {
8030
- const gitignore = fs9.readFileSync(gitignorePath, "utf-8");
8116
+ if (fs10.existsSync(gitignorePath)) {
8117
+ const gitignore = fs10.readFileSync(gitignorePath, "utf-8");
8031
8118
  isIgnored = gitignore.split("\n").some((line) => {
8032
8119
  const trimmed = line.trim();
8033
8120
  return trimmed === ".claude" || trimmed === ".claude/" || trimmed === ".claude/**";
@@ -8046,25 +8133,25 @@ async function printGuide(options) {
8046
8133
  }
8047
8134
 
8048
8135
  // src/template/renderer.ts
8049
- var fs11 = __toESM(require("node:fs"));
8050
- var path7 = __toESM(require("node:path"));
8136
+ var fs12 = __toESM(require("node:fs"));
8137
+ var path8 = __toESM(require("node:path"));
8051
8138
  var import_handlebars = __toESM(require_lib());
8052
8139
 
8053
8140
  // src/utils/fs.ts
8054
- var fs10 = __toESM(require("node:fs"));
8055
- var path6 = __toESM(require("node:path"));
8141
+ var fs11 = __toESM(require("node:fs"));
8142
+ var path7 = __toESM(require("node:path"));
8056
8143
  function ensureDir3(dir) {
8057
- fs10.mkdirSync(dir, { recursive: true });
8144
+ fs11.mkdirSync(dir, { recursive: true });
8058
8145
  }
8059
8146
  function copyDir(src, dest) {
8060
- fs10.cpSync(src, dest, { recursive: true, force: true });
8147
+ fs11.cpSync(src, dest, { recursive: true, force: true });
8061
8148
  }
8062
8149
  function removeDirContents(dir) {
8063
- const entries = fs10.readdirSync(dir);
8150
+ const entries = fs11.readdirSync(dir);
8064
8151
  for (const entry of entries) {
8065
8152
  if (entry === ".DS_Store") continue;
8066
- const fullPath = path6.join(dir, entry);
8067
- fs10.rmSync(fullPath, { recursive: true, force: true });
8153
+ const fullPath = path7.join(dir, entry);
8154
+ fs11.rmSync(fullPath, { recursive: true, force: true });
8068
8155
  }
8069
8156
  }
8070
8157
 
@@ -8085,38 +8172,38 @@ function toNested(vars) {
8085
8172
  }
8086
8173
  var compiledCache = /* @__PURE__ */ new Map();
8087
8174
  function renderTemplate(tmplPath, variables, outputPath) {
8088
- if (!fs11.existsSync(tmplPath)) {
8175
+ if (!fs12.existsSync(tmplPath)) {
8089
8176
  throw new Error(`\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${tmplPath}`);
8090
8177
  }
8091
8178
  let templateFn = compiledCache.get(tmplPath);
8092
8179
  if (!templateFn) {
8093
- const source = fs11.readFileSync(tmplPath, "utf-8");
8180
+ const source = fs12.readFileSync(tmplPath, "utf-8");
8094
8181
  templateFn = import_handlebars.default.compile(source, { noEscape: true });
8095
8182
  compiledCache.set(tmplPath, templateFn);
8096
8183
  }
8097
8184
  const nestedVars = toNested(variables);
8098
8185
  const content = templateFn(nestedVars);
8099
- ensureDir3(path7.dirname(outputPath));
8100
- fs11.writeFileSync(outputPath, content, "utf-8");
8186
+ ensureDir3(path8.dirname(outputPath));
8187
+ fs12.writeFileSync(outputPath, content, "utf-8");
8101
8188
  }
8102
8189
  function copyVariants(sourceVariantsDir, selectedValue, targetDir, clean = false) {
8103
- const variantDir = path7.join(sourceVariantsDir, selectedValue);
8104
- if (!fs11.existsSync(variantDir)) {
8190
+ const variantDir = path8.join(sourceVariantsDir, selectedValue);
8191
+ if (!fs12.existsSync(variantDir)) {
8105
8192
  console.warn(
8106
8193
  `[template] \u26A0 \u53D8\u4F53\u76EE\u5F55\u4E0D\u5B58\u5728: ${variantDir}\uFF08\u76F8\u5BF9\u4E8E ${sourceVariantsDir}\uFF09\uFF0C\u8DF3\u8FC7`
8107
8194
  );
8108
8195
  return;
8109
8196
  }
8110
- if (clean && fs11.existsSync(targetDir)) {
8197
+ if (clean && fs12.existsSync(targetDir)) {
8111
8198
  removeDirContents(targetDir);
8112
8199
  }
8113
8200
  ensureDir3(targetDir);
8114
- const entries = fs11.readdirSync(variantDir);
8201
+ const entries = fs12.readdirSync(variantDir);
8115
8202
  for (const entry of entries) {
8116
8203
  if (entry === ".DS_Store") continue;
8117
- const src = path7.join(variantDir, entry);
8118
- const dest = path7.join(targetDir, entry);
8119
- fs11.cpSync(src, dest, { recursive: true, force: true });
8204
+ const src = path8.join(variantDir, entry);
8205
+ const dest = path8.join(targetDir, entry);
8206
+ fs12.cpSync(src, dest, { recursive: true, force: true });
8120
8207
  }
8121
8208
  }
8122
8209
 
@@ -8144,7 +8231,7 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8144
8231
  let selectedMcpTools = [];
8145
8232
  let templateVariables = {};
8146
8233
  let enabledMcpJsonServers = [];
8147
- const examplesDir = path8.join(cliDir2, "env-examples");
8234
+ const examplesDir = path9.join(cliDir2, "env-examples");
8148
8235
  const installedSkillIds = [];
8149
8236
  if (options.nonInteractive) {
8150
8237
  const parsed = parseNonInteractiveArgs(options.tools, options.set);
@@ -8172,7 +8259,7 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8172
8259
  templateVariables = wizardResult.templateVariables;
8173
8260
  }
8174
8261
  if (selectedMcpTools.length > 0) {
8175
- const mcpPath = path8.join(targetDir, ".mcp.json");
8262
+ const mcpPath = path9.join(targetDir, ".mcp.json");
8176
8263
  const servers = loadMcpServerConfigs(cliDir2, selectedMcpTools);
8177
8264
  mergeMcpServers(mcpPath, servers);
8178
8265
  enabledMcpJsonServers = Object.keys(servers);
@@ -8184,13 +8271,13 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8184
8271
  installedSkillIds.push(...ids);
8185
8272
  }
8186
8273
  if (shouldInstallGlobalHooks(tools, reader)) {
8187
- const hooksSrcDir = path8.join(cliDir2, "hooks");
8188
- const destHooksJson = path8.join(targetDir, ".claude", "hooks.json");
8274
+ const hooksSrcDir = path9.join(cliDir2, "hooks");
8275
+ const destHooksJson = path9.join(targetDir, ".claude", "hooks.json");
8189
8276
  for (const tool of tools) {
8190
- const toolHooksJsonPath = path8.join(hooksSrcDir, `${tool}-hooks.json`);
8191
- if (fs12.existsSync(toolHooksJsonPath)) {
8192
- ensureDir3(path8.join(targetDir, ".claude"));
8193
- const incoming = JSON.parse(fs12.readFileSync(toolHooksJsonPath, "utf-8"));
8277
+ const toolHooksJsonPath = path9.join(hooksSrcDir, `${tool}-hooks.json`);
8278
+ if (fs13.existsSync(toolHooksJsonPath)) {
8279
+ ensureDir3(path9.join(targetDir, ".claude"));
8280
+ const incoming = JSON.parse(fs13.readFileSync(toolHooksJsonPath, "utf-8"));
8194
8281
  mergeHooks(destHooksJson, incoming);
8195
8282
  }
8196
8283
  }
@@ -8216,7 +8303,7 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8216
8303
  const frontend = nestedConfig.reef?.frontend?.framework ?? void 0;
8217
8304
  const backend = nestedConfig.reef?.backend?.language ?? void 0;
8218
8305
  initContextMap(targetDir, { frontend, backend, projectName: "" });
8219
- const claudeSettingsPath = path8.join(targetDir, ".claude", "settings.json");
8306
+ const claudeSettingsPath = path9.join(targetDir, ".claude", "settings.json");
8220
8307
  if (enabledMcpJsonServers.length > 0) {
8221
8308
  writeEnabledMcpJsonServers(claudeSettingsPath, enabledMcpJsonServers);
8222
8309
  const servers = loadMcpServerConfigs(cliDir2, selectedMcpTools);
@@ -8224,13 +8311,13 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8224
8311
  }
8225
8312
  mergeSandboxDisabled(claudeSettingsPath);
8226
8313
  if (selectedMcpTools.length > 0) {
8227
- const envPath = path8.join(targetDir, ".env");
8314
+ const envPath = path9.join(targetDir, ".env");
8228
8315
  const existingKeys = readExistingEnvKeys(envPath);
8229
8316
  const sections = collectEnvSections(selectedMcpTools, examplesDir, existingKeys);
8230
8317
  if (sections.length > 0) {
8231
8318
  let existing = "";
8232
- if (fs12.existsSync(envPath)) {
8233
- existing = fs12.readFileSync(envPath, "utf-8").trimEnd();
8319
+ if (fs13.existsSync(envPath)) {
8320
+ existing = fs13.readFileSync(envPath, "utf-8").trimEnd();
8234
8321
  }
8235
8322
  const deepstormHeader = [
8236
8323
  "# \u2500\u2500 DeepStorm \u2500\u2500",
@@ -8245,7 +8332,7 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8245
8332
  ""
8246
8333
  ].join("\n");
8247
8334
  const content = existing ? existing + "\n\n" + deepstormHeader + sections.join("\n\n") + "\n" : deepstormHeader + sections.join("\n\n") + "\n";
8248
- fs12.writeFileSync(envPath, content, "utf-8");
8335
+ fs13.writeFileSync(envPath, content, "utf-8");
8249
8336
  console.log(`\u2714 \u5DF2\u751F\u6210 .env \u73AF\u5883\u53D8\u91CF\u6A21\u677F`);
8250
8337
  }
8251
8338
  }
@@ -8261,6 +8348,7 @@ async function runSetup(reader, targetDir, cliDir2, options, registry2) {
8261
8348
  mcpTools: selectedMcpTools.length > 0 ? selectedMcpTools : void 0,
8262
8349
  mcpEnvStubs: mcpEnvStubs.length > 0 ? mcpEnvStubs : void 0
8263
8350
  });
8351
+ step9AutoInstallDeps(tools, config, targetDir);
8264
8352
  }
8265
8353
  function shouldSkipSkill(skill, config) {
8266
8354
  if (!skill.configKey) return false;
@@ -8280,9 +8368,9 @@ function shouldSkipAgent(agentFile, config) {
8280
8368
  }
8281
8369
  function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, config, registry2, installedMcpTools = [], targetSubDir = ".claude", skillIdFilter) {
8282
8370
  const installedSkillIds = [];
8283
- const targetSkillsDir = targetSubDir ? path8.join(targetDir, targetSubDir, "skills") : path8.join(targetDir, "skills");
8371
+ const targetSkillsDir = targetSubDir ? path9.join(targetDir, targetSubDir, "skills") : path9.join(targetDir, "skills");
8284
8372
  const toolSkills = reader.getToolSkills(tool);
8285
- const skillsDir = path8.join(cliDir2, "skills");
8373
+ const skillsDir = path9.join(cliDir2, "skills");
8286
8374
  for (const skill of toolSkills) {
8287
8375
  const skillId = getSkillId(skill, registry2);
8288
8376
  if (!skillId) continue;
@@ -8291,12 +8379,12 @@ function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, c
8291
8379
  console.log(` \u23ED ${skillId}\uFF1A\u4F9D\u8D56 ${skill.configKey} \u672A\u914D\u7F6E\uFF0C\u8DF3\u8FC7`);
8292
8380
  continue;
8293
8381
  }
8294
- const srcDir = path8.join(skillsDir, skillId);
8295
- const targetDirPath = path8.join(targetSkillsDir, skillId);
8296
- if (!fs12.existsSync(srcDir)) continue;
8297
- const tmplPath = path8.join(srcDir, "SKILL.md.tmpl");
8298
- const variantsDir = path8.join(srcDir, "variants");
8299
- if (fs12.existsSync(tmplPath)) {
8382
+ const srcDir = path9.join(skillsDir, skillId);
8383
+ const targetDirPath = path9.join(targetSkillsDir, skillId);
8384
+ if (!fs13.existsSync(srcDir)) continue;
8385
+ const tmplPath = path9.join(srcDir, "SKILL.md.tmpl");
8386
+ const variantsDir = path9.join(srcDir, "variants");
8387
+ if (fs13.existsSync(tmplPath)) {
8300
8388
  const enrichedVars = injectSkillCapabilities(
8301
8389
  tmplPath,
8302
8390
  templateVariables,
@@ -8307,7 +8395,7 @@ function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, c
8307
8395
  renderTemplate(
8308
8396
  tmplPath,
8309
8397
  enrichedVars,
8310
- path8.join(targetDirPath, "SKILL.md")
8398
+ path9.join(targetDirPath, "SKILL.md")
8311
8399
  );
8312
8400
  copyVariantsForConfig(variantsDir, config, targetDirPath, skill.configKey);
8313
8401
  copyFragmentsForSkill(skillId, srcDir, config, registry2, targetDirPath);
@@ -8318,9 +8406,9 @@ function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, c
8318
8406
  installedSkillIds.push(skillId);
8319
8407
  }
8320
8408
  const toolAgents = reader.getToolAgents(tool);
8321
- const agentsSrcDir = path8.join(cliDir2, "agents");
8322
- const targetAgentsDir = targetSubDir ? path8.join(targetDir, targetSubDir, "agents") : path8.join(targetDir, "agents");
8323
- if (fs12.existsSync(agentsSrcDir)) {
8409
+ const agentsSrcDir = path9.join(cliDir2, "agents");
8410
+ const targetAgentsDir = targetSubDir ? path9.join(targetDir, targetSubDir, "agents") : path9.join(targetDir, "agents");
8411
+ if (fs13.existsSync(agentsSrcDir)) {
8324
8412
  ensureDir3(targetAgentsDir);
8325
8413
  for (const agentFile of toolAgents) {
8326
8414
  if (shouldSkipAgent(agentFile, config)) {
@@ -8328,38 +8416,38 @@ function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, c
8328
8416
  console.log(` \u23ED ${base}\uFF1A\u4F9D\u8D56\u672A\u914D\u7F6E\uFF0C\u8DF3\u8FC7`);
8329
8417
  continue;
8330
8418
  }
8331
- const srcPath = path8.join(agentsSrcDir, agentFile);
8332
- if (!fs12.existsSync(srcPath)) {
8333
- const tmplSrcPath = path8.join(agentsSrcDir, agentFile.replace(/\.md$/, ".md.tmpl"));
8334
- if (fs12.existsSync(tmplSrcPath)) {
8419
+ const srcPath = path9.join(agentsSrcDir, agentFile);
8420
+ if (!fs13.existsSync(srcPath)) {
8421
+ const tmplSrcPath = path9.join(agentsSrcDir, agentFile.replace(/\.md$/, ".md.tmpl"));
8422
+ if (fs13.existsSync(tmplSrcPath)) {
8335
8423
  const outputName = agentFile.replace(/\.tmpl$/, "");
8336
8424
  renderTemplate(
8337
8425
  tmplSrcPath,
8338
8426
  templateVariables,
8339
- path8.join(targetAgentsDir, outputName)
8427
+ path9.join(targetAgentsDir, outputName)
8340
8428
  );
8341
8429
  }
8342
8430
  continue;
8343
8431
  }
8344
- copyDir(srcPath, path8.join(targetAgentsDir, agentFile));
8432
+ copyDir(srcPath, path9.join(targetAgentsDir, agentFile));
8345
8433
  }
8346
8434
  }
8347
8435
  const toolHooks = reader.getToolHooks(tool);
8348
- const hooksSrcDir = path8.join(cliDir2, "hooks");
8349
- const targetHooksDir = targetSubDir ? path8.join(targetDir, targetSubDir, "hooks") : path8.join(targetDir, "hooks");
8350
- if (fs12.existsSync(hooksSrcDir)) {
8436
+ const hooksSrcDir = path9.join(cliDir2, "hooks");
8437
+ const targetHooksDir = targetSubDir ? path9.join(targetDir, targetSubDir, "hooks") : path9.join(targetDir, "hooks");
8438
+ if (fs13.existsSync(hooksSrcDir)) {
8351
8439
  ensureDir3(targetHooksDir);
8352
8440
  for (const hookFile of toolHooks) {
8353
- const srcPath = path8.join(hooksSrcDir, hookFile);
8354
- if (fs12.existsSync(srcPath)) {
8355
- copyDir(srcPath, path8.join(targetHooksDir, hookFile));
8441
+ const srcPath = path9.join(hooksSrcDir, hookFile);
8442
+ if (fs13.existsSync(srcPath)) {
8443
+ copyDir(srcPath, path9.join(targetHooksDir, hookFile));
8356
8444
  } else {
8357
8445
  const tmplPath = srcPath + ".tmpl";
8358
- if (fs12.existsSync(tmplPath)) {
8446
+ if (fs13.existsSync(tmplPath)) {
8359
8447
  renderTemplate(
8360
8448
  tmplPath,
8361
8449
  templateVariables,
8362
- path8.join(targetHooksDir, hookFile)
8450
+ path9.join(targetHooksDir, hookFile)
8363
8451
  );
8364
8452
  }
8365
8453
  }
@@ -8368,9 +8456,9 @@ function renderToolAssets(tool, reader, cliDir2, targetDir, templateVariables, c
8368
8456
  return installedSkillIds;
8369
8457
  }
8370
8458
  function installMcpSkills(tools, reader, cliDir2, targetDir, installedSkillIds, selectedMcpTools = []) {
8371
- const mcpSkillsDir = path8.join(cliDir2, "mcp-skills");
8372
- const targetSkillsDir = path8.join(targetDir, ".claude", "skills");
8373
- if (!fs12.existsSync(mcpSkillsDir)) return;
8459
+ const mcpSkillsDir = path9.join(cliDir2, "mcp-skills");
8460
+ const targetSkillsDir = path9.join(targetDir, ".claude", "skills");
8461
+ if (!fs13.existsSync(mcpSkillsDir)) return;
8374
8462
  if (selectedMcpTools.length === 0) {
8375
8463
  console.log("\u23ED \u672A\u9009\u62E9 MCP \u670D\u52A1\uFF0C\u8DF3\u8FC7 MCP \u6280\u80FD\u5B89\u88C5");
8376
8464
  return;
@@ -8387,9 +8475,9 @@ function installMcpSkills(tools, reader, cliDir2, targetDir, installedSkillIds,
8387
8475
  }
8388
8476
  let installed = 0;
8389
8477
  for (const skillId of neededSkills) {
8390
- const srcDir = path8.join(mcpSkillsDir, skillId);
8391
- if (fs12.existsSync(srcDir)) {
8392
- const targetDirPath = path8.join(targetSkillsDir, skillId);
8478
+ const srcDir = path9.join(mcpSkillsDir, skillId);
8479
+ if (fs13.existsSync(srcDir)) {
8480
+ const targetDirPath = path9.join(targetSkillsDir, skillId);
8393
8481
  copyDir(srcDir, targetDirPath);
8394
8482
  installedSkillIds.push(skillId);
8395
8483
  installed++;
@@ -8404,14 +8492,14 @@ function shouldInstallGlobalHooks(tools, reader) {
8404
8492
  }
8405
8493
  function buildUnifiedMcpCapabilities(cliDir2, installedMcpTools, mcpTools) {
8406
8494
  const allDeclarations = {};
8407
- const skillsDir = path8.join(cliDir2, "skills");
8408
- if (!fs12.existsSync(skillsDir)) return {};
8409
- const skillDirs = fs12.readdirSync(skillsDir, { withFileTypes: true });
8495
+ const skillsDir = path9.join(cliDir2, "skills");
8496
+ if (!fs13.existsSync(skillsDir)) return {};
8497
+ const skillDirs = fs13.readdirSync(skillsDir, { withFileTypes: true });
8410
8498
  for (const entry of skillDirs) {
8411
8499
  if (!entry.isDirectory()) continue;
8412
- const tmplPath = path8.join(skillsDir, entry.name, "SKILL.md.tmpl");
8413
- if (!fs12.existsSync(tmplPath)) continue;
8414
- const content = fs12.readFileSync(tmplPath, "utf-8");
8500
+ const tmplPath = path9.join(skillsDir, entry.name, "SKILL.md.tmpl");
8501
+ if (!fs13.existsSync(tmplPath)) continue;
8502
+ const content = fs13.readFileSync(tmplPath, "utf-8");
8415
8503
  const fm = parseFrontmatter(content);
8416
8504
  if (!fm) continue;
8417
8505
  const mcpCap = fm.mcpCapabilities;
@@ -8430,7 +8518,7 @@ function getSkillId(skill, registry2) {
8430
8518
  return void 0;
8431
8519
  }
8432
8520
  function copyVariantsForConfig(variantsDir, config, targetDir, configKey) {
8433
- if (!fs12.existsSync(variantsDir)) return;
8521
+ if (!fs13.existsSync(variantsDir)) return;
8434
8522
  for (const [key, value] of Object.entries(config)) {
8435
8523
  if (configKey && key !== configKey) continue;
8436
8524
  if (value.includes(",")) continue;
@@ -8438,8 +8526,8 @@ function copyVariantsForConfig(variantsDir, config, targetDir, configKey) {
8438
8526
  }
8439
8527
  }
8440
8528
  function copyFragmentsForSkill(skillId, srcDir, config, registry2, targetDir) {
8441
- const fragmentsDir = path8.join(srcDir, "fragments");
8442
- if (!fs12.existsSync(fragmentsDir)) return;
8529
+ const fragmentsDir = path9.join(srcDir, "fragments");
8530
+ if (!fs13.existsSync(fragmentsDir)) return;
8443
8531
  const selectedFragments = [];
8444
8532
  for (const wizard of Object.values(registry2.wizards)) {
8445
8533
  for (const question of wizard.questions) {
@@ -8447,43 +8535,43 @@ function copyFragmentsForSkill(skillId, srcDir, config, registry2, targetDir) {
8447
8535
  }
8448
8536
  }
8449
8537
  if (selectedFragments.length === 0) return;
8450
- const targetExamplesDir = path8.join(targetDir, "examples");
8538
+ const targetExamplesDir = path9.join(targetDir, "examples");
8451
8539
  for (const { category, value } of selectedFragments) {
8452
- const srcPath = path8.join(fragmentsDir, category, value);
8453
- if (!fs12.existsSync(srcPath)) continue;
8454
- const srcQr = path8.join(srcPath, "quick-reference.md");
8455
- if (fs12.existsSync(srcQr)) {
8456
- fs12.cpSync(srcQr, path8.join(targetDir, `${value}.md`), { force: true });
8457
- }
8458
- const srcExamples = path8.join(srcPath, "examples");
8459
- if (fs12.existsSync(srcExamples)) {
8460
- const exampleFiles = fs12.readdirSync(srcExamples);
8540
+ const srcPath = path9.join(fragmentsDir, category, value);
8541
+ if (!fs13.existsSync(srcPath)) continue;
8542
+ const srcQr = path9.join(srcPath, "quick-reference.md");
8543
+ if (fs13.existsSync(srcQr)) {
8544
+ fs13.cpSync(srcQr, path9.join(targetDir, `${value}.md`), { force: true });
8545
+ }
8546
+ const srcExamples = path9.join(srcPath, "examples");
8547
+ if (fs13.existsSync(srcExamples)) {
8548
+ const exampleFiles = fs13.readdirSync(srcExamples);
8461
8549
  for (const file of exampleFiles) {
8462
8550
  if (file === ".DS_Store") continue;
8463
8551
  ensureDir3(targetExamplesDir);
8464
- fs12.cpSync(
8465
- path8.join(srcExamples, file),
8466
- path8.join(targetExamplesDir, `${value}-${file}`),
8552
+ fs13.cpSync(
8553
+ path9.join(srcExamples, file),
8554
+ path9.join(targetExamplesDir, `${value}-${file}`),
8467
8555
  { force: true }
8468
8556
  );
8469
8557
  }
8470
8558
  }
8471
- const allFiles = fs12.readdirSync(srcPath);
8559
+ const allFiles = fs13.readdirSync(srcPath);
8472
8560
  for (const file of allFiles) {
8473
8561
  if (file === ".DS_Store") continue;
8474
8562
  if (file === "quick-reference.md") continue;
8475
8563
  if (file === "examples") continue;
8476
8564
  if (!file.endsWith(".md")) continue;
8477
- fs12.cpSync(path8.join(srcPath, file), path8.join(targetDir, file), { force: true });
8565
+ fs13.cpSync(path9.join(srcPath, file), path9.join(targetDir, file), { force: true });
8478
8566
  }
8479
8567
  }
8480
8568
  }
8481
8569
  function copyReferencesForSkill(srcDir, targetDir) {
8482
- const referencesDir = path8.join(srcDir, "references");
8483
- if (fs12.existsSync(referencesDir)) {
8484
- const targetReferencesDir = path8.join(targetDir, "references");
8570
+ const referencesDir = path9.join(srcDir, "references");
8571
+ if (fs13.existsSync(referencesDir)) {
8572
+ const targetReferencesDir = path9.join(targetDir, "references");
8485
8573
  ensureDir3(targetReferencesDir);
8486
- fs12.cpSync(referencesDir, targetReferencesDir, { recursive: true, force: true });
8574
+ fs13.cpSync(referencesDir, targetReferencesDir, { recursive: true, force: true });
8487
8575
  }
8488
8576
  }
8489
8577
  function collectFragmentsFromQuestion(question, config, selectedFragments) {
@@ -8509,15 +8597,15 @@ function collectFragmentsFromQuestion(question, config, selectedFragments) {
8509
8597
  }
8510
8598
  }
8511
8599
  function loadMcpServerConfigs(cliDir2, selectedTools) {
8512
- const mcpDir = path8.join(cliDir2, "mcp");
8513
- if (!fs12.existsSync(mcpDir)) return {};
8600
+ const mcpDir = path9.join(cliDir2, "mcp");
8601
+ if (!fs13.existsSync(mcpDir)) return {};
8514
8602
  const servers = {};
8515
8603
  function collectJsonFiles(dir) {
8516
8604
  const results = [];
8517
- for (const entry of fs12.readdirSync(dir)) {
8518
- const fullPath = path8.join(dir, entry);
8605
+ for (const entry of fs13.readdirSync(dir)) {
8606
+ const fullPath = path9.join(dir, entry);
8519
8607
  if (entry === ".DS_Store") continue;
8520
- if (fs12.statSync(fullPath).isDirectory()) {
8608
+ if (fs13.statSync(fullPath).isDirectory()) {
8521
8609
  results.push(...collectJsonFiles(fullPath));
8522
8610
  } else if (entry.endsWith(".json")) {
8523
8611
  results.push(fullPath);
@@ -8528,7 +8616,7 @@ function loadMcpServerConfigs(cliDir2, selectedTools) {
8528
8616
  const jsonFiles = collectJsonFiles(mcpDir);
8529
8617
  for (const jsonPath of jsonFiles) {
8530
8618
  try {
8531
- const data = JSON.parse(fs12.readFileSync(jsonPath, "utf-8"));
8619
+ const data = JSON.parse(fs13.readFileSync(jsonPath, "utf-8"));
8532
8620
  if (!data.name || !selectedTools.includes(data.name)) continue;
8533
8621
  if (!data.mcpServers || typeof data.mcpServers !== "object") continue;
8534
8622
  for (const [serverName, serverConfig] of Object.entries(data.mcpServers)) {
@@ -8574,37 +8662,37 @@ function writeEnabledMcpJsonServers(settingsPath, serverNames) {
8574
8662
  if (serverNames.length === 0) return;
8575
8663
  let settings = {};
8576
8664
  try {
8577
- if (fs12.existsSync(settingsPath)) {
8578
- const raw = fs12.readFileSync(settingsPath, "utf-8");
8665
+ if (fs13.existsSync(settingsPath)) {
8666
+ const raw = fs13.readFileSync(settingsPath, "utf-8");
8579
8667
  settings = JSON.parse(raw);
8580
8668
  }
8581
8669
  } catch {
8582
8670
  settings = {};
8583
8671
  }
8584
8672
  settings.enabledMcpjsonServers = serverNames;
8585
- ensureDir3(path8.dirname(settingsPath));
8586
- fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8673
+ ensureDir3(path9.dirname(settingsPath));
8674
+ fs13.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8587
8675
  }
8588
8676
  function mergeSandboxDisabled(settingsPath) {
8589
8677
  let settings = {};
8590
8678
  try {
8591
- if (fs12.existsSync(settingsPath)) {
8592
- const raw = fs12.readFileSync(settingsPath, "utf-8");
8679
+ if (fs13.existsSync(settingsPath)) {
8680
+ const raw = fs13.readFileSync(settingsPath, "utf-8");
8593
8681
  settings = JSON.parse(raw);
8594
8682
  }
8595
8683
  } catch {
8596
8684
  settings = {};
8597
8685
  }
8598
8686
  settings.sandbox = { enabled: false };
8599
- ensureDir3(path8.dirname(settingsPath));
8600
- fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8687
+ ensureDir3(path9.dirname(settingsPath));
8688
+ fs13.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8601
8689
  }
8602
8690
  function mergeSettingsMcpServers(settingsPath, servers) {
8603
8691
  if (!servers || Object.keys(servers).length === 0) return;
8604
8692
  let settings = {};
8605
8693
  try {
8606
- if (fs12.existsSync(settingsPath)) {
8607
- const raw = fs12.readFileSync(settingsPath, "utf-8");
8694
+ if (fs13.existsSync(settingsPath)) {
8695
+ const raw = fs13.readFileSync(settingsPath, "utf-8");
8608
8696
  settings = JSON.parse(raw);
8609
8697
  }
8610
8698
  } catch {
@@ -8612,13 +8700,13 @@ function mergeSettingsMcpServers(settingsPath, servers) {
8612
8700
  }
8613
8701
  const existingServers = settings.mcpServers || {};
8614
8702
  settings.mcpServers = deepMerge(existingServers, servers);
8615
- ensureDir3(path8.dirname(settingsPath));
8616
- fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8703
+ ensureDir3(path9.dirname(settingsPath));
8704
+ fs13.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
8617
8705
  }
8618
8706
  function readExistingEnvKeys(envPath) {
8619
8707
  const keys = /* @__PURE__ */ new Set();
8620
- if (!fs12.existsSync(envPath)) return keys;
8621
- for (const line of fs12.readFileSync(envPath, "utf-8").split("\n")) {
8708
+ if (!fs13.existsSync(envPath)) return keys;
8709
+ for (const line of fs13.readFileSync(envPath, "utf-8").split("\n")) {
8622
8710
  const trimmed = line.trim();
8623
8711
  if (!trimmed || trimmed.startsWith("#")) continue;
8624
8712
  const eqIdx = trimmed.indexOf("=");
@@ -8633,22 +8721,22 @@ function readExistingEnvKeys(envPath) {
8633
8721
  }
8634
8722
 
8635
8723
  // src/commands/plugin-build.ts
8636
- var fs14 = __toESM(require("node:fs"));
8637
- var path10 = __toESM(require("node:path"));
8724
+ var fs15 = __toESM(require("node:fs"));
8725
+ var path11 = __toESM(require("node:path"));
8638
8726
 
8639
8727
  // src/engine/plugin-builder.ts
8640
- var fs13 = __toESM(require("node:fs"));
8641
- var path9 = __toESM(require("node:path"));
8728
+ var fs14 = __toESM(require("node:fs"));
8729
+ var path10 = __toESM(require("node:path"));
8642
8730
  async function buildPlugin(config) {
8643
8731
  const { marketplaceName, tools, selectedMcpTools, cliDir: cliDir2, targetDir } = config;
8644
- const outputDir = path9.join(targetDir, ".deepstorm");
8645
- if (fs13.existsSync(outputDir)) {
8646
- fs13.rmSync(outputDir, { recursive: true, force: true });
8732
+ const outputDir = path10.join(targetDir, ".deepstorm");
8733
+ if (fs14.existsSync(outputDir)) {
8734
+ fs14.rmSync(outputDir, { recursive: true, force: true });
8647
8735
  }
8648
- fs13.mkdirSync(outputDir, { recursive: true });
8736
+ fs14.mkdirSync(outputDir, { recursive: true });
8649
8737
  const rootPkgMeta = readRootPackageJson(targetDir);
8650
- const claudePluginDir = path9.join(outputDir, ".claude-plugin");
8651
- fs13.mkdirSync(claudePluginDir, { recursive: true });
8738
+ const claudePluginDir = path10.join(outputDir, ".claude-plugin");
8739
+ fs14.mkdirSync(claudePluginDir, { recursive: true });
8652
8740
  const pluginJson = {
8653
8741
  name: "deepstorm",
8654
8742
  description: rootPkgMeta.description,
@@ -8657,7 +8745,7 @@ async function buildPlugin(config) {
8657
8745
  license: "MIT",
8658
8746
  keywords: ["deepstorm", "ai", "software-engineering", ...tools]
8659
8747
  };
8660
- fs13.writeFileSync(path9.join(claudePluginDir, "plugin.json"), JSON.stringify(pluginJson, null, 2), "utf-8");
8748
+ fs14.writeFileSync(path10.join(claudePluginDir, "plugin.json"), JSON.stringify(pluginJson, null, 2), "utf-8");
8661
8749
  const marketplaceJson = {
8662
8750
  name: marketplaceName,
8663
8751
  description: "DeepStorm Claude Code \u63D2\u4EF6",
@@ -8671,11 +8759,11 @@ async function buildPlugin(config) {
8671
8759
  }
8672
8760
  ]
8673
8761
  };
8674
- fs13.writeFileSync(path9.join(claudePluginDir, "marketplace.json"), JSON.stringify(marketplaceJson, null, 2), "utf-8");
8762
+ fs14.writeFileSync(path10.join(claudePluginDir, "marketplace.json"), JSON.stringify(marketplaceJson, null, 2), "utf-8");
8675
8763
  const settingsJson = {
8676
8764
  enabledMcpjsonServers: selectedMcpTools
8677
8765
  };
8678
- fs13.writeFileSync(path9.join(outputDir, "settings.json"), JSON.stringify(settingsJson, null, 2), "utf-8");
8766
+ fs14.writeFileSync(path10.join(outputDir, "settings.json"), JSON.stringify(settingsJson, null, 2), "utf-8");
8679
8767
  if (selectedMcpTools.length > 0) {
8680
8768
  const mcpServers = {};
8681
8769
  for (const mcpName of selectedMcpTools) {
@@ -8685,46 +8773,48 @@ async function buildPlugin(config) {
8685
8773
  }
8686
8774
  }
8687
8775
  if (Object.keys(mcpServers).length > 0) {
8688
- fs13.writeFileSync(
8689
- path9.join(outputDir, ".mcp.json"),
8776
+ fs14.writeFileSync(
8777
+ path10.join(outputDir, ".mcp.json"),
8690
8778
  JSON.stringify({ mcpServers }, null, 2) + "\n",
8691
8779
  "utf-8"
8692
8780
  );
8693
8781
  }
8694
8782
  }
8695
8783
  if (selectedMcpTools.length > 0) {
8696
- const envPath = path9.join(outputDir, ".env.example");
8697
- const envLines = [
8698
- "# DeepStorm Plugin MCP \u73AF\u5883\u53D8\u91CF\u914D\u7F6E",
8699
- "# \u590D\u5236\u6B64\u6587\u4EF6\u4E3A .env \u5E76\u586B\u5199\u5B9E\u9645\u503C",
8700
- ""
8701
- ];
8784
+ const envPath = path10.join(targetDir, ".env");
8785
+ const header = "# \u2500\u2500 DeepStorm Plugin MCP \u73AF\u5883\u53D8\u91CF \u2500\u2500\n\n";
8786
+ const sections = [];
8702
8787
  for (const mcpName of selectedMcpTools) {
8703
- const envExampleFile = path9.join(cliDir2, "env-examples", `${mcpName}.env-example`);
8704
- if (fs13.existsSync(envExampleFile)) {
8705
- const content = fs13.readFileSync(envExampleFile, "utf-8");
8706
- envLines.push(`# ${mcpName}`);
8707
- envLines.push(content);
8708
- envLines.push("");
8788
+ const envExampleFile = path10.join(cliDir2, "env-examples", `${mcpName}.env-example`);
8789
+ if (fs14.existsSync(envExampleFile)) {
8790
+ const content = fs14.readFileSync(envExampleFile, "utf-8");
8791
+ sections.push(`# ${mcpName}`);
8792
+ sections.push(content);
8709
8793
  }
8710
8794
  }
8711
- fs13.writeFileSync(envPath, envLines.join("\n"), "utf-8");
8795
+ const newContent = header + sections.join("\n") + "\n";
8796
+ if (fs14.existsSync(envPath)) {
8797
+ const existing = fs14.readFileSync(envPath, "utf-8").trimEnd();
8798
+ fs14.writeFileSync(envPath, existing + "\n\n" + newContent, "utf-8");
8799
+ } else {
8800
+ fs14.writeFileSync(envPath, newContent, "utf-8");
8801
+ }
8712
8802
  }
8713
8803
  const readmeContent = generateReadme2(marketplaceName, tools, selectedMcpTools, rootPkgMeta.version);
8714
- fs13.writeFileSync(path9.join(outputDir, "README.md"), readmeContent, "utf-8");
8804
+ fs14.writeFileSync(path10.join(outputDir, "README.md"), readmeContent, "utf-8");
8715
8805
  const changelogContent = `# Changelog
8716
8806
 
8717
8807
  ## v${rootPkgMeta.version}
8718
8808
 
8719
8809
  - \u9996\u6B21\u6784\u5EFA DeepStorm Plugin
8720
8810
  `;
8721
- fs13.writeFileSync(path9.join(outputDir, "CHANGELOG.md"), changelogContent, "utf-8");
8811
+ fs14.writeFileSync(path10.join(outputDir, "CHANGELOG.md"), changelogContent, "utf-8");
8722
8812
  return outputDir;
8723
8813
  }
8724
8814
  function readRootPackageJson(targetDir) {
8725
- const pkgPath = path9.join(targetDir, "package.json");
8815
+ const pkgPath = path10.join(targetDir, "package.json");
8726
8816
  try {
8727
- const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf-8"));
8817
+ const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
8728
8818
  return {
8729
8819
  version: pkg.version || "0.1.0",
8730
8820
  description: pkg.description || "DeepStorm \u2014 Spec \u9A71\u52A8\u7684 AI \u534F\u540C\u8F6F\u4EF6\u5DE5\u7A0B\u5B9E\u8DF5\u5DE5\u5177\u96C6"
@@ -8764,7 +8854,7 @@ function generateReadme2(marketplaceName, tools, selectedMcpTools, version) {
8764
8854
  "",
8765
8855
  "## \u73AF\u5883\u53D8\u91CF",
8766
8856
  "",
8767
- "\u590D\u5236 .env.example \u4E3A .env\uFF0C\u586B\u5199\u5BF9\u5E94\u7684 API Token \u540E\u91CD\u542F Claude Code \u4F1A\u8BDD\u3002",
8857
+ "\u7F16\u8F91 .env \u6587\u4EF6\uFF0C\u586B\u5199\u5BF9\u5E94\u7684 API Token \u540E\u91CD\u542F Claude Code \u4F1A\u8BDD\u3002",
8768
8858
  "",
8769
8859
  "## \u5F00\u53D1",
8770
8860
  "",
@@ -8776,16 +8866,16 @@ function generateReadme2(marketplaceName, tools, selectedMcpTools, version) {
8776
8866
  return lines.join("\n");
8777
8867
  }
8778
8868
  function readMcpServerConfig(cliDir2, mcpName) {
8779
- const mcpDir = path9.join(cliDir2, "mcp");
8780
- if (!fs13.existsSync(mcpDir)) return null;
8781
- const entries = fs13.readdirSync(mcpDir, { withFileTypes: true });
8869
+ const mcpDir = path10.join(cliDir2, "mcp");
8870
+ if (!fs14.existsSync(mcpDir)) return null;
8871
+ const entries = fs14.readdirSync(mcpDir, { withFileTypes: true });
8782
8872
  for (const entry of entries) {
8783
8873
  if (!entry.isDirectory()) continue;
8784
- const domainDir = path9.join(mcpDir, entry.name);
8785
- const files = fs13.readdirSync(domainDir).filter((f) => f.endsWith(".json"));
8874
+ const domainDir = path10.join(mcpDir, entry.name);
8875
+ const files = fs14.readdirSync(domainDir).filter((f) => f.endsWith(".json"));
8786
8876
  for (const file of files) {
8787
8877
  try {
8788
- const content = JSON.parse(fs13.readFileSync(path9.join(domainDir, file), "utf-8"));
8878
+ const content = JSON.parse(fs14.readFileSync(path10.join(domainDir, file), "utf-8"));
8789
8879
  if (content.name === mcpName && content.mcpServers) {
8790
8880
  const servers = content.mcpServers;
8791
8881
  const keys = Object.keys(servers);
@@ -8881,27 +8971,27 @@ function registerPluginBuildCommand(program2, registry2) {
8881
8971
  });
8882
8972
  }
8883
8973
  function updatePluginJsonHooks(pluginDir) {
8884
- const hooksDir = path10.join(pluginDir, "hooks");
8885
- const pluginJsonPath = path10.join(pluginDir, ".claude-plugin", "plugin.json");
8886
- if (!fs14.existsSync(hooksDir) || !fs14.existsSync(pluginJsonPath)) return;
8974
+ const hooksDir = path11.join(pluginDir, "hooks");
8975
+ const pluginJsonPath = path11.join(pluginDir, ".claude-plugin", "plugin.json");
8976
+ if (!fs15.existsSync(hooksDir) || !fs15.existsSync(pluginJsonPath)) return;
8887
8977
  try {
8888
- const pluginJson = JSON.parse(fs14.readFileSync(pluginJsonPath, "utf-8"));
8978
+ const pluginJson = JSON.parse(fs15.readFileSync(pluginJsonPath, "utf-8"));
8889
8979
  pluginJson.hooks = "./hooks/deepstorm-hooks.json";
8890
- fs14.writeFileSync(pluginJsonPath, JSON.stringify(pluginJson, null, 2) + "\n", "utf-8");
8980
+ fs15.writeFileSync(pluginJsonPath, JSON.stringify(pluginJson, null, 2) + "\n", "utf-8");
8891
8981
  console.log("\u2714 plugin.json \u5DF2\u6DFB\u52A0 hooks \u58F0\u660E");
8892
8982
  } catch {
8893
8983
  }
8894
8984
  }
8895
8985
  function ensureGitIgnore(targetDir) {
8896
- const gitIgnorePath = path10.join(targetDir, ".gitignore");
8986
+ const gitIgnorePath = path11.join(targetDir, ".gitignore");
8897
8987
  const line = ".deepstorm/";
8898
8988
  try {
8899
- if (fs14.existsSync(gitIgnorePath)) {
8900
- const content = fs14.readFileSync(gitIgnorePath, "utf-8");
8989
+ if (fs15.existsSync(gitIgnorePath)) {
8990
+ const content = fs15.readFileSync(gitIgnorePath, "utf-8");
8901
8991
  if (content.includes(line)) return;
8902
- fs14.writeFileSync(gitIgnorePath, content.trimEnd() + "\n" + line + "\n", "utf-8");
8992
+ fs15.writeFileSync(gitIgnorePath, content.trimEnd() + "\n" + line + "\n", "utf-8");
8903
8993
  } else {
8904
- fs14.writeFileSync(gitIgnorePath, line + "\n", "utf-8");
8994
+ fs15.writeFileSync(gitIgnorePath, line + "\n", "utf-8");
8905
8995
  }
8906
8996
  console.log("\u2714 .gitignore \u5DF2\u6DFB\u52A0 .deepstorm/ \u5FFD\u7565\u89C4\u5219");
8907
8997
  } catch {
@@ -8909,14 +8999,14 @@ function ensureGitIgnore(targetDir) {
8909
8999
  }
8910
9000
  function mergePluginHooks(tools, reader, pluginDir, packagesDir) {
8911
9001
  if (!tools.some((tool) => reader.getToolHooks(tool).length > 0)) return;
8912
- const pkgsDir = packagesDir ?? path10.resolve(process.cwd(), "packages");
8913
- const pluginHooksDir = path10.join(pluginDir, "hooks");
8914
- const destHooksJson = path10.join(pluginHooksDir, "deepstorm-hooks.json");
9002
+ const pkgsDir = packagesDir ?? path11.resolve(process.cwd(), "packages");
9003
+ const pluginHooksDir = path11.join(pluginDir, "hooks");
9004
+ const destHooksJson = path11.join(pluginHooksDir, "deepstorm-hooks.json");
8915
9005
  for (const tool of tools) {
8916
- const srcPath = path10.join(pkgsDir, tool, "hooks", "hooks.json");
8917
- if (fs14.existsSync(srcPath)) {
8918
- fs14.mkdirSync(pluginHooksDir, { recursive: true });
8919
- const incoming = JSON.parse(fs14.readFileSync(srcPath, "utf-8"));
9006
+ const srcPath = path11.join(pkgsDir, tool, "hooks", "hooks.json");
9007
+ if (fs15.existsSync(srcPath)) {
9008
+ fs15.mkdirSync(pluginHooksDir, { recursive: true });
9009
+ const incoming = JSON.parse(fs15.readFileSync(srcPath, "utf-8"));
8920
9010
  mergeHooks(destHooksJson, incoming);
8921
9011
  }
8922
9012
  }
@@ -8937,24 +9027,24 @@ function viewConfig(targetDir) {
8937
9027
  }
8938
9028
 
8939
9029
  // src/commands/config-set.ts
8940
- var fs16 = __toESM(require("node:fs"));
8941
- var path12 = __toESM(require("node:path"));
9030
+ var fs17 = __toESM(require("node:fs"));
9031
+ var path13 = __toESM(require("node:path"));
8942
9032
  var p6 = __toESM(require("@clack/prompts"));
8943
9033
 
8944
9034
  // src/utils/config-schema.ts
8945
- var fs15 = __toESM(require("node:fs"));
8946
- var path11 = __toESM(require("node:path"));
9035
+ var fs16 = __toESM(require("node:fs"));
9036
+ var path12 = __toESM(require("node:path"));
8947
9037
  function loadValidConfigKeys() {
8948
9038
  const candidates = [
8949
- path11.resolve(__dirname, "config-schema.json"),
8950
- path11.resolve(__dirname, "..", "config-schema.json"),
8951
- path11.resolve(process.cwd(), "config-schema.json"),
8952
- path11.resolve(process.cwd(), "packages", "cli", "config-schema.json")
9039
+ path12.resolve(__dirname, "config-schema.json"),
9040
+ path12.resolve(__dirname, "..", "config-schema.json"),
9041
+ path12.resolve(process.cwd(), "config-schema.json"),
9042
+ path12.resolve(process.cwd(), "packages", "cli", "config-schema.json")
8953
9043
  ];
8954
9044
  for (const schemaPath of candidates) {
8955
9045
  try {
8956
- if (!fs15.existsSync(schemaPath)) continue;
8957
- const schema = JSON.parse(fs15.readFileSync(schemaPath, "utf-8"));
9046
+ if (!fs16.existsSync(schemaPath)) continue;
9047
+ const schema = JSON.parse(fs16.readFileSync(schemaPath, "utf-8"));
8958
9048
  const keys = /* @__PURE__ */ new Set();
8959
9049
  collectLeafPaths(schema.properties, "", keys);
8960
9050
  return keys;
@@ -8992,9 +9082,9 @@ async function setConfigValue(targetDir, key, value, registry2) {
8992
9082
  const settingsPath = getDeepStormConfigPath(targetDir);
8993
9083
  readDeepStormConfig(targetDir);
8994
9084
  let config = {};
8995
- if (fs16.existsSync(settingsPath)) {
9085
+ if (fs17.existsSync(settingsPath)) {
8996
9086
  try {
8997
- config = JSON.parse(fs16.readFileSync(settingsPath, "utf-8"));
9087
+ config = JSON.parse(fs17.readFileSync(settingsPath, "utf-8"));
8998
9088
  } catch {
8999
9089
  config = {};
9000
9090
  }
@@ -9028,7 +9118,7 @@ async function setConfigValue(targetDir, key, value, registry2) {
9028
9118
  writePointer = writePointer[parts[i]];
9029
9119
  }
9030
9120
  writePointer[parts[parts.length - 1]] = value;
9031
- fs16.writeFileSync(settingsPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
9121
+ fs17.writeFileSync(settingsPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
9032
9122
  console.log(`\u2714 ${key} \u5DF2\u66F4\u65B0\u4E3A ${value}`);
9033
9123
  const affected = findAffectedTemplates(registry2, key);
9034
9124
  if (affected.length === 0) {
@@ -9066,8 +9156,8 @@ async function setConfigValue(targetDir, key, value, registry2) {
9066
9156
  const templateVariables = buildTemplateVariables(registry2, fullConfig, installedMcpServers);
9067
9157
  let renderCount = 0;
9068
9158
  for (const tmplRelPath of affected) {
9069
- const tmplPath = path12.join(cliDir, tmplRelPath);
9070
- if (!fs16.existsSync(tmplPath)) {
9159
+ const tmplPath = path13.join(cliDir, tmplRelPath);
9160
+ if (!fs17.existsSync(tmplPath)) {
9071
9161
  console.warn(` \u26A0 \u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${tmplRelPath}\uFF0C\u8DF3\u8FC7`);
9072
9162
  continue;
9073
9163
  }
@@ -9075,12 +9165,12 @@ async function setConfigValue(targetDir, key, value, registry2) {
9075
9165
  const assetType = pathParts[0];
9076
9166
  const assetName = pathParts[1];
9077
9167
  const outputFile = pathParts[pathParts.length - 1].replace(/\.tmpl$/, "");
9078
- const targetDirPath = path12.join(targetDir, ".claude", assetType, assetName);
9168
+ const targetDirPath = path13.join(targetDir, ".claude", assetType, assetName);
9079
9169
  ensureDir3(targetDirPath);
9080
- const outputPath = path12.join(targetDirPath, outputFile);
9170
+ const outputPath = path13.join(targetDirPath, outputFile);
9081
9171
  renderTemplate(tmplPath, templateVariables, outputPath);
9082
- const variantsDir = path12.join(cliDir, assetType, assetName, "variants");
9083
- if (fs16.existsSync(variantsDir)) {
9172
+ const variantsDir = path13.join(cliDir, assetType, assetName, "variants");
9173
+ if (fs17.existsSync(variantsDir)) {
9084
9174
  copyVariants(variantsDir, value, targetDirPath, true);
9085
9175
  }
9086
9176
  renderCount++;
@@ -9090,43 +9180,43 @@ async function setConfigValue(targetDir, key, value, registry2) {
9090
9180
  }
9091
9181
 
9092
9182
  // src/commands/config-reset.ts
9093
- var fs17 = __toESM(require("node:fs"));
9094
- var path13 = __toESM(require("node:path"));
9183
+ var fs18 = __toESM(require("node:fs"));
9184
+ var path14 = __toESM(require("node:path"));
9095
9185
  function resetConfig(targetDir) {
9096
- const settingsPath = path13.join(targetDir, ".deepstorm", "settings.json");
9097
- if (!fs17.existsSync(settingsPath)) return;
9186
+ const settingsPath = path14.join(targetDir, ".deepstorm", "settings.json");
9187
+ if (!fs18.existsSync(settingsPath)) return;
9098
9188
  try {
9099
- fs17.unlinkSync(settingsPath);
9189
+ fs18.unlinkSync(settingsPath);
9100
9190
  console.log("\u2714 \u5DF2\u6E05\u9664 DeepStorm \u914D\u7F6E");
9101
9191
  } catch {
9102
9192
  }
9103
9193
  }
9104
9194
 
9105
9195
  // src/commands/config-refresh.ts
9106
- var fs18 = __toESM(require("node:fs"));
9107
- var path14 = __toESM(require("node:path"));
9196
+ var fs19 = __toESM(require("node:fs"));
9197
+ var path15 = __toESM(require("node:path"));
9108
9198
  function refreshConfig(cliDir2, targetDir, registry2) {
9109
9199
  const result = { refreshed: [], errors: [] };
9110
9200
  const settingsPath = getDeepStormConfigPath(targetDir);
9111
- if (!fs18.existsSync(settingsPath)) {
9201
+ if (!fs19.existsSync(settingsPath)) {
9112
9202
  return result;
9113
9203
  }
9114
9204
  readDeepStormConfig(targetDir);
9115
9205
  let config;
9116
9206
  try {
9117
- config = JSON.parse(fs18.readFileSync(settingsPath, "utf-8"));
9207
+ config = JSON.parse(fs19.readFileSync(settingsPath, "utf-8"));
9118
9208
  } catch {
9119
9209
  return result;
9120
9210
  }
9121
9211
  const installedSkills = config.installedSkills ?? [];
9122
9212
  const installedMcpServers = config.installedMcpServers ?? [];
9123
- const targetDotClaudeDir = path14.join(targetDir, ".claude");
9213
+ const targetDotClaudeDir = path15.join(targetDir, ".claude");
9124
9214
  if (installedSkills.length === 0) return result;
9125
9215
  for (const skillId of installedSkills) {
9126
- const tmplPath = path14.join(cliDir2, "skills", skillId, "SKILL.md.tmpl");
9127
- if (!fs18.existsSync(tmplPath)) continue;
9128
- const targetSkillDir = path14.join(targetDotClaudeDir, "skills", skillId);
9129
- const outputPath = path14.join(targetSkillDir, "SKILL.md");
9216
+ const tmplPath = path15.join(cliDir2, "skills", skillId, "SKILL.md.tmpl");
9217
+ if (!fs19.existsSync(tmplPath)) continue;
9218
+ const targetSkillDir = path15.join(targetDotClaudeDir, "skills", skillId);
9219
+ const outputPath = path15.join(targetSkillDir, "SKILL.md");
9130
9220
  try {
9131
9221
  const enrichedVars = injectSkillCapabilities(
9132
9222
  tmplPath,
@@ -9134,7 +9224,7 @@ function refreshConfig(cliDir2, targetDir, registry2) {
9134
9224
  installedMcpServers,
9135
9225
  registry2.mcpTools ?? {}
9136
9226
  );
9137
- fs18.mkdirSync(targetSkillDir, { recursive: true });
9227
+ fs19.mkdirSync(targetSkillDir, { recursive: true });
9138
9228
  renderTemplate(tmplPath, enrichedVars, outputPath);
9139
9229
  result.refreshed.push(skillId);
9140
9230
  } catch (err) {
@@ -9151,14 +9241,14 @@ function refreshConfig(cliDir2, targetDir, registry2) {
9151
9241
  }
9152
9242
  function buildUnifiedMcpCapabilities2(cliDir2, installedMcpTools, mcpTools) {
9153
9243
  const allDeclarations = {};
9154
- const skillsDir = path14.join(cliDir2, "skills");
9155
- if (!fs18.existsSync(skillsDir)) return {};
9156
- const skillDirs = fs18.readdirSync(skillsDir, { withFileTypes: true });
9244
+ const skillsDir = path15.join(cliDir2, "skills");
9245
+ if (!fs19.existsSync(skillsDir)) return {};
9246
+ const skillDirs = fs19.readdirSync(skillsDir, { withFileTypes: true });
9157
9247
  for (const entry of skillDirs) {
9158
9248
  if (!entry.isDirectory()) continue;
9159
- const tmplPath = path14.join(skillsDir, entry.name, "SKILL.md.tmpl");
9160
- if (!fs18.existsSync(tmplPath)) continue;
9161
- const content = fs18.readFileSync(tmplPath, "utf-8");
9249
+ const tmplPath = path15.join(skillsDir, entry.name, "SKILL.md.tmpl");
9250
+ if (!fs19.existsSync(tmplPath)) continue;
9251
+ const content = fs19.readFileSync(tmplPath, "utf-8");
9162
9252
  const fm = parseFrontmatter(content);
9163
9253
  if (!fm) continue;
9164
9254
  const mcpCap = fm.mcpCapabilities;
@@ -9241,17 +9331,17 @@ function listTemplates(registry2, tool) {
9241
9331
  }
9242
9332
 
9243
9333
  // src/commands/template-init.ts
9244
- var fs19 = __toESM(require("node:fs"));
9245
- var path15 = __toESM(require("node:path"));
9334
+ var fs20 = __toESM(require("node:fs"));
9335
+ var path16 = __toESM(require("node:path"));
9246
9336
  var import_prompts3 = require("@clack/prompts");
9247
9337
  async function initTemplate(cliDir2, targetDir, skillId) {
9248
- const srcDir = path15.join(cliDir2, "skills", skillId);
9249
- const destDir = path15.join(targetDir, ".deepstorm", "templates", skillId);
9250
- if (!fs19.existsSync(srcDir)) {
9338
+ const srcDir = path16.join(cliDir2, "skills", skillId);
9339
+ const destDir = path16.join(targetDir, ".deepstorm", "templates", skillId);
9340
+ if (!fs20.existsSync(srcDir)) {
9251
9341
  console.log(`\u6A21\u677F\u4E0D\u5B58\u5728\uFF1A${skillId}`);
9252
9342
  return;
9253
9343
  }
9254
- if (fs19.existsSync(destDir)) {
9344
+ if (fs20.existsSync(destDir)) {
9255
9345
  const shouldOverwrite = await (0, import_prompts3.confirm)({
9256
9346
  message: `\u6A21\u677F ${skillId} \u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6\uFF1F`,
9257
9347
  initialValue: false
@@ -9260,21 +9350,21 @@ async function initTemplate(cliDir2, targetDir, skillId) {
9260
9350
  console.log("\u5DF2\u53D6\u6D88");
9261
9351
  return;
9262
9352
  }
9263
- fs19.rmSync(destDir, { recursive: true, force: true });
9353
+ fs20.rmSync(destDir, { recursive: true, force: true });
9264
9354
  }
9265
- ensureDir3(path15.dirname(destDir));
9355
+ ensureDir3(path16.dirname(destDir));
9266
9356
  copyDir(srcDir, destDir);
9267
9357
  console.log(`\u2714 \u6A21\u677F\u5DF2\u5BFC\u51FA\u5230 .deepstorm/templates/${skillId}/`);
9268
9358
  console.log(` \u4FEE\u6539\u5B8C\u6210\u540E\u8FD0\u884C deepstorm template apply ${skillId} \u5E94\u7528\u66F4\u6539`);
9269
9359
  }
9270
9360
 
9271
9361
  // src/commands/template-apply.ts
9272
- var fs20 = __toESM(require("node:fs"));
9273
- var path16 = __toESM(require("node:path"));
9362
+ var fs21 = __toESM(require("node:fs"));
9363
+ var path17 = __toESM(require("node:path"));
9274
9364
  function applyTemplate(targetDir, skillId) {
9275
- const srcDir = path16.join(targetDir, ".deepstorm", "templates", skillId);
9276
- const destDir = path16.join(targetDir, ".claude", "skills", skillId);
9277
- if (!fs20.existsSync(srcDir)) {
9365
+ const srcDir = path17.join(targetDir, ".deepstorm", "templates", skillId);
9366
+ const destDir = path17.join(targetDir, ".claude", "skills", skillId);
9367
+ if (!fs21.existsSync(srcDir)) {
9278
9368
  console.log(`\u6A21\u677F\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5148\u8FD0\u884C deepstorm template init ${skillId}`);
9279
9369
  return;
9280
9370
  }
@@ -9308,21 +9398,21 @@ function registerTemplateCommand(program2, registry2) {
9308
9398
  }
9309
9399
 
9310
9400
  // src/commands/update.ts
9311
- var fs23 = __toESM(require("node:fs"));
9312
- var import_node_child_process = require("node:child_process");
9401
+ var fs24 = __toESM(require("node:fs"));
9402
+ var import_node_child_process2 = require("node:child_process");
9313
9403
 
9314
9404
  // src/utils/version.ts
9315
- var fs21 = __toESM(require("node:fs"));
9316
- var path17 = __toESM(require("node:path"));
9405
+ var fs22 = __toESM(require("node:fs"));
9406
+ var path18 = __toESM(require("node:path"));
9317
9407
  function getCliVersion() {
9318
9408
  try {
9319
9409
  const paths = [
9320
- path17.resolve(__dirname, "package.json"),
9321
- path17.resolve(__dirname, "..", "package.json")
9410
+ path18.resolve(__dirname, "package.json"),
9411
+ path18.resolve(__dirname, "..", "package.json")
9322
9412
  ];
9323
9413
  for (const pkgPath of paths) {
9324
- if (fs21.existsSync(pkgPath)) {
9325
- const pkg = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
9414
+ if (fs22.existsSync(pkgPath)) {
9415
+ const pkg = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
9326
9416
  return pkg.version || "0.0.0";
9327
9417
  }
9328
9418
  }
@@ -9333,14 +9423,14 @@ function getCliVersion() {
9333
9423
  }
9334
9424
 
9335
9425
  // src/commands/template-upgrade.ts
9336
- var fs22 = __toESM(require("node:fs"));
9337
- var path18 = __toESM(require("node:path"));
9426
+ var fs23 = __toESM(require("node:fs"));
9427
+ var path19 = __toESM(require("node:path"));
9338
9428
  var crypto = __toESM(require("node:crypto"));
9339
9429
  var CHECKSUM_FILE = "deepstorm-checksums.json";
9340
9430
  function computeFileChecksum(filePath) {
9341
9431
  try {
9342
- if (!fs22.existsSync(filePath)) return null;
9343
- const content = fs22.readFileSync(filePath);
9432
+ if (!fs23.existsSync(filePath)) return null;
9433
+ const content = fs23.readFileSync(filePath);
9344
9434
  return crypto.createHash("sha256").update(content).digest("hex");
9345
9435
  } catch {
9346
9436
  return null;
@@ -9348,15 +9438,15 @@ function computeFileChecksum(filePath) {
9348
9438
  }
9349
9439
  function computeDirChecksums(dirPath, relativeTo = dirPath) {
9350
9440
  const result = {};
9351
- if (!fs22.existsSync(dirPath)) return result;
9441
+ if (!fs23.existsSync(dirPath)) return result;
9352
9442
  function walk(current) {
9353
- for (const entry of fs22.readdirSync(current, { withFileTypes: true })) {
9354
- const fullPath = path18.join(current, entry.name);
9443
+ for (const entry of fs23.readdirSync(current, { withFileTypes: true })) {
9444
+ const fullPath = path19.join(current, entry.name);
9355
9445
  if (entry.name === ".DS_Store") continue;
9356
9446
  if (entry.isDirectory()) {
9357
9447
  walk(fullPath);
9358
9448
  } else if (entry.isFile()) {
9359
- const relPath = path18.relative(relativeTo, fullPath);
9449
+ const relPath = path19.relative(relativeTo, fullPath);
9360
9450
  const checksum = computeFileChecksum(fullPath);
9361
9451
  if (checksum) result[relPath] = checksum;
9362
9452
  }
@@ -9366,32 +9456,32 @@ function computeDirChecksums(dirPath, relativeTo = dirPath) {
9366
9456
  return result;
9367
9457
  }
9368
9458
  function loadChecksums(targetDir) {
9369
- const filePath = path18.join(targetDir, ".claude", CHECKSUM_FILE);
9459
+ const filePath = path19.join(targetDir, ".claude", CHECKSUM_FILE);
9370
9460
  try {
9371
- return JSON.parse(fs22.readFileSync(filePath, "utf-8"));
9461
+ return JSON.parse(fs23.readFileSync(filePath, "utf-8"));
9372
9462
  } catch {
9373
9463
  return {};
9374
9464
  }
9375
9465
  }
9376
9466
  function saveChecksums(targetDir, checksums) {
9377
- const dir = path18.join(targetDir, ".claude");
9467
+ const dir = path19.join(targetDir, ".claude");
9378
9468
  ensureDir3(dir);
9379
- fs22.writeFileSync(
9380
- path18.join(dir, CHECKSUM_FILE),
9469
+ fs23.writeFileSync(
9470
+ path19.join(dir, CHECKSUM_FILE),
9381
9471
  JSON.stringify(checksums, null, 2) + "\n",
9382
9472
  "utf-8"
9383
9473
  );
9384
9474
  }
9385
9475
  function backupFile(filePath) {
9386
9476
  try {
9387
- if (!fs22.existsSync(filePath)) return null;
9388
- const dir = path18.dirname(filePath);
9389
- const ext = path18.extname(filePath);
9390
- const base = path18.basename(filePath, ext);
9477
+ if (!fs23.existsSync(filePath)) return null;
9478
+ const dir = path19.dirname(filePath);
9479
+ const ext = path19.extname(filePath);
9480
+ const base = path19.basename(filePath, ext);
9391
9481
  const timestamp = Date.now();
9392
9482
  const bakName = `${base}.${timestamp}.bak`;
9393
- const bakPath = path18.join(dir, bakName);
9394
- fs22.cpSync(filePath, bakPath, { force: true });
9483
+ const bakPath = path19.join(dir, bakName);
9484
+ fs23.cpSync(filePath, bakPath, { force: true });
9395
9485
  return bakName;
9396
9486
  } catch {
9397
9487
  return null;
@@ -9412,19 +9502,19 @@ function backupModifiedAssets(targetDir, skillIds, toolNames, registry2) {
9412
9502
  const stored = loadChecksums(targetDir);
9413
9503
  const backedUp = [];
9414
9504
  for (const skillId of skillIds) {
9415
- const skillDir = path18.join(targetDir, ".claude", "skills", skillId);
9416
- if (!fs22.existsSync(skillDir)) continue;
9505
+ const skillDir = path19.join(targetDir, ".claude", "skills", skillId);
9506
+ if (!fs23.existsSync(skillDir)) continue;
9417
9507
  const checksums = computeDirChecksums(skillDir);
9418
9508
  for (const [relPath] of Object.entries(checksums)) {
9419
9509
  const key = `skills/${skillId}/${relPath}`;
9420
- checkAndBackup(key, path18.join(skillDir, relPath), stored, backedUp);
9510
+ checkAndBackup(key, path19.join(skillDir, relPath), stored, backedUp);
9421
9511
  }
9422
9512
  }
9423
9513
  const reader = new RegistryReader(registry2);
9424
9514
  for (const tool of toolNames) {
9425
9515
  const agents = reader.getToolAgents(tool);
9426
9516
  for (const agentFile of agents) {
9427
- const filePath = path18.join(targetDir, ".claude", "agents", agentFile.replace(/\.tmpl$/, ""));
9517
+ const filePath = path19.join(targetDir, ".claude", "agents", agentFile.replace(/\.tmpl$/, ""));
9428
9518
  const key = `agents/${agentFile.replace(/\.tmpl$/, "")}`;
9429
9519
  checkAndBackup(key, filePath, stored, backedUp);
9430
9520
  }
@@ -9432,7 +9522,7 @@ function backupModifiedAssets(targetDir, skillIds, toolNames, registry2) {
9432
9522
  for (const tool of toolNames) {
9433
9523
  const hooks = reader.getToolHooks(tool);
9434
9524
  for (const hookFile of hooks) {
9435
- const filePath = path18.join(targetDir, ".claude", "hooks", hookFile);
9525
+ const filePath = path19.join(targetDir, ".claude", "hooks", hookFile);
9436
9526
  const key = `hooks/${hookFile}`;
9437
9527
  checkAndBackup(key, filePath, stored, backedUp);
9438
9528
  }
@@ -9443,7 +9533,7 @@ function storeNewChecksums(targetDir, skillIds, toolNames, registry2) {
9443
9533
  const newChecksums = {};
9444
9534
  const reader = new RegistryReader(registry2);
9445
9535
  for (const skillId of skillIds) {
9446
- const skillDir = path18.join(targetDir, ".claude", "skills", skillId);
9536
+ const skillDir = path19.join(targetDir, ".claude", "skills", skillId);
9447
9537
  const checksums = computeDirChecksums(skillDir);
9448
9538
  for (const [relPath, checksum] of Object.entries(checksums)) {
9449
9539
  newChecksums[`skills/${skillId}/${relPath}`] = checksum;
@@ -9453,7 +9543,7 @@ function storeNewChecksums(targetDir, skillIds, toolNames, registry2) {
9453
9543
  const agents = reader.getToolAgents(tool);
9454
9544
  for (const agentFile of agents) {
9455
9545
  const installedName = agentFile.replace(/\.tmpl$/, "");
9456
- const filePath = path18.join(targetDir, ".claude", "agents", installedName);
9546
+ const filePath = path19.join(targetDir, ".claude", "agents", installedName);
9457
9547
  const chk = computeFileChecksum(filePath);
9458
9548
  if (chk) newChecksums[`agents/${installedName}`] = chk;
9459
9549
  }
@@ -9461,7 +9551,7 @@ function storeNewChecksums(targetDir, skillIds, toolNames, registry2) {
9461
9551
  for (const tool of toolNames) {
9462
9552
  const hooks = reader.getToolHooks(tool);
9463
9553
  for (const hookFile of hooks) {
9464
- const filePath = path18.join(targetDir, ".claude", "hooks", hookFile);
9554
+ const filePath = path19.join(targetDir, ".claude", "hooks", hookFile);
9465
9555
  const chk = computeFileChecksum(filePath);
9466
9556
  if (chk) newChecksums[`hooks/${hookFile}`] = chk;
9467
9557
  }
@@ -9494,7 +9584,7 @@ function detectToolsFromConfig(config, registry2) {
9494
9584
  function readSettingsConfig(targetDir) {
9495
9585
  const settingsPath = getDeepStormConfigPath(targetDir);
9496
9586
  try {
9497
- const raw = fs22.readFileSync(settingsPath, "utf-8");
9587
+ const raw = fs23.readFileSync(settingsPath, "utf-8");
9498
9588
  const config = JSON.parse(raw);
9499
9589
  const metaKeys = /* @__PURE__ */ new Set([
9500
9590
  "installedSkills",
@@ -9524,22 +9614,22 @@ function flattenNestedConfig(obj, prefix, result, skipKeys) {
9524
9614
  }
9525
9615
  }
9526
9616
  function loadRegistryFromCliDir(cliDir2) {
9527
- const registryPath = path18.join(cliDir2, "registry.json");
9617
+ const registryPath = path19.join(cliDir2, "registry.json");
9528
9618
  try {
9529
- const raw = fs22.readFileSync(registryPath, "utf-8");
9619
+ const raw = fs23.readFileSync(registryPath, "utf-8");
9530
9620
  return JSON.parse(raw);
9531
9621
  } catch {
9532
9622
  return null;
9533
9623
  }
9534
9624
  }
9535
9625
  function mergeToolHooksJson(toolNames, cliDir2, targetDir) {
9536
- const hooksSrcDir = path18.join(cliDir2, "hooks");
9537
- const destHooksJson = path18.join(targetDir, ".claude", "hooks.json");
9626
+ const hooksSrcDir = path19.join(cliDir2, "hooks");
9627
+ const destHooksJson = path19.join(targetDir, ".claude", "hooks.json");
9538
9628
  for (const tool of toolNames) {
9539
- const toolHooksJsonPath = path18.join(hooksSrcDir, `${tool}-hooks.json`);
9540
- if (fs22.existsSync(toolHooksJsonPath)) {
9541
- ensureDir3(path18.join(targetDir, ".claude"));
9542
- const incoming = JSON.parse(fs22.readFileSync(toolHooksJsonPath, "utf-8"));
9629
+ const toolHooksJsonPath = path19.join(hooksSrcDir, `${tool}-hooks.json`);
9630
+ if (fs23.existsSync(toolHooksJsonPath)) {
9631
+ ensureDir3(path19.join(targetDir, ".claude"));
9632
+ const incoming = JSON.parse(fs23.readFileSync(toolHooksJsonPath, "utf-8"));
9543
9633
  mergeHooks(destHooksJson, incoming);
9544
9634
  }
9545
9635
  }
@@ -9657,8 +9747,8 @@ function readLocalRegistryFile(url) {
9657
9747
  filePath = filePath.slice(7);
9658
9748
  }
9659
9749
  try {
9660
- if (fs23.existsSync(filePath)) {
9661
- return JSON.parse(fs23.readFileSync(filePath, "utf-8"));
9750
+ if (fs24.existsSync(filePath)) {
9751
+ return JSON.parse(fs24.readFileSync(filePath, "utf-8"));
9662
9752
  }
9663
9753
  } catch {
9664
9754
  }
@@ -9727,7 +9817,7 @@ async function updateCLI(fetchFn) {
9727
9817
  console.log("\u2192 \u6B63\u5728\u81EA\u52A8\u66F4\u65B0...");
9728
9818
  const updateCmd = process.env.DEEPSTORM_UPDATE_CMD || "npm install -g @deepstorm/cli@latest";
9729
9819
  try {
9730
- (0, import_node_child_process.execSync)(updateCmd, { stdio: "inherit" });
9820
+ (0, import_node_child_process2.execSync)(updateCmd, { stdio: "inherit" });
9731
9821
  console.log(`
9732
9822
  \u2714 \u5DF2\u66F4\u65B0\u81F3 v${result.latest}`);
9733
9823
  } catch {
@@ -9742,7 +9832,7 @@ async function updateCLI(fetchFn) {
9742
9832
  function getInstalledSkillIds(targetDir) {
9743
9833
  const settingsPath = getDeepStormConfigPath(targetDir);
9744
9834
  try {
9745
- const raw = fs23.readFileSync(settingsPath, "utf-8");
9835
+ const raw = fs24.readFileSync(settingsPath, "utf-8");
9746
9836
  const config = JSON.parse(raw);
9747
9837
  return config.installedSkills ?? [];
9748
9838
  } catch {
@@ -9769,12 +9859,12 @@ function registerPilotCommands(program2) {
9769
9859
  }
9770
9860
 
9771
9861
  // src/commands/doctor.ts
9772
- var fs24 = __toESM(require("node:fs"));
9773
- var path19 = __toESM(require("node:path"));
9862
+ var fs25 = __toESM(require("node:fs"));
9863
+ var path20 = __toESM(require("node:path"));
9774
9864
  function getInstalledSkills(targetDir) {
9775
9865
  const settingsPath = getDeepStormConfigPath(targetDir);
9776
9866
  try {
9777
- const settings = JSON.parse(fs24.readFileSync(settingsPath, "utf-8"));
9867
+ const settings = JSON.parse(fs25.readFileSync(settingsPath, "utf-8"));
9778
9868
  return settings.installedSkills || [];
9779
9869
  } catch {
9780
9870
  return [];
@@ -9791,7 +9881,7 @@ function runDoctor(targetDir) {
9791
9881
  message: `v${version}\uFF08\u8FD0\u884C deepstorm update --check \u68C0\u67E5\u6700\u65B0\u7248\u672C\uFF09`
9792
9882
  });
9793
9883
  let hasDeepStorm = false;
9794
- if (!fs24.existsSync(settingsPath)) {
9884
+ if (!fs25.existsSync(settingsPath)) {
9795
9885
  checks.push({
9796
9886
  name: "\u914D\u7F6E\u6587\u4EF6",
9797
9887
  status: "warn",
@@ -9799,7 +9889,7 @@ function runDoctor(targetDir) {
9799
9889
  });
9800
9890
  } else {
9801
9891
  try {
9802
- const config = JSON.parse(fs24.readFileSync(settingsPath, "utf-8"));
9892
+ const config = JSON.parse(fs25.readFileSync(settingsPath, "utf-8"));
9803
9893
  if (config && Object.keys(config).length > 0) {
9804
9894
  hasDeepStorm = true;
9805
9895
  checks.push({
@@ -9822,20 +9912,20 @@ function runDoctor(targetDir) {
9822
9912
  });
9823
9913
  }
9824
9914
  }
9825
- const skillsDir = path19.join(targetDir, ".claude", "skills");
9826
- if (fs24.existsSync(skillsDir)) {
9827
- const skillDirs = fs24.readdirSync(skillsDir).filter(
9828
- (n) => fs24.statSync(path19.join(skillsDir, n)).isDirectory()
9915
+ const skillsDir = path20.join(targetDir, ".claude", "skills");
9916
+ if (fs25.existsSync(skillsDir)) {
9917
+ const skillDirs = fs25.readdirSync(skillsDir).filter(
9918
+ (n) => fs25.statSync(path20.join(skillsDir, n)).isDirectory()
9829
9919
  );
9830
9920
  let validCount = 0;
9831
9921
  let invalidCount = 0;
9832
9922
  for (const skillName of skillDirs) {
9833
- const skillMd = path19.join(skillsDir, skillName, "SKILL.md");
9834
- if (!fs24.existsSync(skillMd)) {
9923
+ const skillMd = path20.join(skillsDir, skillName, "SKILL.md");
9924
+ if (!fs25.existsSync(skillMd)) {
9835
9925
  invalidCount++;
9836
9926
  continue;
9837
9927
  }
9838
- const content = fs24.readFileSync(skillMd, "utf-8");
9928
+ const content = fs25.readFileSync(skillMd, "utf-8");
9839
9929
  const frontmatter = parseFrontmatter(content);
9840
9930
  if (frontmatter && frontmatter.name) {
9841
9931
  validCount++;
@@ -9865,7 +9955,7 @@ function runDoctor(targetDir) {
9865
9955
  const installedSkills = getInstalledSkills(targetDir);
9866
9956
  const missingSkills = [];
9867
9957
  for (const skillId of installedSkills) {
9868
- if (!fs24.existsSync(path19.join(skillsDir, skillId))) {
9958
+ if (!fs25.existsSync(path20.join(skillsDir, skillId))) {
9869
9959
  missingSkills.push(skillId);
9870
9960
  }
9871
9961
  }
@@ -9889,10 +9979,10 @@ function runDoctor(targetDir) {
9889
9979
  message: ".claude/skills/ \u4E0D\u5B58\u5728"
9890
9980
  });
9891
9981
  }
9892
- const mcpPath = path19.join(targetDir, ".mcp.json");
9893
- if (fs24.existsSync(mcpPath)) {
9982
+ const mcpPath = path20.join(targetDir, ".mcp.json");
9983
+ if (fs25.existsSync(mcpPath)) {
9894
9984
  try {
9895
- const mcp = JSON.parse(fs24.readFileSync(mcpPath, "utf-8"));
9985
+ const mcp = JSON.parse(fs25.readFileSync(mcpPath, "utf-8"));
9896
9986
  const hasServers = mcp.mcpServers && Object.keys(mcp.mcpServers).length > 0;
9897
9987
  checks.push({
9898
9988
  name: "MCP \u670D\u52A1\u5668",
@@ -9913,12 +10003,12 @@ function runDoctor(targetDir) {
9913
10003
  message: ".mcp.json \u4E0D\u5B58\u5728"
9914
10004
  });
9915
10005
  }
9916
- if (hasDeepStorm && fs24.existsSync(settingsPath)) {
10006
+ if (hasDeepStorm && fs25.existsSync(settingsPath)) {
9917
10007
  try {
9918
- const config = JSON.parse(fs24.readFileSync(settingsPath, "utf-8"));
10008
+ const config = JSON.parse(fs25.readFileSync(settingsPath, "utf-8"));
9919
10009
  const installedMcp = config.installedMcpServers;
9920
10010
  if (installedMcp && installedMcp.length > 0) {
9921
- const mcpExists = fs24.existsSync(mcpPath);
10011
+ const mcpExists = fs25.existsSync(mcpPath);
9922
10012
  if (!mcpExists) {
9923
10013
  checks.push({
9924
10014
  name: "MCP \u4E00\u81F4\u6027",
@@ -9927,7 +10017,7 @@ function runDoctor(targetDir) {
9927
10017
  });
9928
10018
  } else {
9929
10019
  try {
9930
- const mcpConfig = JSON.parse(fs24.readFileSync(mcpPath, "utf-8"));
10020
+ const mcpConfig = JSON.parse(fs25.readFileSync(mcpPath, "utf-8"));
9931
10021
  const servers = mcpConfig.mcpServers || {};
9932
10022
  const missing = [];
9933
10023
  for (const toolName of installedMcp) {
@@ -9955,9 +10045,9 @@ function runDoctor(targetDir) {
9955
10045
  } catch {
9956
10046
  }
9957
10047
  }
9958
- if (hasDeepStorm && fs24.existsSync(settingsPath)) {
10048
+ if (hasDeepStorm && fs25.existsSync(settingsPath)) {
9959
10049
  try {
9960
- const config = JSON.parse(fs24.readFileSync(settingsPath, "utf-8"));
10050
+ const config = JSON.parse(fs25.readFileSync(settingsPath, "utf-8"));
9961
10051
  const validKeys = loadValidConfigKeys();
9962
10052
  if (validKeys.size > 0 && config) {
9963
10053
  const configKeys = [];
@@ -10010,18 +10100,18 @@ function printDoctorReport(report) {
10010
10100
  }
10011
10101
 
10012
10102
  // src/commands/uninstall.ts
10013
- var fs25 = __toESM(require("node:fs"));
10014
- var path20 = __toESM(require("node:path"));
10103
+ var fs26 = __toESM(require("node:fs"));
10104
+ var path21 = __toESM(require("node:path"));
10015
10105
  var import_prompts4 = require("@clack/prompts");
10016
10106
  async function uninstallDeepStorm(targetDir) {
10017
10107
  const settingsPath = getDeepStormConfigPath(targetDir);
10018
- if (!fs25.existsSync(settingsPath)) {
10108
+ if (!fs26.existsSync(settingsPath)) {
10019
10109
  console.log("DeepStorm \u5C1A\u672A\u914D\u7F6E\uFF0C\u65E0\u9700\u5378\u8F7D");
10020
10110
  return;
10021
10111
  }
10022
10112
  let hasDeepStorm = false;
10023
10113
  try {
10024
- const settings = JSON.parse(fs25.readFileSync(settingsPath, "utf-8"));
10114
+ const settings = JSON.parse(fs26.readFileSync(settingsPath, "utf-8"));
10025
10115
  hasDeepStorm = !!settings && Object.keys(settings).length > 0;
10026
10116
  } catch {
10027
10117
  }
@@ -10031,14 +10121,14 @@ async function uninstallDeepStorm(targetDir) {
10031
10121
  }
10032
10122
  cleanInstalled(targetDir);
10033
10123
  resetConfig(targetDir);
10034
- const templatesDir = path20.join(targetDir, ".deepstorm", "templates");
10035
- if (fs25.existsSync(templatesDir)) {
10124
+ const templatesDir = path21.join(targetDir, ".deepstorm", "templates");
10125
+ if (fs26.existsSync(templatesDir)) {
10036
10126
  const shouldDelete = await (0, import_prompts4.confirm)({
10037
10127
  message: "\u662F\u5426\u5220\u9664 .deepstorm/templates/ \u76EE\u5F55\uFF1F",
10038
10128
  initialValue: false
10039
10129
  });
10040
10130
  if (shouldDelete) {
10041
- fs25.rmSync(templatesDir, { recursive: true, force: true });
10131
+ fs26.rmSync(templatesDir, { recursive: true, force: true });
10042
10132
  console.log("\u2714 .deepstorm/templates/ \u5DF2\u5220\u9664");
10043
10133
  } else {
10044
10134
  console.log("\u4FDD\u7559 .deepstorm/templates/");
@@ -10051,9 +10141,9 @@ async function uninstallDeepStorm(targetDir) {
10051
10141
  var program = new import_commander.Command();
10052
10142
  program.name("deepstorm").description("DeepStorm CLI \u2014 \u4E00\u952E\u914D\u7F6E\u9879\u76EE\u5F00\u53D1\u73AF\u5883").version(getCliVersion(), "-v, --version", "\u8F93\u51FA\u7248\u672C\u53F7");
10053
10143
  function loadRegistry() {
10054
- const registryPath = path21.join(__dirname, "registry.json");
10144
+ const registryPath = path22.join(__dirname, "registry.json");
10055
10145
  try {
10056
- const raw = fs26.readFileSync(registryPath, "utf-8");
10146
+ const raw = fs27.readFileSync(registryPath, "utf-8");
10057
10147
  return JSON.parse(raw);
10058
10148
  } catch {
10059
10149
  return { version: "1", tools: {}, wizards: {}, skills: {} };