@tanstack/intent 0.0.36 → 0.0.37
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/artifact-coverage-DA26utB1.mjs +3 -0
- package/dist/cli-error-BrMXlbtx.mjs +15 -0
- package/dist/cli-support-CHEYZ9xj.mjs +6 -0
- package/dist/cli-support-Dk2rgYli.mjs +114 -0
- package/dist/cli.mjs +17 -763
- package/dist/core-BlJqkv0a.mjs +497 -0
- package/dist/core.d.mts +85 -0
- package/dist/core.mjs +9 -0
- package/dist/display-COlw5FaB.mjs +5 -0
- package/dist/{display-CAof6doy.mjs → display-CVeoAwBd.mjs} +1 -1
- package/dist/edit-package-json-CzWlMXOf.mjs +8 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.mjs +11 -11
- package/dist/install-BAUG1FD8.mjs +7 -0
- package/dist/{install-2_wkomiT.mjs → install-DA19Vg17.mjs} +7 -111
- package/dist/intent-library.mjs +8 -7
- package/dist/{library-scanner-fexXlPXb.mjs → library-scanner-CHepLJQJ.mjs} +2 -2
- package/dist/library-scanner.d.mts +1 -1
- package/dist/library-scanner.mjs +3 -3
- package/dist/list-D6osUZl7.mjs +107 -0
- package/dist/load-CzvLUFur.mjs +70 -0
- package/dist/meta-CYV9EzM8.mjs +38 -0
- package/dist/{project-context-alYMNoNa.mjs → project-context-CfSZGJFC.mjs} +1 -1
- package/dist/resolver-BTeG2oyZ.mjs +196 -0
- package/dist/scaffold-D2vwv9ls.mjs +75 -0
- package/dist/scanner-DgRSm4y0.mjs +6 -0
- package/dist/{scanner-B1j-wDhj.mjs → scanner-W6797hWs.mjs} +101 -19
- package/dist/{setup-Dp-W8y0Y.mjs → setup-B-1hsdmA.mjs} +2 -2
- package/dist/setup-github-actions-emXSyGy3.mjs +8 -0
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +4 -4
- package/dist/{skill-paths-8k9K9y26.mjs → skill-paths-DNOHrvL5.mjs} +1 -1
- package/dist/stale-flPZnWfI.mjs +53 -0
- package/dist/{staleness-PdgakrCQ.mjs → staleness-CFr3W-RI.mjs} +2 -2
- package/dist/staleness-DpyuNdd5.mjs +5 -0
- package/dist/{types-DT7Y6TFz.d.mts → types-S2zpibHp.d.mts} +1 -1
- package/dist/{utils-dkVvY7D7.mjs → utils-BHzSyNeJ.mjs} +1 -1
- package/dist/validate-ugk2DZBd.mjs +271 -0
- package/dist/{workflow-review-Dz_ofcYQ.mjs → workflow-review-CIdJXmKP.mjs} +1 -1
- package/dist/{workspace-patterns-x-dLZxx4.mjs → workspace-patterns-BGQcoSy7.mjs} +2 -2
- package/dist/{workspace-patterns-BN2A_60g.mjs → workspace-patterns-CNhdqCO4.mjs} +1 -1
- package/package.json +7 -3
- package/dist/artifact-coverage-BAN2W6aH.mjs +0 -3
- package/dist/display-B3vkG99D.mjs +0 -5
- package/dist/resolver-Whd12ksO.mjs +0 -70
- package/dist/scanner-C2YjF4w_.mjs +0 -6
- package/dist/staleness-DpbmYod4.mjs +0 -5
- /package/dist/{artifact-coverage-wLNVX8yC.mjs → artifact-coverage-DgWuVqUp.mjs} +0 -0
- /package/dist/{setup-t1i2o2-h.d.mts → setup-ldoQOQot.d.mts} +0 -0
- /package/dist/{skill-use-BzuuvLM7.mjs → skill-use-umYvZl94.mjs} +0 -0
- /package/dist/{utils-COlDcU72.mjs → utils-mdb4i6VA.mjs} +0 -0
- /package/dist/{workflow-review-CwkPVIQf.mjs → workflow-review-CwcR2ge4.mjs} +0 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { o as resolveDepDir, r as getDeps, s as toPosixPath } from "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import { n as scanIntentPackageAtRoot, t as scanForIntents } from "./scanner-W6797hWs.mjs";
|
|
3
|
+
import { a as resolveWorkspacePackages } from "./workspace-patterns-CNhdqCO4.mjs";
|
|
4
|
+
import { i as parseSkillUse, n as formatSkillUse } from "./skill-use-umYvZl94.mjs";
|
|
5
|
+
import { t as resolveProjectContext } from "./project-context-CfSZGJFC.mjs";
|
|
6
|
+
import { a as compileExcludePatterns, c as warningMentionsPackage, i as resolveSkillUse, l as readPackageJson, o as getEffectiveExcludePatterns, r as resolveSkillEntry, s as isPackageExcluded, t as ResolveSkillUseError } from "./resolver-BTeG2oyZ.mjs";
|
|
7
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
8
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
//#region src/core/markdown.ts
|
|
11
|
+
function resolveFromCwd$1(path) {
|
|
12
|
+
return resolve(process.cwd(), path);
|
|
13
|
+
}
|
|
14
|
+
function splitDestinationSuffix(destination) {
|
|
15
|
+
const hashIndex = destination.indexOf("#");
|
|
16
|
+
const queryIndex = destination.indexOf("?");
|
|
17
|
+
const suffixIndex = hashIndex === -1 ? queryIndex : queryIndex === -1 ? hashIndex : Math.min(hashIndex, queryIndex);
|
|
18
|
+
if (suffixIndex === -1) return {
|
|
19
|
+
pathPart: destination,
|
|
20
|
+
suffix: ""
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
pathPart: destination.slice(0, suffixIndex),
|
|
24
|
+
suffix: destination.slice(suffixIndex)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function isExternalOrAbsoluteDestination(destination) {
|
|
28
|
+
return destination === "" || destination.startsWith("#") || destination.startsWith("?") || destination.startsWith("//") || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(destination) || isAbsolute(destination);
|
|
29
|
+
}
|
|
30
|
+
function findClosingBracket(line, start) {
|
|
31
|
+
let depth = 0;
|
|
32
|
+
for (let index = start; index < line.length; index++) {
|
|
33
|
+
const char = line[index];
|
|
34
|
+
if (char === "\\") {
|
|
35
|
+
index++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (char === "[") {
|
|
39
|
+
depth++;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === "]") {
|
|
43
|
+
depth--;
|
|
44
|
+
if (depth === 0) return index;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
function findClosingParen(line, start) {
|
|
50
|
+
for (let index = start; index < line.length; index++) {
|
|
51
|
+
const char = line[index];
|
|
52
|
+
if (char === "\\") {
|
|
53
|
+
index++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (char === ")") return index;
|
|
57
|
+
}
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
function readBareDestination(line, start) {
|
|
61
|
+
let depth = 0;
|
|
62
|
+
for (let index = start; index < line.length; index++) {
|
|
63
|
+
const char = line[index];
|
|
64
|
+
if (char === "\\") {
|
|
65
|
+
index++;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (char === "(") {
|
|
69
|
+
depth++;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (char === ")") {
|
|
73
|
+
if (depth === 0) return {
|
|
74
|
+
destinationEnd: index,
|
|
75
|
+
endParen: index
|
|
76
|
+
};
|
|
77
|
+
depth--;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (/\s/.test(char) && depth === 0) {
|
|
81
|
+
const endParen = findClosingParen(line, index);
|
|
82
|
+
if (endParen === -1) return null;
|
|
83
|
+
return {
|
|
84
|
+
destinationEnd: index,
|
|
85
|
+
endParen
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function readMarkdownDestination(line, start) {
|
|
92
|
+
let cursor = start;
|
|
93
|
+
while (cursor < line.length && /\s/.test(line[cursor])) cursor++;
|
|
94
|
+
if (line[cursor] === "<") {
|
|
95
|
+
const destinationStart = cursor + 1;
|
|
96
|
+
const destinationEnd = line.indexOf(">", destinationStart);
|
|
97
|
+
if (destinationEnd === -1) return null;
|
|
98
|
+
const endParen = findClosingParen(line, destinationEnd + 1);
|
|
99
|
+
if (endParen === -1) return null;
|
|
100
|
+
return {
|
|
101
|
+
destination: line.slice(destinationStart, destinationEnd),
|
|
102
|
+
destinationStart,
|
|
103
|
+
destinationEnd,
|
|
104
|
+
endParen
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const read = readBareDestination(line, cursor);
|
|
108
|
+
if (!read) return null;
|
|
109
|
+
return {
|
|
110
|
+
destination: line.slice(cursor, read.destinationEnd),
|
|
111
|
+
destinationStart: cursor,
|
|
112
|
+
destinationEnd: read.destinationEnd,
|
|
113
|
+
endParen: read.endParen
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function getCodeFenceMarker(line) {
|
|
117
|
+
const marker = line.match(/^\s*(`{3,}|~{3,})/)?.[1]?.[0];
|
|
118
|
+
return marker === "`" || marker === "~" ? marker : null;
|
|
119
|
+
}
|
|
120
|
+
function rewriteMarkdownDestination({ context, destination }) {
|
|
121
|
+
if (isExternalOrAbsoluteDestination(destination)) return destination;
|
|
122
|
+
const { pathPart, suffix } = splitDestinationSuffix(destination);
|
|
123
|
+
if (isExternalOrAbsoluteDestination(pathPart)) return destination;
|
|
124
|
+
const resolvedDestinationPath = resolve(context.skillDir, pathPart);
|
|
125
|
+
const relativeToPackageRoot = relative(context.resolvedPackageRoot, resolvedDestinationPath);
|
|
126
|
+
if (relativeToPackageRoot.startsWith("..") || isAbsolute(relativeToPackageRoot)) return destination;
|
|
127
|
+
const relativeToCwd = relative(context.cwd, resolvedDestinationPath);
|
|
128
|
+
return `${toPosixPath(relativeToCwd && !relativeToCwd.startsWith("..") && !isAbsolute(relativeToCwd) ? relativeToCwd : resolvedDestinationPath)}${suffix}`;
|
|
129
|
+
}
|
|
130
|
+
function rewriteMarkdownLineDestinations({ context, line }) {
|
|
131
|
+
if (!line.includes("[")) return line;
|
|
132
|
+
let output = "";
|
|
133
|
+
let cursor = 0;
|
|
134
|
+
while (cursor < line.length) {
|
|
135
|
+
const nextCodeStart = line.indexOf("`", cursor);
|
|
136
|
+
const nextLinkStart = line.indexOf("[", cursor);
|
|
137
|
+
if (nextLinkStart === -1) {
|
|
138
|
+
output += line.slice(cursor);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (nextCodeStart !== -1 && nextCodeStart < nextLinkStart) {
|
|
142
|
+
output += line.slice(cursor, nextCodeStart);
|
|
143
|
+
cursor = nextCodeStart;
|
|
144
|
+
const codeStart = cursor;
|
|
145
|
+
while (cursor < line.length && line[cursor] === "`") cursor++;
|
|
146
|
+
const marker = line.slice(codeStart, cursor);
|
|
147
|
+
const codeEnd = line.indexOf(marker, cursor);
|
|
148
|
+
if (codeEnd === -1) {
|
|
149
|
+
output += line.slice(codeStart);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
output += line.slice(codeStart, codeEnd + marker.length);
|
|
153
|
+
cursor = codeEnd + marker.length;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const linkStart = nextLinkStart > 0 && line[nextLinkStart - 1] === "!" ? nextLinkStart - 1 : nextLinkStart;
|
|
157
|
+
output += line.slice(cursor, linkStart);
|
|
158
|
+
const labelEnd = findClosingBracket(line, nextLinkStart);
|
|
159
|
+
if (labelEnd === -1) {
|
|
160
|
+
output += line.slice(linkStart);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (line[labelEnd + 1] !== "(") {
|
|
164
|
+
output += line.slice(linkStart, nextLinkStart + 1);
|
|
165
|
+
cursor = nextLinkStart + 1;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const destination = readMarkdownDestination(line, labelEnd + 2);
|
|
169
|
+
if (!destination) {
|
|
170
|
+
output += line.slice(linkStart, nextLinkStart + 1);
|
|
171
|
+
cursor = nextLinkStart + 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const rewritten = rewriteMarkdownDestination({
|
|
175
|
+
context,
|
|
176
|
+
destination: destination.destination
|
|
177
|
+
});
|
|
178
|
+
output += line.slice(linkStart, destination.destinationStart) + rewritten + line.slice(destination.destinationEnd, destination.endParen + 1);
|
|
179
|
+
cursor = destination.endParen + 1;
|
|
180
|
+
}
|
|
181
|
+
return output;
|
|
182
|
+
}
|
|
183
|
+
function rewriteLoadedSkillMarkdownDestinations({ content, cwd, packageRoot, skillFilePath }) {
|
|
184
|
+
const context = {
|
|
185
|
+
cwd,
|
|
186
|
+
resolvedPackageRoot: resolveFromCwd$1(packageRoot),
|
|
187
|
+
skillDir: dirname(skillFilePath)
|
|
188
|
+
};
|
|
189
|
+
let inFence = null;
|
|
190
|
+
const parts = content.split(/(\r?\n)/);
|
|
191
|
+
let output = "";
|
|
192
|
+
for (let index = 0; index < parts.length; index += 2) {
|
|
193
|
+
const line = parts[index] ?? "";
|
|
194
|
+
const newline = parts[index + 1] ?? "";
|
|
195
|
+
const marker = getCodeFenceMarker(line);
|
|
196
|
+
if (inFence) {
|
|
197
|
+
output += line + newline;
|
|
198
|
+
if (marker === inFence) inFence = null;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (marker) {
|
|
202
|
+
inFence = marker;
|
|
203
|
+
output += line + newline;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
output += rewriteMarkdownLineDestinations({
|
|
207
|
+
context,
|
|
208
|
+
line
|
|
209
|
+
}) + newline;
|
|
210
|
+
}
|
|
211
|
+
return output;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/core/load-resolution.ts
|
|
216
|
+
function readWorkspacePackageInfos(context) {
|
|
217
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
218
|
+
if (context.packageRoot) dirs.add(context.packageRoot);
|
|
219
|
+
if (context.workspaceRoot) {
|
|
220
|
+
dirs.add(context.workspaceRoot);
|
|
221
|
+
for (const dir of resolveWorkspacePackages(context.workspaceRoot, context.workspacePatterns)) dirs.add(dir);
|
|
222
|
+
}
|
|
223
|
+
return [...dirs].flatMap((dir) => {
|
|
224
|
+
const packageJson = readPackageJson(dir);
|
|
225
|
+
if (!packageJson) return [];
|
|
226
|
+
return [{
|
|
227
|
+
dir,
|
|
228
|
+
name: typeof packageJson.name === "string" ? packageJson.name : null,
|
|
229
|
+
packageJson
|
|
230
|
+
}];
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function addCandidateDir(candidates, seen, dir) {
|
|
234
|
+
if (!dir) return;
|
|
235
|
+
const key = resolve(dir);
|
|
236
|
+
if (seen.has(key)) return;
|
|
237
|
+
seen.add(key);
|
|
238
|
+
candidates.push(dir);
|
|
239
|
+
}
|
|
240
|
+
function findVisibleDependencyDir(packageName, fromDir) {
|
|
241
|
+
let dir = fromDir;
|
|
242
|
+
while (true) {
|
|
243
|
+
const candidate = join(dir, "node_modules", packageName);
|
|
244
|
+
if (existsSync(join(candidate, "package.json"))) return candidate;
|
|
245
|
+
const next = dirname(dir);
|
|
246
|
+
if (next === dir) return null;
|
|
247
|
+
dir = next;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function resolveDependencyPackageDir(packageName, fromDir) {
|
|
251
|
+
return findVisibleDependencyDir(packageName, fromDir) ?? resolveDepDir(packageName, fromDir);
|
|
252
|
+
}
|
|
253
|
+
function workspacePackageDeclaresDependency(packageJson, packageName) {
|
|
254
|
+
return getDeps(packageJson).includes(packageName);
|
|
255
|
+
}
|
|
256
|
+
function hasYarnPnpFile(dir) {
|
|
257
|
+
return dir !== null && (existsSync(join(dir, ".pnp.cjs")) || existsSync(join(dir, ".pnp.js")));
|
|
258
|
+
}
|
|
259
|
+
function shouldSkipFastPathForYarnPnp(context, cwd) {
|
|
260
|
+
return hasYarnPnpFile(cwd) || hasYarnPnpFile(context.workspaceRoot);
|
|
261
|
+
}
|
|
262
|
+
function getDirectLoadFastPathCandidateDirs(packageName, context, cwd) {
|
|
263
|
+
const candidates = [];
|
|
264
|
+
const seen = /* @__PURE__ */ new Set();
|
|
265
|
+
if (!context.workspaceRoot) {
|
|
266
|
+
addCandidateDir(candidates, seen, resolveDependencyPackageDir(packageName, context.packageRoot ?? cwd));
|
|
267
|
+
return candidates;
|
|
268
|
+
}
|
|
269
|
+
addCandidateDir(candidates, seen, resolveDependencyPackageDir(packageName, context.packageRoot ?? context.workspaceRoot ?? cwd));
|
|
270
|
+
if (context.workspaceRoot && context.workspaceRoot !== context.packageRoot) addCandidateDir(candidates, seen, resolveDependencyPackageDir(packageName, context.workspaceRoot));
|
|
271
|
+
return candidates;
|
|
272
|
+
}
|
|
273
|
+
function getWorkspaceLoadFastPathCandidateDirs(packageName, context) {
|
|
274
|
+
const candidates = [];
|
|
275
|
+
const seen = /* @__PURE__ */ new Set();
|
|
276
|
+
const workspacePackages = readWorkspacePackageInfos(context);
|
|
277
|
+
for (const pkg of workspacePackages) if (pkg.name === packageName) addCandidateDir(candidates, seen, pkg.dir);
|
|
278
|
+
for (const pkg of workspacePackages) {
|
|
279
|
+
if (!workspacePackageDeclaresDependency(pkg.packageJson, packageName)) continue;
|
|
280
|
+
addCandidateDir(candidates, seen, resolveDependencyPackageDir(packageName, pkg.dir));
|
|
281
|
+
}
|
|
282
|
+
return candidates;
|
|
283
|
+
}
|
|
284
|
+
function resolveScannedPackageSkill(scanned, parsedUse) {
|
|
285
|
+
const pkg = scanned.package;
|
|
286
|
+
if (!pkg || pkg.name !== parsedUse.packageName) return null;
|
|
287
|
+
const skill = resolveSkillEntry(pkg.name, parsedUse.skillName, pkg.skills).skill;
|
|
288
|
+
if (!skill) return null;
|
|
289
|
+
return {
|
|
290
|
+
packageName: pkg.name,
|
|
291
|
+
skillName: skill.name,
|
|
292
|
+
path: skill.path,
|
|
293
|
+
source: pkg.source,
|
|
294
|
+
version: pkg.version,
|
|
295
|
+
packageRoot: pkg.packageRoot,
|
|
296
|
+
warnings: scanned.warnings.filter((warning) => warningMentionsPackage(warning, pkg.name)),
|
|
297
|
+
conflict: null
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function resolveFromPackageRoots(packageRoots, parsedUse, cwd) {
|
|
301
|
+
for (const packageRoot of packageRoots) {
|
|
302
|
+
const scanned = scanIntentPackageAtRoot(packageRoot, {
|
|
303
|
+
fallbackName: parsedUse.packageName,
|
|
304
|
+
projectRoot: cwd,
|
|
305
|
+
skillNameHint: parsedUse.skillName
|
|
306
|
+
});
|
|
307
|
+
const directResolved = resolveScannedPackageSkill(scanned, parsedUse);
|
|
308
|
+
if (directResolved) return directResolved;
|
|
309
|
+
if (scanned.package?.name === parsedUse.packageName) {
|
|
310
|
+
const fallbackResolved = resolveScannedPackageSkill(scanIntentPackageAtRoot(packageRoot, {
|
|
311
|
+
fallbackName: parsedUse.packageName,
|
|
312
|
+
projectRoot: cwd
|
|
313
|
+
}), parsedUse);
|
|
314
|
+
if (fallbackResolved) return fallbackResolved;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
function resolveSkillUseFastPath(parsedUse, options, context = resolveProjectContext({ cwd: process.cwd() }), cwd = context.cwd) {
|
|
320
|
+
if (options.globalOnly) return null;
|
|
321
|
+
if (shouldSkipFastPathForYarnPnp(context, cwd)) return null;
|
|
322
|
+
const directResolved = resolveFromPackageRoots(getDirectLoadFastPathCandidateDirs(parsedUse.packageName, context, cwd), parsedUse, cwd);
|
|
323
|
+
if (directResolved) return directResolved;
|
|
324
|
+
if (!context.workspaceRoot) return null;
|
|
325
|
+
return resolveFromPackageRoots(getWorkspaceLoadFastPathCandidateDirs(parsedUse.packageName, context), parsedUse, cwd);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/core.ts
|
|
330
|
+
var IntentCoreError = class extends Error {
|
|
331
|
+
constructor(code, message, options = {}) {
|
|
332
|
+
super(message);
|
|
333
|
+
this.name = "IntentCoreError";
|
|
334
|
+
this.code = code;
|
|
335
|
+
if (options.suggestedSkills) this.suggestedSkills = options.suggestedSkills;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
function toScanOptions(options) {
|
|
339
|
+
if (options.global && options.globalOnly) throw new IntentCoreError("invalid-options", "Use either global or globalOnly, not both.");
|
|
340
|
+
if (options.globalOnly) return { scope: "global" };
|
|
341
|
+
if (options.global) return { scope: "local-and-global" };
|
|
342
|
+
return { scope: "local" };
|
|
343
|
+
}
|
|
344
|
+
function getScanScope(options) {
|
|
345
|
+
return options.scope ?? (options.includeGlobal ? "local-and-global" : "local");
|
|
346
|
+
}
|
|
347
|
+
function resolveCoreCwd(options) {
|
|
348
|
+
return resolve(process.cwd(), options.cwd ?? process.cwd());
|
|
349
|
+
}
|
|
350
|
+
function listIntentSkills(options = {}) {
|
|
351
|
+
const cwd = resolveCoreCwd(options);
|
|
352
|
+
const scanOptions = toScanOptions(options);
|
|
353
|
+
const projectContext = resolveProjectContext({ cwd });
|
|
354
|
+
const scanResult = scanForIntents(cwd, scanOptions);
|
|
355
|
+
const excludePatterns = getEffectiveExcludePatterns(options, projectContext);
|
|
356
|
+
const excludeMatchers = compileExcludePatterns(excludePatterns);
|
|
357
|
+
const excludedPackages = scanResult.packages.filter((pkg) => isPackageExcluded(pkg.name, excludeMatchers)).map((pkg) => pkg.name);
|
|
358
|
+
const packages = scanResult.packages.filter((pkg) => !isPackageExcluded(pkg.name, excludeMatchers));
|
|
359
|
+
const result = {
|
|
360
|
+
skills: packages.flatMap((pkg) => pkg.skills.map((skill) => {
|
|
361
|
+
return {
|
|
362
|
+
use: formatSkillUse(pkg.name, skill.name),
|
|
363
|
+
packageName: pkg.name,
|
|
364
|
+
packageRoot: pkg.packageRoot,
|
|
365
|
+
packageVersion: pkg.version,
|
|
366
|
+
packageSource: pkg.source,
|
|
367
|
+
skillName: skill.name,
|
|
368
|
+
description: skill.description,
|
|
369
|
+
type: skill.type,
|
|
370
|
+
framework: skill.framework
|
|
371
|
+
};
|
|
372
|
+
})),
|
|
373
|
+
packages: packages.map((pkg) => ({
|
|
374
|
+
name: pkg.name,
|
|
375
|
+
version: pkg.version,
|
|
376
|
+
source: pkg.source,
|
|
377
|
+
packageRoot: pkg.packageRoot,
|
|
378
|
+
skillCount: pkg.skills.length
|
|
379
|
+
})),
|
|
380
|
+
warnings: scanResult.warnings.filter((warning) => !excludedPackages.some((packageName) => warningMentionsPackage(warning, packageName))),
|
|
381
|
+
conflicts: scanResult.conflicts.filter((conflict) => !isPackageExcluded(conflict.packageName, excludeMatchers))
|
|
382
|
+
};
|
|
383
|
+
if (options.debug) result.debug = {
|
|
384
|
+
cwd,
|
|
385
|
+
scope: getScanScope(scanOptions),
|
|
386
|
+
excludes: excludePatterns,
|
|
387
|
+
packageCount: result.packages.length,
|
|
388
|
+
skillCount: result.skills.length,
|
|
389
|
+
warningCount: result.warnings.length,
|
|
390
|
+
conflictCount: result.conflicts.length
|
|
391
|
+
};
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
function resolveFromCwd(cwd, path) {
|
|
395
|
+
return resolve(cwd, path);
|
|
396
|
+
}
|
|
397
|
+
function isResolvedPathInsidePackageRoot(path, packageRoot) {
|
|
398
|
+
const relativePath = relative(packageRoot, path);
|
|
399
|
+
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
|
400
|
+
}
|
|
401
|
+
function toResolvedIntentSkill(cwd, use, resolved, debug) {
|
|
402
|
+
let realResolvedPath;
|
|
403
|
+
try {
|
|
404
|
+
realResolvedPath = realpathSync.native(resolveFromCwd(cwd, resolved.path));
|
|
405
|
+
} catch {
|
|
406
|
+
throw new IntentCoreError("skill-file-not-found", `Resolved skill file was not found: ${resolved.path}`);
|
|
407
|
+
}
|
|
408
|
+
const realPackageRoot = realpathSync.native(resolveFromCwd(cwd, resolved.packageRoot));
|
|
409
|
+
if (!isResolvedPathInsidePackageRoot(realResolvedPath, realPackageRoot)) throw new IntentCoreError("skill-path-outside-package", `Resolved skill path for "${use}" is outside package root: ${resolved.path}`);
|
|
410
|
+
const result = {
|
|
411
|
+
path: resolved.path,
|
|
412
|
+
packageRoot: resolved.packageRoot,
|
|
413
|
+
packageName: resolved.packageName,
|
|
414
|
+
skillName: resolved.skillName,
|
|
415
|
+
version: resolved.version,
|
|
416
|
+
source: resolved.source,
|
|
417
|
+
warnings: resolved.warnings,
|
|
418
|
+
conflict: resolved.conflict
|
|
419
|
+
};
|
|
420
|
+
if (debug) result.debug = debug;
|
|
421
|
+
return {
|
|
422
|
+
realPackageRoot,
|
|
423
|
+
realResolvedPath,
|
|
424
|
+
result
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function createLoadedSkillDebug({ cwd, excludes, resolution, resolved, scope }) {
|
|
428
|
+
return {
|
|
429
|
+
cwd,
|
|
430
|
+
scope,
|
|
431
|
+
resolution,
|
|
432
|
+
excludes,
|
|
433
|
+
packageName: resolved.packageName,
|
|
434
|
+
skillName: resolved.skillName,
|
|
435
|
+
version: resolved.version,
|
|
436
|
+
source: resolved.source,
|
|
437
|
+
path: resolved.path,
|
|
438
|
+
warningCount: resolved.warnings.length
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function resolveIntentSkillInCwd(cwd, use, options = {}) {
|
|
442
|
+
let parsedUse;
|
|
443
|
+
try {
|
|
444
|
+
parsedUse = parseSkillUse(use);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
throw new IntentCoreError("invalid-skill-use", err instanceof Error ? err.message : String(err));
|
|
447
|
+
}
|
|
448
|
+
const projectContext = resolveProjectContext({ cwd });
|
|
449
|
+
const excludePatterns = getEffectiveExcludePatterns(options, projectContext);
|
|
450
|
+
const excludeMatchers = compileExcludePatterns(excludePatterns);
|
|
451
|
+
if (isPackageExcluded(parsedUse.packageName, excludeMatchers)) throw new IntentCoreError("package-excluded", `Cannot load skill use "${use}": package "${parsedUse.packageName}" is excluded by Intent configuration.`);
|
|
452
|
+
const scanOptions = toScanOptions(options);
|
|
453
|
+
const scope = getScanScope(scanOptions);
|
|
454
|
+
const fastPathResolved = resolveSkillUseFastPath(parsedUse, options, projectContext, cwd);
|
|
455
|
+
if (fastPathResolved) return toResolvedIntentSkill(cwd, use, fastPathResolved, options.debug ? createLoadedSkillDebug({
|
|
456
|
+
cwd,
|
|
457
|
+
excludes: excludePatterns,
|
|
458
|
+
resolution: "fast-path",
|
|
459
|
+
resolved: fastPathResolved,
|
|
460
|
+
scope
|
|
461
|
+
}) : void 0);
|
|
462
|
+
const scanResult = scanForIntents(cwd, scanOptions);
|
|
463
|
+
let resolved;
|
|
464
|
+
try {
|
|
465
|
+
resolved = resolveSkillUse(use, scanResult);
|
|
466
|
+
} catch (err) {
|
|
467
|
+
if (err instanceof ResolveSkillUseError) throw new IntentCoreError(err.code, err.message, { suggestedSkills: err.suggestedSkills });
|
|
468
|
+
throw err;
|
|
469
|
+
}
|
|
470
|
+
return toResolvedIntentSkill(cwd, use, resolved, options.debug ? createLoadedSkillDebug({
|
|
471
|
+
cwd,
|
|
472
|
+
excludes: excludePatterns,
|
|
473
|
+
resolution: "full-scan",
|
|
474
|
+
resolved,
|
|
475
|
+
scope
|
|
476
|
+
}) : void 0);
|
|
477
|
+
}
|
|
478
|
+
function resolveIntentSkill(use, options = {}) {
|
|
479
|
+
return resolveIntentSkillInCwd(resolveCoreCwd(options), use, options).result;
|
|
480
|
+
}
|
|
481
|
+
function loadIntentSkill(use, options = {}) {
|
|
482
|
+
const cwd = resolveCoreCwd(options);
|
|
483
|
+
const resolved = resolveIntentSkillInCwd(cwd, use, options);
|
|
484
|
+
const content = rewriteLoadedSkillMarkdownDestinations({
|
|
485
|
+
content: readFileSync(resolved.realResolvedPath, "utf8"),
|
|
486
|
+
cwd,
|
|
487
|
+
packageRoot: resolved.realPackageRoot,
|
|
488
|
+
skillFilePath: resolved.realResolvedPath
|
|
489
|
+
});
|
|
490
|
+
return {
|
|
491
|
+
...resolved.result,
|
|
492
|
+
content
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
//#endregion
|
|
497
|
+
export { resolveIntentSkill as i, listIntentSkills as n, loadIntentSkill as r, IntentCoreError as t };
|
package/dist/core.d.mts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { b as VersionConflict, h as ScanScope, l as IntentPackage } from "./types-S2zpibHp.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/types.d.ts
|
|
4
|
+
interface IntentCoreOptions {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
global?: boolean;
|
|
8
|
+
globalOnly?: boolean;
|
|
9
|
+
exclude?: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
interface IntentSkillSummary {
|
|
12
|
+
use: string;
|
|
13
|
+
packageName: string;
|
|
14
|
+
packageRoot: string;
|
|
15
|
+
packageVersion: string;
|
|
16
|
+
packageSource: IntentPackage['source'];
|
|
17
|
+
skillName: string;
|
|
18
|
+
description: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
framework?: string;
|
|
21
|
+
}
|
|
22
|
+
interface IntentPackageSummary {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
source: IntentPackage['source'];
|
|
26
|
+
packageRoot: string;
|
|
27
|
+
skillCount: number;
|
|
28
|
+
}
|
|
29
|
+
interface IntentSkillList {
|
|
30
|
+
skills: Array<IntentSkillSummary>;
|
|
31
|
+
packages: Array<IntentPackageSummary>;
|
|
32
|
+
warnings: Array<string>;
|
|
33
|
+
conflicts: Array<VersionConflict>;
|
|
34
|
+
debug?: IntentSkillListDebug;
|
|
35
|
+
}
|
|
36
|
+
interface ResolvedIntentSkill {
|
|
37
|
+
path: string;
|
|
38
|
+
packageRoot: string;
|
|
39
|
+
packageName: string;
|
|
40
|
+
skillName: string;
|
|
41
|
+
version: string;
|
|
42
|
+
source: IntentPackage['source'];
|
|
43
|
+
warnings: Array<string>;
|
|
44
|
+
conflict: VersionConflict | null;
|
|
45
|
+
debug?: LoadedIntentSkillDebug;
|
|
46
|
+
}
|
|
47
|
+
interface LoadedIntentSkill extends ResolvedIntentSkill {
|
|
48
|
+
content: string;
|
|
49
|
+
}
|
|
50
|
+
interface IntentSkillListDebug {
|
|
51
|
+
cwd: string;
|
|
52
|
+
scope: ScanScope;
|
|
53
|
+
excludes: Array<string>;
|
|
54
|
+
packageCount: number;
|
|
55
|
+
skillCount: number;
|
|
56
|
+
warningCount: number;
|
|
57
|
+
conflictCount: number;
|
|
58
|
+
}
|
|
59
|
+
interface LoadedIntentSkillDebug {
|
|
60
|
+
cwd: string;
|
|
61
|
+
scope: ScanScope;
|
|
62
|
+
resolution: 'fast-path' | 'full-scan';
|
|
63
|
+
excludes: Array<string>;
|
|
64
|
+
packageName: string;
|
|
65
|
+
skillName: string;
|
|
66
|
+
version: string;
|
|
67
|
+
source: IntentPackage['source'];
|
|
68
|
+
path: string;
|
|
69
|
+
warningCount: number;
|
|
70
|
+
}
|
|
71
|
+
type IntentCoreErrorCode = 'invalid-options' | 'invalid-skill-use' | 'package-not-found' | 'package-excluded' | 'skill-not-found' | 'skill-path-outside-package' | 'skill-file-not-found';
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/core.d.ts
|
|
74
|
+
declare class IntentCoreError extends Error {
|
|
75
|
+
readonly code: IntentCoreErrorCode;
|
|
76
|
+
readonly suggestedSkills?: Array<string>;
|
|
77
|
+
constructor(code: IntentCoreErrorCode, message: string, options?: {
|
|
78
|
+
suggestedSkills?: Array<string>;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
declare function listIntentSkills(options?: IntentCoreOptions): IntentSkillList;
|
|
82
|
+
declare function resolveIntentSkill(use: string, options?: IntentCoreOptions): ResolvedIntentSkill;
|
|
83
|
+
declare function loadIntentSkill(use: string, options?: IntentCoreOptions): LoadedIntentSkill;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { IntentCoreError, type IntentCoreErrorCode, type IntentCoreOptions, type IntentPackageSummary, type IntentSkillList, type IntentSkillListDebug, type IntentSkillSummary, type LoadedIntentSkill, type LoadedIntentSkillDebug, type ResolvedIntentSkill, listIntentSkills, loadIntentSkill, resolveIntentSkill };
|
package/dist/core.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import "./skill-paths-DNOHrvL5.mjs";
|
|
3
|
+
import "./scanner-W6797hWs.mjs";
|
|
4
|
+
import "./workspace-patterns-CNhdqCO4.mjs";
|
|
5
|
+
import "./project-context-CfSZGJFC.mjs";
|
|
6
|
+
import "./resolver-BTeG2oyZ.mjs";
|
|
7
|
+
import { i as resolveIntentSkill, n as listIntentSkills, r as loadIntentSkill, t as IntentCoreError } from "./core-BlJqkv0a.mjs";
|
|
8
|
+
|
|
9
|
+
export { IntentCoreError, listIntentSkills, loadIntentSkill, resolveIntentSkill };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isStableLoadPath, t as formatRuntimeSkillLookupHint } from "./skill-paths-
|
|
1
|
+
import { n as isStableLoadPath, t as formatRuntimeSkillLookupHint } from "./skill-paths-DNOHrvL5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/display.ts
|
|
4
4
|
function padColumn(text, width) {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { i as runEditPackageJson, o as runSetupGithubActions, r as SetupGithubActionsResult, t as EditPackageJsonResult } from "./setup-
|
|
1
|
+
import { _ as SkillStaleness, a as IntentArtifactSet, b as VersionConflict, c as IntentConfig, d as MetaFeedbackPayload, f as MetaSkillName, g as SkillEntry, i as IntentArtifactFile, l as IntentPackage, m as ScanResult, n as FeedbackPayload, o as IntentArtifactSkill, p as ScanOptions, r as IntentArtifactCoverageIgnore, s as IntentArtifactWarning, t as AgentName, u as IntentProjectConfig, v as StalenessReport, y as StalenessSignal } from "./types-S2zpibHp.mjs";
|
|
2
|
+
import { i as runEditPackageJson, o as runSetupGithubActions, r as SetupGithubActionsResult, t as EditPackageJsonResult } from "./setup-ldoQOQot.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/scanner.d.ts
|
|
5
5
|
declare function scanForIntents(root?: string, options?: ScanOptions): ScanResult;
|
|
@@ -107,12 +107,14 @@ declare class ResolveSkillUseError extends Error {
|
|
|
107
107
|
readonly skillName: string;
|
|
108
108
|
readonly availablePackages: Array<string>;
|
|
109
109
|
readonly availableSkills: Array<string>;
|
|
110
|
+
readonly suggestedSkills: Array<string>;
|
|
110
111
|
constructor({
|
|
111
112
|
availablePackages,
|
|
112
113
|
availableSkills,
|
|
113
114
|
code,
|
|
114
115
|
packageName,
|
|
115
116
|
skillName,
|
|
117
|
+
suggestedSkills,
|
|
116
118
|
use
|
|
117
119
|
}: {
|
|
118
120
|
availablePackages?: Array<string>;
|
|
@@ -120,6 +122,7 @@ declare class ResolveSkillUseError extends Error {
|
|
|
120
122
|
code: ResolveSkillUseErrorCode;
|
|
121
123
|
packageName: string;
|
|
122
124
|
skillName: string;
|
|
125
|
+
suggestedSkills?: Array<string>;
|
|
123
126
|
use: string;
|
|
124
127
|
});
|
|
125
128
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as parseFrontmatter, n as findSkillFiles, o as resolveDepDir, r as getDeps } from "./utils-
|
|
2
|
-
import "./skill-paths-
|
|
3
|
-
import { t as scanForIntents } from "./scanner-
|
|
4
|
-
import "./workspace-patterns-
|
|
5
|
-
import { t as readIntentArtifacts } from "./artifact-coverage-
|
|
6
|
-
import { n as checkStaleness } from "./staleness-
|
|
7
|
-
import { n as collectStaleReviewItems, r as createFailedStaleReviewItem, t as buildStaleReviewBody } from "./workflow-review-
|
|
8
|
-
import { i as parseSkillUse, n as formatSkillUse, r as isSkillUseParseError, t as SkillUseParseError } from "./skill-use-
|
|
9
|
-
import
|
|
10
|
-
import "./
|
|
11
|
-
import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-
|
|
1
|
+
import { a as parseFrontmatter, n as findSkillFiles, o as resolveDepDir, r as getDeps } from "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import "./skill-paths-DNOHrvL5.mjs";
|
|
3
|
+
import { t as scanForIntents } from "./scanner-W6797hWs.mjs";
|
|
4
|
+
import "./workspace-patterns-CNhdqCO4.mjs";
|
|
5
|
+
import { t as readIntentArtifacts } from "./artifact-coverage-DgWuVqUp.mjs";
|
|
6
|
+
import { n as checkStaleness } from "./staleness-CFr3W-RI.mjs";
|
|
7
|
+
import { n as collectStaleReviewItems, r as createFailedStaleReviewItem, t as buildStaleReviewBody } from "./workflow-review-CwcR2ge4.mjs";
|
|
8
|
+
import { i as parseSkillUse, n as formatSkillUse, r as isSkillUseParseError, t as SkillUseParseError } from "./skill-use-umYvZl94.mjs";
|
|
9
|
+
import "./project-context-CfSZGJFC.mjs";
|
|
10
|
+
import { i as resolveSkillUse, n as isResolveSkillUseError, t as ResolveSkillUseError } from "./resolver-BTeG2oyZ.mjs";
|
|
11
|
+
import { r as runSetupGithubActions, t as runEditPackageJson } from "./setup-B-1hsdmA.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";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import "./workspace-patterns-CNhdqCO4.mjs";
|
|
3
|
+
import "./project-context-CfSZGJFC.mjs";
|
|
4
|
+
import "./cli-support-Dk2rgYli.mjs";
|
|
5
|
+
import { n as runInstallCommand, t as INSTALL_PROMPT } from "./install-DA19Vg17.mjs";
|
|
6
|
+
|
|
7
|
+
export { INSTALL_PROMPT, runInstallCommand };
|