@packmind/cli 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.cjs +62 -27
- package/package.json +1 -1
package/main.cjs
CHANGED
|
@@ -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.13.
|
|
3855
|
+
version: "0.13.1",
|
|
3856
3856
|
description: "A command-line interface for Packmind linting and code quality checks",
|
|
3857
3857
|
private: false,
|
|
3858
3858
|
bin: {
|
|
@@ -4195,6 +4195,13 @@ var RuleAddedEvent = class extends UserEvent {
|
|
|
4195
4195
|
}
|
|
4196
4196
|
};
|
|
4197
4197
|
|
|
4198
|
+
// packages/types/src/standards/events/RuleDeletedEvent.ts
|
|
4199
|
+
var RuleDeletedEvent = class extends UserEvent {
|
|
4200
|
+
static {
|
|
4201
|
+
this.eventName = "standards.rule.deleted";
|
|
4202
|
+
}
|
|
4203
|
+
};
|
|
4204
|
+
|
|
4198
4205
|
// packages/types/src/standards/events/RuleUpdatedEvent.ts
|
|
4199
4206
|
var RuleUpdatedEvent = class extends UserEvent {
|
|
4200
4207
|
static {
|
|
@@ -4766,6 +4773,18 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
4766
4773
|
// apps/cli/src/application/services/GitService.ts
|
|
4767
4774
|
var import_child_process = require("child_process");
|
|
4768
4775
|
var path = __toESM(require("path"));
|
|
4776
|
+
|
|
4777
|
+
// apps/cli/src/application/utils/pathUtils.ts
|
|
4778
|
+
function normalizePath(p) {
|
|
4779
|
+
return p.replace(/\\/g, "/");
|
|
4780
|
+
}
|
|
4781
|
+
function pathStartsWith(filePath, prefix) {
|
|
4782
|
+
const normalizedFile = normalizePath(filePath);
|
|
4783
|
+
const normalizedPrefix = normalizePath(prefix);
|
|
4784
|
+
return normalizedFile.startsWith(normalizedPrefix + "/") || normalizedFile === normalizedPrefix;
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4787
|
+
// apps/cli/src/application/services/GitService.ts
|
|
4769
4788
|
var origin = "GitService";
|
|
4770
4789
|
var GitService = class {
|
|
4771
4790
|
constructor(logger2 = new PackmindLogger(origin), gitRunner = (cmd, opts) => {
|
|
@@ -4965,7 +4984,7 @@ ${error.message}`
|
|
|
4965
4984
|
const { stdout } = this.gitRunner("diff --name-only HEAD", {
|
|
4966
4985
|
cwd: gitRoot
|
|
4967
4986
|
});
|
|
4968
|
-
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => path.join(gitRoot, relativePath));
|
|
4987
|
+
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => normalizePath(path.join(gitRoot, relativePath)));
|
|
4969
4988
|
} catch (error) {
|
|
4970
4989
|
if (error instanceof Error && error.message.includes("unknown revision")) {
|
|
4971
4990
|
this.logger.debug(
|
|
@@ -4983,7 +5002,7 @@ ${error.message}`
|
|
|
4983
5002
|
const { stdout } = this.gitRunner("diff --cached --name-only", {
|
|
4984
5003
|
cwd: gitRoot
|
|
4985
5004
|
});
|
|
4986
|
-
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => path.join(gitRoot, relativePath));
|
|
5005
|
+
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => normalizePath(path.join(gitRoot, relativePath)));
|
|
4987
5006
|
}
|
|
4988
5007
|
/**
|
|
4989
5008
|
* Gets untracked files (new files not yet added to git).
|
|
@@ -4994,7 +5013,7 @@ ${error.message}`
|
|
|
4994
5013
|
const { stdout } = this.gitRunner("ls-files --others --exclude-standard", {
|
|
4995
5014
|
cwd: gitRoot
|
|
4996
5015
|
});
|
|
4997
|
-
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => path.join(gitRoot, relativePath));
|
|
5016
|
+
return stdout.trim().split("\n").filter((line) => line.length > 0).map((relativePath) => normalizePath(path.join(gitRoot, relativePath)));
|
|
4998
5017
|
}
|
|
4999
5018
|
/**
|
|
5000
5019
|
* Gets line-level diff information for modified files.
|
|
@@ -5066,7 +5085,7 @@ ${error.message}`
|
|
|
5066
5085
|
for (const line of lines) {
|
|
5067
5086
|
const fileMatch = line.match(/^diff --git a\/(.+) b\/(.+)$/);
|
|
5068
5087
|
if (fileMatch) {
|
|
5069
|
-
currentFile = path.join(gitRoot, fileMatch[2]);
|
|
5088
|
+
currentFile = normalizePath(path.join(gitRoot, fileMatch[2]));
|
|
5070
5089
|
continue;
|
|
5071
5090
|
}
|
|
5072
5091
|
const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/);
|
|
@@ -5326,7 +5345,7 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
5326
5345
|
directoryForGitOps
|
|
5327
5346
|
);
|
|
5328
5347
|
const absoluteLintPath = absoluteUserPath;
|
|
5329
|
-
if (!absoluteLintPath
|
|
5348
|
+
if (!pathStartsWith(absoluteLintPath, gitRepoRoot)) {
|
|
5330
5349
|
throw new Error(
|
|
5331
5350
|
`The path "${absoluteLintPath}" is not within the git repository at "${gitRepoRoot}"`
|
|
5332
5351
|
);
|
|
@@ -5484,7 +5503,7 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
5484
5503
|
const violations = [];
|
|
5485
5504
|
for (const file of files) {
|
|
5486
5505
|
const fileViolations = [];
|
|
5487
|
-
const relativeFilePath = file.path
|
|
5506
|
+
const relativeFilePath = pathStartsWith(file.path, gitRepoRoot) ? file.path.substring(gitRepoRoot.length) : file.path;
|
|
5488
5507
|
const normalizedFilePath = relativeFilePath.startsWith("/") ? relativeFilePath : "/" + relativeFilePath;
|
|
5489
5508
|
this.logger.debug(
|
|
5490
5509
|
`Processing file: absolute="${file.path}", relative="${normalizedFilePath}"`
|
|
@@ -5771,7 +5790,7 @@ var LintFilesLocallyUseCase = class {
|
|
|
5771
5790
|
const allStandardsChecked = /* @__PURE__ */ new Set();
|
|
5772
5791
|
for (const file of files) {
|
|
5773
5792
|
const fileViolations = [];
|
|
5774
|
-
const relativeFilePath = file.path
|
|
5793
|
+
const relativeFilePath = pathStartsWith(file.path, basePath) ? file.path.substring(basePath.length) : file.path;
|
|
5775
5794
|
const normalizedFilePath = relativeFilePath.startsWith("/") ? relativeFilePath : "/" + relativeFilePath;
|
|
5776
5795
|
this.logger.debug(
|
|
5777
5796
|
`Processing file: absolute="${file.path}", relative="${normalizedFilePath}"`
|
|
@@ -5889,7 +5908,7 @@ var LintFilesLocallyUseCase = class {
|
|
|
5889
5908
|
*/
|
|
5890
5909
|
findMatchingTargets(absoluteFilePath, configs) {
|
|
5891
5910
|
return configs.filter(
|
|
5892
|
-
(config) =>
|
|
5911
|
+
(config) => pathStartsWith(absoluteFilePath, config.absoluteTargetPath)
|
|
5893
5912
|
);
|
|
5894
5913
|
}
|
|
5895
5914
|
/**
|
|
@@ -5940,7 +5959,8 @@ var LintFilesLocallyUseCase = class {
|
|
|
5940
5959
|
// apps/cli/src/infra/utils/readSkillDirectory.ts
|
|
5941
5960
|
var import_promises = __toESM(require("fs/promises"));
|
|
5942
5961
|
var import_path = __toESM(require("path"));
|
|
5943
|
-
|
|
5962
|
+
var import_minimatch3 = require("minimatch");
|
|
5963
|
+
function normalizePath2(filePath) {
|
|
5944
5964
|
let normalized = filePath.replace(/\\/g, "/");
|
|
5945
5965
|
if (normalized.startsWith("/") || normalized.startsWith("\\")) {
|
|
5946
5966
|
normalized = normalized.substring(1);
|
|
@@ -6018,6 +6038,13 @@ function isBinaryFile(filePath, buffer) {
|
|
|
6018
6038
|
}
|
|
6019
6039
|
var MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
6020
6040
|
var MAX_FILE_SIZE_MB = 10;
|
|
6041
|
+
var BLACKLIST_PATTERNS = ["**/.DS_Store"];
|
|
6042
|
+
function isBlacklisted(relativePath) {
|
|
6043
|
+
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
6044
|
+
return BLACKLIST_PATTERNS.some(
|
|
6045
|
+
(pattern) => (0, import_minimatch3.minimatch)(normalizedPath, pattern, { dot: true })
|
|
6046
|
+
);
|
|
6047
|
+
}
|
|
6021
6048
|
async function readSkillDirectory(dirPath) {
|
|
6022
6049
|
const files = [];
|
|
6023
6050
|
async function readDir(currentPath, basePath) {
|
|
@@ -6025,6 +6052,9 @@ async function readSkillDirectory(dirPath) {
|
|
|
6025
6052
|
for (const entry of entries) {
|
|
6026
6053
|
const fullPath = import_path.default.join(currentPath, entry.name);
|
|
6027
6054
|
const relativePath = import_path.default.relative(basePath, fullPath);
|
|
6055
|
+
if (isBlacklisted(relativePath)) {
|
|
6056
|
+
continue;
|
|
6057
|
+
}
|
|
6028
6058
|
if (entry.isDirectory()) {
|
|
6029
6059
|
await readDir(fullPath, basePath);
|
|
6030
6060
|
} else if (entry.isFile()) {
|
|
@@ -6037,7 +6067,7 @@ async function readSkillDirectory(dirPath) {
|
|
|
6037
6067
|
}
|
|
6038
6068
|
const buffer = await import_promises.default.readFile(fullPath);
|
|
6039
6069
|
const isBinary = isBinaryFile(fullPath, buffer);
|
|
6040
|
-
const normalizedPath =
|
|
6070
|
+
const normalizedPath = normalizePath2(relativePath);
|
|
6041
6071
|
let content;
|
|
6042
6072
|
if (isBinary) {
|
|
6043
6073
|
content = buffer.toString("base64");
|
|
@@ -10531,7 +10561,7 @@ var ConfigFileRepository = class {
|
|
|
10531
10561
|
* @returns Array of directory paths that contain a packmind.json file
|
|
10532
10562
|
*/
|
|
10533
10563
|
async findDescendantConfigs(directory) {
|
|
10534
|
-
const normalizedDir = path9.resolve(directory);
|
|
10564
|
+
const normalizedDir = normalizePath(path9.resolve(directory));
|
|
10535
10565
|
const results = [];
|
|
10536
10566
|
const searchRecursively = async (currentDir) => {
|
|
10537
10567
|
let entries;
|
|
@@ -10547,7 +10577,7 @@ var ConfigFileRepository = class {
|
|
|
10547
10577
|
if (this.EXCLUDED_DIRECTORIES.includes(entry.name)) {
|
|
10548
10578
|
continue;
|
|
10549
10579
|
}
|
|
10550
|
-
const entryPath = path9.join(currentDir, entry.name);
|
|
10580
|
+
const entryPath = normalizePath(path9.join(currentDir, entry.name));
|
|
10551
10581
|
const config = await this.readConfig(entryPath);
|
|
10552
10582
|
if (config) {
|
|
10553
10583
|
results.push(entryPath);
|
|
@@ -10569,19 +10599,21 @@ var ConfigFileRepository = class {
|
|
|
10569
10599
|
async readHierarchicalConfig(startDirectory, stopDirectory) {
|
|
10570
10600
|
const configs = [];
|
|
10571
10601
|
const configPaths = [];
|
|
10572
|
-
const normalizedStart = path9.resolve(startDirectory);
|
|
10573
|
-
const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
|
|
10602
|
+
const normalizedStart = normalizePath(path9.resolve(startDirectory));
|
|
10603
|
+
const normalizedStop = stopDirectory ? normalizePath(path9.resolve(stopDirectory)) : null;
|
|
10574
10604
|
let currentDir = normalizedStart;
|
|
10575
10605
|
while (true) {
|
|
10576
10606
|
const config = await this.readConfig(currentDir);
|
|
10577
10607
|
if (config) {
|
|
10578
10608
|
configs.push(config);
|
|
10579
|
-
configPaths.push(
|
|
10609
|
+
configPaths.push(
|
|
10610
|
+
normalizePath(path9.join(currentDir, this.CONFIG_FILENAME))
|
|
10611
|
+
);
|
|
10580
10612
|
}
|
|
10581
10613
|
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
10582
10614
|
break;
|
|
10583
10615
|
}
|
|
10584
|
-
const parentDir = path9.dirname(currentDir);
|
|
10616
|
+
const parentDir = normalizePath(path9.dirname(currentDir));
|
|
10585
10617
|
if (parentDir === currentDir) {
|
|
10586
10618
|
break;
|
|
10587
10619
|
}
|
|
@@ -10610,8 +10642,8 @@ var ConfigFileRepository = class {
|
|
|
10610
10642
|
* @returns All configs found with their target paths
|
|
10611
10643
|
*/
|
|
10612
10644
|
async findAllConfigsInTree(startDirectory, stopDirectory) {
|
|
10613
|
-
const normalizedStart = path9.resolve(startDirectory);
|
|
10614
|
-
const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
|
|
10645
|
+
const normalizedStart = normalizePath(path9.resolve(startDirectory));
|
|
10646
|
+
const normalizedStop = stopDirectory ? normalizePath(path9.resolve(stopDirectory)) : null;
|
|
10615
10647
|
const basePath = normalizedStop ?? normalizedStart;
|
|
10616
10648
|
const configsMap = /* @__PURE__ */ new Map();
|
|
10617
10649
|
let currentDir = normalizedStart;
|
|
@@ -10628,7 +10660,7 @@ var ConfigFileRepository = class {
|
|
|
10628
10660
|
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
10629
10661
|
break;
|
|
10630
10662
|
}
|
|
10631
|
-
const parentDir = path9.dirname(currentDir);
|
|
10663
|
+
const parentDir = normalizePath(path9.dirname(currentDir));
|
|
10632
10664
|
if (parentDir === currentDir) {
|
|
10633
10665
|
break;
|
|
10634
10666
|
}
|
|
@@ -10637,18 +10669,19 @@ var ConfigFileRepository = class {
|
|
|
10637
10669
|
const searchRoot = normalizedStop ?? normalizedStart;
|
|
10638
10670
|
const descendantDirs = await this.findDescendantConfigs(searchRoot);
|
|
10639
10671
|
for (const descendantDir of descendantDirs) {
|
|
10640
|
-
|
|
10672
|
+
const normalizedDescendantDir = normalizePath(descendantDir);
|
|
10673
|
+
if (configsMap.has(normalizedDescendantDir)) {
|
|
10641
10674
|
continue;
|
|
10642
10675
|
}
|
|
10643
|
-
const config = await this.readConfig(
|
|
10676
|
+
const config = await this.readConfig(normalizedDescendantDir);
|
|
10644
10677
|
if (config) {
|
|
10645
10678
|
const targetPath = this.computeRelativeTargetPath(
|
|
10646
|
-
|
|
10679
|
+
normalizedDescendantDir,
|
|
10647
10680
|
basePath
|
|
10648
10681
|
);
|
|
10649
|
-
configsMap.set(
|
|
10682
|
+
configsMap.set(normalizedDescendantDir, {
|
|
10650
10683
|
targetPath,
|
|
10651
|
-
absoluteTargetPath:
|
|
10684
|
+
absoluteTargetPath: normalizedDescendantDir,
|
|
10652
10685
|
packages: config.packages
|
|
10653
10686
|
});
|
|
10654
10687
|
}
|
|
@@ -10671,10 +10704,12 @@ var ConfigFileRepository = class {
|
|
|
10671
10704
|
};
|
|
10672
10705
|
}
|
|
10673
10706
|
computeRelativeTargetPath(absolutePath, basePath) {
|
|
10674
|
-
|
|
10707
|
+
const normalizedAbsolute = normalizePath(absolutePath);
|
|
10708
|
+
const normalizedBase = normalizePath(basePath);
|
|
10709
|
+
if (normalizedAbsolute === normalizedBase) {
|
|
10675
10710
|
return "/";
|
|
10676
10711
|
}
|
|
10677
|
-
const relativePath =
|
|
10712
|
+
const relativePath = normalizedAbsolute.substring(normalizedBase.length);
|
|
10678
10713
|
return relativePath.startsWith("/") ? relativePath : "/" + relativePath;
|
|
10679
10714
|
}
|
|
10680
10715
|
};
|