@packmind/cli 0.15.0 → 0.16.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 +1316 -729
- package/package.json +14 -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(string11, substring, replacer) {
|
|
375
|
+
let index = string11.indexOf(substring);
|
|
376
376
|
if (index === -1) {
|
|
377
|
-
return
|
|
377
|
+
return string11;
|
|
378
378
|
}
|
|
379
379
|
const substringLength = substring.length;
|
|
380
380
|
let endIndex = 0;
|
|
381
381
|
let returnValue = "";
|
|
382
382
|
do {
|
|
383
|
-
returnValue +=
|
|
383
|
+
returnValue += string11.slice(endIndex, index) + substring + replacer;
|
|
384
384
|
endIndex = index + substringLength;
|
|
385
|
-
index =
|
|
385
|
+
index = string11.indexOf(substring, endIndex);
|
|
386
386
|
} while (index !== -1);
|
|
387
|
-
returnValue +=
|
|
387
|
+
returnValue += string11.slice(endIndex);
|
|
388
388
|
return returnValue;
|
|
389
389
|
}
|
|
390
|
-
function stringEncaseCRLFWithFirstIndex(
|
|
390
|
+
function stringEncaseCRLFWithFirstIndex(string11, prefix, postfix, index) {
|
|
391
391
|
let endIndex = 0;
|
|
392
392
|
let returnValue = "";
|
|
393
393
|
do {
|
|
394
|
-
const gotCR =
|
|
395
|
-
returnValue +=
|
|
394
|
+
const gotCR = string11[index - 1] === "\r";
|
|
395
|
+
returnValue += string11.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
396
396
|
endIndex = index + 1;
|
|
397
|
-
index =
|
|
397
|
+
index = string11.indexOf("\n", endIndex);
|
|
398
398
|
} while (index !== -1);
|
|
399
|
-
returnValue +=
|
|
399
|
+
returnValue += string11.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, string11) => {
|
|
559
|
+
if (self.level <= 0 || !string11) {
|
|
560
|
+
return self[IS_EMPTY] ? "" : string11;
|
|
561
561
|
}
|
|
562
562
|
let styler = self[STYLER];
|
|
563
563
|
if (styler === void 0) {
|
|
564
|
-
return
|
|
564
|
+
return string11;
|
|
565
565
|
}
|
|
566
566
|
const { openAll, closeAll } = styler;
|
|
567
|
-
if (
|
|
567
|
+
if (string11.includes("\x1B")) {
|
|
568
568
|
while (styler !== void 0) {
|
|
569
|
-
|
|
569
|
+
string11 = stringReplaceAll(string11, styler.close, styler.open);
|
|
570
570
|
styler = styler.parent;
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
const lfIndex =
|
|
573
|
+
const lfIndex = string11.indexOf("\n");
|
|
574
574
|
if (lfIndex !== -1) {
|
|
575
|
-
|
|
575
|
+
string11 = stringEncaseCRLFWithFirstIndex(string11, closeAll, openAll, lfIndex);
|
|
576
576
|
}
|
|
577
|
-
return openAll +
|
|
577
|
+
return openAll + string11 + closeAll;
|
|
578
578
|
};
|
|
579
579
|
Object.defineProperties(createChalk.prototype, styles2);
|
|
580
580
|
chalk = createChalk();
|
|
@@ -767,9 +767,9 @@ var require_findOption = __commonJS({
|
|
|
767
767
|
continue;
|
|
768
768
|
}
|
|
769
769
|
if (node.type === "shortOptions" && opts.shortNames.length) {
|
|
770
|
-
for (const
|
|
771
|
-
if (opts.shortNames.includes(
|
|
772
|
-
result.push(
|
|
770
|
+
for (const option7 of node.options) {
|
|
771
|
+
if (opts.shortNames.includes(option7.key)) {
|
|
772
|
+
result.push(option7);
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
}
|
|
@@ -842,8 +842,8 @@ var require_types = __commonJS({
|
|
|
842
842
|
"use strict";
|
|
843
843
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
844
844
|
exports2.boolean = exports2.string = exports2.number = void 0;
|
|
845
|
-
exports2.optional =
|
|
846
|
-
exports2.array =
|
|
845
|
+
exports2.optional = optional5;
|
|
846
|
+
exports2.array = array3;
|
|
847
847
|
var type_1 = require_type();
|
|
848
848
|
exports2.number = {
|
|
849
849
|
async from(str) {
|
|
@@ -869,7 +869,7 @@ var require_types = __commonJS({
|
|
|
869
869
|
return false;
|
|
870
870
|
}
|
|
871
871
|
};
|
|
872
|
-
function
|
|
872
|
+
function optional5(t) {
|
|
873
873
|
return {
|
|
874
874
|
...t,
|
|
875
875
|
defaultValue() {
|
|
@@ -877,7 +877,7 @@ var require_types = __commonJS({
|
|
|
877
877
|
}
|
|
878
878
|
};
|
|
879
879
|
}
|
|
880
|
-
function
|
|
880
|
+
function array3(t) {
|
|
881
881
|
return {
|
|
882
882
|
...t,
|
|
883
883
|
async from(inputs) {
|
|
@@ -1379,13 +1379,13 @@ var require_subcommands = __commonJS({
|
|
|
1379
1379
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1380
1380
|
};
|
|
1381
1381
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1382
|
-
exports2.subcommands =
|
|
1382
|
+
exports2.subcommands = subcommands7;
|
|
1383
1383
|
var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
|
|
1384
1384
|
var didyoumean_1 = __importDefault(require_didYouMean_1_2_1());
|
|
1385
1385
|
var Result = __importStar(require_Result());
|
|
1386
1386
|
var circuitbreaker_1 = require_circuitbreaker();
|
|
1387
1387
|
var positional_1 = require_positional();
|
|
1388
|
-
function
|
|
1388
|
+
function subcommands7(config) {
|
|
1389
1389
|
const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
|
|
1390
1390
|
const type = {
|
|
1391
1391
|
async from(str) {
|
|
@@ -1403,9 +1403,9 @@ var require_subcommands = __commonJS({
|
|
|
1403
1403
|
let errorMessage = "Not a valid subcommand name";
|
|
1404
1404
|
const closeOptions = (0, didyoumean_1.default)(str, flatMap(commands, (x) => x.names));
|
|
1405
1405
|
if (closeOptions) {
|
|
1406
|
-
const
|
|
1406
|
+
const option7 = Array.isArray(closeOptions) ? closeOptions[0] : closeOptions;
|
|
1407
1407
|
errorMessage += `
|
|
1408
|
-
Did you mean ${chalk_1.default.italic(
|
|
1408
|
+
Did you mean ${chalk_1.default.italic(option7)}?`;
|
|
1409
1409
|
}
|
|
1410
1410
|
throw new Error(errorMessage);
|
|
1411
1411
|
}
|
|
@@ -1526,9 +1526,9 @@ Did you mean ${chalk_1.default.italic(option5)}?`;
|
|
|
1526
1526
|
}
|
|
1527
1527
|
};
|
|
1528
1528
|
}
|
|
1529
|
-
function flatMap(
|
|
1529
|
+
function flatMap(array3, f) {
|
|
1530
1530
|
const rs = [];
|
|
1531
|
-
for (const item of
|
|
1531
|
+
for (const item of array3) {
|
|
1532
1532
|
rs.push(...f(item));
|
|
1533
1533
|
}
|
|
1534
1534
|
return rs;
|
|
@@ -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(string11) {
|
|
1582
|
+
if (typeof string11 !== "string") {
|
|
1583
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string11}\``);
|
|
1584
1584
|
}
|
|
1585
|
-
return
|
|
1585
|
+
return string11.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 = command20;
|
|
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 command20(config) {
|
|
1707
1707
|
const argEntries = (0, utils_1.entries)(config.args);
|
|
1708
1708
|
const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
|
|
1709
1709
|
return {
|
|
@@ -1781,11 +1781,11 @@ var require_command = __commonJS({
|
|
|
1781
1781
|
}
|
|
1782
1782
|
if (node.type === "forcePositional") {
|
|
1783
1783
|
} else if (node.type === "shortOptions") {
|
|
1784
|
-
for (const
|
|
1785
|
-
if (context.visitedNodes.has(
|
|
1784
|
+
for (const option7 of node.options) {
|
|
1785
|
+
if (context.visitedNodes.has(option7)) {
|
|
1786
1786
|
continue;
|
|
1787
1787
|
}
|
|
1788
|
-
unknownArguments.push(
|
|
1788
|
+
unknownArguments.push(option7);
|
|
1789
1789
|
}
|
|
1790
1790
|
} else {
|
|
1791
1791
|
unknownArguments.push(node);
|
|
@@ -1864,7 +1864,7 @@ var require_option = __commonJS({
|
|
|
1864
1864
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1865
1865
|
};
|
|
1866
1866
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1867
|
-
exports2.option =
|
|
1867
|
+
exports2.option = option7;
|
|
1868
1868
|
var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
|
|
1869
1869
|
var Result = __importStar(require_Result());
|
|
1870
1870
|
var findOption_1 = require_findOption();
|
|
@@ -1940,11 +1940,11 @@ var require_option = __commonJS({
|
|
|
1940
1940
|
const valueFromEnv = config.env ? process.env[config.env] : void 0;
|
|
1941
1941
|
const defaultValueFn = config.defaultValue || config.type.defaultValue;
|
|
1942
1942
|
const onMissingFn = config.onMissing || config.type.onMissing;
|
|
1943
|
-
const
|
|
1943
|
+
const option8 = options[0];
|
|
1944
1944
|
let rawValue;
|
|
1945
1945
|
let envPrefix = "";
|
|
1946
|
-
if (
|
|
1947
|
-
rawValue =
|
|
1946
|
+
if (option8 === null || option8 === void 0 ? void 0 : option8.value) {
|
|
1947
|
+
rawValue = option8.value.node.raw;
|
|
1948
1948
|
} else if (valueFromEnv !== void 0) {
|
|
1949
1949
|
rawValue = valueFromEnv;
|
|
1950
1950
|
envPrefix = `env[${chalk_1.default.italic(config.env)}]: `;
|
|
@@ -1979,7 +1979,7 @@ var require_option = __commonJS({
|
|
|
1979
1979
|
});
|
|
1980
1980
|
}
|
|
1981
1981
|
} else {
|
|
1982
|
-
const raw = (
|
|
1982
|
+
const raw = (option8 === null || option8 === void 0 ? void 0 : option8.type) === "shortOption" ? `-${option8 === null || option8 === void 0 ? void 0 : option8.key}` : `--${config.long}`;
|
|
1983
1983
|
return Result.err({
|
|
1984
1984
|
errors: [
|
|
1985
1985
|
{
|
|
@@ -2001,7 +2001,7 @@ var require_option = __commonJS({
|
|
|
2001
2001
|
}
|
|
2002
2002
|
};
|
|
2003
2003
|
}
|
|
2004
|
-
function
|
|
2004
|
+
function option7(config) {
|
|
2005
2005
|
return fullOption({
|
|
2006
2006
|
type: types_1.string,
|
|
2007
2007
|
...config
|
|
@@ -2040,12 +2040,12 @@ var require_errorBox = __commonJS({
|
|
|
2040
2040
|
if (node.type === "shortOptions") {
|
|
2041
2041
|
let failed = false;
|
|
2042
2042
|
let s = "";
|
|
2043
|
-
for (const
|
|
2044
|
-
if (error.nodes.includes(
|
|
2045
|
-
s += chalk_1.default.red(
|
|
2043
|
+
for (const option7 of node.options) {
|
|
2044
|
+
if (error.nodes.includes(option7)) {
|
|
2045
|
+
s += chalk_1.default.red(option7.raw);
|
|
2046
2046
|
failed = true;
|
|
2047
2047
|
} else {
|
|
2048
|
-
s += chalk_1.default.dim(
|
|
2048
|
+
s += chalk_1.default.dim(option7.raw);
|
|
2049
2049
|
}
|
|
2050
2050
|
}
|
|
2051
2051
|
const prefix = failed ? chalk_1.default.red("-") : chalk_1.default.dim("-");
|
|
@@ -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, string11] of (0, utils_1.enumerate)(strings)) {
|
|
3088
|
+
const chars = [...string11];
|
|
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 });
|
|
@@ -3346,15 +3346,15 @@ var require_multiflag = __commonJS({
|
|
|
3346
3346
|
longNames: [config.long],
|
|
3347
3347
|
shortNames: config.short ? [config.short] : []
|
|
3348
3348
|
}).filter((x) => !visitedNodes.has(x));
|
|
3349
|
-
for (const
|
|
3350
|
-
visitedNodes.add(
|
|
3349
|
+
for (const option7 of options) {
|
|
3350
|
+
visitedNodes.add(option7);
|
|
3351
3351
|
}
|
|
3352
3352
|
const optionValues = [];
|
|
3353
3353
|
const errors = [];
|
|
3354
|
-
for (const
|
|
3355
|
-
const decoded = await Result.safeAsync(flag_1.boolean.from((_b = (_a =
|
|
3354
|
+
for (const option7 of options) {
|
|
3355
|
+
const decoded = await Result.safeAsync(flag_1.boolean.from((_b = (_a = option7.value) === null || _a === void 0 ? void 0 : _a.node.raw) !== null && _b !== void 0 ? _b : "true"));
|
|
3356
3356
|
if (Result.isErr(decoded)) {
|
|
3357
|
-
errors.push({ nodes: [
|
|
3357
|
+
errors.push({ nodes: [option7], message: decoded.error.message });
|
|
3358
3358
|
} else {
|
|
3359
3359
|
optionValues.push(decoded.value);
|
|
3360
3360
|
}
|
|
@@ -3427,11 +3427,11 @@ var require_multioption = __commonJS({
|
|
|
3427
3427
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3428
3428
|
};
|
|
3429
3429
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3430
|
-
exports2.multioption =
|
|
3430
|
+
exports2.multioption = multioption3;
|
|
3431
3431
|
var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
|
|
3432
3432
|
var Result = __importStar(require_Result());
|
|
3433
3433
|
var findOption_1 = require_findOption();
|
|
3434
|
-
function
|
|
3434
|
+
function multioption3(config) {
|
|
3435
3435
|
return {
|
|
3436
3436
|
helpTopics() {
|
|
3437
3437
|
var _a, _b;
|
|
@@ -3518,16 +3518,16 @@ var require_multioption = __commonJS({
|
|
|
3518
3518
|
});
|
|
3519
3519
|
}
|
|
3520
3520
|
}
|
|
3521
|
-
for (const
|
|
3522
|
-
visitedNodes.add(
|
|
3521
|
+
for (const option7 of options) {
|
|
3522
|
+
visitedNodes.add(option7);
|
|
3523
3523
|
}
|
|
3524
3524
|
const optionValues = [];
|
|
3525
3525
|
const errors = [];
|
|
3526
3526
|
const flagNodes = [];
|
|
3527
|
-
for (const
|
|
3528
|
-
const providedValue = (_a =
|
|
3527
|
+
for (const option7 of options) {
|
|
3528
|
+
const providedValue = (_a = option7.value) === null || _a === void 0 ? void 0 : _a.node.raw;
|
|
3529
3529
|
if (providedValue === void 0) {
|
|
3530
|
-
flagNodes.push(
|
|
3530
|
+
flagNodes.push(option7);
|
|
3531
3531
|
continue;
|
|
3532
3532
|
}
|
|
3533
3533
|
optionValues.push(providedValue);
|
|
@@ -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.16.1",
|
|
3856
3856
|
description: "A command-line interface for Packmind linting and code quality checks",
|
|
3857
3857
|
private: false,
|
|
3858
3858
|
bin: {
|
|
@@ -3895,7 +3895,7 @@ var require_package = __commonJS({
|
|
|
3895
3895
|
});
|
|
3896
3896
|
|
|
3897
3897
|
// apps/cli/src/main.ts
|
|
3898
|
-
var
|
|
3898
|
+
var import_cmd_ts26 = __toESM(require_cjs());
|
|
3899
3899
|
|
|
3900
3900
|
// apps/cli/src/infra/commands/LinterCommand.ts
|
|
3901
3901
|
var import_cmd_ts = __toESM(require_cjs());
|
|
@@ -4003,6 +4003,9 @@ var createOrganizationId = brandedIdFactory();
|
|
|
4003
4003
|
// packages/types/src/accounts/User.ts
|
|
4004
4004
|
var createUserId = brandedIdFactory();
|
|
4005
4005
|
|
|
4006
|
+
// packages/types/src/accounts/UserMetadata.ts
|
|
4007
|
+
var createUserMetadataId = brandedIdFactory();
|
|
4008
|
+
|
|
4006
4009
|
// packages/types/src/events/PackmindEvent.ts
|
|
4007
4010
|
var PackmindEvent = class {
|
|
4008
4011
|
constructor(payload) {
|
|
@@ -4060,6 +4063,53 @@ var OrganizationCreatedEvent = class extends UserEvent {
|
|
|
4060
4063
|
var createTrialActivationTokenId = brandedIdFactory();
|
|
4061
4064
|
var createTrialActivationToken = brandedIdFactory();
|
|
4062
4065
|
|
|
4066
|
+
// packages/types/src/coding-agent/validation.ts
|
|
4067
|
+
var VALID_CODING_AGENTS = [
|
|
4068
|
+
"packmind",
|
|
4069
|
+
"junie",
|
|
4070
|
+
"claude",
|
|
4071
|
+
"cursor",
|
|
4072
|
+
"copilot",
|
|
4073
|
+
"agents_md",
|
|
4074
|
+
"gitlab_duo",
|
|
4075
|
+
"continue"
|
|
4076
|
+
];
|
|
4077
|
+
function isValidCodingAgent(value) {
|
|
4078
|
+
return VALID_CODING_AGENTS.includes(value);
|
|
4079
|
+
}
|
|
4080
|
+
function validateAgentsWithWarnings(agents) {
|
|
4081
|
+
if (agents === void 0 || agents === null) {
|
|
4082
|
+
return { validAgents: null, invalidAgents: [] };
|
|
4083
|
+
}
|
|
4084
|
+
if (!Array.isArray(agents)) {
|
|
4085
|
+
return { validAgents: null, invalidAgents: [] };
|
|
4086
|
+
}
|
|
4087
|
+
const validAgents = [];
|
|
4088
|
+
const invalidAgents = [];
|
|
4089
|
+
for (const agent of agents) {
|
|
4090
|
+
if (typeof agent === "string") {
|
|
4091
|
+
if (isValidCodingAgent(agent)) {
|
|
4092
|
+
validAgents.push(agent);
|
|
4093
|
+
} else {
|
|
4094
|
+
invalidAgents.push(agent);
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
return { validAgents, invalidAgents };
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
// packages/types/src/coding-agent/CodingAgent.ts
|
|
4102
|
+
var CodingAgents = {
|
|
4103
|
+
packmind: "packmind",
|
|
4104
|
+
junie: "junie",
|
|
4105
|
+
claude: "claude",
|
|
4106
|
+
cursor: "cursor",
|
|
4107
|
+
copilot: "copilot",
|
|
4108
|
+
agents_md: "agents_md",
|
|
4109
|
+
gitlab_duo: "gitlab_duo",
|
|
4110
|
+
continue: "continue"
|
|
4111
|
+
};
|
|
4112
|
+
|
|
4063
4113
|
// packages/types/src/recipes/RecipeId.ts
|
|
4064
4114
|
var createRecipeId = brandedIdFactory();
|
|
4065
4115
|
|
|
@@ -4146,6 +4196,25 @@ var DEFAULT_ACTIVE_RENDER_MODES = normalizeRenderModes([
|
|
|
4146
4196
|
"AGENTS_MD" /* AGENTS_MD */
|
|
4147
4197
|
]);
|
|
4148
4198
|
|
|
4199
|
+
// packages/types/src/deployments/RenderModeCodingAgentMapping.ts
|
|
4200
|
+
var RENDER_MODE_TO_CODING_AGENT = {
|
|
4201
|
+
["PACKMIND" /* PACKMIND */]: CodingAgents.packmind,
|
|
4202
|
+
["AGENTS_MD" /* AGENTS_MD */]: CodingAgents.agents_md,
|
|
4203
|
+
["JUNIE" /* JUNIE */]: CodingAgents.junie,
|
|
4204
|
+
["GH_COPILOT" /* GH_COPILOT */]: CodingAgents.copilot,
|
|
4205
|
+
["CLAUDE" /* CLAUDE */]: CodingAgents.claude,
|
|
4206
|
+
["CURSOR" /* CURSOR */]: CodingAgents.cursor,
|
|
4207
|
+
["GITLAB_DUO" /* GITLAB_DUO */]: CodingAgents.gitlab_duo,
|
|
4208
|
+
["CONTINUE" /* CONTINUE */]: CodingAgents.continue
|
|
4209
|
+
};
|
|
4210
|
+
var CODING_AGENT_TO_RENDER_MODE = Object.entries(RENDER_MODE_TO_CODING_AGENT).reduce(
|
|
4211
|
+
(acc, [renderMode, codingAgent]) => {
|
|
4212
|
+
acc[codingAgent] = renderMode;
|
|
4213
|
+
return acc;
|
|
4214
|
+
},
|
|
4215
|
+
{}
|
|
4216
|
+
);
|
|
4217
|
+
|
|
4149
4218
|
// packages/types/src/deployments/PackagesDeploymentId.ts
|
|
4150
4219
|
var createPackagesDeploymentId = brandedIdFactory();
|
|
4151
4220
|
|
|
@@ -4897,6 +4966,9 @@ var LLM_PROVIDER_METADATA = {
|
|
|
4897
4966
|
// packages/types/src/llm/AIProviderId.ts
|
|
4898
4967
|
var createAIProviderId = brandedIdFactory();
|
|
4899
4968
|
|
|
4969
|
+
// packages/types/src/playbookChangeManagement/ChangeProposalId.ts
|
|
4970
|
+
var createChangeProposalId = brandedIdFactory();
|
|
4971
|
+
|
|
4900
4972
|
// apps/cli/src/application/useCases/ExecuteSingleFileAstUseCase.ts
|
|
4901
4973
|
var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
4902
4974
|
constructor(linterExecutionUseCase) {
|
|
@@ -4908,8 +4980,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
4908
4980
|
static {
|
|
4909
4981
|
this.fallbackRuleContent = "adhoc-rule";
|
|
4910
4982
|
}
|
|
4911
|
-
async execute(
|
|
4912
|
-
const { program, fileContent, language } =
|
|
4983
|
+
async execute(command20) {
|
|
4984
|
+
const { program, fileContent, language } = command20;
|
|
4913
4985
|
const result = await this.linterExecutionUseCase.execute({
|
|
4914
4986
|
filePath: "cli-single-file",
|
|
4915
4987
|
fileContent,
|
|
@@ -4959,30 +5031,30 @@ var GitService = class {
|
|
|
4959
5031
|
this.gitRunner = gitRunner;
|
|
4960
5032
|
this.logger = logger2;
|
|
4961
5033
|
}
|
|
4962
|
-
getGitRepositoryRoot(
|
|
5034
|
+
getGitRepositoryRoot(path14) {
|
|
4963
5035
|
try {
|
|
4964
5036
|
const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
|
|
4965
|
-
cwd:
|
|
5037
|
+
cwd: path14
|
|
4966
5038
|
});
|
|
4967
5039
|
const gitRoot = stdout.trim();
|
|
4968
5040
|
this.logger.debug("Resolved git repository root", {
|
|
4969
|
-
inputPath:
|
|
5041
|
+
inputPath: path14,
|
|
4970
5042
|
gitRoot
|
|
4971
5043
|
});
|
|
4972
5044
|
return gitRoot;
|
|
4973
5045
|
} catch (error) {
|
|
4974
5046
|
if (error instanceof Error) {
|
|
4975
5047
|
throw new Error(
|
|
4976
|
-
`Failed to get Git repository root. The path '${
|
|
5048
|
+
`Failed to get Git repository root. The path '${path14}' does not appear to be inside a Git repository.
|
|
4977
5049
|
${error.message}`
|
|
4978
5050
|
);
|
|
4979
5051
|
}
|
|
4980
5052
|
throw new Error("Failed to get Git repository root: Unknown error");
|
|
4981
5053
|
}
|
|
4982
5054
|
}
|
|
4983
|
-
tryGetGitRepositoryRoot(
|
|
5055
|
+
tryGetGitRepositoryRoot(path14) {
|
|
4984
5056
|
try {
|
|
4985
|
-
return this.getGitRepositoryRoot(
|
|
5057
|
+
return this.getGitRepositoryRoot(path14);
|
|
4986
5058
|
} catch {
|
|
4987
5059
|
return null;
|
|
4988
5060
|
}
|
|
@@ -5289,8 +5361,8 @@ var GetGitRemoteUrlUseCase = class {
|
|
|
5289
5361
|
constructor(gitRemoteUrlService = new GitService()) {
|
|
5290
5362
|
this.gitRemoteUrlService = gitRemoteUrlService;
|
|
5291
5363
|
}
|
|
5292
|
-
async execute(
|
|
5293
|
-
const { path: repoPath, origin: origin9 } =
|
|
5364
|
+
async execute(command20) {
|
|
5365
|
+
const { path: repoPath, origin: origin9 } = command20;
|
|
5294
5366
|
return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin9);
|
|
5295
5367
|
}
|
|
5296
5368
|
};
|
|
@@ -5432,8 +5504,8 @@ var ListFilesInDirectoryUseCase = class {
|
|
|
5432
5504
|
constructor(listFiles = new ListFiles()) {
|
|
5433
5505
|
this.listFiles = listFiles;
|
|
5434
5506
|
}
|
|
5435
|
-
async execute(
|
|
5436
|
-
const { path: directoryPath, extensions, excludes = [] } =
|
|
5507
|
+
async execute(command20) {
|
|
5508
|
+
const { path: directoryPath, extensions, excludes = [] } = command20;
|
|
5437
5509
|
const files = await this.listFiles.listFilesInDirectory(
|
|
5438
5510
|
directoryPath,
|
|
5439
5511
|
extensions,
|
|
@@ -5527,7 +5599,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5527
5599
|
}
|
|
5528
5600
|
return pattern;
|
|
5529
5601
|
}
|
|
5530
|
-
async execute(
|
|
5602
|
+
async execute(command20) {
|
|
5531
5603
|
const {
|
|
5532
5604
|
path: userPath,
|
|
5533
5605
|
draftMode,
|
|
@@ -5535,7 +5607,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5535
5607
|
ruleId,
|
|
5536
5608
|
language,
|
|
5537
5609
|
diffMode
|
|
5538
|
-
} =
|
|
5610
|
+
} = command20;
|
|
5539
5611
|
this.logger.debug(
|
|
5540
5612
|
`Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
|
|
5541
5613
|
);
|
|
@@ -5707,6 +5779,11 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5707
5779
|
this.logger.debug(
|
|
5708
5780
|
`Retrieved detection programs: targetsCount=${detectionPrograms.targets.length}`
|
|
5709
5781
|
);
|
|
5782
|
+
this.repositories.packmindGateway.linter.trackLinterExecution({
|
|
5783
|
+
targetCount: 1,
|
|
5784
|
+
standardCount: 1
|
|
5785
|
+
}).catch(() => {
|
|
5786
|
+
});
|
|
5710
5787
|
const violations = [];
|
|
5711
5788
|
for (const file of files) {
|
|
5712
5789
|
const fileViolations = [];
|
|
@@ -5848,8 +5925,8 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5848
5925
|
return null;
|
|
5849
5926
|
}
|
|
5850
5927
|
}
|
|
5851
|
-
async executeProgramsForFile(
|
|
5852
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
5928
|
+
async executeProgramsForFile(command20) {
|
|
5929
|
+
const result = await this.services.linterExecutionUseCase.execute(command20);
|
|
5853
5930
|
return result.violations;
|
|
5854
5931
|
}
|
|
5855
5932
|
extractExtensionFromFile(filePath) {
|
|
@@ -5906,8 +5983,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
5906
5983
|
}
|
|
5907
5984
|
return pattern;
|
|
5908
5985
|
}
|
|
5909
|
-
async execute(
|
|
5910
|
-
const { path: userPath, diffMode } =
|
|
5986
|
+
async execute(command20) {
|
|
5987
|
+
const { path: userPath, diffMode } = command20;
|
|
5911
5988
|
this.logger.debug(
|
|
5912
5989
|
`Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
|
|
5913
5990
|
);
|
|
@@ -6084,6 +6161,11 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6084
6161
|
});
|
|
6085
6162
|
}
|
|
6086
6163
|
}
|
|
6164
|
+
this.repositories.packmindGateway.linter.trackLinterExecution({
|
|
6165
|
+
targetCount: allConfigs.configs.length,
|
|
6166
|
+
standardCount: allStandardsChecked.size
|
|
6167
|
+
}).catch(() => {
|
|
6168
|
+
});
|
|
6087
6169
|
let filteredViolations = violations;
|
|
6088
6170
|
if (diffMode === "lines" /* LINES */ && modifiedLines) {
|
|
6089
6171
|
filteredViolations = this.services.diffViolationFilterService.filterByLines(
|
|
@@ -6151,8 +6233,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6151
6233
|
return null;
|
|
6152
6234
|
}
|
|
6153
6235
|
}
|
|
6154
|
-
async executeProgramsForFile(
|
|
6155
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
6236
|
+
async executeProgramsForFile(command20) {
|
|
6237
|
+
const result = await this.services.linterExecutionUseCase.execute(command20);
|
|
6156
6238
|
return result.violations;
|
|
6157
6239
|
}
|
|
6158
6240
|
extractExtensionFromFile(filePath) {
|
|
@@ -6218,10 +6300,10 @@ var PackmindHttpClient = class {
|
|
|
6218
6300
|
return null;
|
|
6219
6301
|
}
|
|
6220
6302
|
}
|
|
6221
|
-
async request(
|
|
6303
|
+
async request(path14, options = {}) {
|
|
6222
6304
|
const { host } = this.getAuthContext();
|
|
6223
6305
|
const { method = "GET", body } = options;
|
|
6224
|
-
const url = `${host}${
|
|
6306
|
+
const url = `${host}${path14}`;
|
|
6225
6307
|
try {
|
|
6226
6308
|
const response = await fetch(url, {
|
|
6227
6309
|
method,
|
|
@@ -6278,13 +6360,13 @@ var CommunityEditionError = class extends Error {
|
|
|
6278
6360
|
var LinterGateway = class {
|
|
6279
6361
|
constructor(httpClient) {
|
|
6280
6362
|
this.httpClient = httpClient;
|
|
6281
|
-
this.getDraftDetectionProgramsForRule = async (
|
|
6363
|
+
this.getDraftDetectionProgramsForRule = async (command20) => {
|
|
6282
6364
|
const payload = {
|
|
6283
|
-
standardSlug:
|
|
6284
|
-
ruleId:
|
|
6365
|
+
standardSlug: command20.standardSlug,
|
|
6366
|
+
ruleId: command20.ruleId
|
|
6285
6367
|
};
|
|
6286
|
-
if (
|
|
6287
|
-
payload.language =
|
|
6368
|
+
if (command20.language) {
|
|
6369
|
+
payload.language = command20.language;
|
|
6288
6370
|
}
|
|
6289
6371
|
return this.httpClient.request("/api/v0/list-draft-detection-program", {
|
|
6290
6372
|
method: "POST",
|
|
@@ -6296,13 +6378,13 @@ var LinterGateway = class {
|
|
|
6296
6378
|
}
|
|
6297
6379
|
});
|
|
6298
6380
|
};
|
|
6299
|
-
this.getActiveDetectionProgramsForRule = async (
|
|
6381
|
+
this.getActiveDetectionProgramsForRule = async (command20) => {
|
|
6300
6382
|
const payload = {
|
|
6301
|
-
standardSlug:
|
|
6302
|
-
ruleId:
|
|
6383
|
+
standardSlug: command20.standardSlug,
|
|
6384
|
+
ruleId: command20.ruleId
|
|
6303
6385
|
};
|
|
6304
|
-
if (
|
|
6305
|
-
payload.language =
|
|
6386
|
+
if (command20.language) {
|
|
6387
|
+
payload.language = command20.language;
|
|
6306
6388
|
}
|
|
6307
6389
|
return this.httpClient.request("/api/v0/list-active-detection-program", {
|
|
6308
6390
|
method: "POST",
|
|
@@ -6314,13 +6396,13 @@ var LinterGateway = class {
|
|
|
6314
6396
|
}
|
|
6315
6397
|
});
|
|
6316
6398
|
};
|
|
6317
|
-
this.getDetectionProgramsForPackages = async (
|
|
6399
|
+
this.getDetectionProgramsForPackages = async (command20) => {
|
|
6318
6400
|
const response = await this.httpClient.request(
|
|
6319
6401
|
"/api/v0/detection-programs-for-packages",
|
|
6320
6402
|
{
|
|
6321
6403
|
method: "POST",
|
|
6322
6404
|
body: {
|
|
6323
|
-
packagesSlugs:
|
|
6405
|
+
packagesSlugs: command20.packagesSlugs
|
|
6324
6406
|
},
|
|
6325
6407
|
onError: (response2) => {
|
|
6326
6408
|
if (response2.status === 404) {
|
|
@@ -6331,6 +6413,12 @@ var LinterGateway = class {
|
|
|
6331
6413
|
);
|
|
6332
6414
|
return handleScopeInTargetsResponse(response);
|
|
6333
6415
|
};
|
|
6416
|
+
this.trackLinterExecution = async (command20) => {
|
|
6417
|
+
return this.httpClient.request(`/api/v0/track-execution`, {
|
|
6418
|
+
method: "POST",
|
|
6419
|
+
body: command20
|
|
6420
|
+
});
|
|
6421
|
+
};
|
|
6334
6422
|
}
|
|
6335
6423
|
};
|
|
6336
6424
|
function handleScopeInTargetsResponse(response) {
|
|
@@ -6386,33 +6474,39 @@ var SpacesGateway = class {
|
|
|
6386
6474
|
var SkillsGateway = class {
|
|
6387
6475
|
constructor(httpClient) {
|
|
6388
6476
|
this.httpClient = httpClient;
|
|
6389
|
-
this.upload = async (
|
|
6477
|
+
this.upload = async (command20) => {
|
|
6390
6478
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6391
6479
|
return this.httpClient.request(
|
|
6392
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6480
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/skills/upload`,
|
|
6393
6481
|
{
|
|
6394
6482
|
method: "POST",
|
|
6395
|
-
body:
|
|
6483
|
+
body: command20
|
|
6396
6484
|
}
|
|
6397
6485
|
);
|
|
6398
6486
|
};
|
|
6399
|
-
this.getDefaults = async (
|
|
6487
|
+
this.getDefaults = async (command20) => {
|
|
6400
6488
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6401
6489
|
const queryParams = new URLSearchParams();
|
|
6402
|
-
if (
|
|
6490
|
+
if (command20.includeBeta) {
|
|
6403
6491
|
queryParams.set("includeBeta", "true");
|
|
6404
|
-
} else if (
|
|
6405
|
-
queryParams.set("cliVersion",
|
|
6492
|
+
} else if (command20.cliVersion) {
|
|
6493
|
+
queryParams.set("cliVersion", command20.cliVersion);
|
|
6494
|
+
}
|
|
6495
|
+
if (command20.agents !== void 0) {
|
|
6496
|
+
queryParams.append("agentsConfigOverride", "true");
|
|
6497
|
+
command20.agents.forEach((agent) => {
|
|
6498
|
+
queryParams.append("agent", agent);
|
|
6499
|
+
});
|
|
6406
6500
|
}
|
|
6407
6501
|
const queryString = queryParams.toString();
|
|
6408
6502
|
return this.httpClient.request(
|
|
6409
6503
|
`/api/v0/organizations/${organizationId}/skills/default${queryString ? `?${queryString}` : ""}`
|
|
6410
6504
|
);
|
|
6411
6505
|
};
|
|
6412
|
-
this.list = async (
|
|
6506
|
+
this.list = async (command20) => {
|
|
6413
6507
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6414
6508
|
return this.httpClient.request(
|
|
6415
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6509
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/skills`
|
|
6416
6510
|
);
|
|
6417
6511
|
};
|
|
6418
6512
|
}
|
|
@@ -6420,25 +6514,24 @@ var SkillsGateway = class {
|
|
|
6420
6514
|
|
|
6421
6515
|
// apps/cli/src/infra/repositories/CommandsGateway.ts
|
|
6422
6516
|
var CommandsGateway = class {
|
|
6423
|
-
constructor(httpClient
|
|
6517
|
+
constructor(httpClient) {
|
|
6424
6518
|
this.httpClient = httpClient;
|
|
6425
|
-
this.
|
|
6426
|
-
this.create = async (spaceId, data) => {
|
|
6519
|
+
this.create = async (command20) => {
|
|
6427
6520
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6428
6521
|
return this.httpClient.request(
|
|
6429
|
-
`/api/v0/organizations/${organizationId}/spaces/${spaceId}/recipes`,
|
|
6430
|
-
{ method: "POST", body:
|
|
6522
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/recipes`,
|
|
6523
|
+
{ method: "POST", body: command20 }
|
|
6431
6524
|
);
|
|
6432
6525
|
};
|
|
6433
|
-
this.list = async () => {
|
|
6434
|
-
const space = await this.spaces.getGlobal();
|
|
6526
|
+
this.list = async (command20) => {
|
|
6435
6527
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6436
|
-
const
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
}
|
|
6528
|
+
const listRecipesResponse = await this.httpClient.request(
|
|
6529
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/recipes`
|
|
6530
|
+
);
|
|
6531
|
+
if (listRecipesResponse instanceof Array) {
|
|
6532
|
+
return { recipes: listRecipesResponse };
|
|
6533
|
+
}
|
|
6534
|
+
return listRecipesResponse;
|
|
6442
6535
|
};
|
|
6443
6536
|
}
|
|
6444
6537
|
};
|
|
@@ -6475,374 +6568,107 @@ var StandardsGateway = class {
|
|
|
6475
6568
|
}
|
|
6476
6569
|
);
|
|
6477
6570
|
};
|
|
6478
|
-
this.list = async () => {
|
|
6479
|
-
const space = await this.spaces.getGlobal();
|
|
6571
|
+
this.list = async (command20) => {
|
|
6480
6572
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
slug: s.slug,
|
|
6485
|
-
name: s.name,
|
|
6486
|
-
description: s.description
|
|
6487
|
-
}));
|
|
6573
|
+
return this.httpClient.request(
|
|
6574
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/standards`
|
|
6575
|
+
);
|
|
6488
6576
|
};
|
|
6489
6577
|
}
|
|
6490
6578
|
};
|
|
6491
6579
|
|
|
6492
6580
|
// apps/cli/src/infra/repositories/PackagesGateway.ts
|
|
6493
|
-
function decodeJwt(jwt) {
|
|
6494
|
-
try {
|
|
6495
|
-
const parts = jwt.split(".");
|
|
6496
|
-
if (parts.length !== 3) {
|
|
6497
|
-
return null;
|
|
6498
|
-
}
|
|
6499
|
-
const payload = JSON.parse(
|
|
6500
|
-
Buffer.from(parts[1], "base64").toString("utf-8")
|
|
6501
|
-
);
|
|
6502
|
-
return payload;
|
|
6503
|
-
} catch {
|
|
6504
|
-
return null;
|
|
6505
|
-
}
|
|
6506
|
-
}
|
|
6507
|
-
function decodeApiKey(apiKey) {
|
|
6508
|
-
if (!apiKey) {
|
|
6509
|
-
return {
|
|
6510
|
-
payload: { host: "", jwt: "" },
|
|
6511
|
-
isValid: false,
|
|
6512
|
-
error: "NOT_LOGGED_IN"
|
|
6513
|
-
};
|
|
6514
|
-
}
|
|
6515
|
-
try {
|
|
6516
|
-
const trimmedKey = apiKey.trim();
|
|
6517
|
-
const jsonString = Buffer.from(trimmedKey, "base64").toString("utf-8");
|
|
6518
|
-
const payload = JSON.parse(jsonString);
|
|
6519
|
-
if (!payload.host || typeof payload.host !== "string") {
|
|
6520
|
-
return {
|
|
6521
|
-
payload,
|
|
6522
|
-
isValid: false,
|
|
6523
|
-
error: "Invalid API key: missing or invalid host field"
|
|
6524
|
-
};
|
|
6525
|
-
}
|
|
6526
|
-
if (!payload.jwt || typeof payload.jwt !== "string") {
|
|
6527
|
-
return {
|
|
6528
|
-
payload,
|
|
6529
|
-
isValid: false,
|
|
6530
|
-
error: "Invalid API key: missing or invalid jwt field"
|
|
6531
|
-
};
|
|
6532
|
-
}
|
|
6533
|
-
return {
|
|
6534
|
-
payload,
|
|
6535
|
-
isValid: true
|
|
6536
|
-
};
|
|
6537
|
-
} catch (error) {
|
|
6538
|
-
return {
|
|
6539
|
-
payload: { host: "", jwt: "" },
|
|
6540
|
-
isValid: false,
|
|
6541
|
-
error: `Failed to decode API key: ${error}`
|
|
6542
|
-
};
|
|
6543
|
-
}
|
|
6544
|
-
}
|
|
6545
6581
|
var PackagesGateway = class {
|
|
6546
6582
|
constructor(apiKey, httpClient) {
|
|
6547
6583
|
this.apiKey = apiKey;
|
|
6548
6584
|
this.httpClient = httpClient;
|
|
6549
6585
|
this.list = async () => {
|
|
6550
|
-
const
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
}
|
|
6555
|
-
throw new Error(`Invalid API key: ${decodedApiKey.error}`);
|
|
6556
|
-
}
|
|
6557
|
-
const { host, jwt } = decodedApiKey.payload;
|
|
6558
|
-
const jwtPayload = decodeJwt(jwt);
|
|
6559
|
-
if (!jwtPayload?.organization?.id) {
|
|
6560
|
-
throw new Error("Invalid API key: missing organizationId in JWT");
|
|
6561
|
-
}
|
|
6562
|
-
const organizationId = jwtPayload.organization.id;
|
|
6563
|
-
const url = `${host}/api/v0/organizations/${organizationId}/packages`;
|
|
6564
|
-
try {
|
|
6565
|
-
const response = await fetch(url, {
|
|
6566
|
-
method: "GET",
|
|
6567
|
-
headers: {
|
|
6568
|
-
"Content-Type": "application/json",
|
|
6569
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6570
|
-
}
|
|
6571
|
-
});
|
|
6572
|
-
if (!response.ok) {
|
|
6573
|
-
let errorMsg = `API request failed: ${response.status} ${response.statusText}`;
|
|
6574
|
-
try {
|
|
6575
|
-
const errorBody = await response.json();
|
|
6576
|
-
if (errorBody && errorBody.message) {
|
|
6577
|
-
errorMsg = `${errorBody.message}`;
|
|
6578
|
-
}
|
|
6579
|
-
} catch {
|
|
6580
|
-
}
|
|
6581
|
-
const error = new Error(errorMsg);
|
|
6582
|
-
error.statusCode = response.status;
|
|
6583
|
-
throw error;
|
|
6584
|
-
}
|
|
6585
|
-
const result = await response.json();
|
|
6586
|
-
return result.packages;
|
|
6587
|
-
} catch (error) {
|
|
6588
|
-
const err = error;
|
|
6589
|
-
const code = err?.code || err?.cause?.code;
|
|
6590
|
-
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"))) {
|
|
6591
|
-
throw new Error(
|
|
6592
|
-
`Packmind server is not accessible at ${host}. Please check your network connection or the server URL.`
|
|
6593
|
-
);
|
|
6594
|
-
}
|
|
6595
|
-
throw new Error(
|
|
6596
|
-
`Failed to list packages: Error: ${err?.message || JSON.stringify(error)}`
|
|
6597
|
-
);
|
|
6598
|
-
}
|
|
6586
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6587
|
+
return this.httpClient.request(
|
|
6588
|
+
`/api/v0/organizations/${organizationId}/packages`
|
|
6589
|
+
);
|
|
6599
6590
|
};
|
|
6600
|
-
this.getSummary = async ({
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
throw new Error("Invalid API key: missing organizationId in JWT");
|
|
6614
|
-
}
|
|
6615
|
-
const organizationId = jwtPayload.organization.id;
|
|
6616
|
-
const url = `${host}/api/v0/organizations/${organizationId}/packages/${encodeURIComponent(slug)}`;
|
|
6617
|
-
try {
|
|
6618
|
-
const response = await fetch(url, {
|
|
6619
|
-
method: "GET",
|
|
6620
|
-
headers: {
|
|
6621
|
-
"Content-Type": "application/json",
|
|
6622
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6623
|
-
}
|
|
6624
|
-
});
|
|
6625
|
-
if (!response.ok) {
|
|
6626
|
-
let errorMsg = `API request failed: ${response.status} ${response.statusText}`;
|
|
6627
|
-
try {
|
|
6628
|
-
const errorBody = await response.json();
|
|
6629
|
-
if (errorBody && errorBody.message) {
|
|
6630
|
-
errorMsg = `${errorBody.message}`;
|
|
6631
|
-
}
|
|
6632
|
-
} catch {
|
|
6633
|
-
}
|
|
6634
|
-
const error = new Error(errorMsg);
|
|
6635
|
-
error.statusCode = response.status;
|
|
6636
|
-
throw error;
|
|
6637
|
-
}
|
|
6638
|
-
const result = await response.json();
|
|
6639
|
-
return result;
|
|
6640
|
-
} catch (error) {
|
|
6641
|
-
const err = error;
|
|
6642
|
-
const code = err?.code || err?.cause?.code;
|
|
6643
|
-
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"))) {
|
|
6644
|
-
throw new Error(
|
|
6645
|
-
`Packmind server is not accessible at ${host}. Please check your network connection or the server URL.`
|
|
6646
|
-
);
|
|
6591
|
+
this.getSummary = async ({ slug }) => {
|
|
6592
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6593
|
+
return this.httpClient.request(
|
|
6594
|
+
`/api/v0/organizations/${organizationId}/packages/${encodeURIComponent(slug)}`
|
|
6595
|
+
);
|
|
6596
|
+
};
|
|
6597
|
+
this.create = async (command20) => {
|
|
6598
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6599
|
+
return this.httpClient.request(
|
|
6600
|
+
`/api/v0/organizations/${organizationId}/spaces/${command20.spaceId}/packages`,
|
|
6601
|
+
{
|
|
6602
|
+
method: "POST",
|
|
6603
|
+
body: command20
|
|
6647
6604
|
}
|
|
6648
|
-
|
|
6649
|
-
`Failed to get package '${slug}': Error: ${err?.message || JSON.stringify(error)}`
|
|
6650
|
-
);
|
|
6651
|
-
}
|
|
6605
|
+
);
|
|
6652
6606
|
};
|
|
6653
|
-
this.
|
|
6607
|
+
this.addArtefacts = async (command20) => {
|
|
6654
6608
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6655
|
-
const
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6609
|
+
const { packageId, spaceId } = command20;
|
|
6610
|
+
return this.httpClient.request(
|
|
6611
|
+
`/api/v0/organizations/${organizationId}/spaces/${spaceId}/packages/${packageId}/add-artifacts`,
|
|
6612
|
+
{
|
|
6613
|
+
method: "POST",
|
|
6614
|
+
body: command20
|
|
6615
|
+
}
|
|
6616
|
+
);
|
|
6660
6617
|
};
|
|
6661
6618
|
}
|
|
6662
6619
|
};
|
|
6663
6620
|
|
|
6664
6621
|
// apps/cli/src/infra/repositories/DeploymentGateway.ts
|
|
6665
|
-
function decodeJwt2(jwt) {
|
|
6666
|
-
try {
|
|
6667
|
-
const parts = jwt.split(".");
|
|
6668
|
-
if (parts.length !== 3) {
|
|
6669
|
-
return null;
|
|
6670
|
-
}
|
|
6671
|
-
const payload = JSON.parse(
|
|
6672
|
-
Buffer.from(parts[1], "base64").toString("utf-8")
|
|
6673
|
-
);
|
|
6674
|
-
return payload;
|
|
6675
|
-
} catch {
|
|
6676
|
-
return null;
|
|
6677
|
-
}
|
|
6678
|
-
}
|
|
6679
|
-
function decodeApiKey2(apiKey) {
|
|
6680
|
-
if (!apiKey) {
|
|
6681
|
-
return {
|
|
6682
|
-
payload: { host: "", jwt: "" },
|
|
6683
|
-
isValid: false,
|
|
6684
|
-
error: "NOT_LOGGED_IN"
|
|
6685
|
-
};
|
|
6686
|
-
}
|
|
6687
|
-
try {
|
|
6688
|
-
const trimmedKey = apiKey.trim();
|
|
6689
|
-
const jsonString = Buffer.from(trimmedKey, "base64").toString("utf-8");
|
|
6690
|
-
const payload = JSON.parse(jsonString);
|
|
6691
|
-
if (!payload.host || typeof payload.host !== "string") {
|
|
6692
|
-
return {
|
|
6693
|
-
payload,
|
|
6694
|
-
isValid: false,
|
|
6695
|
-
error: "Invalid API key: missing or invalid host field"
|
|
6696
|
-
};
|
|
6697
|
-
}
|
|
6698
|
-
if (!payload.jwt || typeof payload.jwt !== "string") {
|
|
6699
|
-
return {
|
|
6700
|
-
payload,
|
|
6701
|
-
isValid: false,
|
|
6702
|
-
error: "Invalid API key: missing or invalid jwt field"
|
|
6703
|
-
};
|
|
6704
|
-
}
|
|
6705
|
-
return {
|
|
6706
|
-
payload,
|
|
6707
|
-
isValid: true
|
|
6708
|
-
};
|
|
6709
|
-
} catch (error) {
|
|
6710
|
-
return {
|
|
6711
|
-
payload: { host: "", jwt: "" },
|
|
6712
|
-
isValid: false,
|
|
6713
|
-
error: `Failed to decode API key: ${error}`
|
|
6714
|
-
};
|
|
6715
|
-
}
|
|
6716
|
-
}
|
|
6717
6622
|
var DeploymentGateway = class {
|
|
6718
|
-
constructor(
|
|
6719
|
-
this.
|
|
6720
|
-
this.pull = async (
|
|
6721
|
-
const
|
|
6722
|
-
if (!decodedApiKey.isValid) {
|
|
6723
|
-
if (decodedApiKey.error === "NOT_LOGGED_IN") {
|
|
6724
|
-
throw new NotLoggedInError();
|
|
6725
|
-
}
|
|
6726
|
-
throw new Error(`Invalid API key: ${decodedApiKey.error}`);
|
|
6727
|
-
}
|
|
6728
|
-
const { host, jwt } = decodedApiKey.payload;
|
|
6729
|
-
const jwtPayload = decodeJwt2(jwt);
|
|
6730
|
-
if (!jwtPayload?.organization?.id) {
|
|
6731
|
-
throw new Error("Invalid API key: missing organizationId in JWT");
|
|
6732
|
-
}
|
|
6733
|
-
const organizationId = jwtPayload.organization.id;
|
|
6623
|
+
constructor(httpClient) {
|
|
6624
|
+
this.httpClient = httpClient;
|
|
6625
|
+
this.pull = async (command20) => {
|
|
6626
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6734
6627
|
const queryParams = new URLSearchParams();
|
|
6735
|
-
if (
|
|
6736
|
-
|
|
6628
|
+
if (command20.packagesSlugs && command20.packagesSlugs.length > 0) {
|
|
6629
|
+
command20.packagesSlugs.forEach((slug) => {
|
|
6737
6630
|
queryParams.append("packageSlug", slug);
|
|
6738
6631
|
});
|
|
6739
6632
|
}
|
|
6740
|
-
if (
|
|
6741
|
-
|
|
6633
|
+
if (command20.previousPackagesSlugs && command20.previousPackagesSlugs.length > 0) {
|
|
6634
|
+
command20.previousPackagesSlugs.forEach((slug) => {
|
|
6742
6635
|
queryParams.append("previousPackageSlug", slug);
|
|
6743
6636
|
});
|
|
6744
6637
|
}
|
|
6745
|
-
if (
|
|
6746
|
-
queryParams.append("gitRemoteUrl",
|
|
6638
|
+
if (command20.gitRemoteUrl) {
|
|
6639
|
+
queryParams.append("gitRemoteUrl", command20.gitRemoteUrl);
|
|
6747
6640
|
}
|
|
6748
|
-
if (
|
|
6749
|
-
queryParams.append("gitBranch",
|
|
6641
|
+
if (command20.gitBranch) {
|
|
6642
|
+
queryParams.append("gitBranch", command20.gitBranch);
|
|
6750
6643
|
}
|
|
6751
|
-
if (
|
|
6752
|
-
queryParams.append("relativePath",
|
|
6644
|
+
if (command20.relativePath) {
|
|
6645
|
+
queryParams.append("relativePath", command20.relativePath);
|
|
6753
6646
|
}
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
headers: {
|
|
6759
|
-
"Content-Type": "application/json",
|
|
6760
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6761
|
-
}
|
|
6647
|
+
if (command20.agents !== void 0) {
|
|
6648
|
+
queryParams.append("agentsConfigOverride", "true");
|
|
6649
|
+
command20.agents.forEach((agent) => {
|
|
6650
|
+
queryParams.append("agent", agent);
|
|
6762
6651
|
});
|
|
6763
|
-
if (!response.ok) {
|
|
6764
|
-
let errorMsg = `API request failed: ${response.status} ${response.statusText}`;
|
|
6765
|
-
try {
|
|
6766
|
-
const errorBody = await response.json();
|
|
6767
|
-
if (errorBody && errorBody.message) {
|
|
6768
|
-
errorMsg = `${errorBody.message}`;
|
|
6769
|
-
}
|
|
6770
|
-
} catch {
|
|
6771
|
-
}
|
|
6772
|
-
const error = new Error(errorMsg);
|
|
6773
|
-
error.statusCode = response.status;
|
|
6774
|
-
throw error;
|
|
6775
|
-
}
|
|
6776
|
-
const result = await response.json();
|
|
6777
|
-
return result;
|
|
6778
|
-
} catch (error) {
|
|
6779
|
-
const err = error;
|
|
6780
|
-
const code = err?.code || err?.cause?.code;
|
|
6781
|
-
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"))) {
|
|
6782
|
-
throw new Error(
|
|
6783
|
-
`Packmind server is not accessible at ${host}. Please check your network connection or the server URL.`
|
|
6784
|
-
);
|
|
6785
|
-
}
|
|
6786
|
-
throw new Error(
|
|
6787
|
-
`Failed to fetch content: Error: ${err?.message || JSON.stringify(error)}`
|
|
6788
|
-
);
|
|
6789
6652
|
}
|
|
6653
|
+
return this.httpClient.request(
|
|
6654
|
+
`/api/v0/organizations/${organizationId}/pull?${queryParams.toString()}`
|
|
6655
|
+
);
|
|
6790
6656
|
};
|
|
6791
|
-
this.notifyDistribution = async (
|
|
6792
|
-
const
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
}
|
|
6797
|
-
throw new Error(`Invalid API key: ${decodedApiKey.error}`);
|
|
6798
|
-
}
|
|
6799
|
-
const { host, jwt } = decodedApiKey.payload;
|
|
6800
|
-
const jwtPayload = decodeJwt2(jwt);
|
|
6801
|
-
if (!jwtPayload?.organization?.id) {
|
|
6802
|
-
throw new Error("Invalid API key: missing organizationId in JWT");
|
|
6803
|
-
}
|
|
6804
|
-
const organizationId = jwtPayload.organization.id;
|
|
6805
|
-
const url = `${host}/api/v0/organizations/${organizationId}/deployments`;
|
|
6806
|
-
const payload = {
|
|
6807
|
-
distributedPackages: params.distributedPackages,
|
|
6808
|
-
gitRemoteUrl: params.gitRemoteUrl,
|
|
6809
|
-
gitBranch: params.gitBranch,
|
|
6810
|
-
relativePath: params.relativePath
|
|
6811
|
-
};
|
|
6812
|
-
try {
|
|
6813
|
-
const response = await fetch(url, {
|
|
6657
|
+
this.notifyDistribution = async (command20) => {
|
|
6658
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6659
|
+
return this.httpClient.request(
|
|
6660
|
+
`/api/v0/organizations/${organizationId}/deployments`,
|
|
6661
|
+
{
|
|
6814
6662
|
method: "POST",
|
|
6815
|
-
|
|
6816
|
-
"Content-Type": "application/json",
|
|
6817
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6818
|
-
},
|
|
6819
|
-
body: JSON.stringify(payload)
|
|
6820
|
-
});
|
|
6821
|
-
if (!response.ok) {
|
|
6822
|
-
let errorMsg = `API request failed: ${response.status} ${response.statusText}`;
|
|
6823
|
-
try {
|
|
6824
|
-
const errorBody = await response.json();
|
|
6825
|
-
if (errorBody && errorBody.message) {
|
|
6826
|
-
errorMsg = `${errorBody.message}`;
|
|
6827
|
-
}
|
|
6828
|
-
} catch {
|
|
6829
|
-
}
|
|
6830
|
-
throw new Error(errorMsg);
|
|
6831
|
-
}
|
|
6832
|
-
const result = await response.json();
|
|
6833
|
-
return result;
|
|
6834
|
-
} catch (error) {
|
|
6835
|
-
const err = error;
|
|
6836
|
-
const code = err?.code || err?.cause?.code;
|
|
6837
|
-
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"))) {
|
|
6838
|
-
throw new Error(
|
|
6839
|
-
`Packmind server is not accessible at ${host}. Please check your network connection or the server URL.`
|
|
6840
|
-
);
|
|
6663
|
+
body: command20
|
|
6841
6664
|
}
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
}
|
|
6665
|
+
);
|
|
6666
|
+
};
|
|
6667
|
+
this.getRenderModeConfiguration = async () => {
|
|
6668
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6669
|
+
return this.httpClient.request(
|
|
6670
|
+
`/api/v0/organizations/${organizationId}/deployments/renderModeConfiguration`
|
|
6671
|
+
);
|
|
6846
6672
|
};
|
|
6847
6673
|
}
|
|
6848
6674
|
};
|
|
@@ -6856,10 +6682,10 @@ var PackmindGateway = class {
|
|
|
6856
6682
|
this.mcp = new McpGateway(this.httpClient);
|
|
6857
6683
|
this.spaces = new SpacesGateway(this.httpClient);
|
|
6858
6684
|
this.skills = new SkillsGateway(this.httpClient);
|
|
6859
|
-
this.commands = new CommandsGateway(this.httpClient
|
|
6685
|
+
this.commands = new CommandsGateway(this.httpClient);
|
|
6860
6686
|
this.standards = new StandardsGateway(this.httpClient, this.spaces);
|
|
6861
6687
|
this.packages = new PackagesGateway(apiKey, this.httpClient);
|
|
6862
|
-
this.deployment = new DeploymentGateway(
|
|
6688
|
+
this.deployment = new DeploymentGateway(this.httpClient);
|
|
6863
6689
|
}
|
|
6864
6690
|
};
|
|
6865
6691
|
|
|
@@ -8603,8 +8429,8 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8603
8429
|
this.linterAstAdapter = linterAstAdapter;
|
|
8604
8430
|
this.logger = logger2;
|
|
8605
8431
|
}
|
|
8606
|
-
async execute(
|
|
8607
|
-
const { filePath, fileContent, language, programs } =
|
|
8432
|
+
async execute(command20) {
|
|
8433
|
+
const { filePath, fileContent, language, programs } = command20;
|
|
8608
8434
|
if (programs.length === 0) {
|
|
8609
8435
|
return {
|
|
8610
8436
|
file: filePath,
|
|
@@ -9281,8 +9107,8 @@ var InstallPackagesUseCase = class {
|
|
|
9281
9107
|
constructor(packmindGateway) {
|
|
9282
9108
|
this.packmindGateway = packmindGateway;
|
|
9283
9109
|
}
|
|
9284
|
-
async execute(
|
|
9285
|
-
const baseDirectory =
|
|
9110
|
+
async execute(command20) {
|
|
9111
|
+
const baseDirectory = command20.baseDirectory || process.cwd();
|
|
9286
9112
|
const result = {
|
|
9287
9113
|
filesCreated: 0,
|
|
9288
9114
|
filesUpdated: 0,
|
|
@@ -9294,14 +9120,18 @@ var InstallPackagesUseCase = class {
|
|
|
9294
9120
|
skillDirectoriesDeleted: 0
|
|
9295
9121
|
};
|
|
9296
9122
|
const response = await this.packmindGateway.deployment.pull({
|
|
9297
|
-
packagesSlugs:
|
|
9298
|
-
previousPackagesSlugs:
|
|
9299
|
-
gitRemoteUrl:
|
|
9300
|
-
gitBranch:
|
|
9301
|
-
relativePath:
|
|
9123
|
+
packagesSlugs: command20.packagesSlugs,
|
|
9124
|
+
previousPackagesSlugs: command20.previousPackagesSlugs,
|
|
9125
|
+
gitRemoteUrl: command20.gitRemoteUrl,
|
|
9126
|
+
gitBranch: command20.gitBranch,
|
|
9127
|
+
relativePath: command20.relativePath,
|
|
9128
|
+
agents: command20.agents
|
|
9302
9129
|
});
|
|
9130
|
+
const filteredCreateOrUpdate = response.fileUpdates.createOrUpdate.filter(
|
|
9131
|
+
(file) => file.path !== "packmind.json"
|
|
9132
|
+
);
|
|
9303
9133
|
const uniqueFilesMap = /* @__PURE__ */ new Map();
|
|
9304
|
-
for (const file of
|
|
9134
|
+
for (const file of filteredCreateOrUpdate) {
|
|
9305
9135
|
uniqueFilesMap.set(file.path, file);
|
|
9306
9136
|
}
|
|
9307
9137
|
const uniqueFiles = Array.from(uniqueFilesMap.values());
|
|
@@ -9361,7 +9191,8 @@ var InstallPackagesUseCase = class {
|
|
|
9361
9191
|
fullPath,
|
|
9362
9192
|
file.sections,
|
|
9363
9193
|
fileExists,
|
|
9364
|
-
result
|
|
9194
|
+
result,
|
|
9195
|
+
baseDirectory
|
|
9365
9196
|
);
|
|
9366
9197
|
}
|
|
9367
9198
|
}
|
|
@@ -9398,7 +9229,7 @@ var InstallPackagesUseCase = class {
|
|
|
9398
9229
|
result.filesCreated++;
|
|
9399
9230
|
}
|
|
9400
9231
|
}
|
|
9401
|
-
async handleSectionsUpdate(fullPath, sections, fileExists, result) {
|
|
9232
|
+
async handleSectionsUpdate(fullPath, sections, fileExists, result, baseDirectory) {
|
|
9402
9233
|
let currentContent = "";
|
|
9403
9234
|
if (fileExists) {
|
|
9404
9235
|
currentContent = await fs4.readFile(fullPath, "utf-8");
|
|
@@ -9411,6 +9242,7 @@ var InstallPackagesUseCase = class {
|
|
|
9411
9242
|
if (this.isEffectivelyEmpty(mergedContent) && fileExists) {
|
|
9412
9243
|
await fs4.unlink(fullPath);
|
|
9413
9244
|
result.filesDeleted++;
|
|
9245
|
+
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
9414
9246
|
} else {
|
|
9415
9247
|
await fs4.writeFile(fullPath, mergedContent, "utf-8");
|
|
9416
9248
|
if (fileExists) {
|
|
@@ -9427,9 +9259,11 @@ var InstallPackagesUseCase = class {
|
|
|
9427
9259
|
if (stat4?.isDirectory()) {
|
|
9428
9260
|
await fs4.rm(fullPath, { recursive: true, force: true });
|
|
9429
9261
|
result.filesDeleted++;
|
|
9262
|
+
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
9430
9263
|
} else if (stat4?.isFile()) {
|
|
9431
9264
|
await fs4.unlink(fullPath);
|
|
9432
9265
|
result.filesDeleted++;
|
|
9266
|
+
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
9433
9267
|
}
|
|
9434
9268
|
}
|
|
9435
9269
|
async fileExists(filePath) {
|
|
@@ -9509,6 +9343,7 @@ ${endMarker}`;
|
|
|
9509
9343
|
const fileCount = await this.countFilesInDirectory(fullPath);
|
|
9510
9344
|
await fs4.rm(fullPath, { recursive: true, force: true });
|
|
9511
9345
|
deletedFilesCount += fileCount;
|
|
9346
|
+
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
9512
9347
|
} catch {
|
|
9513
9348
|
}
|
|
9514
9349
|
}
|
|
@@ -9530,26 +9365,60 @@ ${endMarker}`;
|
|
|
9530
9365
|
}
|
|
9531
9366
|
return count;
|
|
9532
9367
|
}
|
|
9368
|
+
/**
|
|
9369
|
+
* Checks if a directory is empty (has no entries).
|
|
9370
|
+
*/
|
|
9371
|
+
async isDirectoryEmpty(dirPath) {
|
|
9372
|
+
try {
|
|
9373
|
+
const entries = await fs4.readdir(dirPath);
|
|
9374
|
+
return entries.length === 0;
|
|
9375
|
+
} catch {
|
|
9376
|
+
return false;
|
|
9377
|
+
}
|
|
9378
|
+
}
|
|
9379
|
+
/**
|
|
9380
|
+
* Removes empty parent directories from fullPath up to (but not including) baseDirectory.
|
|
9381
|
+
* Stops when encountering a non-empty directory or reaching baseDirectory.
|
|
9382
|
+
*/
|
|
9383
|
+
async removeEmptyParentDirectories(fullPath, baseDirectory) {
|
|
9384
|
+
const normalizedBase = path5.resolve(baseDirectory);
|
|
9385
|
+
let currentDir = path5.dirname(path5.resolve(fullPath));
|
|
9386
|
+
while (currentDir.startsWith(normalizedBase + path5.sep) && currentDir !== normalizedBase) {
|
|
9387
|
+
const isEmpty = await this.isDirectoryEmpty(currentDir);
|
|
9388
|
+
if (!isEmpty) break;
|
|
9389
|
+
try {
|
|
9390
|
+
await fs4.rmdir(currentDir);
|
|
9391
|
+
} catch {
|
|
9392
|
+
break;
|
|
9393
|
+
}
|
|
9394
|
+
currentDir = path5.dirname(currentDir);
|
|
9395
|
+
}
|
|
9396
|
+
}
|
|
9533
9397
|
};
|
|
9534
9398
|
|
|
9535
9399
|
// apps/cli/src/application/useCases/InstallDefaultSkillsUseCase.ts
|
|
9536
9400
|
var fs5 = __toESM(require("fs/promises"));
|
|
9537
9401
|
var path6 = __toESM(require("path"));
|
|
9538
9402
|
var InstallDefaultSkillsUseCase = class {
|
|
9539
|
-
constructor(
|
|
9540
|
-
this.
|
|
9403
|
+
constructor(repositories) {
|
|
9404
|
+
this.repositories = repositories;
|
|
9541
9405
|
}
|
|
9542
|
-
async execute(
|
|
9543
|
-
const baseDirectory =
|
|
9406
|
+
async execute(command20) {
|
|
9407
|
+
const baseDirectory = command20.baseDirectory || process.cwd();
|
|
9544
9408
|
const result = {
|
|
9545
9409
|
filesCreated: 0,
|
|
9546
9410
|
filesUpdated: 0,
|
|
9547
9411
|
errors: []
|
|
9548
9412
|
};
|
|
9549
|
-
const
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9413
|
+
const config = await this.repositories.configFileRepository.readConfig(baseDirectory);
|
|
9414
|
+
const agents = config?.agents;
|
|
9415
|
+
const response = await this.repositories.packmindGateway.skills.getDefaults(
|
|
9416
|
+
{
|
|
9417
|
+
cliVersion: command20.cliVersion,
|
|
9418
|
+
includeBeta: command20.includeBeta,
|
|
9419
|
+
agents
|
|
9420
|
+
}
|
|
9421
|
+
);
|
|
9553
9422
|
try {
|
|
9554
9423
|
for (const file of response.fileUpdates.createOrUpdate) {
|
|
9555
9424
|
try {
|
|
@@ -9601,7 +9470,8 @@ var ListPackagesUseCase = class {
|
|
|
9601
9470
|
this.packmindGateway = packmindGateway;
|
|
9602
9471
|
}
|
|
9603
9472
|
async execute() {
|
|
9604
|
-
|
|
9473
|
+
const listPackagesResponse = await this.packmindGateway.packages.list({});
|
|
9474
|
+
return listPackagesResponse.packages;
|
|
9605
9475
|
}
|
|
9606
9476
|
};
|
|
9607
9477
|
|
|
@@ -9610,8 +9480,8 @@ var GetPackageSummaryUseCase = class {
|
|
|
9610
9480
|
constructor(gateway) {
|
|
9611
9481
|
this.gateway = gateway;
|
|
9612
9482
|
}
|
|
9613
|
-
async execute(
|
|
9614
|
-
return this.gateway.packages.getSummary(
|
|
9483
|
+
async execute(command20) {
|
|
9484
|
+
return this.gateway.packages.getSummary(command20);
|
|
9615
9485
|
}
|
|
9616
9486
|
};
|
|
9617
9487
|
|
|
@@ -9621,7 +9491,7 @@ var import_open = __toESM(require("open"));
|
|
|
9621
9491
|
var readline = __toESM(require("readline"));
|
|
9622
9492
|
|
|
9623
9493
|
// apps/cli/src/infra/utils/credentials/decodeApiKey.ts
|
|
9624
|
-
function
|
|
9494
|
+
function decodeApiKey(apiKey) {
|
|
9625
9495
|
try {
|
|
9626
9496
|
const jsonString = Buffer.from(apiKey.trim(), "base64").toString("utf-8");
|
|
9627
9497
|
const apiKeyPayload = JSON.parse(jsonString);
|
|
@@ -9655,7 +9525,7 @@ var EnvCredentialsProvider = class {
|
|
|
9655
9525
|
if (!apiKey) {
|
|
9656
9526
|
return null;
|
|
9657
9527
|
}
|
|
9658
|
-
const decoded =
|
|
9528
|
+
const decoded = decodeApiKey(apiKey);
|
|
9659
9529
|
if (!decoded) {
|
|
9660
9530
|
return null;
|
|
9661
9531
|
}
|
|
@@ -9707,7 +9577,7 @@ var FileCredentialsProvider = class {
|
|
|
9707
9577
|
if (!credentials.apiKey) {
|
|
9708
9578
|
return null;
|
|
9709
9579
|
}
|
|
9710
|
-
const decoded =
|
|
9580
|
+
const decoded = decodeApiKey(credentials.apiKey);
|
|
9711
9581
|
if (!decoded) {
|
|
9712
9582
|
return null;
|
|
9713
9583
|
}
|
|
@@ -9802,10 +9672,10 @@ async function defaultPromptForCode() {
|
|
|
9802
9672
|
input: process.stdin,
|
|
9803
9673
|
output: process.stdout
|
|
9804
9674
|
});
|
|
9805
|
-
return new Promise((
|
|
9675
|
+
return new Promise((resolve7) => {
|
|
9806
9676
|
rl.question("Enter the login code from the browser: ", (answer) => {
|
|
9807
9677
|
rl.close();
|
|
9808
|
-
|
|
9678
|
+
resolve7(answer.trim());
|
|
9809
9679
|
});
|
|
9810
9680
|
});
|
|
9811
9681
|
}
|
|
@@ -9839,7 +9709,7 @@ async function defaultExchangeCodeForApiKey(code, host) {
|
|
|
9839
9709
|
return await response.json();
|
|
9840
9710
|
}
|
|
9841
9711
|
function defaultStartCallbackServer() {
|
|
9842
|
-
return new Promise((
|
|
9712
|
+
return new Promise((resolve7, reject) => {
|
|
9843
9713
|
let timeoutId = null;
|
|
9844
9714
|
const server = http.createServer((req, res) => {
|
|
9845
9715
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
@@ -9852,7 +9722,7 @@ function defaultStartCallbackServer() {
|
|
|
9852
9722
|
if (timeoutId) {
|
|
9853
9723
|
clearTimeout(timeoutId);
|
|
9854
9724
|
}
|
|
9855
|
-
|
|
9725
|
+
resolve7(code);
|
|
9856
9726
|
setImmediate(() => {
|
|
9857
9727
|
server.close();
|
|
9858
9728
|
});
|
|
@@ -9890,8 +9760,8 @@ var LoginUseCase = class {
|
|
|
9890
9760
|
startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
|
|
9891
9761
|
};
|
|
9892
9762
|
}
|
|
9893
|
-
async execute(
|
|
9894
|
-
const { host, code: providedCode } =
|
|
9763
|
+
async execute(command20) {
|
|
9764
|
+
const { host, code: providedCode } = command20;
|
|
9895
9765
|
let code;
|
|
9896
9766
|
if (providedCode) {
|
|
9897
9767
|
code = providedCode;
|
|
@@ -9929,8 +9799,8 @@ var LogoutUseCase = class {
|
|
|
9929
9799
|
constructor(deps) {
|
|
9930
9800
|
this.deps = {
|
|
9931
9801
|
getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
|
|
9932
|
-
fileExists: deps?.fileExists ?? ((
|
|
9933
|
-
deleteFile: deps?.deleteFile ?? ((
|
|
9802
|
+
fileExists: deps?.fileExists ?? ((path14) => fs7.existsSync(path14)),
|
|
9803
|
+
deleteFile: deps?.deleteFile ?? ((path14) => fs7.unlinkSync(path14)),
|
|
9934
9804
|
hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
|
|
9935
9805
|
};
|
|
9936
9806
|
}
|
|
@@ -9990,8 +9860,8 @@ var SetupMcpUseCase = class {
|
|
|
9990
9860
|
constructor(deps) {
|
|
9991
9861
|
this.deps = deps;
|
|
9992
9862
|
}
|
|
9993
|
-
async execute(
|
|
9994
|
-
const { agentTypes } =
|
|
9863
|
+
async execute(command20) {
|
|
9864
|
+
const { agentTypes } = command20;
|
|
9995
9865
|
const [tokenResult, urlResult] = await Promise.all([
|
|
9996
9866
|
this.deps.gateway.mcp.getToken({}),
|
|
9997
9867
|
this.deps.gateway.mcp.getUrl({})
|
|
@@ -10062,9 +9932,9 @@ var McpConfigService = class {
|
|
|
10062
9932
|
return JSON.stringify(mcpConfig, null, 2);
|
|
10063
9933
|
}
|
|
10064
9934
|
installClaudeMcp(config) {
|
|
10065
|
-
const
|
|
9935
|
+
const command20 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
|
|
10066
9936
|
try {
|
|
10067
|
-
(0, import_child_process2.execSync)(
|
|
9937
|
+
(0, import_child_process2.execSync)(command20, { stdio: "pipe" });
|
|
10068
9938
|
return { success: true };
|
|
10069
9939
|
} catch (error) {
|
|
10070
9940
|
const execError = error;
|
|
@@ -10209,12 +10079,11 @@ var ConfigFileRepository = class {
|
|
|
10209
10079
|
];
|
|
10210
10080
|
}
|
|
10211
10081
|
async writeConfig(baseDirectory, config) {
|
|
10212
|
-
const configPath =
|
|
10213
|
-
|
|
10214
|
-
await fs9.writeFile(configPath, configContent, "utf-8");
|
|
10082
|
+
const configPath = this.getConfigPath(baseDirectory);
|
|
10083
|
+
await this.writeConfigToPath(configPath, config);
|
|
10215
10084
|
}
|
|
10216
10085
|
async configExists(baseDirectory) {
|
|
10217
|
-
const configPath =
|
|
10086
|
+
const configPath = this.getConfigPath(baseDirectory);
|
|
10218
10087
|
try {
|
|
10219
10088
|
await fs9.access(configPath);
|
|
10220
10089
|
return true;
|
|
@@ -10223,15 +10092,29 @@ var ConfigFileRepository = class {
|
|
|
10223
10092
|
}
|
|
10224
10093
|
}
|
|
10225
10094
|
async readConfig(baseDirectory) {
|
|
10226
|
-
const configPath =
|
|
10095
|
+
const configPath = this.getConfigPath(baseDirectory);
|
|
10227
10096
|
try {
|
|
10228
10097
|
const configContent = await fs9.readFile(configPath, "utf-8");
|
|
10229
|
-
const
|
|
10230
|
-
if (!
|
|
10098
|
+
const rawConfig = JSON.parse(configContent);
|
|
10099
|
+
if (!rawConfig.packages || typeof rawConfig.packages !== "object") {
|
|
10231
10100
|
throw new Error(
|
|
10232
10101
|
"Invalid packmind.json structure. Expected { packages: { ... } }"
|
|
10233
10102
|
);
|
|
10234
10103
|
}
|
|
10104
|
+
const { validAgents, invalidAgents } = validateAgentsWithWarnings(
|
|
10105
|
+
rawConfig.agents
|
|
10106
|
+
);
|
|
10107
|
+
if (invalidAgents.length > 0) {
|
|
10108
|
+
logWarningConsole(
|
|
10109
|
+
`Invalid agent(s) in ${configPath}: ${invalidAgents.join(", ")}. Valid agents are: packmind, junie, claude, cursor, copilot, agents_md, gitlab_duo, continue`
|
|
10110
|
+
);
|
|
10111
|
+
}
|
|
10112
|
+
const config = {
|
|
10113
|
+
packages: rawConfig.packages
|
|
10114
|
+
};
|
|
10115
|
+
if (validAgents !== null) {
|
|
10116
|
+
config.agents = validAgents;
|
|
10117
|
+
}
|
|
10235
10118
|
return config;
|
|
10236
10119
|
} catch (error) {
|
|
10237
10120
|
if (error.code === "ENOENT") {
|
|
@@ -10244,41 +10127,51 @@ var ConfigFileRepository = class {
|
|
|
10244
10127
|
return null;
|
|
10245
10128
|
}
|
|
10246
10129
|
}
|
|
10130
|
+
getConfigPath(directory) {
|
|
10131
|
+
return path9.join(directory, this.CONFIG_FILENAME);
|
|
10132
|
+
}
|
|
10133
|
+
async writeConfigToPath(configPath, config) {
|
|
10134
|
+
const configContent = JSON.stringify(config, null, 2) + "\n";
|
|
10135
|
+
await fs9.writeFile(configPath, configContent, "utf-8");
|
|
10136
|
+
}
|
|
10247
10137
|
/**
|
|
10248
10138
|
* Recursively finds all directories containing packmind.json in descendant folders.
|
|
10249
10139
|
* Excludes common build/dependency directories (node_modules, .git, dist, etc.)
|
|
10250
|
-
*
|
|
10251
|
-
* @param directory - The root directory to search from
|
|
10252
|
-
* @returns Array of directory paths that contain a packmind.json file
|
|
10253
10140
|
*/
|
|
10254
10141
|
async findDescendantConfigs(directory) {
|
|
10255
10142
|
const normalizedDir = normalizePath(path9.resolve(directory));
|
|
10143
|
+
return this.searchDescendantsRecursively(normalizedDir);
|
|
10144
|
+
}
|
|
10145
|
+
async searchDescendantsRecursively(currentDir) {
|
|
10146
|
+
const entries = await this.tryReadDirectory(currentDir);
|
|
10147
|
+
if (!entries) {
|
|
10148
|
+
return [];
|
|
10149
|
+
}
|
|
10256
10150
|
const results = [];
|
|
10257
|
-
const
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
entries = await fs9.readdir(currentDir, { withFileTypes: true });
|
|
10261
|
-
} catch {
|
|
10262
|
-
return;
|
|
10151
|
+
for (const entry of entries) {
|
|
10152
|
+
if (!entry.isDirectory() || this.isExcludedDirectory(entry.name)) {
|
|
10153
|
+
continue;
|
|
10263
10154
|
}
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
if (this.EXCLUDED_DIRECTORIES.includes(entry.name)) {
|
|
10269
|
-
continue;
|
|
10270
|
-
}
|
|
10271
|
-
const entryPath = normalizePath(path9.join(currentDir, entry.name));
|
|
10272
|
-
const config = await this.readConfig(entryPath);
|
|
10273
|
-
if (config) {
|
|
10274
|
-
results.push(entryPath);
|
|
10275
|
-
}
|
|
10276
|
-
await searchRecursively(entryPath);
|
|
10155
|
+
const entryPath = normalizePath(path9.join(currentDir, entry.name));
|
|
10156
|
+
const config = await this.readConfig(entryPath);
|
|
10157
|
+
if (config) {
|
|
10158
|
+
results.push(entryPath);
|
|
10277
10159
|
}
|
|
10278
|
-
|
|
10279
|
-
|
|
10160
|
+
const nestedResults = await this.searchDescendantsRecursively(entryPath);
|
|
10161
|
+
results.push(...nestedResults);
|
|
10162
|
+
}
|
|
10280
10163
|
return results;
|
|
10281
10164
|
}
|
|
10165
|
+
async tryReadDirectory(directory) {
|
|
10166
|
+
try {
|
|
10167
|
+
return await fs9.readdir(directory, { withFileTypes: true });
|
|
10168
|
+
} catch {
|
|
10169
|
+
return null;
|
|
10170
|
+
}
|
|
10171
|
+
}
|
|
10172
|
+
isExcludedDirectory(name) {
|
|
10173
|
+
return this.EXCLUDED_DIRECTORIES.includes(name);
|
|
10174
|
+
}
|
|
10282
10175
|
/**
|
|
10283
10176
|
* Reads all packmind.json files from startDirectory up to stopDirectory (inclusive)
|
|
10284
10177
|
* and merges their package configurations.
|
|
@@ -10327,28 +10220,33 @@ var ConfigFileRepository = class {
|
|
|
10327
10220
|
/**
|
|
10328
10221
|
* Finds all packmind.json files in the tree (both ancestors and descendants)
|
|
10329
10222
|
* and returns each config with its target path.
|
|
10330
|
-
*
|
|
10331
|
-
* @param startDirectory - Directory to start searching from (typically the lint target)
|
|
10332
|
-
* @param stopDirectory - Directory to stop ancestor search at (typically git repo root), also used as base for descendants search
|
|
10333
|
-
* @returns All configs found with their target paths
|
|
10334
10223
|
*/
|
|
10335
10224
|
async findAllConfigsInTree(startDirectory, stopDirectory) {
|
|
10336
10225
|
const normalizedStart = normalizePath(path9.resolve(startDirectory));
|
|
10337
10226
|
const normalizedStop = stopDirectory ? normalizePath(path9.resolve(stopDirectory)) : null;
|
|
10338
10227
|
const basePath = normalizedStop ?? normalizedStart;
|
|
10228
|
+
const searchRoot = normalizedStop ?? normalizedStart;
|
|
10339
10229
|
const configsMap = /* @__PURE__ */ new Map();
|
|
10340
|
-
|
|
10230
|
+
await this.collectAncestorConfigs(
|
|
10231
|
+
normalizedStart,
|
|
10232
|
+
normalizedStop,
|
|
10233
|
+
basePath,
|
|
10234
|
+
configsMap
|
|
10235
|
+
);
|
|
10236
|
+
await this.collectDescendantConfigs(searchRoot, basePath, configsMap);
|
|
10237
|
+
await this.collectRootConfigIfMissing(searchRoot, basePath, configsMap);
|
|
10238
|
+
const configs = Array.from(configsMap.values());
|
|
10239
|
+
return {
|
|
10240
|
+
configs,
|
|
10241
|
+
hasConfigs: configs.length > 0,
|
|
10242
|
+
basePath
|
|
10243
|
+
};
|
|
10244
|
+
}
|
|
10245
|
+
async collectAncestorConfigs(startDir, stopDir, basePath, configsMap) {
|
|
10246
|
+
let currentDir = startDir;
|
|
10341
10247
|
while (true) {
|
|
10342
|
-
|
|
10343
|
-
if (
|
|
10344
|
-
const targetPath = this.computeRelativeTargetPath(currentDir, basePath);
|
|
10345
|
-
configsMap.set(currentDir, {
|
|
10346
|
-
targetPath,
|
|
10347
|
-
absoluteTargetPath: currentDir,
|
|
10348
|
-
packages: config.packages
|
|
10349
|
-
});
|
|
10350
|
-
}
|
|
10351
|
-
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
10248
|
+
await this.addConfigToMap(currentDir, basePath, configsMap);
|
|
10249
|
+
if (stopDir !== null && currentDir === stopDir) {
|
|
10352
10250
|
break;
|
|
10353
10251
|
}
|
|
10354
10252
|
const parentDir = normalizePath(path9.dirname(currentDir));
|
|
@@ -10357,42 +10255,34 @@ var ConfigFileRepository = class {
|
|
|
10357
10255
|
}
|
|
10358
10256
|
currentDir = parentDir;
|
|
10359
10257
|
}
|
|
10360
|
-
|
|
10258
|
+
}
|
|
10259
|
+
async collectDescendantConfigs(searchRoot, basePath, configsMap) {
|
|
10361
10260
|
const descendantDirs = await this.findDescendantConfigs(searchRoot);
|
|
10362
10261
|
for (const descendantDir of descendantDirs) {
|
|
10363
10262
|
const normalizedDescendantDir = normalizePath(descendantDir);
|
|
10364
10263
|
if (configsMap.has(normalizedDescendantDir)) {
|
|
10365
10264
|
continue;
|
|
10366
10265
|
}
|
|
10367
|
-
|
|
10368
|
-
if (config) {
|
|
10369
|
-
const targetPath = this.computeRelativeTargetPath(
|
|
10370
|
-
normalizedDescendantDir,
|
|
10371
|
-
basePath
|
|
10372
|
-
);
|
|
10373
|
-
configsMap.set(normalizedDescendantDir, {
|
|
10374
|
-
targetPath,
|
|
10375
|
-
absoluteTargetPath: normalizedDescendantDir,
|
|
10376
|
-
packages: config.packages
|
|
10377
|
-
});
|
|
10378
|
-
}
|
|
10266
|
+
await this.addConfigToMap(normalizedDescendantDir, basePath, configsMap);
|
|
10379
10267
|
}
|
|
10268
|
+
}
|
|
10269
|
+
async collectRootConfigIfMissing(searchRoot, basePath, configsMap) {
|
|
10380
10270
|
if (!configsMap.has(searchRoot)) {
|
|
10381
|
-
|
|
10382
|
-
if (rootConfig) {
|
|
10383
|
-
configsMap.set(searchRoot, {
|
|
10384
|
-
targetPath: "/",
|
|
10385
|
-
absoluteTargetPath: searchRoot,
|
|
10386
|
-
packages: rootConfig.packages
|
|
10387
|
-
});
|
|
10388
|
-
}
|
|
10271
|
+
await this.addConfigToMap(searchRoot, basePath, configsMap);
|
|
10389
10272
|
}
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
}
|
|
10273
|
+
}
|
|
10274
|
+
async addConfigToMap(directory, basePath, configsMap) {
|
|
10275
|
+
const config = await this.readConfig(directory);
|
|
10276
|
+
if (!config) {
|
|
10277
|
+
return;
|
|
10278
|
+
}
|
|
10279
|
+
const targetPath = this.computeRelativeTargetPath(directory, basePath);
|
|
10280
|
+
configsMap.set(directory, {
|
|
10281
|
+
targetPath,
|
|
10282
|
+
absoluteTargetPath: directory,
|
|
10283
|
+
packages: config.packages,
|
|
10284
|
+
agents: config.agents
|
|
10285
|
+
});
|
|
10396
10286
|
}
|
|
10397
10287
|
computeRelativeTargetPath(absolutePath, basePath) {
|
|
10398
10288
|
const normalizedAbsolute = normalizePath(absolutePath);
|
|
@@ -10403,6 +10293,91 @@ var ConfigFileRepository = class {
|
|
|
10403
10293
|
const relativePath = normalizedAbsolute.substring(normalizedBase.length);
|
|
10404
10294
|
return relativePath.startsWith("/") ? relativePath : "/" + relativePath;
|
|
10405
10295
|
}
|
|
10296
|
+
/**
|
|
10297
|
+
* Adds new packages to an existing packmind.json while preserving property order.
|
|
10298
|
+
* If the file doesn't exist, creates a new one with default order (packages first).
|
|
10299
|
+
*
|
|
10300
|
+
* Uses JavaScript's built-in property order preservation: JSON.parse() preserves
|
|
10301
|
+
* insertion order for string keys, and mutating the existing object maintains
|
|
10302
|
+
* that order when JSON.stringify() outputs it.
|
|
10303
|
+
*/
|
|
10304
|
+
async addPackagesToConfig(baseDirectory, newPackageSlugs) {
|
|
10305
|
+
const configPath = this.getConfigPath(baseDirectory);
|
|
10306
|
+
const rawContent = await this.tryReadFile(configPath);
|
|
10307
|
+
if (!rawContent) {
|
|
10308
|
+
const newConfig = this.createConfigWithPackages(newPackageSlugs);
|
|
10309
|
+
await this.writeConfigToPath(configPath, newConfig);
|
|
10310
|
+
return;
|
|
10311
|
+
}
|
|
10312
|
+
let parsed;
|
|
10313
|
+
try {
|
|
10314
|
+
parsed = JSON.parse(rawContent);
|
|
10315
|
+
} catch {
|
|
10316
|
+
const newConfig = this.createConfigWithPackages(newPackageSlugs);
|
|
10317
|
+
await this.writeConfigToPath(configPath, newConfig);
|
|
10318
|
+
return;
|
|
10319
|
+
}
|
|
10320
|
+
if (!parsed.packages || typeof parsed.packages !== "object") {
|
|
10321
|
+
parsed.packages = {};
|
|
10322
|
+
}
|
|
10323
|
+
const packages = parsed.packages;
|
|
10324
|
+
for (const slug of newPackageSlugs) {
|
|
10325
|
+
if (!(slug in packages)) {
|
|
10326
|
+
packages[slug] = "*";
|
|
10327
|
+
}
|
|
10328
|
+
}
|
|
10329
|
+
await this.writeConfigToPath(configPath, parsed);
|
|
10330
|
+
}
|
|
10331
|
+
/**
|
|
10332
|
+
* Updates a specific field in packmind.json while preserving property order.
|
|
10333
|
+
* If the file doesn't exist, creates a new one with default packages and the field.
|
|
10334
|
+
*/
|
|
10335
|
+
async updateConfig(baseDirectory, field, value) {
|
|
10336
|
+
const configPath = this.getConfigPath(baseDirectory);
|
|
10337
|
+
const rawContent = await this.tryReadFile(configPath);
|
|
10338
|
+
if (!rawContent) {
|
|
10339
|
+
const newConfig = { packages: {}, [field]: value };
|
|
10340
|
+
await this.writeConfigToPath(configPath, newConfig);
|
|
10341
|
+
return;
|
|
10342
|
+
}
|
|
10343
|
+
let parsed;
|
|
10344
|
+
try {
|
|
10345
|
+
parsed = JSON.parse(rawContent);
|
|
10346
|
+
} catch {
|
|
10347
|
+
const newConfig = { packages: {}, [field]: value };
|
|
10348
|
+
await this.writeConfigToPath(configPath, newConfig);
|
|
10349
|
+
return;
|
|
10350
|
+
}
|
|
10351
|
+
if (!parsed.packages || typeof parsed.packages !== "object") {
|
|
10352
|
+
parsed.packages = {};
|
|
10353
|
+
}
|
|
10354
|
+
parsed[field] = value;
|
|
10355
|
+
await this.writeConfigToPath(configPath, parsed);
|
|
10356
|
+
}
|
|
10357
|
+
/**
|
|
10358
|
+
* Updates the agents configuration in packmind.json.
|
|
10359
|
+
* Convenience wrapper around updateConfig for the agents field.
|
|
10360
|
+
*/
|
|
10361
|
+
async updateAgentsConfig(baseDirectory, agents) {
|
|
10362
|
+
return this.updateConfig(baseDirectory, "agents", agents);
|
|
10363
|
+
}
|
|
10364
|
+
async tryReadFile(filePath) {
|
|
10365
|
+
try {
|
|
10366
|
+
return await fs9.readFile(filePath, "utf-8");
|
|
10367
|
+
} catch (error) {
|
|
10368
|
+
if (error.code === "ENOENT") {
|
|
10369
|
+
return null;
|
|
10370
|
+
}
|
|
10371
|
+
throw error;
|
|
10372
|
+
}
|
|
10373
|
+
}
|
|
10374
|
+
createConfigWithPackages(slugs) {
|
|
10375
|
+
const packages = {};
|
|
10376
|
+
for (const slug of slugs) {
|
|
10377
|
+
packages[slug] = "*";
|
|
10378
|
+
}
|
|
10379
|
+
return { packages };
|
|
10380
|
+
}
|
|
10406
10381
|
};
|
|
10407
10382
|
|
|
10408
10383
|
// apps/cli/src/application/useCases/ListStandardsUseCase.ts
|
|
@@ -10411,7 +10386,11 @@ var ListStandardsUseCase = class {
|
|
|
10411
10386
|
this.packmindGateway = packmindGateway;
|
|
10412
10387
|
}
|
|
10413
10388
|
async execute() {
|
|
10414
|
-
|
|
10389
|
+
const globalSpace = await this.packmindGateway.spaces.getGlobal();
|
|
10390
|
+
const listStandardsResponse = await this.packmindGateway.standards.list({
|
|
10391
|
+
spaceId: globalSpace.id
|
|
10392
|
+
});
|
|
10393
|
+
return listStandardsResponse.standards;
|
|
10415
10394
|
}
|
|
10416
10395
|
};
|
|
10417
10396
|
|
|
@@ -10421,7 +10400,11 @@ var ListCommandsUseCase = class {
|
|
|
10421
10400
|
this.packmindGateway = packmindGateway;
|
|
10422
10401
|
}
|
|
10423
10402
|
async execute() {
|
|
10424
|
-
|
|
10403
|
+
const space = await this.packmindGateway.spaces.getGlobal();
|
|
10404
|
+
const listCommandsResponse = await this.packmindGateway.commands.list({
|
|
10405
|
+
spaceId: space.id
|
|
10406
|
+
});
|
|
10407
|
+
return listCommandsResponse.recipes;
|
|
10425
10408
|
}
|
|
10426
10409
|
};
|
|
10427
10410
|
|
|
@@ -10582,8 +10565,8 @@ var UploadSkillUseCase = class {
|
|
|
10582
10565
|
constructor(deps) {
|
|
10583
10566
|
this.deps = deps;
|
|
10584
10567
|
}
|
|
10585
|
-
async execute(
|
|
10586
|
-
const files = await readSkillDirectory(
|
|
10568
|
+
async execute(command20) {
|
|
10569
|
+
const files = await readSkillDirectory(command20.skillPath);
|
|
10587
10570
|
if (!files.find((f) => f.relativePath === "SKILL.md")) {
|
|
10588
10571
|
throw new Error("SKILL.md not found in skill directory");
|
|
10589
10572
|
}
|
|
@@ -10608,7 +10591,8 @@ var UploadSkillUseCase = class {
|
|
|
10608
10591
|
};
|
|
10609
10592
|
const uploadSkillResponse = await this.deps.gateway.skills.upload({
|
|
10610
10593
|
spaceId: createSpaceId(space.id),
|
|
10611
|
-
files: payload.files
|
|
10594
|
+
files: payload.files,
|
|
10595
|
+
originSkill: command20.originSkill
|
|
10612
10596
|
});
|
|
10613
10597
|
return {
|
|
10614
10598
|
skillId: uploadSkillResponse.skill.id,
|
|
@@ -10652,9 +10636,7 @@ var PackmindCliHexaFactory = class {
|
|
|
10652
10636
|
installPackages: new InstallPackagesUseCase(
|
|
10653
10637
|
this.repositories.packmindGateway
|
|
10654
10638
|
),
|
|
10655
|
-
installDefaultSkills: new InstallDefaultSkillsUseCase(
|
|
10656
|
-
this.repositories.packmindGateway
|
|
10657
|
-
),
|
|
10639
|
+
installDefaultSkills: new InstallDefaultSkillsUseCase(this.repositories),
|
|
10658
10640
|
listPackages: new ListPackagesUseCase(this.repositories.packmindGateway),
|
|
10659
10641
|
getPackageBySlug: new GetPackageSummaryUseCase(
|
|
10660
10642
|
this.repositories.packmindGateway
|
|
@@ -10682,6 +10664,11 @@ var PackmindCliHexaFactory = class {
|
|
|
10682
10664
|
var origin8 = "PackmindCliHexa";
|
|
10683
10665
|
var PackmindCliHexa = class {
|
|
10684
10666
|
constructor(logger2 = new PackmindLogger(origin8)) {
|
|
10667
|
+
this.notifyDistribution = async (command20) => {
|
|
10668
|
+
return this.hexa.repositories.packmindGateway.deployment.notifyDistribution(
|
|
10669
|
+
command20
|
|
10670
|
+
);
|
|
10671
|
+
};
|
|
10685
10672
|
this.logger = logger2;
|
|
10686
10673
|
try {
|
|
10687
10674
|
this.hexa = new PackmindCliHexaFactory();
|
|
@@ -10699,38 +10686,38 @@ var PackmindCliHexa = class {
|
|
|
10699
10686
|
this.logger.info("Destroying PackmindCliHexa");
|
|
10700
10687
|
this.logger.info("PackmindCliHexa destroyed");
|
|
10701
10688
|
}
|
|
10702
|
-
async getGitRemoteUrl(
|
|
10703
|
-
return this.hexa.useCases.getGitRemoteUrl.execute(
|
|
10689
|
+
async getGitRemoteUrl(command20) {
|
|
10690
|
+
return this.hexa.useCases.getGitRemoteUrl.execute(command20);
|
|
10704
10691
|
}
|
|
10705
|
-
async executeSingleFileAst(
|
|
10706
|
-
return this.hexa.useCases.executeSingleFileAst.execute(
|
|
10692
|
+
async executeSingleFileAst(command20) {
|
|
10693
|
+
return this.hexa.useCases.executeSingleFileAst.execute(command20);
|
|
10707
10694
|
}
|
|
10708
|
-
async listFilesInDirectory(
|
|
10709
|
-
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(
|
|
10695
|
+
async listFilesInDirectory(command20) {
|
|
10696
|
+
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command20);
|
|
10710
10697
|
}
|
|
10711
|
-
async lintFilesAgainstRule(
|
|
10712
|
-
return this.hexa.useCases.lintFilesAgainstRule.execute(
|
|
10698
|
+
async lintFilesAgainstRule(command20) {
|
|
10699
|
+
return this.hexa.useCases.lintFilesAgainstRule.execute(command20);
|
|
10713
10700
|
}
|
|
10714
|
-
async lintFilesFromConfig(
|
|
10715
|
-
return this.hexa.useCases.lintFilesFromConfig.execute(
|
|
10701
|
+
async lintFilesFromConfig(command20) {
|
|
10702
|
+
return this.hexa.useCases.lintFilesFromConfig.execute(command20);
|
|
10716
10703
|
}
|
|
10717
|
-
async installPackages(
|
|
10718
|
-
return this.hexa.useCases.installPackages.execute(
|
|
10704
|
+
async installPackages(command20) {
|
|
10705
|
+
return this.hexa.useCases.installPackages.execute(command20);
|
|
10719
10706
|
}
|
|
10720
|
-
async listPackages(
|
|
10721
|
-
return this.hexa.useCases.listPackages.execute(
|
|
10707
|
+
async listPackages(command20) {
|
|
10708
|
+
return this.hexa.useCases.listPackages.execute(command20);
|
|
10722
10709
|
}
|
|
10723
|
-
async getPackageBySlug(
|
|
10724
|
-
return this.hexa.useCases.getPackageBySlug.execute(
|
|
10710
|
+
async getPackageBySlug(command20) {
|
|
10711
|
+
return this.hexa.useCases.getPackageBySlug.execute(command20);
|
|
10725
10712
|
}
|
|
10726
|
-
async listStandards(
|
|
10727
|
-
return this.hexa.useCases.listStandards.execute(
|
|
10713
|
+
async listStandards(command20) {
|
|
10714
|
+
return this.hexa.useCases.listStandards.execute(command20);
|
|
10728
10715
|
}
|
|
10729
|
-
async listCommands(
|
|
10730
|
-
return this.hexa.useCases.listCommands.execute(
|
|
10716
|
+
async listCommands(command20) {
|
|
10717
|
+
return this.hexa.useCases.listCommands.execute(command20);
|
|
10731
10718
|
}
|
|
10732
|
-
async listSkills(
|
|
10733
|
-
return this.hexa.useCases.listSkills.execute(
|
|
10719
|
+
async listSkills(command20) {
|
|
10720
|
+
return this.hexa.useCases.listSkills.execute(command20);
|
|
10734
10721
|
}
|
|
10735
10722
|
async configExists(baseDirectory) {
|
|
10736
10723
|
return await this.hexa.repositories.configFileRepository.configExists(
|
|
@@ -10741,7 +10728,7 @@ var PackmindCliHexa = class {
|
|
|
10741
10728
|
const config = await this.hexa.repositories.configFileRepository.readConfig(
|
|
10742
10729
|
baseDirectory
|
|
10743
10730
|
);
|
|
10744
|
-
if (!config) return
|
|
10731
|
+
if (!config) return { packages: {} };
|
|
10745
10732
|
const hasNonWildcardVersions = Object.values(config.packages).some(
|
|
10746
10733
|
(version) => version !== "*"
|
|
10747
10734
|
);
|
|
@@ -10750,16 +10737,44 @@ var PackmindCliHexa = class {
|
|
|
10750
10737
|
"Package versions are not supported yet, getting the latest version"
|
|
10751
10738
|
);
|
|
10752
10739
|
}
|
|
10753
|
-
return
|
|
10740
|
+
return config;
|
|
10741
|
+
}
|
|
10742
|
+
/**
|
|
10743
|
+
* Reads the full packmind.json configuration including agents.
|
|
10744
|
+
* Returns null if no config file exists.
|
|
10745
|
+
*/
|
|
10746
|
+
async readFullConfig(baseDirectory) {
|
|
10747
|
+
return this.hexa.repositories.configFileRepository.readConfig(
|
|
10748
|
+
baseDirectory
|
|
10749
|
+
);
|
|
10754
10750
|
}
|
|
10755
10751
|
async writeConfig(baseDirectory, packagesSlugs) {
|
|
10756
10752
|
const packages = {};
|
|
10757
10753
|
packagesSlugs.forEach((slug) => {
|
|
10758
10754
|
packages[slug] = "*";
|
|
10759
10755
|
});
|
|
10756
|
+
const existingConfig = await this.hexa.repositories.configFileRepository.readConfig(
|
|
10757
|
+
baseDirectory
|
|
10758
|
+
);
|
|
10760
10759
|
await this.hexa.repositories.configFileRepository.writeConfig(
|
|
10761
10760
|
baseDirectory,
|
|
10762
|
-
{
|
|
10761
|
+
{
|
|
10762
|
+
...existingConfig,
|
|
10763
|
+
packages
|
|
10764
|
+
}
|
|
10765
|
+
);
|
|
10766
|
+
}
|
|
10767
|
+
/**
|
|
10768
|
+
* Adds new packages to an existing packmind.json while preserving property order.
|
|
10769
|
+
* If the file doesn't exist, creates a new one with default order (packages first).
|
|
10770
|
+
*
|
|
10771
|
+
* @param baseDirectory - The directory containing packmind.json
|
|
10772
|
+
* @param newPackageSlugs - Array of package slugs to add
|
|
10773
|
+
*/
|
|
10774
|
+
async addPackagesToConfig(baseDirectory, newPackageSlugs) {
|
|
10775
|
+
return this.hexa.repositories.configFileRepository.addPackagesToConfig(
|
|
10776
|
+
baseDirectory,
|
|
10777
|
+
newPackageSlugs
|
|
10763
10778
|
);
|
|
10764
10779
|
}
|
|
10765
10780
|
async readHierarchicalConfig(startDirectory, stopDirectory) {
|
|
@@ -10789,17 +10804,17 @@ var PackmindCliHexa = class {
|
|
|
10789
10804
|
directory
|
|
10790
10805
|
);
|
|
10791
10806
|
}
|
|
10792
|
-
async login(
|
|
10793
|
-
return this.hexa.useCases.login.execute(
|
|
10807
|
+
async login(command20) {
|
|
10808
|
+
return this.hexa.useCases.login.execute(command20);
|
|
10794
10809
|
}
|
|
10795
|
-
async logout(
|
|
10796
|
-
return this.hexa.useCases.logout.execute(
|
|
10810
|
+
async logout(command20) {
|
|
10811
|
+
return this.hexa.useCases.logout.execute(command20);
|
|
10797
10812
|
}
|
|
10798
|
-
async whoami(
|
|
10799
|
-
return this.hexa.useCases.whoami.execute(
|
|
10813
|
+
async whoami(command20) {
|
|
10814
|
+
return this.hexa.useCases.whoami.execute(command20);
|
|
10800
10815
|
}
|
|
10801
|
-
async setupMcp(
|
|
10802
|
-
return this.hexa.useCases.setupMcp.execute(
|
|
10816
|
+
async setupMcp(command20) {
|
|
10817
|
+
return this.hexa.useCases.setupMcp.execute(command20);
|
|
10803
10818
|
}
|
|
10804
10819
|
getCurrentBranch(repoPath) {
|
|
10805
10820
|
return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
|
|
@@ -10807,16 +10822,11 @@ var PackmindCliHexa = class {
|
|
|
10807
10822
|
getGitRemoteUrlFromPath(repoPath) {
|
|
10808
10823
|
return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
|
|
10809
10824
|
}
|
|
10810
|
-
async
|
|
10811
|
-
return this.hexa.
|
|
10812
|
-
command16
|
|
10813
|
-
);
|
|
10814
|
-
}
|
|
10815
|
-
async uploadSkill(command16) {
|
|
10816
|
-
return this.hexa.useCases.uploadSkill.execute(command16);
|
|
10825
|
+
async uploadSkill(command20) {
|
|
10826
|
+
return this.hexa.useCases.uploadSkill.execute(command20);
|
|
10817
10827
|
}
|
|
10818
|
-
async installDefaultSkills(
|
|
10819
|
-
return this.hexa.useCases.installDefaultSkills.execute(
|
|
10828
|
+
async installDefaultSkills(command20) {
|
|
10829
|
+
return this.hexa.useCases.installDefaultSkills.execute(command20);
|
|
10820
10830
|
}
|
|
10821
10831
|
getPackmindGateway() {
|
|
10822
10832
|
return this.hexa.repositories.packmindGateway;
|
|
@@ -10893,7 +10903,7 @@ function isNotLoggedInError(error) {
|
|
|
10893
10903
|
}
|
|
10894
10904
|
async function lintHandler(args2, deps) {
|
|
10895
10905
|
const {
|
|
10896
|
-
path:
|
|
10906
|
+
path: path14,
|
|
10897
10907
|
draft,
|
|
10898
10908
|
rule,
|
|
10899
10909
|
language,
|
|
@@ -10913,7 +10923,7 @@ async function lintHandler(args2, deps) {
|
|
|
10913
10923
|
throw new Error("option --rule is required to use --draft mode");
|
|
10914
10924
|
}
|
|
10915
10925
|
const startedAt = Date.now();
|
|
10916
|
-
const targetPath =
|
|
10926
|
+
const targetPath = path14 ?? ".";
|
|
10917
10927
|
const absolutePath = resolvePath(targetPath);
|
|
10918
10928
|
if (diff) {
|
|
10919
10929
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
|
|
@@ -11164,8 +11174,8 @@ function extractWasmFiles() {
|
|
|
11164
11174
|
|
|
11165
11175
|
// apps/cli/src/main.ts
|
|
11166
11176
|
var import_dotenv = require("dotenv");
|
|
11167
|
-
var
|
|
11168
|
-
var
|
|
11177
|
+
var fs16 = __toESM(require("fs"));
|
|
11178
|
+
var path13 = __toESM(require("path"));
|
|
11169
11179
|
|
|
11170
11180
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
11171
11181
|
var import_cmd_ts2 = __toESM(require_cjs());
|
|
@@ -11176,7 +11186,7 @@ function buildPackageUrl(host, orgSlug, packageId) {
|
|
|
11176
11186
|
}
|
|
11177
11187
|
var { version: CLI_VERSION } = require_package();
|
|
11178
11188
|
async function notifyDistributionIfInGitRepo(params) {
|
|
11179
|
-
const { packmindCliHexa, cwd, packages, log } = params;
|
|
11189
|
+
const { packmindCliHexa, cwd, packages, log, agents } = params;
|
|
11180
11190
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(cwd);
|
|
11181
11191
|
if (!gitRoot) {
|
|
11182
11192
|
return false;
|
|
@@ -11195,7 +11205,8 @@ async function notifyDistributionIfInGitRepo(params) {
|
|
|
11195
11205
|
distributedPackages: packages,
|
|
11196
11206
|
gitRemoteUrl,
|
|
11197
11207
|
gitBranch,
|
|
11198
|
-
relativePath
|
|
11208
|
+
relativePath,
|
|
11209
|
+
agents
|
|
11199
11210
|
});
|
|
11200
11211
|
log("Successfully notified Packmind of the new distribution");
|
|
11201
11212
|
return true;
|
|
@@ -11246,7 +11257,7 @@ async function listPackagesHandler(_args, deps) {
|
|
|
11246
11257
|
let urlBuilder = null;
|
|
11247
11258
|
const apiKey = loadApiKey();
|
|
11248
11259
|
if (apiKey) {
|
|
11249
|
-
const decoded =
|
|
11260
|
+
const decoded = decodeApiKey(apiKey);
|
|
11250
11261
|
const orgSlug = decoded?.jwt?.organization?.slug;
|
|
11251
11262
|
if (decoded?.host && orgSlug) {
|
|
11252
11263
|
urlBuilder = (id) => buildPackageUrl(decoded.host, orgSlug, id);
|
|
@@ -11407,8 +11418,15 @@ ${uniqueCount} unique ${packageWord} currently installed.`);
|
|
|
11407
11418
|
async function executeInstallForDirectory(directory, deps) {
|
|
11408
11419
|
const { packmindCliHexa, log } = deps;
|
|
11409
11420
|
let configPackages;
|
|
11421
|
+
let configAgents;
|
|
11410
11422
|
try {
|
|
11411
|
-
|
|
11423
|
+
const fullConfig = await packmindCliHexa.readFullConfig(directory);
|
|
11424
|
+
if (fullConfig) {
|
|
11425
|
+
configPackages = Object.keys(fullConfig.packages);
|
|
11426
|
+
configAgents = fullConfig.agents;
|
|
11427
|
+
} else {
|
|
11428
|
+
configPackages = [];
|
|
11429
|
+
}
|
|
11412
11430
|
} catch (err) {
|
|
11413
11431
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
11414
11432
|
return {
|
|
@@ -11438,8 +11456,10 @@ async function executeInstallForDirectory(directory, deps) {
|
|
|
11438
11456
|
const result = await packmindCliHexa.installPackages({
|
|
11439
11457
|
baseDirectory: directory,
|
|
11440
11458
|
packagesSlugs: configPackages,
|
|
11441
|
-
previousPackagesSlugs: configPackages
|
|
11459
|
+
previousPackagesSlugs: configPackages,
|
|
11442
11460
|
// Pass for consistency
|
|
11461
|
+
agents: configAgents
|
|
11462
|
+
// Pass agents from config if present
|
|
11443
11463
|
});
|
|
11444
11464
|
const parts = [];
|
|
11445
11465
|
if (result.recipesCount > 0) parts.push(`${result.recipesCount} commands`);
|
|
@@ -11467,6 +11487,7 @@ async function executeInstallForDirectory(directory, deps) {
|
|
|
11467
11487
|
packmindCliHexa,
|
|
11468
11488
|
cwd: directory,
|
|
11469
11489
|
packages: configPackages,
|
|
11490
|
+
agents: configAgents,
|
|
11470
11491
|
log: () => {
|
|
11471
11492
|
}
|
|
11472
11493
|
});
|
|
@@ -11495,10 +11516,25 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11495
11516
|
const { packagesSlugs } = args2;
|
|
11496
11517
|
const cwd = getCwd();
|
|
11497
11518
|
let configPackages;
|
|
11519
|
+
let configAgents;
|
|
11498
11520
|
let configFileExists = false;
|
|
11499
11521
|
try {
|
|
11500
11522
|
configFileExists = await packmindCliHexa.configExists(cwd);
|
|
11501
|
-
|
|
11523
|
+
const fullConfig = await packmindCliHexa.readFullConfig(cwd);
|
|
11524
|
+
if (fullConfig) {
|
|
11525
|
+
const hasNonWildcardVersions = Object.values(fullConfig.packages).some(
|
|
11526
|
+
(version) => version !== "*"
|
|
11527
|
+
);
|
|
11528
|
+
if (hasNonWildcardVersions) {
|
|
11529
|
+
logWarningConsole(
|
|
11530
|
+
"Package versions are not supported yet, getting the latest version"
|
|
11531
|
+
);
|
|
11532
|
+
}
|
|
11533
|
+
configPackages = Object.keys(fullConfig.packages);
|
|
11534
|
+
configAgents = fullConfig.agents;
|
|
11535
|
+
} else {
|
|
11536
|
+
configPackages = [];
|
|
11537
|
+
}
|
|
11502
11538
|
} catch (err) {
|
|
11503
11539
|
error("ERROR Failed to parse packmind.json");
|
|
11504
11540
|
if (err instanceof Error) {
|
|
@@ -11575,7 +11611,9 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11575
11611
|
// Pass previous config for change detection
|
|
11576
11612
|
gitRemoteUrl,
|
|
11577
11613
|
gitBranch,
|
|
11578
|
-
relativePath
|
|
11614
|
+
relativePath,
|
|
11615
|
+
agents: configAgents
|
|
11616
|
+
// Pass agents from config if present (overrides org-level)
|
|
11579
11617
|
});
|
|
11580
11618
|
const parts = [];
|
|
11581
11619
|
if (result.recipesCount > 0) parts.push(`${result.recipesCount} commands`);
|
|
@@ -11602,16 +11640,27 @@ added ${result.filesCreated} files, changed ${result.filesUpdated} files, remove
|
|
|
11602
11640
|
notificationSent: false
|
|
11603
11641
|
};
|
|
11604
11642
|
}
|
|
11643
|
+
const newPackages = packagesSlugs.filter(
|
|
11644
|
+
(slug) => !configPackages.includes(slug)
|
|
11645
|
+
);
|
|
11646
|
+
if (newPackages.length > 0) {
|
|
11647
|
+
await packmindCliHexa.addPackagesToConfig(cwd, newPackages);
|
|
11648
|
+
}
|
|
11605
11649
|
let notificationSent = false;
|
|
11606
11650
|
if (result.filesCreated > 0 || result.filesUpdated > 0 || result.filesDeleted > 0 || skillDirsDeleted > 0) {
|
|
11607
11651
|
notificationSent = await notifyDistributionIfInGitRepo({
|
|
11608
11652
|
packmindCliHexa,
|
|
11609
11653
|
cwd,
|
|
11610
11654
|
packages: allPackages,
|
|
11655
|
+
agents: configAgents,
|
|
11611
11656
|
log
|
|
11612
11657
|
});
|
|
11613
11658
|
}
|
|
11614
|
-
await installDefaultSkillsIfAtGitRoot({
|
|
11659
|
+
await installDefaultSkillsIfAtGitRoot({
|
|
11660
|
+
packmindCliHexa,
|
|
11661
|
+
cwd,
|
|
11662
|
+
log
|
|
11663
|
+
});
|
|
11615
11664
|
return {
|
|
11616
11665
|
filesCreated: result.filesCreated,
|
|
11617
11666
|
filesUpdated: result.filesUpdated,
|
|
@@ -11708,7 +11757,8 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11708
11757
|
let configFileExists = false;
|
|
11709
11758
|
try {
|
|
11710
11759
|
configFileExists = await packmindCliHexa.configExists(cwd);
|
|
11711
|
-
|
|
11760
|
+
const config = await packmindCliHexa.readConfig(cwd);
|
|
11761
|
+
configPackages = config.packages;
|
|
11712
11762
|
} catch (err) {
|
|
11713
11763
|
error("\u274C Failed to read packmind.json");
|
|
11714
11764
|
if (err instanceof Error) {
|
|
@@ -11723,7 +11773,7 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11723
11773
|
packagesUninstalled: []
|
|
11724
11774
|
};
|
|
11725
11775
|
}
|
|
11726
|
-
if (configPackages.length === 0) {
|
|
11776
|
+
if (Object.keys(configPackages).length === 0) {
|
|
11727
11777
|
if (configFileExists) {
|
|
11728
11778
|
error("\u274C packmind.json is empty.");
|
|
11729
11779
|
} else {
|
|
@@ -11739,10 +11789,10 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11739
11789
|
};
|
|
11740
11790
|
}
|
|
11741
11791
|
const packagesToUninstall = packagesSlugs.filter(
|
|
11742
|
-
(slug) => configPackages
|
|
11792
|
+
(slug) => slug in configPackages
|
|
11743
11793
|
);
|
|
11744
11794
|
const notInstalledPackages = packagesSlugs.filter(
|
|
11745
|
-
(slug) => !
|
|
11795
|
+
(slug) => !(slug in configPackages)
|
|
11746
11796
|
);
|
|
11747
11797
|
if (notInstalledPackages.length > 0) {
|
|
11748
11798
|
const packageWord = notInstalledPackages.length === 1 ? "package" : "packages";
|
|
@@ -11768,7 +11818,7 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11768
11818
|
log(
|
|
11769
11819
|
`Uninstalling ${packageCount} ${packageWord}: ${packagesToUninstall.join(", ")}...`
|
|
11770
11820
|
);
|
|
11771
|
-
const remainingPackages = configPackages.filter(
|
|
11821
|
+
const remainingPackages = Object.keys(configPackages).filter(
|
|
11772
11822
|
(pkg) => !packagesToUninstall.includes(pkg)
|
|
11773
11823
|
);
|
|
11774
11824
|
let filesDeleted = 0;
|
|
@@ -11777,7 +11827,7 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11777
11827
|
const result = await packmindCliHexa.installPackages({
|
|
11778
11828
|
baseDirectory: cwd,
|
|
11779
11829
|
packagesSlugs: [],
|
|
11780
|
-
previousPackagesSlugs: configPackages
|
|
11830
|
+
previousPackagesSlugs: Object.keys(configPackages)
|
|
11781
11831
|
});
|
|
11782
11832
|
log(`
|
|
11783
11833
|
removed ${result.filesDeleted} files`);
|
|
@@ -11797,7 +11847,7 @@ removed ${result.filesDeleted} files`);
|
|
|
11797
11847
|
const result = await packmindCliHexa.installPackages({
|
|
11798
11848
|
baseDirectory: cwd,
|
|
11799
11849
|
packagesSlugs: remainingPackages,
|
|
11800
|
-
previousPackagesSlugs: configPackages
|
|
11850
|
+
previousPackagesSlugs: Object.keys(configPackages)
|
|
11801
11851
|
});
|
|
11802
11852
|
if (result.recipesCount > 0 || result.standardsCount > 0) {
|
|
11803
11853
|
log(
|
|
@@ -12244,10 +12294,10 @@ var AgentDetectionService = class {
|
|
|
12244
12294
|
const continueDir = path11.join(this.projectDir, ".continue");
|
|
12245
12295
|
return fs11.existsSync(continueDir);
|
|
12246
12296
|
}
|
|
12247
|
-
isCommandAvailable(
|
|
12297
|
+
isCommandAvailable(command20) {
|
|
12248
12298
|
try {
|
|
12249
12299
|
const whichCommand = process.platform === "win32" ? "where" : "which";
|
|
12250
|
-
(0, import_child_process3.execSync)(`${whichCommand} ${
|
|
12300
|
+
(0, import_child_process3.execSync)(`${whichCommand} ${command20}`, { stdio: "pipe" });
|
|
12251
12301
|
return true;
|
|
12252
12302
|
} catch {
|
|
12253
12303
|
return false;
|
|
@@ -12296,7 +12346,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
12296
12346
|
output.write("\n");
|
|
12297
12347
|
const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
|
|
12298
12348
|
const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
|
|
12299
|
-
return new Promise((
|
|
12349
|
+
return new Promise((resolve7) => {
|
|
12300
12350
|
rl.question(
|
|
12301
12351
|
`Enter numbers separated by commas (default: ${defaultValue}): `,
|
|
12302
12352
|
(answer) => {
|
|
@@ -12307,7 +12357,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
12307
12357
|
const numbersStr = trimmed === "" ? defaultValue : trimmed;
|
|
12308
12358
|
const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
|
|
12309
12359
|
const selectedAgents = numbers.map((n) => choices[n - 1].value);
|
|
12310
|
-
|
|
12360
|
+
resolve7(selectedAgents);
|
|
12311
12361
|
}
|
|
12312
12362
|
);
|
|
12313
12363
|
});
|
|
@@ -12443,27 +12493,39 @@ Credentials are loaded from (in order of priority):`);
|
|
|
12443
12493
|
});
|
|
12444
12494
|
|
|
12445
12495
|
// apps/cli/src/infra/commands/SkillsCommand.ts
|
|
12446
|
-
var
|
|
12496
|
+
var import_cmd_ts12 = __toESM(require_cjs());
|
|
12447
12497
|
|
|
12448
12498
|
// apps/cli/src/infra/commands/skills/AddSkillCommand.ts
|
|
12499
|
+
var import_cmd_ts9 = __toESM(require_cjs());
|
|
12500
|
+
|
|
12501
|
+
// apps/cli/src/infra/commands/sharedOptions.ts
|
|
12449
12502
|
var import_cmd_ts8 = __toESM(require_cjs());
|
|
12450
|
-
var
|
|
12503
|
+
var originSkillOption = (0, import_cmd_ts8.option)({
|
|
12504
|
+
long: "origin-skill",
|
|
12505
|
+
description: "Name of the skill that triggered this command",
|
|
12506
|
+
type: (0, import_cmd_ts8.optional)(import_cmd_ts8.string)
|
|
12507
|
+
});
|
|
12508
|
+
|
|
12509
|
+
// apps/cli/src/infra/commands/skills/AddSkillCommand.ts
|
|
12510
|
+
var addSkillCommand = (0, import_cmd_ts9.command)({
|
|
12451
12511
|
name: "add",
|
|
12452
12512
|
description: "Add a skill from a local directory to a Packmind organization",
|
|
12453
12513
|
args: {
|
|
12454
|
-
skillPath: (0,
|
|
12455
|
-
type:
|
|
12514
|
+
skillPath: (0, import_cmd_ts9.positional)({
|
|
12515
|
+
type: import_cmd_ts9.string,
|
|
12456
12516
|
displayName: "path",
|
|
12457
12517
|
description: "Path to skill directory containing SKILL.md"
|
|
12458
|
-
})
|
|
12518
|
+
}),
|
|
12519
|
+
originSkill: originSkillOption
|
|
12459
12520
|
},
|
|
12460
|
-
handler: async ({ skillPath }) => {
|
|
12521
|
+
handler: async ({ skillPath, originSkill }) => {
|
|
12461
12522
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
12462
12523
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
12463
12524
|
try {
|
|
12464
12525
|
logInfoConsole(`Uploading skill from ${skillPath}...`);
|
|
12465
12526
|
const result = await packmindCliHexa.uploadSkill({
|
|
12466
|
-
skillPath
|
|
12527
|
+
skillPath,
|
|
12528
|
+
originSkill
|
|
12467
12529
|
});
|
|
12468
12530
|
if (result.isNewSkill) {
|
|
12469
12531
|
logSuccessConsole("Skill created successfully!");
|
|
@@ -12492,13 +12554,13 @@ var addSkillCommand = (0, import_cmd_ts8.command)({
|
|
|
12492
12554
|
});
|
|
12493
12555
|
|
|
12494
12556
|
// apps/cli/src/infra/commands/skills/InstallDefaultSkillsCommand.ts
|
|
12495
|
-
var
|
|
12557
|
+
var import_cmd_ts10 = __toESM(require_cjs());
|
|
12496
12558
|
var { version: CLI_VERSION2 } = require_package();
|
|
12497
|
-
var installDefaultSkillsCommand = (0,
|
|
12559
|
+
var installDefaultSkillsCommand = (0, import_cmd_ts10.command)({
|
|
12498
12560
|
name: "install-default",
|
|
12499
12561
|
description: "Install default Packmind skills for configured coding agents",
|
|
12500
12562
|
args: {
|
|
12501
|
-
includeBeta: (0,
|
|
12563
|
+
includeBeta: (0, import_cmd_ts10.flag)({
|
|
12502
12564
|
long: "include-beta",
|
|
12503
12565
|
description: "Include unreleased/beta skills"
|
|
12504
12566
|
})
|
|
@@ -12542,7 +12604,7 @@ var installDefaultSkillsCommand = (0, import_cmd_ts9.command)({
|
|
|
12542
12604
|
});
|
|
12543
12605
|
|
|
12544
12606
|
// apps/cli/src/infra/commands/ListSkillsCommand.ts
|
|
12545
|
-
var
|
|
12607
|
+
var import_cmd_ts11 = __toESM(require_cjs());
|
|
12546
12608
|
|
|
12547
12609
|
// apps/cli/src/infra/commands/listSkillsHandler.ts
|
|
12548
12610
|
function buildSkillUrl(host, orgSlug, skillSlug) {
|
|
@@ -12564,7 +12626,7 @@ async function listSkillsHandler(deps) {
|
|
|
12564
12626
|
let urlBuilder = null;
|
|
12565
12627
|
const apiKey = loadApiKey();
|
|
12566
12628
|
if (apiKey) {
|
|
12567
|
-
const decoded =
|
|
12629
|
+
const decoded = decodeApiKey(apiKey);
|
|
12568
12630
|
const orgSlug = decoded?.jwt?.organization?.slug;
|
|
12569
12631
|
if (decoded?.host && orgSlug) {
|
|
12570
12632
|
urlBuilder = (slug) => buildSkillUrl(decoded.host, orgSlug, slug);
|
|
@@ -12604,7 +12666,7 @@ async function listSkillsHandler(deps) {
|
|
|
12604
12666
|
}
|
|
12605
12667
|
|
|
12606
12668
|
// apps/cli/src/infra/commands/ListSkillsCommand.ts
|
|
12607
|
-
var listSkillsCommand = (0,
|
|
12669
|
+
var listSkillsCommand = (0, import_cmd_ts11.command)({
|
|
12608
12670
|
name: "list",
|
|
12609
12671
|
description: "List available skills",
|
|
12610
12672
|
args: {},
|
|
@@ -12621,7 +12683,7 @@ var listSkillsCommand = (0, import_cmd_ts10.command)({
|
|
|
12621
12683
|
});
|
|
12622
12684
|
|
|
12623
12685
|
// apps/cli/src/infra/commands/SkillsCommand.ts
|
|
12624
|
-
var skillsCommand = (0,
|
|
12686
|
+
var skillsCommand = (0, import_cmd_ts12.subcommands)({
|
|
12625
12687
|
name: "skills",
|
|
12626
12688
|
description: "Manage skills in your Packmind organization",
|
|
12627
12689
|
cmds: {
|
|
@@ -12632,10 +12694,10 @@ var skillsCommand = (0, import_cmd_ts11.subcommands)({
|
|
|
12632
12694
|
});
|
|
12633
12695
|
|
|
12634
12696
|
// apps/cli/src/infra/commands/StandardsCommand.ts
|
|
12635
|
-
var
|
|
12697
|
+
var import_cmd_ts15 = __toESM(require_cjs());
|
|
12636
12698
|
|
|
12637
12699
|
// apps/cli/src/infra/commands/CreateStandardCommand.ts
|
|
12638
|
-
var
|
|
12700
|
+
var import_cmd_ts13 = __toESM(require_cjs());
|
|
12639
12701
|
|
|
12640
12702
|
// apps/cli/src/infra/utils/readPlaybookFile.ts
|
|
12641
12703
|
var fs13 = __toESM(require("fs/promises"));
|
|
@@ -12701,7 +12763,7 @@ async function readPlaybookFile(filePath) {
|
|
|
12701
12763
|
}
|
|
12702
12764
|
|
|
12703
12765
|
// apps/cli/src/infra/commands/createStandardHandler.ts
|
|
12704
|
-
async function createStandardHandler(filePath, useCase) {
|
|
12766
|
+
async function createStandardHandler(filePath, useCase, originSkill) {
|
|
12705
12767
|
const readResult = await readPlaybookFile(filePath);
|
|
12706
12768
|
if (!readResult.isValid) {
|
|
12707
12769
|
return {
|
|
@@ -12716,7 +12778,10 @@ async function createStandardHandler(filePath, useCase) {
|
|
|
12716
12778
|
};
|
|
12717
12779
|
}
|
|
12718
12780
|
try {
|
|
12719
|
-
const result = await useCase.execute(
|
|
12781
|
+
const result = await useCase.execute({
|
|
12782
|
+
...readResult.data,
|
|
12783
|
+
originSkill
|
|
12784
|
+
});
|
|
12720
12785
|
return {
|
|
12721
12786
|
success: true,
|
|
12722
12787
|
standardId: result.standardId,
|
|
@@ -12750,30 +12815,32 @@ var CreateStandardFromPlaybookUseCase = class {
|
|
|
12750
12815
|
negative: r.examples.negative
|
|
12751
12816
|
}
|
|
12752
12817
|
] : void 0
|
|
12753
|
-
}))
|
|
12818
|
+
})),
|
|
12819
|
+
originSkill: playbook.originSkill
|
|
12754
12820
|
});
|
|
12755
12821
|
return { standardId: standard.id, name: standard.name };
|
|
12756
12822
|
}
|
|
12757
12823
|
};
|
|
12758
12824
|
|
|
12759
12825
|
// apps/cli/src/infra/commands/CreateStandardCommand.ts
|
|
12760
|
-
var createStandardCommand = (0,
|
|
12826
|
+
var createStandardCommand = (0, import_cmd_ts13.command)({
|
|
12761
12827
|
name: "create",
|
|
12762
12828
|
description: "Create a coding standard from a playbook JSON file",
|
|
12763
12829
|
args: {
|
|
12764
|
-
file: (0,
|
|
12830
|
+
file: (0, import_cmd_ts13.positional)({
|
|
12765
12831
|
displayName: "file",
|
|
12766
12832
|
description: "Path to the playbook JSON file",
|
|
12767
|
-
type:
|
|
12768
|
-
})
|
|
12833
|
+
type: import_cmd_ts13.string
|
|
12834
|
+
}),
|
|
12835
|
+
originSkill: originSkillOption
|
|
12769
12836
|
},
|
|
12770
|
-
handler: async ({ file }) => {
|
|
12837
|
+
handler: async ({ file, originSkill }) => {
|
|
12771
12838
|
try {
|
|
12772
12839
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
12773
12840
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
12774
12841
|
const gateway = hexa.getPackmindGateway();
|
|
12775
12842
|
const useCase = new CreateStandardFromPlaybookUseCase(gateway);
|
|
12776
|
-
const result = await createStandardHandler(file, useCase);
|
|
12843
|
+
const result = await createStandardHandler(file, useCase, originSkill);
|
|
12777
12844
|
if (result.success) {
|
|
12778
12845
|
logSuccessConsole(
|
|
12779
12846
|
`Standard "${result.standardName}" created successfully (ID: ${result.standardId})`
|
|
@@ -12793,7 +12860,7 @@ var createStandardCommand = (0, import_cmd_ts12.command)({
|
|
|
12793
12860
|
});
|
|
12794
12861
|
|
|
12795
12862
|
// apps/cli/src/infra/commands/ListStandardsCommand.ts
|
|
12796
|
-
var
|
|
12863
|
+
var import_cmd_ts14 = __toESM(require_cjs());
|
|
12797
12864
|
|
|
12798
12865
|
// apps/cli/src/infra/commands/listStandardsHandler.ts
|
|
12799
12866
|
function buildStandardUrl(host, orgSlug, standardId) {
|
|
@@ -12815,7 +12882,7 @@ async function listStandardsHandler(deps) {
|
|
|
12815
12882
|
let urlBuilder = null;
|
|
12816
12883
|
const apiKey = loadApiKey();
|
|
12817
12884
|
if (apiKey) {
|
|
12818
|
-
const decoded =
|
|
12885
|
+
const decoded = decodeApiKey(apiKey);
|
|
12819
12886
|
const orgSlug = decoded?.jwt?.organization?.slug;
|
|
12820
12887
|
if (decoded?.host && orgSlug) {
|
|
12821
12888
|
urlBuilder = (id) => buildStandardUrl(decoded.host, orgSlug, id);
|
|
@@ -12855,7 +12922,7 @@ async function listStandardsHandler(deps) {
|
|
|
12855
12922
|
}
|
|
12856
12923
|
|
|
12857
12924
|
// apps/cli/src/infra/commands/ListStandardsCommand.ts
|
|
12858
|
-
var listStandardsCommand = (0,
|
|
12925
|
+
var listStandardsCommand = (0, import_cmd_ts14.command)({
|
|
12859
12926
|
name: "list",
|
|
12860
12927
|
description: "List available coding standards",
|
|
12861
12928
|
args: {},
|
|
@@ -12872,7 +12939,7 @@ var listStandardsCommand = (0, import_cmd_ts13.command)({
|
|
|
12872
12939
|
});
|
|
12873
12940
|
|
|
12874
12941
|
// apps/cli/src/infra/commands/StandardsCommand.ts
|
|
12875
|
-
var standardsCommand = (0,
|
|
12942
|
+
var standardsCommand = (0, import_cmd_ts15.subcommands)({
|
|
12876
12943
|
name: "standards",
|
|
12877
12944
|
description: "Manage coding standards",
|
|
12878
12945
|
cmds: {
|
|
@@ -12882,10 +12949,10 @@ var standardsCommand = (0, import_cmd_ts14.subcommands)({
|
|
|
12882
12949
|
});
|
|
12883
12950
|
|
|
12884
12951
|
// apps/cli/src/infra/commands/CommandsCommand.ts
|
|
12885
|
-
var
|
|
12952
|
+
var import_cmd_ts18 = __toESM(require_cjs());
|
|
12886
12953
|
|
|
12887
12954
|
// apps/cli/src/infra/commands/CreateCommandCommand.ts
|
|
12888
|
-
var
|
|
12955
|
+
var import_cmd_ts16 = __toESM(require_cjs());
|
|
12889
12956
|
|
|
12890
12957
|
// apps/cli/src/infra/utils/readCommandPlaybookFile.ts
|
|
12891
12958
|
var fs14 = __toESM(require("fs/promises"));
|
|
@@ -12953,7 +13020,7 @@ async function readCommandPlaybookFile(filePath) {
|
|
|
12953
13020
|
function buildWebappUrl(host, orgSlug, commandId) {
|
|
12954
13021
|
return `${host}/org/${orgSlug}/space/global/commands/${commandId}`;
|
|
12955
13022
|
}
|
|
12956
|
-
async function createCommandHandler(filePath, useCase) {
|
|
13023
|
+
async function createCommandHandler(filePath, useCase, originSkill) {
|
|
12957
13024
|
const readResult = await readCommandPlaybookFile(filePath);
|
|
12958
13025
|
if (!readResult.isValid) {
|
|
12959
13026
|
return {
|
|
@@ -12968,11 +13035,14 @@ async function createCommandHandler(filePath, useCase) {
|
|
|
12968
13035
|
};
|
|
12969
13036
|
}
|
|
12970
13037
|
try {
|
|
12971
|
-
const result = await useCase.execute(
|
|
13038
|
+
const result = await useCase.execute({
|
|
13039
|
+
...readResult.data,
|
|
13040
|
+
originSkill
|
|
13041
|
+
});
|
|
12972
13042
|
let webappUrl;
|
|
12973
13043
|
const apiKey = loadApiKey();
|
|
12974
13044
|
if (apiKey) {
|
|
12975
|
-
const decoded =
|
|
13045
|
+
const decoded = decodeApiKey(apiKey);
|
|
12976
13046
|
if (decoded?.host && decoded?.jwt?.organization?.slug) {
|
|
12977
13047
|
webappUrl = buildWebappUrl(
|
|
12978
13048
|
decoded.host,
|
|
@@ -13002,7 +13072,8 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
13002
13072
|
}
|
|
13003
13073
|
async execute(playbook) {
|
|
13004
13074
|
const space = await this.gateway.spaces.getGlobal();
|
|
13005
|
-
const
|
|
13075
|
+
const command20 = await this.gateway.commands.create({
|
|
13076
|
+
spaceId: space.id,
|
|
13006
13077
|
name: playbook.name,
|
|
13007
13078
|
summary: playbook.summary,
|
|
13008
13079
|
whenToUse: playbook.whenToUse,
|
|
@@ -13011,34 +13082,36 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
13011
13082
|
name: step.name,
|
|
13012
13083
|
description: step.description,
|
|
13013
13084
|
codeSnippet: step.codeSnippet
|
|
13014
|
-
}))
|
|
13085
|
+
})),
|
|
13086
|
+
originSkill: playbook.originSkill
|
|
13015
13087
|
});
|
|
13016
13088
|
return {
|
|
13017
|
-
commandId:
|
|
13018
|
-
name:
|
|
13019
|
-
slug:
|
|
13089
|
+
commandId: command20.id,
|
|
13090
|
+
name: command20.name,
|
|
13091
|
+
slug: command20.slug
|
|
13020
13092
|
};
|
|
13021
13093
|
}
|
|
13022
13094
|
};
|
|
13023
13095
|
|
|
13024
13096
|
// apps/cli/src/infra/commands/CreateCommandCommand.ts
|
|
13025
|
-
var createCommandCommand = (0,
|
|
13097
|
+
var createCommandCommand = (0, import_cmd_ts16.command)({
|
|
13026
13098
|
name: "create",
|
|
13027
13099
|
description: "Create a command from a playbook JSON file",
|
|
13028
13100
|
args: {
|
|
13029
|
-
file: (0,
|
|
13101
|
+
file: (0, import_cmd_ts16.positional)({
|
|
13030
13102
|
displayName: "file",
|
|
13031
13103
|
description: "Path to the command playbook JSON file",
|
|
13032
|
-
type:
|
|
13033
|
-
})
|
|
13104
|
+
type: import_cmd_ts16.string
|
|
13105
|
+
}),
|
|
13106
|
+
originSkill: originSkillOption
|
|
13034
13107
|
},
|
|
13035
|
-
handler: async ({ file }) => {
|
|
13108
|
+
handler: async ({ file, originSkill }) => {
|
|
13036
13109
|
try {
|
|
13037
13110
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13038
13111
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13039
13112
|
const gateway = hexa.getPackmindGateway();
|
|
13040
13113
|
const useCase = new CreateCommandFromPlaybookUseCase(gateway);
|
|
13041
|
-
const result = await createCommandHandler(file, useCase);
|
|
13114
|
+
const result = await createCommandHandler(file, useCase, originSkill);
|
|
13042
13115
|
if (result.success) {
|
|
13043
13116
|
logSuccessConsole(
|
|
13044
13117
|
`Command "${result.commandName}" created successfully (ID: ${result.commandId})`
|
|
@@ -13062,7 +13135,7 @@ var createCommandCommand = (0, import_cmd_ts15.command)({
|
|
|
13062
13135
|
});
|
|
13063
13136
|
|
|
13064
13137
|
// apps/cli/src/infra/commands/ListCommandsCommand.ts
|
|
13065
|
-
var
|
|
13138
|
+
var import_cmd_ts17 = __toESM(require_cjs());
|
|
13066
13139
|
|
|
13067
13140
|
// apps/cli/src/infra/commands/listCommandsHandler.ts
|
|
13068
13141
|
function buildCommandUrl(host, orgSlug, commandId) {
|
|
@@ -13084,7 +13157,7 @@ async function listCommandsHandler(deps) {
|
|
|
13084
13157
|
let urlBuilder = null;
|
|
13085
13158
|
const apiKey = loadApiKey();
|
|
13086
13159
|
if (apiKey) {
|
|
13087
|
-
const decoded =
|
|
13160
|
+
const decoded = decodeApiKey(apiKey);
|
|
13088
13161
|
const orgSlug = decoded?.jwt?.organization?.slug;
|
|
13089
13162
|
if (decoded?.host && orgSlug) {
|
|
13090
13163
|
urlBuilder = (id) => buildCommandUrl(decoded.host, orgSlug, id);
|
|
@@ -13116,7 +13189,7 @@ async function listCommandsHandler(deps) {
|
|
|
13116
13189
|
}
|
|
13117
13190
|
|
|
13118
13191
|
// apps/cli/src/infra/commands/ListCommandsCommand.ts
|
|
13119
|
-
var listCommandsCommand = (0,
|
|
13192
|
+
var listCommandsCommand = (0, import_cmd_ts17.command)({
|
|
13120
13193
|
name: "list",
|
|
13121
13194
|
description: "List available commands",
|
|
13122
13195
|
args: {},
|
|
@@ -13133,7 +13206,7 @@ var listCommandsCommand = (0, import_cmd_ts16.command)({
|
|
|
13133
13206
|
});
|
|
13134
13207
|
|
|
13135
13208
|
// apps/cli/src/infra/commands/CommandsCommand.ts
|
|
13136
|
-
var commandsCommand = (0,
|
|
13209
|
+
var commandsCommand = (0, import_cmd_ts18.subcommands)({
|
|
13137
13210
|
name: "commands",
|
|
13138
13211
|
description: "Manage commands",
|
|
13139
13212
|
cmds: {
|
|
@@ -13143,16 +13216,16 @@ var commandsCommand = (0, import_cmd_ts17.subcommands)({
|
|
|
13143
13216
|
});
|
|
13144
13217
|
|
|
13145
13218
|
// apps/cli/src/infra/commands/PackagesCommand.ts
|
|
13146
|
-
var
|
|
13219
|
+
var import_cmd_ts22 = __toESM(require_cjs());
|
|
13147
13220
|
|
|
13148
13221
|
// apps/cli/src/infra/commands/CreatePackageCommand.ts
|
|
13149
|
-
var
|
|
13222
|
+
var import_cmd_ts19 = __toESM(require_cjs());
|
|
13150
13223
|
|
|
13151
13224
|
// apps/cli/src/infra/commands/createPackageHandler.ts
|
|
13152
13225
|
function buildWebappUrl2(host, orgSlug, packageId) {
|
|
13153
13226
|
return `${host}/org/${orgSlug}/space/global/packages/${packageId}`;
|
|
13154
13227
|
}
|
|
13155
|
-
async function createPackageHandler(name, description, useCase) {
|
|
13228
|
+
async function createPackageHandler(name, description, useCase, originSkill) {
|
|
13156
13229
|
const trimmedName = name.trim();
|
|
13157
13230
|
if (!trimmedName) {
|
|
13158
13231
|
return { success: false, error: "Package name is required" };
|
|
@@ -13160,12 +13233,13 @@ async function createPackageHandler(name, description, useCase) {
|
|
|
13160
13233
|
try {
|
|
13161
13234
|
const result = await useCase.execute({
|
|
13162
13235
|
name: trimmedName,
|
|
13163
|
-
description
|
|
13236
|
+
description,
|
|
13237
|
+
originSkill
|
|
13164
13238
|
});
|
|
13165
13239
|
let webappUrl;
|
|
13166
13240
|
const apiKey = loadApiKey();
|
|
13167
13241
|
if (apiKey) {
|
|
13168
|
-
const decoded =
|
|
13242
|
+
const decoded = decodeApiKey(apiKey);
|
|
13169
13243
|
if (decoded?.host && decoded?.jwt?.organization?.slug) {
|
|
13170
13244
|
webappUrl = buildWebappUrl2(
|
|
13171
13245
|
decoded.host,
|
|
@@ -13194,44 +13268,54 @@ var CreatePackageUseCase = class {
|
|
|
13194
13268
|
constructor(gateway) {
|
|
13195
13269
|
this.gateway = gateway;
|
|
13196
13270
|
}
|
|
13197
|
-
async execute(
|
|
13271
|
+
async execute(command20) {
|
|
13198
13272
|
const space = await this.gateway.spaces.getGlobal();
|
|
13199
|
-
const result = await this.gateway.packages.create(
|
|
13200
|
-
|
|
13201
|
-
|
|
13273
|
+
const result = await this.gateway.packages.create({
|
|
13274
|
+
spaceId: space.id,
|
|
13275
|
+
name: command20.name,
|
|
13276
|
+
description: command20.description ?? "",
|
|
13277
|
+
recipeIds: [],
|
|
13278
|
+
standardIds: [],
|
|
13279
|
+
originSkill: command20.originSkill
|
|
13202
13280
|
});
|
|
13203
13281
|
return {
|
|
13204
|
-
packageId: result.id,
|
|
13205
|
-
name: result.name,
|
|
13206
|
-
slug: result.slug
|
|
13282
|
+
packageId: result.package.id,
|
|
13283
|
+
name: result.package.name,
|
|
13284
|
+
slug: result.package.slug
|
|
13207
13285
|
};
|
|
13208
13286
|
}
|
|
13209
13287
|
};
|
|
13210
13288
|
|
|
13211
13289
|
// apps/cli/src/infra/commands/CreatePackageCommand.ts
|
|
13212
|
-
var createPackageCommand = (0,
|
|
13290
|
+
var createPackageCommand = (0, import_cmd_ts19.command)({
|
|
13213
13291
|
name: "create",
|
|
13214
13292
|
description: "Create a new package",
|
|
13215
13293
|
args: {
|
|
13216
|
-
name: (0,
|
|
13294
|
+
name: (0, import_cmd_ts19.positional)({
|
|
13217
13295
|
displayName: "name",
|
|
13218
13296
|
description: "Name of the package to create",
|
|
13219
|
-
type:
|
|
13297
|
+
type: import_cmd_ts19.string
|
|
13220
13298
|
}),
|
|
13221
|
-
description: (0,
|
|
13299
|
+
description: (0, import_cmd_ts19.option)({
|
|
13222
13300
|
long: "description",
|
|
13223
13301
|
short: "d",
|
|
13224
13302
|
description: "Description of the package (optional)",
|
|
13225
|
-
type: (0,
|
|
13226
|
-
})
|
|
13303
|
+
type: (0, import_cmd_ts19.optional)(import_cmd_ts19.string)
|
|
13304
|
+
}),
|
|
13305
|
+
originSkill: originSkillOption
|
|
13227
13306
|
},
|
|
13228
|
-
handler: async ({ name, description }) => {
|
|
13307
|
+
handler: async ({ name, description, originSkill }) => {
|
|
13229
13308
|
try {
|
|
13230
13309
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13231
13310
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13232
13311
|
const gateway = hexa.getPackmindGateway();
|
|
13233
13312
|
const useCase = new CreatePackageUseCase(gateway);
|
|
13234
|
-
const result = await createPackageHandler(
|
|
13313
|
+
const result = await createPackageHandler(
|
|
13314
|
+
name,
|
|
13315
|
+
description,
|
|
13316
|
+
useCase,
|
|
13317
|
+
originSkill
|
|
13318
|
+
);
|
|
13235
13319
|
if (result.success) {
|
|
13236
13320
|
logConsole("");
|
|
13237
13321
|
logConsole(formatHeader(`\u2705 Package created successfully
|
|
@@ -13264,35 +13348,536 @@ var createPackageCommand = (0, import_cmd_ts18.command)({
|
|
|
13264
13348
|
}
|
|
13265
13349
|
});
|
|
13266
13350
|
|
|
13351
|
+
// apps/cli/src/infra/commands/AddToPackageCommand.ts
|
|
13352
|
+
var import_cmd_ts20 = __toESM(require_cjs());
|
|
13353
|
+
|
|
13354
|
+
// apps/cli/src/domain/errors/ItemNotFoundError.ts
|
|
13355
|
+
var ItemNotFoundError = class extends Error {
|
|
13356
|
+
constructor(itemType, slug) {
|
|
13357
|
+
super(`${itemType} '${slug}' not found`);
|
|
13358
|
+
this.itemType = itemType;
|
|
13359
|
+
this.slug = slug;
|
|
13360
|
+
this.name = "ItemNotFoundError";
|
|
13361
|
+
}
|
|
13362
|
+
};
|
|
13363
|
+
|
|
13364
|
+
// apps/cli/src/application/useCases/AddToPackageUseCase.ts
|
|
13365
|
+
var AddToPackageUseCase = class {
|
|
13366
|
+
constructor(gateway) {
|
|
13367
|
+
this.gateway = gateway;
|
|
13368
|
+
}
|
|
13369
|
+
async execute(command20) {
|
|
13370
|
+
const { packageSlug, itemType, itemSlugs } = command20;
|
|
13371
|
+
const space = await this.gateway.spaces.getGlobal();
|
|
13372
|
+
const packages = await this.gateway.packages.list({});
|
|
13373
|
+
const pkg = packages.packages.find((pkg2) => pkg2.slug === packageSlug);
|
|
13374
|
+
if (!pkg) {
|
|
13375
|
+
throw new ItemNotFoundError("package", packageSlug);
|
|
13376
|
+
}
|
|
13377
|
+
const { ids, idToSlugMap } = await this.resolveSlugsToIds(
|
|
13378
|
+
itemType,
|
|
13379
|
+
itemSlugs
|
|
13380
|
+
);
|
|
13381
|
+
const addCommand = {
|
|
13382
|
+
packageId: pkg.id,
|
|
13383
|
+
spaceId: space.id,
|
|
13384
|
+
standardIds: [],
|
|
13385
|
+
recipeIds: [],
|
|
13386
|
+
skillIds: [],
|
|
13387
|
+
originSkill: command20.originSkill
|
|
13388
|
+
};
|
|
13389
|
+
if (itemType === "standard") {
|
|
13390
|
+
addCommand.standardIds = ids.map(createStandardId);
|
|
13391
|
+
} else if (itemType === "command") {
|
|
13392
|
+
addCommand.recipeIds = ids.map(createRecipeId);
|
|
13393
|
+
} else if (itemType === "skill") {
|
|
13394
|
+
addCommand.skillIds = ids.map(createSkillId);
|
|
13395
|
+
}
|
|
13396
|
+
const result = await this.gateway.packages.addArtefacts(addCommand);
|
|
13397
|
+
const typeKey = itemType === "command" ? "commands" : `${itemType}s`;
|
|
13398
|
+
const addedIds = result.added[typeKey];
|
|
13399
|
+
const skippedIds = result.skipped[typeKey];
|
|
13400
|
+
return {
|
|
13401
|
+
added: addedIds.map((id) => idToSlugMap.get(id) ?? id),
|
|
13402
|
+
skipped: skippedIds.map((id) => idToSlugMap.get(id) ?? id)
|
|
13403
|
+
};
|
|
13404
|
+
}
|
|
13405
|
+
async resolveSlugsToIds(itemType, slugs) {
|
|
13406
|
+
const ids = [];
|
|
13407
|
+
const idToSlugMap = /* @__PURE__ */ new Map();
|
|
13408
|
+
const globalSpace = await this.gateway.spaces.getGlobal();
|
|
13409
|
+
for (const slug of slugs) {
|
|
13410
|
+
let item = null;
|
|
13411
|
+
if (itemType === "standard") {
|
|
13412
|
+
item = await this.findStandardBySlug(slug, globalSpace.id);
|
|
13413
|
+
} else if (itemType === "command") {
|
|
13414
|
+
item = await this.findCommandBySlug(slug, globalSpace.id);
|
|
13415
|
+
} else if (itemType === "skill") {
|
|
13416
|
+
item = await this.findSkillBySlug(slug, globalSpace.id);
|
|
13417
|
+
}
|
|
13418
|
+
if (!item) {
|
|
13419
|
+
throw new ItemNotFoundError(itemType, slug);
|
|
13420
|
+
}
|
|
13421
|
+
ids.push(item.id);
|
|
13422
|
+
idToSlugMap.set(item.id, slug);
|
|
13423
|
+
}
|
|
13424
|
+
return { ids, idToSlugMap };
|
|
13425
|
+
}
|
|
13426
|
+
async findStandardBySlug(slug, spaceId) {
|
|
13427
|
+
const standards = await this.gateway.standards.list({ spaceId });
|
|
13428
|
+
return standards.standards.find((skill) => skill.slug === slug) ?? null;
|
|
13429
|
+
}
|
|
13430
|
+
async findCommandBySlug(slug, spaceId) {
|
|
13431
|
+
const commands = await this.gateway.commands.list({ spaceId });
|
|
13432
|
+
return commands.recipes.find((command20) => command20.slug === slug) ?? null;
|
|
13433
|
+
}
|
|
13434
|
+
async findSkillBySlug(slug, spaceId) {
|
|
13435
|
+
const skills = await this.gateway.skills.list({ spaceId });
|
|
13436
|
+
return skills.find((skill) => skill.slug === slug) ?? null;
|
|
13437
|
+
}
|
|
13438
|
+
};
|
|
13439
|
+
|
|
13440
|
+
// apps/cli/src/infra/commands/addToPackageHandler.ts
|
|
13441
|
+
function pluralize(singular, count) {
|
|
13442
|
+
return count === 1 ? singular : `${singular}s`;
|
|
13443
|
+
}
|
|
13444
|
+
function formatItemType(itemType, count) {
|
|
13445
|
+
return pluralize(itemType.charAt(0).toUpperCase() + itemType.slice(1), count);
|
|
13446
|
+
}
|
|
13447
|
+
function formatItemList(items) {
|
|
13448
|
+
return items.map((item) => `"${item}"`).join(", ");
|
|
13449
|
+
}
|
|
13450
|
+
async function addToPackageHandler(packageSlug, itemType, itemSlugs, useCase, originSkill) {
|
|
13451
|
+
if (itemSlugs.length === 0) {
|
|
13452
|
+
return { success: false, error: "No items provided to add" };
|
|
13453
|
+
}
|
|
13454
|
+
try {
|
|
13455
|
+
const result = await useCase.execute({
|
|
13456
|
+
packageSlug,
|
|
13457
|
+
itemType,
|
|
13458
|
+
itemSlugs,
|
|
13459
|
+
originSkill
|
|
13460
|
+
});
|
|
13461
|
+
if (result.added.length) {
|
|
13462
|
+
logSuccessConsole(
|
|
13463
|
+
`${formatItemType(itemType, result.added.length)} ${formatItemList(result.added)} added to "${packageSlug}"`
|
|
13464
|
+
);
|
|
13465
|
+
logSuccessConsole(
|
|
13466
|
+
`Run \`packmind-cli install ${packageSlug}\` to install the ${pluralize(itemType, result.added.length)}`
|
|
13467
|
+
);
|
|
13468
|
+
}
|
|
13469
|
+
if (result.skipped.length) {
|
|
13470
|
+
logWarningConsole(
|
|
13471
|
+
`${formatItemType(itemType, result.skipped.length)} ${formatItemList(result.skipped)} already in "${packageSlug}" (skipped)`
|
|
13472
|
+
);
|
|
13473
|
+
}
|
|
13474
|
+
return { success: true, added: result.added, skipped: result.skipped };
|
|
13475
|
+
} catch (error) {
|
|
13476
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13477
|
+
logErrorConsole(message);
|
|
13478
|
+
if (error instanceof ItemNotFoundError) {
|
|
13479
|
+
logInfoConsole(
|
|
13480
|
+
`Run \`packmind-cli ${error.itemType}s list\` to display available ${error.itemType}s`
|
|
13481
|
+
);
|
|
13482
|
+
}
|
|
13483
|
+
return { success: false, error: message };
|
|
13484
|
+
}
|
|
13485
|
+
}
|
|
13486
|
+
|
|
13487
|
+
// apps/cli/src/infra/commands/AddToPackageCommand.ts
|
|
13488
|
+
var addToPackageCommand = (0, import_cmd_ts20.command)({
|
|
13489
|
+
name: "add",
|
|
13490
|
+
description: "Add standards, commands, or skills to a package",
|
|
13491
|
+
args: {
|
|
13492
|
+
to: (0, import_cmd_ts20.option)({
|
|
13493
|
+
long: "to",
|
|
13494
|
+
description: "Target package slug",
|
|
13495
|
+
type: import_cmd_ts20.string
|
|
13496
|
+
}),
|
|
13497
|
+
standards: (0, import_cmd_ts20.multioption)({
|
|
13498
|
+
long: "standard",
|
|
13499
|
+
description: "Standard slug(s) to add",
|
|
13500
|
+
type: (0, import_cmd_ts20.array)(import_cmd_ts20.string)
|
|
13501
|
+
}),
|
|
13502
|
+
commands: (0, import_cmd_ts20.multioption)({
|
|
13503
|
+
long: "command",
|
|
13504
|
+
description: "Command slug(s) to add",
|
|
13505
|
+
type: (0, import_cmd_ts20.array)(import_cmd_ts20.string)
|
|
13506
|
+
}),
|
|
13507
|
+
skills: (0, import_cmd_ts20.multioption)({
|
|
13508
|
+
long: "skill",
|
|
13509
|
+
description: "Skill slug(s) to add",
|
|
13510
|
+
type: (0, import_cmd_ts20.array)(import_cmd_ts20.string)
|
|
13511
|
+
}),
|
|
13512
|
+
originSkill: originSkillOption
|
|
13513
|
+
},
|
|
13514
|
+
handler: async ({ to, standards, commands, skills, originSkill }) => {
|
|
13515
|
+
const standardSlugs = standards ?? [];
|
|
13516
|
+
const commandSlugs = commands ?? [];
|
|
13517
|
+
const skillSlugs = skills ?? [];
|
|
13518
|
+
const itemTypes = [
|
|
13519
|
+
{ type: "standard", slugs: standardSlugs },
|
|
13520
|
+
{ type: "command", slugs: commandSlugs },
|
|
13521
|
+
{ type: "skill", slugs: skillSlugs }
|
|
13522
|
+
].filter((t) => t.slugs.length > 0);
|
|
13523
|
+
if (itemTypes.length === 0) {
|
|
13524
|
+
logErrorConsole(
|
|
13525
|
+
"Error: At least one --standard, --command, or --skill is required"
|
|
13526
|
+
);
|
|
13527
|
+
process.exit(1);
|
|
13528
|
+
}
|
|
13529
|
+
if (itemTypes.length > 1) {
|
|
13530
|
+
logErrorConsole(
|
|
13531
|
+
"Cannot add standards, commands, and skills simultaneously. Use dedicated commands for each artefact."
|
|
13532
|
+
);
|
|
13533
|
+
process.exit(1);
|
|
13534
|
+
}
|
|
13535
|
+
const { type: itemType, slugs: itemSlugs } = itemTypes[0];
|
|
13536
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13537
|
+
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13538
|
+
const gateway = hexa.getPackmindGateway();
|
|
13539
|
+
const useCase = new AddToPackageUseCase(gateway);
|
|
13540
|
+
const result = await addToPackageHandler(
|
|
13541
|
+
to,
|
|
13542
|
+
itemType,
|
|
13543
|
+
itemSlugs,
|
|
13544
|
+
useCase,
|
|
13545
|
+
originSkill
|
|
13546
|
+
);
|
|
13547
|
+
if (!result.success) {
|
|
13548
|
+
process.exit(1);
|
|
13549
|
+
}
|
|
13550
|
+
}
|
|
13551
|
+
});
|
|
13552
|
+
|
|
13553
|
+
// apps/cli/src/infra/commands/listPackagesCommand.ts
|
|
13554
|
+
var import_cmd_ts21 = __toESM(require_cjs());
|
|
13555
|
+
var listPackagesCommand = (0, import_cmd_ts21.command)({
|
|
13556
|
+
name: "list",
|
|
13557
|
+
description: "List available packages",
|
|
13558
|
+
args: {},
|
|
13559
|
+
handler: async () => {
|
|
13560
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13561
|
+
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
13562
|
+
const deps = {
|
|
13563
|
+
packmindCliHexa,
|
|
13564
|
+
exit: process.exit,
|
|
13565
|
+
getCwd: () => process.cwd(),
|
|
13566
|
+
log: console.log,
|
|
13567
|
+
error: console.error
|
|
13568
|
+
};
|
|
13569
|
+
await listPackagesHandler({}, deps);
|
|
13570
|
+
}
|
|
13571
|
+
});
|
|
13572
|
+
|
|
13267
13573
|
// apps/cli/src/infra/commands/PackagesCommand.ts
|
|
13268
|
-
var packagesCommand = (0,
|
|
13574
|
+
var packagesCommand = (0, import_cmd_ts22.subcommands)({
|
|
13269
13575
|
name: "packages",
|
|
13270
13576
|
description: "Manage packages",
|
|
13271
13577
|
cmds: {
|
|
13272
|
-
create: createPackageCommand
|
|
13578
|
+
create: createPackageCommand,
|
|
13579
|
+
add: addToPackageCommand,
|
|
13580
|
+
list: listPackagesCommand
|
|
13273
13581
|
}
|
|
13274
13582
|
});
|
|
13275
13583
|
|
|
13276
|
-
// apps/cli/src/
|
|
13584
|
+
// apps/cli/src/infra/commands/config/ConfigCommand.ts
|
|
13585
|
+
var import_cmd_ts24 = __toESM(require_cjs());
|
|
13586
|
+
|
|
13587
|
+
// apps/cli/src/infra/commands/config/ConfigAgentsCommand.ts
|
|
13588
|
+
var import_cmd_ts23 = __toESM(require_cjs());
|
|
13589
|
+
|
|
13590
|
+
// apps/cli/src/application/services/AgentArtifactDetectionService.ts
|
|
13591
|
+
var fs15 = __toESM(require("fs/promises"));
|
|
13592
|
+
var path12 = __toESM(require("path"));
|
|
13593
|
+
var AGENT_ARTIFACT_CHECKS = [
|
|
13594
|
+
{ agent: "claude", paths: [".claude"] },
|
|
13595
|
+
{ agent: "cursor", paths: [".cursor"] },
|
|
13596
|
+
{
|
|
13597
|
+
agent: "copilot",
|
|
13598
|
+
paths: [".github/copilot-instructions.md", ".github/instructions"]
|
|
13599
|
+
},
|
|
13600
|
+
{ agent: "continue", paths: [".continue"] },
|
|
13601
|
+
{ agent: "junie", paths: [".junie", ".junie.md"] },
|
|
13602
|
+
{ agent: "agents_md", paths: ["AGENTS.md"] },
|
|
13603
|
+
{ agent: "gitlab_duo", paths: [".gitlab"] }
|
|
13604
|
+
];
|
|
13605
|
+
var AgentArtifactDetectionService = class {
|
|
13606
|
+
async detectAgentArtifacts(baseDirectory) {
|
|
13607
|
+
const detected = [];
|
|
13608
|
+
for (const check of AGENT_ARTIFACT_CHECKS) {
|
|
13609
|
+
for (const relativePath of check.paths) {
|
|
13610
|
+
const fullPath = path12.join(baseDirectory, relativePath);
|
|
13611
|
+
const exists = await this.pathExists(fullPath);
|
|
13612
|
+
if (exists) {
|
|
13613
|
+
detected.push({
|
|
13614
|
+
agent: check.agent,
|
|
13615
|
+
artifactPath: fullPath
|
|
13616
|
+
});
|
|
13617
|
+
break;
|
|
13618
|
+
}
|
|
13619
|
+
}
|
|
13620
|
+
}
|
|
13621
|
+
return detected;
|
|
13622
|
+
}
|
|
13623
|
+
async pathExists(filePath) {
|
|
13624
|
+
try {
|
|
13625
|
+
await fs15.access(filePath);
|
|
13626
|
+
return true;
|
|
13627
|
+
} catch {
|
|
13628
|
+
return false;
|
|
13629
|
+
}
|
|
13630
|
+
}
|
|
13631
|
+
};
|
|
13632
|
+
|
|
13633
|
+
// apps/cli/src/infra/commands/config/configAgentsHandler.ts
|
|
13634
|
+
var readline3 = __toESM(require("readline"));
|
|
13635
|
+
var inquirer2 = __toESM(require("inquirer"));
|
|
13636
|
+
var SELECTABLE_AGENTS = [
|
|
13637
|
+
"claude",
|
|
13638
|
+
"cursor",
|
|
13639
|
+
"copilot",
|
|
13640
|
+
"agents_md",
|
|
13641
|
+
"continue",
|
|
13642
|
+
"junie",
|
|
13643
|
+
"gitlab_duo"
|
|
13644
|
+
];
|
|
13645
|
+
var AGENT_DISPLAY_NAMES = {
|
|
13646
|
+
packmind: "Packmind",
|
|
13647
|
+
claude: "Claude Code",
|
|
13648
|
+
cursor: "Cursor",
|
|
13649
|
+
copilot: "GitHub Copilot",
|
|
13650
|
+
continue: "Continue.dev",
|
|
13651
|
+
junie: "Junie",
|
|
13652
|
+
agents_md: "AGENTS.md",
|
|
13653
|
+
gitlab_duo: "GitLab Duo"
|
|
13654
|
+
};
|
|
13655
|
+
async function configAgentsHandler(deps) {
|
|
13656
|
+
const { configRepository, baseDirectory } = deps;
|
|
13657
|
+
const isTTY = deps.isTTY ?? process.stdin.isTTY;
|
|
13658
|
+
const useSimplePrompt = process.env.PACKMIND_SIMPLE_PROMPT === "1" || !isTTY;
|
|
13659
|
+
const preselectedAgents = await getPreselectedAgents(deps);
|
|
13660
|
+
const choices = SELECTABLE_AGENTS.map((agent) => ({
|
|
13661
|
+
name: AGENT_DISPLAY_NAMES[agent],
|
|
13662
|
+
value: agent,
|
|
13663
|
+
checked: preselectedAgents.has(agent)
|
|
13664
|
+
}));
|
|
13665
|
+
let selectedAgents;
|
|
13666
|
+
if (useSimplePrompt) {
|
|
13667
|
+
selectedAgents = await promptAgentsWithReadline2(choices);
|
|
13668
|
+
} else {
|
|
13669
|
+
const result = await inquirer2.default.prompt([
|
|
13670
|
+
{
|
|
13671
|
+
type: "checkbox",
|
|
13672
|
+
name: "selectedAgents",
|
|
13673
|
+
message: "Select coding agents to generate artifacts for:",
|
|
13674
|
+
choices
|
|
13675
|
+
}
|
|
13676
|
+
]);
|
|
13677
|
+
selectedAgents = result.selectedAgents;
|
|
13678
|
+
}
|
|
13679
|
+
await configRepository.updateAgentsConfig(baseDirectory, selectedAgents);
|
|
13680
|
+
const agentNames = selectedAgents.map((a) => AGENT_DISPLAY_NAMES[a]);
|
|
13681
|
+
if (selectedAgents.length === 0) {
|
|
13682
|
+
logInfoConsole(
|
|
13683
|
+
"No agents selected. Only packmind artifacts will be generated."
|
|
13684
|
+
);
|
|
13685
|
+
} else {
|
|
13686
|
+
logSuccessConsole(
|
|
13687
|
+
`Configuration saved. Artifacts will be generated for: ${agentNames.join(", ")}`
|
|
13688
|
+
);
|
|
13689
|
+
}
|
|
13690
|
+
}
|
|
13691
|
+
async function promptAgentsWithReadline2(choices) {
|
|
13692
|
+
const input = process.stdin;
|
|
13693
|
+
const output = process.stdout;
|
|
13694
|
+
const rl = readline3.createInterface({
|
|
13695
|
+
input,
|
|
13696
|
+
output
|
|
13697
|
+
});
|
|
13698
|
+
output.write("\nSelect coding agents to generate artifacts for:\n");
|
|
13699
|
+
choices.forEach((choice, index) => {
|
|
13700
|
+
const marker = choice.checked ? "*" : " ";
|
|
13701
|
+
output.write(` ${index + 1}. [${marker}] ${choice.name}
|
|
13702
|
+
`);
|
|
13703
|
+
});
|
|
13704
|
+
output.write("\n");
|
|
13705
|
+
const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
|
|
13706
|
+
const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
|
|
13707
|
+
return new Promise((resolve7) => {
|
|
13708
|
+
rl.question(
|
|
13709
|
+
`Enter numbers separated by commas (default: ${defaultValue}): `,
|
|
13710
|
+
(answer) => {
|
|
13711
|
+
rl.close();
|
|
13712
|
+
const trimmed = answer.trim();
|
|
13713
|
+
const numbersStr = trimmed === "" ? defaultValue : trimmed;
|
|
13714
|
+
const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
|
|
13715
|
+
const selectedAgents = numbers.map((n) => choices[n - 1].value);
|
|
13716
|
+
resolve7(selectedAgents);
|
|
13717
|
+
}
|
|
13718
|
+
);
|
|
13719
|
+
});
|
|
13720
|
+
}
|
|
13721
|
+
async function getPreselectedAgents(deps) {
|
|
13722
|
+
const { configRepository, agentDetectionService, baseDirectory } = deps;
|
|
13723
|
+
const existingConfig = await configRepository.readConfig(baseDirectory);
|
|
13724
|
+
if (existingConfig?.agents && existingConfig.agents.length > 0) {
|
|
13725
|
+
return new Set(
|
|
13726
|
+
existingConfig.agents.filter(
|
|
13727
|
+
(agent) => SELECTABLE_AGENTS.includes(agent)
|
|
13728
|
+
)
|
|
13729
|
+
);
|
|
13730
|
+
}
|
|
13731
|
+
const detectedArtifacts = await agentDetectionService.detectAgentArtifacts(baseDirectory);
|
|
13732
|
+
if (detectedArtifacts.length > 0) {
|
|
13733
|
+
return new Set(detectedArtifacts.map((a) => a.agent));
|
|
13734
|
+
}
|
|
13735
|
+
try {
|
|
13736
|
+
const result = await deps.packmindGateway.deployment.getRenderModeConfiguration({});
|
|
13737
|
+
if (result.configuration) {
|
|
13738
|
+
return new Set(
|
|
13739
|
+
result.configuration.activeRenderModes.map((mode) => RENDER_MODE_TO_CODING_AGENT[mode]).filter((agent) => agent !== void 0)
|
|
13740
|
+
);
|
|
13741
|
+
}
|
|
13742
|
+
} catch {
|
|
13743
|
+
}
|
|
13744
|
+
return /* @__PURE__ */ new Set();
|
|
13745
|
+
}
|
|
13746
|
+
|
|
13747
|
+
// apps/cli/src/infra/commands/config/ConfigAgentsCommand.ts
|
|
13748
|
+
var configAgentsCommand = (0, import_cmd_ts23.command)({
|
|
13749
|
+
name: "agents",
|
|
13750
|
+
description: "Configure which coding agents to generate artifacts for",
|
|
13751
|
+
args: {},
|
|
13752
|
+
handler: async () => {
|
|
13753
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13754
|
+
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
13755
|
+
const configRepository = new ConfigFileRepository();
|
|
13756
|
+
const agentDetectionService = new AgentArtifactDetectionService();
|
|
13757
|
+
const baseDirectory = process.cwd();
|
|
13758
|
+
await configAgentsHandler({
|
|
13759
|
+
configRepository,
|
|
13760
|
+
agentDetectionService,
|
|
13761
|
+
packmindGateway: packmindCliHexa.getPackmindGateway(),
|
|
13762
|
+
baseDirectory
|
|
13763
|
+
});
|
|
13764
|
+
}
|
|
13765
|
+
});
|
|
13766
|
+
|
|
13767
|
+
// apps/cli/src/infra/commands/config/ConfigCommand.ts
|
|
13768
|
+
var configCommand = (0, import_cmd_ts24.subcommands)({
|
|
13769
|
+
name: "config",
|
|
13770
|
+
description: "Manage Packmind configuration",
|
|
13771
|
+
cmds: {
|
|
13772
|
+
agents: configAgentsCommand
|
|
13773
|
+
}
|
|
13774
|
+
});
|
|
13775
|
+
|
|
13776
|
+
// apps/cli/src/infra/commands/InitCommand.ts
|
|
13777
|
+
var import_cmd_ts25 = __toESM(require_cjs());
|
|
13778
|
+
|
|
13779
|
+
// apps/cli/src/infra/commands/initHandler.ts
|
|
13780
|
+
async function initHandler(deps) {
|
|
13781
|
+
const {
|
|
13782
|
+
configRepository,
|
|
13783
|
+
agentDetectionService,
|
|
13784
|
+
packmindGateway,
|
|
13785
|
+
baseDirectory,
|
|
13786
|
+
installDefaultSkills,
|
|
13787
|
+
cliVersion,
|
|
13788
|
+
isTTY
|
|
13789
|
+
} = deps;
|
|
13790
|
+
const configAgentsDeps = {
|
|
13791
|
+
configRepository,
|
|
13792
|
+
agentDetectionService,
|
|
13793
|
+
packmindGateway,
|
|
13794
|
+
baseDirectory,
|
|
13795
|
+
isTTY
|
|
13796
|
+
};
|
|
13797
|
+
await configAgentsHandler(configAgentsDeps);
|
|
13798
|
+
logInfoConsole("Installing default skills...");
|
|
13799
|
+
const result = await installDefaultSkills({
|
|
13800
|
+
includeBeta: false,
|
|
13801
|
+
cliVersion
|
|
13802
|
+
});
|
|
13803
|
+
if (result.errors.length > 0) {
|
|
13804
|
+
return {
|
|
13805
|
+
success: false,
|
|
13806
|
+
errors: result.errors
|
|
13807
|
+
};
|
|
13808
|
+
}
|
|
13809
|
+
const totalFiles = result.filesCreated + result.filesUpdated;
|
|
13810
|
+
if (totalFiles === 0) {
|
|
13811
|
+
logInfoConsole("Default skills are already up to date.");
|
|
13812
|
+
} else {
|
|
13813
|
+
logSuccessConsole("Default skills installed successfully!");
|
|
13814
|
+
if (result.filesCreated > 0) {
|
|
13815
|
+
logInfoConsole(` Files created: ${result.filesCreated}`);
|
|
13816
|
+
}
|
|
13817
|
+
if (result.filesUpdated > 0) {
|
|
13818
|
+
logInfoConsole(` Files updated: ${result.filesUpdated}`);
|
|
13819
|
+
}
|
|
13820
|
+
}
|
|
13821
|
+
logConsole("");
|
|
13822
|
+
logSuccessConsole("Packmind initialized successfully!");
|
|
13823
|
+
logInfoConsole(
|
|
13824
|
+
`Next step: Run ${formatCommand("/packmind-onboard")} in your AI agent to onboard the project`
|
|
13825
|
+
);
|
|
13826
|
+
return {
|
|
13827
|
+
success: true,
|
|
13828
|
+
errors: []
|
|
13829
|
+
};
|
|
13830
|
+
}
|
|
13831
|
+
|
|
13832
|
+
// apps/cli/src/infra/commands/InitCommand.ts
|
|
13277
13833
|
var { version: CLI_VERSION3 } = require_package();
|
|
13834
|
+
var initCommand = (0, import_cmd_ts25.command)({
|
|
13835
|
+
name: "init",
|
|
13836
|
+
description: "Initialize Packmind in the current project",
|
|
13837
|
+
args: {},
|
|
13838
|
+
handler: async () => {
|
|
13839
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13840
|
+
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
13841
|
+
const configRepository = new ConfigFileRepository();
|
|
13842
|
+
const agentDetectionService = new AgentArtifactDetectionService();
|
|
13843
|
+
const baseDirectory = process.cwd();
|
|
13844
|
+
const result = await initHandler({
|
|
13845
|
+
configRepository,
|
|
13846
|
+
agentDetectionService,
|
|
13847
|
+
packmindGateway: packmindCliHexa.getPackmindGateway(),
|
|
13848
|
+
baseDirectory,
|
|
13849
|
+
installDefaultSkills: packmindCliHexa.installDefaultSkills.bind(packmindCliHexa),
|
|
13850
|
+
cliVersion: CLI_VERSION3
|
|
13851
|
+
});
|
|
13852
|
+
if (!result.success) {
|
|
13853
|
+
for (const error of result.errors) {
|
|
13854
|
+
logErrorConsole(`Error: ${error}`);
|
|
13855
|
+
}
|
|
13856
|
+
process.exit(1);
|
|
13857
|
+
}
|
|
13858
|
+
}
|
|
13859
|
+
});
|
|
13860
|
+
|
|
13861
|
+
// apps/cli/src/main.ts
|
|
13862
|
+
var { version: CLI_VERSION4 } = require_package();
|
|
13278
13863
|
function findEnvFile() {
|
|
13279
13864
|
const currentDir = process.cwd();
|
|
13280
13865
|
const gitService = new GitService();
|
|
13281
13866
|
const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
|
|
13282
|
-
const filesystemRoot =
|
|
13867
|
+
const filesystemRoot = path13.parse(currentDir).root;
|
|
13283
13868
|
const stopDir = gitRoot ?? filesystemRoot;
|
|
13284
13869
|
let searchDir = currentDir;
|
|
13285
|
-
let parentDir =
|
|
13870
|
+
let parentDir = path13.dirname(searchDir);
|
|
13286
13871
|
while (searchDir !== parentDir) {
|
|
13287
|
-
const envPath2 =
|
|
13288
|
-
if (
|
|
13872
|
+
const envPath2 = path13.join(searchDir, ".env");
|
|
13873
|
+
if (fs16.existsSync(envPath2)) {
|
|
13289
13874
|
return envPath2;
|
|
13290
13875
|
}
|
|
13291
13876
|
if (searchDir === stopDir) {
|
|
13292
13877
|
return null;
|
|
13293
13878
|
}
|
|
13294
13879
|
searchDir = parentDir;
|
|
13295
|
-
parentDir =
|
|
13880
|
+
parentDir = path13.dirname(searchDir);
|
|
13296
13881
|
}
|
|
13297
13882
|
return null;
|
|
13298
13883
|
}
|
|
@@ -13309,29 +13894,31 @@ if (hasEmbeddedWasmFiles()) {
|
|
|
13309
13894
|
}
|
|
13310
13895
|
var args = process.argv.slice(2);
|
|
13311
13896
|
if (args.includes("--version") || args.includes("-v")) {
|
|
13312
|
-
logConsole(`packmind-cli version ${
|
|
13897
|
+
logConsole(`packmind-cli version ${CLI_VERSION4}`);
|
|
13313
13898
|
process.exit(0);
|
|
13314
13899
|
}
|
|
13315
|
-
var app = (0,
|
|
13900
|
+
var app = (0, import_cmd_ts26.subcommands)({
|
|
13316
13901
|
name: "packmind-cli",
|
|
13317
13902
|
description: "Packmind CLI tool",
|
|
13318
13903
|
cmds: {
|
|
13319
|
-
|
|
13904
|
+
commands: commandsCommand,
|
|
13905
|
+
config: configCommand,
|
|
13906
|
+
init: initCommand,
|
|
13320
13907
|
install: installCommand,
|
|
13321
|
-
|
|
13322
|
-
remove: uninstallCommand,
|
|
13323
|
-
// Alias for uninstall
|
|
13908
|
+
lint: lintCommand,
|
|
13324
13909
|
login: loginCommand,
|
|
13325
13910
|
logout: logoutCommand,
|
|
13326
|
-
|
|
13911
|
+
packages: packagesCommand,
|
|
13912
|
+
remove: uninstallCommand,
|
|
13913
|
+
// Alias for uninstall
|
|
13327
13914
|
"setup-mcp": setupMcpCommand,
|
|
13328
13915
|
skills: skillsCommand,
|
|
13329
13916
|
standards: standardsCommand,
|
|
13330
|
-
|
|
13331
|
-
|
|
13917
|
+
uninstall: uninstallCommand,
|
|
13918
|
+
whoami: whoamiCommand
|
|
13332
13919
|
}
|
|
13333
13920
|
});
|
|
13334
|
-
(0,
|
|
13921
|
+
(0, import_cmd_ts26.run)(app, args).catch((error) => {
|
|
13335
13922
|
logErrorConsole(error.message);
|
|
13336
13923
|
process.exit(1);
|
|
13337
13924
|
});
|