@packmind/cli 0.10.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.
- package/main.cjs +456 -248
- 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(
|
|
375
|
-
let index =
|
|
374
|
+
function stringReplaceAll(string6, substring, replacer) {
|
|
375
|
+
let index = string6.indexOf(substring);
|
|
376
376
|
if (index === -1) {
|
|
377
|
-
return
|
|
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 +=
|
|
383
|
+
returnValue += string6.slice(endIndex, index) + substring + replacer;
|
|
384
384
|
endIndex = index + substringLength;
|
|
385
|
-
index =
|
|
385
|
+
index = string6.indexOf(substring, endIndex);
|
|
386
386
|
} while (index !== -1);
|
|
387
|
-
returnValue +=
|
|
387
|
+
returnValue += string6.slice(endIndex);
|
|
388
388
|
return returnValue;
|
|
389
389
|
}
|
|
390
|
-
function stringEncaseCRLFWithFirstIndex(
|
|
390
|
+
function stringEncaseCRLFWithFirstIndex(string6, prefix, postfix, index) {
|
|
391
391
|
let endIndex = 0;
|
|
392
392
|
let returnValue = "";
|
|
393
393
|
do {
|
|
394
|
-
const gotCR =
|
|
395
|
-
returnValue +=
|
|
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 =
|
|
397
|
+
index = string6.indexOf("\n", endIndex);
|
|
398
398
|
} while (index !== -1);
|
|
399
|
-
returnValue +=
|
|
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,
|
|
559
|
-
if (self.level <= 0 || !
|
|
560
|
-
return self[IS_EMPTY] ? "" :
|
|
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
|
|
564
|
+
return string6;
|
|
565
565
|
}
|
|
566
566
|
const { openAll, closeAll } = styler;
|
|
567
|
-
if (
|
|
567
|
+
if (string6.includes("\x1B")) {
|
|
568
568
|
while (styler !== void 0) {
|
|
569
|
-
|
|
569
|
+
string6 = stringReplaceAll(string6, styler.close, styler.open);
|
|
570
570
|
styler = styler.parent;
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
const lfIndex =
|
|
573
|
+
const lfIndex = string6.indexOf("\n");
|
|
574
574
|
if (lfIndex !== -1) {
|
|
575
|
-
|
|
575
|
+
string6 = stringEncaseCRLFWithFirstIndex(string6, closeAll, openAll, lfIndex);
|
|
576
576
|
}
|
|
577
|
-
return openAll +
|
|
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 =
|
|
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
|
|
1299
|
-
if (!
|
|
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(
|
|
1313
|
-
const decoded = await Result.safeAsync(config.type.from(
|
|
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: [
|
|
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
|
|
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(
|
|
1582
|
-
if (typeof
|
|
1583
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof
|
|
1581
|
+
function stripAnsi(string6) {
|
|
1582
|
+
if (typeof string6 !== "string") {
|
|
1583
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string6}\``);
|
|
1584
1584
|
}
|
|
1585
|
-
return
|
|
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 =
|
|
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
|
|
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,
|
|
3088
|
-
const chars = [...
|
|
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
|
|
3245
|
-
visitedNodes.add(
|
|
3246
|
-
const decoded = await Result.safeAsync(config.type.from(
|
|
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: [
|
|
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.
|
|
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
|
|
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());
|
|
@@ -4034,17 +4034,17 @@ var UserJoinedOrganizationEvent = class extends PackmindEvent {
|
|
|
4034
4034
|
}
|
|
4035
4035
|
};
|
|
4036
4036
|
|
|
4037
|
-
// packages/types/src/accounts/events/
|
|
4038
|
-
var
|
|
4037
|
+
// packages/types/src/accounts/events/AnonymousTrialStartedEvent.ts
|
|
4038
|
+
var AnonymousTrialStartedEvent = class extends PackmindEvent {
|
|
4039
4039
|
static {
|
|
4040
|
-
this.eventName = "accounts.trial.started";
|
|
4040
|
+
this.eventName = "accounts.anonymous-trial.started";
|
|
4041
4041
|
}
|
|
4042
4042
|
};
|
|
4043
4043
|
|
|
4044
|
-
// packages/types/src/accounts/events/
|
|
4045
|
-
var
|
|
4044
|
+
// packages/types/src/accounts/events/AnonymousTrialAccountActivatedEvent.ts
|
|
4045
|
+
var AnonymousTrialAccountActivatedEvent = class extends PackmindEvent {
|
|
4046
4046
|
static {
|
|
4047
|
-
this.eventName = "accounts.trial.activated";
|
|
4047
|
+
this.eventName = "accounts.anonymous-trial.activated";
|
|
4048
4048
|
}
|
|
4049
4049
|
};
|
|
4050
4050
|
|
|
@@ -4058,27 +4058,57 @@ var createRecipeId = brandedIdFactory();
|
|
|
4058
4058
|
// packages/types/src/recipes/RecipeVersion.ts
|
|
4059
4059
|
var createRecipeVersionId = brandedIdFactory();
|
|
4060
4060
|
|
|
4061
|
-
// packages/types/src/recipes/events/
|
|
4062
|
-
var
|
|
4061
|
+
// packages/types/src/recipes/events/CommandCreatedEvent.ts
|
|
4062
|
+
var CommandCreatedEvent = class extends UserEvent {
|
|
4063
4063
|
static {
|
|
4064
4064
|
this.eventName = "recipes.recipe.created";
|
|
4065
4065
|
}
|
|
4066
4066
|
};
|
|
4067
4067
|
|
|
4068
|
-
// packages/types/src/recipes/events/
|
|
4069
|
-
var
|
|
4068
|
+
// packages/types/src/recipes/events/CommandDeletedEvent.ts
|
|
4069
|
+
var CommandDeletedEvent = class extends UserEvent {
|
|
4070
4070
|
static {
|
|
4071
4071
|
this.eventName = "recipes.recipe.deleted";
|
|
4072
4072
|
}
|
|
4073
4073
|
};
|
|
4074
4074
|
|
|
4075
|
-
// packages/types/src/recipes/events/
|
|
4076
|
-
var
|
|
4075
|
+
// packages/types/src/recipes/events/CommandUpdatedEvent.ts
|
|
4076
|
+
var CommandUpdatedEvent = class extends UserEvent {
|
|
4077
4077
|
static {
|
|
4078
4078
|
this.eventName = "recipes.recipe.updated";
|
|
4079
4079
|
}
|
|
4080
4080
|
};
|
|
4081
4081
|
|
|
4082
|
+
// packages/types/src/skills/SkillId.ts
|
|
4083
|
+
var createSkillId = brandedIdFactory();
|
|
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
|
+
|
|
4082
4112
|
// packages/types/src/deployments/TargetId.ts
|
|
4083
4113
|
var createTargetId = brandedIdFactory();
|
|
4084
4114
|
|
|
@@ -4703,8 +4733,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
4703
4733
|
static {
|
|
4704
4734
|
this.fallbackRuleContent = "adhoc-rule";
|
|
4705
4735
|
}
|
|
4706
|
-
async execute(
|
|
4707
|
-
const { program, fileContent, language } =
|
|
4736
|
+
async execute(command9) {
|
|
4737
|
+
const { program, fileContent, language } = command9;
|
|
4708
4738
|
const result = await this.linterExecutionUseCase.execute({
|
|
4709
4739
|
filePath: "cli-single-file",
|
|
4710
4740
|
fileContent,
|
|
@@ -4742,30 +4772,30 @@ var GitService = class {
|
|
|
4742
4772
|
this.gitRunner = gitRunner;
|
|
4743
4773
|
this.logger = logger2;
|
|
4744
4774
|
}
|
|
4745
|
-
getGitRepositoryRoot(
|
|
4775
|
+
getGitRepositoryRoot(path12) {
|
|
4746
4776
|
try {
|
|
4747
4777
|
const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
|
|
4748
|
-
cwd:
|
|
4778
|
+
cwd: path12
|
|
4749
4779
|
});
|
|
4750
4780
|
const gitRoot = stdout.trim();
|
|
4751
4781
|
this.logger.debug("Resolved git repository root", {
|
|
4752
|
-
inputPath:
|
|
4782
|
+
inputPath: path12,
|
|
4753
4783
|
gitRoot
|
|
4754
4784
|
});
|
|
4755
4785
|
return gitRoot;
|
|
4756
4786
|
} catch (error) {
|
|
4757
4787
|
if (error instanceof Error) {
|
|
4758
4788
|
throw new Error(
|
|
4759
|
-
`Failed to get Git repository root. The path '${
|
|
4789
|
+
`Failed to get Git repository root. The path '${path12}' does not appear to be inside a Git repository.
|
|
4760
4790
|
${error.message}`
|
|
4761
4791
|
);
|
|
4762
4792
|
}
|
|
4763
4793
|
throw new Error("Failed to get Git repository root: Unknown error");
|
|
4764
4794
|
}
|
|
4765
4795
|
}
|
|
4766
|
-
tryGetGitRepositoryRoot(
|
|
4796
|
+
tryGetGitRepositoryRoot(path12) {
|
|
4767
4797
|
try {
|
|
4768
|
-
return this.getGitRepositoryRoot(
|
|
4798
|
+
return this.getGitRepositoryRoot(path12);
|
|
4769
4799
|
} catch {
|
|
4770
4800
|
return null;
|
|
4771
4801
|
}
|
|
@@ -5072,8 +5102,8 @@ var GetGitRemoteUrlUseCase = class {
|
|
|
5072
5102
|
constructor(gitRemoteUrlService = new GitService()) {
|
|
5073
5103
|
this.gitRemoteUrlService = gitRemoteUrlService;
|
|
5074
5104
|
}
|
|
5075
|
-
async execute(
|
|
5076
|
-
const { path: repoPath, origin: origin11 } =
|
|
5105
|
+
async execute(command9) {
|
|
5106
|
+
const { path: repoPath, origin: origin11 } = command9;
|
|
5077
5107
|
return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin11);
|
|
5078
5108
|
}
|
|
5079
5109
|
};
|
|
@@ -5173,8 +5203,8 @@ var ListFilesInDirectoryUseCase = class {
|
|
|
5173
5203
|
constructor(listFiles = new ListFiles()) {
|
|
5174
5204
|
this.listFiles = listFiles;
|
|
5175
5205
|
}
|
|
5176
|
-
async execute(
|
|
5177
|
-
const { path: directoryPath, extensions, excludes = [] } =
|
|
5206
|
+
async execute(command9) {
|
|
5207
|
+
const { path: directoryPath, extensions, excludes = [] } = command9;
|
|
5178
5208
|
const files = await this.listFiles.listFilesInDirectory(
|
|
5179
5209
|
directoryPath,
|
|
5180
5210
|
extensions,
|
|
@@ -5259,7 +5289,7 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
5259
5289
|
}
|
|
5260
5290
|
return pattern;
|
|
5261
5291
|
}
|
|
5262
|
-
async execute(
|
|
5292
|
+
async execute(command9) {
|
|
5263
5293
|
const {
|
|
5264
5294
|
path: userPath,
|
|
5265
5295
|
draftMode,
|
|
@@ -5267,7 +5297,7 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
5267
5297
|
ruleId,
|
|
5268
5298
|
language,
|
|
5269
5299
|
diffMode
|
|
5270
|
-
} =
|
|
5300
|
+
} = command9;
|
|
5271
5301
|
this.logger.debug(
|
|
5272
5302
|
`Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
|
|
5273
5303
|
);
|
|
@@ -5586,8 +5616,8 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
5586
5616
|
return null;
|
|
5587
5617
|
}
|
|
5588
5618
|
}
|
|
5589
|
-
async executeProgramsForFile(
|
|
5590
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
5619
|
+
async executeProgramsForFile(command9) {
|
|
5620
|
+
const result = await this.services.linterExecutionUseCase.execute(command9);
|
|
5591
5621
|
return result.violations;
|
|
5592
5622
|
}
|
|
5593
5623
|
extractExtensionFromFile(filePath) {
|
|
@@ -5644,8 +5674,8 @@ var LintFilesLocallyUseCase = class {
|
|
|
5644
5674
|
}
|
|
5645
5675
|
return pattern;
|
|
5646
5676
|
}
|
|
5647
|
-
async execute(
|
|
5648
|
-
const { path: userPath, diffMode } =
|
|
5677
|
+
async execute(command9) {
|
|
5678
|
+
const { path: userPath, diffMode } = command9;
|
|
5649
5679
|
this.logger.debug(
|
|
5650
5680
|
`Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
|
|
5651
5681
|
);
|
|
@@ -5887,8 +5917,8 @@ var LintFilesLocallyUseCase = class {
|
|
|
5887
5917
|
return null;
|
|
5888
5918
|
}
|
|
5889
5919
|
}
|
|
5890
|
-
async executeProgramsForFile(
|
|
5891
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
5920
|
+
async executeProgramsForFile(command9) {
|
|
5921
|
+
const result = await this.services.linterExecutionUseCase.execute(command9);
|
|
5892
5922
|
return result.violations;
|
|
5893
5923
|
}
|
|
5894
5924
|
extractExtensionFromFile(filePath) {
|
|
@@ -5900,6 +5930,35 @@ var LintFilesLocallyUseCase = class {
|
|
|
5900
5930
|
}
|
|
5901
5931
|
};
|
|
5902
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
|
+
|
|
5903
5962
|
// apps/cli/src/domain/errors/CommunityEditionError.ts
|
|
5904
5963
|
var CommunityEditionError = class extends Error {
|
|
5905
5964
|
constructor(feature) {
|
|
@@ -5976,7 +6035,7 @@ function decodeApiKey(apiKey) {
|
|
|
5976
6035
|
var PackmindGateway = class {
|
|
5977
6036
|
constructor(apiKey) {
|
|
5978
6037
|
this.apiKey = apiKey;
|
|
5979
|
-
this.getPullData = async (
|
|
6038
|
+
this.getPullData = async (command9) => {
|
|
5980
6039
|
const decodedApiKey = decodeApiKey(this.apiKey);
|
|
5981
6040
|
if (!decodedApiKey.isValid) {
|
|
5982
6041
|
if (decodedApiKey.error === "NOT_LOGGED_IN") {
|
|
@@ -5991,13 +6050,13 @@ var PackmindGateway = class {
|
|
|
5991
6050
|
}
|
|
5992
6051
|
const organizationId = jwtPayload.organization.id;
|
|
5993
6052
|
const queryParams = new URLSearchParams();
|
|
5994
|
-
if (
|
|
5995
|
-
|
|
6053
|
+
if (command9.packagesSlugs && command9.packagesSlugs.length > 0) {
|
|
6054
|
+
command9.packagesSlugs.forEach((slug) => {
|
|
5996
6055
|
queryParams.append("packageSlug", slug);
|
|
5997
6056
|
});
|
|
5998
6057
|
}
|
|
5999
|
-
if (
|
|
6000
|
-
|
|
6058
|
+
if (command9.previousPackagesSlugs && command9.previousPackagesSlugs.length > 0) {
|
|
6059
|
+
command9.previousPackagesSlugs.forEach((slug) => {
|
|
6001
6060
|
queryParams.append("previousPackageSlug", slug);
|
|
6002
6061
|
});
|
|
6003
6062
|
}
|
|
@@ -6537,6 +6596,90 @@ var PackmindGateway = class {
|
|
|
6537
6596
|
);
|
|
6538
6597
|
}
|
|
6539
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
|
+
};
|
|
6540
6683
|
}
|
|
6541
6684
|
};
|
|
6542
6685
|
|
|
@@ -6622,7 +6765,7 @@ var ParserInitializationError = class extends Error {
|
|
|
6622
6765
|
};
|
|
6623
6766
|
|
|
6624
6767
|
// packages/linter-ast/src/core/BaseParser.ts
|
|
6625
|
-
var
|
|
6768
|
+
var import_path2 = require("path");
|
|
6626
6769
|
var import_fs = require("fs");
|
|
6627
6770
|
var BaseParser = class _BaseParser {
|
|
6628
6771
|
constructor() {
|
|
@@ -6646,20 +6789,20 @@ var BaseParser = class _BaseParser {
|
|
|
6646
6789
|
if (_BaseParser.externalWasmDirectory) {
|
|
6647
6790
|
paths.push(_BaseParser.externalWasmDirectory);
|
|
6648
6791
|
}
|
|
6649
|
-
const execDir = process.argv[0] ? (0,
|
|
6650
|
-
const scriptDir = require.main?.filename ? (0,
|
|
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();
|
|
6651
6794
|
paths.push(
|
|
6652
6795
|
// Next to the main script (for npm packages like @packmind/scan)
|
|
6653
6796
|
scriptDir,
|
|
6654
|
-
(0,
|
|
6797
|
+
(0, import_path2.join)(scriptDir, "tree-sitter"),
|
|
6655
6798
|
// Next to the Bun executable in tree-sitter/ subdirectory
|
|
6656
|
-
(0,
|
|
6799
|
+
(0, import_path2.join)(execDir, "tree-sitter"),
|
|
6657
6800
|
// Fallback paths
|
|
6658
|
-
(0,
|
|
6659
|
-
(0,
|
|
6660
|
-
(0,
|
|
6661
|
-
(0,
|
|
6662
|
-
(0,
|
|
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")
|
|
6663
6806
|
);
|
|
6664
6807
|
return paths;
|
|
6665
6808
|
}
|
|
@@ -6670,12 +6813,12 @@ var BaseParser = class _BaseParser {
|
|
|
6670
6813
|
const wasmDirs = _BaseParser.getTreeSitterWasmPaths();
|
|
6671
6814
|
return (fileName) => {
|
|
6672
6815
|
for (const dir of wasmDirs) {
|
|
6673
|
-
const fullPath = (0,
|
|
6816
|
+
const fullPath = (0, import_path2.join)(dir, fileName);
|
|
6674
6817
|
if ((0, import_fs.existsSync)(fullPath)) {
|
|
6675
6818
|
return fullPath;
|
|
6676
6819
|
}
|
|
6677
6820
|
}
|
|
6678
|
-
return (0,
|
|
6821
|
+
return (0, import_path2.join)(process.cwd(), fileName);
|
|
6679
6822
|
};
|
|
6680
6823
|
}
|
|
6681
6824
|
/**
|
|
@@ -6684,15 +6827,15 @@ var BaseParser = class _BaseParser {
|
|
|
6684
6827
|
static getLanguageWasmPaths(languageName) {
|
|
6685
6828
|
const wasmDirs = _BaseParser.getTreeSitterWasmPaths();
|
|
6686
6829
|
const wasmFileName = `tree-sitter-${languageName}.wasm`;
|
|
6687
|
-
return wasmDirs.map((dir) => (0,
|
|
6830
|
+
return wasmDirs.map((dir) => (0, import_path2.join)(dir, wasmFileName)).concat([
|
|
6688
6831
|
// Additional fallback paths
|
|
6689
|
-
(0,
|
|
6690
|
-
(0,
|
|
6691
|
-
(0,
|
|
6692
|
-
(0,
|
|
6693
|
-
(0,
|
|
6694
|
-
(0,
|
|
6695
|
-
(0,
|
|
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}`)
|
|
6696
6839
|
]);
|
|
6697
6840
|
}
|
|
6698
6841
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -8280,8 +8423,8 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8280
8423
|
this.linterAstAdapter = linterAstAdapter;
|
|
8281
8424
|
this.logger = logger2;
|
|
8282
8425
|
}
|
|
8283
|
-
async execute(
|
|
8284
|
-
const { filePath, fileContent, language, programs } =
|
|
8426
|
+
async execute(command9) {
|
|
8427
|
+
const { filePath, fileContent, language, programs } = command9;
|
|
8285
8428
|
if (programs.length === 0) {
|
|
8286
8429
|
return {
|
|
8287
8430
|
file: filePath,
|
|
@@ -8434,10 +8577,10 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8434
8577
|
return typeof line === "number" && Number.isInteger(line) && line >= 0;
|
|
8435
8578
|
}
|
|
8436
8579
|
extractRuleName(ruleContent) {
|
|
8437
|
-
if (
|
|
8438
|
-
return ruleContent;
|
|
8580
|
+
if (ruleContent.endsWith(".js") && ruleContent.includes("/")) {
|
|
8581
|
+
return ruleContent.split("/").pop()?.replace(".js", "") ?? ruleContent;
|
|
8439
8582
|
}
|
|
8440
|
-
return ruleContent
|
|
8583
|
+
return ruleContent;
|
|
8441
8584
|
}
|
|
8442
8585
|
filterProgramsByLanguage(programs, fileLanguage) {
|
|
8443
8586
|
const filtered = programs.filter((p) => p.language === fileLanguage);
|
|
@@ -9370,14 +9513,14 @@ ${sectionBlock}
|
|
|
9370
9513
|
}
|
|
9371
9514
|
|
|
9372
9515
|
// apps/cli/src/application/useCases/InstallPackagesUseCase.ts
|
|
9373
|
-
var
|
|
9374
|
-
var
|
|
9516
|
+
var fs5 = __toESM(require("fs/promises"));
|
|
9517
|
+
var path6 = __toESM(require("path"));
|
|
9375
9518
|
var InstallPackagesUseCase = class {
|
|
9376
9519
|
constructor(packmindGateway) {
|
|
9377
9520
|
this.packmindGateway = packmindGateway;
|
|
9378
9521
|
}
|
|
9379
|
-
async execute(
|
|
9380
|
-
const baseDirectory =
|
|
9522
|
+
async execute(command9) {
|
|
9523
|
+
const baseDirectory = command9.baseDirectory || process.cwd();
|
|
9381
9524
|
const result = {
|
|
9382
9525
|
filesCreated: 0,
|
|
9383
9526
|
filesUpdated: 0,
|
|
@@ -9387,8 +9530,8 @@ var InstallPackagesUseCase = class {
|
|
|
9387
9530
|
standardsCount: 0
|
|
9388
9531
|
};
|
|
9389
9532
|
const response = await this.packmindGateway.getPullData({
|
|
9390
|
-
packagesSlugs:
|
|
9391
|
-
previousPackagesSlugs:
|
|
9533
|
+
packagesSlugs: command9.packagesSlugs,
|
|
9534
|
+
previousPackagesSlugs: command9.previousPackagesSlugs
|
|
9392
9535
|
});
|
|
9393
9536
|
const uniqueFilesMap = /* @__PURE__ */ new Map();
|
|
9394
9537
|
for (const file of response.fileUpdates.createOrUpdate) {
|
|
@@ -9428,9 +9571,9 @@ var InstallPackagesUseCase = class {
|
|
|
9428
9571
|
return result;
|
|
9429
9572
|
}
|
|
9430
9573
|
async createOrUpdateFile(baseDirectory, file, result) {
|
|
9431
|
-
const fullPath =
|
|
9432
|
-
const directory =
|
|
9433
|
-
await
|
|
9574
|
+
const fullPath = path6.join(baseDirectory, file.path);
|
|
9575
|
+
const directory = path6.dirname(fullPath);
|
|
9576
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
9434
9577
|
const fileExists = await this.fileExists(fullPath);
|
|
9435
9578
|
if (file.content !== void 0) {
|
|
9436
9579
|
await this.handleFullContentUpdate(
|
|
@@ -9450,7 +9593,7 @@ var InstallPackagesUseCase = class {
|
|
|
9450
9593
|
}
|
|
9451
9594
|
async handleFullContentUpdate(fullPath, content, fileExists, result) {
|
|
9452
9595
|
if (fileExists) {
|
|
9453
|
-
const existingContent = await
|
|
9596
|
+
const existingContent = await fs5.readFile(fullPath, "utf-8");
|
|
9454
9597
|
const commentMarker = this.extractCommentMarker(content);
|
|
9455
9598
|
let finalContent;
|
|
9456
9599
|
if (!commentMarker) {
|
|
@@ -9463,18 +9606,18 @@ var InstallPackagesUseCase = class {
|
|
|
9463
9606
|
);
|
|
9464
9607
|
}
|
|
9465
9608
|
if (existingContent !== finalContent) {
|
|
9466
|
-
await
|
|
9609
|
+
await fs5.writeFile(fullPath, finalContent, "utf-8");
|
|
9467
9610
|
result.filesUpdated++;
|
|
9468
9611
|
}
|
|
9469
9612
|
} else {
|
|
9470
|
-
await
|
|
9613
|
+
await fs5.writeFile(fullPath, content, "utf-8");
|
|
9471
9614
|
result.filesCreated++;
|
|
9472
9615
|
}
|
|
9473
9616
|
}
|
|
9474
9617
|
async handleSectionsUpdate(fullPath, sections, fileExists, result) {
|
|
9475
9618
|
let currentContent = "";
|
|
9476
9619
|
if (fileExists) {
|
|
9477
|
-
currentContent = await
|
|
9620
|
+
currentContent = await fs5.readFile(fullPath, "utf-8");
|
|
9478
9621
|
}
|
|
9479
9622
|
const mergedContent = mergeSectionsIntoFileContent(
|
|
9480
9623
|
currentContent,
|
|
@@ -9482,10 +9625,10 @@ var InstallPackagesUseCase = class {
|
|
|
9482
9625
|
);
|
|
9483
9626
|
if (currentContent !== mergedContent) {
|
|
9484
9627
|
if (this.isEffectivelyEmpty(mergedContent) && fileExists) {
|
|
9485
|
-
await
|
|
9628
|
+
await fs5.unlink(fullPath);
|
|
9486
9629
|
result.filesDeleted++;
|
|
9487
9630
|
} else {
|
|
9488
|
-
await
|
|
9631
|
+
await fs5.writeFile(fullPath, mergedContent, "utf-8");
|
|
9489
9632
|
if (fileExists) {
|
|
9490
9633
|
result.filesUpdated++;
|
|
9491
9634
|
} else {
|
|
@@ -9495,19 +9638,19 @@ var InstallPackagesUseCase = class {
|
|
|
9495
9638
|
}
|
|
9496
9639
|
}
|
|
9497
9640
|
async deleteFile(baseDirectory, filePath, result) {
|
|
9498
|
-
const fullPath =
|
|
9499
|
-
const stat4 = await
|
|
9641
|
+
const fullPath = path6.join(baseDirectory, filePath);
|
|
9642
|
+
const stat4 = await fs5.stat(fullPath).catch(() => null);
|
|
9500
9643
|
if (stat4?.isDirectory()) {
|
|
9501
|
-
await
|
|
9644
|
+
await fs5.rm(fullPath, { recursive: true, force: true });
|
|
9502
9645
|
result.filesDeleted++;
|
|
9503
9646
|
} else if (stat4?.isFile()) {
|
|
9504
|
-
await
|
|
9647
|
+
await fs5.unlink(fullPath);
|
|
9505
9648
|
result.filesDeleted++;
|
|
9506
9649
|
}
|
|
9507
9650
|
}
|
|
9508
9651
|
async fileExists(filePath) {
|
|
9509
9652
|
try {
|
|
9510
|
-
await
|
|
9653
|
+
await fs5.access(filePath);
|
|
9511
9654
|
return true;
|
|
9512
9655
|
} catch {
|
|
9513
9656
|
return false;
|
|
@@ -9586,8 +9729,8 @@ var GetPackageSummaryUseCase = class {
|
|
|
9586
9729
|
constructor(gateway) {
|
|
9587
9730
|
this.gateway = gateway;
|
|
9588
9731
|
}
|
|
9589
|
-
async execute(
|
|
9590
|
-
return this.gateway.getPackageSummary(
|
|
9732
|
+
async execute(command9) {
|
|
9733
|
+
return this.gateway.getPackageSummary(command9);
|
|
9591
9734
|
}
|
|
9592
9735
|
};
|
|
9593
9736
|
|
|
@@ -9647,13 +9790,13 @@ var EnvCredentialsProvider = class {
|
|
|
9647
9790
|
};
|
|
9648
9791
|
|
|
9649
9792
|
// apps/cli/src/infra/utils/credentials/FileCredentialsProvider.ts
|
|
9650
|
-
var
|
|
9651
|
-
var
|
|
9793
|
+
var fs6 = __toESM(require("fs"));
|
|
9794
|
+
var path7 = __toESM(require("path"));
|
|
9652
9795
|
var os2 = __toESM(require("os"));
|
|
9653
9796
|
var CREDENTIALS_DIR = ".packmind";
|
|
9654
9797
|
var CREDENTIALS_FILE = "credentials.json";
|
|
9655
9798
|
function getCredentialsPath() {
|
|
9656
|
-
return
|
|
9799
|
+
return path7.join(os2.homedir(), CREDENTIALS_DIR, CREDENTIALS_FILE);
|
|
9657
9800
|
}
|
|
9658
9801
|
var FileCredentialsProvider = class {
|
|
9659
9802
|
getSourceName() {
|
|
@@ -9661,11 +9804,11 @@ var FileCredentialsProvider = class {
|
|
|
9661
9804
|
}
|
|
9662
9805
|
hasCredentials() {
|
|
9663
9806
|
const credentialsPath = getCredentialsPath();
|
|
9664
|
-
if (!
|
|
9807
|
+
if (!fs6.existsSync(credentialsPath)) {
|
|
9665
9808
|
return false;
|
|
9666
9809
|
}
|
|
9667
9810
|
try {
|
|
9668
|
-
const content =
|
|
9811
|
+
const content = fs6.readFileSync(credentialsPath, "utf-8");
|
|
9669
9812
|
const credentials = JSON.parse(content);
|
|
9670
9813
|
return !!credentials.apiKey;
|
|
9671
9814
|
} catch {
|
|
@@ -9674,11 +9817,11 @@ var FileCredentialsProvider = class {
|
|
|
9674
9817
|
}
|
|
9675
9818
|
loadCredentials() {
|
|
9676
9819
|
const credentialsPath = getCredentialsPath();
|
|
9677
|
-
if (!
|
|
9820
|
+
if (!fs6.existsSync(credentialsPath)) {
|
|
9678
9821
|
return null;
|
|
9679
9822
|
}
|
|
9680
9823
|
try {
|
|
9681
|
-
const content =
|
|
9824
|
+
const content = fs6.readFileSync(credentialsPath, "utf-8");
|
|
9682
9825
|
const credentials = JSON.parse(content);
|
|
9683
9826
|
if (!credentials.apiKey) {
|
|
9684
9827
|
return null;
|
|
@@ -9701,13 +9844,13 @@ var FileCredentialsProvider = class {
|
|
|
9701
9844
|
}
|
|
9702
9845
|
};
|
|
9703
9846
|
function saveCredentials(apiKey) {
|
|
9704
|
-
const credentialsDir =
|
|
9705
|
-
if (!
|
|
9706
|
-
|
|
9847
|
+
const credentialsDir = path7.join(os2.homedir(), CREDENTIALS_DIR);
|
|
9848
|
+
if (!fs6.existsSync(credentialsDir)) {
|
|
9849
|
+
fs6.mkdirSync(credentialsDir, { recursive: true, mode: 448 });
|
|
9707
9850
|
}
|
|
9708
9851
|
const credentialsPath = getCredentialsPath();
|
|
9709
9852
|
const credentials = { apiKey };
|
|
9710
|
-
|
|
9853
|
+
fs6.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {
|
|
9711
9854
|
mode: 384
|
|
9712
9855
|
});
|
|
9713
9856
|
}
|
|
@@ -9865,8 +10008,8 @@ var LoginUseCase = class {
|
|
|
9865
10008
|
startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
|
|
9866
10009
|
};
|
|
9867
10010
|
}
|
|
9868
|
-
async execute(
|
|
9869
|
-
const { host, code: providedCode } =
|
|
10011
|
+
async execute(command9) {
|
|
10012
|
+
const { host, code: providedCode } = command9;
|
|
9870
10013
|
let code;
|
|
9871
10014
|
if (providedCode) {
|
|
9872
10015
|
code = providedCode;
|
|
@@ -9897,14 +10040,14 @@ var LoginUseCase = class {
|
|
|
9897
10040
|
};
|
|
9898
10041
|
|
|
9899
10042
|
// apps/cli/src/application/useCases/LogoutUseCase.ts
|
|
9900
|
-
var
|
|
10043
|
+
var fs7 = __toESM(require("fs"));
|
|
9901
10044
|
var ENV_VAR_NAME2 = "PACKMIND_API_KEY_V3";
|
|
9902
10045
|
var LogoutUseCase = class {
|
|
9903
10046
|
constructor(deps) {
|
|
9904
10047
|
this.deps = {
|
|
9905
10048
|
getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
|
|
9906
|
-
fileExists: deps?.fileExists ?? ((
|
|
9907
|
-
deleteFile: deps?.deleteFile ?? ((
|
|
10049
|
+
fileExists: deps?.fileExists ?? ((path12) => fs7.existsSync(path12)),
|
|
10050
|
+
deleteFile: deps?.deleteFile ?? ((path12) => fs7.unlinkSync(path12)),
|
|
9908
10051
|
hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
|
|
9909
10052
|
};
|
|
9910
10053
|
}
|
|
@@ -9964,8 +10107,8 @@ var SetupMcpUseCase = class {
|
|
|
9964
10107
|
constructor(deps) {
|
|
9965
10108
|
this.deps = deps;
|
|
9966
10109
|
}
|
|
9967
|
-
async execute(
|
|
9968
|
-
const { agentTypes } =
|
|
10110
|
+
async execute(command9) {
|
|
10111
|
+
const { agentTypes } = command9;
|
|
9969
10112
|
const [tokenResult, urlResult] = await Promise.all([
|
|
9970
10113
|
this.deps.gateway.getMcpToken({}),
|
|
9971
10114
|
this.deps.gateway.getMcpUrl({})
|
|
@@ -10000,8 +10143,8 @@ var SetupMcpUseCase = class {
|
|
|
10000
10143
|
};
|
|
10001
10144
|
|
|
10002
10145
|
// apps/cli/src/application/services/McpConfigService.ts
|
|
10003
|
-
var
|
|
10004
|
-
var
|
|
10146
|
+
var fs8 = __toESM(require("fs"));
|
|
10147
|
+
var path8 = __toESM(require("path"));
|
|
10005
10148
|
var os3 = __toESM(require("os"));
|
|
10006
10149
|
var import_child_process2 = require("child_process");
|
|
10007
10150
|
var McpConfigService = class {
|
|
@@ -10036,9 +10179,9 @@ var McpConfigService = class {
|
|
|
10036
10179
|
return JSON.stringify(mcpConfig, null, 2);
|
|
10037
10180
|
}
|
|
10038
10181
|
installClaudeMcp(config) {
|
|
10039
|
-
const
|
|
10182
|
+
const command9 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
|
|
10040
10183
|
try {
|
|
10041
|
-
(0, import_child_process2.execSync)(
|
|
10184
|
+
(0, import_child_process2.execSync)(command9, { stdio: "pipe" });
|
|
10042
10185
|
return { success: true };
|
|
10043
10186
|
} catch (error) {
|
|
10044
10187
|
const execError = error;
|
|
@@ -10048,11 +10191,11 @@ var McpConfigService = class {
|
|
|
10048
10191
|
}
|
|
10049
10192
|
installCursorMcp(config) {
|
|
10050
10193
|
try {
|
|
10051
|
-
const cursorConfigPath =
|
|
10194
|
+
const cursorConfigPath = path8.join(os3.homedir(), ".cursor", "mcp.json");
|
|
10052
10195
|
const cursorConfig = this.buildCursorConfig(config);
|
|
10053
10196
|
const existingConfig = this.readExistingJsonConfig(cursorConfigPath);
|
|
10054
10197
|
const mergedConfig = this.mergeConfig(existingConfig, cursorConfig);
|
|
10055
|
-
|
|
10198
|
+
fs8.writeFileSync(cursorConfigPath, JSON.stringify(mergedConfig, null, 2));
|
|
10056
10199
|
return { success: true };
|
|
10057
10200
|
} catch (error) {
|
|
10058
10201
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -10061,15 +10204,15 @@ var McpConfigService = class {
|
|
|
10061
10204
|
}
|
|
10062
10205
|
installVSCodeMcp(config) {
|
|
10063
10206
|
try {
|
|
10064
|
-
const vscodeDir =
|
|
10065
|
-
if (!
|
|
10066
|
-
|
|
10207
|
+
const vscodeDir = path8.join(this.projectDir, ".vscode");
|
|
10208
|
+
if (!fs8.existsSync(vscodeDir)) {
|
|
10209
|
+
fs8.mkdirSync(vscodeDir, { recursive: true });
|
|
10067
10210
|
}
|
|
10068
|
-
const vscodeConfigPath =
|
|
10211
|
+
const vscodeConfigPath = path8.join(vscodeDir, "mcp.json");
|
|
10069
10212
|
const vscodeConfig = this.buildVSCodeConfig(config);
|
|
10070
10213
|
const existingConfig = this.readExistingJsonConfig(vscodeConfigPath);
|
|
10071
10214
|
const mergedConfig = this.mergeVSCodeConfig(existingConfig, vscodeConfig);
|
|
10072
|
-
|
|
10215
|
+
fs8.writeFileSync(vscodeConfigPath, JSON.stringify(mergedConfig, null, 2));
|
|
10073
10216
|
return { success: true };
|
|
10074
10217
|
} catch (error) {
|
|
10075
10218
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -10078,14 +10221,14 @@ var McpConfigService = class {
|
|
|
10078
10221
|
}
|
|
10079
10222
|
installContinueMcp(config) {
|
|
10080
10223
|
try {
|
|
10081
|
-
const continueDir =
|
|
10082
|
-
const mcpServersDir =
|
|
10083
|
-
if (!
|
|
10084
|
-
|
|
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 });
|
|
10085
10228
|
}
|
|
10086
|
-
const continueConfigPath =
|
|
10229
|
+
const continueConfigPath = path8.join(mcpServersDir, "packmind.yaml");
|
|
10087
10230
|
const continueConfig = this.buildContinueYamlConfig(config);
|
|
10088
|
-
|
|
10231
|
+
fs8.writeFileSync(continueConfigPath, continueConfig);
|
|
10089
10232
|
return { success: true };
|
|
10090
10233
|
} catch (error) {
|
|
10091
10234
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -10133,8 +10276,8 @@ mcpServers:
|
|
|
10133
10276
|
}
|
|
10134
10277
|
readExistingJsonConfig(filePath) {
|
|
10135
10278
|
try {
|
|
10136
|
-
if (
|
|
10137
|
-
const content =
|
|
10279
|
+
if (fs8.existsSync(filePath)) {
|
|
10280
|
+
const content = fs8.readFileSync(filePath, "utf-8");
|
|
10138
10281
|
return JSON.parse(content);
|
|
10139
10282
|
}
|
|
10140
10283
|
} catch {
|
|
@@ -10167,8 +10310,8 @@ mcpServers:
|
|
|
10167
10310
|
};
|
|
10168
10311
|
|
|
10169
10312
|
// apps/cli/src/infra/repositories/ConfigFileRepository.ts
|
|
10170
|
-
var
|
|
10171
|
-
var
|
|
10313
|
+
var fs9 = __toESM(require("fs/promises"));
|
|
10314
|
+
var path9 = __toESM(require("path"));
|
|
10172
10315
|
|
|
10173
10316
|
// apps/cli/src/infra/utils/consoleLogger.ts
|
|
10174
10317
|
init_source();
|
|
@@ -10216,23 +10359,23 @@ var ConfigFileRepository = class {
|
|
|
10216
10359
|
];
|
|
10217
10360
|
}
|
|
10218
10361
|
async writeConfig(baseDirectory, config) {
|
|
10219
|
-
const configPath =
|
|
10362
|
+
const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
|
|
10220
10363
|
const configContent = JSON.stringify(config, null, 2) + "\n";
|
|
10221
|
-
await
|
|
10364
|
+
await fs9.writeFile(configPath, configContent, "utf-8");
|
|
10222
10365
|
}
|
|
10223
10366
|
async configExists(baseDirectory) {
|
|
10224
|
-
const configPath =
|
|
10367
|
+
const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
|
|
10225
10368
|
try {
|
|
10226
|
-
await
|
|
10369
|
+
await fs9.access(configPath);
|
|
10227
10370
|
return true;
|
|
10228
10371
|
} catch {
|
|
10229
10372
|
return false;
|
|
10230
10373
|
}
|
|
10231
10374
|
}
|
|
10232
10375
|
async readConfig(baseDirectory) {
|
|
10233
|
-
const configPath =
|
|
10376
|
+
const configPath = path9.join(baseDirectory, this.CONFIG_FILENAME);
|
|
10234
10377
|
try {
|
|
10235
|
-
const configContent = await
|
|
10378
|
+
const configContent = await fs9.readFile(configPath, "utf-8");
|
|
10236
10379
|
const config = JSON.parse(configContent);
|
|
10237
10380
|
if (!config.packages || typeof config.packages !== "object") {
|
|
10238
10381
|
throw new Error(
|
|
@@ -10259,12 +10402,12 @@ var ConfigFileRepository = class {
|
|
|
10259
10402
|
* @returns Array of directory paths that contain a packmind.json file
|
|
10260
10403
|
*/
|
|
10261
10404
|
async findDescendantConfigs(directory) {
|
|
10262
|
-
const normalizedDir =
|
|
10405
|
+
const normalizedDir = path9.resolve(directory);
|
|
10263
10406
|
const results = [];
|
|
10264
10407
|
const searchRecursively = async (currentDir) => {
|
|
10265
10408
|
let entries;
|
|
10266
10409
|
try {
|
|
10267
|
-
entries = await
|
|
10410
|
+
entries = await fs9.readdir(currentDir, { withFileTypes: true });
|
|
10268
10411
|
} catch {
|
|
10269
10412
|
return;
|
|
10270
10413
|
}
|
|
@@ -10275,7 +10418,7 @@ var ConfigFileRepository = class {
|
|
|
10275
10418
|
if (this.EXCLUDED_DIRECTORIES.includes(entry.name)) {
|
|
10276
10419
|
continue;
|
|
10277
10420
|
}
|
|
10278
|
-
const entryPath =
|
|
10421
|
+
const entryPath = path9.join(currentDir, entry.name);
|
|
10279
10422
|
const config = await this.readConfig(entryPath);
|
|
10280
10423
|
if (config) {
|
|
10281
10424
|
results.push(entryPath);
|
|
@@ -10297,19 +10440,19 @@ var ConfigFileRepository = class {
|
|
|
10297
10440
|
async readHierarchicalConfig(startDirectory, stopDirectory) {
|
|
10298
10441
|
const configs = [];
|
|
10299
10442
|
const configPaths = [];
|
|
10300
|
-
const normalizedStart =
|
|
10301
|
-
const normalizedStop = stopDirectory ?
|
|
10443
|
+
const normalizedStart = path9.resolve(startDirectory);
|
|
10444
|
+
const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
|
|
10302
10445
|
let currentDir = normalizedStart;
|
|
10303
10446
|
while (true) {
|
|
10304
10447
|
const config = await this.readConfig(currentDir);
|
|
10305
10448
|
if (config) {
|
|
10306
10449
|
configs.push(config);
|
|
10307
|
-
configPaths.push(
|
|
10450
|
+
configPaths.push(path9.join(currentDir, this.CONFIG_FILENAME));
|
|
10308
10451
|
}
|
|
10309
10452
|
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
10310
10453
|
break;
|
|
10311
10454
|
}
|
|
10312
|
-
const parentDir =
|
|
10455
|
+
const parentDir = path9.dirname(currentDir);
|
|
10313
10456
|
if (parentDir === currentDir) {
|
|
10314
10457
|
break;
|
|
10315
10458
|
}
|
|
@@ -10338,8 +10481,8 @@ var ConfigFileRepository = class {
|
|
|
10338
10481
|
* @returns All configs found with their target paths
|
|
10339
10482
|
*/
|
|
10340
10483
|
async findAllConfigsInTree(startDirectory, stopDirectory) {
|
|
10341
|
-
const normalizedStart =
|
|
10342
|
-
const normalizedStop = stopDirectory ?
|
|
10484
|
+
const normalizedStart = path9.resolve(startDirectory);
|
|
10485
|
+
const normalizedStop = stopDirectory ? path9.resolve(stopDirectory) : null;
|
|
10343
10486
|
const basePath = normalizedStop ?? normalizedStart;
|
|
10344
10487
|
const configsMap = /* @__PURE__ */ new Map();
|
|
10345
10488
|
let currentDir = normalizedStart;
|
|
@@ -10356,7 +10499,7 @@ var ConfigFileRepository = class {
|
|
|
10356
10499
|
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
10357
10500
|
break;
|
|
10358
10501
|
}
|
|
10359
|
-
const parentDir =
|
|
10502
|
+
const parentDir = path9.dirname(currentDir);
|
|
10360
10503
|
if (parentDir === currentDir) {
|
|
10361
10504
|
break;
|
|
10362
10505
|
}
|
|
@@ -10476,29 +10619,29 @@ var PackmindCliHexa = class {
|
|
|
10476
10619
|
this.logger.info("Destroying PackmindCliHexa");
|
|
10477
10620
|
this.logger.info("PackmindCliHexa destroyed");
|
|
10478
10621
|
}
|
|
10479
|
-
async getGitRemoteUrl(
|
|
10480
|
-
return this.hexa.useCases.getGitRemoteUrl.execute(
|
|
10622
|
+
async getGitRemoteUrl(command9) {
|
|
10623
|
+
return this.hexa.useCases.getGitRemoteUrl.execute(command9);
|
|
10481
10624
|
}
|
|
10482
|
-
async executeSingleFileAst(
|
|
10483
|
-
return this.hexa.useCases.executeSingleFileAst.execute(
|
|
10625
|
+
async executeSingleFileAst(command9) {
|
|
10626
|
+
return this.hexa.useCases.executeSingleFileAst.execute(command9);
|
|
10484
10627
|
}
|
|
10485
|
-
async listFilesInDirectory(
|
|
10486
|
-
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(
|
|
10628
|
+
async listFilesInDirectory(command9) {
|
|
10629
|
+
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command9);
|
|
10487
10630
|
}
|
|
10488
|
-
async lintFilesInDirectory(
|
|
10489
|
-
return this.hexa.useCases.lintFilesInDirectory.execute(
|
|
10631
|
+
async lintFilesInDirectory(command9) {
|
|
10632
|
+
return this.hexa.useCases.lintFilesInDirectory.execute(command9);
|
|
10490
10633
|
}
|
|
10491
|
-
async lintFilesLocally(
|
|
10492
|
-
return this.hexa.useCases.lintFilesLocally.execute(
|
|
10634
|
+
async lintFilesLocally(command9) {
|
|
10635
|
+
return this.hexa.useCases.lintFilesLocally.execute(command9);
|
|
10493
10636
|
}
|
|
10494
|
-
async installPackages(
|
|
10495
|
-
return this.hexa.useCases.installPackages.execute(
|
|
10637
|
+
async installPackages(command9) {
|
|
10638
|
+
return this.hexa.useCases.installPackages.execute(command9);
|
|
10496
10639
|
}
|
|
10497
|
-
async listPackages(
|
|
10498
|
-
return this.hexa.useCases.listPackages.execute(
|
|
10640
|
+
async listPackages(command9) {
|
|
10641
|
+
return this.hexa.useCases.listPackages.execute(command9);
|
|
10499
10642
|
}
|
|
10500
|
-
async getPackageBySlug(
|
|
10501
|
-
return this.hexa.useCases.getPackageBySlug.execute(
|
|
10643
|
+
async getPackageBySlug(command9) {
|
|
10644
|
+
return this.hexa.useCases.getPackageBySlug.execute(command9);
|
|
10502
10645
|
}
|
|
10503
10646
|
async configExists(baseDirectory) {
|
|
10504
10647
|
return await this.hexa.repositories.configFileRepository.configExists(
|
|
@@ -10557,17 +10700,17 @@ var PackmindCliHexa = class {
|
|
|
10557
10700
|
directory
|
|
10558
10701
|
);
|
|
10559
10702
|
}
|
|
10560
|
-
async login(
|
|
10561
|
-
return this.hexa.useCases.login.execute(
|
|
10703
|
+
async login(command9) {
|
|
10704
|
+
return this.hexa.useCases.login.execute(command9);
|
|
10562
10705
|
}
|
|
10563
|
-
async logout(
|
|
10564
|
-
return this.hexa.useCases.logout.execute(
|
|
10706
|
+
async logout(command9) {
|
|
10707
|
+
return this.hexa.useCases.logout.execute(command9);
|
|
10565
10708
|
}
|
|
10566
|
-
async whoami(
|
|
10567
|
-
return this.hexa.useCases.whoami.execute(
|
|
10709
|
+
async whoami(command9) {
|
|
10710
|
+
return this.hexa.useCases.whoami.execute(command9);
|
|
10568
10711
|
}
|
|
10569
|
-
async setupMcp(
|
|
10570
|
-
return this.hexa.useCases.setupMcp.execute(
|
|
10712
|
+
async setupMcp(command9) {
|
|
10713
|
+
return this.hexa.useCases.setupMcp.execute(command9);
|
|
10571
10714
|
}
|
|
10572
10715
|
getCurrentBranch(repoPath) {
|
|
10573
10716
|
return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
|
|
@@ -10575,8 +10718,11 @@ var PackmindCliHexa = class {
|
|
|
10575
10718
|
getGitRemoteUrlFromPath(repoPath) {
|
|
10576
10719
|
return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
|
|
10577
10720
|
}
|
|
10578
|
-
async notifyDistribution(
|
|
10579
|
-
return this.hexa.repositories.packmindGateway.notifyDistribution(
|
|
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);
|
|
10580
10726
|
}
|
|
10581
10727
|
};
|
|
10582
10728
|
|
|
@@ -10633,7 +10779,7 @@ function isNotLoggedInError(error) {
|
|
|
10633
10779
|
}
|
|
10634
10780
|
async function lintHandler(args2, deps) {
|
|
10635
10781
|
const {
|
|
10636
|
-
path:
|
|
10782
|
+
path: path12,
|
|
10637
10783
|
draft,
|
|
10638
10784
|
rule,
|
|
10639
10785
|
language,
|
|
@@ -10653,14 +10799,14 @@ async function lintHandler(args2, deps) {
|
|
|
10653
10799
|
throw new Error("option --rule is required to use --draft mode");
|
|
10654
10800
|
}
|
|
10655
10801
|
const startedAt = Date.now();
|
|
10656
|
-
const targetPath =
|
|
10802
|
+
const targetPath = path12 ?? ".";
|
|
10657
10803
|
const hasArguments = !!(draft || rule || language);
|
|
10658
10804
|
const absolutePath = resolvePath(targetPath);
|
|
10659
10805
|
if (diff) {
|
|
10660
10806
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
|
|
10661
10807
|
if (!gitRoot) {
|
|
10662
10808
|
throw new Error(
|
|
10663
|
-
"The --
|
|
10809
|
+
"The --changed-files and --changed-lines options require the project to be in a Git repository"
|
|
10664
10810
|
);
|
|
10665
10811
|
}
|
|
10666
10812
|
}
|
|
@@ -10700,15 +10846,15 @@ async function lintHandler(args2, deps) {
|
|
|
10700
10846
|
}
|
|
10701
10847
|
} catch (error) {
|
|
10702
10848
|
if (isNotLoggedInError(error) && continueOnMissingKey) {
|
|
10703
|
-
|
|
10849
|
+
logWarningConsole(
|
|
10704
10850
|
"Warning: Not logged in to Packmind, linting is skipped. Run `packmind-cli login` to authenticate."
|
|
10705
10851
|
);
|
|
10706
10852
|
exit(0);
|
|
10707
10853
|
return;
|
|
10708
10854
|
}
|
|
10709
10855
|
if (error instanceof CommunityEditionError) {
|
|
10710
|
-
|
|
10711
|
-
|
|
10856
|
+
logInfoConsole(`packmind-cli ${error.message}`);
|
|
10857
|
+
logInfoConsole("Linting skipped.");
|
|
10712
10858
|
exit(0);
|
|
10713
10859
|
return;
|
|
10714
10860
|
}
|
|
@@ -10718,7 +10864,7 @@ async function lintHandler(args2, deps) {
|
|
|
10718
10864
|
violations
|
|
10719
10865
|
);
|
|
10720
10866
|
const durationSeconds = (Date.now() - startedAt) / 1e3;
|
|
10721
|
-
|
|
10867
|
+
logInfoConsole(`Lint completed in ${durationSeconds.toFixed(2)}s`);
|
|
10722
10868
|
if (violations.length > 0 && !continueOnError) {
|
|
10723
10869
|
exit(1);
|
|
10724
10870
|
} else {
|
|
@@ -10811,11 +10957,34 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
10811
10957
|
}),
|
|
10812
10958
|
diff: (0, import_cmd_ts.option)({
|
|
10813
10959
|
long: "diff",
|
|
10814
|
-
description: "Filter violations by git diff (files | lines)",
|
|
10960
|
+
description: "[Deprecated: use --changed-files or --changed-lines] Filter violations by git diff (files | lines)",
|
|
10815
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"
|
|
10816
10970
|
})
|
|
10817
10971
|
},
|
|
10818
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
|
+
}
|
|
10819
10988
|
const packmindLogger = new PackmindLogger(
|
|
10820
10989
|
"PackmindCLI",
|
|
10821
10990
|
args2.debug ? "debug" /* DEBUG */ : "info" /* INFO */
|
|
@@ -10827,13 +10996,13 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
10827
10996
|
resolvePath: (targetPath) => pathModule.isAbsolute(targetPath) ? targetPath : pathModule.resolve(process.cwd(), targetPath),
|
|
10828
10997
|
exit: (code) => process.exit(code)
|
|
10829
10998
|
};
|
|
10830
|
-
await lintHandler(args2, deps);
|
|
10999
|
+
await lintHandler({ ...args2, diff }, deps);
|
|
10831
11000
|
}
|
|
10832
11001
|
});
|
|
10833
11002
|
|
|
10834
11003
|
// apps/cli/src/wasm-runtime.ts
|
|
10835
11004
|
var import_fs18 = require("fs");
|
|
10836
|
-
var
|
|
11005
|
+
var import_path3 = require("path");
|
|
10837
11006
|
var import_os = require("os");
|
|
10838
11007
|
|
|
10839
11008
|
// apps/cli/src/embedded-wasm.ts
|
|
@@ -10867,12 +11036,12 @@ function extractWasmFiles() {
|
|
|
10867
11036
|
if (wasmExtractedDir && (0, import_fs18.existsSync)(wasmExtractedDir)) {
|
|
10868
11037
|
return wasmExtractedDir;
|
|
10869
11038
|
}
|
|
10870
|
-
const tempDir = (0,
|
|
11039
|
+
const tempDir = (0, import_path3.join)((0, import_os.tmpdir)(), `packmind-wasm-${process.pid}`);
|
|
10871
11040
|
if (!(0, import_fs18.existsSync)(tempDir)) {
|
|
10872
11041
|
(0, import_fs18.mkdirSync)(tempDir, { recursive: true });
|
|
10873
11042
|
}
|
|
10874
11043
|
for (const [filename, base64Data] of Object.entries(EMBEDDED_WASM_FILES)) {
|
|
10875
|
-
const wasmPath = (0,
|
|
11044
|
+
const wasmPath = (0, import_path3.join)(tempDir, filename);
|
|
10876
11045
|
if ((0, import_fs18.existsSync)(wasmPath)) {
|
|
10877
11046
|
continue;
|
|
10878
11047
|
}
|
|
@@ -10887,8 +11056,8 @@ function extractWasmFiles() {
|
|
|
10887
11056
|
|
|
10888
11057
|
// apps/cli/src/main.ts
|
|
10889
11058
|
var import_dotenv = require("dotenv");
|
|
10890
|
-
var
|
|
10891
|
-
var
|
|
11059
|
+
var fs12 = __toESM(require("fs"));
|
|
11060
|
+
var path11 = __toESM(require("path"));
|
|
10892
11061
|
|
|
10893
11062
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
10894
11063
|
var import_cmd_ts2 = __toESM(require_cjs());
|
|
@@ -10990,7 +11159,7 @@ async function showPackageHandler(args2, deps) {
|
|
|
10990
11159
|
log("");
|
|
10991
11160
|
}
|
|
10992
11161
|
if (pkg.recipes && pkg.recipes.length > 0) {
|
|
10993
|
-
log("
|
|
11162
|
+
log("Commands:");
|
|
10994
11163
|
pkg.recipes.forEach((recipe) => {
|
|
10995
11164
|
if (recipe.summary) {
|
|
10996
11165
|
log(` - ${recipe.name}: ${recipe.summary}`);
|
|
@@ -11121,7 +11290,7 @@ async function executeInstallForDirectory(directory, deps) {
|
|
|
11121
11290
|
// Pass for consistency
|
|
11122
11291
|
});
|
|
11123
11292
|
log(
|
|
11124
|
-
` Installing ${result.recipesCount}
|
|
11293
|
+
` Installing ${result.recipesCount} commands and ${result.standardsCount} standards...`
|
|
11125
11294
|
);
|
|
11126
11295
|
log(
|
|
11127
11296
|
` added ${result.filesCreated} files, changed ${result.filesUpdated} files, removed ${result.filesDeleted} files`
|
|
@@ -11207,7 +11376,7 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11207
11376
|
log(" packmind-cli install backend frontend");
|
|
11208
11377
|
log(" packmind-cli install --list # Show available packages");
|
|
11209
11378
|
log("");
|
|
11210
|
-
log("Install
|
|
11379
|
+
log("Install commands and standards from the specified packages.");
|
|
11211
11380
|
exit(0);
|
|
11212
11381
|
return {
|
|
11213
11382
|
filesCreated: 0,
|
|
@@ -11232,7 +11401,7 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11232
11401
|
// Pass previous config for change detection
|
|
11233
11402
|
});
|
|
11234
11403
|
log(
|
|
11235
|
-
`Installing ${result.recipesCount}
|
|
11404
|
+
`Installing ${result.recipesCount} commands and ${result.standardsCount} standards...`
|
|
11236
11405
|
);
|
|
11237
11406
|
log(
|
|
11238
11407
|
`
|
|
@@ -11449,7 +11618,7 @@ removed ${result.filesDeleted} files`);
|
|
|
11449
11618
|
});
|
|
11450
11619
|
if (result.recipesCount > 0 || result.standardsCount > 0) {
|
|
11451
11620
|
log(
|
|
11452
|
-
`Removing ${result.recipesCount}
|
|
11621
|
+
`Removing ${result.recipesCount} commands and ${result.standardsCount} standards...`
|
|
11453
11622
|
);
|
|
11454
11623
|
}
|
|
11455
11624
|
log(`
|
|
@@ -11597,7 +11766,7 @@ async function recursiveInstallHandler(_args, deps) {
|
|
|
11597
11766
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
11598
11767
|
var installCommand = (0, import_cmd_ts2.command)({
|
|
11599
11768
|
name: "install",
|
|
11600
|
-
description: "Install
|
|
11769
|
+
description: "Install commands and standards from specified packages and save them to the current directory",
|
|
11601
11770
|
aliases: ["pull"],
|
|
11602
11771
|
args: {
|
|
11603
11772
|
list: (0, import_cmd_ts2.flag)({
|
|
@@ -11659,7 +11828,7 @@ var installCommand = (0, import_cmd_ts2.command)({
|
|
|
11659
11828
|
var import_cmd_ts3 = __toESM(require_cjs());
|
|
11660
11829
|
var uninstallCommand = (0, import_cmd_ts3.command)({
|
|
11661
11830
|
name: "uninstall",
|
|
11662
|
-
description: "Uninstall packages and remove their
|
|
11831
|
+
description: "Uninstall packages and remove their commands and standards from the current directory",
|
|
11663
11832
|
args: {
|
|
11664
11833
|
packagesSlugs: (0, import_cmd_ts3.restPositionals)({
|
|
11665
11834
|
type: import_cmd_ts3.string,
|
|
@@ -11847,13 +12016,13 @@ Credentials are loaded from (in order of priority):`);
|
|
|
11847
12016
|
|
|
11848
12017
|
// apps/cli/src/infra/commands/SetupMcpCommand.ts
|
|
11849
12018
|
var import_cmd_ts7 = __toESM(require_cjs());
|
|
11850
|
-
var
|
|
12019
|
+
var fs11 = __toESM(require("fs"));
|
|
11851
12020
|
var readline2 = __toESM(require("readline"));
|
|
11852
12021
|
var inquirer = __toESM(require("inquirer"));
|
|
11853
12022
|
|
|
11854
12023
|
// apps/cli/src/application/services/AgentDetectionService.ts
|
|
11855
|
-
var
|
|
11856
|
-
var
|
|
12024
|
+
var fs10 = __toESM(require("fs"));
|
|
12025
|
+
var path10 = __toESM(require("path"));
|
|
11857
12026
|
var os4 = __toESM(require("os"));
|
|
11858
12027
|
var import_child_process3 = require("child_process");
|
|
11859
12028
|
var AgentDetectionService = class {
|
|
@@ -11880,21 +12049,21 @@ var AgentDetectionService = class {
|
|
|
11880
12049
|
return this.isCommandAvailable("claude");
|
|
11881
12050
|
}
|
|
11882
12051
|
isCursorAvailable() {
|
|
11883
|
-
const cursorConfigDir =
|
|
11884
|
-
return
|
|
12052
|
+
const cursorConfigDir = path10.join(os4.homedir(), ".cursor");
|
|
12053
|
+
return fs10.existsSync(cursorConfigDir);
|
|
11885
12054
|
}
|
|
11886
12055
|
isVSCodeAvailable() {
|
|
11887
|
-
const vscodeDir =
|
|
11888
|
-
return
|
|
12056
|
+
const vscodeDir = path10.join(this.projectDir, ".vscode");
|
|
12057
|
+
return fs10.existsSync(vscodeDir);
|
|
11889
12058
|
}
|
|
11890
12059
|
isContinueAvailable() {
|
|
11891
|
-
const continueDir =
|
|
11892
|
-
return
|
|
12060
|
+
const continueDir = path10.join(this.projectDir, ".continue");
|
|
12061
|
+
return fs10.existsSync(continueDir);
|
|
11893
12062
|
}
|
|
11894
|
-
isCommandAvailable(
|
|
12063
|
+
isCommandAvailable(command9) {
|
|
11895
12064
|
try {
|
|
11896
12065
|
const whichCommand = process.platform === "win32" ? "where" : "which";
|
|
11897
|
-
(0, import_child_process3.execSync)(`${whichCommand} ${
|
|
12066
|
+
(0, import_child_process3.execSync)(`${whichCommand} ${command9}`, { stdio: "pipe" });
|
|
11898
12067
|
return true;
|
|
11899
12068
|
} catch {
|
|
11900
12069
|
return false;
|
|
@@ -11928,8 +12097,8 @@ var ALL_AGENTS2 = [
|
|
|
11928
12097
|
{ type: "continue", name: "Continue.dev" }
|
|
11929
12098
|
];
|
|
11930
12099
|
async function promptAgentsWithReadline(choices) {
|
|
11931
|
-
const input =
|
|
11932
|
-
const output =
|
|
12100
|
+
const input = fs11.createReadStream("/dev/tty");
|
|
12101
|
+
const output = fs11.createWriteStream("/dev/tty");
|
|
11933
12102
|
const rl = readline2.createInterface({
|
|
11934
12103
|
input,
|
|
11935
12104
|
output
|
|
@@ -12089,26 +12258,64 @@ Credentials are loaded from (in order of priority):`);
|
|
|
12089
12258
|
}
|
|
12090
12259
|
});
|
|
12091
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
|
+
|
|
12092
12299
|
// apps/cli/src/main.ts
|
|
12093
12300
|
var { version: CLI_VERSION } = require_package();
|
|
12094
12301
|
function findEnvFile() {
|
|
12095
12302
|
const currentDir = process.cwd();
|
|
12096
12303
|
const gitService = new GitService();
|
|
12097
12304
|
const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
|
|
12098
|
-
const filesystemRoot =
|
|
12305
|
+
const filesystemRoot = path11.parse(currentDir).root;
|
|
12099
12306
|
const stopDir = gitRoot ?? filesystemRoot;
|
|
12100
12307
|
let searchDir = currentDir;
|
|
12101
|
-
let parentDir =
|
|
12308
|
+
let parentDir = path11.dirname(searchDir);
|
|
12102
12309
|
while (searchDir !== parentDir) {
|
|
12103
|
-
const envPath2 =
|
|
12104
|
-
if (
|
|
12310
|
+
const envPath2 = path11.join(searchDir, ".env");
|
|
12311
|
+
if (fs12.existsSync(envPath2)) {
|
|
12105
12312
|
return envPath2;
|
|
12106
12313
|
}
|
|
12107
12314
|
if (searchDir === stopDir) {
|
|
12108
12315
|
return null;
|
|
12109
12316
|
}
|
|
12110
12317
|
searchDir = parentDir;
|
|
12111
|
-
parentDir =
|
|
12318
|
+
parentDir = path11.dirname(searchDir);
|
|
12112
12319
|
}
|
|
12113
12320
|
return null;
|
|
12114
12321
|
}
|
|
@@ -12128,7 +12335,7 @@ if (args.includes("--version") || args.includes("-v")) {
|
|
|
12128
12335
|
console.log(`packmind-cli version ${CLI_VERSION}`);
|
|
12129
12336
|
process.exit(0);
|
|
12130
12337
|
}
|
|
12131
|
-
var app = (0,
|
|
12338
|
+
var app = (0, import_cmd_ts9.subcommands)({
|
|
12132
12339
|
name: "packmind-cli",
|
|
12133
12340
|
description: "Packmind CLI tool",
|
|
12134
12341
|
cmds: {
|
|
@@ -12140,10 +12347,11 @@ var app = (0, import_cmd_ts8.subcommands)({
|
|
|
12140
12347
|
login: loginCommand,
|
|
12141
12348
|
logout: logoutCommand,
|
|
12142
12349
|
whoami: whoamiCommand,
|
|
12143
|
-
"setup-mcp": setupMcpCommand
|
|
12350
|
+
"setup-mcp": setupMcpCommand,
|
|
12351
|
+
"upload-skill": uploadSkillCommand
|
|
12144
12352
|
}
|
|
12145
12353
|
});
|
|
12146
|
-
(0,
|
|
12354
|
+
(0, import_cmd_ts9.run)(app, args).catch((error) => {
|
|
12147
12355
|
logErrorConsole(error.message);
|
|
12148
12356
|
process.exit(1);
|
|
12149
12357
|
});
|