pnpm-plugin-skills 0.1.1 → 0.2.0
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 +1 -1
- package/dist/index.js +154 -32
- package/dist/index.mjs +6993 -0
- package/package.json +8 -3
- package/pnpmfile.cjs +1 -0
- package/pnpmfile.mjs +4 -0
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Then create a `skills.json` in your project root:
|
|
|
25
25
|
```jsonc
|
|
26
26
|
{
|
|
27
27
|
"installDir": ".agents/skills",
|
|
28
|
-
"linkTargets": [".
|
|
28
|
+
"linkTargets": [".claude/skills"],
|
|
29
29
|
"skills": {
|
|
30
30
|
"my-skill": "https://github.com/owner/repo.git#path:/skills/my-skill"
|
|
31
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -6436,9 +6436,14 @@ var __webpack_exports__ = {};
|
|
|
6436
6436
|
const external_node_path_namespaceObject = require("node:path");
|
|
6437
6437
|
var dist = __webpack_require__("../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/dist/index.js");
|
|
6438
6438
|
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
6439
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
6439
6440
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
6440
6441
|
const external_node_util_namespaceObject = require("node:util");
|
|
6441
|
-
|
|
6442
|
+
if ("u" > typeof process) {
|
|
6443
|
+
"u" > typeof Deno && "string" == typeof Deno.version?.deno || "u" > typeof Bun && Bun.version;
|
|
6444
|
+
process.platform, process.arch, process.version;
|
|
6445
|
+
process.argv;
|
|
6446
|
+
} else "u" < typeof navigator || (navigator.platform, navigator.userAgent);
|
|
6442
6447
|
const external_node_process_namespaceObject = require("node:process");
|
|
6443
6448
|
require("node:readline");
|
|
6444
6449
|
__webpack_require__("../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js");
|
|
@@ -6642,19 +6647,58 @@ var __webpack_exports__ = {};
|
|
|
6642
6647
|
return `sha256-${(0, external_node_crypto_namespaceObject.createHash)('sha256').update(content).digest('hex')}`;
|
|
6643
6648
|
}
|
|
6644
6649
|
const execFileAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile);
|
|
6650
|
+
async function resolveGitCommitByLsRemote(url, target) {
|
|
6651
|
+
try {
|
|
6652
|
+
const { stdout } = await execFileAsync('git', [
|
|
6653
|
+
'ls-remote',
|
|
6654
|
+
url,
|
|
6655
|
+
target,
|
|
6656
|
+
`${target}^{}`
|
|
6657
|
+
]);
|
|
6658
|
+
const lines = stdout.trim().split('\n').map((line)=>line.trim()).filter(Boolean);
|
|
6659
|
+
const peeledLine = lines.find((line)=>line.endsWith('^{}'));
|
|
6660
|
+
const resolvedLine = peeledLine ?? lines[0];
|
|
6661
|
+
return resolvedLine?.split('\t')[0]?.trim() || null;
|
|
6662
|
+
} catch {
|
|
6663
|
+
return null;
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
async function resolveGitCommitByClone(url, target) {
|
|
6667
|
+
const checkoutRoot = await (0, promises_namespaceObject.mkdtemp)(external_node_path_namespaceObject.join((0, external_node_os_namespaceObject.tmpdir)(), 'skills-pm-git-ref-'));
|
|
6668
|
+
try {
|
|
6669
|
+
await execFileAsync('git', [
|
|
6670
|
+
'clone',
|
|
6671
|
+
'--bare',
|
|
6672
|
+
'--quiet',
|
|
6673
|
+
url,
|
|
6674
|
+
checkoutRoot
|
|
6675
|
+
]);
|
|
6676
|
+
const { stdout } = await execFileAsync('git', [
|
|
6677
|
+
'rev-parse',
|
|
6678
|
+
'--verify',
|
|
6679
|
+
`${target}^{commit}`
|
|
6680
|
+
], {
|
|
6681
|
+
cwd: checkoutRoot
|
|
6682
|
+
});
|
|
6683
|
+
return stdout.trim().split('\n')[0]?.trim() || null;
|
|
6684
|
+
} catch {
|
|
6685
|
+
return null;
|
|
6686
|
+
} finally{
|
|
6687
|
+
await (0, promises_namespaceObject.rm)(checkoutRoot, {
|
|
6688
|
+
recursive: true,
|
|
6689
|
+
force: true
|
|
6690
|
+
}).catch(()=>{});
|
|
6691
|
+
}
|
|
6692
|
+
}
|
|
6645
6693
|
async function resolveGitCommit(url, ref) {
|
|
6646
6694
|
const target = ref ?? 'HEAD';
|
|
6647
|
-
const
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
const line = stdout.trim().split('\n')[0];
|
|
6653
|
-
const commit = line?.split('\t')[0]?.trim();
|
|
6654
|
-
if (!commit) throw new Error(`Unable to resolve git ref ${target} for ${url}`);
|
|
6655
|
-
return commit;
|
|
6695
|
+
const commit = await resolveGitCommitByLsRemote(url, target);
|
|
6696
|
+
if (commit) return commit;
|
|
6697
|
+
const clonedCommit = await resolveGitCommitByClone(url, target);
|
|
6698
|
+
if (clonedCommit) return clonedCommit;
|
|
6699
|
+
throw new Error(`Unable to resolve git ref ${target} for ${url}`);
|
|
6656
6700
|
}
|
|
6657
|
-
async function
|
|
6701
|
+
async function resolveLockEntry(cwd, specifier) {
|
|
6658
6702
|
const normalized = normalizeSpecifier(specifier);
|
|
6659
6703
|
if ('file' === normalized.type) {
|
|
6660
6704
|
const sourceRoot = external_node_path_namespaceObject.resolve(cwd, normalized.source.slice(5));
|
|
@@ -6664,7 +6708,7 @@ var __webpack_exports__ = {};
|
|
|
6664
6708
|
specifier: normalized.normalized,
|
|
6665
6709
|
resolution: {
|
|
6666
6710
|
type: 'file',
|
|
6667
|
-
path: sourceRoot
|
|
6711
|
+
path: external_node_path_namespaceObject.relative(cwd, sourceRoot) || '.'
|
|
6668
6712
|
},
|
|
6669
6713
|
digest: sha256(`${sourceRoot}:${normalized.path}`)
|
|
6670
6714
|
}
|
|
@@ -6691,7 +6735,7 @@ var __webpack_exports__ = {};
|
|
|
6691
6735
|
async function syncSkillsLock(cwd, manifest, existingLock) {
|
|
6692
6736
|
const nextSkills = {};
|
|
6693
6737
|
for (const specifier of Object.values(manifest.skills)){
|
|
6694
|
-
const { skillName, entry } = await
|
|
6738
|
+
const { skillName, entry } = await resolveLockEntry(cwd, specifier);
|
|
6695
6739
|
nextSkills[skillName] = entry;
|
|
6696
6740
|
}
|
|
6697
6741
|
return {
|
|
@@ -6772,6 +6816,54 @@ var __webpack_exports__ = {};
|
|
|
6772
6816
|
});
|
|
6773
6817
|
}
|
|
6774
6818
|
const materializeGitSkill_execFileAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile);
|
|
6819
|
+
async function checkoutCommit(checkoutRoot, commit) {
|
|
6820
|
+
await materializeGitSkill_execFileAsync('git', [
|
|
6821
|
+
'checkout',
|
|
6822
|
+
commit
|
|
6823
|
+
], {
|
|
6824
|
+
cwd: checkoutRoot
|
|
6825
|
+
});
|
|
6826
|
+
}
|
|
6827
|
+
async function fetchCommitFallback(checkoutRoot, commit) {
|
|
6828
|
+
try {
|
|
6829
|
+
await materializeGitSkill_execFileAsync('git', [
|
|
6830
|
+
'fetch',
|
|
6831
|
+
'--depth',
|
|
6832
|
+
'1',
|
|
6833
|
+
'origin',
|
|
6834
|
+
commit
|
|
6835
|
+
], {
|
|
6836
|
+
cwd: checkoutRoot
|
|
6837
|
+
});
|
|
6838
|
+
return;
|
|
6839
|
+
} catch {}
|
|
6840
|
+
try {
|
|
6841
|
+
await materializeGitSkill_execFileAsync('git', [
|
|
6842
|
+
'fetch',
|
|
6843
|
+
'--tags',
|
|
6844
|
+
'origin'
|
|
6845
|
+
], {
|
|
6846
|
+
cwd: checkoutRoot
|
|
6847
|
+
});
|
|
6848
|
+
return;
|
|
6849
|
+
} catch {}
|
|
6850
|
+
try {
|
|
6851
|
+
await materializeGitSkill_execFileAsync('git', [
|
|
6852
|
+
'fetch',
|
|
6853
|
+
'--unshallow',
|
|
6854
|
+
'origin'
|
|
6855
|
+
], {
|
|
6856
|
+
cwd: checkoutRoot
|
|
6857
|
+
});
|
|
6858
|
+
} catch {
|
|
6859
|
+
await materializeGitSkill_execFileAsync('git', [
|
|
6860
|
+
'fetch',
|
|
6861
|
+
'origin'
|
|
6862
|
+
], {
|
|
6863
|
+
cwd: checkoutRoot
|
|
6864
|
+
});
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6775
6867
|
async function materializeGitSkill(rootDir, skillName, repoUrl, commit, sourcePath, installDir) {
|
|
6776
6868
|
const checkoutRoot = await (0, promises_namespaceObject.mkdtemp)(external_node_path_namespaceObject.join((0, external_node_os_namespaceObject.tmpdir)(), 'skills-pm-git-checkout-'));
|
|
6777
6869
|
try {
|
|
@@ -6782,12 +6874,12 @@ var __webpack_exports__ = {};
|
|
|
6782
6874
|
repoUrl,
|
|
6783
6875
|
checkoutRoot
|
|
6784
6876
|
]);
|
|
6785
|
-
if (commit && 'HEAD' !== commit)
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
}
|
|
6877
|
+
if (commit && 'HEAD' !== commit) try {
|
|
6878
|
+
await checkoutCommit(checkoutRoot, commit);
|
|
6879
|
+
} catch {
|
|
6880
|
+
await fetchCommitFallback(checkoutRoot, commit);
|
|
6881
|
+
await checkoutCommit(checkoutRoot, commit);
|
|
6882
|
+
}
|
|
6791
6883
|
const skillDocPath = external_node_path_namespaceObject.join(checkoutRoot, sourcePath.replace(/^\//, ''), 'SKILL.md');
|
|
6792
6884
|
await (0, promises_namespaceObject.readFile)(skillDocPath, 'utf8');
|
|
6793
6885
|
await materializeLocalSkill(rootDir, skillName, checkoutRoot, sourcePath, installDir);
|
|
@@ -6835,21 +6927,17 @@ var __webpack_exports__ = {};
|
|
|
6835
6927
|
}
|
|
6836
6928
|
} catch {}
|
|
6837
6929
|
}
|
|
6930
|
+
const installStageHooks = {
|
|
6931
|
+
beforeFetch: async (_rootDir, _manifest, _lockfile)=>{}
|
|
6932
|
+
};
|
|
6838
6933
|
function extractSkillPath(specifier, skillName) {
|
|
6839
6934
|
const marker = '#path:';
|
|
6840
6935
|
const index = specifier.indexOf(marker);
|
|
6841
6936
|
if (index >= 0) return specifier.slice(index + marker.length);
|
|
6842
6937
|
return `/${skillName}`;
|
|
6843
6938
|
}
|
|
6844
|
-
async function
|
|
6845
|
-
|
|
6846
|
-
if (!manifest) return {
|
|
6847
|
-
status: 'skipped',
|
|
6848
|
-
reason: 'manifest-missing'
|
|
6849
|
-
};
|
|
6850
|
-
const currentLock = await readSkillsLock(rootDir);
|
|
6851
|
-
const lockfile = await syncSkillsLock(rootDir, manifest, currentLock);
|
|
6852
|
-
await writeSkillsLock(rootDir, lockfile);
|
|
6939
|
+
async function fetchSkillsFromLock(rootDir, manifest, lockfile) {
|
|
6940
|
+
await installStageHooks.beforeFetch(rootDir, manifest, lockfile);
|
|
6853
6941
|
const lockDigest = sha256(JSON.stringify(lockfile));
|
|
6854
6942
|
const state = await readInstallState(rootDir);
|
|
6855
6943
|
if (state?.lockDigest === lockDigest) return {
|
|
@@ -6860,10 +6948,15 @@ var __webpack_exports__ = {};
|
|
|
6860
6948
|
const linkTargets = manifest.linkTargets ?? [];
|
|
6861
6949
|
await pruneManagedSkills(rootDir, installDir, linkTargets, Object.keys(lockfile.skills));
|
|
6862
6950
|
for (const [skillName, entry] of Object.entries(lockfile.skills)){
|
|
6863
|
-
if ('file' === entry.resolution.type)
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6951
|
+
if ('file' === entry.resolution.type) {
|
|
6952
|
+
await materializeLocalSkill(rootDir, skillName, external_node_path_namespaceObject.resolve(rootDir, entry.resolution.path), extractSkillPath(entry.specifier, skillName), installDir);
|
|
6953
|
+
continue;
|
|
6954
|
+
}
|
|
6955
|
+
if ('git' === entry.resolution.type) {
|
|
6956
|
+
await materializeGitSkill(rootDir, skillName, entry.resolution.url, entry.resolution.commit, entry.resolution.path, installDir);
|
|
6957
|
+
continue;
|
|
6958
|
+
}
|
|
6959
|
+
throw new Error(`Unsupported resolution type in 0.1.0 core flow: ${entry.resolution.type}`);
|
|
6867
6960
|
}
|
|
6868
6961
|
await writeInstallState(rootDir, {
|
|
6869
6962
|
lockDigest,
|
|
@@ -6872,6 +6965,31 @@ var __webpack_exports__ = {};
|
|
|
6872
6965
|
installerVersion: '0.1.0',
|
|
6873
6966
|
installedAt: new Date().toISOString()
|
|
6874
6967
|
});
|
|
6968
|
+
return {
|
|
6969
|
+
status: 'fetched',
|
|
6970
|
+
fetched: Object.keys(lockfile.skills)
|
|
6971
|
+
};
|
|
6972
|
+
}
|
|
6973
|
+
async function linkSkillsFromLock(rootDir, manifest, lockfile) {
|
|
6974
|
+
const installDir = manifest.installDir ?? '.agents/skills';
|
|
6975
|
+
const linkTargets = manifest.linkTargets ?? [];
|
|
6976
|
+
for (const skillName of Object.keys(lockfile.skills))for (const linkTarget of linkTargets)await linkSkill(rootDir, installDir, linkTarget, skillName);
|
|
6977
|
+
return {
|
|
6978
|
+
status: 'linked',
|
|
6979
|
+
linked: Object.keys(lockfile.skills)
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
async function installSkills(rootDir) {
|
|
6983
|
+
const manifest = await readSkillsManifest(rootDir);
|
|
6984
|
+
if (!manifest) return {
|
|
6985
|
+
status: 'skipped',
|
|
6986
|
+
reason: 'manifest-missing'
|
|
6987
|
+
};
|
|
6988
|
+
const currentLock = await readSkillsLock(rootDir);
|
|
6989
|
+
const lockfile = await syncSkillsLock(rootDir, manifest, currentLock);
|
|
6990
|
+
await fetchSkillsFromLock(rootDir, manifest, lockfile);
|
|
6991
|
+
await linkSkillsFromLock(rootDir, manifest, lockfile);
|
|
6992
|
+
await writeSkillsLock(rootDir, lockfile);
|
|
6875
6993
|
return {
|
|
6876
6994
|
status: 'installed',
|
|
6877
6995
|
installed: Object.keys(lockfile.skills)
|
|
@@ -6880,6 +6998,10 @@ var __webpack_exports__ = {};
|
|
|
6880
6998
|
async function installCommand(options) {
|
|
6881
6999
|
return installSkills(options.cwd);
|
|
6882
7000
|
}
|
|
7001
|
+
var package_namespaceObject = {
|
|
7002
|
+
rE: "0.2.0"
|
|
7003
|
+
};
|
|
7004
|
+
package_namespaceObject.rE;
|
|
6883
7005
|
async function preResolution(options = {}) {
|
|
6884
7006
|
const lockfileDir = options.lockfileDir;
|
|
6885
7007
|
if (!lockfileDir) return;
|