@tanstack/intent 0.0.14 → 0.0.20

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 (36) hide show
  1. package/README.md +42 -5
  2. package/dist/cli.d.mts +6 -1
  3. package/dist/cli.mjs +253 -170
  4. package/dist/display-CuCDLPP_.mjs +3 -0
  5. package/dist/index.d.mts +10 -11
  6. package/dist/index.mjs +37 -14
  7. package/dist/install-prompt-C0M-U3WZ.mjs +59 -0
  8. package/dist/intent-library.mjs +5 -49
  9. package/dist/{library-scanner-B1tmOzwf.mjs → library-scanner-DBOEhfm8.mjs} +4 -5
  10. package/dist/library-scanner.d.mts +5 -5
  11. package/dist/library-scanner.mjs +2 -2
  12. package/dist/scanner-BHPl60jH.mjs +5 -0
  13. package/dist/scanner-DVepyEwz.mjs +365 -0
  14. package/dist/setup-B-zdCBu4.d.mts +36 -0
  15. package/dist/setup-mGV2dZrq.mjs +367 -0
  16. package/dist/setup.d.mts +2 -2
  17. package/dist/setup.mjs +3 -2
  18. package/dist/{staleness-DJfMKH62.mjs → staleness-DZKvsLVq.mjs} +24 -3
  19. package/dist/staleness-Dr5-5wj5.mjs +4 -0
  20. package/dist/{types-BmnI8kFB.d.mts → types-ddLtccfV.d.mts} +30 -7
  21. package/dist/utils-BfjM1mQe.mjs +152 -0
  22. package/dist/utils-D7OKi0Rn.mjs +3 -0
  23. package/meta/domain-discovery/SKILL.md +95 -20
  24. package/meta/feedback-collection/SKILL.md +20 -1
  25. package/meta/generate-skill/SKILL.md +56 -5
  26. package/meta/templates/workflows/check-skills.yml +4 -4
  27. package/meta/templates/workflows/{notify-playbooks.yml → notify-intent.yml} +4 -4
  28. package/meta/tree-generator/SKILL.md +2 -2
  29. package/package.json +9 -5
  30. package/dist/scanner-CECGXgox.mjs +0 -4
  31. package/dist/scanner-CY40iozO.mjs +0 -218
  32. package/dist/setup-CANkTz55.d.mts +0 -18
  33. package/dist/setup-Nif1-nhS.mjs +0 -211
  34. package/dist/staleness-C1h7RuZ9.mjs +0 -4
  35. package/dist/utils-CDJzAdjD.mjs +0 -79
  36. /package/dist/{display-D_XzuGnu.mjs → display-DhsUxNJW.mjs} +0 -0
