@tanstack/intent 0.0.23 → 0.0.29
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/dist/cli.mjs +28 -41
- package/dist/display-DdmZXLZm.mjs +3 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +6 -4
- package/dist/{install-BHbA_wkb.mjs → install-BzDmD5yI.mjs} +7 -0
- package/dist/intent-library.mjs +4 -4
- package/dist/{library-scanner-DlWy8VeZ.mjs → library-scanner-B51qV5aX.mjs} +6 -4
- package/dist/library-scanner.d.mts +1 -1
- package/dist/library-scanner.mjs +2 -2
- package/dist/project-context-D6A5sBBO.mjs +53 -0
- package/dist/{scanner-BCgNt-oI.mjs → scanner-B-bbXBLY.mjs} +10 -4
- package/dist/scanner-CP4U8F_n.mjs +5 -0
- package/dist/{setup-Nyfl1KTS.mjs → setup-B4ZwN5Hg.mjs} +9 -104
- package/dist/{setup-BNBVotfR.d.mts → setup-BA9RkENh.d.mts} +7 -13
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +4 -2
- package/dist/staleness-LRbiWWZK.mjs +4 -0
- package/dist/{staleness-DZKvsLVq.mjs → staleness-SY7-mZMH.mjs} +13 -2
- package/dist/{utils-BfjM1mQe.mjs → utils-COlDcU72.mjs} +8 -2
- package/dist/utils-dkVvY7D7.mjs +3 -0
- package/dist/workspace-patterns-Cndd-7vB.mjs +167 -0
- package/dist/workspace-patterns-D_y6rlqX.mjs +4 -0
- package/package.json +1 -1
- package/dist/display-CuCDLPP_.mjs +0 -3
- package/dist/scanner-CsDGCRDm.mjs +0 -5
- package/dist/staleness-Dr5-5wj5.mjs +0 -4
- package/dist/utils-D7OKi0Rn.mjs +0 -3
- /package/dist/{display-DhsUxNJW.mjs → display-hdsqb4w-.mjs} +0 -0
- /package/dist/{types-ddLtccfV.d.mts → types-BTQ9efv-.d.mts} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import "./utils-COlDcU72.mjs";
|
|
3
|
+
import "./workspace-patterns-Cndd-7vB.mjs";
|
|
4
|
+
import { t as resolveProjectContext } from "./project-context-D6A5sBBO.mjs";
|
|
5
|
+
import { n as runInstallCommand } from "./install-BzDmD5yI.mjs";
|
|
3
6
|
import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
4
|
-
import { dirname, join, relative, sep } from "node:path";
|
|
7
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
5
8
|
import { fileURLToPath } from "node:url";
|
|
6
9
|
import { cac } from "cac";
|
|
7
10
|
|
|
@@ -29,7 +32,7 @@ function getMetaDir() {
|
|
|
29
32
|
return join(dirname(fileURLToPath(import.meta.url)), "..", "meta");
|
|
30
33
|
}
|
|
31
34
|
async function scanIntentsOrFail() {
|
|
32
|
-
const { scanForIntents } = await import("./scanner-
|
|
35
|
+
const { scanForIntents } = await import("./scanner-CP4U8F_n.mjs");
|
|
33
36
|
try {
|
|
34
37
|
return scanForIntents();
|
|
35
38
|
} catch (err) {
|
|
@@ -45,10 +48,15 @@ function readPackageName(root) {
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
async function resolveStaleTargets(targetDir) {
|
|
48
|
-
const resolvedRoot = targetDir ?
|
|
49
|
-
const
|
|
51
|
+
const resolvedRoot = targetDir ? resolve(process.cwd(), targetDir) : process.cwd();
|
|
52
|
+
const context = resolveProjectContext({
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
targetPath: targetDir
|
|
55
|
+
});
|
|
56
|
+
const { checkStaleness } = await import("./staleness-LRbiWWZK.mjs");
|
|
57
|
+
if (context.packageRoot && (context.targetSkillsDir !== null || resolvedRoot !== context.workspaceRoot)) return { reports: [await checkStaleness(context.packageRoot, readPackageName(context.packageRoot))] };
|
|
50
58
|
if (existsSync(join(resolvedRoot, "skills"))) return { reports: [await checkStaleness(resolvedRoot, readPackageName(resolvedRoot))] };
|
|
51
|
-
const { findPackagesWithSkills, findWorkspaceRoot } = await import("./
|
|
59
|
+
const { findPackagesWithSkills, findWorkspaceRoot } = await import("./workspace-patterns-D_y6rlqX.mjs");
|
|
52
60
|
const workspaceRoot = findWorkspaceRoot(resolvedRoot);
|
|
53
61
|
if (workspaceRoot) {
|
|
54
62
|
const packageDirs = findPackagesWithSkills(workspaceRoot);
|
|
@@ -87,7 +95,7 @@ function printVersionConflicts(result) {
|
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
async function runListCommand(options, scanIntentsOrFail$1) {
|
|
90
|
-
const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-
|
|
98
|
+
const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-DdmZXLZm.mjs");
|
|
91
99
|
const result = await scanIntentsOrFail$1();
|
|
92
100
|
if (options.json) {
|
|
93
101
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -151,7 +159,7 @@ async function runMetaCommand(name, metaDir) {
|
|
|
151
159
|
}
|
|
152
160
|
return;
|
|
153
161
|
}
|
|
154
|
-
const { parseFrontmatter } = await import("./utils-
|
|
162
|
+
const { parseFrontmatter } = await import("./utils-dkVvY7D7.mjs");
|
|
155
163
|
const entries = readdirSync(metaDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => existsSync(join(metaDir, entry.name, "SKILL.md")));
|
|
156
164
|
if (entries.length === 0) {
|
|
157
165
|
console.log("No meta-skills found.");
|
|
@@ -286,24 +294,9 @@ function buildValidationFailure(errors, warnings) {
|
|
|
286
294
|
}
|
|
287
295
|
return lines.join("\n");
|
|
288
296
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const parentPkg = join(dir, "package.json");
|
|
293
|
-
if (existsSync(parentPkg)) try {
|
|
294
|
-
const parent = JSON.parse(readFileSync(parentPkg, "utf8"));
|
|
295
|
-
return Array.isArray(parent.workspaces) || parent.workspaces?.packages;
|
|
296
|
-
} catch {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
const next = dirname(dir);
|
|
300
|
-
if (next === dir) break;
|
|
301
|
-
dir = next;
|
|
302
|
-
}
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
function collectPackagingWarnings(root) {
|
|
306
|
-
const pkgJsonPath = join(root, "package.json");
|
|
297
|
+
function collectPackagingWarnings(context) {
|
|
298
|
+
if (!context.packageRoot || !context.targetPackageJsonPath) return [];
|
|
299
|
+
const pkgJsonPath = context.targetPackageJsonPath;
|
|
307
300
|
if (!existsSync(pkgJsonPath)) return [];
|
|
308
301
|
let pkgJson;
|
|
309
302
|
try {
|
|
@@ -318,24 +311,18 @@ function collectPackagingWarnings(root) {
|
|
|
318
311
|
const files = pkgJson.files;
|
|
319
312
|
if (Array.isArray(files)) {
|
|
320
313
|
if (!files.includes("skills")) warnings.push("\"skills\" is not in the \"files\" array — skills won't be published");
|
|
321
|
-
if (!
|
|
314
|
+
if (!context.isMonorepo && !files.includes("!skills/_artifacts")) warnings.push("\"!skills/_artifacts\" is not in the \"files\" array — artifacts will be published unnecessarily");
|
|
322
315
|
}
|
|
323
316
|
return warnings;
|
|
324
317
|
}
|
|
325
|
-
function resolvePackageRoot(startDir) {
|
|
326
|
-
let dir = startDir;
|
|
327
|
-
while (true) {
|
|
328
|
-
if (existsSync(join(dir, "package.json"))) return dir;
|
|
329
|
-
const next = dirname(dir);
|
|
330
|
-
if (next === dir) return startDir;
|
|
331
|
-
dir = next;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
318
|
async function runValidateCommand(dir) {
|
|
335
|
-
const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-
|
|
319
|
+
const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-dkVvY7D7.mjs")]);
|
|
336
320
|
const targetDir = dir ?? "skills";
|
|
337
|
-
const
|
|
338
|
-
|
|
321
|
+
const context = resolveProjectContext({
|
|
322
|
+
cwd: process.cwd(),
|
|
323
|
+
targetPath: targetDir
|
|
324
|
+
});
|
|
325
|
+
const skillsDir = context.targetSkillsDir ?? resolve(process.cwd(), targetDir);
|
|
339
326
|
if (!existsSync(skillsDir)) fail(`Skills directory not found: ${skillsDir}`);
|
|
340
327
|
const errors = [];
|
|
341
328
|
const skillFiles = findSkillFiles(skillsDir);
|
|
@@ -399,7 +386,7 @@ async function runValidateCommand(dir) {
|
|
|
399
386
|
});
|
|
400
387
|
}
|
|
401
388
|
const artifactsDir = join(skillsDir, "_artifacts");
|
|
402
|
-
if (existsSync(artifactsDir)) for (const fileName of [
|
|
389
|
+
if (!context.isMonorepo && existsSync(artifactsDir)) for (const fileName of [
|
|
403
390
|
"domain_map.yaml",
|
|
404
391
|
"skill_spec.md",
|
|
405
392
|
"skill_tree.yaml"
|
|
@@ -430,7 +417,7 @@ async function runValidateCommand(dir) {
|
|
|
430
417
|
});
|
|
431
418
|
}
|
|
432
419
|
}
|
|
433
|
-
const warnings = collectPackagingWarnings(
|
|
420
|
+
const warnings = collectPackagingWarnings(context);
|
|
434
421
|
if (errors.length > 0) fail(buildValidationFailure(errors, warnings));
|
|
435
422
|
console.log(`✅ Validated ${skillFiles.length} skill files — all passed`);
|
|
436
423
|
if (warnings.length > 0) console.log();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as IntentProjectConfig, c as ScanResult, d as StalenessReport, i as IntentPackage, l as SkillEntry, n as FeedbackPayload, o as MetaFeedbackPayload, r as IntentConfig, s as MetaSkillName, t as AgentName, u as SkillStaleness } from "./types-
|
|
2
|
-
import {
|
|
1
|
+
import { a as IntentProjectConfig, c as ScanResult, d as StalenessReport, i as IntentPackage, l as SkillEntry, n as FeedbackPayload, o as MetaFeedbackPayload, r as IntentConfig, s as MetaSkillName, t as AgentName, u as SkillStaleness } from "./types-BTQ9efv-.mjs";
|
|
2
|
+
import { i as runEditPackageJson, o as runSetupGithubActions, r as SetupGithubActionsResult, t as EditPackageJsonResult } from "./setup-BA9RkENh.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/scanner.d.ts
|
|
5
5
|
declare function scanForIntents(root?: string): ScanResult;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { a as parseFrontmatter, n as findSkillFiles, o as resolveDepDir, r as getDeps } from "./utils-
|
|
2
|
-
import
|
|
3
|
-
import { t as scanForIntents } from "./scanner-
|
|
4
|
-
import { t as checkStaleness } from "./staleness-
|
|
1
|
+
import { a as parseFrontmatter, n as findSkillFiles, o as resolveDepDir, r as getDeps } from "./utils-COlDcU72.mjs";
|
|
2
|
+
import "./workspace-patterns-Cndd-7vB.mjs";
|
|
3
|
+
import { t as scanForIntents } from "./scanner-B-bbXBLY.mjs";
|
|
4
|
+
import { t as checkStaleness } from "./staleness-SY7-mZMH.mjs";
|
|
5
|
+
import "./project-context-D6A5sBBO.mjs";
|
|
6
|
+
import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-B4ZwN5Hg.mjs";
|
|
5
7
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
6
8
|
import { join } from "node:path";
|
|
7
9
|
import { execFileSync, execSync } from "node:child_process";
|
|
@@ -51,6 +51,13 @@ skills:
|
|
|
51
51
|
Rules:
|
|
52
52
|
- Use the user's own words for task descriptions
|
|
53
53
|
- Include the exact path from \`npx @tanstack/intent@latest list\` output so agents can load it directly
|
|
54
|
+
- Paths should use the stable \`node_modules/<package-name>/skills/...\` format (no version numbers)
|
|
55
|
+
- If a skill path from \`list\` contains package-manager-internal directories (e.g. \`.pnpm/\`, \`.bun/\`)
|
|
56
|
+
with version numbers, it is a transitive dependency without a stable top-level symlink.
|
|
57
|
+
For these skills, do NOT embed the versioned path. Instead, add a comment telling the agent
|
|
58
|
+
how to locate the skill at runtime:
|
|
59
|
+
- task: "describe the task"
|
|
60
|
+
# To load this skill, run: npx @tanstack/intent@latest list | grep <skill-name>
|
|
54
61
|
- Keep entries concise - this block is read on every agent task
|
|
55
62
|
- Preserve all content outside the block tags unchanged
|
|
56
63
|
- If the user is on Deno, note that this setup is best-effort today and relies on npm interop`;
|
package/dist/intent-library.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./utils-
|
|
3
|
-
import { t as INSTALL_PROMPT } from "./install-
|
|
4
|
-
import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-
|
|
5
|
-
import { t as scanLibrary } from "./library-scanner-
|
|
2
|
+
import "./utils-COlDcU72.mjs";
|
|
3
|
+
import { t as INSTALL_PROMPT } from "./install-BzDmD5yI.mjs";
|
|
4
|
+
import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-hdsqb4w-.mjs";
|
|
5
|
+
import { t as scanLibrary } from "./library-scanner-B51qV5aX.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/intent-library.ts
|
|
8
8
|
function cmdList() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as parseFrontmatter, o as resolveDepDir, r as getDeps } from "./utils-
|
|
1
|
+
import { a as parseFrontmatter, o as resolveDepDir, r as getDeps, s as toPosixPath } from "./utils-COlDcU72.mjs";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
-
import { dirname, join, relative
|
|
3
|
+
import { dirname, join, relative } from "node:path";
|
|
4
4
|
|
|
5
5
|
//#region src/library-scanner.ts
|
|
6
6
|
function readPkgJson(dir) {
|
|
@@ -44,7 +44,7 @@ function discoverSkills(skillsDir) {
|
|
|
44
44
|
const skillFile = join(childDir, "SKILL.md");
|
|
45
45
|
if (existsSync(skillFile)) {
|
|
46
46
|
const fm = parseFrontmatter(skillFile);
|
|
47
|
-
const relName = relative(skillsDir, childDir)
|
|
47
|
+
const relName = toPosixPath(relative(skillsDir, childDir));
|
|
48
48
|
skills.push({
|
|
49
49
|
name: typeof fm?.name === "string" ? fm.name : relName,
|
|
50
50
|
path: skillFile,
|
|
@@ -83,11 +83,13 @@ function scanLibrary(scriptPath, _projectRoot) {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
const skillsDir = join(dir, "skills");
|
|
86
|
+
const skills = existsSync(skillsDir) ? discoverSkills(skillsDir) : [];
|
|
87
|
+
if (name) for (const skill of skills) skill.path = `node_modules/${name}/${toPosixPath(relative(dir, skill.path))}`;
|
|
86
88
|
packages.push({
|
|
87
89
|
name,
|
|
88
90
|
version: typeof pkg.version === "string" ? pkg.version : "0.0.0",
|
|
89
91
|
description: typeof pkg.description === "string" ? pkg.description : "",
|
|
90
|
-
skills
|
|
92
|
+
skills
|
|
91
93
|
});
|
|
92
94
|
for (const depName of getDeps(pkg)) {
|
|
93
95
|
const depDir = resolveDepDir(depName, dir);
|
package/dist/library-scanner.mjs
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-Cndd-7vB.mjs";
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/core/project-context.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolves project structure by walking up from targetPath (or cwd) to find the
|
|
8
|
+
* owning package.json, then searches for a workspace root from the package root.
|
|
9
|
+
* Falls back to searching from cwd when targetPath points deep into a package.
|
|
10
|
+
*/
|
|
11
|
+
function resolveProjectContext({ cwd, targetPath }) {
|
|
12
|
+
const resolvedCwd = resolve(cwd);
|
|
13
|
+
const resolvedTargetPath = targetPath ? resolve(resolvedCwd, targetPath) : resolvedCwd;
|
|
14
|
+
const packageRoot = findOwningPackageRoot(resolvedTargetPath);
|
|
15
|
+
const workspaceRoot = findWorkspaceRoot(packageRoot ?? resolvedTargetPath) ?? findWorkspaceRoot(resolvedCwd);
|
|
16
|
+
const workspacePatterns = workspaceRoot ? readWorkspacePatterns(workspaceRoot) ?? [] : [];
|
|
17
|
+
return {
|
|
18
|
+
cwd: resolvedCwd,
|
|
19
|
+
workspaceRoot,
|
|
20
|
+
packageRoot,
|
|
21
|
+
isMonorepo: workspaceRoot !== null,
|
|
22
|
+
workspacePatterns,
|
|
23
|
+
targetPackageJsonPath: packageRoot ? join(packageRoot, "package.json") : null,
|
|
24
|
+
targetSkillsDir: resolveTargetSkillsDir(resolvedTargetPath, packageRoot)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function findOwningPackageRoot(startPath) {
|
|
28
|
+
let dir = toSearchDir(startPath);
|
|
29
|
+
while (true) {
|
|
30
|
+
if (existsSync(join(dir, "package.json"))) return dir;
|
|
31
|
+
const next = dirname(dir);
|
|
32
|
+
if (next === dir) return null;
|
|
33
|
+
dir = next;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function toSearchDir(path) {
|
|
37
|
+
if (!existsSync(path)) return path;
|
|
38
|
+
return statSync(path).isDirectory() ? path : dirname(path);
|
|
39
|
+
}
|
|
40
|
+
function resolveTargetSkillsDir(targetPath, packageRoot) {
|
|
41
|
+
if (!packageRoot) return null;
|
|
42
|
+
const packageSkillsDir = join(packageRoot, "skills");
|
|
43
|
+
if (isWithinOrEqual(targetPath, packageSkillsDir)) return packageSkillsDir;
|
|
44
|
+
if (targetPath === packageRoot && existsSync(packageSkillsDir)) return packageSkillsDir;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function isWithinOrEqual(path, parentDir) {
|
|
48
|
+
const rel = relative(parentDir, path);
|
|
49
|
+
return rel === "" || !rel.startsWith("..") && !rel.startsWith("/");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { resolveProjectContext as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as parseFrontmatter, i as listNodeModulesPackageDirs, o as resolveDepDir, r as getDeps, t as detectGlobalNodeModules } from "./utils-
|
|
2
|
-
import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns } from "./
|
|
1
|
+
import { a as parseFrontmatter, i as listNodeModulesPackageDirs, o as resolveDepDir, r as getDeps, s as toPosixPath, t as detectGlobalNodeModules } from "./utils-COlDcU72.mjs";
|
|
2
|
+
import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-Cndd-7vB.mjs";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import { join, relative, sep } from "node:path";
|
|
5
5
|
|
|
@@ -74,7 +74,7 @@ function discoverSkills(skillsDir, _baseName) {
|
|
|
74
74
|
const skillFile = join(childDir, "SKILL.md");
|
|
75
75
|
if (existsSync(skillFile)) {
|
|
76
76
|
const fm = parseFrontmatter(skillFile);
|
|
77
|
-
const relName = relative(skillsDir, childDir)
|
|
77
|
+
const relName = toPosixPath(relative(skillsDir, childDir));
|
|
78
78
|
const desc = typeof fm?.description === "string" ? fm.description.replace(/\s+/g, " ").trim() : "";
|
|
79
79
|
skills.push({
|
|
80
80
|
name: typeof fm?.name === "string" ? fm.name : relName,
|
|
@@ -251,11 +251,17 @@ function scanForIntents(root) {
|
|
|
251
251
|
warnings.push(`${name} has a skills/ directory but could not determine repo/docs from package.json (add a "repository" field or explicit "intent" config)`);
|
|
252
252
|
return false;
|
|
253
253
|
}
|
|
254
|
+
const skills = discoverSkills(skillsDir, name);
|
|
255
|
+
if (dirPath.startsWith(projectRoot + sep) || dirPath.startsWith(projectRoot + "/")) {
|
|
256
|
+
const hasStableSymlink = name !== "" && existsSync(join(projectRoot, "node_modules", name));
|
|
257
|
+
for (const skill of skills) if (hasStableSymlink) skill.path = `node_modules/${name}/${toPosixPath(relative(dirPath, skill.path))}`;
|
|
258
|
+
else skill.path = toPosixPath(relative(projectRoot, skill.path));
|
|
259
|
+
}
|
|
254
260
|
const candidate = {
|
|
255
261
|
name,
|
|
256
262
|
version,
|
|
257
263
|
intent,
|
|
258
|
-
skills
|
|
264
|
+
skills,
|
|
259
265
|
packageRoot: dirPath
|
|
260
266
|
};
|
|
261
267
|
const existingIndex = packageIndexes.get(name);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-Cndd-7vB.mjs";
|
|
2
|
+
import { t as resolveProjectContext } from "./project-context-D6A5sBBO.mjs";
|
|
2
3
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { basename, join, relative } from "node:path";
|
|
4
|
-
import { parse } from "yaml";
|
|
5
5
|
|
|
6
6
|
//#region src/setup.ts
|
|
7
7
|
function isGenericWorkspaceName(name, root) {
|
|
@@ -107,9 +107,11 @@ function runEditPackageJson(root) {
|
|
|
107
107
|
added: [],
|
|
108
108
|
alreadyPresent: []
|
|
109
109
|
};
|
|
110
|
-
const
|
|
110
|
+
const context = resolveProjectContext({ cwd: root });
|
|
111
|
+
const packageRoot = context.packageRoot ?? root;
|
|
112
|
+
const pkgPath = join(packageRoot, "package.json");
|
|
111
113
|
if (!existsSync(pkgPath)) {
|
|
112
|
-
console.error("No package.json found in " +
|
|
114
|
+
console.error("No package.json found in " + packageRoot);
|
|
113
115
|
process.exitCode = 1;
|
|
114
116
|
return result;
|
|
115
117
|
}
|
|
@@ -120,6 +122,7 @@ function runEditPackageJson(root) {
|
|
|
120
122
|
} catch (err) {
|
|
121
123
|
const detail = err instanceof SyntaxError ? err.message : String(err);
|
|
122
124
|
console.error(`Failed to parse ${pkgPath}: ${detail}`);
|
|
125
|
+
process.exitCode = 1;
|
|
123
126
|
return result;
|
|
124
127
|
}
|
|
125
128
|
const indentMatch = raw.match(/^(\s+)"/m);
|
|
@@ -133,23 +136,7 @@ function runEditPackageJson(root) {
|
|
|
133
136
|
}
|
|
134
137
|
if (!Array.isArray(pkg.files)) pkg.files = [];
|
|
135
138
|
const files = pkg.files;
|
|
136
|
-
const requiredFiles =
|
|
137
|
-
let dir = join(root, "..");
|
|
138
|
-
for (let i = 0; i < 5; i++) {
|
|
139
|
-
const parentPkg = join(dir, "package.json");
|
|
140
|
-
if (existsSync(parentPkg)) {
|
|
141
|
-
try {
|
|
142
|
-
const parent = JSON.parse(readFileSync(parentPkg, "utf8"));
|
|
143
|
-
if (Array.isArray(parent.workspaces) || parent.workspaces?.packages) return true;
|
|
144
|
-
} catch {}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
const next = join(dir, "..");
|
|
148
|
-
if (next === dir) break;
|
|
149
|
-
dir = next;
|
|
150
|
-
}
|
|
151
|
-
return false;
|
|
152
|
-
})() ? ["skills"] : ["skills", "!skills/_artifacts"];
|
|
139
|
+
const requiredFiles = context.isMonorepo ? ["skills"] : ["skills", "!skills/_artifacts"];
|
|
153
140
|
for (const entry of requiredFiles) if (files.includes(entry)) result.alreadyPresent.push(`files: "${entry}"`);
|
|
154
141
|
else {
|
|
155
142
|
files.push(entry);
|
|
@@ -160,88 +147,6 @@ function runEditPackageJson(root) {
|
|
|
160
147
|
for (const a of result.alreadyPresent) console.log(` Already present: ${a}`);
|
|
161
148
|
return result;
|
|
162
149
|
}
|
|
163
|
-
function readWorkspacePatterns(root) {
|
|
164
|
-
const pnpmWs = join(root, "pnpm-workspace.yaml");
|
|
165
|
-
if (existsSync(pnpmWs)) try {
|
|
166
|
-
const config = parse(readFileSync(pnpmWs, "utf8"));
|
|
167
|
-
if (Array.isArray(config.packages)) return config.packages;
|
|
168
|
-
} catch (err) {
|
|
169
|
-
console.error(`Warning: failed to parse ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
|
|
170
|
-
}
|
|
171
|
-
const pkgPath = join(root, "package.json");
|
|
172
|
-
if (existsSync(pkgPath)) try {
|
|
173
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
174
|
-
if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
|
|
175
|
-
if (Array.isArray(pkg.workspaces?.packages)) return pkg.workspaces.packages;
|
|
176
|
-
} catch (err) {
|
|
177
|
-
console.error(`Warning: failed to parse ${pkgPath}: ${err instanceof Error ? err.message : err}`);
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Resolve workspace glob patterns to actual package directories.
|
|
183
|
-
* Handles simple patterns like "packages/*" and "packages/**".
|
|
184
|
-
* Each resolved directory must contain a package.json.
|
|
185
|
-
*/
|
|
186
|
-
function resolveWorkspacePackages(root, patterns) {
|
|
187
|
-
const dirs = [];
|
|
188
|
-
for (const pattern of patterns) {
|
|
189
|
-
const baseDir = join(root, pattern.replace(/\/\*\*?(\/\*)?$/, ""));
|
|
190
|
-
if (!existsSync(baseDir)) continue;
|
|
191
|
-
if (pattern.includes("**")) collectPackageDirs(baseDir, dirs);
|
|
192
|
-
else if (pattern.endsWith("/*")) {
|
|
193
|
-
let entries;
|
|
194
|
-
try {
|
|
195
|
-
entries = readdirSync(baseDir, { withFileTypes: true });
|
|
196
|
-
} catch {
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
for (const entry of entries) {
|
|
200
|
-
if (!entry.isDirectory()) continue;
|
|
201
|
-
const dir = join(baseDir, entry.name);
|
|
202
|
-
if (existsSync(join(dir, "package.json"))) dirs.push(dir);
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
const dir = join(root, pattern);
|
|
206
|
-
if (existsSync(join(dir, "package.json"))) dirs.push(dir);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return dirs;
|
|
210
|
-
}
|
|
211
|
-
function collectPackageDirs(dir, result) {
|
|
212
|
-
if (existsSync(join(dir, "package.json"))) result.push(dir);
|
|
213
|
-
let entries;
|
|
214
|
-
try {
|
|
215
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
216
|
-
} catch (err) {
|
|
217
|
-
console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
for (const entry of entries) {
|
|
221
|
-
if (!entry.isDirectory() || entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
222
|
-
collectPackageDirs(join(dir, entry.name), result);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function findWorkspaceRoot(start) {
|
|
226
|
-
let dir = start;
|
|
227
|
-
while (true) {
|
|
228
|
-
if (readWorkspacePatterns(dir)) return dir;
|
|
229
|
-
const next = join(dir, "..");
|
|
230
|
-
if (next === dir) return null;
|
|
231
|
-
dir = next;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Find workspace packages that contain at least one SKILL.md file.
|
|
236
|
-
*/
|
|
237
|
-
function findPackagesWithSkills(root) {
|
|
238
|
-
const patterns = readWorkspacePatterns(root);
|
|
239
|
-
if (!patterns) return [];
|
|
240
|
-
return resolveWorkspacePackages(root, patterns).filter((dir) => {
|
|
241
|
-
const skillsDir = join(dir, "skills");
|
|
242
|
-
return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
150
|
/**
|
|
246
151
|
* When run from a monorepo root, finds all workspace packages with SKILL.md
|
|
247
152
|
* files and runs the given command on each. Falls back to single-package
|
|
@@ -292,4 +197,4 @@ function runSetupGithubActions(root, metaDir) {
|
|
|
292
197
|
}
|
|
293
198
|
|
|
294
199
|
//#endregion
|
|
295
|
-
export {
|
|
200
|
+
export { runEditPackageJsonAll as n, runSetupGithubActions as r, runEditPackageJson as t };
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
//#region src/workspace-patterns.d.ts
|
|
2
|
+
declare function readWorkspacePatterns(root: string): Array<string> | null;
|
|
3
|
+
declare function resolveWorkspacePackages(root: string, patterns: Array<string>): Array<string>;
|
|
4
|
+
declare function findWorkspaceRoot(start: string): string | null;
|
|
5
|
+
declare function findPackagesWithSkills(root: string): Array<string>;
|
|
6
|
+
//#endregion
|
|
1
7
|
//#region src/setup.d.ts
|
|
2
8
|
interface EditPackageJsonResult {
|
|
3
9
|
added: Array<string>;
|
|
@@ -12,19 +18,7 @@ interface MonorepoResult<T> {
|
|
|
12
18
|
result: T;
|
|
13
19
|
}
|
|
14
20
|
declare function runEditPackageJson(root: string): EditPackageJsonResult;
|
|
15
|
-
declare function readWorkspacePatterns(root: string): Array<string> | null;
|
|
16
|
-
/**
|
|
17
|
-
* Resolve workspace glob patterns to actual package directories.
|
|
18
|
-
* Handles simple patterns like "packages/*" and "packages/**".
|
|
19
|
-
* Each resolved directory must contain a package.json.
|
|
20
|
-
*/
|
|
21
|
-
declare function resolveWorkspacePackages(root: string, patterns: Array<string>): Array<string>;
|
|
22
|
-
declare function findWorkspaceRoot(start: string): string | null;
|
|
23
|
-
/**
|
|
24
|
-
* Find workspace packages that contain at least one SKILL.md file.
|
|
25
|
-
*/
|
|
26
|
-
declare function findPackagesWithSkills(root: string): Array<string>;
|
|
27
21
|
declare function runEditPackageJsonAll(root: string): Array<MonorepoResult<EditPackageJsonResult>> | EditPackageJsonResult;
|
|
28
22
|
declare function runSetupGithubActions(root: string, metaDir: string): SetupGithubActionsResult;
|
|
29
23
|
//#endregion
|
|
30
|
-
export {
|
|
24
|
+
export { runEditPackageJsonAll as a, findWorkspaceRoot as c, runEditPackageJson as i, readWorkspacePatterns as l, MonorepoResult as n, runSetupGithubActions as o, SetupGithubActionsResult as r, findPackagesWithSkills as s, EditPackageJsonResult as t, resolveWorkspacePackages as u };
|
package/dist/setup.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as runEditPackageJsonAll, c as findWorkspaceRoot, i as runEditPackageJson, l as readWorkspacePatterns, n as MonorepoResult, o as runSetupGithubActions, r as SetupGithubActionsResult, s as findPackagesWithSkills, t as EditPackageJsonResult, u as resolveWorkspacePackages } from "./setup-BA9RkENh.mjs";
|
|
2
2
|
export { EditPackageJsonResult, MonorepoResult, SetupGithubActionsResult, findPackagesWithSkills, findWorkspaceRoot, readWorkspacePatterns, resolveWorkspacePackages, runEditPackageJson, runEditPackageJsonAll, runSetupGithubActions };
|
package/dist/setup.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import "./utils-
|
|
2
|
-
import {
|
|
1
|
+
import "./utils-COlDcU72.mjs";
|
|
2
|
+
import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-Cndd-7vB.mjs";
|
|
3
|
+
import "./project-context-D6A5sBBO.mjs";
|
|
4
|
+
import { n as runEditPackageJsonAll, r as runSetupGithubActions, t as runEditPackageJson } from "./setup-B4ZwN5Hg.mjs";
|
|
3
5
|
|
|
4
6
|
export { findPackagesWithSkills, findWorkspaceRoot, readWorkspacePatterns, resolveWorkspacePackages, runEditPackageJson, runEditPackageJsonAll, runSetupGithubActions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as parseFrontmatter, n as findSkillFiles } from "./utils-
|
|
1
|
+
import { a as parseFrontmatter, n as findSkillFiles } from "./utils-COlDcU72.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join, relative, sep } from "node:path";
|
|
4
4
|
|
|
@@ -12,6 +12,14 @@ function classifyVersionDrift(oldVer, newVer) {
|
|
|
12
12
|
if ((newParts[2] ?? 0) > (oldParts[2] ?? 0)) return "patch";
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
+
function readLocalVersion(packageDir) {
|
|
16
|
+
try {
|
|
17
|
+
const pkgJson = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
|
|
18
|
+
return typeof pkgJson.version === "string" ? pkgJson.version : null;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
async function fetchNpmVersion(packageName) {
|
|
16
24
|
try {
|
|
17
25
|
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`);
|
|
@@ -22,6 +30,9 @@ async function fetchNpmVersion(packageName) {
|
|
|
22
30
|
return null;
|
|
23
31
|
}
|
|
24
32
|
}
|
|
33
|
+
async function fetchCurrentVersion(packageDir, packageName) {
|
|
34
|
+
return readLocalVersion(packageDir) ?? await fetchNpmVersion(packageName);
|
|
35
|
+
}
|
|
25
36
|
function isStringRecord(value) {
|
|
26
37
|
return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
27
38
|
}
|
|
@@ -65,7 +76,7 @@ async function checkStaleness(packageDir, packageName) {
|
|
|
65
76
|
};
|
|
66
77
|
});
|
|
67
78
|
const skillVersion = skillMetas.find((s) => s.libraryVersion)?.libraryVersion ?? null;
|
|
68
|
-
const currentVersion = await
|
|
79
|
+
const currentVersion = await fetchCurrentVersion(packageDir, library);
|
|
69
80
|
const versionDrift = skillVersion && currentVersion ? classifyVersionDrift(skillVersion, currentVersion) : null;
|
|
70
81
|
const syncState = readSyncState(packageDir);
|
|
71
82
|
return {
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
3
|
+
import { dirname, join, sep } from "node:path";
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
import { parse } from "yaml";
|
|
6
6
|
|
|
7
7
|
//#region src/utils.ts
|
|
8
8
|
/**
|
|
9
|
+
* Convert a path to use forward slashes (for cross-platform consistency).
|
|
10
|
+
*/
|
|
11
|
+
function toPosixPath(p) {
|
|
12
|
+
return p.split(sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
9
15
|
* Recursively find all SKILL.md files under a directory.
|
|
10
16
|
*/
|
|
11
17
|
function findSkillFiles(dir) {
|
|
@@ -149,4 +155,4 @@ function parseFrontmatter(filePath) {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
//#endregion
|
|
152
|
-
export { parseFrontmatter as a, listNodeModulesPackageDirs as i, findSkillFiles as n, resolveDepDir as o, getDeps as r, detectGlobalNodeModules as t };
|
|
158
|
+
export { parseFrontmatter as a, listNodeModulesPackageDirs as i, findSkillFiles as n, resolveDepDir as o, getDeps as r, toPosixPath as s, detectGlobalNodeModules as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as parseFrontmatter, i as listNodeModulesPackageDirs, n as findSkillFiles, o as resolveDepDir, r as getDeps, s as toPosixPath, t as detectGlobalNodeModules } from "./utils-COlDcU72.mjs";
|
|
2
|
+
|
|
3
|
+
export { detectGlobalNodeModules, findSkillFiles, getDeps, listNodeModulesPackageDirs, parseFrontmatter, resolveDepDir, toPosixPath };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { n as findSkillFiles } from "./utils-COlDcU72.mjs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { parse } from "yaml";
|
|
5
|
+
|
|
6
|
+
//#region src/workspace-patterns.ts
|
|
7
|
+
function normalizeWorkspacePattern(pattern) {
|
|
8
|
+
return pattern.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
9
|
+
}
|
|
10
|
+
function normalizeWorkspacePatterns(patterns) {
|
|
11
|
+
return [...new Set(patterns.map(normalizeWorkspacePattern).filter(Boolean))].sort((a, b) => a.localeCompare(b));
|
|
12
|
+
}
|
|
13
|
+
function parseWorkspacePatterns(value) {
|
|
14
|
+
if (!Array.isArray(value)) return null;
|
|
15
|
+
return normalizeWorkspacePatterns(value.filter((pattern) => typeof pattern === "string"));
|
|
16
|
+
}
|
|
17
|
+
function hasPackageJson(dir) {
|
|
18
|
+
return existsSync(join(dir, "package.json"));
|
|
19
|
+
}
|
|
20
|
+
function stripJsonCommentsAndTrailingCommas(source) {
|
|
21
|
+
let result = "";
|
|
22
|
+
let inString = false;
|
|
23
|
+
let escaped = false;
|
|
24
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
25
|
+
const char = source[index];
|
|
26
|
+
const next = source[index + 1];
|
|
27
|
+
if (inString) {
|
|
28
|
+
result += char;
|
|
29
|
+
if (escaped) escaped = false;
|
|
30
|
+
else if (char === "\\") escaped = true;
|
|
31
|
+
else if (char === "\"") inString = false;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (char === "\"") {
|
|
35
|
+
inString = true;
|
|
36
|
+
result += char;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (char === "/" && next === "/") {
|
|
40
|
+
while (index < source.length && source[index] !== "\n") index += 1;
|
|
41
|
+
if (index < source.length) result += source[index];
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (char === "/" && next === "*") {
|
|
45
|
+
const commentStart = index;
|
|
46
|
+
index += 2;
|
|
47
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
|
|
48
|
+
if (index >= source.length) throw new SyntaxError(`Unterminated block comment starting at position ${commentStart}`);
|
|
49
|
+
index += 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (char === ",") {
|
|
53
|
+
let lookahead = index + 1;
|
|
54
|
+
while (lookahead < source.length) {
|
|
55
|
+
const la = source[lookahead];
|
|
56
|
+
if (/\s/.test(la)) lookahead += 1;
|
|
57
|
+
else if (la === "/" && source[lookahead + 1] === "/") {
|
|
58
|
+
lookahead += 2;
|
|
59
|
+
while (lookahead < source.length && source[lookahead] !== "\n") lookahead += 1;
|
|
60
|
+
} else if (la === "/" && source[lookahead + 1] === "*") {
|
|
61
|
+
lookahead += 2;
|
|
62
|
+
while (lookahead < source.length && !(source[lookahead] === "*" && source[lookahead + 1] === "/")) lookahead += 1;
|
|
63
|
+
lookahead += 2;
|
|
64
|
+
} else break;
|
|
65
|
+
}
|
|
66
|
+
if (source[lookahead] === "}" || source[lookahead] === "]") continue;
|
|
67
|
+
}
|
|
68
|
+
result += char;
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function readJsonFile(path, jsonc = false) {
|
|
73
|
+
const source = readFileSync(path, "utf8");
|
|
74
|
+
return JSON.parse(jsonc ? stripJsonCommentsAndTrailingCommas(source) : source);
|
|
75
|
+
}
|
|
76
|
+
function readWorkspacePatterns(root) {
|
|
77
|
+
const pnpmWs = join(root, "pnpm-workspace.yaml");
|
|
78
|
+
if (existsSync(pnpmWs)) try {
|
|
79
|
+
const patterns = parseWorkspacePatterns(parse(readFileSync(pnpmWs, "utf8")).packages);
|
|
80
|
+
if (patterns) return patterns;
|
|
81
|
+
} catch (err) {
|
|
82
|
+
const verb = err instanceof SyntaxError ? "parse" : "read";
|
|
83
|
+
console.error(`Warning: failed to ${verb} ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
|
|
84
|
+
}
|
|
85
|
+
const pkgPath = join(root, "package.json");
|
|
86
|
+
if (existsSync(pkgPath)) try {
|
|
87
|
+
const workspaces = readJsonFile(pkgPath).workspaces;
|
|
88
|
+
const patterns = parseWorkspacePatterns(workspaces) ?? parseWorkspacePatterns(workspaces?.packages);
|
|
89
|
+
if (patterns) return patterns;
|
|
90
|
+
} catch (err) {
|
|
91
|
+
const verb = err instanceof SyntaxError ? "parse" : "read";
|
|
92
|
+
console.error(`Warning: failed to ${verb} ${pkgPath}: ${err instanceof Error ? err.message : err}`);
|
|
93
|
+
}
|
|
94
|
+
for (const denoConfigName of ["deno.json", "deno.jsonc"]) {
|
|
95
|
+
const denoConfigPath = join(root, denoConfigName);
|
|
96
|
+
if (!existsSync(denoConfigPath)) continue;
|
|
97
|
+
try {
|
|
98
|
+
const patterns = parseWorkspacePatterns(readJsonFile(denoConfigPath, true).workspace);
|
|
99
|
+
if (patterns) return patterns;
|
|
100
|
+
} catch (err) {
|
|
101
|
+
const verb = err instanceof SyntaxError ? "parse" : "read";
|
|
102
|
+
console.error(`Warning: failed to ${verb} ${denoConfigPath}: ${err instanceof Error ? err.message : err}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function resolveWorkspacePackages(root, patterns) {
|
|
108
|
+
const includedDirs = /* @__PURE__ */ new Set();
|
|
109
|
+
const excludedDirs = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const pattern of normalizeWorkspacePatterns(patterns)) {
|
|
111
|
+
if (pattern.startsWith("!")) {
|
|
112
|
+
resolveWorkspacePatternSegments(root, pattern.slice(1).split("/"), excludedDirs);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
resolveWorkspacePatternSegments(root, pattern.split("/"), includedDirs);
|
|
116
|
+
}
|
|
117
|
+
return [...includedDirs].filter((dir) => !excludedDirs.has(dir)).sort((a, b) => a.localeCompare(b));
|
|
118
|
+
}
|
|
119
|
+
/** Recursively matches path segments: `*` matches one level, `**` matches zero or more levels. */
|
|
120
|
+
function resolveWorkspacePatternSegments(dir, segments, result) {
|
|
121
|
+
if (segments.length === 0) {
|
|
122
|
+
if (hasPackageJson(dir)) result.add(dir);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const segment = segments[0];
|
|
126
|
+
const remainingSegments = segments.slice(1);
|
|
127
|
+
if (segment === "**") {
|
|
128
|
+
resolveWorkspacePatternSegments(dir, remainingSegments, result);
|
|
129
|
+
for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, segments, result);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (segment === "*") {
|
|
133
|
+
for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, remainingSegments, result);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const nextDir = join(dir, segment);
|
|
137
|
+
if (!existsSync(nextDir)) return;
|
|
138
|
+
resolveWorkspacePatternSegments(nextDir, remainingSegments, result);
|
|
139
|
+
}
|
|
140
|
+
function readChildDirectories(dir) {
|
|
141
|
+
try {
|
|
142
|
+
return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")).map((entry) => join(dir, entry.name));
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function findWorkspaceRoot(start) {
|
|
149
|
+
let dir = start;
|
|
150
|
+
while (true) {
|
|
151
|
+
if (readWorkspacePatterns(dir)) return dir;
|
|
152
|
+
const next = dirname(dir);
|
|
153
|
+
if (next === dir) return null;
|
|
154
|
+
dir = next;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function findPackagesWithSkills(root) {
|
|
158
|
+
const patterns = readWorkspacePatterns(root);
|
|
159
|
+
if (!patterns) return [];
|
|
160
|
+
return resolveWorkspacePackages(root, patterns).filter((dir) => {
|
|
161
|
+
const skillsDir = join(dir, "skills");
|
|
162
|
+
return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { resolveWorkspacePackages as i, findWorkspaceRoot as n, readWorkspacePatterns as r, findPackagesWithSkills as t };
|
package/package.json
CHANGED
package/dist/utils-D7OKi0Rn.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as parseFrontmatter, i as listNodeModulesPackageDirs, n as findSkillFiles, o as resolveDepDir, r as getDeps, t as detectGlobalNodeModules } from "./utils-BfjM1mQe.mjs";
|
|
2
|
-
|
|
3
|
-
export { detectGlobalNodeModules, findSkillFiles, getDeps, listNodeModulesPackageDirs, parseFrontmatter, resolveDepDir };
|
|
File without changes
|
|
File without changes
|