@localskills/cli 0.1.7 → 0.1.9
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/index.js +77 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1476,7 +1476,7 @@ function detect(projectDir) {
|
|
|
1476
1476
|
project: existsSync3(join2(cwd, ".cursor"))
|
|
1477
1477
|
};
|
|
1478
1478
|
}
|
|
1479
|
-
function resolvePath(slug, scope, projectDir) {
|
|
1479
|
+
function resolvePath(slug, scope, projectDir, _contentType) {
|
|
1480
1480
|
const safeName = slug.replace(/\//g, "-");
|
|
1481
1481
|
if (scope === "global") {
|
|
1482
1482
|
return join2(homedir2(), ".cursor", "rules", `${safeName}.mdc`);
|
|
@@ -1537,19 +1537,22 @@ function detect2(projectDir) {
|
|
|
1537
1537
|
project: existsSync4(join3(cwd, ".claude"))
|
|
1538
1538
|
};
|
|
1539
1539
|
}
|
|
1540
|
-
function resolvePath2(slug, scope, projectDir) {
|
|
1540
|
+
function resolvePath2(slug, scope, projectDir, contentType) {
|
|
1541
1541
|
const safeName = slug.replace(/\//g, "-");
|
|
1542
|
-
|
|
1543
|
-
|
|
1542
|
+
const base = scope === "global" ? join3(homedir3(), ".claude") : join3(projectDir || process.cwd(), ".claude");
|
|
1543
|
+
if (contentType === "rule") {
|
|
1544
|
+
return join3(base, "rules", `${safeName}.md`);
|
|
1544
1545
|
}
|
|
1545
|
-
|
|
1546
|
-
return join3(dir, ".claude", "skills", safeName, "SKILL.md");
|
|
1546
|
+
return join3(base, "skills", safeName, "SKILL.md");
|
|
1547
1547
|
}
|
|
1548
1548
|
function transformContent2(content, skill) {
|
|
1549
|
+
if (skill.type === "rule") {
|
|
1550
|
+
return toPlainMD(content);
|
|
1551
|
+
}
|
|
1549
1552
|
return toClaudeMD(content, skill);
|
|
1550
1553
|
}
|
|
1551
1554
|
function install2(opts) {
|
|
1552
|
-
const targetPath = resolvePath2(opts.slug, opts.scope, opts.projectDir);
|
|
1555
|
+
const targetPath = resolvePath2(opts.slug, opts.scope, opts.projectDir, opts.contentType);
|
|
1553
1556
|
const targetDir = join3(targetPath, "..");
|
|
1554
1557
|
if (opts.method === "symlink") {
|
|
1555
1558
|
createSymlink(opts.cachePath, targetPath);
|
|
@@ -1665,7 +1668,7 @@ function detect3() {
|
|
|
1665
1668
|
}
|
|
1666
1669
|
return { global: hasCommand, project: hasCommand };
|
|
1667
1670
|
}
|
|
1668
|
-
function resolvePath3(slug, scope, projectDir) {
|
|
1671
|
+
function resolvePath3(slug, scope, projectDir, _contentType) {
|
|
1669
1672
|
if (scope === "global") {
|
|
1670
1673
|
return join4(homedir4(), ".codex", "AGENTS.md");
|
|
1671
1674
|
}
|
|
@@ -1718,7 +1721,7 @@ function detect4(projectDir) {
|
|
|
1718
1721
|
project: existsSync6(join5(cwd, ".windsurf"))
|
|
1719
1722
|
};
|
|
1720
1723
|
}
|
|
1721
|
-
function resolvePath4(slug, scope, projectDir) {
|
|
1724
|
+
function resolvePath4(slug, scope, projectDir, _contentType) {
|
|
1722
1725
|
const safeName = slug.replace(/\//g, "-");
|
|
1723
1726
|
if (scope === "global") {
|
|
1724
1727
|
return join5(homedir5(), ".codeium", "windsurf", "memories", "global_rules.md");
|
|
@@ -1782,7 +1785,7 @@ function detect5(projectDir) {
|
|
|
1782
1785
|
project: existsSync7(join6(cwd, ".clinerules"))
|
|
1783
1786
|
};
|
|
1784
1787
|
}
|
|
1785
|
-
function resolvePath5(slug, scope, projectDir) {
|
|
1788
|
+
function resolvePath5(slug, scope, projectDir, _contentType) {
|
|
1786
1789
|
if (scope === "global") {
|
|
1787
1790
|
throw new Error("Cline does not support global installation");
|
|
1788
1791
|
}
|
|
@@ -1840,7 +1843,7 @@ function detect6(projectDir) {
|
|
|
1840
1843
|
project: existsSync8(join7(cwd, ".github"))
|
|
1841
1844
|
};
|
|
1842
1845
|
}
|
|
1843
|
-
function resolvePath6(slug, scope, projectDir) {
|
|
1846
|
+
function resolvePath6(slug, scope, projectDir, _contentType) {
|
|
1844
1847
|
if (scope === "global") {
|
|
1845
1848
|
throw new Error("GitHub Copilot does not support global installation");
|
|
1846
1849
|
}
|
|
@@ -1898,7 +1901,7 @@ function detect7(projectDir) {
|
|
|
1898
1901
|
project: hasCommand || existsSync9(join8(cwd, ".opencode"))
|
|
1899
1902
|
};
|
|
1900
1903
|
}
|
|
1901
|
-
function resolvePath7(slug, scope, projectDir) {
|
|
1904
|
+
function resolvePath7(slug, scope, projectDir, _contentType) {
|
|
1902
1905
|
const safeName = slug.replace(/\//g, "-");
|
|
1903
1906
|
if (scope === "global") {
|
|
1904
1907
|
return join8(homedir6(), ".config", "opencode", "rules", `${safeName}.md`);
|
|
@@ -1959,12 +1962,13 @@ function detect8() {
|
|
|
1959
1962
|
}
|
|
1960
1963
|
return { global: false, project: hasCommand };
|
|
1961
1964
|
}
|
|
1962
|
-
function resolvePath8(slug, scope, projectDir) {
|
|
1965
|
+
function resolvePath8(slug, scope, projectDir, contentType) {
|
|
1963
1966
|
if (scope === "global") {
|
|
1964
1967
|
throw new Error("Aider does not support global installation");
|
|
1965
1968
|
}
|
|
1966
1969
|
const safeName = slug.replace(/\//g, "-");
|
|
1967
|
-
|
|
1970
|
+
const subdir = contentType === "rule" ? "rules" : "skills";
|
|
1971
|
+
return join9(projectDir || process.cwd(), ".aider", subdir, `${safeName}.md`);
|
|
1968
1972
|
}
|
|
1969
1973
|
function transformContent8(content) {
|
|
1970
1974
|
return toPlainMD(content);
|
|
@@ -1993,7 +1997,7 @@ function removeAiderRead(projectDir, relativePath) {
|
|
|
1993
1997
|
writeFileSync8(configPath, filtered.join("\n"));
|
|
1994
1998
|
}
|
|
1995
1999
|
function install8(opts) {
|
|
1996
|
-
const targetPath = resolvePath8(opts.slug, opts.scope, opts.projectDir);
|
|
2000
|
+
const targetPath = resolvePath8(opts.slug, opts.scope, opts.projectDir, opts.contentType);
|
|
1997
2001
|
const projectDir = opts.projectDir || process.cwd();
|
|
1998
2002
|
if (opts.method === "symlink") {
|
|
1999
2003
|
createSymlink(opts.cachePath, targetPath);
|
|
@@ -2002,7 +2006,8 @@ function install8(opts) {
|
|
|
2002
2006
|
writeFileSync8(targetPath, opts.content);
|
|
2003
2007
|
}
|
|
2004
2008
|
const safeName = opts.slug.replace(/\//g, "-");
|
|
2005
|
-
const
|
|
2009
|
+
const subdir = opts.contentType === "rule" ? "rules" : "skills";
|
|
2010
|
+
const relativePath = `.aider/${subdir}/${safeName}.md`;
|
|
2006
2011
|
addAiderRead(projectDir, relativePath);
|
|
2007
2012
|
return targetPath;
|
|
2008
2013
|
}
|
|
@@ -2014,8 +2019,8 @@ function uninstall8(installation, slug) {
|
|
|
2014
2019
|
}
|
|
2015
2020
|
const projectDir = installation.projectDir || process.cwd();
|
|
2016
2021
|
const safeName = slug.replace(/\//g, "-");
|
|
2017
|
-
|
|
2018
|
-
removeAiderRead(projectDir,
|
|
2022
|
+
removeAiderRead(projectDir, `.aider/skills/${safeName}.md`);
|
|
2023
|
+
removeAiderRead(projectDir, `.aider/rules/${safeName}.md`);
|
|
2019
2024
|
}
|
|
2020
2025
|
function defaultMethod8() {
|
|
2021
2026
|
return "symlink";
|
|
@@ -2074,6 +2079,7 @@ function store(slug, content, skill, version) {
|
|
|
2074
2079
|
version,
|
|
2075
2080
|
name: skill.name,
|
|
2076
2081
|
description: skill.description,
|
|
2082
|
+
type: skill.type ?? "skill",
|
|
2077
2083
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2078
2084
|
};
|
|
2079
2085
|
writeFileSync9(join10(dir, "meta.json"), JSON.stringify(meta, null, 2) + "\n");
|
|
@@ -2086,6 +2092,13 @@ function getPlatformFile(slug, platform, skill) {
|
|
|
2086
2092
|
if (!raw) throw new Error(`No cached content for ${slug}`);
|
|
2087
2093
|
const transformed = adapter.transformContent(raw, skill);
|
|
2088
2094
|
if (platform === "claude") {
|
|
2095
|
+
if (skill.type === "rule") {
|
|
2096
|
+
const claudeRuleDir = join10(dir, "claude-rule");
|
|
2097
|
+
mkdirSync10(claudeRuleDir, { recursive: true });
|
|
2098
|
+
const filePath3 = join10(claudeRuleDir, `${slug.replace(/\//g, "-")}.md`);
|
|
2099
|
+
writeFileSync9(filePath3, transformed);
|
|
2100
|
+
return filePath3;
|
|
2101
|
+
}
|
|
2089
2102
|
const claudeDir = join10(dir, "claude");
|
|
2090
2103
|
mkdirSync10(claudeDir, { recursive: true });
|
|
2091
2104
|
const filePath2 = join10(claudeDir, "SKILL.md");
|
|
@@ -2350,6 +2363,7 @@ var installCommand = new Command2("install").description("Install a skill locall
|
|
|
2350
2363
|
const { skill, content, version } = res.data;
|
|
2351
2364
|
spinner.stop(`Fetched ${skill.name} v${version}`);
|
|
2352
2365
|
store(slug, content, skill, version);
|
|
2366
|
+
const contentType = skill.type ?? "skill";
|
|
2353
2367
|
const installations = [];
|
|
2354
2368
|
const results = [];
|
|
2355
2369
|
for (const platformId of platforms) {
|
|
@@ -2372,7 +2386,8 @@ var installCommand = new Command2("install").description("Install a skill locall
|
|
|
2372
2386
|
scope,
|
|
2373
2387
|
method: actualMethod,
|
|
2374
2388
|
cachePath,
|
|
2375
|
-
projectDir
|
|
2389
|
+
projectDir,
|
|
2390
|
+
contentType
|
|
2376
2391
|
});
|
|
2377
2392
|
const installation = {
|
|
2378
2393
|
platform: platformId,
|
|
@@ -2390,6 +2405,7 @@ var installCommand = new Command2("install").description("Install a skill locall
|
|
|
2390
2405
|
const skillRecord = {
|
|
2391
2406
|
slug,
|
|
2392
2407
|
name: skill.name,
|
|
2408
|
+
type: contentType,
|
|
2393
2409
|
hash: skill.contentHash,
|
|
2394
2410
|
version,
|
|
2395
2411
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2556,6 +2572,7 @@ ${transformed}`
|
|
|
2556
2572
|
import { Command as Command6 } from "commander";
|
|
2557
2573
|
import { readFileSync as readFileSync6, existsSync as existsSync14 } from "fs";
|
|
2558
2574
|
import { resolve as resolve3, basename as basename2, extname as extname2 } from "path";
|
|
2575
|
+
import { homedir as homedir10 } from "os";
|
|
2559
2576
|
|
|
2560
2577
|
// src/lib/scanner.ts
|
|
2561
2578
|
import { existsSync as existsSync13, readdirSync as readdirSync2, readFileSync as readFileSync5 } from "fs";
|
|
@@ -2570,6 +2587,8 @@ function scanForSkills(projectDir) {
|
|
|
2570
2587
|
scanDirectory(join12(cwd, ".cursor", "rules"), ".mdc", "cursor", "project", results);
|
|
2571
2588
|
scanClaudeSkills(join12(home, ".claude", "skills"), "global", results);
|
|
2572
2589
|
scanClaudeSkills(join12(cwd, ".claude", "skills"), "project", results);
|
|
2590
|
+
scanDirectory(join12(home, ".claude", "rules"), ".md", "claude", "global", results, "rule");
|
|
2591
|
+
scanDirectory(join12(cwd, ".claude", "rules"), ".md", "claude", "project", results, "rule");
|
|
2573
2592
|
scanSingleFile(join12(home, ".codex", "AGENTS.md"), "codex", "global", results);
|
|
2574
2593
|
scanSingleFile(join12(cwd, "AGENTS.md"), "codex", "project", results);
|
|
2575
2594
|
scanSingleFile(
|
|
@@ -2618,7 +2637,7 @@ function slugFromFilename(filename) {
|
|
|
2618
2637
|
function nameFromSlug(slug) {
|
|
2619
2638
|
return slug.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
2620
2639
|
}
|
|
2621
|
-
function scanDirectory(dir, ext, platform, scope, results) {
|
|
2640
|
+
function scanDirectory(dir, ext, platform, scope, results, contentType = "skill") {
|
|
2622
2641
|
if (!existsSync13(dir)) return;
|
|
2623
2642
|
let entries;
|
|
2624
2643
|
try {
|
|
@@ -2640,7 +2659,8 @@ function scanDirectory(dir, ext, platform, scope, results) {
|
|
|
2640
2659
|
scope,
|
|
2641
2660
|
suggestedName: nameFromSlug(slug),
|
|
2642
2661
|
suggestedSlug: slug,
|
|
2643
|
-
content
|
|
2662
|
+
content,
|
|
2663
|
+
contentType
|
|
2644
2664
|
});
|
|
2645
2665
|
} catch {
|
|
2646
2666
|
}
|
|
@@ -2667,7 +2687,8 @@ function scanClaudeSkills(skillsDir, scope, results) {
|
|
|
2667
2687
|
scope,
|
|
2668
2688
|
suggestedName: nameFromSlug(entry),
|
|
2669
2689
|
suggestedSlug: entry,
|
|
2670
|
-
content
|
|
2690
|
+
content,
|
|
2691
|
+
contentType: "skill"
|
|
2671
2692
|
});
|
|
2672
2693
|
} catch {
|
|
2673
2694
|
}
|
|
@@ -2697,7 +2718,8 @@ function scanSingleFile(filePath, platform, scope, results) {
|
|
|
2697
2718
|
scope,
|
|
2698
2719
|
suggestedName: nameFromSlug(slug2),
|
|
2699
2720
|
suggestedSlug: slug2,
|
|
2700
|
-
content: content2
|
|
2721
|
+
content: content2,
|
|
2722
|
+
contentType: "skill"
|
|
2701
2723
|
});
|
|
2702
2724
|
}
|
|
2703
2725
|
return;
|
|
@@ -2711,7 +2733,8 @@ function scanSingleFile(filePath, platform, scope, results) {
|
|
|
2711
2733
|
scope,
|
|
2712
2734
|
suggestedName: nameFromSlug(slug),
|
|
2713
2735
|
suggestedSlug: slug,
|
|
2714
|
-
content
|
|
2736
|
+
content,
|
|
2737
|
+
contentType: "skill"
|
|
2715
2738
|
});
|
|
2716
2739
|
}
|
|
2717
2740
|
|
|
@@ -2720,7 +2743,7 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
|
|
|
2720
2743
|
"--visibility <visibility>",
|
|
2721
2744
|
"Visibility: public, private, or unlisted",
|
|
2722
2745
|
"private"
|
|
2723
|
-
).option("-m, --message <message>", "Version message").action(
|
|
2746
|
+
).option("--type <type>", "Content type: skill or rule", "skill").option("-m, --message <message>", "Version message").action(
|
|
2724
2747
|
async (fileArg, opts) => {
|
|
2725
2748
|
const client = new ApiClient();
|
|
2726
2749
|
if (!client.isAuthenticated()) {
|
|
@@ -2753,13 +2776,15 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
|
|
|
2753
2776
|
const defaultSlug = basename2(filePath, extname2(filePath));
|
|
2754
2777
|
const defaultName = defaultSlug.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
2755
2778
|
const skillName = opts.name || defaultName;
|
|
2779
|
+
const contentType = validateContentType(opts.type || "skill");
|
|
2756
2780
|
const visibility = validateVisibility(opts.visibility || "private");
|
|
2757
2781
|
const tenantId = await resolveTeam(teams, opts.team);
|
|
2758
2782
|
await uploadSkill(client, {
|
|
2759
2783
|
name: skillName,
|
|
2760
2784
|
content,
|
|
2761
2785
|
tenantId,
|
|
2762
|
-
visibility
|
|
2786
|
+
visibility,
|
|
2787
|
+
type: contentType
|
|
2763
2788
|
});
|
|
2764
2789
|
} else {
|
|
2765
2790
|
We("localskills publish");
|
|
@@ -2776,11 +2801,11 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
|
|
|
2776
2801
|
return;
|
|
2777
2802
|
}
|
|
2778
2803
|
const selected = await je({
|
|
2779
|
-
message: "Select
|
|
2804
|
+
message: "Select items to publish",
|
|
2780
2805
|
options: detected.map((s) => ({
|
|
2781
2806
|
value: s,
|
|
2782
2807
|
label: s.suggestedName,
|
|
2783
|
-
hint: `${s.platform}/${s.scope} ${shortenPath(s.filePath)}`
|
|
2808
|
+
hint: `${s.platform}/${s.scope}/${s.contentType} ${shortenPath(s.filePath)}`
|
|
2784
2809
|
})),
|
|
2785
2810
|
required: true
|
|
2786
2811
|
});
|
|
@@ -2817,11 +2842,24 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
|
|
|
2817
2842
|
Ne("Cancelled.");
|
|
2818
2843
|
process.exit(0);
|
|
2819
2844
|
}
|
|
2845
|
+
const contentType = await Je({
|
|
2846
|
+
message: "Type?",
|
|
2847
|
+
options: [
|
|
2848
|
+
{ value: "skill", label: "Skill", hint: "Reusable agent instructions" },
|
|
2849
|
+
{ value: "rule", label: "Rule", hint: "Governance constraints" }
|
|
2850
|
+
],
|
|
2851
|
+
initialValue: skill.contentType
|
|
2852
|
+
});
|
|
2853
|
+
if (Ct(contentType)) {
|
|
2854
|
+
Ne("Cancelled.");
|
|
2855
|
+
process.exit(0);
|
|
2856
|
+
}
|
|
2820
2857
|
await uploadSkill(client, {
|
|
2821
2858
|
name,
|
|
2822
2859
|
content: skill.content,
|
|
2823
2860
|
tenantId,
|
|
2824
|
-
visibility
|
|
2861
|
+
visibility,
|
|
2862
|
+
type: contentType
|
|
2825
2863
|
});
|
|
2826
2864
|
}
|
|
2827
2865
|
Le("Done!");
|
|
@@ -2861,7 +2899,8 @@ async function uploadSkill(client, params) {
|
|
|
2861
2899
|
name: params.name,
|
|
2862
2900
|
content: params.content,
|
|
2863
2901
|
tenantId: params.tenantId,
|
|
2864
|
-
visibility: params.visibility
|
|
2902
|
+
visibility: params.visibility,
|
|
2903
|
+
type: params.type
|
|
2865
2904
|
});
|
|
2866
2905
|
if (!res.success || !res.data) {
|
|
2867
2906
|
spinner.stop(`Failed: ${res.error || "Unknown error"}`);
|
|
@@ -2870,6 +2909,13 @@ async function uploadSkill(client, params) {
|
|
|
2870
2909
|
spinner.stop(`Published!`);
|
|
2871
2910
|
R2.success(`\u2192 localskills.sh/s/${res.data.slug}`);
|
|
2872
2911
|
}
|
|
2912
|
+
function validateContentType(value) {
|
|
2913
|
+
if (value === "skill" || value === "rule") {
|
|
2914
|
+
return value;
|
|
2915
|
+
}
|
|
2916
|
+
console.error(`Invalid type: ${value}. Use skill or rule.`);
|
|
2917
|
+
process.exit(1);
|
|
2918
|
+
}
|
|
2873
2919
|
function validateVisibility(value) {
|
|
2874
2920
|
if (value === "public" || value === "private" || value === "unlisted") {
|
|
2875
2921
|
return value;
|
|
@@ -2878,7 +2924,7 @@ function validateVisibility(value) {
|
|
|
2878
2924
|
process.exit(1);
|
|
2879
2925
|
}
|
|
2880
2926
|
function shortenPath(filePath) {
|
|
2881
|
-
const home =
|
|
2927
|
+
const home = homedir10();
|
|
2882
2928
|
if (filePath.startsWith(home)) {
|
|
2883
2929
|
return "~" + filePath.slice(home.length);
|
|
2884
2930
|
}
|