@tanstack/intent 0.0.42 → 0.0.44

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.
Files changed (29) hide show
  1. package/dist/{cli-support-C-t4xQw0.mjs → cli-support-BNDR3l1g.mjs} +4 -4
  2. package/dist/{cli-support-B26oUGbf.mjs → cli-support-BtHFD7gl.mjs} +4 -4
  3. package/dist/cli.mjs +9 -9
  4. package/dist/{core-CEeo37aT.mjs → core-qlBI_aQL.mjs} +13 -12
  5. package/dist/core.mjs +7 -7
  6. package/dist/{display-BdSvrwWJ.mjs → display-0FnzlKRq.mjs} +2 -2
  7. package/dist/index.d.mts +40 -21
  8. package/dist/index.mjs +8 -8
  9. package/dist/{install-t4jkDdD0.mjs → install-D1dsnbr9.mjs} +4 -4
  10. package/dist/{list-DQxqa1AT.mjs → list-DrChOziX.mjs} +9 -9
  11. package/dist/{load-3ACx3170.mjs → load-ll7s5E3J.mjs} +8 -8
  12. package/dist/{meta-DZgsju5x.mjs → meta-BEJIfnPG.mjs} +1 -1
  13. package/dist/{project-context-4wzbLY9c.mjs → project-context-BRIMzhi4.mjs} +1 -1
  14. package/dist/{resolver-D8sX72Lg.mjs → resolver-D9cjsz11.mjs} +1 -1
  15. package/dist/scanner-BV7X5n_z.mjs +6 -0
  16. package/dist/{scanner-QujEINYm.mjs → scanner-DaG82zNc.mjs} +49 -22
  17. package/dist/{setup-BElEzHxS.mjs → setup-BklJkH_6.mjs} +2 -2
  18. package/dist/setup.mjs +4 -4
  19. package/dist/{skill-paths-Cc0-Y331.mjs → skill-paths-B-j0dWDA.mjs} +1 -1
  20. package/dist/{staleness-BwcLygsY.mjs → staleness-BGFfic-Y.mjs} +1 -1
  21. package/dist/{staleness-Dd1kWwCz.mjs → staleness-CB3qpVCq.mjs} +2 -2
  22. package/dist/{utils-CF7OL__5.mjs → utils-9fhWAVua.mjs} +76 -18
  23. package/dist/utils-CSPzvaFu.mjs +3 -0
  24. package/dist/{validate-D0n-rBpp.mjs → validate-CEhp9gDs.mjs} +5 -5
  25. package/dist/{workspace-patterns-FljtM2Xb.mjs → workspace-patterns-BffPlZ1D.mjs} +1 -1
  26. package/dist/{workspace-patterns-CnGMcicG.mjs → workspace-patterns-Bjq_cXww.mjs} +2 -2
  27. package/package.json +1 -1
  28. package/dist/scanner-BK8rIEA3.mjs +0 -6
  29. package/dist/utils-DTvYXAsM.mjs +0 -3
@@ -1,4 +1,4 @@
1
- import { t as resolveProjectContext } from "./project-context-4wzbLY9c.mjs";
1
+ import { t as resolveProjectContext } from "./project-context-BRIMzhi4.mjs";
2
2
  import { t as fail } from "./cli-error-BrMXlbtx.mjs";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { dirname, join, relative, resolve } from "node:path";
@@ -31,7 +31,7 @@ function getCheckSkillsWorkflowAdvisories(root) {
31
31
  return [`Intent workflow update available: run \`npx @tanstack/intent@latest setup\` to refresh ${relative(process.cwd(), workflowPath) || workflowPath}.`];
32
32
  }
