agentinit 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +15 -1
  3. package/dist/agents/Agent.d.ts +12 -0
  4. package/dist/agents/Agent.d.ts.map +1 -1
  5. package/dist/agents/Agent.js +22 -0
  6. package/dist/agents/Agent.js.map +1 -1
  7. package/dist/agents/AiderAgent.d.ts.map +1 -1
  8. package/dist/agents/AiderAgent.js +3 -0
  9. package/dist/agents/AiderAgent.js.map +1 -1
  10. package/dist/agents/ClaudeAgent.d.ts.map +1 -1
  11. package/dist/agents/ClaudeAgent.js +5 -1
  12. package/dist/agents/ClaudeAgent.js.map +1 -1
  13. package/dist/agents/ClaudeDesktopAgent.d.ts.map +1 -1
  14. package/dist/agents/ClaudeDesktopAgent.js +5 -1
  15. package/dist/agents/ClaudeDesktopAgent.js.map +1 -1
  16. package/dist/agents/CodexCliAgent.d.ts.map +1 -1
  17. package/dist/agents/CodexCliAgent.js +6 -2
  18. package/dist/agents/CodexCliAgent.js.map +1 -1
  19. package/dist/agents/CopilotAgent.d.ts.map +1 -1
  20. package/dist/agents/CopilotAgent.js +6 -2
  21. package/dist/agents/CopilotAgent.js.map +1 -1
  22. package/dist/agents/CursorAgent.d.ts.map +1 -1
  23. package/dist/agents/CursorAgent.js +6 -2
  24. package/dist/agents/CursorAgent.js.map +1 -1
  25. package/dist/agents/DroidAgent.d.ts.map +1 -1
  26. package/dist/agents/DroidAgent.js +7 -2
  27. package/dist/agents/DroidAgent.js.map +1 -1
  28. package/dist/agents/GeminiCliAgent.d.ts.map +1 -1
  29. package/dist/agents/GeminiCliAgent.js +5 -2
  30. package/dist/agents/GeminiCliAgent.js.map +1 -1
  31. package/dist/agents/RooCodeAgent.d.ts.map +1 -1
  32. package/dist/agents/RooCodeAgent.js +5 -1
  33. package/dist/agents/RooCodeAgent.js.map +1 -1
  34. package/dist/agents/ZedAgent.d.ts.map +1 -1
  35. package/dist/agents/ZedAgent.js +3 -0
  36. package/dist/agents/ZedAgent.js.map +1 -1
  37. package/dist/cli.js +926 -431
  38. package/dist/cli.js.map +1 -1
  39. package/dist/commands/apply.d.ts +1 -0
  40. package/dist/commands/apply.d.ts.map +1 -1
  41. package/dist/commands/apply.js +30 -5
  42. package/dist/commands/apply.js.map +1 -1
  43. package/dist/commands/mcp.d.ts.map +1 -1
  44. package/dist/commands/mcp.js +97 -39
  45. package/dist/commands/mcp.js.map +1 -1
  46. package/dist/commands/plugins.d.ts.map +1 -1
  47. package/dist/commands/plugins.js +2 -0
  48. package/dist/commands/plugins.js.map +1 -1
  49. package/dist/commands/skills.d.ts.map +1 -1
  50. package/dist/commands/skills.js +48 -19
  51. package/dist/commands/skills.js.map +1 -1
  52. package/dist/commands/sync.d.ts.map +1 -1
  53. package/dist/commands/sync.js +14 -1
  54. package/dist/commands/sync.js.map +1 -1
  55. package/dist/core/managedState.d.ts +1 -0
  56. package/dist/core/managedState.d.ts.map +1 -1
  57. package/dist/core/managedState.js +40 -8
  58. package/dist/core/managedState.js.map +1 -1
  59. package/dist/core/pluginManager.d.ts.map +1 -1
  60. package/dist/core/pluginManager.js +46 -33
  61. package/dist/core/pluginManager.js.map +1 -1
  62. package/dist/core/projectSkills.d.ts +3 -3
  63. package/dist/core/projectSkills.d.ts.map +1 -1
  64. package/dist/core/projectSkills.js +22 -18
  65. package/dist/core/projectSkills.js.map +1 -1
  66. package/dist/core/projectStandards.d.ts +18 -0
  67. package/dist/core/projectStandards.d.ts.map +1 -0
  68. package/dist/core/projectStandards.js +50 -0
  69. package/dist/core/projectStandards.js.map +1 -0
  70. package/dist/core/propagator.d.ts +3 -0
  71. package/dist/core/propagator.d.ts.map +1 -1
  72. package/dist/core/propagator.js +109 -23
  73. package/dist/core/propagator.js.map +1 -1
  74. package/dist/core/skillsManager.d.ts +18 -5
  75. package/dist/core/skillsManager.d.ts.map +1 -1
  76. package/dist/core/skillsManager.js +187 -50
  77. package/dist/core/skillsManager.js.map +1 -1
  78. package/dist/types/index.d.ts +5 -0
  79. package/dist/types/index.d.ts.map +1 -1
  80. package/dist/types/index.js.map +1 -1
  81. package/dist/types/plugins.d.ts +4 -5
  82. package/dist/types/plugins.d.ts.map +1 -1
  83. package/dist/types/skills.d.ts +18 -2
  84. package/dist/types/skills.d.ts.map +1 -1
  85. package/dist/utils/fs.d.ts +5 -0
  86. package/dist/utils/fs.d.ts.map +1 -1
  87. package/dist/utils/fs.js +86 -1
  88. package/dist/utils/fs.js.map +1 -1
  89. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -13587,20 +13587,20 @@ var require_parse_async = __commonJS((exports, module) => {
13587
13587
  const index = 0;
13588
13588
  const blocksize = opts.blocksize || 40960;
13589
13589
  const parser = new TOMLParser;
13590
- return new Promise((resolve6, reject) => {
13591
- setImmediate(parseAsyncNext, index, blocksize, resolve6, reject);
13590
+ return new Promise((resolve7, reject) => {
13591
+ setImmediate(parseAsyncNext, index, blocksize, resolve7, reject);
13592
13592
  });
13593
- function parseAsyncNext(index2, blocksize2, resolve6, reject) {
13593
+ function parseAsyncNext(index2, blocksize2, resolve7, reject) {
13594
13594
  if (index2 >= str2.length) {
13595
13595
  try {
13596
- return resolve6(parser.finish());
13596
+ return resolve7(parser.finish());
13597
13597
  } catch (err) {
13598
13598
  return reject(prettyError(err, str2));
13599
13599
  }
13600
13600
  }
13601
13601
  try {
13602
13602
  parser.parse(str2.slice(index2, index2 + blocksize2));
13603
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve6, reject);
13603
+ setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve7, reject);
13604
13604
  } catch (err) {
13605
13605
  reject(prettyError(err, str2));
13606
13606
  }
@@ -13623,7 +13623,7 @@ var require_parse_stream = __commonJS((exports, module) => {
13623
13623
  var parseReadable = function(stm) {
13624
13624
  const parser = new TOMLParser;
13625
13625
  stm.setEncoding("utf8");
13626
- return new Promise((resolve6, reject) => {
13626
+ return new Promise((resolve7, reject) => {
13627
13627
  let readable;
13628
13628
  let ended = false;
13629
13629
  let errored = false;
@@ -13632,7 +13632,7 @@ var require_parse_stream = __commonJS((exports, module) => {
13632
13632
  if (readable)
13633
13633
  return;
13634
13634
  try {
13635
- resolve6(parser.finish());
13635
+ resolve7(parser.finish());
13636
13636
  } catch (err) {
13637
13637
  reject(err);
13638
13638
  }
@@ -14840,51 +14840,51 @@ var require_uri_all = __commonJS((exports, module) => {
14840
14840
  }
14841
14841
  return uriTokens.join("");
14842
14842
  }
14843
- function resolveComponents(base2, relative3) {
14843
+ function resolveComponents(base2, relative5) {
14844
14844
  var options2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14845
14845
  var skipNormalization = arguments[3];
14846
14846
  var target = {};
14847
14847
  if (!skipNormalization) {
14848
14848
  base2 = parse4(serialize(base2, options2), options2);
14849
- relative3 = parse4(serialize(relative3, options2), options2);
14849
+ relative5 = parse4(serialize(relative5, options2), options2);
14850
14850
  }
14851
14851
  options2 = options2 || {};
14852
- if (!options2.tolerant && relative3.scheme) {
14853
- target.scheme = relative3.scheme;
14854
- target.userinfo = relative3.userinfo;
14855
- target.host = relative3.host;
14856
- target.port = relative3.port;
14857
- target.path = removeDotSegments(relative3.path || "");
14858
- target.query = relative3.query;
14852
+ if (!options2.tolerant && relative5.scheme) {
14853
+ target.scheme = relative5.scheme;
14854
+ target.userinfo = relative5.userinfo;
14855
+ target.host = relative5.host;
14856
+ target.port = relative5.port;
14857
+ target.path = removeDotSegments(relative5.path || "");
14858
+ target.query = relative5.query;
14859
14859
  } else {
14860
- if (relative3.userinfo !== undefined || relative3.host !== undefined || relative3.port !== undefined) {
14861
- target.userinfo = relative3.userinfo;
14862
- target.host = relative3.host;
14863
- target.port = relative3.port;
14864
- target.path = removeDotSegments(relative3.path || "");
14865
- target.query = relative3.query;
14860
+ if (relative5.userinfo !== undefined || relative5.host !== undefined || relative5.port !== undefined) {
14861
+ target.userinfo = relative5.userinfo;
14862
+ target.host = relative5.host;
14863
+ target.port = relative5.port;
14864
+ target.path = removeDotSegments(relative5.path || "");
14865
+ target.query = relative5.query;
14866
14866
  } else {
14867
- if (!relative3.path) {
14867
+ if (!relative5.path) {
14868
14868
  target.path = base2.path;
14869
- if (relative3.query !== undefined) {
14870
- target.query = relative3.query;
14869
+ if (relative5.query !== undefined) {
14870
+ target.query = relative5.query;
14871
14871
  } else {
14872
14872
  target.query = base2.query;
14873
14873
  }
14874
14874
  } else {
14875
- if (relative3.path.charAt(0) === "/") {
14876
- target.path = removeDotSegments(relative3.path);
14875
+ if (relative5.path.charAt(0) === "/") {
14876
+ target.path = removeDotSegments(relative5.path);
14877
14877
  } else {
14878
14878
  if ((base2.userinfo !== undefined || base2.host !== undefined || base2.port !== undefined) && !base2.path) {
14879
- target.path = "/" + relative3.path;
14879
+ target.path = "/" + relative5.path;
14880
14880
  } else if (!base2.path) {
14881
- target.path = relative3.path;
14881
+ target.path = relative5.path;
14882
14882
  } else {
14883
- target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative3.path;
14883
+ target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative5.path;
14884
14884
  }
14885
14885
  target.path = removeDotSegments(target.path);
14886
14886
  }
14887
- target.query = relative3.query;
14887
+ target.query = relative5.query;
14888
14888
  }
14889
14889
  target.userinfo = base2.userinfo;
14890
14890
  target.host = base2.host;
@@ -14892,10 +14892,10 @@ var require_uri_all = __commonJS((exports, module) => {
14892
14892
  }
14893
14893
  target.scheme = base2.scheme;
14894
14894
  }
14895
- target.fragment = relative3.fragment;
14895
+ target.fragment = relative5.fragment;
14896
14896
  return target;
14897
14897
  }
14898
- function resolve10(baseURI, relativeURI, options2) {
14898
+ function resolve11(baseURI, relativeURI, options2) {
14899
14899
  var schemelessOptions = assign({ scheme: "null" }, options2);
14900
14900
  return serialize(resolveComponents(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
14901
14901
  }
@@ -15163,7 +15163,7 @@ var require_uri_all = __commonJS((exports, module) => {
15163
15163
  exports2.removeDotSegments = removeDotSegments;
15164
15164
  exports2.serialize = serialize;
15165
15165
  exports2.resolveComponents = resolveComponents;
15166
- exports2.resolve = resolve10;
15166
+ exports2.resolve = resolve11;
15167
15167
  exports2.normalize = normalize;
15168
15168
  exports2.equal = equal;
15169
15169
  exports2.escapeComponent = escapeComponent;
@@ -15526,13 +15526,13 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
15526
15526
 
15527
15527
  // node_modules/ajv/lib/compile/resolve.js
15528
15528
  var require_resolve = __commonJS((exports, module) => {
15529
- var resolve10 = function(compile, root, ref) {
15529
+ var resolve11 = function(compile, root, ref) {
15530
15530
  var refVal = this._refs[ref];
15531
15531
  if (typeof refVal == "string") {
15532
15532
  if (this._refs[refVal])
15533
15533
  refVal = this._refs[refVal];
15534
15534
  else
15535
- return resolve10.call(this, compile, root, refVal);
15535
+ return resolve11.call(this, compile, root, refVal);
15536
15536
  }
15537
15537
  refVal = refVal || this._schemas[ref];
15538
15538
  if (refVal instanceof SchemaObject) {
@@ -15737,13 +15737,13 @@ var require_resolve = __commonJS((exports, module) => {
15737
15737
  var util6 = require_util3();
15738
15738
  var SchemaObject = require_schema_obj();
15739
15739
  var traverse = require_json_schema_traverse();
15740
- module.exports = resolve10;
15741
- resolve10.normalizeId = normalizeId;
15742
- resolve10.fullPath = getFullPath;
15743
- resolve10.url = resolveUrl;
15744
- resolve10.ids = resolveIds;
15745
- resolve10.inlineRef = inlineRef;
15746
- resolve10.schema = resolveSchema;
15740
+ module.exports = resolve11;
15741
+ resolve11.normalizeId = normalizeId;
15742
+ resolve11.fullPath = getFullPath;
15743
+ resolve11.url = resolveUrl;
15744
+ resolve11.ids = resolveIds;
15745
+ resolve11.inlineRef = inlineRef;
15746
+ resolve11.schema = resolveSchema;
15747
15747
  var PREVENT_SCOPE_CHANGE = util6.toHash(["properties", "patternProperties", "enum", "dependencies", "definitions"]);
15748
15748
  var SIMPLE_INLINED = util6.toHash([
15749
15749
  "type",
@@ -15774,15 +15774,15 @@ var require_error_classes = __commonJS((exports, module) => {
15774
15774
  };
15775
15775
  var MissingRefError = function(baseId, ref, message) {
15776
15776
  this.message = message || MissingRefError.message(baseId, ref);
15777
- this.missingRef = resolve10.url(baseId, ref);
15778
- this.missingSchema = resolve10.normalizeId(resolve10.fullPath(this.missingRef));
15777
+ this.missingRef = resolve11.url(baseId, ref);
15778
+ this.missingSchema = resolve11.normalizeId(resolve11.fullPath(this.missingRef));
15779
15779
  };
15780
15780
  var errorSubclass = function(Subclass) {
15781
15781
  Subclass.prototype = Object.create(Error.prototype);
15782
15782
  Subclass.prototype.constructor = Subclass;
15783
15783
  return Subclass;
15784
15784
  };
15785
- var resolve10 = require_resolve();
15785
+ var resolve11 = require_resolve();
15786
15786
  module.exports = {
15787
15787
  Validation: errorSubclass(ValidationError),
15788
15788
  MissingRef: errorSubclass(MissingRefError)
@@ -16376,7 +16376,7 @@ var require_compile = __commonJS((exports, module) => {
16376
16376
  RULES,
16377
16377
  validate: validateGenerator,
16378
16378
  util: util6,
16379
- resolve: resolve10,
16379
+ resolve: resolve11,
16380
16380
  resolveRef,
16381
16381
  usePattern,
16382
16382
  useDefault,
@@ -16415,7 +16415,7 @@ var require_compile = __commonJS((exports, module) => {
16415
16415
  return validate2;
16416
16416
  }
16417
16417
  function resolveRef(baseId2, ref, isRoot) {
16418
- ref = resolve10.url(baseId2, ref);
16418
+ ref = resolve11.url(baseId2, ref);
16419
16419
  var refIndex = refs[ref];
16420
16420
  var _refVal, refCode;
16421
16421
  if (refIndex !== undefined) {
@@ -16432,11 +16432,11 @@ var require_compile = __commonJS((exports, module) => {
16432
16432
  }
16433
16433
  }
16434
16434
  refCode = addLocalRef(ref);
16435
- var v2 = resolve10.call(self, localCompile, root, ref);
16435
+ var v2 = resolve11.call(self, localCompile, root, ref);
16436
16436
  if (v2 === undefined) {
16437
16437
  var localSchema = localRefs && localRefs[ref];
16438
16438
  if (localSchema) {
16439
- v2 = resolve10.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId2);
16439
+ v2 = resolve11.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId2);
16440
16440
  }
16441
16441
  }
16442
16442
  if (v2 === undefined) {
@@ -16578,7 +16578,7 @@ var require_compile = __commonJS((exports, module) => {
16578
16578
  code += statement(i, arr);
16579
16579
  return code;
16580
16580
  };
16581
- var resolve10 = require_resolve();
16581
+ var resolve11 = require_resolve();
16582
16582
  var util6 = require_util3();
16583
16583
  var errorClasses = require_error_classes();
16584
16584
  var stableStringify = require_fast_json_stable_stringify();
@@ -19827,7 +19827,7 @@ var require_ajv = __commonJS((exports, module) => {
19827
19827
  var id = this._getId(schema2);
19828
19828
  if (id !== undefined && typeof id != "string")
19829
19829
  throw new Error("schema id must be string");
19830
- key = resolve10.normalizeId(key || id);
19830
+ key = resolve11.normalizeId(key || id);
19831
19831
  checkUnique(this, key);
19832
19832
  this._schemas[key] = this._addSchema(schema2, _skipValidation, _meta, true);
19833
19833
  return this;
@@ -19873,7 +19873,7 @@ var require_ajv = __commonJS((exports, module) => {
19873
19873
  }
19874
19874
  };
19875
19875
  var _getSchemaFragment = function(self, ref) {
19876
- var res = resolve10.schema.call(self, { schema: {} }, ref);
19876
+ var res = resolve11.schema.call(self, { schema: {} }, ref);
19877
19877
  if (res) {
19878
19878
  var { schema: schema2, root, baseId } = res;
19879
19879
  var v = compileSchema.call(self, schema2, root, undefined, baseId);
@@ -19889,7 +19889,7 @@ var require_ajv = __commonJS((exports, module) => {
19889
19889
  }
19890
19890
  };
19891
19891
  var _getSchemaObj = function(self, keyRef) {
19892
- keyRef = resolve10.normalizeId(keyRef);
19892
+ keyRef = resolve11.normalizeId(keyRef);
19893
19893
  return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
19894
19894
  };
19895
19895
  var removeSchema = function(schemaKeyRef) {
@@ -19917,7 +19917,7 @@ var require_ajv = __commonJS((exports, module) => {
19917
19917
  this._cache.del(cacheKey);
19918
19918
  var id = this._getId(schemaKeyRef);
19919
19919
  if (id) {
19920
- id = resolve10.normalizeId(id);
19920
+ id = resolve11.normalizeId(id);
19921
19921
  delete this._schemas[id];
19922
19922
  delete this._refs[id];
19923
19923
  }
@@ -19942,14 +19942,14 @@ var require_ajv = __commonJS((exports, module) => {
19942
19942
  if (cached)
19943
19943
  return cached;
19944
19944
  shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
19945
- var id = resolve10.normalizeId(this._getId(schema2));
19945
+ var id = resolve11.normalizeId(this._getId(schema2));
19946
19946
  if (id && shouldAddSchema)
19947
19947
  checkUnique(this, id);
19948
19948
  var willValidate = this._opts.validateSchema !== false && !skipValidation;
19949
19949
  var recursiveMeta;
19950
- if (willValidate && !(recursiveMeta = id && id == resolve10.normalizeId(schema2.$schema)))
19950
+ if (willValidate && !(recursiveMeta = id && id == resolve11.normalizeId(schema2.$schema)))
19951
19951
  this.validateSchema(schema2, true);
19952
- var localRefs = resolve10.ids.call(this, schema2);
19952
+ var localRefs = resolve11.ids.call(this, schema2);
19953
19953
  var schemaObj = new SchemaObject({
19954
19954
  id,
19955
19955
  schema: schema2,
@@ -20110,7 +20110,7 @@ var require_ajv = __commonJS((exports, module) => {
20110
20110
  var noop = function() {
20111
20111
  };
20112
20112
  var compileSchema = require_compile();
20113
- var resolve10 = require_resolve();
20113
+ var resolve11 = require_resolve();
20114
20114
  var Cache = require_cache();
20115
20115
  var SchemaObject = require_schema_obj();
20116
20116
  var stableStringify = require_fast_json_stable_stringify();
@@ -20171,27 +20171,27 @@ var require_windows = __commonJS((exports, module) => {
20171
20171
  return checkPathExt(path, options2);
20172
20172
  };
20173
20173
  var isexe = function(path, options2, cb) {
20174
- fs24.stat(path, function(er, stat) {
20174
+ fs25.stat(path, function(er, stat) {
20175
20175
  cb(er, er ? false : checkStat(stat, path, options2));
20176
20176
  });
20177
20177
  };
20178
20178
  var sync = function(path, options2) {
20179
- return checkStat(fs24.statSync(path), path, options2);
20179
+ return checkStat(fs25.statSync(path), path, options2);
20180
20180
  };
20181
20181
  module.exports = isexe;
20182
20182
  isexe.sync = sync;
20183
- var fs24 = __require("fs");
20183
+ var fs25 = __require("fs");
20184
20184
  });
20185
20185
 
20186
20186
  // node_modules/isexe/mode.js
20187
20187
  var require_mode = __commonJS((exports, module) => {
20188
20188
  var isexe = function(path, options2, cb) {
20189
- fs24.stat(path, function(er, stat) {
20189
+ fs25.stat(path, function(er, stat) {
20190
20190
  cb(er, er ? false : checkStat(stat, options2));
20191
20191
  });
20192
20192
  };
20193
20193
  var sync = function(path, options2) {
20194
- return checkStat(fs24.statSync(path), options2);
20194
+ return checkStat(fs25.statSync(path), options2);
20195
20195
  };
20196
20196
  var checkStat = function(stat, options2) {
20197
20197
  return stat.isFile() && checkMode(stat, options2);
@@ -20211,7 +20211,7 @@ var require_mode = __commonJS((exports, module) => {
20211
20211
  };
20212
20212
  module.exports = isexe;
20213
20213
  isexe.sync = sync;
20214
- var fs24 = __require("fs");
20214
+ var fs25 = __require("fs");
20215
20215
  });
20216
20216
 
20217
20217
  // node_modules/isexe/index.js
@@ -20225,12 +20225,12 @@ var require_isexe = __commonJS((exports, module) => {
20225
20225
  if (typeof Promise !== "function") {
20226
20226
  throw new TypeError("callback not provided");
20227
20227
  }
20228
- return new Promise(function(resolve10, reject) {
20228
+ return new Promise(function(resolve11, reject) {
20229
20229
  isexe(path, options2 || {}, function(er, is) {
20230
20230
  if (er) {
20231
20231
  reject(er);
20232
20232
  } else {
20233
- resolve10(is);
20233
+ resolve11(is);
20234
20234
  }
20235
20235
  });
20236
20236
  });
@@ -20256,7 +20256,7 @@ var require_isexe = __commonJS((exports, module) => {
20256
20256
  }
20257
20257
  }
20258
20258
  };
20259
- var fs24 = __require("fs");
20259
+ var fs25 = __require("fs");
20260
20260
  var core2;
20261
20261
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
20262
20262
  core2 = require_windows();
@@ -20301,27 +20301,27 @@ var require_which = __commonJS((exports, module) => {
20301
20301
  opt = {};
20302
20302
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
20303
20303
  const found = [];
20304
- const step = (i) => new Promise((resolve10, reject) => {
20304
+ const step = (i) => new Promise((resolve11, reject) => {
20305
20305
  if (i === pathEnv.length)
20306
- return opt.all && found.length ? resolve10(found) : reject(getNotFoundError(cmd));
20306
+ return opt.all && found.length ? resolve11(found) : reject(getNotFoundError(cmd));
20307
20307
  const ppRaw = pathEnv[i];
20308
20308
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
20309
20309
  const pCmd = path.join(pathPart, cmd);
20310
20310
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
20311
- resolve10(subStep(p, i, 0));
20311
+ resolve11(subStep(p, i, 0));
20312
20312
  });
20313
- const subStep = (p, i, ii) => new Promise((resolve10, reject) => {
20313
+ const subStep = (p, i, ii) => new Promise((resolve11, reject) => {
20314
20314
  if (ii === pathExt.length)
20315
- return resolve10(step(i + 1));
20315
+ return resolve11(step(i + 1));
20316
20316
  const ext = pathExt[ii];
20317
20317
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
20318
20318
  if (!er && is) {
20319
20319
  if (opt.all)
20320
20320
  found.push(p + ext);
20321
20321
  else
20322
- return resolve10(p + ext);
20322
+ return resolve11(p + ext);
20323
20323
  }
20324
- return resolve10(subStep(p, i, ii + 1));
20324
+ return resolve11(subStep(p, i, ii + 1));
20325
20325
  });
20326
20326
  });
20327
20327
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -20363,8 +20363,8 @@ var require_which = __commonJS((exports, module) => {
20363
20363
  var require_path_key = __commonJS((exports, module) => {
20364
20364
  var pathKey = (options2 = {}) => {
20365
20365
  const environment = options2.env || process.env;
20366
- const platform = options2.platform || process.platform;
20367
- if (platform !== "win32") {
20366
+ const platform2 = options2.platform || process.platform;
20367
+ if (platform2 !== "win32") {
20368
20368
  return "PATH";
20369
20369
  }
20370
20370
  return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
@@ -20463,14 +20463,14 @@ var require_readShebang = __commonJS((exports, module) => {
20463
20463
  const buffer = Buffer.alloc(size);
20464
20464
  let fd;
20465
20465
  try {
20466
- fd = fs24.openSync(command, "r");
20467
- fs24.readSync(fd, buffer, 0, size, 0);
20468
- fs24.closeSync(fd);
20466
+ fd = fs25.openSync(command, "r");
20467
+ fs25.readSync(fd, buffer, 0, size, 0);
20468
+ fs25.closeSync(fd);
20469
20469
  } catch (e) {
20470
20470
  }
20471
20471
  return shebangCommand(buffer.toString());
20472
20472
  };
20473
- var fs24 = __require("fs");
20473
+ var fs25 = __require("fs");
20474
20474
  var shebangCommand = require_shebang_command();
20475
20475
  module.exports = readShebang;
20476
20476
  });
@@ -21911,13 +21911,13 @@ var init_screen_manager = __esm(() => {
21911
21911
  // node_modules/@inquirer/core/dist/lib/promise-polyfill.js
21912
21912
  class PromisePolyfill extends Promise {
21913
21913
  static withResolver() {
21914
- let resolve11;
21914
+ let resolve12;
21915
21915
  let reject;
21916
21916
  const promise = new Promise((res, rej) => {
21917
- resolve11 = res;
21917
+ resolve12 = res;
21918
21918
  reject = rej;
21919
21919
  });
21920
- return { promise, resolve: resolve11, reject };
21920
+ return { promise, resolve: resolve12, reject };
21921
21921
  }
21922
21922
  }
21923
21923
  var init_promise_polyfill = __esm(() => {
@@ -21940,7 +21940,7 @@ function createPrompt(view) {
21940
21940
  output
21941
21941
  });
21942
21942
  const screen = new ScreenManager(rl);
21943
- const { promise, resolve: resolve11, reject } = PromisePolyfill.withResolver();
21943
+ const { promise, resolve: resolve12, reject } = PromisePolyfill.withResolver();
21944
21944
  const cancel = () => reject(new CancelPromptError);
21945
21945
  if (signal) {
21946
21946
  const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
@@ -21968,7 +21968,7 @@ function createPrompt(view) {
21968
21968
  cycle(() => {
21969
21969
  try {
21970
21970
  const nextView = view(config, (value) => {
21971
- setImmediate(() => resolve11(value));
21971
+ setImmediate(() => resolve12(value));
21972
21972
  });
21973
21973
  if (nextView === undefined) {
21974
21974
  const callerFilename = callSites[1]?.getFileName();
@@ -27848,26 +27848,26 @@ var require_lib3 = __commonJS((exports) => {
27848
27848
  return matches;
27849
27849
  };
27850
27850
  exports.analyse = analyse;
27851
- var detectFile = (filepath, opts = {}) => new Promise((resolve11, reject) => {
27851
+ var detectFile = (filepath, opts = {}) => new Promise((resolve12, reject) => {
27852
27852
  let fd;
27853
- const fs30 = (0, node_1.default)();
27853
+ const fs31 = (0, node_1.default)();
27854
27854
  const handler = (err, buffer) => {
27855
27855
  if (fd) {
27856
- fs30.closeSync(fd);
27856
+ fs31.closeSync(fd);
27857
27857
  }
27858
27858
  if (err) {
27859
27859
  reject(err);
27860
27860
  } else if (buffer) {
27861
- resolve11((0, exports.detect)(buffer));
27861
+ resolve12((0, exports.detect)(buffer));
27862
27862
  } else {
27863
27863
  reject(new Error("No error and no buffer received"));
27864
27864
  }
27865
27865
  };
27866
27866
  const sampleSize = (opts === null || opts === undefined ? undefined : opts.sampleSize) || 0;
27867
27867
  if (sampleSize > 0) {
27868
- fd = fs30.openSync(filepath, "r");
27868
+ fd = fs31.openSync(filepath, "r");
27869
27869
  let sample = Buffer.allocUnsafe(sampleSize);
27870
- fs30.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
27870
+ fs31.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
27871
27871
  if (err) {
27872
27872
  handler(err, null);
27873
27873
  } else {
@@ -27879,22 +27879,22 @@ var require_lib3 = __commonJS((exports) => {
27879
27879
  });
27880
27880
  return;
27881
27881
  }
27882
- fs30.readFile(filepath, handler);
27882
+ fs31.readFile(filepath, handler);
27883
27883
  });
27884
27884
  exports.detectFile = detectFile;
27885
27885
  var detectFileSync = (filepath, opts = {}) => {
27886
- const fs30 = (0, node_1.default)();
27886
+ const fs31 = (0, node_1.default)();
27887
27887
  if (opts && opts.sampleSize) {
27888
- const fd = fs30.openSync(filepath, "r");
27888
+ const fd = fs31.openSync(filepath, "r");
27889
27889
  let sample = Buffer.allocUnsafe(opts.sampleSize);
27890
- const bytesRead = fs30.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
27890
+ const bytesRead = fs31.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
27891
27891
  if (bytesRead < opts.sampleSize) {
27892
27892
  sample = sample.subarray(0, bytesRead);
27893
27893
  }
27894
- fs30.closeSync(fd);
27894
+ fs31.closeSync(fd);
27895
27895
  return (0, exports.detect)(sample);
27896
27896
  }
27897
- return (0, exports.detect)(fs30.readFileSync(filepath));
27897
+ return (0, exports.detect)(fs31.readFileSync(filepath));
27898
27898
  };
27899
27899
  exports.detectFileSync = detectFileSync;
27900
27900
  exports.default = {
@@ -32807,7 +32807,7 @@ var {
32807
32807
  } = import_.default;
32808
32808
 
32809
32809
  // dist/commands/init.js
32810
- import {resolve as resolve3} from "path";
32810
+ import {resolve as resolve4} from "path";
32811
32811
 
32812
32812
  // node_modules/ora/index.js
32813
32813
  import process9 from "node:process";
@@ -33983,7 +33983,8 @@ var logger = Logger.getInstance();
33983
33983
 
33984
33984
  // dist/utils/fs.js
33985
33985
  import {promises as fs} from "fs";
33986
- import {join, dirname} from "path";
33986
+ import {platform} from "os";
33987
+ import {join, dirname, basename, resolve, relative} from "path";
33987
33988
  async function fileExists(path) {
33988
33989
  try {
33989
33990
  await fs.access(path);
@@ -34064,9 +34065,85 @@ async function ensureDirectoryExists(filePath) {
34064
34065
  const dir = dirname(filePath);
34065
34066
  await fs.mkdir(dir, { recursive: true });
34066
34067
  }
34068
+ async function readSymlinkTarget(path) {
34069
+ try {
34070
+ return await fs.readlink(path);
34071
+ } catch {
34072
+ return null;
34073
+ }
34074
+ }
34075
+ async function resolveRealPathOrSelf(path) {
34076
+ const resolvedPath = resolve(path);
34077
+ try {
34078
+ return await fs.realpath(resolvedPath);
34079
+ } catch {
34080
+ return resolvedPath;
34081
+ }
34082
+ }
34083
+ async function resolveParentSymlinks(path) {
34084
+ const resolvedPath = resolve(path);
34085
+ const parentDir = dirname(resolvedPath);
34086
+ const baseName = basename(resolvedPath);
34087
+ try {
34088
+ const realParent = await fs.realpath(parentDir);
34089
+ return join(realParent, baseName);
34090
+ } catch {
34091
+ return resolvedPath;
34092
+ }
34093
+ }
34094
+ async function pathsReferToSameLocation(left, right) {
34095
+ const [realLeft, realRight] = await Promise.all([
34096
+ resolveRealPathOrSelf(left),
34097
+ resolveRealPathOrSelf(right)
34098
+ ]);
34099
+ if (realLeft === realRight) {
34100
+ return true;
34101
+ }
34102
+ const [leftWithResolvedParents, rightWithResolvedParents] = await Promise.all([
34103
+ resolveParentSymlinks(left),
34104
+ resolveParentSymlinks(right)
34105
+ ]);
34106
+ return leftWithResolvedParents === rightWithResolvedParents;
34107
+ }
34108
+ async function createRelativeSymlink(target, linkPath) {
34109
+ try {
34110
+ const resolvedTarget = resolve(target);
34111
+ const resolvedLinkPath = resolve(linkPath);
34112
+ if (await pathsReferToSameLocation(resolvedTarget, resolvedLinkPath)) {
34113
+ return true;
34114
+ }
34115
+ try {
34116
+ const stats = await fs.lstat(resolvedLinkPath);
34117
+ if (stats.isSymbolicLink()) {
34118
+ const existingTarget = await fs.readlink(resolvedLinkPath);
34119
+ const resolvedExistingTarget = resolve(dirname(resolvedLinkPath), existingTarget);
34120
+ if (resolvedExistingTarget === resolvedTarget) {
34121
+ return true;
34122
+ }
34123
+ await fs.rm(resolvedLinkPath, { force: true });
34124
+ } else {
34125
+ await fs.rm(resolvedLinkPath, { recursive: true, force: true });
34126
+ }
34127
+ } catch (error) {
34128
+ if (error && typeof error === "object" && "code" in error && error.code === "ELOOP") {
34129
+ await fs.rm(resolvedLinkPath, { force: true }).catch(() => {
34130
+ });
34131
+ }
34132
+ }
34133
+ await fs.mkdir(dirname(resolvedLinkPath), { recursive: true });
34134
+ const realLinkDir = await resolveParentSymlinks(dirname(resolvedLinkPath));
34135
+ const realTarget = await resolveRealPathOrSelf(resolvedTarget);
34136
+ const relativeTarget = relative(realLinkDir, realTarget);
34137
+ const symlinkType = platform() === "win32" ? "junction" : undefined;
34138
+ await fs.symlink(relativeTarget, resolvedLinkPath, symlinkType);
34139
+ return true;
34140
+ } catch {
34141
+ return false;
34142
+ }
34143
+ }
34067
34144
 
34068
34145
  // dist/core/agentDetector.js
34069
- import {resolve} from "path";
34146
+ import {resolve as resolve2} from "path";
34070
34147
  class AgentDetector {
34071
34148
  agentConfigs = [
34072
34149
  { name: "cursor", files: [".cursorrules", ".cursor/settings.json"] },
@@ -34096,7 +34173,7 @@ class AgentDetector {
34096
34173
  }
34097
34174
  async checkAgentFiles(projectPath, files) {
34098
34175
  for (const file of files) {
34099
- const fullPath = resolve(projectPath, file);
34176
+ const fullPath = resolve2(projectPath, file);
34100
34177
  if (await fileExists(fullPath)) {
34101
34178
  return { found: true, path: fullPath };
34102
34179
  }
@@ -34121,7 +34198,7 @@ class AgentDetector {
34121
34198
  }
34122
34199
 
34123
34200
  // dist/core/stackDetector.js
34124
- import {resolve as resolve2} from "path";
34201
+ import {resolve as resolve3} from "path";
34125
34202
  class StackDetector {
34126
34203
  lockFiles = [
34127
34204
  "package-lock.json",
@@ -34166,7 +34243,7 @@ class StackDetector {
34166
34243
  }
34167
34244
  async detectFromLockFiles(projectPath) {
34168
34245
  for (const lockFile of this.lockFiles) {
34169
- const lockPath = resolve2(projectPath, lockFile);
34246
+ const lockPath = resolve3(projectPath, lockFile);
34170
34247
  if (await fileExists(lockPath)) {
34171
34248
  return this.inferStackFromLockFile(projectPath, lockFile);
34172
34249
  }
@@ -34198,7 +34275,7 @@ class StackDetector {
34198
34275
  }
34199
34276
  async detectFromManifests(projectPath) {
34200
34277
  for (const manifest of this.manifestFiles) {
34201
- const manifestPath = resolve2(projectPath, manifest);
34278
+ const manifestPath = resolve3(projectPath, manifest);
34202
34279
  if (await fileExists(manifestPath)) {
34203
34280
  return this.inferStackFromManifest(projectPath, manifest);
34204
34281
  }
@@ -34230,7 +34307,7 @@ class StackDetector {
34230
34307
  }
34231
34308
  async detectFromConfigs(projectPath) {
34232
34309
  for (const config of this.configFiles) {
34233
- const configPath = resolve2(projectPath, config);
34310
+ const configPath = resolve3(projectPath, config);
34234
34311
  if (await fileExists(configPath)) {
34235
34312
  return this.inferStackFromConfig(projectPath, config);
34236
34313
  }
@@ -34289,7 +34366,7 @@ class StackDetector {
34289
34366
  };
34290
34367
  }
34291
34368
  async analyzeJavaScriptProject(projectPath) {
34292
- const packageJsonPath = resolve2(projectPath, "package.json");
34369
+ const packageJsonPath = resolve3(projectPath, "package.json");
34293
34370
  const packageJsonContent = await readFileIfExists(packageJsonPath);
34294
34371
  const info = {
34295
34372
  language: "javascript",
@@ -34304,7 +34381,7 @@ class StackDetector {
34304
34381
  ...packageJson.devDependencies
34305
34382
  };
34306
34383
  info.dependencies = Object.keys(allDeps);
34307
- if (allDeps.typescript || await fileExists(resolve2(projectPath, "tsconfig.json"))) {
34384
+ if (allDeps.typescript || await fileExists(resolve3(projectPath, "tsconfig.json"))) {
34308
34385
  info.language = "typescript";
34309
34386
  }
34310
34387
  if (allDeps.next)
@@ -34321,11 +34398,11 @@ class StackDetector {
34321
34398
  info.framework = "express";
34322
34399
  else if (allDeps.fastify)
34323
34400
  info.framework = "fastify";
34324
- if (await fileExists(resolve2(projectPath, "yarn.lock")))
34401
+ if (await fileExists(resolve3(projectPath, "yarn.lock")))
34325
34402
  info.packageManager = "yarn";
34326
- else if (await fileExists(resolve2(projectPath, "pnpm-lock.yaml")))
34403
+ else if (await fileExists(resolve3(projectPath, "pnpm-lock.yaml")))
34327
34404
  info.packageManager = "pnpm";
34328
- else if (await fileExists(resolve2(projectPath, "bun.lockb")))
34405
+ else if (await fileExists(resolve3(projectPath, "bun.lockb")))
34329
34406
  info.packageManager = "bun";
34330
34407
  else
34331
34408
  info.packageManager = "npm";
@@ -34604,7 +34681,7 @@ This is a {{STACK}} project{{FRAMEWORK_CONTEXT}}. The codebase follows modern de
34604
34681
  // dist/commands/init.js
34605
34682
  async function initCommand(options2) {
34606
34683
  const cwd = process.cwd();
34607
- const agentsPath = resolve3(cwd, "agents.md");
34684
+ const agentsPath = resolve4(cwd, "agents.md");
34608
34685
  logger.title("\uD83D\uDE80 AgentInit - Initialize Project");
34609
34686
  if (!options2.force && await fileExists(agentsPath)) {
34610
34687
  const response = await import_prompts.default({
@@ -34682,7 +34759,7 @@ async function initCommand(options2) {
34682
34759
  }
34683
34760
  var getProjectName = function(cwd) {
34684
34761
  try {
34685
- const packageJsonPath = resolve3(cwd, "package.json");
34762
+ const packageJsonPath = resolve4(cwd, "package.json");
34686
34763
  const packageJson = __require(packageJsonPath);
34687
34764
  return packageJson.name || cwd.split("/").pop() || "project";
34688
34765
  } catch {
@@ -34692,18 +34769,18 @@ var getProjectName = function(cwd) {
34692
34769
 
34693
34770
  // dist/core/skillsManager.js
34694
34771
  var import_gray_matter = __toESM(require_gray_matter(), 1);
34695
- import {resolve as resolve6, join as join3, relative} from "path";
34772
+ import {resolve as resolve7, join as join3, relative as relative2} from "path";
34696
34773
  import {promises as fs18} from "fs";
34697
- import {tmpdir} from "os";
34774
+ import {homedir as homedir3, tmpdir} from "os";
34698
34775
  import {execFile} from "child_process";
34699
34776
  import {promisify} from "util";
34700
34777
 
34701
34778
  // dist/agents/Agent.js
34702
- import {resolve as resolve5} from "path";
34779
+ import {resolve as resolve6} from "path";
34703
34780
  import {homedir as homedir2} from "os";
34704
34781
 
34705
34782
  // dist/utils/paths.js
34706
- import {resolve as resolve4, join as join2} from "path";
34783
+ import {resolve as resolve5, join as join2} from "path";
34707
34784
  import {homedir} from "os";
34708
34785
  function getHomeDirectory() {
34709
34786
  return homedir();
@@ -34737,8 +34814,8 @@ function resolveGlobalConfigPath(globalConfigPath, globalConfigPaths) {
34737
34814
  return expandTilde(globalConfigPath);
34738
34815
  }
34739
34816
  if (globalConfigPaths) {
34740
- const platform = getPlatform();
34741
- const platformPath = globalConfigPaths[platform];
34817
+ const platform2 = getPlatform();
34818
+ const platformPath = globalConfigPaths[platform2];
34742
34819
  if (platformPath) {
34743
34820
  return expandTilde(platformPath);
34744
34821
  }
@@ -34765,7 +34842,7 @@ function getFullGlobalConfigPath(globalConfigPath, globalConfigPaths) {
34765
34842
  return null;
34766
34843
  }
34767
34844
  const resolvedPath = resolveEnvironmentVariables(path);
34768
- return resolve4(resolvedPath);
34845
+ return resolve5(resolvedPath);
34769
34846
  }
34770
34847
 
34771
34848
  // node_modules/contextcalc/dist/lib/index.js
@@ -35198,7 +35275,7 @@ class Agent {
35198
35275
  }
35199
35276
  async detectPresence(projectPath) {
35200
35277
  for (const configFile of this.configFiles) {
35201
- const fullPath = resolve5(projectPath, configFile.path);
35278
+ const fullPath = resolve6(projectPath, configFile.path);
35202
35279
  if (await pathExists(fullPath, configFile.type)) {
35203
35280
  return {
35204
35281
  agent: this,
@@ -35209,7 +35286,7 @@ class Agent {
35209
35286
  return null;
35210
35287
  }
35211
35288
  getNativeMcpPath(projectPath) {
35212
- return resolve5(projectPath, this.nativeConfigPath);
35289
+ return resolve6(projectPath, this.nativeConfigPath);
35213
35290
  }
35214
35291
  getGlobalMcpPath() {
35215
35292
  return getFullGlobalConfigPath(this.definition.globalConfigPath, this.definition.globalConfigPaths);
@@ -35218,7 +35295,7 @@ class Agent {
35218
35295
  if (!this.capabilities.rules || !this.definition.rulesPath) {
35219
35296
  return null;
35220
35297
  }
35221
- return resolve5(projectPath, this.definition.rulesPath);
35298
+ return resolve6(projectPath, this.definition.rulesPath);
35222
35299
  }
35223
35300
  getGlobalRulesPath() {
35224
35301
  if (!this.capabilities.rules) {
@@ -35278,7 +35355,20 @@ class Agent {
35278
35355
  if (global3) {
35279
35356
  return this.definition.skillPaths.global.replace("~", homedir2());
35280
35357
  }
35281
- return resolve5(projectPath, this.definition.skillPaths.project);
35358
+ return resolve6(projectPath, this.definition.skillPaths.project);
35359
+ }
35360
+ getProjectRulesStandard() {
35361
+ return this.definition.projectStandards?.rules || null;
35362
+ }
35363
+ getProjectSkillsStandard() {
35364
+ return this.definition.projectStandards?.skills || null;
35365
+ }
35366
+ supportsProjectMcpConfig() {
35367
+ const supportsAnyMcp = Object.values(this.capabilities.mcp).some(Boolean);
35368
+ if (!supportsAnyMcp) {
35369
+ return false;
35370
+ }
35371
+ return this.definition.mcpConfigScope !== "global-only";
35282
35372
  }
35283
35373
  supportsGlobalRules() {
35284
35374
  return this.getGlobalRulesPath() !== null;
@@ -35383,6 +35473,10 @@ class ClaudeAgent extends Agent {
35383
35473
  skillPaths: {
35384
35474
  project: ".claude/skills/",
35385
35475
  global: "~/.claude/skills/"
35476
+ },
35477
+ projectStandards: {
35478
+ rules: "claude",
35479
+ skills: "claude"
35386
35480
  }
35387
35481
  };
35388
35482
  super(definition);
@@ -35578,7 +35672,11 @@ class ClaudeDesktopAgent extends Agent {
35578
35672
  skillPaths: {
35579
35673
  project: ".claude/skills/",
35580
35674
  global: "~/.claude/skills/"
35581
- }
35675
+ },
35676
+ projectStandards: {
35677
+ skills: "claude"
35678
+ },
35679
+ mcpConfigScope: "global-only"
35582
35680
  };
35583
35681
  super(definition);
35584
35682
  }
@@ -35712,8 +35810,12 @@ class CodexCliAgent extends Agent {
35712
35810
  rulesPath: ".codex/config.toml",
35713
35811
  globalRulesPath: "~/.codex/config.toml",
35714
35812
  skillPaths: {
35715
- project: ".codex/skills/",
35813
+ project: ".agents/skills/",
35716
35814
  global: "~/.codex/skills/"
35815
+ },
35816
+ projectStandards: {
35817
+ rules: "agents",
35818
+ skills: "agents"
35717
35819
  }
35718
35820
  };
35719
35821
  super(definition);
@@ -35945,8 +36047,11 @@ class GeminiCliAgent extends Agent {
35945
36047
  rulesPath: ".gemini/settings.json",
35946
36048
  globalRulesPath: "~/.gemini/settings.json",
35947
36049
  skillPaths: {
35948
- project: ".gemini/skills/",
36050
+ project: ".agents/skills/",
35949
36051
  global: "~/.gemini/skills/"
36052
+ },
36053
+ projectStandards: {
36054
+ skills: "agents"
35950
36055
  }
35951
36056
  };
35952
36057
  super(definition);
@@ -36150,8 +36255,12 @@ class CursorAgent extends Agent {
36150
36255
  globalConfigPath: "~/.cursor/mcp.json",
36151
36256
  rulesPath: ".cursorrules",
36152
36257
  skillPaths: {
36153
- project: ".cursor/skills/",
36258
+ project: ".agents/skills/",
36154
36259
  global: "~/.cursor/skills/"
36260
+ },
36261
+ projectStandards: {
36262
+ rules: "agents",
36263
+ skills: "agents"
36155
36264
  }
36156
36265
  };
36157
36266
  super(definition);
@@ -36303,9 +36412,14 @@ class DroidAgent extends Agent {
36303
36412
  globalConfigPath: "~/.factory/mcp.json",
36304
36413
  rulesPath: "AGENTS.md",
36305
36414
  skillPaths: {
36306
- project: ".factory/skills/",
36415
+ project: ".agents/skills/",
36307
36416
  global: "~/.factory/skills/"
36308
- }
36417
+ },
36418
+ projectStandards: {
36419
+ rules: "agents",
36420
+ skills: "agents"
36421
+ },
36422
+ mcpConfigScope: "global-only"
36309
36423
  };
36310
36424
  super(definition);
36311
36425
  }
@@ -36547,8 +36661,12 @@ class CopilotAgent extends MarkdownRulesAgent {
36547
36661
  nativeConfigPath: ".vscode/mcp.json",
36548
36662
  rulesPath: "AGENTS.md",
36549
36663
  skillPaths: {
36550
- project: ".claude/skills/",
36551
- global: "~/.claude/skills/"
36664
+ project: ".agents/skills/",
36665
+ global: "~/.copilot/skills/"
36666
+ },
36667
+ projectStandards: {
36668
+ rules: "agents",
36669
+ skills: "agents"
36552
36670
  }
36553
36671
  };
36554
36672
  super(definition);
@@ -36680,7 +36798,10 @@ class AiderAgent extends MarkdownRulesAgent {
36680
36798
  }
36681
36799
  ],
36682
36800
  nativeConfigPath: ".mcp.json",
36683
- rulesPath: "AGENTS.md"
36801
+ rulesPath: "AGENTS.md",
36802
+ projectStandards: {
36803
+ rules: "agents"
36804
+ }
36684
36805
  };
36685
36806
  super(definition);
36686
36807
  }
@@ -36970,8 +37091,12 @@ class RooCodeAgent extends MarkdownRulesAgent {
36970
37091
  nativeConfigPath: ".roo/mcp.json",
36971
37092
  rulesPath: "AGENTS.md",
36972
37093
  skillPaths: {
36973
- project: ".roo/skills/",
37094
+ project: ".agents/skills/",
36974
37095
  global: "~/.roo/skills/"
37096
+ },
37097
+ projectStandards: {
37098
+ rules: "agents",
37099
+ skills: "agents"
36975
37100
  }
36976
37101
  };
36977
37102
  super(definition);
@@ -37095,7 +37220,10 @@ class ZedAgent extends MarkdownRulesAgent {
37095
37220
  }
37096
37221
  ],
37097
37222
  nativeConfigPath: ".zed/settings.json",
37098
- rulesPath: "AGENTS.md"
37223
+ rulesPath: "AGENTS.md",
37224
+ projectStandards: {
37225
+ rules: "agents"
37226
+ }
37099
37227
  };
37100
37228
  super(definition);
37101
37229
  }
@@ -37319,7 +37447,7 @@ class SkillsManager {
37319
37447
  const skills = [];
37320
37448
  const seen = new Set;
37321
37449
  for (const searchDir of SKILL_SEARCH_DIRS) {
37322
- const fullDir = resolve6(repoPath, searchDir);
37450
+ const fullDir = resolve7(repoPath, searchDir);
37323
37451
  if (!await fileExists(fullDir))
37324
37452
  continue;
37325
37453
  const directSkillMd = join3(fullDir, "SKILL.md");
@@ -37327,7 +37455,7 @@ class SkillsManager {
37327
37455
  const parsed = await this.parseSkillMd(directSkillMd);
37328
37456
  if (parsed && !seen.has(parsed.name)) {
37329
37457
  seen.add(parsed.name);
37330
- skills.push({ ...parsed, path: resolve6(fullDir) });
37458
+ skills.push({ ...parsed, path: resolve7(fullDir) });
37331
37459
  }
37332
37460
  }
37333
37461
  const directSkillMdLower = join3(fullDir, "skill.md");
@@ -37335,7 +37463,7 @@ class SkillsManager {
37335
37463
  const parsed = await this.parseSkillMd(directSkillMdLower);
37336
37464
  if (parsed && !seen.has(parsed.name)) {
37337
37465
  seen.add(parsed.name);
37338
- skills.push({ ...parsed, path: resolve6(fullDir) });
37466
+ skills.push({ ...parsed, path: resolve7(fullDir) });
37339
37467
  }
37340
37468
  }
37341
37469
  if (!await isDirectory(fullDir))
@@ -37389,7 +37517,7 @@ class SkillsManager {
37389
37517
  async installSkill(skillPath, skillName, targetDir, copy = false) {
37390
37518
  const normalizedSkillName = this.normalizeSkillName(skillName);
37391
37519
  const destPath = this.resolveInstallPath(targetDir, normalizedSkillName);
37392
- await fs18.mkdir(resolve6(targetDir), { recursive: true });
37520
+ await fs18.mkdir(resolve7(targetDir), { recursive: true });
37393
37521
  if (await fileExists(destPath)) {
37394
37522
  await fs18.rm(destPath, { recursive: true, force: true });
37395
37523
  }
@@ -37403,7 +37531,7 @@ class SkillsManager {
37403
37531
  async installSkillFromContent(skillName, skillContent, targetDir) {
37404
37532
  const normalizedSkillName = this.normalizeSkillName(skillName);
37405
37533
  const destPath = this.resolveInstallPath(targetDir, normalizedSkillName);
37406
- await fs18.mkdir(resolve6(targetDir), { recursive: true });
37534
+ await fs18.mkdir(resolve7(targetDir), { recursive: true });
37407
37535
  if (await fileExists(destPath)) {
37408
37536
  await fs18.rm(destPath, { recursive: true, force: true });
37409
37537
  }
@@ -37411,6 +37539,95 @@ class SkillsManager {
37411
37539
  await fs18.writeFile(join3(destPath, "SKILL.md"), skillContent, "utf8");
37412
37540
  return destPath;
37413
37541
  }
37542
+ getCanonicalSkillsDir(projectPath, global3 = false) {
37543
+ return global3 ? resolve7(homedir3(), ".agents/skills") : resolve7(projectPath, ".agents/skills");
37544
+ }
37545
+ async getInstallPlan(skillName, agent, projectPath, options2 = {}) {
37546
+ const normalizedSkillName = this.normalizeSkillName(skillName);
37547
+ const skillsDir = agent.getSkillsDir(projectPath, options2.global);
37548
+ if (!skillsDir) {
37549
+ throw new Error(`No skills directory for ${agent.name}`);
37550
+ }
37551
+ const agentPath = this.resolveInstallPath(skillsDir, normalizedSkillName);
37552
+ if (options2.copy) {
37553
+ return {
37554
+ path: agentPath,
37555
+ mode: "copy"
37556
+ };
37557
+ }
37558
+ const canonicalPath = this.resolveInstallPath(this.getCanonicalSkillsDir(projectPath, options2.global ?? false), normalizedSkillName);
37559
+ if (await pathsReferToSameLocation(canonicalPath, agentPath)) {
37560
+ return {
37561
+ path: canonicalPath,
37562
+ canonicalPath,
37563
+ mode: "symlink"
37564
+ };
37565
+ }
37566
+ return {
37567
+ path: agentPath,
37568
+ canonicalPath,
37569
+ mode: "symlink"
37570
+ };
37571
+ }
37572
+ async installSkillForAgent(skillPath, skillName, agent, projectPath, options2 = {}) {
37573
+ const plan = await this.getInstallPlan(skillName, agent, projectPath, options2);
37574
+ const skillsDir = agent.getSkillsDir(projectPath, options2.global);
37575
+ if (!skillsDir) {
37576
+ throw new Error(`No skills directory for ${agent.name}`);
37577
+ }
37578
+ if (plan.mode === "copy") {
37579
+ await this.installSkill(skillPath, skillName, skillsDir, true);
37580
+ return plan;
37581
+ }
37582
+ const canonicalPath = plan.canonicalPath;
37583
+ if (!canonicalPath) {
37584
+ throw new Error(`Missing canonical path for ${skillName}`);
37585
+ }
37586
+ await this.cleanAndCreateDirectory(canonicalPath);
37587
+ await this.copyDir(skillPath, canonicalPath);
37588
+ if (plan.path === canonicalPath) {
37589
+ return plan;
37590
+ }
37591
+ const symlinkCreated = await createRelativeSymlink(canonicalPath, plan.path);
37592
+ if (!symlinkCreated) {
37593
+ await this.cleanAndCreateDirectory(plan.path);
37594
+ await this.copyDir(skillPath, plan.path);
37595
+ return {
37596
+ ...plan,
37597
+ symlinkFailed: true
37598
+ };
37599
+ }
37600
+ return plan;
37601
+ }
37602
+ async installSkillFromContentForAgent(skillName, skillContent, agent, projectPath, options2 = {}) {
37603
+ const plan = await this.getInstallPlan(skillName, agent, projectPath, options2);
37604
+ const skillsDir = agent.getSkillsDir(projectPath, options2.global);
37605
+ if (!skillsDir) {
37606
+ throw new Error(`No skills directory for ${agent.name}`);
37607
+ }
37608
+ if (plan.mode === "copy") {
37609
+ await this.installSkillFromContent(skillName, skillContent, skillsDir);
37610
+ return plan;
37611
+ }
37612
+ const canonicalPath = plan.canonicalPath;
37613
+ if (!canonicalPath) {
37614
+ throw new Error(`Missing canonical path for ${skillName}`);
37615
+ }
37616
+ await this.cleanAndCreateDirectory(canonicalPath);
37617
+ await fs18.writeFile(join3(canonicalPath, "SKILL.md"), skillContent, "utf8");
37618
+ if (plan.path === canonicalPath) {
37619
+ return plan;
37620
+ }
37621
+ const symlinkCreated = await createRelativeSymlink(canonicalPath, plan.path);
37622
+ if (!symlinkCreated) {
37623
+ await this.installSkillFromContent(skillName, skillContent, skillsDir);
37624
+ return {
37625
+ ...plan,
37626
+ symlinkFailed: true
37627
+ };
37628
+ }
37629
+ return plan;
37630
+ }
37414
37631
  normalizeSkillName(skillName) {
37415
37632
  const normalized = skillName.trim();
37416
37633
  if (!normalized) {
@@ -37422,9 +37639,9 @@ class SkillsManager {
37422
37639
  return normalized;
37423
37640
  }
37424
37641
  resolveInstallPath(targetDir, skillName) {
37425
- const resolvedTargetDir = resolve6(targetDir);
37426
- const destPath = resolve6(resolvedTargetDir, skillName);
37427
- const relativePath = relative(resolvedTargetDir, destPath);
37642
+ const resolvedTargetDir = resolve7(targetDir);
37643
+ const destPath = resolve7(resolvedTargetDir, skillName);
37644
+ const relativePath = relative2(resolvedTargetDir, destPath);
37428
37645
  if (relativePath === "" || relativePath.startsWith("..") || relativePath.includes("/../") || relativePath.includes("\\..\\")) {
37429
37646
  throw new Error(`Refusing to install skill outside target directory: ${skillName}`);
37430
37647
  }
@@ -37433,18 +37650,17 @@ class SkillsManager {
37433
37650
  getInstallPath(skillName, targetDir) {
37434
37651
  return this.resolveInstallPath(targetDir, this.normalizeSkillName(skillName));
37435
37652
  }
37653
+ async cleanAndCreateDirectory(path) {
37654
+ await fs18.rm(path, { recursive: true, force: true }).catch(() => {
37655
+ });
37656
+ await fs18.mkdir(path, { recursive: true });
37657
+ }
37658
+ isWithinPath(basePath, targetPath) {
37659
+ const relativePath = relative2(resolve7(basePath), resolve7(targetPath));
37660
+ return relativePath === "" || !relativePath.startsWith("..") && !relativePath.includes("/../") && !relativePath.includes("\\..\\");
37661
+ }
37436
37662
  async copyDir(src, dest) {
37437
- await fs18.mkdir(dest, { recursive: true });
37438
- const entries = await fs18.readdir(src, { withFileTypes: true });
37439
- for (const entry of entries) {
37440
- const srcPath = join3(src, entry.name);
37441
- const destPath = join3(dest, entry.name);
37442
- if (entry.isDirectory()) {
37443
- await this.copyDir(srcPath, destPath);
37444
- } else {
37445
- await fs18.copyFile(srcPath, destPath);
37446
- }
37447
- }
37663
+ await fs18.cp(src, dest, { recursive: true, dereference: true });
37448
37664
  }
37449
37665
  async addFromSource(source, projectPath, options2 = {}) {
37450
37666
  const resolved = this.resolveSource(source);
@@ -37456,7 +37672,7 @@ class SkillsManager {
37456
37672
  tempDir = await this.cloneRepo(resolved.url);
37457
37673
  repoPath = tempDir;
37458
37674
  } else {
37459
- repoPath = resolve6(resolved.path || source);
37675
+ repoPath = resolve7(resolved.path || source);
37460
37676
  if (!await fileExists(repoPath)) {
37461
37677
  throw new Error(`Local path not found: ${repoPath}`);
37462
37678
  }
@@ -37478,21 +37694,32 @@ class SkillsManager {
37478
37694
  };
37479
37695
  }
37480
37696
  const result = { installed: [], skipped: [] };
37481
- for (const skill of skills) {
37482
- for (const agent of agents) {
37483
- if (!agent.supportsSkills()) {
37697
+ const installableAgents = [];
37698
+ for (const agent of agents) {
37699
+ if (!agent.supportsSkills()) {
37700
+ for (const skill of skills) {
37484
37701
  result.skipped.push({ skill, reason: `${agent.name} does not support skills` });
37485
- continue;
37486
37702
  }
37487
- const skillsDir = agent.getSkillsDir(projectPath, options2.global);
37488
- if (!skillsDir) {
37703
+ continue;
37704
+ }
37705
+ const skillsDir = agent.getSkillsDir(projectPath, options2.global);
37706
+ if (!skillsDir) {
37707
+ for (const skill of skills) {
37489
37708
  result.skipped.push({ skill, reason: `No skills directory for ${agent.name}` });
37490
- continue;
37491
37709
  }
37710
+ continue;
37711
+ }
37712
+ installableAgents.push(agent);
37713
+ }
37714
+ for (const skill of skills) {
37715
+ for (const agent of installableAgents) {
37492
37716
  try {
37493
- const shouldCopy = options2.copy || resolved.type === "github";
37494
- const installedPath = await this.installSkill(skill.path, skill.name, skillsDir, shouldCopy);
37495
- result.installed.push({ skill, agent: agent.id, path: installedPath });
37717
+ const installOptions = {
37718
+ ...options2.global !== undefined ? { global: options2.global } : {},
37719
+ ...options2.copy !== undefined ? { copy: options2.copy } : {}
37720
+ };
37721
+ const installed = await this.installSkillForAgent(skill.path, skill.name, agent, projectPath, installOptions);
37722
+ result.installed.push({ skill, agent: agent.id, ...installed });
37496
37723
  } catch (error) {
37497
37724
  result.skipped.push({ skill, reason: error.message });
37498
37725
  }
@@ -37508,6 +37735,9 @@ class SkillsManager {
37508
37735
  }
37509
37736
  async listInstalled(projectPath, options2 = {}) {
37510
37737
  const agents = await this.getTargetAgents(projectPath, options2);
37738
+ return this.listInstalledForAgents(projectPath, agents, options2);
37739
+ }
37740
+ async listInstalledForAgents(projectPath, agents, options2 = {}) {
37511
37741
  const installed = [];
37512
37742
  for (const agent of agents) {
37513
37743
  if (!agent.supportsSkills())
@@ -37534,9 +37764,17 @@ class SkillsManager {
37534
37764
  if (!parsed)
37535
37765
  continue;
37536
37766
  let isSymlink = false;
37767
+ let canonicalPath;
37537
37768
  try {
37538
37769
  const stat = await fs18.lstat(entryPath);
37539
37770
  isSymlink = stat.isSymbolicLink();
37771
+ const canonicalBase = this.getCanonicalSkillsDir(projectPath, scope === "global");
37772
+ const resolvedEntryPath = await resolveRealPathOrSelf(entryPath);
37773
+ if (this.isWithinPath(canonicalBase, resolvedEntryPath)) {
37774
+ canonicalPath = resolvedEntryPath;
37775
+ } else if (this.isWithinPath(canonicalBase, entryPath)) {
37776
+ canonicalPath = resolve7(entryPath);
37777
+ }
37540
37778
  } catch {
37541
37779
  }
37542
37780
  installed.push({
@@ -37545,7 +37783,9 @@ class SkillsManager {
37545
37783
  path: entryPath,
37546
37784
  agent: agent.id,
37547
37785
  scope,
37548
- isSymlink
37786
+ isSymlink,
37787
+ mode: canonicalPath ? "symlink" : "copy",
37788
+ ...canonicalPath ? { canonicalPath } : {}
37549
37789
  });
37550
37790
  }
37551
37791
  }
@@ -37554,42 +37794,60 @@ class SkillsManager {
37554
37794
  }
37555
37795
  async remove(skillNames, projectPath, options2 = {}) {
37556
37796
  const agents = await this.getTargetAgents(projectPath, options2);
37797
+ const allAgents = this.agentManager.getAllAgents().filter((agent) => agent.supportsSkills());
37557
37798
  const removed = [];
37558
37799
  const notFound = [];
37800
+ const skipped = [];
37559
37801
  const namesLower = new Set(skillNames.map((n) => n.toLowerCase()));
37560
- for (const agent of agents) {
37561
- if (!agent.supportsSkills())
37562
- continue;
37563
- const scopes = [];
37564
- if (!options2.global) {
37565
- scopes.push({ scope: "project", dir: agent.getSkillsDir(projectPath, false) });
37566
- }
37567
- if (options2.global) {
37568
- scopes.push({ scope: "global", dir: agent.getSkillsDir(projectPath, true) });
37802
+ const targetAgentIds = new Set(agents.map((agent) => agent.id));
37803
+ const installed = await this.listInstalledForAgents(projectPath, allAgents, options2);
37804
+ const scopedInstalled = installed.filter((entry) => options2.global ? entry.scope === "global" : entry.scope === "project");
37805
+ const targetedEntries = scopedInstalled.filter((entry) => targetAgentIds.has(entry.agent) && namesLower.has(entry.name.toLowerCase()));
37806
+ const targetedKeys = new Set(targetedEntries.map((entry) => `${entry.agent}:${entry.scope}:${entry.path}:${entry.name}`));
37807
+ const remainingEntries = installed.filter((entry) => !targetedKeys.has(`${entry.agent}:${entry.scope}:${entry.path}:${entry.name}`));
37808
+ const removedPaths = new Set;
37809
+ const removedCanonicalPaths = new Set;
37810
+ for (const entry of targetedEntries) {
37811
+ const removedEntry = `${entry.agent}:${entry.name}`;
37812
+ if (entry.canonicalPath && entry.path === entry.canonicalPath) {
37813
+ const stillReferenced = remainingEntries.some((other) => other.name.toLowerCase() === entry.name.toLowerCase() && other.canonicalPath === entry.canonicalPath);
37814
+ if (stillReferenced) {
37815
+ skipped.push({
37816
+ name: entry.name,
37817
+ reason: `Shared canonical path still used by another agent: ${entry.canonicalPath}`
37818
+ });
37819
+ continue;
37820
+ }
37569
37821
  }
37570
- for (const { dir } of scopes) {
37571
- if (!dir || !await fileExists(dir))
37822
+ if (!removedPaths.has(entry.path)) {
37823
+ try {
37824
+ await fs18.rm(entry.path, { recursive: true, force: true });
37825
+ removedPaths.add(entry.path);
37826
+ } catch {
37827
+ skipped.push({
37828
+ name: entry.name,
37829
+ reason: `Could not remove skill path: ${entry.path}`
37830
+ });
37572
37831
  continue;
37573
- const entries = await listFiles(dir);
37574
- for (const entry of entries) {
37575
- if (!namesLower.has(entry.toLowerCase()))
37576
- continue;
37577
- const entryPath = join3(dir, entry);
37578
- try {
37579
- await fs18.rm(entryPath, { recursive: true, force: true });
37580
- removed.push(`${agent.id}:${entry}`);
37581
- } catch {
37582
- }
37583
37832
  }
37584
37833
  }
37834
+ if (entry.canonicalPath && entry.canonicalPath !== entry.path && !removedCanonicalPaths.has(entry.canonicalPath)) {
37835
+ const stillReferenced = remainingEntries.some((other) => other.name.toLowerCase() === entry.name.toLowerCase() && other.canonicalPath === entry.canonicalPath);
37836
+ if (!stillReferenced) {
37837
+ await fs18.rm(entry.canonicalPath, { recursive: true, force: true }).catch(() => {
37838
+ });
37839
+ removedCanonicalPaths.add(entry.canonicalPath);
37840
+ }
37841
+ }
37842
+ removed.push(removedEntry);
37585
37843
  }
37586
- const removedNames = new Set(removed.map((r) => r.split(":")[1]?.toLowerCase()));
37844
+ const foundNames = new Set(targetedEntries.map((entry) => entry.name.toLowerCase()));
37587
37845
  for (const name of skillNames) {
37588
- if (!removedNames.has(name.toLowerCase())) {
37846
+ if (!foundNames.has(name.toLowerCase())) {
37589
37847
  notFound.push(name);
37590
37848
  }
37591
37849
  }
37592
- return { removed, notFound };
37850
+ return { removed, notFound, skipped };
37593
37851
  }
37594
37852
  }
37595
37853
 
@@ -37659,9 +37917,13 @@ async function detectCommand(options2) {
37659
37917
  }
37660
37918
  }
37661
37919
 
37920
+ // dist/commands/sync.js
37921
+ import {relative as relative4} from "path";
37922
+
37662
37923
  // dist/core/propagator.js
37663
37924
  var import_gray_matter2 = __toESM(require_gray_matter(), 1);
37664
- import {resolve as resolve7} from "path";
37925
+ import {promises as fs20} from "fs";
37926
+ import {resolve as resolve8} from "path";
37665
37927
 
37666
37928
  // node_modules/js-yaml/dist/js-yaml.mjs
37667
37929
  var isNothing = function(subject) {
@@ -40290,6 +40552,9 @@ var parseTargets = function(value) {
40290
40552
  }
40291
40553
  return [];
40292
40554
  };
40555
+ var parseRulesAlias = function(value) {
40556
+ return typeof value === "string" && value.trim().toLowerCase() === "agents" ? "agents" : null;
40557
+ };
40293
40558
 
40294
40559
  class Propagator {
40295
40560
  agentAdapters = new Map;
@@ -40301,9 +40566,10 @@ class Propagator {
40301
40566
  success: true,
40302
40567
  changes: [],
40303
40568
  errors: [],
40569
+ warnings: [],
40304
40570
  resolvedTargets: []
40305
40571
  };
40306
- const agentsPath = resolve7(projectPath, "agents.md");
40572
+ const agentsPath = resolve8(projectPath, "agents.md");
40307
40573
  if (!await fileExists(agentsPath)) {
40308
40574
  result.success = false;
40309
40575
  result.errors.push("agents.md not found. Run `agentinit init` first.");
@@ -40318,12 +40584,14 @@ class Propagator {
40318
40584
  }
40319
40585
  const parsed = import_gray_matter2.default(agentsContent);
40320
40586
  const targets = await this.resolveTargets(projectPath, options2.targets, parsed.data.targets);
40587
+ const rulesAlias = parseRulesAlias(parsed.data.rules_alias);
40321
40588
  result.resolvedTargets = targets;
40322
- const generatedFiles = await this.buildGeneratedFiles(projectPath, parsed.content, targets);
40589
+ const generatedFiles = await this.buildGeneratedFiles(projectPath, parsed.content, targets, rulesAlias);
40323
40590
  for (const generatedFile of generatedFiles) {
40324
40591
  try {
40325
40592
  const syncResult = await this.writeGeneratedFile(projectPath, generatedFile, options2);
40326
40593
  result.changes.push(...syncResult.changes);
40594
+ result.warnings.push(...syncResult.warnings);
40327
40595
  if (!syncResult.success) {
40328
40596
  result.errors.push(...syncResult.errors);
40329
40597
  }
@@ -40355,51 +40623,86 @@ class Propagator {
40355
40623
  }
40356
40624
  return this.getDefaultTargets();
40357
40625
  }
40358
- async buildGeneratedFiles(projectPath, content, targets) {
40626
+ async buildGeneratedFiles(projectPath, content, targets, rulesAlias) {
40359
40627
  const generatedFiles = new Map;
40628
+ if (rulesAlias === "agents" && targets.includes("claude")) {
40629
+ this.mergeGeneratedFile(projectPath, generatedFiles, {
40630
+ path: "AGENTS.md",
40631
+ kind: "file",
40632
+ content
40633
+ }, "claude");
40634
+ this.mergeGeneratedFile(projectPath, generatedFiles, {
40635
+ path: "CLAUDE.md",
40636
+ kind: "symlink",
40637
+ target: "AGENTS.md",
40638
+ content
40639
+ }, "claude");
40640
+ }
40360
40641
  for (const target of targets) {
40642
+ if (target === "claude" && rulesAlias === "agents") {
40643
+ continue;
40644
+ }
40361
40645
  const adapter = this.agentAdapters.get(target);
40362
40646
  if (!adapter) {
40363
40647
  throw new Error(`No adapter found for agent: ${target}`);
40364
40648
  }
40365
40649
  const outputs = await adapter.buildOutputs(projectPath, content);
40366
40650
  for (const output of outputs) {
40367
- const outputPath = resolve7(projectPath, output.path);
40368
- const existing = generatedFiles.get(outputPath);
40369
- if (existing) {
40370
- if (existing.content !== output.content) {
40371
- throw new Error(`Conflicting generated content for ${output.path}`);
40372
- }
40373
- existing.agents.push(target);
40374
- continue;
40375
- }
40376
- generatedFiles.set(outputPath, {
40377
- path: outputPath,
40378
- content: normalizeContent(output.content),
40379
- agents: [target],
40380
- ignorePath: output.ignorePath ?? output.path
40381
- });
40651
+ this.mergeGeneratedFile(projectPath, generatedFiles, output, target);
40382
40652
  }
40383
40653
  }
40384
40654
  return [...generatedFiles.values()];
40385
40655
  }
40656
+ mergeGeneratedFile(projectPath, generatedFiles, output, agentId) {
40657
+ const outputPath = resolve8(projectPath, output.path);
40658
+ const nextKind = output.kind ?? "file";
40659
+ const nextContent = nextKind === "file" || output.content !== undefined ? normalizeContent(output.content || "") : undefined;
40660
+ const existing = generatedFiles.get(outputPath);
40661
+ if (existing) {
40662
+ if (existing.kind !== nextKind) {
40663
+ throw new Error(`Conflicting generated output type for ${output.path}`);
40664
+ }
40665
+ if (existing.target !== output.target) {
40666
+ throw new Error(`Conflicting generated symlink target for ${output.path}`);
40667
+ }
40668
+ if (existing.content !== nextContent) {
40669
+ throw new Error(`Conflicting generated content for ${output.path}`);
40670
+ }
40671
+ existing.agents.push(agentId);
40672
+ return;
40673
+ }
40674
+ generatedFiles.set(outputPath, {
40675
+ path: outputPath,
40676
+ kind: nextKind,
40677
+ agents: [agentId],
40678
+ ignorePath: output.ignorePath ?? output.path,
40679
+ ...nextContent !== undefined ? { content: nextContent } : {},
40680
+ ...output.target !== undefined ? { target: output.target } : {}
40681
+ });
40682
+ }
40386
40683
  async writeGeneratedFile(projectPath, generatedFile, options2) {
40387
40684
  const result = {
40388
40685
  success: true,
40389
40686
  changes: [],
40390
40687
  errors: [],
40688
+ warnings: [],
40391
40689
  resolvedTargets: []
40392
40690
  };
40393
40691
  const exists = await fileExists(generatedFile.path);
40394
- const existingContent = exists ? await readFileIfExists(generatedFile.path) : null;
40692
+ const existingStats = exists ? await fs20.lstat(generatedFile.path).catch(() => null) : null;
40693
+ const existingContent = exists && !existingStats?.isSymbolicLink() ? await readFileIfExists(generatedFile.path) : null;
40694
+ const existingTarget = existingStats?.isSymbolicLink() ? await readSymlinkTarget(generatedFile.path) : null;
40395
40695
  if (options2.managedState && !options2.dryRun) {
40396
40696
  await options2.managedState.trackGeneratedPath(generatedFile.path, {
40397
40697
  kind: "file",
40398
40698
  source: "sync",
40399
- ignorePath: resolve7(projectPath, generatedFile.ignorePath)
40699
+ ignorePath: resolve8(projectPath, generatedFile.ignorePath)
40400
40700
  });
40401
40701
  }
40402
- if (exists && existingContent === generatedFile.content) {
40702
+ if (generatedFile.kind === "file" && exists && !existingStats?.isSymbolicLink() && existingContent === generatedFile.content) {
40703
+ return result;
40704
+ }
40705
+ if (generatedFile.kind === "symlink" && exists && existingStats?.isSymbolicLink() && existingTarget === generatedFile.target) {
40403
40706
  return result;
40404
40707
  }
40405
40708
  if (options2.backup && exists) {
@@ -40409,15 +40712,29 @@ class Propagator {
40409
40712
  }
40410
40713
  result.changes.push({
40411
40714
  agent: generatedFile.agents.join(", "),
40715
+ agents: [...generatedFile.agents],
40412
40716
  action: "backed_up",
40413
40717
  file: backupPath
40414
40718
  });
40415
40719
  }
40416
40720
  if (!options2.dryRun) {
40417
- await writeFile(generatedFile.path, generatedFile.content);
40721
+ if (generatedFile.kind === "file") {
40722
+ if (existingStats?.isSymbolicLink()) {
40723
+ await fs20.rm(generatedFile.path, { force: true }).catch(() => {
40724
+ });
40725
+ }
40726
+ await writeFile(generatedFile.path, generatedFile.content || "");
40727
+ } else {
40728
+ const symlinkCreated = await createRelativeSymlink(resolve8(projectPath, generatedFile.target || ""), generatedFile.path);
40729
+ if (!symlinkCreated) {
40730
+ await writeFile(generatedFile.path, generatedFile.content || "");
40731
+ result.warnings.push(`Could not create symlink for ${generatedFile.path}; wrote a copied file instead.`);
40732
+ }
40733
+ }
40418
40734
  }
40419
40735
  result.changes.push({
40420
40736
  agent: generatedFile.agents.join(", "),
40737
+ agents: [...generatedFile.agents],
40421
40738
  action: exists ? "updated" : "created",
40422
40739
  file: generatedFile.path
40423
40740
  });
@@ -40438,8 +40755,8 @@ class Propagator {
40438
40755
  this.agentAdapters.set("cursor", {
40439
40756
  buildOutputs: async (_projectPath, content) => [
40440
40757
  {
40441
- path: ".cursorrules",
40442
- content: this.formatForCursor(content)
40758
+ path: "AGENTS.md",
40759
+ content
40443
40760
  }
40444
40761
  ]
40445
40762
  });
@@ -40475,6 +40792,14 @@ class Propagator {
40475
40792
  }
40476
40793
  ]
40477
40794
  });
40795
+ this.agentAdapters.set("codex", {
40796
+ buildOutputs: async (_projectPath, content) => [
40797
+ {
40798
+ path: "AGENTS.md",
40799
+ content
40800
+ }
40801
+ ]
40802
+ });
40478
40803
  this.agentAdapters.set("zed", {
40479
40804
  buildOutputs: async (_projectPath, content) => [
40480
40805
  {
@@ -40483,6 +40808,14 @@ class Propagator {
40483
40808
  }
40484
40809
  ]
40485
40810
  });
40811
+ this.agentAdapters.set("droid", {
40812
+ buildOutputs: async (_projectPath, content) => [
40813
+ {
40814
+ path: "AGENTS.md",
40815
+ content
40816
+ }
40817
+ ]
40818
+ });
40486
40819
  this.agentAdapters.set("aider", {
40487
40820
  buildOutputs: async (projectPath, content) => [
40488
40821
  {
@@ -40497,7 +40830,7 @@ class Propagator {
40497
40830
  });
40498
40831
  }
40499
40832
  async buildAiderConfig(projectPath) {
40500
- const configPath = resolve7(projectPath, ".aider.conf.yml");
40833
+ const configPath = resolve8(projectPath, ".aider.conf.yml");
40501
40834
  const existingContent = await readFileIfExists(configPath);
40502
40835
  let document = {};
40503
40836
  if (existingContent) {
@@ -40563,30 +40896,37 @@ ${content}
40563
40896
  }
40564
40897
 
40565
40898
  // dist/core/managedState.js
40566
- import {promises as fs21} from "fs";
40567
- import {dirname as dirname2, join as join4, relative as relative2, resolve as resolve8} from "path";
40899
+ import {promises as fs22} from "fs";
40900
+ import {dirname as dirname2, join as join4, relative as relative3, resolve as resolve9} from "path";
40568
40901
  var toPosixPath = function(value) {
40569
40902
  return value.replace(/\\/g, "/");
40570
40903
  };
40571
40904
  async function pathType(targetPath) {
40572
40905
  try {
40573
- const stat = await fs21.stat(targetPath);
40906
+ const stat = await fs22.lstat(targetPath);
40907
+ if (stat.isSymbolicLink()) {
40908
+ return "symlink";
40909
+ }
40574
40910
  return stat.isDirectory() ? "directory" : "file";
40575
40911
  } catch {
40576
40912
  return null;
40577
40913
  }
40578
40914
  }
40579
40915
  async function copyDirectory(src, dest) {
40580
- await fs21.mkdir(dest, { recursive: true });
40581
- const entries = await fs21.readdir(src, { withFileTypes: true });
40916
+ await fs22.mkdir(dest, { recursive: true });
40917
+ const entries = await fs22.readdir(src, { withFileTypes: true });
40582
40918
  for (const entry of entries) {
40583
40919
  const srcPath = join4(src, entry.name);
40584
40920
  const destPath = join4(dest, entry.name);
40585
40921
  if (entry.isDirectory()) {
40586
40922
  await copyDirectory(srcPath, destPath);
40923
+ } else if (entry.isSymbolicLink()) {
40924
+ const target = await fs22.readlink(srcPath);
40925
+ await fs22.mkdir(dirname2(destPath), { recursive: true });
40926
+ await fs22.symlink(target, destPath);
40587
40927
  } else {
40588
- await fs21.mkdir(dirname2(destPath), { recursive: true });
40589
- await fs21.copyFile(srcPath, destPath);
40928
+ await fs22.mkdir(dirname2(destPath), { recursive: true });
40929
+ await fs22.copyFile(srcPath, destPath);
40590
40930
  }
40591
40931
  }
40592
40932
  }
@@ -40595,11 +40935,14 @@ async function copyPath(src, dest) {
40595
40935
  if (!type2) {
40596
40936
  return;
40597
40937
  }
40598
- await fs21.mkdir(dirname2(dest), { recursive: true });
40599
- if (type2 === "directory") {
40938
+ await fs22.mkdir(dirname2(dest), { recursive: true });
40939
+ if (type2 === "symlink") {
40940
+ const target = await fs22.readlink(src);
40941
+ await fs22.symlink(target, dest);
40942
+ } else if (type2 === "directory") {
40600
40943
  await copyDirectory(src, dest);
40601
40944
  } else {
40602
- await fs21.copyFile(src, dest);
40945
+ await fs22.copyFile(src, dest);
40603
40946
  }
40604
40947
  }
40605
40948
  var MANAGED_STATE_FILE = "managed-state.json";
@@ -40617,7 +40960,7 @@ class ManagedStateStore {
40617
40960
  const statePath = join4(agentInitDir, MANAGED_STATE_FILE);
40618
40961
  const emptyState = { version: 1, entries: [] };
40619
40962
  try {
40620
- const raw = await fs21.readFile(statePath, "utf8");
40963
+ const raw = await fs22.readFile(statePath, "utf8");
40621
40964
  const parsed = JSON.parse(raw);
40622
40965
  if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.entries)) {
40623
40966
  return new ManagedStateStore(projectPath, emptyState);
@@ -40638,7 +40981,7 @@ class ManagedStateStore {
40638
40981
  }
40639
40982
  normalizeRelativePath(targetPath, preserveTrailingSlash = false) {
40640
40983
  const hasTrailingSlash = preserveTrailingSlash && /[\\/]$/.test(targetPath);
40641
- const relativePath = relative2(this.projectPath, resolve8(targetPath));
40984
+ const relativePath = relative3(this.projectPath, resolve9(targetPath));
40642
40985
  const normalizedPath = toPosixPath(relativePath);
40643
40986
  if (hasTrailingSlash && normalizedPath) {
40644
40987
  return normalizedPath.endsWith("/") ? normalizedPath : `${normalizedPath}/`;
@@ -40650,15 +40993,24 @@ class ManagedStateStore {
40650
40993
  return this.state.entries.find((entry) => entry.path === relativePath);
40651
40994
  }
40652
40995
  async createBackup(targetPath) {
40653
- if (!await fileExists(targetPath)) {
40654
- return;
40996
+ const type2 = await pathType(targetPath);
40997
+ if (!type2) {
40998
+ return {};
40999
+ }
41000
+ if (type2 === "symlink") {
41001
+ try {
41002
+ const backupLinkTarget = await fs22.readlink(targetPath);
41003
+ return { backupLinkTarget };
41004
+ } catch {
41005
+ return {};
41006
+ }
40655
41007
  }
40656
41008
  const relativeTargetPath = this.normalizeRelativePath(targetPath);
40657
41009
  const backupPath = join4(this.backupsDir, relativeTargetPath);
40658
41010
  if (!await fileExists(backupPath)) {
40659
41011
  await copyPath(targetPath, backupPath);
40660
41012
  }
40661
- return this.normalizeRelativePath(backupPath);
41013
+ return { backupPath: this.normalizeRelativePath(backupPath) };
40662
41014
  }
40663
41015
  async trackGeneratedPath(targetPath, options2) {
40664
41016
  const existing = this.getEntry(targetPath);
@@ -40669,13 +41021,14 @@ class ManagedStateStore {
40669
41021
  return existing;
40670
41022
  }
40671
41023
  const existedBefore = await fileExists(targetPath);
40672
- const backupPath = existedBefore ? await this.createBackup(targetPath) : undefined;
41024
+ const backup = existedBefore ? await this.createBackup(targetPath) : {};
40673
41025
  const entry = {
40674
41026
  path: this.normalizeRelativePath(targetPath),
40675
41027
  kind: options2.kind,
40676
41028
  source: options2.source,
40677
41029
  existedBefore,
40678
- ...backupPath ? { backupPath } : {},
41030
+ ...backup.backupPath ? { backupPath: backup.backupPath } : {},
41031
+ ...backup.backupLinkTarget ? { backupLinkTarget: backup.backupLinkTarget } : {},
40679
41032
  ...options2.ignorePath ? { ignorePath: this.normalizeRelativePath(options2.ignorePath, true) } : {}
40680
41033
  };
40681
41034
  this.state.entries.push(entry);
@@ -40700,8 +41053,8 @@ class ManagedStateStore {
40700
41053
  return [...paths2];
40701
41054
  }
40702
41055
  async save() {
40703
- await fs21.mkdir(this.agentInitDir, { recursive: true });
40704
- await fs21.writeFile(this.stateFilePath, JSON.stringify(this.state, null, 2), "utf8");
41056
+ await fs22.mkdir(this.agentInitDir, { recursive: true });
41057
+ await fs22.writeFile(this.stateFilePath, JSON.stringify(this.state, null, 2), "utf8");
40705
41058
  }
40706
41059
  async revertAll(options2 = {}) {
40707
41060
  const summary = {
@@ -40711,25 +41064,34 @@ class ManagedStateStore {
40711
41064
  };
40712
41065
  const entries = [...this.state.entries].sort((a, b) => b.path.length - a.path.length);
40713
41066
  for (const entry of entries) {
40714
- const absolutePath = resolve8(this.projectPath, entry.path);
40715
- const backupPath = entry.backupPath ? resolve8(this.projectPath, entry.backupPath) : null;
40716
- if (entry.existedBefore && backupPath && await fileExists(backupPath)) {
41067
+ const absolutePath = resolve9(this.projectPath, entry.path);
41068
+ const backupPath = entry.backupPath ? resolve9(this.projectPath, entry.backupPath) : null;
41069
+ const backupLinkTarget = entry.backupLinkTarget;
41070
+ if (entry.existedBefore && backupLinkTarget !== undefined) {
41071
+ if (!options2.dryRun) {
41072
+ await fs22.rm(absolutePath, { recursive: true, force: true }).catch(() => {
41073
+ });
41074
+ await fs22.mkdir(dirname2(absolutePath), { recursive: true });
41075
+ await fs22.symlink(backupLinkTarget, absolutePath);
41076
+ }
41077
+ summary.restored++;
41078
+ } else if (entry.existedBefore && backupPath && await fileExists(backupPath)) {
40717
41079
  if (!options2.dryRun) {
40718
- await fs21.rm(absolutePath, { recursive: true, force: true }).catch(() => {
41080
+ await fs22.rm(absolutePath, { recursive: true, force: true }).catch(() => {
40719
41081
  });
40720
41082
  await copyPath(backupPath, absolutePath);
40721
41083
  }
40722
41084
  summary.restored++;
40723
41085
  } else {
40724
41086
  if (!options2.dryRun) {
40725
- await fs21.rm(absolutePath, { recursive: true, force: true }).catch(() => {
41087
+ await fs22.rm(absolutePath, { recursive: true, force: true }).catch(() => {
40726
41088
  });
40727
41089
  }
40728
41090
  summary.removed++;
40729
41091
  }
40730
41092
  if (!options2.keepBackups && backupPath && await fileExists(backupPath)) {
40731
41093
  if (!options2.dryRun) {
40732
- await fs21.rm(backupPath, { recursive: true, force: true }).catch(() => {
41094
+ await fs22.rm(backupPath, { recursive: true, force: true }).catch(() => {
40733
41095
  });
40734
41096
  }
40735
41097
  summary.backupsRemoved++;
@@ -40737,16 +41099,16 @@ class ManagedStateStore {
40737
41099
  }
40738
41100
  if (!options2.dryRun) {
40739
41101
  this.state.entries.length = 0;
40740
- await fs21.rm(this.stateFilePath, { force: true }).catch(() => {
41102
+ await fs22.rm(this.stateFilePath, { force: true }).catch(() => {
40741
41103
  });
40742
41104
  if (!options2.keepBackups) {
40743
- await fs21.rm(this.backupsDir, { recursive: true, force: true }).catch(() => {
41105
+ await fs22.rm(this.backupsDir, { recursive: true, force: true }).catch(() => {
40744
41106
  });
40745
41107
  }
40746
41108
  try {
40747
- const remainingEntries = await fs21.readdir(this.agentInitDir);
41109
+ const remainingEntries = await fs22.readdir(this.agentInitDir);
40748
41110
  if (remainingEntries.length === 0) {
40749
- await fs21.rm(this.agentInitDir, { recursive: true, force: true });
41111
+ await fs22.rm(this.agentInitDir, { recursive: true, force: true });
40750
41112
  }
40751
41113
  } catch {
40752
41114
  }
@@ -40758,6 +41120,7 @@ class ManagedStateStore {
40758
41120
  // dist/commands/sync.js
40759
41121
  async function syncCommand(options2) {
40760
41122
  const cwd = process.cwd();
41123
+ const agentManager4 = new AgentManager;
40761
41124
  logger.title("\uD83D\uDD04 AgentInit - Sync Configuration");
40762
41125
  if (options2.dryRun) {
40763
41126
  logger.info("Running in dry-run mode - no files will be modified");
@@ -40784,13 +41147,18 @@ async function syncCommand(options2) {
40784
41147
  }
40785
41148
  if (result.success) {
40786
41149
  spinner.succeed("Synchronization complete");
41150
+ if (result.warnings.length > 0) {
41151
+ result.warnings.forEach((warning) => logger.warning(warning));
41152
+ }
40787
41153
  if (result.changes.length === 0) {
40788
41154
  logger.info("No changes needed - all configurations are up to date");
40789
41155
  } else {
40790
41156
  logger.success(`Applied ${result.changes.length} changes:`);
40791
41157
  for (const change of result.changes) {
40792
41158
  const action = change.action === "created" ? "\u2795" : change.action === "updated" ? "\uD83D\uDCDD" : "\uD83D\uDCBE";
40793
- logger.info(` ${action} ${change.agent}: ${change.file}`);
41159
+ const names = change.agents.map((id) => agentManager4.getAgentById(id)?.name || id).join(", ");
41160
+ logger.info(` ${action} ${relative4(cwd, change.file) || change.file}`);
41161
+ logger.info(` Agents: ${names}`);
40794
41162
  }
40795
41163
  if (options2.backup && result.changes.some((c) => c.action === "backed_up")) {
40796
41164
  logger.info("\uD83D\uDCBE Backup files created with .agentinit.backup extension");
@@ -40801,6 +41169,9 @@ async function syncCommand(options2) {
40801
41169
  for (const error of result.errors) {
40802
41170
  logger.error(error);
40803
41171
  }
41172
+ for (const warning of result.warnings) {
41173
+ logger.warning(warning);
41174
+ }
40804
41175
  if (result.changes.length > 0) {
40805
41176
  logger.warning("Partial sync completed. Some changes were applied:");
40806
41177
  for (const change of result.changes) {
@@ -40814,6 +41185,9 @@ async function syncCommand(options2) {
40814
41185
  }
40815
41186
  }
40816
41187
 
41188
+ // dist/commands/apply.js
41189
+ import {relative as relative5} from "path";
41190
+
40817
41191
  // dist/types/index.js
40818
41192
  var MCPServerType;
40819
41193
  (function(MCPServerType2) {
@@ -41113,7 +41487,7 @@ import {readFileSync as readFileSync3} from "fs";
41113
41487
 
41114
41488
  // dist/core/rulesTemplateLoader.js
41115
41489
  var toml = __toESM(require_toml(), 1);
41116
- import {resolve as resolve9, dirname as dirname4} from "path";
41490
+ import {resolve as resolve10, dirname as dirname4} from "path";
41117
41491
  import {fileURLToPath as fileURLToPath2} from "url";
41118
41492
  import {readFileSync as readFileSync2, readdirSync, existsSync} from "fs";
41119
41493
  var __filename2 = fileURLToPath2(import.meta.url);
@@ -41123,7 +41497,7 @@ class RulesTemplateLoader {
41123
41497
  templatesPath;
41124
41498
  templates = new Map;
41125
41499
  constructor() {
41126
- this.templatesPath = resolve9(__dirname2, "../templates/rules");
41500
+ this.templatesPath = resolve10(__dirname2, "../templates/rules");
41127
41501
  this.loadTemplates();
41128
41502
  }
41129
41503
  loadTemplates() {
@@ -41133,7 +41507,7 @@ class RulesTemplateLoader {
41133
41507
  const files = readdirSync(this.templatesPath).filter((file) => file.endsWith(".toml"));
41134
41508
  for (const file of files) {
41135
41509
  try {
41136
- const filePath = resolve9(this.templatesPath, file);
41510
+ const filePath = resolve10(this.templatesPath, file);
41137
41511
  const content = readFileSync2(filePath, "utf-8");
41138
41512
  const parsed = toml.default.parse(content);
41139
41513
  const template = {
@@ -46793,7 +47167,7 @@ class Protocol {
46793
47167
  }
46794
47168
  request(request, resultSchema, options2) {
46795
47169
  const { relatedRequestId, resumptionToken, onresumptiontoken } = options2 !== null && options2 !== undefined ? options2 : {};
46796
- return new Promise((resolve10, reject) => {
47170
+ return new Promise((resolve11, reject) => {
46797
47171
  var _a, _b, _c, _d, _e, _f;
46798
47172
  if (!this._transport) {
46799
47173
  reject(new Error("Not connected"));
@@ -46844,7 +47218,7 @@ class Protocol {
46844
47218
  }
46845
47219
  try {
46846
47220
  const result = resultSchema.parse(response.result);
46847
- resolve10(result);
47221
+ resolve11(result);
46848
47222
  } catch (error) {
46849
47223
  reject(error);
46850
47224
  }
@@ -47224,7 +47598,7 @@ class StdioClientTransport {
47224
47598
  if (this._process) {
47225
47599
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
47226
47600
  }
47227
- return new Promise((resolve10, reject) => {
47601
+ return new Promise((resolve11, reject) => {
47228
47602
  var _a, _b, _c, _d, _e;
47229
47603
  this._process = import_cross_spawn.default(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== undefined ? _a : [], {
47230
47604
  env: {
@@ -47247,7 +47621,7 @@ class StdioClientTransport {
47247
47621
  (_b2 = this.onerror) === null || _b2 === undefined || _b2.call(this, error);
47248
47622
  });
47249
47623
  this._process.on("spawn", () => {
47250
- resolve10();
47624
+ resolve11();
47251
47625
  });
47252
47626
  this._process.on("close", (_code) => {
47253
47627
  var _a2;
@@ -47302,16 +47676,16 @@ class StdioClientTransport {
47302
47676
  this._readBuffer.clear();
47303
47677
  }
47304
47678
  send(message) {
47305
- return new Promise((resolve10) => {
47679
+ return new Promise((resolve11) => {
47306
47680
  var _a;
47307
47681
  if (!((_a = this._process) === null || _a === undefined ? undefined : _a.stdin)) {
47308
47682
  throw new Error("Not connected");
47309
47683
  }
47310
47684
  const json2 = serializeMessage(message);
47311
47685
  if (this._process.stdin.write(json2)) {
47312
- resolve10();
47686
+ resolve11();
47313
47687
  } else {
47314
- this._process.stdin.once("drain", resolve10);
47688
+ this._process.stdin.once("drain", resolve11);
47315
47689
  }
47316
47690
  });
47317
47691
  }
@@ -48733,7 +49107,7 @@ class SSEClientTransport {
48733
49107
  _startOrAuth() {
48734
49108
  var _a, _b, _c;
48735
49109
  const fetchImpl = (_c = (_b = (_a = this === null || this === undefined ? undefined : this._eventSourceInit) === null || _a === undefined ? undefined : _a.fetch) !== null && _b !== undefined ? _b : this._fetch) !== null && _c !== undefined ? _c : fetch;
48736
- return new Promise((resolve10, reject) => {
49110
+ return new Promise((resolve11, reject) => {
48737
49111
  this._eventSource = new EventSource(this._url.href, {
48738
49112
  ...this._eventSourceInit,
48739
49113
  fetch: async (url, init2) => {
@@ -48753,7 +49127,7 @@ class SSEClientTransport {
48753
49127
  this._eventSource.onerror = (event) => {
48754
49128
  var _a2;
48755
49129
  if (event.code === 401 && this._authProvider) {
48756
- this._authThenStart().then(resolve10, reject);
49130
+ this._authThenStart().then(resolve11, reject);
48757
49131
  return;
48758
49132
  }
48759
49133
  const error = new SseError(event.code, event.message, event);
@@ -48776,7 +49150,7 @@ class SSEClientTransport {
48776
49150
  this.close();
48777
49151
  return;
48778
49152
  }
48779
- resolve10();
49153
+ resolve11();
48780
49154
  });
48781
49155
  this._eventSource.onmessage = (event) => {
48782
49156
  var _a2, _b2;
@@ -49437,11 +49811,11 @@ class MCPVerifier {
49437
49811
  }
49438
49812
 
49439
49813
  // dist/core/gitignoreManager.js
49440
- import {promises as fs24} from "fs";
49814
+ import {promises as fs25} from "fs";
49441
49815
  import {dirname as dirname5, join as join6} from "path";
49442
49816
  var normalizeIgnorePath = function(projectPath, value) {
49443
- const relative3 = value.startsWith(projectPath) ? value.slice(projectPath.length + 1) : value;
49444
- const normalized = relative3.replace(/\\/g, "/").replace(/^\/+/, "");
49817
+ const relative5 = value.startsWith(projectPath) ? value.slice(projectPath.length + 1) : value;
49818
+ const normalized = relative5.replace(/\\/g, "/").replace(/^\/+/, "");
49445
49819
  if (!normalized) {
49446
49820
  return normalized;
49447
49821
  }
@@ -49490,7 +49864,7 @@ async function updateManagedIgnoreFile(projectPath, paths2, options2 = {}) {
49490
49864
  if (options2.local) {
49491
49865
  const gitDir = join6(projectPath, ".git");
49492
49866
  try {
49493
- const stat = await fs24.stat(gitDir);
49867
+ const stat = await fs25.stat(gitDir);
49494
49868
  if (!stat.isDirectory()) {
49495
49869
  throw new Error;
49496
49870
  }
@@ -49501,13 +49875,13 @@ async function updateManagedIgnoreFile(projectPath, paths2, options2 = {}) {
49501
49875
  const normalizedPaths = [...new Set(paths2.map((path) => normalizeIgnorePath(projectPath, path)).filter(Boolean))].sort();
49502
49876
  let existingContent = "";
49503
49877
  try {
49504
- existingContent = await fs24.readFile(ignoreFilePath, "utf8");
49878
+ existingContent = await fs25.readFile(ignoreFilePath, "utf8");
49505
49879
  } catch {
49506
49880
  existingContent = "";
49507
49881
  }
49508
49882
  const updatedContent = updateManagedBlock(existingContent, normalizedPaths);
49509
- await fs24.mkdir(dirname5(ignoreFilePath), { recursive: true });
49510
- await fs24.writeFile(ignoreFilePath, updatedContent, "utf8");
49883
+ await fs25.mkdir(dirname5(ignoreFilePath), { recursive: true });
49884
+ await fs25.writeFile(ignoreFilePath, updatedContent, "utf8");
49511
49885
  return ignoreFilePath;
49512
49886
  }
49513
49887
  async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
@@ -49515,7 +49889,7 @@ async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
49515
49889
  const ignoreFilePath = join6(projectPath, ignoreFile);
49516
49890
  let content;
49517
49891
  try {
49518
- content = await fs24.readFile(ignoreFilePath, "utf8");
49892
+ content = await fs25.readFile(ignoreFilePath, "utf8");
49519
49893
  } catch {
49520
49894
  return false;
49521
49895
  }
@@ -49531,13 +49905,13 @@ async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
49531
49905
  const afterBlock = content.slice(endIndex + END_MARKER.length).replace(/^\n+/, "");
49532
49906
  let nextContent = `${beforeBlock}${afterBlock}`.replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "");
49533
49907
  if (nextContent.trim() === "") {
49534
- await fs24.rm(ignoreFilePath, { force: true }).catch(() => {
49908
+ await fs25.rm(ignoreFilePath, { force: true }).catch(() => {
49535
49909
  });
49536
49910
  } else {
49537
49911
  if (!nextContent.endsWith("\n")) {
49538
49912
  nextContent += "\n";
49539
49913
  }
49540
- await fs24.writeFile(ignoreFilePath, nextContent, "utf8");
49914
+ await fs25.writeFile(ignoreFilePath, nextContent, "utf8");
49541
49915
  }
49542
49916
  return true;
49543
49917
  }
@@ -49545,7 +49919,7 @@ var START_MARKER = "# START AgentInit Generated Files";
49545
49919
  var END_MARKER = "# END AgentInit Generated Files";
49546
49920
 
49547
49921
  // dist/core/projectSkills.js
49548
- import {join as join7} from "path";
49922
+ import {dirname as dirname6, join as join7} from "path";
49549
49923
  async function discoverProjectSkills(projectPath, skillsManager3) {
49550
49924
  const sources = [];
49551
49925
  const skills = new Map;
@@ -49569,8 +49943,8 @@ async function discoverProjectSkills(projectPath, skillsManager3) {
49569
49943
  };
49570
49944
  }
49571
49945
  async function applyProjectSkills(projectPath, targetAgentIds, managedState2, options2 = {}) {
49572
- const agentManager4 = new AgentManager;
49573
- const skillsManager3 = new SkillsManager(agentManager4);
49946
+ const agentManager5 = new AgentManager;
49947
+ const skillsManager3 = new SkillsManager(agentManager5);
49574
49948
  const { sources, skills } = await discoverProjectSkills(projectPath, skillsManager3);
49575
49949
  const installed = [];
49576
49950
  const skipped = [];
@@ -49582,7 +49956,7 @@ async function applyProjectSkills(projectPath, targetAgentIds, managedState2, op
49582
49956
  skipped
49583
49957
  };
49584
49958
  }
49585
- const targetAgents = targetAgentIds.map((id) => agentManager4.getAgentById(id)).filter((agent) => !!agent);
49959
+ const targetAgents = targetAgentIds.map((id) => agentManager5.getAgentById(id)).filter((agent) => !!agent);
49586
49960
  if (targetAgents.length === 0) {
49587
49961
  return {
49588
49962
  discovered: skills.length,
@@ -49591,7 +49965,6 @@ async function applyProjectSkills(projectPath, targetAgentIds, managedState2, op
49591
49965
  skipped: skills.map((skill) => ({ skill, reason: "No target agents found" }))
49592
49966
  };
49593
49967
  }
49594
- const dirToAgents = new Map;
49595
49968
  for (const agent of targetAgents) {
49596
49969
  if (!agent.supportsSkills()) {
49597
49970
  for (const skill of skills) {
@@ -49606,25 +49979,30 @@ async function applyProjectSkills(projectPath, targetAgentIds, managedState2, op
49606
49979
  }
49607
49980
  continue;
49608
49981
  }
49609
- const existing = dirToAgents.get(skillsDir) || [];
49610
- existing.push(agent);
49611
- dirToAgents.set(skillsDir, existing);
49612
49982
  }
49613
- for (const [skillsDir, dirAgents] of dirToAgents) {
49983
+ for (const agent of targetAgents) {
49984
+ if (!agent.supportsSkills())
49985
+ continue;
49986
+ if (!agent.getSkillsDir(projectPath, false))
49987
+ continue;
49614
49988
  for (const skill of skills) {
49615
49989
  try {
49616
- const installPath = skillsManager3.getInstallPath(skill.name, skillsDir);
49990
+ const installOptions = {
49991
+ ...options2.copy !== undefined ? { copy: options2.copy } : {}
49992
+ };
49993
+ const installPlan = await skillsManager3.getInstallPlan(skill.name, agent, projectPath, installOptions);
49617
49994
  if (!options2.dryRun) {
49618
- await managedState2.trackGeneratedPath(installPath, {
49619
- kind: "directory",
49620
- source: "skills",
49621
- ignorePath: `${skillsDir}/`
49622
- });
49623
- }
49624
- const installedPath = options2.dryRun ? installPath : await skillsManager3.installSkill(skill.path, skill.name, skillsDir, true);
49625
- for (const agent of dirAgents) {
49626
- installed.push({ skill, agent: agent.id, path: installedPath });
49995
+ const generatedPaths = new Set([installPlan.path, installPlan.canonicalPath].filter((value) => !!value));
49996
+ for (const generatedPath of generatedPaths) {
49997
+ await managedState2.trackGeneratedPath(generatedPath, {
49998
+ kind: "directory",
49999
+ source: "skills",
50000
+ ignorePath: `${dirname6(generatedPath)}/`
50001
+ });
50002
+ }
49627
50003
  }
50004
+ const installResult = options2.dryRun ? installPlan : await skillsManager3.installSkillForAgent(skill.path, skill.name, agent, projectPath, installOptions);
50005
+ installed.push({ skill, agent: agent.id, ...installResult });
49628
50006
  } catch (error) {
49629
50007
  skipped.push({ skill, reason: error.message });
49630
50008
  }
@@ -49662,6 +50040,7 @@ function hasLegacyApplyArgs(args) {
49662
50040
  }
49663
50041
  async function applyProjectCommand(options2) {
49664
50042
  const cwd = process.cwd();
50043
+ const agentManager6 = new AgentManager;
49665
50044
  let managedState3 = null;
49666
50045
  logger.title("\uD83D\uDD27 AgentInit - Apply");
49667
50046
  if (options2.dryRun) {
@@ -49690,10 +50069,14 @@ async function applyProjectCommand(options2) {
49690
50069
  }
49691
50070
  spinner.fail("Apply failed");
49692
50071
  syncResult.errors.forEach((error) => logger.error(error));
50072
+ syncResult.warnings.forEach((warning) => logger.warning(warning));
49693
50073
  return;
49694
50074
  }
49695
50075
  const skillsEnabled = options2.skills !== false;
49696
- const projectSkills2 = skillsEnabled ? await applyProjectSkills(cwd, syncResult.resolvedTargets, managedState3, options2.dryRun !== undefined ? { dryRun: options2.dryRun } : {}) : {
50076
+ const projectSkills2 = skillsEnabled ? await applyProjectSkills(cwd, syncResult.resolvedTargets, managedState3, {
50077
+ ...options2.dryRun !== undefined ? { dryRun: options2.dryRun } : {},
50078
+ ...options2.copySkills !== undefined ? { copy: options2.copySkills } : {}
50079
+ }) : {
49697
50080
  discovered: 0,
49698
50081
  sources: [],
49699
50082
  installed: [],
@@ -49713,6 +50096,9 @@ async function applyProjectCommand(options2) {
49713
50096
  await managedState3.save();
49714
50097
  }
49715
50098
  spinner.succeed("Apply complete");
50099
+ if (syncResult.warnings.length > 0) {
50100
+ syncResult.warnings.forEach((warning) => logger.warning(warning));
50101
+ }
49716
50102
  if (syncResult.changes.length === 0 && projectSkills2.installed.length === 0) {
49717
50103
  logger.info("No changes needed - generated files are already up to date");
49718
50104
  } else {
@@ -49721,15 +50107,29 @@ async function applyProjectCommand(options2) {
49721
50107
  syncResult.changes.forEach((change) => {
49722
50108
  if (change.action === "backed_up")
49723
50109
  return;
49724
- logger.info(` ${change.agent}: ${change.file}`);
50110
+ const names = change.agents.map((id) => agentManager6.getAgentById(id)?.name || id).join(", ");
50111
+ logger.info(` ${relative5(cwd, change.file) || change.file}`);
50112
+ logger.info(` Agents: ${names}`);
49725
50113
  });
49726
50114
  }
49727
50115
  if (projectSkills2.installed.length > 0) {
49728
50116
  logger.info("");
49729
50117
  logger.info(`Installed ${green(String(projectSkills2.installed.length))} project skill target(s):`);
49730
- projectSkills2.installed.forEach((item) => {
49731
- logger.info(` ${item.agent}: ${item.skill.name} -> ${item.path}`);
49732
- });
50118
+ const installsByPath = new Map;
50119
+ for (const item of projectSkills2.installed) {
50120
+ const existing = installsByPath.get(item.path) || {
50121
+ agents: new Set,
50122
+ skills: new Set
50123
+ };
50124
+ existing.agents.add(agentManager6.getAgentById(item.agent)?.name || item.agent);
50125
+ existing.skills.add(item.skill.name);
50126
+ installsByPath.set(item.path, existing);
50127
+ }
50128
+ for (const [path, details] of installsByPath) {
50129
+ logger.info(` ${relative5(cwd, path) || path}`);
50130
+ logger.info(` Agents: ${[...details.agents].join(", ")}`);
50131
+ logger.info(` Skills: ${[...details.skills].join(", ")}`);
50132
+ }
49733
50133
  }
49734
50134
  }
49735
50135
  if (projectSkills2.discovered > 0) {
@@ -49879,13 +50279,13 @@ async function applyCommand(args) {
49879
50279
  process.exit(1);
49880
50280
  }
49881
50281
  spinner.text = isGlobal ? "Preparing global configuration..." : "Detecting agents...";
49882
- const agentManager5 = new AgentManager;
50282
+ const agentManager6 = new AgentManager;
49883
50283
  let targetAgents;
49884
50284
  if (specifiedClient) {
49885
- const agent = agentManager5.getAgentById(specifiedClient);
50285
+ const agent = agentManager6.getAgentById(specifiedClient);
49886
50286
  if (!agent) {
49887
50287
  spinner.fail(`Unknown agent: ${specifiedClient}`);
49888
- logger.error(`Supported agents: ${agentManager5.getSupportedAgentIds().join(", ")}`);
50288
+ logger.error(`Supported agents: ${agentManager6.getSupportedAgentIds().join(", ")}`);
49889
50289
  process.exit(1);
49890
50290
  }
49891
50291
  if (isGlobal) {
@@ -49918,11 +50318,11 @@ async function applyCommand(args) {
49918
50318
  spinner.fail("Global configuration requires specifying an agent with --agent");
49919
50319
  process.exit(1);
49920
50320
  }
49921
- const detectedAgents = await agentManager5.detectAgents(cwd);
50321
+ const detectedAgents = await agentManager6.detectAgents(cwd);
49922
50322
  if (detectedAgents.length === 0) {
49923
50323
  spinner.warn("No AI coding agents detected in this project");
49924
50324
  logger.info("Supported agents:");
49925
- agentManager5.getAllAgents().forEach((agent) => {
50325
+ agentManager6.getAllAgents().forEach((agent) => {
49926
50326
  logger.info(` \u2022 ${agent.name} (${agent.id})`);
49927
50327
  logger.info(` Files: ${agent.configFiles.map((c) => c.path).join(", ")}`);
49928
50328
  });
@@ -50247,8 +50647,8 @@ async function verifyMcpCommand(args) {
50247
50647
  spinner.text = `Verifying ${serversToVerify.length} MCP server(s) from arguments...`;
50248
50648
  } else {
50249
50649
  spinner = ora("Detecting agents and MCP configurations...").start();
50250
- const agentManager6 = new AgentManager;
50251
- const detectedAgents = await agentManager6.detectAgents(cwd);
50650
+ const agentManager7 = new AgentManager;
50651
+ const detectedAgents = await agentManager7.detectAgents(cwd);
50252
50652
  if (detectedAgents.length === 0) {
50253
50653
  spinner.warn("No AI coding agents detected in this project");
50254
50654
  logger.info("Run `agentinit detect` to see which agents are supported");
@@ -50416,12 +50816,13 @@ async function revertCommand(options2) {
50416
50816
  }
50417
50817
 
50418
50818
  // dist/commands/skills.js
50819
+ import {relative as relative6} from "path";
50419
50820
  function registerSkillsCommand(program2) {
50420
50821
  const skills = program2.command("skills").description("Manage agent skills");
50421
50822
  skills.command("add <source>").description("Add skills from a GitHub repo or local path").option("-g, --global", "Install skills globally").option("-a, --agent <agents...>", "Target specific agent(s)").option("-s, --skill <names...>", "Install only specific skills by name").option("-l, --list", "List available skills from the source without installing").option("--copy", "Copy skill files instead of symlinking").option("-y, --yes", "Skip confirmation prompts").action(async (source, options2) => {
50422
50823
  logger.title("\uD83D\uDCE6 AgentInit - Skills");
50423
- const agentManager7 = new AgentManager;
50424
- const skillsManager4 = new SkillsManager(agentManager7);
50824
+ const agentManager8 = new AgentManager;
50825
+ const skillsManager4 = new SkillsManager(agentManager8);
50425
50826
  if (options2.list) {
50426
50827
  const spinner2 = ora("Discovering skills...").start();
50427
50828
  try {
@@ -50453,8 +50854,8 @@ function registerSkillsCommand(program2) {
50453
50854
  logger.info(` ${green(name)} ${skill.description}`);
50454
50855
  }
50455
50856
  if (tempDir) {
50456
- const { promises: fs27 } = await import("fs");
50457
- await fs27.rm(tempDir, { recursive: true, force: true }).catch(() => {
50857
+ const { promises: fs28 } = await import("fs");
50858
+ await fs28.rm(tempDir, { recursive: true, force: true }).catch(() => {
50458
50859
  });
50459
50860
  }
50460
50861
  } catch (error) {
@@ -50476,13 +50877,23 @@ function registerSkillsCommand(program2) {
50476
50877
  spinner.warn("No skills found in the source.");
50477
50878
  return;
50478
50879
  }
50479
- spinner.succeed(`Installed ${green(String(result.installed.length))} skill(s)`);
50480
- const byAgent = new Map;
50880
+ const uniqueInstallCount = new Set(result.installed.map((item) => `${item.path}:${item.skill.name}`)).size;
50881
+ spinner.succeed(`Installed ${green(String(uniqueInstallCount))} skill(s)`);
50882
+ const byPath = new Map;
50481
50883
  for (const item of result.installed) {
50482
- byAgent.set(item.agent, (byAgent.get(item.agent) || 0) + 1);
50884
+ const path = item.path;
50885
+ const existing = byPath.get(path) || {
50886
+ agents: new Set,
50887
+ skills: new Set
50888
+ };
50889
+ existing.agents.add(agentManager8.getAgentById(item.agent)?.name || item.agent);
50890
+ existing.skills.add(item.skill.name);
50891
+ byPath.set(path, existing);
50483
50892
  }
50484
- for (const [agent, count] of byAgent) {
50485
- logger.info(` ${agent}: ${green(String(count))} skill(s) installed`);
50893
+ for (const [path, details] of byPath) {
50894
+ logger.info(` ${relative6(process.cwd(), path) || path}`);
50895
+ logger.info(` Agents: ${[...details.agents].join(", ")}`);
50896
+ logger.info(` Skills: ${green(String(details.skills.size))} installed (${[...details.skills].join(", ")})`);
50486
50897
  }
50487
50898
  if (result.skipped.length > 0) {
50488
50899
  logger.info("");
@@ -50499,8 +50910,8 @@ function registerSkillsCommand(program2) {
50499
50910
  });
50500
50911
  skills.command("list").alias("ls").description("List installed skills").option("-g, --global", "List only global skills").option("-a, --agent <agents...>", "Filter by specific agent(s)").action(async (options2) => {
50501
50912
  logger.title("\uD83D\uDCE6 AgentInit - Skills");
50502
- const agentManager7 = new AgentManager;
50503
- const skillsManager4 = new SkillsManager(agentManager7);
50913
+ const agentManager8 = new AgentManager;
50914
+ const skillsManager4 = new SkillsManager(agentManager8);
50504
50915
  const installed = await skillsManager4.listInstalled(process.cwd(), {
50505
50916
  global: options2.global,
50506
50917
  agents: options2.agent
@@ -50509,19 +50920,32 @@ function registerSkillsCommand(program2) {
50509
50920
  logger.info("No skills installed.");
50510
50921
  return;
50511
50922
  }
50512
- const byAgent = new Map;
50923
+ const bySkill = new Map;
50513
50924
  for (const skill of installed) {
50514
- const list = byAgent.get(skill.agent) || [];
50515
- list.push(skill);
50516
- byAgent.set(skill.agent, list);
50517
- }
50518
- for (const [agent, agentSkills] of byAgent) {
50519
- logger.info(`\n ${green(agent)}`);
50520
- for (const skill of agentSkills) {
50521
- const symlink = skill.isSymlink ? " (symlink)" : "";
50522
- const scope = skill.scope === "global" ? " [global]" : "";
50523
- logger.info(` ${green(skill.name)} - ${skill.description}${scope}${symlink}`);
50925
+ const canonicalPath = skill.canonicalPath || skill.path;
50926
+ const key = `${skill.scope}:${canonicalPath}`;
50927
+ const existing = bySkill.get(key) || {
50928
+ name: skill.name,
50929
+ description: skill.description,
50930
+ path: canonicalPath,
50931
+ scope: skill.scope,
50932
+ mode: skill.mode,
50933
+ isSymlink: skill.isSymlink,
50934
+ agents: new Set
50935
+ };
50936
+ existing.isSymlink = existing.isSymlink || skill.isSymlink;
50937
+ if (skill.mode === "symlink") {
50938
+ existing.mode = "symlink";
50524
50939
  }
50940
+ existing.agents.add(agentManager8.getAgentById(skill.agent)?.name || skill.agent);
50941
+ bySkill.set(key, existing);
50942
+ }
50943
+ for (const skill of bySkill.values()) {
50944
+ const mode = skill.mode === "symlink" ? " (canonical)" : "";
50945
+ const scope = skill.scope === "global" ? " [global]" : "";
50946
+ logger.info(`\n ${green(skill.name)} - ${skill.description}${scope}${mode}`);
50947
+ logger.info(` Path: ${relative6(process.cwd(), skill.path) || skill.path}`);
50948
+ logger.info(` Agents: ${[...skill.agents].join(", ")}`);
50525
50949
  }
50526
50950
  });
50527
50951
  skills.command("remove [names...]").alias("rm").description("Remove installed skills by name").option("-g, --global", "Remove from global scope").option("-a, --agent <agents...>", "Target specific agent(s)").option("-y, --yes", "Skip confirmation prompts").action(async (names, options2) => {
@@ -50533,8 +50957,8 @@ function registerSkillsCommand(program2) {
50533
50957
  return;
50534
50958
  }
50535
50959
  }
50536
- const agentManager7 = new AgentManager;
50537
- const skillsManager4 = new SkillsManager(agentManager7);
50960
+ const agentManager8 = new AgentManager;
50961
+ const skillsManager4 = new SkillsManager(agentManager8);
50538
50962
  const result = await skillsManager4.remove(names, process.cwd(), {
50539
50963
  global: options2.global,
50540
50964
  agents: options2.agent,
@@ -50549,7 +50973,13 @@ function registerSkillsCommand(program2) {
50549
50973
  if (result.notFound.length > 0) {
50550
50974
  logger.warn(`Not found: ${result.notFound.join(", ")}`);
50551
50975
  }
50552
- if (result.removed.length === 0 && result.notFound.length === 0) {
50976
+ if (result.skipped.length > 0) {
50977
+ logger.warn(`Skipped: ${result.skipped.length}`);
50978
+ for (const entry of result.skipped) {
50979
+ logger.info(` ${entry.name}: ${entry.reason}`);
50980
+ }
50981
+ }
50982
+ if (result.removed.length === 0 && result.notFound.length === 0 && result.skipped.length === 0) {
50553
50983
  logger.info("Nothing to remove.");
50554
50984
  }
50555
50985
  });
@@ -50574,26 +51004,23 @@ var filterMcpArgs = function(args) {
50574
51004
  }
50575
51005
  return filtered;
50576
51006
  };
50577
- async function resolveAgents(agentManager8, agentIds, isGlobal, cwd) {
51007
+ async function resolveAgents(agentManager9, agentIds, isGlobal, cwd) {
50578
51008
  if (agentIds && agentIds.length > 0) {
50579
51009
  const results = [];
50580
51010
  for (const id of agentIds) {
50581
- const agent = agentManager8.getAgentById(id);
51011
+ const agent = agentManager9.getAgentById(id);
50582
51012
  if (!agent) {
50583
51013
  logger.error(`Unknown agent: ${id}`);
50584
- logger.info(`Supported agents: ${agentManager8.getSupportedAgentIds().join(", ")}`);
51014
+ logger.info(`Supported agents: ${agentManager9.getSupportedAgentIds().join(", ")}`);
50585
51015
  process.exit(1);
50586
51016
  }
50587
51017
  if (isGlobal && !agent.supportsGlobalConfig()) {
50588
51018
  logger.error(`Agent ${agent.name} does not support global configuration`);
50589
51019
  process.exit(1);
50590
51020
  }
50591
- if (!isGlobal) {
50592
- const detection = await agent.detectPresence(cwd);
50593
- if (!detection) {
50594
- logger.warning(`Agent ${id} not detected in project, skipping`);
50595
- continue;
50596
- }
51021
+ if (!isGlobal && !agent.supportsProjectMcpConfig()) {
51022
+ logger.error(`Agent ${agent.name} only supports global MCP configuration. Use --global.`);
51023
+ process.exit(1);
50597
51024
  }
50598
51025
  results.push({ agent, isGlobal });
50599
51026
  }
@@ -50603,19 +51030,61 @@ async function resolveAgents(agentManager8, agentIds, isGlobal, cwd) {
50603
51030
  logger.error("--global requires --agent to specify target agent(s)");
50604
51031
  process.exit(1);
50605
51032
  }
50606
- const detected = await agentManager8.detectAgents(cwd);
51033
+ const detector = new AgentDetector;
51034
+ const detectedConfigs = await detector.detectAgents(cwd);
51035
+ const detected = detectedConfigs.filter((config) => config.detected).map((config) => agentManager9.getAgentById(config.name)).filter((agent) => !!agent).filter((agent) => agent.supportsProjectMcpConfig());
50607
51036
  if (detected.length === 0) {
50608
51037
  logger.warning("No AI coding agents detected in this project");
50609
51038
  logger.info("Supported agents:");
50610
- agentManager8.getAllAgents().forEach((a) => {
51039
+ agentManager9.getAllAgents().filter((a) => a.supportsProjectMcpConfig()).forEach((a) => {
50611
51040
  logger.info(` - ${a.name} (${a.id})`);
50612
51041
  });
50613
51042
  logger.info("");
50614
51043
  logger.info("To target a specific agent, use: --agent <agent-id>");
50615
51044
  return [];
50616
51045
  }
50617
- return detected.map((d) => ({ agent: d.agent, isGlobal: false }));
51046
+ return detected.map((agent) => ({ agent, isGlobal: false }));
50618
51047
  }
51048
+ var buildPlannedTargets = function(targets, servers, cwd) {
51049
+ const plans = [];
51050
+ for (const { agent, isGlobal } of targets) {
51051
+ const filtered = MCPFilter.filterForAgent(agent, servers);
51052
+ if (filtered.servers.length === 0) {
51053
+ continue;
51054
+ }
51055
+ const configPath = isGlobal ? agent.getGlobalMcpPath() : agent.getNativeMcpPath(cwd);
51056
+ if (!configPath) {
51057
+ continue;
51058
+ }
51059
+ plans.push({
51060
+ agent,
51061
+ isGlobal,
51062
+ configPath,
51063
+ servers: filtered.servers,
51064
+ transformations: filtered.transformations
51065
+ });
51066
+ }
51067
+ return plans;
51068
+ };
51069
+ var logPlannedTargets = function(plans) {
51070
+ if (plans.length === 0) {
51071
+ return;
51072
+ }
51073
+ const grouped = new Map;
51074
+ for (const plan of plans) {
51075
+ const existing = grouped.get(plan.configPath) || [];
51076
+ existing.push(plan.agent.name);
51077
+ grouped.set(plan.configPath, existing);
51078
+ }
51079
+ logger.info("Planned targets:");
51080
+ for (const [configPath, agentNames] of grouped) {
51081
+ logger.info(` - ${configPath}`);
51082
+ for (const agentName of agentNames) {
51083
+ logger.info(` ${agentName}`);
51084
+ }
51085
+ }
51086
+ logger.info("");
51087
+ };
50619
51088
  var registerAddCommand = function(mcp) {
50620
51089
  mcp.command("add").description("Add MCP server(s) to agent configurations").allowUnknownOption(true).option("--agent <agents...>", "Target specific agent(s)").option("-g, --global", "Apply to global configuration").option("--verify", "Verify MCP servers after adding").option("--timeout <ms>", "Connection timeout for verification (ms)").action(async (options2, command) => {
50621
51090
  const cwd = process.cwd();
@@ -50650,42 +51119,56 @@ var registerAddCommand = function(mcp) {
50650
51119
  return;
50651
51120
  }
50652
51121
  spinner.text = "Resolving target agents...";
50653
- const agentManager8 = new AgentManager;
51122
+ const agentManager9 = new AgentManager;
50654
51123
  const isGlobal = !!options2.global;
50655
- const targets = await resolveAgents(agentManager8, options2.agent, isGlobal, cwd);
51124
+ const targets = await resolveAgents(agentManager9, options2.agent, isGlobal, cwd);
50656
51125
  if (targets.length === 0) {
50657
51126
  spinner.warn("No target agents resolved");
50658
51127
  return;
50659
51128
  }
50660
- let totalApplied = 0;
50661
- for (const { agent, isGlobal: global3 } of targets) {
50662
- spinner.text = `Applying to ${agent.name}...`;
50663
- const filtered = MCPFilter.filterForAgent(agent, parsed.servers);
50664
- if (filtered.servers.length === 0) {
50665
- logger.warning(`${agent.name}: No compatible MCP servers`);
50666
- continue;
51129
+ const plans = buildPlannedTargets(targets, parsed.servers, cwd);
51130
+ if (plans.length === 0) {
51131
+ spinner.warn("No servers were applied (all filtered out)");
51132
+ return;
51133
+ }
51134
+ spinner.stop();
51135
+ logPlannedTargets(plans);
51136
+ if (options2.verify) {
51137
+ const timeout = options2.timeout ? parseInt(options2.timeout, 10) : undefined;
51138
+ const verificationSources = plans.flatMap((plan) => plan.servers.map((server) => ({
51139
+ server,
51140
+ agentName: plan.agent.name,
51141
+ configPath: plan.configPath
51142
+ })));
51143
+ const verificationResult = await runVerification(plans.flatMap((plan) => plan.servers), timeout, undefined, verificationSources);
51144
+ if (!verificationResult.allSucceeded) {
51145
+ logger.error("Verification failed. No MCP configuration changes were applied.");
51146
+ process.exit(1);
50667
51147
  }
50668
- if (global3) {
50669
- await agent.applyGlobalMCPConfig(filtered.servers);
51148
+ logger.info("");
51149
+ }
51150
+ const spinnerApply = ora("Applying MCP configuration...").start();
51151
+ let totalApplied = 0;
51152
+ for (const plan of plans) {
51153
+ spinnerApply.text = `Applying to ${plan.agent.name}...`;
51154
+ if (plan.isGlobal) {
51155
+ await plan.agent.applyGlobalMCPConfig(plan.servers);
50670
51156
  } else {
50671
- await agent.applyMCPConfig(cwd, filtered.servers);
51157
+ await plan.agent.applyMCPConfig(cwd, plan.servers);
50672
51158
  }
50673
- totalApplied += filtered.servers.length;
50674
- const configPath = global3 ? agent.getGlobalMcpPath() : agent.getNativeMcpPath(cwd);
50675
- logger.info(` ${green("+")} ${agent.name}: ${filtered.servers.length} server(s) added`);
50676
- if (configPath) {
50677
- logger.info(` Config: ${configPath}`);
50678
- }
50679
- if (filtered.transformations.length > 0) {
50680
- filtered.transformations.forEach((t) => {
51159
+ totalApplied += plan.servers.length;
51160
+ logger.info(` ${green("+")} ${plan.agent.name}: ${plan.servers.length} server(s) added`);
51161
+ logger.info(` Config: ${plan.configPath}`);
51162
+ if (plan.transformations.length > 0) {
51163
+ plan.transformations.forEach((t) => {
50681
51164
  logger.info(` ${yellow("~")} ${t.original.name}: ${t.reason}`);
50682
51165
  });
50683
51166
  }
50684
51167
  }
50685
51168
  if (totalApplied === 0) {
50686
- spinner.warn("No servers were applied (all filtered out)");
51169
+ spinnerApply.warn("No servers were applied (all filtered out)");
50687
51170
  } else {
50688
- spinner.succeed(`Added ${totalApplied} MCP server(s)`);
51171
+ spinnerApply.succeed(`Added ${totalApplied} MCP server(s)`);
50689
51172
  parsed.servers.forEach((server) => {
50690
51173
  const typeLabel = server.type.toUpperCase();
50691
51174
  if (server.type === "stdio" && server.command) {
@@ -50695,11 +51178,6 @@ var registerAddCommand = function(mcp) {
50695
51178
  }
50696
51179
  });
50697
51180
  }
50698
- if (options2.verify && parsed.servers.length > 0) {
50699
- logger.info("");
50700
- const timeout = options2.timeout ? parseInt(options2.timeout, 10) : undefined;
50701
- await runVerification(parsed.servers, timeout);
50702
- }
50703
51181
  } catch (error) {
50704
51182
  spinner.fail("Failed to add MCP servers");
50705
51183
  if (error instanceof MCPParseError) {
@@ -50714,11 +51192,11 @@ var registerAddCommand = function(mcp) {
50714
51192
  var registerListCommand = function(mcp) {
50715
51193
  mcp.command("list").alias("ls").description("List configured MCP servers").option("--agent <agents...>", "Target specific agent(s)").option("-g, --global", "List global configuration").action(async (options2) => {
50716
51194
  const cwd = process.cwd();
50717
- const agentManager8 = new AgentManager;
51195
+ const agentManager9 = new AgentManager;
50718
51196
  const isGlobal = !!options2.global;
50719
51197
  const spinner = ora("Reading MCP configurations...").start();
50720
51198
  try {
50721
- const targets = await resolveAgents(agentManager8, options2.agent, isGlobal, cwd);
51199
+ const targets = await resolveAgents(agentManager9, options2.agent, isGlobal, cwd);
50722
51200
  if (targets.length === 0) {
50723
51201
  spinner.warn("No target agents resolved");
50724
51202
  return;
@@ -50781,11 +51259,11 @@ var registerListCommand = function(mcp) {
50781
51259
  var registerRemoveCommand = function(mcp) {
50782
51260
  mcp.command("remove <name>").description("Remove an MCP server by name").option("--agent <agents...>", "Target specific agent(s)").option("-g, --global", "Remove from global configuration").action(async (name, options2) => {
50783
51261
  const cwd = process.cwd();
50784
- const agentManager8 = new AgentManager;
51262
+ const agentManager9 = new AgentManager;
50785
51263
  const isGlobal = !!options2.global;
50786
51264
  const spinner = ora(`Removing MCP server "${name}"...`).start();
50787
51265
  try {
50788
- const targets = await resolveAgents(agentManager8, options2.agent, isGlobal, cwd);
51266
+ const targets = await resolveAgents(agentManager9, options2.agent, isGlobal, cwd);
50789
51267
  if (targets.length === 0) {
50790
51268
  spinner.warn("No target agents resolved");
50791
51269
  return;
@@ -50875,8 +51353,8 @@ var registerVerifyCommand = function(mcp) {
50875
51353
  spinner.text = `Verifying ${serversToVerify.length} MCP server(s) from arguments...`;
50876
51354
  } else {
50877
51355
  spinner.text = "Detecting agents and MCP configurations...";
50878
- const agentManager8 = new AgentManager;
50879
- const detectedAgents = await agentManager8.detectAgents(cwd);
51356
+ const agentManager9 = new AgentManager;
51357
+ const detectedAgents = await resolveAgents(agentManager9, undefined, false, cwd);
50880
51358
  if (detectedAgents.length === 0) {
50881
51359
  spinner.warn("No AI coding agents detected in this project");
50882
51360
  logger.info("Run `agentinit detect` to see which agents are supported");
@@ -50980,6 +51458,11 @@ async function runVerification(servers, timeout, spinner, serverSources) {
50980
51458
  logger.info(" 3. Verify network connectivity for HTTP/SSE servers");
50981
51459
  logger.info(" 4. Try increasing timeout with --timeout <ms>");
50982
51460
  }
51461
+ return {
51462
+ results,
51463
+ successCount,
51464
+ allSucceeded: successCount === results.length
51465
+ };
50983
51466
  }
50984
51467
  function registerMcpCommand(program2) {
50985
51468
  const mcp = program2.command("mcp").description("Manage MCP server configurations");
@@ -51010,7 +51493,7 @@ var colorizeTokenDiff2 = function(diff) {
51010
51493
  return green(`+${diff}`);
51011
51494
  return red(`${diff}`);
51012
51495
  };
51013
- async function resolveTargetAgents(agentManager9, options2, cwd) {
51496
+ async function resolveTargetAgents(agentManager10, options2, cwd) {
51014
51497
  if (options2.global && !options2.agent?.length) {
51015
51498
  logger.error("--global flag requires --agent to specify target agent(s)");
51016
51499
  logger.info("Example: agentinit rules add --global --agent claude --template git");
@@ -51019,10 +51502,10 @@ async function resolveTargetAgents(agentManager9, options2, cwd) {
51019
51502
  if (options2.agent?.length) {
51020
51503
  const agents = [];
51021
51504
  for (const id of options2.agent) {
51022
- const agent = agentManager9.getAgentById(id);
51505
+ const agent = agentManager10.getAgentById(id);
51023
51506
  if (!agent) {
51024
51507
  logger.error(`Unknown agent: ${id}`);
51025
- logger.info(`Supported agents: ${agentManager9.getSupportedAgentIds().join(", ")}`);
51508
+ logger.info(`Supported agents: ${agentManager10.getSupportedAgentIds().join(", ")}`);
51026
51509
  process.exit(1);
51027
51510
  }
51028
51511
  if (options2.global && !agent.supportsGlobalRules()) {
@@ -51033,11 +51516,11 @@ async function resolveTargetAgents(agentManager9, options2, cwd) {
51033
51516
  }
51034
51517
  return agents;
51035
51518
  }
51036
- const detected = await agentManager9.detectAgents(cwd);
51519
+ const detected = await agentManager10.detectAgents(cwd);
51037
51520
  if (detected.length === 0) {
51038
51521
  logger.warning("No AI coding agents detected in this project");
51039
51522
  logger.info("Supported agents:");
51040
- agentManager9.getAllAgents().forEach((a) => {
51523
+ agentManager10.getAllAgents().forEach((a) => {
51041
51524
  logger.info(` - ${a.name} (${a.id})`);
51042
51525
  });
51043
51526
  logger.info("");
@@ -51112,8 +51595,8 @@ function registerRulesCommand(program2) {
51112
51595
  return;
51113
51596
  }
51114
51597
  spinner.text = "Resolving agents...";
51115
- const agentManager9 = new AgentManager;
51116
- const agents = await resolveTargetAgents(agentManager9, options2, cwd);
51598
+ const agentManager10 = new AgentManager;
51599
+ const agents = await resolveTargetAgents(agentManager10, options2, cwd);
51117
51600
  const results = [];
51118
51601
  for (const agent of agents) {
51119
51602
  if (!agent.capabilities.rules) {
@@ -51194,8 +51677,8 @@ function registerRulesCommand(program2) {
51194
51677
  logger.title("\uD83D\uDCCF AgentInit - Rules");
51195
51678
  const cwd = process.cwd();
51196
51679
  const isGlobal = !!options2.global;
51197
- const agentManager9 = new AgentManager;
51198
- const agents = await resolveTargetAgents(agentManager9, options2, cwd);
51680
+ const agentManager10 = new AgentManager;
51681
+ const agents = await resolveTargetAgents(agentManager10, options2, cwd);
51199
51682
  let foundAny = false;
51200
51683
  for (const agent of agents) {
51201
51684
  if (!agent.capabilities.rules) {
@@ -51242,8 +51725,8 @@ function registerRulesCommand(program2) {
51242
51725
  }
51243
51726
  const cwd = process.cwd();
51244
51727
  const isGlobal = !!options2.global;
51245
- const agentManager9 = new AgentManager;
51246
- const agents = await resolveTargetAgents(agentManager9, options2, cwd);
51728
+ const agentManager10 = new AgentManager;
51729
+ const agents = await resolveTargetAgents(agentManager10, options2, cwd);
51247
51730
  const spinner = ora("Removing rules...").start();
51248
51731
  let totalRemoved = 0;
51249
51732
  try {
@@ -51289,15 +51772,15 @@ function registerRulesCommand(program2) {
51289
51772
 
51290
51773
  // dist/core/pluginManager.js
51291
51774
  var import_gray_matter3 = __toESM(require_gray_matter(), 1);
51292
- import {resolve as resolve10, join as join8, basename} from "path";
51293
- import {promises as fs28} from "fs";
51294
- import {homedir as homedir3} from "os";
51775
+ import {resolve as resolve11, join as join8, basename as basename2} from "path";
51776
+ import {promises as fs29} from "fs";
51777
+ import {homedir as homedir4} from "os";
51295
51778
  var getMarketplaceCacheDir = function(registryId) {
51296
- return join8(homedir3(), ".agentinit", "marketplace-cache", registryId);
51779
+ return join8(homedir4(), ".agentinit", "marketplace-cache", registryId);
51297
51780
  };
51298
51781
  var getRegistryPath = function(projectPath, global3) {
51299
51782
  if (global3) {
51300
- return join8(homedir3(), ".agentinit", "plugins.json");
51783
+ return join8(homedir4(), ".agentinit", "plugins.json");
51301
51784
  }
51302
51785
  return join8(projectPath, ".agentinit", "plugins.json");
51303
51786
  };
@@ -51314,8 +51797,8 @@ var MARKETPLACES = [
51314
51797
  class PluginManager {
51315
51798
  agentManager;
51316
51799
  skillsManager;
51317
- constructor(agentManager10) {
51318
- this.agentManager = agentManager10 || new AgentManager;
51800
+ constructor(agentManager11) {
51801
+ this.agentManager = agentManager11 || new AgentManager;
51319
51802
  this.skillsManager = new SkillsManager(this.agentManager);
51320
51803
  }
51321
51804
  resolveSource(source, options2) {
@@ -51382,7 +51865,7 @@ class PluginManager {
51382
51865
  const cacheMetaPath = join8(cacheDir, ".agentinit-cache-meta.json");
51383
51866
  if (await fileExists(cacheMetaPath)) {
51384
51867
  try {
51385
- const meta = JSON.parse(await fs28.readFile(cacheMetaPath, "utf8"));
51868
+ const meta = JSON.parse(await fs29.readFile(cacheMetaPath, "utf8"));
51386
51869
  const age = Date.now() - (meta.fetchedAt || 0);
51387
51870
  if (age < registry.cacheTtlMs) {
51388
51871
  return cacheDir;
@@ -51397,22 +51880,22 @@ class PluginManager {
51397
51880
  try {
51398
51881
  await exec("git", ["pull", "--ff-only"], { cwd: cacheDir, timeout: 30000 });
51399
51882
  } catch {
51400
- await fs28.rm(cacheDir, { recursive: true, force: true });
51883
+ await fs29.rm(cacheDir, { recursive: true, force: true });
51401
51884
  await this.cloneMarketplace(registry.repoUrl, cacheDir);
51402
51885
  }
51403
51886
  } else {
51404
51887
  await this.cloneMarketplace(registry.repoUrl, cacheDir);
51405
51888
  }
51406
- await fs28.mkdir(cacheDir, { recursive: true });
51407
- await fs28.writeFile(cacheMetaPath, JSON.stringify({ fetchedAt: Date.now() }));
51889
+ await fs29.mkdir(cacheDir, { recursive: true });
51890
+ await fs29.writeFile(cacheMetaPath, JSON.stringify({ fetchedAt: Date.now() }));
51408
51891
  return cacheDir;
51409
51892
  }
51410
51893
  async cloneMarketplace(repoUrl, dest) {
51411
- await fs28.mkdir(dest, { recursive: true });
51894
+ await fs29.mkdir(dest, { recursive: true });
51412
51895
  const { execFile: execFile2 } = await import("child_process");
51413
51896
  const { promisify: promisify2 } = await import("util");
51414
51897
  const exec = promisify2(execFile2);
51415
- await fs28.rm(dest, { recursive: true, force: true }).catch(() => {
51898
+ await fs29.rm(dest, { recursive: true, force: true }).catch(() => {
51416
51899
  });
51417
51900
  await exec("git", ["clone", "--depth", "1", repoUrl, dest], { timeout: 60000 });
51418
51901
  }
@@ -51461,7 +51944,7 @@ class PluginManager {
51461
51944
  let version = "0.0.0";
51462
51945
  if (await fileExists(manifestPath)) {
51463
51946
  try {
51464
- const manifest = JSON.parse(await fs28.readFile(manifestPath, "utf8"));
51947
+ const manifest = JSON.parse(await fs29.readFile(manifestPath, "utf8"));
51465
51948
  name = manifest.name || entry;
51466
51949
  description = manifest.description || "";
51467
51950
  version = manifest.version || "0.0.0";
@@ -51555,7 +52038,7 @@ class PluginManager {
51555
52038
  async parseGenericPlugin(pluginDir, source) {
51556
52039
  const skills = await this.skillsManager.discoverSkills(pluginDir);
51557
52040
  const mcpServers = await this.parseMcpJson(pluginDir);
51558
- const dirName = basename(pluginDir);
52041
+ const dirName = basename2(pluginDir);
51559
52042
  return {
51560
52043
  name: dirName,
51561
52044
  version: "0.0.0",
@@ -51612,7 +52095,7 @@ class PluginManager {
51612
52095
  if (manifest.commands) {
51613
52096
  const cmds = Array.isArray(manifest.commands) ? manifest.commands : [manifest.commands];
51614
52097
  for (const cmd of cmds) {
51615
- commandsDirs.push(resolve10(pluginDir, cmd));
52098
+ commandsDirs.push(resolve11(pluginDir, cmd));
51616
52099
  }
51617
52100
  } else {
51618
52101
  commandsDirs.push(join8(pluginDir, "commands"));
@@ -51636,7 +52119,7 @@ class PluginManager {
51636
52119
  const content = await readFileIfExists(cmdPath);
51637
52120
  if (!content)
51638
52121
  return null;
51639
- const fileName = basename(cmdPath, ".md");
52122
+ const fileName = basename2(cmdPath, ".md");
51640
52123
  let skillName;
51641
52124
  let description;
51642
52125
  let body;
@@ -51677,7 +52160,7 @@ ${body.trim()}
51677
52160
  tempDir = await this.skillsManager.cloneRepo(resolved.url);
51678
52161
  pluginDir = tempDir;
51679
52162
  } else {
51680
- pluginDir = resolve10(resolved.path || source);
52163
+ pluginDir = resolve11(resolved.path || source);
51681
52164
  if (!await fileExists(pluginDir)) {
51682
52165
  throw new Error(`Local path not found: ${pluginDir}`);
51683
52166
  }
@@ -51728,7 +52211,7 @@ ${body.trim()}
51728
52211
  };
51729
52212
  } finally {
51730
52213
  if (tempDir) {
51731
- await fs28.rm(tempDir, { recursive: true, force: true }).catch(() => {
52214
+ await fs29.rm(tempDir, { recursive: true, force: true }).catch(() => {
51732
52215
  });
51733
52216
  }
51734
52217
  }
@@ -51738,7 +52221,6 @@ ${body.trim()}
51738
52221
  const skipped = [];
51739
52222
  if (plugin.skills.length === 0)
51740
52223
  return { installed, skipped };
51741
- const dirToAgents = new Map;
51742
52224
  for (const agent of agents) {
51743
52225
  if (!agent.supportsSkills()) {
51744
52226
  for (const skill of plugin.skills) {
@@ -51746,24 +52228,20 @@ ${body.trim()}
51746
52228
  }
51747
52229
  continue;
51748
52230
  }
51749
- const skillsDir = agent.getSkillsDir(projectPath, options2.global);
51750
- if (!skillsDir) {
52231
+ if (!agent.getSkillsDir(projectPath, options2.global)) {
51751
52232
  for (const skill of plugin.skills) {
51752
52233
  skipped.push({ name: skill.name, reason: `No skills directory for ${agent.name}` });
51753
52234
  }
51754
52235
  continue;
51755
52236
  }
51756
- const existing = dirToAgents.get(skillsDir) || [];
51757
- existing.push(agent);
51758
- dirToAgents.set(skillsDir, existing);
51759
- }
51760
- for (const [skillsDir, dirAgents] of dirToAgents) {
51761
52237
  for (const skill of plugin.skills) {
51762
52238
  try {
51763
- const installedPath = skill.generatedContent ? await this.skillsManager.installSkillFromContent(skill.name, skill.generatedContent, skillsDir) : await this.skillsManager.installSkill(skill.path, skill.name, skillsDir, true);
51764
- for (const agent of dirAgents) {
51765
- installed.push({ name: skill.name, agent: agent.id, path: installedPath });
51766
- }
52239
+ const installOptions = {
52240
+ ...options2.global !== undefined ? { global: options2.global } : {},
52241
+ ...options2.copySkills !== undefined ? { copy: options2.copySkills } : {}
52242
+ };
52243
+ const installResult = skill.generatedContent ? await this.skillsManager.installSkillFromContentForAgent(skill.name, skill.generatedContent, agent, projectPath, installOptions) : await this.skillsManager.installSkillForAgent(skill.path, skill.name, agent, projectPath, installOptions);
52244
+ installed.push({ name: skill.name, agent: agent.id, ...installResult });
51767
52245
  } catch (error) {
51768
52246
  skipped.push({ name: skill.name, reason: error.message });
51769
52247
  }
@@ -51888,32 +52366,48 @@ ${body.trim()}
51888
52366
  const agentFilter = options2.agents?.length ? new Set(options2.agents) : null;
51889
52367
  const targetedSkills = agentFilter ? plugin.components.skills.filter((skill) => agentFilter.has(skill.agent)) : plugin.components.skills;
51890
52368
  const retainedSkills = agentFilter ? plugin.components.skills.filter((skill) => !agentFilter.has(skill.agent)) : [];
51891
- const retainedSkillPaths = new Set(retainedSkills.map((skill) => skill.path));
52369
+ const otherPluginSkills = registry.plugins.filter((entry) => entry.name !== plugin.name).flatMap((entry) => entry.components.skills);
52370
+ const remainingSkillRefs = [
52371
+ ...retainedSkills,
52372
+ ...otherPluginSkills
52373
+ ];
51892
52374
  const removedSkillPaths = new Set;
51893
- const sharedSkillPaths = new Set;
52375
+ const removedSkillKeys = new Set;
52376
+ const removedCanonicalPaths = new Set;
51894
52377
  for (const skill of targetedSkills) {
51895
- if (removedSkillPaths.has(skill.path) || sharedSkillPaths.has(skill.path)) {
52378
+ const skillKey = `${skill.agent}:${skill.path}:${skill.name}`;
52379
+ if (removedSkillKeys.has(skillKey)) {
51896
52380
  continue;
51897
52381
  }
51898
- if (retainedSkillPaths.has(skill.path)) {
51899
- sharedSkillPaths.add(skill.path);
51900
- details.push(`Skipped shared skill path: ${skill.path}`);
52382
+ const canonicalRef = skill.canonicalPath || skill.path;
52383
+ const sharedCanonicalPath = remainingSkillRefs.some((other) => (other.canonicalPath || other.path) === canonicalRef);
52384
+ if (skill.canonicalPath && skill.path === skill.canonicalPath && sharedCanonicalPath) {
52385
+ details.push(`Skipped shared canonical skill path: ${skill.path}`);
51901
52386
  continue;
51902
52387
  }
51903
- try {
51904
- await fs28.rm(skill.path, { recursive: true, force: true });
51905
- removedSkillPaths.add(skill.path);
51906
- } catch {
51907
- details.push(`Could not remove skill path: ${skill.path}`);
52388
+ if (!removedSkillPaths.has(skill.path)) {
52389
+ try {
52390
+ await fs29.rm(skill.path, { recursive: true, force: true });
52391
+ removedSkillPaths.add(skill.path);
52392
+ } catch {
52393
+ details.push(`Could not remove skill path: ${skill.path}`);
52394
+ continue;
52395
+ }
51908
52396
  }
51909
- }
51910
- const removedSkills = targetedSkills.filter((skill) => removedSkillPaths.has(skill.path));
51911
- for (const skill of removedSkills) {
52397
+ if (skill.canonicalPath && skill.canonicalPath !== skill.path && !removedCanonicalPaths.has(skill.canonicalPath) && !sharedCanonicalPath) {
52398
+ try {
52399
+ await fs29.rm(skill.canonicalPath, { recursive: true, force: true });
52400
+ removedCanonicalPaths.add(skill.canonicalPath);
52401
+ } catch {
52402
+ details.push(`Could not remove canonical skill path: ${skill.canonicalPath}`);
52403
+ }
52404
+ }
52405
+ removedSkillKeys.add(skillKey);
51912
52406
  details.push(`Removed skill: ${skill.name} (${skill.agent})`);
51913
52407
  }
51914
52408
  const remainingSkills = [
51915
52409
  ...retainedSkills,
51916
- ...targetedSkills.filter((skill) => !removedSkillPaths.has(skill.path))
52410
+ ...targetedSkills.filter((skill) => !removedSkillKeys.has(`${skill.agent}:${skill.path}:${skill.name}`))
51917
52411
  ];
51918
52412
  const targetedMcpServers = agentFilter ? plugin.components.mcpServers.filter((mcp) => agentFilter.has(mcp.agent)) : plugin.components.mcpServers;
51919
52413
  const retainedMcpServers = agentFilter ? plugin.components.mcpServers.filter((mcp) => !agentFilter.has(mcp.agent)) : [];
@@ -51969,10 +52463,10 @@ ${body.trim()}
51969
52463
  function registerPluginsCommand(program2) {
51970
52464
  const marketplaceHelp = new PluginManager().getMarketplaceIds().join(", ");
51971
52465
  const plugins = program2.command("plugins").description("Install agent-agnostic plugins from any marketplace or source");
51972
- plugins.command("install <source>").description("Install a plugin from <marketplace>/<name>, a GitHub repo, or a local path").option("--from <marketplace>", `Marketplace source override (available: ${marketplaceHelp})`).option("-a, --agent <agents...>", "Target specific agent(s)").option("-g, --global", "Install globally").option("-l, --list", "Preview plugin contents without installing").option("-y, --yes", "Skip confirmation prompts, auto-detect all agents").action(async (source, options2) => {
52466
+ plugins.command("install <source>").description("Install a plugin from <marketplace>/<name>, a GitHub repo, or a local path").option("--from <marketplace>", `Marketplace source override (available: ${marketplaceHelp})`).option("-a, --agent <agents...>", "Target specific agent(s)").option("-g, --global", "Install globally").option("--copy-skills", "Copy plugin skills instead of using canonical symlink installs").option("-l, --list", "Preview plugin contents without installing").option("-y, --yes", "Skip confirmation prompts, auto-detect all agents").action(async (source, options2) => {
51973
52467
  logger.title("\uD83D\uDD0C AgentInit - Plugins");
51974
- const agentManager11 = new AgentManager;
51975
- const pluginManager2 = new PluginManager(agentManager11);
52468
+ const agentManager12 = new AgentManager;
52469
+ const pluginManager2 = new PluginManager(agentManager12);
51976
52470
  if (options2.list) {
51977
52471
  const spinner2 = ora("Fetching plugin...").start();
51978
52472
  try {
@@ -52032,6 +52526,7 @@ function registerPluginsCommand(program2) {
52032
52526
  from: options2.from,
52033
52527
  agents: agentIds,
52034
52528
  global: options2.global,
52529
+ copySkills: options2.copySkills,
52035
52530
  yes: options2.yes
52036
52531
  });
52037
52532
  const p = result.plugin;
@@ -52226,7 +52721,7 @@ registerPluginsCommand(program2);
52226
52721
  program2.command("init").description("Initialize agents.md configuration for the current project").option("-f, --force", "Overwrite existing configuration").option("-t, --template <template>", "Use specific template (web, cli, library)").action(initCommand);
52227
52722
  program2.command("detect").description("Detect current project stack and existing agent configurations").option("-v, --verbose", "Show detailed detection results").action(detectCommand);
52228
52723
  program2.command("sync").description("Sync agents.md with agent-specific configuration files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Show what would be changed without making changes").option("-b, --backup", "Create backup before syncing").action(syncCommand);
52229
- program2.command("apply").description("Apply agents.md and project-owned skills to supported agent files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Preview changes without writing files").option("-b, --backup", "Create sibling .agentinit.backup files before overwriting").option("--no-skills", "Disable project-owned skills propagation").option("--no-gitignore", "Disable managed ignore block updates").option("--gitignore-local", "Write ignore entries to .git/info/exclude instead of .gitignore").allowUnknownOption(true).action(async (options2, command) => {
52724
+ program2.command("apply").description("Apply agents.md and project-owned skills to supported agent files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Preview changes without writing files").option("-b, --backup", "Create sibling .agentinit.backup files before overwriting").option("--no-skills", "Disable project-owned skills propagation").option("--copy-skills", "Copy project-owned skills instead of using canonical symlink installs").option("--no-gitignore", "Disable managed ignore block updates").option("--gitignore-local", "Write ignore entries to .git/info/exclude instead of .gitignore").allowUnknownOption(true).action(async (options2, command) => {
52230
52725
  const rawArgs = command.parent.rawArgs.slice(3);
52231
52726
  if (hasLegacyApplyArgs(rawArgs)) {
52232
52727
  logger.warn("\u26A0 Legacy apply mode detected. Prefer:");