@packmind/cli 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.cjs +505 -293
- package/package.json +1 -1
package/main.cjs
CHANGED
|
@@ -2590,7 +2590,7 @@ var require_has_flag = __commonJS({
|
|
|
2590
2590
|
var require_supports_color = __commonJS({
|
|
2591
2591
|
"node_modules/supports-color/index.js"(exports2, module2) {
|
|
2592
2592
|
"use strict";
|
|
2593
|
-
var
|
|
2593
|
+
var os6 = require("os");
|
|
2594
2594
|
var tty2 = require("tty");
|
|
2595
2595
|
var hasFlag2 = require_has_flag();
|
|
2596
2596
|
var { env: env2 } = process;
|
|
@@ -2638,7 +2638,7 @@ var require_supports_color = __commonJS({
|
|
|
2638
2638
|
return min;
|
|
2639
2639
|
}
|
|
2640
2640
|
if (process.platform === "win32") {
|
|
2641
|
-
const osRelease =
|
|
2641
|
+
const osRelease = os6.release().split(".");
|
|
2642
2642
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
2643
2643
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
2644
2644
|
}
|
|
@@ -3855,7 +3855,7 @@ var require_package = __commonJS({
|
|
|
3855
3855
|
"apps/cli/package.json"(exports2, module2) {
|
|
3856
3856
|
module2.exports = {
|
|
3857
3857
|
name: "@packmind/cli",
|
|
3858
|
-
version: "0.29.
|
|
3858
|
+
version: "0.29.1",
|
|
3859
3859
|
description: "A command-line interface for Packmind linting and code quality checks",
|
|
3860
3860
|
private: false,
|
|
3861
3861
|
bin: {
|
|
@@ -4347,6 +4347,7 @@ function camelToKebab(str) {
|
|
|
4347
4347
|
}
|
|
4348
4348
|
var CLAUDE_CODE_ADDITIONAL_FIELDS = {
|
|
4349
4349
|
"argument-hint": "argumentHint",
|
|
4350
|
+
arguments: "arguments",
|
|
4350
4351
|
when_to_use: "whenToUse",
|
|
4351
4352
|
"disable-model-invocation": "disableModelInvocation",
|
|
4352
4353
|
"user-invocable": "userInvocable",
|
|
@@ -5419,30 +5420,30 @@ var GitService = class {
|
|
|
5419
5420
|
this.gitRunner = gitRunner;
|
|
5420
5421
|
this.logger = logger2;
|
|
5421
5422
|
}
|
|
5422
|
-
getGitRepositoryRoot(
|
|
5423
|
+
getGitRepositoryRoot(path37) {
|
|
5423
5424
|
try {
|
|
5424
5425
|
const { stdout } = this.gitRunner("rev-parse --show-toplevel", {
|
|
5425
|
-
cwd:
|
|
5426
|
+
cwd: path37
|
|
5426
5427
|
});
|
|
5427
5428
|
const gitRoot = stdout.trim();
|
|
5428
5429
|
this.logger.debug("Resolved git repository root", {
|
|
5429
|
-
inputPath:
|
|
5430
|
+
inputPath: path37,
|
|
5430
5431
|
gitRoot
|
|
5431
5432
|
});
|
|
5432
5433
|
return gitRoot;
|
|
5433
5434
|
} catch (error) {
|
|
5434
5435
|
if (error instanceof Error) {
|
|
5435
5436
|
throw new Error(
|
|
5436
|
-
`Failed to get Git repository root. The path '${
|
|
5437
|
+
`Failed to get Git repository root. The path '${path37}' does not appear to be inside a Git repository.
|
|
5437
5438
|
${error.message}`
|
|
5438
5439
|
);
|
|
5439
5440
|
}
|
|
5440
5441
|
throw new Error("Failed to get Git repository root: Unknown error");
|
|
5441
5442
|
}
|
|
5442
5443
|
}
|
|
5443
|
-
tryGetGitRepositoryRoot(
|
|
5444
|
+
tryGetGitRepositoryRoot(path37) {
|
|
5444
5445
|
try {
|
|
5445
|
-
return this.getGitRepositoryRoot(
|
|
5446
|
+
return this.getGitRepositoryRoot(path37);
|
|
5446
5447
|
} catch {
|
|
5447
5448
|
return null;
|
|
5448
5449
|
}
|
|
@@ -6744,10 +6745,10 @@ var PackmindHttpClient = class {
|
|
|
6744
6745
|
return null;
|
|
6745
6746
|
}
|
|
6746
6747
|
}
|
|
6747
|
-
async request(
|
|
6748
|
+
async request(path37, options = {}) {
|
|
6748
6749
|
const { host } = this.getAuthContext();
|
|
6749
6750
|
const { method = "GET", body } = options;
|
|
6750
|
-
const url = `${host}${
|
|
6751
|
+
const url = `${host}${path37}`;
|
|
6751
6752
|
try {
|
|
6752
6753
|
const response = await fetch(url, {
|
|
6753
6754
|
method,
|
|
@@ -10145,8 +10146,8 @@ ${endMarker}`;
|
|
|
10145
10146
|
};
|
|
10146
10147
|
|
|
10147
10148
|
// apps/cli/src/application/useCases/InstallUseCase.ts
|
|
10148
|
-
var
|
|
10149
|
-
var
|
|
10149
|
+
var fs7 = __toESM(require("fs/promises"));
|
|
10150
|
+
var path8 = __toESM(require("path"));
|
|
10150
10151
|
|
|
10151
10152
|
// apps/cli/src/application/utils/normalizePackageSlugs.ts
|
|
10152
10153
|
async function normalizePackageSlugs(slugs, spaceService) {
|
|
@@ -10164,6 +10165,48 @@ async function normalizePackageSlugs(slugs, spaceService) {
|
|
|
10164
10165
|
);
|
|
10165
10166
|
}
|
|
10166
10167
|
|
|
10168
|
+
// apps/cli/src/infra/utils/agentHomeDirectory.ts
|
|
10169
|
+
var fs6 = __toESM(require("fs"));
|
|
10170
|
+
var os2 = __toESM(require("os"));
|
|
10171
|
+
var path7 = __toESM(require("path"));
|
|
10172
|
+
var AGENT_HOME_DIR_NAMES = {
|
|
10173
|
+
claude: ".claude"
|
|
10174
|
+
};
|
|
10175
|
+
function safeRealpath(target) {
|
|
10176
|
+
try {
|
|
10177
|
+
return fs6.realpathSync(target);
|
|
10178
|
+
} catch {
|
|
10179
|
+
return path7.resolve(target);
|
|
10180
|
+
}
|
|
10181
|
+
}
|
|
10182
|
+
function isAgentHomeDirectory(cwd) {
|
|
10183
|
+
const home = os2.homedir();
|
|
10184
|
+
if (!home) {
|
|
10185
|
+
return null;
|
|
10186
|
+
}
|
|
10187
|
+
const resolvedCwd = safeRealpath(cwd);
|
|
10188
|
+
const resolvedHome = safeRealpath(home);
|
|
10189
|
+
for (const [agent, dirName] of Object.entries(AGENT_HOME_DIR_NAMES)) {
|
|
10190
|
+
if (!dirName) continue;
|
|
10191
|
+
if (resolvedCwd === path7.join(resolvedHome, dirName)) {
|
|
10192
|
+
return agent;
|
|
10193
|
+
}
|
|
10194
|
+
}
|
|
10195
|
+
return null;
|
|
10196
|
+
}
|
|
10197
|
+
function getAgentHomeDirPrefix(agent) {
|
|
10198
|
+
const dirName = AGENT_HOME_DIR_NAMES[agent];
|
|
10199
|
+
return dirName ? `${dirName}/` : null;
|
|
10200
|
+
}
|
|
10201
|
+
|
|
10202
|
+
// apps/cli/src/infra/utils/stripFullStandardLinkFooter.ts
|
|
10203
|
+
function stripFullStandardLinkFooter(content) {
|
|
10204
|
+
return content.replace(
|
|
10205
|
+
/\n+Full standard is available here for further request: \[.+?]\(.+?\.packmind\/standards\/.+?\)\s*$/,
|
|
10206
|
+
""
|
|
10207
|
+
);
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10167
10210
|
// apps/cli/src/application/useCases/InstallUseCase.ts
|
|
10168
10211
|
var InstallUseCase = class {
|
|
10169
10212
|
constructor(packmindGateway, lockFileRepository, configFileRepository, spaceService) {
|
|
@@ -10184,6 +10227,9 @@ var InstallUseCase = class {
|
|
|
10184
10227
|
standardsCount: 0,
|
|
10185
10228
|
commandsCount: 0,
|
|
10186
10229
|
skillsCount: 0,
|
|
10230
|
+
skillsChanged: 0,
|
|
10231
|
+
standardsChanged: 0,
|
|
10232
|
+
commandsChanged: 0,
|
|
10187
10233
|
recipesRemoved: 0,
|
|
10188
10234
|
standardsRemoved: 0,
|
|
10189
10235
|
commandsRemoved: 0,
|
|
@@ -10253,11 +10299,31 @@ var InstallUseCase = class {
|
|
|
10253
10299
|
}
|
|
10254
10300
|
return result;
|
|
10255
10301
|
}
|
|
10302
|
+
const installAgents = this.resolveInstallAgents(command32, config);
|
|
10303
|
+
const stripPathPrefix = command32.homeAgent ? getAgentHomeDirPrefix(command32.homeAgent) ?? void 0 : void 0;
|
|
10256
10304
|
const response = await this.packmindGateway.deployment.install({
|
|
10257
10305
|
packagesSlugs,
|
|
10258
10306
|
packmindLockFile: effectiveLockFile,
|
|
10259
|
-
agents:
|
|
10307
|
+
agents: installAgents
|
|
10260
10308
|
});
|
|
10309
|
+
if (stripPathPrefix) {
|
|
10310
|
+
const isPackmindMirrorPath = (p) => p.startsWith(".packmind/");
|
|
10311
|
+
response.fileUpdates.createOrUpdate = response.fileUpdates.createOrUpdate.filter((file) => !isPackmindMirrorPath(file.path)).map((file) => {
|
|
10312
|
+
const remapped = {
|
|
10313
|
+
...file,
|
|
10314
|
+
path: this.stripPrefix(file.path, stripPathPrefix)
|
|
10315
|
+
};
|
|
10316
|
+
if (remapped.content !== void 0) {
|
|
10317
|
+
remapped.content = stripFullStandardLinkFooter(remapped.content);
|
|
10318
|
+
}
|
|
10319
|
+
return remapped;
|
|
10320
|
+
});
|
|
10321
|
+
response.fileUpdates.delete = response.fileUpdates.delete.filter((file) => !isPackmindMirrorPath(file.path)).map((file) => ({
|
|
10322
|
+
...file,
|
|
10323
|
+
path: this.stripPrefix(file.path, stripPathPrefix)
|
|
10324
|
+
}));
|
|
10325
|
+
response.skillFolders = response.skillFolders.filter((folder) => !isPackmindMirrorPath(folder)).map((folder) => this.stripPrefix(folder, stripPathPrefix));
|
|
10326
|
+
}
|
|
10261
10327
|
result.missingAccess = response.missingAccess;
|
|
10262
10328
|
result.resolvedAgents = response.resolvedAgents;
|
|
10263
10329
|
result.sourceArtifacts = response.sourceArtifacts;
|
|
@@ -10277,6 +10343,25 @@ var InstallUseCase = class {
|
|
|
10277
10343
|
uniqueFilesMap.set(file.path, file);
|
|
10278
10344
|
}
|
|
10279
10345
|
const uniqueFiles = Array.from(uniqueFilesMap.values());
|
|
10346
|
+
const changedArtifactIds = {
|
|
10347
|
+
skill: /* @__PURE__ */ new Set(),
|
|
10348
|
+
standard: /* @__PURE__ */ new Set(),
|
|
10349
|
+
command: /* @__PURE__ */ new Set()
|
|
10350
|
+
};
|
|
10351
|
+
const filesByArtifactId = /* @__PURE__ */ new Map();
|
|
10352
|
+
for (const file of uniqueFiles) {
|
|
10353
|
+
if (file.artifactType && file.artifactId) {
|
|
10354
|
+
const list = filesByArtifactId.get(file.artifactId) ?? [];
|
|
10355
|
+
list.push(file);
|
|
10356
|
+
filesByArtifactId.set(file.artifactId, list);
|
|
10357
|
+
}
|
|
10358
|
+
}
|
|
10359
|
+
const unchangedArtifactIds = /* @__PURE__ */ new Set();
|
|
10360
|
+
for (const [artifactId, files] of filesByArtifactId) {
|
|
10361
|
+
if (await this.allFilesAlreadyMatch(baseDirectory, files)) {
|
|
10362
|
+
unchangedArtifactIds.add(artifactId);
|
|
10363
|
+
}
|
|
10364
|
+
}
|
|
10280
10365
|
for (const file of uniqueFiles) {
|
|
10281
10366
|
if (file.path.includes(".packmind/recipes/") && file.path.endsWith(".md")) {
|
|
10282
10367
|
result.recipesCount++;
|
|
@@ -10302,9 +10387,13 @@ var InstallUseCase = class {
|
|
|
10302
10387
|
result,
|
|
10303
10388
|
file.skillFilePermissions
|
|
10304
10389
|
);
|
|
10305
|
-
|
|
10390
|
+
const fileActuallyChanged = result.filesCreated + result.filesUpdated > changesBefore;
|
|
10391
|
+
if (fileActuallyChanged && this.isContentFile(file.path)) {
|
|
10306
10392
|
result.contentFilesChanged++;
|
|
10307
10393
|
}
|
|
10394
|
+
if (fileActuallyChanged && file.artifactType && file.artifactId && !unchangedArtifactIds.has(file.artifactId)) {
|
|
10395
|
+
changedArtifactIds[file.artifactType].add(file.artifactId);
|
|
10396
|
+
}
|
|
10308
10397
|
} catch (error) {
|
|
10309
10398
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
10310
10399
|
result.errors.push(
|
|
@@ -10340,6 +10429,9 @@ var InstallUseCase = class {
|
|
|
10340
10429
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
10341
10430
|
result.errors.push(`Failed to install packages: ${errorMsg}`);
|
|
10342
10431
|
}
|
|
10432
|
+
result.skillsChanged = changedArtifactIds.skill.size;
|
|
10433
|
+
result.standardsChanged = changedArtifactIds.standard.size;
|
|
10434
|
+
result.commandsChanged = changedArtifactIds.command.size;
|
|
10343
10435
|
try {
|
|
10344
10436
|
let lockFileToPersist = effectiveLockFile;
|
|
10345
10437
|
if (serverLockFile?.content) {
|
|
@@ -10352,6 +10444,12 @@ var InstallUseCase = class {
|
|
|
10352
10444
|
delete lockFileToPersist.installedAt;
|
|
10353
10445
|
}
|
|
10354
10446
|
lockFileToPersist.cliVersion = command32.cliVersion;
|
|
10447
|
+
if (stripPathPrefix) {
|
|
10448
|
+
lockFileToPersist = this.stripLockFileArtifactPaths(
|
|
10449
|
+
lockFileToPersist,
|
|
10450
|
+
stripPathPrefix
|
|
10451
|
+
);
|
|
10452
|
+
}
|
|
10355
10453
|
await this.lockFileRepository.write(baseDirectory, lockFileToPersist);
|
|
10356
10454
|
} catch (error) {
|
|
10357
10455
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -10374,6 +10472,32 @@ var InstallUseCase = class {
|
|
|
10374
10472
|
async normalizePackageSlugs(slugs) {
|
|
10375
10473
|
return normalizePackageSlugs(slugs, this.spaceService);
|
|
10376
10474
|
}
|
|
10475
|
+
resolveInstallAgents(command32, config) {
|
|
10476
|
+
if (command32.homeAgent) {
|
|
10477
|
+
return [command32.homeAgent];
|
|
10478
|
+
}
|
|
10479
|
+
return config?.agents;
|
|
10480
|
+
}
|
|
10481
|
+
stripPrefix(filePath, prefix) {
|
|
10482
|
+
return filePath.startsWith(prefix) ? filePath.slice(prefix.length) : filePath;
|
|
10483
|
+
}
|
|
10484
|
+
// In home-install mode the on-disk files live without the agent prefix
|
|
10485
|
+
// (e.g. `commands/foo.md` instead of `.claude/commands/foo.md`) and the
|
|
10486
|
+
// `.packmind/` mirror folder is not rendered. The lockfile content returned
|
|
10487
|
+
// by the server still references the original paths, so we realign it here
|
|
10488
|
+
// before persisting — otherwise `playbook status`/`add` can't match local
|
|
10489
|
+
// files against the lockfile entries.
|
|
10490
|
+
stripLockFileArtifactPaths(lockFile, prefix) {
|
|
10491
|
+
const remappedArtifacts = {};
|
|
10492
|
+
for (const [key, entry] of Object.entries(lockFile.artifacts)) {
|
|
10493
|
+
const remappedFiles = entry.files.filter((file) => !file.path.startsWith(".packmind/")).map((file) => ({
|
|
10494
|
+
...file,
|
|
10495
|
+
path: this.stripPrefix(file.path, prefix)
|
|
10496
|
+
}));
|
|
10497
|
+
remappedArtifacts[key] = { ...entry, files: remappedFiles };
|
|
10498
|
+
}
|
|
10499
|
+
return { ...lockFile, artifacts: remappedArtifacts };
|
|
10500
|
+
}
|
|
10377
10501
|
async normalizeAndSaveConfigPackages(baseDirectory, config) {
|
|
10378
10502
|
const originalSlugs = Object.keys(config.packages);
|
|
10379
10503
|
if (originalSlugs.length === 0) return [];
|
|
@@ -10434,9 +10558,9 @@ var InstallUseCase = class {
|
|
|
10434
10558
|
return `${host}/org/${organization.slug}/spaces/${spaceSlug}/join`;
|
|
10435
10559
|
}
|
|
10436
10560
|
async createOrUpdateFile(baseDirectory, file, result, skillFilePermissions) {
|
|
10437
|
-
const fullPath =
|
|
10438
|
-
const directory =
|
|
10439
|
-
await
|
|
10561
|
+
const fullPath = path8.join(baseDirectory, file.path);
|
|
10562
|
+
const directory = path8.dirname(fullPath);
|
|
10563
|
+
await fs7.mkdir(directory, { recursive: true });
|
|
10440
10564
|
const fileExists = await this.fileExists(fullPath);
|
|
10441
10565
|
if (file.content !== void 0) {
|
|
10442
10566
|
await this.handleFullContentUpdate(
|
|
@@ -10456,13 +10580,13 @@ var InstallUseCase = class {
|
|
|
10456
10580
|
);
|
|
10457
10581
|
}
|
|
10458
10582
|
if (skillFilePermissions && supportsUnixPermissions()) {
|
|
10459
|
-
await
|
|
10583
|
+
await fs7.chmod(fullPath, parsePermissionString(skillFilePermissions));
|
|
10460
10584
|
}
|
|
10461
10585
|
}
|
|
10462
10586
|
async handleFullContentUpdate(fullPath, content, fileExists, result, isBase64) {
|
|
10463
10587
|
if (isBase64) {
|
|
10464
10588
|
const buffer = Buffer.from(content, "base64");
|
|
10465
|
-
await
|
|
10589
|
+
await fs7.writeFile(fullPath, buffer);
|
|
10466
10590
|
if (fileExists) {
|
|
10467
10591
|
result.filesUpdated++;
|
|
10468
10592
|
} else {
|
|
@@ -10471,7 +10595,7 @@ var InstallUseCase = class {
|
|
|
10471
10595
|
return;
|
|
10472
10596
|
}
|
|
10473
10597
|
if (fileExists) {
|
|
10474
|
-
const existingContent = await
|
|
10598
|
+
const existingContent = await fs7.readFile(fullPath, "utf-8");
|
|
10475
10599
|
const commentMarker = this.extractCommentMarker(content);
|
|
10476
10600
|
let finalContent;
|
|
10477
10601
|
if (!commentMarker) {
|
|
@@ -10484,18 +10608,18 @@ var InstallUseCase = class {
|
|
|
10484
10608
|
);
|
|
10485
10609
|
}
|
|
10486
10610
|
if (existingContent !== finalContent) {
|
|
10487
|
-
await
|
|
10611
|
+
await fs7.writeFile(fullPath, finalContent, "utf-8");
|
|
10488
10612
|
result.filesUpdated++;
|
|
10489
10613
|
}
|
|
10490
10614
|
} else {
|
|
10491
|
-
await
|
|
10615
|
+
await fs7.writeFile(fullPath, content, "utf-8");
|
|
10492
10616
|
result.filesCreated++;
|
|
10493
10617
|
}
|
|
10494
10618
|
}
|
|
10495
10619
|
async handleSectionsUpdate(fullPath, sections, fileExists, result, baseDirectory) {
|
|
10496
10620
|
let currentContent = "";
|
|
10497
10621
|
if (fileExists) {
|
|
10498
|
-
currentContent = await
|
|
10622
|
+
currentContent = await fs7.readFile(fullPath, "utf-8");
|
|
10499
10623
|
}
|
|
10500
10624
|
const mergedContent = mergeSectionsIntoFileContent(
|
|
10501
10625
|
currentContent,
|
|
@@ -10503,11 +10627,11 @@ var InstallUseCase = class {
|
|
|
10503
10627
|
);
|
|
10504
10628
|
if (currentContent !== mergedContent) {
|
|
10505
10629
|
if (this.isEffectivelyEmpty(mergedContent) && fileExists) {
|
|
10506
|
-
await
|
|
10630
|
+
await fs7.unlink(fullPath);
|
|
10507
10631
|
result.filesDeleted++;
|
|
10508
10632
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
10509
10633
|
} else {
|
|
10510
|
-
await
|
|
10634
|
+
await fs7.writeFile(fullPath, mergedContent, "utf-8");
|
|
10511
10635
|
if (fileExists) {
|
|
10512
10636
|
result.filesUpdated++;
|
|
10513
10637
|
} else {
|
|
@@ -10517,14 +10641,14 @@ var InstallUseCase = class {
|
|
|
10517
10641
|
}
|
|
10518
10642
|
}
|
|
10519
10643
|
async deleteFile(baseDirectory, filePath, result) {
|
|
10520
|
-
const fullPath =
|
|
10521
|
-
const stat9 = await
|
|
10644
|
+
const fullPath = path8.join(baseDirectory, filePath);
|
|
10645
|
+
const stat9 = await fs7.stat(fullPath).catch(() => null);
|
|
10522
10646
|
if (stat9?.isDirectory()) {
|
|
10523
|
-
await
|
|
10647
|
+
await fs7.rm(fullPath, { recursive: true, force: true });
|
|
10524
10648
|
result.filesDeleted++;
|
|
10525
10649
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
10526
10650
|
} else if (stat9?.isFile()) {
|
|
10527
|
-
await
|
|
10651
|
+
await fs7.unlink(fullPath);
|
|
10528
10652
|
result.filesDeleted++;
|
|
10529
10653
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
10530
10654
|
}
|
|
@@ -10534,12 +10658,36 @@ var InstallUseCase = class {
|
|
|
10534
10658
|
}
|
|
10535
10659
|
async fileExists(filePath) {
|
|
10536
10660
|
try {
|
|
10537
|
-
await
|
|
10661
|
+
await fs7.access(filePath);
|
|
10538
10662
|
return true;
|
|
10539
10663
|
} catch {
|
|
10540
10664
|
return false;
|
|
10541
10665
|
}
|
|
10542
10666
|
}
|
|
10667
|
+
// Returns true iff every file in `files` already exists on disk with the
|
|
10668
|
+
// exact content the server is about to write. Used to decide whether an
|
|
10669
|
+
// artifact (skill/standard/command) is genuinely changing this install.
|
|
10670
|
+
// Files with `sections` (index files like CLAUDE.md) carry no artifactType
|
|
10671
|
+
// and never reach this helper.
|
|
10672
|
+
async allFilesAlreadyMatch(baseDirectory, files) {
|
|
10673
|
+
for (const file of files) {
|
|
10674
|
+
if (file.content === void 0) return false;
|
|
10675
|
+
const fullPath = path8.join(baseDirectory, file.path);
|
|
10676
|
+
try {
|
|
10677
|
+
if (file.isBase64) {
|
|
10678
|
+
const expected = Buffer.from(file.content, "base64");
|
|
10679
|
+
const actual = await fs7.readFile(fullPath);
|
|
10680
|
+
if (!expected.equals(actual)) return false;
|
|
10681
|
+
} else {
|
|
10682
|
+
const actual = await fs7.readFile(fullPath, "utf-8");
|
|
10683
|
+
if (actual !== file.content) return false;
|
|
10684
|
+
}
|
|
10685
|
+
} catch {
|
|
10686
|
+
return false;
|
|
10687
|
+
}
|
|
10688
|
+
}
|
|
10689
|
+
return true;
|
|
10690
|
+
}
|
|
10543
10691
|
extractCommentMarker(content) {
|
|
10544
10692
|
const startMarkerPattern = /<!--\s*start:\s*([^-]+?)\s*-->/;
|
|
10545
10693
|
const match = content.match(startMarkerPattern);
|
|
@@ -10584,11 +10732,11 @@ ${endMarker}`;
|
|
|
10584
10732
|
async deleteSkillFolders(baseDirectory, folders) {
|
|
10585
10733
|
let deletedFilesCount = 0;
|
|
10586
10734
|
for (const folder of folders) {
|
|
10587
|
-
const fullPath =
|
|
10735
|
+
const fullPath = path8.join(baseDirectory, folder);
|
|
10588
10736
|
try {
|
|
10589
|
-
await
|
|
10737
|
+
await fs7.access(fullPath);
|
|
10590
10738
|
const fileCount = await this.countFilesInDirectory(fullPath);
|
|
10591
|
-
await
|
|
10739
|
+
await fs7.rm(fullPath, { recursive: true, force: true });
|
|
10592
10740
|
deletedFilesCount += fileCount;
|
|
10593
10741
|
await this.removeEmptyParentDirectories(fullPath, baseDirectory);
|
|
10594
10742
|
} catch {
|
|
@@ -10598,9 +10746,9 @@ ${endMarker}`;
|
|
|
10598
10746
|
}
|
|
10599
10747
|
async countFilesInDirectory(dirPath) {
|
|
10600
10748
|
let count = 0;
|
|
10601
|
-
const entries = await
|
|
10749
|
+
const entries = await fs7.readdir(dirPath, { withFileTypes: true });
|
|
10602
10750
|
for (const entry of entries) {
|
|
10603
|
-
const entryPath =
|
|
10751
|
+
const entryPath = path8.join(dirPath, entry.name);
|
|
10604
10752
|
if (entry.isDirectory()) {
|
|
10605
10753
|
count += await this.countFilesInDirectory(entryPath);
|
|
10606
10754
|
} else {
|
|
@@ -10611,24 +10759,24 @@ ${endMarker}`;
|
|
|
10611
10759
|
}
|
|
10612
10760
|
async isDirectoryEmpty(dirPath) {
|
|
10613
10761
|
try {
|
|
10614
|
-
const entries = await
|
|
10762
|
+
const entries = await fs7.readdir(dirPath);
|
|
10615
10763
|
return entries.length === 0;
|
|
10616
10764
|
} catch {
|
|
10617
10765
|
return false;
|
|
10618
10766
|
}
|
|
10619
10767
|
}
|
|
10620
10768
|
async removeEmptyParentDirectories(fullPath, baseDirectory) {
|
|
10621
|
-
const normalizedBase =
|
|
10622
|
-
let currentDir =
|
|
10623
|
-
while (currentDir.startsWith(normalizedBase +
|
|
10769
|
+
const normalizedBase = path8.resolve(baseDirectory);
|
|
10770
|
+
let currentDir = path8.dirname(path8.resolve(fullPath));
|
|
10771
|
+
while (currentDir.startsWith(normalizedBase + path8.sep) && currentDir !== normalizedBase) {
|
|
10624
10772
|
const isEmpty = await this.isDirectoryEmpty(currentDir);
|
|
10625
10773
|
if (!isEmpty) break;
|
|
10626
10774
|
try {
|
|
10627
|
-
await
|
|
10775
|
+
await fs7.rmdir(currentDir);
|
|
10628
10776
|
} catch {
|
|
10629
10777
|
break;
|
|
10630
10778
|
}
|
|
10631
|
-
currentDir =
|
|
10779
|
+
currentDir = path8.dirname(currentDir);
|
|
10632
10780
|
}
|
|
10633
10781
|
}
|
|
10634
10782
|
};
|
|
@@ -10692,8 +10840,8 @@ ${pkgList}`
|
|
|
10692
10840
|
};
|
|
10693
10841
|
|
|
10694
10842
|
// apps/cli/src/application/useCases/InstallDefaultSkillsUseCase.ts
|
|
10695
|
-
var
|
|
10696
|
-
var
|
|
10843
|
+
var fs8 = __toESM(require("fs/promises"));
|
|
10844
|
+
var path9 = __toESM(require("path"));
|
|
10697
10845
|
var import_semver = __toESM(require("semver"));
|
|
10698
10846
|
|
|
10699
10847
|
// apps/cli/src/application/utils/normalizeSemver.ts
|
|
@@ -10745,9 +10893,9 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
10745
10893
|
const incompatibleSkillDirs = /* @__PURE__ */ new Map();
|
|
10746
10894
|
if (command32.cliVersion) {
|
|
10747
10895
|
for (const file of response.fileUpdates.createOrUpdate) {
|
|
10748
|
-
if (
|
|
10749
|
-
const dir =
|
|
10750
|
-
const skillName = this.getSkillName(file.content) ??
|
|
10896
|
+
if (path9.basename(file.path) === "SKILL.md" && file.content && this.isVersionConstraintViolated(file.content, command32.cliVersion)) {
|
|
10897
|
+
const dir = path9.dirname(file.path);
|
|
10898
|
+
const skillName = this.getSkillName(file.content) ?? path9.basename(dir);
|
|
10751
10899
|
incompatibleSkillDirs.set(dir, skillName);
|
|
10752
10900
|
}
|
|
10753
10901
|
}
|
|
@@ -10764,8 +10912,8 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
10764
10912
|
incompatibleSkillDirs
|
|
10765
10913
|
));
|
|
10766
10914
|
if (isIncompatible) {
|
|
10767
|
-
const skillName = this.getSkillName(file.content) ?? this.getSkillNameForPath(file.path, incompatibleSkillDirs) ??
|
|
10768
|
-
const fullPath =
|
|
10915
|
+
const skillName = this.getSkillName(file.content) ?? this.getSkillNameForPath(file.path, incompatibleSkillDirs) ?? path9.basename(file.path);
|
|
10916
|
+
const fullPath = path9.join(baseDirectory, file.path);
|
|
10769
10917
|
const fileAlreadyInstalled = await this.fileExists(fullPath);
|
|
10770
10918
|
if (fileAlreadyInstalled) {
|
|
10771
10919
|
const paths = incompatibleInstalledMap.get(skillName) ?? [];
|
|
@@ -10882,24 +11030,24 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
10882
11030
|
);
|
|
10883
11031
|
}
|
|
10884
11032
|
async createOrUpdateFile(baseDirectory, file, result) {
|
|
10885
|
-
const fullPath =
|
|
10886
|
-
const directory =
|
|
10887
|
-
await
|
|
11033
|
+
const fullPath = path9.join(baseDirectory, file.path);
|
|
11034
|
+
const directory = path9.dirname(fullPath);
|
|
11035
|
+
await fs8.mkdir(directory, { recursive: true });
|
|
10888
11036
|
const fileExists = await this.fileExists(fullPath);
|
|
10889
11037
|
if (fileExists) {
|
|
10890
|
-
const existingContent = await
|
|
11038
|
+
const existingContent = await fs8.readFile(fullPath, "utf-8");
|
|
10891
11039
|
if (existingContent !== file.content) {
|
|
10892
|
-
await
|
|
11040
|
+
await fs8.writeFile(fullPath, file.content, "utf-8");
|
|
10893
11041
|
result.filesUpdated++;
|
|
10894
11042
|
}
|
|
10895
11043
|
} else {
|
|
10896
|
-
await
|
|
11044
|
+
await fs8.writeFile(fullPath, file.content, "utf-8");
|
|
10897
11045
|
result.filesCreated++;
|
|
10898
11046
|
}
|
|
10899
11047
|
}
|
|
10900
11048
|
async fileExists(filePath) {
|
|
10901
11049
|
try {
|
|
10902
|
-
await
|
|
11050
|
+
await fs8.access(filePath);
|
|
10903
11051
|
return true;
|
|
10904
11052
|
} catch {
|
|
10905
11053
|
return false;
|
|
@@ -10918,7 +11066,7 @@ var InstallDefaultSkillsUseCase = class {
|
|
|
10918
11066
|
*/
|
|
10919
11067
|
getSkillNameForPath(filePath, incompatibleSkillDirs) {
|
|
10920
11068
|
for (const [dir, skillName] of incompatibleSkillDirs.entries()) {
|
|
10921
|
-
if (filePath === dir || filePath.startsWith(dir + "/") || filePath.startsWith(dir +
|
|
11069
|
+
if (filePath === dir || filePath.startsWith(dir + "/") || filePath.startsWith(dir + path9.sep)) {
|
|
10922
11070
|
return skillName;
|
|
10923
11071
|
}
|
|
10924
11072
|
}
|
|
@@ -11091,13 +11239,13 @@ var EnvCredentialsProvider = class {
|
|
|
11091
11239
|
};
|
|
11092
11240
|
|
|
11093
11241
|
// apps/cli/src/infra/utils/credentials/FileCredentialsProvider.ts
|
|
11094
|
-
var
|
|
11095
|
-
var
|
|
11096
|
-
var
|
|
11242
|
+
var fs9 = __toESM(require("fs"));
|
|
11243
|
+
var path10 = __toESM(require("path"));
|
|
11244
|
+
var os3 = __toESM(require("os"));
|
|
11097
11245
|
var CREDENTIALS_DIR = ".packmind";
|
|
11098
11246
|
var CREDENTIALS_FILE = "credentials.json";
|
|
11099
11247
|
function getCredentialsPath() {
|
|
11100
|
-
return
|
|
11248
|
+
return path10.join(os3.homedir(), CREDENTIALS_DIR, CREDENTIALS_FILE);
|
|
11101
11249
|
}
|
|
11102
11250
|
var FileCredentialsProvider = class {
|
|
11103
11251
|
getSourceName() {
|
|
@@ -11105,11 +11253,11 @@ var FileCredentialsProvider = class {
|
|
|
11105
11253
|
}
|
|
11106
11254
|
hasCredentials() {
|
|
11107
11255
|
const credentialsPath = getCredentialsPath();
|
|
11108
|
-
if (!
|
|
11256
|
+
if (!fs9.existsSync(credentialsPath)) {
|
|
11109
11257
|
return false;
|
|
11110
11258
|
}
|
|
11111
11259
|
try {
|
|
11112
|
-
const content =
|
|
11260
|
+
const content = fs9.readFileSync(credentialsPath, "utf-8");
|
|
11113
11261
|
const credentials = JSON.parse(content);
|
|
11114
11262
|
return !!credentials.apiKey;
|
|
11115
11263
|
} catch {
|
|
@@ -11118,11 +11266,11 @@ var FileCredentialsProvider = class {
|
|
|
11118
11266
|
}
|
|
11119
11267
|
loadCredentials() {
|
|
11120
11268
|
const credentialsPath = getCredentialsPath();
|
|
11121
|
-
if (!
|
|
11269
|
+
if (!fs9.existsSync(credentialsPath)) {
|
|
11122
11270
|
return null;
|
|
11123
11271
|
}
|
|
11124
11272
|
try {
|
|
11125
|
-
const content =
|
|
11273
|
+
const content = fs9.readFileSync(credentialsPath, "utf-8");
|
|
11126
11274
|
const credentials = JSON.parse(content);
|
|
11127
11275
|
if (!credentials.apiKey) {
|
|
11128
11276
|
return null;
|
|
@@ -11145,13 +11293,13 @@ var FileCredentialsProvider = class {
|
|
|
11145
11293
|
}
|
|
11146
11294
|
};
|
|
11147
11295
|
function saveCredentials(apiKey) {
|
|
11148
|
-
const credentialsDir =
|
|
11149
|
-
if (!
|
|
11150
|
-
|
|
11296
|
+
const credentialsDir = path10.join(os3.homedir(), CREDENTIALS_DIR);
|
|
11297
|
+
if (!fs9.existsSync(credentialsDir)) {
|
|
11298
|
+
fs9.mkdirSync(credentialsDir, { recursive: true, mode: 448 });
|
|
11151
11299
|
}
|
|
11152
11300
|
const credentialsPath = getCredentialsPath();
|
|
11153
11301
|
const credentials = { apiKey };
|
|
11154
|
-
|
|
11302
|
+
fs9.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {
|
|
11155
11303
|
mode: 384
|
|
11156
11304
|
});
|
|
11157
11305
|
}
|
|
@@ -11222,10 +11370,10 @@ async function defaultPromptForCode() {
|
|
|
11222
11370
|
input: process.stdin,
|
|
11223
11371
|
output: process.stdout
|
|
11224
11372
|
});
|
|
11225
|
-
return new Promise((
|
|
11373
|
+
return new Promise((resolve16) => {
|
|
11226
11374
|
rl.question("Enter the login code from the browser: ", (answer) => {
|
|
11227
11375
|
rl.close();
|
|
11228
|
-
|
|
11376
|
+
resolve16(answer.trim());
|
|
11229
11377
|
});
|
|
11230
11378
|
});
|
|
11231
11379
|
}
|
|
@@ -11259,7 +11407,7 @@ async function defaultExchangeCodeForApiKey(code, host) {
|
|
|
11259
11407
|
return await response.json();
|
|
11260
11408
|
}
|
|
11261
11409
|
function defaultStartCallbackServer() {
|
|
11262
|
-
return new Promise((
|
|
11410
|
+
return new Promise((resolve16, reject) => {
|
|
11263
11411
|
let timeoutId = null;
|
|
11264
11412
|
const server = http.createServer((req, res) => {
|
|
11265
11413
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
@@ -11272,7 +11420,7 @@ function defaultStartCallbackServer() {
|
|
|
11272
11420
|
if (timeoutId) {
|
|
11273
11421
|
clearTimeout(timeoutId);
|
|
11274
11422
|
}
|
|
11275
|
-
|
|
11423
|
+
resolve16(code);
|
|
11276
11424
|
setImmediate(() => {
|
|
11277
11425
|
server.close();
|
|
11278
11426
|
});
|
|
@@ -11343,13 +11491,13 @@ var LoginUseCase = class {
|
|
|
11343
11491
|
};
|
|
11344
11492
|
|
|
11345
11493
|
// apps/cli/src/application/useCases/LogoutUseCase.ts
|
|
11346
|
-
var
|
|
11494
|
+
var fs10 = __toESM(require("fs"));
|
|
11347
11495
|
var LogoutUseCase = class {
|
|
11348
11496
|
constructor(deps) {
|
|
11349
11497
|
this.deps = {
|
|
11350
11498
|
getCredentialsPath: deps?.getCredentialsPath ?? getCredentialsPath,
|
|
11351
|
-
fileExists: deps?.fileExists ?? ((
|
|
11352
|
-
deleteFile: deps?.deleteFile ?? ((
|
|
11499
|
+
fileExists: deps?.fileExists ?? ((path37) => fs10.existsSync(path37)),
|
|
11500
|
+
deleteFile: deps?.deleteFile ?? ((path37) => fs10.unlinkSync(path37)),
|
|
11353
11501
|
hasEnvVar: deps?.hasEnvVar ?? (() => ENV_VAR_NAMES.some((name) => {
|
|
11354
11502
|
const value = process.env[name];
|
|
11355
11503
|
return !!value && value.trim().length > 0;
|
|
@@ -11622,23 +11770,23 @@ async function updateHandler(deps) {
|
|
|
11622
11770
|
}
|
|
11623
11771
|
|
|
11624
11772
|
// apps/cli/src/infra/utils/versionCache/FileVersionCacheProvider.ts
|
|
11625
|
-
var
|
|
11626
|
-
var
|
|
11627
|
-
var
|
|
11773
|
+
var fs11 = __toESM(require("fs"));
|
|
11774
|
+
var os4 = __toESM(require("os"));
|
|
11775
|
+
var path12 = __toESM(require("path"));
|
|
11628
11776
|
var import_semver4 = __toESM(require("semver"));
|
|
11629
11777
|
var CACHE_DIR = ".packmind";
|
|
11630
11778
|
var CACHE_FILE = "version-check.json";
|
|
11631
11779
|
function getCachePath() {
|
|
11632
|
-
return
|
|
11780
|
+
return path12.join(os4.homedir(), CACHE_DIR, CACHE_FILE);
|
|
11633
11781
|
}
|
|
11634
11782
|
var FileVersionCacheProvider = class {
|
|
11635
11783
|
read() {
|
|
11636
11784
|
const cachePath = getCachePath();
|
|
11637
|
-
if (!
|
|
11785
|
+
if (!fs11.existsSync(cachePath)) {
|
|
11638
11786
|
return null;
|
|
11639
11787
|
}
|
|
11640
11788
|
try {
|
|
11641
|
-
const content =
|
|
11789
|
+
const content = fs11.readFileSync(cachePath, "utf-8");
|
|
11642
11790
|
const stored = JSON.parse(content);
|
|
11643
11791
|
if (!stored.latestVersion || !stored.checkedAt) {
|
|
11644
11792
|
return null;
|
|
@@ -11659,10 +11807,10 @@ var FileVersionCacheProvider = class {
|
|
|
11659
11807
|
}
|
|
11660
11808
|
}
|
|
11661
11809
|
write(entry) {
|
|
11662
|
-
const cacheDir =
|
|
11810
|
+
const cacheDir = path12.join(os4.homedir(), CACHE_DIR);
|
|
11663
11811
|
try {
|
|
11664
|
-
if (!
|
|
11665
|
-
|
|
11812
|
+
if (!fs11.existsSync(cacheDir)) {
|
|
11813
|
+
fs11.mkdirSync(cacheDir, { recursive: true, mode: 448 });
|
|
11666
11814
|
}
|
|
11667
11815
|
const stored = {
|
|
11668
11816
|
latestVersion: entry.latestVersion,
|
|
@@ -11670,10 +11818,10 @@ var FileVersionCacheProvider = class {
|
|
|
11670
11818
|
};
|
|
11671
11819
|
const cachePath = getCachePath();
|
|
11672
11820
|
const tmpPath = `${cachePath}.${process.pid}.tmp`;
|
|
11673
|
-
|
|
11821
|
+
fs11.writeFileSync(tmpPath, JSON.stringify(stored, null, 2), {
|
|
11674
11822
|
mode: 384
|
|
11675
11823
|
});
|
|
11676
|
-
|
|
11824
|
+
fs11.renameSync(tmpPath, cachePath);
|
|
11677
11825
|
} catch {
|
|
11678
11826
|
}
|
|
11679
11827
|
}
|
|
@@ -11743,8 +11891,8 @@ var CheckCliVersionUseCase = class {
|
|
|
11743
11891
|
};
|
|
11744
11892
|
|
|
11745
11893
|
// apps/cli/src/infra/repositories/ConfigFileRepository.ts
|
|
11746
|
-
var
|
|
11747
|
-
var
|
|
11894
|
+
var fs12 = __toESM(require("fs/promises"));
|
|
11895
|
+
var path13 = __toESM(require("path"));
|
|
11748
11896
|
var ConfigFileRepository = class {
|
|
11749
11897
|
constructor() {
|
|
11750
11898
|
this.CONFIG_FILENAME = "packmind.json";
|
|
@@ -11765,7 +11913,7 @@ var ConfigFileRepository = class {
|
|
|
11765
11913
|
async configExists(baseDirectory) {
|
|
11766
11914
|
const configPath = this.getConfigPath(baseDirectory);
|
|
11767
11915
|
try {
|
|
11768
|
-
await
|
|
11916
|
+
await fs12.access(configPath);
|
|
11769
11917
|
return true;
|
|
11770
11918
|
} catch {
|
|
11771
11919
|
return false;
|
|
@@ -11774,7 +11922,7 @@ var ConfigFileRepository = class {
|
|
|
11774
11922
|
async readConfig(baseDirectory) {
|
|
11775
11923
|
const configPath = this.getConfigPath(baseDirectory);
|
|
11776
11924
|
try {
|
|
11777
|
-
const configContent = await
|
|
11925
|
+
const configContent = await fs12.readFile(configPath, "utf-8");
|
|
11778
11926
|
const rawConfig = JSON.parse(configContent);
|
|
11779
11927
|
if (!rawConfig.packages || typeof rawConfig.packages !== "object") {
|
|
11780
11928
|
throw new Error(
|
|
@@ -11808,18 +11956,18 @@ var ConfigFileRepository = class {
|
|
|
11808
11956
|
}
|
|
11809
11957
|
}
|
|
11810
11958
|
getConfigPath(directory) {
|
|
11811
|
-
return
|
|
11959
|
+
return path13.join(directory, this.CONFIG_FILENAME);
|
|
11812
11960
|
}
|
|
11813
11961
|
async writeConfigToPath(configPath, config) {
|
|
11814
11962
|
const configContent = JSON.stringify(config, null, 2) + "\n";
|
|
11815
|
-
await
|
|
11963
|
+
await fs12.writeFile(configPath, configContent, "utf-8");
|
|
11816
11964
|
}
|
|
11817
11965
|
/**
|
|
11818
11966
|
* Recursively finds all directories containing packmind.json in descendant folders.
|
|
11819
11967
|
* Excludes common build/dependency directories (node_modules, .git, dist, etc.)
|
|
11820
11968
|
*/
|
|
11821
11969
|
async findDescendantConfigs(directory) {
|
|
11822
|
-
const normalizedDir = normalizePath2(
|
|
11970
|
+
const normalizedDir = normalizePath2(path13.resolve(directory));
|
|
11823
11971
|
return this.searchDescendantsRecursively(normalizedDir);
|
|
11824
11972
|
}
|
|
11825
11973
|
async searchDescendantsRecursively(currentDir) {
|
|
@@ -11832,7 +11980,7 @@ var ConfigFileRepository = class {
|
|
|
11832
11980
|
if (!entry.isDirectory() || this.isExcludedDirectory(entry.name)) {
|
|
11833
11981
|
continue;
|
|
11834
11982
|
}
|
|
11835
|
-
const entryPath = normalizePath2(
|
|
11983
|
+
const entryPath = normalizePath2(path13.join(currentDir, entry.name));
|
|
11836
11984
|
const config = await this.readConfig(entryPath);
|
|
11837
11985
|
if (config) {
|
|
11838
11986
|
results.push(entryPath);
|
|
@@ -11844,7 +11992,7 @@ var ConfigFileRepository = class {
|
|
|
11844
11992
|
}
|
|
11845
11993
|
async tryReadDirectory(directory) {
|
|
11846
11994
|
try {
|
|
11847
|
-
return await
|
|
11995
|
+
return await fs12.readdir(directory, { withFileTypes: true });
|
|
11848
11996
|
} catch {
|
|
11849
11997
|
return null;
|
|
11850
11998
|
}
|
|
@@ -11863,21 +12011,21 @@ var ConfigFileRepository = class {
|
|
|
11863
12011
|
async readHierarchicalConfig(startDirectory, stopDirectory) {
|
|
11864
12012
|
const configs = [];
|
|
11865
12013
|
const configPaths = [];
|
|
11866
|
-
const normalizedStart = normalizePath2(
|
|
11867
|
-
const normalizedStop = stopDirectory ? normalizePath2(
|
|
12014
|
+
const normalizedStart = normalizePath2(path13.resolve(startDirectory));
|
|
12015
|
+
const normalizedStop = stopDirectory ? normalizePath2(path13.resolve(stopDirectory)) : null;
|
|
11868
12016
|
let currentDir = normalizedStart;
|
|
11869
12017
|
while (true) {
|
|
11870
12018
|
const config = await this.readConfig(currentDir);
|
|
11871
12019
|
if (config) {
|
|
11872
12020
|
configs.push(config);
|
|
11873
12021
|
configPaths.push(
|
|
11874
|
-
normalizePath2(
|
|
12022
|
+
normalizePath2(path13.join(currentDir, this.CONFIG_FILENAME))
|
|
11875
12023
|
);
|
|
11876
12024
|
}
|
|
11877
12025
|
if (normalizedStop !== null && currentDir === normalizedStop) {
|
|
11878
12026
|
break;
|
|
11879
12027
|
}
|
|
11880
|
-
const parentDir = normalizePath2(
|
|
12028
|
+
const parentDir = normalizePath2(path13.dirname(currentDir));
|
|
11881
12029
|
if (parentDir === currentDir) {
|
|
11882
12030
|
break;
|
|
11883
12031
|
}
|
|
@@ -11902,8 +12050,8 @@ var ConfigFileRepository = class {
|
|
|
11902
12050
|
* and returns each config with its target path.
|
|
11903
12051
|
*/
|
|
11904
12052
|
async findAllConfigsInTree(startDirectory, stopDirectory) {
|
|
11905
|
-
const normalizedStart = normalizePath2(
|
|
11906
|
-
const normalizedStop = stopDirectory ? normalizePath2(
|
|
12053
|
+
const normalizedStart = normalizePath2(path13.resolve(startDirectory));
|
|
12054
|
+
const normalizedStop = stopDirectory ? normalizePath2(path13.resolve(stopDirectory)) : null;
|
|
11907
12055
|
const basePath = normalizedStop ?? normalizedStart;
|
|
11908
12056
|
const searchRoot = normalizedStop ?? normalizedStart;
|
|
11909
12057
|
const configsMap = /* @__PURE__ */ new Map();
|
|
@@ -11929,7 +12077,7 @@ var ConfigFileRepository = class {
|
|
|
11929
12077
|
if (stopDir !== null && currentDir === stopDir) {
|
|
11930
12078
|
break;
|
|
11931
12079
|
}
|
|
11932
|
-
const parentDir = normalizePath2(
|
|
12080
|
+
const parentDir = normalizePath2(path13.dirname(currentDir));
|
|
11933
12081
|
if (parentDir === currentDir) {
|
|
11934
12082
|
break;
|
|
11935
12083
|
}
|
|
@@ -12060,7 +12208,7 @@ var ConfigFileRepository = class {
|
|
|
12060
12208
|
}
|
|
12061
12209
|
async tryReadFile(filePath) {
|
|
12062
12210
|
try {
|
|
12063
|
-
return await
|
|
12211
|
+
return await fs12.readFile(filePath, "utf-8");
|
|
12064
12212
|
} catch (error) {
|
|
12065
12213
|
if (error.code === "ENOENT") {
|
|
12066
12214
|
return null;
|
|
@@ -12078,8 +12226,8 @@ var ConfigFileRepository = class {
|
|
|
12078
12226
|
};
|
|
12079
12227
|
|
|
12080
12228
|
// apps/cli/src/infra/repositories/LockFileRepository.ts
|
|
12081
|
-
var
|
|
12082
|
-
var
|
|
12229
|
+
var fs13 = __toESM(require("fs/promises"));
|
|
12230
|
+
var path14 = __toESM(require("path"));
|
|
12083
12231
|
var LockFileRepository = class {
|
|
12084
12232
|
constructor() {
|
|
12085
12233
|
this.LOCK_FILENAME = "packmind-lock.json";
|
|
@@ -12088,7 +12236,7 @@ var LockFileRepository = class {
|
|
|
12088
12236
|
async read(baseDirectory) {
|
|
12089
12237
|
const lockFilePath = this.getLockFilePath(baseDirectory);
|
|
12090
12238
|
try {
|
|
12091
|
-
const content = await
|
|
12239
|
+
const content = await fs13.readFile(lockFilePath, "utf-8");
|
|
12092
12240
|
const parsed = JSON.parse(content);
|
|
12093
12241
|
if (!this.isValidLockFile(parsed)) {
|
|
12094
12242
|
logWarningConsole(`Malformed lock file: ${lockFilePath}`);
|
|
@@ -12112,7 +12260,7 @@ var LockFileRepository = class {
|
|
|
12112
12260
|
async write(baseDirectory, lockFile) {
|
|
12113
12261
|
const lockFilePath = this.getLockFilePath(baseDirectory);
|
|
12114
12262
|
const serialized = JSON.stringify(lockFile, null, 2) + "\n";
|
|
12115
|
-
await
|
|
12263
|
+
await fs13.writeFile(lockFilePath, serialized, "utf-8");
|
|
12116
12264
|
}
|
|
12117
12265
|
isValidLockFile(data) {
|
|
12118
12266
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
@@ -12152,7 +12300,7 @@ var LockFileRepository = class {
|
|
|
12152
12300
|
};
|
|
12153
12301
|
}
|
|
12154
12302
|
getLockFilePath(baseDirectory) {
|
|
12155
|
-
return
|
|
12303
|
+
return path14.join(baseDirectory, this.LOCK_FILENAME);
|
|
12156
12304
|
}
|
|
12157
12305
|
};
|
|
12158
12306
|
|
|
@@ -12248,7 +12396,7 @@ function normalizeLineEndings(content) {
|
|
|
12248
12396
|
}
|
|
12249
12397
|
|
|
12250
12398
|
// apps/cli/src/infra/utils/binaryDetection.ts
|
|
12251
|
-
var
|
|
12399
|
+
var path15 = __toESM(require("path"));
|
|
12252
12400
|
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
12253
12401
|
// Images
|
|
12254
12402
|
".png",
|
|
@@ -12306,7 +12454,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
12306
12454
|
".sqlite3"
|
|
12307
12455
|
]);
|
|
12308
12456
|
function isBinaryExtension(filePath) {
|
|
12309
|
-
const ext =
|
|
12457
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
12310
12458
|
return BINARY_EXTENSIONS.has(ext);
|
|
12311
12459
|
}
|
|
12312
12460
|
function isBinaryBuffer(buffer) {
|
|
@@ -12452,17 +12600,17 @@ ${spaceList}`
|
|
|
12452
12600
|
|
|
12453
12601
|
// apps/cli/src/application/useCases/diffStrategies/CommandDiffStrategy.ts
|
|
12454
12602
|
var import_diff2 = require("diff");
|
|
12455
|
-
var
|
|
12456
|
-
var
|
|
12603
|
+
var fs15 = __toESM(require("fs/promises"));
|
|
12604
|
+
var path17 = __toESM(require("path"));
|
|
12457
12605
|
var CommandDiffStrategy = class {
|
|
12458
12606
|
supports(file) {
|
|
12459
12607
|
return file.artifactType === "command";
|
|
12460
12608
|
}
|
|
12461
12609
|
async diff(file, baseDirectory) {
|
|
12462
|
-
const fullPath =
|
|
12610
|
+
const fullPath = path17.join(baseDirectory, file.path);
|
|
12463
12611
|
let localContent;
|
|
12464
12612
|
try {
|
|
12465
|
-
localContent = await
|
|
12613
|
+
localContent = await fs15.readFile(fullPath, "utf-8");
|
|
12466
12614
|
} catch {
|
|
12467
12615
|
return [];
|
|
12468
12616
|
}
|
|
@@ -12492,8 +12640,8 @@ var CommandDiffStrategy = class {
|
|
|
12492
12640
|
|
|
12493
12641
|
// apps/cli/src/application/useCases/diffStrategies/SkillDiffStrategy.ts
|
|
12494
12642
|
var import_diff3 = require("diff");
|
|
12495
|
-
var
|
|
12496
|
-
var
|
|
12643
|
+
var fs16 = __toESM(require("fs/promises"));
|
|
12644
|
+
var path18 = __toESM(require("path"));
|
|
12497
12645
|
|
|
12498
12646
|
// apps/cli/src/application/utils/stripFrontmatter.ts
|
|
12499
12647
|
var FRONTMATTER_DELIMITER2 = "---";
|
|
@@ -12528,7 +12676,7 @@ var SkillDiffStrategy = class {
|
|
|
12528
12676
|
async diffNewFiles(skillFolders, serverFiles, baseDirectory) {
|
|
12529
12677
|
const diffs = [];
|
|
12530
12678
|
for (const folder of skillFolders) {
|
|
12531
|
-
const folderPath =
|
|
12679
|
+
const folderPath = path18.join(baseDirectory, folder);
|
|
12532
12680
|
const localFiles = await this.listFilesRecursively(folderPath);
|
|
12533
12681
|
const serverPathsInFolder = new Set(
|
|
12534
12682
|
serverFiles.filter((f) => f.path.startsWith(folder + "/")).map((f) => f.path)
|
|
@@ -12547,7 +12695,7 @@ var SkillDiffStrategy = class {
|
|
|
12547
12695
|
if (serverPathsInFolder.has(filePath)) {
|
|
12548
12696
|
continue;
|
|
12549
12697
|
}
|
|
12550
|
-
const fullPath =
|
|
12698
|
+
const fullPath = path18.join(baseDirectory, filePath);
|
|
12551
12699
|
const localRead = await this.tryReadFileBinaryAware(fullPath);
|
|
12552
12700
|
if (localRead === null) {
|
|
12553
12701
|
continue;
|
|
@@ -12574,7 +12722,7 @@ var SkillDiffStrategy = class {
|
|
|
12574
12722
|
return diffs;
|
|
12575
12723
|
}
|
|
12576
12724
|
async diffSkillMd(file, baseDirectory) {
|
|
12577
|
-
const fullPath =
|
|
12725
|
+
const fullPath = path18.join(baseDirectory, file.path);
|
|
12578
12726
|
const localContent = await this.tryReadFile(fullPath);
|
|
12579
12727
|
if (localContent === null) {
|
|
12580
12728
|
return [];
|
|
@@ -12631,7 +12779,7 @@ var SkillDiffStrategy = class {
|
|
|
12631
12779
|
return [];
|
|
12632
12780
|
}
|
|
12633
12781
|
const skillFileId = createSkillFileId(file.skillFileId);
|
|
12634
|
-
const fullPath =
|
|
12782
|
+
const fullPath = path18.join(baseDirectory, file.path);
|
|
12635
12783
|
const localRead = await this.tryReadFileBinaryAware(fullPath);
|
|
12636
12784
|
const fileRelativePath = this.computeRelativePath(file.path, skillFolders);
|
|
12637
12785
|
if (localRead === null) {
|
|
@@ -12841,14 +12989,14 @@ var SkillDiffStrategy = class {
|
|
|
12841
12989
|
}
|
|
12842
12990
|
async tryReadFile(filePath) {
|
|
12843
12991
|
try {
|
|
12844
|
-
return await
|
|
12992
|
+
return await fs16.readFile(filePath, "utf-8");
|
|
12845
12993
|
} catch {
|
|
12846
12994
|
return null;
|
|
12847
12995
|
}
|
|
12848
12996
|
}
|
|
12849
12997
|
async tryReadFileBinaryAware(filePath) {
|
|
12850
12998
|
try {
|
|
12851
|
-
const buffer = await
|
|
12999
|
+
const buffer = await fs16.readFile(filePath);
|
|
12852
13000
|
if (isBinaryFile(filePath, buffer)) {
|
|
12853
13001
|
return { content: buffer.toString("base64"), isBase64: true };
|
|
12854
13002
|
}
|
|
@@ -12860,13 +13008,13 @@ var SkillDiffStrategy = class {
|
|
|
12860
13008
|
async listFilesRecursively(dirPath, prefix = "") {
|
|
12861
13009
|
let entries;
|
|
12862
13010
|
try {
|
|
12863
|
-
entries = await
|
|
13011
|
+
entries = await fs16.readdir(dirPath);
|
|
12864
13012
|
} catch {
|
|
12865
13013
|
return [];
|
|
12866
13014
|
}
|
|
12867
13015
|
const files = [];
|
|
12868
13016
|
for (const entry of entries) {
|
|
12869
|
-
const fullPath =
|
|
13017
|
+
const fullPath = path18.join(dirPath, entry);
|
|
12870
13018
|
const stat9 = await this.tryStatFile(fullPath);
|
|
12871
13019
|
if (!stat9) {
|
|
12872
13020
|
continue;
|
|
@@ -12886,7 +13034,7 @@ var SkillDiffStrategy = class {
|
|
|
12886
13034
|
}
|
|
12887
13035
|
async tryStatFile(filePath) {
|
|
12888
13036
|
try {
|
|
12889
|
-
const stat9 = await
|
|
13037
|
+
const stat9 = await fs16.stat(filePath);
|
|
12890
13038
|
return { isDirectory: stat9.isDirectory() };
|
|
12891
13039
|
} catch {
|
|
12892
13040
|
return null;
|
|
@@ -12894,7 +13042,7 @@ var SkillDiffStrategy = class {
|
|
|
12894
13042
|
}
|
|
12895
13043
|
async tryGetPermissions(filePath) {
|
|
12896
13044
|
try {
|
|
12897
|
-
const stat9 = await
|
|
13045
|
+
const stat9 = await fs16.stat(filePath);
|
|
12898
13046
|
return modeToPermissionStringOrDefault(stat9.mode);
|
|
12899
13047
|
} catch {
|
|
12900
13048
|
return null;
|
|
@@ -12910,8 +13058,8 @@ var SkillDiffStrategy = class {
|
|
|
12910
13058
|
};
|
|
12911
13059
|
|
|
12912
13060
|
// apps/cli/src/application/useCases/diffStrategies/StandardDiffStrategy.ts
|
|
12913
|
-
var
|
|
12914
|
-
var
|
|
13061
|
+
var fs17 = __toESM(require("fs/promises"));
|
|
13062
|
+
var path19 = __toESM(require("path"));
|
|
12915
13063
|
|
|
12916
13064
|
// apps/cli/src/application/utils/parseStandardMd.ts
|
|
12917
13065
|
var DEPLOYER_PARSERS = [
|
|
@@ -12922,7 +13070,13 @@ var DEPLOYER_PARSERS = [
|
|
|
12922
13070
|
pattern: ".continue/rules/packmind/standard-",
|
|
12923
13071
|
parse: parseContinueStandard
|
|
12924
13072
|
},
|
|
12925
|
-
{ pattern: ".github/instructions/packmind-", parse: parseCopilotStandard }
|
|
13073
|
+
{ pattern: ".github/instructions/packmind-", parse: parseCopilotStandard },
|
|
13074
|
+
// Home-install variant (e.g. `~/.claude`): the agent directory prefix is
|
|
13075
|
+
// stripped from on-disk and lockfile paths. Only Claude supports home-install
|
|
13076
|
+
// today, so an unprefixed `rules/packmind/standard-…` path is Claude-rendered.
|
|
13077
|
+
// Keep this entry last so the prefixed patterns above still win for in-repo
|
|
13078
|
+
// installs whose paths happen to contain this suffix.
|
|
13079
|
+
{ pattern: "rules/packmind/standard-", parse: parseClaudeStandard }
|
|
12926
13080
|
];
|
|
12927
13081
|
function parseStandardMd(content, filePath) {
|
|
12928
13082
|
const deployer = DEPLOYER_PARSERS.find((d) => filePath.includes(d.pattern));
|
|
@@ -13219,10 +13373,10 @@ var StandardDiffStrategy = class {
|
|
|
13219
13373
|
return file.artifactType === "standard";
|
|
13220
13374
|
}
|
|
13221
13375
|
async diff(file, baseDirectory) {
|
|
13222
|
-
const fullPath =
|
|
13376
|
+
const fullPath = path19.join(baseDirectory, file.path);
|
|
13223
13377
|
let localContent;
|
|
13224
13378
|
try {
|
|
13225
|
-
localContent = await
|
|
13379
|
+
localContent = await fs17.readFile(fullPath, "utf-8");
|
|
13226
13380
|
} catch {
|
|
13227
13381
|
return [];
|
|
13228
13382
|
}
|
|
@@ -14139,31 +14293,31 @@ var HumanReadableLogger = class {
|
|
|
14139
14293
|
var pathModule2 = __toESM(require("path"));
|
|
14140
14294
|
|
|
14141
14295
|
// apps/cli/src/infra/commands/lintHandler.ts
|
|
14142
|
-
var
|
|
14296
|
+
var fs19 = __toESM(require("fs/promises"));
|
|
14143
14297
|
var pathModule = __toESM(require("path"));
|
|
14144
14298
|
|
|
14145
14299
|
// apps/cli/src/application/services/PackmindIgnoreReader.ts
|
|
14146
|
-
var
|
|
14147
|
-
var
|
|
14300
|
+
var fs18 = __toESM(require("fs/promises"));
|
|
14301
|
+
var path20 = __toESM(require("path"));
|
|
14148
14302
|
var IGNORE_FILENAME = ".packmindignore";
|
|
14149
14303
|
var PackmindIgnoreReader = class {
|
|
14150
14304
|
async readIgnorePatterns(startDirectory, stopDirectory) {
|
|
14151
14305
|
const patterns = [];
|
|
14152
|
-
const normalizedStart =
|
|
14153
|
-
const normalizedStop = stopDirectory ?
|
|
14306
|
+
const normalizedStart = path20.resolve(startDirectory);
|
|
14307
|
+
const normalizedStop = stopDirectory ? path20.resolve(stopDirectory) : null;
|
|
14154
14308
|
if (normalizedStop === null) {
|
|
14155
|
-
const ignoreFile =
|
|
14309
|
+
const ignoreFile = path20.join(normalizedStart, IGNORE_FILENAME);
|
|
14156
14310
|
return this.parseIgnoreFile(ignoreFile);
|
|
14157
14311
|
}
|
|
14158
14312
|
let currentDir = normalizedStart;
|
|
14159
14313
|
while (true) {
|
|
14160
|
-
const ignoreFile =
|
|
14314
|
+
const ignoreFile = path20.join(currentDir, IGNORE_FILENAME);
|
|
14161
14315
|
const filePatterns = await this.parseIgnoreFile(ignoreFile);
|
|
14162
14316
|
patterns.push(...filePatterns);
|
|
14163
14317
|
if (currentDir === normalizedStop) {
|
|
14164
14318
|
break;
|
|
14165
14319
|
}
|
|
14166
|
-
const parentDir =
|
|
14320
|
+
const parentDir = path20.dirname(currentDir);
|
|
14167
14321
|
if (parentDir === currentDir) {
|
|
14168
14322
|
break;
|
|
14169
14323
|
}
|
|
@@ -14174,7 +14328,7 @@ var PackmindIgnoreReader = class {
|
|
|
14174
14328
|
async parseIgnoreFile(filePath) {
|
|
14175
14329
|
let content;
|
|
14176
14330
|
try {
|
|
14177
|
-
content = await
|
|
14331
|
+
content = await fs18.readFile(filePath, "utf-8");
|
|
14178
14332
|
} catch (err) {
|
|
14179
14333
|
if (err.code === "ENOENT") {
|
|
14180
14334
|
return [];
|
|
@@ -14195,7 +14349,7 @@ function isNotLoggedInError(error) {
|
|
|
14195
14349
|
}
|
|
14196
14350
|
async function lintHandler(args2, deps) {
|
|
14197
14351
|
const {
|
|
14198
|
-
path:
|
|
14352
|
+
path: path37,
|
|
14199
14353
|
draft,
|
|
14200
14354
|
rule,
|
|
14201
14355
|
language,
|
|
@@ -14217,11 +14371,11 @@ async function lintHandler(args2, deps) {
|
|
|
14217
14371
|
throw new Error("option --rule is required to use --draft mode");
|
|
14218
14372
|
}
|
|
14219
14373
|
const startedAt = Date.now();
|
|
14220
|
-
const targetPath =
|
|
14374
|
+
const targetPath = path37 ?? ".";
|
|
14221
14375
|
const absolutePath = resolvePath(targetPath);
|
|
14222
14376
|
let stats;
|
|
14223
14377
|
try {
|
|
14224
|
-
stats = await
|
|
14378
|
+
stats = await fs19.stat(absolutePath);
|
|
14225
14379
|
} catch (err) {
|
|
14226
14380
|
const isNotFound = err.code === "ENOENT";
|
|
14227
14381
|
const message = isNotFound ? `File or directory "${absolutePath}" does not exist` : `Cannot access "${absolutePath}": ${err.message}`;
|
|
@@ -14539,13 +14693,13 @@ function extractWasmFiles() {
|
|
|
14539
14693
|
|
|
14540
14694
|
// apps/cli/src/main.ts
|
|
14541
14695
|
var import_dotenv = require("dotenv");
|
|
14542
|
-
var
|
|
14543
|
-
var
|
|
14696
|
+
var fs28 = __toESM(require("fs"));
|
|
14697
|
+
var path36 = __toESM(require("path"));
|
|
14544
14698
|
|
|
14545
14699
|
// apps/cli/src/infra/commands/InstallCommand.ts
|
|
14546
14700
|
var import_cmd_ts2 = __toESM(require_cjs());
|
|
14547
|
-
var
|
|
14548
|
-
var
|
|
14701
|
+
var path24 = __toESM(require("path"));
|
|
14702
|
+
var fs23 = __toESM(require("fs"));
|
|
14549
14703
|
|
|
14550
14704
|
// apps/cli/src/infra/commands/installPackagesHandler.ts
|
|
14551
14705
|
function formatOverviewRow(configPath, packages, pathColumnWidth) {
|
|
@@ -14628,28 +14782,23 @@ function pluralize(noun, count) {
|
|
|
14628
14782
|
function nounFor(type, count) {
|
|
14629
14783
|
return `${count} ${pluralize(type, count)}`;
|
|
14630
14784
|
}
|
|
14631
|
-
function
|
|
14785
|
+
function changedParts(result) {
|
|
14632
14786
|
const parts = [];
|
|
14633
|
-
if (result.
|
|
14634
|
-
parts.push(nounFor("standard", result.
|
|
14635
|
-
if (result.
|
|
14636
|
-
parts.push(nounFor("command", result.
|
|
14637
|
-
if (result.
|
|
14638
|
-
|
|
14639
|
-
parts.push(nounFor("recipe", result.recipesCount));
|
|
14787
|
+
if (result.standardsChanged > 0)
|
|
14788
|
+
parts.push(nounFor("standard", result.standardsChanged));
|
|
14789
|
+
if (result.commandsChanged > 0)
|
|
14790
|
+
parts.push(nounFor("command", result.commandsChanged));
|
|
14791
|
+
if (result.skillsChanged > 0)
|
|
14792
|
+
parts.push(nounFor("skill", result.skillsChanged));
|
|
14640
14793
|
return parts;
|
|
14641
14794
|
}
|
|
14642
14795
|
function buildInstallSummary(result) {
|
|
14643
|
-
const contentChanged = result.
|
|
14644
|
-
const parts = contentParts(result);
|
|
14796
|
+
const contentChanged = result.skillsChanged > 0 || result.standardsChanged > 0 || result.commandsChanged > 0;
|
|
14645
14797
|
const filesDeleted = result.filesDeleted > 0;
|
|
14646
14798
|
const configCreated = result.configCreated;
|
|
14647
14799
|
const packagesAdded = result.packagesAdded.length > 0;
|
|
14648
14800
|
const nothingHappened = !configCreated && !packagesAdded && !contentChanged && !filesDeleted;
|
|
14649
14801
|
if (nothingHappened) {
|
|
14650
|
-
if (parts.length > 0) {
|
|
14651
|
-
return `\u2705 Already up to date \u2014 ${parts.join(", ")}`;
|
|
14652
|
-
}
|
|
14653
14802
|
return "\u2705 Already up to date";
|
|
14654
14803
|
}
|
|
14655
14804
|
const lines = [];
|
|
@@ -14668,7 +14817,10 @@ function buildInstallSummary(result) {
|
|
|
14668
14817
|
lines.push(...result.packagesAdded.map((s) => ` - ${s}`));
|
|
14669
14818
|
}
|
|
14670
14819
|
if (contentChanged) {
|
|
14671
|
-
|
|
14820
|
+
const changed = changedParts(result);
|
|
14821
|
+
if (changed.length > 0) {
|
|
14822
|
+
lines.push(`\u2705 Synced ${changed.join(", ")}`);
|
|
14823
|
+
}
|
|
14672
14824
|
}
|
|
14673
14825
|
if (filesDeleted && !contentChanged) {
|
|
14674
14826
|
lines.push(
|
|
@@ -14714,8 +14866,8 @@ function buildIncapableArtifactsWarning(result) {
|
|
|
14714
14866
|
}
|
|
14715
14867
|
|
|
14716
14868
|
// apps/cli/src/application/services/AgentArtifactDetectionService.ts
|
|
14717
|
-
var
|
|
14718
|
-
var
|
|
14869
|
+
var fs20 = __toESM(require("fs/promises"));
|
|
14870
|
+
var path21 = __toESM(require("path"));
|
|
14719
14871
|
var AGENT_ARTIFACT_CHECKS = [
|
|
14720
14872
|
{ agent: "claude", paths: [".claude"] },
|
|
14721
14873
|
{ agent: "cursor", paths: [".cursor"] },
|
|
@@ -14749,7 +14901,7 @@ var AgentArtifactDetectionService = class {
|
|
|
14749
14901
|
}
|
|
14750
14902
|
} else {
|
|
14751
14903
|
for (const relativePath of check.paths) {
|
|
14752
|
-
const fullPath =
|
|
14904
|
+
const fullPath = path21.join(baseDirectory, relativePath);
|
|
14753
14905
|
const exists = await this.pathExists(fullPath);
|
|
14754
14906
|
if (exists) {
|
|
14755
14907
|
detected.push({
|
|
@@ -14765,7 +14917,7 @@ var AgentArtifactDetectionService = class {
|
|
|
14765
14917
|
}
|
|
14766
14918
|
async pathExists(filePath) {
|
|
14767
14919
|
try {
|
|
14768
|
-
await
|
|
14920
|
+
await fs20.access(filePath);
|
|
14769
14921
|
return true;
|
|
14770
14922
|
} catch {
|
|
14771
14923
|
return false;
|
|
@@ -14776,16 +14928,16 @@ var AgentArtifactDetectionService = class {
|
|
|
14776
14928
|
while (queue.length > 0) {
|
|
14777
14929
|
const currentDir = queue.shift();
|
|
14778
14930
|
for (const targetPath of targetPaths) {
|
|
14779
|
-
const fullPath =
|
|
14931
|
+
const fullPath = path21.join(currentDir, targetPath);
|
|
14780
14932
|
if (await this.pathExists(fullPath)) {
|
|
14781
14933
|
return fullPath;
|
|
14782
14934
|
}
|
|
14783
14935
|
}
|
|
14784
14936
|
try {
|
|
14785
|
-
const entries = await
|
|
14937
|
+
const entries = await fs20.readdir(currentDir, { withFileTypes: true });
|
|
14786
14938
|
for (const entry of entries) {
|
|
14787
14939
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
14788
|
-
queue.push(
|
|
14940
|
+
queue.push(path21.join(currentDir, entry.name));
|
|
14789
14941
|
}
|
|
14790
14942
|
}
|
|
14791
14943
|
} catch {
|
|
@@ -14804,18 +14956,18 @@ var readline2 = __toESM(require("readline"));
|
|
|
14804
14956
|
var inquirer = __toESM(require("inquirer"));
|
|
14805
14957
|
|
|
14806
14958
|
// apps/cli/src/infra/commands/config/agents/agentsHandlerUtils.ts
|
|
14807
|
-
var
|
|
14808
|
-
var
|
|
14959
|
+
var path22 = __toESM(require("path"));
|
|
14960
|
+
var fs21 = __toESM(require("fs/promises"));
|
|
14809
14961
|
function getRelativePath(dir, startDirectory) {
|
|
14810
14962
|
if (dir === startDirectory) return "./packmind.json";
|
|
14811
|
-
return "./" +
|
|
14963
|
+
return "./" + path22.relative(startDirectory, dir) + "/packmind.json";
|
|
14812
14964
|
}
|
|
14813
14965
|
async function resolveStartDirectory(args2, getCwd, exit) {
|
|
14814
14966
|
let startDirectory = getCwd();
|
|
14815
14967
|
if (args2.path) {
|
|
14816
|
-
const resolvedPath =
|
|
14968
|
+
const resolvedPath = path22.resolve(getCwd(), args2.path);
|
|
14817
14969
|
try {
|
|
14818
|
-
const stat9 = await
|
|
14970
|
+
const stat9 = await fs21.stat(resolvedPath);
|
|
14819
14971
|
if (!stat9.isDirectory()) {
|
|
14820
14972
|
logErrorConsole(`Path is not a directory: ${resolvedPath}`);
|
|
14821
14973
|
exit(1);
|
|
@@ -14932,7 +15084,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
14932
15084
|
output.write("\n");
|
|
14933
15085
|
const preselected = choices.map((c, i) => c.checked ? i + 1 : null).filter((i) => i !== null);
|
|
14934
15086
|
const defaultValue = preselected.length > 0 ? preselected.join(",") : "1,2,3";
|
|
14935
|
-
return new Promise((
|
|
15087
|
+
return new Promise((resolve16) => {
|
|
14936
15088
|
rl.question(
|
|
14937
15089
|
`Enter numbers separated by commas (default: ${defaultValue}): `,
|
|
14938
15090
|
(answer) => {
|
|
@@ -14941,7 +15093,7 @@ async function promptAgentsWithReadline(choices) {
|
|
|
14941
15093
|
const numbersStr = trimmed === "" ? defaultValue : trimmed;
|
|
14942
15094
|
const numbers = numbersStr.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n >= 1 && n <= choices.length);
|
|
14943
15095
|
const selectedAgents = numbers.map((n) => choices[n - 1].value);
|
|
14944
|
-
|
|
15096
|
+
resolve16(selectedAgents);
|
|
14945
15097
|
}
|
|
14946
15098
|
);
|
|
14947
15099
|
});
|
|
@@ -14988,8 +15140,8 @@ async function propagateAgentsToDescendants(configRepository, baseDirectory, sel
|
|
|
14988
15140
|
}
|
|
14989
15141
|
|
|
14990
15142
|
// apps/cli/src/infra/commands/skills/incompatibleSkillsHandler.ts
|
|
14991
|
-
var
|
|
14992
|
-
var
|
|
15143
|
+
var fs22 = __toESM(require("fs/promises"));
|
|
15144
|
+
var path23 = __toESM(require("path"));
|
|
14993
15145
|
var alwaysConfirm = () => Promise.resolve(true);
|
|
14994
15146
|
async function handleIncompatibleInstalledSkillsSilently(skills, baseDirectory) {
|
|
14995
15147
|
for (const skill of skills) {
|
|
@@ -15009,10 +15161,10 @@ async function handleIncompatibleInstalledSkills(skills, baseDirectory, confirm)
|
|
|
15009
15161
|
return;
|
|
15010
15162
|
}
|
|
15011
15163
|
for (const skill of skills) {
|
|
15012
|
-
const skillRootDirs = skill.filePaths.filter((p) =>
|
|
15164
|
+
const skillRootDirs = skill.filePaths.filter((p) => path23.basename(p) === "SKILL.md").map((p) => path23.dirname(p));
|
|
15013
15165
|
for (const dir of skillRootDirs) {
|
|
15014
15166
|
try {
|
|
15015
|
-
await
|
|
15167
|
+
await fs22.rm(path23.join(baseDirectory, dir), {
|
|
15016
15168
|
recursive: true,
|
|
15017
15169
|
force: true
|
|
15018
15170
|
});
|
|
@@ -15025,7 +15177,7 @@ async function handleIncompatibleInstalledSkills(skills, baseDirectory, confirm)
|
|
|
15025
15177
|
for (const relativePath of skill.filePaths) {
|
|
15026
15178
|
if (!skillRootDirs.some((dir) => relativePath.startsWith(dir + "/"))) {
|
|
15027
15179
|
try {
|
|
15028
|
-
await
|
|
15180
|
+
await fs22.unlink(path23.join(baseDirectory, relativePath));
|
|
15029
15181
|
} catch (error) {
|
|
15030
15182
|
logErrorConsole(
|
|
15031
15183
|
`Failed to delete "${relativePath}": ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -15165,7 +15317,8 @@ async function bootstrapInstallContext(deps) {
|
|
|
15165
15317
|
isTTY = false,
|
|
15166
15318
|
installDefaultSkills,
|
|
15167
15319
|
cliVersion,
|
|
15168
|
-
runInit = initHandler
|
|
15320
|
+
runInit = initHandler,
|
|
15321
|
+
homeAgent
|
|
15169
15322
|
} = deps;
|
|
15170
15323
|
const hierarchicalResult = await configRepository.readHierarchicalConfig(
|
|
15171
15324
|
baseDirectory,
|
|
@@ -15179,6 +15332,22 @@ async function bootstrapInstallContext(deps) {
|
|
|
15179
15332
|
packagesAdded: []
|
|
15180
15333
|
};
|
|
15181
15334
|
}
|
|
15335
|
+
if (homeAgent) {
|
|
15336
|
+
const packagesMap = packages.length > 0 ? Object.fromEntries(packages.map((s) => [s, "*"])) : {};
|
|
15337
|
+
await configRepository.writeConfig(baseDirectory, {
|
|
15338
|
+
packages: packagesMap,
|
|
15339
|
+
agents: [homeAgent]
|
|
15340
|
+
});
|
|
15341
|
+
logSuccessConsole(
|
|
15342
|
+
`Created packmind.json at ${baseDirectory} for ${homeAgent} (home install).`
|
|
15343
|
+
);
|
|
15344
|
+
return {
|
|
15345
|
+
configReady: true,
|
|
15346
|
+
warned: false,
|
|
15347
|
+
configCreated: true,
|
|
15348
|
+
packagesAdded: [...packages]
|
|
15349
|
+
};
|
|
15350
|
+
}
|
|
15182
15351
|
const detected = await agentDetectionService.detectAgentArtifacts(baseDirectory);
|
|
15183
15352
|
if (detected.length > 0) {
|
|
15184
15353
|
const agents = [...new Set(detected.map((d) => d.agent))];
|
|
@@ -15321,11 +15490,11 @@ async function confirmWithReadline(question) {
|
|
|
15321
15490
|
input: process.stdin,
|
|
15322
15491
|
output: process.stdout
|
|
15323
15492
|
});
|
|
15324
|
-
return new Promise((
|
|
15493
|
+
return new Promise((resolve16) => {
|
|
15325
15494
|
rl.question(question, (answer) => {
|
|
15326
15495
|
rl.close();
|
|
15327
15496
|
const trimmed = answer.trim().toLowerCase();
|
|
15328
|
-
|
|
15497
|
+
resolve16(trimmed === "" || trimmed === "y" || trimmed === "yes");
|
|
15329
15498
|
});
|
|
15330
15499
|
});
|
|
15331
15500
|
}
|
|
@@ -15336,14 +15505,14 @@ function findSubDirectoriesWithPackmindJson(dirPath, recursive) {
|
|
|
15336
15505
|
const result = [];
|
|
15337
15506
|
let entries;
|
|
15338
15507
|
try {
|
|
15339
|
-
entries =
|
|
15508
|
+
entries = fs23.readdirSync(dirPath, { withFileTypes: true });
|
|
15340
15509
|
} catch {
|
|
15341
15510
|
return result;
|
|
15342
15511
|
}
|
|
15343
15512
|
for (const entry of entries) {
|
|
15344
15513
|
if (!entry.isDirectory()) continue;
|
|
15345
|
-
const subDir =
|
|
15346
|
-
if (
|
|
15514
|
+
const subDir = path24.join(dirPath, entry.name);
|
|
15515
|
+
if (fs23.existsSync(path24.join(subDir, "packmind.json"))) {
|
|
15347
15516
|
result.push(subDir);
|
|
15348
15517
|
}
|
|
15349
15518
|
if (recursive) {
|
|
@@ -15363,6 +15532,9 @@ function mergeInstallResults(results) {
|
|
|
15363
15532
|
standardsCount: 0,
|
|
15364
15533
|
commandsCount: 0,
|
|
15365
15534
|
skillsCount: 0,
|
|
15535
|
+
skillsChanged: 0,
|
|
15536
|
+
standardsChanged: 0,
|
|
15537
|
+
commandsChanged: 0,
|
|
15366
15538
|
recipesRemoved: 0,
|
|
15367
15539
|
standardsRemoved: 0,
|
|
15368
15540
|
commandsRemoved: 0,
|
|
@@ -15392,6 +15564,9 @@ function mergeInstallResults(results) {
|
|
|
15392
15564
|
merged.standardsCount += r.standardsCount;
|
|
15393
15565
|
merged.commandsCount += r.commandsCount;
|
|
15394
15566
|
merged.skillsCount += r.skillsCount;
|
|
15567
|
+
merged.skillsChanged += r.skillsChanged;
|
|
15568
|
+
merged.standardsChanged += r.standardsChanged;
|
|
15569
|
+
merged.commandsChanged += r.commandsChanged;
|
|
15395
15570
|
merged.recipesRemoved += r.recipesRemoved;
|
|
15396
15571
|
merged.standardsRemoved += r.standardsRemoved;
|
|
15397
15572
|
merged.commandsRemoved += r.commandsRemoved;
|
|
@@ -15421,8 +15596,8 @@ async function notifyArtefactsDistributionIfInGitRepo(params) {
|
|
|
15421
15596
|
try {
|
|
15422
15597
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(dir);
|
|
15423
15598
|
if (!gitRoot) return;
|
|
15424
|
-
const lockFilePath =
|
|
15425
|
-
const content =
|
|
15599
|
+
const lockFilePath = path24.join(dir, "packmind-lock.json");
|
|
15600
|
+
const content = fs23.readFileSync(lockFilePath, "utf-8");
|
|
15426
15601
|
const packmindLockFile = JSON.parse(content);
|
|
15427
15602
|
const gitRemoteUrl = packmindCliHexa.getGitRemoteUrlFromPath(gitRoot);
|
|
15428
15603
|
const gitBranch = packmindCliHexa.getCurrentBranch(gitRoot);
|
|
@@ -15511,14 +15686,14 @@ async function installHandler({
|
|
|
15511
15686
|
logConsole(`Use ${formatCommand(showCommand)} instead.`);
|
|
15512
15687
|
process.exit(1);
|
|
15513
15688
|
}
|
|
15514
|
-
const cwd = installPath ?
|
|
15689
|
+
const cwd = installPath ? path24.resolve(process.cwd(), installPath) : process.cwd();
|
|
15515
15690
|
if (installPath) {
|
|
15516
|
-
if (!
|
|
15691
|
+
if (!fs23.existsSync(cwd)) {
|
|
15517
15692
|
logErrorConsole(`Path does not exist: ${cwd}`);
|
|
15518
15693
|
process.exit(1);
|
|
15519
15694
|
return;
|
|
15520
15695
|
}
|
|
15521
|
-
if (!
|
|
15696
|
+
if (!fs23.statSync(cwd).isDirectory()) {
|
|
15522
15697
|
logErrorConsole(`Path is not a directory: ${cwd}`);
|
|
15523
15698
|
process.exit(1);
|
|
15524
15699
|
return;
|
|
@@ -15534,6 +15709,7 @@ async function installHandler({
|
|
|
15534
15709
|
} catch {
|
|
15535
15710
|
}
|
|
15536
15711
|
const configRepository = new ConfigFileRepository();
|
|
15712
|
+
const cwdHomeAgent = isAgentHomeDirectory(cwd) ?? void 0;
|
|
15537
15713
|
const bootstrap = await bootstrapInstallContext({
|
|
15538
15714
|
configRepository,
|
|
15539
15715
|
agentDetectionService: new AgentArtifactDetectionService(),
|
|
@@ -15542,12 +15718,13 @@ async function installHandler({
|
|
|
15542
15718
|
packages,
|
|
15543
15719
|
isTTY: process.stdin.isTTY ?? false,
|
|
15544
15720
|
installDefaultSkills: packmindCliHexa.installDefaultSkills.bind(packmindCliHexa),
|
|
15545
|
-
cliVersion: CLI_VERSION
|
|
15721
|
+
cliVersion: CLI_VERSION,
|
|
15722
|
+
homeAgent: cwdHomeAgent
|
|
15546
15723
|
});
|
|
15547
15724
|
let targetDirs;
|
|
15548
15725
|
if (installPath) {
|
|
15549
15726
|
targetDirs = [];
|
|
15550
|
-
if (
|
|
15727
|
+
if (fs23.existsSync(path24.join(cwd, "packmind.json")) || packages.length > 0) {
|
|
15551
15728
|
targetDirs.push(cwd);
|
|
15552
15729
|
}
|
|
15553
15730
|
targetDirs.push(...findSubDirectoriesWithPackmindJson(cwd, false));
|
|
@@ -15555,7 +15732,7 @@ async function installHandler({
|
|
|
15555
15732
|
targetDirs = [cwd];
|
|
15556
15733
|
} else {
|
|
15557
15734
|
targetDirs = [];
|
|
15558
|
-
if (
|
|
15735
|
+
if (fs23.existsSync(path24.join(cwd, "packmind.json"))) {
|
|
15559
15736
|
targetDirs.push(cwd);
|
|
15560
15737
|
}
|
|
15561
15738
|
targetDirs.push(...findSubDirectoriesWithPackmindJson(cwd, true));
|
|
@@ -15574,17 +15751,21 @@ async function installHandler({
|
|
|
15574
15751
|
const multiDir = targetDirs.length > 1;
|
|
15575
15752
|
for (const dir of targetDirs) {
|
|
15576
15753
|
try {
|
|
15754
|
+
const dirHomeAgent = isAgentHomeDirectory(dir) ?? void 0;
|
|
15577
15755
|
const result = await packmindCliHexa.install({
|
|
15578
15756
|
baseDirectory: dir,
|
|
15579
15757
|
packages: packages.length > 0 ? packages : void 0,
|
|
15580
15758
|
skipInstalledAt,
|
|
15581
|
-
cliVersion: CLI_VERSION
|
|
15759
|
+
cliVersion: CLI_VERSION,
|
|
15760
|
+
homeAgent: dirHomeAgent
|
|
15582
15761
|
});
|
|
15583
15762
|
results.push(result);
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15763
|
+
if (!dirHomeAgent) {
|
|
15764
|
+
await notifyArtefactsDistributionIfInGitRepo({
|
|
15765
|
+
packmindCliHexa,
|
|
15766
|
+
dir
|
|
15767
|
+
});
|
|
15768
|
+
}
|
|
15588
15769
|
} catch (error) {
|
|
15589
15770
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15590
15771
|
thrownErrors.push(
|
|
@@ -15617,11 +15798,13 @@ async function installHandler({
|
|
|
15617
15798
|
logWarningConsole(capabilityWarning);
|
|
15618
15799
|
}
|
|
15619
15800
|
logConsole(buildInstallSummary(combined));
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15801
|
+
if (!cwdHomeAgent) {
|
|
15802
|
+
await installDefaultSkillsIfAtGitRoot({
|
|
15803
|
+
packmindCliHexa,
|
|
15804
|
+
cwd,
|
|
15805
|
+
configRepository
|
|
15806
|
+
});
|
|
15807
|
+
}
|
|
15625
15808
|
}
|
|
15626
15809
|
const allErrors = [...combined.errors, ...thrownErrors];
|
|
15627
15810
|
if (allErrors.length > 0) {
|
|
@@ -15704,6 +15887,15 @@ var uninstallCommand = (0, import_cmd_ts3.command)({
|
|
|
15704
15887
|
}
|
|
15705
15888
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
15706
15889
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
15890
|
+
try {
|
|
15891
|
+
const ensureOutcome = await packmindCliHexa.ensureCliVersion({
|
|
15892
|
+
baseDirectory: process.cwd(),
|
|
15893
|
+
currentCliVersion: CLI_VERSION2,
|
|
15894
|
+
includeBeta: false
|
|
15895
|
+
});
|
|
15896
|
+
reportEnsureCliVersionOutcome(ensureOutcome, CLI_VERSION2);
|
|
15897
|
+
} catch {
|
|
15898
|
+
}
|
|
15707
15899
|
try {
|
|
15708
15900
|
const result = await packmindCliHexa.uninstall({
|
|
15709
15901
|
baseDirectory: process.cwd(),
|
|
@@ -16436,7 +16628,7 @@ var import_cmd_ts18 = __toESM(require_cjs());
|
|
|
16436
16628
|
|
|
16437
16629
|
// apps/cli/src/infra/commands/playbook/diffArtefactsHandler.ts
|
|
16438
16630
|
var nodePath = __toESM(require("path"));
|
|
16439
|
-
var
|
|
16631
|
+
var fs24 = __toESM(require("fs/promises"));
|
|
16440
16632
|
|
|
16441
16633
|
// apps/cli/src/infra/utils/diffFormatter.ts
|
|
16442
16634
|
var import_diff4 = require("diff");
|
|
@@ -16735,7 +16927,7 @@ async function diffArtefactsHandler(deps) {
|
|
|
16735
16927
|
const searchPath = nodePath.resolve(cwd, deps.path ?? ".");
|
|
16736
16928
|
if (deps.path !== void 0) {
|
|
16737
16929
|
try {
|
|
16738
|
-
await
|
|
16930
|
+
await fs24.stat(searchPath);
|
|
16739
16931
|
} catch {
|
|
16740
16932
|
logErrorConsole(`Path does not exist: ${searchPath}`);
|
|
16741
16933
|
exit(1);
|
|
@@ -16895,7 +17087,7 @@ var diffCommand = (0, import_cmd_ts18.command)({
|
|
|
16895
17087
|
description: "Subcommand and arguments (e.g., add <path>, remove <path>)"
|
|
16896
17088
|
})
|
|
16897
17089
|
},
|
|
16898
|
-
handler: async ({ submit, includeSubmitted, message, path:
|
|
17090
|
+
handler: async ({ submit, includeSubmitted, message, path: path37, positionals }) => {
|
|
16899
17091
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
16900
17092
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
16901
17093
|
if (submit) {
|
|
@@ -16911,7 +17103,7 @@ var diffCommand = (0, import_cmd_ts18.command)({
|
|
|
16911
17103
|
process.exit(1);
|
|
16912
17104
|
}
|
|
16913
17105
|
if (positionals[0] === "add") {
|
|
16914
|
-
const addFilePath =
|
|
17106
|
+
const addFilePath = path37 && positionals[1] ? `${path37}/${positionals[1]}`.replace(/\/+/g, "/") : positionals[1];
|
|
16915
17107
|
const addCommand = `packmind-cli playbook add ${addFilePath}`;
|
|
16916
17108
|
logErrorConsole("Deprecated: `packmind-cli diff add` has been removed");
|
|
16917
17109
|
logInfoConsole("Use the following command instead:");
|
|
@@ -16919,7 +17111,7 @@ var diffCommand = (0, import_cmd_ts18.command)({
|
|
|
16919
17111
|
process.exit(1);
|
|
16920
17112
|
}
|
|
16921
17113
|
if (positionals[0] === "remove" || positionals[0] === "rm") {
|
|
16922
|
-
const removeFilePath =
|
|
17114
|
+
const removeFilePath = path37 && positionals[1] ? `${path37}/${positionals[1]}`.replace(/\/+/g, "/") : positionals[1];
|
|
16923
17115
|
const removeCommand = `packmind-cli playbook remove ${removeFilePath}`;
|
|
16924
17116
|
logErrorConsole(
|
|
16925
17117
|
"Deprecated: `packmind-cli diff remove` has been removed"
|
|
@@ -16928,7 +17120,7 @@ var diffCommand = (0, import_cmd_ts18.command)({
|
|
|
16928
17120
|
logInfoConsole(` ${formatCommand(removeCommand)}`);
|
|
16929
17121
|
process.exit(1);
|
|
16930
17122
|
}
|
|
16931
|
-
const diffCommand3 = `packmind-cli playbook diff${includeSubmitted ? " --include-submitted" : ""}${
|
|
17123
|
+
const diffCommand3 = `packmind-cli playbook diff${includeSubmitted ? " --include-submitted" : ""}${path37 ? ` --path ${path37}` : ""}`;
|
|
16932
17124
|
logErrorConsole("Deprecated: `packmind-cli diff` will be removed");
|
|
16933
17125
|
logInfoConsole("Use the following command instead:");
|
|
16934
17126
|
logInfoConsole(` ${formatCommand(diffCommand3)}`);
|
|
@@ -16938,7 +17130,7 @@ var diffCommand = (0, import_cmd_ts18.command)({
|
|
|
16938
17130
|
getCwd: () => process.cwd(),
|
|
16939
17131
|
log: console.log,
|
|
16940
17132
|
includeSubmitted,
|
|
16941
|
-
path:
|
|
17133
|
+
path: path37
|
|
16942
17134
|
});
|
|
16943
17135
|
}
|
|
16944
17136
|
});
|
|
@@ -17630,16 +17822,16 @@ var import_cmd_ts24 = __toESM(require_cjs());
|
|
|
17630
17822
|
|
|
17631
17823
|
// apps/cli/src/infra/repositories/PlaybookLocalRepository.ts
|
|
17632
17824
|
var crypto = __toESM(require("crypto"));
|
|
17633
|
-
var
|
|
17634
|
-
var
|
|
17635
|
-
var
|
|
17825
|
+
var fs25 = __toESM(require("fs"));
|
|
17826
|
+
var os5 = __toESM(require("os"));
|
|
17827
|
+
var path25 = __toESM(require("path"));
|
|
17636
17828
|
var yaml = __toESM(require("yaml"));
|
|
17637
17829
|
var PlaybookLocalRepository = class {
|
|
17638
17830
|
constructor(repoRoot) {
|
|
17639
17831
|
const normalized = this.normalizeRepoRoot(repoRoot);
|
|
17640
17832
|
const hash = crypto.createHash("md5").update(normalized).digest("hex");
|
|
17641
|
-
this.storagePath =
|
|
17642
|
-
|
|
17833
|
+
this.storagePath = path25.join(
|
|
17834
|
+
os5.homedir(),
|
|
17643
17835
|
".packmind",
|
|
17644
17836
|
hash,
|
|
17645
17837
|
"playbook.yaml"
|
|
@@ -17686,11 +17878,11 @@ var PlaybookLocalRepository = class {
|
|
|
17686
17878
|
return normalized;
|
|
17687
17879
|
}
|
|
17688
17880
|
readYaml() {
|
|
17689
|
-
if (!
|
|
17881
|
+
if (!fs25.existsSync(this.storagePath)) {
|
|
17690
17882
|
return { version: 1, changes: [] };
|
|
17691
17883
|
}
|
|
17692
17884
|
try {
|
|
17693
|
-
const content =
|
|
17885
|
+
const content = fs25.readFileSync(this.storagePath, "utf-8");
|
|
17694
17886
|
const parsed = yaml.parse(content);
|
|
17695
17887
|
if (!parsed || !Array.isArray(parsed.changes)) {
|
|
17696
17888
|
return { version: 1, changes: [] };
|
|
@@ -17704,20 +17896,20 @@ var PlaybookLocalRepository = class {
|
|
|
17704
17896
|
}
|
|
17705
17897
|
}
|
|
17706
17898
|
writeYaml(data) {
|
|
17707
|
-
const dir =
|
|
17708
|
-
|
|
17709
|
-
|
|
17899
|
+
const dir = path25.dirname(this.storagePath);
|
|
17900
|
+
fs25.mkdirSync(dir, { recursive: true });
|
|
17901
|
+
fs25.writeFileSync(this.storagePath, yaml.stringify(data), "utf-8");
|
|
17710
17902
|
}
|
|
17711
17903
|
};
|
|
17712
17904
|
|
|
17713
17905
|
// apps/cli/src/infra/commands/playbook/addHandler.ts
|
|
17714
|
-
var
|
|
17715
|
-
var
|
|
17906
|
+
var fs26 = __toESM(require("fs"));
|
|
17907
|
+
var path29 = __toESM(require("path"));
|
|
17716
17908
|
var yaml2 = __toESM(require("yaml"));
|
|
17717
17909
|
var import_slug4 = __toESM(require("slug"));
|
|
17718
17910
|
|
|
17719
17911
|
// apps/cli/src/application/utils/parseCommandFile.ts
|
|
17720
|
-
var
|
|
17912
|
+
var path26 = __toESM(require("path"));
|
|
17721
17913
|
var FRONTMATTER_DELIMITER3 = "---";
|
|
17722
17914
|
function parseCommandFile(content, filePath) {
|
|
17723
17915
|
content = normalizeLineEndings(content);
|
|
@@ -17773,7 +17965,7 @@ function stripYamlQuotes2(value) {
|
|
|
17773
17965
|
return value;
|
|
17774
17966
|
}
|
|
17775
17967
|
function extractFilenameSlug(filePath) {
|
|
17776
|
-
let basename4 =
|
|
17968
|
+
let basename4 = path26.basename(filePath);
|
|
17777
17969
|
if (basename4.endsWith(".prompt.md")) {
|
|
17778
17970
|
basename4 = basename4.slice(0, -".prompt.md".length);
|
|
17779
17971
|
} else if (basename4.endsWith(".md")) {
|
|
@@ -18187,7 +18379,7 @@ function parseSkillDirectory(files) {
|
|
|
18187
18379
|
}
|
|
18188
18380
|
|
|
18189
18381
|
// apps/cli/src/application/utils/findNearestConfigDir.ts
|
|
18190
|
-
var
|
|
18382
|
+
var path27 = __toESM(require("path"));
|
|
18191
18383
|
async function findNearestConfigDir(startDir, packmindCliHexa) {
|
|
18192
18384
|
let current = startDir;
|
|
18193
18385
|
while (true) {
|
|
@@ -18195,7 +18387,7 @@ async function findNearestConfigDir(startDir, packmindCliHexa) {
|
|
|
18195
18387
|
if (exists) {
|
|
18196
18388
|
return current;
|
|
18197
18389
|
}
|
|
18198
|
-
const parent =
|
|
18390
|
+
const parent = path27.dirname(current);
|
|
18199
18391
|
if (parent === current) {
|
|
18200
18392
|
return null;
|
|
18201
18393
|
}
|
|
@@ -18204,7 +18396,7 @@ async function findNearestConfigDir(startDir, packmindCliHexa) {
|
|
|
18204
18396
|
}
|
|
18205
18397
|
|
|
18206
18398
|
// apps/cli/src/application/utils/resolveDeployedContext.ts
|
|
18207
|
-
var
|
|
18399
|
+
var path28 = __toESM(require("path"));
|
|
18208
18400
|
async function resolveDeployedContext(packmindCliHexa, targetDir) {
|
|
18209
18401
|
try {
|
|
18210
18402
|
const space = await packmindCliHexa.getDefaultSpace();
|
|
@@ -18216,7 +18408,7 @@ async function resolveDeployedContext(packmindCliHexa, targetDir) {
|
|
|
18216
18408
|
}
|
|
18217
18409
|
const gitRemoteUrl = packmindCliHexa.getGitRemoteUrlFromPath(gitRoot);
|
|
18218
18410
|
const gitBranch = packmindCliHexa.getCurrentBranch(gitRoot);
|
|
18219
|
-
const rel =
|
|
18411
|
+
const rel = path28.relative(gitRoot, targetDir);
|
|
18220
18412
|
const relativePath = rel.startsWith("..") ? "/" : rel ? `/${rel}/` : "/";
|
|
18221
18413
|
const deployedContent = await packmindCliHexa.getPackmindGateway().deployment.getDeployed({
|
|
18222
18414
|
packagesSlugs: configPackages,
|
|
@@ -18266,34 +18458,51 @@ function lockFileToArtifactVersionEntries(lockFile) {
|
|
|
18266
18458
|
spaceId: entry.spaceId
|
|
18267
18459
|
}));
|
|
18268
18460
|
}
|
|
18269
|
-
async function fetchDeployedFiles(gateway, lockFile) {
|
|
18461
|
+
async function fetchDeployedFiles(gateway, lockFile, options = {}) {
|
|
18270
18462
|
try {
|
|
18271
18463
|
const artifacts = lockFileToArtifactVersionEntries(lockFile);
|
|
18272
18464
|
const response = await gateway.deployment.getContentByVersions({
|
|
18273
18465
|
artifacts,
|
|
18274
18466
|
agents: lockFile.agents
|
|
18275
18467
|
});
|
|
18276
|
-
return
|
|
18468
|
+
return remapDeployedFilesForHomeInstall(
|
|
18469
|
+
response.fileUpdates.createOrUpdate,
|
|
18470
|
+
options.projectDir
|
|
18471
|
+
);
|
|
18277
18472
|
} catch {
|
|
18278
18473
|
return [];
|
|
18279
18474
|
}
|
|
18280
18475
|
}
|
|
18476
|
+
function remapDeployedFilesForHomeInstall(files, projectDir) {
|
|
18477
|
+
if (!projectDir) return files;
|
|
18478
|
+
const homeAgent = isAgentHomeDirectory(projectDir);
|
|
18479
|
+
if (!homeAgent) return files;
|
|
18480
|
+
const prefix = getAgentHomeDirPrefix(homeAgent);
|
|
18481
|
+
if (!prefix) return files;
|
|
18482
|
+
return files.filter((file) => !file.path.startsWith(".packmind/")).map((file) => {
|
|
18483
|
+
const remapped = file.path.startsWith(prefix) ? { ...file, path: file.path.slice(prefix.length) } : { ...file };
|
|
18484
|
+
if (remapped.content !== void 0) {
|
|
18485
|
+
remapped.content = stripFullStandardLinkFooter(remapped.content);
|
|
18486
|
+
}
|
|
18487
|
+
return remapped;
|
|
18488
|
+
});
|
|
18489
|
+
}
|
|
18281
18490
|
|
|
18282
18491
|
// apps/cli/src/infra/commands/playbook/addHandler.ts
|
|
18283
18492
|
async function tryStageRemovedFromLockFile(resolvedPath, deps) {
|
|
18284
|
-
const fileDir =
|
|
18493
|
+
const fileDir = path29.dirname(resolvedPath);
|
|
18285
18494
|
const targetDir = await findNearestConfigDir(fileDir, deps.packmindCliHexa);
|
|
18286
18495
|
if (!targetDir) return false;
|
|
18287
18496
|
const lockFile = await deps.lockFileRepository.read(targetDir);
|
|
18288
18497
|
if (!lockFile) return false;
|
|
18289
|
-
const normalizedPath = normalizePath2(
|
|
18498
|
+
const normalizedPath = normalizePath2(path29.relative(targetDir, resolvedPath));
|
|
18290
18499
|
const lockEntry = findLockFileEntryForPath(
|
|
18291
18500
|
normalizedPath,
|
|
18292
18501
|
lockFile.artifacts
|
|
18293
18502
|
);
|
|
18294
18503
|
if (!lockEntry) return false;
|
|
18295
18504
|
const gitRoot = await deps.packmindCliHexa.tryGetGitRepositoryRoot(targetDir);
|
|
18296
|
-
const configDir = gitRoot ? normalizePath2(
|
|
18505
|
+
const configDir = gitRoot ? normalizePath2(path29.relative(gitRoot, targetDir)) : void 0;
|
|
18297
18506
|
const deployedContext = await resolveDeployedContext(
|
|
18298
18507
|
deps.packmindCliHexa,
|
|
18299
18508
|
targetDir
|
|
@@ -18325,22 +18534,22 @@ async function tryStageRemovedFromLockFile(resolvedPath, deps) {
|
|
|
18325
18534
|
}
|
|
18326
18535
|
function resolveSkillDirectoryRoot(absolutePath) {
|
|
18327
18536
|
if (absolutePath.endsWith("SKILL.md")) {
|
|
18328
|
-
return
|
|
18537
|
+
return path29.dirname(absolutePath);
|
|
18329
18538
|
}
|
|
18330
18539
|
try {
|
|
18331
|
-
if (
|
|
18540
|
+
if (fs26.statSync(absolutePath).isDirectory()) {
|
|
18332
18541
|
return absolutePath;
|
|
18333
18542
|
}
|
|
18334
18543
|
} catch {
|
|
18335
18544
|
return absolutePath;
|
|
18336
18545
|
}
|
|
18337
|
-
let current =
|
|
18338
|
-
const root =
|
|
18546
|
+
let current = path29.dirname(absolutePath);
|
|
18547
|
+
const root = path29.parse(current).root;
|
|
18339
18548
|
while (current !== root) {
|
|
18340
|
-
if (
|
|
18549
|
+
if (fs26.existsSync(path29.join(current, "SKILL.md"))) {
|
|
18341
18550
|
return current;
|
|
18342
18551
|
}
|
|
18343
|
-
current =
|
|
18552
|
+
current = path29.dirname(current);
|
|
18344
18553
|
}
|
|
18345
18554
|
return absolutePath;
|
|
18346
18555
|
}
|
|
@@ -18363,17 +18572,17 @@ async function playbookAddHandler(deps) {
|
|
|
18363
18572
|
exit(1);
|
|
18364
18573
|
return;
|
|
18365
18574
|
}
|
|
18366
|
-
const absolutePath =
|
|
18575
|
+
const absolutePath = path29.resolve(cwd, filePath);
|
|
18367
18576
|
let artifactType;
|
|
18368
18577
|
let codingAgent;
|
|
18369
18578
|
const earlyTargetDir = await findNearestConfigDir(
|
|
18370
|
-
|
|
18579
|
+
path29.dirname(absolutePath),
|
|
18371
18580
|
packmindCliHexa
|
|
18372
18581
|
);
|
|
18373
18582
|
const earlyLockFile = earlyTargetDir ? await lockFileRepository.read(earlyTargetDir) : null;
|
|
18374
18583
|
if (earlyLockFile && earlyTargetDir) {
|
|
18375
18584
|
const normalizedForLookup = normalizePath2(
|
|
18376
|
-
|
|
18585
|
+
path29.relative(earlyTargetDir, absolutePath)
|
|
18377
18586
|
);
|
|
18378
18587
|
const lockResult = findLockFileEntryAndFileForPath(
|
|
18379
18588
|
normalizedForLookup,
|
|
@@ -18507,7 +18716,7 @@ Content goes here...`
|
|
|
18507
18716
|
return;
|
|
18508
18717
|
}
|
|
18509
18718
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(targetDir);
|
|
18510
|
-
const configDir = gitRoot ? normalizePath2(
|
|
18719
|
+
const configDir = gitRoot ? normalizePath2(path29.relative(gitRoot, targetDir)) : void 0;
|
|
18511
18720
|
const deployedContext = await resolveDeployedContext(
|
|
18512
18721
|
packmindCliHexa,
|
|
18513
18722
|
targetDir
|
|
@@ -18515,7 +18724,7 @@ Content goes here...`
|
|
|
18515
18724
|
const targetId = deployedContext?.targetId ?? earlyLockFile?.targetId;
|
|
18516
18725
|
const normalizedFilePath = (() => {
|
|
18517
18726
|
const refPath = artifactType === "skill" && skillDirPath ? skillDirPath : absolutePath;
|
|
18518
|
-
return normalizePath2(
|
|
18727
|
+
return normalizePath2(path29.relative(targetDir, refPath));
|
|
18519
18728
|
})();
|
|
18520
18729
|
let spaceId;
|
|
18521
18730
|
let spaceName;
|
|
@@ -18622,7 +18831,8 @@ Run ${formatLabel("packmind-cli install")} to update before making changes.`
|
|
|
18622
18831
|
if (changeType === "updated" && earlyLockFile) {
|
|
18623
18832
|
const deployedFiles = await fetchDeployedFiles(
|
|
18624
18833
|
packmindCliHexa.getPackmindGateway(),
|
|
18625
|
-
earlyLockFile
|
|
18834
|
+
earlyLockFile,
|
|
18835
|
+
{ projectDir: targetDir }
|
|
18626
18836
|
);
|
|
18627
18837
|
if (artifactType === "skill") {
|
|
18628
18838
|
const skillDeployedFiles = deployedFiles.filter(
|
|
@@ -18630,7 +18840,7 @@ Run ${formatLabel("packmind-cli install")} to update before making changes.`
|
|
|
18630
18840
|
);
|
|
18631
18841
|
const allMatch = skillDeployedFiles.length > 0 && skillDeployedFiles.length === skillFiles.length && skillDeployedFiles.every((deployed) => {
|
|
18632
18842
|
const localFile = skillFiles.find(
|
|
18633
|
-
(f) => normalizePath2(
|
|
18843
|
+
(f) => normalizePath2(path29.join(normalizedFilePath, f.relativePath)) === normalizePath2(deployed.path)
|
|
18634
18844
|
);
|
|
18635
18845
|
return localFile && deployed.content?.trim() === localFile.content.trim() && (!deployed.skillFilePermissions || deployed.skillFilePermissions === localFile.permissions);
|
|
18636
18846
|
});
|
|
@@ -18742,8 +18952,8 @@ var addPlaybookCommand = (0, import_cmd_ts24.command)({
|
|
|
18742
18952
|
var import_cmd_ts25 = __toESM(require_cjs());
|
|
18743
18953
|
|
|
18744
18954
|
// apps/cli/src/infra/commands/playbook/rmHandler.ts
|
|
18745
|
-
var
|
|
18746
|
-
var
|
|
18955
|
+
var fs27 = __toESM(require("fs"));
|
|
18956
|
+
var path30 = __toESM(require("path"));
|
|
18747
18957
|
function isSkillSupportFile(absolutePath) {
|
|
18748
18958
|
const normalized = absolutePath.replace(/\\/g, "/");
|
|
18749
18959
|
const skillDirMatch = normalized.match(/\/skills\/[^/]+\//);
|
|
@@ -18770,14 +18980,14 @@ async function playbookRmHandler(deps) {
|
|
|
18770
18980
|
exit(1);
|
|
18771
18981
|
return;
|
|
18772
18982
|
}
|
|
18773
|
-
const absolutePath =
|
|
18774
|
-
if (!
|
|
18983
|
+
const absolutePath = path30.resolve(getCwd(), filePath);
|
|
18984
|
+
if (!fs27.existsSync(absolutePath)) {
|
|
18775
18985
|
logErrorConsole(`File not found: "${filePath}"`);
|
|
18776
18986
|
exit(1);
|
|
18777
18987
|
return;
|
|
18778
18988
|
}
|
|
18779
18989
|
const targetDir = await findNearestConfigDir(
|
|
18780
|
-
|
|
18990
|
+
path30.dirname(absolutePath),
|
|
18781
18991
|
packmindCliHexa
|
|
18782
18992
|
);
|
|
18783
18993
|
if (!targetDir) {
|
|
@@ -18794,7 +19004,7 @@ async function playbookRmHandler(deps) {
|
|
|
18794
19004
|
return;
|
|
18795
19005
|
}
|
|
18796
19006
|
const normalizedForLookup = normalizePath2(
|
|
18797
|
-
|
|
19007
|
+
path30.relative(targetDir, absolutePath)
|
|
18798
19008
|
);
|
|
18799
19009
|
const lockResult = findLockFileEntryAndFileForPath(
|
|
18800
19010
|
normalizedForLookup,
|
|
@@ -18816,7 +19026,7 @@ async function playbookRmHandler(deps) {
|
|
|
18816
19026
|
}
|
|
18817
19027
|
const resolvedAbsolutePath = artifactType === "skill" ? resolveSkillDirPath(absolutePath) : absolutePath;
|
|
18818
19028
|
const normalizedFilePath = normalizePath2(
|
|
18819
|
-
|
|
19029
|
+
path30.relative(targetDir, resolvedAbsolutePath)
|
|
18820
19030
|
);
|
|
18821
19031
|
const lockEntry = findLockFileEntryAndFileForPath(normalizedFilePath, lockFile.artifacts)?.entry ?? lockResult.entry;
|
|
18822
19032
|
if (!lockEntry) {
|
|
@@ -18844,7 +19054,7 @@ async function playbookRmHandler(deps) {
|
|
|
18844
19054
|
}
|
|
18845
19055
|
const spaceName = matchingSpace.name;
|
|
18846
19056
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(targetDir);
|
|
18847
|
-
const configDir = gitRoot ? normalizePath2(
|
|
19057
|
+
const configDir = gitRoot ? normalizePath2(path30.relative(gitRoot, targetDir)) : "";
|
|
18848
19058
|
const deployedContext = await resolveDeployedContext(
|
|
18849
19059
|
packmindCliHexa,
|
|
18850
19060
|
targetDir
|
|
@@ -18905,7 +19115,7 @@ var rmPlaybookCommand = (0, import_cmd_ts25.command)({
|
|
|
18905
19115
|
var import_cmd_ts26 = __toESM(require_cjs());
|
|
18906
19116
|
|
|
18907
19117
|
// apps/cli/src/infra/commands/playbook/unstageHandler.ts
|
|
18908
|
-
var
|
|
19118
|
+
var path31 = __toESM(require("path"));
|
|
18909
19119
|
async function playbookUnstageHandler(deps) {
|
|
18910
19120
|
const {
|
|
18911
19121
|
packmindCliHexa,
|
|
@@ -18923,10 +19133,10 @@ async function playbookUnstageHandler(deps) {
|
|
|
18923
19133
|
return;
|
|
18924
19134
|
}
|
|
18925
19135
|
const cwd = getCwd();
|
|
18926
|
-
const absolutePath =
|
|
19136
|
+
const absolutePath = path31.resolve(cwd, filePath);
|
|
18927
19137
|
const resolvedPath = resolveSkillDirPath(absolutePath);
|
|
18928
19138
|
const configDir = await findNearestConfigDir(
|
|
18929
|
-
|
|
19139
|
+
path31.dirname(resolvedPath),
|
|
18930
19140
|
packmindCliHexa
|
|
18931
19141
|
);
|
|
18932
19142
|
if (!configDir) {
|
|
@@ -18939,10 +19149,10 @@ async function playbookUnstageHandler(deps) {
|
|
|
18939
19149
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(cwd);
|
|
18940
19150
|
const baseDir = gitRoot ?? configDir;
|
|
18941
19151
|
const normalizedFilePath = normalizePath2(
|
|
18942
|
-
|
|
19152
|
+
path31.relative(baseDir, resolvedPath)
|
|
18943
19153
|
);
|
|
18944
19154
|
const matchingEntries = playbookLocalRepository.getChanges().filter((c) => {
|
|
18945
|
-
const fullEntryPath = c.configDir ? normalizePath2(
|
|
19155
|
+
const fullEntryPath = c.configDir ? normalizePath2(path31.join(c.configDir, c.filePath)) : c.filePath;
|
|
18946
19156
|
return fullEntryPath === normalizedFilePath;
|
|
18947
19157
|
});
|
|
18948
19158
|
if (matchingEntries.length === 0) {
|
|
@@ -19026,15 +19236,15 @@ var import_cmd_ts27 = __toESM(require_cjs());
|
|
|
19026
19236
|
|
|
19027
19237
|
// apps/cli/src/infra/utils/listDirectoryFiles.ts
|
|
19028
19238
|
var import_fs22 = require("fs");
|
|
19029
|
-
var
|
|
19239
|
+
var path32 = __toESM(require("path"));
|
|
19030
19240
|
function listDirectoryFiles(dirPath) {
|
|
19031
19241
|
const results = [];
|
|
19032
19242
|
const entries = (0, import_fs22.readdirSync)(dirPath, { withFileTypes: true });
|
|
19033
19243
|
for (const entry of entries) {
|
|
19034
|
-
const fullPath =
|
|
19244
|
+
const fullPath = path32.join(dirPath, entry.name);
|
|
19035
19245
|
if (entry.isDirectory()) {
|
|
19036
19246
|
for (const nested of listDirectoryFiles(fullPath)) {
|
|
19037
|
-
results.push(
|
|
19247
|
+
results.push(path32.join(entry.name, nested));
|
|
19038
19248
|
}
|
|
19039
19249
|
} else if (entry.isFile()) {
|
|
19040
19250
|
results.push(entry.name);
|
|
@@ -19044,7 +19254,7 @@ function listDirectoryFiles(dirPath) {
|
|
|
19044
19254
|
}
|
|
19045
19255
|
|
|
19046
19256
|
// apps/cli/src/infra/commands/playbook/statusHandler.ts
|
|
19047
|
-
var
|
|
19257
|
+
var path33 = __toESM(require("path"));
|
|
19048
19258
|
|
|
19049
19259
|
// apps/cli/src/infra/utils/stringUtils.ts
|
|
19050
19260
|
function capitalize(s) {
|
|
@@ -19079,7 +19289,7 @@ function groupStagedChanges(changes, cwd, gitRoot) {
|
|
|
19079
19289
|
const changeType = change.changeType ?? "updated";
|
|
19080
19290
|
const key = `${change.artifactType}:${change.artifactName}:${changeType}`;
|
|
19081
19291
|
const rootRelativePath = change.configDir ? `${change.configDir}/${change.filePath}` : change.filePath;
|
|
19082
|
-
const displayPath = gitRoot ? normalizePath2(
|
|
19292
|
+
const displayPath = gitRoot ? normalizePath2(path33.relative(cwd, path33.join(gitRoot, rootRelativePath))) : rootRelativePath;
|
|
19083
19293
|
const existing = groups.get(key);
|
|
19084
19294
|
if (existing) {
|
|
19085
19295
|
existing.filePaths.push(displayPath);
|
|
@@ -19137,12 +19347,12 @@ async function playbookStatusHandler(deps) {
|
|
|
19137
19347
|
const fallbackConfigDir = await findNearestConfigDir(cwd, packmindCliHexa);
|
|
19138
19348
|
const configDirs = /* @__PURE__ */ new Set([...stagedByConfigDir.keys()]);
|
|
19139
19349
|
if (fallbackConfigDir && !configDirs.has("__cwd__")) {
|
|
19140
|
-
const
|
|
19141
|
-
if (!configDirs.has(
|
|
19350
|
+
const key = gitRoot ? normalizePath2(path33.relative(gitRoot, fallbackConfigDir)) : "__cwd__";
|
|
19351
|
+
if (!configDirs.has(key)) configDirs.add(key);
|
|
19142
19352
|
}
|
|
19143
19353
|
const descendantDirs = await packmindCliHexa.findDescendantConfigs(cwd);
|
|
19144
19354
|
for (const descendantDir of descendantDirs) {
|
|
19145
|
-
const rel = gitRoot ? normalizePath2(
|
|
19355
|
+
const rel = gitRoot ? normalizePath2(path33.relative(gitRoot, descendantDir)) : normalizePath2(path33.relative(cwd, descendantDir));
|
|
19146
19356
|
if (!configDirs.has(rel)) configDirs.add(rel);
|
|
19147
19357
|
}
|
|
19148
19358
|
for (const configDirKey of configDirs) {
|
|
@@ -19150,7 +19360,7 @@ async function playbookStatusHandler(deps) {
|
|
|
19150
19360
|
if (configDirKey === "__cwd__") {
|
|
19151
19361
|
projectDir = fallbackConfigDir;
|
|
19152
19362
|
} else if (gitRoot) {
|
|
19153
|
-
projectDir =
|
|
19363
|
+
projectDir = path33.join(gitRoot, configDirKey);
|
|
19154
19364
|
} else {
|
|
19155
19365
|
continue;
|
|
19156
19366
|
}
|
|
@@ -19159,7 +19369,8 @@ async function playbookStatusHandler(deps) {
|
|
|
19159
19369
|
if (!lockFile || Object.keys(lockFile.artifacts).length === 0) continue;
|
|
19160
19370
|
const deployedFiles = await fetchDeployedFiles(
|
|
19161
19371
|
packmindCliHexa.getPackmindGateway(),
|
|
19162
|
-
lockFile
|
|
19372
|
+
lockFile,
|
|
19373
|
+
{ projectDir }
|
|
19163
19374
|
);
|
|
19164
19375
|
const targetStagedPaths = new Set(
|
|
19165
19376
|
(stagedByConfigDir.get(configDirKey) ?? []).map(
|
|
@@ -19175,11 +19386,11 @@ async function playbookStatusHandler(deps) {
|
|
|
19175
19386
|
continue;
|
|
19176
19387
|
}
|
|
19177
19388
|
const displayPath = normalizePath2(
|
|
19178
|
-
|
|
19389
|
+
path33.relative(cwd, path33.join(projectDir, deployedFile.path))
|
|
19179
19390
|
);
|
|
19180
19391
|
let localContent;
|
|
19181
19392
|
try {
|
|
19182
|
-
localContent = readFile11(
|
|
19393
|
+
localContent = readFile11(path33.join(projectDir, deployedFile.path));
|
|
19183
19394
|
} catch {
|
|
19184
19395
|
const artifact = findArtifactForFile(
|
|
19185
19396
|
deployedFile.path,
|
|
@@ -19208,7 +19419,7 @@ async function playbookStatusHandler(deps) {
|
|
|
19208
19419
|
});
|
|
19209
19420
|
}
|
|
19210
19421
|
} else if (deployedFile.skillFilePermissions && getFileMode) {
|
|
19211
|
-
const localMode = getFileMode(
|
|
19422
|
+
const localMode = getFileMode(path33.join(projectDir, deployedFile.path));
|
|
19212
19423
|
if (localMode !== null) {
|
|
19213
19424
|
const localPermissions = modeToPermissionStringOrDefault(localMode);
|
|
19214
19425
|
if (localPermissions !== deployedFile.skillFilePermissions) {
|
|
@@ -19237,13 +19448,13 @@ async function playbookStatusHandler(deps) {
|
|
|
19237
19448
|
(f) => normalizePath2(f.path).endsWith("/SKILL.md")
|
|
19238
19449
|
);
|
|
19239
19450
|
if (!skillMdFile) continue;
|
|
19240
|
-
const skillDir = normalizePath2(
|
|
19451
|
+
const skillDir = normalizePath2(path33.dirname(skillMdFile.path));
|
|
19241
19452
|
if (targetStagedPaths.has(skillDir) || targetSkillDirPaths.some(
|
|
19242
19453
|
(staged) => skillDir === staged || skillDir.startsWith(staged + "/")
|
|
19243
19454
|
)) {
|
|
19244
19455
|
continue;
|
|
19245
19456
|
}
|
|
19246
|
-
const absoluteSkillDir =
|
|
19457
|
+
const absoluteSkillDir = path33.join(projectDir, skillDir);
|
|
19247
19458
|
let localFiles;
|
|
19248
19459
|
try {
|
|
19249
19460
|
localFiles = listDirectoryFiles2(absoluteSkillDir);
|
|
@@ -19252,11 +19463,11 @@ async function playbookStatusHandler(deps) {
|
|
|
19252
19463
|
}
|
|
19253
19464
|
for (const localRelPath of localFiles) {
|
|
19254
19465
|
const normalizedLocalPath = normalizePath2(
|
|
19255
|
-
|
|
19466
|
+
path33.join(skillDir, localRelPath)
|
|
19256
19467
|
);
|
|
19257
19468
|
if (!deployedPathSet.has(normalizedLocalPath)) {
|
|
19258
19469
|
const displayPath = normalizePath2(
|
|
19259
|
-
|
|
19470
|
+
path33.relative(cwd, path33.join(projectDir, normalizedLocalPath))
|
|
19260
19471
|
);
|
|
19261
19472
|
untrackedChanges.push({
|
|
19262
19473
|
artifactName: entry.name,
|
|
@@ -19341,7 +19552,7 @@ var import_fs25 = require("fs");
|
|
|
19341
19552
|
var import_cmd_ts28 = __toESM(require_cjs());
|
|
19342
19553
|
|
|
19343
19554
|
// apps/cli/src/infra/commands/playbook/submitHandler.ts
|
|
19344
|
-
var
|
|
19555
|
+
var path35 = __toESM(require("path"));
|
|
19345
19556
|
|
|
19346
19557
|
// apps/cli/src/infra/commands/playbook/submit/duplicateNameChecker.ts
|
|
19347
19558
|
var import_slug5 = __toESM(require("slug"));
|
|
@@ -19403,7 +19614,7 @@ async function checkForDuplicateNames(createdEntries, packmindGateway) {
|
|
|
19403
19614
|
}
|
|
19404
19615
|
|
|
19405
19616
|
// apps/cli/src/infra/commands/playbook/submit/targetContextResolver.ts
|
|
19406
|
-
var
|
|
19617
|
+
var path34 = __toESM(require("path"));
|
|
19407
19618
|
async function createTargetContextResolver(deps) {
|
|
19408
19619
|
const { lockFileRepository, cwd, packmindCliHexa } = deps;
|
|
19409
19620
|
const gitRoot = await packmindCliHexa.tryGetGitRepositoryRoot(cwd);
|
|
@@ -19414,14 +19625,15 @@ async function createTargetContextResolver(deps) {
|
|
|
19414
19625
|
if (cache.has(key)) return cache.get(key);
|
|
19415
19626
|
let projectDir;
|
|
19416
19627
|
if (entry.configDir !== void 0 && gitRoot) {
|
|
19417
|
-
projectDir =
|
|
19628
|
+
projectDir = path34.join(gitRoot, entry.configDir);
|
|
19418
19629
|
} else {
|
|
19419
19630
|
projectDir = await findNearestConfigDir(cwd, packmindCliHexa);
|
|
19420
19631
|
}
|
|
19421
19632
|
const lockFile = projectDir ? await lockFileRepository.read(projectDir) : null;
|
|
19422
19633
|
const deployedFiles = lockFile && Object.keys(lockFile.artifacts).length > 0 ? await fetchDeployedFiles(
|
|
19423
19634
|
packmindCliHexa.getPackmindGateway(),
|
|
19424
|
-
lockFile
|
|
19635
|
+
lockFile,
|
|
19636
|
+
{ projectDir: projectDir ?? void 0 }
|
|
19425
19637
|
) : [];
|
|
19426
19638
|
const ctx = { lockFile, deployedFiles, projectDir };
|
|
19427
19639
|
cache.set(key, ctx);
|
|
@@ -20396,7 +20608,7 @@ Only one agent version can be submitted at a time. Use "playbook unstage" to rem
|
|
|
20396
20608
|
const entryCtx = resolver.getCachedContext(entry.configDir);
|
|
20397
20609
|
if (!entryCtx?.projectDir) continue;
|
|
20398
20610
|
try {
|
|
20399
|
-
const fullPath =
|
|
20611
|
+
const fullPath = path35.join(entryCtx.projectDir, entry.filePath);
|
|
20400
20612
|
if (entry.artifactType === "skill") {
|
|
20401
20613
|
deps.rmSync(fullPath, { recursive: true });
|
|
20402
20614
|
} else {
|
|
@@ -20424,7 +20636,7 @@ Only one agent version can be submitted at a time. Use "playbook unstage" to rem
|
|
|
20424
20636
|
const entryCtx = resolver.getCachedContext(entry.configDir);
|
|
20425
20637
|
if (!entryCtx?.projectDir) continue;
|
|
20426
20638
|
try {
|
|
20427
|
-
const fullPath =
|
|
20639
|
+
const fullPath = path35.join(entryCtx.projectDir, entry.filePath);
|
|
20428
20640
|
if (entry.artifactType === "skill") {
|
|
20429
20641
|
deps.rmSync(fullPath, { recursive: true });
|
|
20430
20642
|
} else {
|
|
@@ -20602,7 +20814,7 @@ var diffCommand2 = (0, import_cmd_ts29.command)({
|
|
|
20602
20814
|
type: (0, import_cmd_ts29.optional)(import_cmd_ts29.string)
|
|
20603
20815
|
})
|
|
20604
20816
|
},
|
|
20605
|
-
handler: async ({ includeSubmitted, path:
|
|
20817
|
+
handler: async ({ includeSubmitted, path: path37 }) => {
|
|
20606
20818
|
const packmindLogger = new PackmindLogger("PackmindCLI", "info" /* INFO */);
|
|
20607
20819
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
20608
20820
|
await diffArtefactsHandler({
|
|
@@ -20611,7 +20823,7 @@ var diffCommand2 = (0, import_cmd_ts29.command)({
|
|
|
20611
20823
|
getCwd: () => process.cwd(),
|
|
20612
20824
|
log: console.log,
|
|
20613
20825
|
includeSubmitted,
|
|
20614
|
-
path:
|
|
20826
|
+
path: path37
|
|
20615
20827
|
});
|
|
20616
20828
|
}
|
|
20617
20829
|
});
|
|
@@ -20818,14 +21030,14 @@ To restore organization settings later, remove all local agents with: packmind-c
|
|
|
20818
21030
|
|
|
20819
21031
|
// apps/cli/src/infra/commands/config/ConfigAgentsAddCommand.ts
|
|
20820
21032
|
function createPromptConfirm() {
|
|
20821
|
-
return (message) => new Promise((
|
|
21033
|
+
return (message) => new Promise((resolve16) => {
|
|
20822
21034
|
const rl = readline4.createInterface({
|
|
20823
21035
|
input: process.stdin,
|
|
20824
21036
|
output: process.stdout
|
|
20825
21037
|
});
|
|
20826
21038
|
rl.question(`${message} (y/N) `, (answer) => {
|
|
20827
21039
|
rl.close();
|
|
20828
|
-
|
|
21040
|
+
resolve16(answer.toLowerCase() === "y");
|
|
20829
21041
|
});
|
|
20830
21042
|
});
|
|
20831
21043
|
}
|
|
@@ -21181,20 +21393,20 @@ function findEnvFile() {
|
|
|
21181
21393
|
const currentDir = process.cwd();
|
|
21182
21394
|
const gitService = new GitService();
|
|
21183
21395
|
const gitRoot = gitService.getGitRepositoryRootSync(currentDir);
|
|
21184
|
-
const filesystemRoot =
|
|
21396
|
+
const filesystemRoot = path36.parse(currentDir).root;
|
|
21185
21397
|
const stopDir = gitRoot ?? filesystemRoot;
|
|
21186
21398
|
let searchDir = currentDir;
|
|
21187
|
-
let parentDir =
|
|
21399
|
+
let parentDir = path36.dirname(searchDir);
|
|
21188
21400
|
while (searchDir !== parentDir) {
|
|
21189
|
-
const envPath2 =
|
|
21190
|
-
if (
|
|
21401
|
+
const envPath2 = path36.join(searchDir, ".env");
|
|
21402
|
+
if (fs28.existsSync(envPath2)) {
|
|
21191
21403
|
return envPath2;
|
|
21192
21404
|
}
|
|
21193
21405
|
if (searchDir === stopDir) {
|
|
21194
21406
|
return null;
|
|
21195
21407
|
}
|
|
21196
21408
|
searchDir = parentDir;
|
|
21197
|
-
parentDir =
|
|
21409
|
+
parentDir = path36.dirname(searchDir);
|
|
21198
21410
|
}
|
|
21199
21411
|
return null;
|
|
21200
21412
|
}
|