@@ -1,211 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
-
4
- //#region src/setup.ts
5
- function detectVars(root) {
6
- const pkgPath = join(root, "package.json");
7
- let pkgJson = {};
8
- try {
9
- pkgJson = JSON.parse(readFileSync(pkgPath, "utf8"));
10
- } catch (err) {
11
- if (!(err && typeof err === "object" && "code" in err && err.code === "ENOENT")) console.error(`Warning: could not read ${pkgPath}: ${err instanceof Error ? err.message : err}`);
12
- }
13
- const name = typeof pkgJson.name === "string" ? pkgJson.name : "unknown";
14
- const intent = pkgJson.intent;
15
- const repo = typeof intent?.repo === "string" ? intent.repo : name.replace(/^@/, "").replace(/\//, "/");
16
- const docs = typeof intent?.docs === "string" ? intent.docs : "docs/";
17
- let srcPath = `packages/${name.replace(/^@[^/]+\//, "")}/src/**`;
18
- if (existsSync(join(root, "src"))) srcPath = "src/**";
19
- return {
20
- PACKAGE_NAME: name,
21
- REPO: repo,
22
- DOCS_PATH: docs.endsWith("**") ? docs : docs.replace(/\/$/, "") + "/**",
23
- SRC_PATH: srcPath
24
- };
25
- }
26
- function applyVars(content, vars) {
27
- return content.replace(/\{\{PACKAGE_NAME\}\}/g, vars.PACKAGE_NAME).replace(/\{\{REPO\}\}/g, vars.REPO).replace(/\{\{DOCS_PATH\}\}/g, vars.DOCS_PATH).replace(/\{\{SRC_PATH\}\}/g, vars.SRC_PATH);
28
- }
29
- function copyTemplates(srcDir, destDir, vars) {
30
- const copied = [];
31
- const skipped = [];
32
- if (!existsSync(srcDir)) return {
33
- copied,
34
- skipped
35
- };
36
- mkdirSync(destDir, { recursive: true });
37
- for (const entry of readdirSync(srcDir)) {
38
- const srcPath = join(srcDir, entry);
39
- const destPath = join(destDir, entry);
40
- if (existsSync(destPath)) {
41
- skipped.push(destPath);
42
- continue;
43
- }
44
- writeFileSync(destPath, applyVars(readFileSync(srcPath, "utf8"), vars));
45
- copied.push(destPath);
46
- }
47
- return {
48
- copied,
49
- skipped
50
- };
51
- }
52
- function getShimContent(ext) {
53
- return `#!/usr/bin/env node
54
- // Auto-generated by @tanstack/intent setup
55
- // Exposes the intent end-user CLI for consumers of this library.
56
- // Commit this file, then add to your package.json:
57
- // "bin": { "intent": "./bin/intent.${ext}" }
58
- try {
59
- await import('@tanstack/intent/intent-library')
60
- } catch (e) {
61
- if (e?.code === 'ERR_MODULE_NOT_FOUND' || e?.code === 'MODULE_NOT_FOUND') {
62
- console.error('@tanstack/intent is not installed.')
63
- console.error('')
64
- console.error('Install it as a dev dependency:')
65
- console.error(' npm add -D @tanstack/intent')
66
- console.error('')
67
- console.error('Or run directly:')
68
- console.error(' npx @tanstack/intent@latest list')
69
- process.exit(1)
70
- }
71
- throw e
72
- }
73
- `;
74
- }
75
- function detectShimExtension(root) {
76
- try {
77
- if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).type === "module") return "js";
78
- } catch (err) {
79
- if (!(err && typeof err === "object" && "code" in err && err.code === "ENOENT")) console.error(`Warning: could not read package.json: ${err instanceof Error ? err.message : err}`);
80
- }
81
- return "mjs";
82
- }
83
- function findExistingShim(root) {
84
- const shimJs = join(root, "bin", "intent.js");
85
- if (existsSync(shimJs)) return shimJs;
86
- const shimMjs = join(root, "bin", "intent.mjs");
87
- if (existsSync(shimMjs)) return shimMjs;
88
- return null;
89
- }
90
- function runAddLibraryBin(root) {
91
- const result = {
92
- shim: null,
93
- skipped: null
94
- };
95
- const existingShim = findExistingShim(root);
96
- if (existingShim) {
97
- result.skipped = existingShim;
98
- console.log(` Already exists: ${existingShim}`);
99
- return result;
100
- }
101
- const ext = detectShimExtension(root);
102
- const shimPath = join(root, "bin", `intent.${ext}`);
103
- mkdirSync(join(root, "bin"), { recursive: true });
104
- writeFileSync(shimPath, getShimContent(ext));
105
- result.shim = shimPath;
106
- console.log(`✓ Generated intent shim: ${shimPath}`);
107
- console.log(`\n Run \`npx @tanstack/intent edit-package-json\` to wire package.json.`);
108
- return result;
109
- }
110
- function runEditPackageJson(root) {
111
- const result = {
112
- added: [],
113
- alreadyPresent: []
114
- };
115
- const pkgPath = join(root, "package.json");
116
- if (!existsSync(pkgPath)) {
117
- console.error("No package.json found in " + root);
118
- process.exitCode = 1;
119
- return result;
120
- }
121
- const raw = readFileSync(pkgPath, "utf8");
122
- let pkg;
123
- try {
124
- pkg = JSON.parse(raw);
125
- } catch (err) {
126
- const detail = err instanceof SyntaxError ? err.message : String(err);
127
- console.error(`Failed to parse ${pkgPath}: ${detail}`);
128
- return result;
129
- }
130
- const indentMatch = raw.match(/^(\s+)"/m);
131
- const indentSize = indentMatch?.[1] ? indentMatch[1].length : 2;
132
- if (!Array.isArray(pkg.files)) pkg.files = [];
133
- const files = pkg.files;
134
- const requiredFiles = (() => {
135
- let dir = join(root, "..");
136
- for (let i = 0; i < 5; i++) {
137
- const parentPkg = join(dir, "package.json");
138
- if (existsSync(parentPkg)) {
139
- try {
140
- const parent = JSON.parse(readFileSync(parentPkg, "utf8"));
141
- if (Array.isArray(parent.workspaces) || parent.workspaces?.packages) return true;
142
- } catch {}
143
- return false;
144
- }
145
- const next = join(dir, "..");
146
- if (next === dir) break;
147
- dir = next;
148
- }
149
- return false;
150
- })() ? ["skills", "bin"] : [
151
- "skills",
152
- "bin",
153
- "!skills/_artifacts"
154
- ];
155
- for (const entry of requiredFiles) if (files.includes(entry)) result.alreadyPresent.push(`files: "${entry}"`);
156
- else {
157
- files.push(entry);
158
- result.added.push(`files: "${entry}"`);
159
- }
160
- const existingShim = findExistingShim(root);
161
- let ext;
162
- if (existingShim) ext = existingShim.endsWith(".mjs") ? "mjs" : "js";
163
- else ext = pkg.type === "module" ? "js" : "mjs";
164
- const shimRelative = `./bin/intent.${ext}`;
165
- if (typeof pkg.bin === "object" && pkg.bin !== null) {
166
- const binObj = pkg.bin;
167
- if (binObj.intent) result.alreadyPresent.push(`bin.intent`);
168
- else {
169
- binObj.intent = shimRelative;
170
- result.added.push(`bin.intent: "${shimRelative}"`);
171
- }
172
- } else if (!pkg.bin) {
173
- pkg.bin = { intent: shimRelative };
174
- result.added.push(`bin.intent: "${shimRelative}"`);
175
- } else if (typeof pkg.bin === "string") {
176
- const pkgName = typeof pkg.name === "string" ? pkg.name.replace(/^@[^/]+\//, "") : "unknown";
177
- pkg.bin = {
178
- [pkgName]: pkg.bin,
179
- intent: shimRelative
180
- };
181
- result.added.push(`bin.intent: "${shimRelative}" (converted bin from string to object)`);
182
- }
183
- writeFileSync(pkgPath, JSON.stringify(pkg, null, indentSize) + "\n");
184
- for (const a of result.added) console.log(`✓ Added ${a}`);
185
- for (const a of result.alreadyPresent) console.log(` Already present: ${a}`);
186
- return result;
187
- }
188
- function runSetupGithubActions(root, metaDir) {
189
- const vars = detectVars(root);
190
- const result = {
191
- workflows: [],
192
- skipped: []
193
- };
194
- const { copied, skipped } = copyTemplates(join(metaDir, "templates", "workflows"), join(root, ".github", "workflows"), vars);
195
- result.workflows = copied;
196
- result.skipped = skipped;
197
- for (const f of result.workflows) console.log(`✓ Copied workflow: ${f}`);
198
- for (const f of result.skipped) console.log(` Already exists: ${f}`);
199
- if (result.workflows.length === 0 && result.skipped.length === 0) console.log("No templates directory found. Is @tanstack/intent installed?");
200
- else if (result.workflows.length > 0) {
201
- console.log(`\nTemplate variables applied:`);
202
- console.log(` Package: ${vars.PACKAGE_NAME}`);
203
- console.log(` Repo: ${vars.REPO}`);
204
- console.log(` Docs: ${vars.DOCS_PATH}`);
205
- console.log(` Src: ${vars.SRC_PATH}`);
206
- }
207
- return result;
208
- }
209
-
210
- //#endregion
211
- export { runEditPackageJson as n, runSetupGithubActions as r, runAddLibraryBin as t };
@@ -1,4 +0,0 @@
1
- import "./utils-CDJzAdjD.mjs";
2
- import { t as checkStaleness } from "./staleness-DJfMKH62.mjs";
3
-
4
- export { checkStaleness };
@@ -1,79 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
2
- import { dirname, join } from "node:path";
3
- import { parse } from "yaml";
4
-
5
- //#region src/utils.ts
6
- /**
7
- * Recursively find all SKILL.md files under a directory.
8
- */
9
- function findSkillFiles(dir) {
10
- const files = [];
11
- if (!existsSync(dir)) return files;
12
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
13
- const fullPath = join(dir, entry.name);
14
- if (entry.isDirectory()) files.push(...findSkillFiles(fullPath));
15
- else if (entry.name === "SKILL.md") files.push(fullPath);
16
- }
17
- return files;
18
- }
19
- /**
20
- * Read dependencies and peerDependencies (and optionally devDependencies) from
21
- * a parsed package.json object.
22
- */
23
- function getDeps(pkgJson, includeDevDeps = false) {
24
- const deps = /* @__PURE__ */ new Set();
25
- const fields = includeDevDeps ? [
26
- "dependencies",
27
- "devDependencies",
28
- "peerDependencies"
29
- ] : ["dependencies", "peerDependencies"];
30
- for (const field of fields) {
31
- const d = pkgJson[field];
32
- if (d && typeof d === "object") for (const name of Object.keys(d)) deps.add(name);
33
- }
34
- return [...deps];
35
- }
36
- /**
37
- * Resolve the directory of a dependency by name. First checks the top-level
38
- * node_modules (hoisted layout — npm, yarn, bun), then resolves through the
39
- * parent package's real path to handle pnpm's virtual store layout where
40
- * transitive deps are siblings in the .pnpm virtual store node_modules.
41
- */
42
- function resolveDepDir(depName, parentDir, parentName, nodeModulesDir) {
43
- if (!parentName) return null;
44
- const topLevel = join(nodeModulesDir, depName);
45
- if (existsSync(join(topLevel, "package.json"))) return topLevel;
46
- try {
47
- const realParent = realpathSync(parentDir);
48
- const segments = parentName.split("/").length;
49
- let nmDir = realParent;
50
- for (let i = 0; i < segments; i++) nmDir = dirname(nmDir);
51
- const nested = join(nmDir, depName);
52
- if (existsSync(join(nested, "package.json"))) return nested;
53
- } catch (err) {
54
- const code = err && typeof err === "object" && "code" in err ? err.code : void 0;
55
- if (code !== "ENOENT" && code !== "ENOTDIR") console.warn(`Warning: could not resolve ${depName} from ${parentDir}: ${err instanceof Error ? err.message : String(err)}`);
56
- }
57
- return null;
58
- }
59
- /**
60
- * Parse YAML frontmatter from a file. Returns null if no frontmatter or on error.
61
- */
62
- function parseFrontmatter(filePath) {
63
- let content;
64
- try {
65
- content = readFileSync(filePath, "utf8");
66
- } catch {
67
- return null;
68
- }
69
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
70
- if (!match?.[1]) return null;
71
- try {
72
- return parse(match[1]);
73
- } catch {
74
- return null;
75
- }
76
- }
77
-
78
- //#endregion
79
- export { resolveDepDir as i, getDeps as n, parseFrontmatter as r, findSkillFiles as t };