@packmind/cli 0.19.0 → 0.21.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 +1203 -233
- package/package.json +6 -6
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(flag6, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
238
|
+
const prefix = flag6.startsWith("-") ? "" : flag6.length === 1 ? "-" : "--";
|
|
239
|
+
const position = argv.indexOf(prefix + flag6);
|
|
240
240
|
const terminatorPosition = argv.indexOf("--");
|
|
241
241
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
242
242
|
}
|
|
@@ -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 = flag6;
|
|
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 flag6(config) {
|
|
1088
1088
|
return fullFlag({
|
|
1089
1089
|
type: types_1.boolean,
|
|
1090
1090
|
...config
|
|
@@ -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 = command22;
|
|
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 command22(config) {
|
|
1707
1707
|
const argEntries = (0, utils_1.entries)(config.args);
|
|
1708
1708
|
const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
|
|
1709
1709
|
return {
|
|
@@ -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 = (flag6, argv = process.argv) => {
|
|
2578
|
+
const prefix = flag6.startsWith("-") ? "" : flag6.length === 1 ? "-" : "--";
|
|
2579
|
+
const position = argv.indexOf(prefix + flag6);
|
|
2580
2580
|
const terminatorPosition = argv.indexOf("--");
|
|
2581
2581
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2582
2582
|
};
|
|
@@ -3218,7 +3218,7 @@ var require_restPositionals = __commonJS({
|
|
|
3218
3218
|
};
|
|
3219
3219
|
}();
|
|
3220
3220
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3221
|
-
exports2.restPositionals =
|
|
3221
|
+
exports2.restPositionals = restPositionals4;
|
|
3222
3222
|
var Result = __importStar(require_Result());
|
|
3223
3223
|
var types_1 = require_types();
|
|
3224
3224
|
function fullRestPositionals(config) {
|
|
@@ -3262,7 +3262,7 @@ var require_restPositionals = __commonJS({
|
|
|
3262
3262
|
}
|
|
3263
3263
|
};
|
|
3264
3264
|
}
|
|
3265
|
-
function
|
|
3265
|
+
function restPositionals4(config) {
|
|
3266
3266
|
return fullRestPositionals({
|
|
3267
3267
|
type: types_1.string,
|
|
3268
3268
|
...config
|
|
@@ -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.21.0",
|
|
3856
3856
|
description: "A command-line interface for Packmind linting and code quality checks",
|
|
3857
3857
|
private: false,
|
|
3858
3858
|
bin: {
|
|
@@ -3887,15 +3887,17 @@ var require_package = __commonJS({
|
|
|
3887
3887
|
},
|
|
3888
3888
|
dependencies: {
|
|
3889
3889
|
"@types/inquirer": "^9.0.9",
|
|
3890
|
+
diff: "^8.0.3",
|
|
3890
3891
|
inquirer: "^13.0.2",
|
|
3891
|
-
zod: "^4.3.5"
|
|
3892
|
+
zod: "^4.3.5",
|
|
3893
|
+
semver: "^6.3.1"
|
|
3892
3894
|
}
|
|
3893
3895
|
};
|
|
3894
3896
|
}
|
|
3895
3897
|
});
|
|
3896
3898
|
|
|
3897
3899
|
// apps/cli/src/main.ts
|
|
3898
|
-
var
|
|
3900
|
+
var import_cmd_ts28 = __toESM(require_cjs());
|
|
3899
3901
|
|
|
3900
3902
|
// apps/cli/src/infra/commands/LinterCommand.ts
|
|
3901
3903
|
var import_cmd_ts = __toESM(require_cjs());
|
|
@@ -4117,6 +4119,35 @@ var CodingAgents = {
|
|
|
4117
4119
|
continue: "continue"
|
|
4118
4120
|
};
|
|
4119
4121
|
|
|
4122
|
+
// packages/types/src/coding-agent/CodingAgentArtefactPaths.ts
|
|
4123
|
+
var CODING_AGENT_ARTEFACT_PATHS = {
|
|
4124
|
+
claude: {
|
|
4125
|
+
command: ".claude/commands/",
|
|
4126
|
+
standard: ".claude/rules/",
|
|
4127
|
+
skill: ".claude/skills/"
|
|
4128
|
+
},
|
|
4129
|
+
cursor: {
|
|
4130
|
+
command: ".cursor/commands/",
|
|
4131
|
+
standard: ".cursor/rules/",
|
|
4132
|
+
skill: ".cursor/skills/"
|
|
4133
|
+
},
|
|
4134
|
+
copilot: {
|
|
4135
|
+
command: ".github/prompts/",
|
|
4136
|
+
standard: ".github/instructions/",
|
|
4137
|
+
skill: ".github/skills/"
|
|
4138
|
+
},
|
|
4139
|
+
continue: {
|
|
4140
|
+
command: ".continue/prompts/",
|
|
4141
|
+
standard: ".continue/rules/",
|
|
4142
|
+
skill: ""
|
|
4143
|
+
},
|
|
4144
|
+
packmind: {
|
|
4145
|
+
command: ".packmind/commands/",
|
|
4146
|
+
standard: ".packmind/standards/",
|
|
4147
|
+
skill: ""
|
|
4148
|
+
}
|
|
4149
|
+
};
|
|
4150
|
+
|
|
4120
4151
|
// packages/types/src/recipes/RecipeId.ts
|
|
4121
4152
|
var createRecipeId = brandedIdFactory();
|
|
4122
4153
|
|
|
@@ -4353,6 +4384,7 @@ var ProgrammingLanguage = /* @__PURE__ */ ((ProgrammingLanguage5) => {
|
|
|
4353
4384
|
ProgrammingLanguage5["SAP_CDS"] = "SAP_CDS";
|
|
4354
4385
|
ProgrammingLanguage5["SAP_HANA_SQL"] = "SAP_HANA_SQL";
|
|
4355
4386
|
ProgrammingLanguage5["SWIFT"] = "SWIFT";
|
|
4387
|
+
ProgrammingLanguage5["DART"] = "DART";
|
|
4356
4388
|
ProgrammingLanguage5["PROPERTIES"] = "PROPERTIES";
|
|
4357
4389
|
return ProgrammingLanguage5;
|
|
4358
4390
|
})(ProgrammingLanguage || {});
|
|
@@ -4482,6 +4514,10 @@ var ProgrammingLanguageDetails = {
|
|
|
4482
4514
|
displayName: "Swift",
|
|
4483
4515
|
fileExtensions: ["swift"]
|
|
4484
4516
|
},
|
|
4517
|
+
["DART" /* DART */]: {
|
|
4518
|
+
displayName: "Dart",
|
|
4519
|
+
fileExtensions: ["dart"]
|
|
4520
|
+
},
|
|
4485
4521
|
["PROPERTIES" /* PROPERTIES */]: {
|
|
4486
4522
|
displayName: "Properties",
|
|
4487
4523
|
fileExtensions: ["properties"]
|
|
@@ -4696,9 +4732,8 @@ var frameworkSampleMappings = {
|
|
|
4696
4732
|
exampleLanguage: null
|
|
4697
4733
|
},
|
|
4698
4734
|
flutter: {
|
|
4699
|
-
languages: [],
|
|
4700
|
-
|
|
4701
|
-
exampleLanguage: null
|
|
4735
|
+
languages: ["DART" /* DART */],
|
|
4736
|
+
exampleLanguage: "DART" /* DART */
|
|
4702
4737
|
}
|
|
4703
4738
|
};
|
|
4704
4739
|
|
|
@@ -4996,9 +5031,69 @@ var CHANGE_PROPOSAL_TYPE_LABELS = {
|
|
|
4996
5031
|
["addSkillFile" /* addSkillFile */]: "File (add)",
|
|
4997
5032
|
["updateSkillFileContent" /* updateSkillFileContent */]: "File content",
|
|
4998
5033
|
["updateSkillFilePermissions" /* updateSkillFilePermissions */]: "File permissions",
|
|
4999
|
-
["deleteSkillFile" /* deleteSkillFile */]: "File (delete)"
|
|
5034
|
+
["deleteSkillFile" /* deleteSkillFile */]: "File (delete)",
|
|
5035
|
+
["createStandard" /* createStandard */]: "New standard",
|
|
5036
|
+
["createCommand" /* createCommand */]: "New command",
|
|
5037
|
+
["createSkill" /* createSkill */]: "New skill",
|
|
5038
|
+
["removeStandard" /* removeStandard */]: "Remove standard",
|
|
5039
|
+
["removeCommand" /* removeCommand */]: "Remove command",
|
|
5040
|
+
["removeSkill" /* removeSkill */]: "Remove skill"
|
|
5041
|
+
};
|
|
5042
|
+
|
|
5043
|
+
// packages/types/src/playbookChangeManagement/events/ChangeProposalAcceptedEvent.ts
|
|
5044
|
+
var ChangeProposalAcceptedEvent = class extends UserEvent {
|
|
5045
|
+
static {
|
|
5046
|
+
this.eventName = "change-proposals.change-proposal.accepted";
|
|
5047
|
+
}
|
|
5048
|
+
};
|
|
5049
|
+
|
|
5050
|
+
// packages/types/src/playbookChangeManagement/events/ChangeProposalRejectedEvent.ts
|
|
5051
|
+
var ChangeProposalRejectedEvent = class extends UserEvent {
|
|
5052
|
+
static {
|
|
5053
|
+
this.eventName = "change-proposals.change-proposal.rejected";
|
|
5054
|
+
}
|
|
5055
|
+
};
|
|
5056
|
+
|
|
5057
|
+
// packages/types/src/playbookChangeManagement/events/ChangeProposalSubmittedEvent.ts
|
|
5058
|
+
var ChangeProposalSubmittedEvent = class extends UserEvent {
|
|
5059
|
+
static {
|
|
5060
|
+
this.eventName = "change-proposals.change-proposal.submitted";
|
|
5061
|
+
}
|
|
5000
5062
|
};
|
|
5001
5063
|
|
|
5064
|
+
// packages/types/src/playbookChangeManagement/applier/DiffService.ts
|
|
5065
|
+
var import_diff = require("diff");
|
|
5066
|
+
|
|
5067
|
+
// packages/types/src/playbookChangeManagement/applier/types.ts
|
|
5068
|
+
var STANDARD_CHANGE_TYPES = [
|
|
5069
|
+
"updateStandardName" /* updateStandardName */,
|
|
5070
|
+
"updateStandardScope" /* updateStandardScope */,
|
|
5071
|
+
"updateStandardDescription" /* updateStandardDescription */,
|
|
5072
|
+
"addRule" /* addRule */,
|
|
5073
|
+
"updateRule" /* updateRule */,
|
|
5074
|
+
"deleteRule" /* deleteRule */,
|
|
5075
|
+
"removeStandard" /* removeStandard */
|
|
5076
|
+
];
|
|
5077
|
+
var RECIPE_CHANGE_TYPES = [
|
|
5078
|
+
"updateCommandName" /* updateCommandName */,
|
|
5079
|
+
"updateCommandDescription" /* updateCommandDescription */,
|
|
5080
|
+
"removeCommand" /* removeCommand */
|
|
5081
|
+
];
|
|
5082
|
+
var SKILL_CHANGE_TYPES = [
|
|
5083
|
+
"updateSkillName" /* updateSkillName */,
|
|
5084
|
+
"updateSkillDescription" /* updateSkillDescription */,
|
|
5085
|
+
"updateSkillPrompt" /* updateSkillPrompt */,
|
|
5086
|
+
"updateSkillMetadata" /* updateSkillMetadata */,
|
|
5087
|
+
"updateSkillLicense" /* updateSkillLicense */,
|
|
5088
|
+
"updateSkillCompatibility" /* updateSkillCompatibility */,
|
|
5089
|
+
"updateSkillAllowedTools" /* updateSkillAllowedTools */,
|
|
5090
|
+
"addSkillFile" /* addSkillFile */,
|
|
5091
|
+
"updateSkillFileContent" /* updateSkillFileContent */,
|
|
5092
|
+
"updateSkillFilePermissions" /* updateSkillFilePermissions */,
|
|
5093
|
+
"deleteSkillFile" /* deleteSkillFile */,
|
|
5094
|
+
"removeSkill" /* removeSkill */
|
|
5095
|
+
];
|
|
5096
|
+
|
|
5002
5097
|
// apps/cli/src/application/useCases/ExecuteSingleFileAstUseCase.ts
|
|
5003
5098
|
var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
5004
5099
|
constructor(linterExecutionUseCase) {
|
|
@@ -5010,8 +5105,8 @@ var ExecuteSingleFileAstUseCase = class _ExecuteSingleFileAstUseCase {
|
|
|
5010
5105
|
static {
|
|
5011
5106
|
this.fallbackRuleContent = "adhoc-rule";
|
|
5012
5107
|
}
|
|
5013
|
-
async execute(
|
|
5014
|
-
const { program, fileContent, language } =
|
|
5108
|
+
async execute(command22) {
|
|
5109
|
+
const { program, fileContent, language } = command22;
|
|
5015
5110
|
const result = await this.linterExecutionUseCase.execute({
|
|
5016
5111
|
filePath: "cli-single-file",
|
|
5017
5112
|
fileContent,
|
|
@@ -5062,30 +5157,30 @@ var GitService = class {
|
|
|
5062
5157
|
this.gitRunner = gitRunner;
|
|
5063
5158
|
this.logger = logger2;
|
|
5064
5159
|
}
|
|
5065
|
-
getGitRepositoryRoot(
|
|
5160
|
+
getGitRepositoryRoot(path22) {
|
|
5066
5161
|
try {
|
|
5067
5162
|
const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
|
|
5068
|
-
cwd:
|
|
5163
|
+
cwd: path22
|
|
5069
5164
|
});
|
|
5070
5165
|
const gitRoot = stdout.trim();
|
|
5071
5166
|
this.logger.debug("Resolved git repository root", {
|
|
5072
|
-
inputPath:
|
|
5167
|
+
inputPath: path22,
|
|
5073
5168
|
gitRoot
|
|
5074
5169
|
});
|
|
5075
5170
|
return gitRoot;
|
|
5076
5171
|
} catch (error) {
|
|
5077
5172
|
if (error instanceof Error) {
|
|
5078
5173
|
throw new Error(
|
|
5079
|
-
`Failed to get Git repository root. The path '${
|
|
5174
|
+
`Failed to get Git repository root. The path '${path22}' does not appear to be inside a Git repository.
|
|
5080
5175
|
${error.message}`
|
|
5081
5176
|
);
|
|
5082
5177
|
}
|
|
5083
5178
|
throw new Error("Failed to get Git repository root: Unknown error");
|
|
5084
5179
|
}
|
|
5085
5180
|
}
|
|
5086
|
-
tryGetGitRepositoryRoot(
|
|
5181
|
+
tryGetGitRepositoryRoot(path22) {
|
|
5087
5182
|
try {
|
|
5088
|
-
return this.getGitRepositoryRoot(
|
|
5183
|
+
return this.getGitRepositoryRoot(path22);
|
|
5089
5184
|
} catch {
|
|
5090
5185
|
return null;
|
|
5091
5186
|
}
|
|
@@ -5392,8 +5487,8 @@ var GetGitRemoteUrlUseCase = class {
|
|
|
5392
5487
|
constructor(gitRemoteUrlService = new GitService()) {
|
|
5393
5488
|
this.gitRemoteUrlService = gitRemoteUrlService;
|
|
5394
5489
|
}
|
|
5395
|
-
async execute(
|
|
5396
|
-
const { path: repoPath, origin: origin9 } =
|
|
5490
|
+
async execute(command22) {
|
|
5491
|
+
const { path: repoPath, origin: origin9 } = command22;
|
|
5397
5492
|
return this.gitRemoteUrlService.getGitRemoteUrl(repoPath, origin9);
|
|
5398
5493
|
}
|
|
5399
5494
|
};
|
|
@@ -5538,8 +5633,8 @@ var ListFilesInDirectoryUseCase = class {
|
|
|
5538
5633
|
constructor(listFiles = new ListFiles()) {
|
|
5539
5634
|
this.listFiles = listFiles;
|
|
5540
5635
|
}
|
|
5541
|
-
async execute(
|
|
5542
|
-
const { path: directoryPath, extensions, excludes = [] } =
|
|
5636
|
+
async execute(command22) {
|
|
5637
|
+
const { path: directoryPath, extensions, excludes = [] } = command22;
|
|
5543
5638
|
const files = await this.listFiles.listFilesInDirectory(
|
|
5544
5639
|
directoryPath,
|
|
5545
5640
|
extensions,
|
|
@@ -5644,7 +5739,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5644
5739
|
}
|
|
5645
5740
|
return pattern;
|
|
5646
5741
|
}
|
|
5647
|
-
async execute(
|
|
5742
|
+
async execute(command22) {
|
|
5648
5743
|
const {
|
|
5649
5744
|
path: userPath,
|
|
5650
5745
|
draftMode,
|
|
@@ -5652,7 +5747,7 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5652
5747
|
ruleId,
|
|
5653
5748
|
language,
|
|
5654
5749
|
diffMode
|
|
5655
|
-
} =
|
|
5750
|
+
} = command22;
|
|
5656
5751
|
this.logger.debug(
|
|
5657
5752
|
`Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}", diffMode="${diffMode ?? "none"}"`
|
|
5658
5753
|
);
|
|
@@ -5957,8 +6052,8 @@ var LintFilesAgainstRuleUseCase = class {
|
|
|
5957
6052
|
return null;
|
|
5958
6053
|
}
|
|
5959
6054
|
}
|
|
5960
|
-
async executeProgramsForFile(
|
|
5961
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
6055
|
+
async executeProgramsForFile(command22) {
|
|
6056
|
+
const result = await this.services.linterExecutionUseCase.execute(command22);
|
|
5962
6057
|
return result.violations;
|
|
5963
6058
|
}
|
|
5964
6059
|
extractExtensionFromFile(filePath) {
|
|
@@ -6015,8 +6110,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6015
6110
|
}
|
|
6016
6111
|
return pattern;
|
|
6017
6112
|
}
|
|
6018
|
-
async execute(
|
|
6019
|
-
const { path: userPath, diffMode } =
|
|
6113
|
+
async execute(command22) {
|
|
6114
|
+
const { path: userPath, diffMode } = command22;
|
|
6020
6115
|
this.logger.debug(
|
|
6021
6116
|
`Starting local linting: path="${userPath}", diffMode="${diffMode ?? "none"}"`
|
|
6022
6117
|
);
|
|
@@ -6272,8 +6367,8 @@ var LintFilesFromConfigUseCase = class {
|
|
|
6272
6367
|
return null;
|
|
6273
6368
|
}
|
|
6274
6369
|
}
|
|
6275
|
-
async executeProgramsForFile(
|
|
6276
|
-
const result = await this.services.linterExecutionUseCase.execute(
|
|
6370
|
+
async executeProgramsForFile(command22) {
|
|
6371
|
+
const result = await this.services.linterExecutionUseCase.execute(command22);
|
|
6277
6372
|
return result.violations;
|
|
6278
6373
|
}
|
|
6279
6374
|
extractExtensionFromFile(filePath) {
|
|
@@ -6339,10 +6434,10 @@ var PackmindHttpClient = class {
|
|
|
6339
6434
|
return null;
|
|
6340
6435
|
}
|
|
6341
6436
|
}
|
|
6342
|
-
async request(
|
|
6437
|
+
async request(path22, options = {}) {
|
|
6343
6438
|
const { host } = this.getAuthContext();
|
|
6344
6439
|
const { method = "GET", body } = options;
|
|
6345
|
-
const url = `${host}${
|
|
6440
|
+
const url = `${host}${path22}`;
|
|
6346
6441
|
try {
|
|
6347
6442
|
const response = await fetch(url, {
|
|
6348
6443
|
method,
|
|
@@ -6389,23 +6484,23 @@ var PackmindHttpClient = class {
|
|
|
6389
6484
|
var ChangeProposalGateway = class {
|
|
6390
6485
|
constructor(httpClient) {
|
|
6391
6486
|
this.httpClient = httpClient;
|
|
6392
|
-
this.batchCreate = async (
|
|
6487
|
+
this.batchCreate = async (command22) => {
|
|
6393
6488
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6394
6489
|
return this.httpClient.request(
|
|
6395
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6490
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/change-proposals/batch`,
|
|
6396
6491
|
{
|
|
6397
6492
|
method: "POST",
|
|
6398
|
-
body: { proposals:
|
|
6493
|
+
body: { proposals: command22.proposals }
|
|
6399
6494
|
}
|
|
6400
6495
|
);
|
|
6401
6496
|
};
|
|
6402
|
-
this.check = async (
|
|
6497
|
+
this.check = async (command22) => {
|
|
6403
6498
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6404
6499
|
return this.httpClient.request(
|
|
6405
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6500
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/change-proposals/check`,
|
|
6406
6501
|
{
|
|
6407
6502
|
method: "POST",
|
|
6408
|
-
body: { proposals:
|
|
6503
|
+
body: { proposals: command22.proposals }
|
|
6409
6504
|
}
|
|
6410
6505
|
);
|
|
6411
6506
|
};
|
|
@@ -6426,13 +6521,13 @@ var CommunityEditionError = class extends Error {
|
|
|
6426
6521
|
var LinterGateway = class {
|
|
6427
6522
|
constructor(httpClient) {
|
|
6428
6523
|
this.httpClient = httpClient;
|
|
6429
|
-
this.getDraftDetectionProgramsForRule = async (
|
|
6524
|
+
this.getDraftDetectionProgramsForRule = async (command22) => {
|
|
6430
6525
|
const payload = {
|
|
6431
|
-
standardSlug:
|
|
6432
|
-
ruleId:
|
|
6526
|
+
standardSlug: command22.standardSlug,
|
|
6527
|
+
ruleId: command22.ruleId
|
|
6433
6528
|
};
|
|
6434
|
-
if (
|
|
6435
|
-
payload.language =
|
|
6529
|
+
if (command22.language) {
|
|
6530
|
+
payload.language = command22.language;
|
|
6436
6531
|
}
|
|
6437
6532
|
return this.httpClient.request("/api/v0/list-draft-detection-program", {
|
|
6438
6533
|
method: "POST",
|
|
@@ -6444,13 +6539,13 @@ var LinterGateway = class {
|
|
|
6444
6539
|
}
|
|
6445
6540
|
});
|
|
6446
6541
|
};
|
|
6447
|
-
this.getActiveDetectionProgramsForRule = async (
|
|
6542
|
+
this.getActiveDetectionProgramsForRule = async (command22) => {
|
|
6448
6543
|
const payload = {
|
|
6449
|
-
standardSlug:
|
|
6450
|
-
ruleId:
|
|
6544
|
+
standardSlug: command22.standardSlug,
|
|
6545
|
+
ruleId: command22.ruleId
|
|
6451
6546
|
};
|
|
6452
|
-
if (
|
|
6453
|
-
payload.language =
|
|
6547
|
+
if (command22.language) {
|
|
6548
|
+
payload.language = command22.language;
|
|
6454
6549
|
}
|
|
6455
6550
|
return this.httpClient.request("/api/v0/list-active-detection-program", {
|
|
6456
6551
|
method: "POST",
|
|
@@ -6462,13 +6557,13 @@ var LinterGateway = class {
|
|
|
6462
6557
|
}
|
|
6463
6558
|
});
|
|
6464
6559
|
};
|
|
6465
|
-
this.getDetectionProgramsForPackages = async (
|
|
6560
|
+
this.getDetectionProgramsForPackages = async (command22) => {
|
|
6466
6561
|
const response = await this.httpClient.request(
|
|
6467
6562
|
"/api/v0/detection-programs-for-packages",
|
|
6468
6563
|
{
|
|
6469
6564
|
method: "POST",
|
|
6470
6565
|
body: {
|
|
6471
|
-
packagesSlugs:
|
|
6566
|
+
packagesSlugs: command22.packagesSlugs
|
|
6472
6567
|
},
|
|
6473
6568
|
onError: (response2) => {
|
|
6474
6569
|
if (response2.status === 404) {
|
|
@@ -6479,10 +6574,10 @@ var LinterGateway = class {
|
|
|
6479
6574
|
);
|
|
6480
6575
|
return handleScopeInTargetsResponse(response);
|
|
6481
6576
|
};
|
|
6482
|
-
this.trackLinterExecution = async (
|
|
6577
|
+
this.trackLinterExecution = async (command22) => {
|
|
6483
6578
|
return this.httpClient.request(`/api/v0/track-execution`, {
|
|
6484
6579
|
method: "POST",
|
|
6485
|
-
body:
|
|
6580
|
+
body: command22
|
|
6486
6581
|
});
|
|
6487
6582
|
};
|
|
6488
6583
|
}
|
|
@@ -6540,27 +6635,27 @@ var SpacesGateway = class {
|
|
|
6540
6635
|
var SkillsGateway = class {
|
|
6541
6636
|
constructor(httpClient) {
|
|
6542
6637
|
this.httpClient = httpClient;
|
|
6543
|
-
this.upload = async (
|
|
6638
|
+
this.upload = async (command22) => {
|
|
6544
6639
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6545
6640
|
return this.httpClient.request(
|
|
6546
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6641
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/skills/upload`,
|
|
6547
6642
|
{
|
|
6548
6643
|
method: "POST",
|
|
6549
|
-
body:
|
|
6644
|
+
body: command22
|
|
6550
6645
|
}
|
|
6551
6646
|
);
|
|
6552
6647
|
};
|
|
6553
|
-
this.getDefaults = async (
|
|
6648
|
+
this.getDefaults = async (command22) => {
|
|
6554
6649
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6555
6650
|
const queryParams = new URLSearchParams();
|
|
6556
|
-
if (
|
|
6651
|
+
if (command22.includeBeta) {
|
|
6557
6652
|
queryParams.set("includeBeta", "true");
|
|
6558
|
-
} else if (
|
|
6559
|
-
queryParams.set("cliVersion",
|
|
6653
|
+
} else if (command22.cliVersion) {
|
|
6654
|
+
queryParams.set("cliVersion", command22.cliVersion);
|
|
6560
6655
|
}
|
|
6561
|
-
if (
|
|
6656
|
+
if (command22.agents !== void 0) {
|
|
6562
6657
|
queryParams.append("agentsConfigOverride", "true");
|
|
6563
|
-
|
|
6658
|
+
command22.agents.forEach((agent) => {
|
|
6564
6659
|
queryParams.append("agent", agent);
|
|
6565
6660
|
});
|
|
6566
6661
|
}
|
|
@@ -6569,10 +6664,10 @@ var SkillsGateway = class {
|
|
|
6569
6664
|
`/api/v0/organizations/${organizationId}/skills/default${queryString ? `?${queryString}` : ""}`
|
|
6570
6665
|
);
|
|
6571
6666
|
};
|
|
6572
|
-
this.list = async (
|
|
6667
|
+
this.list = async (command22) => {
|
|
6573
6668
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6574
6669
|
return this.httpClient.request(
|
|
6575
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6670
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/skills`
|
|
6576
6671
|
);
|
|
6577
6672
|
};
|
|
6578
6673
|
}
|
|
@@ -6582,17 +6677,17 @@ var SkillsGateway = class {
|
|
|
6582
6677
|
var CommandsGateway = class {
|
|
6583
6678
|
constructor(httpClient) {
|
|
6584
6679
|
this.httpClient = httpClient;
|
|
6585
|
-
this.create = async (
|
|
6680
|
+
this.create = async (command22) => {
|
|
6586
6681
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6587
6682
|
return this.httpClient.request(
|
|
6588
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6589
|
-
{ method: "POST", body:
|
|
6683
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/recipes`,
|
|
6684
|
+
{ method: "POST", body: command22 }
|
|
6590
6685
|
);
|
|
6591
6686
|
};
|
|
6592
|
-
this.list = async (
|
|
6687
|
+
this.list = async (command22) => {
|
|
6593
6688
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6594
6689
|
const listRecipesResponse = await this.httpClient.request(
|
|
6595
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6690
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/recipes`
|
|
6596
6691
|
);
|
|
6597
6692
|
if (listRecipesResponse instanceof Array) {
|
|
6598
6693
|
return { recipes: listRecipesResponse };
|
|
@@ -6634,10 +6729,10 @@ var StandardsGateway = class {
|
|
|
6634
6729
|
}
|
|
6635
6730
|
);
|
|
6636
6731
|
};
|
|
6637
|
-
this.list = async (
|
|
6732
|
+
this.list = async (command22) => {
|
|
6638
6733
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6639
6734
|
return this.httpClient.request(
|
|
6640
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6735
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/standards`
|
|
6641
6736
|
);
|
|
6642
6737
|
};
|
|
6643
6738
|
}
|
|
@@ -6660,24 +6755,24 @@ var PackagesGateway = class {
|
|
|
6660
6755
|
`/api/v0/organizations/${organizationId}/packages/${encodeURIComponent(slug)}`
|
|
6661
6756
|
);
|
|
6662
6757
|
};
|
|
6663
|
-
this.create = async (
|
|
6758
|
+
this.create = async (command22) => {
|
|
6664
6759
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6665
6760
|
return this.httpClient.request(
|
|
6666
|
-
`/api/v0/organizations/${organizationId}/spaces/${
|
|
6761
|
+
`/api/v0/organizations/${organizationId}/spaces/${command22.spaceId}/packages`,
|
|
6667
6762
|
{
|
|
6668
6763
|
method: "POST",
|
|
6669
|
-
body:
|
|
6764
|
+
body: command22
|
|
6670
6765
|
}
|
|
6671
6766
|
);
|
|
6672
6767
|
};
|
|
6673
|
-
this.addArtefacts = async (
|
|
6768
|
+
this.addArtefacts = async (command22) => {
|
|
6674
6769
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6675
|
-
const { packageId, spaceId } =
|
|
6770
|
+
const { packageId, spaceId } = command22;
|
|
6676
6771
|
return this.httpClient.request(
|
|
6677
6772
|
`/api/v0/organizations/${organizationId}/spaces/${spaceId}/packages/${packageId}/add-artifacts`,
|
|
6678
6773
|
{
|
|
6679
6774
|
method: "POST",
|
|
6680
|
-
body:
|
|
6775
|
+
body: command22
|
|
6681
6776
|
}
|
|
6682
6777
|
);
|
|
6683
6778
|
};
|
|
@@ -6688,31 +6783,31 @@ var PackagesGateway = class {
|
|
|
6688
6783
|
var DeploymentGateway = class {
|
|
6689
6784
|
constructor(httpClient) {
|
|
6690
6785
|
this.httpClient = httpClient;
|
|
6691
|
-
this.pull = async (
|
|
6786
|
+
this.pull = async (command22) => {
|
|
6692
6787
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6693
6788
|
const queryParams = new URLSearchParams();
|
|
6694
|
-
if (
|
|
6695
|
-
|
|
6789
|
+
if (command22.packagesSlugs && command22.packagesSlugs.length > 0) {
|
|
6790
|
+
command22.packagesSlugs.forEach((slug) => {
|
|
6696
6791
|
queryParams.append("packageSlug", slug);
|
|
6697
6792
|
});
|
|
6698
6793
|
}
|
|
6699
|
-
if (
|
|
6700
|
-
|
|
6794
|
+
if (command22.previousPackagesSlugs && command22.previousPackagesSlugs.length > 0) {
|
|
6795
|
+
command22.previousPackagesSlugs.forEach((slug) => {
|
|
6701
6796
|
queryParams.append("previousPackageSlug", slug);
|
|
6702
6797
|
});
|
|
6703
6798
|
}
|
|
6704
|
-
if (
|
|
6705
|
-
queryParams.append("gitRemoteUrl",
|
|
6799
|
+
if (command22.gitRemoteUrl) {
|
|
6800
|
+
queryParams.append("gitRemoteUrl", command22.gitRemoteUrl);
|
|
6706
6801
|
}
|
|
6707
|
-
if (
|
|
6708
|
-
queryParams.append("gitBranch",
|
|
6802
|
+
if (command22.gitBranch) {
|
|
6803
|
+
queryParams.append("gitBranch", command22.gitBranch);
|
|
6709
6804
|
}
|
|
6710
|
-
if (
|
|
6711
|
-
queryParams.append("relativePath",
|
|
6805
|
+
if (command22.relativePath) {
|
|
6806
|
+
queryParams.append("relativePath", command22.relativePath);
|
|
6712
6807
|
}
|
|
6713
|
-
if (
|
|
6808
|
+
if (command22.agents !== void 0) {
|
|
6714
6809
|
queryParams.append("agentsConfigOverride", "true");
|
|
6715
|
-
|
|
6810
|
+
command22.agents.forEach((agent) => {
|
|
6716
6811
|
queryParams.append("agent", agent);
|
|
6717
6812
|
});
|
|
6718
6813
|
}
|
|
@@ -6720,29 +6815,29 @@ var DeploymentGateway = class {
|
|
|
6720
6815
|
`/api/v0/organizations/${organizationId}/pull?${queryParams.toString()}`
|
|
6721
6816
|
);
|
|
6722
6817
|
};
|
|
6723
|
-
this.getDeployed = async (
|
|
6818
|
+
this.getDeployed = async (command22) => {
|
|
6724
6819
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6725
6820
|
return this.httpClient.request(
|
|
6726
6821
|
`/api/v0/organizations/${organizationId}/deployed-content`,
|
|
6727
6822
|
{
|
|
6728
6823
|
method: "POST",
|
|
6729
6824
|
body: {
|
|
6730
|
-
packagesSlugs:
|
|
6731
|
-
gitRemoteUrl:
|
|
6732
|
-
gitBranch:
|
|
6733
|
-
relativePath:
|
|
6734
|
-
...
|
|
6825
|
+
packagesSlugs: command22.packagesSlugs,
|
|
6826
|
+
gitRemoteUrl: command22.gitRemoteUrl,
|
|
6827
|
+
gitBranch: command22.gitBranch,
|
|
6828
|
+
relativePath: command22.relativePath,
|
|
6829
|
+
...command22.agents !== void 0 && { agents: command22.agents }
|
|
6735
6830
|
}
|
|
6736
6831
|
}
|
|
6737
6832
|
);
|
|
6738
6833
|
};
|
|
6739
|
-
this.notifyDistribution = async (
|
|
6834
|
+
this.notifyDistribution = async (command22) => {
|
|
6740
6835
|
const { organizationId } = this.httpClient.getAuthContext();
|
|
6741
6836
|
return this.httpClient.request(
|
|
6742
6837
|
`/api/v0/organizations/${organizationId}/deployments`,
|
|
6743
6838
|
{
|
|
6744
6839
|
method: "POST",
|
|
6745
|
-
body:
|
|
6840
|
+
body: command22
|
|
6746
6841
|
}
|
|
6747
6842
|
);
|
|
6748
6843
|
};
|
|
@@ -8512,8 +8607,8 @@ var ExecuteLinterProgramsUseCase = class {
|
|
|
8512
8607
|
this.linterAstAdapter = linterAstAdapter;
|
|
8513
8608
|
this.logger = logger2;
|
|
8514
8609
|
}
|
|
8515
|
-
async execute(
|
|
8516
|
-
const { filePath, fileContent, language, programs } =
|
|
8610
|
+
async execute(command22) {
|
|
8611
|
+
const { filePath, fileContent, language, programs } = command22;
|
|
8517
8612
|
if (programs.length === 0) {
|
|
8518
8613
|
return {
|
|
8519
8614
|
file: filePath,
|
|
@@ -9290,8 +9385,8 @@ var InstallPackagesUseCase = class {
|
|
|
9290
9385
|
constructor(packmindGateway) {
|
|
9291
9386
|
this.packmindGateway = packmindGateway;
|
|
9292
9387
|
}
|
|
9293
|
-
async execute(
|
|
9294
|
-
const baseDirectory =
|
|
9388
|
+
async execute(command22) {
|
|
9389
|
+
const baseDirectory = command22.baseDirectory || process.cwd();
|
|
9295
9390
|
const result = {
|
|
9296
9391
|
filesCreated: 0,
|
|
9297
9392
|
filesUpdated: 0,
|
|
@@ -9303,12 +9398,12 @@ var InstallPackagesUseCase = class {
|
|
|
9303
9398
|
skillDirectoriesDeleted: 0
|
|
9304
9399
|
};
|
|
9305
9400
|
const response = await this.packmindGateway.deployment.pull({
|
|
9306
|
-
packagesSlugs:
|
|
9307
|
-
previousPackagesSlugs:
|
|
9308
|
-
gitRemoteUrl:
|
|
9309
|
-
gitBranch:
|
|
9310
|
-
relativePath:
|
|
9311
|
-
agents:
|
|
9401
|
+
packagesSlugs: command22.packagesSlugs,
|
|
9402
|
+
previousPackagesSlugs: command22.previousPackagesSlugs,
|
|
9403
|
+
gitRemoteUrl: command22.gitRemoteUrl,
|
|
9404
|
+
gitBranch: command22.gitBranch,
|
|
9405
|
+
relativePath: command22.relativePath,
|
|
9406
|
+
agents: command22.agents
|
|
9312
9407
|
});
|
|
9313
9408
|
const filteredCreateOrUpdate = response.fileUpdates.createOrUpdate.filter(
|
|
9314
9409
|
(file) => file.path !== "packmind.json"
|
|
@@ -9594,8 +9689,8 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
9594
9689
|
constructor(repositories) {
|
|
9595
9690
|
this.repositories = repositories;
|
|
9596
9691
|
}
|
|
9597
|
-
async execute(
|
|
9598
|
-
const baseDirectory =
|
|
9692
|
+
async execute(command22) {
|
|
9693
|
+
const baseDirectory = command22.baseDirectory || process.cwd();
|
|
9599
9694
|
const result = {
|
|
9600
9695
|
filesCreated: 0,
|
|
9601
9696
|
filesUpdated: 0,
|
|
@@ -9605,8 +9700,8 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
9605
9700
|
const agents = config?.agents;
|
|
9606
9701
|
const response = await this.repositories.packmindGateway.skills.getDefaults(
|
|
9607
9702
|
{
|
|
9608
|
-
cliVersion:
|
|
9609
|
-
includeBeta:
|
|
9703
|
+
cliVersion: command22.cliVersion,
|
|
9704
|
+
includeBeta: command22.includeBeta,
|
|
9610
9705
|
agents
|
|
9611
9706
|
}
|
|
9612
9707
|
);
|
|
@@ -9671,8 +9766,8 @@ var GetPackageSummaryUseCase = class {
|
|
|
9671
9766
|
constructor(gateway) {
|
|
9672
9767
|
this.gateway = gateway;
|
|
9673
9768
|
}
|
|
9674
|
-
async execute(
|
|
9675
|
-
return this.gateway.packages.getSummary(
|
|
9769
|
+
async execute(command22) {
|
|
9770
|
+
return this.gateway.packages.getSummary(command22);
|
|
9676
9771
|
}
|
|
9677
9772
|
};
|
|
9678
9773
|
|
|
@@ -9863,10 +9958,10 @@ async function defaultPromptForCode() {
|
|
|
9863
9958
|
input: process.stdin,
|
|
9864
9959
|
output: process.stdout
|
|
9865
9960
|
});
|
|
9866
|
-
return new Promise((
|
|
9961
|
+
return new Promise((resolve9) => {
|
|
9867
9962
|
rl.question("Enter the login code from the browser: ", (answer) => {
|
|
9868
9963
|
rl.close();
|
|
9869
|
-
|
|
9964
|
+
resolve9(answer.trim());
|
|
9870
9965
|
});
|
|
9871
9966
|
});
|
|
9872
9967
|
}
|
|
@@ -9900,7 +9995,7 @@ async function defaultExchangeCodeForApiKey(code, host) {
|
|
|
9900
9995
|
return await response.json();
|
|
9901
9996
|
}
|
|
9902
9997
|
function defaultStartCallbackServer() {
|
|
9903
|
-
return new Promise((
|
|
9998
|
+
return new Promise((resolve9, reject) => {
|
|
9904
9999
|
let timeoutId = null;
|
|
9905
10000
|
const server = http.createServer((req, res) => {
|
|
9906
10001
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
@@ -9913,7 +10008,7 @@ function defaultStartCallbackServer() {
|
|
|
9913
10008
|
if (timeoutId) {
|
|
9914
10009
|
clearTimeout(timeoutId);
|
|
9915
10010
|
}
|
|
9916
|
-
|
|
10011
|
+
resolve9(code);
|
|
9917
10012
|
setImmediate(() => {
|
|
9918
10013
|
server.close();
|
|
9919
10014
|
});
|
|
@@ -9951,8 +10046,8 @@ var LoginUseCase = class {
|
|
|
9951
10046
|
startCallbackServer: deps?.startCallbackServer ?? defaultStartCallbackServer
|
|
9952
10047
|
};
|
|
9953
10048
|
}
|
|
9954
|
-
async execute(
|
|
9955
|
-
const { host, code: providedCode } =
|
|
10049
|
+
async execute(command22) {
|
|
10050
|
+
const { host, code: providedCode } = command22;
|
|
9956
10051
|
let code;
|
|
9957
10052
|
if (providedCode) {
|
|
9958
10053
|
code = providedCode;
|
|
@@ -9990,8 +10085,8 @@ var LogoutUseCase = class {
|
|
|
9990
10085
|
constructor(deps) {
|
|
9991
10086
|
this.deps = {
|
|
9992
10087
|
getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
|
|
9993
|
-
fileExists: deps?.fileExists ?? ((
|
|
9994
|
-
deleteFile: deps?.deleteFile ?? ((
|
|
10088
|
+
fileExists: deps?.fileExists ?? ((path22) => fs7.existsSync(path22)),
|
|
10089
|
+
deleteFile: deps?.deleteFile ?? ((path22) => fs7.unlinkSync(path22)),
|
|
9995
10090
|
hasEnvVar: deps?.hasEnvVar ?? (() => !!process.env[ENV_VAR_NAME2])
|
|
9996
10091
|
};
|
|
9997
10092
|
}
|
|
@@ -10051,8 +10146,8 @@ var SetupMcpUseCase = class {
|
|
|
10051
10146
|
constructor(deps) {
|
|
10052
10147
|
this.deps = deps;
|
|
10053
10148
|
}
|
|
10054
|
-
async execute(
|
|
10055
|
-
const { agentTypes } =
|
|
10149
|
+
async execute(command22) {
|
|
10150
|
+
const { agentTypes } = command22;
|
|
10056
10151
|
const [tokenResult, urlResult] = await Promise.all([
|
|
10057
10152
|
this.deps.gateway.mcp.getToken({}),
|
|
10058
10153
|
this.deps.gateway.mcp.getUrl({})
|
|
@@ -10123,9 +10218,9 @@ var McpConfigService = class {
|
|
|
10123
10218
|
return JSON.stringify(mcpConfig, null, 2);
|
|
10124
10219
|
}
|
|
10125
10220
|
installClaudeMcp(config) {
|
|
10126
|
-
const
|
|
10221
|
+
const command22 = `claude mcp add --transport http packmind ${config.url} --header "Authorization: Bearer ${config.accessToken}"`;
|
|
10127
10222
|
try {
|
|
10128
|
-
(0, import_child_process2.execSync)(
|
|
10223
|
+
(0, import_child_process2.execSync)(command22, { stdio: "pipe" });
|
|
10129
10224
|
return { success: true };
|
|
10130
10225
|
} catch (error) {
|
|
10131
10226
|
const execError = error;
|
|
@@ -10622,6 +10717,11 @@ var import_promises = __toESM(require("fs/promises"));
|
|
|
10622
10717
|
var import_path2 = __toESM(require("path"));
|
|
10623
10718
|
var import_minimatch3 = require("minimatch");
|
|
10624
10719
|
|
|
10720
|
+
// apps/cli/src/application/utils/normalizeLineEndings.ts
|
|
10721
|
+
function normalizeLineEndings(content) {
|
|
10722
|
+
return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10723
|
+
}
|
|
10724
|
+
|
|
10625
10725
|
// apps/cli/src/infra/utils/binaryDetection.ts
|
|
10626
10726
|
var path10 = __toESM(require("path"));
|
|
10627
10727
|
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -10699,9 +10799,6 @@ function normalizePath2(filePath) {
|
|
|
10699
10799
|
}
|
|
10700
10800
|
return normalized;
|
|
10701
10801
|
}
|
|
10702
|
-
function normalizeLineEndings(content) {
|
|
10703
|
-
return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10704
|
-
}
|
|
10705
10802
|
var MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
10706
10803
|
var MAX_FILE_SIZE_MB = 10;
|
|
10707
10804
|
var BLACKLIST_PATTERNS = ["**/.DS_Store"];
|
|
@@ -10760,8 +10857,8 @@ var UploadSkillUseCase = class {
|
|
|
10760
10857
|
constructor(deps) {
|
|
10761
10858
|
this.deps = deps;
|
|
10762
10859
|
}
|
|
10763
|
-
async execute(
|
|
10764
|
-
const files = await readSkillDirectory(
|
|
10860
|
+
async execute(command22) {
|
|
10861
|
+
const files = await readSkillDirectory(command22.skillPath);
|
|
10765
10862
|
if (!files.find((f) => f.relativePath === "SKILL.md")) {
|
|
10766
10863
|
throw new Error("SKILL.md not found in skill directory");
|
|
10767
10864
|
}
|
|
@@ -10787,7 +10884,7 @@ var UploadSkillUseCase = class {
|
|
|
10787
10884
|
const uploadSkillResponse = await this.deps.gateway.skills.upload({
|
|
10788
10885
|
spaceId: createSpaceId(space.id),
|
|
10789
10886
|
files: payload.files,
|
|
10790
|
-
originSkill:
|
|
10887
|
+
originSkill: command22.originSkill
|
|
10791
10888
|
});
|
|
10792
10889
|
return {
|
|
10793
10890
|
skillId: uploadSkillResponse.skill.id,
|
|
@@ -10802,13 +10899,14 @@ var UploadSkillUseCase = class {
|
|
|
10802
10899
|
};
|
|
10803
10900
|
|
|
10804
10901
|
// apps/cli/src/application/useCases/diffStrategies/CommandDiffStrategy.ts
|
|
10805
|
-
var
|
|
10902
|
+
var import_diff2 = require("diff");
|
|
10806
10903
|
var fs11 = __toESM(require("fs/promises"));
|
|
10807
10904
|
var path12 = __toESM(require("path"));
|
|
10808
10905
|
|
|
10809
10906
|
// apps/cli/src/application/utils/stripFrontmatter.ts
|
|
10810
10907
|
var FRONTMATTER_DELIMITER2 = "---";
|
|
10811
10908
|
function stripFrontmatter(content) {
|
|
10909
|
+
content = normalizeLineEndings(content);
|
|
10812
10910
|
if (!content.startsWith(`${FRONTMATTER_DELIMITER2}
|
|
10813
10911
|
`)) {
|
|
10814
10912
|
return content;
|
|
@@ -10839,7 +10937,7 @@ var CommandDiffStrategy = class {
|
|
|
10839
10937
|
}
|
|
10840
10938
|
const serverBody = stripFrontmatter(file.content);
|
|
10841
10939
|
const localBody = stripFrontmatter(localContent);
|
|
10842
|
-
const changes = (0,
|
|
10940
|
+
const changes = (0, import_diff2.diffLines)(serverBody, localBody);
|
|
10843
10941
|
const hasDifferences = changes.some(
|
|
10844
10942
|
(change) => change.added || change.removed
|
|
10845
10943
|
);
|
|
@@ -10864,7 +10962,7 @@ var CommandDiffStrategy = class {
|
|
|
10864
10962
|
};
|
|
10865
10963
|
|
|
10866
10964
|
// apps/cli/src/application/useCases/diffStrategies/SkillDiffStrategy.ts
|
|
10867
|
-
var
|
|
10965
|
+
var import_diff3 = require("diff");
|
|
10868
10966
|
var fs12 = __toESM(require("fs/promises"));
|
|
10869
10967
|
var path13 = __toESM(require("path"));
|
|
10870
10968
|
var SkillDiffStrategy = class {
|
|
@@ -10936,7 +11034,7 @@ var SkillDiffStrategy = class {
|
|
|
10936
11034
|
if (!serverParsed || !localParsed) {
|
|
10937
11035
|
const serverBody = stripFrontmatter(file.content);
|
|
10938
11036
|
const localBody = stripFrontmatter(localContent);
|
|
10939
|
-
const changes = (0,
|
|
11037
|
+
const changes = (0, import_diff3.diffLines)(serverBody, localBody);
|
|
10940
11038
|
const hasDifferences = changes.some(
|
|
10941
11039
|
(change) => change.added || change.removed
|
|
10942
11040
|
);
|
|
@@ -11253,7 +11351,18 @@ function parseStandardMd(content, filePath) {
|
|
|
11253
11351
|
}
|
|
11254
11352
|
return deployer.parse(content);
|
|
11255
11353
|
}
|
|
11354
|
+
var AGENT_PARSERS = {
|
|
11355
|
+
packmind: parsePackmindStandard,
|
|
11356
|
+
claude: parseClaudeStandard,
|
|
11357
|
+
cursor: parseCursorStandard,
|
|
11358
|
+
continue: parseContinueStandard,
|
|
11359
|
+
copilot: parseCopilotStandard
|
|
11360
|
+
};
|
|
11361
|
+
function parseStandardMdForAgent(content, agent) {
|
|
11362
|
+
return AGENT_PARSERS[agent](content);
|
|
11363
|
+
}
|
|
11256
11364
|
function parsePackmindStandard(content) {
|
|
11365
|
+
content = normalizeLineEndings(content);
|
|
11257
11366
|
const lines = content.split("\n");
|
|
11258
11367
|
let name = null;
|
|
11259
11368
|
let nameLineIndex = -1;
|
|
@@ -11303,7 +11412,7 @@ function parsePackmindStandard(content) {
|
|
|
11303
11412
|
}
|
|
11304
11413
|
function parseClaudeStandard(content) {
|
|
11305
11414
|
const { frontmatter, body } = extractFrontmatter(content);
|
|
11306
|
-
const scope = extractScopeFromKey(frontmatter, "paths");
|
|
11415
|
+
const scope = extractScopeFromKey(frontmatter, "paths") || extractScopeFromKey(frontmatter, "globs");
|
|
11307
11416
|
const parsed = parseIdeStandardBody(body, scope);
|
|
11308
11417
|
if (!parsed) return null;
|
|
11309
11418
|
return addFrontmatterFields(parsed, frontmatter);
|
|
@@ -11350,6 +11459,7 @@ function extractRulesList(lines, startIndex) {
|
|
|
11350
11459
|
return rules;
|
|
11351
11460
|
}
|
|
11352
11461
|
function extractFrontmatter(content) {
|
|
11462
|
+
content = normalizeLineEndings(content);
|
|
11353
11463
|
const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
11354
11464
|
if (!match) {
|
|
11355
11465
|
return { frontmatter: "", body: content };
|
|
@@ -11424,8 +11534,17 @@ function stripYamlQuotes(value) {
|
|
|
11424
11534
|
}
|
|
11425
11535
|
function extractScopeFromKey(frontmatter, key) {
|
|
11426
11536
|
const rawValue = extractFrontmatterValue(frontmatter, key);
|
|
11427
|
-
if (
|
|
11428
|
-
|
|
11537
|
+
if (rawValue) return normalizeScopeValue(rawValue);
|
|
11538
|
+
const lines = frontmatter.split("\n");
|
|
11539
|
+
const keyIndex = lines.findIndex((l) => l.trim() === `${key}:`);
|
|
11540
|
+
if (keyIndex === -1) return "";
|
|
11541
|
+
const items = [];
|
|
11542
|
+
for (let i = keyIndex + 1; i < lines.length; i++) {
|
|
11543
|
+
const match = lines[i].match(/^ +-\s(.+)$/);
|
|
11544
|
+
if (!match) break;
|
|
11545
|
+
items.push(stripYamlQuotes(match[1].trim()));
|
|
11546
|
+
}
|
|
11547
|
+
return items.join(", ");
|
|
11429
11548
|
}
|
|
11430
11549
|
function normalizeScopeValue(rawValue) {
|
|
11431
11550
|
if (!rawValue) return "";
|
|
@@ -11633,14 +11752,14 @@ var DiffArtefactsUseCase = class {
|
|
|
11633
11752
|
new StandardDiffStrategy()
|
|
11634
11753
|
];
|
|
11635
11754
|
}
|
|
11636
|
-
async execute(
|
|
11637
|
-
const baseDirectory =
|
|
11755
|
+
async execute(command22) {
|
|
11756
|
+
const baseDirectory = command22.baseDirectory || process.cwd();
|
|
11638
11757
|
const response = await this.packmindGateway.deployment.getDeployed({
|
|
11639
|
-
packagesSlugs:
|
|
11640
|
-
gitRemoteUrl:
|
|
11641
|
-
gitBranch:
|
|
11642
|
-
relativePath:
|
|
11643
|
-
agents:
|
|
11758
|
+
packagesSlugs: command22.packagesSlugs,
|
|
11759
|
+
gitRemoteUrl: command22.gitRemoteUrl,
|
|
11760
|
+
gitBranch: command22.gitBranch,
|
|
11761
|
+
relativePath: command22.relativePath,
|
|
11762
|
+
agents: command22.agents
|
|
11644
11763
|
});
|
|
11645
11764
|
const filteredFiles = response.fileUpdates.createOrUpdate.filter(
|
|
11646
11765
|
(file) => file.path !== "packmind.json"
|
|
@@ -11654,7 +11773,7 @@ var DiffArtefactsUseCase = class {
|
|
|
11654
11773
|
);
|
|
11655
11774
|
const prefixedSkillFolders = this.prefixSkillFolders(
|
|
11656
11775
|
response.skillFolders,
|
|
11657
|
-
|
|
11776
|
+
command22.relativePath
|
|
11658
11777
|
);
|
|
11659
11778
|
const diffs = [];
|
|
11660
11779
|
for (const file of diffableFiles) {
|
|
@@ -11690,12 +11809,17 @@ var DiffArtefactsUseCase = class {
|
|
|
11690
11809
|
|
|
11691
11810
|
// apps/cli/src/application/useCases/SubmitDiffsUseCase.ts
|
|
11692
11811
|
var SUPPORTED_ARTIFACT_TYPES = /* @__PURE__ */ new Set(["command", "skill", "standard"]);
|
|
11812
|
+
var CREATION_TYPES = /* @__PURE__ */ new Set([
|
|
11813
|
+
"createStandard" /* createStandard */,
|
|
11814
|
+
"createCommand" /* createCommand */,
|
|
11815
|
+
"createSkill" /* createSkill */
|
|
11816
|
+
]);
|
|
11693
11817
|
var SubmitDiffsUseCase = class {
|
|
11694
11818
|
constructor(packmindGateway) {
|
|
11695
11819
|
this.packmindGateway = packmindGateway;
|
|
11696
11820
|
}
|
|
11697
|
-
async execute(
|
|
11698
|
-
const { groupedDiffs, message } =
|
|
11821
|
+
async execute(command22) {
|
|
11822
|
+
const { groupedDiffs, message } = command22;
|
|
11699
11823
|
const skipped = [];
|
|
11700
11824
|
const validDiffs = [];
|
|
11701
11825
|
for (const group of groupedDiffs) {
|
|
@@ -11711,7 +11835,14 @@ var SubmitDiffsUseCase = class {
|
|
|
11711
11835
|
continue;
|
|
11712
11836
|
}
|
|
11713
11837
|
for (const diff of group) {
|
|
11714
|
-
if (!diff.
|
|
11838
|
+
if (!diff.spaceId) {
|
|
11839
|
+
skipped.push({
|
|
11840
|
+
name: diff.artifactName,
|
|
11841
|
+
reason: "Missing artifact metadata"
|
|
11842
|
+
});
|
|
11843
|
+
continue;
|
|
11844
|
+
}
|
|
11845
|
+
if (!diff.artifactId && !CREATION_TYPES.has(diff.type)) {
|
|
11715
11846
|
skipped.push({
|
|
11716
11847
|
name: diff.artifactName,
|
|
11717
11848
|
reason: "Missing artifact metadata"
|
|
@@ -11735,7 +11866,7 @@ var SubmitDiffsUseCase = class {
|
|
|
11735
11866
|
spaceId,
|
|
11736
11867
|
proposals: diffs.map((diff) => ({
|
|
11737
11868
|
type: diff.type,
|
|
11738
|
-
artefactId: diff.artifactId,
|
|
11869
|
+
artefactId: CREATION_TYPES.has(diff.type) ? null : diff.artifactId,
|
|
11739
11870
|
payload: diff.payload,
|
|
11740
11871
|
captureMode: "commit" /* commit */,
|
|
11741
11872
|
message
|
|
@@ -11762,8 +11893,8 @@ var CheckDiffsUseCase = class {
|
|
|
11762
11893
|
constructor(packmindGateway) {
|
|
11763
11894
|
this.packmindGateway = packmindGateway;
|
|
11764
11895
|
}
|
|
11765
|
-
async execute(
|
|
11766
|
-
const { groupedDiffs } =
|
|
11896
|
+
async execute(command22) {
|
|
11897
|
+
const { groupedDiffs } = command22;
|
|
11767
11898
|
const results = [];
|
|
11768
11899
|
const validDiffs = [];
|
|
11769
11900
|
const invalidDiffs = [];
|
|
@@ -11881,9 +12012,9 @@ var PackmindCliHexaFactory = class {
|
|
|
11881
12012
|
var origin8 = "PackmindCliHexa";
|
|
11882
12013
|
var PackmindCliHexa = class {
|
|
11883
12014
|
constructor(logger2 = new PackmindLogger(origin8)) {
|
|
11884
|
-
this.notifyDistribution = async (
|
|
12015
|
+
this.notifyDistribution = async (command22) => {
|
|
11885
12016
|
return this.hexa.repositories.packmindGateway.deployment.notifyDistribution(
|
|
11886
|
-
|
|
12017
|
+
command22
|
|
11887
12018
|
);
|
|
11888
12019
|
};
|
|
11889
12020
|
this.logger = logger2;
|
|
@@ -11903,26 +12034,26 @@ var PackmindCliHexa = class {
|
|
|
11903
12034
|
this.logger.info("Destroying PackmindCliHexa");
|
|
11904
12035
|
this.logger.info("PackmindCliHexa destroyed");
|
|
11905
12036
|
}
|
|
11906
|
-
async getGitRemoteUrl(
|
|
11907
|
-
return this.hexa.useCases.getGitRemoteUrl.execute(
|
|
12037
|
+
async getGitRemoteUrl(command22) {
|
|
12038
|
+
return this.hexa.useCases.getGitRemoteUrl.execute(command22);
|
|
11908
12039
|
}
|
|
11909
|
-
async executeSingleFileAst(
|
|
11910
|
-
return this.hexa.useCases.executeSingleFileAst.execute(
|
|
12040
|
+
async executeSingleFileAst(command22) {
|
|
12041
|
+
return this.hexa.useCases.executeSingleFileAst.execute(command22);
|
|
11911
12042
|
}
|
|
11912
|
-
async listFilesInDirectory(
|
|
11913
|
-
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(
|
|
12043
|
+
async listFilesInDirectory(command22) {
|
|
12044
|
+
return this.hexa.useCases.listFilesInDirectoryUseCase.execute(command22);
|
|
11914
12045
|
}
|
|
11915
|
-
async lintFilesAgainstRule(
|
|
11916
|
-
return this.hexa.useCases.lintFilesAgainstRule.execute(
|
|
12046
|
+
async lintFilesAgainstRule(command22) {
|
|
12047
|
+
return this.hexa.useCases.lintFilesAgainstRule.execute(command22);
|
|
11917
12048
|
}
|
|
11918
|
-
async lintFilesFromConfig(
|
|
11919
|
-
return this.hexa.useCases.lintFilesFromConfig.execute(
|
|
12049
|
+
async lintFilesFromConfig(command22) {
|
|
12050
|
+
return this.hexa.useCases.lintFilesFromConfig.execute(command22);
|
|
11920
12051
|
}
|
|
11921
|
-
async installPackages(
|
|
11922
|
-
return this.hexa.useCases.installPackages.execute(
|
|
12052
|
+
async installPackages(command22) {
|
|
12053
|
+
return this.hexa.useCases.installPackages.execute(command22);
|
|
11923
12054
|
}
|
|
11924
|
-
async diffArtefacts(
|
|
11925
|
-
return this.hexa.useCases.diffArtefacts.execute(
|
|
12055
|
+
async diffArtefacts(command22) {
|
|
12056
|
+
return this.hexa.useCases.diffArtefacts.execute(command22);
|
|
11926
12057
|
}
|
|
11927
12058
|
async submitDiffs(groupedDiffs, message) {
|
|
11928
12059
|
return this.hexa.useCases.submitDiffs.execute({ groupedDiffs, message });
|
|
@@ -11930,20 +12061,20 @@ var PackmindCliHexa = class {
|
|
|
11930
12061
|
async checkDiffs(groupedDiffs) {
|
|
11931
12062
|
return this.hexa.useCases.checkDiffs.execute({ groupedDiffs });
|
|
11932
12063
|
}
|
|
11933
|
-
async listPackages(
|
|
11934
|
-
return this.hexa.useCases.listPackages.execute(
|
|
12064
|
+
async listPackages(command22) {
|
|
12065
|
+
return this.hexa.useCases.listPackages.execute(command22);
|
|
11935
12066
|
}
|
|
11936
|
-
async getPackageBySlug(
|
|
11937
|
-
return this.hexa.useCases.getPackageBySlug.execute(
|
|
12067
|
+
async getPackageBySlug(command22) {
|
|
12068
|
+
return this.hexa.useCases.getPackageBySlug.execute(command22);
|
|
11938
12069
|
}
|
|
11939
|
-
async listStandards(
|
|
11940
|
-
return this.hexa.useCases.listStandards.execute(
|
|
12070
|
+
async listStandards(command22) {
|
|
12071
|
+
return this.hexa.useCases.listStandards.execute(command22);
|
|
11941
12072
|
}
|
|
11942
|
-
async listCommands(
|
|
11943
|
-
return this.hexa.useCases.listCommands.execute(
|
|
12073
|
+
async listCommands(command22) {
|
|
12074
|
+
return this.hexa.useCases.listCommands.execute(command22);
|
|
11944
12075
|
}
|
|
11945
|
-
async listSkills(
|
|
11946
|
-
return this.hexa.useCases.listSkills.execute(
|
|
12076
|
+
async listSkills(command22) {
|
|
12077
|
+
return this.hexa.useCases.listSkills.execute(command22);
|
|
11947
12078
|
}
|
|
11948
12079
|
async configExists(baseDirectory) {
|
|
11949
12080
|
return await this.hexa.repositories.configFileRepository.configExists(
|
|
@@ -12030,17 +12161,17 @@ var PackmindCliHexa = class {
|
|
|
12030
12161
|
directory
|
|
12031
12162
|
);
|
|
12032
12163
|
}
|
|
12033
|
-
async login(
|
|
12034
|
-
return this.hexa.useCases.login.execute(
|
|
12164
|
+
async login(command22) {
|
|
12165
|
+
return this.hexa.useCases.login.execute(command22);
|
|
12035
12166
|
}
|
|
12036
|
-
async logout(
|
|
12037
|
-
return this.hexa.useCases.logout.execute(
|
|
12167
|
+
async logout(command22) {
|
|
12168
|
+
return this.hexa.useCases.logout.execute(command22);
|
|
12038
12169
|
}
|
|
12039
|
-
async whoami(
|
|
12040
|
-
return this.hexa.useCases.whoami.execute(
|
|
12170
|
+
async whoami(command22) {
|
|
12171
|
+
return this.hexa.useCases.whoami.execute(command22);
|
|
12041
12172
|
}
|
|
12042
|
-
async setupMcp(
|
|
12043
|
-
return this.hexa.useCases.setupMcp.execute(
|
|
12173
|
+
async setupMcp(command22) {
|
|
12174
|
+
return this.hexa.useCases.setupMcp.execute(command22);
|
|
12044
12175
|
}
|
|
12045
12176
|
getCurrentBranch(repoPath) {
|
|
12046
12177
|
return this.hexa.services.gitRemoteUrlService.getCurrentBranch(repoPath).branch;
|
|
@@ -12048,11 +12179,11 @@ var PackmindCliHexa = class {
|
|
|
12048
12179
|
getGitRemoteUrlFromPath(repoPath) {
|
|
12049
12180
|
return this.hexa.services.gitRemoteUrlService.getGitRemoteUrl(repoPath).gitRemoteUrl;
|
|
12050
12181
|
}
|
|
12051
|
-
async uploadSkill(
|
|
12052
|
-
return this.hexa.useCases.uploadSkill.execute(
|
|
12182
|
+
async uploadSkill(command22) {
|
|
12183
|
+
return this.hexa.useCases.uploadSkill.execute(command22);
|
|
12053
12184
|
}
|
|
12054
|
-
async installDefaultSkills(
|
|
12055
|
-
return this.hexa.useCases.installDefaultSkills.execute(
|
|
12185
|
+
async installDefaultSkills(command22) {
|
|
12186
|
+
return this.hexa.useCases.installDefaultSkills.execute(command22);
|
|
12056
12187
|
}
|
|
12057
12188
|
getPackmindGateway() {
|
|
12058
12189
|
return this.hexa.repositories.packmindGateway;
|
|
@@ -12164,7 +12295,7 @@ function isNotLoggedInError(error) {
|
|
|
12164
12295
|
}
|
|
12165
12296
|
async function lintHandler(args2, deps) {
|
|
12166
12297
|
const {
|
|
12167
|
-
path:
|
|
12298
|
+
path: path22,
|
|
12168
12299
|
draft,
|
|
12169
12300
|
rule,
|
|
12170
12301
|
language,
|
|
@@ -12185,7 +12316,7 @@ async function lintHandler(args2, deps) {
|
|
|
12185
12316
|
throw new Error("option --rule is required to use --draft mode");
|
|
12186
12317
|
}
|
|
12187
12318
|
const startedAt = Date.now();
|
|
12188
|
-
const targetPath =
|
|
12319
|
+
const targetPath = path22 ?? ".";
|
|
12189
12320
|
const absolutePath = resolvePath(targetPath);
|
|
12190
12321
|
if (diff) {
|
|
12191
12322
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(absolutePath);
|
|
@@ -12468,7 +12599,7 @@ function extractWasmFiles() {
|
|
|
12468
12599
|
// apps/cli/src/main.ts
|
|
12469
12600
|
var import_dotenv = require("dotenv");
|
|
12470
12601
|
var fs19 = __toESM(require("fs"));
|
|
12471
|
-
var
|
|
12602
|
+
var path21 = __toESM(require("path"));
|
|
12472
12603
|
|
|
12473
12604
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
12474
12605
|
var import_cmd_ts2 = __toESM(require_cjs());
|
|
@@ -13587,10 +13718,10 @@ var AgentDetectionService = class {
|
|
|
13587
13718
|
const continueDir = path15.join(this.projectDir, ".continue");
|
|
13588
13719
|
return fs14.existsSync(continueDir);
|
|
13589
13720
|
}
|
|
13590
|
-
isCommandAvailable(
|
|
13721
|
+
isCommandAvailable(command22) {
|
|
13591
13722
|
try {
|
|
13592
13723
|
const whichCommand = process.platform === "win32" ? "where" : "which";
|
|
13593
|
-
(0, import_child_process3.execSync)(`${whichCommand} ${
|
|
13724
|
+
(0, import_child_process3.execSync)(`${whichCommand} ${command22}`, { stdio: "pipe" });
|
|
13594
13725
|
return true;
|
|
13595
13726
|
} catch {
|
|
13596
13727
|
return false;
|
|
@@ -13639,7 +13770,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
13639
13770
|
output.write("\n");
|
|
13640
13771
|
const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
|
|
13641
13772
|
const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
|
|
13642
|
-
return new Promise((
|
|
13773
|
+
return new Promise((resolve9) => {
|
|
13643
13774
|
rl.question(
|
|
13644
13775
|
`Enter numbers separated by commas (default: ${defaultValue}): `,
|
|
13645
13776
|
(answer) => {
|
|
@@ -13650,7 +13781,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
13650
13781
|
const numbersStr = trimmed === "" ? defaultValue : trimmed;
|
|
13651
13782
|
const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
|
|
13652
13783
|
const selectedAgents = numbers.map((n) => choices[n - 1].value);
|
|
13653
|
-
|
|
13784
|
+
resolve9(selectedAgents);
|
|
13654
13785
|
}
|
|
13655
13786
|
);
|
|
13656
13787
|
});
|
|
@@ -14415,7 +14546,7 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
14415
14546
|
}
|
|
14416
14547
|
async execute(playbook) {
|
|
14417
14548
|
const space = await this.gateway.spaces.getGlobal();
|
|
14418
|
-
const
|
|
14549
|
+
const command22 = await this.gateway.commands.create({
|
|
14419
14550
|
spaceId: space.id,
|
|
14420
14551
|
name: playbook.name,
|
|
14421
14552
|
summary: playbook.summary,
|
|
@@ -14429,9 +14560,9 @@ var CreateCommandFromPlaybookUseCase = class {
|
|
|
14429
14560
|
originSkill: playbook.originSkill
|
|
14430
14561
|
});
|
|
14431
14562
|
return {
|
|
14432
|
-
commandId:
|
|
14433
|
-
name:
|
|
14434
|
-
slug:
|
|
14563
|
+
commandId: command22.id,
|
|
14564
|
+
name: command22.name,
|
|
14565
|
+
slug: command22.slug
|
|
14435
14566
|
};
|
|
14436
14567
|
}
|
|
14437
14568
|
};
|
|
@@ -14559,13 +14690,14 @@ var commandsCommand = (0, import_cmd_ts18.subcommands)({
|
|
|
14559
14690
|
});
|
|
14560
14691
|
|
|
14561
14692
|
// apps/cli/src/infra/commands/DiffCommand.ts
|
|
14693
|
+
var import_fs20 = require("fs");
|
|
14562
14694
|
var import_cmd_ts19 = __toESM(require_cjs());
|
|
14563
14695
|
|
|
14564
14696
|
// apps/cli/src/infra/utils/diffFormatter.ts
|
|
14565
|
-
var
|
|
14697
|
+
var import_diff4 = require("diff");
|
|
14566
14698
|
init_source();
|
|
14567
14699
|
function formatContentDiff(oldContent, newContent) {
|
|
14568
|
-
const changes = (0,
|
|
14700
|
+
const changes = (0, import_diff4.diffLines)(oldContent, newContent);
|
|
14569
14701
|
const lines = [];
|
|
14570
14702
|
for (const change of changes) {
|
|
14571
14703
|
const trimmedValue = change.value.replace(/\n$/, "");
|
|
@@ -15049,6 +15181,593 @@ async function diffArtefactsHandler(deps) {
|
|
|
15049
15181
|
}
|
|
15050
15182
|
}
|
|
15051
15183
|
|
|
15184
|
+
// apps/cli/src/infra/commands/diffAddHandler.ts
|
|
15185
|
+
var path17 = __toESM(require("path"));
|
|
15186
|
+
|
|
15187
|
+
// apps/cli/src/application/utils/resolveArtefactFromPath.ts
|
|
15188
|
+
function resolveArtefactFromPath(filePath) {
|
|
15189
|
+
const normalized = normalizePath(filePath);
|
|
15190
|
+
for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
|
|
15191
|
+
if (paths.command && normalized.includes(paths.command)) {
|
|
15192
|
+
return {
|
|
15193
|
+
artifactType: "command",
|
|
15194
|
+
codingAgent: agent
|
|
15195
|
+
};
|
|
15196
|
+
}
|
|
15197
|
+
}
|
|
15198
|
+
for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
|
|
15199
|
+
if (paths.standard && normalized.includes(paths.standard)) {
|
|
15200
|
+
return {
|
|
15201
|
+
artifactType: "standard",
|
|
15202
|
+
codingAgent: agent
|
|
15203
|
+
};
|
|
15204
|
+
}
|
|
15205
|
+
}
|
|
15206
|
+
for (const [agent, paths] of Object.entries(CODING_AGENT_ARTEFACT_PATHS)) {
|
|
15207
|
+
if (paths.skill && normalized.includes(paths.skill)) {
|
|
15208
|
+
return {
|
|
15209
|
+
artifactType: "skill",
|
|
15210
|
+
codingAgent: agent
|
|
15211
|
+
};
|
|
15212
|
+
}
|
|
15213
|
+
}
|
|
15214
|
+
return null;
|
|
15215
|
+
}
|
|
15216
|
+
|
|
15217
|
+
// apps/cli/src/application/utils/parseCommandFile.ts
|
|
15218
|
+
var path16 = __toESM(require("path"));
|
|
15219
|
+
var FRONTMATTER_DELIMITER3 = "---";
|
|
15220
|
+
function parseCommandFile(content, filePath) {
|
|
15221
|
+
content = normalizeLineEndings(content);
|
|
15222
|
+
if (!content || content.trim().length === 0) {
|
|
15223
|
+
return { success: false, error: "File is empty" };
|
|
15224
|
+
}
|
|
15225
|
+
if (content.startsWith(`${FRONTMATTER_DELIMITER3}
|
|
15226
|
+
`)) {
|
|
15227
|
+
const contentAfterOpening = content.slice(FRONTMATTER_DELIMITER3.length + 1);
|
|
15228
|
+
const closingIndex = contentAfterOpening.indexOf(
|
|
15229
|
+
`
|
|
15230
|
+
${FRONTMATTER_DELIMITER3}`
|
|
15231
|
+
);
|
|
15232
|
+
if (closingIndex === -1) {
|
|
15233
|
+
return {
|
|
15234
|
+
success: false,
|
|
15235
|
+
error: "Malformed frontmatter: opening --- without closing ---"
|
|
15236
|
+
};
|
|
15237
|
+
}
|
|
15238
|
+
const frontmatter = contentAfterOpening.slice(0, closingIndex);
|
|
15239
|
+
const name2 = resolveName(frontmatter, filePath);
|
|
15240
|
+
return { success: true, parsed: { name: name2, content } };
|
|
15241
|
+
}
|
|
15242
|
+
const name = humanizeSlug(extractFilenameSlug(filePath));
|
|
15243
|
+
return { success: true, parsed: { name, content } };
|
|
15244
|
+
}
|
|
15245
|
+
function resolveName(frontmatter, filePath) {
|
|
15246
|
+
const nameValue = extractFrontmatterValue2(frontmatter, "name");
|
|
15247
|
+
if (nameValue) return nameValue;
|
|
15248
|
+
return humanizeSlug(extractFilenameSlug(filePath));
|
|
15249
|
+
}
|
|
15250
|
+
function extractFrontmatterValue2(frontmatter, key) {
|
|
15251
|
+
for (const line of frontmatter.split("\n")) {
|
|
15252
|
+
const trimmed = line.trim();
|
|
15253
|
+
if (trimmed.startsWith(`${key}:`)) {
|
|
15254
|
+
const raw = trimmed.slice(key.length + 1).trim();
|
|
15255
|
+
return stripYamlQuotes2(raw);
|
|
15256
|
+
}
|
|
15257
|
+
}
|
|
15258
|
+
return "";
|
|
15259
|
+
}
|
|
15260
|
+
function stripYamlQuotes2(value) {
|
|
15261
|
+
if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
|
|
15262
|
+
return value.slice(1, -1).replace(/''/g, "'");
|
|
15263
|
+
}
|
|
15264
|
+
if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
|
|
15265
|
+
return value.slice(1, -1);
|
|
15266
|
+
}
|
|
15267
|
+
return value;
|
|
15268
|
+
}
|
|
15269
|
+
function extractFilenameSlug(filePath) {
|
|
15270
|
+
let basename2 = path16.basename(filePath);
|
|
15271
|
+
if (basename2.endsWith(".prompt.md")) {
|
|
15272
|
+
basename2 = basename2.slice(0, -".prompt.md".length);
|
|
15273
|
+
} else if (basename2.endsWith(".md")) {
|
|
15274
|
+
basename2 = basename2.slice(0, -".md".length);
|
|
15275
|
+
}
|
|
15276
|
+
return basename2;
|
|
15277
|
+
}
|
|
15278
|
+
function humanizeSlug(slug) {
|
|
15279
|
+
const words = slug.replace(/[-_]/g, " ");
|
|
15280
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
15281
|
+
}
|
|
15282
|
+
|
|
15283
|
+
// apps/cli/src/application/utils/parseSkillDirectory.ts
|
|
15284
|
+
var SKILL_MD_FILENAME = "SKILL.md";
|
|
15285
|
+
function parseSkillDirectory(files) {
|
|
15286
|
+
const skillMdFile = files.find((f) => f.relativePath === SKILL_MD_FILENAME);
|
|
15287
|
+
if (!skillMdFile) {
|
|
15288
|
+
return {
|
|
15289
|
+
success: false,
|
|
15290
|
+
error: "Skill directory does not contain a SKILL.md file."
|
|
15291
|
+
};
|
|
15292
|
+
}
|
|
15293
|
+
const parsed = parseSkillMdContent(skillMdFile.content);
|
|
15294
|
+
if (!parsed) {
|
|
15295
|
+
return {
|
|
15296
|
+
success: false,
|
|
15297
|
+
error: "Failed to parse SKILL.md: file must have valid YAML frontmatter."
|
|
15298
|
+
};
|
|
15299
|
+
}
|
|
15300
|
+
const { properties, body } = parsed;
|
|
15301
|
+
const name = properties.name;
|
|
15302
|
+
if (typeof name !== "string" || name.trim().length === 0) {
|
|
15303
|
+
return {
|
|
15304
|
+
success: false,
|
|
15305
|
+
error: 'SKILL.md is missing a required "name" property in frontmatter.'
|
|
15306
|
+
};
|
|
15307
|
+
}
|
|
15308
|
+
const description = properties.description;
|
|
15309
|
+
if (typeof description !== "string" || description.trim().length === 0) {
|
|
15310
|
+
return {
|
|
15311
|
+
success: false,
|
|
15312
|
+
error: 'SKILL.md is missing a required "description" property in frontmatter.'
|
|
15313
|
+
};
|
|
15314
|
+
}
|
|
15315
|
+
if (body.trim().length === 0) {
|
|
15316
|
+
return {
|
|
15317
|
+
success: false,
|
|
15318
|
+
error: "SKILL.md body (prompt) cannot be empty."
|
|
15319
|
+
};
|
|
15320
|
+
}
|
|
15321
|
+
const payload = {
|
|
15322
|
+
name: name.trim(),
|
|
15323
|
+
description: description.trim(),
|
|
15324
|
+
prompt: body,
|
|
15325
|
+
skillMdPermissions: skillMdFile.permissions
|
|
15326
|
+
};
|
|
15327
|
+
if (typeof properties.license === "string") {
|
|
15328
|
+
payload.license = properties.license;
|
|
15329
|
+
}
|
|
15330
|
+
if (typeof properties.compatibility === "string") {
|
|
15331
|
+
payload.compatibility = properties.compatibility;
|
|
15332
|
+
}
|
|
15333
|
+
if (typeof properties.allowedTools === "string") {
|
|
15334
|
+
payload.allowedTools = properties.allowedTools;
|
|
15335
|
+
}
|
|
15336
|
+
if (properties.metadata != null && typeof properties.metadata === "object") {
|
|
15337
|
+
payload.metadata = properties.metadata;
|
|
15338
|
+
}
|
|
15339
|
+
const supportingFiles = files.filter(
|
|
15340
|
+
(f) => f.relativePath !== SKILL_MD_FILENAME
|
|
15341
|
+
);
|
|
15342
|
+
payload.files = supportingFiles.map((f) => ({
|
|
15343
|
+
path: f.relativePath,
|
|
15344
|
+
content: f.content,
|
|
15345
|
+
permissions: f.permissions,
|
|
15346
|
+
isBase64: f.isBase64
|
|
15347
|
+
}));
|
|
15348
|
+
return { success: true, payload };
|
|
15349
|
+
}
|
|
15350
|
+
|
|
15351
|
+
// apps/cli/src/infra/commands/diffAddHandler.ts
|
|
15352
|
+
async function diffAddHandler(deps) {
|
|
15353
|
+
const {
|
|
15354
|
+
packmindCliHexa,
|
|
15355
|
+
filePath,
|
|
15356
|
+
message: messageFlag,
|
|
15357
|
+
exit,
|
|
15358
|
+
getCwd,
|
|
15359
|
+
readFile: readFile10,
|
|
15360
|
+
readSkillDirectory: readSkillDirectory2
|
|
15361
|
+
} = deps;
|
|
15362
|
+
if (!filePath) {
|
|
15363
|
+
logErrorConsole("Missing file path. Usage: packmind-cli diff add <path>");
|
|
15364
|
+
exit(1);
|
|
15365
|
+
return;
|
|
15366
|
+
}
|
|
15367
|
+
const absolutePath = path17.resolve(getCwd(), filePath);
|
|
15368
|
+
const artefactResult = resolveArtefactFromPath(absolutePath);
|
|
15369
|
+
if (!artefactResult) {
|
|
15370
|
+
logErrorConsole(
|
|
15371
|
+
`Unsupported file path: ${absolutePath}. File must be in a recognized artefact directory (command, standard, or skill).`
|
|
15372
|
+
);
|
|
15373
|
+
exit(1);
|
|
15374
|
+
return;
|
|
15375
|
+
}
|
|
15376
|
+
let diffResult;
|
|
15377
|
+
if (artefactResult.artifactType === "skill") {
|
|
15378
|
+
const dirPath = absolutePath.endsWith("SKILL.md") ? path17.dirname(absolutePath) : absolutePath;
|
|
15379
|
+
let files;
|
|
15380
|
+
try {
|
|
15381
|
+
files = await readSkillDirectory2(dirPath);
|
|
15382
|
+
} catch (err) {
|
|
15383
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
15384
|
+
logErrorConsole(`Failed to read skill directory: ${errorMessage}`);
|
|
15385
|
+
exit(1);
|
|
15386
|
+
return;
|
|
15387
|
+
}
|
|
15388
|
+
const parseResult = parseSkillDirectory(files);
|
|
15389
|
+
if (!parseResult.success) {
|
|
15390
|
+
logErrorConsole(parseResult.error);
|
|
15391
|
+
exit(1);
|
|
15392
|
+
return;
|
|
15393
|
+
}
|
|
15394
|
+
diffResult = {
|
|
15395
|
+
success: true,
|
|
15396
|
+
diff: {
|
|
15397
|
+
type: "createSkill" /* createSkill */,
|
|
15398
|
+
payload: parseResult.payload,
|
|
15399
|
+
artifactName: parseResult.payload.name,
|
|
15400
|
+
artifactType: "skill"
|
|
15401
|
+
}
|
|
15402
|
+
};
|
|
15403
|
+
} else {
|
|
15404
|
+
let content;
|
|
15405
|
+
try {
|
|
15406
|
+
content = readFile10(absolutePath);
|
|
15407
|
+
} catch (err) {
|
|
15408
|
+
if (isErrnoException(err) && err.code === "EISDIR") {
|
|
15409
|
+
logErrorConsole(
|
|
15410
|
+
`Path is a directory, not a file: ${absolutePath}. Please provide a path to an artefact file.`
|
|
15411
|
+
);
|
|
15412
|
+
} else {
|
|
15413
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
15414
|
+
logErrorConsole(`Failed to read file: ${errorMessage}`);
|
|
15415
|
+
}
|
|
15416
|
+
exit(1);
|
|
15417
|
+
return;
|
|
15418
|
+
}
|
|
15419
|
+
const buildResult = buildDiff(
|
|
15420
|
+
artefactResult.artifactType,
|
|
15421
|
+
content,
|
|
15422
|
+
absolutePath,
|
|
15423
|
+
artefactResult.codingAgent
|
|
15424
|
+
);
|
|
15425
|
+
if (!buildResult.success) {
|
|
15426
|
+
logErrorConsole(buildResult.error);
|
|
15427
|
+
exit(1);
|
|
15428
|
+
return;
|
|
15429
|
+
}
|
|
15430
|
+
diffResult = buildResult;
|
|
15431
|
+
}
|
|
15432
|
+
let message;
|
|
15433
|
+
if (messageFlag !== void 0) {
|
|
15434
|
+
const validation = validateMessage(messageFlag);
|
|
15435
|
+
if (!validation.valid) {
|
|
15436
|
+
logErrorConsole(validation.error);
|
|
15437
|
+
exit(1);
|
|
15438
|
+
return;
|
|
15439
|
+
}
|
|
15440
|
+
message = validation.message;
|
|
15441
|
+
} else if (process.stdin.isTTY) {
|
|
15442
|
+
const editorMessage = openEditorForMessage();
|
|
15443
|
+
const validation = validateMessage(editorMessage);
|
|
15444
|
+
if (!validation.valid) {
|
|
15445
|
+
logErrorConsole(
|
|
15446
|
+
"Aborting submission: empty message. Use -m to provide a message."
|
|
15447
|
+
);
|
|
15448
|
+
exit(1);
|
|
15449
|
+
return;
|
|
15450
|
+
}
|
|
15451
|
+
message = validation.message;
|
|
15452
|
+
} else {
|
|
15453
|
+
logErrorConsole(
|
|
15454
|
+
'Non-interactive mode requires -m flag. Usage: packmind-cli diff add <path> -m "your message"'
|
|
15455
|
+
);
|
|
15456
|
+
exit(1);
|
|
15457
|
+
return;
|
|
15458
|
+
}
|
|
15459
|
+
const space = await packmindCliHexa.getPackmindGateway().spaces.getGlobal();
|
|
15460
|
+
const diff = {
|
|
15461
|
+
...diffResult.diff,
|
|
15462
|
+
filePath: absolutePath,
|
|
15463
|
+
spaceId: space.id
|
|
15464
|
+
};
|
|
15465
|
+
const result = await packmindCliHexa.submitDiffs([[diff]], message);
|
|
15466
|
+
for (const err of result.errors) {
|
|
15467
|
+
logErrorConsole(`Failed to submit addition "${err.name}": ${err.message}`);
|
|
15468
|
+
}
|
|
15469
|
+
const summaryParts = [];
|
|
15470
|
+
if (result.submitted > 0) {
|
|
15471
|
+
summaryParts.push(`${result.submitted} submitted`);
|
|
15472
|
+
}
|
|
15473
|
+
if (result.alreadySubmitted > 0) {
|
|
15474
|
+
summaryParts.push(`${result.alreadySubmitted} already submitted`);
|
|
15475
|
+
}
|
|
15476
|
+
if (result.errors.length > 0) {
|
|
15477
|
+
const errorWord = result.errors.length === 1 ? "error" : "errors";
|
|
15478
|
+
summaryParts.push(`${result.errors.length} ${errorWord}`);
|
|
15479
|
+
}
|
|
15480
|
+
if (summaryParts.length > 0) {
|
|
15481
|
+
const summaryMessage = `Summary: ${summaryParts.join(", ")}`;
|
|
15482
|
+
if (result.errors.length === 0 && result.alreadySubmitted === 0) {
|
|
15483
|
+
logSuccessConsole(summaryMessage);
|
|
15484
|
+
} else if (result.errors.length > 0 && result.submitted > 0 || result.alreadySubmitted > 0) {
|
|
15485
|
+
logWarningConsole(summaryMessage);
|
|
15486
|
+
} else {
|
|
15487
|
+
logErrorConsole(summaryMessage);
|
|
15488
|
+
}
|
|
15489
|
+
}
|
|
15490
|
+
if (result.submitted > 0) {
|
|
15491
|
+
const truncatedMessage = message.length > 50 ? message.slice(0, 50) + "..." : message;
|
|
15492
|
+
logInfoConsole(`Message: "${truncatedMessage}"`);
|
|
15493
|
+
}
|
|
15494
|
+
if (result.errors.length > 0) {
|
|
15495
|
+
exit(1);
|
|
15496
|
+
return;
|
|
15497
|
+
}
|
|
15498
|
+
exit(0);
|
|
15499
|
+
}
|
|
15500
|
+
function buildDiff(artifactType, content, filePath, codingAgent) {
|
|
15501
|
+
if (artifactType === "command") {
|
|
15502
|
+
const parseResult = parseCommandFile(content, filePath);
|
|
15503
|
+
if (!parseResult.success) {
|
|
15504
|
+
return {
|
|
15505
|
+
success: false,
|
|
15506
|
+
error: `Failed to parse command file: ${parseResult.error}`
|
|
15507
|
+
};
|
|
15508
|
+
}
|
|
15509
|
+
return {
|
|
15510
|
+
success: true,
|
|
15511
|
+
diff: {
|
|
15512
|
+
type: "createCommand" /* createCommand */,
|
|
15513
|
+
payload: {
|
|
15514
|
+
name: parseResult.parsed.name,
|
|
15515
|
+
content: parseResult.parsed.content
|
|
15516
|
+
},
|
|
15517
|
+
artifactName: parseResult.parsed.name,
|
|
15518
|
+
artifactType: "command"
|
|
15519
|
+
}
|
|
15520
|
+
};
|
|
15521
|
+
}
|
|
15522
|
+
const parsed = parseStandardMdForAgent(content, codingAgent);
|
|
15523
|
+
if (!parsed) {
|
|
15524
|
+
return {
|
|
15525
|
+
success: false,
|
|
15526
|
+
error: `File format is invalid. It should be formatted like:
|
|
15527
|
+
|
|
15528
|
+
${getStandardFormatExample(codingAgent)}`
|
|
15529
|
+
};
|
|
15530
|
+
}
|
|
15531
|
+
if (parsed.rules.length === 0) {
|
|
15532
|
+
return {
|
|
15533
|
+
success: false,
|
|
15534
|
+
error: `Standard has no rules. Add at least one rule, formatted like:
|
|
15535
|
+
|
|
15536
|
+
${getStandardFormatExample(codingAgent)}`
|
|
15537
|
+
};
|
|
15538
|
+
}
|
|
15539
|
+
return {
|
|
15540
|
+
success: true,
|
|
15541
|
+
diff: {
|
|
15542
|
+
type: "createStandard" /* createStandard */,
|
|
15543
|
+
payload: {
|
|
15544
|
+
name: parsed.name,
|
|
15545
|
+
description: parsed.description,
|
|
15546
|
+
scope: parsed.scope || null,
|
|
15547
|
+
rules: parsed.rules.map((r) => ({ content: r }))
|
|
15548
|
+
},
|
|
15549
|
+
artifactName: parsed.name,
|
|
15550
|
+
artifactType: "standard"
|
|
15551
|
+
}
|
|
15552
|
+
};
|
|
15553
|
+
}
|
|
15554
|
+
function getStandardFormatExample(agent) {
|
|
15555
|
+
if (agent === "packmind") {
|
|
15556
|
+
return "# <name>\n\n<description>\n\n## Rules\n\n* <rule 1>\n* <rule 2>";
|
|
15557
|
+
}
|
|
15558
|
+
return "## Standard: <name>\n\n<description>\n\n* <rule 1>\n* <rule 2>";
|
|
15559
|
+
}
|
|
15560
|
+
function isErrnoException(err) {
|
|
15561
|
+
return err instanceof Error && "code" in err;
|
|
15562
|
+
}
|
|
15563
|
+
|
|
15564
|
+
// apps/cli/src/infra/commands/diffRemoveHandler.ts
|
|
15565
|
+
var path18 = __toESM(require("path"));
|
|
15566
|
+
var ARTIFACT_TYPE_LABELS2 = {
|
|
15567
|
+
command: "command",
|
|
15568
|
+
standard: "standard",
|
|
15569
|
+
skill: "skill"
|
|
15570
|
+
};
|
|
15571
|
+
async function diffRemoveHandler(deps) {
|
|
15572
|
+
const {
|
|
15573
|
+
packmindCliHexa,
|
|
15574
|
+
filePath,
|
|
15575
|
+
message: messageFlag,
|
|
15576
|
+
exit,
|
|
15577
|
+
getCwd,
|
|
15578
|
+
existsSync: existsSync25,
|
|
15579
|
+
unlinkSync: unlinkSync5,
|
|
15580
|
+
rmSync: rmSync2
|
|
15581
|
+
} = deps;
|
|
15582
|
+
if (!filePath) {
|
|
15583
|
+
logErrorConsole(
|
|
15584
|
+
'Missing file path. Usage: packmind-cli diff remove <path> -m "message"'
|
|
15585
|
+
);
|
|
15586
|
+
exit(1);
|
|
15587
|
+
return;
|
|
15588
|
+
}
|
|
15589
|
+
const cwd = getCwd();
|
|
15590
|
+
const absolutePath = path18.resolve(cwd, filePath);
|
|
15591
|
+
const artefactResult = resolveArtefactFromPath(absolutePath);
|
|
15592
|
+
if (!artefactResult) {
|
|
15593
|
+
logErrorConsole(
|
|
15594
|
+
`Unsupported file path: ${absolutePath}. File must be in a recognized artefact directory (command, standard, or skill).`
|
|
15595
|
+
);
|
|
15596
|
+
exit(1);
|
|
15597
|
+
return;
|
|
15598
|
+
}
|
|
15599
|
+
const matchPath = artefactResult.artifactType === "skill" ? absolutePath.endsWith("SKILL.md") ? absolutePath : path18.join(absolutePath, "SKILL.md") : absolutePath;
|
|
15600
|
+
const skillDirPath = artefactResult.artifactType === "skill" ? absolutePath.endsWith("SKILL.md") ? path18.dirname(absolutePath) : absolutePath : void 0;
|
|
15601
|
+
const existsCheckPath = skillDirPath ?? absolutePath;
|
|
15602
|
+
if (!existsSync25(existsCheckPath)) {
|
|
15603
|
+
logErrorConsole(`File or directory does not exist: ${filePath}`);
|
|
15604
|
+
exit(1);
|
|
15605
|
+
return;
|
|
15606
|
+
}
|
|
15607
|
+
let configPackages;
|
|
15608
|
+
let configAgents;
|
|
15609
|
+
try {
|
|
15610
|
+
const fullConfig = await packmindCliHexa.readFullConfig(cwd);
|
|
15611
|
+
if (fullConfig) {
|
|
15612
|
+
configPackages = Object.keys(fullConfig.packages);
|
|
15613
|
+
configAgents = fullConfig.agents;
|
|
15614
|
+
} else {
|
|
15615
|
+
configPackages = [];
|
|
15616
|
+
}
|
|
15617
|
+
} catch (err) {
|
|
15618
|
+
logErrorConsole("Failed to parse packmind.json");
|
|
15619
|
+
if (err instanceof Error) {
|
|
15620
|
+
logErrorConsole(err.message);
|
|
15621
|
+
} else {
|
|
15622
|
+
logErrorConsole(String(err));
|
|
15623
|
+
}
|
|
15624
|
+
logErrorConsole(
|
|
15625
|
+
"\n\u{1F4A1} Please fix the packmind.json file or delete it to continue."
|
|
15626
|
+
);
|
|
15627
|
+
exit(1);
|
|
15628
|
+
return;
|
|
15629
|
+
}
|
|
15630
|
+
if (configPackages.length === 0) {
|
|
15631
|
+
logErrorConsole(
|
|
15632
|
+
"No packages configured. Configure packages in packmind.json first."
|
|
15633
|
+
);
|
|
15634
|
+
exit(1);
|
|
15635
|
+
return;
|
|
15636
|
+
}
|
|
15637
|
+
let gitRemoteUrl;
|
|
15638
|
+
let gitBranch;
|
|
15639
|
+
let relativePath;
|
|
15640
|
+
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(cwd);
|
|
15641
|
+
if (gitRoot) {
|
|
15642
|
+
try {
|
|
15643
|
+
gitRemoteUrl = packmindCliHexa.getGitRemoteUrlFromPath(gitRoot);
|
|
15644
|
+
gitBranch = packmindCliHexa.getCurrentBranch(gitRoot);
|
|
15645
|
+
relativePath = cwd.startsWith(gitRoot) ? cwd.slice(gitRoot.length) : "/";
|
|
15646
|
+
if (!relativePath.startsWith("/")) {
|
|
15647
|
+
relativePath = "/" + relativePath;
|
|
15648
|
+
}
|
|
15649
|
+
if (!relativePath.endsWith("/")) {
|
|
15650
|
+
relativePath = relativePath + "/";
|
|
15651
|
+
}
|
|
15652
|
+
} catch (err) {
|
|
15653
|
+
logErrorConsole(
|
|
15654
|
+
`Failed to collect git info: ${err instanceof Error ? err.message : String(err)}`
|
|
15655
|
+
);
|
|
15656
|
+
}
|
|
15657
|
+
}
|
|
15658
|
+
if (!gitRemoteUrl || !gitBranch || !relativePath) {
|
|
15659
|
+
logErrorConsole(
|
|
15660
|
+
"\n\u274C Could not determine git repository info. The diff command requires a git repository with a remote configured."
|
|
15661
|
+
);
|
|
15662
|
+
exit(1);
|
|
15663
|
+
return;
|
|
15664
|
+
}
|
|
15665
|
+
const deployedContent = await packmindCliHexa.getPackmindGateway().deployment.getDeployed({
|
|
15666
|
+
packagesSlugs: configPackages,
|
|
15667
|
+
gitRemoteUrl,
|
|
15668
|
+
gitBranch,
|
|
15669
|
+
relativePath,
|
|
15670
|
+
agents: configAgents
|
|
15671
|
+
});
|
|
15672
|
+
const relativeToGitRoot = matchPath.startsWith(gitRoot) ? matchPath.slice(gitRoot.length) : matchPath;
|
|
15673
|
+
let normalizedFilePath = normalizePath(relativeToGitRoot);
|
|
15674
|
+
if (normalizedFilePath.startsWith("/")) {
|
|
15675
|
+
normalizedFilePath = normalizedFilePath.slice(1);
|
|
15676
|
+
}
|
|
15677
|
+
const deployedFile = deployedContent.fileUpdates.createOrUpdate.find(
|
|
15678
|
+
(file) => normalizePath(file.path) === normalizedFilePath
|
|
15679
|
+
);
|
|
15680
|
+
if (!deployedFile) {
|
|
15681
|
+
const artifactTypeLabel = ARTIFACT_TYPE_LABELS2[artefactResult.artifactType];
|
|
15682
|
+
logErrorConsole(`This ${artifactTypeLabel} does not come from Packmind`);
|
|
15683
|
+
exit(1);
|
|
15684
|
+
return;
|
|
15685
|
+
}
|
|
15686
|
+
if (!deployedFile.artifactId || !deployedFile.spaceId) {
|
|
15687
|
+
logErrorConsole(
|
|
15688
|
+
"Missing artifact metadata. Cannot create change proposal for removal."
|
|
15689
|
+
);
|
|
15690
|
+
exit(1);
|
|
15691
|
+
return;
|
|
15692
|
+
}
|
|
15693
|
+
if (!deployedContent.targetId || !deployedContent.packageIds) {
|
|
15694
|
+
logErrorConsole(
|
|
15695
|
+
"Missing target or package information. Cannot create change proposal for removal."
|
|
15696
|
+
);
|
|
15697
|
+
exit(1);
|
|
15698
|
+
return;
|
|
15699
|
+
}
|
|
15700
|
+
let message;
|
|
15701
|
+
if (messageFlag !== void 0) {
|
|
15702
|
+
const validation = validateMessage(messageFlag);
|
|
15703
|
+
if (!validation.valid) {
|
|
15704
|
+
logErrorConsole(validation.error);
|
|
15705
|
+
exit(1);
|
|
15706
|
+
return;
|
|
15707
|
+
}
|
|
15708
|
+
message = validation.message;
|
|
15709
|
+
} else if (process.stdin.isTTY) {
|
|
15710
|
+
const editorMessage = openEditorForMessage();
|
|
15711
|
+
const validation = validateMessage(editorMessage);
|
|
15712
|
+
if (!validation.valid) {
|
|
15713
|
+
logErrorConsole(
|
|
15714
|
+
"Aborting submission: empty message. Use -m to provide a message."
|
|
15715
|
+
);
|
|
15716
|
+
exit(1);
|
|
15717
|
+
return;
|
|
15718
|
+
}
|
|
15719
|
+
message = validation.message;
|
|
15720
|
+
} else {
|
|
15721
|
+
logErrorConsole(
|
|
15722
|
+
'Non-interactive mode requires -m flag. Usage: packmind-cli diff remove <path> -m "your message"'
|
|
15723
|
+
);
|
|
15724
|
+
exit(1);
|
|
15725
|
+
return;
|
|
15726
|
+
}
|
|
15727
|
+
const changeProposalType = artefactResult.artifactType === "standard" ? "removeStandard" /* removeStandard */ : artefactResult.artifactType === "command" ? "removeCommand" /* removeCommand */ : "removeSkill" /* removeSkill */;
|
|
15728
|
+
const diff = {
|
|
15729
|
+
filePath: absolutePath,
|
|
15730
|
+
type: changeProposalType,
|
|
15731
|
+
payload: {
|
|
15732
|
+
targetId: deployedContent.targetId,
|
|
15733
|
+
packageIds: deployedContent.packageIds
|
|
15734
|
+
},
|
|
15735
|
+
artifactName: deployedFile.artifactName || artefactResult.artifactType,
|
|
15736
|
+
artifactType: artefactResult.artifactType,
|
|
15737
|
+
artifactId: deployedFile.artifactId,
|
|
15738
|
+
spaceId: deployedFile.spaceId
|
|
15739
|
+
};
|
|
15740
|
+
const result = await packmindCliHexa.submitDiffs([[diff]], message);
|
|
15741
|
+
for (const err of result.errors) {
|
|
15742
|
+
logErrorConsole(`Failed to submit removal "${err.name}": ${err.message}`);
|
|
15743
|
+
}
|
|
15744
|
+
if (result.errors.length > 0) {
|
|
15745
|
+
exit(1);
|
|
15746
|
+
return;
|
|
15747
|
+
}
|
|
15748
|
+
if (result.submitted > 0) {
|
|
15749
|
+
logSuccessConsole("Change proposal for removal submitted successfully");
|
|
15750
|
+
} else if (result.alreadySubmitted > 0) {
|
|
15751
|
+
logWarningConsole("Change proposal for removal already submitted");
|
|
15752
|
+
}
|
|
15753
|
+
try {
|
|
15754
|
+
if (skillDirPath) {
|
|
15755
|
+
rmSync2(skillDirPath, { recursive: true });
|
|
15756
|
+
logSuccessConsole(`Directory deleted: ${skillDirPath}`);
|
|
15757
|
+
} else {
|
|
15758
|
+
unlinkSync5(absolutePath);
|
|
15759
|
+
logSuccessConsole(`File deleted: ${filePath}`);
|
|
15760
|
+
}
|
|
15761
|
+
} catch (err) {
|
|
15762
|
+
logErrorConsole(
|
|
15763
|
+
`Failed to delete file: ${err instanceof Error ? err.message : String(err)}`
|
|
15764
|
+
);
|
|
15765
|
+
exit(1);
|
|
15766
|
+
return;
|
|
15767
|
+
}
|
|
15768
|
+
exit(0);
|
|
15769
|
+
}
|
|
15770
|
+
|
|
15052
15771
|
// apps/cli/src/infra/commands/DiffCommand.ts
|
|
15053
15772
|
var diffCommand = (0, import_cmd_ts19.command)({
|
|
15054
15773
|
name: "diff",
|
|
@@ -15067,11 +15786,41 @@ var diffCommand = (0, import_cmd_ts19.command)({
|
|
|
15067
15786
|
short: "m",
|
|
15068
15787
|
description: "Message describing the intent behind the changes (max 1024 chars)",
|
|
15069
15788
|
type: (0, import_cmd_ts19.optional)(import_cmd_ts19.string)
|
|
15789
|
+
}),
|
|
15790
|
+
positionals: (0, import_cmd_ts19.restPositionals)({
|
|
15791
|
+
type: import_cmd_ts19.string,
|
|
15792
|
+
displayName: "args",
|
|
15793
|
+
description: "Subcommand and arguments (e.g., add <path>, remove <path>)"
|
|
15070
15794
|
})
|
|
15071
15795
|
},
|
|
15072
|
-
handler: async ({ submit, includeSubmitted, message }) => {
|
|
15796
|
+
handler: async ({ submit, includeSubmitted, message, positionals }) => {
|
|
15073
15797
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
15074
15798
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
15799
|
+
if (positionals[0] === "add") {
|
|
15800
|
+
await diffAddHandler({
|
|
15801
|
+
packmindCliHexa,
|
|
15802
|
+
filePath: positionals[1],
|
|
15803
|
+
message,
|
|
15804
|
+
exit: process.exit,
|
|
15805
|
+
getCwd: () => process.cwd(),
|
|
15806
|
+
readFile: (p) => (0, import_fs20.readFileSync)(p, "utf-8"),
|
|
15807
|
+
readSkillDirectory
|
|
15808
|
+
});
|
|
15809
|
+
return;
|
|
15810
|
+
}
|
|
15811
|
+
if (positionals[0] === "remove" || positionals[0] === "rm") {
|
|
15812
|
+
await diffRemoveHandler({
|
|
15813
|
+
packmindCliHexa,
|
|
15814
|
+
filePath: positionals[1],
|
|
15815
|
+
message,
|
|
15816
|
+
exit: process.exit,
|
|
15817
|
+
getCwd: () => process.cwd(),
|
|
15818
|
+
existsSync: (p) => (0, import_fs20.existsSync)(p),
|
|
15819
|
+
unlinkSync: (p) => (0, import_fs20.unlinkSync)(p),
|
|
15820
|
+
rmSync: (p, opts) => (0, import_fs20.rmSync)(p, opts)
|
|
15821
|
+
});
|
|
15822
|
+
return;
|
|
15823
|
+
}
|
|
15075
15824
|
await diffArtefactsHandler({
|
|
15076
15825
|
packmindCliHexa,
|
|
15077
15826
|
exit: process.exit,
|
|
@@ -15138,15 +15887,15 @@ var CreatePackageUseCase = class {
|
|
|
15138
15887
|
constructor(gateway) {
|
|
15139
15888
|
this.gateway = gateway;
|
|
15140
15889
|
}
|
|
15141
|
-
async execute(
|
|
15890
|
+
async execute(command22) {
|
|
15142
15891
|
const space = await this.gateway.spaces.getGlobal();
|
|
15143
15892
|
const result = await this.gateway.packages.create({
|
|
15144
15893
|
spaceId: space.id,
|
|
15145
|
-
name:
|
|
15146
|
-
description:
|
|
15894
|
+
name: command22.name,
|
|
15895
|
+
description: command22.description ?? "",
|
|
15147
15896
|
recipeIds: [],
|
|
15148
15897
|
standardIds: [],
|
|
15149
|
-
originSkill:
|
|
15898
|
+
originSkill: command22.originSkill
|
|
15150
15899
|
});
|
|
15151
15900
|
return {
|
|
15152
15901
|
packageId: result.package.id,
|
|
@@ -15236,8 +15985,8 @@ var AddToPackageUseCase = class {
|
|
|
15236
15985
|
constructor(gateway) {
|
|
15237
15986
|
this.gateway = gateway;
|
|
15238
15987
|
}
|
|
15239
|
-
async execute(
|
|
15240
|
-
const { packageSlug, itemType, itemSlugs } =
|
|
15988
|
+
async execute(command22) {
|
|
15989
|
+
const { packageSlug, itemType, itemSlugs } = command22;
|
|
15241
15990
|
const space = await this.gateway.spaces.getGlobal();
|
|
15242
15991
|
const packages = await this.gateway.packages.list({});
|
|
15243
15992
|
const pkg = packages.packages.find((pkg2) => pkg2.slug === packageSlug);
|
|
@@ -15254,7 +16003,7 @@ var AddToPackageUseCase = class {
|
|
|
15254
16003
|
standardIds: [],
|
|
15255
16004
|
recipeIds: [],
|
|
15256
16005
|
skillIds: [],
|
|
15257
|
-
originSkill:
|
|
16006
|
+
originSkill: command22.originSkill
|
|
15258
16007
|
};
|
|
15259
16008
|
if (itemType === "standard") {
|
|
15260
16009
|
addCommand.standardIds = ids.map(createStandardId);
|
|
@@ -15299,7 +16048,7 @@ var AddToPackageUseCase = class {
|
|
|
15299
16048
|
}
|
|
15300
16049
|
async findCommandBySlug(slug, spaceId) {
|
|
15301
16050
|
const commands = await this.gateway.commands.list({ spaceId });
|
|
15302
|
-
return commands.recipes.find((
|
|
16051
|
+
return commands.recipes.find((command22) => command22.slug === slug) ?? null;
|
|
15303
16052
|
}
|
|
15304
16053
|
async findSkillBySlug(slug, spaceId) {
|
|
15305
16054
|
const skills = await this.gateway.skills.list({ spaceId });
|
|
@@ -15459,7 +16208,7 @@ var import_cmd_ts24 = __toESM(require_cjs());
|
|
|
15459
16208
|
|
|
15460
16209
|
// apps/cli/src/application/services/AgentArtifactDetectionService.ts
|
|
15461
16210
|
var fs18 = __toESM(require("fs/promises"));
|
|
15462
|
-
var
|
|
16211
|
+
var path19 = __toESM(require("path"));
|
|
15463
16212
|
var AGENT_ARTIFACT_CHECKS = [
|
|
15464
16213
|
{ agent: "claude", paths: [".claude"] },
|
|
15465
16214
|
{ agent: "cursor", paths: [".cursor"] },
|
|
@@ -15477,7 +16226,7 @@ var AgentArtifactDetectionService = class {
|
|
|
15477
16226
|
const detected = [];
|
|
15478
16227
|
for (const check of AGENT_ARTIFACT_CHECKS) {
|
|
15479
16228
|
for (const relativePath of check.paths) {
|
|
15480
|
-
const fullPath =
|
|
16229
|
+
const fullPath = path19.join(baseDirectory, relativePath);
|
|
15481
16230
|
const exists = await this.pathExists(fullPath);
|
|
15482
16231
|
if (exists) {
|
|
15483
16232
|
detected.push({
|
|
@@ -15574,7 +16323,7 @@ async function promptAgentsWithReadline2(choices) {
|
|
|
15574
16323
|
output.write("\n");
|
|
15575
16324
|
const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
|
|
15576
16325
|
const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
|
|
15577
|
-
return new Promise((
|
|
16326
|
+
return new Promise((resolve9) => {
|
|
15578
16327
|
rl.question(
|
|
15579
16328
|
`Enter numbers separated by commas (default: ${defaultValue}): `,
|
|
15580
16329
|
(answer) => {
|
|
@@ -15583,7 +16332,7 @@ async function promptAgentsWithReadline2(choices) {
|
|
|
15583
16332
|
const numbersStr = trimmed === "" ? defaultValue : trimmed;
|
|
15584
16333
|
const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
|
|
15585
16334
|
const selectedAgents = numbers.map((n) => choices[n - 1].value);
|
|
15586
|
-
|
|
16335
|
+
resolve9(selectedAgents);
|
|
15587
16336
|
}
|
|
15588
16337
|
);
|
|
15589
16338
|
});
|
|
@@ -15728,18 +16477,238 @@ var initCommand = (0, import_cmd_ts26.command)({
|
|
|
15728
16477
|
}
|
|
15729
16478
|
});
|
|
15730
16479
|
|
|
15731
|
-
// apps/cli/src/
|
|
16480
|
+
// apps/cli/src/infra/commands/UpdateCommand.ts
|
|
16481
|
+
var import_cmd_ts27 = __toESM(require_cjs());
|
|
16482
|
+
|
|
16483
|
+
// apps/cli/src/infra/commands/updateHandler.ts
|
|
16484
|
+
var import_path5 = __toESM(require("path"));
|
|
16485
|
+
var import_child_process5 = require("child_process");
|
|
16486
|
+
var import_fs21 = require("fs");
|
|
16487
|
+
var import_promises2 = require("stream/promises");
|
|
16488
|
+
var import_stream = require("stream");
|
|
16489
|
+
var import_semver = __toESM(require("semver"));
|
|
16490
|
+
var GITHUB_REPO = "PackmindHub/packmind";
|
|
16491
|
+
var NPM_PACKAGE = "@packmind/cli";
|
|
16492
|
+
function getPlatformAssetSuffix(platform, arch) {
|
|
16493
|
+
const osMap = {
|
|
16494
|
+
linux: "linux",
|
|
16495
|
+
darwin: "macos",
|
|
16496
|
+
win32: "windows"
|
|
16497
|
+
};
|
|
16498
|
+
const osName = osMap[platform];
|
|
16499
|
+
if (!osName) {
|
|
16500
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
16501
|
+
}
|
|
16502
|
+
const archName = platform === "darwin" && arch === "x64" ? "x64-baseline" : arch;
|
|
16503
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
16504
|
+
return `${osName}-${archName}${ext}`;
|
|
16505
|
+
}
|
|
16506
|
+
async function fetchLatestVersionFromNpm(fetchFn) {
|
|
16507
|
+
const res = await fetchFn(`https://registry.npmjs.org/${NPM_PACKAGE}/latest`);
|
|
16508
|
+
if (!res.ok) {
|
|
16509
|
+
throw new Error(
|
|
16510
|
+
`Failed to fetch from npm registry: ${res.status} ${res.statusText}`
|
|
16511
|
+
);
|
|
16512
|
+
}
|
|
16513
|
+
const data = await res.json();
|
|
16514
|
+
return data.version;
|
|
16515
|
+
}
|
|
16516
|
+
async function fetchLatestVersionFromGitHub(fetchFn) {
|
|
16517
|
+
const res = await fetchFn(
|
|
16518
|
+
`https://api.github.com/repos/${GITHUB_REPO}/releases?per_page=20`,
|
|
16519
|
+
{
|
|
16520
|
+
headers: { Accept: "application/vnd.github.v3+json" }
|
|
16521
|
+
}
|
|
16522
|
+
);
|
|
16523
|
+
if (!res.ok) {
|
|
16524
|
+
throw new Error(
|
|
16525
|
+
`Failed to fetch from GitHub API: ${res.status} ${res.statusText}`
|
|
16526
|
+
);
|
|
16527
|
+
}
|
|
16528
|
+
const releases = await res.json();
|
|
16529
|
+
const cliReleases = releases.filter((r) => r.tag_name?.startsWith("release-cli/")).map((r) => ({
|
|
16530
|
+
...r,
|
|
16531
|
+
version: r.tag_name.replace("release-cli/", "")
|
|
16532
|
+
})).filter((r) => import_semver.default.valid(r.version)).sort((a, b) => import_semver.default.rcompare(a.version, b.version));
|
|
16533
|
+
if (cliReleases.length === 0) {
|
|
16534
|
+
throw new Error("No CLI release found on GitHub");
|
|
16535
|
+
}
|
|
16536
|
+
return cliReleases[0].version;
|
|
16537
|
+
}
|
|
16538
|
+
async function downloadExecutable(fetchFn, version, platformSuffix, targetPath) {
|
|
16539
|
+
const assetName = `packmind-cli-${platformSuffix}-${version}`;
|
|
16540
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/release-cli/${version}/${assetName}`;
|
|
16541
|
+
logInfoConsole(`Downloading ${assetName}...`);
|
|
16542
|
+
const res = await fetchFn(url, { redirect: "follow" });
|
|
16543
|
+
if (!res.ok) {
|
|
16544
|
+
throw new Error(
|
|
16545
|
+
`Failed to download executable: ${res.status} ${res.statusText}
|
|
16546
|
+
URL: ${url}`
|
|
16547
|
+
);
|
|
16548
|
+
}
|
|
16549
|
+
if (!res.body) {
|
|
16550
|
+
throw new Error("No response body received");
|
|
16551
|
+
}
|
|
16552
|
+
const nodeReadable = import_stream.Readable.fromWeb(res.body);
|
|
16553
|
+
const fileStream = (0, import_fs21.createWriteStream)(targetPath);
|
|
16554
|
+
await (0, import_promises2.pipeline)(nodeReadable, fileStream);
|
|
16555
|
+
const stats = (0, import_fs21.statSync)(targetPath);
|
|
16556
|
+
if (stats.size < 1e6) {
|
|
16557
|
+
(0, import_fs21.unlinkSync)(targetPath);
|
|
16558
|
+
throw new Error(
|
|
16559
|
+
`Downloaded file is too small (${stats.size} bytes). The download may have failed.`
|
|
16560
|
+
);
|
|
16561
|
+
}
|
|
16562
|
+
logInfoConsole(
|
|
16563
|
+
`Downloaded successfully (${(stats.size / 1048576).toFixed(1)} MB)`
|
|
16564
|
+
);
|
|
16565
|
+
}
|
|
16566
|
+
function updateViaNpm(version) {
|
|
16567
|
+
logInfoConsole(`Updating via npm to version ${version}...`);
|
|
16568
|
+
(0, import_child_process5.execSync)(`npm install -g ${NPM_PACKAGE}@${version}`, {
|
|
16569
|
+
stdio: "inherit"
|
|
16570
|
+
});
|
|
16571
|
+
}
|
|
16572
|
+
async function updateViaExecutableReplace(deps, version) {
|
|
16573
|
+
const platformSuffix = getPlatformAssetSuffix(deps.platform, deps.arch);
|
|
16574
|
+
const currentPath = deps.executablePath;
|
|
16575
|
+
const tempPath = currentPath + ".update-tmp";
|
|
16576
|
+
try {
|
|
16577
|
+
await downloadExecutable(deps.fetchFn, version, platformSuffix, tempPath);
|
|
16578
|
+
(0, import_fs21.renameSync)(tempPath, currentPath);
|
|
16579
|
+
if (deps.platform !== "win32") {
|
|
16580
|
+
(0, import_fs21.chmodSync)(currentPath, 493);
|
|
16581
|
+
}
|
|
16582
|
+
} catch (error) {
|
|
16583
|
+
try {
|
|
16584
|
+
(0, import_fs21.unlinkSync)(tempPath);
|
|
16585
|
+
} catch {
|
|
16586
|
+
}
|
|
16587
|
+
throw error;
|
|
16588
|
+
}
|
|
16589
|
+
}
|
|
16590
|
+
function isLocalNpmPackage(scriptPath) {
|
|
16591
|
+
if (!scriptPath) return false;
|
|
16592
|
+
return scriptPath.includes(import_path5.default.join("node_modules", "@packmind", "cli"));
|
|
16593
|
+
}
|
|
16594
|
+
function isHomebrewInstall(executablePath) {
|
|
16595
|
+
try {
|
|
16596
|
+
const realPath = (0, import_fs21.realpathSync)(executablePath);
|
|
16597
|
+
return realPath.includes("/Cellar/");
|
|
16598
|
+
} catch {
|
|
16599
|
+
return false;
|
|
16600
|
+
}
|
|
16601
|
+
}
|
|
16602
|
+
async function updateHandler(deps) {
|
|
16603
|
+
const execBasename = import_path5.default.basename(deps.executablePath).replace(/\.exe$/, "");
|
|
16604
|
+
const jsRuntimes = ["node", "bun", "deno"];
|
|
16605
|
+
if (jsRuntimes.includes(execBasename)) {
|
|
16606
|
+
if (isLocalNpmPackage(deps.scriptPath)) {
|
|
16607
|
+
logErrorConsole(
|
|
16608
|
+
"Your CLI version is managed by your local package.json.\nTo update, run: npm update @packmind/cli"
|
|
16609
|
+
);
|
|
16610
|
+
} else {
|
|
16611
|
+
logErrorConsole(
|
|
16612
|
+
"The update command is not available when running the CLI via a JavaScript runtime.\nTo update, use the standalone executable or run: npm install -g @packmind/cli@latest"
|
|
16613
|
+
);
|
|
16614
|
+
}
|
|
16615
|
+
process.exit(1);
|
|
16616
|
+
return;
|
|
16617
|
+
}
|
|
16618
|
+
if (isHomebrewInstall(deps.executablePath)) {
|
|
16619
|
+
logInfoConsole(
|
|
16620
|
+
"This CLI was installed via Homebrew.\nTo update, run: brew upgrade packmind-cli"
|
|
16621
|
+
);
|
|
16622
|
+
process.exit(0);
|
|
16623
|
+
return;
|
|
16624
|
+
}
|
|
16625
|
+
logInfoConsole(
|
|
16626
|
+
`Current version: ${deps.currentVersion} (${deps.isExecutableMode ? "standalone executable" : "npm package"})`
|
|
16627
|
+
);
|
|
16628
|
+
let latestVersion;
|
|
16629
|
+
try {
|
|
16630
|
+
latestVersion = deps.isExecutableMode ? await fetchLatestVersionFromGitHub(deps.fetchFn) : await fetchLatestVersionFromNpm(deps.fetchFn);
|
|
16631
|
+
} catch (error) {
|
|
16632
|
+
logErrorConsole(
|
|
16633
|
+
`Failed to check for updates: ${error instanceof Error ? error.message : String(error)}`
|
|
16634
|
+
);
|
|
16635
|
+
process.exit(1);
|
|
16636
|
+
return;
|
|
16637
|
+
}
|
|
16638
|
+
if (!import_semver.default.gt(latestVersion, deps.currentVersion)) {
|
|
16639
|
+
logSuccessConsole(`Already up to date (v${deps.currentVersion})`);
|
|
16640
|
+
return;
|
|
16641
|
+
}
|
|
16642
|
+
logConsole("");
|
|
16643
|
+
logInfoConsole(
|
|
16644
|
+
`New version available: ${deps.currentVersion} -> ${latestVersion}`
|
|
16645
|
+
);
|
|
16646
|
+
if (deps.checkOnly) {
|
|
16647
|
+
process.exit(1);
|
|
16648
|
+
return;
|
|
16649
|
+
}
|
|
16650
|
+
try {
|
|
16651
|
+
if (deps.isExecutableMode) {
|
|
16652
|
+
await updateViaExecutableReplace(deps, latestVersion);
|
|
16653
|
+
} else {
|
|
16654
|
+
updateViaNpm(latestVersion);
|
|
16655
|
+
}
|
|
16656
|
+
logConsole("");
|
|
16657
|
+
logSuccessConsole(`Updated to v${latestVersion}`);
|
|
16658
|
+
if (deps.isExecutableMode) {
|
|
16659
|
+
logInfoConsole(`Binary location: ${deps.executablePath}`);
|
|
16660
|
+
}
|
|
16661
|
+
} catch (error) {
|
|
16662
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16663
|
+
if (message.includes("EACCES") || message.includes("permission denied")) {
|
|
16664
|
+
logErrorConsole(
|
|
16665
|
+
`Permission denied. Try running with sudo:
|
|
16666
|
+
sudo packmind-cli update`
|
|
16667
|
+
);
|
|
16668
|
+
} else {
|
|
16669
|
+
logErrorConsole(`Update failed: ${message}`);
|
|
16670
|
+
}
|
|
16671
|
+
process.exit(1);
|
|
16672
|
+
}
|
|
16673
|
+
}
|
|
16674
|
+
|
|
16675
|
+
// apps/cli/src/infra/commands/UpdateCommand.ts
|
|
15732
16676
|
var { version: CLI_VERSION4 } = require_package();
|
|
16677
|
+
var updateCommand = (0, import_cmd_ts27.command)({
|
|
16678
|
+
name: "update",
|
|
16679
|
+
description: "Update packmind-cli to the latest version",
|
|
16680
|
+
args: {
|
|
16681
|
+
check: (0, import_cmd_ts27.flag)({
|
|
16682
|
+
long: "check",
|
|
16683
|
+
description: "Only check if a newer version is available without performing the update"
|
|
16684
|
+
})
|
|
16685
|
+
},
|
|
16686
|
+
handler: async ({ check }) => {
|
|
16687
|
+
await updateHandler({
|
|
16688
|
+
currentVersion: CLI_VERSION4,
|
|
16689
|
+
isExecutableMode: hasEmbeddedWasmFiles(),
|
|
16690
|
+
executablePath: process.execPath,
|
|
16691
|
+
scriptPath: require.main?.filename,
|
|
16692
|
+
platform: process.platform,
|
|
16693
|
+
arch: process.arch,
|
|
16694
|
+
fetchFn: fetch,
|
|
16695
|
+
checkOnly: check
|
|
16696
|
+
});
|
|
16697
|
+
}
|
|
16698
|
+
});
|
|
16699
|
+
|
|
16700
|
+
// apps/cli/src/main.ts
|
|
16701
|
+
var { version: CLI_VERSION5 } = require_package();
|
|
15733
16702
|
function findEnvFile() {
|
|
15734
16703
|
const currentDir = process.cwd();
|
|
15735
16704
|
const gitService = new GitService();
|
|
15736
16705
|
const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
|
|
15737
|
-
const filesystemRoot =
|
|
16706
|
+
const filesystemRoot = path21.parse(currentDir).root;
|
|
15738
16707
|
const stopDir = gitRoot ?? filesystemRoot;
|
|
15739
16708
|
let searchDir = currentDir;
|
|
15740
|
-
let parentDir =
|
|
16709
|
+
let parentDir = path21.dirname(searchDir);
|
|
15741
16710
|
while (searchDir !== parentDir) {
|
|
15742
|
-
const envPath2 =
|
|
16711
|
+
const envPath2 = path21.join(searchDir, ".env");
|
|
15743
16712
|
if (fs19.existsSync(envPath2)) {
|
|
15744
16713
|
return envPath2;
|
|
15745
16714
|
}
|
|
@@ -15747,7 +16716,7 @@ function findEnvFile() {
|
|
|
15747
16716
|
return null;
|
|
15748
16717
|
}
|
|
15749
16718
|
searchDir = parentDir;
|
|
15750
|
-
parentDir =
|
|
16719
|
+
parentDir = path21.dirname(searchDir);
|
|
15751
16720
|
}
|
|
15752
16721
|
return null;
|
|
15753
16722
|
}
|
|
@@ -15764,10 +16733,10 @@ if (hasEmbeddedWasmFiles()) {
|
|
|
15764
16733
|
}
|
|
15765
16734
|
var args = process.argv.slice(2);
|
|
15766
16735
|
if (args.includes("--version") || args.includes("-v")) {
|
|
15767
|
-
logConsole(`packmind-cli version ${
|
|
16736
|
+
logConsole(`packmind-cli version ${CLI_VERSION5}`);
|
|
15768
16737
|
process.exit(0);
|
|
15769
16738
|
}
|
|
15770
|
-
var app = (0,
|
|
16739
|
+
var app = (0, import_cmd_ts28.subcommands)({
|
|
15771
16740
|
name: "packmind-cli",
|
|
15772
16741
|
description: "Packmind CLI tool",
|
|
15773
16742
|
cmds: {
|
|
@@ -15786,10 +16755,11 @@ var app = (0, import_cmd_ts27.subcommands)({
|
|
|
15786
16755
|
skills: skillsCommand,
|
|
15787
16756
|
standards: standardsCommand,
|
|
15788
16757
|
uninstall: uninstallCommand,
|
|
16758
|
+
update: updateCommand,
|
|
15789
16759
|
whoami: whoamiCommand
|
|
15790
16760
|
}
|
|
15791
16761
|
});
|
|
15792
|
-
(0,
|
|
16762
|
+
(0, import_cmd_ts28.run)(app, args).catch((error) => {
|
|
15793
16763
|
logErrorConsole(error.message);
|
|
15794
16764
|
process.exit(1);
|
|
15795
16765
|
});
|