@r_masseater/plugin-kit 0.1.0 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@r_masseater/plugin-kit",
3
- "version": "0.1.0",
4
- "description": "Reads untrusted JSON in Claude Code plugin hooks and scripts: tell a plain object from other values and parse text without throwing.",
3
+ "version": "0.2.0",
4
+ "description": "Shared code for Claude Code plugin hooks and scripts: read untrusted JSON without throwing and find the plugin cache folder.",
5
5
  "keywords": [
6
6
  "claude-code",
7
7
  "hooks",
@@ -22,6 +22,7 @@
22
22
  "files": [
23
23
  "LICENSE",
24
24
  "dist",
25
+ "skills/find-cache-folder",
25
26
  "skills/read-hook-input"
26
27
  ],
27
28
  "type": "module",
@@ -41,6 +42,7 @@
41
42
  "provenance": true
42
43
  },
43
44
  "devDependencies": {
45
+ "@effect/vitest": "4.1.5",
44
46
  "effect": "4.1.5",
45
47
  "vite-plus": "1.8.0"
46
48
  },
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: find-cache-folder
3
+ description: >
4
+ Use when a Claude Code plugin hook or script must keep downloaded or built files between runs,
5
+ such as a model, a binary or an installed tool: cacheRootOf gives the folder under
6
+ XDG_CACHE_HOME or ~/.cache.
7
+ metadata:
8
+ type: core
9
+ library: "@r_masseater/plugin-kit"
10
+ library_version: 0.2.0
11
+ sources:
12
+ - src/app/**
13
+ - README.md
14
+ ---
15
+
16
+ # find-cache-folder
17
+
18
+ A plugin's own directory is replaced when the plugin updates, so files that are costly to fetch again belong in the user's cache folder. `cacheRootOf` gives that folder and keeps every plugin on the same rule.
19
+
20
+ ## Setup
21
+
22
+ ```sh
23
+ bun add @r_masseater/plugin-kit
24
+ ```
25
+
26
+ Commit the `bun.lock` that `bun add` writes. Claude Code installs the dependencies of a plugin from its `package.json` and a text `bun.lock` when it caches the plugin.
27
+
28
+ ## Find the folder
29
+
30
+ ```ts
31
+ import { cacheRootOf } from "@r_masseater/plugin-kit";
32
+
33
+ const root = await cacheRootOf(["my-plugin", "runtime"]);
34
+ ```
35
+
36
+ The folder is `$XDG_CACHE_HOME/my-plugin/runtime`, or `~/.cache/my-plugin/runtime` when `XDG_CACHE_HOME` is unset or empty. The function builds the path only and creates nothing. It rejects with `CacheRootError` when neither `XDG_CACHE_HOME` nor `HOME` (or `USERPROFILE` on Windows) is set. `cacheRootEffect` is the same lookup as an Effect: provide a `ConfigProvider` to test it with a fake environment.
@@ -7,7 +7,7 @@ description: >
7
7
  metadata:
8
8
  type: core
9
9
  library: "@r_masseater/plugin-kit"
10
- library_version: 0.1.0
10
+ library_version: 0.2.0
11
11
  sources:
12
12
  - src/app/**
13
13
  - README.md