@tanstack/intent 0.0.36 → 0.0.38

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 (54) hide show
  1. package/dist/artifact-coverage-DA26utB1.mjs +3 -0
  2. package/dist/cli-error-BrMXlbtx.mjs +15 -0
  3. package/dist/cli-support-BON5hn4L.mjs +114 -0
  4. package/dist/cli-support-BlSsqyx7.mjs +6 -0
  5. package/dist/cli.mjs +17 -763
  6. package/dist/core-baYs6H7Z.mjs +497 -0
  7. package/dist/core.d.mts +85 -0
  8. package/dist/core.mjs +9 -0
  9. package/dist/display-COlw5FaB.mjs +5 -0
  10. package/dist/{display-CAof6doy.mjs → display-CVeoAwBd.mjs} +1 -1
  11. package/dist/edit-package-json-CzWlMXOf.mjs +8 -0
  12. package/dist/index.d.mts +5 -2
  13. package/dist/index.mjs +11 -11
  14. package/dist/{install-2_wkomiT.mjs → install-BPWtaOuo.mjs} +7 -111
  15. package/dist/install-RZpz279M.mjs +7 -0
  16. package/dist/intent-library.mjs +8 -7
  17. package/dist/{library-scanner-fexXlPXb.mjs → library-scanner-CHepLJQJ.mjs} +2 -2
  18. package/dist/library-scanner.d.mts +1 -1
  19. package/dist/library-scanner.mjs +3 -3
  20. package/dist/list-iLIL-EO3.mjs +107 -0
  21. package/dist/load-8868G50-.mjs +70 -0
  22. package/dist/meta-CYV9EzM8.mjs +38 -0
  23. package/dist/{project-context-alYMNoNa.mjs → project-context-Dx6XIJJo.mjs} +1 -1
  24. package/dist/resolver-CP0S8UjZ.mjs +196 -0
  25. package/dist/scaffold-D2vwv9ls.mjs +75 -0
  26. package/dist/scanner-ByG70-E3.mjs +6 -0
  27. package/dist/{scanner-B1j-wDhj.mjs → scanner-DwYsjXzI.mjs} +101 -19
  28. package/dist/{setup-t1i2o2-h.d.mts → setup-2SE9zYJk.d.mts} +1 -0
  29. package/dist/setup-github-actions-emXSyGy3.mjs +8 -0
  30. package/dist/{setup-Dp-W8y0Y.mjs → setup-kvWN4xCr.mjs} +2 -2
  31. package/dist/setup.d.mts +1 -1
  32. package/dist/setup.mjs +4 -4
  33. package/dist/{skill-paths-8k9K9y26.mjs → skill-paths-DNOHrvL5.mjs} +1 -1
  34. package/dist/stale-flPZnWfI.mjs +53 -0
  35. package/dist/{staleness-PdgakrCQ.mjs → staleness-CFr3W-RI.mjs} +2 -2
  36. package/dist/staleness-DpyuNdd5.mjs +5 -0
  37. package/dist/{types-DT7Y6TFz.d.mts → types-S2zpibHp.d.mts} +1 -1
  38. package/dist/{utils-dkVvY7D7.mjs → utils-BHzSyNeJ.mjs} +1 -1
  39. package/dist/validate-BL1SYAwh.mjs +271 -0
  40. package/dist/{workflow-review-Dz_ofcYQ.mjs → workflow-review-CIdJXmKP.mjs} +1 -1
  41. package/dist/workspace-patterns-BWMz7TsI.mjs +4 -0
  42. package/dist/workspace-patterns-BZLEaMcS.mjs +195 -0
  43. package/package.json +9 -4
  44. package/dist/artifact-coverage-BAN2W6aH.mjs +0 -3
  45. package/dist/display-B3vkG99D.mjs +0 -5
  46. package/dist/resolver-Whd12ksO.mjs +0 -70
  47. package/dist/scanner-C2YjF4w_.mjs +0 -6
  48. package/dist/staleness-DpbmYod4.mjs +0 -5
  49. package/dist/workspace-patterns-BN2A_60g.mjs +0 -172
  50. package/dist/workspace-patterns-x-dLZxx4.mjs +0 -4
  51. /package/dist/{artifact-coverage-wLNVX8yC.mjs → artifact-coverage-DgWuVqUp.mjs} +0 -0
  52. /package/dist/{skill-use-BzuuvLM7.mjs → skill-use-umYvZl94.mjs} +0 -0
  53. /package/dist/{utils-COlDcU72.mjs → utils-mdb4i6VA.mjs} +0 -0
  54. /package/dist/{workflow-review-CwkPVIQf.mjs → workflow-review-CwcR2ge4.mjs} +0 -0
