@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
|
@@ -1,114 +1,10 @@
|
|
|
1
|
-
import { i as parseSkillUse, n as formatSkillUse } from "./skill-use-
|
|
2
|
-
import { t as
|
|
1
|
+
import { i as parseSkillUse, n as formatSkillUse } from "./skill-use-umYvZl94.mjs";
|
|
2
|
+
import { t as fail } from "./cli-error-BrMXlbtx.mjs";
|
|
3
|
+
import { c as scanOptionsFromGlobalFlags, l as printWarnings } from "./cli-support-Dk2rgYli.mjs";
|
|
3
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join, relative
|
|
5
|
+
import { dirname, join, relative } from "node:path";
|
|
5
6
|
import { parse } from "yaml";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
|
-
//#region src/cli-error.ts
|
|
9
|
-
const CLI_FAILURE = Symbol("CliFailure");
|
|
10
|
-
function fail(message, exitCode = 1) {
|
|
11
|
-
throw {
|
|
12
|
-
[CLI_FAILURE]: true,
|
|
13
|
-
message,
|
|
14
|
-
exitCode
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function isCliFailure(value) {
|
|
18
|
-
return !!value && typeof value === "object" && CLI_FAILURE in value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/cli-output.ts
|
|
23
|
-
function printWarnings(warnings) {
|
|
24
|
-
if (warnings.length === 0) return;
|
|
25
|
-
console.log("Warnings:");
|
|
26
|
-
for (const warning of warnings) console.log(` ⚠ ${warning}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/cli-support.ts
|
|
31
|
-
const INTENT_CHECK_SKILLS_WORKFLOW_VERSION = 3;
|
|
32
|
-
function getMetaDir() {
|
|
33
|
-
return join(dirname(fileURLToPath(import.meta.url)), "..", "meta");
|
|
34
|
-
}
|
|
35
|
-
function getCheckSkillsWorkflowAdvisories(root) {
|
|
36
|
-
const workflowPath = join(root, ".github", "workflows", "check-skills.yml");
|
|
37
|
-
if (!existsSync(workflowPath)) return [];
|
|
38
|
-
let content;
|
|
39
|
-
try {
|
|
40
|
-
content = readFileSync(workflowPath, "utf8");
|
|
41
|
-
} catch {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
const versionMatch = content.match(/intent-workflow-version:\s*(\d+)/);
|
|
45
|
-
if ((versionMatch ? Number(versionMatch[1]) : 0) >= INTENT_CHECK_SKILLS_WORKFLOW_VERSION) return [];
|
|
46
|
-
return [`Intent workflow update available: run \`npx @tanstack/intent@latest setup\` to refresh ${relative(process.cwd(), workflowPath) || workflowPath}.`];
|
|
47
|
-
}
|
|
48
|
-
async function scanIntentsOrFail(options) {
|
|
49
|
-
const { scanForIntents } = await import("./scanner-C2YjF4w_.mjs");
|
|
50
|
-
try {
|
|
51
|
-
return scanForIntents(void 0, options);
|
|
52
|
-
} catch (err) {
|
|
53
|
-
fail(err instanceof Error ? err.message : String(err));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function scanOptionsFromGlobalFlags(options) {
|
|
57
|
-
if (options.global && options.globalOnly) fail("Use either --global or --global-only, not both.");
|
|
58
|
-
if (options.globalOnly) return { scope: "global" };
|
|
59
|
-
if (options.global) return { scope: "local-and-global" };
|
|
60
|
-
return { scope: "local" };
|
|
61
|
-
}
|
|
62
|
-
async function resolveStaleTargets(targetDir) {
|
|
63
|
-
const resolvedRoot = targetDir ? resolve(process.cwd(), targetDir) : process.cwd();
|
|
64
|
-
const context = resolveProjectContext({
|
|
65
|
-
cwd: process.cwd(),
|
|
66
|
-
targetPath: targetDir
|
|
67
|
-
});
|
|
68
|
-
const workflowAdvisories = getCheckSkillsWorkflowAdvisories(context.workspaceRoot ?? context.packageRoot ?? resolvedRoot);
|
|
69
|
-
const { buildWorkspaceCoverageSignals, checkStaleness, readPackageName } = await import("./staleness-DpbmYod4.mjs");
|
|
70
|
-
const isWorkspaceRootTarget = context.workspaceRoot !== null && resolvedRoot === context.workspaceRoot;
|
|
71
|
-
if (context.packageRoot && !isWorkspaceRootTarget && (context.targetSkillsDir !== null || context.workspaceRoot === null)) return {
|
|
72
|
-
reports: [await checkStaleness(context.packageRoot, readPackageName(context.packageRoot), context.workspaceRoot ?? context.packageRoot)],
|
|
73
|
-
workflowAdvisories
|
|
74
|
-
};
|
|
75
|
-
const { findPackagesWithSkills, findWorkspacePackages, findWorkspaceRoot } = await import("./workspace-patterns-x-dLZxx4.mjs");
|
|
76
|
-
const workspaceRoot = findWorkspaceRoot(resolvedRoot);
|
|
77
|
-
if (workspaceRoot) {
|
|
78
|
-
const packageDirsWithSkills = findPackagesWithSkills(workspaceRoot);
|
|
79
|
-
const allPackageDirs = findWorkspacePackages(workspaceRoot);
|
|
80
|
-
const reports = await Promise.all(packageDirsWithSkills.map((packageDir) => checkStaleness(packageDir, readPackageName(packageDir), workspaceRoot)));
|
|
81
|
-
const { readIntentArtifacts } = await import("./artifact-coverage-BAN2W6aH.mjs");
|
|
82
|
-
const coverageSignals = buildWorkspaceCoverageSignals({
|
|
83
|
-
artifactRoot: workspaceRoot,
|
|
84
|
-
artifacts: existsSync(join(workspaceRoot, "_artifacts")) ? readIntentArtifacts(workspaceRoot) : null,
|
|
85
|
-
packageDirs: allPackageDirs
|
|
86
|
-
});
|
|
87
|
-
if (coverageSignals.length > 0) reports.push({
|
|
88
|
-
library: relative(process.cwd(), workspaceRoot) || "workspace",
|
|
89
|
-
currentVersion: null,
|
|
90
|
-
skillVersion: null,
|
|
91
|
-
versionDrift: null,
|
|
92
|
-
skills: [],
|
|
93
|
-
signals: coverageSignals
|
|
94
|
-
});
|
|
95
|
-
if (reports.length > 0) return {
|
|
96
|
-
reports,
|
|
97
|
-
workflowAdvisories
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
if (existsSync(join(resolvedRoot, "skills"))) return {
|
|
101
|
-
reports: [await checkStaleness(resolvedRoot, readPackageName(resolvedRoot))],
|
|
102
|
-
workflowAdvisories
|
|
103
|
-
};
|
|
104
|
-
const staleResult = await scanIntentsOrFail();
|
|
105
|
-
return {
|
|
106
|
-
reports: await Promise.all(staleResult.packages.map((pkg) => checkStaleness(pkg.packageRoot, pkg.name))),
|
|
107
|
-
workflowAdvisories
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
8
|
//#region src/commands/install-writer.ts
|
|
113
9
|
const INTENT_SKILLS_START = "<!-- intent-skills:start -->";
|
|
114
10
|
const INTENT_SKILLS_END = "<!-- intent-skills:end -->";
|
|
@@ -475,7 +371,7 @@ function printWriteResult({ mappingCount, status, targetPath }) {
|
|
|
475
371
|
break;
|
|
476
372
|
}
|
|
477
373
|
}
|
|
478
|
-
async function runInstallCommand(options, scanIntentsOrFail
|
|
374
|
+
async function runInstallCommand(options, scanIntentsOrFail) {
|
|
479
375
|
if (options.printPrompt) {
|
|
480
376
|
console.log(INSTALL_PROMPT);
|
|
481
377
|
return;
|
|
@@ -505,7 +401,7 @@ async function runInstallCommand(options, scanIntentsOrFail$1) {
|
|
|
505
401
|
printPlacementTip(result$1.targetPath);
|
|
506
402
|
return;
|
|
507
403
|
}
|
|
508
|
-
const scanResult = await scanIntentsOrFail
|
|
404
|
+
const scanResult = await scanIntentsOrFail(scanOptionsFromGlobalFlags(options));
|
|
509
405
|
const generated = buildIntentSkillsBlock(scanResult);
|
|
510
406
|
if (options.dryRun) {
|
|
511
407
|
const targetPath = resolveIntentSkillsBlockTargetPath(process.cwd(), generated.mappingCount);
|
|
@@ -539,4 +435,4 @@ async function runInstallCommand(options, scanIntentsOrFail$1) {
|
|
|
539
435
|
}
|
|
540
436
|
|
|
541
437
|
//#endregion
|
|
542
|
-
export {
|
|
438
|
+
export { runInstallCommand as n, INSTALL_PROMPT as t };
|
package/dist/intent-library.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./utils-
|
|
3
|
-
import "./skill-paths-
|
|
4
|
-
import "./workspace-patterns-
|
|
5
|
-
import "./project-context-
|
|
6
|
-
import { t as
|
|
7
|
-
import
|
|
8
|
-
import { t as
|
|
2
|
+
import "./utils-mdb4i6VA.mjs";
|
|
3
|
+
import "./skill-paths-DNOHrvL5.mjs";
|
|
4
|
+
import "./workspace-patterns-CNhdqCO4.mjs";
|
|
5
|
+
import "./project-context-CfSZGJFC.mjs";
|
|
6
|
+
import { n as printSkillTree, r as printTable, t as computeSkillNameWidth } from "./display-CVeoAwBd.mjs";
|
|
7
|
+
import "./cli-support-Dk2rgYli.mjs";
|
|
8
|
+
import { t as INSTALL_PROMPT } from "./install-DA19Vg17.mjs";
|
|
9
|
+
import { t as scanLibrary } from "./library-scanner-CHepLJQJ.mjs";
|
|
9
10
|
|
|
10
11
|
//#region src/intent-library.ts
|
|
11
12
|
function cmdList() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as parseFrontmatter, o as resolveDepDir, r as getDeps, s as toPosixPath } from "./utils-
|
|
2
|
-
import { r as rewriteSkillLoadPaths } from "./skill-paths-
|
|
1
|
+
import { a as parseFrontmatter, o as resolveDepDir, r as getDeps, s as toPosixPath } from "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import { r as rewriteSkillLoadPaths } from "./skill-paths-DNOHrvL5.mjs";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative } from "node:path";
|
|
5
5
|
|
package/dist/library-scanner.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./utils-
|
|
2
|
-
import "./skill-paths-
|
|
3
|
-
import { t as scanLibrary } from "./library-scanner-
|
|
1
|
+
import "./utils-mdb4i6VA.mjs";
|
|
2
|
+
import "./skill-paths-DNOHrvL5.mjs";
|
|
3
|
+
import { t as scanLibrary } from "./library-scanner-CHepLJQJ.mjs";
|
|
4
4
|
|
|
5
5
|
export { scanLibrary };
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { a as printDebugInfo, l as printWarnings, n as coreOptionsFromGlobalFlags } from "./cli-support-Dk2rgYli.mjs";
|
|
8
|
+
import { n as listIntentSkills } from "./core-BlJqkv0a.mjs";
|
|
9
|
+
|
|
10
|
+
//#region src/commands/list.ts
|
|
11
|
+
function printListDebug(result) {
|
|
12
|
+
if (!result.debug) return;
|
|
13
|
+
printDebugInfo("intent list", [
|
|
14
|
+
["cwd", result.debug.cwd],
|
|
15
|
+
["scope", result.debug.scope],
|
|
16
|
+
["excludes", result.debug.excludes],
|
|
17
|
+
["packages", result.debug.packageCount],
|
|
18
|
+
["skills", result.debug.skillCount],
|
|
19
|
+
["warnings", result.debug.warningCount],
|
|
20
|
+
["conflicts", result.debug.conflictCount]
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
function printVersionConflicts(result) {
|
|
24
|
+
if (result.conflicts.length === 0) return;
|
|
25
|
+
console.log("\nVersion conflicts:\n");
|
|
26
|
+
for (const conflict of result.conflicts) {
|
|
27
|
+
console.log(` ${conflict.packageName} -> using ${conflict.chosen.version}`);
|
|
28
|
+
console.log(` chosen: ${conflict.chosen.packageRoot}`);
|
|
29
|
+
for (const variant of conflict.variants) {
|
|
30
|
+
if (variant.packageRoot === conflict.chosen.packageRoot) continue;
|
|
31
|
+
console.log(` also found: ${variant.version} at ${variant.packageRoot}`);
|
|
32
|
+
}
|
|
33
|
+
console.log();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function groupSkillsByPackageRoot(skills) {
|
|
37
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const skill of skills) {
|
|
39
|
+
const packageSkills = grouped.get(skill.packageRoot);
|
|
40
|
+
if (packageSkills) packageSkills.push(skill);
|
|
41
|
+
else grouped.set(skill.packageRoot, [skill]);
|
|
42
|
+
}
|
|
43
|
+
return grouped;
|
|
44
|
+
}
|
|
45
|
+
function getPackageSkills(pkg, skillsByPackageRoot) {
|
|
46
|
+
return skillsByPackageRoot.get(pkg.packageRoot) ?? [];
|
|
47
|
+
}
|
|
48
|
+
async function runListCommand(options, _scanIntentsOrFail) {
|
|
49
|
+
const result = listIntentSkills(coreOptionsFromGlobalFlags(options));
|
|
50
|
+
printListDebug(result);
|
|
51
|
+
if (options.json) {
|
|
52
|
+
const { debug: _debug, ...jsonResult } = result;
|
|
53
|
+
console.log(JSON.stringify(jsonResult, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { computeSkillNameWidth, printSkillTree, printTable } = await import("./display-COlw5FaB.mjs");
|
|
57
|
+
if (result.packages.length === 0) {
|
|
58
|
+
console.log("No intent-enabled packages found.");
|
|
59
|
+
if (result.warnings.length > 0) {
|
|
60
|
+
console.log();
|
|
61
|
+
printWarnings(result.warnings);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
console.log(`\n${result.packages.length} intent-enabled packages, ${result.skills.length} skills\n`);
|
|
66
|
+
printTable([
|
|
67
|
+
"PACKAGE",
|
|
68
|
+
"SOURCE",
|
|
69
|
+
"VERSION",
|
|
70
|
+
"SKILLS"
|
|
71
|
+
], result.packages.map((pkg) => [
|
|
72
|
+
pkg.name,
|
|
73
|
+
pkg.source,
|
|
74
|
+
pkg.version,
|
|
75
|
+
String(pkg.skillCount)
|
|
76
|
+
]));
|
|
77
|
+
printVersionConflicts(result);
|
|
78
|
+
const skillsByPackageRoot = groupSkillsByPackageRoot(result.skills);
|
|
79
|
+
const nameWidth = computeSkillNameWidth(result.packages.map((pkg) => getPackageSkills(pkg, skillsByPackageRoot).map((skill) => ({
|
|
80
|
+
name: skill.skillName,
|
|
81
|
+
description: skill.description,
|
|
82
|
+
type: skill.type
|
|
83
|
+
}))));
|
|
84
|
+
const showTypes = result.skills.some((skill) => skill.type);
|
|
85
|
+
console.log(`\nSkills:\n`);
|
|
86
|
+
for (const pkg of result.packages) {
|
|
87
|
+
console.log(` ${pkg.name}`);
|
|
88
|
+
printSkillTree(getPackageSkills(pkg, skillsByPackageRoot).map((skill) => ({
|
|
89
|
+
name: skill.skillName,
|
|
90
|
+
description: skill.description,
|
|
91
|
+
type: skill.type
|
|
92
|
+
})), {
|
|
93
|
+
nameWidth,
|
|
94
|
+
packageName: pkg.name,
|
|
95
|
+
showTypes
|
|
96
|
+
});
|
|
97
|
+
console.log();
|
|
98
|
+
}
|
|
99
|
+
console.log("Feedback:");
|
|
100
|
+
console.log(" Submit feedback on skill usage to help maintainers improve the skills.");
|
|
101
|
+
console.log(" Load: node_modules/@tanstack/intent/meta/feedback-collection/SKILL.md");
|
|
102
|
+
console.log();
|
|
103
|
+
printWarnings(result.warnings);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
export { runListCommand };
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { t as fail } from "./cli-error-BrMXlbtx.mjs";
|
|
8
|
+
import { a as printDebugInfo, n as coreOptionsFromGlobalFlags } from "./cli-support-Dk2rgYli.mjs";
|
|
9
|
+
import { i as resolveIntentSkill, r as loadIntentSkill, t as IntentCoreError } from "./core-BlJqkv0a.mjs";
|
|
10
|
+
|
|
11
|
+
//#region src/commands/load.ts
|
|
12
|
+
function printLoadDebug(loaded) {
|
|
13
|
+
if (!loaded.debug) return;
|
|
14
|
+
printDebugInfo("intent load", [
|
|
15
|
+
["cwd", loaded.debug.cwd],
|
|
16
|
+
["scope", loaded.debug.scope],
|
|
17
|
+
["resolution", loaded.debug.resolution],
|
|
18
|
+
["excludes", loaded.debug.excludes],
|
|
19
|
+
["package", loaded.debug.packageName],
|
|
20
|
+
["version", loaded.debug.version],
|
|
21
|
+
["source", loaded.debug.source],
|
|
22
|
+
["skill", loaded.debug.skillName],
|
|
23
|
+
["path", loaded.debug.path],
|
|
24
|
+
["warnings", loaded.debug.warningCount]
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
async function runLoadCommand(use, options, _scanIntentsOrFail) {
|
|
28
|
+
if (!use) fail("Missing skill use. Expected: intent load <package>#<skill>");
|
|
29
|
+
if (options.json && options.path) fail("Use either --json or --path, not both.");
|
|
30
|
+
const coreOptions = coreOptionsFromGlobalFlags(options);
|
|
31
|
+
if (options.path) {
|
|
32
|
+
let resolved;
|
|
33
|
+
try {
|
|
34
|
+
resolved = resolveIntentSkill(use, coreOptions);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
if (err instanceof IntentCoreError) fail(err.message);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
printLoadDebug(resolved);
|
|
40
|
+
console.log(resolved.path);
|
|
41
|
+
for (const warning of resolved.warnings) console.error(`Warning: ${warning}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let loaded;
|
|
45
|
+
try {
|
|
46
|
+
loaded = loadIntentSkill(use, coreOptions);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (err instanceof IntentCoreError) fail(err.message);
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
printLoadDebug(loaded);
|
|
52
|
+
if (options.json) {
|
|
53
|
+
console.log(JSON.stringify({
|
|
54
|
+
package: loaded.packageName,
|
|
55
|
+
skill: loaded.skillName,
|
|
56
|
+
path: loaded.path,
|
|
57
|
+
packageRoot: loaded.packageRoot,
|
|
58
|
+
source: loaded.source,
|
|
59
|
+
version: loaded.version,
|
|
60
|
+
content: loaded.content,
|
|
61
|
+
warnings: loaded.warnings
|
|
62
|
+
}, null, 2));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
process.stdout.write(loaded.content);
|
|
66
|
+
for (const warning of loaded.warnings) console.error(`Warning: ${warning}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { runLoadCommand };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { t as fail } from "./cli-error-BrMXlbtx.mjs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/commands/meta.ts
|
|
6
|
+
async function runMetaCommand(name, metaDir) {
|
|
7
|
+
if (!existsSync(metaDir)) fail("Meta-skills directory not found.");
|
|
8
|
+
if (name) {
|
|
9
|
+
if (name.includes("..") || name.includes("/") || name.includes("\\")) fail(`Invalid meta-skill name: "${name}"`);
|
|
10
|
+
const skillFile = join(metaDir, name, "SKILL.md");
|
|
11
|
+
if (!existsSync(skillFile)) fail(`Meta-skill "${name}" not found. Run \`intent meta\` to list available meta-skills.`);
|
|
12
|
+
try {
|
|
13
|
+
console.log(readFileSync(skillFile, "utf8"));
|
|
14
|
+
} catch (err) {
|
|
15
|
+
fail(`Failed to read meta-skill "${name}": ${err instanceof Error ? err.message : String(err)}`);
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { parseFrontmatter } = await import("./utils-BHzSyNeJ.mjs");
|
|
20
|
+
const entries = readdirSync(metaDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => existsSync(join(metaDir, entry.name, "SKILL.md")));
|
|
21
|
+
if (entries.length === 0) {
|
|
22
|
+
console.log("No meta-skills found.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log("Meta-skills (for library maintainers):\n");
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const fm = parseFrontmatter(join(metaDir, entry.name, "SKILL.md"));
|
|
28
|
+
let description = "";
|
|
29
|
+
if (typeof fm?.description === "string") description = fm.description.replace(/\s+/g, " ").trim();
|
|
30
|
+
const shortDesc = description.length > 60 ? `${description.slice(0, 57)}...` : description;
|
|
31
|
+
console.log(` ${entry.name.padEnd(28)} ${shortDesc}`);
|
|
32
|
+
}
|
|
33
|
+
console.log("\nUsage: load the SKILL.md into your AI agent conversation.");
|
|
34
|
+
console.log("Path: node_modules/@tanstack/intent/meta/<name>/SKILL.md");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { runMetaCommand };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as readWorkspacePatterns, r as findWorkspaceRoot } from "./workspace-patterns-
|
|
1
|
+
import { i as readWorkspacePatterns, r as findWorkspaceRoot } from "./workspace-patterns-CNhdqCO4.mjs";
|
|
2
2
|
import { existsSync, statSync } from "node:fs";
|
|
3
3
|
import { dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { i as parseSkillUse } from "./skill-use-umYvZl94.mjs";
|
|
2
|
+
import { t as resolveProjectContext } from "./project-context-CfSZGJFC.mjs";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/core/package-json.ts
|
|
7
|
+
function readPackageJson(dir) {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/excludes.ts
|
|
17
|
+
const MAX_EXCLUDE_PATTERN_LENGTH = 200;
|
|
18
|
+
const PACKAGE_NAME_BOUNDARY = /[^a-zA-Z0-9_.-]/;
|
|
19
|
+
function normalizeExcludePatterns(value) {
|
|
20
|
+
if (!Array.isArray(value)) return [];
|
|
21
|
+
return value.filter((pattern) => typeof pattern === "string").map((pattern) => pattern.trim()).filter(Boolean);
|
|
22
|
+
}
|
|
23
|
+
function isWithinOrEqual(path, parentDir) {
|
|
24
|
+
const rel = relative(parentDir, path);
|
|
25
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
26
|
+
}
|
|
27
|
+
function readPackageExcludes(dir) {
|
|
28
|
+
const intent = readPackageJson(dir)?.intent;
|
|
29
|
+
if (!intent || typeof intent !== "object") return [];
|
|
30
|
+
return normalizeExcludePatterns(intent.exclude);
|
|
31
|
+
}
|
|
32
|
+
function getConfigExcludePatterns(cwd, context = resolveProjectContext({ cwd })) {
|
|
33
|
+
const root = context.workspaceRoot ?? context.packageRoot ?? cwd;
|
|
34
|
+
const dirs = [];
|
|
35
|
+
let dir = cwd;
|
|
36
|
+
while (isWithinOrEqual(dir, root)) {
|
|
37
|
+
dirs.push(dir);
|
|
38
|
+
if (dir === root) break;
|
|
39
|
+
const next = dirname(dir);
|
|
40
|
+
if (next === dir) break;
|
|
41
|
+
dir = next;
|
|
42
|
+
}
|
|
43
|
+
return dirs.reverse().flatMap(readPackageExcludes);
|
|
44
|
+
}
|
|
45
|
+
function getEffectiveExcludePatterns(options = {}, context) {
|
|
46
|
+
return [...getConfigExcludePatterns(context?.cwd ?? resolve(process.cwd(), options.cwd ?? process.cwd()), context), ...normalizeExcludePatterns(options.exclude)];
|
|
47
|
+
}
|
|
48
|
+
function normalizeGlobPattern(pattern) {
|
|
49
|
+
if (pattern.length > MAX_EXCLUDE_PATTERN_LENGTH) throw new Error(`Intent exclude pattern is too long: ${pattern.length} characters. Maximum is ${MAX_EXCLUDE_PATTERN_LENGTH}.`);
|
|
50
|
+
return pattern.replace(/\*+/g, "*");
|
|
51
|
+
}
|
|
52
|
+
function globToRegExp(pattern) {
|
|
53
|
+
const source = normalizeGlobPattern(pattern).split("*").map((part) => part.replace(/[\\^$+?.()|[\]{}]/g, "\\$&")).join(".*");
|
|
54
|
+
return /* @__PURE__ */ new RegExp(`^${source}$`);
|
|
55
|
+
}
|
|
56
|
+
function compileExcludePatterns(patterns) {
|
|
57
|
+
return patterns.map((pattern) => {
|
|
58
|
+
if (!pattern.includes("*")) {
|
|
59
|
+
normalizeGlobPattern(pattern);
|
|
60
|
+
return {
|
|
61
|
+
pattern,
|
|
62
|
+
matches: (packageName) => packageName === pattern
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const regex = globToRegExp(pattern);
|
|
66
|
+
return {
|
|
67
|
+
pattern,
|
|
68
|
+
matches: (packageName) => regex.test(packageName)
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function isPackageExcluded(packageName, matchers) {
|
|
73
|
+
return matchers.some((matcher) => matcher.matches(packageName));
|
|
74
|
+
}
|
|
75
|
+
function warningMentionsPackage(warning, packageName) {
|
|
76
|
+
let fromIndex = 0;
|
|
77
|
+
while (true) {
|
|
78
|
+
const idx = warning.indexOf(packageName, fromIndex);
|
|
79
|
+
if (idx === -1) return false;
|
|
80
|
+
const before = warning[idx - 1];
|
|
81
|
+
const after = warning[idx + packageName.length];
|
|
82
|
+
if ((before === void 0 || PACKAGE_NAME_BOUNDARY.test(before)) && (after === void 0 || PACKAGE_NAME_BOUNDARY.test(after))) return true;
|
|
83
|
+
fromIndex = idx + packageName.length;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/resolver.ts
|
|
89
|
+
var ResolveSkillUseError = class extends Error {
|
|
90
|
+
constructor({ availablePackages = [], availableSkills = [], code, packageName, skillName, suggestedSkills = [], use }) {
|
|
91
|
+
super(formatResolveSkillUseErrorMessage({
|
|
92
|
+
availablePackages,
|
|
93
|
+
availableSkills,
|
|
94
|
+
code,
|
|
95
|
+
packageName,
|
|
96
|
+
skillName,
|
|
97
|
+
suggestedSkills,
|
|
98
|
+
use
|
|
99
|
+
}));
|
|
100
|
+
this.name = "ResolveSkillUseError";
|
|
101
|
+
this.availablePackages = availablePackages;
|
|
102
|
+
this.availableSkills = availableSkills;
|
|
103
|
+
this.suggestedSkills = suggestedSkills;
|
|
104
|
+
this.code = code;
|
|
105
|
+
this.packageName = packageName;
|
|
106
|
+
this.skillName = skillName;
|
|
107
|
+
this.use = use;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function isResolveSkillUseError(error) {
|
|
111
|
+
return error instanceof ResolveSkillUseError;
|
|
112
|
+
}
|
|
113
|
+
function getPackageShortName(packageName) {
|
|
114
|
+
return packageName.split("/").pop() ?? packageName;
|
|
115
|
+
}
|
|
116
|
+
function getPackagePrefixedSkillAlias(packageName, skillName) {
|
|
117
|
+
const prefix = `${getPackageShortName(packageName)}/`;
|
|
118
|
+
return skillName.startsWith(prefix) ? skillName.slice(prefix.length) : null;
|
|
119
|
+
}
|
|
120
|
+
function getSuggestedSkills(packageName, skillName, skills) {
|
|
121
|
+
const lowerSkillName = skillName.toLowerCase();
|
|
122
|
+
const suggestions = [];
|
|
123
|
+
const seen = /* @__PURE__ */ new Set();
|
|
124
|
+
for (const skill of skills) {
|
|
125
|
+
const alias = getPackagePrefixedSkillAlias(packageName, skill.name);
|
|
126
|
+
const lowerName = skill.name.toLowerCase();
|
|
127
|
+
const lowerAlias = alias?.toLowerCase();
|
|
128
|
+
if (!(lowerAlias === lowerSkillName || lowerName.includes(lowerSkillName) || lowerAlias?.includes(lowerSkillName)) || seen.has(skill.name)) continue;
|
|
129
|
+
seen.add(skill.name);
|
|
130
|
+
suggestions.push(skill.name);
|
|
131
|
+
}
|
|
132
|
+
return suggestions.slice(0, 3);
|
|
133
|
+
}
|
|
134
|
+
function resolveSkillEntry(packageName, skillName, skills) {
|
|
135
|
+
const exact = skills.find((candidate) => candidate.name === skillName);
|
|
136
|
+
if (exact) return {
|
|
137
|
+
skill: exact,
|
|
138
|
+
suggestedSkills: []
|
|
139
|
+
};
|
|
140
|
+
const aliasMatches = skills.filter((candidate) => getPackagePrefixedSkillAlias(packageName, candidate.name) === skillName);
|
|
141
|
+
if (aliasMatches.length === 1) return {
|
|
142
|
+
skill: aliasMatches[0],
|
|
143
|
+
suggestedSkills: []
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
skill: null,
|
|
147
|
+
suggestedSkills: getSuggestedSkills(packageName, skillName, skills)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function resolveSkillUse(use, scanResult) {
|
|
151
|
+
const { packageName, skillName } = parseSkillUse(use);
|
|
152
|
+
const packages = scanResult.packages.filter((pkg$1) => pkg$1.name === packageName);
|
|
153
|
+
const pkg = packages.find((candidate) => candidate.source === "local") ?? packages[0];
|
|
154
|
+
if (!pkg) throw new ResolveSkillUseError({
|
|
155
|
+
availablePackages: scanResult.packages.map((candidate) => candidate.name),
|
|
156
|
+
code: "package-not-found",
|
|
157
|
+
packageName,
|
|
158
|
+
skillName,
|
|
159
|
+
use
|
|
160
|
+
});
|
|
161
|
+
const resolvedSkill = resolveSkillEntry(packageName, skillName, pkg.skills);
|
|
162
|
+
const skill = resolvedSkill.skill;
|
|
163
|
+
if (!skill) throw new ResolveSkillUseError({
|
|
164
|
+
availableSkills: pkg.skills.map((candidate) => candidate.name),
|
|
165
|
+
code: "skill-not-found",
|
|
166
|
+
packageName,
|
|
167
|
+
skillName,
|
|
168
|
+
suggestedSkills: resolvedSkill.suggestedSkills,
|
|
169
|
+
use
|
|
170
|
+
});
|
|
171
|
+
const conflict = scanResult.conflicts.find((candidate) => candidate.packageName === packageName) ?? null;
|
|
172
|
+
return {
|
|
173
|
+
packageName,
|
|
174
|
+
skillName: skill.name,
|
|
175
|
+
path: skill.path,
|
|
176
|
+
source: pkg.source,
|
|
177
|
+
version: pkg.version,
|
|
178
|
+
packageRoot: pkg.packageRoot,
|
|
179
|
+
warnings: scanResult.warnings.filter((warning) => warningMentionsPackage(warning, packageName)),
|
|
180
|
+
conflict
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function formatResolveSkillUseErrorMessage({ availablePackages, availableSkills, code, packageName, skillName, suggestedSkills, use }) {
|
|
184
|
+
switch (code) {
|
|
185
|
+
case "package-not-found": return `Cannot resolve skill use "${use}": package "${packageName}" was not found.${availablePackages.length > 0 ? ` Available packages: ${availablePackages.join(", ")}.` : ""}`;
|
|
186
|
+
case "skill-not-found": return `Cannot resolve skill use "${use}": skill "${skillName}" was not found in package "${packageName}".${suggestedSkills.length > 0 ? ` Did you mean ${formatSkillSuggestions(packageName, suggestedSkills)}?` : ""}${availableSkills.length > 0 ? ` Available skills: ${availableSkills.join(", ")}.` : ""}`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function formatSkillSuggestions(packageName, skillNames) {
|
|
190
|
+
const uses = skillNames.map((skillName) => `${packageName}#${skillName}`);
|
|
191
|
+
if (uses.length <= 2) return uses.join(" or ");
|
|
192
|
+
return `${uses.slice(0, -1).join(", ")}, or ${uses.at(-1)}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
export { compileExcludePatterns as a, warningMentionsPackage as c, resolveSkillUse as i, readPackageJson as l, isResolveSkillUseError as n, getEffectiveExcludePatterns as o, resolveSkillEntry as r, isPackageExcluded as s, ResolveSkillUseError as t };
|