skilldb 0.5.0 → 0.5.2

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 CHANGED
@@ -12,13 +12,16 @@ Connect SkillDB directly to your AI coding tool via the Model Context Protocol:
12
12
  # Step 1: Install globally (one time)
13
13
  npm install -g skilldb
14
14
 
15
- # Step 2: Add to Claude Code
16
- claude mcp add skilldb -- skilldb-mcp
15
+ # Step 2: Get your free API key at https://skilldb.dev/api-access
17
16
 
18
- # With API key (for full skill content)
19
- claude mcp add skilldb -- skilldb-mcp --api-key sk_live_xxx
17
+ # Step 3: Add to Claude Code (with API key for full content)
18
+ claude mcp add skilldb -- skilldb-mcp --api-key sk_live_YOUR_KEY
20
19
  ```
21
20
 
21
+ > **⚠️ Without an API key**, you can search and browse skills (metadata only).
22
+ > **With a free API key**, you get full skill content — the actual markdown instructions your agent uses.
23
+ > Get your key in 30 seconds at [skilldb.dev/api-access](https://skilldb.dev/api-access).
24
+
22
25
  **Cursor** — add to `.cursor/mcp.json`:
23
26
  ```json
24
27
  {
package/dist/cli.js CHANGED
@@ -1760,6 +1760,178 @@ ${pc17.green(`${upToDate} up to date`)}` + (changed > 0 ? pc17.yellow(`, ${chang
1760
1760
  }
1761
1761
  }
1762
1762
 
