@packmind/cli 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.cjs +2053 -501
- package/package.json +3 -2
package/main.cjs
CHANGED
|
@@ -234,9 +234,9 @@ var init_ansi_styles = __esm({
|
|
|
234
234
|
});
|
|
235
235
|
|
|
236
236
|
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
237
|
-
function hasFlag(
|
|
238
|
-
const prefix =
|
|
239
|
-
const position = argv.indexOf(prefix +
|
|
237
|
+
function hasFlag(flag5, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
238
|
+
const prefix = flag5.startsWith("-") ? "" : flag5.length === 1 ? "-" : "--";
|
|
239
|
+
const position = argv.indexOf(prefix + flag5);
|
|
240
240
|
const terminatorPosition = argv.indexOf("--");
|
|
241
241
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
242
242
|
}
|
|
@@ -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,7 +842,7 @@ 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 =
|
|
845
|
+
exports2.optional = optional5;
|
|
846
846
|
exports2.array = array3;
|
|
847
847
|
var type_1 = require_type();
|
|
848
848
|
exports2.number = {
|
|
@@ -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() {
|
|
@@ -935,7 +935,7 @@ var require_flag = __commonJS({
|
|
|
935
935
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
936
936
|
exports2.boolean = void 0;
|
|
937
937
|
exports2.fullFlag = fullFlag;
|
|
938
|
-
exports2.flag =
|
|
938
|
+
exports2.flag = flag5;
|
|
939
939
|
var chalk_1 = __importDefault((init_source(), __toCommonJS(source_exports)));
|
|
940
940
|
var Result = __importStar(require_Result());
|
|
941
941
|
var findOption_1 = require_findOption();
|
|
@@ -1084,7 +1084,7 @@ var require_flag = __commonJS({
|
|
|
1084
1084
|
}
|
|
1085
1085
|
};
|
|
1086
1086
|
}
|
|
1087
|
-
function
|
|
1087
|
+
function flag5(config) {
|
|
1088
1088
|
return fullFlag({
|
|
1089
1089
|
type: types_1.boolean,
|
|
1090
1090
|
...config
|
|
@@ -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
|
}
|
|
@@ -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 = command21;
|
|
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 command21(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("-");
|
|
@@ -2574,9 +2574,9 @@ var require_browser = __commonJS({
|
|
|
2574
2574
|
var require_has_flag = __commonJS({
|
|
2575
2575
|
"node_modules/has-flag/index.js"(exports2, module2) {
|
|
2576
2576
|
"use strict";
|
|
2577
|
-
module2.exports = (
|
|
2578
|
-
const prefix =
|
|
2579
|
-
const position = argv.indexOf(prefix +
|
|
2577
|
+
module2.exports = (flag5, argv = process.argv) => {
|
|
2578
|
+
const prefix = flag5.startsWith("-") ? "" : flag5.length === 1 ? "-" : "--";
|
|
2579
|
+
const position = argv.indexOf(prefix + flag5);
|
|
2580
2580
|
const terminatorPosition = argv.indexOf("--");
|
|
2581
2581
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2582
2582
|
};
|
|
@@ -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
|
}
|
|
@@ -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.17.0",
|
|
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_ts27 = __toESM(require_cjs());
|
|
3899
3899
|
|
|
3900
3900
|
// apps/cli/src/infra/commands/LinterCommand.ts
|
|
3901
3901
|
var import_cmd_ts = __toESM(require_cjs());
|
|
@@ -4059,6 +4059,13 @@ var OrganizationCreatedEvent = class extends UserEvent {
|
|
|
4059
4059
|
}
|
|
4060
4060
|
};
|
|
4061
4061
|
|
|
4062
|
+
// packages/types/src/accounts/events/UserSignedInEvent.ts
|
|
4063
|
+
var UserSignedInEvent = class extends UserEvent {
|
|
4064
|
+
static {
|
|
4065
|
+
this.eventName = "accounts.user.signed-in";
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
|
|
4062
4069
|
// packages/types/src/accounts/TrialActivationToken.ts
|
|
4063
4070
|
var createTrialActivationTokenId = brandedIdFactory();
|
|
4064
4071
|
var createTrialActivationToken = brandedIdFactory();
|
|
@@ -4098,6 +4105,18 @@ function validateAgentsWithWarnings(agents) {
|
|
|
4098
4105
|
return { validAgents, invalidAgents };
|
|
4099
4106
|
}
|
|
4100
4107
|
|
|
4108
|
+
// packages/types/src/coding-agent/CodingAgent.ts
|
|
4109
|
+
var CodingAgents = {
|
|
4110
|
+
packmind: "packmind",
|
|
4111
|
+
junie: "junie",
|
|
4112
|
+
claude: "claude",
|
|
4113
|
+
cursor: "cursor",
|
|
4114
|
+
copilot: "copilot",
|
|
4115
|
+
agents_md: "agents_md",
|
|
4116
|
+
gitlab_duo: "gitlab_duo",
|
|
4117
|
+
continue: "continue"
|
|
4118
|
+
};
|
|
4119
|
+
|
|
4101
4120
|
// packages/types/src/recipes/RecipeId.ts
|
|
4102
4121
|
var createRecipeId = brandedIdFactory();
|
|
4103
4122
|
|
|
@@ -4184,6 +4203,25 @@ var DEFAULT_ACTIVE_RENDER_MODES = normalizeRenderModes([
|
|
|
4184
4203
|
"AGENTS_MD" /* AGENTS_MD */
|
|
4185
4204
|
]);
|
|
4186
4205
|
|
|
4206
|
+
// packages/types/src/deployments/RenderModeCodingAgentMapping.ts
|
|
4207
|
+
var RENDER_MODE_TO_CODING_AGENT = {
|
|
4208
|
+
["PACKMIND" /* PACKMIND */]: CodingAgents.packmind,
|
|
4209
|
+
["AGENTS_MD" /* AGENTS_MD */]: CodingAgents.agents_md,
|
|
4210
|
+
["JUNIE" /* JUNIE */]: CodingAgents.junie,
|
|
4211
|
+
["GH_COPILOT" /* GH_COPILOT */]: CodingAgents.copilot,
|
|
4212
|
+
["CLAUDE" /* CLAUDE */]: CodingAgents.claude,
|
|
4213
|
+
["CURSOR" /* CURSOR */]: CodingAgents.cursor,
|
|
4214
|
+
["GITLAB_DUO" /* GITLAB_DUO */]: CodingAgents.gitlab_duo,
|
|
4215
|
+
["CONTINUE" /* CONTINUE */]: CodingAgents.continue
|
|
4216
|
+
};
|
|
4217
|
+
var CODING_AGENT_TO_RENDER_MODE = Object.entries(RENDER_MODE_TO_CODING_AGENT).reduce(
|
|
4218
|
+
(acc, [renderMode, codingAgent]) => {
|
|
4219
|
+
acc[codingAgent] = renderMode;
|
|
4220
|
+
return acc;
|
|
4221
|
+
},
|
|
4222
|
+
{}
|
|
4223
|
+
);
|
|
4224
|
+
|
|
4187
4225
|
// packages/types/src/deployments/PackagesDeploymentId.ts
|
|
4188
4226
|
var createPackagesDeploymentId = brandedIdFactory();
|
|
4189
4227
|
|
|
@@ -4935,6 +4973,32 @@ var LLM_PROVIDER_METADATA = {
|
|
|
4935
4973
|
// packages/types/src/llm/AIProviderId.ts
|
|
4936
4974
|
var createAIProviderId = brandedIdFactory();
|
|
4937
4975
|
|
|
4976
|
+
// packages/types/src/playbookChangeManagement/ChangeProposalId.ts
|
|
4977
|
+
var createChangeProposalId = brandedIdFactory();
|
|
4978
|
+
|
|
4979
|
+
// packages/types/src/playbookChangeManagement/ChangeProposalTypeLabels.ts
|
|
4980
|
+
var CHANGE_PROPOSAL_TYPE_LABELS = {
|
|
4981
|
+
["updateCommandName" /* updateCommandName */]: "Name",
|
|
4982
|
+
["updateCommandDescription" /* updateCommandDescription */]: "Instructions updated",
|
|
4983
|
+
["updateStandardName" /* updateStandardName */]: "Name",
|
|
4984
|
+
["updateStandardDescription" /* updateStandardDescription */]: "Description",
|
|
4985
|
+
["updateStandardScope" /* updateStandardScope */]: "Scope",
|
|
4986
|
+
["addRule" /* addRule */]: "Rule (add)",
|
|
4987
|
+
["updateRule" /* updateRule */]: "Rule (update)",
|
|
4988
|
+
["deleteRule" /* deleteRule */]: "Rule (delete)",
|
|
4989
|
+
["updateSkillName" /* updateSkillName */]: "Name",
|
|
4990
|
+
["updateSkillDescription" /* updateSkillDescription */]: "Description",
|
|
4991
|
+
["updateSkillPrompt" /* updateSkillPrompt */]: "Prompt",
|
|
4992
|
+
["updateSkillMetadata" /* updateSkillMetadata */]: "Metadata",
|
|
4993
|
+
["updateSkillLicense" /* updateSkillLicense */]: "License",
|
|
4994
|
+
["updateSkillCompatibility" /* updateSkillCompatibility */]: "Compatibility",
|
|
4995
|
+
["updateSkillAllowedTools" /* updateSkillAllowedTools */]: "Allowed Tools",
|
|
4996
|
+
["addSkillFile" /* addSkillFile */]: "File (add)",
|
|
4997
|
+
["updateSkillFileContent" /* updateSkillFileContent */]: "File content",
|
|
4998
|
+
["updateSkillFilePermissions" /* updateSkillFilePermissions */]: "File permissions",
|
|
4999
|
+
["deleteSkillFile" /* deleteSkillFile */]: "File (delete)"
|
|
5000
|
+
};
|
|
5001
|
+
|
|
4938
5002
|
// apps/cli/src/application/useCases/ExecuteSingleFileAstUseCase.ts
|
|
4939
5003
|
var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
4940
5004
|
constructor(linterExecutionUseCase) {
|
|
@@ -4946,8 +5010,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
4946
5010
|
static {
|
|
4947
5011
|
this.fallbackRuleContent = "adhoc-rule";
|
|
4948
5012
|
}
|
|
4949
|
-
async execute(
|
|
4950
|
-
const { program, fileContent, language } =
|
|
5013
|
+
async execute(command21) {
|
|
5014
|
+
const { program, fileContent, language } = command21;
|
|
4951
5015
|
const result = await this.linterExecutionUseCase.execute({
|
|
4952
5016
|
filePath: "cli-single-file",
|
|
4953
5017
|
fileContent,
|
|
@@ -4958,7 +5022,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
4958
5022
|
ruleContent: _ExecuteSingleFileAstUseCase.fallbackRuleContent,
|
|
4959
5023
|
standardSlug: _ExecuteSingleFileAstUseCase.fallbackStandardSlug,
|
|
4960
5024
|
sourceCodeState: "AST",
|
|
4961
|
-
language
|
|
5025
|
+
language,
|
|
5026
|
+
severity: "error" /* ERROR */
|
|
4962
5027
|
}
|
|
4963
5028
|
]
|
|
4964
5029
|
});
|
|
@@ -4997,30 +5062,30 @@ var GitService = class {
|
|
|
4997
5062
|
this.gitRunner = gitRunner;
|
|
4998
5063
|
this.logger = logger2;
|
|
4999
5064
|
}
|
|
5000
|
-
getGitRepositoryRoot(
|
|
5065
|
+
getGitRepositoryRoot(path18) {
|
|
5001
5066
|
try {
|
|
5002
5067
|
const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
|
|
5003
|
-
cwd:
|
|
5068
|
+
cwd: path18
|
|
5004
5069
|
});
|
|
5005
5070
|
const gitRoot = stdout.trim();
|
|
5006
5071
|
this.logger.debug("Resolved git repository root", {
|
|
5007
|
-
inputPath:
|
|
5072
|
+
inputPath: path18,
|
|
5008
5073
|
gitRoot
|
|
5009
5074
|
});
|
|
5010
5075
|
return gitRoot;
|
|
5011
5076
|
} catch (error) {
|
|
5012
5077
|
if (error instanceof Error) {
|
|
5013
5078
|
throw new Error(
|
|
5014
|
-
`Failed to get Git repository root. The path '${
|
|
5079
|
+
`Failed to get Git repository root. The path '${path18}' does not appear to be inside a Git repository.
|
|
5015
5080
|
${error.message}`
|
|
5016
5081
|
);
|
|
5017
5082
|
}
|
|
5018
5083
|
throw new Error("Failed to get Git repository root: Unknown error");
|
|
5019
5084
|
}
|
|
5020
5085
|
}
|
|
5021
|
-
tryGetGitRepositoryRoot(
|
|
5086
|
+
tryGetGitRepositoryRoot(path18) {
|
|
5022
5087
|
try {
|
|
5023
|
-
return this.getGitRepositoryRoot(
|
|
5088
|
+
return this.getGitRepositoryRoot(path18);
|
|
5024
5089
|
} catch {
|
|
5025
5090
|
return null;
|
|
5026
5091
|
}
|
|
@@ -5327,8 +5392,8 @@ var GetGitRemoteUrlUseCase = class {
|
|
|
5327
5392
|
constructor(gitRemoteUrlService = new GitService()) {
|
|
5328
5393
|
this.gitRemoteUrlService = gitRemoteUrlService;
|
|
5329
5394
|
}
|
|
5330
|
-
async execute(
|
|
5331
|
-
const { path: repoPath, origin: origin9 } =
|
|
5395
|
+
async execute(command21) {
|
|
5396
|
+
const { path: repoPath, origin: origin9 } = command21;
|
|
5332
5397
|
return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin9);
|
|
5333
5398
|
}
|
|
5334
5399
|
};
|
|
@@ -5364,6 +5429,9 @@ function formatLabel(text) {
|
|
|
5364
5429
|
function formatError(text) {
|
|
5365
5430
|
return source_default.red(text);
|
|
5366
5431
|
}
|
|
5432
|
+
function formatWarning(text) {
|
|
5433
|
+
return source_default.yellow(text);
|
|
5434
|
+
}
|
|
5367
5435
|
function formatBold(text) {
|
|
5368
5436
|
return source_default.bold(text);
|
|
5369
5437
|
}
|
|
@@ -5470,8 +5538,8 @@ var ListFilesInDirectoryUseCase = class {
|
|
|
5470
5538
|
constructor(listFiles = new ListFiles()) {
|
|
5471
5539
|
this.listFiles = listFiles;
|
|
5472
5540
|
}
|
|
5473
|
-
async execute(
|
|
5474
|
-
const { path: directoryPath, extensions, excludes = [] } =
|
|
5541
|
+
async execute(command21) {
|
|
5542
|
+
const { path: directoryPath, extensions, excludes = [] } = command21;
|
|
5475
5543
|
const files = await this.listFiles.listFilesInDirectory(
|
|
5476
5544
|
directoryPath,
|
|
5477
5545
|
extensions,
|
|
@@ -5518,6 +5586,17 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5518
5586
|
this.services = services;
|
|
5519
5587
|
this.repositories = repositories;
|
|
5520
5588
|
this.logger = logger2;
|
|
5589
|
+
this.mapToActiveDetectionProgram = (item, fallbackLanguage) => {
|
|
5590
|
+
return {
|
|
5591
|
+
language: item.language ?? fallbackLanguage,
|
|
5592
|
+
severity: item.severity,
|
|
5593
|
+
detectionProgram: {
|
|
5594
|
+
mode: item.mode,
|
|
5595
|
+
code: item.code,
|
|
5596
|
+
sourceCodeState: item.sourceCodeState
|
|
5597
|
+
}
|
|
5598
|
+
};
|
|
5599
|
+
};
|
|
5521
5600
|
}
|
|
5522
5601
|
fileMatchesTargetAndScope(filePath, targetPath, scopePatterns) {
|
|
5523
5602
|
if (!scopePatterns || scopePatterns.length === 0) {
|
|
@@ -5565,7 +5644,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5565
5644
|
}
|
|
5566
5645
|
return pattern;
|
|
5567
5646
|
}
|
|
5568
|
-
async execute(
|
|
5647
|
+
async execute(command21) {
|
|
5569
5648
|
const {
|
|
5570
5649
|
path: userPath,
|
|
5571
5650
|
draftMode,
|
|
@@ -5573,7 +5652,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5573
5652
|
ruleId,
|
|
5574
5653
|
language,
|
|
5575
5654
|
diffMode
|
|
5576
|
-
} =
|
|
5655
|
+
} = command21;
|
|
5577
5656
|
this.logger.debug(
|
|
5578
5657
|
`Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
|
|
5579
5658
|
);
|
|
@@ -5681,14 +5760,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5681
5760
|
{
|
|
5682
5761
|
content: draftProgramsResult.ruleContent || "Draft Rule",
|
|
5683
5762
|
activeDetectionPrograms: draftProgramsResult.programs.map(
|
|
5684
|
-
(
|
|
5685
|
-
language: program.language,
|
|
5686
|
-
detectionProgram: {
|
|
5687
|
-
mode: program.mode,
|
|
5688
|
-
code: program.code,
|
|
5689
|
-
sourceCodeState: program.sourceCodeState
|
|
5690
|
-
}
|
|
5691
|
-
})
|
|
5763
|
+
(item) => this.mapToActiveDetectionProgram(item, language)
|
|
5692
5764
|
)
|
|
5693
5765
|
}
|
|
5694
5766
|
]
|
|
@@ -5725,14 +5797,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5725
5797
|
{
|
|
5726
5798
|
content: activeProgramsResult.ruleContent || "Active Rule",
|
|
5727
5799
|
activeDetectionPrograms: activeProgramsResult.programs.map(
|
|
5728
|
-
(
|
|
5729
|
-
language: program.language,
|
|
5730
|
-
detectionProgram: {
|
|
5731
|
-
mode: program.mode,
|
|
5732
|
-
code: program.code,
|
|
5733
|
-
sourceCodeState: program.sourceCodeState
|
|
5734
|
-
}
|
|
5735
|
-
})
|
|
5800
|
+
(item) => this.mapToActiveDetectionProgram(item, language)
|
|
5736
5801
|
)
|
|
5737
5802
|
}
|
|
5738
5803
|
]
|
|
@@ -5808,7 +5873,8 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5808
5873
|
ruleContent: rule.content,
|
|
5809
5874
|
standardSlug: standard.slug,
|
|
5810
5875
|
sourceCodeState: activeProgram.detectionProgram.sourceCodeState,
|
|
5811
|
-
language: fileLanguage
|
|
5876
|
+
language: fileLanguage,
|
|
5877
|
+
severity: activeProgram.severity ?? "error" /* ERROR */
|
|
5812
5878
|
});
|
|
5813
5879
|
programsByLanguage.set(programLanguage, programsForLanguage);
|
|
5814
5880
|
} catch (error) {
|
|
@@ -5891,8 +5957,8 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5891
5957
|
return null;
|
|
5892
5958
|
}
|
|
5893
5959
|
}
|
|
5894
|
-
async executeProgramsForFile(
|
|
5895
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
5960
|
+
async executeProgramsForFile(command21) {
|
|
5961
|
+
const result = await this.services.linterExecutionUseCase.execute(command21);
|
|
5896
5962
|
return result.violations;
|
|
5897
5963
|
}
|
|
5898
5964
|
extractExtensionFromFile(filePath) {
|
|
@@ -5949,8 +6015,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
5949
6015
|
}
|
|
5950
6016
|
return pattern;
|
|
5951
6017
|
}
|
|
5952
|
-
async execute(
|
|
5953
|
-
const { path: userPath, diffMode } =
|
|
6018
|
+
async execute(command21) {
|
|
6019
|
+
const { path: userPath, diffMode } = command21;
|
|
5954
6020
|
this.logger.debug(
|
|
5955
6021
|
`Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
|
|
5956
6022
|
);
|
|
@@ -6054,6 +6120,7 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6054
6120
|
allConfigs.configs
|
|
6055
6121
|
);
|
|
6056
6122
|
const programsByLanguage = /* @__PURE__ */ new Map();
|
|
6123
|
+
const seenPrograms = /* @__PURE__ */ new Set();
|
|
6057
6124
|
for (const targetConfig of matchingTargets) {
|
|
6058
6125
|
const detectionPrograms = await this.getDetectionProgramsForTarget(targetConfig);
|
|
6059
6126
|
for (const target of detectionPrograms.targets) {
|
|
@@ -6075,13 +6142,19 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6075
6142
|
if (!programLanguage || programLanguage !== fileLanguage) {
|
|
6076
6143
|
continue;
|
|
6077
6144
|
}
|
|
6145
|
+
const programKey = `${standard.slug}:${rule.content}:${activeProgram.language}`;
|
|
6146
|
+
if (seenPrograms.has(programKey)) {
|
|
6147
|
+
continue;
|
|
6148
|
+
}
|
|
6149
|
+
seenPrograms.add(programKey);
|
|
6078
6150
|
const programsForLanguage = programsByLanguage.get(programLanguage) ?? [];
|
|
6079
6151
|
programsForLanguage.push({
|
|
6080
6152
|
code: activeProgram.detectionProgram.code,
|
|
6081
6153
|
ruleContent: rule.content,
|
|
6082
6154
|
standardSlug: standard.slug,
|
|
6083
6155
|
sourceCodeState: activeProgram.detectionProgram.sourceCodeState,
|
|
6084
|
-
language: fileLanguage
|
|
6156
|
+
language: fileLanguage,
|
|
6157
|
+
severity: activeProgram.severity ?? "error" /* ERROR */
|
|
6085
6158
|
});
|
|
6086
6159
|
programsByLanguage.set(programLanguage, programsForLanguage);
|
|
6087
6160
|
} catch (error) {
|
|
@@ -6199,8 +6272,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6199
6272
|
return null;
|
|
6200
6273
|
}
|
|
6201
6274
|
}
|
|
6202
|
-
async executeProgramsForFile(
|
|
6203
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
6275
|
+
async executeProgramsForFile(command21) {
|
|
6276
|
+
const result = await this.services.linterExecutionUseCase.execute(command21);
|
|
6204
6277
|
return result.violations;
|
|
6205
6278
|
}
|
|
6206
6279
|
extractExtensionFromFile(filePath) {
|
|
@@ -6266,10 +6339,10 @@ var PackmindHttpClient = class {
|
|
|
6266
6339
|
return null;
|
|
6267
6340
|
}
|
|
6268
6341
|
}
|
|
6269
|
-
async request(
|
|
6342
|
+
async request(path18, options = {}) {
|
|
6270
6343
|
const { host } = this.getAuthContext();
|
|
6271
6344
|
const { method = "GET", body } = options;
|
|
6272
|
-
const url = `${host}${
|
|
6345
|
+
const url = `${host}${path18}`;
|
|
6273
6346
|
try {
|
|
6274
6347
|
const response = await fetch(url, {
|
|
6275
6348
|
method,
|
|
@@ -6312,6 +6385,23 @@ var PackmindHttpClient = class {
|
|
|
6312
6385
|
}
|
|
6313
6386
|
};
|
|
6314
6387
|
|
|
6388
|
+
// apps/cli/src/infra/repositories/ChangeProposalGateway.ts
|
|
6389
|
+
var ChangeProposalGateway = class {
|
|
6390
|
+
constructor(httpClient) {
|
|
6391
|
+
this.httpClient = httpClient;
|
|
6392
|
+
this.batchCreate = async (command21) => {
|
|
6393
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6394
|
+
return this.httpClient.request(
|
|
6395
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/change-proposals/batch`,
|
|
6396
|
+
{
|
|
6397
|
+
method: "POST",
|
|
6398
|
+
body: { proposals: command21.proposals }
|
|
6399
|
+
}
|
|
6400
|
+
);
|
|
6401
|
+
};
|
|
6402
|
+
}
|
|
6403
|
+
};
|
|
6404
|
+
|
|
6315
6405
|
// apps/cli/src/domain/errors/CommunityEditionError.ts
|
|
6316
6406
|
var CommunityEditionError = class extends Error {
|
|
6317
6407
|
constructor(feature) {
|
|
@@ -6326,13 +6416,13 @@ var CommunityEditionError = class extends Error {
|
|
|
6326
6416
|
var LinterGateway = class {
|
|
6327
6417
|
constructor(httpClient) {
|
|
6328
6418
|
this.httpClient = httpClient;
|
|
6329
|
-
this.getDraftDetectionProgramsForRule = async (
|
|
6419
|
+
this.getDraftDetectionProgramsForRule = async (command21) => {
|
|
6330
6420
|
const payload = {
|
|
6331
|
-
standardSlug:
|
|
6332
|
-
ruleId:
|
|
6421
|
+
standardSlug: command21.standardSlug,
|
|
6422
|
+
ruleId: command21.ruleId
|
|
6333
6423
|
};
|
|
6334
|
-
if (
|
|
6335
|
-
payload.language =
|
|
6424
|
+
if (command21.language) {
|
|
6425
|
+
payload.language = command21.language;
|
|
6336
6426
|
}
|
|
6337
6427
|
return this.httpClient.request("/api/v0/list-draft-detection-program", {
|
|
6338
6428
|
method: "POST",
|
|
@@ -6344,13 +6434,13 @@ var LinterGateway = class {
|
|
|
6344
6434
|
}
|
|
6345
6435
|
});
|
|
6346
6436
|
};
|
|
6347
|
-
this.getActiveDetectionProgramsForRule = async (
|
|
6437
|
+
this.getActiveDetectionProgramsForRule = async (command21) => {
|
|
6348
6438
|
const payload = {
|
|
6349
|
-
standardSlug:
|
|
6350
|
-
ruleId:
|
|
6439
|
+
standardSlug: command21.standardSlug,
|
|
6440
|
+
ruleId: command21.ruleId
|
|
6351
6441
|
};
|
|
6352
|
-
if (
|
|
6353
|
-
payload.language =
|
|
6442
|
+
if (command21.language) {
|
|
6443
|
+
payload.language = command21.language;
|
|
6354
6444
|
}
|
|
6355
6445
|
return this.httpClient.request("/api/v0/list-active-detection-program", {
|
|
6356
6446
|
method: "POST",
|
|
@@ -6362,13 +6452,13 @@ var LinterGateway = class {
|
|
|
6362
6452
|
}
|
|
6363
6453
|
});
|
|
6364
6454
|
};
|
|
6365
|
-
this.getDetectionProgramsForPackages = async (
|
|
6455
|
+
this.getDetectionProgramsForPackages = async (command21) => {
|
|
6366
6456
|
const response = await this.httpClient.request(
|
|
6367
6457
|
"/api/v0/detection-programs-for-packages",
|
|
6368
6458
|
{
|
|
6369
6459
|
method: "POST",
|
|
6370
6460
|
body: {
|
|
6371
|
-
packagesSlugs:
|
|
6461
|
+
packagesSlugs: command21.packagesSlugs
|
|
6372
6462
|
},
|
|
6373
6463
|
onError: (response2) => {
|
|
6374
6464
|
if (response2.status === 404) {
|
|
@@ -6379,10 +6469,10 @@ var LinterGateway = class {
|
|
|
6379
6469
|
);
|
|
6380
6470
|
return handleScopeInTargetsResponse(response);
|
|
6381
6471
|
};
|
|
6382
|
-
this.trackLinterExecution = async (
|
|
6472
|
+
this.trackLinterExecution = async (command21) => {
|
|
6383
6473
|
return this.httpClient.request(`/api/v0/track-execution`, {
|
|
6384
6474
|
method: "POST",
|
|
6385
|
-
body:
|
|
6475
|
+
body: command21
|
|
6386
6476
|
});
|
|
6387
6477
|
};
|
|
6388
6478
|
}
|
|
@@ -6440,27 +6530,27 @@ var SpacesGateway = class {
|
|
|
6440
6530
|
var SkillsGateway = class {
|
|
6441
6531
|
constructor(httpClient) {
|
|
6442
6532
|
this.httpClient = httpClient;
|
|
6443
|
-
this.upload = async (
|
|
6533
|
+
this.upload = async (command21) => {
|
|
6444
6534
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6445
6535
|
return this.httpClient.request(
|
|
6446
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6536
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/skills/upload`,
|
|
6447
6537
|
{
|
|
6448
6538
|
method: "POST",
|
|
6449
|
-
body:
|
|
6539
|
+
body: command21
|
|
6450
6540
|
}
|
|
6451
6541
|
);
|
|
6452
6542
|
};
|
|
6453
|
-
this.getDefaults = async (
|
|
6543
|
+
this.getDefaults = async (command21) => {
|
|
6454
6544
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6455
6545
|
const queryParams = new URLSearchParams();
|
|
6456
|
-
if (
|
|
6546
|
+
if (command21.includeBeta) {
|
|
6457
6547
|
queryParams.set("includeBeta", "true");
|
|
6458
|
-
} else if (
|
|
6459
|
-
queryParams.set("cliVersion",
|
|
6548
|
+
} else if (command21.cliVersion) {
|
|
6549
|
+
queryParams.set("cliVersion", command21.cliVersion);
|
|
6460
6550
|
}
|
|
6461
|
-
if (
|
|
6551
|
+
if (command21.agents !== void 0) {
|
|
6462
6552
|
queryParams.append("agentsConfigOverride", "true");
|
|
6463
|
-
|
|
6553
|
+
command21.agents.forEach((agent) => {
|
|
6464
6554
|
queryParams.append("agent", agent);
|
|
6465
6555
|
});
|
|
6466
6556
|
}
|
|
@@ -6469,10 +6559,10 @@ var SkillsGateway = class {
|
|
|
6469
6559
|
`/api/v0/organizations/${organizationId}/skills/default${queryString ? `?${queryString}` : ""}`
|
|
6470
6560
|
);
|
|
6471
6561
|
};
|
|
6472
|
-
this.list = async (
|
|
6562
|
+
this.list = async (command21) => {
|
|
6473
6563
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6474
6564
|
return this.httpClient.request(
|
|
6475
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6565
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/skills`
|
|
6476
6566
|
);
|
|
6477
6567
|
};
|
|
6478
6568
|
}
|
|
@@ -6482,17 +6572,17 @@ var SkillsGateway = class {
|
|
|
6482
6572
|
var CommandsGateway = class {
|
|
6483
6573
|
constructor(httpClient) {
|
|
6484
6574
|
this.httpClient = httpClient;
|
|
6485
|
-
this.create = async (
|
|
6575
|
+
this.create = async (command21) => {
|
|
6486
6576
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6487
6577
|
return this.httpClient.request(
|
|
6488
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6489
|
-
{ method: "POST", body:
|
|
6578
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/recipes`,
|
|
6579
|
+
{ method: "POST", body: command21 }
|
|
6490
6580
|
);
|
|
6491
6581
|
};
|
|
6492
|
-
this.list = async (
|
|
6582
|
+
this.list = async (command21) => {
|
|
6493
6583
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6494
6584
|
const listRecipesResponse = await this.httpClient.request(
|
|
6495
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6585
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/recipes`
|
|
6496
6586
|
);
|
|
6497
6587
|
if (listRecipesResponse instanceof Array) {
|
|
6498
6588
|
return { recipes: listRecipesResponse };
|
|
@@ -6534,10 +6624,10 @@ var StandardsGateway = class {
|
|
|
6534
6624
|
}
|
|
6535
6625
|
);
|
|
6536
6626
|
};
|
|
6537
|
-
this.list = async (
|
|
6627
|
+
this.list = async (command21) => {
|
|
6538
6628
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6539
6629
|
return this.httpClient.request(
|
|
6540
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6630
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/standards`
|
|
6541
6631
|
);
|
|
6542
6632
|
};
|
|
6543
6633
|
}
|
|
@@ -6560,24 +6650,24 @@ var PackagesGateway = class {
|
|
|
6560
6650
|
`/api/v0/organizations/${organizationId}/packages/${encodeURIComponent(slug)}`
|
|
6561
6651
|
);
|
|
6562
6652
|
};
|
|
6563
|
-
this.create = async (
|
|
6653
|
+
this.create = async (command21) => {
|
|
6564
6654
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6565
6655
|
return this.httpClient.request(
|
|
6566
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6656
|
+
`/api/v0/organizations/${organizationId}/spaces/${command21.spaceId}/packages`,
|
|
6567
6657
|
{
|
|
6568
6658
|
method: "POST",
|
|
6569
|
-
body:
|
|
6659
|
+
body: command21
|
|
6570
6660
|
}
|
|
6571
6661
|
);
|
|
6572
6662
|
};
|
|
6573
|
-
this.addArtefacts = async (
|
|
6663
|
+
this.addArtefacts = async (command21) => {
|
|
6574
6664
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6575
|
-
const { packageId, spaceId } =
|
|
6665
|
+
const { packageId, spaceId } = command21;
|
|
6576
6666
|
return this.httpClient.request(
|
|
6577
6667
|
`/api/v0/organizations/${organizationId}/spaces/${spaceId}/packages/${packageId}/add-artifacts`,
|
|
6578
6668
|
{
|
|
6579
6669
|
method: "POST",
|
|
6580
|
-
body:
|
|
6670
|
+
body: command21
|
|
6581
6671
|
}
|
|
6582
6672
|
);
|
|
6583
6673
|
};
|
|
@@ -6588,31 +6678,31 @@ var PackagesGateway = class {
|
|
|
6588
6678
|
var DeploymentGateway = class {
|
|
6589
6679
|
constructor(httpClient) {
|
|
6590
6680
|
this.httpClient = httpClient;
|
|
6591
|
-
this.pull = async (
|
|
6681
|
+
this.pull = async (command21) => {
|
|
6592
6682
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6593
6683
|
const queryParams = new URLSearchParams();
|
|
6594
|
-
if (
|
|
6595
|
-
|
|
6684
|
+
if (command21.packagesSlugs && command21.packagesSlugs.length > 0) {
|
|
6685
|
+
command21.packagesSlugs.forEach((slug) => {
|
|
6596
6686
|
queryParams.append("packageSlug", slug);
|
|
6597
6687
|
});
|
|
6598
6688
|
}
|
|
6599
|
-
if (
|
|
6600
|
-
|
|
6689
|
+
if (command21.previousPackagesSlugs && command21.previousPackagesSlugs.length > 0) {
|
|
6690
|
+
command21.previousPackagesSlugs.forEach((slug) => {
|
|
6601
6691
|
queryParams.append("previousPackageSlug", slug);
|
|
6602
6692
|
});
|
|
6603
6693
|
}
|
|
6604
|
-
if (
|
|
6605
|
-
queryParams.append("gitRemoteUrl",
|
|
6694
|
+
if (command21.gitRemoteUrl) {
|
|
6695
|
+
queryParams.append("gitRemoteUrl", command21.gitRemoteUrl);
|
|
6606
6696
|
}
|
|
6607
|
-
if (
|
|
6608
|
-
queryParams.append("gitBranch",
|
|
6697
|
+
if (command21.gitBranch) {
|
|
6698
|
+
queryParams.append("gitBranch", command21.gitBranch);
|
|
6609
6699
|
}
|
|
6610
|
-
if (
|
|
6611
|
-
queryParams.append("relativePath",
|
|
6700
|
+
if (command21.relativePath) {
|
|
6701
|
+
queryParams.append("relativePath", command21.relativePath);
|
|
6612
6702
|
}
|
|
6613
|
-
if (
|
|
6703
|
+
if (command21.agents !== void 0) {
|
|
6614
6704
|
queryParams.append("agentsConfigOverride", "true");
|
|
6615
|
-
|
|
6705
|
+
command21.agents.forEach((agent) => {
|
|
6616
6706
|
queryParams.append("agent", agent);
|
|
6617
6707
|
});
|
|
6618
6708
|
}
|
|
@@ -6620,16 +6710,38 @@ var DeploymentGateway = class {
|
|
|
6620
6710
|
`/api/v0/organizations/${organizationId}/pull?${queryParams.toString()}`
|
|
6621
6711
|
);
|
|
6622
6712
|
};
|
|
6623
|
-
this.
|
|
6713
|
+
this.getDeployed = async (command21) => {
|
|
6714
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6715
|
+
return this.httpClient.request(
|
|
6716
|
+
`/api/v0/organizations/${organizationId}/deployed-content`,
|
|
6717
|
+
{
|
|
6718
|
+
method: "POST",
|
|
6719
|
+
body: {
|
|
6720
|
+
packagesSlugs: command21.packagesSlugs,
|
|
6721
|
+
gitRemoteUrl: command21.gitRemoteUrl,
|
|
6722
|
+
gitBranch: command21.gitBranch,
|
|
6723
|
+
relativePath: command21.relativePath,
|
|
6724
|
+
...command21.agents !== void 0 && { agents: command21.agents }
|
|
6725
|
+
}
|
|
6726
|
+
}
|
|
6727
|
+
);
|
|
6728
|
+
};
|
|
6729
|
+
this.notifyDistribution = async (command21) => {
|
|
6624
6730
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6625
6731
|
return this.httpClient.request(
|
|
6626
6732
|
`/api/v0/organizations/${organizationId}/deployments`,
|
|
6627
6733
|
{
|
|
6628
6734
|
method: "POST",
|
|
6629
|
-
body:
|
|
6735
|
+
body: command21
|
|
6630
6736
|
}
|
|
6631
6737
|
);
|
|
6632
6738
|
};
|
|
6739
|
+
this.getRenderModeConfiguration = async () => {
|
|
6740
|
+
const { organizationId } = this.httpClient.getAuthContext();
|
|
6741
|
+
return this.httpClient.request(
|
|
6742
|
+
`/api/v0/organizations/${organizationId}/deployments/renderModeConfiguration`
|
|
6743
|
+
);
|
|
6744
|
+
};
|
|
6633
6745
|
}
|
|
6634
6746
|
};
|
|
6635
6747
|
|
|
@@ -6638,6 +6750,7 @@ var PackmindGateway = class {
|
|
|
6638
6750
|
constructor(apiKey) {
|
|
6639
6751
|
this.apiKey = apiKey;
|
|
6640
6752
|
this.httpClient = new PackmindHttpClient(apiKey);
|
|
6753
|
+
this.changeProposals = new ChangeProposalGateway(this.httpClient);
|
|
6641
6754
|
this.linter = new LinterGateway(this.httpClient);
|
|
6642
6755
|
this.mcp = new McpGateway(this.httpClient);
|
|
6643
6756
|
this.spaces = new SpacesGateway(this.httpClient);
|
|
@@ -8389,8 +8502,8 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8389
8502
|
this.linterAstAdapter = linterAstAdapter;
|
|
8390
8503
|
this.logger = logger2;
|
|
8391
8504
|
}
|
|
8392
|
-
async execute(
|
|
8393
|
-
const { filePath, fileContent, language, programs } =
|
|
8505
|
+
async execute(command21) {
|
|
8506
|
+
const { filePath, fileContent, language, programs } = command21;
|
|
8394
8507
|
if (programs.length === 0) {
|
|
8395
8508
|
return {
|
|
8396
8509
|
file: filePath,
|
|
@@ -8533,7 +8646,8 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8533
8646
|
line,
|
|
8534
8647
|
character,
|
|
8535
8648
|
rule: ruleName,
|
|
8536
|
-
standard: program.standardSlug
|
|
8649
|
+
standard: program.standardSlug,
|
|
8650
|
+
severity: program.severity
|
|
8537
8651
|
};
|
|
8538
8652
|
}
|
|
8539
8653
|
isViolationLike(value) {
|
|
@@ -9060,15 +9174,114 @@ function removeTrailingSlash(url) {
|
|
|
9060
9174
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
9061
9175
|
}
|
|
9062
9176
|
|
|
9177
|
+
// packages/node-utils/src/skillMd/parseSkillMdContent.ts
|
|
9178
|
+
var import_yaml = require("yaml");
|
|
9179
|
+
var FRONTMATTER_DELIMITER = "---";
|
|
9180
|
+
function serializeSkillMetadata(fields) {
|
|
9181
|
+
const sorted = Object.keys(fields).sort((a, b) => a.localeCompare(b)).reduce(
|
|
9182
|
+
(acc, key) => {
|
|
9183
|
+
acc[key] = fields[key];
|
|
9184
|
+
return acc;
|
|
9185
|
+
},
|
|
9186
|
+
{}
|
|
9187
|
+
);
|
|
9188
|
+
return JSON.stringify(sorted);
|
|
9189
|
+
}
|
|
9190
|
+
function parseSkillMdContent(content) {
|
|
9191
|
+
try {
|
|
9192
|
+
const trimmed = content.trim();
|
|
9193
|
+
if (!trimmed.startsWith(FRONTMATTER_DELIMITER)) {
|
|
9194
|
+
return null;
|
|
9195
|
+
}
|
|
9196
|
+
const afterOpening = trimmed.slice(FRONTMATTER_DELIMITER.length);
|
|
9197
|
+
const closingIndex = afterOpening.indexOf(`
|
|
9198
|
+
${FRONTMATTER_DELIMITER}`);
|
|
9199
|
+
if (closingIndex === -1) {
|
|
9200
|
+
return null;
|
|
9201
|
+
}
|
|
9202
|
+
const frontmatter = afterOpening.slice(0, closingIndex).trim();
|
|
9203
|
+
const body = afterOpening.slice(closingIndex + FRONTMATTER_DELIMITER.length + 1).trim();
|
|
9204
|
+
const parsed = (0, import_yaml.parse)(frontmatter);
|
|
9205
|
+
if (parsed === null || typeof parsed !== "object") {
|
|
9206
|
+
return null;
|
|
9207
|
+
}
|
|
9208
|
+
const { "allowed-tools": allowedTools, ...rest } = parsed;
|
|
9209
|
+
const properties = {
|
|
9210
|
+
...rest,
|
|
9211
|
+
...allowedTools !== void 0 && { allowedTools }
|
|
9212
|
+
};
|
|
9213
|
+
return { properties, body };
|
|
9214
|
+
} catch {
|
|
9215
|
+
return null;
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
|
|
9219
|
+
// packages/node-utils/src/skillMd/parseSkillMd.ts
|
|
9220
|
+
function parseSkillMd(content) {
|
|
9221
|
+
const parsed = parseSkillMdContent(content);
|
|
9222
|
+
if (!parsed) {
|
|
9223
|
+
return null;
|
|
9224
|
+
}
|
|
9225
|
+
const { properties, body } = parsed;
|
|
9226
|
+
const name = String(properties["name"] ?? "");
|
|
9227
|
+
const description = String(properties["description"] ?? "");
|
|
9228
|
+
const license = String(properties["license"] ?? "");
|
|
9229
|
+
const compatibility = String(properties["compatibility"] ?? "");
|
|
9230
|
+
const allowedTools = String(properties["allowedTools"] ?? "");
|
|
9231
|
+
const metadata = properties["metadata"];
|
|
9232
|
+
const metadataJson = metadata != null && typeof metadata === "object" ? serializeSkillMetadata(metadata) : "{}";
|
|
9233
|
+
return {
|
|
9234
|
+
name,
|
|
9235
|
+
description,
|
|
9236
|
+
body,
|
|
9237
|
+
license,
|
|
9238
|
+
compatibility,
|
|
9239
|
+
allowedTools,
|
|
9240
|
+
metadataJson
|
|
9241
|
+
};
|
|
9242
|
+
}
|
|
9243
|
+
|
|
9063
9244
|
// apps/cli/src/application/useCases/InstallPackagesUseCase.ts
|
|
9064
9245
|
var fs4 = __toESM(require("fs/promises"));
|
|
9065
9246
|
var path5 = __toESM(require("path"));
|
|
9247
|
+
|
|
9248
|
+
// apps/cli/src/infra/utils/permissions.ts
|
|
9249
|
+
var DEFAULT_PERMISSIONS = "rw-r--r--";
|
|
9250
|
+
function supportsUnixPermissions() {
|
|
9251
|
+
return process.platform !== "win32";
|
|
9252
|
+
}
|
|
9253
|
+
function modeToPermissionString(mode) {
|
|
9254
|
+
const perms = mode & 511;
|
|
9255
|
+
const chars = "rwx";
|
|
9256
|
+
let result = "";
|
|
9257
|
+
for (let i = 8; i >= 0; i--) {
|
|
9258
|
+
result += perms & 1 << i ? chars[(8 - i) % 3] : "-";
|
|
9259
|
+
}
|
|
9260
|
+
return result;
|
|
9261
|
+
}
|
|
9262
|
+
function modeToPermissionStringOrDefault(mode) {
|
|
9263
|
+
if (!supportsUnixPermissions()) {
|
|
9264
|
+
return DEFAULT_PERMISSIONS;
|
|
9265
|
+
}
|
|
9266
|
+
return modeToPermissionString(mode);
|
|
9267
|
+
}
|
|
9268
|
+
function parsePermissionString(permString) {
|
|
9269
|
+
let mode = 0;
|
|
9270
|
+
for (let i = 0; i < 9; i++) {
|
|
9271
|
+
if (permString[i] !== "-") {
|
|
9272
|
+
mode |= 1 << 8 - i;
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
9275
|
+
return mode;
|
|
9276
|
+
}
|
|
9277
|
+
|
|
9278
|
+
// apps/cli/src/application/useCases/InstallPackagesUseCase.ts
|
|
9066
9279
|
var InstallPackagesUseCase = class {
|
|
9067
9280
|
constructor(packmindGateway) {
|
|
9068
9281
|
this.packmindGateway = packmindGateway;
|
|
9069
9282
|
}
|
|
9070
|
-
async execute(
|
|
9071
|
-
const baseDirectory =
|
|
9283
|
+
async execute(command21) {
|
|
9284
|
+
const baseDirectory = command21.baseDirectory || process.cwd();
|
|
9072
9285
|
const result = {
|
|
9073
9286
|
filesCreated: 0,
|
|
9074
9287
|
filesUpdated: 0,
|
|
@@ -9080,12 +9293,12 @@ var InstallPackagesUseCase = class {
|
|
|
9080
9293
|
skillDirectoriesDeleted: 0
|
|
9081
9294
|
};
|
|
9082
9295
|
const response = await this.packmindGateway.deployment.pull({
|
|
9083
|
-
packagesSlugs:
|
|
9084
|
-
previousPackagesSlugs:
|
|
9085
|
-
gitRemoteUrl:
|
|
9086
|
-
gitBranch:
|
|
9087
|
-
relativePath:
|
|
9088
|
-
agents:
|
|
9296
|
+
packagesSlugs: command21.packagesSlugs,
|
|
9297
|
+
previousPackagesSlugs: command21.previousPackagesSlugs,
|
|
9298
|
+
gitRemoteUrl: command21.gitRemoteUrl,
|
|
9299
|
+
gitBranch: command21.gitBranch,
|
|
9300
|
+
relativePath: command21.relativePath,
|
|
9301
|
+
agents: command21.agents
|
|
9089
9302
|
});
|
|
9090
9303
|
const filteredCreateOrUpdate = response.fileUpdates.createOrUpdate.filter(
|
|
9091
9304
|
(file) => file.path !== "packmind.json"
|
|
@@ -9111,7 +9324,12 @@ var InstallPackagesUseCase = class {
|
|
|
9111
9324
|
);
|
|
9112
9325
|
for (const file of uniqueFiles) {
|
|
9113
9326
|
try {
|
|
9114
|
-
await this.createOrUpdateFile(
|
|
9327
|
+
await this.createOrUpdateFile(
|
|
9328
|
+
baseDirectory,
|
|
9329
|
+
file,
|
|
9330
|
+
result,
|
|
9331
|
+
file.skillFilePermissions
|
|
9332
|
+
);
|
|
9115
9333
|
} catch (error) {
|
|
9116
9334
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
9117
9335
|
result.errors.push(
|
|
@@ -9133,7 +9351,7 @@ var InstallPackagesUseCase = class {
|
|
|
9133
9351
|
}
|
|
9134
9352
|
return result;
|
|
9135
9353
|
}
|
|
9136
|
-
async createOrUpdateFile(baseDirectory, file, result) {
|
|
9354
|
+
async createOrUpdateFile(baseDirectory, file, result, skillFilePermissions) {
|
|
9137
9355
|
const fullPath = path5.join(baseDirectory, file.path);
|
|
9138
9356
|
const directory = path5.dirname(fullPath);
|
|
9139
9357
|
await fs4.mkdir(directory, { recursive: true });
|
|
@@ -9155,6 +9373,9 @@ var InstallPackagesUseCase = class {
|
|
|
9155
9373
|
baseDirectory
|
|
9156
9374
|
);
|
|
9157
9375
|
}
|
|
9376
|
+
if (skillFilePermissions && supportsUnixPermissions()) {
|
|
9377
|
+
await fs4.chmod(fullPath, parsePermissionString(skillFilePermissions));
|
|
9378
|
+
}
|
|
9158
9379
|
}
|
|
9159
9380
|
async handleFullContentUpdate(fullPath, content, fileExists, result, isBase64) {
|
|
9160
9381
|
if (isBase64) {
|
|
@@ -9215,12 +9436,12 @@ var InstallPackagesUseCase = class {
|
|
|
9215
9436
|
}
|
|
9216
9437
|
async deleteFile(baseDirectory, filePath, result) {
|
|
9217
9438
|
const fullPath = path5.join(baseDirectory, filePath);
|
|
9218
|
-
const
|
|
9219
|
-
if (
|
|
9439
|
+
const stat5 = await fs4.stat(fullPath).catch(() => null);
|
|
9440
|
+
if (stat5?.isDirectory()) {
|
|
9220
9441
|
await fs4.rm(fullPath, { recursive: true, force: true });
|
|
9221
9442
|
result.filesDeleted++;
|
|
9222
9443
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
9223
|
-
} else if (
|
|
9444
|
+
} else if (stat5?.isFile()) {
|
|
9224
9445
|
await fs4.unlink(fullPath);
|
|
9225
9446
|
result.filesDeleted++;
|
|
9226
9447
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
@@ -9363,8 +9584,8 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
9363
9584
|
constructor(repositories) {
|
|
9364
9585
|
this.repositories = repositories;
|
|
9365
9586
|
}
|
|
9366
|
-
async execute(
|
|
9367
|
-
const baseDirectory =
|
|
9587
|
+
async execute(command21) {
|
|
9588
|
+
const baseDirectory = command21.baseDirectory || process.cwd();
|
|
9368
9589
|
const result = {
|
|
9369
9590
|
filesCreated: 0,
|
|
9370
9591
|
filesUpdated: 0,
|
|
@@ -9374,8 +9595,8 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
9374
9595
|
const agents = config?.agents;
|
|
9375
9596
|
const response = await this.repositories.packmindGateway.skills.getDefaults(
|
|
9376
9597
|
{
|
|
9377
|
-
cliVersion:
|
|
9378
|
-
includeBeta:
|
|
9598
|
+
cliVersion: command21.cliVersion,
|
|
9599
|
+
includeBeta: command21.includeBeta,
|
|
9379
9600
|
agents
|
|
9380
9601
|
}
|
|
9381
9602
|
);
|
|
@@ -9440,8 +9661,8 @@ var GetPackageSummaryUseCase = class {
|
|
|
9440
9661
|
constructor(gateway) {
|
|
9441
9662
|
this.gateway = gateway;
|
|
9442
9663
|
}
|
|
9443
|
-
async execute(
|
|
9444
|
-
return this.gateway.packages.getSummary(
|
|
9664
|
+
async execute(command21) {
|
|
9665
|
+
return this.gateway.packages.getSummary(command21);
|
|
9445
9666
|
}
|
|
9446
9667
|
};
|
|
9447
9668
|
|
|
@@ -9720,8 +9941,8 @@ var LoginUseCase = class {
|
|
|
9720
9941
|
startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
|
|
9721
9942
|
};
|
|
9722
9943
|
}
|
|
9723
|
-
async execute(
|
|
9724
|
-
const { host, code: providedCode } =
|
|
9944
|
+
async execute(command21) {
|
|
9945
|
+
const { host, code: providedCode } = command21;
|
|
9725
9946
|
let code;
|
|
9726
9947
|
if (providedCode) {
|
|
9727
9948
|
code = providedCode;
|
|
@@ -9759,8 +9980,8 @@ var LogoutUseCase = class {
|
|
|
9759
9980
|
constructor(deps) {
|
|
9760
9981
|
this.deps = {
|
|
9761
9982
|
getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
|
|
9762
|
-
fileExists: deps?.fileExists ?? ((
|
|
9763
|
-
deleteFile: deps?.deleteFile ?? ((
|
|
9983
|
+
fileExists: deps?.fileExists ?? ((path18) => fs7.existsSync(path18)),
|
|
9984
|
+
deleteFile: deps?.deleteFile ?? ((path18) => fs7.unlinkSync(path18)),
|
|
9764
9985
|
hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
|
|
9765
9986
|
};
|
|
9766
9987
|
}
|
|
@@ -9820,8 +10041,8 @@ var SetupMcpUseCase = class {
|
|
|
9820
10041
|
constructor(deps) {
|
|
9821
10042
|
this.deps = deps;
|
|
9822
10043
|
}
|
|
9823
|
-
async execute(
|
|
9824
|
-
const { agentTypes } =
|
|
10044
|
+
async execute(command21) {
|
|
10045
|
+
const { agentTypes } = command21;
|
|
9825
10046
|
const [tokenResult, urlResult] = await Promise.all([
|
|
9826
10047
|
this.deps.gateway.mcp.getToken({}),
|
|
9827
10048
|
this.deps.gateway.mcp.getUrl({})
|
|
@@ -9892,9 +10113,9 @@ var McpConfigService = class {
|
|
|
9892
10113
|
return JSON.stringify(mcpConfig, null, 2);
|
|
9893
10114
|
}
|
|
9894
10115
|
installClaudeMcp(config) {
|
|
9895
|
-
const
|
|
10116
|
+
const command21 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
|
|
9896
10117
|
try {
|
|
9897
|
-
(0, import_child_process2.execSync)(
|
|
10118
|
+
(0, import_child_process2.execSync)(command21, { stdio: "pipe" });
|
|
9898
10119
|
return { success: true };
|
|
9899
10120
|
} catch (error) {
|
|
9900
10121
|
const execError = error;
|
|
@@ -10390,16 +10611,9 @@ var ListSkillsUseCase = class {
|
|
|
10390
10611
|
var import_promises = __toESM(require("fs/promises"));
|
|
10391
10612
|
var import_path2 = __toESM(require("path"));
|
|
10392
10613
|
var import_minimatch3 = require("minimatch");
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
normalized = normalized.substring(1);
|
|
10397
|
-
}
|
|
10398
|
-
return normalized;
|
|
10399
|
-
}
|
|
10400
|
-
function normalizeLineEndings(content) {
|
|
10401
|
-
return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10402
|
-
}
|
|
10614
|
+
|
|
10615
|
+
// apps/cli/src/infra/utils/binaryDetection.ts
|
|
10616
|
+
var path10 = __toESM(require("path"));
|
|
10403
10617
|
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10404
10618
|
// Images
|
|
10405
10619
|
".png",
|
|
@@ -10457,7 +10671,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
10457
10671
|
".sqlite3"
|
|
10458
10672
|
]);
|
|
10459
10673
|
function isBinaryExtension(filePath) {
|
|
10460
|
-
const ext =
|
|
10674
|
+
const ext = path10.extname(filePath).toLowerCase();
|
|
10461
10675
|
return BINARY_EXTENSIONS.has(ext);
|
|
10462
10676
|
}
|
|
10463
10677
|
function isBinaryBuffer(buffer) {
|
|
@@ -10466,6 +10680,18 @@ function isBinaryBuffer(buffer) {
|
|
|
10466
10680
|
function isBinaryFile(filePath, buffer) {
|
|
10467
10681
|
return isBinaryExtension(filePath) || isBinaryBuffer(buffer);
|
|
10468
10682
|
}
|
|
10683
|
+
|
|
10684
|
+
// apps/cli/src/infra/utils/readSkillDirectory.ts
|
|
10685
|
+
function normalizePath2(filePath) {
|
|
10686
|
+
let normalized = filePath.replace(/\\/g, "/");
|
|
10687
|
+
if (normalized.startsWith("/") || normalized.startsWith("\\")) {
|
|
10688
|
+
normalized = normalized.substring(1);
|
|
10689
|
+
}
|
|
10690
|
+
return normalized;
|
|
10691
|
+
}
|
|
10692
|
+
function normalizeLineEndings(content) {
|
|
10693
|
+
return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10694
|
+
}
|
|
10469
10695
|
var MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
10470
10696
|
var MAX_FILE_SIZE_MB = 10;
|
|
10471
10697
|
var BLACKLIST_PATTERNS = ["**/.DS_Store"];
|
|
@@ -10488,9 +10714,9 @@ async function readSkillDirectory(dirPath) {
|
|
|
10488
10714
|
if (entry.isDirectory()) {
|
|
10489
10715
|
await readDir(fullPath, basePath);
|
|
10490
10716
|
} else if (entry.isFile()) {
|
|
10491
|
-
const
|
|
10492
|
-
if (
|
|
10493
|
-
const fileSizeMB = (
|
|
10717
|
+
const stat5 = await import_promises.default.stat(fullPath);
|
|
10718
|
+
if (stat5.size > MAX_FILE_SIZE_BYTES) {
|
|
10719
|
+
const fileSizeMB = (stat5.size / (1024 * 1024)).toFixed(2);
|
|
10494
10720
|
throw new Error(
|
|
10495
10721
|
`File "${relativePath}" is ${fileSizeMB} MB which exceeds the maximum allowed size of ${MAX_FILE_SIZE_MB} MB per file.`
|
|
10496
10722
|
);
|
|
@@ -10509,8 +10735,7 @@ async function readSkillDirectory(dirPath) {
|
|
|
10509
10735
|
relativePath: normalizedPath,
|
|
10510
10736
|
content,
|
|
10511
10737
|
size: Buffer.byteLength(content, isBinary ? "base64" : "utf-8"),
|
|
10512
|
-
permissions:
|
|
10513
|
-
// Simple default
|
|
10738
|
+
permissions: modeToPermissionStringOrDefault(stat5.mode),
|
|
10514
10739
|
isBase64: isBinary
|
|
10515
10740
|
});
|
|
10516
10741
|
}
|
|
@@ -10525,8 +10750,8 @@ var UploadSkillUseCase = class {
|
|
|
10525
10750
|
constructor(deps) {
|
|
10526
10751
|
this.deps = deps;
|
|
10527
10752
|
}
|
|
10528
|
-
async execute(
|
|
10529
|
-
const files = await readSkillDirectory(
|
|
10753
|
+
async execute(command21) {
|
|
10754
|
+
const files = await readSkillDirectory(command21.skillPath);
|
|
10530
10755
|
if (!files.find((f) => f.relativePath === "SKILL.md")) {
|
|
10531
10756
|
throw new Error("SKILL.md not found in skill directory");
|
|
10532
10757
|
}
|
|
@@ -10551,7 +10776,8 @@ var UploadSkillUseCase = class {
|
|
|
10551
10776
|
};
|
|
10552
10777
|
const uploadSkillResponse = await this.deps.gateway.skills.upload({
|
|
10553
10778
|
spaceId: createSpaceId(space.id),
|
|
10554
|
-
files: payload.files
|
|
10779
|
+
files: payload.files,
|
|
10780
|
+
originSkill: command21.originSkill
|
|
10555
10781
|
});
|
|
10556
10782
|
return {
|
|
10557
10783
|
skillId: uploadSkillResponse.skill.id,
|
|
@@ -10565,120 +10791,1004 @@ var UploadSkillUseCase = class {
|
|
|
10565
10791
|
}
|
|
10566
10792
|
};
|
|
10567
10793
|
|
|
10568
|
-
// apps/cli/src/
|
|
10569
|
-
var
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
lintFilesAgainstRule: new LintFilesAgainstRuleUseCase(
|
|
10588
|
-
this.services,
|
|
10589
|
-
this.repositories
|
|
10590
|
-
),
|
|
10591
|
-
lintFilesFromConfig: new LintFilesFromConfigUseCase(
|
|
10592
|
-
this.services,
|
|
10593
|
-
this.repositories
|
|
10594
|
-
),
|
|
10595
|
-
installPackages: new InstallPackagesUseCase(
|
|
10596
|
-
this.repositories.packmindGateway
|
|
10597
|
-
),
|
|
10598
|
-
installDefaultSkills: new InstallDefaultSkillsUseCase(this.repositories),
|
|
10599
|
-
listPackages: new ListPackagesUseCase(this.repositories.packmindGateway),
|
|
10600
|
-
getPackageBySlug: new GetPackageSummaryUseCase(
|
|
10601
|
-
this.repositories.packmindGateway
|
|
10602
|
-
),
|
|
10603
|
-
login: new LoginUseCase(),
|
|
10604
|
-
logout: new LogoutUseCase(),
|
|
10605
|
-
whoami: new WhoamiUseCase(),
|
|
10606
|
-
setupMcp: new SetupMcpUseCase({
|
|
10607
|
-
gateway: this.repositories.packmindGateway,
|
|
10608
|
-
mcpConfigService: new McpConfigService()
|
|
10609
|
-
}),
|
|
10610
|
-
listStandards: new ListStandardsUseCase(
|
|
10611
|
-
this.repositories.packmindGateway
|
|
10612
|
-
),
|
|
10613
|
-
listCommands: new ListCommandsUseCase(this.repositories.packmindGateway),
|
|
10614
|
-
listSkills: new ListSkillsUseCase(this.repositories.packmindGateway),
|
|
10615
|
-
uploadSkill: new UploadSkillUseCase({
|
|
10616
|
-
gateway: this.repositories.packmindGateway
|
|
10617
|
-
})
|
|
10618
|
-
};
|
|
10794
|
+
// apps/cli/src/application/useCases/diffStrategies/CommandDiffStrategy.ts
|
|
10795
|
+
var import_diff = require("diff");
|
|
10796
|
+
var fs11 = __toESM(require("fs/promises"));
|
|
10797
|
+
var path12 = __toESM(require("path"));
|
|
10798
|
+
|
|
10799
|
+
// apps/cli/src/application/utils/stripFrontmatter.ts
|
|
10800
|
+
var FRONTMATTER_DELIMITER2 = "---";
|
|
10801
|
+
function stripFrontmatter(content) {
|
|
10802
|
+
if (!content.startsWith(`${FRONTMATTER_DELIMITER2}
|
|
10803
|
+
`)) {
|
|
10804
|
+
return content;
|
|
10805
|
+
}
|
|
10806
|
+
const contentAfterOpening = content.slice(FRONTMATTER_DELIMITER2.length + 1);
|
|
10807
|
+
const closingIndex = contentAfterOpening.indexOf(
|
|
10808
|
+
`
|
|
10809
|
+
${FRONTMATTER_DELIMITER2}`
|
|
10810
|
+
);
|
|
10811
|
+
if (closingIndex === -1) {
|
|
10812
|
+
return content;
|
|
10619
10813
|
}
|
|
10620
|
-
|
|
10814
|
+
return contentAfterOpening.slice(closingIndex + FRONTMATTER_DELIMITER2.length + 1).trimStart();
|
|
10815
|
+
}
|
|
10621
10816
|
|
|
10622
|
-
// apps/cli/src/
|
|
10623
|
-
var
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
};
|
|
10631
|
-
this.logger = logger2;
|
|
10817
|
+
// apps/cli/src/application/useCases/diffStrategies/CommandDiffStrategy.ts
|
|
10818
|
+
var CommandDiffStrategy = class {
|
|
10819
|
+
supports(file) {
|
|
10820
|
+
return file.artifactType === "command";
|
|
10821
|
+
}
|
|
10822
|
+
async diff(file, baseDirectory) {
|
|
10823
|
+
const fullPath = path12.join(baseDirectory, file.path);
|
|
10824
|
+
let localContent;
|
|
10632
10825
|
try {
|
|
10633
|
-
|
|
10634
|
-
} catch
|
|
10635
|
-
|
|
10636
|
-
error: error instanceof Error ? error.message : String(error)
|
|
10637
|
-
});
|
|
10638
|
-
throw error;
|
|
10826
|
+
localContent = await fs11.readFile(fullPath, "utf-8");
|
|
10827
|
+
} catch {
|
|
10828
|
+
return [];
|
|
10639
10829
|
}
|
|
10830
|
+
const serverBody = stripFrontmatter(file.content);
|
|
10831
|
+
const localBody = stripFrontmatter(localContent);
|
|
10832
|
+
const changes = (0, import_diff.diffLines)(serverBody, localBody);
|
|
10833
|
+
const hasDifferences = changes.some(
|
|
10834
|
+
(change) => change.added || change.removed
|
|
10835
|
+
);
|
|
10836
|
+
if (!hasDifferences) {
|
|
10837
|
+
return [];
|
|
10838
|
+
}
|
|
10839
|
+
return [
|
|
10840
|
+
{
|
|
10841
|
+
filePath: file.path,
|
|
10842
|
+
type: "updateCommandDescription" /* updateCommandDescription */,
|
|
10843
|
+
payload: {
|
|
10844
|
+
oldValue: serverBody,
|
|
10845
|
+
newValue: localBody
|
|
10846
|
+
},
|
|
10847
|
+
artifactName: file.artifactName,
|
|
10848
|
+
artifactType: file.artifactType,
|
|
10849
|
+
artifactId: file.artifactId,
|
|
10850
|
+
spaceId: file.spaceId
|
|
10851
|
+
}
|
|
10852
|
+
];
|
|
10640
10853
|
}
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
return
|
|
10650
|
-
}
|
|
10651
|
-
async executeSingleFileAst(command20) {
|
|
10652
|
-
return this.hexa.useCases.executeSingleFileAst.execute(command20);
|
|
10854
|
+
};
|
|
10855
|
+
|
|
10856
|
+
// apps/cli/src/application/useCases/diffStrategies/SkillDiffStrategy.ts
|
|
10857
|
+
var import_diff2 = require("diff");
|
|
10858
|
+
var fs12 = __toESM(require("fs/promises"));
|
|
10859
|
+
var path13 = __toESM(require("path"));
|
|
10860
|
+
var SkillDiffStrategy = class {
|
|
10861
|
+
supports(file) {
|
|
10862
|
+
return file.artifactType === "skill";
|
|
10653
10863
|
}
|
|
10654
|
-
async
|
|
10655
|
-
|
|
10864
|
+
async diff(file, baseDirectory, context) {
|
|
10865
|
+
if (file.path.endsWith("/SKILL.md")) {
|
|
10866
|
+
return this.diffSkillMd(file, baseDirectory);
|
|
10867
|
+
}
|
|
10868
|
+
return this.diffSkillFile(file, baseDirectory, context?.skillFolders ?? []);
|
|
10656
10869
|
}
|
|
10657
|
-
async
|
|
10658
|
-
|
|
10870
|
+
async diffNewFiles(skillFolders, serverFiles, baseDirectory) {
|
|
10871
|
+
const diffs = [];
|
|
10872
|
+
for (const folder of skillFolders) {
|
|
10873
|
+
const folderPath = path13.join(baseDirectory, folder);
|
|
10874
|
+
const localFiles = await this.listFilesRecursively(folderPath);
|
|
10875
|
+
const serverPathsInFolder = new Set(
|
|
10876
|
+
serverFiles.filter((f) => f.path.startsWith(folder + "/")).map((f) => f.path)
|
|
10877
|
+
);
|
|
10878
|
+
const skillMdFile = serverFiles.find(
|
|
10879
|
+
(f) => f.path === `${folder}/SKILL.md` && f.artifactType === "skill"
|
|
10880
|
+
);
|
|
10881
|
+
if (!skillMdFile) {
|
|
10882
|
+
continue;
|
|
10883
|
+
}
|
|
10884
|
+
for (const relativePath of localFiles) {
|
|
10885
|
+
if (relativePath === "SKILL.md") {
|
|
10886
|
+
continue;
|
|
10887
|
+
}
|
|
10888
|
+
const filePath = `${folder}/${relativePath}`;
|
|
10889
|
+
if (serverPathsInFolder.has(filePath)) {
|
|
10890
|
+
continue;
|
|
10891
|
+
}
|
|
10892
|
+
const fullPath = path13.join(baseDirectory, filePath);
|
|
10893
|
+
const localRead = await this.tryReadFileBinaryAware(fullPath);
|
|
10894
|
+
if (localRead === null) {
|
|
10895
|
+
continue;
|
|
10896
|
+
}
|
|
10897
|
+
const permissions = await this.tryGetPermissions(fullPath) ?? "rw-r--r--";
|
|
10898
|
+
diffs.push({
|
|
10899
|
+
filePath,
|
|
10900
|
+
type: "addSkillFile" /* addSkillFile */,
|
|
10901
|
+
payload: {
|
|
10902
|
+
item: {
|
|
10903
|
+
path: relativePath,
|
|
10904
|
+
content: localRead.content,
|
|
10905
|
+
permissions,
|
|
10906
|
+
isBase64: localRead.isBase64
|
|
10907
|
+
}
|
|
10908
|
+
},
|
|
10909
|
+
artifactName: skillMdFile.artifactName,
|
|
10910
|
+
artifactType: "skill",
|
|
10911
|
+
artifactId: skillMdFile.artifactId,
|
|
10912
|
+
spaceId: skillMdFile.spaceId
|
|
10913
|
+
});
|
|
10914
|
+
}
|
|
10915
|
+
}
|
|
10916
|
+
return diffs;
|
|
10659
10917
|
}
|
|
10660
|
-
async
|
|
10661
|
-
|
|
10918
|
+
async diffSkillMd(file, baseDirectory) {
|
|
10919
|
+
const fullPath = path13.join(baseDirectory, file.path);
|
|
10920
|
+
const localContent = await this.tryReadFile(fullPath);
|
|
10921
|
+
if (localContent === null) {
|
|
10922
|
+
return [];
|
|
10923
|
+
}
|
|
10924
|
+
const serverParsed = parseSkillMd(file.content);
|
|
10925
|
+
const localParsed = parseSkillMd(localContent);
|
|
10926
|
+
if (!serverParsed || !localParsed) {
|
|
10927
|
+
const serverBody = stripFrontmatter(file.content);
|
|
10928
|
+
const localBody = stripFrontmatter(localContent);
|
|
10929
|
+
const changes = (0, import_diff2.diffLines)(serverBody, localBody);
|
|
10930
|
+
const hasDifferences = changes.some(
|
|
10931
|
+
(change) => change.added || change.removed
|
|
10932
|
+
);
|
|
10933
|
+
if (!hasDifferences) {
|
|
10934
|
+
return [];
|
|
10935
|
+
}
|
|
10936
|
+
return [
|
|
10937
|
+
{
|
|
10938
|
+
filePath: file.path,
|
|
10939
|
+
type: "updateSkillPrompt" /* updateSkillPrompt */,
|
|
10940
|
+
payload: { oldValue: serverBody, newValue: localBody },
|
|
10941
|
+
artifactName: file.artifactName,
|
|
10942
|
+
artifactType: file.artifactType,
|
|
10943
|
+
artifactId: file.artifactId,
|
|
10944
|
+
spaceId: file.spaceId
|
|
10945
|
+
}
|
|
10946
|
+
];
|
|
10947
|
+
}
|
|
10948
|
+
const baseDiff = {
|
|
10949
|
+
filePath: file.path,
|
|
10950
|
+
artifactName: file.artifactName,
|
|
10951
|
+
artifactType: file.artifactType,
|
|
10952
|
+
artifactId: file.artifactId,
|
|
10953
|
+
spaceId: file.spaceId
|
|
10954
|
+
};
|
|
10955
|
+
const checks = [
|
|
10956
|
+
this.checkUpdateSkillName(serverParsed, localParsed, baseDiff),
|
|
10957
|
+
this.checkUpdateSkillDescription(serverParsed, localParsed, baseDiff),
|
|
10958
|
+
this.checkUpdateSkillPrompt(serverParsed, localParsed, baseDiff),
|
|
10959
|
+
this.checkUpdateSkillMetadata(serverParsed, localParsed, baseDiff),
|
|
10960
|
+
this.checkUpdateSkillLicense(serverParsed, localParsed, baseDiff),
|
|
10961
|
+
this.checkUpdateSkillCompatibility(serverParsed, localParsed, baseDiff),
|
|
10962
|
+
this.checkUpdateSkillAllowedTools(serverParsed, localParsed, baseDiff)
|
|
10963
|
+
];
|
|
10964
|
+
return checks.filter((d) => d !== null);
|
|
10662
10965
|
}
|
|
10663
|
-
async
|
|
10664
|
-
|
|
10966
|
+
async diffSkillFile(file, baseDirectory, skillFolders) {
|
|
10967
|
+
if (!file.skillFileId) {
|
|
10968
|
+
return [];
|
|
10969
|
+
}
|
|
10970
|
+
const skillFileId = createSkillFileId(file.skillFileId);
|
|
10971
|
+
const fullPath = path13.join(baseDirectory, file.path);
|
|
10972
|
+
const localRead = await this.tryReadFileBinaryAware(fullPath);
|
|
10973
|
+
const fileRelativePath = this.computeRelativePath(file.path, skillFolders);
|
|
10974
|
+
if (localRead === null) {
|
|
10975
|
+
return [
|
|
10976
|
+
{
|
|
10977
|
+
filePath: file.path,
|
|
10978
|
+
type: "deleteSkillFile" /* deleteSkillFile */,
|
|
10979
|
+
payload: {
|
|
10980
|
+
targetId: skillFileId,
|
|
10981
|
+
item: {
|
|
10982
|
+
id: skillFileId,
|
|
10983
|
+
path: fileRelativePath,
|
|
10984
|
+
content: file.content,
|
|
10985
|
+
permissions: file.skillFilePermissions ?? "read",
|
|
10986
|
+
isBase64: file.isBase64 ?? false
|
|
10987
|
+
}
|
|
10988
|
+
},
|
|
10989
|
+
artifactName: file.artifactName,
|
|
10990
|
+
artifactType: file.artifactType,
|
|
10991
|
+
artifactId: file.artifactId,
|
|
10992
|
+
spaceId: file.spaceId
|
|
10993
|
+
}
|
|
10994
|
+
];
|
|
10995
|
+
}
|
|
10996
|
+
const baseDiff = {
|
|
10997
|
+
filePath: file.path,
|
|
10998
|
+
artifactName: file.artifactName,
|
|
10999
|
+
artifactType: file.artifactType,
|
|
11000
|
+
artifactId: file.artifactId,
|
|
11001
|
+
spaceId: file.spaceId
|
|
11002
|
+
};
|
|
11003
|
+
const checks = await Promise.all([
|
|
11004
|
+
this.checkUpdateSkillFileContent(
|
|
11005
|
+
file,
|
|
11006
|
+
localRead.content,
|
|
11007
|
+
localRead.isBase64,
|
|
11008
|
+
skillFileId,
|
|
11009
|
+
baseDiff
|
|
11010
|
+
),
|
|
11011
|
+
this.checkUpdateSkillFilePermissions(
|
|
11012
|
+
file,
|
|
11013
|
+
fullPath,
|
|
11014
|
+
skillFileId,
|
|
11015
|
+
baseDiff
|
|
11016
|
+
)
|
|
11017
|
+
]);
|
|
11018
|
+
return checks.filter((d) => d !== null);
|
|
10665
11019
|
}
|
|
10666
|
-
|
|
10667
|
-
|
|
11020
|
+
checkUpdateSkillName(serverParsed, localParsed, baseDiff) {
|
|
11021
|
+
if (serverParsed.name === localParsed.name) {
|
|
11022
|
+
return null;
|
|
11023
|
+
}
|
|
11024
|
+
return {
|
|
11025
|
+
...baseDiff,
|
|
11026
|
+
type: "updateSkillName" /* updateSkillName */,
|
|
11027
|
+
payload: { oldValue: serverParsed.name, newValue: localParsed.name }
|
|
11028
|
+
};
|
|
10668
11029
|
}
|
|
10669
|
-
|
|
10670
|
-
|
|
11030
|
+
checkUpdateSkillDescription(serverParsed, localParsed, baseDiff) {
|
|
11031
|
+
if (serverParsed.description === localParsed.description) {
|
|
11032
|
+
return null;
|
|
11033
|
+
}
|
|
11034
|
+
return {
|
|
11035
|
+
...baseDiff,
|
|
11036
|
+
type: "updateSkillDescription" /* updateSkillDescription */,
|
|
11037
|
+
payload: {
|
|
11038
|
+
oldValue: serverParsed.description,
|
|
11039
|
+
newValue: localParsed.description
|
|
11040
|
+
}
|
|
11041
|
+
};
|
|
10671
11042
|
}
|
|
10672
|
-
|
|
10673
|
-
|
|
11043
|
+
checkUpdateSkillPrompt(serverParsed, localParsed, baseDiff) {
|
|
11044
|
+
if (serverParsed.body === localParsed.body) {
|
|
11045
|
+
return null;
|
|
11046
|
+
}
|
|
11047
|
+
return {
|
|
11048
|
+
...baseDiff,
|
|
11049
|
+
type: "updateSkillPrompt" /* updateSkillPrompt */,
|
|
11050
|
+
payload: { oldValue: serverParsed.body, newValue: localParsed.body }
|
|
11051
|
+
};
|
|
10674
11052
|
}
|
|
10675
|
-
|
|
10676
|
-
|
|
11053
|
+
checkUpdateSkillMetadata(serverParsed, localParsed, baseDiff) {
|
|
11054
|
+
if (serverParsed.metadataJson === localParsed.metadataJson) {
|
|
11055
|
+
return null;
|
|
11056
|
+
}
|
|
11057
|
+
return {
|
|
11058
|
+
...baseDiff,
|
|
11059
|
+
type: "updateSkillMetadata" /* updateSkillMetadata */,
|
|
11060
|
+
payload: {
|
|
11061
|
+
oldValue: serverParsed.metadataJson,
|
|
11062
|
+
newValue: localParsed.metadataJson
|
|
11063
|
+
}
|
|
11064
|
+
};
|
|
10677
11065
|
}
|
|
10678
|
-
|
|
10679
|
-
|
|
11066
|
+
checkUpdateSkillLicense(serverParsed, localParsed, baseDiff) {
|
|
11067
|
+
if (serverParsed.license === localParsed.license) {
|
|
11068
|
+
return null;
|
|
11069
|
+
}
|
|
11070
|
+
return {
|
|
11071
|
+
...baseDiff,
|
|
11072
|
+
type: "updateSkillLicense" /* updateSkillLicense */,
|
|
11073
|
+
payload: {
|
|
11074
|
+
oldValue: serverParsed.license,
|
|
11075
|
+
newValue: localParsed.license
|
|
11076
|
+
}
|
|
11077
|
+
};
|
|
10680
11078
|
}
|
|
10681
|
-
|
|
11079
|
+
checkUpdateSkillCompatibility(serverParsed, localParsed, baseDiff) {
|
|
11080
|
+
if (serverParsed.compatibility === localParsed.compatibility) {
|
|
11081
|
+
return null;
|
|
11082
|
+
}
|
|
11083
|
+
return {
|
|
11084
|
+
...baseDiff,
|
|
11085
|
+
type: "updateSkillCompatibility" /* updateSkillCompatibility */,
|
|
11086
|
+
payload: {
|
|
11087
|
+
oldValue: serverParsed.compatibility,
|
|
11088
|
+
newValue: localParsed.compatibility
|
|
11089
|
+
}
|
|
11090
|
+
};
|
|
11091
|
+
}
|
|
11092
|
+
checkUpdateSkillAllowedTools(serverParsed, localParsed, baseDiff) {
|
|
11093
|
+
if (serverParsed.allowedTools === localParsed.allowedTools) {
|
|
11094
|
+
return null;
|
|
11095
|
+
}
|
|
11096
|
+
return {
|
|
11097
|
+
...baseDiff,
|
|
11098
|
+
type: "updateSkillAllowedTools" /* updateSkillAllowedTools */,
|
|
11099
|
+
payload: {
|
|
11100
|
+
oldValue: serverParsed.allowedTools,
|
|
11101
|
+
newValue: localParsed.allowedTools
|
|
11102
|
+
}
|
|
11103
|
+
};
|
|
11104
|
+
}
|
|
11105
|
+
checkUpdateSkillFileContent(file, localContent, localIsBase64, skillFileId, baseDiff) {
|
|
11106
|
+
const isBinary = localIsBase64 || (file.isBase64 ?? false);
|
|
11107
|
+
if (isBinary) {
|
|
11108
|
+
if (localContent === file.content) {
|
|
11109
|
+
return null;
|
|
11110
|
+
}
|
|
11111
|
+
return {
|
|
11112
|
+
...baseDiff,
|
|
11113
|
+
type: "updateSkillFileContent" /* updateSkillFileContent */,
|
|
11114
|
+
payload: {
|
|
11115
|
+
targetId: skillFileId,
|
|
11116
|
+
oldValue: file.content,
|
|
11117
|
+
newValue: localContent,
|
|
11118
|
+
isBase64: true
|
|
11119
|
+
}
|
|
11120
|
+
};
|
|
11121
|
+
}
|
|
11122
|
+
if (localContent === file.content) {
|
|
11123
|
+
return null;
|
|
11124
|
+
}
|
|
11125
|
+
return {
|
|
11126
|
+
...baseDiff,
|
|
11127
|
+
type: "updateSkillFileContent" /* updateSkillFileContent */,
|
|
11128
|
+
payload: {
|
|
11129
|
+
targetId: skillFileId,
|
|
11130
|
+
oldValue: file.content,
|
|
11131
|
+
newValue: localContent,
|
|
11132
|
+
isBase64: false
|
|
11133
|
+
}
|
|
11134
|
+
};
|
|
11135
|
+
}
|
|
11136
|
+
async checkUpdateSkillFilePermissions(file, fullPath, skillFileId, baseDiff) {
|
|
11137
|
+
if (!file.skillFilePermissions) {
|
|
11138
|
+
return null;
|
|
11139
|
+
}
|
|
11140
|
+
const localPermissions = await this.tryGetPermissions(fullPath);
|
|
11141
|
+
if (!localPermissions || localPermissions === file.skillFilePermissions) {
|
|
11142
|
+
return null;
|
|
11143
|
+
}
|
|
11144
|
+
return {
|
|
11145
|
+
...baseDiff,
|
|
11146
|
+
type: "updateSkillFilePermissions" /* updateSkillFilePermissions */,
|
|
11147
|
+
payload: {
|
|
11148
|
+
targetId: skillFileId,
|
|
11149
|
+
oldValue: file.skillFilePermissions,
|
|
11150
|
+
newValue: localPermissions
|
|
11151
|
+
}
|
|
11152
|
+
};
|
|
11153
|
+
}
|
|
11154
|
+
async tryReadFile(filePath) {
|
|
11155
|
+
try {
|
|
11156
|
+
return await fs12.readFile(filePath, "utf-8");
|
|
11157
|
+
} catch {
|
|
11158
|
+
return null;
|
|
11159
|
+
}
|
|
11160
|
+
}
|
|
11161
|
+
async tryReadFileBinaryAware(filePath) {
|
|
11162
|
+
try {
|
|
11163
|
+
const buffer = await fs12.readFile(filePath);
|
|
11164
|
+
if (isBinaryFile(filePath, buffer)) {
|
|
11165
|
+
return { content: buffer.toString("base64"), isBase64: true };
|
|
11166
|
+
}
|
|
11167
|
+
return { content: buffer.toString("utf-8"), isBase64: false };
|
|
11168
|
+
} catch {
|
|
11169
|
+
return null;
|
|
11170
|
+
}
|
|
11171
|
+
}
|
|
11172
|
+
async listFilesRecursively(dirPath, prefix = "") {
|
|
11173
|
+
let entries;
|
|
11174
|
+
try {
|
|
11175
|
+
entries = await fs12.readdir(dirPath);
|
|
11176
|
+
} catch {
|
|
11177
|
+
return [];
|
|
11178
|
+
}
|
|
11179
|
+
const files = [];
|
|
11180
|
+
for (const entry of entries) {
|
|
11181
|
+
const fullPath = path13.join(dirPath, entry);
|
|
11182
|
+
const stat5 = await this.tryStatFile(fullPath);
|
|
11183
|
+
if (!stat5) {
|
|
11184
|
+
continue;
|
|
11185
|
+
}
|
|
11186
|
+
const relativePath = prefix ? `${prefix}/${entry}` : entry;
|
|
11187
|
+
if (stat5.isDirectory) {
|
|
11188
|
+
const subFiles = await this.listFilesRecursively(
|
|
11189
|
+
fullPath,
|
|
11190
|
+
relativePath
|
|
11191
|
+
);
|
|
11192
|
+
files.push(...subFiles);
|
|
11193
|
+
} else {
|
|
11194
|
+
files.push(relativePath);
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
return files;
|
|
11198
|
+
}
|
|
11199
|
+
async tryStatFile(filePath) {
|
|
11200
|
+
try {
|
|
11201
|
+
const stat5 = await fs12.stat(filePath);
|
|
11202
|
+
return { isDirectory: stat5.isDirectory() };
|
|
11203
|
+
} catch {
|
|
11204
|
+
return null;
|
|
11205
|
+
}
|
|
11206
|
+
}
|
|
11207
|
+
async tryGetPermissions(filePath) {
|
|
11208
|
+
try {
|
|
11209
|
+
const stat5 = await fs12.stat(filePath);
|
|
11210
|
+
return modeToPermissionStringOrDefault(stat5.mode);
|
|
11211
|
+
} catch {
|
|
11212
|
+
return null;
|
|
11213
|
+
}
|
|
11214
|
+
}
|
|
11215
|
+
computeRelativePath(filePath, skillFolders) {
|
|
11216
|
+
const skillFolder = skillFolders.find((f) => filePath.startsWith(f + "/"));
|
|
11217
|
+
if (skillFolder) {
|
|
11218
|
+
return filePath.slice(skillFolder.length + 1);
|
|
11219
|
+
}
|
|
11220
|
+
return filePath.split("/").slice(3).join("/");
|
|
11221
|
+
}
|
|
11222
|
+
};
|
|
11223
|
+
|
|
11224
|
+
// apps/cli/src/application/useCases/diffStrategies/StandardDiffStrategy.ts
|
|
11225
|
+
var fs13 = __toESM(require("fs/promises"));
|
|
11226
|
+
var path14 = __toESM(require("path"));
|
|
11227
|
+
|
|
11228
|
+
// apps/cli/src/application/utils/parseStandardMd.ts
|
|
11229
|
+
var DEPLOYER_PARSERS = [
|
|
11230
|
+
{ pattern: ".packmind/standards/", parse: parsePackmindStandard },
|
|
11231
|
+
{ pattern: ".claude/rules/packmind/standard-", parse: parseClaudeStandard },
|
|
11232
|
+
{ pattern: ".cursor/rules/packmind/standard-", parse: parseCursorStandard },
|
|
11233
|
+
{
|
|
11234
|
+
pattern: ".continue/rules/packmind/standard-",
|
|
11235
|
+
parse: parseContinueStandard
|
|
11236
|
+
},
|
|
11237
|
+
{ pattern: ".github/instructions/packmind-", parse: parseCopilotStandard }
|
|
11238
|
+
];
|
|
11239
|
+
function parseStandardMd(content, filePath) {
|
|
11240
|
+
const deployer = DEPLOYER_PARSERS.find((d) => filePath.includes(d.pattern));
|
|
11241
|
+
if (!deployer) {
|
|
11242
|
+
return null;
|
|
11243
|
+
}
|
|
11244
|
+
return deployer.parse(content);
|
|
11245
|
+
}
|
|
11246
|
+
function parsePackmindStandard(content) {
|
|
11247
|
+
const lines = content.split("\n");
|
|
11248
|
+
let name = null;
|
|
11249
|
+
let nameLineIndex = -1;
|
|
11250
|
+
for (let i = 0; i < lines.length; i++) {
|
|
11251
|
+
if (lines[i].startsWith("# ") && !lines[i].startsWith("## ")) {
|
|
11252
|
+
const extracted = lines[i].slice(2).trim();
|
|
11253
|
+
if (extracted) {
|
|
11254
|
+
name = extracted;
|
|
11255
|
+
nameLineIndex = i;
|
|
11256
|
+
break;
|
|
11257
|
+
}
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
if (!name) {
|
|
11261
|
+
return null;
|
|
11262
|
+
}
|
|
11263
|
+
let rulesLineIndex = -1;
|
|
11264
|
+
for (let i = nameLineIndex + 1; i < lines.length; i++) {
|
|
11265
|
+
if (lines[i].trim() === "## Rules") {
|
|
11266
|
+
rulesLineIndex = i;
|
|
11267
|
+
break;
|
|
11268
|
+
}
|
|
11269
|
+
}
|
|
11270
|
+
const descriptionLines = [];
|
|
11271
|
+
let rulesStartIndex = -1;
|
|
11272
|
+
if (rulesLineIndex >= 0) {
|
|
11273
|
+
for (let i = nameLineIndex + 1; i < rulesLineIndex; i++) {
|
|
11274
|
+
descriptionLines.push(lines[i]);
|
|
11275
|
+
}
|
|
11276
|
+
rulesStartIndex = rulesLineIndex + 1;
|
|
11277
|
+
} else {
|
|
11278
|
+
for (let i = nameLineIndex + 1; i < lines.length; i++) {
|
|
11279
|
+
if (lines[i].startsWith("* ") || lines[i].startsWith("- ")) {
|
|
11280
|
+
rulesStartIndex = i;
|
|
11281
|
+
break;
|
|
11282
|
+
}
|
|
11283
|
+
descriptionLines.push(lines[i]);
|
|
11284
|
+
}
|
|
11285
|
+
}
|
|
11286
|
+
const rules = extractRulesList(lines, rulesStartIndex);
|
|
11287
|
+
return {
|
|
11288
|
+
name,
|
|
11289
|
+
description: descriptionLines.join("\n").trim(),
|
|
11290
|
+
scope: "",
|
|
11291
|
+
rules
|
|
11292
|
+
};
|
|
11293
|
+
}
|
|
11294
|
+
function parseClaudeStandard(content) {
|
|
11295
|
+
const { frontmatter, body } = extractFrontmatter(content);
|
|
11296
|
+
const scope = extractScopeFromKey(frontmatter, "paths");
|
|
11297
|
+
const parsed = parseIdeStandardBody(body, scope);
|
|
11298
|
+
if (!parsed) return null;
|
|
11299
|
+
return addFrontmatterFields(parsed, frontmatter);
|
|
11300
|
+
}
|
|
11301
|
+
function parseCursorStandard(content) {
|
|
11302
|
+
const { frontmatter, body } = extractFrontmatter(content);
|
|
11303
|
+
const scope = extractScopeFromKey(frontmatter, "globs");
|
|
11304
|
+
return parseIdeStandardBody(body, scope);
|
|
11305
|
+
}
|
|
11306
|
+
function parseContinueStandard(content) {
|
|
11307
|
+
const { frontmatter, body } = extractFrontmatter(content);
|
|
11308
|
+
const scope = extractScopeFromKey(frontmatter, "globs");
|
|
11309
|
+
const parsed = parseIdeStandardBody(body, scope);
|
|
11310
|
+
if (!parsed) return null;
|
|
11311
|
+
return addFrontmatterFields(parsed, frontmatter);
|
|
11312
|
+
}
|
|
11313
|
+
function parseCopilotStandard(content) {
|
|
11314
|
+
const { frontmatter, body } = extractFrontmatter(content);
|
|
11315
|
+
const rawScope = extractFrontmatterValue(frontmatter, "applyTo");
|
|
11316
|
+
let scope = "";
|
|
11317
|
+
if (rawScope) {
|
|
11318
|
+
const stripped = rawScope.replace(/(?:^['"])|(?:['"]$)/g, "");
|
|
11319
|
+
scope = stripped === "**" ? "" : stripped;
|
|
11320
|
+
}
|
|
11321
|
+
return parseIdeStandardBody(body, scope);
|
|
11322
|
+
}
|
|
11323
|
+
var RULES_FALLBACK = "No rules defined yet.";
|
|
11324
|
+
function extractRulesList(lines, startIndex) {
|
|
11325
|
+
if (startIndex < 0) return [];
|
|
11326
|
+
const rules = [];
|
|
11327
|
+
for (let i = startIndex; i < lines.length; i++) {
|
|
11328
|
+
const line = lines[i];
|
|
11329
|
+
if (line.startsWith("* ") || line.startsWith("- ")) {
|
|
11330
|
+
const content = line.slice(2).trim();
|
|
11331
|
+
if (content && content !== RULES_FALLBACK) {
|
|
11332
|
+
rules.push(content);
|
|
11333
|
+
}
|
|
11334
|
+
} else if (line.startsWith("Full standard is available")) {
|
|
11335
|
+
break;
|
|
11336
|
+
} else if (line.startsWith("## ")) {
|
|
11337
|
+
break;
|
|
11338
|
+
}
|
|
11339
|
+
}
|
|
11340
|
+
return rules;
|
|
11341
|
+
}
|
|
11342
|
+
function extractFrontmatter(content) {
|
|
11343
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
11344
|
+
if (!match) {
|
|
11345
|
+
return { frontmatter: "", body: content };
|
|
11346
|
+
}
|
|
11347
|
+
return {
|
|
11348
|
+
frontmatter: match[1],
|
|
11349
|
+
body: content.slice(match[0].length)
|
|
11350
|
+
};
|
|
11351
|
+
}
|
|
11352
|
+
function parseIdeStandardBody(body, scope) {
|
|
11353
|
+
const lines = body.split("\n");
|
|
11354
|
+
let name = null;
|
|
11355
|
+
let nameLineIndex = -1;
|
|
11356
|
+
for (let i = 0; i < lines.length; i++) {
|
|
11357
|
+
if (lines[i].startsWith("## Standard: ")) {
|
|
11358
|
+
const extracted = lines[i].slice("## Standard: ".length).trim();
|
|
11359
|
+
if (extracted) {
|
|
11360
|
+
name = extracted;
|
|
11361
|
+
nameLineIndex = i;
|
|
11362
|
+
break;
|
|
11363
|
+
}
|
|
11364
|
+
}
|
|
11365
|
+
}
|
|
11366
|
+
if (!name) {
|
|
11367
|
+
return null;
|
|
11368
|
+
}
|
|
11369
|
+
const descriptionLines = [];
|
|
11370
|
+
let rulesStartIndex = -1;
|
|
11371
|
+
for (let i = nameLineIndex + 1; i < lines.length; i++) {
|
|
11372
|
+
if (lines[i].startsWith("* ") || lines[i].startsWith("- ")) {
|
|
11373
|
+
rulesStartIndex = i;
|
|
11374
|
+
break;
|
|
11375
|
+
}
|
|
11376
|
+
if (lines[i].startsWith("Full standard is available")) break;
|
|
11377
|
+
descriptionLines.push(lines[i]);
|
|
11378
|
+
}
|
|
11379
|
+
let description = descriptionLines.join("\n").trim();
|
|
11380
|
+
if (description.endsWith(" :")) {
|
|
11381
|
+
description = description.slice(0, -2).trim();
|
|
11382
|
+
}
|
|
11383
|
+
const rules = extractRulesList(lines, rulesStartIndex);
|
|
11384
|
+
return { name, description, scope, rules };
|
|
11385
|
+
}
|
|
11386
|
+
function addFrontmatterFields(parsed, frontmatter) {
|
|
11387
|
+
const fmName = extractFrontmatterValue(frontmatter, "name");
|
|
11388
|
+
const fmDescription = extractFrontmatterValue(frontmatter, "description");
|
|
11389
|
+
return {
|
|
11390
|
+
...parsed,
|
|
11391
|
+
...fmName ? { frontmatterName: fmName } : {},
|
|
11392
|
+
...fmDescription ? { frontmatterDescription: fmDescription } : {}
|
|
11393
|
+
};
|
|
11394
|
+
}
|
|
11395
|
+
function extractFrontmatterValue(frontmatter, key) {
|
|
11396
|
+
if (!frontmatter) return "";
|
|
11397
|
+
for (const line of frontmatter.split("\n")) {
|
|
11398
|
+
const trimmed = line.trim();
|
|
11399
|
+
if (trimmed.startsWith(`${key}:`)) {
|
|
11400
|
+
const raw = trimmed.slice(key.length + 1).trim();
|
|
11401
|
+
return stripYamlQuotes(raw);
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
return "";
|
|
11405
|
+
}
|
|
11406
|
+
function stripYamlQuotes(value) {
|
|
11407
|
+
if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
|
|
11408
|
+
return value.slice(1, -1).replace(/''/g, "'");
|
|
11409
|
+
}
|
|
11410
|
+
if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
|
|
11411
|
+
return value.slice(1, -1);
|
|
11412
|
+
}
|
|
11413
|
+
return value;
|
|
11414
|
+
}
|
|
11415
|
+
function extractScopeFromKey(frontmatter, key) {
|
|
11416
|
+
const rawValue = extractFrontmatterValue(frontmatter, key);
|
|
11417
|
+
if (!rawValue) return "";
|
|
11418
|
+
return normalizeScopeValue(rawValue);
|
|
11419
|
+
}
|
|
11420
|
+
function normalizeScopeValue(rawValue) {
|
|
11421
|
+
if (!rawValue) return "";
|
|
11422
|
+
if (rawValue.startsWith("[")) {
|
|
11423
|
+
const inner = rawValue.slice(1, -1);
|
|
11424
|
+
const items = inner.split(",").map((item) => item.trim().replace(/(?:^["'])|(?:["']$)/g, ""));
|
|
11425
|
+
return items.join(", ");
|
|
11426
|
+
}
|
|
11427
|
+
return rawValue.replace(/(?:^["'])|(?:["']$)/g, "");
|
|
11428
|
+
}
|
|
11429
|
+
|
|
11430
|
+
// apps/cli/src/application/useCases/diffStrategies/StandardDiffStrategy.ts
|
|
11431
|
+
var StandardDiffStrategy = class {
|
|
11432
|
+
supports(file) {
|
|
11433
|
+
return file.artifactType === "standard";
|
|
11434
|
+
}
|
|
11435
|
+
async diff(file, baseDirectory) {
|
|
11436
|
+
const fullPath = path14.join(baseDirectory, file.path);
|
|
11437
|
+
let localContent;
|
|
11438
|
+
try {
|
|
11439
|
+
localContent = await fs13.readFile(fullPath, "utf-8");
|
|
11440
|
+
} catch {
|
|
11441
|
+
return [];
|
|
11442
|
+
}
|
|
11443
|
+
const serverParsed = parseStandardMd(file.content, file.path);
|
|
11444
|
+
const localParsed = parseStandardMd(localContent, file.path);
|
|
11445
|
+
if (!serverParsed || !localParsed) {
|
|
11446
|
+
return [];
|
|
11447
|
+
}
|
|
11448
|
+
const diffs = [];
|
|
11449
|
+
const diffBase = {
|
|
11450
|
+
filePath: file.path,
|
|
11451
|
+
artifactName: file.artifactName,
|
|
11452
|
+
artifactType: file.artifactType,
|
|
11453
|
+
artifactId: file.artifactId,
|
|
11454
|
+
spaceId: file.spaceId
|
|
11455
|
+
};
|
|
11456
|
+
if (serverParsed.frontmatterName && localParsed.frontmatterName && serverParsed.frontmatterName !== localParsed.frontmatterName) {
|
|
11457
|
+
diffs.push({
|
|
11458
|
+
...diffBase,
|
|
11459
|
+
type: "updateStandardName" /* updateStandardName */,
|
|
11460
|
+
payload: {
|
|
11461
|
+
oldValue: serverParsed.frontmatterName,
|
|
11462
|
+
newValue: localParsed.frontmatterName
|
|
11463
|
+
}
|
|
11464
|
+
});
|
|
11465
|
+
}
|
|
11466
|
+
if (serverParsed.name !== localParsed.name) {
|
|
11467
|
+
diffs.push({
|
|
11468
|
+
...diffBase,
|
|
11469
|
+
type: "updateStandardName" /* updateStandardName */,
|
|
11470
|
+
payload: {
|
|
11471
|
+
oldValue: serverParsed.name,
|
|
11472
|
+
newValue: localParsed.name
|
|
11473
|
+
}
|
|
11474
|
+
});
|
|
11475
|
+
}
|
|
11476
|
+
if (serverParsed.frontmatterDescription && localParsed.frontmatterDescription && serverParsed.frontmatterDescription !== localParsed.frontmatterDescription) {
|
|
11477
|
+
diffs.push({
|
|
11478
|
+
...diffBase,
|
|
11479
|
+
type: "updateStandardDescription" /* updateStandardDescription */,
|
|
11480
|
+
payload: {
|
|
11481
|
+
oldValue: serverParsed.frontmatterDescription,
|
|
11482
|
+
newValue: localParsed.frontmatterDescription
|
|
11483
|
+
}
|
|
11484
|
+
});
|
|
11485
|
+
}
|
|
11486
|
+
if (serverParsed.description !== localParsed.description) {
|
|
11487
|
+
diffs.push({
|
|
11488
|
+
...diffBase,
|
|
11489
|
+
type: "updateStandardDescription" /* updateStandardDescription */,
|
|
11490
|
+
payload: {
|
|
11491
|
+
oldValue: serverParsed.description,
|
|
11492
|
+
newValue: localParsed.description
|
|
11493
|
+
}
|
|
11494
|
+
});
|
|
11495
|
+
}
|
|
11496
|
+
if (serverParsed.scope !== localParsed.scope) {
|
|
11497
|
+
diffs.push({
|
|
11498
|
+
...diffBase,
|
|
11499
|
+
type: "updateStandardScope" /* updateStandardScope */,
|
|
11500
|
+
payload: {
|
|
11501
|
+
oldValue: serverParsed.scope,
|
|
11502
|
+
newValue: localParsed.scope
|
|
11503
|
+
}
|
|
11504
|
+
});
|
|
11505
|
+
}
|
|
11506
|
+
const serverRules = new Set(serverParsed.rules);
|
|
11507
|
+
const localRules = new Set(localParsed.rules);
|
|
11508
|
+
for (const rule of serverRules) {
|
|
11509
|
+
if (!localRules.has(rule)) {
|
|
11510
|
+
const ruleId = createRuleId("unresolved");
|
|
11511
|
+
diffs.push({
|
|
11512
|
+
...diffBase,
|
|
11513
|
+
type: "deleteRule" /* deleteRule */,
|
|
11514
|
+
payload: {
|
|
11515
|
+
targetId: ruleId,
|
|
11516
|
+
item: { id: ruleId, content: rule }
|
|
11517
|
+
}
|
|
11518
|
+
});
|
|
11519
|
+
}
|
|
11520
|
+
}
|
|
11521
|
+
for (const rule of localRules) {
|
|
11522
|
+
if (!serverRules.has(rule)) {
|
|
11523
|
+
diffs.push({
|
|
11524
|
+
...diffBase,
|
|
11525
|
+
type: "addRule" /* addRule */,
|
|
11526
|
+
payload: {
|
|
11527
|
+
item: { content: rule }
|
|
11528
|
+
}
|
|
11529
|
+
});
|
|
11530
|
+
}
|
|
11531
|
+
}
|
|
11532
|
+
return diffs;
|
|
11533
|
+
}
|
|
11534
|
+
};
|
|
11535
|
+
|
|
11536
|
+
// apps/cli/src/application/useCases/DiffArtefactsUseCase.ts
|
|
11537
|
+
var DiffArtefactsUseCase = class {
|
|
11538
|
+
constructor(packmindGateway) {
|
|
11539
|
+
this.packmindGateway = packmindGateway;
|
|
11540
|
+
this.strategies = [
|
|
11541
|
+
new CommandDiffStrategy(),
|
|
11542
|
+
new SkillDiffStrategy(),
|
|
11543
|
+
new StandardDiffStrategy()
|
|
11544
|
+
];
|
|
11545
|
+
}
|
|
11546
|
+
async execute(command21) {
|
|
11547
|
+
const baseDirectory = command21.baseDirectory || process.cwd();
|
|
11548
|
+
const response = await this.packmindGateway.deployment.getDeployed({
|
|
11549
|
+
packagesSlugs: command21.packagesSlugs,
|
|
11550
|
+
gitRemoteUrl: command21.gitRemoteUrl,
|
|
11551
|
+
gitBranch: command21.gitBranch,
|
|
11552
|
+
relativePath: command21.relativePath,
|
|
11553
|
+
agents: command21.agents
|
|
11554
|
+
});
|
|
11555
|
+
const filteredFiles = response.fileUpdates.createOrUpdate.filter(
|
|
11556
|
+
(file) => file.path !== "packmind.json"
|
|
11557
|
+
);
|
|
11558
|
+
const uniqueFilesMap = /* @__PURE__ */ new Map();
|
|
11559
|
+
for (const file of filteredFiles) {
|
|
11560
|
+
uniqueFilesMap.set(file.path, file);
|
|
11561
|
+
}
|
|
11562
|
+
const diffableFiles = Array.from(uniqueFilesMap.values()).filter(
|
|
11563
|
+
(file) => !!file.artifactType && !!file.artifactName && file.content !== void 0
|
|
11564
|
+
);
|
|
11565
|
+
const prefixedSkillFolders = this.prefixSkillFolders(
|
|
11566
|
+
response.skillFolders,
|
|
11567
|
+
command21.relativePath
|
|
11568
|
+
);
|
|
11569
|
+
const diffs = [];
|
|
11570
|
+
for (const file of diffableFiles) {
|
|
11571
|
+
const strategy = this.strategies.find((s) => s.supports(file));
|
|
11572
|
+
if (strategy) {
|
|
11573
|
+
const fileDiffs = await strategy.diff(file, baseDirectory, {
|
|
11574
|
+
skillFolders: prefixedSkillFolders
|
|
11575
|
+
});
|
|
11576
|
+
diffs.push(...fileDiffs);
|
|
11577
|
+
}
|
|
11578
|
+
}
|
|
11579
|
+
for (const strategy of this.strategies) {
|
|
11580
|
+
if (strategy.diffNewFiles) {
|
|
11581
|
+
const newFileDiffs = await strategy.diffNewFiles(
|
|
11582
|
+
prefixedSkillFolders,
|
|
11583
|
+
diffableFiles,
|
|
11584
|
+
baseDirectory
|
|
11585
|
+
);
|
|
11586
|
+
diffs.push(...newFileDiffs);
|
|
11587
|
+
}
|
|
11588
|
+
}
|
|
11589
|
+
return diffs;
|
|
11590
|
+
}
|
|
11591
|
+
prefixSkillFolders(skillFolders, relativePath) {
|
|
11592
|
+
if (!relativePath) return skillFolders;
|
|
11593
|
+
let normalized = relativePath;
|
|
11594
|
+
while (normalized.startsWith("/")) normalized = normalized.slice(1);
|
|
11595
|
+
while (normalized.endsWith("/")) normalized = normalized.slice(0, -1);
|
|
11596
|
+
if (!normalized) return skillFolders;
|
|
11597
|
+
return skillFolders.map((folder) => `${normalized}/${folder}`);
|
|
11598
|
+
}
|
|
11599
|
+
};
|
|
11600
|
+
|
|
11601
|
+
// apps/cli/src/application/useCases/SubmitDiffsUseCase.ts
|
|
11602
|
+
var SUPPORTED_ARTIFACT_TYPES = /* @__PURE__ */ new Set(["command", "skill", "standard"]);
|
|
11603
|
+
var SubmitDiffsUseCase = class {
|
|
11604
|
+
constructor(packmindGateway) {
|
|
11605
|
+
this.packmindGateway = packmindGateway;
|
|
11606
|
+
}
|
|
11607
|
+
async execute(command21) {
|
|
11608
|
+
const { groupedDiffs } = command21;
|
|
11609
|
+
const skipped = [];
|
|
11610
|
+
const validDiffs = [];
|
|
11611
|
+
for (const group of groupedDiffs) {
|
|
11612
|
+
const firstDiff = group[0];
|
|
11613
|
+
if (!firstDiff) {
|
|
11614
|
+
continue;
|
|
11615
|
+
}
|
|
11616
|
+
if (!SUPPORTED_ARTIFACT_TYPES.has(firstDiff.artifactType)) {
|
|
11617
|
+
skipped.push({
|
|
11618
|
+
name: firstDiff.artifactName,
|
|
11619
|
+
reason: "Only commands, skills, and standards are supported"
|
|
11620
|
+
});
|
|
11621
|
+
continue;
|
|
11622
|
+
}
|
|
11623
|
+
for (const diff of group) {
|
|
11624
|
+
if (!diff.artifactId || !diff.spaceId) {
|
|
11625
|
+
skipped.push({
|
|
11626
|
+
name: diff.artifactName,
|
|
11627
|
+
reason: "Missing artifact metadata"
|
|
11628
|
+
});
|
|
11629
|
+
continue;
|
|
11630
|
+
}
|
|
11631
|
+
validDiffs.push(diff);
|
|
11632
|
+
}
|
|
11633
|
+
}
|
|
11634
|
+
const diffsBySpaceId = /* @__PURE__ */ new Map();
|
|
11635
|
+
for (const diff of validDiffs) {
|
|
11636
|
+
const existing = diffsBySpaceId.get(diff.spaceId) ?? [];
|
|
11637
|
+
existing.push(diff);
|
|
11638
|
+
diffsBySpaceId.set(diff.spaceId, existing);
|
|
11639
|
+
}
|
|
11640
|
+
let submitted = 0;
|
|
11641
|
+
let alreadySubmitted = 0;
|
|
11642
|
+
const errors = [];
|
|
11643
|
+
for (const [spaceId, diffs] of diffsBySpaceId) {
|
|
11644
|
+
const response = await this.packmindGateway.changeProposals.batchCreate({
|
|
11645
|
+
spaceId,
|
|
11646
|
+
proposals: diffs.map((diff) => ({
|
|
11647
|
+
type: diff.type,
|
|
11648
|
+
artefactId: diff.artifactId,
|
|
11649
|
+
payload: diff.payload,
|
|
11650
|
+
captureMode: "commit" /* commit */
|
|
11651
|
+
}))
|
|
11652
|
+
});
|
|
11653
|
+
submitted += response.created;
|
|
11654
|
+
alreadySubmitted += response.skipped;
|
|
11655
|
+
for (const error of response.errors) {
|
|
11656
|
+
errors.push({
|
|
11657
|
+
name: diffs[error.index].artifactName,
|
|
11658
|
+
message: error.message,
|
|
11659
|
+
code: error.code,
|
|
11660
|
+
artifactType: diffs[error.index].artifactType
|
|
11661
|
+
});
|
|
11662
|
+
}
|
|
11663
|
+
}
|
|
11664
|
+
return { submitted, alreadySubmitted, skipped, errors };
|
|
11665
|
+
}
|
|
11666
|
+
};
|
|
11667
|
+
|
|
11668
|
+
// apps/cli/src/PackmindCliHexaFactory.ts
|
|
11669
|
+
var PackmindCliHexaFactory = class {
|
|
11670
|
+
constructor() {
|
|
11671
|
+
this.repositories = {
|
|
11672
|
+
packmindGateway: new PackmindGateway(loadApiKey()),
|
|
11673
|
+
configFileRepository: new ConfigFileRepository()
|
|
11674
|
+
};
|
|
11675
|
+
this.services = {
|
|
11676
|
+
listFiles: new ListFiles(),
|
|
11677
|
+
gitRemoteUrlService: new GitService(),
|
|
11678
|
+
linterExecutionUseCase: new ExecuteLinterProgramsUseCase(),
|
|
11679
|
+
diffViolationFilterService: new DiffViolationFilterService()
|
|
11680
|
+
};
|
|
11681
|
+
this.useCases = {
|
|
11682
|
+
executeSingleFileAst: new ExecuteSingleFileAstUseCase(
|
|
11683
|
+
this.services.linterExecutionUseCase
|
|
11684
|
+
),
|
|
11685
|
+
getGitRemoteUrl: new GetGitRemoteUrlUseCase(),
|
|
11686
|
+
listFilesInDirectoryUseCase: new ListFilesInDirectoryUseCase(),
|
|
11687
|
+
lintFilesAgainstRule: new LintFilesAgainstRuleUseCase(
|
|
11688
|
+
this.services,
|
|
11689
|
+
this.repositories
|
|
11690
|
+
),
|
|
11691
|
+
lintFilesFromConfig: new LintFilesFromConfigUseCase(
|
|
11692
|
+
this.services,
|
|
11693
|
+
this.repositories
|
|
11694
|
+
),
|
|
11695
|
+
installPackages: new InstallPackagesUseCase(
|
|
11696
|
+
this.repositories.packmindGateway
|
|
11697
|
+
),
|
|
11698
|
+
installDefaultSkills: new InstallDefaultSkillsUseCase(this.repositories),
|
|
11699
|
+
listPackages: new ListPackagesUseCase(this.repositories.packmindGateway),
|
|
11700
|
+
getPackageBySlug: new GetPackageSummaryUseCase(
|
|
11701
|
+
this.repositories.packmindGateway
|
|
11702
|
+
),
|
|
11703
|
+
login: new LoginUseCase(),
|
|
11704
|
+
logout: new LogoutUseCase(),
|
|
11705
|
+
whoami: new WhoamiUseCase(),
|
|
11706
|
+
setupMcp: new SetupMcpUseCase({
|
|
11707
|
+
gateway: this.repositories.packmindGateway,
|
|
11708
|
+
mcpConfigService: new McpConfigService()
|
|
11709
|
+
}),
|
|
11710
|
+
listStandards: new ListStandardsUseCase(
|
|
11711
|
+
this.repositories.packmindGateway
|
|
11712
|
+
),
|
|
11713
|
+
listCommands: new ListCommandsUseCase(this.repositories.packmindGateway),
|
|
11714
|
+
listSkills: new ListSkillsUseCase(this.repositories.packmindGateway),
|
|
11715
|
+
uploadSkill: new UploadSkillUseCase({
|
|
11716
|
+
gateway: this.repositories.packmindGateway
|
|
11717
|
+
}),
|
|
11718
|
+
diffArtefacts: new DiffArtefactsUseCase(
|
|
11719
|
+
this.repositories.packmindGateway
|
|
11720
|
+
),
|
|
11721
|
+
submitDiffs: new SubmitDiffsUseCase(this.repositories.packmindGateway)
|
|
11722
|
+
};
|
|
11723
|
+
}
|
|
11724
|
+
};
|
|
11725
|
+
|
|
11726
|
+
// apps/cli/src/PackmindCliHexa.ts
|
|
11727
|
+
var origin8 = "PackmindCliHexa";
|
|
11728
|
+
var PackmindCliHexa = class {
|
|
11729
|
+
constructor(logger2 = new PackmindLogger(origin8)) {
|
|
11730
|
+
this.notifyDistribution = async (command21) => {
|
|
11731
|
+
return this.hexa.repositories.packmindGateway.deployment.notifyDistribution(
|
|
11732
|
+
command21
|
|
11733
|
+
);
|
|
11734
|
+
};
|
|
11735
|
+
this.logger = logger2;
|
|
11736
|
+
try {
|
|
11737
|
+
this.hexa = new PackmindCliHexaFactory();
|
|
11738
|
+
} catch (error) {
|
|
11739
|
+
this.logger.error("Failed to initialize PackmindCliHexa", {
|
|
11740
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11741
|
+
});
|
|
11742
|
+
throw error;
|
|
11743
|
+
}
|
|
11744
|
+
}
|
|
11745
|
+
/**
|
|
11746
|
+
* Destroys the DeploymentsHexa and cleans up resources
|
|
11747
|
+
*/
|
|
11748
|
+
destroy() {
|
|
11749
|
+
this.logger.info("Destroying PackmindCliHexa");
|
|
11750
|
+
this.logger.info("PackmindCliHexa destroyed");
|
|
11751
|
+
}
|
|
11752
|
+
async getGitRemoteUrl(command21) {
|
|
11753
|
+
return this.hexa.useCases.getGitRemoteUrl.execute(command21);
|
|
11754
|
+
}
|
|
11755
|
+
async executeSingleFileAst(command21) {
|
|
11756
|
+
return this.hexa.useCases.executeSingleFileAst.execute(command21);
|
|
11757
|
+
}
|
|
11758
|
+
async listFilesInDirectory(command21) {
|
|
11759
|
+
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command21);
|
|
11760
|
+
}
|
|
11761
|
+
async lintFilesAgainstRule(command21) {
|
|
11762
|
+
return this.hexa.useCases.lintFilesAgainstRule.execute(command21);
|
|
11763
|
+
}
|
|
11764
|
+
async lintFilesFromConfig(command21) {
|
|
11765
|
+
return this.hexa.useCases.lintFilesFromConfig.execute(command21);
|
|
11766
|
+
}
|
|
11767
|
+
async installPackages(command21) {
|
|
11768
|
+
return this.hexa.useCases.installPackages.execute(command21);
|
|
11769
|
+
}
|
|
11770
|
+
async diffArtefacts(command21) {
|
|
11771
|
+
return this.hexa.useCases.diffArtefacts.execute(command21);
|
|
11772
|
+
}
|
|
11773
|
+
async submitDiffs(groupedDiffs) {
|
|
11774
|
+
return this.hexa.useCases.submitDiffs.execute({ groupedDiffs });
|
|
11775
|
+
}
|
|
11776
|
+
async listPackages(command21) {
|
|
11777
|
+
return this.hexa.useCases.listPackages.execute(command21);
|
|
11778
|
+
}
|
|
11779
|
+
async getPackageBySlug(command21) {
|
|
11780
|
+
return this.hexa.useCases.getPackageBySlug.execute(command21);
|
|
11781
|
+
}
|
|
11782
|
+
async listStandards(command21) {
|
|
11783
|
+
return this.hexa.useCases.listStandards.execute(command21);
|
|
11784
|
+
}
|
|
11785
|
+
async listCommands(command21) {
|
|
11786
|
+
return this.hexa.useCases.listCommands.execute(command21);
|
|
11787
|
+
}
|
|
11788
|
+
async listSkills(command21) {
|
|
11789
|
+
return this.hexa.useCases.listSkills.execute(command21);
|
|
11790
|
+
}
|
|
11791
|
+
async configExists(baseDirectory) {
|
|
10682
11792
|
return await this.hexa.repositories.configFileRepository.configExists(
|
|
10683
11793
|
baseDirectory
|
|
10684
11794
|
);
|
|
@@ -10763,17 +11873,17 @@ var PackmindCliHexa = class {
|
|
|
10763
11873
|
directory
|
|
10764
11874
|
);
|
|
10765
11875
|
}
|
|
10766
|
-
async login(
|
|
10767
|
-
return this.hexa.useCases.login.execute(
|
|
11876
|
+
async login(command21) {
|
|
11877
|
+
return this.hexa.useCases.login.execute(command21);
|
|
10768
11878
|
}
|
|
10769
|
-
async logout(
|
|
10770
|
-
return this.hexa.useCases.logout.execute(
|
|
11879
|
+
async logout(command21) {
|
|
11880
|
+
return this.hexa.useCases.logout.execute(command21);
|
|
10771
11881
|
}
|
|
10772
|
-
async whoami(
|
|
10773
|
-
return this.hexa.useCases.whoami.execute(
|
|
11882
|
+
async whoami(command21) {
|
|
11883
|
+
return this.hexa.useCases.whoami.execute(command21);
|
|
10774
11884
|
}
|
|
10775
|
-
async setupMcp(
|
|
10776
|
-
return this.hexa.useCases.setupMcp.execute(
|
|
11885
|
+
async setupMcp(command21) {
|
|
11886
|
+
return this.hexa.useCases.setupMcp.execute(command21);
|
|
10777
11887
|
}
|
|
10778
11888
|
getCurrentBranch(repoPath) {
|
|
10779
11889
|
return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
|
|
@@ -10781,11 +11891,11 @@ var PackmindCliHexa = class {
|
|
|
10781
11891
|
getGitRemoteUrlFromPath(repoPath) {
|
|
10782
11892
|
return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
|
|
10783
11893
|
}
|
|
10784
|
-
async uploadSkill(
|
|
10785
|
-
return this.hexa.useCases.uploadSkill.execute(
|
|
11894
|
+
async uploadSkill(command21) {
|
|
11895
|
+
return this.hexa.useCases.uploadSkill.execute(command21);
|
|
10786
11896
|
}
|
|
10787
|
-
async installDefaultSkills(
|
|
10788
|
-
return this.hexa.useCases.installDefaultSkills.execute(
|
|
11897
|
+
async installDefaultSkills(command21) {
|
|
11898
|
+
return this.hexa.useCases.installDefaultSkills.execute(command21);
|
|
10789
11899
|
}
|
|
10790
11900
|
getPackmindGateway() {
|
|
10791
11901
|
return this.hexa.repositories.packmindGateway;
|
|
@@ -10817,39 +11927,70 @@ var IDELintLogger = class {
|
|
|
10817
11927
|
});
|
|
10818
11928
|
}
|
|
10819
11929
|
logViolation(violation) {
|
|
10820
|
-
violation.violations.forEach(
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
11930
|
+
violation.violations.forEach(
|
|
11931
|
+
({ line, character, standard, rule, severity }) => {
|
|
11932
|
+
const label = (severity ?? "error" /* ERROR */) === "warning" /* WARNING */ ? "warning" : "error";
|
|
11933
|
+
logConsole(
|
|
11934
|
+
`${violation.file}:${line}:${character}:${label}:@${standard}/${rule}`
|
|
11935
|
+
);
|
|
11936
|
+
}
|
|
11937
|
+
);
|
|
10825
11938
|
}
|
|
10826
11939
|
};
|
|
10827
11940
|
|
|
10828
11941
|
// apps/cli/src/infra/repositories/HumanReadableLogger.ts
|
|
10829
11942
|
var HumanReadableLogger = class {
|
|
11943
|
+
effectiveSeverity(s) {
|
|
11944
|
+
return s ?? "error" /* ERROR */;
|
|
11945
|
+
}
|
|
10830
11946
|
logViolations(violations) {
|
|
10831
11947
|
violations.forEach((violation) => {
|
|
10832
11948
|
this.logViolation(violation);
|
|
10833
11949
|
});
|
|
10834
|
-
if (violations.length
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
11950
|
+
if (violations.length === 0) {
|
|
11951
|
+
logSuccessConsole(`\u2705 No violations found`);
|
|
11952
|
+
return;
|
|
11953
|
+
}
|
|
11954
|
+
const allDetails = violations.flatMap((v) => v.violations);
|
|
11955
|
+
const errorCount = allDetails.filter(
|
|
11956
|
+
(d) => this.effectiveSeverity(d.severity) === "error" /* ERROR */
|
|
11957
|
+
).length;
|
|
11958
|
+
const warningCount = allDetails.filter(
|
|
11959
|
+
(d) => this.effectiveSeverity(d.severity) === "warning" /* WARNING */
|
|
11960
|
+
).length;
|
|
11961
|
+
const errorFileCount = violations.filter(
|
|
11962
|
+
(v) => v.violations.some(
|
|
11963
|
+
(d) => this.effectiveSeverity(d.severity) === "error" /* ERROR */
|
|
11964
|
+
)
|
|
11965
|
+
).length;
|
|
11966
|
+
const warningFileCount = violations.filter(
|
|
11967
|
+
(v) => v.violations.some(
|
|
11968
|
+
(d) => this.effectiveSeverity(d.severity) === "warning" /* WARNING */
|
|
11969
|
+
)
|
|
11970
|
+
).length;
|
|
11971
|
+
if (errorCount > 0) {
|
|
10839
11972
|
logErrorConsole(
|
|
10840
|
-
`\u274C
|
|
11973
|
+
`\u274C Found ${formatBold(String(errorCount))} error(s) in ${formatBold(String(errorFileCount))} file(s)`
|
|
11974
|
+
);
|
|
11975
|
+
}
|
|
11976
|
+
if (warningCount > 0) {
|
|
11977
|
+
logWarningConsole(
|
|
11978
|
+
`\u26A0\uFE0F Found ${formatBold(String(warningCount))} warning(s) in ${formatBold(String(warningFileCount))} file(s)`
|
|
10841
11979
|
);
|
|
10842
|
-
} else {
|
|
10843
|
-
logSuccessConsole(`\u2705 No violations found`);
|
|
10844
11980
|
}
|
|
10845
11981
|
}
|
|
10846
11982
|
logViolation(violation) {
|
|
10847
11983
|
logConsole(formatFilePath(violation.file));
|
|
10848
|
-
violation.violations.forEach(
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
11984
|
+
violation.violations.forEach(
|
|
11985
|
+
({ line, character, standard, rule, severity }) => {
|
|
11986
|
+
const effective = this.effectiveSeverity(severity);
|
|
11987
|
+
const label = effective === "warning" /* WARNING */ ? "warning" : "error";
|
|
11988
|
+
const format = effective === "warning" /* WARNING */ ? formatWarning : formatError;
|
|
11989
|
+
logConsole(
|
|
11990
|
+
format(` ${line}:${character} ${label} @${standard}/${rule}`)
|
|
11991
|
+
);
|
|
11992
|
+
}
|
|
11993
|
+
);
|
|
10853
11994
|
}
|
|
10854
11995
|
};
|
|
10855
11996
|
|
|
@@ -10857,19 +11998,24 @@ var HumanReadableLogger = class {
|
|
|
10857
11998
|
var pathModule = __toESM(require("path"));
|
|
10858
11999
|
|
|
10859
12000
|
// apps/cli/src/infra/commands/lintHandler.ts
|
|
12001
|
+
var SEVERITY_LEVELS = {
|
|
12002
|
+
["warning" /* WARNING */]: 0,
|
|
12003
|
+
["error" /* ERROR */]: 1
|
|
12004
|
+
};
|
|
10860
12005
|
function isNotLoggedInError(error) {
|
|
10861
12006
|
return error instanceof NotLoggedInError;
|
|
10862
12007
|
}
|
|
10863
12008
|
async function lintHandler(args2, deps) {
|
|
10864
12009
|
const {
|
|
10865
|
-
path:
|
|
12010
|
+
path: path18,
|
|
10866
12011
|
draft,
|
|
10867
12012
|
rule,
|
|
10868
12013
|
language,
|
|
10869
12014
|
logger: logger2,
|
|
10870
12015
|
continueOnError,
|
|
10871
12016
|
continueOnMissingKey,
|
|
10872
|
-
diff
|
|
12017
|
+
diff,
|
|
12018
|
+
level
|
|
10873
12019
|
} = args2;
|
|
10874
12020
|
const {
|
|
10875
12021
|
packmindCliHexa,
|
|
@@ -10882,7 +12028,7 @@ async function lintHandler(args2, deps) {
|
|
|
10882
12028
|
throw new Error("option --rule is required to use --draft mode");
|
|
10883
12029
|
}
|
|
10884
12030
|
const startedAt = Date.now();
|
|
10885
|
-
const targetPath =
|
|
12031
|
+
const targetPath = path18 ?? ".";
|
|
10886
12032
|
const absolutePath = resolvePath(targetPath);
|
|
10887
12033
|
if (diff) {
|
|
10888
12034
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
|
|
@@ -10937,14 +12083,27 @@ async function lintHandler(args2, deps) {
|
|
|
10937
12083
|
}
|
|
10938
12084
|
throw error;
|
|
10939
12085
|
}
|
|
12086
|
+
const effectiveSeverity = (s) => s ?? "error" /* ERROR */;
|
|
12087
|
+
const filteredViolations = level ? violations.map((v) => ({
|
|
12088
|
+
...v,
|
|
12089
|
+
violations: v.violations.filter(
|
|
12090
|
+
(d) => SEVERITY_LEVELS[effectiveSeverity(d.severity)] >= SEVERITY_LEVELS[level]
|
|
12091
|
+
)
|
|
12092
|
+
})).filter((v) => v.violations.length > 0) : violations;
|
|
10940
12093
|
(logger2 === "ide" /* ide */ ? ideLintLogger : humanReadableLogger).logViolations(
|
|
10941
|
-
|
|
12094
|
+
filteredViolations
|
|
12095
|
+
);
|
|
12096
|
+
const hasErrors = filteredViolations.some(
|
|
12097
|
+
(v) => v.violations.some(
|
|
12098
|
+
(d) => effectiveSeverity(d.severity) === "error" /* ERROR */
|
|
12099
|
+
)
|
|
10942
12100
|
);
|
|
10943
12101
|
const durationSeconds = (Date.now() - startedAt) / 1e3;
|
|
10944
|
-
|
|
10945
|
-
|
|
12102
|
+
if (hasErrors && !continueOnError) {
|
|
12103
|
+
logErrorConsole(`Lint failed in ${durationSeconds.toFixed(2)}s`);
|
|
10946
12104
|
exit(1);
|
|
10947
12105
|
} else {
|
|
12106
|
+
logInfoConsole(`Lint completed in ${durationSeconds.toFixed(2)}s`);
|
|
10948
12107
|
exit(0);
|
|
10949
12108
|
}
|
|
10950
12109
|
}
|
|
@@ -10990,6 +12149,19 @@ var DiffModeType = {
|
|
|
10990
12149
|
);
|
|
10991
12150
|
}
|
|
10992
12151
|
};
|
|
12152
|
+
var LevelType = {
|
|
12153
|
+
from: async (input) => {
|
|
12154
|
+
switch (input) {
|
|
12155
|
+
case "error":
|
|
12156
|
+
return "error" /* ERROR */;
|
|
12157
|
+
case "warning":
|
|
12158
|
+
return "warning" /* WARNING */;
|
|
12159
|
+
}
|
|
12160
|
+
throw new Error(
|
|
12161
|
+
`${input} is not a valid value for the --level option. Expected values are: error, warning`
|
|
12162
|
+
);
|
|
12163
|
+
}
|
|
12164
|
+
};
|
|
10993
12165
|
var lintCommand = (0, import_cmd_ts.command)({
|
|
10994
12166
|
name: "lint",
|
|
10995
12167
|
description: "Lint code at the specified path",
|
|
@@ -11044,6 +12216,11 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
11044
12216
|
changedLines: (0, import_cmd_ts.flag)({
|
|
11045
12217
|
long: "changed-lines",
|
|
11046
12218
|
description: "Only lint lines that have changed"
|
|
12219
|
+
}),
|
|
12220
|
+
level: (0, import_cmd_ts.option)({
|
|
12221
|
+
long: "level",
|
|
12222
|
+
description: "Minimum severity level to display (error | warning)",
|
|
12223
|
+
type: (0, import_cmd_ts.optional)(LevelType)
|
|
11047
12224
|
})
|
|
11048
12225
|
},
|
|
11049
12226
|
handler: async (args2) => {
|
|
@@ -11133,8 +12310,8 @@ function extractWasmFiles() {
|
|
|
11133
12310
|
|
|
11134
12311
|
// apps/cli/src/main.ts
|
|
11135
12312
|
var import_dotenv = require("dotenv");
|
|
11136
|
-
var
|
|
11137
|
-
var
|
|
12313
|
+
var fs19 = __toESM(require("fs"));
|
|
12314
|
+
var path17 = __toESM(require("path"));
|
|
11138
12315
|
|
|
11139
12316
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
11140
12317
|
var import_cmd_ts2 = __toESM(require_cjs());
|
|
@@ -12209,13 +13386,13 @@ Credentials are loaded from (in order of priority):`);
|
|
|
12209
13386
|
|
|
12210
13387
|
// apps/cli/src/infra/commands/SetupMcpCommand.ts
|
|
12211
13388
|
var import_cmd_ts7 = __toESM(require_cjs());
|
|
12212
|
-
var
|
|
13389
|
+
var fs15 = __toESM(require("fs"));
|
|
12213
13390
|
var readline2 = __toESM(require("readline"));
|
|
12214
13391
|
var inquirer = __toESM(require("inquirer"));
|
|
12215
13392
|
|
|
12216
13393
|
// apps/cli/src/application/services/AgentDetectionService.ts
|
|
12217
|
-
var
|
|
12218
|
-
var
|
|
13394
|
+
var fs14 = __toESM(require("fs"));
|
|
13395
|
+
var path15 = __toESM(require("path"));
|
|
12219
13396
|
var os4 = __toESM(require("os"));
|
|
12220
13397
|
var import_child_process3 = require("child_process");
|
|
12221
13398
|
var AgentDetectionService = class {
|
|
@@ -12242,21 +13419,21 @@ var AgentDetectionService = class {
|
|
|
12242
13419
|
return this.isCommandAvailable("claude");
|
|
12243
13420
|
}
|
|
12244
13421
|
isCursorAvailable() {
|
|
12245
|
-
const cursorConfigDir =
|
|
12246
|
-
return
|
|
13422
|
+
const cursorConfigDir = path15.join(os4.homedir(), ".cursor");
|
|
13423
|
+
return fs14.existsSync(cursorConfigDir);
|
|
12247
13424
|
}
|
|
12248
13425
|
isVSCodeAvailable() {
|
|
12249
|
-
const vscodeDir =
|
|
12250
|
-
return
|
|
13426
|
+
const vscodeDir = path15.join(this.projectDir, ".vscode");
|
|
13427
|
+
return fs14.existsSync(vscodeDir);
|
|
12251
13428
|
}
|
|
12252
13429
|
isContinueAvailable() {
|
|
12253
|
-
const continueDir =
|
|
12254
|
-
return
|
|
13430
|
+
const continueDir = path15.join(this.projectDir, ".continue");
|
|
13431
|
+
return fs14.existsSync(continueDir);
|
|
12255
13432
|
}
|
|
12256
|
-
isCommandAvailable(
|
|
13433
|
+
isCommandAvailable(command21) {
|
|
12257
13434
|
try {
|
|
12258
13435
|
const whichCommand = process.platform === "win32" ? "where" : "which";
|
|
12259
|
-
(0, import_child_process3.execSync)(`${whichCommand} ${
|
|
13436
|
+
(0, import_child_process3.execSync)(`${whichCommand} ${command21}`, { stdio: "pipe" });
|
|
12260
13437
|
return true;
|
|
12261
13438
|
} catch {
|
|
12262
13439
|
return false;
|
|
@@ -12290,8 +13467,8 @@ var ALL_AGENTS2 = [
|
|
|
12290
13467
|
{ type: "continue", name: "Continue.dev" }
|
|
12291
13468
|
];
|
|
12292
13469
|
async function promptAgentsWithReadline(choices) {
|
|
12293
|
-
const input =
|
|
12294
|
-
const output =
|
|
13470
|
+
const input = fs15.createReadStream("/dev/tty");
|
|
13471
|
+
const output = fs15.createWriteStream("/dev/tty");
|
|
12295
13472
|
const rl = readline2.createInterface({
|
|
12296
13473
|
input,
|
|
12297
13474
|
output
|
|
@@ -12452,27 +13629,39 @@ Credentials are loaded from (in order of priority):`);
|
|
|
12452
13629
|
});
|
|
12453
13630
|
|
|
12454
13631
|
// apps/cli/src/infra/commands/SkillsCommand.ts
|
|
12455
|
-
var
|
|
13632
|
+
var import_cmd_ts12 = __toESM(require_cjs());
|
|
12456
13633
|
|
|
12457
13634
|
// apps/cli/src/infra/commands/skills/AddSkillCommand.ts
|
|
13635
|
+
var import_cmd_ts9 = __toESM(require_cjs());
|
|
13636
|
+
|
|
13637
|
+
// apps/cli/src/infra/commands/sharedOptions.ts
|
|
12458
13638
|
var import_cmd_ts8 = __toESM(require_cjs());
|
|
12459
|
-
var
|
|
13639
|
+
var originSkillOption = (0, import_cmd_ts8.option)({
|
|
13640
|
+
long: "origin-skill",
|
|
13641
|
+
description: "Name of the skill that triggered this command",
|
|
13642
|
+
type: (0, import_cmd_ts8.optional)(import_cmd_ts8.string)
|
|
13643
|
+
});
|
|
13644
|
+
|
|
13645
|
+
// apps/cli/src/infra/commands/skills/AddSkillCommand.ts
|
|
13646
|
+
var addSkillCommand = (0, import_cmd_ts9.command)({
|
|
12460
13647
|
name: "add",
|
|
12461
13648
|
description: "Add a skill from a local directory to a Packmind organization",
|
|
12462
13649
|
args: {
|
|
12463
|
-
skillPath: (0,
|
|
12464
|
-
type:
|
|
13650
|
+
skillPath: (0, import_cmd_ts9.positional)({
|
|
13651
|
+
type: import_cmd_ts9.string,
|
|
12465
13652
|
displayName: "path",
|
|
12466
13653
|
description: "Path to skill directory containing SKILL.md"
|
|
12467
|
-
})
|
|
13654
|
+
}),
|
|
13655
|
+
originSkill: originSkillOption
|
|
12468
13656
|
},
|
|
12469
|
-
handler: async ({ skillPath }) => {
|
|
13657
|
+
handler: async ({ skillPath, originSkill }) => {
|
|
12470
13658
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
12471
13659
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
12472
13660
|
try {
|
|
12473
13661
|
logInfoConsole(`Uploading skill from ${skillPath}...`);
|
|
12474
13662
|
const result = await packmindCliHexa.uploadSkill({
|
|
12475
|
-
skillPath
|
|
13663
|
+
skillPath,
|
|
13664
|
+
originSkill
|
|
12476
13665
|
});
|
|
12477
13666
|
if (result.isNewSkill) {
|
|
12478
13667
|
logSuccessConsole("Skill created successfully!");
|
|
@@ -12501,13 +13690,13 @@ var addSkillCommand = (0, import_cmd_ts8.command)({
|
|
|
12501
13690
|
});
|
|
12502
13691
|
|
|
12503
13692
|
// apps/cli/src/infra/commands/skills/InstallDefaultSkillsCommand.ts
|
|
12504
|
-
var
|
|
13693
|
+
var import_cmd_ts10 = __toESM(require_cjs());
|
|
12505
13694
|
var { version: CLI_VERSION2 } = require_package();
|
|
12506
|
-
var installDefaultSkillsCommand = (0,
|
|
13695
|
+
var installDefaultSkillsCommand = (0, import_cmd_ts10.command)({
|
|
12507
13696
|
name: "install-default",
|
|
12508
13697
|
description: "Install default Packmind skills for configured coding agents",
|
|
12509
13698
|
args: {
|
|
12510
|
-
includeBeta: (0,
|
|
13699
|
+
includeBeta: (0, import_cmd_ts10.flag)({
|
|
12511
13700
|
long: "include-beta",
|
|
12512
13701
|
description: "Include unreleased/beta skills"
|
|
12513
13702
|
})
|
|
@@ -12551,7 +13740,7 @@ var installDefaultSkillsCommand = (0, import_cmd_ts9.command)({
|
|
|
12551
13740
|
});
|
|
12552
13741
|
|
|
12553
13742
|
// apps/cli/src/infra/commands/ListSkillsCommand.ts
|
|
12554
|
-
var
|
|
13743
|
+
var import_cmd_ts11 = __toESM(require_cjs());
|
|
12555
13744
|
|
|
12556
13745
|
// apps/cli/src/infra/commands/listSkillsHandler.ts
|
|
12557
13746
|
function buildSkillUrl(host, orgSlug, skillSlug) {
|
|
@@ -12613,7 +13802,7 @@ async function listSkillsHandler(deps) {
|
|
|
12613
13802
|
}
|
|
12614
13803
|
|
|
12615
13804
|
// apps/cli/src/infra/commands/ListSkillsCommand.ts
|
|
12616
|
-
var listSkillsCommand = (0,
|
|
13805
|
+
var listSkillsCommand = (0, import_cmd_ts11.command)({
|
|
12617
13806
|
name: "list",
|
|
12618
13807
|
description: "List available skills",
|
|
12619
13808
|
args: {},
|
|
@@ -12630,7 +13819,7 @@ var listSkillsCommand = (0, import_cmd_ts10.command)({
|
|
|
12630
13819
|
});
|
|
12631
13820
|
|
|
12632
13821
|
// apps/cli/src/infra/commands/SkillsCommand.ts
|
|
12633
|
-
var skillsCommand = (0,
|
|
13822
|
+
var skillsCommand = (0, import_cmd_ts12.subcommands)({
|
|
12634
13823
|
name: "skills",
|
|
12635
13824
|
description: "Manage skills in your Packmind organization",
|
|
12636
13825
|
cmds: {
|
|
@@ -12641,13 +13830,13 @@ var skillsCommand = (0, import_cmd_ts11.subcommands)({
|
|
|
12641
13830
|
});
|
|
12642
13831
|
|
|
12643
13832
|
// apps/cli/src/infra/commands/StandardsCommand.ts
|
|
12644
|
-
var
|
|
13833
|
+
var import_cmd_ts15 = __toESM(require_cjs());
|
|
12645
13834
|
|
|
12646
13835
|
// apps/cli/src/infra/commands/CreateStandardCommand.ts
|
|
12647
|
-
var
|
|
13836
|
+
var import_cmd_ts13 = __toESM(require_cjs());
|
|
12648
13837
|
|
|
12649
13838
|
// apps/cli/src/infra/utils/readPlaybookFile.ts
|
|
12650
|
-
var
|
|
13839
|
+
var fs16 = __toESM(require("fs/promises"));
|
|
12651
13840
|
|
|
12652
13841
|
// apps/cli/src/domain/entities/PlaybookDTO.ts
|
|
12653
13842
|
var import_zod = require("zod");
|
|
@@ -12686,7 +13875,7 @@ function validatePlaybook(data) {
|
|
|
12686
13875
|
// apps/cli/src/infra/utils/readPlaybookFile.ts
|
|
12687
13876
|
async function readPlaybookFile(filePath) {
|
|
12688
13877
|
try {
|
|
12689
|
-
const content = await
|
|
13878
|
+
const content = await fs16.readFile(filePath, "utf-8");
|
|
12690
13879
|
let parsed;
|
|
12691
13880
|
try {
|
|
12692
13881
|
parsed = JSON.parse(content);
|
|
@@ -12710,7 +13899,7 @@ async function readPlaybookFile(filePath) {
|
|
|
12710
13899
|
}
|
|
12711
13900
|
|
|
12712
13901
|
// apps/cli/src/infra/commands/createStandardHandler.ts
|
|
12713
|
-
async function createStandardHandler(filePath, useCase) {
|
|
13902
|
+
async function createStandardHandler(filePath, useCase, originSkill) {
|
|
12714
13903
|
const readResult = await readPlaybookFile(filePath);
|
|
12715
13904
|
if (!readResult.isValid) {
|
|
12716
13905
|
return {
|
|
@@ -12725,7 +13914,10 @@ async function createStandardHandler(filePath, useCase) {
|
|
|
12725
13914
|
};
|
|
12726
13915
|
}
|
|
12727
13916
|
try {
|
|
12728
|
-
const result = await useCase.execute(
|
|
13917
|
+
const result = await useCase.execute({
|
|
13918
|
+
...readResult.data,
|
|
13919
|
+
originSkill
|
|
13920
|
+
});
|
|
12729
13921
|
return {
|
|
12730
13922
|
success: true,
|
|
12731
13923
|
standardId: result.standardId,
|
|
@@ -12759,30 +13951,32 @@ var CreateStandardFromPlaybookUseCase = class {
|
|
|
12759
13951
|
negative: r.examples.negative
|
|
12760
13952
|
}
|
|
12761
13953
|
] : void 0
|
|
12762
|
-
}))
|
|
13954
|
+
})),
|
|
13955
|
+
originSkill: playbook.originSkill
|
|
12763
13956
|
});
|
|
12764
13957
|
return { standardId: standard.id, name: standard.name };
|
|
12765
13958
|
}
|
|
12766
13959
|
};
|
|
12767
13960
|
|
|
12768
13961
|
// apps/cli/src/infra/commands/CreateStandardCommand.ts
|
|
12769
|
-
var createStandardCommand = (0,
|
|
13962
|
+
var createStandardCommand = (0, import_cmd_ts13.command)({
|
|
12770
13963
|
name: "create",
|
|
12771
13964
|
description: "Create a coding standard from a playbook JSON file",
|
|
12772
13965
|
args: {
|
|
12773
|
-
file: (0,
|
|
13966
|
+
file: (0, import_cmd_ts13.positional)({
|
|
12774
13967
|
displayName: "file",
|
|
12775
13968
|
description: "Path to the playbook JSON file",
|
|
12776
|
-
type:
|
|
12777
|
-
})
|
|
13969
|
+
type: import_cmd_ts13.string
|
|
13970
|
+
}),
|
|
13971
|
+
originSkill: originSkillOption
|
|
12778
13972
|
},
|
|
12779
|
-
handler: async ({ file }) => {
|
|
13973
|
+
handler: async ({ file, originSkill }) => {
|
|
12780
13974
|
try {
|
|
12781
13975
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
12782
13976
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
12783
13977
|
const gateway = hexa.getPackmindGateway();
|
|
12784
13978
|
const useCase = new CreateStandardFromPlaybookUseCase(gateway);
|
|
12785
|
-
const result = await createStandardHandler(file, useCase);
|
|
13979
|
+
const result = await createStandardHandler(file, useCase, originSkill);
|
|
12786
13980
|
if (result.success) {
|
|
12787
13981
|
logSuccessConsole(
|
|
12788
13982
|
`Standard "${result.standardName}" created successfully (ID: ${result.standardId})`
|
|
@@ -12802,7 +13996,7 @@ var createStandardCommand = (0, import_cmd_ts12.command)({
|
|
|
12802
13996
|
});
|
|
12803
13997
|
|
|
12804
13998
|
// apps/cli/src/infra/commands/ListStandardsCommand.ts
|
|
12805
|
-
var
|
|
13999
|
+
var import_cmd_ts14 = __toESM(require_cjs());
|
|
12806
14000
|
|
|
12807
14001
|
// apps/cli/src/infra/commands/listStandardsHandler.ts
|
|
12808
14002
|
function buildStandardUrl(host, orgSlug, standardId) {
|
|
@@ -12864,7 +14058,7 @@ async function listStandardsHandler(deps) {
|
|
|
12864
14058
|
}
|
|
12865
14059
|
|
|
12866
14060
|
// apps/cli/src/infra/commands/ListStandardsCommand.ts
|
|
12867
|
-
var listStandardsCommand = (0,
|
|
14061
|
+
var listStandardsCommand = (0, import_cmd_ts14.command)({
|
|
12868
14062
|
name: "list",
|
|
12869
14063
|
description: "List available coding standards",
|
|
12870
14064
|
args: {},
|
|
@@ -12881,7 +14075,7 @@ var listStandardsCommand = (0, import_cmd_ts13.command)({
|
|
|
12881
14075
|
});
|
|
12882
14076
|
|
|
12883
14077
|
// apps/cli/src/infra/commands/StandardsCommand.ts
|
|
12884
|
-
var standardsCommand = (0,
|
|
14078
|
+
var standardsCommand = (0, import_cmd_ts15.subcommands)({
|
|
12885
14079
|
name: "standards",
|
|
12886
14080
|
description: "Manage coding standards",
|
|
12887
14081
|
cmds: {
|
|
@@ -12891,13 +14085,13 @@ var standardsCommand = (0, import_cmd_ts14.subcommands)({
|
|
|
12891
14085
|
});
|
|
12892
14086
|
|
|
12893
14087
|
// apps/cli/src/infra/commands/CommandsCommand.ts
|
|
12894
|
-
var
|
|
14088
|
+
var import_cmd_ts18 = __toESM(require_cjs());
|
|
12895
14089
|
|
|
12896
14090
|
// apps/cli/src/infra/commands/CreateCommandCommand.ts
|
|
12897
|
-
var
|
|
14091
|
+
var import_cmd_ts16 = __toESM(require_cjs());
|
|
12898
14092
|
|
|
12899
14093
|
// apps/cli/src/infra/utils/readCommandPlaybookFile.ts
|
|
12900
|
-
var
|
|
14094
|
+
var fs17 = __toESM(require("fs/promises"));
|
|
12901
14095
|
|
|
12902
14096
|
// apps/cli/src/domain/entities/CommandPlaybookDTO.ts
|
|
12903
14097
|
var import_zod2 = require("zod");
|
|
@@ -12935,7 +14129,7 @@ function validateCommandPlaybook(data) {
|
|
|
12935
14129
|
// apps/cli/src/infra/utils/readCommandPlaybookFile.ts
|
|
12936
14130
|
async function readCommandPlaybookFile(filePath) {
|
|
12937
14131
|
try {
|
|
12938
|
-
const content = await
|
|
14132
|
+
const content = await fs17.readFile(filePath, "utf-8");
|
|
12939
14133
|
let parsed;
|
|
12940
14134
|
try {
|
|
12941
14135
|
parsed = JSON.parse(content);
|
|
@@ -12962,7 +14156,7 @@ async function readCommandPlaybookFile(filePath) {
|
|
|
12962
14156
|
function buildWebappUrl(host, orgSlug, commandId) {
|
|
12963
14157
|
return `${host}/org/${orgSlug}/space/global/commands/${commandId}`;
|
|
12964
14158
|
}
|
|
12965
|
-
async function createCommandHandler(filePath, useCase) {
|
|
14159
|
+
async function createCommandHandler(filePath, useCase, originSkill) {
|
|
12966
14160
|
const readResult = await readCommandPlaybookFile(filePath);
|
|
12967
14161
|
if (!readResult.isValid) {
|
|
12968
14162
|
return {
|
|
@@ -12977,7 +14171,10 @@ async function createCommandHandler(filePath, useCase) {
|
|
|
12977
14171
|
};
|
|
12978
14172
|
}
|
|
12979
14173
|
try {
|
|
12980
|
-
const result = await useCase.execute(
|
|
14174
|
+
const result = await useCase.execute({
|
|
14175
|
+
...readResult.data,
|
|
14176
|
+
originSkill
|
|
14177
|
+
});
|
|
12981
14178
|
let webappUrl;
|
|
12982
14179
|
const apiKey = loadApiKey();
|
|
12983
14180
|
if (apiKey) {
|
|
@@ -13011,7 +14208,7 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
13011
14208
|
}
|
|
13012
14209
|
async execute(playbook) {
|
|
13013
14210
|
const space = await this.gateway.spaces.getGlobal();
|
|
13014
|
-
const
|
|
14211
|
+
const command21 = await this.gateway.commands.create({
|
|
13015
14212
|
spaceId: space.id,
|
|
13016
14213
|
name: playbook.name,
|
|
13017
14214
|
summary: playbook.summary,
|
|
@@ -13021,34 +14218,36 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
13021
14218
|
name: step.name,
|
|
13022
14219
|
description: step.description,
|
|
13023
14220
|
codeSnippet: step.codeSnippet
|
|
13024
|
-
}))
|
|
14221
|
+
})),
|
|
14222
|
+
originSkill: playbook.originSkill
|
|
13025
14223
|
});
|
|
13026
14224
|
return {
|
|
13027
|
-
commandId:
|
|
13028
|
-
name:
|
|
13029
|
-
slug:
|
|
14225
|
+
commandId: command21.id,
|
|
14226
|
+
name: command21.name,
|
|
14227
|
+
slug: command21.slug
|
|
13030
14228
|
};
|
|
13031
14229
|
}
|
|
13032
14230
|
};
|
|
13033
14231
|
|
|
13034
14232
|
// apps/cli/src/infra/commands/CreateCommandCommand.ts
|
|
13035
|
-
var createCommandCommand = (0,
|
|
14233
|
+
var createCommandCommand = (0, import_cmd_ts16.command)({
|
|
13036
14234
|
name: "create",
|
|
13037
14235
|
description: "Create a command from a playbook JSON file",
|
|
13038
14236
|
args: {
|
|
13039
|
-
file: (0,
|
|
14237
|
+
file: (0, import_cmd_ts16.positional)({
|
|
13040
14238
|
displayName: "file",
|
|
13041
14239
|
description: "Path to the command playbook JSON file",
|
|
13042
|
-
type:
|
|
13043
|
-
})
|
|
14240
|
+
type: import_cmd_ts16.string
|
|
14241
|
+
}),
|
|
14242
|
+
originSkill: originSkillOption
|
|
13044
14243
|
},
|
|
13045
|
-
handler: async ({ file }) => {
|
|
14244
|
+
handler: async ({ file, originSkill }) => {
|
|
13046
14245
|
try {
|
|
13047
14246
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13048
14247
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13049
14248
|
const gateway = hexa.getPackmindGateway();
|
|
13050
14249
|
const useCase = new CreateCommandFromPlaybookUseCase(gateway);
|
|
13051
|
-
const result = await createCommandHandler(file, useCase);
|
|
14250
|
+
const result = await createCommandHandler(file, useCase, originSkill);
|
|
13052
14251
|
if (result.success) {
|
|
13053
14252
|
logSuccessConsole(
|
|
13054
14253
|
`Command "${result.commandName}" created successfully (ID: ${result.commandId})`
|
|
@@ -13072,7 +14271,7 @@ var createCommandCommand = (0, import_cmd_ts15.command)({
|
|
|
13072
14271
|
});
|
|
13073
14272
|
|
|
13074
14273
|
// apps/cli/src/infra/commands/ListCommandsCommand.ts
|
|
13075
|
-
var
|
|
14274
|
+
var import_cmd_ts17 = __toESM(require_cjs());
|
|
13076
14275
|
|
|
13077
14276
|
// apps/cli/src/infra/commands/listCommandsHandler.ts
|
|
13078
14277
|
function buildCommandUrl(host, orgSlug, commandId) {
|
|
@@ -13126,7 +14325,7 @@ async function listCommandsHandler(deps) {
|
|
|
13126
14325
|
}
|
|
13127
14326
|
|
|
13128
14327
|
// apps/cli/src/infra/commands/ListCommandsCommand.ts
|
|
13129
|
-
var listCommandsCommand = (0,
|
|
14328
|
+
var listCommandsCommand = (0, import_cmd_ts17.command)({
|
|
13130
14329
|
name: "list",
|
|
13131
14330
|
description: "List available commands",
|
|
13132
14331
|
args: {},
|
|
@@ -13143,7 +14342,7 @@ var listCommandsCommand = (0, import_cmd_ts16.command)({
|
|
|
13143
14342
|
});
|
|
13144
14343
|
|
|
13145
14344
|
// apps/cli/src/infra/commands/CommandsCommand.ts
|
|
13146
|
-
var commandsCommand = (0,
|
|
14345
|
+
var commandsCommand = (0, import_cmd_ts18.subcommands)({
|
|
13147
14346
|
name: "commands",
|
|
13148
14347
|
description: "Manage commands",
|
|
13149
14348
|
cmds: {
|
|
@@ -13152,17 +14351,328 @@ var commandsCommand = (0, import_cmd_ts17.subcommands)({
|
|
|
13152
14351
|
}
|
|
13153
14352
|
});
|
|
13154
14353
|
|
|
14354
|
+
// apps/cli/src/infra/commands/DiffCommand.ts
|
|
14355
|
+
var import_cmd_ts19 = __toESM(require_cjs());
|
|
14356
|
+
|
|
14357
|
+
// apps/cli/src/infra/utils/diffFormatter.ts
|
|
14358
|
+
var import_diff3 = require("diff");
|
|
14359
|
+
init_source();
|
|
14360
|
+
function formatContentDiff(oldContent, newContent) {
|
|
14361
|
+
const changes = (0, import_diff3.diffLines)(oldContent, newContent);
|
|
14362
|
+
const lines = [];
|
|
14363
|
+
for (const change of changes) {
|
|
14364
|
+
const trimmedValue = change.value.replace(/\n$/, "");
|
|
14365
|
+
const changeLines = trimmedValue.split("\n");
|
|
14366
|
+
if (change.added) {
|
|
14367
|
+
for (const line of changeLines) {
|
|
14368
|
+
lines.push(source_default.green(` + ${line}`));
|
|
14369
|
+
}
|
|
14370
|
+
} else if (change.removed) {
|
|
14371
|
+
for (const line of changeLines) {
|
|
14372
|
+
lines.push(source_default.red(` - ${line}`));
|
|
14373
|
+
}
|
|
14374
|
+
}
|
|
14375
|
+
}
|
|
14376
|
+
return {
|
|
14377
|
+
lines,
|
|
14378
|
+
hasChanges: lines.length > 0
|
|
14379
|
+
};
|
|
14380
|
+
}
|
|
14381
|
+
|
|
14382
|
+
// apps/cli/src/infra/commands/diffArtefactsHandler.ts
|
|
14383
|
+
init_source();
|
|
14384
|
+
var ARTIFACT_TYPE_LABELS = {
|
|
14385
|
+
command: "Command",
|
|
14386
|
+
standard: "Standard",
|
|
14387
|
+
skill: "Skill"
|
|
14388
|
+
};
|
|
14389
|
+
function subGroupByChangeContent(diffs) {
|
|
14390
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14391
|
+
for (const diff of diffs) {
|
|
14392
|
+
const key = JSON.stringify({ type: diff.type, payload: diff.payload });
|
|
14393
|
+
const group = groups.get(key) ?? [];
|
|
14394
|
+
group.push(diff);
|
|
14395
|
+
groups.set(key, group);
|
|
14396
|
+
}
|
|
14397
|
+
return Array.from(groups.values());
|
|
14398
|
+
}
|
|
14399
|
+
function groupDiffsByArtefact(diffs) {
|
|
14400
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14401
|
+
for (const diff of diffs) {
|
|
14402
|
+
const key = `${diff.artifactType}:${diff.artifactName}`;
|
|
14403
|
+
const group = groups.get(key) ?? [];
|
|
14404
|
+
group.push(diff);
|
|
14405
|
+
groups.set(key, group);
|
|
14406
|
+
}
|
|
14407
|
+
return groups;
|
|
14408
|
+
}
|
|
14409
|
+
function formatDiffPayload(diff, log) {
|
|
14410
|
+
const payload = diff.payload;
|
|
14411
|
+
if (diff.type === "addSkillFile" /* addSkillFile */) {
|
|
14412
|
+
const item = payload.item;
|
|
14413
|
+
if (item.isBase64) {
|
|
14414
|
+
log(source_default.green(" + [binary file]"));
|
|
14415
|
+
} else {
|
|
14416
|
+
for (const line of item.content.split("\n")) {
|
|
14417
|
+
log(source_default.green(` + ${line}`));
|
|
14418
|
+
}
|
|
14419
|
+
}
|
|
14420
|
+
return;
|
|
14421
|
+
}
|
|
14422
|
+
if (diff.type === "deleteSkillFile" /* deleteSkillFile */) {
|
|
14423
|
+
const item = payload.item;
|
|
14424
|
+
if (item.isBase64) {
|
|
14425
|
+
log(source_default.red(" - [binary file]"));
|
|
14426
|
+
} else {
|
|
14427
|
+
const lines2 = item.content.split("\n");
|
|
14428
|
+
const MAX_DELETED_LINES = 3;
|
|
14429
|
+
const preview = lines2.slice(0, MAX_DELETED_LINES);
|
|
14430
|
+
for (const line of preview) {
|
|
14431
|
+
log(source_default.red(` - ${line}`));
|
|
14432
|
+
}
|
|
14433
|
+
if (lines2.length > MAX_DELETED_LINES) {
|
|
14434
|
+
const remaining = lines2.length - MAX_DELETED_LINES;
|
|
14435
|
+
log(source_default.red(` ... and ${remaining} more lines deleted`));
|
|
14436
|
+
}
|
|
14437
|
+
}
|
|
14438
|
+
return;
|
|
14439
|
+
}
|
|
14440
|
+
if (diff.type === "updateSkillFileContent" /* updateSkillFileContent */) {
|
|
14441
|
+
const typedPayload = payload;
|
|
14442
|
+
if (typedPayload.isBase64) {
|
|
14443
|
+
log(source_default.green(" ~ [binary content changed]"));
|
|
14444
|
+
return;
|
|
14445
|
+
}
|
|
14446
|
+
}
|
|
14447
|
+
if (diff.type === "addRule" /* addRule */) {
|
|
14448
|
+
const item = payload.item;
|
|
14449
|
+
log(source_default.green(` + ${item.content}`));
|
|
14450
|
+
return;
|
|
14451
|
+
}
|
|
14452
|
+
if (diff.type === "deleteRule" /* deleteRule */) {
|
|
14453
|
+
const item = payload.item;
|
|
14454
|
+
log(source_default.red(` - ${item.content}`));
|
|
14455
|
+
return;
|
|
14456
|
+
}
|
|
14457
|
+
const oldValue = payload.oldValue;
|
|
14458
|
+
const newValue = payload.newValue;
|
|
14459
|
+
const { lines } = formatContentDiff(oldValue, newValue);
|
|
14460
|
+
for (const line of lines) {
|
|
14461
|
+
log(line);
|
|
14462
|
+
}
|
|
14463
|
+
}
|
|
14464
|
+
async function diffArtefactsHandler(deps) {
|
|
14465
|
+
const { packmindCliHexa, exit, getCwd, log, error, submit } = deps;
|
|
14466
|
+
const cwd = getCwd();
|
|
14467
|
+
let configPackages;
|
|
14468
|
+
let configAgents;
|
|
14469
|
+
try {
|
|
14470
|
+
const fullConfig = await packmindCliHexa.readFullConfig(cwd);
|
|
14471
|
+
if (fullConfig) {
|
|
14472
|
+
configPackages = Object.keys(fullConfig.packages);
|
|
14473
|
+
configAgents = fullConfig.agents;
|
|
14474
|
+
} else {
|
|
14475
|
+
configPackages = [];
|
|
14476
|
+
}
|
|
14477
|
+
} catch (err) {
|
|
14478
|
+
error("ERROR Failed to parse packmind.json");
|
|
14479
|
+
if (err instanceof Error) {
|
|
14480
|
+
error(`ERROR ${err.message}`);
|
|
14481
|
+
} else {
|
|
14482
|
+
error(`ERROR ${String(err)}`);
|
|
14483
|
+
}
|
|
14484
|
+
error("\n\u{1F4A1} Please fix the packmind.json file or delete it to continue.");
|
|
14485
|
+
exit(1);
|
|
14486
|
+
return { diffsFound: 0 };
|
|
14487
|
+
}
|
|
14488
|
+
if (configPackages.length === 0) {
|
|
14489
|
+
log("Usage: packmind-cli diff");
|
|
14490
|
+
log("");
|
|
14491
|
+
log("Compare local command files against the server.");
|
|
14492
|
+
log("Configure packages in packmind.json first.");
|
|
14493
|
+
exit(0);
|
|
14494
|
+
return { diffsFound: 0 };
|
|
14495
|
+
}
|
|
14496
|
+
try {
|
|
14497
|
+
let gitRemoteUrl;
|
|
14498
|
+
let gitBranch;
|
|
14499
|
+
let relativePath;
|
|
14500
|
+
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(cwd);
|
|
14501
|
+
if (gitRoot) {
|
|
14502
|
+
try {
|
|
14503
|
+
gitRemoteUrl = packmindCliHexa.getGitRemoteUrlFromPath(gitRoot);
|
|
14504
|
+
gitBranch = packmindCliHexa.getCurrentBranch(gitRoot);
|
|
14505
|
+
relativePath = cwd.startsWith(gitRoot) ? cwd.slice(gitRoot.length) : "/";
|
|
14506
|
+
if (!relativePath.startsWith("/")) {
|
|
14507
|
+
relativePath = "/" + relativePath;
|
|
14508
|
+
}
|
|
14509
|
+
if (!relativePath.endsWith("/")) {
|
|
14510
|
+
relativePath = relativePath + "/";
|
|
14511
|
+
}
|
|
14512
|
+
} catch (err) {
|
|
14513
|
+
logWarningConsole(
|
|
14514
|
+
`Failed to collect git info: ${err instanceof Error ? err.message : String(err)}`
|
|
14515
|
+
);
|
|
14516
|
+
}
|
|
14517
|
+
}
|
|
14518
|
+
if (!gitRemoteUrl || !gitBranch || !relativePath) {
|
|
14519
|
+
error(
|
|
14520
|
+
"\n\u274C Could not determine git repository info. The diff command requires a git repository with a remote configured."
|
|
14521
|
+
);
|
|
14522
|
+
exit(1);
|
|
14523
|
+
return { diffsFound: 0 };
|
|
14524
|
+
}
|
|
14525
|
+
const packageCount = configPackages.length;
|
|
14526
|
+
const packageWord = packageCount === 1 ? "package" : "packages";
|
|
14527
|
+
logInfoConsole(
|
|
14528
|
+
`Comparing ${packageCount} ${packageWord}: ${configPackages.join(", ")}...`
|
|
14529
|
+
);
|
|
14530
|
+
const diffs = await packmindCliHexa.diffArtefacts({
|
|
14531
|
+
baseDirectory: cwd,
|
|
14532
|
+
packagesSlugs: configPackages,
|
|
14533
|
+
gitRemoteUrl,
|
|
14534
|
+
gitBranch,
|
|
14535
|
+
relativePath,
|
|
14536
|
+
agents: configAgents
|
|
14537
|
+
});
|
|
14538
|
+
if (diffs.length === 0) {
|
|
14539
|
+
log("No changes found.");
|
|
14540
|
+
if (submit) {
|
|
14541
|
+
logInfoConsole("No changes to submit.");
|
|
14542
|
+
}
|
|
14543
|
+
exit(0);
|
|
14544
|
+
return { diffsFound: 0 };
|
|
14545
|
+
}
|
|
14546
|
+
log(formatHeader(`
|
|
14547
|
+
Changes found:
|
|
14548
|
+
`));
|
|
14549
|
+
const groups = groupDiffsByArtefact(diffs);
|
|
14550
|
+
for (const [, groupDiffs] of groups) {
|
|
14551
|
+
const { artifactType, artifactName } = groupDiffs[0];
|
|
14552
|
+
const typeLabel = ARTIFACT_TYPE_LABELS[artifactType];
|
|
14553
|
+
log(formatBold(`${typeLabel} "${artifactName}"`));
|
|
14554
|
+
const subGroups = subGroupByChangeContent(groupDiffs);
|
|
14555
|
+
for (const subGroup of subGroups) {
|
|
14556
|
+
for (const diff of subGroup) {
|
|
14557
|
+
log(` ${formatFilePath(diff.filePath)}`);
|
|
14558
|
+
}
|
|
14559
|
+
const label = CHANGE_PROPOSAL_TYPE_LABELS[subGroup[0].type] ?? "content changed";
|
|
14560
|
+
log(` - ${label}`);
|
|
14561
|
+
formatDiffPayload(subGroup[0], log);
|
|
14562
|
+
}
|
|
14563
|
+
log("");
|
|
14564
|
+
}
|
|
14565
|
+
const changeCount = diffs.length;
|
|
14566
|
+
const changeWord = changeCount === 1 ? "change" : "changes";
|
|
14567
|
+
const typeSortOrder = {
|
|
14568
|
+
command: 0,
|
|
14569
|
+
skill: 1,
|
|
14570
|
+
standard: 2
|
|
14571
|
+
};
|
|
14572
|
+
const uniqueArtefacts = /* @__PURE__ */ new Map();
|
|
14573
|
+
for (const [key, groupDiffs] of groups) {
|
|
14574
|
+
if (!uniqueArtefacts.has(key)) {
|
|
14575
|
+
uniqueArtefacts.set(key, {
|
|
14576
|
+
type: groupDiffs[0].artifactType,
|
|
14577
|
+
name: groupDiffs[0].artifactName
|
|
14578
|
+
});
|
|
14579
|
+
}
|
|
14580
|
+
}
|
|
14581
|
+
const sortedArtefacts = Array.from(uniqueArtefacts.values()).sort(
|
|
14582
|
+
(a, b) => typeSortOrder[a.type] - typeSortOrder[b.type] || a.name.localeCompare(b.name, void 0, { sensitivity: "base" })
|
|
14583
|
+
);
|
|
14584
|
+
const artefactCount = sortedArtefacts.length;
|
|
14585
|
+
const artefactWord = artefactCount === 1 ? "artefact" : "artefacts";
|
|
14586
|
+
logWarningConsole(
|
|
14587
|
+
`Summary: ${changeCount} ${changeWord} found on ${artefactCount} ${artefactWord}:`
|
|
14588
|
+
);
|
|
14589
|
+
for (const artefact of sortedArtefacts) {
|
|
14590
|
+
const typeLabel = ARTIFACT_TYPE_LABELS[artefact.type];
|
|
14591
|
+
logWarningConsole(`* ${typeLabel} "${artefact.name}"`);
|
|
14592
|
+
}
|
|
14593
|
+
if (submit) {
|
|
14594
|
+
const groupedDiffs = Array.from(groupDiffsByArtefact(diffs).values());
|
|
14595
|
+
const result = await packmindCliHexa.submitDiffs(groupedDiffs);
|
|
14596
|
+
for (const err of result.errors) {
|
|
14597
|
+
if (err.code === "ChangeProposalPayloadMismatchError") {
|
|
14598
|
+
logErrorConsole(
|
|
14599
|
+
`Failed to submit "${err.name}": ${err.artifactType ?? "artifact"} is outdated, please run \`packmind-cli install\` to update it`
|
|
14600
|
+
);
|
|
14601
|
+
} else {
|
|
14602
|
+
logErrorConsole(`Failed to submit "${err.name}": ${err.message}`);
|
|
14603
|
+
}
|
|
14604
|
+
}
|
|
14605
|
+
const summaryParts = [];
|
|
14606
|
+
if (result.submitted > 0) {
|
|
14607
|
+
summaryParts.push(`${result.submitted} submitted`);
|
|
14608
|
+
}
|
|
14609
|
+
if (result.alreadySubmitted > 0) {
|
|
14610
|
+
summaryParts.push(`${result.alreadySubmitted} already submitted`);
|
|
14611
|
+
}
|
|
14612
|
+
if (result.errors.length > 0) {
|
|
14613
|
+
const errorWord = result.errors.length === 1 ? "error" : "errors";
|
|
14614
|
+
summaryParts.push(`${result.errors.length} ${errorWord}`);
|
|
14615
|
+
}
|
|
14616
|
+
if (summaryParts.length > 0) {
|
|
14617
|
+
const summaryMessage = `Summary: ${summaryParts.join(", ")}`;
|
|
14618
|
+
if (result.errors.length === 0 && result.alreadySubmitted === 0) {
|
|
14619
|
+
logSuccessConsole(summaryMessage);
|
|
14620
|
+
} else if (result.errors.length > 0 && result.submitted > 0 || result.alreadySubmitted > 0) {
|
|
14621
|
+
logWarningConsole(summaryMessage);
|
|
14622
|
+
} else {
|
|
14623
|
+
logErrorConsole(summaryMessage);
|
|
14624
|
+
}
|
|
14625
|
+
}
|
|
14626
|
+
}
|
|
14627
|
+
exit(0);
|
|
14628
|
+
return { diffsFound: changeCount };
|
|
14629
|
+
} catch (err) {
|
|
14630
|
+
error("\n\u274C Failed to diff:");
|
|
14631
|
+
if (err instanceof Error) {
|
|
14632
|
+
error(` ${err.message}`);
|
|
14633
|
+
} else {
|
|
14634
|
+
error(` ${String(err)}`);
|
|
14635
|
+
}
|
|
14636
|
+
exit(1);
|
|
14637
|
+
return { diffsFound: 0 };
|
|
14638
|
+
}
|
|
14639
|
+
}
|
|
14640
|
+
|
|
14641
|
+
// apps/cli/src/infra/commands/DiffCommand.ts
|
|
14642
|
+
var diffCommand = (0, import_cmd_ts19.command)({
|
|
14643
|
+
name: "diff",
|
|
14644
|
+
description: "Show differences between local command files and server content",
|
|
14645
|
+
args: {
|
|
14646
|
+
submit: (0, import_cmd_ts19.flag)({
|
|
14647
|
+
long: "submit",
|
|
14648
|
+
description: "Submit detected changes as change proposals"
|
|
14649
|
+
})
|
|
14650
|
+
},
|
|
14651
|
+
handler: async ({ submit }) => {
|
|
14652
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
14653
|
+
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
14654
|
+
await diffArtefactsHandler({
|
|
14655
|
+
packmindCliHexa,
|
|
14656
|
+
exit: process.exit,
|
|
14657
|
+
getCwd: () => process.cwd(),
|
|
14658
|
+
log: console.log,
|
|
14659
|
+
error: console.error,
|
|
14660
|
+
submit
|
|
14661
|
+
});
|
|
14662
|
+
}
|
|
14663
|
+
});
|
|
14664
|
+
|
|
13155
14665
|
// apps/cli/src/infra/commands/PackagesCommand.ts
|
|
13156
|
-
var
|
|
14666
|
+
var import_cmd_ts23 = __toESM(require_cjs());
|
|
13157
14667
|
|
|
13158
14668
|
// apps/cli/src/infra/commands/CreatePackageCommand.ts
|
|
13159
|
-
var
|
|
14669
|
+
var import_cmd_ts20 = __toESM(require_cjs());
|
|
13160
14670
|
|
|
13161
14671
|
// apps/cli/src/infra/commands/createPackageHandler.ts
|
|
13162
14672
|
function buildWebappUrl2(host, orgSlug, packageId) {
|
|
13163
14673
|
return `${host}/org/${orgSlug}/space/global/packages/${packageId}`;
|
|
13164
14674
|
}
|
|
13165
|
-
async function createPackageHandler(name, description, useCase) {
|
|
14675
|
+
async function createPackageHandler(name, description, useCase, originSkill) {
|
|
13166
14676
|
const trimmedName = name.trim();
|
|
13167
14677
|
if (!trimmedName) {
|
|
13168
14678
|
return { success: false, error: "Package name is required" };
|
|
@@ -13170,7 +14680,8 @@ async function createPackageHandler(name, description, useCase) {
|
|
|
13170
14680
|
try {
|
|
13171
14681
|
const result = await useCase.execute({
|
|
13172
14682
|
name: trimmedName,
|
|
13173
|
-
description
|
|
14683
|
+
description,
|
|
14684
|
+
originSkill
|
|
13174
14685
|
});
|
|
13175
14686
|
let webappUrl;
|
|
13176
14687
|
const apiKey = loadApiKey();
|
|
@@ -13204,14 +14715,15 @@ var CreatePackageUseCase = class {
|
|
|
13204
14715
|
constructor(gateway) {
|
|
13205
14716
|
this.gateway = gateway;
|
|
13206
14717
|
}
|
|
13207
|
-
async execute(
|
|
14718
|
+
async execute(command21) {
|
|
13208
14719
|
const space = await this.gateway.spaces.getGlobal();
|
|
13209
14720
|
const result = await this.gateway.packages.create({
|
|
13210
14721
|
spaceId: space.id,
|
|
13211
|
-
name:
|
|
13212
|
-
description:
|
|
14722
|
+
name: command21.name,
|
|
14723
|
+
description: command21.description ?? "",
|
|
13213
14724
|
recipeIds: [],
|
|
13214
|
-
standardIds: []
|
|
14725
|
+
standardIds: [],
|
|
14726
|
+
originSkill: command21.originSkill
|
|
13215
14727
|
});
|
|
13216
14728
|
return {
|
|
13217
14729
|
packageId: result.package.id,
|
|
@@ -13222,29 +14734,35 @@ var CreatePackageUseCase = class {
|
|
|
13222
14734
|
};
|
|
13223
14735
|
|
|
13224
14736
|
// apps/cli/src/infra/commands/CreatePackageCommand.ts
|
|
13225
|
-
var createPackageCommand = (0,
|
|
14737
|
+
var createPackageCommand = (0, import_cmd_ts20.command)({
|
|
13226
14738
|
name: "create",
|
|
13227
14739
|
description: "Create a new package",
|
|
13228
14740
|
args: {
|
|
13229
|
-
name: (0,
|
|
14741
|
+
name: (0, import_cmd_ts20.positional)({
|
|
13230
14742
|
displayName: "name",
|
|
13231
14743
|
description: "Name of the package to create",
|
|
13232
|
-
type:
|
|
14744
|
+
type: import_cmd_ts20.string
|
|
13233
14745
|
}),
|
|
13234
|
-
description: (0,
|
|
14746
|
+
description: (0, import_cmd_ts20.option)({
|
|
13235
14747
|
long: "description",
|
|
13236
14748
|
short: "d",
|
|
13237
14749
|
description: "Description of the package (optional)",
|
|
13238
|
-
type: (0,
|
|
13239
|
-
})
|
|
14750
|
+
type: (0, import_cmd_ts20.optional)(import_cmd_ts20.string)
|
|
14751
|
+
}),
|
|
14752
|
+
originSkill: originSkillOption
|
|
13240
14753
|
},
|
|
13241
|
-
handler: async ({ name, description }) => {
|
|
14754
|
+
handler: async ({ name, description, originSkill }) => {
|
|
13242
14755
|
try {
|
|
13243
14756
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
13244
14757
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13245
14758
|
const gateway = hexa.getPackmindGateway();
|
|
13246
14759
|
const useCase = new CreatePackageUseCase(gateway);
|
|
13247
|
-
const result = await createPackageHandler(
|
|
14760
|
+
const result = await createPackageHandler(
|
|
14761
|
+
name,
|
|
14762
|
+
description,
|
|
14763
|
+
useCase,
|
|
14764
|
+
originSkill
|
|
14765
|
+
);
|
|
13248
14766
|
if (result.success) {
|
|
13249
14767
|
logConsole("");
|
|
13250
14768
|
logConsole(formatHeader(`\u2705 Package created successfully
|
|
@@ -13278,7 +14796,7 @@ var createPackageCommand = (0, import_cmd_ts18.command)({
|
|
|
13278
14796
|
});
|
|
13279
14797
|
|
|
13280
14798
|
// apps/cli/src/infra/commands/AddToPackageCommand.ts
|
|
13281
|
-
var
|
|
14799
|
+
var import_cmd_ts21 = __toESM(require_cjs());
|
|
13282
14800
|
|
|
13283
14801
|
// apps/cli/src/domain/errors/ItemNotFoundError.ts
|
|
13284
14802
|
var ItemNotFoundError = class extends Error {
|
|
@@ -13295,8 +14813,8 @@ var AddToPackageUseCase = class {
|
|
|
13295
14813
|
constructor(gateway) {
|
|
13296
14814
|
this.gateway = gateway;
|
|
13297
14815
|
}
|
|
13298
|
-
async execute(
|
|
13299
|
-
const { packageSlug, itemType, itemSlugs } =
|
|
14816
|
+
async execute(command21) {
|
|
14817
|
+
const { packageSlug, itemType, itemSlugs } = command21;
|
|
13300
14818
|
const space = await this.gateway.spaces.getGlobal();
|
|
13301
14819
|
const packages = await this.gateway.packages.list({});
|
|
13302
14820
|
const pkg = packages.packages.find((pkg2) => pkg2.slug === packageSlug);
|
|
@@ -13312,7 +14830,8 @@ var AddToPackageUseCase = class {
|
|
|
13312
14830
|
spaceId: space.id,
|
|
13313
14831
|
standardIds: [],
|
|
13314
14832
|
recipeIds: [],
|
|
13315
|
-
skillIds: []
|
|
14833
|
+
skillIds: [],
|
|
14834
|
+
originSkill: command21.originSkill
|
|
13316
14835
|
};
|
|
13317
14836
|
if (itemType === "standard") {
|
|
13318
14837
|
addCommand.standardIds = ids.map(createStandardId);
|
|
@@ -13357,7 +14876,7 @@ var AddToPackageUseCase = class {
|
|
|
13357
14876
|
}
|
|
13358
14877
|
async findCommandBySlug(slug, spaceId) {
|
|
13359
14878
|
const commands = await this.gateway.commands.list({ spaceId });
|
|
13360
|
-
return commands.recipes.find((
|
|
14879
|
+
return commands.recipes.find((command21) => command21.slug === slug) ?? null;
|
|
13361
14880
|
}
|
|
13362
14881
|
async findSkillBySlug(slug, spaceId) {
|
|
13363
14882
|
const skills = await this.gateway.skills.list({ spaceId });
|
|
@@ -13375,12 +14894,17 @@ function formatItemType(itemType, count) {
|
|
|
13375
14894
|
function formatItemList(items) {
|
|
13376
14895
|
return items.map((item) => `"${item}"`).join(", ");
|
|
13377
14896
|
}
|
|
13378
|
-
async function addToPackageHandler(packageSlug, itemType, itemSlugs, useCase) {
|
|
14897
|
+
async function addToPackageHandler(packageSlug, itemType, itemSlugs, useCase, originSkill) {
|
|
13379
14898
|
if (itemSlugs.length === 0) {
|
|
13380
14899
|
return { success: false, error: "No items provided to add" };
|
|
13381
14900
|
}
|
|
13382
14901
|
try {
|
|
13383
|
-
const result = await useCase.execute({
|
|
14902
|
+
const result = await useCase.execute({
|
|
14903
|
+
packageSlug,
|
|
14904
|
+
itemType,
|
|
14905
|
+
itemSlugs,
|
|
14906
|
+
originSkill
|
|
14907
|
+
});
|
|
13384
14908
|
if (result.added.length) {
|
|
13385
14909
|
logSuccessConsole(
|
|
13386
14910
|
`${formatItemType(itemType, result.added.length)} ${formatItemList(result.added)} added to "${packageSlug}"`
|
|
@@ -13408,32 +14932,33 @@ async function addToPackageHandler(packageSlug, itemType, itemSlugs, useCase) {
|
|
|
13408
14932
|
}
|
|
13409
14933
|
|
|
13410
14934
|
// apps/cli/src/infra/commands/AddToPackageCommand.ts
|
|
13411
|
-
var addToPackageCommand = (0,
|
|
14935
|
+
var addToPackageCommand = (0, import_cmd_ts21.command)({
|
|
13412
14936
|
name: "add",
|
|
13413
14937
|
description: "Add standards, commands, or skills to a package",
|
|
13414
14938
|
args: {
|
|
13415
|
-
to: (0,
|
|
14939
|
+
to: (0, import_cmd_ts21.option)({
|
|
13416
14940
|
long: "to",
|
|
13417
14941
|
description: "Target package slug",
|
|
13418
|
-
type:
|
|
14942
|
+
type: import_cmd_ts21.string
|
|
13419
14943
|
}),
|
|
13420
|
-
standards: (0,
|
|
14944
|
+
standards: (0, import_cmd_ts21.multioption)({
|
|
13421
14945
|
long: "standard",
|
|
13422
14946
|
description: "Standard slug(s) to add",
|
|
13423
|
-
type: (0,
|
|
14947
|
+
type: (0, import_cmd_ts21.array)(import_cmd_ts21.string)
|
|
13424
14948
|
}),
|
|
13425
|
-
commands: (0,
|
|
14949
|
+
commands: (0, import_cmd_ts21.multioption)({
|
|
13426
14950
|
long: "command",
|
|
13427
14951
|
description: "Command slug(s) to add",
|
|
13428
|
-
type: (0,
|
|
14952
|
+
type: (0, import_cmd_ts21.array)(import_cmd_ts21.string)
|
|
13429
14953
|
}),
|
|
13430
|
-
skills: (0,
|
|
14954
|
+
skills: (0, import_cmd_ts21.multioption)({
|
|
13431
14955
|
long: "skill",
|
|
13432
14956
|
description: "Skill slug(s) to add",
|
|
13433
|
-
type: (0,
|
|
13434
|
-
})
|
|
14957
|
+
type: (0, import_cmd_ts21.array)(import_cmd_ts21.string)
|
|
14958
|
+
}),
|
|
14959
|
+
originSkill: originSkillOption
|
|
13435
14960
|
},
|
|
13436
|
-
handler: async ({ to, standards, commands, skills }) => {
|
|
14961
|
+
handler: async ({ to, standards, commands, skills, originSkill }) => {
|
|
13437
14962
|
const standardSlugs = standards ?? [];
|
|
13438
14963
|
const commandSlugs = commands ?? [];
|
|
13439
14964
|
const skillSlugs = skills ?? [];
|
|
@@ -13459,7 +14984,13 @@ var addToPackageCommand = (0, import_cmd_ts19.command)({
|
|
|
13459
14984
|
const hexa = new PackmindCliHexa(packmindLogger);
|
|
13460
14985
|
const gateway = hexa.getPackmindGateway();
|
|
13461
14986
|
const useCase = new AddToPackageUseCase(gateway);
|
|
13462
|
-
const result = await addToPackageHandler(
|
|
14987
|
+
const result = await addToPackageHandler(
|
|
14988
|
+
to,
|
|
14989
|
+
itemType,
|
|
14990
|
+
itemSlugs,
|
|
14991
|
+
useCase,
|
|
14992
|
+
originSkill
|
|
14993
|
+
);
|
|
13463
14994
|
if (!result.success) {
|
|
13464
14995
|
process.exit(1);
|
|
13465
14996
|
}
|
|
@@ -13467,8 +14998,8 @@ var addToPackageCommand = (0, import_cmd_ts19.command)({
|
|
|
13467
14998
|
});
|
|
13468
14999
|
|
|
13469
15000
|
// apps/cli/src/infra/commands/listPackagesCommand.ts
|
|
13470
|
-
var
|
|
13471
|
-
var listPackagesCommand = (0,
|
|
15001
|
+
var import_cmd_ts22 = __toESM(require_cjs());
|
|
15002
|
+
var listPackagesCommand = (0, import_cmd_ts22.command)({
|
|
13472
15003
|
name: "list",
|
|
13473
15004
|
description: "List available packages",
|
|
13474
15005
|
args: {},
|
|
@@ -13487,7 +15018,7 @@ var listPackagesCommand = (0, import_cmd_ts20.command)({
|
|
|
13487
15018
|
});
|
|
13488
15019
|
|
|
13489
15020
|
// apps/cli/src/infra/commands/PackagesCommand.ts
|
|
13490
|
-
var packagesCommand = (0,
|
|
15021
|
+
var packagesCommand = (0, import_cmd_ts23.subcommands)({
|
|
13491
15022
|
name: "packages",
|
|
13492
15023
|
description: "Manage packages",
|
|
13493
15024
|
cmds: {
|
|
@@ -13498,14 +15029,14 @@ var packagesCommand = (0, import_cmd_ts21.subcommands)({
|
|
|
13498
15029
|
});
|
|
13499
15030
|
|
|
13500
15031
|
// apps/cli/src/infra/commands/config/ConfigCommand.ts
|
|
13501
|
-
var
|
|
15032
|
+
var import_cmd_ts25 = __toESM(require_cjs());
|
|
13502
15033
|
|
|
13503
15034
|
// apps/cli/src/infra/commands/config/ConfigAgentsCommand.ts
|
|
13504
|
-
var
|
|
15035
|
+
var import_cmd_ts24 = __toESM(require_cjs());
|
|
13505
15036
|
|
|
13506
15037
|
// apps/cli/src/application/services/AgentArtifactDetectionService.ts
|
|
13507
|
-
var
|
|
13508
|
-
var
|
|
15038
|
+
var fs18 = __toESM(require("fs/promises"));
|
|
15039
|
+
var path16 = __toESM(require("path"));
|
|
13509
15040
|
var AGENT_ARTIFACT_CHECKS = [
|
|
13510
15041
|
{ agent: "claude", paths: [".claude"] },
|
|
13511
15042
|
{ agent: "cursor", paths: [".cursor"] },
|
|
@@ -13523,7 +15054,7 @@ var AgentArtifactDetectionService = class {
|
|
|
13523
15054
|
const detected = [];
|
|
13524
15055
|
for (const check of AGENT_ARTIFACT_CHECKS) {
|
|
13525
15056
|
for (const relativePath of check.paths) {
|
|
13526
|
-
const fullPath =
|
|
15057
|
+
const fullPath = path16.join(baseDirectory, relativePath);
|
|
13527
15058
|
const exists = await this.pathExists(fullPath);
|
|
13528
15059
|
if (exists) {
|
|
13529
15060
|
detected.push({
|
|
@@ -13538,7 +15069,7 @@ var AgentArtifactDetectionService = class {
|
|
|
13538
15069
|
}
|
|
13539
15070
|
async pathExists(filePath) {
|
|
13540
15071
|
try {
|
|
13541
|
-
await
|
|
15072
|
+
await fs18.access(filePath);
|
|
13542
15073
|
return true;
|
|
13543
15074
|
} catch {
|
|
13544
15075
|
return false;
|
|
@@ -13568,6 +15099,42 @@ var AGENT_DISPLAY_NAMES = {
|
|
|
13568
15099
|
agents_md: "AGENTS.md",
|
|
13569
15100
|
gitlab_duo: "GitLab Duo"
|
|
13570
15101
|
};
|
|
15102
|
+
async function configAgentsHandler(deps) {
|
|
15103
|
+
const { configRepository, baseDirectory } = deps;
|
|
15104
|
+
const isTTY = deps.isTTY ?? process.stdin.isTTY;
|
|
15105
|
+
const useSimplePrompt = process.env.PACKMIND_SIMPLE_PROMPT === "1" || !isTTY;
|
|
15106
|
+
const preselectedAgents = await getPreselectedAgents(deps);
|
|
15107
|
+
const choices = SELECTABLE_AGENTS.map((agent) => ({
|
|
15108
|
+
name: AGENT_DISPLAY_NAMES[agent],
|
|
15109
|
+
value: agent,
|
|
15110
|
+
checked: preselectedAgents.has(agent)
|
|
15111
|
+
}));
|
|
15112
|
+
let selectedAgents;
|
|
15113
|
+
if (useSimplePrompt) {
|
|
15114
|
+
selectedAgents = await promptAgentsWithReadline2(choices);
|
|
15115
|
+
} else {
|
|
15116
|
+
const result = await inquirer2.default.prompt([
|
|
15117
|
+
{
|
|
15118
|
+
type: "checkbox",
|
|
15119
|
+
name: "selectedAgents",
|
|
15120
|
+
message: "Select coding agents to generate artifacts for:",
|
|
15121
|
+
choices
|
|
15122
|
+
}
|
|
15123
|
+
]);
|
|
15124
|
+
selectedAgents = result.selectedAgents;
|
|
15125
|
+
}
|
|
15126
|
+
await configRepository.updateAgentsConfig(baseDirectory, selectedAgents);
|
|
15127
|
+
const agentNames = selectedAgents.map((a) => AGENT_DISPLAY_NAMES[a]);
|
|
15128
|
+
if (selectedAgents.length === 0) {
|
|
15129
|
+
logInfoConsole(
|
|
15130
|
+
"No agents selected. Only packmind artifacts will be generated."
|
|
15131
|
+
);
|
|
15132
|
+
} else {
|
|
15133
|
+
logSuccessConsole(
|
|
15134
|
+
`Configuration saved. Artifacts will be generated for: ${agentNames.join(", ")}`
|
|
15135
|
+
);
|
|
15136
|
+
}
|
|
15137
|
+
}
|
|
13571
15138
|
async function promptAgentsWithReadline2(choices) {
|
|
13572
15139
|
const input = process.stdin;
|
|
13573
15140
|
const output = process.stdout;
|
|
@@ -13598,73 +15165,54 @@ async function promptAgentsWithReadline2(choices) {
|
|
|
13598
15165
|
);
|
|
13599
15166
|
});
|
|
13600
15167
|
}
|
|
13601
|
-
async function
|
|
15168
|
+
async function getPreselectedAgents(deps) {
|
|
13602
15169
|
const { configRepository, agentDetectionService, baseDirectory } = deps;
|
|
13603
|
-
const isTTY = deps.isTTY ?? process.stdin.isTTY;
|
|
13604
|
-
const useSimplePrompt = process.env.PACKMIND_SIMPLE_PROMPT === "1" || !isTTY;
|
|
13605
15170
|
const existingConfig = await configRepository.readConfig(baseDirectory);
|
|
13606
|
-
let preselectedAgents;
|
|
13607
15171
|
if (existingConfig?.agents && existingConfig.agents.length > 0) {
|
|
13608
|
-
|
|
15172
|
+
return new Set(
|
|
13609
15173
|
existingConfig.agents.filter(
|
|
13610
15174
|
(agent) => SELECTABLE_AGENTS.includes(agent)
|
|
13611
15175
|
)
|
|
13612
15176
|
);
|
|
13613
|
-
} else {
|
|
13614
|
-
const detectedArtifacts = await agentDetectionService.detectAgentArtifacts(baseDirectory);
|
|
13615
|
-
preselectedAgents = new Set(detectedArtifacts.map((a) => a.agent));
|
|
13616
15177
|
}
|
|
13617
|
-
const
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
checked: preselectedAgents.has(agent)
|
|
13621
|
-
}));
|
|
13622
|
-
let selectedAgents;
|
|
13623
|
-
if (useSimplePrompt) {
|
|
13624
|
-
selectedAgents = await promptAgentsWithReadline2(choices);
|
|
13625
|
-
} else {
|
|
13626
|
-
const result = await inquirer2.default.prompt([
|
|
13627
|
-
{
|
|
13628
|
-
type: "checkbox",
|
|
13629
|
-
name: "selectedAgents",
|
|
13630
|
-
message: "Select coding agents to generate artifacts for:",
|
|
13631
|
-
choices
|
|
13632
|
-
}
|
|
13633
|
-
]);
|
|
13634
|
-
selectedAgents = result.selectedAgents;
|
|
15178
|
+
const detectedArtifacts = await agentDetectionService.detectAgentArtifacts(baseDirectory);
|
|
15179
|
+
if (detectedArtifacts.length > 0) {
|
|
15180
|
+
return new Set(detectedArtifacts.map((a) => a.agent));
|
|
13635
15181
|
}
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
`Configuration saved. Artifacts will be generated for: ${agentNames.join(", ")}`
|
|
13645
|
-
);
|
|
15182
|
+
try {
|
|
15183
|
+
const result = await deps.packmindGateway.deployment.getRenderModeConfiguration({});
|
|
15184
|
+
if (result.configuration) {
|
|
15185
|
+
return new Set(
|
|
15186
|
+
result.configuration.activeRenderModes.map((mode) => RENDER_MODE_TO_CODING_AGENT[mode]).filter((agent) => agent !== void 0)
|
|
15187
|
+
);
|
|
15188
|
+
}
|
|
15189
|
+
} catch {
|
|
13646
15190
|
}
|
|
15191
|
+
return /* @__PURE__ */ new Set();
|
|
13647
15192
|
}
|
|
13648
15193
|
|
|
13649
15194
|
// apps/cli/src/infra/commands/config/ConfigAgentsCommand.ts
|
|
13650
|
-
var configAgentsCommand = (0,
|
|
15195
|
+
var configAgentsCommand = (0, import_cmd_ts24.command)({
|
|
13651
15196
|
name: "agents",
|
|
13652
15197
|
description: "Configure which coding agents to generate artifacts for",
|
|
13653
15198
|
args: {},
|
|
13654
15199
|
handler: async () => {
|
|
15200
|
+
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
15201
|
+
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
13655
15202
|
const configRepository = new ConfigFileRepository();
|
|
13656
15203
|
const agentDetectionService = new AgentArtifactDetectionService();
|
|
13657
15204
|
const baseDirectory = process.cwd();
|
|
13658
15205
|
await configAgentsHandler({
|
|
13659
15206
|
configRepository,
|
|
13660
15207
|
agentDetectionService,
|
|
15208
|
+
packmindGateway: packmindCliHexa.getPackmindGateway(),
|
|
13661
15209
|
baseDirectory
|
|
13662
15210
|
});
|
|
13663
15211
|
}
|
|
13664
15212
|
});
|
|
13665
15213
|
|
|
13666
15214
|
// apps/cli/src/infra/commands/config/ConfigCommand.ts
|
|
13667
|
-
var configCommand = (0,
|
|
15215
|
+
var configCommand = (0, import_cmd_ts25.subcommands)({
|
|
13668
15216
|
name: "config",
|
|
13669
15217
|
description: "Manage Packmind configuration",
|
|
13670
15218
|
cmds: {
|
|
@@ -13673,13 +15221,14 @@ var configCommand = (0, import_cmd_ts23.subcommands)({
|
|
|
13673
15221
|
});
|
|
13674
15222
|
|
|
13675
15223
|
// apps/cli/src/infra/commands/InitCommand.ts
|
|
13676
|
-
var
|
|
15224
|
+
var import_cmd_ts26 = __toESM(require_cjs());
|
|
13677
15225
|
|
|
13678
15226
|
// apps/cli/src/infra/commands/initHandler.ts
|
|
13679
15227
|
async function initHandler(deps) {
|
|
13680
15228
|
const {
|
|
13681
15229
|
configRepository,
|
|
13682
15230
|
agentDetectionService,
|
|
15231
|
+
packmindGateway,
|
|
13683
15232
|
baseDirectory,
|
|
13684
15233
|
installDefaultSkills,
|
|
13685
15234
|
cliVersion,
|
|
@@ -13688,6 +15237,7 @@ async function initHandler(deps) {
|
|
|
13688
15237
|
const configAgentsDeps = {
|
|
13689
15238
|
configRepository,
|
|
13690
15239
|
agentDetectionService,
|
|
15240
|
+
packmindGateway,
|
|
13691
15241
|
baseDirectory,
|
|
13692
15242
|
isTTY
|
|
13693
15243
|
};
|
|
@@ -13728,7 +15278,7 @@ async function initHandler(deps) {
|
|
|
13728
15278
|
|
|
13729
15279
|
// apps/cli/src/infra/commands/InitCommand.ts
|
|
13730
15280
|
var { version: CLI_VERSION3 } = require_package();
|
|
13731
|
-
var initCommand = (0,
|
|
15281
|
+
var initCommand = (0, import_cmd_ts26.command)({
|
|
13732
15282
|
name: "init",
|
|
13733
15283
|
description: "Initialize Packmind in the current project",
|
|
13734
15284
|
args: {},
|
|
@@ -13741,6 +15291,7 @@ var initCommand = (0, import_cmd_ts24.command)({
|
|
|
13741
15291
|
const result = await initHandler({
|
|
13742
15292
|
configRepository,
|
|
13743
15293
|
agentDetectionService,
|
|
15294
|
+
packmindGateway: packmindCliHexa.getPackmindGateway(),
|
|
13744
15295
|
baseDirectory,
|
|
13745
15296
|
installDefaultSkills: packmindCliHexa.installDefaultSkills.bind(packmindCliHexa),
|
|
13746
15297
|
cliVersion: CLI_VERSION3
|
|
@@ -13760,20 +15311,20 @@ function findEnvFile() {
|
|
|
13760
15311
|
const currentDir = process.cwd();
|
|
13761
15312
|
const gitService = new GitService();
|
|
13762
15313
|
const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
|
|
13763
|
-
const filesystemRoot =
|
|
15314
|
+
const filesystemRoot = path17.parse(currentDir).root;
|
|
13764
15315
|
const stopDir = gitRoot ?? filesystemRoot;
|
|
13765
15316
|
let searchDir = currentDir;
|
|
13766
|
-
let parentDir =
|
|
15317
|
+
let parentDir = path17.dirname(searchDir);
|
|
13767
15318
|
while (searchDir !== parentDir) {
|
|
13768
|
-
const envPath2 =
|
|
13769
|
-
if (
|
|
15319
|
+
const envPath2 = path17.join(searchDir, ".env");
|
|
15320
|
+
if (fs19.existsSync(envPath2)) {
|
|
13770
15321
|
return envPath2;
|
|
13771
15322
|
}
|
|
13772
15323
|
if (searchDir === stopDir) {
|
|
13773
15324
|
return null;
|
|
13774
15325
|
}
|
|
13775
15326
|
searchDir = parentDir;
|
|
13776
|
-
parentDir =
|
|
15327
|
+
parentDir = path17.dirname(searchDir);
|
|
13777
15328
|
}
|
|
13778
15329
|
return null;
|
|
13779
15330
|
}
|
|
@@ -13793,12 +15344,13 @@ if (args.includes("--version") || args.includes("-v")) {
|
|
|
13793
15344
|
logConsole(`packmind-cli version ${CLI_VERSION4}`);
|
|
13794
15345
|
process.exit(0);
|
|
13795
15346
|
}
|
|
13796
|
-
var app = (0,
|
|
15347
|
+
var app = (0, import_cmd_ts27.subcommands)({
|
|
13797
15348
|
name: "packmind-cli",
|
|
13798
15349
|
description: "Packmind CLI tool",
|
|
13799
15350
|
cmds: {
|
|
13800
15351
|
commands: commandsCommand,
|
|
13801
15352
|
config: configCommand,
|
|
15353
|
+
diff: diffCommand,
|
|
13802
15354
|
init: initCommand,
|
|
13803
15355
|
install: installCommand,
|
|
13804
15356
|
lint: lintCommand,
|
|
@@ -13814,7 +15366,7 @@ var app = (0, import_cmd_ts25.subcommands)({
|
|
|
13814
15366
|
whoami: whoamiCommand
|
|
13815
15367
|
}
|
|
13816
15368
|
});
|
|
13817
|
-
(0,
|
|
15369
|
+
(0, import_cmd_ts27.run)(app, args).catch((error) => {
|
|
13818
15370
|
logErrorConsole(error.message);
|
|
13819
15371
|
process.exit(1);
|
|
13820
15372
|
});
|