@tanstack/intent 0.0.3 → 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.
@@ -3,6 +3,55 @@ import "./utils-DH3jY3CI.mjs";
3
3
  import { t as scanLibrary } from "./library-scanner-D0aP7is_.mjs";
4
4
 
5
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
+ }
6
55
  async function cmdList() {
7
56
  let result;
8
57
  try {
@@ -19,18 +68,30 @@ async function cmdList() {
19
68
  }
20
69
  return;
21
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`);
22
85
  for (const pkg of result.packages) {
23
- const header = pkg.description ? `${pkg.name} v${pkg.version} — ${pkg.description}` : `${pkg.name} v${pkg.version}`;
24
- console.log(header);
25
- for (const skill of pkg.skills) {
26
- const name = skill.name.padEnd(28);
27
- const desc = (skill.description || "").padEnd(52);
28
- console.log(` ${name}${desc}${skill.path}`);
29
- }
86
+ console.log(` ${pkg.name}`);
87
+ printSkillTree(pkg.skills, {
88
+ nameWidth,
89
+ showTypes
90
+ });
30
91
  console.log();
31
92
  }
32
93
  if (result.warnings.length > 0) {
33
- console.log("Warnings:");
94
+ console.log(`Warnings:`);
34
95
  for (const w of result.warnings) console.log(` ⚠ ${w}`);
35
96
  }
36
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/intent",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Ship compositional knowledge for AI coding agents alongside your npm packages",
5
5
  "license": "MIT",
6
6
  "type": "module",