@@ -0,0 +1,195 @@
1
+ import { n as findSkillFiles } from "./utils-mdb4i6VA.mjs";
2
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { parse } from "yaml";
5
+ import { parse as parse$1 } from "jsonc-parser";
6
+
7
+ //#region src/workspace-patterns.ts
8
+ function normalizeWorkspacePattern(pattern) {
9
+ return pattern.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
10
+ }
11
+ function normalizeWorkspacePatterns(patterns) {
12
+ return [...new Set(patterns.map(normalizeWorkspacePattern).filter(Boolean))].sort((a, b) => a.localeCompare(b));
13
+ }
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ function parseWorkspacePatternList(value, fieldName) {
18
+ if (value === void 0 || value === null) return null;
19
+ if (!Array.isArray(value)) throw new TypeError(`${fieldName} must be an array of strings`);
20
+ if (value.some((pattern) => typeof pattern !== "string")) throw new TypeError(`${fieldName} must be an array of strings`);
21
+ return normalizeWorkspacePatterns(value);
22
+ }
23
+ function parseWorkspacePatternField(value, fieldName, nestedKey) {
24
+ if (value === void 0 || value === null) return null;
25
+ if (Array.isArray(value)) return parseWorkspacePatternList(value, fieldName);
26
+ if (isRecord(value)) return parseWorkspacePatternList(value[nestedKey], `${fieldName}.${nestedKey}`);
27
+ throw new TypeError(`${fieldName} must be an array of strings or an object with ${nestedKey}`);
28
+ }
29
+ function hasWorkspaceManifest(dir) {
30
+ return existsSync(join(dir, "package.json")) || existsSync(join(dir, "deno.json")) || existsSync(join(dir, "deno.jsonc"));
31
+ }
32
+ function readYamlFile(path) {
33
+ return parse(readFileSync(path, "utf8"));
34
+ }
35
+ function readJsonFile(path) {
36
+ return JSON.parse(readFileSync(path, "utf8"));
37
+ }
38
+ function readJsoncFile(path) {
39
+ const errors = [];
40
+ const value = parse$1(readFileSync(path, "utf8"), errors, { allowTrailingComma: true });
41
+ if (errors.length > 0) throw new SyntaxError(errors.map((error) => `JSONC parse error ${error.error} at offset ${error.offset}`).join("; "));
42
+ return value;
43
+ }
44
+ function warnConfigError(path, err) {
45
+ const verb = err instanceof SyntaxError ? "parse" : "read";
46
+ console.error(`Warning: failed to ${verb} ${path}: ${err instanceof Error ? err.message : err}`);
47
+ }
48
+ const workspacePatternSources = [
49
+ {
50
+ fileName: "pnpm-workspace.yaml",
51
+ read: readYamlFile,
52
+ getPatterns: (config) => parseWorkspacePatternList(isRecord(config) ? config.packages : void 0, "pnpm-workspace.yaml#packages")
53
+ },
54
+ {
55
+ fileName: "package.json",
56
+ read: readJsonFile,
57
+ getPatterns: (config) => parseWorkspacePatternField(isRecord(config) ? config.workspaces : void 0, "package.json#workspaces", "packages")
58
+ },
59
+ {
60
+ fileName: "deno.json",
61
+ read: readJsoncFile,
62
+ getPatterns: (config) => parseWorkspacePatternField(isRecord(config) ? config.workspace : void 0, "deno.json#workspace", "members")
63
+ },
64
+ {
65
+ fileName: "deno.jsonc",
66
+ read: readJsoncFile,
67
+ getPatterns: (config) => parseWorkspacePatternField(isRecord(config) ? config.workspace : void 0, "deno.jsonc#workspace", "members")
68
+ }
69
+ ];
70
+ const workspacePatternsCache = /* @__PURE__ */ new Map();
71
+ const workspaceRootCache = /* @__PURE__ */ new Map();
72
+ const workspacePackageDirsCache = /* @__PURE__ */ new Map();
73
+ const workspaceInfoCache = /* @__PURE__ */ new Map();
74
+ function readWorkspacePatterns(root) {
75
+ if (workspacePatternsCache.has(root)) return workspacePatternsCache.get(root) ?? null;
76
+ const patterns = readWorkspacePatternsUncached(root);
77
+ workspacePatternsCache.set(root, patterns);
78
+ return patterns;
79
+ }
80
+ function readWorkspacePatternsUncached(root) {
81
+ for (const source of workspacePatternSources) {
82
+ const path = join(root, source.fileName);
83
+ if (!existsSync(path)) continue;
84
+ try {
85
+ const patterns = source.getPatterns(source.read(path));
86
+ if (patterns) return patterns;
87
+ } catch (err) {
88
+ warnConfigError(path, err);
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+ function readWorkspacePackageDirs(root) {
94
+ if (workspacePackageDirsCache.has(root)) return workspacePackageDirsCache.get(root) ?? null;
95
+ const patterns = readWorkspacePatterns(root);
96
+ if (!patterns) {
97
+ workspacePackageDirsCache.set(root, null);
98
+ return null;
99
+ }
100
+ const packageDirs = resolveWorkspacePackages(root, patterns);
101
+ workspacePackageDirsCache.set(root, packageDirs);
102
+ return packageDirs;
103
+ }
104
+ function getWorkspaceInfo(root) {
105
+ if (workspaceInfoCache.has(root)) return workspaceInfoCache.get(root) ?? null;
106
+ const patterns = readWorkspacePatterns(root);
107
+ if (!patterns) {
108
+ workspaceInfoCache.set(root, null);
109
+ return null;
110
+ }
111
+ const packageDirs = readWorkspacePackageDirs(root) ?? [];
112
+ const info = {
113
+ root,
114
+ patterns,
115
+ packageDirs,
116
+ packageDirsWithSkills: packageDirs.filter((dir) => {
117
+ const skillsDir = join(dir, "skills");
118
+ return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
119
+ })
120
+ };
121
+ workspaceInfoCache.set(root, info);
122
+ return info;
123
+ }
124
+ function resolveWorkspacePackages(root, patterns) {
125
+ const includedDirs = /* @__PURE__ */ new Set();
126
+ const excludedDirs = /* @__PURE__ */ new Set();
127
+ for (const pattern of normalizeWorkspacePatterns(patterns)) {
128
+ if (pattern.startsWith("!")) {
129
+ resolveWorkspacePatternSegments(root, pattern.slice(1).split("/"), excludedDirs);
130
+ continue;
131
+ }
132
+ resolveWorkspacePatternSegments(root, pattern.split("/"), includedDirs);
133
+ }
134
+ return [...includedDirs].filter((dir) => !excludedDirs.has(dir)).sort((a, b) => a.localeCompare(b));
135
+ }
136
+ /** Recursively matches path segments: `*` matches one level, `**` matches zero or more levels. */
137
+ function resolveWorkspacePatternSegments(dir, segments, result) {
138
+ if (segments.length === 0) {
139
+ if (hasWorkspaceManifest(dir)) result.add(dir);
140
+ return;
141
+ }
142
+ const segment = segments[0];
143
+ const remainingSegments = segments.slice(1);
144
+ if (segment === "**") {
145
+ resolveWorkspacePatternSegments(dir, remainingSegments, result);
146
+ for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, segments, result);
147
+ return;
148
+ }
149
+ if (segment === "*") {
150
+ for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, remainingSegments, result);
151
+ return;
152
+ }
153
+ const nextDir = join(dir, segment);
154
+ if (!existsSync(nextDir)) return;
155
+ resolveWorkspacePatternSegments(nextDir, remainingSegments, result);
156
+ }
157
+ function readChildDirectories(dir) {
158
+ try {
159
+ return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")).map((entry) => join(dir, entry.name));
160
+ } catch (err) {
161
+ console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
162
+ return [];
163
+ }
164
+ }
165
+ function findWorkspaceRoot(start) {
166
+ let dir = start;
167
+ const visited = [];
168
+ while (true) {
169
+ const cached = workspaceRootCache.get(dir);
170
+ if (cached !== void 0) {
171
+ for (const visitedDir of visited) workspaceRootCache.set(visitedDir, cached);
172
+ return cached;
173
+ }
174
+ visited.push(dir);
175
+ if (readWorkspacePatterns(dir)) {
176
+ for (const visitedDir of visited) workspaceRootCache.set(visitedDir, dir);
177
+ return dir;
178
+ }
179
+ const next = dirname(dir);
180
+ if (next === dir) {
181
+ for (const visitedDir of visited) workspaceRootCache.set(visitedDir, null);
182
+ return null;
183
+ }
184
+ dir = next;
185
+ }
186
+ }
187
+ function findPackagesWithSkills(root) {
188
+ return getWorkspaceInfo(root)?.packageDirsWithSkills ?? [];
189
+ }
190
+ function findWorkspacePackages(root) {
191
+ return readWorkspacePackageDirs(root) ?? [];
192
+ }
193
+
194
+ //#endregion
195
+ export { readWorkspacePatterns as a, getWorkspaceInfo as i, findWorkspacePackages as n, resolveWorkspacePackages as o, findWorkspaceRoot as r, findPackagesWithSkills as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/intent",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "description": "Ship compositional knowledge for AI coding agents alongside your npm packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,6 +16,10 @@
16
16
  "./intent-library": {
17
17
  "import": "./dist/intent-library.mjs",
18
18
  "types": "./dist/intent-library.d.mts"
19
+ },
20
+ "./core": {
21
+ "import": "./dist/core.mjs",
22
+ "types": "./dist/core.d.mts"
19
23
  }
20
24
  },
21
25
  "bin": {
@@ -28,7 +32,8 @@
28
32
  ],
29
33
  "dependencies": {
30
34
  "cac": "^6.7.14",
31
- "yaml": "^2.7.0"
35
+ "jsonc-parser": "^3.3.1",
36
+ "yaml": "2.8.3"
32
37
  },
33
38
  "devDependencies": {
34
39
  "@verdaccio/node-api": "6.0.0-6-next.76",
@@ -36,8 +41,8 @@
36
41
  "verdaccio": "^6.3.2"
37
42
  },
38
43
  "scripts": {
39
- "build": "tsdown src/index.ts src/cli.ts src/setup.ts src/intent-library.ts src/library-scanner.ts --format esm --dts",
40
- "test:smoke": "pnpm run build && node dist/cli.mjs --help > /dev/null",
44
+ "build": "tsdown src/index.ts src/cli.ts src/setup.ts src/intent-library.ts src/library-scanner.ts src/core.ts --format esm --dts",
45
+ "test:smoke": "pnpm run build && node dist/cli.mjs --help > /dev/null && node dist/cli.mjs load --help > /dev/null",
41
46
  "test:lib": "vitest run --exclude 'tests/integration/**'",
42
47
  "test:integration": "vitest run tests/integration/",
43
48
  "test:types": "tsc --noEmit"
@@ -1,3 +0,0 @@
1
- import { t as readIntentArtifacts } from "./artifact-coverage-wLNVX8yC.mjs";
2
-
3
- export { readIntentArtifacts };
@@ -1,5 +0,0 @@
1
- import "./utils-COlDcU72.mjs";
2
- import "./skill-paths-8k9K9y26.mjs";
3
- import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-CAof6doy.mjs";
4
-
5
- export { computeSkillNameWidth, printSkillTree, printTable };
@@ -1,70 +0,0 @@
1
- import { i as parseSkillUse } from "./skill-use-BzuuvLM7.mjs";
2
-
3
- //#region src/resolver.ts
4
- var ResolveSkillUseError = class extends Error {
5
- constructor({ availablePackages = [], availableSkills = [], code, packageName, skillName, use }) {
6
- super(formatResolveSkillUseErrorMessage({
7
- availablePackages,
8
- availableSkills,
9
- code,
10
- packageName,
11
- skillName,
12
- use
13
- }));
14
- this.name = "ResolveSkillUseError";
15
- this.availablePackages = availablePackages;
16
- this.availableSkills = availableSkills;
17
- this.code = code;
18
- this.packageName = packageName;
19
- this.skillName = skillName;
20
- this.use = use;
21
- }
22
- };
23
- function isResolveSkillUseError(error) {
24
- return error instanceof ResolveSkillUseError;
25
- }
26
- function resolveSkillUse(use, scanResult) {
27
- const { packageName, skillName } = parseSkillUse(use);
28
- const packages = scanResult.packages.filter((pkg$1) => pkg$1.name === packageName);
29
- const pkg = packages.find((candidate) => candidate.source === "local") ?? packages[0];
30
- if (!pkg) throw new ResolveSkillUseError({
31
- availablePackages: scanResult.packages.map((candidate) => candidate.name),
32
- code: "package-not-found",
33
- packageName,
34
- skillName,
35
- use
36
- });
37
- const skill = pkg.skills.find((candidate) => candidate.name === skillName);
38
- if (!skill) throw new ResolveSkillUseError({
39
- availableSkills: pkg.skills.map((candidate) => candidate.name),
40
- code: "skill-not-found",
41
- packageName,
42
- skillName,
43
- use
44
- });
45
- const conflict = scanResult.conflicts.find((candidate) => candidate.packageName === packageName) ?? null;
46
- return {
47
- packageName,
48
- skillName,
49
- path: skill.path,
50
- source: pkg.source,
51
- version: pkg.version,
52
- packageRoot: pkg.packageRoot,
53
- warnings: scanResult.warnings.filter((warning) => {
54
- const idx = warning.indexOf(packageName);
55
- if (idx === -1) return false;
56
- const after = warning[idx + packageName.length];
57
- return after === void 0 || /[^a-zA-Z0-9_-]/.test(after);
58
- }),
59
- conflict
60
- };
61
- }
62
- function formatResolveSkillUseErrorMessage({ availablePackages, availableSkills, code, packageName, skillName, use }) {
63
- switch (code) {
64
- case "package-not-found": return `Cannot resolve skill use "${use}": package "${packageName}" was not found.${availablePackages.length > 0 ? ` Available packages: ${availablePackages.join(", ")}.` : ""}`;
65
- case "skill-not-found": return `Cannot resolve skill use "${use}": skill "${skillName}" was not found in package "${packageName}".${availableSkills.length > 0 ? ` Available skills: ${availableSkills.join(", ")}.` : ""}`;
66
- }
67
- }
68
-
69
- //#endregion
70
- export { isResolveSkillUseError as n, resolveSkillUse as r, ResolveSkillUseError as t };
@@ -1,6 +0,0 @@
1
- import "./utils-COlDcU72.mjs";
2
- import "./skill-paths-8k9K9y26.mjs";
3
- import { t as scanForIntents } from "./scanner-B1j-wDhj.mjs";
4
- import "./workspace-patterns-BN2A_60g.mjs";
5
-
6
- export { scanForIntents };
@@ -1,5 +0,0 @@
1
- import "./utils-COlDcU72.mjs";
2
- import "./artifact-coverage-wLNVX8yC.mjs";
3
- import { n as checkStaleness, r as readPackageName, t as buildWorkspaceCoverageSignals } from "./staleness-PdgakrCQ.mjs";
4
-
5
- export { buildWorkspaceCoverageSignals, checkStaleness, readPackageName };
@@ -1,172 +0,0 @@
1
- import { n as findSkillFiles } from "./utils-COlDcU72.mjs";
2
- import { existsSync, readFileSync, readdirSync } from "node:fs";
3
- import { dirname, join } from "node:path";
4
- import { parse } from "yaml";
5
-
6
- //#region src/workspace-patterns.ts
7
- function normalizeWorkspacePattern(pattern) {
8
- return pattern.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
9
- }
10
- function normalizeWorkspacePatterns(patterns) {
11
- return [...new Set(patterns.map(normalizeWorkspacePattern).filter(Boolean))].sort((a, b) => a.localeCompare(b));
12
- }
13
- function parseWorkspacePatterns(value) {
14
- if (!Array.isArray(value)) return null;
15
- return normalizeWorkspacePatterns(value.filter((pattern) => typeof pattern === "string"));
16
- }
17
- function hasPackageJson(dir) {
18
- return existsSync(join(dir, "package.json"));
19
- }
20
- function stripJsonCommentsAndTrailingCommas(source) {
21
- let result = "";
22
- let inString = false;
23
- let escaped = false;
24
- for (let index = 0; index < source.length; index += 1) {
25
- const char = source[index];
26
- const next = source[index + 1];
27
- if (inString) {
28
- result += char;
29
- if (escaped) escaped = false;
30
- else if (char === "\\") escaped = true;
31
- else if (char === "\"") inString = false;
32
- continue;
33
- }
34
- if (char === "\"") {
35
- inString = true;
36
- result += char;
37
- continue;
38
- }
39
- if (char === "/" && next === "/") {
40
- while (index < source.length && source[index] !== "\n") index += 1;
41
- if (index < source.length) result += source[index];
42
- continue;
43
- }
44
- if (char === "/" && next === "*") {
45
- const commentStart = index;
46
- index += 2;
47
- while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
48
- if (index >= source.length) throw new SyntaxError(`Unterminated block comment starting at position ${commentStart}`);
49
- index += 1;
50
- continue;
51
- }
52
- if (char === ",") {
53
- let lookahead = index + 1;
54
- while (lookahead < source.length) {
55
- const la = source[lookahead];
56
- if (/\s/.test(la)) lookahead += 1;
57
- else if (la === "/" && source[lookahead + 1] === "/") {
58
- lookahead += 2;
59
- while (lookahead < source.length && source[lookahead] !== "\n") lookahead += 1;
60
- } else if (la === "/" && source[lookahead + 1] === "*") {
61
- lookahead += 2;
62
- while (lookahead < source.length && !(source[lookahead] === "*" && source[lookahead + 1] === "/")) lookahead += 1;
63
- lookahead += 2;
64
- } else break;
65
- }
66
- if (source[lookahead] === "}" || source[lookahead] === "]") continue;
67
- }
68
- result += char;
69
- }
70
- return result;
71
- }
72
- function readJsonFile(path, jsonc = false) {
73
- const source = readFileSync(path, "utf8");
74
- return JSON.parse(jsonc ? stripJsonCommentsAndTrailingCommas(source) : source);
75
- }
76
- function readWorkspacePatterns(root) {
77
- const pnpmWs = join(root, "pnpm-workspace.yaml");
78
- if (existsSync(pnpmWs)) try {
79
- const patterns = parseWorkspacePatterns(parse(readFileSync(pnpmWs, "utf8")).packages);
80
- if (patterns) return patterns;
81
- } catch (err) {
82
- const verb = err instanceof SyntaxError ? "parse" : "read";
83
- console.error(`Warning: failed to ${verb} ${pnpmWs}: ${err instanceof Error ? err.message : err}`);
84
- }
85
- const pkgPath = join(root, "package.json");
86
- if (existsSync(pkgPath)) try {
87
- const workspaces = readJsonFile(pkgPath).workspaces;
88
- const patterns = parseWorkspacePatterns(workspaces) ?? parseWorkspacePatterns(workspaces?.packages);
89
- if (patterns) return patterns;
90
- } catch (err) {
91
- const verb = err instanceof SyntaxError ? "parse" : "read";
92
- console.error(`Warning: failed to ${verb} ${pkgPath}: ${err instanceof Error ? err.message : err}`);
93
- }
94
- for (const denoConfigName of ["deno.json", "deno.jsonc"]) {
95
- const denoConfigPath = join(root, denoConfigName);
96
- if (!existsSync(denoConfigPath)) continue;
97
- try {
98
- const patterns = parseWorkspacePatterns(readJsonFile(denoConfigPath, true).workspace);
99
- if (patterns) return patterns;
100
- } catch (err) {
101
- const verb = err instanceof SyntaxError ? "parse" : "read";
102
- console.error(`Warning: failed to ${verb} ${denoConfigPath}: ${err instanceof Error ? err.message : err}`);
103
- }
104
- }
105
- return null;
106
- }
107
- function resolveWorkspacePackages(root, patterns) {
108
- const includedDirs = /* @__PURE__ */ new Set();
109
- const excludedDirs = /* @__PURE__ */ new Set();
110
- for (const pattern of normalizeWorkspacePatterns(patterns)) {
111
- if (pattern.startsWith("!")) {
112
- resolveWorkspacePatternSegments(root, pattern.slice(1).split("/"), excludedDirs);
113
- continue;
114
- }
115
- resolveWorkspacePatternSegments(root, pattern.split("/"), includedDirs);
116
- }
117
- return [...includedDirs].filter((dir) => !excludedDirs.has(dir)).sort((a, b) => a.localeCompare(b));
118
- }
119
- /** Recursively matches path segments: `*` matches one level, `**` matches zero or more levels. */
120
- function resolveWorkspacePatternSegments(dir, segments, result) {
121
- if (segments.length === 0) {
122
- if (hasPackageJson(dir)) result.add(dir);
123
- return;
124
- }
125
- const segment = segments[0];
126
- const remainingSegments = segments.slice(1);
127
- if (segment === "**") {
128
- resolveWorkspacePatternSegments(dir, remainingSegments, result);
129
- for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, segments, result);
130
- return;
131
- }
132
- if (segment === "*") {
133
- for (const childDir of readChildDirectories(dir)) resolveWorkspacePatternSegments(childDir, remainingSegments, result);
134
- return;
135
- }
136
- const nextDir = join(dir, segment);
137
- if (!existsSync(nextDir)) return;
138
- resolveWorkspacePatternSegments(nextDir, remainingSegments, result);
139
- }
140
- function readChildDirectories(dir) {
141
- try {
142
- return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")).map((entry) => join(dir, entry.name));
143
- } catch (err) {
144
- console.error(`Warning: could not read directory ${dir}: ${err instanceof Error ? err.message : err}`);
145
- return [];
146
- }
147
- }
148
- function findWorkspaceRoot(start) {
149
- let dir = start;
150
- while (true) {
151
- if (readWorkspacePatterns(dir)) return dir;
152
- const next = dirname(dir);
153
- if (next === dir) return null;
154
- dir = next;
155
- }
156
- }
157
- function findPackagesWithSkills(root) {
158
- const patterns = readWorkspacePatterns(root);
159
- if (!patterns) return [];
160
- return resolveWorkspacePackages(root, patterns).filter((dir) => {
161
- const skillsDir = join(dir, "skills");
162
- return existsSync(skillsDir) && findSkillFiles(skillsDir).length > 0;
163
- });
164
- }
165
- function findWorkspacePackages(root) {
166
- const patterns = readWorkspacePatterns(root);
167
- if (!patterns) return [];
168
- return resolveWorkspacePackages(root, patterns);
169
- }
170
-
171
- //#endregion
172
- export { resolveWorkspacePackages as a, readWorkspacePatterns as i, findWorkspacePackages as n, findWorkspaceRoot as r, findPackagesWithSkills as t };
@@ -1,4 +0,0 @@
1
- import "./utils-COlDcU72.mjs";
2
- import { a as resolveWorkspacePackages, i as readWorkspacePatterns, n as findWorkspacePackages, r as findWorkspaceRoot, t as findPackagesWithSkills } from "./workspace-patterns-BN2A_60g.mjs";
3
-
4
- export { findPackagesWithSkills, findWorkspacePackages, findWorkspaceRoot };
File without changes