@localskills/cli 0.1.8 → 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.
Files changed (2) hide show
  1. package/dist/index.js +75 -30
  2. 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
- if (scope === "global") {
1543
- return join3(homedir3(), ".claude", "skills", safeName, "SKILL.md");
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
- const dir = projectDir || process.cwd();
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
- return join9(projectDir || process.cwd(), ".aider", "skills", `${safeName}.md`);
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 relativePath = `.aider/skills/${safeName}.md`;
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
- const relativePath = `.aider/skills/${safeName}.md`;
2018
- removeAiderRead(projectDir, relativePath);
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(),
@@ -2571,6 +2587,8 @@ function scanForSkills(projectDir) {
2571
2587
  scanDirectory(join12(cwd, ".cursor", "rules"), ".mdc", "cursor", "project", results);
2572
2588
  scanClaudeSkills(join12(home, ".claude", "skills"), "global", results);
2573
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");
2574
2592
  scanSingleFile(join12(home, ".codex", "AGENTS.md"), "codex", "global", results);
2575
2593
  scanSingleFile(join12(cwd, "AGENTS.md"), "codex", "project", results);
2576
2594
  scanSingleFile(
@@ -2619,7 +2637,7 @@ function slugFromFilename(filename) {
2619
2637
  function nameFromSlug(slug) {
2620
2638
  return slug.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
2621
2639
  }
2622
- function scanDirectory(dir, ext, platform, scope, results) {
2640
+ function scanDirectory(dir, ext, platform, scope, results, contentType = "skill") {
2623
2641
  if (!existsSync13(dir)) return;
2624
2642
  let entries;
2625
2643
  try {
@@ -2641,7 +2659,8 @@ function scanDirectory(dir, ext, platform, scope, results) {
2641
2659
  scope,
2642
2660
  suggestedName: nameFromSlug(slug),
2643
2661
  suggestedSlug: slug,
2644
- content
2662
+ content,
2663
+ contentType
2645
2664
  });
2646
2665
  } catch {
2647
2666
  }
@@ -2668,7 +2687,8 @@ function scanClaudeSkills(skillsDir, scope, results) {
2668
2687
  scope,
2669
2688
  suggestedName: nameFromSlug(entry),
2670
2689
  suggestedSlug: entry,
2671
- content
2690
+ content,
2691
+ contentType: "skill"
2672
2692
  });
2673
2693
  } catch {
2674
2694
  }
@@ -2698,7 +2718,8 @@ function scanSingleFile(filePath, platform, scope, results) {
2698
2718
  scope,
2699
2719
  suggestedName: nameFromSlug(slug2),
2700
2720
  suggestedSlug: slug2,
2701
- content: content2
2721
+ content: content2,
2722
+ contentType: "skill"
2702
2723
  });
2703
2724
  }
2704
2725
  return;
@@ -2712,7 +2733,8 @@ function scanSingleFile(filePath, platform, scope, results) {
2712
2733
  scope,
2713
2734
  suggestedName: nameFromSlug(slug),
2714
2735
  suggestedSlug: slug,
2715
- content
2736
+ content,
2737
+ contentType: "skill"
2716
2738
  });
2717
2739
  }
2718
2740
 
@@ -2721,7 +2743,7 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
2721
2743
  "--visibility <visibility>",
2722
2744
  "Visibility: public, private, or unlisted",
2723
2745
  "private"
2724
- ).option("-m, --message <message>", "Version message").action(
2746
+ ).option("--type <type>", "Content type: skill or rule", "skill").option("-m, --message <message>", "Version message").action(
2725
2747
  async (fileArg, opts) => {
2726
2748
  const client = new ApiClient();
2727
2749
  if (!client.isAuthenticated()) {
@@ -2754,13 +2776,15 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
2754
2776
  const defaultSlug = basename2(filePath, extname2(filePath));
2755
2777
  const defaultName = defaultSlug.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
2756
2778
  const skillName = opts.name || defaultName;
2779
+ const contentType = validateContentType(opts.type || "skill");
2757
2780
  const visibility = validateVisibility(opts.visibility || "private");
2758
2781
  const tenantId = await resolveTeam(teams, opts.team);
2759
2782
  await uploadSkill(client, {
2760
2783
  name: skillName,
2761
2784
  content,
2762
2785
  tenantId,
2763
- visibility
2786
+ visibility,
2787
+ type: contentType
2764
2788
  });
2765
2789
  } else {
2766
2790
  We("localskills publish");
@@ -2777,11 +2801,11 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
2777
2801
  return;
2778
2802
  }
2779
2803
  const selected = await je({
2780
- message: "Select skills to publish",
2804
+ message: "Select items to publish",
2781
2805
  options: detected.map((s) => ({
2782
2806
  value: s,
2783
2807
  label: s.suggestedName,
2784
- hint: `${s.platform}/${s.scope} ${shortenPath(s.filePath)}`
2808
+ hint: `${s.platform}/${s.scope}/${s.contentType} ${shortenPath(s.filePath)}`
2785
2809
  })),
2786
2810
  required: true
2787
2811
  });
@@ -2818,11 +2842,24 @@ var publishCommand = new Command6("publish").description("Publish local skill fi
2818
2842
  Ne("Cancelled.");
2819
2843
  process.exit(0);
2820
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
+ }
2821
2857
  await uploadSkill(client, {
2822
2858
  name,
2823
2859
  content: skill.content,
2824
2860
  tenantId,
2825
- visibility
2861
+ visibility,
2862
+ type: contentType
2826
2863
  });
2827
2864
  }
2828
2865
  Le("Done!");
@@ -2862,7 +2899,8 @@ async function uploadSkill(client, params) {
2862
2899
  name: params.name,
2863
2900
  content: params.content,
2864
2901
  tenantId: params.tenantId,
2865
- visibility: params.visibility
2902
+ visibility: params.visibility,
2903
+ type: params.type
2866
2904
  });
2867
2905
  if (!res.success || !res.data) {
2868
2906
  spinner.stop(`Failed: ${res.error || "Unknown error"}`);
@@ -2871,6 +2909,13 @@ async function uploadSkill(client, params) {
2871
2909
  spinner.stop(`Published!`);
2872
2910
  R2.success(`\u2192 localskills.sh/s/${res.data.slug}`);
2873
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
+ }
2874
2919
  function validateVisibility(value) {
2875
2920
  if (value === "public" || value === "private" || value === "unlisted") {
2876
2921
  return value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localskills/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "CLI for localskills.sh — install agent skills locally",
5
5
  "type": "module",
6
6
  "bin": {