@packmind/cli 0.11.0 → 0.12.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 +434 -229
  2. package/package.json +1 -1
package/main.cjs CHANGED
@@ -371,32 +371,32 @@ var init_supports_color = __esm({
371
371
  });
372
372
 
373
373
  // node_modules/chalk/source/utilities.js
374
- function stringReplaceAll(string5, substring, replacer) {
375
- let index = string5.indexOf(substring);
374
+ function stringReplaceAll(string6, substring, replacer) {
375
+ let index = string6.indexOf(substring);
376
376
  if (index === -1) {
377
- return string5;
377
+ return string6;
378
378
  }
379
379
  const substringLength = substring.length;
380
380
  let endIndex = 0;
381
381
  let returnValue = "";
382
382
  do {
383
- returnValue += string5.slice(endIndex, index) + substring + replacer;
383
+ returnValue += string6.slice(endIndex, index) + substring + replacer;
384
384
  endIndex = index + substringLength;
385
- index = string5.indexOf(substring, endIndex);
385
+ index = string6.indexOf(substring, endIndex);
386
386
  } while (index !== -1);
387
- returnValue += string5.slice(endIndex);
387
+ returnValue += string6.slice(endIndex);
388
388
  return returnValue;
389
389
  }
390
- function stringEncaseCRLFWithFirstIndex(string5, prefix, postfix, index) {
390
+ function stringEncaseCRLFWithFirstIndex(string6, prefix, postfix, index) {
391
391
  let endIndex = 0;
392
392
  let returnValue = "";
393
393
  do {
394
- const gotCR = string5[index - 1] === "\r";
395
- returnValue += string5.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
394
+ const gotCR = string6[index - 1] === "\r";
395
+ returnValue += string6.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
396
396
  endIndex = index + 1;
397
- index = string5.indexOf("\n", endIndex);
397
+ index = string6.indexOf("\n", endIndex);
398
398
  } while (index !== -1);
399
- returnValue += string5.slice(endIndex);
399
+ returnValue += string6.slice(endIndex);
400
400
  return returnValue;
401
401
  }
402
402
  var init_utilities = __esm({
@@ -555,26 +555,26 @@ var init_source = __esm({
555
555
  builder[IS_EMPTY] = _isEmpty;
556
556
  return builder;
557
557
  };
558
- applyStyle = (self, string5) => {
559
- if (self.level <= 0 || !string5) {
560
- return self[IS_EMPTY] ? "" : string5;
558
+ applyStyle = (self, string6) => {
559
+ if (self.level <= 0 || !string6) {
560
+ return self[IS_EMPTY] ? "" : string6;
561
561
  }
562
562
  let styler = self[STYLER];
563
563
  if (styler === void 0) {
564
- return string5;
564
+ return string6;
565
565
  }
566
566
  const { openAll, closeAll } = styler;
567
- if (string5.includes("\x1B")) {
567
+ if (string6.includes("\x1B")) {
568
568
  while (styler !== void 0) {
569
- string5 = stringReplaceAll(string5, styler.close, styler.open);
569
+ string6 = stringReplaceAll(string6, styler.close, styler.open);
570
570
  styler = styler.parent;
571
571
  }
572
572
  }
573
- const lfIndex = string5.indexOf("\n");
573
+ const lfIndex = string6.indexOf("\n");
574
574
  if (lfIndex !== -1) {
575
- string5 = stringEncaseCRLFWithFirstIndex(string5, closeAll, openAll, lfIndex);
575
+ string6 = stringEncaseCRLFWithFirstIndex(string6, closeAll, openAll, lfIndex);
576
576
  }
577
- return openAll + string5 + closeAll;
577
+ return openAll + string6 + closeAll;
578
578
  };
579
579
  Object.defineProperties(createChalk.prototype, styles2);
580
580
  chalk = createChalk();
@@ -1255,7 +1255,7 @@ var require_positional = __commonJS({
1255
1255
  return mod && mod.__esModule ? mod : { "default": mod };
1256
1256
  };
1257
1257
  Object.defineProperty(exports2, "__esModule", { value: true });
1258
- exports2.positional = positional2;
1258
+ exports2.positional = positional3;
1259
1259
  var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
1260
1260
  var Result = __importStar(require_Result());
1261
1261
  var types_1 = require_types();
@@ -1295,8 +1295,8 @@ var require_positional = __commonJS({
1295
1295
  var _a2;
1296
1296
  const positionals = nodes.filter((node) => node.type === "positionalArgument" && !visitedNodes.has(node));
1297
1297
  const defaultValueFn = (_a2 = config.defaultValue) !== null && _a2 !== void 0 ? _a2 : config.type.defaultValue;
1298
- const positional3 = positionals[0];
1299
- if (!positional3) {
1298
+ const positional4 = positionals[0];
1299
+ if (!positional4) {
1300
1300
  if (defaultValueFn) {
1301
1301
  return Result.ok(defaultValueFn());
1302
1302
  }
@@ -1309,13 +1309,13 @@ var require_positional = __commonJS({
1309
1309
  ]
1310
1310
  });
1311
1311
  }
1312
- visitedNodes.add(positional3);
1313
- const decoded = await Result.safeAsync(config.type.from(positional3.raw));
1312
+ visitedNodes.add(positional4);
1313
+ const decoded = await Result.safeAsync(config.type.from(positional4.raw));
1314
1314
  if (Result.isErr(decoded)) {
1315
1315
  return Result.err({
1316
1316
  errors: [
1317
1317
  {
1318
- nodes: [positional3],
1318
+ nodes: [positional4],
1319
1319
  message: decoded.error.message
1320
1320
  }
1321
1321
  ]
@@ -1325,7 +1325,7 @@ var require_positional = __commonJS({
1325
1325
  }
1326
1326
  };
1327
1327
  }
1328
- function positional2(config) {
1328
+ function positional3(config) {
1329
1329
  return fullPositional({
1330
1330
  type: types_1.string,
1331
1331
  ...config
@@ -1578,11 +1578,11 @@ var strip_ansi_exports = {};
1578
1578
  __export(strip_ansi_exports, {
1579
1579
  default: () => stripAnsi
1580
1580
  });
1581
- function stripAnsi(string5) {
1582
- if (typeof string5 !== "string") {
1583
- throw new TypeError(`Expected a \`string\`, got \`${typeof string5}\``);
1581
+ function stripAnsi(string6) {
1582
+ if (typeof string6 !== "string") {
1583
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string6}\``);
1584
1584
  }
1585
- return string5.replace(regex, "");
1585
+ return string6.replace(regex, "");
1586
1586
  }
1587
1587
  var regex;
1588
1588
  var init_strip_ansi = __esm({
@@ -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 = command8;
1701
+ exports2.command = command9;
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 command8(config) {
1706
+ function command9(config) {
1707
1707
  const argEntries = (0, utils_1.entries)(config.args);
1708
1708
  const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
1709
1709
  return {
@@ -3084,8 +3084,8 @@ var require_tokenizer = __commonJS({
3084
3084
  tokens.push(token);
3085
3085
  overallIndex += token.raw.length;
3086
3086
  };
3087
- for (const [stringIndex, string5] of (0, utils_1.enumerate)(strings)) {
3088
- const chars = [...string5];
3087
+ for (const [stringIndex, string6] of (0, utils_1.enumerate)(strings)) {
3088
+ const chars = [...string6];
3089
3089
  for (let i = 0; i < chars.length; i++) {
3090
3090
  if (chars[i] === "-" && chars[i + 1] === "-") {
3091
3091
  push({ type: "longPrefix", raw: "--", index: overallIndex });
@@ -3241,14 +3241,14 @@ var require_restPositionals = __commonJS({
3241
3241
  const positionals = nodes.filter((node) => node.type === "positionalArgument" && !visitedNodes.has(node));
3242
3242
  const results = [];
3243
3243
  const errors = [];
3244
- for (const positional2 of positionals) {
3245
- visitedNodes.add(positional2);
3246
- const decoded = await Result.safeAsync(config.type.from(positional2.raw));
3244
+ for (const positional3 of positionals) {
3245
+ visitedNodes.add(positional3);
3246
+ const decoded = await Result.safeAsync(config.type.from(positional3.raw));
3247
3247
  if (Result.isOk(decoded)) {
3248
3248
  results.push(decoded.value);
3249
3249
  } else {
3250
3250
  errors.push({
3251
- nodes: [positional2],
3251
+ nodes: [positional3],
3252
3252
  message: decoded.error.message
3253
3253
  });
3254
3254
  }
@@ -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.11.0",
3855
+ version: "0.12.0",
3856
3856
  description: "A command-line interface for Packmind linting and code quality checks",
3857
3857
  private: false,
3858
3858
  bin: {
@@ -3894,7 +3894,7 @@ var require_package = __commonJS({
3894
3894
  });
3895
3895
 
3896
3896
  // apps/cli/src/main.ts
3897
- var import_cmd_ts8 = __toESM(require_cjs());
3897
+ var import_cmd_ts9 = __toESM(require_cjs());
3898
3898
 
3899
3899
  // apps/cli/src/infra/commands/LinterCommand.ts
3900
3900
  var import_cmd_ts = __toESM(require_cjs());
@@ -4082,6 +4082,33 @@ var CommandUpdatedEvent = class extends UserEvent {
4082
4082
  // packages/types/src/skills/SkillId.ts
4083
4083
  var createSkillId = brandedIdFactory();
4084
4084
 
4085
+ // packages/types/src/skills/SkillVersionId.ts
4086
+ var createSkillVersionId = brandedIdFactory();
4087
+
4088
+ // packages/types/src/skills/SkillFileId.ts
4089
+ var createSkillFileId = brandedIdFactory();
4090
+
4091
+ // packages/types/src/skills/events/SkillCreatedEvent.ts
4092
+ var SkillCreatedEvent = class extends UserEvent {
4093
+ static {
4094
+ this.eventName = "skills.skill.created";
4095
+ }
4096
+ };
4097
+
4098
+ // packages/types/src/skills/events/SkillUpdatedEvent.ts
4099
+ var SkillUpdatedEvent = class extends UserEvent {
4100
+ static {
4101
+ this.eventName = "skills.skill.updated";
4102
+ }
4103
+ };
4104
+
4105
+ // packages/types/src/skills/events/SkillDeletedEvent.ts
4106
+ var SkillDeletedEvent = class extends UserEvent {
4107
+ static {
4108
+ this.eventName = "skills.skill.deleted";
4109
+ }
4110
+ };
4111
+
4085
4112
  // packages/types/src/deployments/TargetId.ts
4086
4113
  var createTargetId = brandedIdFactory();
4087
4114
 
@@ -4706,8 +4733,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
4706
4733
  static {
4707
4734
  this.fallbackRuleContent = "adhoc-rule";
4708
4735
  }
4709
- async execute(command8) {
4710
- const { program, fileContent, language } = command8;
4736
+ async execute(command9) {
4737
+ const { program, fileContent, language } = command9;
4711
4738
  const result = await this.linterExecutionUseCase.execute({
4712
4739
  filePath: "cli-single-file",
4713
4740
  fileContent,
@@ -4745,30 +4772,30 @@ var GitService = class {
4745
4772
  this.gitRunner = gitRunner;
4746
4773
  this.logger = logger2;
4747
4774
  }
4748
- getGitRepositoryRoot(path11) {
4775
+ getGitRepositoryRoot(path12) {
4749
4776
  try {
4750
4777
  const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
4751
- cwd: path11
4778
+ cwd: path12
4752
4779
  });
4753
4780
  const gitRoot = stdout.trim();
4754
4781
  this.logger.debug("Resolved git repository root", {
4755
- inputPath: path11,
4782
+ inputPath: path12,
4756
4783
  gitRoot
4757
4784
  });
4758
4785
  return gitRoot;
4759
4786
  } catch (error) {
4760
4787
  if (error instanceof Error) {
4761
4788
  throw new Error(
4762
- `Failed to get Git repository root. The path '${path11}' does not appear to be inside a Git repository.
4789
+ `Failed to get Git repository root. The path '${path12}' does not appear to be inside a Git repository.
4763
4790
  ${error.message}`
4764
4791
  );
4765
4792
  }
4766
4793
  throw new Error("Failed to get Git repository root: Unknown error");
4767
4794
  }
4768
4795
  }
4769
- tryGetGitRepositoryRoot(path11) {
4796
+ tryGetGitRepositoryRoot(path12) {
4770
4797
  try {
4771
- return this.getGitRepositoryRoot(path11);
4798
+ return this.getGitRepositoryRoot(path12);
4772
4799
  } catch {
4773
4800
  return null;
4774
4801
  }
@@ -5075,8 +5102,8 @@ var GetGitRemoteUrlUseCase = class {
5075
5102
  constructor(gitRemoteUrlService = new GitService()) {
5076
5103
  this.gitRemoteUrlService = gitRemoteUrlService;
5077
5104
  }
5078
- async execute(command8) {
5079
- const { path: repoPath, origin: origin11 } = command8;
5105
+ async execute(command9) {
5106
+ const { path: repoPath, origin: origin11 } = command9;
5080
5107
  return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin11);
5081
5108
  }
5082
5109
  };
@@ -5176,8 +5203,8 @@ var ListFilesInDirectoryUseCase = class {
5176
5203
  constructor(listFiles = new ListFiles()) {
5177
5204
  this.listFiles = listFiles;
5178
5205
  }
5179
- async execute(command8) {
5180
- const { path: directoryPath, extensions, excludes = [] } = command8;
5206
+ async execute(command9) {
5207
+ const { path: directoryPath, extensions, excludes = [] } = command9;
5181
5208
  const files = await this.listFiles.listFilesInDirectory(
5182
5209
  directoryPath,
5183
5210
  extensions,
@@ -5262,7 +5289,7 @@ var LintFilesInDirectoryUseCase = class {
5262
5289
  }
5263
5290
  return pattern;
5264
5291
  }
5265
- async execute(command8) {
5292
+ async execute(command9) {
5266
5293
  const {
5267
5294
  path: userPath,
5268
5295
  draftMode,
@@ -5270,7 +5297,7 @@ var LintFilesInDirectoryUseCase = class {
5270
5297
  ruleId,
5271
5298
  language,
5272
5299
  diffMode
5273
- } = command8;
5300
+ } = command9;
5274
5301
  this.logger.debug(
5275
5302
  `Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
5276
5303
  );
@@ -5589,8 +5616,8 @@ var LintFilesInDirectoryUseCase = class {
5589
5616
  return null;
5590
5617
  }
5591
5618
  }
5592
- async executeProgramsForFile(command8) {
5593
- const result = await this.services.linterExecutionUseCase.execute(command8);
5619
+ async executeProgramsForFile(command9) {
5620
+ const result = await this.services.linterExecutionUseCase.execute(command9);
5594
5621
  return result.violations;
5595
5622
  }
5596
5623
  extractExtensionFromFile(filePath) {
@@ -5647,8 +5674,8 @@ var LintFilesLocallyUseCase = class {
5647
5674
  }
5648
5675
  return pattern;
5649
5676
  }
5650
- async execute(command8) {
5651
- const { path: userPath, diffMode } = command8;
5677
+ async execute(command9) {
5678
+ const { path: userPath, diffMode } = command9;
5652
5679
  this.logger.debug(
5653
5680
  `Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
5654
5681
  );
@@ -5890,8 +5917,8 @@ var LintFilesLocallyUseCase = class {
5890
5917
  return null;
5891
5918
  }
5892
5919
  }
5893
- async executeProgramsForFile(command8) {
5894
- const result = await this.services.linterExecutionUseCase.execute(command8);
5920
+ async executeProgramsForFile(command9) {
5921
+ const result = await this.services.linterExecutionUseCase.execute(command9);
5895
5922
  return result.violations;
5896
5923
  }
5897
5924
  extractExtensionFromFile(filePath) {
@@ -5903,6 +5930,35 @@ var LintFilesLocallyUseCase = class {
5903
5930
  }
5904
5931
  };
5905
5932
 
5933
+ // apps/cli/src/infra/utils/readSkillDirectory.ts
5934
+ var import_promises = __toESM(require("fs/promises"));
5935
+ var import_path = __toESM(require("path"));
5936
+ async function readSkillDirectory(dirPath) {
5937
+ const files = [];
5938
+ async function readDir(currentPath, basePath) {
5939
+ const entries = await import_promises.default.readdir(currentPath, { withFileTypes: true });
5940
+ for (const entry of entries) {
5941
+ const fullPath = import_path.default.join(currentPath, entry.name);
5942
+ const relativePath = import_path.default.relative(basePath, fullPath);
5943
+ if (entry.isDirectory()) {
5944
+ await readDir(fullPath, basePath);
5945
+ } else if (entry.isFile()) {
5946
+ const content = await import_promises.default.readFile(fullPath, "utf-8");
5947
+ files.push({
5948
+ path: fullPath,
5949
+ relativePath,
5950
+ content,
5951
+ size: Buffer.byteLength(content, "utf-8"),
5952
+ permissions: "rw-r--r--"
5953
+ // Simple default
5954
+ });
5955
+ }
5956
+ }
5957
+ }
5958
+ await readDir(dirPath, dirPath);
5959
+ return files;
5960
+ }
5961
+
5906
5962
  // apps/cli/src/domain/errors/CommunityEditionError.ts
5907
5963
  var CommunityEditionError = class extends Error {
5908
5964
  constructor(feature) {
@@ -5979,7 +6035,7 @@ function decodeApiKey(apiKey) {
5979
6035
  var PackmindGateway = class {
5980
6036
  constructor(apiKey) {
5981
6037
  this.apiKey = apiKey;
5982
- this.getPullData = async (command8) => {
6038
+ this.getPullData = async (command9) => {
5983
6039
  const decodedApiKey = decodeApiKey(this.apiKey);
5984
6040
  if (!decodedApiKey.isValid) {
5985
6041
  if (decodedApiKey.error === "NOT_LOGGED_IN") {
@@ -5994,13 +6050,13 @@ var PackmindGateway = class {
5994
6050
  }
5995
6051
  const organizationId = jwtPayload.organization.id;
5996
6052
  const queryParams = new URLSearchParams();
5997
- if (command8.packagesSlugs && command8.packagesSlugs.length > 0) {
5998
- command8.packagesSlugs.forEach((slug) => {
6053
+ if (command9.packagesSlugs && command9.packagesSlugs.length > 0) {
6054
+ command9.packagesSlugs.forEach((slug) => {
5999
6055
  queryParams.append("packageSlug", slug);
6000
6056
  });
6001
6057
  }
6002
- if (command8.previousPackagesSlugs && command8.previousPackagesSlugs.length > 0) {
6003
- command8.previousPackagesSlugs.forEach((slug) => {
6058
+ if (command9.previousPackagesSlugs && command9.previousPackagesSlugs.length > 0) {
6059
+ command9.previousPackagesSlugs.forEach((slug) => {
6004
6060
  queryParams.append("previousPackageSlug", slug);
6005
6061
  });
6006
6062
  }
@@ -6540,6 +6596,90 @@ var PackmindGateway = class {
6540
6596
  );
6541
6597
  }
6542
6598
  };
6599
+ this.uploadSkill = async (command9) => {
6600
+ const decodedApiKey = decodeApiKey(this.apiKey);
6601
+ if (!decodedApiKey.isValid) {
6602
+ if (decodedApiKey.error === "NOT_LOGGED_IN") {
6603
+ throw new NotLoggedInError();
6604
+ }
6605
+ throw new Error(`Invalid API key: ${decodedApiKey.error}`);
6606
+ }
6607
+ const { host, jwt } = decodedApiKey.payload;
6608
+ const jwtPayload = decodeJwt(jwt);
6609
+ if (!jwtPayload?.organization?.id) {
6610
+ throw new Error("Invalid API key: missing organizationId in JWT");
6611
+ }
6612
+ const organizationId = jwtPayload.organization.id;
6613
+ const spacesUrl = `${host}/api/v0/organizations/${organizationId}/spaces/global`;
6614
+ const spaceResponse = await fetch(spacesUrl, {
6615
+ method: "GET",
6616
+ headers: {
6617
+ Authorization: `Bearer ${this.apiKey}`
6618
+ }
6619
+ });
6620
+ if (!spaceResponse.ok) {
6621
+ throw new Error(
6622
+ `Failed to resolve global space: ${spaceResponse.status} ${spaceResponse.statusText}`
6623
+ );
6624
+ }
6625
+ const space = await spaceResponse.json();
6626
+ const spaceId = space.id;
6627
+ const files = await readSkillDirectory(command9.skillPath);
6628
+ if (!files.find((f) => f.relativePath === "SKILL.md")) {
6629
+ throw new Error("SKILL.md not found in skill directory");
6630
+ }
6631
+ const totalSize = files.reduce((sum, f) => sum + f.size, 0);
6632
+ if (totalSize > 10 * 1024 * 1024) {
6633
+ throw new Error(`Skill size (${totalSize} bytes) exceeds 10MB limit`);
6634
+ }
6635
+ const payload = {
6636
+ files: files.map((f) => ({
6637
+ path: f.relativePath,
6638
+ content: f.content,
6639
+ permissions: f.permissions || "rw-r--r--"
6640
+ }))
6641
+ };
6642
+ const url = `${host}/api/v0/organizations/${organizationId}/spaces/${spaceId}/skills/upload`;
6643
+ try {
6644
+ const response = await fetch(url, {
6645
+ method: "POST",
6646
+ headers: {
6647
+ "Content-Type": "application/json",
6648
+ Authorization: `Bearer ${this.apiKey}`
6649
+ },
6650
+ body: JSON.stringify(payload)
6651
+ });
6652
+ if (!response.ok) {
6653
+ let errorMsg = `API request failed: ${response.status} ${response.statusText}`;
6654
+ try {
6655
+ const errorBody = await response.json();
6656
+ if (errorBody?.message) {
6657
+ errorMsg = errorBody.message;
6658
+ }
6659
+ } catch {
6660
+ }
6661
+ throw new Error(errorMsg);
6662
+ }
6663
+ const result = await response.json();
6664
+ return {
6665
+ skillId: result.id,
6666
+ name: result.name,
6667
+ fileCount: files.length,
6668
+ totalSize
6669
+ };
6670
+ } catch (error) {
6671
+ const err = error;
6672
+ const code = err?.code || err?.cause?.code;
6673
+ if (code === "ECONNREFUSED" || code === "ENOTFOUND" || err?.name === "FetchError" || typeof err?.message === "string" && (err.message.includes("Failed to fetch") || err.message.includes("network") || err.message.includes("NetworkError"))) {
6674
+ throw new Error(
6675
+ `Packmind server is not accessible at ${host}. Please check your network connection or the server URL.`
6676
+ );
6677
+ }
6678
+ throw new Error(
6679
+ `Failed to upload skill: Error: ${err?.message || JSON.stringify(error)}`
6680
+ );
6681
+ }
6682
+ };
6543
6683
  }
6544
6684
  };
6545
6685
 
@@ -6625,7 +6765,7 @@ var ParserInitializationError = class extends Error {
6625
6765
  };
6626
6766
 
6627
6767
  // packages/linter-ast/src/core/BaseParser.ts
6628
- var import_path = require("path");
6768
+ var import_path2 = require("path");
6629
6769
  var import_fs = require("fs");
6630
6770
  var BaseParser = class _BaseParser {
6631
6771
  constructor() {
@@ -6649,20 +6789,20 @@ var BaseParser = class _BaseParser {
6649
6789
  if (_BaseParser.externalWasmDirectory) {
6650
6790
  paths.push(_BaseParser.externalWasmDirectory);
6651
6791
  }
6652
- const execDir = process.argv[0] ? (0, import_path.dirname)(process.argv[0]) : process.cwd();
6653
- const scriptDir = require.main?.filename ? (0, import_path.dirname)(require.main.filename) : process.cwd();
6792
+ const execDir = process.argv[0] ? (0, import_path2.dirname)(process.argv[0]) : process.cwd();
6793
+ const scriptDir = require.main?.filename ? (0, import_path2.dirname)(require.main.filename) : process.cwd();
6654
6794
  paths.push(
6655
6795
  // Next to the main script (for npm packages like @packmind/scan)
6656
6796
  scriptDir,
6657
- (0, import_path.join)(scriptDir, "tree-sitter"),
6797
+ (0, import_path2.join)(scriptDir, "tree-sitter"),
6658
6798
  // Next to the Bun executable in tree-sitter/ subdirectory
6659
- (0, import_path.join)(execDir, "tree-sitter"),
6799
+ (0, import_path2.join)(execDir, "tree-sitter"),
6660
6800
  // Fallback paths
6661
- (0, import_path.join)(process.cwd(), "tree-sitter"),
6662
- (0, import_path.join)(process.cwd(), "dist/apps/cli-executables/tree-sitter"),
6663
- (0, import_path.resolve)(__dirname, "tree-sitter"),
6664
- (0, import_path.resolve)(__dirname, "../../res"),
6665
- (0, import_path.resolve)(__dirname, "../../../packages/linter-ast/res")
6801
+ (0, import_path2.join)(process.cwd(), "tree-sitter"),
6802
+ (0, import_path2.join)(process.cwd(), "dist/apps/cli-executables/tree-sitter"),
6803
+ (0, import_path2.resolve)(__dirname, "tree-sitter"),
6804
+ (0, import_path2.resolve)(__dirname, "../../res"),
6805
+ (0, import_path2.resolve)(__dirname, "../../../packages/linter-ast/res")
6666
6806
  );
6667
6807
  return paths;
6668
6808
  }
@@ -6673,12 +6813,12 @@ var BaseParser = class _BaseParser {
6673
6813
  const wasmDirs = _BaseParser.getTreeSitterWasmPaths();
6674
6814
  return (fileName) => {
6675
6815
  for (const dir of wasmDirs) {
6676
- const fullPath = (0, import_path.join)(dir, fileName);
6816
+ const fullPath = (0, import_path2.join)(dir, fileName);
6677
6817
  if ((0, import_fs.existsSync)(fullPath)) {
6678
6818
  return fullPath;
6679
6819
  }
6680
6820
  }
6681
- return (0, import_path.join)(process.cwd(), fileName);
6821
+ return (0, import_path2.join)(process.cwd(), fileName);
6682
6822
  };
6683
6823
  }
6684
6824
  /**
@@ -6687,15 +6827,15 @@ var BaseParser = class _BaseParser {
6687
6827
  static getLanguageWasmPaths(languageName) {
6688
6828
  const wasmDirs = _BaseParser.getTreeSitterWasmPaths();
6689
6829
  const wasmFileName = `tree-sitter-${languageName}.wasm`;
6690
- return wasmDirs.map((dir) => (0, import_path.join)(dir, wasmFileName)).concat([
6830
+ return wasmDirs.map((dir) => (0, import_path2.join)(dir, wasmFileName)).concat([
6691
6831
  // Additional fallback paths
6692
- (0, import_path.resolve)(__dirname, `tree-sitter/${wasmFileName}`),
6693
- (0, import_path.resolve)(__dirname, wasmFileName),
6694
- (0, import_path.resolve)(__dirname, `res/${wasmFileName}`),
6695
- (0, import_path.resolve)(__dirname, `../../res/${wasmFileName}`),
6696
- (0, import_path.resolve)(__dirname, `../res/${wasmFileName}`),
6697
- (0, import_path.resolve)(__dirname, `../../../packages/linter-ast/res/${wasmFileName}`),
6698
- (0, import_path.join)(process.cwd(), `packages/linter-ast/res/${wasmFileName}`)
6832
+ (0, import_path2.resolve)(__dirname, `tree-sitter/${wasmFileName}`),
6833
+ (0, import_path2.resolve)(__dirname, wasmFileName),
6834
+ (0, import_path2.resolve)(__dirname, `res/${wasmFileName}`),
6835
+ (0, import_path2.resolve)(__dirname, `../../res/${wasmFileName}`),
6836
+ (0, import_path2.resolve)(__dirname, `../res/${wasmFileName}`),
6837
+ (0, import_path2.resolve)(__dirname, `../../../packages/linter-ast/res/${wasmFileName}`),
6838
+ (0, import_path2.join)(process.cwd(), `packages/linter-ast/res/${wasmFileName}`)
6699
6839
  ]);
6700
6840
  }
6701
6841
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -8283,8 +8423,8 @@ var ExecuteLinterProgramsUseCase = class {
8283
8423
  this.linterAstAdapter = linterAstAdapter;
8284
8424
  this.logger = logger2;
8285
8425
  }
8286
- async execute(command8) {
8287
- const { filePath, fileContent, language, programs } = command8;
8426
+ async execute(command9) {
8427
+ const { filePath, fileContent, language, programs } = command9;
8288
8428
  if (programs.length === 0) {
8289
8429
  return {
8290
8430
  file: filePath,
@@ -8437,10 +8577,10 @@ var ExecuteLinterProgramsUseCase = class {
8437
8577
  return typeof line === "number" && Number.isInteger(line) && line >= 0;
8438
8578
  }
8439
8579
  extractRuleName(ruleContent) {
8440
- if (!ruleContent.includes("/")) {
8441
- return ruleContent;
8580
+ if (ruleContent.endsWith(".js") && ruleContent.includes("/")) {
8581
+ return ruleContent.split("/").pop()?.replace(".js", "") ?? ruleContent;
8442
8582
  }
8443
- return ruleContent.split("/").pop()?.replace(".js", "") ?? ruleContent;
8583
+ return ruleContent;
8444
8584
  }
8445
8585
  filterProgramsByLanguage(programs, fileLanguage) {
8446
8586
  const filtered = programs.filter((p) => p.language === fileLanguage);
@@ -9373,14 +9513,14 @@ ${sectionBlock}
9373
9513
  }
9374
9514
 
9375
9515
  // apps/cli/src/application/useCases/InstallPackagesUseCase.ts
9376
- var fs4 = __toESM(require("fs/promises"));
9377
- var path5 = __toESM(require("path"));
9516
+ var fs5 = __toESM(require("fs/promises"));
9517
+ var path6 = __toESM(require("path"));
9378
9518
  var InstallPackagesUseCase = class {
9379
9519
  constructor(packmindGateway) {
9380
9520
  this.packmindGateway = packmindGateway;
9381
9521
  }
9382
- async execute(command8) {
9383
- const baseDirectory = command8.baseDirectory || process.cwd();
9522
+ async execute(command9) {
9523
+ const baseDirectory = command9.baseDirectory || process.cwd();
9384
9524
  const result = {
9385
9525
  filesCreated: 0,
9386
9526
  filesUpdated: 0,
@@ -9390,8 +9530,8 @@ var InstallPackagesUseCase = class {
9390
9530
  standardsCount: 0
9391
9531
  };
9392
9532
  const response = await this.packmindGateway.getPullData({
9393
- packagesSlugs: command8.packagesSlugs,
9394
- previousPackagesSlugs: command8.previousPackagesSlugs
9533
+ packagesSlugs: command9.packagesSlugs,
9534
+ previousPackagesSlugs: command9.previousPackagesSlugs
9395
9535
  });
9396
9536
  const uniqueFilesMap = /* @__PURE__ */ new Map();
9397
9537
  for (const file of response.fileUpdates.createOrUpdate) {
@@ -9431,9 +9571,9 @@ var InstallPackagesUseCase = class {
9431
9571
  return result;
9432
9572
  }
9433
9573
  async createOrUpdateFile(baseDirectory, file, result) {
9434
- const fullPath = path5.join(baseDirectory, file.path);
9435
- const directory = path5.dirname(fullPath);
9436
- await fs4.mkdir(directory, { recursive: true });
9574
+ const fullPath = path6.join(baseDirectory, file.path);
9575
+ const directory = path6.dirname(fullPath);
9576
+ await fs5.mkdir(directory, { recursive: true });
9437
9577
  const fileExists = await this.fileExists(fullPath);
9438
9578
  if (file.content !== void 0) {
9439
9579
  await this.handleFullContentUpdate(
@@ -9453,7 +9593,7 @@ var InstallPackagesUseCase = class {
9453
9593
  }
9454
9594
  async handleFullContentUpdate(fullPath, content, fileExists, result) {
9455
9595
  if (fileExists) {
9456
- const existingContent = await fs4.readFile(fullPath, "utf-8");
9596
+ const existingContent = await fs5.readFile(fullPath, "utf-8");
9457
9597
  const commentMarker = this.extractCommentMarker(content);
9458
9598
  let finalContent;
9459
9599
  if (!commentMarker) {
@@ -9466,18 +9606,18 @@ var InstallPackagesUseCase = class {
9466
9606
  );
9467
9607
  }
9468
9608
  if (existingContent !== finalContent) {
9469
- await fs4.writeFile(fullPath, finalContent, "utf-8");
9609
+ await fs5.writeFile(fullPath, finalContent, "utf-8");
9470
9610
  result.filesUpdated++;
9471
9611
  }
9472
9612
  } else {
9473
- await fs4.writeFile(fullPath, content, "utf-8");
9613
+ await fs5.writeFile(fullPath, content, "utf-8");
9474
9614
  result.filesCreated++;
9475
9615
  }
9476
9616
  }
9477
9617
  async handleSectionsUpdate(fullPath, sections, fileExists, result) {
9478
9618
  let currentContent = "";
9479
9619
  if (fileExists) {
9480
- currentContent = await fs4.readFile(fullPath, "utf-8");
9620
+ currentContent = await fs5.readFile(fullPath, "utf-8");
9481
9621
  }
9482
9622
  const mergedContent = mergeSectionsIntoFileContent(
9483
9623
  currentContent,
@@ -9485,10 +9625,10 @@ var InstallPackagesUseCase = class {
9485
9625
  );
9486
9626
  if (currentContent !== mergedContent) {
9487
9627
  if (this.isEffectivelyEmpty(mergedContent) && fileExists) {
9488
- await fs4.unlink(fullPath);
9628
+ await fs5.unlink(fullPath);
9489
9629
  result.filesDeleted++;
9490
9630
  } else {
9491
- await fs4.writeFile(fullPath, mergedContent, "utf-8");
9631
+ await fs5.writeFile(fullPath, mergedContent, "utf-8");
9492
9632
  if (fileExists) {
9493
9633
  result.filesUpdated++;
9494
9634
  } else {
@@ -9498,19 +9638,19 @@ var InstallPackagesUseCase = class {
9498
9638
  }
9499
9639
  }
9500
9640
  async deleteFile(baseDirectory, filePath, result) {
9501
- const fullPath = path5.join(baseDirectory, filePath);
9502
- const stat4 = await fs4.stat(fullPath).catch(() => null);
9641
+ const fullPath = path6.join(baseDirectory, filePath);
9642
+ const stat4 = await fs5.stat(fullPath).catch(() => null);
9503
9643
  if (stat4?.isDirectory()) {
9504
- await fs4.rm(fullPath, { recursive: true, force: true });
9644
+ await fs5.rm(fullPath, { recursive: true, force: true });
9505
9645
  result.filesDeleted++;
9506
9646
  } else if (stat4?.isFile()) {
9507
- await fs4.unlink(fullPath);
9647
+ await fs5.unlink(fullPath);
9508
9648
  result.filesDeleted++;
9509
9649
  }
9510
9650
  }
9511
9651
  async fileExists(filePath) {
9512
9652
  try {
9513
- await fs4.access(filePath);
9653
+ await fs5.access(filePath);
9514
9654
  return true;
9515
9655
  } catch {
9516
9656
  return false;
@@ -9589,8 +9729,8 @@ var GetPackageSummaryUseCase = class {
9589
9729
  constructor(gateway) {
9590
9730
  this.gateway = gateway;
9591
9731
  }
9592
- async execute(command8) {
9593
- return this.gateway.getPackageSummary(command8);
9732
+ async execute(command9) {
9733
+ return this.gateway.getPackageSummary(command9);
9594
9734
  }
9595
9735
  };
9596
9736
 
@@ -9650,13 +9790,13 @@ var EnvCredentialsProvider = class {
9650
9790
  };
9651
9791
 
9652
9792
  // apps/cli/src/infra/utils/credentials/FileCredentialsProvider.ts
9653
- var fs5 = __toESM(require("fs"));
9654
- var path6 = __toESM(require("path"));
9793
+ var fs6 = __toESM(require("fs"));
9794
+ var path7 = __toESM(require("path"));
9655
9795
  var os2 = __toESM(require("os"));
9656
9796
  var CREDENTIALS_DIR = ".packmind";
9657
9797
  var CREDENTIALS_FILE = "credentials.json";
9658
9798
  function getCredentialsPath() {
9659
- return path6.join(os2.homedir(), CREDENTIALS_DIR, CREDENTIALS_FILE);
9799
+ return path7.join(os2.homedir(), CREDENTIALS_DIR, CREDENTIALS_FILE);
9660
9800
  }
9661
9801
  var FileCredentialsProvider = class {
9662
9802
  getSourceName() {
@@ -9664,11 +9804,11 @@ var FileCredentialsProvider = class {
9664
9804
  }
9665
9805
  hasCredentials() {
9666
9806
  const credentialsPath = getCredentialsPath();
9667
- if (!fs5.existsSync(credentialsPath)) {
9807
+ if (!fs6.existsSync(credentialsPath)) {
9668
9808
  return false;
9669
9809
  }
9670
9810
  try {
9671
- const content = fs5.readFileSync(credentialsPath, "utf-8");
9811
+ const content = fs6.readFileSync(credentialsPath, "utf-8");
9672
9812
  const credentials = JSON.parse(content);
9673
9813
  return !!credentials.apiKey;
9674
9814
  } catch {
@@ -9677,11 +9817,11 @@ var FileCredentialsProvider = class {
9677
9817
  }
9678
9818
  loadCredentials() {
9679
9819
  const credentialsPath = getCredentialsPath();
9680
- if (!fs5.existsSync(credentialsPath)) {
9820
+ if (!fs6.existsSync(credentialsPath)) {
9681
9821
  return null;
9682
9822
  }
9683
9823
  try {
9684
- const content = fs5.readFileSync(credentialsPath, "utf-8");
9824
+ const content = fs6.readFileSync(credentialsPath, "utf-8");
9685
9825
  const credentials = JSON.parse(content);
9686
9826
  if (!credentials.apiKey) {
9687
9827
  return null;
@@ -9704,13 +9844,13 @@ var FileCredentialsProvider = class {
9704
9844
  }
9705
9845
  };
9706
9846
  function saveCredentials(apiKey) {
9707
- const credentialsDir = path6.join(os2.homedir(), CREDENTIALS_DIR);
9708
- if (!fs5.existsSync(credentialsDir)) {
9709
- fs5.mkdirSync(credentialsDir, { recursive: true, mode: 448 });
9847
+ const credentialsDir = path7.join(os2.homedir(), CREDENTIALS_DIR);
9848
+ if (!fs6.existsSync(credentialsDir)) {
9849
+ fs6.mkdirSync(credentialsDir, { recursive: true, mode: 448 });
9710
9850
  }
9711
9851
  const credentialsPath = getCredentialsPath();
9712
9852
  const credentials = { apiKey };
9713
- fs5.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {
9853
+ fs6.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {
9714
9854
  mode: 384
9715
9855
  });
9716
9856
  }
@@ -9868,8 +10008,8 @@ var LoginUseCase = class {
9868
10008
  startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
9869
10009
  };
9870
10010
  }
9871
- async execute(command8) {
9872
- const { host, code: providedCode } = command8;
10011
+ async execute(command9) {
10012
+ const { host, code: providedCode } = command9;
9873
10013
  let code;
9874
10014
  if (providedCode) {
9875
10015
  code = providedCode;
@@ -9900,14 +10040,14 @@ var LoginUseCase = class {
9900
10040
  };
9901
10041
 
9902
10042
  // apps/cli/src/application/useCases/LogoutUseCase.ts
9903
- var fs6 = __toESM(require("fs"));
10043
+ var fs7 = __toESM(require("fs"));
9904
10044
  var ENV_VAR_NAME2 = "PACKMIND_API_KEY_V3";
9905
10045
  var LogoutUseCase = class {
9906
10046
  constructor(deps) {
9907
10047
  this.deps = {
9908
10048
  getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
9909
- fileExists: deps?.fileExists ?? ((path11) => fs6.existsSync(path11)),
9910
- deleteFile: deps?.deleteFile ?? ((path11) => fs6.unlinkSync(path11)),
10049
+ fileExists: deps?.fileExists ?? ((path12) => fs7.existsSync(path12)),
10050
+ deleteFile: deps?.deleteFile ?? ((path12) => fs7.unlinkSync(path12)),
9911
10051
  hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
9912
10052
  };
9913
10053
  }
@@ -9967,8 +10107,8 @@ var SetupMcpUseCase = class {
9967
10107
  constructor(deps) {
9968
10108
  this.deps = deps;
9969
10109
  }
9970
- async execute(command8) {
9971
- const { agentTypes } = command8;
10110
+ async execute(command9) {
10111
+ const { agentTypes } = command9;
9972
10112
  const [tokenResult, urlResult] = await Promise.all([
9973
10113
  this.deps.gateway.getMcpToken({}),
9974
10114
  this.deps.gateway.getMcpUrl({})
@@ -10003,8 +10143,8 @@ var SetupMcpUseCase = class {
10003
10143
  };
10004
10144
 
10005
10145
  // apps/cli/src/application/services/McpConfigService.ts
10006
- var fs7 = __toESM(require("fs"));
10007
- var path7 = __toESM(require("path"));
10146
+ var fs8 = __toESM(require("fs"));
10147
+ var path8 = __toESM(require("path"));
10008
10148
  var os3 = __toESM(require("os"));
10009
10149
  var import_child_process2 = require("child_process");
10010
10150
  var McpConfigService = class {
@@ -10039,9 +10179,9 @@ var McpConfigService = class {
10039
10179
  return JSON.stringify(mcpConfig, null, 2);
10040
10180
  }
10041
10181
  installClaudeMcp(config) {
10042
- const command8 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
10182
+ const command9 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
10043
10183
  try {
10044
- (0, import_child_process2.execSync)(command8, { stdio: "pipe" });
10184
+ (0, import_child_process2.execSync)(command9, { stdio: "pipe" });
10045
10185
  return { success: true };
10046
10186
  } catch (error) {
10047
10187
  const execError = error;
@@ -10051,11 +10191,11 @@ var McpConfigService = class {
10051
10191
  }
10052
10192
  installCursorMcp(config) {
10053
10193
  try {
10054
- const cursorConfigPath = path7.join(os3.homedir(), ".cursor", "mcp.json");
10194
+ const cursorConfigPath = path8.join(os3.homedir(), ".cursor", "mcp.json");
10055
10195
  const cursorConfig = this.buildCursorConfig(config);
10056
10196
  const existingConfig = this.readExistingJsonConfig(cursorConfigPath);
10057
10197
  const mergedConfig = this.mergeConfig(existingConfig, cursorConfig);
10058
- fs7.writeFileSync(cursorConfigPath, JSON.stringify(mergedConfig, null, 2));
10198
+ fs8.writeFileSync(cursorConfigPath, JSON.stringify(mergedConfig, null, 2));
10059
10199
  return { success: true };
10060
10200
  } catch (error) {
10061
10201
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -10064,15 +10204,15 @@ var McpConfigService = class {
10064
10204
  }
10065
10205
  installVSCodeMcp(config) {
10066
10206
  try {
10067
- const vscodeDir = path7.join(this.projectDir, ".vscode");
10068
- if (!fs7.existsSync(vscodeDir)) {
10069
- fs7.mkdirSync(vscodeDir, { recursive: true });
10207
+ const vscodeDir = path8.join(this.projectDir, ".vscode");
10208
+ if (!fs8.existsSync(vscodeDir)) {
10209
+ fs8.mkdirSync(vscodeDir, { recursive: true });
10070
10210
  }
10071
- const vscodeConfigPath = path7.join(vscodeDir, "mcp.json");
10211
+ const vscodeConfigPath = path8.join(vscodeDir, "mcp.json");
10072
10212
  const vscodeConfig = this.buildVSCodeConfig(config);
10073
10213
  const existingConfig = this.readExistingJsonConfig(vscodeConfigPath);
10074
10214
  const mergedConfig = this.mergeVSCodeConfig(existingConfig, vscodeConfig);
10075
- fs7.writeFileSync(vscodeConfigPath, JSON.stringify(mergedConfig, null, 2));
10215
+ fs8.writeFileSync(vscodeConfigPath, JSON.stringify(mergedConfig, null, 2));
10076
10216
  return { success: true };
10077
10217
  } catch (error) {
10078
10218
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -10081,14 +10221,14 @@ var McpConfigService = class {
10081
10221
  }
10082
10222
  installContinueMcp(config) {
10083
10223
  try {
10084
- const continueDir = path7.join(this.projectDir, ".continue");
10085
- const mcpServersDir = path7.join(continueDir, "mcpServers");
10086
- if (!fs7.existsSync(mcpServersDir)) {
10087
- fs7.mkdirSync(mcpServersDir, { recursive: true });
10224
+ const continueDir = path8.join(this.projectDir, ".continue");
10225
+ const mcpServersDir = path8.join(continueDir, "mcpServers");
10226
+ if (!fs8.existsSync(mcpServersDir)) {
10227
+ fs8.mkdirSync(mcpServersDir, { recursive: true });
10088
10228
  }
10089
- const continueConfigPath = path7.join(mcpServersDir, "packmind.yaml");
10229
+ const continueConfigPath = path8.join(mcpServersDir, "packmind.yaml");
10090
10230
  const continueConfig = this.buildContinueYamlConfig(config);
10091
- fs7.writeFileSync(continueConfigPath, continueConfig);
10231
+ fs8.writeFileSync(continueConfigPath, continueConfig);
10092
10232
  return { success: true };
10093
10233
  } catch (error) {
10094
10234
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -10136,8 +10276,8 @@ mcpServers:
10136
10276
  }
10137
10277
  readExistingJsonConfig(filePath) {
10138
10278
  try {
10139
- if (fs7.existsSync(filePath)) {
10140
- const content = fs7.readFileSync(filePath, "utf-8");
10279
+ if (fs8.existsSync(filePath)) {
10280
+ const content = fs8.readFileSync(filePath, "utf-8");
10141
10281
  return JSON.parse(content);
10142
10282
  }
10143
10283
  } catch {
@@ -10170,8 +10310,8 @@ mcpServers:
10170
10310
  };
10171
10311
 
10172
10312
  // apps/cli/src/infra/repositories/ConfigFileRepository.ts
10173
- var fs8 = __toESM(require("fs/promises"));
10174
- var path8 = __toESM(require("path"));
10313
+ var fs9 = __toESM(require("fs/promises"));
10314
+ var path9 = __toESM(require("path"));
10175
10315
 
10176
10316
  // apps/cli/src/infra/utils/consoleLogger.ts
10177
10317
  init_source();
@@ -10219,23 +10359,23 @@ var ConfigFileRepository = class {
10219
10359
  ];
10220
10360
  }
10221
10361
  async writeConfig(baseDirectory, config) {
10222
- const configPath = path8.join(baseDirectory, this.CONFIG_FILENAME);
10362
+ const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
10223
10363
  const configContent = JSON.stringify(config, null, 2) + "\n";
10224
- await fs8.writeFile(configPath, configContent, "utf-8");
10364
+ await fs9.writeFile(configPath, configContent, "utf-8");
10225
10365
  }
10226
10366
  async configExists(baseDirectory) {
10227
- const configPath = path8.join(baseDirectory, this.CONFIG_FILENAME);
10367
+ const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
10228
10368
  try {
10229
- await fs8.access(configPath);
10369
+ await fs9.access(configPath);
10230
10370
  return true;
10231
10371
  } catch {
10232
10372
  return false;
10233
10373
  }
10234
10374
  }
10235
10375
  async readConfig(baseDirectory) {
10236
- const configPath = path8.join(baseDirectory, this.CONFIG_FILENAME);
10376
+ const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
10237
10377
  try {
10238
- const configContent = await fs8.readFile(configPath, "utf-8");
10378
+ const configContent = await fs9.readFile(configPath, "utf-8");
10239
10379
  const config = JSON.parse(configContent);
10240
10380
  if (!config.packages || typeof config.packages !== "object") {
10241
10381
  throw new Error(
@@ -10262,12 +10402,12 @@ var ConfigFileRepository = class {
10262
10402
  * @returns Array of directory paths that contain a packmind.json file
10263
10403
  */
10264
10404
  async findDescendantConfigs(directory) {
10265
- const normalizedDir = path8.resolve(directory);
10405
+ const normalizedDir = path9.resolve(directory);
10266
10406
  const results = [];
10267
10407
  const searchRecursively = async (currentDir) => {
10268
10408
  let entries;
10269
10409
  try {
10270
- entries = await fs8.readdir(currentDir, { withFileTypes: true });
10410
+ entries = await fs9.readdir(currentDir, { withFileTypes: true });
10271
10411
  } catch {
10272
10412
  return;
10273
10413
  }
@@ -10278,7 +10418,7 @@ var ConfigFileRepository = class {
10278
10418
  if (this.EXCLUDED_DIRECTORIES.includes(entry.name)) {
10279
10419
  continue;
10280
10420
  }
10281
- const entryPath = path8.join(currentDir, entry.name);
10421
+ const entryPath = path9.join(currentDir, entry.name);
10282
10422
  const config = await this.readConfig(entryPath);
10283
10423
  if (config) {
10284
10424
  results.push(entryPath);
@@ -10300,19 +10440,19 @@ var ConfigFileRepository = class {
10300
10440
  async readHierarchicalConfig(startDirectory, stopDirectory) {
10301
10441
  const configs = [];
10302
10442
  const configPaths = [];
10303
- const normalizedStart = path8.resolve(startDirectory);
10304
- const normalizedStop = stopDirectory ? path8.resolve(stopDirectory) : null;
10443
+ const normalizedStart = path9.resolve(startDirectory);
10444
+ const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
10305
10445
  let currentDir = normalizedStart;
10306
10446
  while (true) {
10307
10447
  const config = await this.readConfig(currentDir);
10308
10448
  if (config) {
10309
10449
  configs.push(config);
10310
- configPaths.push(path8.join(currentDir, this.CONFIG_FILENAME));
10450
+ configPaths.push(path9.join(currentDir, this.CONFIG_FILENAME));
10311
10451
  }
10312
10452
  if (normalizedStop !== null && currentDir === normalizedStop) {
10313
10453
  break;
10314
10454
  }
10315
- const parentDir = path8.dirname(currentDir);
10455
+ const parentDir = path9.dirname(currentDir);
10316
10456
  if (parentDir === currentDir) {
10317
10457
  break;
10318
10458
  }
@@ -10341,8 +10481,8 @@ var ConfigFileRepository = class {
10341
10481
  * @returns All configs found with their target paths
10342
10482
  */
10343
10483
  async findAllConfigsInTree(startDirectory, stopDirectory) {
10344
- const normalizedStart = path8.resolve(startDirectory);
10345
- const normalizedStop = stopDirectory ? path8.resolve(stopDirectory) : null;
10484
+ const normalizedStart = path9.resolve(startDirectory);
10485
+ const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
10346
10486
  const basePath = normalizedStop ?? normalizedStart;
10347
10487
  const configsMap = /* @__PURE__ */ new Map();
10348
10488
  let currentDir = normalizedStart;
@@ -10359,7 +10499,7 @@ var ConfigFileRepository = class {
10359
10499
  if (normalizedStop !== null && currentDir === normalizedStop) {
10360
10500
  break;
10361
10501
  }
10362
- const parentDir = path8.dirname(currentDir);
10502
+ const parentDir = path9.dirname(currentDir);
10363
10503
  if (parentDir === currentDir) {
10364
10504
  break;
10365
10505
  }
@@ -10479,29 +10619,29 @@ var PackmindCliHexa = class {
10479
10619
  this.logger.info("Destroying PackmindCliHexa");
10480
10620
  this.logger.info("PackmindCliHexa destroyed");
10481
10621
  }
10482
- async getGitRemoteUrl(command8) {
10483
- return this.hexa.useCases.getGitRemoteUrl.execute(command8);
10622
+ async getGitRemoteUrl(command9) {
10623
+ return this.hexa.useCases.getGitRemoteUrl.execute(command9);
10484
10624
  }
10485
- async executeSingleFileAst(command8) {
10486
- return this.hexa.useCases.executeSingleFileAst.execute(command8);
10625
+ async executeSingleFileAst(command9) {
10626
+ return this.hexa.useCases.executeSingleFileAst.execute(command9);
10487
10627
  }
10488
- async listFilesInDirectory(command8) {
10489
- return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command8);
10628
+ async listFilesInDirectory(command9) {
10629
+ return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command9);
10490
10630
  }
10491
- async lintFilesInDirectory(command8) {
10492
- return this.hexa.useCases.lintFilesInDirectory.execute(command8);
10631
+ async lintFilesInDirectory(command9) {
10632
+ return this.hexa.useCases.lintFilesInDirectory.execute(command9);
10493
10633
  }
10494
- async lintFilesLocally(command8) {
10495
- return this.hexa.useCases.lintFilesLocally.execute(command8);
10634
+ async lintFilesLocally(command9) {
10635
+ return this.hexa.useCases.lintFilesLocally.execute(command9);
10496
10636
  }
10497
- async installPackages(command8) {
10498
- return this.hexa.useCases.installPackages.execute(command8);
10637
+ async installPackages(command9) {
10638
+ return this.hexa.useCases.installPackages.execute(command9);
10499
10639
  }
10500
- async listPackages(command8) {
10501
- return this.hexa.useCases.listPackages.execute(command8);
10640
+ async listPackages(command9) {
10641
+ return this.hexa.useCases.listPackages.execute(command9);
10502
10642
  }
10503
- async getPackageBySlug(command8) {
10504
- return this.hexa.useCases.getPackageBySlug.execute(command8);
10643
+ async getPackageBySlug(command9) {
10644
+ return this.hexa.useCases.getPackageBySlug.execute(command9);
10505
10645
  }
10506
10646
  async configExists(baseDirectory) {
10507
10647
  return await this.hexa.repositories.configFileRepository.configExists(
@@ -10560,17 +10700,17 @@ var PackmindCliHexa = class {
10560
10700
  directory
10561
10701
  );
10562
10702
  }
10563
- async login(command8) {
10564
- return this.hexa.useCases.login.execute(command8);
10703
+ async login(command9) {
10704
+ return this.hexa.useCases.login.execute(command9);
10565
10705
  }
10566
- async logout(command8) {
10567
- return this.hexa.useCases.logout.execute(command8);
10706
+ async logout(command9) {
10707
+ return this.hexa.useCases.logout.execute(command9);
10568
10708
  }
10569
- async whoami(command8) {
10570
- return this.hexa.useCases.whoami.execute(command8);
10709
+ async whoami(command9) {
10710
+ return this.hexa.useCases.whoami.execute(command9);
10571
10711
  }
10572
- async setupMcp(command8) {
10573
- return this.hexa.useCases.setupMcp.execute(command8);
10712
+ async setupMcp(command9) {
10713
+ return this.hexa.useCases.setupMcp.execute(command9);
10574
10714
  }
10575
10715
  getCurrentBranch(repoPath) {
10576
10716
  return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
@@ -10578,8 +10718,11 @@ var PackmindCliHexa = class {
10578
10718
  getGitRemoteUrlFromPath(repoPath) {
10579
10719
  return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
10580
10720
  }
10581
- async notifyDistribution(command8) {
10582
- return this.hexa.repositories.packmindGateway.notifyDistribution(command8);
10721
+ async notifyDistribution(command9) {
10722
+ return this.hexa.repositories.packmindGateway.notifyDistribution(command9);
10723
+ }
10724
+ async uploadSkill(command9) {
10725
+ return this.hexa.repositories.packmindGateway.uploadSkill(command9);
10583
10726
  }
10584
10727
  };
10585
10728
 
@@ -10636,7 +10779,7 @@ function isNotLoggedInError(error) {
10636
10779
  }
10637
10780
  async function lintHandler(args2, deps) {
10638
10781
  const {
10639
- path: path11,
10782
+ path: path12,
10640
10783
  draft,
10641
10784
  rule,
10642
10785
  language,
@@ -10656,14 +10799,14 @@ async function lintHandler(args2, deps) {
10656
10799
  throw new Error("option --rule is required to use --draft mode");
10657
10800
  }
10658
10801
  const startedAt = Date.now();
10659
- const targetPath = path11 ?? ".";
10802
+ const targetPath = path12 ?? ".";
10660
10803
  const hasArguments = !!(draft || rule || language);
10661
10804
  const absolutePath = resolvePath(targetPath);
10662
10805
  if (diff) {
10663
10806
  const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
10664
10807
  if (!gitRoot) {
10665
10808
  throw new Error(
10666
- "The --diff option requires the project to be in a Git repository"
10809
+ "The --changed-files and --changed-lines options require the project to be in a Git repository"
10667
10810
  );
10668
10811
  }
10669
10812
  }
@@ -10703,15 +10846,15 @@ async function lintHandler(args2, deps) {
10703
10846
  }
10704
10847
  } catch (error) {
10705
10848
  if (isNotLoggedInError(error) && continueOnMissingKey) {
10706
- console.warn(
10849
+ logWarningConsole(
10707
10850
  "Warning: Not logged in to Packmind, linting is skipped. Run `packmind-cli login` to authenticate."
10708
10851
  );
10709
10852
  exit(0);
10710
10853
  return;
10711
10854
  }
10712
10855
  if (error instanceof CommunityEditionError) {
10713
- console.log(`packmind-cli ${error.message}`);
10714
- console.log("Linting skipped.");
10856
+ logInfoConsole(`packmind-cli ${error.message}`);
10857
+ logInfoConsole("Linting skipped.");
10715
10858
  exit(0);
10716
10859
  return;
10717
10860
  }
@@ -10721,7 +10864,7 @@ async function lintHandler(args2, deps) {
10721
10864
  violations
10722
10865
  );
10723
10866
  const durationSeconds = (Date.now() - startedAt) / 1e3;
10724
- console.log(`Lint completed in ${durationSeconds.toFixed(2)}s`);
10867
+ logInfoConsole(`Lint completed in ${durationSeconds.toFixed(2)}s`);
10725
10868
  if (violations.length > 0 && !continueOnError) {
10726
10869
  exit(1);
10727
10870
  } else {
@@ -10814,11 +10957,34 @@ var lintCommand = (0, import_cmd_ts.command)({
10814
10957
  }),
10815
10958
  diff: (0, import_cmd_ts.option)({
10816
10959
  long: "diff",
10817
- description: "Filter violations by git diff (files | lines)",
10960
+ description: "[Deprecated: use --changed-files or --changed-lines] Filter violations by git diff (files | lines)",
10818
10961
  type: (0, import_cmd_ts.optional)(DiffModeType)
10962
+ }),
10963
+ changedFiles: (0, import_cmd_ts.flag)({
10964
+ long: "changed-files",
10965
+ description: "Only lint files that have changed"
10966
+ }),
10967
+ changedLines: (0, import_cmd_ts.flag)({
10968
+ long: "changed-lines",
10969
+ description: "Only lint lines that have changed"
10819
10970
  })
10820
10971
  },
10821
10972
  handler: async (args2) => {
10973
+ if (args2.changedFiles && args2.changedLines) {
10974
+ throw new Error(
10975
+ "Options --changed-files and --changed-lines are mutually exclusive"
10976
+ );
10977
+ }
10978
+ if (args2.diff) {
10979
+ const replacement = args2.diff === "files" /* FILES */ ? "--changed-files" : "--changed-lines";
10980
+ logWarningConsole(`--diff is deprecated. Use ${replacement} instead.`);
10981
+ }
10982
+ let diff = args2.diff;
10983
+ if (args2.changedFiles) {
10984
+ diff = "files" /* FILES */;
10985
+ } else if (args2.changedLines) {
10986
+ diff = "lines" /* LINES */;
10987
+ }
10822
10988
  const packmindLogger = new PackmindLogger(
10823
10989
  "PackmindCLI",
10824
10990
  args2.debug ? "debug" /* DEBUG */ : "info" /* INFO */
@@ -10830,13 +10996,13 @@ var lintCommand = (0, import_cmd_ts.command)({
10830
10996
  resolvePath: (targetPath) => pathModule.isAbsolute(targetPath) ? targetPath : pathModule.resolve(process.cwd(), targetPath),
10831
10997
  exit: (code) => process.exit(code)
10832
10998
  };
10833
- await lintHandler(args2, deps);
10999
+ await lintHandler({ ...args2, diff }, deps);
10834
11000
  }
10835
11001
  });
10836
11002
 
10837
11003
  // apps/cli/src/wasm-runtime.ts
10838
11004
  var import_fs18 = require("fs");
10839
- var import_path2 = require("path");
11005
+ var import_path3 = require("path");
10840
11006
  var import_os = require("os");
10841
11007
 
10842
11008
  // apps/cli/src/embedded-wasm.ts
@@ -10870,12 +11036,12 @@ function extractWasmFiles() {
10870
11036
  if (wasmExtractedDir && (0, import_fs18.existsSync)(wasmExtractedDir)) {
10871
11037
  return wasmExtractedDir;
10872
11038
  }
10873
- const tempDir = (0, import_path2.join)((0, import_os.tmpdir)(), `packmind-wasm-${process.pid}`);
11039
+ const tempDir = (0, import_path3.join)((0, import_os.tmpdir)(), `packmind-wasm-${process.pid}`);
10874
11040
  if (!(0, import_fs18.existsSync)(tempDir)) {
10875
11041
  (0, import_fs18.mkdirSync)(tempDir, { recursive: true });
10876
11042
  }
10877
11043
  for (const [filename, base64Data] of Object.entries(EMBEDDED_WASM_FILES)) {
10878
- const wasmPath = (0, import_path2.join)(tempDir, filename);
11044
+ const wasmPath = (0, import_path3.join)(tempDir, filename);
10879
11045
  if ((0, import_fs18.existsSync)(wasmPath)) {
10880
11046
  continue;
10881
11047
  }
@@ -10890,8 +11056,8 @@ function extractWasmFiles() {
10890
11056
 
10891
11057
  // apps/cli/src/main.ts
10892
11058
  var import_dotenv = require("dotenv");
10893
- var fs11 = __toESM(require("fs"));
10894
- var path10 = __toESM(require("path"));
11059
+ var fs12 = __toESM(require("fs"));
11060
+ var path11 = __toESM(require("path"));
10895
11061
 
10896
11062
  // apps/cli/src/infra/commands/InstallCommand.ts
10897
11063
  var import_cmd_ts2 = __toESM(require_cjs());
@@ -11850,13 +12016,13 @@ Credentials are loaded from (in order of priority):`);
11850
12016
 
11851
12017
  // apps/cli/src/infra/commands/SetupMcpCommand.ts
11852
12018
  var import_cmd_ts7 = __toESM(require_cjs());
11853
- var fs10 = __toESM(require("fs"));
12019
+ var fs11 = __toESM(require("fs"));
11854
12020
  var readline2 = __toESM(require("readline"));
11855
12021
  var inquirer = __toESM(require("inquirer"));
11856
12022
 
11857
12023
  // apps/cli/src/application/services/AgentDetectionService.ts
11858
- var fs9 = __toESM(require("fs"));
11859
- var path9 = __toESM(require("path"));
12024
+ var fs10 = __toESM(require("fs"));
12025
+ var path10 = __toESM(require("path"));
11860
12026
  var os4 = __toESM(require("os"));
11861
12027
  var import_child_process3 = require("child_process");
11862
12028
  var AgentDetectionService = class {
@@ -11883,21 +12049,21 @@ var AgentDetectionService = class {
11883
12049
  return this.isCommandAvailable("claude");
11884
12050
  }
11885
12051
  isCursorAvailable() {
11886
- const cursorConfigDir = path9.join(os4.homedir(), ".cursor");
11887
- return fs9.existsSync(cursorConfigDir);
12052
+ const cursorConfigDir = path10.join(os4.homedir(), ".cursor");
12053
+ return fs10.existsSync(cursorConfigDir);
11888
12054
  }
11889
12055
  isVSCodeAvailable() {
11890
- const vscodeDir = path9.join(this.projectDir, ".vscode");
11891
- return fs9.existsSync(vscodeDir);
12056
+ const vscodeDir = path10.join(this.projectDir, ".vscode");
12057
+ return fs10.existsSync(vscodeDir);
11892
12058
  }
11893
12059
  isContinueAvailable() {
11894
- const continueDir = path9.join(this.projectDir, ".continue");
11895
- return fs9.existsSync(continueDir);
12060
+ const continueDir = path10.join(this.projectDir, ".continue");
12061
+ return fs10.existsSync(continueDir);
11896
12062
  }
11897
- isCommandAvailable(command8) {
12063
+ isCommandAvailable(command9) {
11898
12064
  try {
11899
12065
  const whichCommand = process.platform === "win32" ? "where" : "which";
11900
- (0, import_child_process3.execSync)(`${whichCommand} ${command8}`, { stdio: "pipe" });
12066
+ (0, import_child_process3.execSync)(`${whichCommand} ${command9}`, { stdio: "pipe" });
11901
12067
  return true;
11902
12068
  } catch {
11903
12069
  return false;
@@ -11931,8 +12097,8 @@ var ALL_AGENTS2 = [
11931
12097
  { type: "continue", name: "Continue.dev" }
11932
12098
  ];
11933
12099
  async function promptAgentsWithReadline(choices) {
11934
- const input = fs10.createReadStream("/dev/tty");
11935
- const output = fs10.createWriteStream("/dev/tty");
12100
+ const input = fs11.createReadStream("/dev/tty");
12101
+ const output = fs11.createWriteStream("/dev/tty");
11936
12102
  const rl = readline2.createInterface({
11937
12103
  input,
11938
12104
  output
@@ -12092,26 +12258,64 @@ Credentials are loaded from (in order of priority):`);
12092
12258
  }
12093
12259
  });
12094
12260
 
12261
+ // apps/cli/src/infra/commands/UploadSkillCommand.ts
12262
+ var import_cmd_ts8 = __toESM(require_cjs());
12263
+ var uploadSkillCommand = (0, import_cmd_ts8.command)({
12264
+ name: "upload-skill",
12265
+ description: "Upload a skill from a local directory to a Packmind organization",
12266
+ args: {
12267
+ skillPath: (0, import_cmd_ts8.positional)({
12268
+ type: import_cmd_ts8.string,
12269
+ displayName: "path",
12270
+ description: "Path to skill directory containing SKILL.md"
12271
+ })
12272
+ },
12273
+ handler: async ({ skillPath }) => {
12274
+ const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
12275
+ const packmindCliHexa = new PackmindCliHexa(packmindLogger);
12276
+ try {
12277
+ logInfoConsole(`Uploading skill from ${skillPath}...`);
12278
+ const result = await packmindCliHexa.uploadSkill({
12279
+ skillPath,
12280
+ organizationId: "",
12281
+ userId: ""
12282
+ });
12283
+ logSuccessConsole("Skill uploaded successfully!");
12284
+ console.log(` Skill ID: ${result.skillId}`);
12285
+ console.log(` Name: ${result.name}`);
12286
+ console.log(` Files: ${result.fileCount}`);
12287
+ console.log(` Total size: ${(result.totalSize / 1024).toFixed(2)} KB`);
12288
+ } catch (error) {
12289
+ if (error instanceof Error) {
12290
+ logErrorConsole(`Upload failed: ${error.message}`);
12291
+ } else {
12292
+ logErrorConsole(`Upload failed: ${String(error)}`);
12293
+ }
12294
+ process.exit(1);
12295
+ }
12296
+ }
12297
+ });
12298
+
12095
12299
  // apps/cli/src/main.ts
12096
12300
  var { version: CLI_VERSION } = require_package();
12097
12301
  function findEnvFile() {
12098
12302
  const currentDir = process.cwd();
12099
12303
  const gitService = new GitService();
12100
12304
  const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
12101
- const filesystemRoot = path10.parse(currentDir).root;
12305
+ const filesystemRoot = path11.parse(currentDir).root;
12102
12306
  const stopDir = gitRoot ?? filesystemRoot;
12103
12307
  let searchDir = currentDir;
12104
- let parentDir = path10.dirname(searchDir);
12308
+ let parentDir = path11.dirname(searchDir);
12105
12309
  while (searchDir !== parentDir) {
12106
- const envPath2 = path10.join(searchDir, ".env");
12107
- if (fs11.existsSync(envPath2)) {
12310
+ const envPath2 = path11.join(searchDir, ".env");
12311
+ if (fs12.existsSync(envPath2)) {
12108
12312
  return envPath2;
12109
12313
  }
12110
12314
  if (searchDir === stopDir) {
12111
12315
  return null;
12112
12316
  }
12113
12317
  searchDir = parentDir;
12114
- parentDir = path10.dirname(searchDir);
12318
+ parentDir = path11.dirname(searchDir);
12115
12319
  }
12116
12320
  return null;
12117
12321
  }
@@ -12131,7 +12335,7 @@ if (args.includes("--version") || args.includes("-v")) {
12131
12335
  console.log(`packmind-cli version ${CLI_VERSION}`);
12132
12336
  process.exit(0);
12133
12337
  }
12134
- var app = (0, import_cmd_ts8.subcommands)({
12338
+ var app = (0, import_cmd_ts9.subcommands)({
12135
12339
  name: "packmind-cli",
12136
12340
  description: "Packmind CLI tool",
12137
12341
  cmds: {
@@ -12143,10 +12347,11 @@ var app = (0, import_cmd_ts8.subcommands)({
12143
12347
  login: loginCommand,
12144
12348
  logout: logoutCommand,
12145
12349
  whoami: whoamiCommand,
12146
- "setup-mcp": setupMcpCommand
12350
+ "setup-mcp": setupMcpCommand,
12351
+ "upload-skill": uploadSkillCommand
12147
12352
  }
12148
12353
  });
12149
- (0, import_cmd_ts8.run)(app, args).catch((error) => {
12354
+ (0, import_cmd_ts9.run)(app, args).catch((error) => {
12150
12355
  logErrorConsole(error.message);
12151
12356
  process.exit(1);
12152
12357
  });