@packmind/cli 0.19.0 → 0.20.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 (2) hide show
  1. package/main.cjs +925 -227
  2. package/package.json +4 -4
package/main.cjs CHANGED
@@ -234,9 +234,9 @@ var init_ansi_styles = __esm({
234
234
  });
235
235
 
236
236
  // node_modules/chalk/source/vendor/supports-color/index.js
237
- function hasFlag(flag5, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
238
- const prefix = flag5.startsWith("-") ? "" : flag5.length === 1 ? "-" : "--";
239
- const position = argv.indexOf(prefix + flag5);
237
+ function hasFlag(flag6, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
238
+ const prefix = flag6.startsWith("-") ? "" : flag6.length === 1 ? "-" : "--";
239
+ const position = argv.indexOf(prefix + flag6);
240
240
  const terminatorPosition = argv.indexOf("--");
241
241
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
242
242
  }
@@ -935,7 +935,7 @@ var require_flag = __commonJS({
935
935
  Object.defineProperty(exports2, "__esModule", { value: true });
936
936
  exports2.boolean = void 0;
937
937
  exports2.fullFlag = fullFlag;
938
- exports2.flag = flag5;
938
+ exports2.flag = flag6;
939
939
  var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
940
940
  var Result = __importStar(require_Result());
941
941
  var findOption_1 = require_findOption();
@@ -1084,7 +1084,7 @@ var require_flag = __commonJS({
1084
1084
  }
1085
1085
  };
1086
1086
  }
1087
- function flag5(config) {
1087
+ function flag6(config) {
1088
1088
  return fullFlag({
1089
1089
  type: types_1.boolean,
1090
1090
  ...config
@@ -1698,12 +1698,12 @@ var require_command = __commonJS({
1698
1698
  return mod && mod.__esModule ? mod : { "default": mod };
1699
1699
  };
1700
1700
  Object.defineProperty(exports2, "__esModule", { value: true });
1701
- exports2.command = command21;
1701
+ exports2.command = command22;
1702
1702
  var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
1703
1703
  var Result = __importStar(require_Result());
1704
1704
  var circuitbreaker_1 = require_circuitbreaker();
1705
1705
  var utils_1 = require_utils();
1706
- function command21(config) {
1706
+ function command22(config) {
1707
1707
  const argEntries = (0, utils_1.entries)(config.args);
1708
1708
  const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
1709
1709
  return {
@@ -2574,9 +2574,9 @@ var require_browser = __commonJS({
2574
2574
  var require_has_flag = __commonJS({
2575
2575
  "node_modules/has-flag/index.js"(exports2, module2) {
2576
2576
  "use strict";
2577
- module2.exports = (flag5, argv = process.argv) => {
2578
- const prefix = flag5.startsWith("-") ? "" : flag5.length === 1 ? "-" : "--";
2579
- const position = argv.indexOf(prefix + flag5);
2577
+ module2.exports = (flag6, argv = process.argv) => {
2578
+ const prefix = flag6.startsWith("-") ? "" : flag6.length === 1 ? "-" : "--";
2579
+ const position = argv.indexOf(prefix + flag6);
2580
2580
  const terminatorPosition = argv.indexOf("--");
2581
2581
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
2582
2582
  };
@@ -3218,7 +3218,7 @@ var require_restPositionals = __commonJS({
3218
3218
  };
3219
3219
  }();
3220
3220
  Object.defineProperty(exports2, "__esModule", { value: true });
3221
- exports2.restPositionals = restPositionals3;
3221
+ exports2.restPositionals = restPositionals4;
3222
3222
  var Result = __importStar(require_Result());
3223
3223
  var types_1 = require_types();
3224
3224
  function fullRestPositionals(config) {
@@ -3262,7 +3262,7 @@ var require_restPositionals = __commonJS({
3262
3262
  }
3263
3263
  };
3264
3264
  }
3265
- function restPositionals3(config) {
3265
+ function restPositionals4(config) {
3266
3266
  return fullRestPositionals({
3267
3267
  type: types_1.string,
3268
3268
  ...config
@@ -3852,7 +3852,7 @@ var require_package = __commonJS({
3852
3852
  "apps/cli/package.json"(exports2, module2) {
3853
3853
  module2.exports = {
3854
3854
  name: "@packmind/cli",
3855
- version: "0.19.0",
3855
+ version: "0.20.0",
3856
3856
  description: "A command-line interface for Packmind linting and code quality checks",
3857
3857
  private: false,
3858
3858
  bin: {
@@ -3888,14 +3888,15 @@ var require_package = __commonJS({
3888
3888
  dependencies: {
3889
3889
  "@types/inquirer": "^9.0.9",
3890
3890
  inquirer: "^13.0.2",
3891
- zod: "^4.3.5"
3891
+ zod: "^4.3.5",
3892
+ semver: "^6.3.1"
3892
3893
  }
3893
3894
  };
3894
3895
  }
3895
3896
  });
3896
3897
 
3897
3898
  // apps/cli/src/main.ts
3898
- var import_cmd_ts27 = __toESM(require_cjs());
3899
+ var import_cmd_ts28 = __toESM(require_cjs());
3899
3900
 
3900
3901
  // apps/cli/src/infra/commands/LinterCommand.ts
3901
3902
  var import_cmd_ts = __toESM(require_cjs());
@@ -4117,6 +4118,35 @@ var CodingAgents = {
4117
4118
  continue: "continue"
4118
4119
  };
4119
4120
 
4121
+ // packages/types/src/coding-agent/CodingAgentArtefactPaths.ts
4122
+ var CODING_AGENT_ARTEFACT_PATHS = {
4123
+ claude: {
4124
+ command: ".claude/commands/",
4125
+ standard: ".claude/rules/",
4126
+ skill: ".claude/skills/"
4127
+ },
4128
+ cursor: {
4129
+ command: ".cursor/commands/",
4130
+ standard: ".cursor/rules/",
4131
+ skill: ".cursor/skills/"
4132
+ },
4133
+ copilot: {
4134
+ command: ".github/prompts/",
4135
+ standard: ".github/instructions/",
4136
+ skill: ".github/skills/"
4137
+ },
4138
+ continue: {
4139
+ command: ".continue/prompts/",
4140
+ standard: ".continue/rules/",
4141
+ skill: ""
4142
+ },
4143
+ packmind: {
4144
+ command: ".packmind/commands/",
4145
+ standard: ".packmind/standards/",
4146
+ skill: ""
4147
+ }
4148
+ };
4149
+
4120
4150
  // packages/types/src/recipes/RecipeId.ts
4121
4151
  var createRecipeId = brandedIdFactory();
4122
4152
 
@@ -4353,6 +4383,7 @@ var ProgrammingLanguage = /* @__PURE__ */ ((ProgrammingLanguage5) => {
4353
4383
  ProgrammingLanguage5["SAP_CDS"] = "SAP_CDS";
4354
4384
  ProgrammingLanguage5["SAP_HANA_SQL"] = "SAP_HANA_SQL";
4355
4385
  ProgrammingLanguage5["SWIFT"] = "SWIFT";
4386
+ ProgrammingLanguage5["DART"] = "DART";
4356
4387
  ProgrammingLanguage5["PROPERTIES"] = "PROPERTIES";
4357
4388
  return ProgrammingLanguage5;
4358
4389
  })(ProgrammingLanguage || {});
@@ -4482,6 +4513,10 @@ var ProgrammingLanguageDetails = {
4482
4513
  displayName: "Swift",
4483
4514
  fileExtensions: ["swift"]
4484
4515
  },
4516
+ ["DART" /* DART */]: {
4517
+ displayName: "Dart",
4518
+ fileExtensions: ["dart"]
4519
+ },
4485
4520
  ["PROPERTIES" /* PROPERTIES */]: {
4486
4521
  displayName: "Properties",
4487
4522
  fileExtensions: ["properties"]
@@ -4696,9 +4731,8 @@ var frameworkSampleMappings = {
4696
4731
  exampleLanguage: null
4697
4732
  },
4698
4733
  flutter: {
4699
- languages: [],
4700
- hardcodedPatterns: ["**/*.dart"],
4701
- exampleLanguage: null
4734
+ languages: ["DART" /* DART */],
4735
+ exampleLanguage: "DART" /* DART */
4702
4736
  }
4703
4737
  };
4704
4738
 
@@ -4996,7 +5030,34 @@ var CHANGE_PROPOSAL_TYPE_LABELS = {
4996
5030
  ["addSkillFile" /* addSkillFile */]: "File (add)",
4997
5031
  ["updateSkillFileContent" /* updateSkillFileContent */]: "File content",
4998
5032
  ["updateSkillFilePermissions" /* updateSkillFilePermissions */]: "File permissions",
4999
- ["deleteSkillFile" /* deleteSkillFile */]: "File (delete)"
5033
+ ["deleteSkillFile" /* deleteSkillFile */]: "File (delete)",
5034
+ ["createStandard" /* createStandard */]: "New standard",
5035
+ ["createCommand" /* createCommand */]: "New command",
5036
+ ["createSkill" /* createSkill */]: "New skill",
5037
+ ["removeStandard" /* removeStandard */]: "Remove standard",
5038
+ ["removeCommand" /* removeCommand */]: "Remove command",
5039
+ ["removeSkill" /* removeSkill */]: "Remove skill"
5040
+ };
5041
+
5042
+ // packages/types/src/playbookChangeManagement/events/ChangeProposalAcceptedEvent.ts
5043
+ var ChangeProposalAcceptedEvent = class extends UserEvent {
5044
+ static {
5045
+ this.eventName = "change-proposals.change-proposal.accepted";
5046
+ }
5047
+ };
5048
+
5049
+ // packages/types/src/playbookChangeManagement/events/ChangeProposalRejectedEvent.ts
5050
+ var ChangeProposalRejectedEvent = class extends UserEvent {
5051
+ static {
5052
+ this.eventName = "change-proposals.change-proposal.rejected";
5053
+ }
5054
+ };
5055
+
5056
+ // packages/types/src/playbookChangeManagement/events/ChangeProposalSubmittedEvent.ts
5057
+ var ChangeProposalSubmittedEvent = class extends UserEvent {
5058
+ static {
5059
+ this.eventName = "change-proposals.change-proposal.submitted";
5060
+ }
5000
5061
  };
5001
5062
 
5002
5063
  // apps/cli/src/application/useCases/ExecuteSingleFileAstUseCase.ts
@@ -5010,8 +5071,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
5010
5071
  static {
5011
5072
  this.fallbackRuleContent = "adhoc-rule";
5012
5073
  }
5013
- async execute(command21) {
5014
- const { program, fileContent, language } = command21;
5074
+ async execute(command22) {
5075
+ const { program, fileContent, language } = command22;
5015
5076
  const result = await this.linterExecutionUseCase.execute({
5016
5077
  filePath: "cli-single-file",
5017
5078
  fileContent,
@@ -5062,30 +5123,30 @@ var GitService = class {
5062
5123
  this.gitRunner = gitRunner;
5063
5124
  this.logger = logger2;
5064
5125
  }
5065
- getGitRepositoryRoot(path18) {
5126
+ getGitRepositoryRoot(path21) {
5066
5127
  try {
5067
5128
  const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
5068
- cwd: path18
5129
+ cwd: path21
5069
5130
  });
5070
5131
  const gitRoot = stdout.trim();
5071
5132
  this.logger.debug("Resolved git repository root", {
5072
- inputPath: path18,
5133
+ inputPath: path21,
5073
5134
  gitRoot
5074
5135
  });
5075
5136
  return gitRoot;
5076
5137
  } catch (error) {
5077
5138
  if (error instanceof Error) {
5078
5139
  throw new Error(
5079
- `Failed to get Git repository root. The path '${path18}' does not appear to be inside a Git repository.
5140
+ `Failed to get Git repository root. The path '${path21}' does not appear to be inside a Git repository.
5080
5141
  ${error.message}`
5081
5142
  );
5082
5143
  }
5083
5144
  throw new Error("Failed to get Git repository root: Unknown error");
5084
5145
  }
5085
5146
  }
5086
- tryGetGitRepositoryRoot(path18) {
5147
+ tryGetGitRepositoryRoot(path21) {
5087
5148
  try {
5088
- return this.getGitRepositoryRoot(path18);
5149
+ return this.getGitRepositoryRoot(path21);
5089
5150
  } catch {
5090
5151
  return null;
5091
5152
  }
@@ -5392,8 +5453,8 @@ var GetGitRemoteUrlUseCase = class {
5392
5453
  constructor(gitRemoteUrlService = new GitService()) {
5393
5454
  this.gitRemoteUrlService = gitRemoteUrlService;
5394
5455
  }
5395
- async execute(command21) {
5396
- const { path: repoPath, origin: origin9 } = command21;
5456
+ async execute(command22) {
5457
+ const { path: repoPath, origin: origin9 } = command22;
5397
5458
  return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin9);
5398
5459
  }
5399
5460
  };
@@ -5538,8 +5599,8 @@ var ListFilesInDirectoryUseCase = class {
5538
5599
  constructor(listFiles = new ListFiles()) {
5539
5600
  this.listFiles = listFiles;
5540
5601
  }
5541
- async execute(command21) {
5542
- const { path: directoryPath, extensions, excludes = [] } = command21;
5602
+ async execute(command22) {
5603
+ const { path: directoryPath, extensions, excludes = [] } = command22;
5543
5604
  const files = await this.listFiles.listFilesInDirectory(
5544
5605
  directoryPath,
5545
5606
  extensions,
@@ -5644,7 +5705,7 @@ var LintFilesAgainstRuleUseCase = class {
5644
5705
  }
5645
5706
  return pattern;
5646
5707
  }
5647
- async execute(command21) {
5708
+ async execute(command22) {
5648
5709
  const {
5649
5710
  path: userPath,
5650
5711
  draftMode,
@@ -5652,7 +5713,7 @@ var LintFilesAgainstRuleUseCase = class {
5652
5713
  ruleId,
5653
5714
  language,
5654
5715
  diffMode
5655
- } = command21;
5716
+ } = command22;
5656
5717
  this.logger.debug(
5657
5718
  `Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
5658
5719
  );
@@ -5957,8 +6018,8 @@ var LintFilesAgainstRuleUseCase = class {
5957
6018
  return null;
5958
6019
  }
5959
6020
  }
5960
- async executeProgramsForFile(command21) {
5961
- const result = await this.services.linterExecutionUseCase.execute(command21);
6021
+ async executeProgramsForFile(command22) {
6022
+ const result = await this.services.linterExecutionUseCase.execute(command22);
5962
6023
  return result.violations;
5963
6024
  }
5964
6025
  extractExtensionFromFile(filePath) {
@@ -6015,8 +6076,8 @@ var LintFilesFromConfigUseCase = class {
6015
6076
  }
6016
6077
  return pattern;
6017
6078
  }
6018
- async execute(command21) {
6019
- const { path: userPath, diffMode } = command21;
6079
+ async execute(command22) {
6080
+ const { path: userPath, diffMode } = command22;
6020
6081
  this.logger.debug(
6021
6082
  `Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
6022
6083
  );
@@ -6272,8 +6333,8 @@ var LintFilesFromConfigUseCase = class {
6272
6333
  return null;
6273
6334
  }
6274
6335
  }
6275
- async executeProgramsForFile(command21) {
6276
- const result = await this.services.linterExecutionUseCase.execute(command21);
6336
+ async executeProgramsForFile(command22) {
6337
+ const result = await this.services.linterExecutionUseCase.execute(command22);
6277
6338
  return result.violations;
6278
6339
  }
6279
6340
  extractExtensionFromFile(filePath) {
@@ -6339,10 +6400,10 @@ var PackmindHttpClient = class {
6339
6400
  return null;
6340
6401
  }
6341
6402
  }
6342
- async request(path18, options = {}) {
6403
+ async request(path21, options = {}) {
6343
6404
  const { host } = this.getAuthContext();
6344
6405
  const { method = "GET", body } = options;
6345
- const url = `${host}${path18}`;
6406
+ const url = `${host}${path21}`;
6346
6407
  try {
6347
6408
  const response = await fetch(url, {
6348
6409
  method,
@@ -6389,23 +6450,23 @@ var PackmindHttpClient = class {
6389
6450
  var ChangeProposalGateway = class {
6390
6451
  constructor(httpClient) {
6391
6452
  this.httpClient = httpClient;
6392
- this.batchCreate = async (command21) => {
6453
+ this.batchCreate = async (command22) => {
6393
6454
  const { organizationId } = this.httpClient.getAuthContext();
6394
6455
  return this.httpClient.request(
6395
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/change-proposals/batch`,
6456
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/change-proposals/batch`,
6396
6457
  {
6397
6458
  method: "POST",
6398
- body: { proposals: command21.proposals }
6459
+ body: { proposals: command22.proposals }
6399
6460
  }
6400
6461
  );
6401
6462
  };
6402
- this.check = async (command21) => {
6463
+ this.check = async (command22) => {
6403
6464
  const { organizationId } = this.httpClient.getAuthContext();
6404
6465
  return this.httpClient.request(
6405
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/change-proposals/check`,
6466
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/change-proposals/check`,
6406
6467
  {
6407
6468
  method: "POST",
6408
- body: { proposals: command21.proposals }
6469
+ body: { proposals: command22.proposals }
6409
6470
  }
6410
6471
  );
6411
6472
  };
@@ -6426,13 +6487,13 @@ var CommunityEditionError = class extends Error {
6426
6487
  var LinterGateway = class {
6427
6488
  constructor(httpClient) {
6428
6489
  this.httpClient = httpClient;
6429
- this.getDraftDetectionProgramsForRule = async (command21) => {
6490
+ this.getDraftDetectionProgramsForRule = async (command22) => {
6430
6491
  const payload = {
6431
- standardSlug: command21.standardSlug,
6432
- ruleId: command21.ruleId
6492
+ standardSlug: command22.standardSlug,
6493
+ ruleId: command22.ruleId
6433
6494
  };
6434
- if (command21.language) {
6435
- payload.language = command21.language;
6495
+ if (command22.language) {
6496
+ payload.language = command22.language;
6436
6497
  }
6437
6498
  return this.httpClient.request("/api/v0/list-draft-detection-program", {
6438
6499
  method: "POST",
@@ -6444,13 +6505,13 @@ var LinterGateway = class {
6444
6505
  }
6445
6506
  });
6446
6507
  };
6447
- this.getActiveDetectionProgramsForRule = async (command21) => {
6508
+ this.getActiveDetectionProgramsForRule = async (command22) => {
6448
6509
  const payload = {
6449
- standardSlug: command21.standardSlug,
6450
- ruleId: command21.ruleId
6510
+ standardSlug: command22.standardSlug,
6511
+ ruleId: command22.ruleId
6451
6512
  };
6452
- if (command21.language) {
6453
- payload.language = command21.language;
6513
+ if (command22.language) {
6514
+ payload.language = command22.language;
6454
6515
  }
6455
6516
  return this.httpClient.request("/api/v0/list-active-detection-program", {
6456
6517
  method: "POST",
@@ -6462,13 +6523,13 @@ var LinterGateway = class {
6462
6523
  }
6463
6524
  });
6464
6525
  };
6465
- this.getDetectionProgramsForPackages = async (command21) => {
6526
+ this.getDetectionProgramsForPackages = async (command22) => {
6466
6527
  const response = await this.httpClient.request(
6467
6528
  "/api/v0/detection-programs-for-packages",
6468
6529
  {
6469
6530
  method: "POST",
6470
6531
  body: {
6471
- packagesSlugs: command21.packagesSlugs
6532
+ packagesSlugs: command22.packagesSlugs
6472
6533
  },
6473
6534
  onError: (response2) => {
6474
6535
  if (response2.status === 404) {
@@ -6479,10 +6540,10 @@ var LinterGateway = class {
6479
6540
  );
6480
6541
  return handleScopeInTargetsResponse(response);
6481
6542
  };
6482
- this.trackLinterExecution = async (command21) => {
6543
+ this.trackLinterExecution = async (command22) => {
6483
6544
  return this.httpClient.request(`/api/v0/track-execution`, {
6484
6545
  method: "POST",
6485
- body: command21
6546
+ body: command22
6486
6547
  });
6487
6548
  };
6488
6549
  }
@@ -6540,27 +6601,27 @@ var SpacesGateway = class {
6540
6601
  var SkillsGateway = class {
6541
6602
  constructor(httpClient) {
6542
6603
  this.httpClient = httpClient;
6543
- this.upload = async (command21) => {
6604
+ this.upload = async (command22) => {
6544
6605
  const { organizationId } = this.httpClient.getAuthContext();
6545
6606
  return this.httpClient.request(
6546
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/skills/upload`,
6607
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/skills/upload`,
6547
6608
  {
6548
6609
  method: "POST",
6549
- body: command21
6610
+ body: command22
6550
6611
  }
6551
6612
  );
6552
6613
  };
6553
- this.getDefaults = async (command21) => {
6614
+ this.getDefaults = async (command22) => {
6554
6615
  const { organizationId } = this.httpClient.getAuthContext();
6555
6616
  const queryParams = new URLSearchParams();
6556
- if (command21.includeBeta) {
6617
+ if (command22.includeBeta) {
6557
6618
  queryParams.set("includeBeta", "true");
6558
- } else if (command21.cliVersion) {
6559
- queryParams.set("cliVersion", command21.cliVersion);
6619
+ } else if (command22.cliVersion) {
6620
+ queryParams.set("cliVersion", command22.cliVersion);
6560
6621
  }
6561
- if (command21.agents !== void 0) {
6622
+ if (command22.agents !== void 0) {
6562
6623
  queryParams.append("agentsConfigOverride", "true");
6563
- command21.agents.forEach((agent) => {
6624
+ command22.agents.forEach((agent) => {
6564
6625
  queryParams.append("agent", agent);
6565
6626
  });
6566
6627
  }
@@ -6569,10 +6630,10 @@ var SkillsGateway = class {
6569
6630
  `/api/v0/organizations/${organizationId}/skills/default${queryString ? `?${queryString}` : ""}`
6570
6631
  );
6571
6632
  };
6572
- this.list = async (command21) => {
6633
+ this.list = async (command22) => {
6573
6634
  const { organizationId } = this.httpClient.getAuthContext();
6574
6635
  return this.httpClient.request(
6575
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/skills`
6636
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/skills`
6576
6637
  );
6577
6638
  };
6578
6639
  }
@@ -6582,17 +6643,17 @@ var SkillsGateway = class {
6582
6643
  var CommandsGateway = class {
6583
6644
  constructor(httpClient) {
6584
6645
  this.httpClient = httpClient;
6585
- this.create = async (command21) => {
6646
+ this.create = async (command22) => {
6586
6647
  const { organizationId } = this.httpClient.getAuthContext();
6587
6648
  return this.httpClient.request(
6588
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/recipes`,
6589
- { method: "POST", body: command21 }
6649
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/recipes`,
6650
+ { method: "POST", body: command22 }
6590
6651
  );
6591
6652
  };
6592
- this.list = async (command21) => {
6653
+ this.list = async (command22) => {
6593
6654
  const { organizationId } = this.httpClient.getAuthContext();
6594
6655
  const listRecipesResponse = await this.httpClient.request(
6595
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/recipes`
6656
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/recipes`
6596
6657
  );
6597
6658
  if (listRecipesResponse instanceof Array) {
6598
6659
  return { recipes: listRecipesResponse };
@@ -6634,10 +6695,10 @@ var StandardsGateway = class {
6634
6695
  }
6635
6696
  );
6636
6697
  };
6637
- this.list = async (command21) => {
6698
+ this.list = async (command22) => {
6638
6699
  const { organizationId } = this.httpClient.getAuthContext();
6639
6700
  return this.httpClient.request(
6640
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/standards`
6701
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/standards`
6641
6702
  );
6642
6703
  };
6643
6704
  }
@@ -6660,24 +6721,24 @@ var PackagesGateway = class {
6660
6721
  `/api/v0/organizations/${organizationId}/packages/${encodeURIComponent(slug)}`
6661
6722
  );
6662
6723
  };
6663
- this.create = async (command21) => {
6724
+ this.create = async (command22) => {
6664
6725
  const { organizationId } = this.httpClient.getAuthContext();
6665
6726
  return this.httpClient.request(
6666
- `/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/packages`,
6727
+ `/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/packages`,
6667
6728
  {
6668
6729
  method: "POST",
6669
- body: command21
6730
+ body: command22
6670
6731
  }
6671
6732
  );
6672
6733
  };
6673
- this.addArtefacts = async (command21) => {
6734
+ this.addArtefacts = async (command22) => {
6674
6735
  const { organizationId } = this.httpClient.getAuthContext();
6675
- const { packageId, spaceId } = command21;
6736
+ const { packageId, spaceId } = command22;
6676
6737
  return this.httpClient.request(
6677
6738
  `/api/v0/organizations/${organizationId}/spaces/${spaceId}/packages/${packageId}/add-artifacts`,
6678
6739
  {
6679
6740
  method: "POST",
6680
- body: command21
6741
+ body: command22
6681
6742
  }
6682
6743
  );
6683
6744
  };
@@ -6688,31 +6749,31 @@ var PackagesGateway = class {
6688
6749
  var DeploymentGateway = class {
6689
6750
  constructor(httpClient) {
6690
6751
  this.httpClient = httpClient;
6691
- this.pull = async (command21) => {
6752
+ this.pull = async (command22) => {
6692
6753
  const { organizationId } = this.httpClient.getAuthContext();
6693
6754
  const queryParams = new URLSearchParams();
6694
- if (command21.packagesSlugs && command21.packagesSlugs.length > 0) {
6695
- command21.packagesSlugs.forEach((slug) => {
6755
+ if (command22.packagesSlugs && command22.packagesSlugs.length > 0) {
6756
+ command22.packagesSlugs.forEach((slug) => {
6696
6757
  queryParams.append("packageSlug", slug);
6697
6758
  });
6698
6759
  }
6699
- if (command21.previousPackagesSlugs && command21.previousPackagesSlugs.length > 0) {
6700
- command21.previousPackagesSlugs.forEach((slug) => {
6760
+ if (command22.previousPackagesSlugs && command22.previousPackagesSlugs.length > 0) {
6761
+ command22.previousPackagesSlugs.forEach((slug) => {
6701
6762
  queryParams.append("previousPackageSlug", slug);
6702
6763
  });
6703
6764
  }
6704
- if (command21.gitRemoteUrl) {
6705
- queryParams.append("gitRemoteUrl", command21.gitRemoteUrl);
6765
+ if (command22.gitRemoteUrl) {
6766
+ queryParams.append("gitRemoteUrl", command22.gitRemoteUrl);
6706
6767
  }
6707
- if (command21.gitBranch) {
6708
- queryParams.append("gitBranch", command21.gitBranch);
6768
+ if (command22.gitBranch) {
6769
+ queryParams.append("gitBranch", command22.gitBranch);
6709
6770
  }
6710
- if (command21.relativePath) {
6711
- queryParams.append("relativePath", command21.relativePath);
6771
+ if (command22.relativePath) {
6772
+ queryParams.append("relativePath", command22.relativePath);
6712
6773
  }
6713
- if (command21.agents !== void 0) {
6774
+ if (command22.agents !== void 0) {
6714
6775
  queryParams.append("agentsConfigOverride", "true");
6715
- command21.agents.forEach((agent) => {
6776
+ command22.agents.forEach((agent) => {
6716
6777
  queryParams.append("agent", agent);
6717
6778
  });
6718
6779
  }
@@ -6720,29 +6781,29 @@ var DeploymentGateway = class {
6720
6781
  `/api/v0/organizations/${organizationId}/pull?${queryParams.toString()}`
6721
6782
  );
6722
6783
  };
6723
- this.getDeployed = async (command21) => {
6784
+ this.getDeployed = async (command22) => {
6724
6785
  const { organizationId } = this.httpClient.getAuthContext();
6725
6786
  return this.httpClient.request(
6726
6787
  `/api/v0/organizations/${organizationId}/deployed-content`,
6727
6788
  {
6728
6789
  method: "POST",
6729
6790
  body: {
6730
- packagesSlugs: command21.packagesSlugs,
6731
- gitRemoteUrl: command21.gitRemoteUrl,
6732
- gitBranch: command21.gitBranch,
6733
- relativePath: command21.relativePath,
6734
- ...command21.agents !== void 0 && { agents: command21.agents }
6791
+ packagesSlugs: command22.packagesSlugs,
6792
+ gitRemoteUrl: command22.gitRemoteUrl,
6793
+ gitBranch: command22.gitBranch,
6794
+ relativePath: command22.relativePath,
6795
+ ...command22.agents !== void 0 && { agents: command22.agents }
6735
6796
  }
6736
6797
  }
6737
6798
  );
6738
6799
  };
6739
- this.notifyDistribution = async (command21) => {
6800
+ this.notifyDistribution = async (command22) => {
6740
6801
  const { organizationId } = this.httpClient.getAuthContext();
6741
6802
  return this.httpClient.request(
6742
6803
  `/api/v0/organizations/${organizationId}/deployments`,
6743
6804
  {
6744
6805
  method: "POST",
6745
- body: command21
6806
+ body: command22
6746
6807
  }
6747
6808
  );
6748
6809
  };
@@ -8512,8 +8573,8 @@ var ExecuteLinterProgramsUseCase = class {
8512
8573
  this.linterAstAdapter = linterAstAdapter;
8513
8574
  this.logger = logger2;
8514
8575
  }
8515
- async execute(command21) {
8516
- const { filePath, fileContent, language, programs } = command21;
8576
+ async execute(command22) {
8577
+ const { filePath, fileContent, language, programs } = command22;
8517
8578
  if (programs.length === 0) {
8518
8579
  return {
8519
8580
  file: filePath,
@@ -9290,8 +9351,8 @@ var InstallPackagesUseCase = class {
9290
9351
  constructor(packmindGateway) {
9291
9352
  this.packmindGateway = packmindGateway;
9292
9353
  }
9293
- async execute(command21) {
9294
- const baseDirectory = command21.baseDirectory || process.cwd();
9354
+ async execute(command22) {
9355
+ const baseDirectory = command22.baseDirectory || process.cwd();
9295
9356
  const result = {
9296
9357
  filesCreated: 0,
9297
9358
  filesUpdated: 0,
@@ -9303,12 +9364,12 @@ var InstallPackagesUseCase = class {
9303
9364
  skillDirectoriesDeleted: 0
9304
9365
  };
9305
9366
  const response = await this.packmindGateway.deployment.pull({
9306
- packagesSlugs: command21.packagesSlugs,
9307
- previousPackagesSlugs: command21.previousPackagesSlugs,
9308
- gitRemoteUrl: command21.gitRemoteUrl,
9309
- gitBranch: command21.gitBranch,
9310
- relativePath: command21.relativePath,
9311
- agents: command21.agents
9367
+ packagesSlugs: command22.packagesSlugs,
9368
+ previousPackagesSlugs: command22.previousPackagesSlugs,
9369
+ gitRemoteUrl: command22.gitRemoteUrl,
9370
+ gitBranch: command22.gitBranch,
9371
+ relativePath: command22.relativePath,
9372
+ agents: command22.agents
9312
9373
  });
9313
9374
  const filteredCreateOrUpdate = response.fileUpdates.createOrUpdate.filter(
9314
9375
  (file) => file.path !== "packmind.json"
@@ -9594,8 +9655,8 @@ var InstallDefaultSkillsUseCase = class {
9594
9655
  constructor(repositories) {
9595
9656
  this.repositories = repositories;
9596
9657
  }
9597
- async execute(command21) {
9598
- const baseDirectory = command21.baseDirectory || process.cwd();
9658
+ async execute(command22) {
9659
+ const baseDirectory = command22.baseDirectory || process.cwd();
9599
9660
  const result = {
9600
9661
  filesCreated: 0,
9601
9662
  filesUpdated: 0,
@@ -9605,8 +9666,8 @@ var InstallDefaultSkillsUseCase = class {
9605
9666
  const agents = config?.agents;
9606
9667
  const response = await this.repositories.packmindGateway.skills.getDefaults(
9607
9668
  {
9608
- cliVersion: command21.cliVersion,
9609
- includeBeta: command21.includeBeta,
9669
+ cliVersion: command22.cliVersion,
9670
+ includeBeta: command22.includeBeta,
9610
9671
  agents
9611
9672
  }
9612
9673
  );
@@ -9671,8 +9732,8 @@ var GetPackageSummaryUseCase = class {
9671
9732
  constructor(gateway) {
9672
9733
  this.gateway = gateway;
9673
9734
  }
9674
- async execute(command21) {
9675
- return this.gateway.packages.getSummary(command21);
9735
+ async execute(command22) {
9736
+ return this.gateway.packages.getSummary(command22);
9676
9737
  }
9677
9738
  };
9678
9739
 
@@ -9863,10 +9924,10 @@ async function defaultPromptForCode() {
9863
9924
  input: process.stdin,
9864
9925
  output: process.stdout
9865
9926
  });
9866
- return new Promise((resolve7) => {
9927
+ return new Promise((resolve8) => {
9867
9928
  rl.question("Enter the login code from the browser: ", (answer) => {
9868
9929
  rl.close();
9869
- resolve7(answer.trim());
9930
+ resolve8(answer.trim());
9870
9931
  });
9871
9932
  });
9872
9933
  }
@@ -9900,7 +9961,7 @@ async function defaultExchangeCodeForApiKey(code, host) {
9900
9961
  return await response.json();
9901
9962
  }
9902
9963
  function defaultStartCallbackServer() {
9903
- return new Promise((resolve7, reject) => {
9964
+ return new Promise((resolve8, reject) => {
9904
9965
  let timeoutId = null;
9905
9966
  const server = http.createServer((req, res) => {
9906
9967
  res.setHeader("Access-Control-Allow-Origin", "*");
@@ -9913,7 +9974,7 @@ function defaultStartCallbackServer() {
9913
9974
  if (timeoutId) {
9914
9975
  clearTimeout(timeoutId);
9915
9976
  }
9916
- resolve7(code);
9977
+ resolve8(code);
9917
9978
  setImmediate(() => {
9918
9979
  server.close();
9919
9980
  });
@@ -9951,8 +10012,8 @@ var LoginUseCase = class {
9951
10012
  startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
9952
10013
  };
9953
10014
  }
9954
- async execute(command21) {
9955
- const { host, code: providedCode } = command21;
10015
+ async execute(command22) {
10016
+ const { host, code: providedCode } = command22;
9956
10017
  let code;
9957
10018
  if (providedCode) {
9958
10019
  code = providedCode;
@@ -9990,8 +10051,8 @@ var LogoutUseCase = class {
9990
10051
  constructor(deps) {
9991
10052
  this.deps = {
9992
10053
  getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
9993
- fileExists: deps?.fileExists ?? ((path18) => fs7.existsSync(path18)),
9994
- deleteFile: deps?.deleteFile ?? ((path18) => fs7.unlinkSync(path18)),
10054
+ fileExists: deps?.fileExists ?? ((path21) => fs7.existsSync(path21)),
10055
+ deleteFile: deps?.deleteFile ?? ((path21) => fs7.unlinkSync(path21)),
9995
10056
  hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
9996
10057
  };
9997
10058
  }
@@ -10051,8 +10112,8 @@ var SetupMcpUseCase = class {
10051
10112
  constructor(deps) {
10052
10113
  this.deps = deps;
10053
10114
  }
10054
- async execute(command21) {
10055
- const { agentTypes } = command21;
10115
+ async execute(command22) {
10116
+ const { agentTypes } = command22;
10056
10117
  const [tokenResult, urlResult] = await Promise.all([
10057
10118
  this.deps.gateway.mcp.getToken({}),
10058
10119
  this.deps.gateway.mcp.getUrl({})
@@ -10123,9 +10184,9 @@ var McpConfigService = class {
10123
10184
  return JSON.stringify(mcpConfig, null, 2);
10124
10185
  }
10125
10186
  installClaudeMcp(config) {
10126
- const command21 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
10187
+ const command22 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
10127
10188
  try {
10128
- (0, import_child_process2.execSync)(command21, { stdio: "pipe" });
10189
+ (0, import_child_process2.execSync)(command22, { stdio: "pipe" });
10129
10190
  return { success: true };
10130
10191
  } catch (error) {
10131
10192
  const execError = error;
@@ -10622,6 +10683,11 @@ var import_promises = __toESM(require("fs/promises"));
10622
10683
  var import_path2 = __toESM(require("path"));
10623
10684
  var import_minimatch3 = require("minimatch");
10624
10685
 
10686
+ // apps/cli/src/application/utils/normalizeLineEndings.ts
10687
+ function normalizeLineEndings(content) {
10688
+ return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
10689
+ }
10690
+
10625
10691
  // apps/cli/src/infra/utils/binaryDetection.ts
10626
10692
  var path10 = __toESM(require("path"));
10627
10693
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -10699,9 +10765,6 @@ function normalizePath2(filePath) {
10699
10765
  }
10700
10766
  return normalized;
10701
10767
  }
10702
- function normalizeLineEndings(content) {
10703
- return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
10704
- }
10705
10768
  var MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
10706
10769
  var MAX_FILE_SIZE_MB = 10;
10707
10770
  var BLACKLIST_PATTERNS = ["**/.DS_Store"];
@@ -10760,8 +10823,8 @@ var UploadSkillUseCase = class {
10760
10823
  constructor(deps) {
10761
10824
  this.deps = deps;
10762
10825
  }
10763
- async execute(command21) {
10764
- const files = await readSkillDirectory(command21.skillPath);
10826
+ async execute(command22) {
10827
+ const files = await readSkillDirectory(command22.skillPath);
10765
10828
  if (!files.find((f) => f.relativePath === "SKILL.md")) {
10766
10829
  throw new Error("SKILL.md not found in skill directory");
10767
10830
  }
@@ -10787,7 +10850,7 @@ var UploadSkillUseCase = class {
10787
10850
  const uploadSkillResponse = await this.deps.gateway.skills.upload({
10788
10851
  spaceId: createSpaceId(space.id),
10789
10852
  files: payload.files,
10790
- originSkill: command21.originSkill
10853
+ originSkill: command22.originSkill
10791
10854
  });
10792
10855
  return {
10793
10856
  skillId: uploadSkillResponse.skill.id,
@@ -10809,6 +10872,7 @@ var path12 = __toESM(require("path"));
10809
10872
  // apps/cli/src/application/utils/stripFrontmatter.ts
10810
10873
  var FRONTMATTER_DELIMITER2 = "---";
10811
10874
  function stripFrontmatter(content) {
10875
+ content = normalizeLineEndings(content);
10812
10876
  if (!content.startsWith(`${FRONTMATTER_DELIMITER2}
10813
10877
  `)) {
10814
10878
  return content;
@@ -11253,7 +11317,18 @@ function parseStandardMd(content, filePath) {
11253
11317
  }
11254
11318
  return deployer.parse(content);
11255
11319
  }
11320
+ var AGENT_PARSERS = {
11321
+ packmind: parsePackmindStandard,
11322
+ claude: parseClaudeStandard,
11323
+ cursor: parseCursorStandard,
11324
+ continue: parseContinueStandard,
11325
+ copilot: parseCopilotStandard
11326
+ };
11327
+ function parseStandardMdForAgent(content, agent) {
11328
+ return AGENT_PARSERS[agent](content);
11329
+ }
11256
11330
  function parsePackmindStandard(content) {
11331
+ content = normalizeLineEndings(content);
11257
11332
  const lines = content.split("\n");
11258
11333
  let name = null;
11259
11334
  let nameLineIndex = -1;
@@ -11303,7 +11378,7 @@ function parsePackmindStandard(content) {
11303
11378
  }
11304
11379
  function parseClaudeStandard(content) {
11305
11380
  const { frontmatter, body } = extractFrontmatter(content);
11306
- const scope = extractScopeFromKey(frontmatter, "paths");
11381
+ const scope = extractScopeFromKey(frontmatter, "paths") || extractScopeFromKey(frontmatter, "globs");
11307
11382
  const parsed = parseIdeStandardBody(body, scope);
11308
11383
  if (!parsed) return null;
11309
11384
  return addFrontmatterFields(parsed, frontmatter);
@@ -11350,6 +11425,7 @@ function extractRulesList(lines, startIndex) {
11350
11425
  return rules;
11351
11426
  }
11352
11427
  function extractFrontmatter(content) {
11428
+ content = normalizeLineEndings(content);
11353
11429
  const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
11354
11430
  if (!match) {
11355
11431
  return { frontmatter: "", body: content };
@@ -11424,8 +11500,17 @@ function stripYamlQuotes(value) {
11424
11500
  }
11425
11501
  function extractScopeFromKey(frontmatter, key) {
11426
11502
  const rawValue = extractFrontmatterValue(frontmatter, key);
11427
- if (!rawValue) return "";
11428
- return normalizeScopeValue(rawValue);
11503
+ if (rawValue) return normalizeScopeValue(rawValue);
11504
+ const lines = frontmatter.split("\n");
11505
+ const keyIndex = lines.findIndex((l) => l.trim() === `${key}:`);
11506
+ if (keyIndex === -1) return "";
11507
+ const items = [];
11508
+ for (let i = keyIndex + 1; i < lines.length; i++) {
11509
+ const match = lines[i].match(/^ +-\s(.+)$/);
11510
+ if (!match) break;
11511
+ items.push(stripYamlQuotes(match[1].trim()));
11512
+ }
11513
+ return items.join(", ");
11429
11514
  }
11430
11515
  function normalizeScopeValue(rawValue) {
11431
11516
  if (!rawValue) return "";
@@ -11633,14 +11718,14 @@ var DiffArtefactsUseCase = class {
11633
11718
  new StandardDiffStrategy()
11634
11719
  ];
11635
11720
  }
11636
- async execute(command21) {
11637
- const baseDirectory = command21.baseDirectory || process.cwd();
11721
+ async execute(command22) {
11722
+ const baseDirectory = command22.baseDirectory || process.cwd();
11638
11723
  const response = await this.packmindGateway.deployment.getDeployed({
11639
- packagesSlugs: command21.packagesSlugs,
11640
- gitRemoteUrl: command21.gitRemoteUrl,
11641
- gitBranch: command21.gitBranch,
11642
- relativePath: command21.relativePath,
11643
- agents: command21.agents
11724
+ packagesSlugs: command22.packagesSlugs,
11725
+ gitRemoteUrl: command22.gitRemoteUrl,
11726
+ gitBranch: command22.gitBranch,
11727
+ relativePath: command22.relativePath,
11728
+ agents: command22.agents
11644
11729
  });
11645
11730
  const filteredFiles = response.fileUpdates.createOrUpdate.filter(
11646
11731
  (file) => file.path !== "packmind.json"
@@ -11654,7 +11739,7 @@ var DiffArtefactsUseCase = class {
11654
11739
  );
11655
11740
  const prefixedSkillFolders = this.prefixSkillFolders(
11656
11741
  response.skillFolders,
11657
- command21.relativePath
11742
+ command22.relativePath
11658
11743
  );
11659
11744
  const diffs = [];
11660
11745
  for (const file of diffableFiles) {
@@ -11690,12 +11775,17 @@ var DiffArtefactsUseCase = class {
11690
11775
 
11691
11776
  // apps/cli/src/application/useCases/SubmitDiffsUseCase.ts
11692
11777
  var SUPPORTED_ARTIFACT_TYPES = /* @__PURE__ */ new Set(["command", "skill", "standard"]);
11778
+ var CREATION_TYPES = /* @__PURE__ */ new Set([
11779
+ "createStandard" /* createStandard */,
11780
+ "createCommand" /* createCommand */,
11781
+ "createSkill" /* createSkill */
11782
+ ]);
11693
11783
  var SubmitDiffsUseCase = class {
11694
11784
  constructor(packmindGateway) {
11695
11785
  this.packmindGateway = packmindGateway;
11696
11786
  }
11697
- async execute(command21) {
11698
- const { groupedDiffs, message } = command21;
11787
+ async execute(command22) {
11788
+ const { groupedDiffs, message } = command22;
11699
11789
  const skipped = [];
11700
11790
  const validDiffs = [];
11701
11791
  for (const group of groupedDiffs) {
@@ -11711,7 +11801,14 @@ var SubmitDiffsUseCase = class {
11711
11801
  continue;
11712
11802
  }
11713
11803
  for (const diff of group) {
11714
- if (!diff.artifactId || !diff.spaceId) {
11804
+ if (!diff.spaceId) {
11805
+ skipped.push({
11806
+ name: diff.artifactName,
11807
+ reason: "Missing artifact metadata"
11808
+ });
11809
+ continue;
11810
+ }
11811
+ if (!diff.artifactId && !CREATION_TYPES.has(diff.type)) {
11715
11812
  skipped.push({
11716
11813
  name: diff.artifactName,
11717
11814
  reason: "Missing artifact metadata"
@@ -11735,7 +11832,7 @@ var SubmitDiffsUseCase = class {
11735
11832
  spaceId,
11736
11833
  proposals: diffs.map((diff) => ({
11737
11834
  type: diff.type,
11738
- artefactId: diff.artifactId,
11835
+ artefactId: CREATION_TYPES.has(diff.type) ? null : diff.artifactId,
11739
11836
  payload: diff.payload,
11740
11837
  captureMode: "commit" /* commit */,
11741
11838
  message
@@ -11762,8 +11859,8 @@ var CheckDiffsUseCase = class {
11762
11859
  constructor(packmindGateway) {
11763
11860
  this.packmindGateway = packmindGateway;
11764
11861
  }
11765
- async execute(command21) {
11766
- const { groupedDiffs } = command21;
11862
+ async execute(command22) {
11863
+ const { groupedDiffs } = command22;
11767
11864
  const results = [];
11768
11865
  const validDiffs = [];
11769
11866
  const invalidDiffs = [];
@@ -11881,9 +11978,9 @@ var PackmindCliHexaFactory = class {
11881
11978
  var origin8 = "PackmindCliHexa";
11882
11979
  var PackmindCliHexa = class {
11883
11980
  constructor(logger2 = new PackmindLogger(origin8)) {
11884
- this.notifyDistribution = async (command21) => {
11981
+ this.notifyDistribution = async (command22) => {
11885
11982
  return this.hexa.repositories.packmindGateway.deployment.notifyDistribution(
11886
- command21
11983
+ command22
11887
11984
  );
11888
11985
  };
11889
11986
  this.logger = logger2;
@@ -11903,26 +12000,26 @@ var PackmindCliHexa = class {
11903
12000
  this.logger.info("Destroying PackmindCliHexa");
11904
12001
  this.logger.info("PackmindCliHexa destroyed");
11905
12002
  }
11906
- async getGitRemoteUrl(command21) {
11907
- return this.hexa.useCases.getGitRemoteUrl.execute(command21);
12003
+ async getGitRemoteUrl(command22) {
12004
+ return this.hexa.useCases.getGitRemoteUrl.execute(command22);
11908
12005
  }
11909
- async executeSingleFileAst(command21) {
11910
- return this.hexa.useCases.executeSingleFileAst.execute(command21);
12006
+ async executeSingleFileAst(command22) {
12007
+ return this.hexa.useCases.executeSingleFileAst.execute(command22);
11911
12008
  }
11912
- async listFilesInDirectory(command21) {
11913
- return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command21);
12009
+ async listFilesInDirectory(command22) {
12010
+ return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command22);
11914
12011
  }
11915
- async lintFilesAgainstRule(command21) {
11916
- return this.hexa.useCases.lintFilesAgainstRule.execute(command21);
12012
+ async lintFilesAgainstRule(command22) {
12013
+ return this.hexa.useCases.lintFilesAgainstRule.execute(command22);
11917
12014
  }
11918
- async lintFilesFromConfig(command21) {
11919
- return this.hexa.useCases.lintFilesFromConfig.execute(command21);
12015
+ async lintFilesFromConfig(command22) {
12016
+ return this.hexa.useCases.lintFilesFromConfig.execute(command22);
11920
12017
  }
11921
- async installPackages(command21) {
11922
- return this.hexa.useCases.installPackages.execute(command21);
12018
+ async installPackages(command22) {
12019
+ return this.hexa.useCases.installPackages.execute(command22);
11923
12020
  }
11924
- async diffArtefacts(command21) {
11925
- return this.hexa.useCases.diffArtefacts.execute(command21);
12021
+ async diffArtefacts(command22) {
12022
+ return this.hexa.useCases.diffArtefacts.execute(command22);
11926
12023
  }
11927
12024
  async submitDiffs(groupedDiffs, message) {
11928
12025
  return this.hexa.useCases.submitDiffs.execute({ groupedDiffs, message });
@@ -11930,20 +12027,20 @@ var PackmindCliHexa = class {
11930
12027
  async checkDiffs(groupedDiffs) {
11931
12028
  return this.hexa.useCases.checkDiffs.execute({ groupedDiffs });
11932
12029
  }
11933
- async listPackages(command21) {
11934
- return this.hexa.useCases.listPackages.execute(command21);
12030
+ async listPackages(command22) {
12031
+ return this.hexa.useCases.listPackages.execute(command22);
11935
12032
  }
11936
- async getPackageBySlug(command21) {
11937
- return this.hexa.useCases.getPackageBySlug.execute(command21);
12033
+ async getPackageBySlug(command22) {
12034
+ return this.hexa.useCases.getPackageBySlug.execute(command22);
11938
12035
  }
11939
- async listStandards(command21) {
11940
- return this.hexa.useCases.listStandards.execute(command21);
12036
+ async listStandards(command22) {
12037
+ return this.hexa.useCases.listStandards.execute(command22);
11941
12038
  }
11942
- async listCommands(command21) {
11943
- return this.hexa.useCases.listCommands.execute(command21);
12039
+ async listCommands(command22) {
12040
+ return this.hexa.useCases.listCommands.execute(command22);
11944
12041
  }
11945
- async listSkills(command21) {
11946
- return this.hexa.useCases.listSkills.execute(command21);
12042
+ async listSkills(command22) {
12043
+ return this.hexa.useCases.listSkills.execute(command22);
11947
12044
  }
11948
12045
  async configExists(baseDirectory) {
11949
12046
  return await this.hexa.repositories.configFileRepository.configExists(
@@ -12030,17 +12127,17 @@ var PackmindCliHexa = class {
12030
12127
  directory
12031
12128
  );
12032
12129
  }
12033
- async login(command21) {
12034
- return this.hexa.useCases.login.execute(command21);
12130
+ async login(command22) {
12131
+ return this.hexa.useCases.login.execute(command22);
12035
12132
  }
12036
- async logout(command21) {
12037
- return this.hexa.useCases.logout.execute(command21);
12133
+ async logout(command22) {
12134
+ return this.hexa.useCases.logout.execute(command22);
12038
12135
  }
12039
- async whoami(command21) {
12040
- return this.hexa.useCases.whoami.execute(command21);
12136
+ async whoami(command22) {
12137
+ return this.hexa.useCases.whoami.execute(command22);
12041
12138
  }
12042
- async setupMcp(command21) {
12043
- return this.hexa.useCases.setupMcp.execute(command21);
12139
+ async setupMcp(command22) {
12140
+ return this.hexa.useCases.setupMcp.execute(command22);
12044
12141
  }
12045
12142
  getCurrentBranch(repoPath) {
12046
12143
  return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
@@ -12048,11 +12145,11 @@ var PackmindCliHexa = class {
12048
12145
  getGitRemoteUrlFromPath(repoPath) {
12049
12146
  return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
12050
12147
  }
12051
- async uploadSkill(command21) {
12052
- return this.hexa.useCases.uploadSkill.execute(command21);
12148
+ async uploadSkill(command22) {
12149
+ return this.hexa.useCases.uploadSkill.execute(command22);
12053
12150
  }
12054
- async installDefaultSkills(command21) {
12055
- return this.hexa.useCases.installDefaultSkills.execute(command21);
12151
+ async installDefaultSkills(command22) {
12152
+ return this.hexa.useCases.installDefaultSkills.execute(command22);
12056
12153
  }
12057
12154
  getPackmindGateway() {
12058
12155
  return this.hexa.repositories.packmindGateway;
@@ -12164,7 +12261,7 @@ function isNotLoggedInError(error) {
12164
12261
  }
12165
12262
  async function lintHandler(args2, deps) {
12166
12263
  const {
12167
- path: path18,
12264
+ path: path21,
12168
12265
  draft,
12169
12266
  rule,
12170
12267
  language,
@@ -12185,7 +12282,7 @@ async function lintHandler(args2, deps) {
12185
12282
  throw new Error("option --rule is required to use --draft mode");
12186
12283
  }
12187
12284
  const startedAt = Date.now();
12188
- const targetPath = path18 ?? ".";
12285
+ const targetPath = path21 ?? ".";
12189
12286
  const absolutePath = resolvePath(targetPath);
12190
12287
  if (diff) {
12191
12288
  const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
@@ -12468,7 +12565,7 @@ function extractWasmFiles() {
12468
12565
  // apps/cli/src/main.ts
12469
12566
  var import_dotenv = require("dotenv");
12470
12567
  var fs19 = __toESM(require("fs"));
12471
- var path17 = __toESM(require("path"));
12568
+ var path20 = __toESM(require("path"));
12472
12569
 
12473
12570
  // apps/cli/src/infra/commands/InstallCommand.ts
12474
12571
  var import_cmd_ts2 = __toESM(require_cjs());
@@ -13587,10 +13684,10 @@ var AgentDetectionService = class {
13587
13684
  const continueDir = path15.join(this.projectDir, ".continue");
13588
13685
  return fs14.existsSync(continueDir);
13589
13686
  }
13590
- isCommandAvailable(command21) {
13687
+ isCommandAvailable(command22) {
13591
13688
  try {
13592
13689
  const whichCommand = process.platform === "win32" ? "where" : "which";
13593
- (0, import_child_process3.execSync)(`${whichCommand} ${command21}`, { stdio: "pipe" });
13690
+ (0, import_child_process3.execSync)(`${whichCommand} ${command22}`, { stdio: "pipe" });
13594
13691
  return true;
13595
13692
  } catch {
13596
13693
  return false;
@@ -13639,7 +13736,7 @@ async function promptAgentsWithReadline(choices) {
13639
13736
  output.write("\n");
13640
13737
  const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
13641
13738
  const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
13642
- return new Promise((resolve7) => {
13739
+ return new Promise((resolve8) => {
13643
13740
  rl.question(
13644
13741
  `Enter numbers separated by commas (default: ${defaultValue}): `,
13645
13742
  (answer) => {
@@ -13650,7 +13747,7 @@ async function promptAgentsWithReadline(choices) {
13650
13747
  const numbersStr = trimmed === "" ? defaultValue : trimmed;
13651
13748
  const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
13652
13749
  const selectedAgents = numbers.map((n) => choices[n - 1].value);
13653
- resolve7(selectedAgents);
13750
+ resolve8(selectedAgents);
13654
13751
  }
13655
13752
  );
13656
13753
  });
@@ -14415,7 +14512,7 @@ var CreateCommandFromPlaybookUseCase = class {
14415
14512
  }
14416
14513
  async execute(playbook) {
14417
14514
  const space = await this.gateway.spaces.getGlobal();
14418
- const command21 = await this.gateway.commands.create({
14515
+ const command22 = await this.gateway.commands.create({
14419
14516
  spaceId: space.id,
14420
14517
  name: playbook.name,
14421
14518
  summary: playbook.summary,
@@ -14429,9 +14526,9 @@ var CreateCommandFromPlaybookUseCase = class {
14429
14526
  originSkill: playbook.originSkill
14430
14527
  });
14431
14528
  return {
14432
- commandId: command21.id,
14433
- name: command21.name,
14434
- slug: command21.slug
14529
+ commandId: command22.id,
14530
+ name: command22.name,
14531
+ slug: command22.slug
14435
14532
  };
14436
14533
  }
14437
14534
  };
@@ -14559,6 +14656,7 @@ var commandsCommand = (0, import_cmd_ts18.subcommands)({
14559
14656
  });
14560
14657
 
14561
14658
  // apps/cli/src/infra/commands/DiffCommand.ts
14659
+ var import_fs20 = require("fs");
14562
14660
  var import_cmd_ts19 = __toESM(require_cjs());
14563
14661
 
14564
14662
  // apps/cli/src/infra/utils/diffFormatter.ts
@@ -15049,6 +15147,383 @@ async function diffArtefactsHandler(deps) {
15049
15147
  }
15050
15148
  }
15051
15149
 
15150
+ // apps/cli/src/infra/commands/diffAddHandler.ts
15151
+ var path17 = __toESM(require("path"));
15152
+
15153
+ // apps/cli/src/application/utils/resolveArtefactFromPath.ts
15154
+ function resolveArtefactFromPath(filePath) {
15155
+ const normalized = normalizePath(filePath);
15156
+ for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
15157
+ if (paths.command && normalized.includes(paths.command)) {
15158
+ return {
15159
+ artifactType: "command",
15160
+ codingAgent: agent
15161
+ };
15162
+ }
15163
+ }
15164
+ for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
15165
+ if (paths.standard && normalized.includes(paths.standard)) {
15166
+ return {
15167
+ artifactType: "standard",
15168
+ codingAgent: agent
15169
+ };
15170
+ }
15171
+ }
15172
+ for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
15173
+ if (paths.skill && normalized.includes(paths.skill)) {
15174
+ return {
15175
+ artifactType: "skill",
15176
+ codingAgent: agent
15177
+ };
15178
+ }
15179
+ }
15180
+ return null;
15181
+ }
15182
+
15183
+ // apps/cli/src/application/utils/parseCommandFile.ts
15184
+ var path16 = __toESM(require("path"));
15185
+ var FRONTMATTER_DELIMITER3 = "---";
15186
+ function parseCommandFile(content, filePath) {
15187
+ content = normalizeLineEndings(content);
15188
+ if (!content || content.trim().length === 0) {
15189
+ return { success: false, error: "File is empty" };
15190
+ }
15191
+ if (content.startsWith(`${FRONTMATTER_DELIMITER3}
15192
+ `)) {
15193
+ const contentAfterOpening = content.slice(FRONTMATTER_DELIMITER3.length + 1);
15194
+ const closingIndex = contentAfterOpening.indexOf(
15195
+ `
15196
+ ${FRONTMATTER_DELIMITER3}`
15197
+ );
15198
+ if (closingIndex === -1) {
15199
+ return {
15200
+ success: false,
15201
+ error: "Malformed frontmatter: opening --- without closing ---"
15202
+ };
15203
+ }
15204
+ const frontmatter = contentAfterOpening.slice(0, closingIndex);
15205
+ const name2 = resolveName(frontmatter, filePath);
15206
+ return { success: true, parsed: { name: name2, content } };
15207
+ }
15208
+ const name = humanizeSlug(extractFilenameSlug(filePath));
15209
+ return { success: true, parsed: { name, content } };
15210
+ }
15211
+ function resolveName(frontmatter, filePath) {
15212
+ const nameValue = extractFrontmatterValue2(frontmatter, "name");
15213
+ if (nameValue) return nameValue;
15214
+ return humanizeSlug(extractFilenameSlug(filePath));
15215
+ }
15216
+ function extractFrontmatterValue2(frontmatter, key) {
15217
+ for (const line of frontmatter.split("\n")) {
15218
+ const trimmed = line.trim();
15219
+ if (trimmed.startsWith(`${key}:`)) {
15220
+ const raw = trimmed.slice(key.length + 1).trim();
15221
+ return stripYamlQuotes2(raw);
15222
+ }
15223
+ }
15224
+ return "";
15225
+ }
15226
+ function stripYamlQuotes2(value) {
15227
+ if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
15228
+ return value.slice(1, -1).replace(/''/g, "'");
15229
+ }
15230
+ if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
15231
+ return value.slice(1, -1);
15232
+ }
15233
+ return value;
15234
+ }
15235
+ function extractFilenameSlug(filePath) {
15236
+ let basename2 = path16.basename(filePath);
15237
+ if (basename2.endsWith(".prompt.md")) {
15238
+ basename2 = basename2.slice(0, -".prompt.md".length);
15239
+ } else if (basename2.endsWith(".md")) {
15240
+ basename2 = basename2.slice(0, -".md".length);
15241
+ }
15242
+ return basename2;
15243
+ }
15244
+ function humanizeSlug(slug) {
15245
+ const words = slug.replace(/[-_]/g, " ");
15246
+ return words.charAt(0).toUpperCase() + words.slice(1);
15247
+ }
15248
+
15249
+ // apps/cli/src/application/utils/parseSkillDirectory.ts
15250
+ var SKILL_MD_FILENAME = "SKILL.md";
15251
+ function parseSkillDirectory(files) {
15252
+ const skillMdFile = files.find((f) => f.relativePath === SKILL_MD_FILENAME);
15253
+ if (!skillMdFile) {
15254
+ return {
15255
+ success: false,
15256
+ error: "Skill directory does not contain a SKILL.md file."
15257
+ };
15258
+ }
15259
+ const parsed = parseSkillMdContent(skillMdFile.content);
15260
+ if (!parsed) {
15261
+ return {
15262
+ success: false,
15263
+ error: "Failed to parse SKILL.md: file must have valid YAML frontmatter."
15264
+ };
15265
+ }
15266
+ const { properties, body } = parsed;
15267
+ const name = properties.name;
15268
+ if (typeof name !== "string" || name.trim().length === 0) {
15269
+ return {
15270
+ success: false,
15271
+ error: 'SKILL.md is missing a required "name" property in frontmatter.'
15272
+ };
15273
+ }
15274
+ const description = properties.description;
15275
+ if (typeof description !== "string" || description.trim().length === 0) {
15276
+ return {
15277
+ success: false,
15278
+ error: 'SKILL.md is missing a required "description" property in frontmatter.'
15279
+ };
15280
+ }
15281
+ if (body.trim().length === 0) {
15282
+ return {
15283
+ success: false,
15284
+ error: "SKILL.md body (prompt) cannot be empty."
15285
+ };
15286
+ }
15287
+ const payload = {
15288
+ name: name.trim(),
15289
+ description: description.trim(),
15290
+ prompt: body,
15291
+ skillMdPermissions: skillMdFile.permissions
15292
+ };
15293
+ if (typeof properties.license === "string") {
15294
+ payload.license = properties.license;
15295
+ }
15296
+ if (typeof properties.compatibility === "string") {
15297
+ payload.compatibility = properties.compatibility;
15298
+ }
15299
+ if (typeof properties.allowedTools === "string") {
15300
+ payload.allowedTools = properties.allowedTools;
15301
+ }
15302
+ const supportingFiles = files.filter(
15303
+ (f) => f.relativePath !== SKILL_MD_FILENAME
15304
+ );
15305
+ payload.files = supportingFiles.map((f) => ({
15306
+ path: f.relativePath,
15307
+ content: f.content,
15308
+ permissions: f.permissions,
15309
+ isBase64: f.isBase64
15310
+ }));
15311
+ return { success: true, payload };
15312
+ }
15313
+
15314
+ // apps/cli/src/infra/commands/diffAddHandler.ts
15315
+ async function diffAddHandler(deps) {
15316
+ const {
15317
+ packmindCliHexa,
15318
+ filePath,
15319
+ message: messageFlag,
15320
+ exit,
15321
+ getCwd,
15322
+ readFile: readFile10,
15323
+ readSkillDirectory: readSkillDirectory2
15324
+ } = deps;
15325
+ if (!filePath) {
15326
+ logErrorConsole("Missing file path. Usage: packmind-cli diff add <path>");
15327
+ exit(1);
15328
+ return;
15329
+ }
15330
+ const absolutePath = path17.resolve(getCwd(), filePath);
15331
+ const artefactResult = resolveArtefactFromPath(absolutePath);
15332
+ if (!artefactResult) {
15333
+ logErrorConsole(
15334
+ `Unsupported file path: ${absolutePath}. File must be in a recognized artefact directory (command, standard, or skill).`
15335
+ );
15336
+ exit(1);
15337
+ return;
15338
+ }
15339
+ let diffResult;
15340
+ if (artefactResult.artifactType === "skill") {
15341
+ const dirPath = absolutePath.endsWith("SKILL.md") ? path17.dirname(absolutePath) : absolutePath;
15342
+ let files;
15343
+ try {
15344
+ files = await readSkillDirectory2(dirPath);
15345
+ } catch (err) {
15346
+ const errorMessage = err instanceof Error ? err.message : String(err);
15347
+ logErrorConsole(`Failed to read skill directory: ${errorMessage}`);
15348
+ exit(1);
15349
+ return;
15350
+ }
15351
+ const parseResult = parseSkillDirectory(files);
15352
+ if (!parseResult.success) {
15353
+ logErrorConsole(parseResult.error);
15354
+ exit(1);
15355
+ return;
15356
+ }
15357
+ diffResult = {
15358
+ success: true,
15359
+ diff: {
15360
+ type: "createSkill" /* createSkill */,
15361
+ payload: parseResult.payload,
15362
+ artifactName: parseResult.payload.name,
15363
+ artifactType: "skill"
15364
+ }
15365
+ };
15366
+ } else {
15367
+ let content;
15368
+ try {
15369
+ content = readFile10(absolutePath);
15370
+ } catch (err) {
15371
+ if (isErrnoException(err) && err.code === "EISDIR") {
15372
+ logErrorConsole(
15373
+ `Path is a directory, not a file: ${absolutePath}. Please provide a path to an artefact file.`
15374
+ );
15375
+ } else {
15376
+ const errorMessage = err instanceof Error ? err.message : String(err);
15377
+ logErrorConsole(`Failed to read file: ${errorMessage}`);
15378
+ }
15379
+ exit(1);
15380
+ return;
15381
+ }
15382
+ const buildResult = buildDiff(
15383
+ artefactResult.artifactType,
15384
+ content,
15385
+ absolutePath,
15386
+ artefactResult.codingAgent
15387
+ );
15388
+ if (!buildResult.success) {
15389
+ logErrorConsole(buildResult.error);
15390
+ exit(1);
15391
+ return;
15392
+ }
15393
+ diffResult = buildResult;
15394
+ }
15395
+ let message;
15396
+ if (messageFlag !== void 0) {
15397
+ const validation = validateMessage(messageFlag);
15398
+ if (!validation.valid) {
15399
+ logErrorConsole(validation.error);
15400
+ exit(1);
15401
+ return;
15402
+ }
15403
+ message = validation.message;
15404
+ } else if (process.stdin.isTTY) {
15405
+ const editorMessage = openEditorForMessage();
15406
+ const validation = validateMessage(editorMessage);
15407
+ if (!validation.valid) {
15408
+ logErrorConsole(
15409
+ "Aborting submission: empty message. Use -m to provide a message."
15410
+ );
15411
+ exit(1);
15412
+ return;
15413
+ }
15414
+ message = validation.message;
15415
+ } else {
15416
+ logErrorConsole(
15417
+ 'Non-interactive mode requires -m flag. Usage: packmind-cli diff add <path> -m "your message"'
15418
+ );
15419
+ exit(1);
15420
+ return;
15421
+ }
15422
+ const space = await packmindCliHexa.getPackmindGateway().spaces.getGlobal();
15423
+ const diff = {
15424
+ ...diffResult.diff,
15425
+ filePath: absolutePath,
15426
+ spaceId: space.id
15427
+ };
15428
+ const result = await packmindCliHexa.submitDiffs([[diff]], message);
15429
+ for (const err of result.errors) {
15430
+ logErrorConsole(`Failed to submit "${err.name}": ${err.message}`);
15431
+ }
15432
+ const summaryParts = [];
15433
+ if (result.submitted > 0) {
15434
+ summaryParts.push(`${result.submitted} submitted`);
15435
+ }
15436
+ if (result.alreadySubmitted > 0) {
15437
+ summaryParts.push(`${result.alreadySubmitted} already submitted`);
15438
+ }
15439
+ if (result.errors.length > 0) {
15440
+ const errorWord = result.errors.length === 1 ? "error" : "errors";
15441
+ summaryParts.push(`${result.errors.length} ${errorWord}`);
15442
+ }
15443
+ if (summaryParts.length > 0) {
15444
+ const summaryMessage = `Summary: ${summaryParts.join(", ")}`;
15445
+ if (result.errors.length === 0 && result.alreadySubmitted === 0) {
15446
+ logSuccessConsole(summaryMessage);
15447
+ } else if (result.errors.length > 0 && result.submitted > 0 || result.alreadySubmitted > 0) {
15448
+ logWarningConsole(summaryMessage);
15449
+ } else {
15450
+ logErrorConsole(summaryMessage);
15451
+ }
15452
+ }
15453
+ if (result.submitted > 0) {
15454
+ const truncatedMessage = message.length > 50 ? message.slice(0, 50) + "..." : message;
15455
+ logInfoConsole(`Message: "${truncatedMessage}"`);
15456
+ }
15457
+ if (result.errors.length > 0) {
15458
+ exit(1);
15459
+ return;
15460
+ }
15461
+ exit(0);
15462
+ }
15463
+ function buildDiff(artifactType, content, filePath, codingAgent) {
15464
+ if (artifactType === "command") {
15465
+ const parseResult = parseCommandFile(content, filePath);
15466
+ if (!parseResult.success) {
15467
+ return {
15468
+ success: false,
15469
+ error: `Failed to parse command file: ${parseResult.error}`
15470
+ };
15471
+ }
15472
+ return {
15473
+ success: true,
15474
+ diff: {
15475
+ type: "createCommand" /* createCommand */,
15476
+ payload: {
15477
+ name: parseResult.parsed.name,
15478
+ content: parseResult.parsed.content
15479
+ },
15480
+ artifactName: parseResult.parsed.name,
15481
+ artifactType: "command"
15482
+ }
15483
+ };
15484
+ }
15485
+ const parsed = parseStandardMdForAgent(content, codingAgent);
15486
+ if (!parsed) {
15487
+ return {
15488
+ success: false,
15489
+ error: `File format is invalid. It should be formatted like:
15490
+
15491
+ ${getStandardFormatExample(codingAgent)}`
15492
+ };
15493
+ }
15494
+ if (parsed.rules.length === 0) {
15495
+ return {
15496
+ success: false,
15497
+ error: `Standard has no rules. Add at least one rule, formatted like:
15498
+
15499
+ ${getStandardFormatExample(codingAgent)}`
15500
+ };
15501
+ }
15502
+ return {
15503
+ success: true,
15504
+ diff: {
15505
+ type: "createStandard" /* createStandard */,
15506
+ payload: {
15507
+ name: parsed.name,
15508
+ description: parsed.description,
15509
+ scope: parsed.scope || null,
15510
+ rules: parsed.rules.map((r) => ({ content: r }))
15511
+ },
15512
+ artifactName: parsed.name,
15513
+ artifactType: "standard"
15514
+ }
15515
+ };
15516
+ }
15517
+ function getStandardFormatExample(agent) {
15518
+ if (agent === "packmind") {
15519
+ return "# <name>\n\n<description>\n\n## Rules\n\n* <rule 1>\n* <rule 2>";
15520
+ }
15521
+ return "## Standard: <name>\n\n<description>\n\n* <rule 1>\n* <rule 2>";
15522
+ }
15523
+ function isErrnoException(err) {
15524
+ return err instanceof Error && "code" in err;
15525
+ }
15526
+
15052
15527
  // apps/cli/src/infra/commands/DiffCommand.ts
15053
15528
  var diffCommand = (0, import_cmd_ts19.command)({
15054
15529
  name: "diff",
@@ -15067,11 +15542,28 @@ var diffCommand = (0, import_cmd_ts19.command)({
15067
15542
  short: "m",
15068
15543
  description: "Message describing the intent behind the changes (max 1024 chars)",
15069
15544
  type: (0, import_cmd_ts19.optional)(import_cmd_ts19.string)
15545
+ }),
15546
+ positionals: (0, import_cmd_ts19.restPositionals)({
15547
+ type: import_cmd_ts19.string,
15548
+ displayName: "args",
15549
+ description: "Subcommand and arguments (e.g., add <path>)"
15070
15550
  })
15071
15551
  },
15072
- handler: async ({ submit, includeSubmitted, message }) => {
15552
+ handler: async ({ submit, includeSubmitted, message, positionals }) => {
15073
15553
  const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
15074
15554
  const packmindCliHexa = new PackmindCliHexa(packmindLogger);
15555
+ if (positionals[0] === "add") {
15556
+ await diffAddHandler({
15557
+ packmindCliHexa,
15558
+ filePath: positionals[1],
15559
+ message,
15560
+ exit: process.exit,
15561
+ getCwd: () => process.cwd(),
15562
+ readFile: (p) => (0, import_fs20.readFileSync)(p, "utf-8"),
15563
+ readSkillDirectory
15564
+ });
15565
+ return;
15566
+ }
15075
15567
  await diffArtefactsHandler({
15076
15568
  packmindCliHexa,
15077
15569
  exit: process.exit,
@@ -15138,15 +15630,15 @@ var CreatePackageUseCase = class {
15138
15630
  constructor(gateway) {
15139
15631
  this.gateway = gateway;
15140
15632
  }
15141
- async execute(command21) {
15633
+ async execute(command22) {
15142
15634
  const space = await this.gateway.spaces.getGlobal();
15143
15635
  const result = await this.gateway.packages.create({
15144
15636
  spaceId: space.id,
15145
- name: command21.name,
15146
- description: command21.description ?? "",
15637
+ name: command22.name,
15638
+ description: command22.description ?? "",
15147
15639
  recipeIds: [],
15148
15640
  standardIds: [],
15149
- originSkill: command21.originSkill
15641
+ originSkill: command22.originSkill
15150
15642
  });
15151
15643
  return {
15152
15644
  packageId: result.package.id,
@@ -15236,8 +15728,8 @@ var AddToPackageUseCase = class {
15236
15728
  constructor(gateway) {
15237
15729
  this.gateway = gateway;
15238
15730
  }
15239
- async execute(command21) {
15240
- const { packageSlug, itemType, itemSlugs } = command21;
15731
+ async execute(command22) {
15732
+ const { packageSlug, itemType, itemSlugs } = command22;
15241
15733
  const space = await this.gateway.spaces.getGlobal();
15242
15734
  const packages = await this.gateway.packages.list({});
15243
15735
  const pkg = packages.packages.find((pkg2) => pkg2.slug === packageSlug);
@@ -15254,7 +15746,7 @@ var AddToPackageUseCase = class {
15254
15746
  standardIds: [],
15255
15747
  recipeIds: [],
15256
15748
  skillIds: [],
15257
- originSkill: command21.originSkill
15749
+ originSkill: command22.originSkill
15258
15750
  };
15259
15751
  if (itemType === "standard") {
15260
15752
  addCommand.standardIds = ids.map(createStandardId);
@@ -15299,7 +15791,7 @@ var AddToPackageUseCase = class {
15299
15791
  }
15300
15792
  async findCommandBySlug(slug, spaceId) {
15301
15793
  const commands = await this.gateway.commands.list({ spaceId });
15302
- return commands.recipes.find((command21) => command21.slug === slug) ?? null;
15794
+ return commands.recipes.find((command22) => command22.slug === slug) ?? null;
15303
15795
  }
15304
15796
  async findSkillBySlug(slug, spaceId) {
15305
15797
  const skills = await this.gateway.skills.list({ spaceId });
@@ -15459,7 +15951,7 @@ var import_cmd_ts24 = __toESM(require_cjs());
15459
15951
 
15460
15952
  // apps/cli/src/application/services/AgentArtifactDetectionService.ts
15461
15953
  var fs18 = __toESM(require("fs/promises"));
15462
- var path16 = __toESM(require("path"));
15954
+ var path18 = __toESM(require("path"));
15463
15955
  var AGENT_ARTIFACT_CHECKS = [
15464
15956
  { agent: "claude", paths: [".claude"] },
15465
15957
  { agent: "cursor", paths: [".cursor"] },
@@ -15477,7 +15969,7 @@ var AgentArtifactDetectionService = class {
15477
15969
  const detected = [];
15478
15970
  for (const check of AGENT_ARTIFACT_CHECKS) {
15479
15971
  for (const relativePath of check.paths) {
15480
- const fullPath = path16.join(baseDirectory, relativePath);
15972
+ const fullPath = path18.join(baseDirectory, relativePath);
15481
15973
  const exists = await this.pathExists(fullPath);
15482
15974
  if (exists) {
15483
15975
  detected.push({
@@ -15574,7 +16066,7 @@ async function promptAgentsWithReadline2(choices) {
15574
16066
  output.write("\n");
15575
16067
  const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
15576
16068
  const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
15577
- return new Promise((resolve7) => {
16069
+ return new Promise((resolve8) => {
15578
16070
  rl.question(
15579
16071
  `Enter numbers separated by commas (default: ${defaultValue}): `,
15580
16072
  (answer) => {
@@ -15583,7 +16075,7 @@ async function promptAgentsWithReadline2(choices) {
15583
16075
  const numbersStr = trimmed === "" ? defaultValue : trimmed;
15584
16076
  const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
15585
16077
  const selectedAgents = numbers.map((n) => choices[n - 1].value);
15586
- resolve7(selectedAgents);
16078
+ resolve8(selectedAgents);
15587
16079
  }
15588
16080
  );
15589
16081
  });
@@ -15728,18 +16220,223 @@ var initCommand = (0, import_cmd_ts26.command)({
15728
16220
  }
15729
16221
  });
15730
16222
 
15731
- // apps/cli/src/main.ts
16223
+ // apps/cli/src/infra/commands/UpdateCommand.ts
16224
+ var import_cmd_ts27 = __toESM(require_cjs());
16225
+
16226
+ // apps/cli/src/infra/commands/updateHandler.ts
16227
+ var import_path5 = __toESM(require("path"));
16228
+ var import_child_process5 = require("child_process");
16229
+ var import_fs21 = require("fs");
16230
+ var import_promises2 = require("stream/promises");
16231
+ var import_stream = require("stream");
16232
+ var import_semver = __toESM(require("semver"));
16233
+ var GITHUB_REPO = "PackmindHub/packmind";
16234
+ var NPM_PACKAGE = "@packmind/cli";
16235
+ function getPlatformAssetSuffix(platform, arch) {
16236
+ const osMap = {
16237
+ linux: "linux",
16238
+ darwin: "macos",
16239
+ win32: "windows"
16240
+ };
16241
+ const osName = osMap[platform];
16242
+ if (!osName) {
16243
+ throw new Error(`Unsupported platform: ${platform}`);
16244
+ }
16245
+ const archName = platform === "darwin" && arch === "x64" ? "x64-baseline" : arch;
16246
+ const ext = platform === "win32" ? ".exe" : "";
16247
+ return `${osName}-${archName}${ext}`;
16248
+ }
16249
+ async function fetchLatestVersionFromNpm(fetchFn) {
16250
+ const res = await fetchFn(`https://registry.npmjs.org/${NPM_PACKAGE}/latest`);
16251
+ if (!res.ok) {
16252
+ throw new Error(
16253
+ `Failed to fetch from npm registry: ${res.status} ${res.statusText}`
16254
+ );
16255
+ }
16256
+ const data = await res.json();
16257
+ return data.version;
16258
+ }
16259
+ async function fetchLatestVersionFromGitHub(fetchFn) {
16260
+ const res = await fetchFn(
16261
+ `https://api.github.com/repos/${GITHUB_REPO}/releases?per_page=20`,
16262
+ {
16263
+ headers: { Accept: "application/vnd.github.v3+json" }
16264
+ }
16265
+ );
16266
+ if (!res.ok) {
16267
+ throw new Error(
16268
+ `Failed to fetch from GitHub API: ${res.status} ${res.statusText}`
16269
+ );
16270
+ }
16271
+ const releases = await res.json();
16272
+ const cliReleases = releases.filter((r) => r.tag_name?.startsWith("release-cli/")).map((r) => ({
16273
+ ...r,
16274
+ version: r.tag_name.replace("release-cli/", "")
16275
+ })).filter((r) => import_semver.default.valid(r.version)).sort((a, b) => import_semver.default.rcompare(a.version, b.version));
16276
+ if (cliReleases.length === 0) {
16277
+ throw new Error("No CLI release found on GitHub");
16278
+ }
16279
+ return cliReleases[0].version;
16280
+ }
16281
+ async function downloadExecutable(fetchFn, version, platformSuffix, targetPath) {
16282
+ const assetName = `packmind-cli-${platformSuffix}-${version}`;
16283
+ const url = `https://github.com/${GITHUB_REPO}/releases/download/release-cli/${version}/${assetName}`;
16284
+ logInfoConsole(`Downloading ${assetName}...`);
16285
+ const res = await fetchFn(url, { redirect: "follow" });
16286
+ if (!res.ok) {
16287
+ throw new Error(
16288
+ `Failed to download executable: ${res.status} ${res.statusText}
16289
+ URL: ${url}`
16290
+ );
16291
+ }
16292
+ if (!res.body) {
16293
+ throw new Error("No response body received");
16294
+ }
16295
+ const nodeReadable = import_stream.Readable.fromWeb(res.body);
16296
+ const fileStream = (0, import_fs21.createWriteStream)(targetPath);
16297
+ await (0, import_promises2.pipeline)(nodeReadable, fileStream);
16298
+ const stats = (0, import_fs21.statSync)(targetPath);
16299
+ if (stats.size < 1e6) {
16300
+ (0, import_fs21.unlinkSync)(targetPath);
16301
+ throw new Error(
16302
+ `Downloaded file is too small (${stats.size} bytes). The download may have failed.`
16303
+ );
16304
+ }
16305
+ logInfoConsole(
16306
+ `Downloaded successfully (${(stats.size / 1048576).toFixed(1)} MB)`
16307
+ );
16308
+ }
16309
+ function updateViaNpm(version) {
16310
+ logInfoConsole(`Updating via npm to version ${version}...`);
16311
+ (0, import_child_process5.execSync)(`npm install -g ${NPM_PACKAGE}@${version}`, {
16312
+ stdio: "inherit"
16313
+ });
16314
+ }
16315
+ async function updateViaExecutableReplace(deps, version) {
16316
+ const platformSuffix = getPlatformAssetSuffix(deps.platform, deps.arch);
16317
+ const currentPath = deps.executablePath;
16318
+ const tempPath = currentPath + ".update-tmp";
16319
+ try {
16320
+ await downloadExecutable(deps.fetchFn, version, platformSuffix, tempPath);
16321
+ (0, import_fs21.renameSync)(tempPath, currentPath);
16322
+ if (deps.platform !== "win32") {
16323
+ (0, import_fs21.chmodSync)(currentPath, 493);
16324
+ }
16325
+ } catch (error) {
16326
+ try {
16327
+ (0, import_fs21.unlinkSync)(tempPath);
16328
+ } catch {
16329
+ }
16330
+ throw error;
16331
+ }
16332
+ }
16333
+ function isLocalNpmPackage(scriptPath) {
16334
+ if (!scriptPath) return false;
16335
+ return scriptPath.includes(import_path5.default.join("node_modules", "@packmind", "cli"));
16336
+ }
16337
+ async function updateHandler(deps) {
16338
+ const execBasename = import_path5.default.basename(deps.executablePath).replace(/\.exe$/, "");
16339
+ const jsRuntimes = ["node", "bun", "deno"];
16340
+ if (jsRuntimes.includes(execBasename)) {
16341
+ if (isLocalNpmPackage(deps.scriptPath)) {
16342
+ logErrorConsole(
16343
+ "Your CLI version is managed by your local package.json.\nTo update, run: npm update @packmind/cli"
16344
+ );
16345
+ } else {
16346
+ logErrorConsole(
16347
+ "The update command is not available when running the CLI via a JavaScript runtime.\nTo update, use the standalone executable or run: npm install -g @packmind/cli@latest"
16348
+ );
16349
+ }
16350
+ process.exit(1);
16351
+ return;
16352
+ }
16353
+ logInfoConsole(
16354
+ `Current version: ${deps.currentVersion} (${deps.isExecutableMode ? "standalone executable" : "npm package"})`
16355
+ );
16356
+ let latestVersion;
16357
+ try {
16358
+ latestVersion = deps.isExecutableMode ? await fetchLatestVersionFromGitHub(deps.fetchFn) : await fetchLatestVersionFromNpm(deps.fetchFn);
16359
+ } catch (error) {
16360
+ logErrorConsole(
16361
+ `Failed to check for updates: ${error instanceof Error ? error.message : String(error)}`
16362
+ );
16363
+ process.exit(1);
16364
+ return;
16365
+ }
16366
+ if (!import_semver.default.gt(latestVersion, deps.currentVersion)) {
16367
+ logSuccessConsole(`Already up to date (v${deps.currentVersion})`);
16368
+ return;
16369
+ }
16370
+ logConsole("");
16371
+ logInfoConsole(
16372
+ `New version available: ${deps.currentVersion} -> ${latestVersion}`
16373
+ );
16374
+ if (deps.checkOnly) {
16375
+ process.exit(1);
16376
+ return;
16377
+ }
16378
+ try {
16379
+ if (deps.isExecutableMode) {
16380
+ await updateViaExecutableReplace(deps, latestVersion);
16381
+ } else {
16382
+ updateViaNpm(latestVersion);
16383
+ }
16384
+ logConsole("");
16385
+ logSuccessConsole(`Updated to v${latestVersion}`);
16386
+ if (deps.isExecutableMode) {
16387
+ logInfoConsole(`Binary location: ${deps.executablePath}`);
16388
+ }
16389
+ } catch (error) {
16390
+ const message = error instanceof Error ? error.message : String(error);
16391
+ if (message.includes("EACCES") || message.includes("permission denied")) {
16392
+ logErrorConsole(
16393
+ `Permission denied. Try running with sudo:
16394
+ sudo packmind-cli update`
16395
+ );
16396
+ } else {
16397
+ logErrorConsole(`Update failed: ${message}`);
16398
+ }
16399
+ process.exit(1);
16400
+ }
16401
+ }
16402
+
16403
+ // apps/cli/src/infra/commands/UpdateCommand.ts
15732
16404
  var { version: CLI_VERSION4 } = require_package();
16405
+ var updateCommand = (0, import_cmd_ts27.command)({
16406
+ name: "update",
16407
+ description: "Update packmind-cli to the latest version",
16408
+ args: {
16409
+ check: (0, import_cmd_ts27.flag)({
16410
+ long: "check",
16411
+ description: "Only check if a newer version is available without performing the update"
16412
+ })
16413
+ },
16414
+ handler: async ({ check }) => {
16415
+ await updateHandler({
16416
+ currentVersion: CLI_VERSION4,
16417
+ isExecutableMode: hasEmbeddedWasmFiles(),
16418
+ executablePath: process.execPath,
16419
+ scriptPath: require.main?.filename,
16420
+ platform: process.platform,
16421
+ arch: process.arch,
16422
+ fetchFn: fetch,
16423
+ checkOnly: check
16424
+ });
16425
+ }
16426
+ });
16427
+
16428
+ // apps/cli/src/main.ts
16429
+ var { version: CLI_VERSION5 } = require_package();
15733
16430
  function findEnvFile() {
15734
16431
  const currentDir = process.cwd();
15735
16432
  const gitService = new GitService();
15736
16433
  const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
15737
- const filesystemRoot = path17.parse(currentDir).root;
16434
+ const filesystemRoot = path20.parse(currentDir).root;
15738
16435
  const stopDir = gitRoot ?? filesystemRoot;
15739
16436
  let searchDir = currentDir;
15740
- let parentDir = path17.dirname(searchDir);
16437
+ let parentDir = path20.dirname(searchDir);
15741
16438
  while (searchDir !== parentDir) {
15742
- const envPath2 = path17.join(searchDir, ".env");
16439
+ const envPath2 = path20.join(searchDir, ".env");
15743
16440
  if (fs19.existsSync(envPath2)) {
15744
16441
  return envPath2;
15745
16442
  }
@@ -15747,7 +16444,7 @@ function findEnvFile() {
15747
16444
  return null;
15748
16445
  }
15749
16446
  searchDir = parentDir;
15750
- parentDir = path17.dirname(searchDir);
16447
+ parentDir = path20.dirname(searchDir);
15751
16448
  }
15752
16449
  return null;
15753
16450
  }
@@ -15764,10 +16461,10 @@ if (hasEmbeddedWasmFiles()) {
15764
16461
  }
15765
16462
  var args = process.argv.slice(2);
15766
16463
  if (args.includes("--version") || args.includes("-v")) {
15767
- logConsole(`packmind-cli version ${CLI_VERSION4}`);
16464
+ logConsole(`packmind-cli version ${CLI_VERSION5}`);
15768
16465
  process.exit(0);
15769
16466
  }
15770
- var app = (0, import_cmd_ts27.subcommands)({
16467
+ var app = (0, import_cmd_ts28.subcommands)({
15771
16468
  name: "packmind-cli",
15772
16469
  description: "Packmind CLI tool",
15773
16470
  cmds: {
@@ -15786,10 +16483,11 @@ var app = (0, import_cmd_ts27.subcommands)({
15786
16483
  skills: skillsCommand,
15787
16484
  standards: standardsCommand,
15788
16485
  uninstall: uninstallCommand,
16486
+ update: updateCommand,
15789
16487
  whoami: whoamiCommand
15790
16488
  }
15791
16489
  });
15792
- (0, import_cmd_ts27.run)(app, args).catch((error) => {
16490
+ (0, import_cmd_ts28.run)(app, args).catch((error) => {
15793
16491
  logErrorConsole(error.message);
15794
16492
  process.exit(1);
15795
16493
  });