@tanstack/intent 0.0.21 → 0.0.27
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.d.mts +1 -2
- package/dist/cli.mjs +271 -300
- package/dist/display-DdmZXLZm.mjs +3 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +6 -4
- package/dist/{install-prompt-C0M-U3WZ.mjs → install-BzDmD5yI.mjs} +12 -2
- package/dist/intent-library.mjs +7 -7
- package/dist/{library-scanner-CU3ZHPYU.mjs → library-scanner-B51qV5aX.mjs} +7 -5
- package/dist/library-scanner.d.mts +2 -2
- package/dist/library-scanner.mjs +2 -2
- package/dist/project-context-B7UXTA9F.mjs +53 -0
- package/dist/{scanner-SHzOJKcz.mjs → scanner-1ZGYK3Qm.mjs} +11 -5
- package/dist/scanner-CERQgrRN.mjs +5 -0
- package/dist/{setup-BNBVotfR.d.mts → setup-BA9RkENh.d.mts} +7 -13
- package/dist/{setup-J7F7DIP2.mjs → setup-BzhEoOBi.mjs} +34 -113
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +4 -2
- package/dist/{staleness-DZKvsLVq.mjs → staleness-BtmJtMpz.mjs} +1 -1
- package/dist/staleness-SRims-ZP.mjs +4 -0
- package/dist/{utils-BfjM1mQe.mjs → utils-COlDcU72.mjs} +8 -2
- package/dist/utils-dkVvY7D7.mjs +3 -0
- package/dist/workspace-patterns-Boa5mAbf.mjs +4 -0
- package/dist/workspace-patterns-BuJMfudb.mjs +98 -0
- package/package.json +3 -1
- package/dist/display-CuCDLPP_.mjs +0 -3
- package/dist/scanner-RWHFrJ_C.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/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
declare function scanForIntents(root?: string):
|
|
5
|
+
declare function scanForIntents(root?: string): ScanResult;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/staleness.d.ts
|
|
8
8
|
declare function checkStaleness(packageDir: string, packageName?: string): Promise<StalenessReport>;
|
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-BuJMfudb.mjs";
|
|
3
|
+
import { t as scanForIntents } from "./scanner-1ZGYK3Qm.mjs";
|
|
4
|
+
import { t as checkStaleness } from "./staleness-BtmJtMpz.mjs";
|
|
5
|
+
import "./project-context-B7UXTA9F.mjs";
|
|
6
|
+
import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BzhEoOBi.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/install
|
|
1
|
+
//#region src/commands/install.ts
|
|
2
2
|
const INSTALL_PROMPT = `You are an AI assistant helping a developer set up skill-to-task mappings for their project.
|
|
3
3
|
|
|
4
4
|
Follow these steps in order:
|
|
@@ -51,9 +51,19 @@ 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`;
|
|
64
|
+
function runInstallCommand() {
|
|
65
|
+
console.log(INSTALL_PROMPT);
|
|
66
|
+
}
|
|
57
67
|
|
|
58
68
|
//#endregion
|
|
59
|
-
export { INSTALL_PROMPT as t };
|
|
69
|
+
export { runInstallCommand as n, INSTALL_PROMPT as t };
|
package/dist/intent-library.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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() {
|
|
9
9
|
let result;
|
|
10
10
|
try {
|
|
11
|
-
result =
|
|
11
|
+
result = scanLibrary(process.argv[1]);
|
|
12
12
|
} catch (err) {
|
|
13
13
|
console.error(err.message);
|
|
14
14
|
process.exit(1);
|
|
@@ -65,7 +65,7 @@ const command = process.argv[2];
|
|
|
65
65
|
switch (command) {
|
|
66
66
|
case "list":
|
|
67
67
|
case void 0:
|
|
68
|
-
|
|
68
|
+
cmdList();
|
|
69
69
|
break;
|
|
70
70
|
case "install":
|
|
71
71
|
cmdInstall();
|
|
@@ -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,
|
|
@@ -59,7 +59,7 @@ function discoverSkills(skillsDir) {
|
|
|
59
59
|
walk(skillsDir);
|
|
60
60
|
return skills;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
function scanLibrary(scriptPath, _projectRoot) {
|
|
63
63
|
const packages = [];
|
|
64
64
|
const warnings = [];
|
|
65
65
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -83,11 +83,13 @@ async 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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as SkillEntry } from "./types-
|
|
1
|
+
import { l as SkillEntry } from "./types-BTQ9efv-.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/library-scanner.d.ts
|
|
4
4
|
interface LibraryPackage {
|
|
@@ -11,6 +11,6 @@ interface LibraryScanResult {
|
|
|
11
11
|
packages: Array<LibraryPackage>;
|
|
12
12
|
warnings: Array<string>;
|
|
13
13
|
}
|
|
14
|
-
declare function scanLibrary(scriptPath: string, _projectRoot?: string):
|
|
14
|
+
declare function scanLibrary(scriptPath: string, _projectRoot?: string): LibraryScanResult;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LibraryPackage, LibraryScanResult, scanLibrary };
|
package/dist/library-scanner.mjs
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-BuJMfudb.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-BuJMfudb.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,
|
|
@@ -169,7 +169,7 @@ function toVersionConflict(packageName, variants, chosen) {
|
|
|
169
169
|
variants
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
function scanForIntents(root) {
|
|
173
173
|
const projectRoot = root ?? process.cwd();
|
|
174
174
|
const packageManager = detectPackageManager(projectRoot);
|
|
175
175
|
const nodeModulesDir = join(projectRoot, "node_modules");
|
|
@@ -251,11 +251,17 @@ async 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,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 };
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-BuJMfudb.mjs";
|
|
2
|
+
import { t as resolveProjectContext } from "./project-context-B7UXTA9F.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
|
+
function isGenericWorkspaceName(name, root) {
|
|
8
|
+
const normalized = name.trim().toLowerCase();
|
|
9
|
+
return normalized.length === 0 || normalized === "unknown" || normalized === "root" || normalized === "workspace" || normalized === "monorepo" || normalized === basename(root).toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function deriveWorkspacePackageName(root, repo, packageDirs) {
|
|
12
|
+
const repoName = repo.split("/").filter(Boolean).pop() || basename(root);
|
|
13
|
+
for (const packageDir of packageDirs) {
|
|
14
|
+
const pkgJson = readPackageJson(packageDir);
|
|
15
|
+
const pkgName = typeof pkgJson.name === "string" ? pkgJson.name : null;
|
|
16
|
+
if (pkgName?.startsWith("@")) return `${pkgName.split("/")[0]}/${repoName}`;
|
|
17
|
+
}
|
|
18
|
+
return repoName;
|
|
19
|
+
}
|
|
7
20
|
function readPackageJson(root) {
|
|
8
21
|
const pkgPath = join(root, "package.json");
|
|
9
22
|
try {
|
|
@@ -41,19 +54,22 @@ function buildWatchPaths(root, packageDirs) {
|
|
|
41
54
|
}
|
|
42
55
|
function detectVars(root, packageDirs) {
|
|
43
56
|
const pkgJson = readPackageJson(root);
|
|
44
|
-
const
|
|
57
|
+
const rawName = typeof pkgJson.name === "string" ? pkgJson.name : "unknown";
|
|
45
58
|
const docs = typeof pkgJson.intent?.docs === "string" ? pkgJson.intent.docs : "docs/";
|
|
46
|
-
const repo = detectRepo(pkgJson, name.replace(/^@/, "").replace(/\//, "/"));
|
|
47
59
|
const isMonorepo = packageDirs !== void 0;
|
|
48
|
-
const
|
|
49
|
-
let
|
|
50
|
-
if (
|
|
60
|
+
const repo = detectRepo(pkgJson, detectRepo((packageDirs?.[0] ? readPackageJson(packageDirs[0]) : null) ?? {}, basename(root)));
|
|
61
|
+
let packageName = rawName;
|
|
62
|
+
if (isMonorepo && isGenericWorkspaceName(rawName, root)) packageName = deriveWorkspacePackageName(root, repo, packageDirs);
|
|
63
|
+
const shortName = packageName.replace(/^@[^/]+\//, "");
|
|
64
|
+
let srcPath = isMonorepo ? "packages/*/src/**" : `packages/${shortName}/src/**`;
|
|
65
|
+
if (!isMonorepo && existsSync(join(root, "src"))) srcPath = "src/**";
|
|
66
|
+
const docsPath = isMonorepo ? "packages/*/docs/**" : docs;
|
|
51
67
|
return {
|
|
52
|
-
PACKAGE_NAME:
|
|
53
|
-
PACKAGE_LABEL:
|
|
54
|
-
PAYLOAD_PACKAGE:
|
|
68
|
+
PACKAGE_NAME: packageName,
|
|
69
|
+
PACKAGE_LABEL: packageName,
|
|
70
|
+
PAYLOAD_PACKAGE: packageName,
|
|
55
71
|
REPO: repo,
|
|
56
|
-
DOCS_PATH:
|
|
72
|
+
DOCS_PATH: docsPath.endsWith("**") ? docsPath : docsPath.replace(/\/$/, "") + "/**",
|
|
57
73
|
SRC_PATH: srcPath,
|
|
58
74
|
WATCH_PATHS: isMonorepo ? buildWatchPaths(root, packageDirs) : ` - '${docs.endsWith("**") ? docs : docs.replace(/\/$/, "") + "/**"}'\n - '${srcPath}'`
|
|
59
75
|
};
|
|
@@ -91,9 +107,11 @@ function runEditPackageJson(root) {
|
|
|
91
107
|
added: [],
|
|
92
108
|
alreadyPresent: []
|
|
93
109
|
};
|
|
94
|
-
const
|
|
110
|
+
const context = resolveProjectContext({ cwd: root });
|
|
111
|
+
const packageRoot = context.packageRoot ?? root;
|
|
112
|
+
const pkgPath = join(packageRoot, "package.json");
|
|
95
113
|
if (!existsSync(pkgPath)) {
|
|
96
|
-
console.error("No package.json found in " +
|
|
114
|
+
console.error("No package.json found in " + packageRoot);
|
|
97
115
|
process.exitCode = 1;
|
|
98
116
|
return result;
|
|
99
117
|
}
|
|
@@ -104,6 +122,7 @@ function runEditPackageJson(root) {
|
|
|
104
122
|
} catch (err) {
|
|
105
123
|
const detail = err instanceof SyntaxError ? err.message : String(err);
|
|
106
124
|
console.error(`Failed to parse ${pkgPath}: ${detail}`);
|
|
125
|
+
process.exitCode = 1;
|
|
107
126
|
return result;
|
|
108
127
|
}
|
|
109
128
|
const indentMatch = raw.match(/^(\s+)"/m);
|
|
@@ -117,23 +136,7 @@ function runEditPackageJson(root) {
|
|
|
117
136
|
}
|
|
118
137
|
if (!Array.isArray(pkg.files)) pkg.files = [];
|
|
119
138
|
const files = pkg.files;
|
|
120
|
-
const requiredFiles =
|
|
121
|
-
let dir = join(root, "..");
|
|
122
|
-
for (let i = 0; i < 5; i++) {
|
|
123
|
-
const parentPkg = join(dir, "package.json");
|
|
124
|
-
if (existsSync(parentPkg)) {
|
|
125
|
-
try {
|
|
126
|
-
const parent = JSON.parse(readFileSync(parentPkg, "utf8"));
|
|
127
|
-
if (Array.isArray(parent.workspaces) || parent.workspaces?.packages) return true;
|
|
128
|
-
} catch {}
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
const next = join(dir, "..");
|
|
132
|
-
if (next === dir) break;
|
|
133
|
-
dir = next;
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
136
|
-
})() ? ["skills"] : ["skills", "!skills/_artifacts"];
|
|
139
|
+
const requiredFiles = context.isMonorepo ? ["skills"] : ["skills", "!skills/_artifacts"];
|
|
137
140
|
for (const entry of requiredFiles) if (files.includes(entry)) result.alreadyPresent.push(`files: "${entry}"`);
|
|
138
141
|
else {
|
|
139
142
|
files.push(entry);
|
|
@@ -144,88 +147,6 @@ function runEditPackageJson(root) {
|
|
|
144
147
|
for (const a of result.alreadyPresent) console.log(` Already present: ${a}`);
|
|
145
148
|
return result;
|
|
146
149
|
}
|
|
147
|
-
function readWorkspacePatterns(root) {
|
|
148
|
-
const pnpmWs = join(root, "pnpm-workspace.yaml");
|
|
149
|
-
if (existsSync(pnpmWs)) try {
|
|
150
|
-
const config = parse(readFileSync(pnpmWs, "utf8"));
|
|
151
|
-
if (Array.isArray(config.packages)) return config.packages;
|
|
152
|
-
} catch (err) {
|
|
153
|
-
console.error(`Warning: failed to parse ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
|
|
154
|
-
}
|
|
155
|
-
const pkgPath = join(root, "package.json");
|
|
156
|
-
if (existsSync(pkgPath)) try {
|
|
157
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
158
|
-
if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
|
|
159
|
-
if (Array.isArray(pkg.workspaces?.packages)) return pkg.workspaces.packages;
|
|
160
|
-
} catch (err) {
|
|
161
|
-
console.error(`Warning: failed to parse ${pkgPath}: ${err instanceof Error ? err.message : err}`);
|
|
162
|
-
}
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Resolve workspace glob patterns to actual package directories.
|
|
167
|
-
* Handles simple patterns like "packages/*" and "packages/**".
|
|
168
|
-
* Each resolved directory must contain a package.json.
|
|
169
|
-
*/
|
|
170
|
-
function resolveWorkspacePackages(root, patterns) {
|
|
171
|
-
const dirs = [];
|
|
172
|
-
for (const pattern of patterns) {
|
|
173
|
-
const baseDir = join(root, pattern.replace(/\/\*\*?(\/\*)?$/, ""));
|
|
174
|
-
if (!existsSync(baseDir)) continue;
|
|
175
|
-
if (pattern.includes("**")) collectPackageDirs(baseDir, dirs);
|
|
176
|
-
else if (pattern.endsWith("/*")) {
|
|
177
|
-
let entries;
|
|
178
|
-
try {
|
|
179
|
-
entries = readdirSync(baseDir, { withFileTypes: true });
|
|
180
|
-
} catch {
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
for (const entry of entries) {
|
|
184
|
-
if (!entry.isDirectory()) continue;
|
|
185
|
-
const dir = join(baseDir, entry.name);
|
|
186
|
-
if (existsSync(join(dir, "package.json"))) dirs.push(dir);
|
|
187
|
-
}
|
|
188
|
-
} else {
|
|
189
|
-
const dir = join(root, pattern);
|
|
190
|
-
if (existsSync(join(dir, "package.json"))) dirs.push(dir);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return dirs;
|
|
194
|
-
}
|
|
195
|
-
function collectPackageDirs(dir, result) {
|
|
196
|
-
if (existsSync(join(dir, "package.json"))) result.push(dir);
|
|
197
|
-
let entries;
|
|
198
|
-
try {
|
|
199
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
200
|
-
} catch (err) {
|
|
201
|
-
console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
for (const entry of entries) {
|
|
205
|
-
if (!entry.isDirectory() || entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
206
|
-
collectPackageDirs(join(dir, entry.name), result);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function findWorkspaceRoot(start) {
|
|
210
|
-
let dir = start;
|
|
211
|
-
while (true) {
|
|
212
|
-
if (readWorkspacePatterns(dir)) return dir;
|
|
213
|
-
const next = join(dir, "..");
|
|
214
|
-
if (next === dir) return null;
|
|
215
|
-
dir = next;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Find workspace packages that contain at least one SKILL.md file.
|
|
220
|
-
*/
|
|
221
|
-
function findPackagesWithSkills(root) {
|
|
222
|
-
const patterns = readWorkspacePatterns(root);
|
|
223
|
-
if (!patterns) return [];
|
|
224
|
-
return resolveWorkspacePackages(root, patterns).filter((dir) => {
|
|
225
|
-
const skillsDir = join(dir, "skills");
|
|
226
|
-
return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
150
|
/**
|
|
230
151
|
* When run from a monorepo root, finds all workspace packages with SKILL.md
|
|
231
152
|
* files and runs the given command on each. Falls back to single-package
|
|
@@ -276,4 +197,4 @@ function runSetupGithubActions(root, metaDir) {
|
|
|
276
197
|
}
|
|
277
198
|
|
|
278
199
|
//#endregion
|
|
279
|
-
export {
|
|
200
|
+
export { runEditPackageJsonAll as n, runSetupGithubActions as r, runEditPackageJson as t };
|
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-BuJMfudb.mjs";
|
|
3
|
+
import "./project-context-B7UXTA9F.mjs";
|
|
4
|
+
import { n as runEditPackageJsonAll, r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BzhEoOBi.mjs";
|
|
3
5
|
|
|
4
6
|
export { findPackagesWithSkills, findWorkspaceRoot, readWorkspacePatterns, resolveWorkspacePackages, runEditPackageJson, runEditPackageJsonAll, runSetupGithubActions };
|
|
@@ -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 };
|