@tanstack/intent 0.0.27 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import "./utils-COlDcU72.mjs";
3
- import "./workspace-patterns-BuJMfudb.mjs";
4
- import { t as resolveProjectContext } from "./project-context-B7UXTA9F.mjs";
3
+ import "./workspace-patterns-Cndd-7vB.mjs";
4
+ import { t as resolveProjectContext } from "./project-context-D6A5sBBO.mjs";
5
5
  import { n as runInstallCommand } from "./install-BzDmD5yI.mjs";
6
6
  import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
7
7
  import { dirname, join, relative, resolve, sep } from "node:path";
@@ -32,7 +32,7 @@ function getMetaDir() {
32
32
  return join(dirname(fileURLToPath(import.meta.url)), "..", "meta");
33
33
  }
34
34
  async function scanIntentsOrFail() {
35
- const { scanForIntents } = await import("./scanner-CERQgrRN.mjs");
35
+ const { scanForIntents } = await import("./scanner-CP4U8F_n.mjs");
36
36
  try {
37
37
  return scanForIntents();
38
38
  } catch (err) {
@@ -48,10 +48,15 @@ function readPackageName(root) {
48
48
  }
49
49
  }
50
50
  async function resolveStaleTargets(targetDir) {
51
- const resolvedRoot = targetDir ? join(process.cwd(), targetDir) : process.cwd();
52
- const { checkStaleness } = await import("./staleness-SRims-ZP.mjs");
51
+ const resolvedRoot = targetDir ? resolve(process.cwd(), targetDir) : process.cwd();
52
+ const context = resolveProjectContext({
53
+ cwd: process.cwd(),
54
+ targetPath: targetDir
55
+ });
56
+ const { checkStaleness } = await import("./staleness-LRbiWWZK.mjs");
57
+ if (context.packageRoot && (context.targetSkillsDir !== null || resolvedRoot !== context.workspaceRoot)) return { reports: [await checkStaleness(context.packageRoot, readPackageName(context.packageRoot))] };
53
58
  if (existsSync(join(resolvedRoot, "skills"))) return { reports: [await checkStaleness(resolvedRoot, readPackageName(resolvedRoot))] };
54
- const { findPackagesWithSkills, findWorkspaceRoot } = await import("./workspace-patterns-Boa5mAbf.mjs");
59
+ const { findPackagesWithSkills, findWorkspaceRoot } = await import("./workspace-patterns-D_y6rlqX.mjs");
55
60
  const workspaceRoot = findWorkspaceRoot(resolvedRoot);
56
61
  if (workspaceRoot) {
57
62
  const packageDirs = findPackagesWithSkills(workspaceRoot);
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
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";
2
+ import "./workspace-patterns-Cndd-7vB.mjs";
3
+ import { t as scanForIntents } from "./scanner-B-bbXBLY.mjs";
4
+ import { t as checkStaleness } from "./staleness-SY7-mZMH.mjs";
5
+ import "./project-context-D6A5sBBO.mjs";
6
+ import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-B4ZwN5Hg.mjs";
7
7
  import { readFileSync, writeFileSync } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { execFileSync, execSync } from "node:child_process";
@@ -1,4 +1,4 @@
1
- import { n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-BuJMfudb.mjs";
1
+ import { n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-Cndd-7vB.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 { 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";
2
+ import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns } from "./workspace-patterns-Cndd-7vB.mjs";
3
3
  import { existsSync, readFileSync, readdirSync } from "node:fs";
4
4
  import { join, relative, sep } from "node:path";
5
5
 
@@ -0,0 +1,5 @@
1
+ import "./utils-COlDcU72.mjs";
2
+ import "./workspace-patterns-Cndd-7vB.mjs";
3
+ import { t as scanForIntents } from "./scanner-B-bbXBLY.mjs";
4
+
5
+ export { scanForIntents };
@@ -1,5 +1,5 @@
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";
1
+ import { n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-Cndd-7vB.mjs";
2
+ import { t as resolveProjectContext } from "./project-context-D6A5sBBO.mjs";
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
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";
2
+ import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-Cndd-7vB.mjs";
3
+ import "./project-context-D6A5sBBO.mjs";
4
+ import { n as runEditPackageJsonAll, r as runSetupGithubActions, t as runEditPackageJson } from "./setup-B4ZwN5Hg.mjs";
5
5
 
6
6
  export { findPackagesWithSkills, findWorkspaceRoot, readWorkspacePatterns, resolveWorkspacePackages, runEditPackageJson, runEditPackageJsonAll, runSetupGithubActions };
@@ -0,0 +1,4 @@
1
+ import "./utils-COlDcU72.mjs";
2
+ import { t as checkStaleness } from "./staleness-SY7-mZMH.mjs";
3
+
4
+ export { checkStaleness };
@@ -12,6 +12,14 @@ function classifyVersionDrift(oldVer, newVer) {
12
12
  if ((newParts[2] ?? 0) > (oldParts[2] ?? 0)) return "patch";
13
13
  return null;
14
14
  }
15
+ function readLocalVersion(packageDir) {
16
+ try {
17
+ const pkgJson = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
18
+ return typeof pkgJson.version === "string" ? pkgJson.version : null;
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
15
23
  async function fetchNpmVersion(packageName) {
16
24
  try {
17
25
  const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`);
@@ -22,6 +30,9 @@ async function fetchNpmVersion(packageName) {
22
30
  return null;
23
31
  }
24
32
  }
33
+ async function fetchCurrentVersion(packageDir, packageName) {
34
+ return readLocalVersion(packageDir) ?? await fetchNpmVersion(packageName);
35
+ }
25
36
  function isStringRecord(value) {
26
37
  return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
27
38
  }
@@ -65,7 +76,7 @@ async function checkStaleness(packageDir, packageName) {
65
76
  };
66
77
  });
67
78
  const skillVersion = skillMetas.find((s) => s.libraryVersion)?.libraryVersion ?? null;
68
- const currentVersion = await fetchNpmVersion(library);
79
+ const currentVersion = await fetchCurrentVersion(packageDir, library);
69
80
  const versionDrift = skillVersion && currentVersion ? classifyVersionDrift(skillVersion, currentVersion) : null;
70
81
  const syncState = readSyncState(packageDir);
71
82
  return {
@@ -17,21 +17,90 @@ function parseWorkspacePatterns(value) {
17
17
  function hasPackageJson(dir) {
18
18
  return existsSync(join(dir, "package.json"));
19
19
  }
20
+ function stripJsonCommentsAndTrailingCommas(source) {
21
+ let result = "";
22
+ let inString = false;
23
+ let escaped = false;
24
+ for (let index = 0; index < source.length; index += 1) {
25
+ const char = source[index];
26
+ const next = source[index + 1];
27
+ if (inString) {
28
+ result += char;
29
+ if (escaped) escaped = false;
30
+ else if (char === "\\") escaped = true;
31
+ else if (char === "\"") inString = false;
32
+ continue;
33
+ }
34
+ if (char === "\"") {
35
+ inString = true;
36
+ result += char;
37
+ continue;
38
+ }
39
+ if (char === "/" && next === "/") {
40
+ while (index < source.length && source[index] !== "\n") index += 1;
41
+ if (index < source.length) result += source[index];
42
+ continue;
43
+ }
44
+ if (char === "/" && next === "*") {
45
+ const commentStart = index;
46
+ index += 2;
47
+ while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
48
+ if (index >= source.length) throw new SyntaxError(`Unterminated block comment starting at position ${commentStart}`);
49
+ index += 1;
50
+ continue;
51
+ }
52
+ if (char === ",") {
53
+ let lookahead = index + 1;
54
+ while (lookahead < source.length) {
55
+ const la = source[lookahead];
56
+ if (/\s/.test(la)) lookahead += 1;
57
+ else if (la === "/" && source[lookahead + 1] === "/") {
58
+ lookahead += 2;
59
+ while (lookahead < source.length && source[lookahead] !== "\n") lookahead += 1;
60
+ } else if (la === "/" && source[lookahead + 1] === "*") {
61
+ lookahead += 2;
62
+ while (lookahead < source.length && !(source[lookahead] === "*" && source[lookahead + 1] === "/")) lookahead += 1;
63
+ lookahead += 2;
64
+ } else break;
65
+ }
66
+ if (source[lookahead] === "}" || source[lookahead] === "]") continue;
67
+ }
68
+ result += char;
69
+ }
70
+ return result;
71
+ }
72
+ function readJsonFile(path, jsonc = false) {
73
+ const source = readFileSync(path, "utf8");
74
+ return JSON.parse(jsonc ? stripJsonCommentsAndTrailingCommas(source) : source);
75
+ }
20
76
  function readWorkspacePatterns(root) {
21
77
  const pnpmWs = join(root, "pnpm-workspace.yaml");
22
78
  if (existsSync(pnpmWs)) try {
23
79
  const patterns = parseWorkspacePatterns(parse(readFileSync(pnpmWs, "utf8")).packages);
24
80
  if (patterns) return patterns;
25
81
  } catch (err) {
26
- console.error(`Warning: failed to parse ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
82
+ const verb = err instanceof SyntaxError ? "parse" : "read";
83
+ console.error(`Warning: failed to ${verb} ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
27
84
  }
28
85
  const pkgPath = join(root, "package.json");
29
86
  if (existsSync(pkgPath)) try {
30
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
31
- const patterns = parseWorkspacePatterns(pkg.workspaces) ?? parseWorkspacePatterns(pkg.workspaces?.packages);
87
+ const workspaces = readJsonFile(pkgPath).workspaces;
88
+ const patterns = parseWorkspacePatterns(workspaces) ?? parseWorkspacePatterns(workspaces?.packages);
32
89
  if (patterns) return patterns;
33
90
  } catch (err) {
34
- console.error(`Warning: failed to parse ${pkgPath}: ${err instanceof Error ? err.message : err}`);
91
+ const verb = err instanceof SyntaxError ? "parse" : "read";
92
+ console.error(`Warning: failed to ${verb} ${pkgPath}: ${err instanceof Error ? err.message : err}`);
93
+ }
94
+ for (const denoConfigName of ["deno.json", "deno.jsonc"]) {
95
+ const denoConfigPath = join(root, denoConfigName);
96
+ if (!existsSync(denoConfigPath)) continue;
97
+ try {
98
+ const patterns = parseWorkspacePatterns(readJsonFile(denoConfigPath, true).workspace);
99
+ if (patterns) return patterns;
100
+ } catch (err) {
101
+ const verb = err instanceof SyntaxError ? "parse" : "read";
102
+ console.error(`Warning: failed to ${verb} ${denoConfigPath}: ${err instanceof Error ? err.message : err}`);
103
+ }
35
104
  }
36
105
  return null;
37
106
  }
@@ -1,4 +1,4 @@
1
1
  import "./utils-COlDcU72.mjs";
2
- import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-BuJMfudb.mjs";
2
+ import { i as resolveWorkspacePackages, n as findWorkspaceRoot, r as readWorkspacePatterns, t as findPackagesWithSkills } from "./workspace-patterns-Cndd-7vB.mjs";
3
3
 
4
4
  export { findPackagesWithSkills, findWorkspaceRoot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/intent",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Ship compositional knowledge for AI coding agents alongside your npm packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,5 +0,0 @@
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,4 +0,0 @@
1
- import "./utils-COlDcU72.mjs";
2
- import { t as checkStaleness } from "./staleness-BtmJtMpz.mjs";
3
-
4
- export { checkStaleness };