1763
+ // src/commands/purge.ts
1764
+ import fs15 from "fs";
1765
+ import path15 from "path";
1766
+ import pc18 from "picocolors";
1767
+ import readline3 from "readline";
1768
+ var SKILLDB_DIR11 = ".skilldb";
1769
+ var SKILLS_DIR8 = "skills";
1770
+ var ACTIVE_DIR8 = "active";
1771
+ var SLIM_DIR2 = "slim";
1772
+ function prompt3(question) {
1773
+ const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
1774
+ return new Promise((resolve) => {
1775
+ rl.question(question, (answer) => {
1776
+ rl.close();
1777
+ resolve(answer.trim());
1778
+ });
1779
+ });
1780
+ }
1781
+ function getDirectorySize(dir) {
1782
+ if (!fs15.existsSync(dir)) return 0;
1783
+ let size = 0;
1784
+ for (const entry of fs15.readdirSync(dir, { withFileTypes: true })) {
1785
+ const full = path15.join(dir, entry.name);
1786
+ if (entry.isDirectory()) size += getDirectorySize(full);
1787
+ else size += fs15.statSync(full).size;
1788
+ }
1789
+ return size;
1790
+ }
1791
+ function collectAllSkills(dir) {
1792
+ const skills = [];
1793
+ if (!fs15.existsSync(dir)) return skills;
1794
+ for (const pack of fs15.readdirSync(dir, { withFileTypes: true })) {
1795
+ if (!pack.isDirectory()) continue;
1796
+ for (const file of fs15.readdirSync(path15.join(dir, pack.name))) {
1797
+ if (file.endsWith(".md")) skills.push(`${pack.name}/${file}`);
1798
+ }
1799
+ }
1800
+ return skills;
1801
+ }
1802
+ function collectActivePacks(cwd) {
1803
+ const activeDir = path15.join(cwd, SKILLDB_DIR11, ACTIVE_DIR8);
1804
+ const packs = /* @__PURE__ */ new Set();
1805
+ if (!fs15.existsSync(activeDir)) return packs;
1806
+ for (const entry of fs15.readdirSync(activeDir, { withFileTypes: true })) {
1807
+ if (entry.isDirectory()) packs.add(entry.name);
1808
+ }
1809
+ return packs;
1810
+ }
1811
+ async function purgeCommand(options) {
1812
+ const cwd = process.cwd();
1813
+ const skillsDir = path15.join(cwd, SKILLDB_DIR11, SKILLS_DIR8);
1814
+ const activeDir = path15.join(cwd, SKILLDB_DIR11, ACTIVE_DIR8);
1815
+ const slimDir = path15.join(cwd, SKILLDB_DIR11, SLIM_DIR2);
1816
+ if (!fs15.existsSync(path15.join(cwd, SKILLDB_DIR11))) {
1817
+ console.log(pc18.red('No .skilldb/ directory found. Run "skilldb init" first.'));
1818
+ process.exit(1);
1819
+ }
1820
+ const allSkills = collectAllSkills(skillsDir);
1821
+ const activePacks = collectActivePacks(cwd);
1822
+ const activeSkills = /* @__PURE__ */ new Set();
1823
+ if (fs15.existsSync(activeDir)) {
1824
+ for (const pack of fs15.readdirSync(activeDir, { withFileTypes: true })) {
1825
+ if (!pack.isDirectory()) continue;
1826
+ for (const file of fs15.readdirSync(path15.join(activeDir, pack.name))) {
1827
+ if (file.endsWith(".md")) activeSkills.add(`${pack.name}/${file}`);
1828
+ }
1829
+ }
1830
+ }
1831
+ const inactiveSkills = allSkills.filter((s) => !activeSkills.has(s));
1832
+ const slimSkills = collectAllSkills(slimDir);
1833
+ const totalSize = getDirectorySize(path15.join(cwd, SKILLDB_DIR11));
1834
+ const skillsSize = getDirectorySize(skillsDir);
1835
+ const slimSize = getDirectorySize(slimDir);
1836
+ console.log(pc18.bold("\nSkillDB Purge\n"));
1837
+ console.log(` Total skills cached: ${pc18.cyan(String(allSkills.length))}`);
1838
+ console.log(` Active skills: ${pc18.green(String(activeSkills.size))}`);
1839
+ console.log(` Inactive skills: ${pc18.yellow(String(inactiveSkills.length))}`);
1840
+ console.log(` Slim summaries: ${pc18.dim(String(slimSkills.length))}`);
1841
+ console.log(` Total disk usage: ${pc18.cyan((totalSize / 1024).toFixed(0) + " KB")}`);
1842
+ console.log();
1843
+ if (allSkills.length === 0 && slimSkills.length === 0) {
1844
+ console.log(pc18.dim("Nothing to purge."));
1845
+ return;
1846
+ }
1847
+ const stats = { skillsRemoved: 0, packsRemoved: 0, slimRemoved: 0, bytesFreed: 0, activeKept: activeSkills.size };
1848
+ let toPurge = [];
1849
+ let purgeSlim = options?.slim || options?.all || false;
1850
+ if (options?.all) {
1851
+ toPurge = [...allSkills];
1852
+ purgeSlim = true;
1853
+ console.log(pc18.red(`Will remove ALL ${allSkills.length} cached skills + ${slimSkills.length} slim summaries`));
1854
+ } else if (options?.inactive) {
1855
+ toPurge = inactiveSkills;
1856
+ console.log(pc18.yellow(`Will remove ${inactiveSkills.length} inactive skills (keeping ${activeSkills.size} active)`));
1857
+ } else {
1858
+ toPurge = inactiveSkills;
1859
+ purgeSlim = true;
1860
+ console.log(pc18.yellow(`Will remove ${inactiveSkills.length} inactive skills + ${slimSkills.length} slim summaries`));
1861
+ console.log(pc18.green(` Keeping ${activeSkills.size} active skills`));
1862
+ }
1863
+ if (toPurge.length === 0 && !purgeSlim) {
1864
+ console.log(pc18.dim("\nNothing to purge \u2014 all skills are active."));
1865
+ return;
1866
+ }
1867
+ if (!options?.force && !options?.dryRun) {
1868
+ const answer = await prompt3(`
1869
+ Continue? (y/N) `);
1870
+ if (answer.toLowerCase() !== "y") {
1871
+ console.log(pc18.dim("Cancelled."));
1872
+ return;
1873
+ }
1874
+ }
1875
+ if (options?.dryRun) {
1876
+ console.log(pc18.dim("\n (Dry run \u2014 no files will be deleted)\n"));
1877
+ for (const skill of toPurge.slice(0, 20)) {
1878
+ console.log(pc18.dim(` would remove: ${skill}`));
1879
+ }
1880
+ if (toPurge.length > 20) console.log(pc18.dim(` ... and ${toPurge.length - 20} more`));
1881
+ return;
1882
+ }
1883
+ const manifest = readManifest(cwd);
1884
+ for (const skillId of toPurge) {
1885
+ const [pack, file] = skillId.split("/");
1886
+ const filePath = path15.join(skillsDir, pack, file);
1887
+ if (fs15.existsSync(filePath)) {
1888
+ stats.bytesFreed += fs15.statSync(filePath).size;
1889
+ fs15.unlinkSync(filePath);
1890
+ stats.skillsRemoved++;
1891
+ }
1892
+ if (manifest.installed[skillId]) {
1893
+ delete manifest.installed[skillId];
1894
+ }
1895
+ const packDir = path15.join(skillsDir, pack);
1896
+ if (fs15.existsSync(packDir) && fs15.readdirSync(packDir).length === 0) {
1897
+ fs15.rmdirSync(packDir);
1898
+ stats.packsRemoved++;
1899
+ }
1900
+ }
1901
+ if (purgeSlim && fs15.existsSync(slimDir)) {
1902
+ for (const pack of fs15.readdirSync(slimDir, { withFileTypes: true })) {
1903
+ if (!pack.isDirectory()) continue;
1904
+ const packPath = path15.join(slimDir, pack.name);
1905
+ for (const file of fs15.readdirSync(packPath)) {
1906
+ const filePath = path15.join(packPath, file);
1907
+ stats.bytesFreed += fs15.statSync(filePath).size;
1908
+ fs15.unlinkSync(filePath);
1909
+ stats.slimRemoved++;
1910
+ }
1911
+ if (fs15.readdirSync(packPath).length === 0) fs15.rmdirSync(packPath);
1912
+ }
1913
+ }
1914
+ if (options?.all && fs15.existsSync(activeDir)) {
1915
+ for (const pack of fs15.readdirSync(activeDir, { withFileTypes: true })) {
1916
+ if (!pack.isDirectory()) continue;
1917
+ const packPath = path15.join(activeDir, pack.name);
1918
+ for (const file of fs15.readdirSync(packPath)) {
1919
+ fs15.unlinkSync(path15.join(packPath, file));
1920
+ }
1921
+ fs15.rmdirSync(packPath);
1922
+ }
1923
+ stats.activeKept = 0;
1924
+ }
1925
+ writeManifest(cwd, manifest);
1926
+ console.log(pc18.green(`
1927
+ \u2713 Purge complete`));
1928
+ console.log(` Skills removed: ${stats.skillsRemoved}`);
1929
+ console.log(` Slim removed: ${stats.slimRemoved}`);
1930
+ console.log(` Packs cleaned: ${stats.packsRemoved}`);
1931
+ console.log(` Space freed: ${(stats.bytesFreed / 1024).toFixed(0)} KB`);
1932
+ console.log(` Active kept: ${stats.activeKept}`);
1933
+ }
1934
+
1763
1935
  // src/cli.ts
1764
1936
  var program = new Command();
1765
1937
  program.name("skilldb").description("SkillDB CLI \u2014 discover, install, and manage AI agent skills").version("0.3.0");
@@ -1799,5 +1971,8 @@ program.command("stats").description("Show local statistics and coverage").actio
1799
1971
  program.command("diff [target]").description("Compare local skills with latest remote versions").action((target) => {
1800
1972
  diffCommand(target);
1801
1973
  });
1974
+ program.command("purge").description("Remove cached skills to free disk space").option("-a, --all", "Remove ALL cached skills (including active)").option("-i, --inactive", "Remove only inactive skills").option("-s, --slim", "Also remove slim summaries").option("-n, --dry-run", "Show what would be removed without deleting").option("-f, --force", "Skip confirmation prompt").action((opts) => {
1975
+ purgeCommand(opts);
1976
+ });
1802
1977
  program.parse();
1803
1978
  //# sourceMappingURL=cli.js.map