@tanstack/intent 0.0.32 → 0.0.33
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/README.md +7 -7
- package/dist/artifact-coverage-BAN2W6aH.mjs +3 -0
- package/dist/artifact-coverage-wLNVX8yC.mjs +128 -0
- package/dist/cli.mjs +21 -9
- package/dist/{display-DCRCp4-C.mjs → display-DvLbcWzq.mjs} +1 -1
- package/dist/index.d.mts +22 -4
- package/dist/index.mjs +125 -8
- package/dist/{install-BmVqcbEi.mjs → install-PUnIfBNC.mjs} +54 -18
- package/dist/intent-library.mjs +5 -5
- package/dist/library-scanner.d.mts +1 -1
- package/dist/library-scanner.mjs +1 -1
- package/dist/{project-context-CKG-q4rD.mjs → project-context-IDLpJU3S.mjs} +1 -1
- package/dist/{resolver-aFigTqXi.mjs → resolver-D2CgIYGg.mjs} +1 -1
- package/dist/{scanner-DKL8v8is.mjs → scanner-CW59cxE_.mjs} +1 -1
- package/dist/scanner-DlkcbVye.mjs +6 -0
- package/dist/{setup-JJvjiGkM.mjs → setup-DfLsziXU.mjs} +2 -2
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +3 -3
- package/dist/staleness-DpbmYod4.mjs +5 -0
- package/dist/staleness-PdgakrCQ.mjs +243 -0
- package/dist/{types-CsySN6Vw.d.mts → types-_y9b00bI.d.mts} +48 -1
- package/dist/{workspace-patterns-U35B5AO-.mjs → workspace-patterns-BN2A_60g.mjs} +6 -1
- package/dist/workspace-patterns-x-dLZxx4.mjs +4 -0
- package/meta/templates/workflows/check-skills.yml +199 -91
- package/package.json +1 -1
- package/dist/scanner-CRZITpcY.mjs +0 -6
- package/dist/staleness-DorwfGrf.mjs +0 -104
- package/dist/staleness-NF-lxfXf.mjs +0 -4
- package/dist/workspace-patterns-DbnA0peB.mjs +0 -4
- package/meta/templates/workflows/notify-intent.yml +0 -51
- /package/dist/{display-DUgtRJkt.mjs → display-BTZWCjzT.mjs} +0 -0
- /package/dist/{library-scanner-DFFreLjW.mjs → library-scanner-Cl-XPEMf.mjs} +0 -0
- /package/dist/{setup-DDoOLriA.d.mts → setup-D2CGdTsx.d.mts} +0 -0
- /package/dist/{skill-use-CXOnncWK.mjs → skill-use-uwGleSOz.mjs} +0 -0
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { a as parseFrontmatter, n as findSkillFiles } from "./utils-COlDcU72.mjs";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { join, relative, sep } from "node:path";
|
|
4
|
-
|
|
5
|
-
//#region src/staleness.ts
|
|
6
|
-
function classifyVersionDrift(oldVer, newVer) {
|
|
7
|
-
if (oldVer === newVer) return null;
|
|
8
|
-
const oldParts = oldVer.replace(/[^0-9.]/g, "").split(".").map(Number);
|
|
9
|
-
const newParts = newVer.replace(/[^0-9.]/g, "").split(".").map(Number);
|
|
10
|
-
if ((newParts[0] ?? 0) > (oldParts[0] ?? 0)) return "major";
|
|
11
|
-
if ((newParts[1] ?? 0) > (oldParts[1] ?? 0)) return "minor";
|
|
12
|
-
if ((newParts[2] ?? 0) > (oldParts[2] ?? 0)) return "patch";
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
function readLocalVersion(packageDir) {
|
|
16
|
-
try {
|
|
17
|
-
const pkgJson = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
|
|
18
|
-
return typeof pkgJson.version === "string" ? pkgJson.version : null;
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function fetchNpmVersion(packageName) {
|
|
24
|
-
try {
|
|
25
|
-
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`);
|
|
26
|
-
if (!res.ok) return null;
|
|
27
|
-
const data = await res.json();
|
|
28
|
-
return typeof data.version === "string" ? data.version : null;
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function fetchCurrentVersion(packageDir, packageName) {
|
|
34
|
-
return readLocalVersion(packageDir) ?? await fetchNpmVersion(packageName);
|
|
35
|
-
}
|
|
36
|
-
function isStringRecord(value) {
|
|
37
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
38
|
-
}
|
|
39
|
-
function parseSyncState(value) {
|
|
40
|
-
if (!value || typeof value !== "object") return null;
|
|
41
|
-
const raw = value;
|
|
42
|
-
const parsed = {};
|
|
43
|
-
if (typeof raw.library_version === "string") parsed.library_version = raw.library_version;
|
|
44
|
-
if (raw.skills && typeof raw.skills === "object") {
|
|
45
|
-
const skills = {};
|
|
46
|
-
for (const [skillName, skillValue] of Object.entries(raw.skills)) {
|
|
47
|
-
if (!skillValue || typeof skillValue !== "object") continue;
|
|
48
|
-
const sourcesSha = skillValue.sources_sha;
|
|
49
|
-
if (sourcesSha !== void 0 && !isStringRecord(sourcesSha)) continue;
|
|
50
|
-
skills[skillName] = {};
|
|
51
|
-
if (sourcesSha) skills[skillName].sources_sha = sourcesSha;
|
|
52
|
-
}
|
|
53
|
-
parsed.skills = skills;
|
|
54
|
-
}
|
|
55
|
-
return parsed;
|
|
56
|
-
}
|
|
57
|
-
function readSyncState(packageDir) {
|
|
58
|
-
const statePath = join(packageDir, "skills", "sync-state.json");
|
|
59
|
-
try {
|
|
60
|
-
return parseSyncState(JSON.parse(readFileSync(statePath, "utf8")));
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async function checkStaleness(packageDir, packageName) {
|
|
66
|
-
const skillsDir = join(packageDir, "skills");
|
|
67
|
-
const library = packageName ?? "unknown";
|
|
68
|
-
const skillMetas = findSkillFiles(skillsDir).map((filePath) => {
|
|
69
|
-
const fm = parseFrontmatter(filePath);
|
|
70
|
-
const relName = relative(skillsDir, filePath).replace(/[/\\]SKILL\.md$/, "").split(sep).join("/");
|
|
71
|
-
return {
|
|
72
|
-
name: typeof fm?.name === "string" ? fm.name : relName,
|
|
73
|
-
filePath,
|
|
74
|
-
libraryVersion: fm?.library_version,
|
|
75
|
-
sources: Array.isArray(fm?.sources) ? fm.sources : void 0
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
const skillVersion = skillMetas.find((s) => s.libraryVersion)?.libraryVersion ?? null;
|
|
79
|
-
const currentVersion = await fetchCurrentVersion(packageDir, library);
|
|
80
|
-
const versionDrift = skillVersion && currentVersion ? classifyVersionDrift(skillVersion, currentVersion) : null;
|
|
81
|
-
const syncState = readSyncState(packageDir);
|
|
82
|
-
return {
|
|
83
|
-
library,
|
|
84
|
-
currentVersion,
|
|
85
|
-
skillVersion,
|
|
86
|
-
versionDrift,
|
|
87
|
-
skills: skillMetas.map((skill) => {
|
|
88
|
-
const reasons = [];
|
|
89
|
-
if (currentVersion && skill.libraryVersion && skill.libraryVersion !== currentVersion) reasons.push(`version drift (${skill.libraryVersion} → ${currentVersion})`);
|
|
90
|
-
const storedShas = syncState?.skills?.[skill.name]?.sources_sha ?? {};
|
|
91
|
-
if (skill.sources && Object.keys(storedShas).length > 0) {
|
|
92
|
-
for (const source of skill.sources) if (!storedShas[source]) reasons.push(`new source (${source})`);
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
name: skill.name,
|
|
96
|
-
reasons,
|
|
97
|
-
needsReview: reasons.length > 0
|
|
98
|
-
};
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
//#endregion
|
|
104
|
-
export { checkStaleness as t };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# notify-intent.yml — Drop this into your library repo's .github/workflows/
|
|
2
|
-
#
|
|
3
|
-
# Fires a repository_dispatch event whenever docs or source files change
|
|
4
|
-
# on merge to main. This triggers the skill staleness check workflow.
|
|
5
|
-
#
|
|
6
|
-
# Requirements:
|
|
7
|
-
# - A fine-grained PAT with contents:write on this repository stored
|
|
8
|
-
# as the INTENT_NOTIFY_TOKEN repository secret.
|
|
9
|
-
#
|
|
10
|
-
# Template variables (replaced by `intent setup`):
|
|
11
|
-
# {{PAYLOAD_PACKAGE}} — e.g. @tanstack/query or my-workspace workspace
|
|
12
|
-
# {{DOCS_PATH}} — e.g. docs/**
|
|
13
|
-
# {{SRC_PATH}} — e.g. packages/query-core/src/**
|
|
14
|
-
|
|
15
|
-
name: Trigger Skill Review
|
|
16
|
-
|
|
17
|
-
on:
|
|
18
|
-
push:
|
|
19
|
-
branches: [main]
|
|
20
|
-
paths:
|
|
21
|
-
- '{{DOCS_PATH}}'
|
|
22
|
-
- '{{SRC_PATH}}'
|
|
23
|
-
|
|
24
|
-
jobs:
|
|
25
|
-
notify:
|
|
26
|
-
name: Trigger Skill Review
|
|
27
|
-
runs-on: ubuntu-latest
|
|
28
|
-
steps:
|
|
29
|
-
- name: Checkout
|
|
30
|
-
uses: actions/checkout@v4
|
|
31
|
-
with:
|
|
32
|
-
fetch-depth: 2
|
|
33
|
-
|
|
34
|
-
- name: Collect changed files
|
|
35
|
-
id: changes
|
|
36
|
-
run: |
|
|
37
|
-
FILES=$(git diff --name-only HEAD~1 HEAD | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
|
38
|
-
echo "files=$FILES" >> "$GITHUB_OUTPUT"
|
|
39
|
-
|
|
40
|
-
- name: Dispatch to intent repo
|
|
41
|
-
uses: peter-evans/repository-dispatch@v3
|
|
42
|
-
with:
|
|
43
|
-
token: ${{ secrets.INTENT_NOTIFY_TOKEN }}
|
|
44
|
-
repository: ${{ github.repository }}
|
|
45
|
-
event-type: skill-check
|
|
46
|
-
client-payload: |
|
|
47
|
-
{
|
|
48
|
-
"package": "{{PAYLOAD_PACKAGE}}",
|
|
49
|
-
"sha": "${{ github.sha }}",
|
|
50
|
-
"changed_files": ${{ steps.changes.outputs.files }}
|
|
51
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|