33
33
  async function scanIntentsOrFail(options) {
34
- const { scanForIntents } = await import("./scanner-BK8rIEA3.mjs");
34
+ const { scanForIntents } = await import("./scanner-BV7X5n_z.mjs");
35
35
  try {
36
36
  return scanForIntents(void 0, options);
37
37
  } catch (err) {
@@ -68,13 +68,13 @@ async function resolveStaleTargets(targetDir) {
68
68
  targetPath: targetDir
69
69
  });
70
70
  const workflowAdvisories = getCheckSkillsWorkflowAdvisories(context.workspaceRoot ?? context.packageRoot ?? resolvedRoot);
71
- const { buildWorkspaceCoverageSignals, checkStaleness, readPackageName } = await import("./staleness-Dd1kWwCz.mjs");
71
+ const { buildWorkspaceCoverageSignals, checkStaleness, readPackageName } = await import("./staleness-CB3qpVCq.mjs");
72
72
  const isWorkspaceRootTarget = context.workspaceRoot !== null && resolvedRoot === context.workspaceRoot;
73
73
  if (context.packageRoot && !isWorkspaceRootTarget && (context.targetSkillsDir !== null || context.workspaceRoot === null)) return {
74
74
  reports: [await checkStaleness(context.packageRoot, readPackageName(context.packageRoot), context.workspaceRoot ?? context.packageRoot)],
75
75
  workflowAdvisories
76
76
  };
77
- const { findWorkspaceRoot, getWorkspaceInfo } = await import("./workspace-patterns-CnGMcicG.mjs");
77
+ const { findWorkspaceRoot, getWorkspaceInfo } = await import("./workspace-patterns-Bjq_cXww.mjs");
78
78
  const workspaceRoot = findWorkspaceRoot(resolvedRoot);
79
79
  const workspaceInfo = workspaceRoot ? getWorkspaceInfo(workspaceRoot) : null;
80
80
  if (workspaceInfo) {
@@ -1,6 +1,6 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./workspace-patterns-FljtM2Xb.mjs";
3
- import "./project-context-4wzbLY9c.mjs";
4
- import { a as printDebugInfo, c as scanOptionsFromGlobalFlags, i as getMetaDir, l as printWarnings, n as coreOptionsFromGlobalFlags, o as resolveStaleTargets, r as getCheckSkillsWorkflowAdvisories, s as scanIntentsOrFail, t as INTENT_CHECK_SKILLS_WORKFLOW_VERSION } from "./cli-support-C-t4xQw0.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./workspace-patterns-BffPlZ1D.mjs";
3
+ import "./project-context-BRIMzhi4.mjs";
4
+ import { a as printDebugInfo, c as scanOptionsFromGlobalFlags, i as getMetaDir, l as printWarnings, n as coreOptionsFromGlobalFlags, o as resolveStaleTargets, r as getCheckSkillsWorkflowAdvisories, s as scanIntentsOrFail, t as INTENT_CHECK_SKILLS_WORKFLOW_VERSION } from "./cli-support-BNDR3l1g.mjs";
5
5
 
6
6
  export { INTENT_CHECK_SKILLS_WORKFLOW_VERSION, coreOptionsFromGlobalFlags, getCheckSkillsWorkflowAdvisories, getMetaDir, printDebugInfo, printWarnings, resolveStaleTargets, scanIntentsOrFail, scanOptionsFromGlobalFlags };
package/dist/cli.mjs CHANGED
@@ -9,31 +9,31 @@ function createCli() {
9
9
  const cli = cac("intent");
10
10
  cli.usage("<command> [options]");
11
11
  cli.command("list", "Discover intent-enabled packages from the project or workspace").usage("list [--json] [--debug] [--exclude <pattern>] [--global] [--global-only]").option("--json", "Output JSON").option("--debug", "Print discovery debug details to stderr").option("--exclude <pattern>", "Exclude package name glob").option("--global", "Include global packages after project packages").option("--global-only", "List global packages only").example("list").example("list --json").example("list --global").action(async (options) => {
12
- const { runListCommand } = await import("./list-DQxqa1AT.mjs");
12
+ const { runListCommand } = await import("./list-DrChOziX.mjs");
13
13
  await runListCommand(options);
14
14
  });
15
15
  cli.command("load [use]", "Load a compact skill use and print its SKILL.md").usage("load <use> [--path] [--json] [--debug] [--exclude <pattern>] [--global] [--global-only]").option("--path", "Print the resolved skill path instead of file content").option("--json", "Output JSON").option("--debug", "Print resolution debug details to stderr").option("--exclude <pattern>", "Exclude package name glob").option("--global", "Load from project packages, then global packages").option("--global-only", "Load from global packages only").example("load @tanstack/query#core").example("load @tanstack/query#core --path").action(async (use, options) => {
16
- const { runLoadCommand } = await import("./load-3ACx3170.mjs");
16
+ const { runLoadCommand } = await import("./load-ll7s5E3J.mjs");
17
17
  await runLoadCommand(use, options);
18
18
  });
19
19
  cli.command("meta [name]", "List meta-skills, or print one by name").usage("meta [name]").example("meta").example("meta domain-discovery").action(async (name) => {
20
- const [{ getMetaDir }, { runMetaCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./meta-DZgsju5x.mjs")]);
20
+ const [{ getMetaDir }, { runMetaCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./meta-BEJIfnPG.mjs")]);
21
21
  await runMetaCommand(name, getMetaDir());
22
22
  });
23
23
  cli.command("validate [dir]", "Validate skill files").usage("validate [dir] [--github-summary]").option("--github-summary", "Write a GitHub Actions step summary").example("validate").example("validate packages/query/skills").action(async (dir, options) => {
24
- const { runValidateCommand } = await import("./validate-D0n-rBpp.mjs");
24
+ const { runValidateCommand } = await import("./validate-CEhp9gDs.mjs");
25
25
  await runValidateCommand(dir, options);
26
26
  });
27
27
  cli.command("install", "Create or update skill loading guidance in an agent config file").usage("install [--map] [--dry-run] [--print-prompt] [--global] [--global-only]").option("--map", "Write explicit skill-to-task mappings").option("--dry-run", "Print the generated block without writing").option("--print-prompt", "Print the legacy agent setup prompt instead of writing").option("--global", "Include global packages after project packages").option("--global-only", "Install mappings from global packages only").example("install").example("install --map").example("install --dry-run").example("install --print-prompt").example("install --global").action(async (options) => {
28
- const [{ scanIntentsOrFail }, { runInstallCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./install-t4jkDdD0.mjs")]);
28
+ const [{ scanIntentsOrFail }, { runInstallCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./install-D1dsnbr9.mjs")]);
29
29
  await runInstallCommand(options, scanIntentsOrFail);
30
30
  });
31
31
  cli.command("scaffold", "Print maintainer scaffold prompt").usage("scaffold").action(async () => {
32
- const [{ getMetaDir }, { runScaffoldCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./scaffold-CLM6bt3c.mjs")]);
32
+ const [{ getMetaDir }, { runScaffoldCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./scaffold-CLM6bt3c.mjs")]);
33
33
  runScaffoldCommand(getMetaDir());
34
34
  });
35
35
  cli.command("stale [dir]", "Check skills for staleness in the current package or workspace").usage("stale [dir] [--json] [--github-review]").option("--json", "Output JSON").option("--github-review", "Write GitHub Actions review PR files").option("--package-label <label>", "Fallback package label for review PRs").example("stale").example("stale packages/query").example("stale --json").action(async (targetDir, options) => {
36
- const [{ resolveStaleTargets }, { runStaleCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./stale-C6dPKQ98.mjs")]);
36
+ const [{ resolveStaleTargets }, { runStaleCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./stale-C6dPKQ98.mjs")]);
37
37
  await runStaleCommand(targetDir, options, resolveStaleTargets);
38
38
  });
39
39
  cli.command("edit-package-json", "Update package.json files so skills are published").usage("edit-package-json").action(async () => {
@@ -41,11 +41,11 @@ function createCli() {
41
41
  await runEditPackageJsonCommand(process.cwd());
42
42
  });
43
43
  cli.command("setup", "Copy Intent CI workflow templates into .github/workflows/").usage("setup").action(async () => {
44
- const [{ getMetaDir }, { runSetupGithubActionsCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./setup-github-actions-CUd1oncY.mjs")]);
44
+ const [{ getMetaDir }, { runSetupGithubActionsCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./setup-github-actions-CUd1oncY.mjs")]);
45
45
  await runSetupGithubActionsCommand(process.cwd(), getMetaDir());
46
46
  });
47
47
  cli.command("setup-github-actions", "Copy Intent CI workflow templates into .github/workflows/").usage("setup-github-actions").action(async () => {
48
- const [{ getMetaDir }, { runSetupGithubActionsCommand }] = await Promise.all([import("./cli-support-B26oUGbf.mjs"), import("./setup-github-actions-CUd1oncY.mjs")]);
48
+ const [{ getMetaDir }, { runSetupGithubActionsCommand }] = await Promise.all([import("./cli-support-BtHFD7gl.mjs"), import("./setup-github-actions-CUd1oncY.mjs")]);
49
49
  await runSetupGithubActionsCommand(process.cwd(), getMetaDir());
50
50
  });
51
51
  cli.command("help [command]", "Display help for a command").action((commandName) => {
@@ -1,10 +1,10 @@
1
- import { c as resolveDepDir, i as getDeps, l as toPosixPath } from "./utils-CF7OL__5.mjs";
2
- import { n as scanIntentPackageAtRoot, r as createIntentFsCache, t as scanForIntents } from "./scanner-QujEINYm.mjs";
3
- import { n as findWorkspacePackages } from "./workspace-patterns-FljtM2Xb.mjs";
1
+ import { i as getDeps, l as resolveDepDir, u as toPosixPath } from "./utils-9fhWAVua.mjs";
2
+ import { n as scanIntentPackageAtRoot, r as createIntentFsCache, t as scanForIntents } from "./scanner-DaG82zNc.mjs";
3
+ import { n as findWorkspacePackages } from "./workspace-patterns-BffPlZ1D.mjs";
4
4
  import { i as parseSkillUse, n as formatSkillUse } from "./skill-use-umYvZl94.mjs";
5
- import { t as resolveProjectContext } from "./project-context-4wzbLY9c.mjs";
6
- import { a as compileExcludePatterns, c as warningMentionsPackage, i as resolveSkillUse, o as getEffectiveExcludePatterns, r as resolveSkillEntry, s as isPackageExcluded, t as ResolveSkillUseError } from "./resolver-D8sX72Lg.mjs";
7
- import { existsSync, readFileSync, realpathSync } from "node:fs";
5
+ import { t as resolveProjectContext } from "./project-context-BRIMzhi4.mjs";
6
+ import { a as compileExcludePatterns, c as warningMentionsPackage, i as resolveSkillUse, o as getEffectiveExcludePatterns, r as resolveSkillEntry, s as isPackageExcluded, t as ResolveSkillUseError } from "./resolver-D9cjsz11.mjs";
7
+ import { existsSync } from "node:fs";
8
8
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
9
9
 
10
10
  //#region src/core/markdown.ts
@@ -411,14 +411,14 @@ function isResolvedPathInsidePackageRoot(path, packageRoot) {
411
411
  const relativePath = relative(packageRoot, path);
412
412
  return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute(relativePath);
413
413
  }
414
- function toResolvedIntentSkill(cwd, use, resolved, debug) {
414
+ function toResolvedIntentSkill(cwd, use, resolved, readFs, debug) {
415
415
  let realResolvedPath;
416
416
  try {
417
- realResolvedPath = realpathSync.native(resolveFromCwd(cwd, resolved.path));
417
+ realResolvedPath = readFs.realpathSync.native(resolveFromCwd(cwd, resolved.path));
418
418
  } catch {
419
419
  throw new IntentCoreError("skill-file-not-found", `Resolved skill file was not found: ${resolved.path}`);
420
420
  }
421
- const realPackageRoot = realpathSync.native(resolveFromCwd(cwd, resolved.packageRoot));
421
+ const realPackageRoot = readFs.realpathSync.native(resolveFromCwd(cwd, resolved.packageRoot));
422
422
  if (!isResolvedPathInsidePackageRoot(realResolvedPath, realPackageRoot)) throw new IntentCoreError("skill-path-outside-package", `Resolved skill path for "${use}" is outside package root: ${resolved.path}`);
423
423
  const result = {
424
424
  path: resolved.path,
@@ -434,6 +434,7 @@ function toResolvedIntentSkill(cwd, use, resolved, debug) {
434
434
  return {
435
435
  realPackageRoot,
436
436
  realResolvedPath,
437
+ readFs,
437
438
  result
438
439
  };
439
440
  }
@@ -467,7 +468,7 @@ function resolveIntentSkillInCwd(cwd, use, options = {}) {
467
468
  const scanOptions = toScanOptions(options);
468
469
  const scope = getScanScope(scanOptions);
469
470
  const fastPathResolved = resolveSkillUseFastPath(parsedUse, options, projectContext, cwd, fsCache);
470
- if (fastPathResolved) return toResolvedIntentSkill(cwd, use, fastPathResolved, options.debug ? createLoadedSkillDebug({
471
+ if (fastPathResolved) return toResolvedIntentSkill(cwd, use, fastPathResolved, fsCache.getReadFs(), options.debug ? createLoadedSkillDebug({
471
472
  cwd,
472
473
  excludes: excludePatterns,
473
474
  resolution: "fast-path",
@@ -483,7 +484,7 @@ function resolveIntentSkillInCwd(cwd, use, options = {}) {
483
484
  if (err instanceof ResolveSkillUseError) throw new IntentCoreError(err.code, err.message, { suggestedSkills: err.suggestedSkills });
484
485
  throw err;
485
486
  }
486
- return toResolvedIntentSkill(cwd, use, resolved, options.debug ? createLoadedSkillDebug({
487
+ return toResolvedIntentSkill(cwd, use, resolved, fsCache.getReadFs(), options.debug ? createLoadedSkillDebug({
487
488
  cwd,
488
489
  excludes: excludePatterns,
489
490
  resolution: "full-scan",
@@ -499,7 +500,7 @@ function loadIntentSkill(use, options = {}) {
499
500
  const cwd = resolveCoreCwd(options);
500
501
  const resolved = resolveIntentSkillInCwd(cwd, use, options);
501
502
  const content = rewriteLoadedSkillMarkdownDestinations({
502
- content: readFileSync(resolved.realResolvedPath, "utf8"),
503
+ content: resolved.readFs.readFileSync(resolved.realResolvedPath, "utf8"),
503
504
  cwd,
504
505
  packageRoot: resolved.realPackageRoot,
505
506
  skillFilePath: resolved.realResolvedPath
package/dist/core.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./skill-paths-Cc0-Y331.mjs";
3
- import "./scanner-QujEINYm.mjs";
4
- import "./workspace-patterns-FljtM2Xb.mjs";
5
- import "./project-context-4wzbLY9c.mjs";
6
- import "./resolver-D8sX72Lg.mjs";
7
- import { i as resolveIntentSkill, n as listIntentSkills, r as loadIntentSkill, t as IntentCoreError } from "./core-CEeo37aT.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./skill-paths-B-j0dWDA.mjs";
3
+ import "./scanner-DaG82zNc.mjs";
4
+ import "./workspace-patterns-BffPlZ1D.mjs";
5
+ import "./project-context-BRIMzhi4.mjs";
6
+ import "./resolver-D9cjsz11.mjs";
7
+ import { i as resolveIntentSkill, n as listIntentSkills, r as loadIntentSkill, t as IntentCoreError } from "./core-qlBI_aQL.mjs";
8
8
 
9
9
  export { IntentCoreError, listIntentSkills, loadIntentSkill, resolveIntentSkill };
@@ -1,5 +1,5 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import { n as isStableLoadPath, t as formatRuntimeSkillLookupHint } from "./skill-paths-Cc0-Y331.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import { n as isStableLoadPath, t as formatRuntimeSkillLookupHint } from "./skill-paths-B-j0dWDA.mjs";
3
3
 
4
4
  //#region src/display.ts
5
5
  function padColumn(text, width) {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,46 @@
1
1
  import { S as VersionConflict, a as IntentArtifactSet, b as StalenessReport, c as IntentConfig, d as MetaFeedbackPayload, f as MetaSkillName, h as ScanResult, i as IntentArtifactFile, l as IntentPackage, m as ScanOptions, n as FeedbackPayload, o as IntentArtifactSkill, r as IntentArtifactCoverageIgnore, s as IntentArtifactWarning, t as AgentName, u as IntentProjectConfig, v as SkillEntry, x as StalenessSignal, y as SkillStaleness } from "./types-CIha6LtJ.mjs";
2
2
  import { i as runEditPackageJson, o as runSetupGithubActions, r as SetupGithubActionsResult, t as EditPackageJsonResult } from "./setup-DhMqESd3.mjs";
3
+ import { closeSync, existsSync, lstatSync, openSync, readFileSync, readSync, readdirSync, realpathSync } from "node:fs";
3
4
 
5
+ //#region src/utils.d.ts
6
+
7
+ /**
8
+ * The subset of `node:fs` the scanner reads through. Under Yarn PnP this is
9
+ * swapped for Yarn's libzip-patched `fs` so reads can reach files inside
10
+ * `.yarn/cache/*.zip` (see scanner `loadPnpApi`). The static `node:fs` named
11
+ * imports cannot be used directly for that, because their bindings are captured
12
+ * before Yarn's `setup()` patches the CommonJS `fs` module.
13
+ */
14
+ interface ReadFs {
15
+ existsSync: typeof existsSync;
16
+ lstatSync: typeof lstatSync;
17
+ readFileSync: typeof readFileSync;
18
+ readdirSync: typeof readdirSync;
19
+ realpathSync: typeof realpathSync;
20
+ /**
21
+ * Optional low-level read primitives. When present (always on `node:fs` and
22
+ * Yarn's libzip-patched module) `parseFrontmatter` reads only the leading
23
+ * region of a file instead of its whole body.
24
+ */
25
+ openSync?: typeof openSync;
26
+ readSync?: typeof readSync;
27
+ closeSync?: typeof closeSync;
28
+ }
29
+ /**
30
+ * Recursively find all SKILL.md files under a directory.
31
+ */
32
+ declare function findSkillFiles(dir: string, fs?: ReadFs): Array<string>;
33
+ /**
34
+ * Read dependencies and peerDependencies (and optionally devDependencies) from
35
+ * a parsed package.json object.
36
+ */
37
+ declare function getDeps(pkgJson: Record<string, unknown>, includeDevDeps?: boolean): Array<string>;
38
+ declare function resolveDepDir(depName: string, parentDir: string): string | null;
39
+ /**
40
+ * Parse YAML frontmatter from a file. Returns null if no frontmatter or on error.
41
+ */
42
+ declare function parseFrontmatter(filePath: string, fs?: ReadFs): Record<string, unknown> | null;
43
+ //#endregion
4
44
  //#region src/scanner.d.ts
5
45
  declare function scanForIntents(root?: string, options?: ScanOptions): ScanResult;
6
46
  //#endregion
@@ -52,27 +92,6 @@ declare function submitMetaFeedback(payload: MetaFeedbackPayload, opts: {
52
92
  outputPath?: string;
53
93
  }): SubmitResult;
54
94
  //#endregion
55
- //#region src/utils.d.ts
56
- /**
57
- * Recursively find all SKILL.md files under a directory.
58
- */
59
- declare function findSkillFiles(dir: string): Array<string>;
60
- /**
61
- * Read dependencies and peerDependencies (and optionally devDependencies) from
62
- * a parsed package.json object.
63
- */
64
- declare function getDeps(pkgJson: Record<string, unknown>, includeDevDeps?: boolean): Array<string>;
65
- /**
66
- * Resolve the directory of a dependency by name. Tries createRequire first
67
- * (handles pnpm symlinks), then falls back to walking up node_modules
68
- * directories (handles packages with export maps that block ./package.json).
69
- */
70
- declare function resolveDepDir(depName: string, parentDir: string): string | null;
71
- /**
72
- * Parse YAML frontmatter from a file. Returns null if no frontmatter or on error.
73
- */
74
- declare function parseFrontmatter(filePath: string): Record<string, unknown> | null;
75
- //#endregion
76
95
  //#region src/skill-use.d.ts
77
96
  interface SkillUse {
78
97
  packageName: string;
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- import { c as resolveDepDir, i as getDeps, r as findSkillFiles, s as parseFrontmatter } from "./utils-CF7OL__5.mjs";
2
- import "./skill-paths-Cc0-Y331.mjs";
3
- import { t as scanForIntents } from "./scanner-QujEINYm.mjs";
4
- import "./workspace-patterns-FljtM2Xb.mjs";
1
+ import { c as parseFrontmatter, i as getDeps, l as resolveDepDir, r as findSkillFiles } from "./utils-9fhWAVua.mjs";
2
+ import "./skill-paths-B-j0dWDA.mjs";
3
+ import { t as scanForIntents } from "./scanner-DaG82zNc.mjs";
4
+ import "./workspace-patterns-BffPlZ1D.mjs";
5
5
  import { t as readIntentArtifacts } from "./artifact-coverage-DgWuVqUp.mjs";
6
- import { n as checkStaleness } from "./staleness-BwcLygsY.mjs";
6
+ import { n as checkStaleness } from "./staleness-BGFfic-Y.mjs";
7
7
  import { n as collectStaleReviewItems, r as createFailedStaleReviewItem, t as buildStaleReviewBody } from "./workflow-review-D9Fg1G0P.mjs";
8
8
  import { i as parseSkillUse, n as formatSkillUse, r as isSkillUseParseError, t as SkillUseParseError } from "./skill-use-umYvZl94.mjs";
9
- import "./project-context-4wzbLY9c.mjs";
10
- import { i as resolveSkillUse, n as isResolveSkillUseError, t as ResolveSkillUseError } from "./resolver-D8sX72Lg.mjs";
11
- import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BElEzHxS.mjs";
9
+ import "./project-context-BRIMzhi4.mjs";
10
+ import { i as resolveSkillUse, n as isResolveSkillUseError, t as ResolveSkillUseError } from "./resolver-D9cjsz11.mjs";
11
+ import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BklJkH_6.mjs";
12
12
  import { readFileSync, writeFileSync } from "node:fs";
13
13
  import { join } from "node:path";
14
14
  import { execFileSync, execSync } from "node:child_process";
@@ -1,10 +1,10 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./workspace-patterns-FljtM2Xb.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./workspace-patterns-BffPlZ1D.mjs";
3
3
  import { t as detectPackageManager } from "./package-manager-BUgTjW9Q.mjs";
4
4
  import { i as parseSkillUse, n as formatSkillUse } from "./skill-use-umYvZl94.mjs";
5
- import "./project-context-4wzbLY9c.mjs";
5
+ import "./project-context-BRIMzhi4.mjs";
6
6
  import { t as fail } from "./cli-error-BrMXlbtx.mjs";
7
- import { c as scanOptionsFromGlobalFlags, l as printWarnings } from "./cli-support-C-t4xQw0.mjs";
7
+ import { c as scanOptionsFromGlobalFlags, l as printWarnings } from "./cli-support-BNDR3l1g.mjs";
8
8
  import { t as formatIntentCommand } from "./command-runner-C0yCOHLi.mjs";
9
9
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
10
10
  import { dirname, join, relative } from "node:path";
@@ -1,11 +1,11 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./skill-paths-Cc0-Y331.mjs";
3
- import "./scanner-QujEINYm.mjs";
4
- import "./workspace-patterns-FljtM2Xb.mjs";
5
- import "./project-context-4wzbLY9c.mjs";
6
- import "./resolver-D8sX72Lg.mjs";
7
- import { n as listIntentSkills } from "./core-CEeo37aT.mjs";
8
- import { a as printDebugInfo, l as printWarnings, n as coreOptionsFromGlobalFlags } from "./cli-support-C-t4xQw0.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./skill-paths-B-j0dWDA.mjs";
3
+ import "./scanner-DaG82zNc.mjs";
4
+ import "./workspace-patterns-BffPlZ1D.mjs";
5
+ import "./project-context-BRIMzhi4.mjs";
6
+ import "./resolver-D9cjsz11.mjs";
7
+ import { n as listIntentSkills } from "./core-qlBI_aQL.mjs";
8
+ import { a as printDebugInfo, l as printWarnings, n as coreOptionsFromGlobalFlags } from "./cli-support-BNDR3l1g.mjs";
9
9
  import { t as formatIntentCommand } from "./command-runner-C0yCOHLi.mjs";
10
10
 
11
11
  //#region src/commands/list.ts
@@ -59,7 +59,7 @@ async function runListCommand(options, _scanIntentsOrFail) {
59
59
  console.log(JSON.stringify(jsonResult, null, 2));
60
60
  return;
61
61
  }
62
- const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-BdSvrwWJ.mjs");
62
+ const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-0FnzlKRq.mjs");
63
63
  if (result.packages.length === 0) {
64
64
  console.log("No intent-enabled packages found.");
65
65
  if (result.warnings.length > 0) {
@@ -1,12 +1,12 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./skill-paths-Cc0-Y331.mjs";
3
- import "./scanner-QujEINYm.mjs";
4
- import "./workspace-patterns-FljtM2Xb.mjs";
5
- import "./project-context-4wzbLY9c.mjs";
6
- import "./resolver-D8sX72Lg.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./skill-paths-B-j0dWDA.mjs";
3
+ import "./scanner-DaG82zNc.mjs";
4
+ import "./workspace-patterns-BffPlZ1D.mjs";
5
+ import "./project-context-BRIMzhi4.mjs";
6
+ import "./resolver-D9cjsz11.mjs";
7
7
  import { t as fail } from "./cli-error-BrMXlbtx.mjs";
8
- import { i as resolveIntentSkill, r as loadIntentSkill, t as IntentCoreError } from "./core-CEeo37aT.mjs";
9
- import { a as printDebugInfo, n as coreOptionsFromGlobalFlags } from "./cli-support-C-t4xQw0.mjs";
8
+ import { i as resolveIntentSkill, r as loadIntentSkill, t as IntentCoreError } from "./core-qlBI_aQL.mjs";
9
+ import { a as printDebugInfo, n as coreOptionsFromGlobalFlags } from "./cli-support-BNDR3l1g.mjs";
10
10
 
11
11
  //#region src/commands/load.ts
12
12
  function printLoadDebug(loaded) {
@@ -16,7 +16,7 @@ async function runMetaCommand(name, metaDir) {
16
16
  }
17
17
  return;
18
18
  }
19
- const { parseFrontmatter } = await import("./utils-DTvYXAsM.mjs");
19
+ const { parseFrontmatter } = await import("./utils-CSPzvaFu.mjs");
20
20
  const entries = readdirSync(metaDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => existsSync(join(metaDir, entry.name, "SKILL.md")));
21
21
  if (entries.length === 0) {
22
22
  console.log("No meta-skills found.");
@@ -1,4 +1,4 @@
1
- import { a as readWorkspacePatterns, r as findWorkspaceRoot } from "./workspace-patterns-FljtM2Xb.mjs";
1
+ import { a as readWorkspacePatterns, r as findWorkspaceRoot } from "./workspace-patterns-BffPlZ1D.mjs";
2
2
  import { existsSync, statSync } from "node:fs";
3
3
  import { dirname, join, relative, resolve } from "node:path";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { i as parseSkillUse } from "./skill-use-umYvZl94.mjs";
2
- import { t as resolveProjectContext } from "./project-context-4wzbLY9c.mjs";
2
+ import { t as resolveProjectContext } from "./project-context-BRIMzhi4.mjs";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
5
5
 
@@ -0,0 +1,6 @@
1
+ import "./utils-9fhWAVua.mjs";
2
+ import "./skill-paths-B-j0dWDA.mjs";
3
+ import { n as scanIntentPackageAtRoot, t as scanForIntents } from "./scanner-DaG82zNc.mjs";
4
+ import "./workspace-patterns-BffPlZ1D.mjs";
5
+
6
+ export { scanForIntents };
@@ -1,9 +1,9 @@
1
- import { a as listNestedNodeModulesPackageDirs, c as resolveDepDir, i as getDeps, l as toPosixPath, n as detectGlobalNodeModules, o as listNodeModulesPackageDirs, r as findSkillFiles, s as parseFrontmatter, t as createFsIdentityCache } from "./utils-CF7OL__5.mjs";
2
- import { r as rewriteSkillLoadPaths } from "./skill-paths-Cc0-Y331.mjs";
3
- import { n as findWorkspacePackages, r as findWorkspaceRoot } from "./workspace-patterns-FljtM2Xb.mjs";
1
+ import { a as listNestedNodeModulesPackageDirs, c as parseFrontmatter, i as getDeps, l as resolveDepDir, n as detectGlobalNodeModules, o as listNodeModulesPackageDirs, r as findSkillFiles, s as nodeReadFs, t as createFsIdentityCache, u as toPosixPath } from "./utils-9fhWAVua.mjs";
2
+ import { r as rewriteSkillLoadPaths } from "./skill-paths-B-j0dWDA.mjs";
3
+ import { n as findWorkspacePackages, r as findWorkspaceRoot } from "./workspace-patterns-BffPlZ1D.mjs";
4
4
  import { t as detectPackageManager } from "./package-manager-BUgTjW9Q.mjs";
5
5
  import { createRequire } from "node:module";
6
- import { existsSync, readFileSync } from "node:fs";
6
+ import { existsSync } from "node:fs";
7
7
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
8
8
  import semver from "semver";
9
9
 
@@ -35,7 +35,7 @@ function createPackageRegistrar(opts) {
35
35
  function tryRegister(dirPath, fallbackName, source = "local") {
36
36
  if (!shouldAttemptPackageRoot(dirPath)) return false;
37
37
  const skillsDir = join(dirPath, "skills");
38
- if (!existsSync(skillsDir)) return false;
38
+ if (!opts.exists(skillsDir)) return false;
39
39
  const pkgJson = opts.readPkgJson(dirPath);
40
40
  if (!pkgJson) {
41
41
  opts.warnings.push(`Could not read package.json for ${dirPath}`);
@@ -117,7 +117,7 @@ function createDependencyWalker(opts) {
117
117
  opts.warnings.push(`Could not read package.json for ${pkgName} (skipping dependency walk)`);
118
118
  return;
119
119
  }
120
- walkDepsOf(pkgJson, pkgDir);
120
+ walkDepsOf(pkgJson, pkgKey);
121
121
  }
122
122
  function walkKnownPackages() {
123
123
  for (const pkg of [...opts.packages]) walkDeps(pkg.packageRoot, pkg.name);
@@ -165,7 +165,8 @@ function isRecord(value) {
165
165
  function createIntentFsCache() {
166
166
  const packageJsonCache = /* @__PURE__ */ new Map();
167
167
  const skillFilesCache = /* @__PURE__ */ new Map();
168
- const getFsIdentity = createFsIdentityCache();
168
+ let activeFs = nodeReadFs;
169
+ const getFsIdentity = createFsIdentityCache(() => activeFs);
169
170
  const stats = {
170
171
  packageJsonReadCount: 0,
171
172
  packageJsonCacheHits: 0
@@ -179,7 +180,7 @@ function createIntentFsCache() {
179
180
  }
180
181
  stats.packageJsonReadCount += 1;
181
182
  try {
182
- const parsed = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
183
+ const parsed = JSON.parse(activeFs.readFileSync(join(dir, "package.json"), "utf8"));
183
184
  const result = {
184
185
  packageJson: isRecord(parsed) ? parsed : null,
185
186
  error: null
@@ -202,7 +203,7 @@ function createIntentFsCache() {
202
203
  const key = getFsIdentity(dir);
203
204
  const cached = skillFilesCache.get(key);
204
205
  if (cached) return [...cached];
205
- const files = findSkillFiles(dir);
206
+ const files = findSkillFiles(dir, activeFs);
206
207
  skillFilesCache.set(key, files);
207
208
  return [...files];
208
209
  }
@@ -211,7 +212,12 @@ function createIntentFsCache() {
211
212
  readPackageJsonResult,
212
213
  findSkillFiles: findSkillFiles$1,
213
214
  getFsIdentity,
214
- getStats: () => ({ ...stats })
215
+ getStats: () => ({ ...stats }),
216
+ useFs: (fs) => {
217
+ activeFs = fs;
218
+ },
219
+ getReadFs: () => activeFs,
220
+ exists: (path) => activeFs.existsSync(path)
215
221
  };
216
222
  }
217
223
 
@@ -237,15 +243,29 @@ function assertLocalNodeModulesSupported(root) {
237
243
  function loadPnpApi(root) {
238
244
  const pnpPath = findPnpFile(root);
239
245
  if (!pnpPath) return null;
246
+ const moduleApi = requireFromHere("node:module");
247
+ const originalResolveFilename = moduleApi._resolveFilename;
248
+ const readFs = requireFromHere("node:fs");
240
249
  try {
241
250
  const pnpModule = requireFromHere(pnpPath);
242
251
  if (typeof pnpModule.setup === "function") pnpModule.setup();
243
- if (typeof pnpModule.getDependencyTreeRoots === "function" && typeof pnpModule.getPackageInformation === "function") return pnpModule;
244
- return createRequire(join(dirname(pnpPath), "package.json"))("pnpapi");
252
+ moduleApi._resolveFilename = originalResolveFilename;
253
+ if (typeof pnpModule.getDependencyTreeRoots === "function" && typeof pnpModule.getPackageInformation === "function") return {
254
+ api: pnpModule,
255
+ readFs
256
+ };
257
+ return {
258
+ api: createRequire(join(dirname(pnpPath), "package.json"))("pnpapi"),
259
+ readFs
260
+ };
245
261
  } catch (err) {
262
+ moduleApi._resolveFilename = originalResolveFilename;
246
263
  try {
247
- const foundApi = requireFromHere("node:module").findPnpApi?.(root);
248
- if (foundApi) return foundApi;
264
+ const foundApi = moduleApi.findPnpApi?.(root);
265
+ if (foundApi) return {
266
+ api: foundApi,
267
+ readFs
268
+ };
249
269
  } catch {}
250
270
  const msg = err instanceof Error ? err.message : String(err);
251
271
  throw new Error(`Yarn PnP project detected, but Intent could not load Yarn's PnP API from ${pnpPath}: ${msg}`);
@@ -303,8 +323,8 @@ function deriveIntentConfig(pkgJson) {
303
323
  requires
304
324
  };
305
325
  }
306
- function readSkillEntry(skillsDir, childDir, skillFile) {
307
- const fm = parseFrontmatter(skillFile);
326
+ function readSkillEntry(skillsDir, childDir, skillFile, readFs = nodeReadFs) {
327
+ const fm = parseFrontmatter(skillFile, readFs);
308
328
  const relName = toPosixPath(relative(skillsDir, childDir));
309
329
  const desc = typeof fm?.description === "string" ? fm.description.replace(/\s+/g, " ").trim() : "";
310
330
  return {
@@ -315,7 +335,7 @@ function readSkillEntry(skillsDir, childDir, skillFile) {
315
335
  framework: typeof fm?.framework === "string" ? fm.framework : void 0
316
336
  };
317
337
  }
318
- function discoverSkillByNameHint(skillsDir, packageName, skillNameHint) {
338
+ function discoverSkillByNameHint(skillsDir, packageName, skillNameHint, readFs = nodeReadFs) {
319
339
  const skills = [];
320
340
  const seen = /* @__PURE__ */ new Set();
321
341
  const skillNameHints = getSkillNameHints(packageName, skillNameHint);
@@ -323,8 +343,8 @@ function discoverSkillByNameHint(skillsDir, packageName, skillNameHint) {
323
343
  const resolvedHint = resolveSkillNameHintPath(skillsDir, hint);
324
344
  if (!resolvedHint) continue;
325
345
  const { childDir, skillFile } = resolvedHint;
326
- if (!existsSync(skillFile)) continue;
327
- const skill = readSkillEntry(skillsDir, childDir, skillFile);
346
+ if (!readFs.existsSync(skillFile)) continue;
347
+ const skill = readSkillEntry(skillsDir, childDir, skillFile, readFs);
328
348
  if (skill.name !== hint || seen.has(skill.name)) continue;
329
349
  seen.add(skill.name);
330
350
  skills.push(skill);
@@ -332,10 +352,11 @@ function discoverSkillByNameHint(skillsDir, packageName, skillNameHint) {
332
352
  return skills;
333
353
  }
334
354
  function discoverSkills(skillsDir, fsCache) {
355
+ const readFs = fsCache.getReadFs();
335
356
  return fsCache.findSkillFiles(skillsDir).flatMap((skillFile) => {
336
357
  const childDir = dirname(skillFile);
337
358
  if (childDir === skillsDir) return [];
338
- return [readSkillEntry(skillsDir, childDir, skillFile)];
359
+ return [readSkillEntry(skillsDir, childDir, skillFile, readFs)];
339
360
  });
340
361
  }
341
362
  function getPackageShortName(packageName) {
@@ -446,7 +467,11 @@ function scanForIntents(root, options = {}) {
446
467
  let pnpApi;
447
468
  function getPnpApi() {
448
469
  if (scanScope === "global") return null;
449
- if (pnpApi === void 0) pnpApi = loadPnpApi(projectRoot);
470
+ if (pnpApi === void 0) {
471
+ const loaded = loadPnpApi(projectRoot);
472
+ pnpApi = loaded?.api ?? null;
473
+ if (loaded) fsCache.useFs(loaded.readFs);
474
+ }
450
475
  return pnpApi;
451
476
  }
452
477
  function getStats() {
@@ -481,6 +506,7 @@ function scanForIntents(root, options = {}) {
481
506
  discoverSkills: (skillsDir) => discoverSkills(skillsDir, fsCache),
482
507
  getPackageDepth,
483
508
  getFsIdentity: fsCache.getFsIdentity,
509
+ exists: fsCache.exists,
484
510
  packageIndexes,
485
511
  packages,
486
512
  projectRoot,
@@ -594,9 +620,10 @@ function scanIntentPackageAtRoot(packageRoot, options = {}) {
594
620
  const { tryRegister } = createPackageRegistrar({
595
621
  comparePackageVersions,
596
622
  deriveIntentConfig,
597
- discoverSkills: options.skillNameHint ? (skillsDir, packageName) => discoverSkillByNameHint(skillsDir, packageName, options.skillNameHint) : (skillsDir) => discoverSkills(skillsDir, fsCache),
623
+ discoverSkills: options.skillNameHint ? (skillsDir, packageName) => discoverSkillByNameHint(skillsDir, packageName, options.skillNameHint, fsCache.getReadFs()) : (skillsDir) => discoverSkills(skillsDir, fsCache),
598
624
  getPackageDepth,
599
625
  getFsIdentity: fsCache.getFsIdentity,
626
+ exists: fsCache.exists,
600
627
  packageIndexes,
601
628
  packages,
602
629
  projectRoot,
@@ -1,5 +1,5 @@
1
- import { a as readWorkspacePatterns, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-FljtM2Xb.mjs";
2
- import { t as resolveProjectContext } from "./project-context-4wzbLY9c.mjs";
1
+ import { a as readWorkspacePatterns, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-BffPlZ1D.mjs";
2
+ import { t as resolveProjectContext } from "./project-context-BRIMzhi4.mjs";
3
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
4
4
  import { basename, join, relative } from "node:path";
5
5
 
package/dist/setup.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import { a as readWorkspacePatterns, o as resolveWorkspacePackages, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-FljtM2Xb.mjs";
3
- import "./project-context-4wzbLY9c.mjs";
4
- import { n as runEditPackageJsonAll, r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BElEzHxS.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import { a as readWorkspacePatterns, o as resolveWorkspacePackages, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-BffPlZ1D.mjs";
3
+ import "./project-context-BRIMzhi4.mjs";
4
+ import { n as runEditPackageJsonAll, r as runSetupGithubActions, t as runEditPackageJson } from "./setup-BklJkH_6.mjs";
5
5
 
6
6
  export { findPackagesWithSkills, findWorkspaceRoot, readWorkspacePatterns, resolveWorkspacePackages, runEditPackageJson, runEditPackageJsonAll, runSetupGithubActions };
@@ -1,4 +1,4 @@
1
- import { l as toPosixPath } from "./utils-CF7OL__5.mjs";
1
+ import { u as toPosixPath } from "./utils-9fhWAVua.mjs";
2
2
  import { existsSync } from "node:fs";
3
3
  import { join, relative } from "node:path";
4
4
 
@@ -1,4 +1,4 @@
1
- import { l as toPosixPath, r as findSkillFiles, s as parseFrontmatter } from "./utils-CF7OL__5.mjs";
1
+ import { c as parseFrontmatter, r as findSkillFiles, u as toPosixPath } from "./utils-9fhWAVua.mjs";
2
2
  import { t as readIntentArtifacts } from "./artifact-coverage-DgWuVqUp.mjs";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { isAbsolute, join, relative, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import "./utils-CF7OL__5.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
2
  import "./artifact-coverage-DgWuVqUp.mjs";
3
- import { n as checkStaleness, r as readPackageName, t as buildWorkspaceCoverageSignals } from "./staleness-BwcLygsY.mjs";
3
+ import { n as checkStaleness, r as readPackageName, t as buildWorkspaceCoverageSignals } from "./staleness-BGFfic-Y.mjs";
4
4
 
5
5
  export { buildWorkspaceCoverageSignals, checkStaleness, readPackageName };
@@ -1,25 +1,36 @@
1
1
  import { createRequire } from "node:module";
2
- import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync } from "node:fs";
2
+ import { closeSync, existsSync, lstatSync, openSync, readFileSync, readSync, readdirSync, realpathSync } from "node:fs";
3
3
  import { dirname, join, resolve, 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
+ const nodeReadFs = {
9
+ existsSync,
10
+ lstatSync,
11
+ readFileSync,
12
+ readdirSync,
13
+ realpathSync,
14
+ openSync,
15
+ readSync,
16
+ closeSync
17
+ };
8
18
  /**
9
19
  * Convert a path to use forward slashes (for cross-platform consistency).
10
20
  */
11
21
  function toPosixPath(p) {
12
22
  return p.split(sep).join("/");
13
23
  }
14
- function createFsIdentityCache() {
24
+ function createFsIdentityCache(getFs = () => nodeReadFs) {
15
25
  const cache = /* @__PURE__ */ new Map();
16
26
  return (path) => {
17
27
  const resolved = resolve(path);
18
28
  const cached = cache.get(resolved);
19
29
  if (cached) return cached;
30
+ const fs = getFs();
20
31
  let identity;
21
32
  try {
22
- identity = lstatSync(resolved).isSymbolicLink() ? realpathSync(resolved) : resolved;
33
+ identity = fs.lstatSync(resolved).isSymbolicLink() ? fs.realpathSync(resolved) : resolved;
23
34
  } catch {
24
35
  identity = resolved;
25
36
  }
@@ -30,24 +41,26 @@ function createFsIdentityCache() {
30
41
  /**
31
42
  * Recursively find all SKILL.md files under a directory.
32
43
  */
33
- function findSkillFiles(dir) {
44
+ function findSkillFiles(dir, fs = nodeReadFs) {
34
45
  const files = [];
35
- if (!existsSync(dir)) return files;
46
+ collectSkillFiles(dir, fs, files);
47
+ return files;
48
+ }
49
+ function collectSkillFiles(dir, fs, files) {
36
50
  let entries;
37
51
  try {
38
- entries = readdirSync(dir, {
52
+ entries = fs.readdirSync(dir, {
39
53
  withFileTypes: true,
40
54
  encoding: "utf8"
41
55
  });
42
56
  } catch {
43
- return files;
57
+ return;
44
58
  }
45
59
  for (const entry of entries) {
46
60
  const fullPath = join(dir, entry.name);
47
- if (entry.isDirectory()) files.push(...findSkillFiles(fullPath));
61
+ if (entry.isDirectory()) collectSkillFiles(fullPath, fs, files);
48
62
  else if (entry.name === "SKILL.md") files.push(fullPath);
49
63
  }
50
- return files;
51
64
  }
52
65
  /**
53
66
  * Read dependencies and peerDependencies (and optionally devDependencies) from
@@ -67,7 +80,6 @@ function getDeps(pkgJson, includeDevDeps = false) {
67
80
  return [...deps];
68
81
  }
69
82
  function listNodeModulesPackageDirs(nodeModulesDir) {
70
- if (!existsSync(nodeModulesDir)) return [];
71
83
  let topEntries;
72
84
  try {
73
85
  topEntries = readdirSync(nodeModulesDir, {
@@ -184,9 +196,25 @@ function detectGlobalNodeModules(packageManager) {
184
196
  * (handles pnpm symlinks), then falls back to walking up node_modules
185
197
  * directories (handles packages with export maps that block ./package.json).
186
198
  */
199
+ /**
200
+ * `createRequire` builds a full module-resolution context; constructing it is
201
+ * non-trivial and `resolveDepDir` is called once per dependency, often many
202
+ * times from the same `parentDir` (every sibling dep of one package). Cache the
203
+ * require function by its base `package.json` path. `req.resolve` still hits the
204
+ * live filesystem on each call, so cached entries never go stale.
205
+ */
206
+ const requireForBaseCache = /* @__PURE__ */ new Map();
207
+ function getRequireForBase(basePackageJson) {
208
+ let req = requireForBaseCache.get(basePackageJson);
209
+ if (!req) {
210
+ req = createRequire(basePackageJson);
211
+ requireForBaseCache.set(basePackageJson, req);
212
+ }
213
+ return req;
214
+ }
187
215
  function resolveDepDir(depName, parentDir) {
188
216
  try {
189
- return dirname(createRequire(join(parentDir, "package.json")).resolve(join(depName, "package.json")));
217
+ return dirname(getRequireForBase(join(parentDir, "package.json")).resolve(join(depName, "package.json")));
190
218
  } catch (err) {
191
219
  const code = err && typeof err === "object" && "code" in err ? err.code : void 0;
192
220
  if (code && code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") console.warn(`Warning: could not resolve ${depName} from ${parentDir}: ${err instanceof Error ? err.message : String(err)}`);
@@ -204,21 +232,51 @@ function resolveDepDir(depName, parentDir) {
204
232
  /**
205
233
  * Parse YAML frontmatter from a file. Returns null if no frontmatter or on error.
206
234
  */
207
- function parseFrontmatter(filePath) {
208
- let content;
235
+ function parseFrontmatter(filePath, fs = nodeReadFs) {
236
+ const content = readFrontmatterRegion(filePath, fs);
237
+ if (content === null) return null;
238
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
239
+ if (!match?.[1]) return null;
209
240
  try {
210
- content = readFileSync(filePath, "utf8");
241
+ return parse(match[1]);
211
242
  } catch {
212
243
  return null;
213
244
  }
214
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
215
- if (!match?.[1]) return null;
245
+ }
246
+ /** Max bytes read when probing a file's leading frontmatter region. */
247
+ const FRONTMATTER_READ_LIMIT = 16 * 1024;
248
+ /** Reused across calls; safe because reads are synchronous and single-threaded. */
249
+ const frontmatterBuffer = Buffer.allocUnsafe(FRONTMATTER_READ_LIMIT);
250
+ /**
251
+ * Read just the leading region of a file, enough to cover its frontmatter,
252
+ * instead of its whole body. Falls back to a full read when the bounded read
253
+ * primitives are unavailable or the frontmatter exceeds the probe limit.
254
+ */
255
+ function readFrontmatterRegion(filePath, fs) {
256
+ if (fs.openSync && fs.readSync && fs.closeSync) {
257
+ let region = null;
258
+ let truncated = false;
259
+ let fd;
260
+ try {
261
+ fd = fs.openSync(filePath, "r");
262
+ } catch {
263
+ return null;
264
+ }
265
+ try {
266
+ const bytesRead = fs.readSync(fd, frontmatterBuffer, 0, FRONTMATTER_READ_LIMIT, 0);
267
+ region = frontmatterBuffer.toString("utf8", 0, bytesRead);
268
+ truncated = bytesRead === FRONTMATTER_READ_LIMIT && !/\r?\n---/.test(region.slice(3));
269
+ } finally {
270
+ fs.closeSync(fd);
271
+ }
272
+ if (!truncated) return region;
273
+ }
216
274
  try {
217
- return parse(match[1]);
275
+ return fs.readFileSync(filePath, "utf8");
218
276
  } catch {
219
277
  return null;
220
278
  }
221
279
  }
222
280
 
223
281
  //#endregion
224
- export { listNestedNodeModulesPackageDirs as a, resolveDepDir as c, getDeps as i, toPosixPath as l, detectGlobalNodeModules as n, listNodeModulesPackageDirs as o, findSkillFiles as r, parseFrontmatter as s, createFsIdentityCache as t };
282
+ export { listNestedNodeModulesPackageDirs as a, parseFrontmatter as c, getDeps as i, resolveDepDir as l, detectGlobalNodeModules as n, listNodeModulesPackageDirs as o, findSkillFiles as r, nodeReadFs as s, createFsIdentityCache as t, toPosixPath as u };
@@ -0,0 +1,3 @@
1
+ import { a as listNestedNodeModulesPackageDirs, c as parseFrontmatter, i as getDeps, l as resolveDepDir, n as detectGlobalNodeModules, o as listNodeModulesPackageDirs, r as findSkillFiles, s as nodeReadFs, t as createFsIdentityCache, u as toPosixPath } from "./utils-9fhWAVua.mjs";
2
+
3
+ export { createFsIdentityCache, detectGlobalNodeModules, findSkillFiles, getDeps, listNestedNodeModulesPackageDirs, listNodeModulesPackageDirs, nodeReadFs, parseFrontmatter, resolveDepDir, toPosixPath };
@@ -1,8 +1,8 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import { n as findWorkspacePackages } from "./workspace-patterns-FljtM2Xb.mjs";
3
- import { t as resolveProjectContext } from "./project-context-4wzbLY9c.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import { n as findWorkspacePackages } from "./workspace-patterns-BffPlZ1D.mjs";
3
+ import { t as resolveProjectContext } from "./project-context-BRIMzhi4.mjs";
4
4
  import { n as isCliFailure, t as fail } from "./cli-error-BrMXlbtx.mjs";
5
- import { l as printWarnings } from "./cli-support-C-t4xQw0.mjs";
5
+ import { l as printWarnings } from "./cli-support-BNDR3l1g.mjs";
6
6
  import { appendFileSync, existsSync, readFileSync } from "node:fs";
7
7
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
8
8
 
@@ -115,7 +115,7 @@ async function runValidateCommand(dir, options = {}) {
115
115
  }
116
116
  }
117
117
  async function runValidateCommandInternal(dir) {
118
- const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-DTvYXAsM.mjs")]);
118
+ const [{ parse: parseYaml }, { findSkillFiles }] = await Promise.all([import("yaml"), import("./utils-CSPzvaFu.mjs")]);
119
119
  const context = resolveProjectContext({
120
120
  cwd: process.cwd(),
121
121
  targetPath: dir
@@ -1,4 +1,4 @@
1
- import { r as findSkillFiles } from "./utils-CF7OL__5.mjs";
1
+ import { r as findSkillFiles } from "./utils-9fhWAVua.mjs";
2
2
  import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { parse } from "yaml";
@@ -1,4 +1,4 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import { a as readWorkspacePatterns, i as getWorkspaceInfo, n as findWorkspacePackages, o as resolveWorkspacePackages, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-FljtM2Xb.mjs";
1
+ import "./utils-9fhWAVua.mjs";
2
+ import { a as readWorkspacePatterns, i as getWorkspaceInfo, n as findWorkspacePackages, o as resolveWorkspacePackages, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-BffPlZ1D.mjs";
3
3
 
4
4
  export { findWorkspaceRoot, getWorkspaceInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/intent",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "Ship compositional knowledge for AI coding agents alongside your npm packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +0,0 @@
1
- import "./utils-CF7OL__5.mjs";
2
- import "./skill-paths-Cc0-Y331.mjs";
3
- import { n as scanIntentPackageAtRoot, t as scanForIntents } from "./scanner-QujEINYm.mjs";
4
- import "./workspace-patterns-FljtM2Xb.mjs";
5
-
6
- export { scanForIntents };
@@ -1,3 +0,0 @@
1
- import { a as listNestedNodeModulesPackageDirs, c as resolveDepDir, i as getDeps, l as toPosixPath, n as detectGlobalNodeModules, o as listNodeModulesPackageDirs, r as findSkillFiles, s as parseFrontmatter, t as createFsIdentityCache } from "./utils-CF7OL__5.mjs";
2
-
3
- export { createFsIdentityCache, detectGlobalNodeModules, findSkillFiles, getDeps, listNestedNodeModulesPackageDirs, listNodeModulesPackageDirs, parseFrontmatter, resolveDepDir, toPosixPath };