@tanstack/intent 0.0.2 → 0.0.4
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 +4 -4
- package/dist/index.mjs +3 -3
- package/dist/intent-library.mjs +75 -31
- package/dist/{library-scanner-BrznE00j.mjs → library-scanner-D0aP7is_.mjs} +5 -2
- package/dist/library-scanner.mjs +2 -2
- package/dist/{scanner-CpsJAHXT.mjs → scanner-BwCyu1Jq.mjs} +15 -6
- package/dist/scanner-fAWJUn6Q.mjs +4 -0
- package/dist/staleness-B5gUj7FR.mjs +4 -0
- package/dist/{staleness-CnomT9Hm.mjs → staleness-lP6B0O4z.mjs} +1 -1
- package/dist/{utils-DjkEPBxu.mjs → utils-DH3jY3CI.mjs} +1 -1
- package/package.json +1 -1
- package/dist/scanner-BuWPDJ4P.mjs +0 -4
- package/dist/staleness-DyhsrqQ5.mjs +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as parseFrontmatter, t as findSkillFiles } from "./utils-
|
|
3
|
-
import { t as scanForIntents } from "./scanner-
|
|
2
|
+
import { n as parseFrontmatter, t as findSkillFiles } from "./utils-DH3jY3CI.mjs";
|
|
3
|
+
import { t as scanForIntents } from "./scanner-BwCyu1Jq.mjs";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { dirname, join, relative, sep } from "node:path";
|
|
6
6
|
import { parse } from "yaml";
|
|
@@ -339,8 +339,8 @@ switch (command) {
|
|
|
339
339
|
cmdScaffold();
|
|
340
340
|
break;
|
|
341
341
|
case "stale": {
|
|
342
|
-
const { checkStaleness } = await import("./staleness-
|
|
343
|
-
const { scanForIntents: scanStale } = await import("./scanner-
|
|
342
|
+
const { checkStaleness } = await import("./staleness-B5gUj7FR.mjs");
|
|
343
|
+
const { scanForIntents: scanStale } = await import("./scanner-fAWJUn6Q.mjs");
|
|
344
344
|
let staleResult;
|
|
345
345
|
try {
|
|
346
346
|
staleResult = await scanStale();
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as parseFrontmatter, t as findSkillFiles } from "./utils-
|
|
2
|
-
import { t as scanForIntents } from "./scanner-
|
|
3
|
-
import { t as checkStaleness } from "./staleness-
|
|
1
|
+
import { n as parseFrontmatter, t as findSkillFiles } from "./utils-DH3jY3CI.mjs";
|
|
2
|
+
import { t as scanForIntents } from "./scanner-BwCyu1Jq.mjs";
|
|
3
|
+
import { t as checkStaleness } from "./staleness-lP6B0O4z.mjs";
|
|
4
4
|
import { c as toMarkdown, i as resolveFrequency, l as validateMetaPayload, n as hasGhCli, o as submitFeedback, r as metaToMarkdown, s as submitMetaFeedback, t as containsSecrets, u as validatePayload } from "./feedback-DKreHfB1.mjs";
|
|
5
5
|
import { a as runInit, i as readProjectConfig, n as hasIntentBlock, o as writeProjectConfig, r as injectIntentBlock, t as detectAgentConfigs } from "./init-DNxmjQfU.mjs";
|
|
6
6
|
import { t as runSetup } from "./setup-CNGz26qL.mjs";
|
package/dist/intent-library.mjs
CHANGED
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./utils-
|
|
3
|
-
import { t as scanLibrary } from "./library-scanner-
|
|
4
|
-
import { spawnSync } from "node:child_process";
|
|
5
|
-
import { release } from "node:os";
|
|
2
|
+
import "./utils-DH3jY3CI.mjs";
|
|
3
|
+
import { t as scanLibrary } from "./library-scanner-D0aP7is_.mjs";
|
|
6
4
|
|
|
7
5
|
//#region src/intent-library.ts
|
|
6
|
+
function padColumn(text, width) {
|
|
7
|
+
return text.length >= width ? text + " " : text.padEnd(width);
|
|
8
|
+
}
|
|
9
|
+
function printTable(headers, rows) {
|
|
10
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)) + 2);
|
|
11
|
+
const headerLine = headers.map((h, i) => padColumn(h, widths[i])).join("");
|
|
12
|
+
const separator = widths.map((w) => "─".repeat(w)).join("");
|
|
13
|
+
console.log(headerLine);
|
|
14
|
+
console.log(separator);
|
|
15
|
+
for (const row of rows) console.log(row.map((cell, i) => padColumn(cell, widths[i])).join(""));
|
|
16
|
+
}
|
|
17
|
+
function printSkillTree(skills, opts) {
|
|
18
|
+
const roots = [];
|
|
19
|
+
const children = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const skill of skills) {
|
|
21
|
+
const slashIdx = skill.name.indexOf("/");
|
|
22
|
+
if (slashIdx === -1) roots.push(skill.name);
|
|
23
|
+
else {
|
|
24
|
+
const parent = skill.name.slice(0, slashIdx);
|
|
25
|
+
if (!children.has(parent)) children.set(parent, []);
|
|
26
|
+
children.get(parent).push(skill);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (roots.length === 0) {
|
|
30
|
+
for (const skill of skills) if (!roots.includes(skill.name)) roots.push(skill.name);
|
|
31
|
+
}
|
|
32
|
+
for (const rootName of roots) {
|
|
33
|
+
const rootSkill = skills.find((s) => s.name === rootName);
|
|
34
|
+
if (!rootSkill) continue;
|
|
35
|
+
printSkillLine(rootName, rootSkill, 4, opts);
|
|
36
|
+
for (const sub of children.get(rootName) ?? []) printSkillLine(sub.name.slice(sub.name.indexOf("/") + 1), sub, 6, opts);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function printSkillLine(displayName, skill, indent, opts) {
|
|
40
|
+
const nameStr = " ".repeat(indent) + displayName;
|
|
41
|
+
const padding = " ".repeat(Math.max(2, opts.nameWidth - nameStr.length));
|
|
42
|
+
const typeCol = opts.showTypes ? (skill.type ? `[${skill.type}]` : "").padEnd(14) : "";
|
|
43
|
+
console.log(`${nameStr}${padding}${typeCol}${skill.description}`);
|
|
44
|
+
}
|
|
45
|
+
function computeSkillNameWidth(allPackageSkills) {
|
|
46
|
+
let max = 0;
|
|
47
|
+
for (const skills of allPackageSkills) for (const s of skills) {
|
|
48
|
+
const slashIdx = s.name.indexOf("/");
|
|
49
|
+
const displayName = slashIdx === -1 ? s.name : s.name.slice(slashIdx + 1);
|
|
50
|
+
const indent = slashIdx === -1 ? 4 : 6;
|
|
51
|
+
max = Math.max(max, indent + displayName.length);
|
|
52
|
+
}
|
|
53
|
+
return max + 2;
|
|
54
|
+
}
|
|
8
55
|
async function cmdList() {
|
|
9
56
|
let result;
|
|
10
57
|
try {
|
|
@@ -21,34 +68,35 @@ async function cmdList() {
|
|
|
21
68
|
}
|
|
22
69
|
return;
|
|
23
70
|
}
|
|
71
|
+
const totalSkills = result.packages.reduce((sum, p) => sum + p.skills.length, 0);
|
|
72
|
+
console.log(`\n${result.packages.length} intent-enabled packages, ${totalSkills} skills\n`);
|
|
73
|
+
printTable([
|
|
74
|
+
"PACKAGE",
|
|
75
|
+
"VERSION",
|
|
76
|
+
"SKILLS"
|
|
77
|
+
], result.packages.map((pkg) => [
|
|
78
|
+
pkg.name,
|
|
79
|
+
pkg.version,
|
|
80
|
+
String(pkg.skills.length)
|
|
81
|
+
]));
|
|
82
|
+
const nameWidth = computeSkillNameWidth(result.packages.map((p) => p.skills));
|
|
83
|
+
const showTypes = result.packages.some((p) => p.skills.some((s) => s.type));
|
|
84
|
+
console.log(`\nSkills:\n`);
|
|
24
85
|
for (const pkg of result.packages) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
console.log(` ${name}${desc}${skill.path}`);
|
|
31
|
-
}
|
|
86
|
+
console.log(` ${pkg.name}`);
|
|
87
|
+
printSkillTree(pkg.skills, {
|
|
88
|
+
nameWidth,
|
|
89
|
+
showTypes
|
|
90
|
+
});
|
|
32
91
|
console.log();
|
|
33
92
|
}
|
|
34
93
|
if (result.warnings.length > 0) {
|
|
35
|
-
console.log(
|
|
94
|
+
console.log(`Warnings:`);
|
|
36
95
|
for (const w of result.warnings) console.log(` ⚠ ${w}`);
|
|
37
96
|
}
|
|
38
97
|
}
|
|
39
98
|
function cmdInstall() {
|
|
40
|
-
|
|
41
|
-
const platform = process.platform;
|
|
42
|
-
const isWsl = platform === "linux" && (Boolean(process.env.WSL_DISTRO_NAME) || Boolean(process.env.WSL_INTEROP) || release().toLowerCase().includes("microsoft"));
|
|
43
|
-
const tryCommand = (command$1, args = []) => {
|
|
44
|
-
return spawnSync(command$1, args, { input: text }).status === 0;
|
|
45
|
-
};
|
|
46
|
-
if (platform === "darwin") return tryCommand("pbcopy");
|
|
47
|
-
if (platform === "win32") return tryCommand("clip");
|
|
48
|
-
if (isWsl) return tryCommand("clip.exe");
|
|
49
|
-
return tryCommand("wl-copy") || tryCommand("xclip", ["-selection", "clipboard"]) || tryCommand("xsel", ["--clipboard", "--input"]);
|
|
50
|
-
}
|
|
51
|
-
const prompt = `You are an AI assistant helping a developer set up skill-to-task mappings for their project.
|
|
99
|
+
console.log(`You are an AI assistant helping a developer set up skill-to-task mappings for their project.
|
|
52
100
|
|
|
53
101
|
Follow these steps in order:
|
|
54
102
|
|
|
@@ -93,18 +141,14 @@ skills:
|
|
|
93
141
|
- Use the user's own words for task descriptions
|
|
94
142
|
- Include the exact path from \`intent list\` output so agents can load it directly
|
|
95
143
|
- Keep entries concise — this block is read on every agent task
|
|
96
|
-
- Preserve all content outside the block tags unchanged
|
|
97
|
-
console.log("🚀 Intent Install");
|
|
98
|
-
console.log("✨ Copy the prompt below into your AI agent:\n");
|
|
99
|
-
console.log(prompt);
|
|
100
|
-
if (tryCopyToClipboard(prompt)) console.log("\n✅ Copied prompt to clipboard");
|
|
101
|
-
else console.log("\n⚠ Tip: Manually copy the prompt above into your agent");
|
|
144
|
+
- Preserve all content outside the block tags unchanged`);
|
|
102
145
|
}
|
|
103
146
|
const USAGE = `TanStack Intent
|
|
104
147
|
|
|
105
148
|
Usage:
|
|
106
149
|
intent list List all available skills from this library and its dependencies
|
|
107
|
-
intent install
|
|
150
|
+
intent install Print a skill that guides your coding agent to scan the project
|
|
151
|
+
and set up skill-to-task mappings in your agent config`;
|
|
108
152
|
const command = process.argv[2];
|
|
109
153
|
switch (command) {
|
|
110
154
|
case "list":
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as parseFrontmatter } from "./utils-
|
|
1
|
+
import { n as parseFrontmatter } from "./utils-DH3jY3CI.mjs";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import { dirname, join, relative, sep } from "node:path";
|
|
4
4
|
|
|
@@ -37,7 +37,10 @@ function discoverSkills(skillsDir) {
|
|
|
37
37
|
function walk(dir) {
|
|
38
38
|
let entries;
|
|
39
39
|
try {
|
|
40
|
-
entries = readdirSync(dir, {
|
|
40
|
+
entries = readdirSync(dir, {
|
|
41
|
+
withFileTypes: true,
|
|
42
|
+
encoding: "utf8"
|
|
43
|
+
});
|
|
41
44
|
} catch {
|
|
42
45
|
return;
|
|
43
46
|
}
|
package/dist/library-scanner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as parseFrontmatter } from "./utils-
|
|
1
|
+
import { n as parseFrontmatter } from "./utils-DH3jY3CI.mjs";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import { join, relative, sep } from "node:path";
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ function detectPackageManager(root) {
|
|
|
12
12
|
if (existsSync(join(root, "package-lock.json"))) return "npm";
|
|
13
13
|
return "unknown";
|
|
14
14
|
}
|
|
15
|
-
function validateIntentField(
|
|
15
|
+
function validateIntentField(_pkgName, intent) {
|
|
16
16
|
if (!intent || typeof intent !== "object") return null;
|
|
17
17
|
const pb = intent;
|
|
18
18
|
if (pb.version !== 1) return null;
|
|
@@ -26,12 +26,15 @@ function validateIntentField(pkgName, intent) {
|
|
|
26
26
|
requires
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function discoverSkills(skillsDir,
|
|
29
|
+
function discoverSkills(skillsDir, _baseName) {
|
|
30
30
|
const skills = [];
|
|
31
31
|
function walk(dir) {
|
|
32
32
|
let entries;
|
|
33
33
|
try {
|
|
34
|
-
entries = readdirSync(dir, {
|
|
34
|
+
entries = readdirSync(dir, {
|
|
35
|
+
withFileTypes: true,
|
|
36
|
+
encoding: "utf8"
|
|
37
|
+
});
|
|
35
38
|
} catch {
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
@@ -86,7 +89,10 @@ async function scanForIntents(root) {
|
|
|
86
89
|
const packageDirs = [];
|
|
87
90
|
let topEntries;
|
|
88
91
|
try {
|
|
89
|
-
topEntries = readdirSync(nodeModulesDir, {
|
|
92
|
+
topEntries = readdirSync(nodeModulesDir, {
|
|
93
|
+
withFileTypes: true,
|
|
94
|
+
encoding: "utf8"
|
|
95
|
+
});
|
|
90
96
|
} catch {
|
|
91
97
|
return {
|
|
92
98
|
packageManager,
|
|
@@ -100,7 +106,10 @@ async function scanForIntents(root) {
|
|
|
100
106
|
if (entry.name.startsWith("@")) {
|
|
101
107
|
let scopedEntries;
|
|
102
108
|
try {
|
|
103
|
-
scopedEntries = readdirSync(dirPath, {
|
|
109
|
+
scopedEntries = readdirSync(dirPath, {
|
|
110
|
+
withFileTypes: true,
|
|
111
|
+
encoding: "utf8"
|
|
112
|
+
});
|
|
104
113
|
} catch {
|
|
105
114
|
continue;
|
|
106
115
|
}
|
package/package.json
CHANGED