@r_masseater/plugin-kit 0.0.0-stage → 0.1.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/LICENSE +87 -0
- package/README.md +29 -2
- package/dist/index.d.mts +569 -0
- package/dist/index.mjs +9081 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -3
- package/skills/read-hook-input/SKILL.md +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/plugin-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
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.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude-code",
|
|
7
|
+
"hooks",
|
|
8
|
+
"json",
|
|
9
|
+
"plugin",
|
|
10
|
+
"tanstack-intent"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/masseater/ecosystems/tree/main/libs/plugin-kit#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/masseater/ecosystems/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/masseater/ecosystems.git",
|
|
20
|
+
"directory": "libs/plugin-kit"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"dist",
|
|
25
|
+
"skills/read-hook-input"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"imports": {
|
|
30
|
+
"#/*": "./src/*"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"effect": "4.1.5",
|
|
45
|
+
"vite-plus": "1.8.0"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=26.13.1"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {}
|
|
6
51
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: read-hook-input
|
|
3
|
+
description: >
|
|
4
|
+
Use when a Claude Code plugin hook or script must read JSON it did not write, such as a hook
|
|
5
|
+
payload on stdin or a settings file: parseJson to parse without throwing and isRecord to narrow
|
|
6
|
+
the result to a plain object.
|
|
7
|
+
metadata:
|
|
8
|
+
type: core
|
|
9
|
+
library: "@r_masseater/plugin-kit"
|
|
10
|
+
library_version: 0.1.0
|
|
11
|
+
sources:
|
|
12
|
+
- src/app/**
|
|
13
|
+
- README.md
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# read-hook-input
|
|
17
|
+
|
|
18
|
+
A hook payload comes from outside the hook, so its shape is not guaranteed. `parseJson` and `isRecord` read it without a cast and without a thrown error.
|
|
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
|
+
## Read a payload
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { isRecord, parseJson } from "@r_masseater/plugin-kit";
|
|
32
|
+
|
|
33
|
+
const parsed = parseJson(text);
|
|
34
|
+
if (parsed._tag === "Some" && isRecord(parsed.value)) {
|
|
35
|
+
console.log(parsed.value["tool_name"]);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`parseJson` returns `{ _tag: "None" }` when the text is not JSON and never throws. `isRecord` is false for `null`, arrays and primitives, so check it before reading keys.
|