@tanstack/intent 0.0.23 → 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.mjs CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { n as runInstallCommand } from "./install-BHbA_wkb.mjs";
2
+ import "./utils-COlDcU72.mjs";
3
+ import "./workspace-patterns-BuJMfudb.mjs";
4
+ import { t as resolveProjectContext } from "./project-context-B7UXTA9F.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-CsDGCRDm.mjs");
35
+ const { scanForIntents } = await import("./scanner-CERQgrRN.mjs");
33
36
  try {
34
37
  return scanForIntents();
35
38
  } catch (err) {
@@ -46,9 +49,9 @@ function readPackageName(root) {
46
49
  }
47
50
  async function resolveStaleTargets(targetDir) {
48
51
  const resolvedRoot = targetDir ? join(process.cwd(), targetDir) : process.cwd();
49
- const { checkStaleness } = await import("./staleness-Dr5-5wj5.mjs");
52
+ const { checkStaleness } = await import("./staleness-SRims-ZP.mjs");
50
53
  if (existsSync(join(resolvedRoot, "skills"))) return { reports: [await checkStaleness(resolvedRoot, readPackageName(resolvedRoot))] };
51
- const { findPackagesWithSkills, findWorkspaceRoot } = await import("./setup.mjs");
54
+ const { findPackagesWithSkills, findWorkspaceRoot } = await import("./workspace-patterns-Boa5mAbf.mjs");
52
55
  const workspaceRoot = findWorkspaceRoot(resolvedRoot);
53
56
  if (workspaceRoot) {
54
57
  const packageDirs = findPackagesWithSkills(workspaceRoot);
@@ -87,7 +90,7 @@ function printVersionConflicts(result) {
87
90
  }
88
91
  }
89
92
  async function runListCommand(options, scanIntentsOrFail$1) {
90
- const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-CuCDLPP_.mjs");
93
+ const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-DdmZXLZm.mjs");
91
94
  const result = await scanIntentsOrFail$1();
92
95
  if (options.json) {
93
96
  console.log(JSON.stringify(result, null, 2));
@@ -151,7 +154,7 @@ async function runMetaCommand(name, metaDir) {
151
154
  }
152
155
  return;
153
156
  }
154
- const { parseFrontmatter } = await import("./utils-D7OKi0Rn.mjs");
157
+ const { parseFrontmatter } = await import("./utils-dkVvY7D7.mjs");
155
158
  const entries = readdirSync(metaDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => existsSync(join(metaDir, entry.name, "SKILL.md")));
156
159
  if (entries.length === 0) {
157
160
  console.log("No meta-skills found.");
@@ -286,24 +289,9 @@ function buildValidationFailure(errors, warnings) {
286
289
  }
287
290
  return lines.join("\n");
288
291
  }
289
- function isInsideMonorepo(root) {
290
- let dir = join(root, "..");
291
- for (let i = 0; i < 5; i++) {
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");
292
+ function collectPackagingWarnings(context) {
293
+ if (!context.packageRoot || !context.targetPackageJsonPath) return [];
294
+ const pkgJsonPath = context.targetPackageJsonPath;
307
295
  if (!existsSync(pkgJsonPath)) return [];
308
296
  let pkgJson;
309
297
  try {
@@ -318,24 +306,18 @@ function collectPackagingWarnings(root) {
318
306
  const files = pkgJson.files;
319
307
  if (Array.isArray(files)) {
320
308
  if (!files.includes("skills")) warnings.push("\"skills\" is not in the \"files\" array — skills won't be published");
321
- if (!isInsideMonorepo(root) && !files.includes("!skills/_artifacts")) warnings.push("\"!skills/_artifacts\" is not in the \"files\" array — artifacts will be published unnecessarily");
309
+ if (!context.isMonorepo && !files.includes("!skills/_artifacts")) warnings.push("\"!skills/_artifacts\" is not in the \"files\" array — artifacts will be published unnecessarily");
322
310
  }
323
311
  return warnings;
324
312
  }
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
313
  async function runValidateCommand(dir) {
335
- const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-D7OKi0Rn.mjs")]);
314
+ const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-dkVvY7D7.mjs")]);
336
315
  const targetDir = dir ?? "skills";
337
- const skillsDir = join(process.cwd(), targetDir);
338
- const packageRoot = resolvePackageRoot(skillsDir);
316
+ const context = resolveProjectContext({
317
+ cwd: process.cwd(),
318
+ targetPath: targetDir
319
+ });
320
+ const skillsDir = context.targetSkillsDir ?? resolve(process.cwd(), targetDir);
339
321
  if (!existsSync(skillsDir)) fail(`Skills directory not found: ${skillsDir}`);
340
322
  const errors = [];
341
323
  const skillFiles = findSkillFiles(skillsDir);
@@ -399,7 +381,7 @@ async function runValidateCommand(dir) {
399
381
  });
400
382
  }
401
383
  const artifactsDir = join(skillsDir, "_artifacts");
402
- if (existsSync(artifactsDir)) for (const fileName of [
384
+ if (!context.isMonorepo && existsSync(artifactsDir)) for (const fileName of [
403
385
  "domain_map.yaml",
404
386
  "skill_spec.md",
405
387
  "skill_tree.yaml"
@@ -430,7 +412,7 @@ async function runValidateCommand(dir) {
430
412
  });
431
413
  }
432
414
  }
433
- const warnings = collectPackagingWarnings(packageRoot);
415
+ const warnings = collectPackagingWarnings(context);
434
416
  if (errors.length > 0) fail(buildValidationFailure(errors, warnings));
435
417
  console.log(`✅ Validated ${skillFiles.length} skill files — all passed`);
436
418
  if (warnings.length > 0) console.log();
@@ -0,0 +1,3 @@
1
+ import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-hdsqb4w-.mjs";
2
+
3
+ export { computeSkillNameWidth, printSkillTree, printTable };
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-ddLtccfV.mjs";
2
- import { c as runEditPackageJson, r as SetupGithubActionsResult, t as EditPackageJsonResult, u as runSetupGithubActions } from "./setup-BNBVotfR.mjs";
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-BfjM1mQe.mjs";
2
- import { a as runEditPackageJson, s as runSetupGithubActions } from "./setup-Nyfl1KTS.mjs";
3
- import { t as scanForIntents } from "./scanner-BCgNt-oI.mjs";
4
- import { t as checkStaleness } from "./staleness-DZKvsLVq.mjs";
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";
@@ -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`;
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import "./utils-BfjM1mQe.mjs";
3
- import { t as INSTALL_PROMPT } from "./install-BHbA_wkb.mjs";
4
- import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-DhsUxNJW.mjs";
5
- import { t as scanLibrary } from "./library-scanner-DlWy8VeZ.mjs";
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-BfjM1mQe.mjs";
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, sep } from "node:path";
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).split(sep).join("/");
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: existsSync(skillsDir) ? discoverSkills(skillsDir) : []
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-ddLtccfV.mjs";
1
+ import { l as SkillEntry } from "./types-BTQ9efv-.mjs";
2
2
 
3
3
  //#region src/library-scanner.d.ts
4
4
  interface LibraryPackage {
@@ -1,4 +1,4 @@
1
- import "./utils-BfjM1mQe.mjs";
2
- import { t as scanLibrary } from "./library-scanner-DlWy8VeZ.mjs";
1
+ import "./utils-COlDcU72.mjs";
2
+ import { t as scanLibrary } from "./library-scanner-B51qV5aX.mjs";
3
3
 
4
4
  export { scanLibrary };
@@ -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-BfjM1mQe.mjs";
2
- import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns } from "./setup-Nyfl1KTS.mjs";
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).split(sep).join("/");
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: discoverSkills(skillsDir, name),
264
+ skills,
259
265
  packageRoot: dirPath
260
266
  };
261
267
  const existingIndex = packageIndexes.get(name);
@@ -0,0 +1,5 @@
1
+ import "./utils-COlDcU72.mjs";
2
+ import "./workspace-patterns-BuJMfudb.mjs";
3
+ import { t as scanForIntents } from "./scanner-1ZGYK3Qm.mjs";
4
+
5
+ export { scanForIntents };
@@ -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 { findWorkspaceRoot as a, runEditPackageJson as c, findPackagesWithSkills as i, runEditPackageJsonAll as l, MonorepoResult as n, readWorkspacePatterns as o, SetupGithubActionsResult as r, resolveWorkspacePackages as s, EditPackageJsonResult as t, runSetupGithubActions as u };
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,7 +1,7 @@
1
- import { n as findSkillFiles } from "./utils-BfjM1mQe.mjs";
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
7
  function isGenericWorkspaceName(name, root) {
@@ -107,9 +107,11 @@ function runEditPackageJson(root) {
107
107
  added: [],
108
108
  alreadyPresent: []
109
109
  };
110
- const pkgPath = join(root, "package.json");
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 " + root);
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 { runEditPackageJson as a, resolveWorkspacePackages as i, findWorkspaceRoot as n, runEditPackageJsonAll as o, readWorkspacePatterns as r, runSetupGithubActions as s, findPackagesWithSkills as t };
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 findWorkspaceRoot, c as runEditPackageJson, i as findPackagesWithSkills, l as runEditPackageJsonAll, n as MonorepoResult, o as readWorkspacePatterns, r as SetupGithubActionsResult, s as resolveWorkspacePackages, t as EditPackageJsonResult, u as runSetupGithubActions } from "./setup-BNBVotfR.mjs";
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-BfjM1mQe.mjs";
2
- import { a as runEditPackageJson, i as resolveWorkspacePackages, n as findWorkspaceRoot, o as runEditPackageJsonAll, r as readWorkspacePatterns, s as runSetupGithubActions, t as findPackagesWithSkills } from "./setup-Nyfl1KTS.mjs";
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,4 +1,4 @@
1
- import { a as parseFrontmatter, n as findSkillFiles } from "./utils-BfjM1mQe.mjs";
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
 
@@ -0,0 +1,4 @@
1
+ import "./utils-COlDcU72.mjs";
2
+ import { t as checkStaleness } from "./staleness-BtmJtMpz.mjs";
3
+
4
+ export { checkStaleness };
@@ -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,4 @@
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
+
4
+ export { findPackagesWithSkills, findWorkspaceRoot };
@@ -0,0 +1,98 @@
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 readWorkspacePatterns(root) {
21
+ const pnpmWs = join(root, "pnpm-workspace.yaml");
22
+ if (existsSync(pnpmWs)) try {
23
+ const patterns = parseWorkspacePatterns(parse(readFileSync(pnpmWs, "utf8")).packages);
24
+ if (patterns) return patterns;
25
+ } catch (err) {
26
+ console.error(`Warning: failed to parse ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
27
+ }
28
+ const pkgPath = join(root, "package.json");
29
+ if (existsSync(pkgPath)) try {
30
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
31
+ const patterns = parseWorkspacePatterns(pkg.workspaces) ?? parseWorkspacePatterns(pkg.workspaces?.packages);
32
+ if (patterns) return patterns;
33
+ } catch (err) {
34
+ console.error(`Warning: failed to parse ${pkgPath}: ${err instanceof Error ? err.message : err}`);
35
+ }
36
+ return null;
37
+ }
38
+ function resolveWorkspacePackages(root, patterns) {
39
+ const includedDirs = /* @__PURE__ */ new Set();
40
+ const excludedDirs = /* @__PURE__ */ new Set();
41
+ for (const pattern of normalizeWorkspacePatterns(patterns)) {
42
+ if (pattern.startsWith("!")) {
43
+ resolveWorkspacePatternSegments(root, pattern.slice(1).split("/"), excludedDirs);
44
+ continue;
45
+ }
46
+ resolveWorkspacePatternSegments(root, pattern.split("/"), includedDirs);
47
+ }
48
+ return [...includedDirs].filter((dir) => !excludedDirs.has(dir)).sort((a, b) => a.localeCompare(b));
49
+ }
50
+ /** Recursively matches path segments: `*` matches one level, `**` matches zero or more levels. */
51
+ function resolveWorkspacePatternSegments(dir, segments, result) {
52
+ if (segments.length === 0) {
53
+ if (hasPackageJson(dir)) result.add(dir);
54
+ return;
55
+ }
56
+ const segment = segments[0];
57
+ const remainingSegments = segments.slice(1);
58
+ if (segment === "**") {
59
+ resolveWorkspacePatternSegments(dir, remainingSegments, result);
60
+ for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, segments, result);
61
+ return;
62
+ }
63
+ if (segment === "*") {
64
+ for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, remainingSegments, result);
65
+ return;
66
+ }
67
+ const nextDir = join(dir, segment);
68
+ if (!existsSync(nextDir)) return;
69
+ resolveWorkspacePatternSegments(nextDir, remainingSegments, result);
70
+ }
71
+ function readChildDirectories(dir) {
72
+ try {
73
+ return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")).map((entry) => join(dir, entry.name));
74
+ } catch (err) {
75
+ console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
76
+ return [];
77
+ }
78
+ }
79
+ function findWorkspaceRoot(start) {
80
+ let dir = start;
81
+ while (true) {
82
+ if (readWorkspacePatterns(dir)) return dir;
83
+ const next = dirname(dir);
84
+ if (next === dir) return null;
85
+ dir = next;
86
+ }
87
+ }
88
+ function findPackagesWithSkills(root) {
89
+ const patterns = readWorkspacePatterns(root);
90
+ if (!patterns) return [];
91
+ return resolveWorkspacePackages(root, patterns).filter((dir) => {
92
+ const skillsDir = join(dir, "skills");
93
+ return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
94
+ });
95
+ }
96
+
97
+ //#endregion
98
+ export { resolveWorkspacePackages as i, findWorkspaceRoot as n, readWorkspacePatterns as r, findPackagesWithSkills as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/intent",
3
- "version": "0.0.23",
3
+ "version": "0.0.27",
4
4
  "description": "Ship compositional knowledge for AI coding agents alongside your npm packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +0,0 @@
1
- import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-DhsUxNJW.mjs";
2
-
3
- export { computeSkillNameWidth, printSkillTree, printTable };
@@ -1,5 +0,0 @@
1
- import "./utils-BfjM1mQe.mjs";
2
- import "./setup-Nyfl1KTS.mjs";
3
- import { t as scanForIntents } from "./scanner-BCgNt-oI.mjs";
4
-
5
- export { scanForIntents };
@@ -1,4 +0,0 @@
1
- import "./utils-BfjM1mQe.mjs";
2
- import { t as checkStaleness } from "./staleness-DZKvsLVq.mjs";
3
-
4
- export { checkStaleness };
@@ -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 };