claude-plugin-dsh 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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -2
  3. package/dist/bin/cli.d.ts +3 -0
  4. package/dist/bin/cli.d.ts.map +1 -0
  5. package/dist/bin/cli.js +80 -0
  6. package/dist/bin/cli.js.map +1 -0
  7. package/dist/bin/inspect.d.ts +2 -0
  8. package/dist/bin/inspect.d.ts.map +1 -0
  9. package/dist/bin/inspect.js +45 -0
  10. package/dist/bin/inspect.js.map +1 -0
  11. package/dist/bin/runtime.d.ts +2 -0
  12. package/dist/bin/runtime.d.ts.map +1 -0
  13. package/dist/bin/runtime.js +4 -0
  14. package/dist/bin/runtime.js.map +1 -0
  15. package/dist/bin/scaffold.d.ts +2 -0
  16. package/dist/bin/scaffold.d.ts.map +1 -0
  17. package/dist/bin/scaffold.js +44 -0
  18. package/dist/bin/scaffold.js.map +1 -0
  19. package/dist/bin/sync.d.ts +2 -0
  20. package/dist/bin/sync.d.ts.map +1 -0
  21. package/dist/bin/sync.js +24 -0
  22. package/dist/bin/sync.js.map +1 -0
  23. package/dist/claude-compat.js +825 -0
  24. package/dist/src/claude-compat.d.ts +8 -0
  25. package/dist/src/claude-compat.d.ts.map +1 -0
  26. package/dist/src/claude-compat.js +7 -0
  27. package/dist/src/claude-compat.js.map +1 -0
  28. package/dist/src/dsh-types.d.ts +252 -0
  29. package/dist/src/dsh-types.d.ts.map +1 -0
  30. package/dist/src/dsh-types.js +6 -0
  31. package/dist/src/dsh-types.js.map +1 -0
  32. package/dist/src/hooks.d.ts +38 -0
  33. package/dist/src/hooks.d.ts.map +1 -0
  34. package/dist/src/hooks.js +136 -0
  35. package/dist/src/hooks.js.map +1 -0
  36. package/dist/src/plugin-files.d.ts +92 -0
  37. package/dist/src/plugin-files.d.ts.map +1 -0
  38. package/dist/src/plugin-files.js +198 -0
  39. package/dist/src/plugin-files.js.map +1 -0
  40. package/dist/src/plugin.d.ts +35 -0
  41. package/dist/src/plugin.d.ts.map +1 -0
  42. package/dist/src/plugin.js +422 -0
  43. package/dist/src/plugin.js.map +1 -0
  44. package/dist/src/transcript.d.ts +25 -0
  45. package/dist/src/transcript.d.ts.map +1 -0
  46. package/dist/src/transcript.js +198 -0
  47. package/dist/src/transcript.js.map +1 -0
  48. package/package.json +54 -4
@@ -0,0 +1,198 @@
1
+ // Reading a Claude Code plugin tree: manifest, skills, commands, agents, hooks.json,
2
+ // and the text transforms applied to what is read.
3
+ import { readdirSync, readFileSync } from 'node:fs';
4
+ import { basename, dirname, join, resolve } from 'node:path';
5
+ export const DEFAULT_HOOK_TIMEOUT_S = 60;
6
+ /** Split YAML-ish front matter from a markdown file. Only flat `key: value` lines are read. */
7
+ export function parseFrontMatter(text) {
8
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
9
+ if (!match)
10
+ return { meta: {}, body: text };
11
+ const meta = {};
12
+ for (const line of (match[1] ?? '').split(/\r?\n/)) {
13
+ const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
14
+ if (!kv || kv[1] === undefined || kv[2] === undefined)
15
+ continue;
16
+ const raw = kv[2].trim();
17
+ let value = raw;
18
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
19
+ value = value.slice(1, -1);
20
+ if (raw.startsWith('"'))
21
+ value = value.replace(/\\"/g, '"').replace(/\\\\/g, '\\');
22
+ }
23
+ meta[kv[1]] = value;
24
+ }
25
+ return { meta, body: text.slice(match[0].length) };
26
+ }
27
+ // A marker counts only on a line of its own, optionally after heading hashes (`## <!--/harness-->`).
28
+ const CLAUDE_ONLY_OPEN = /^\s*(?:#+\s*)?<!--\s*harness:claude-only\s*-->\s*$/;
29
+ const CLAUDE_ONLY_CLOSE = /^\s*(?:#+\s*)?<!--\s*\/harness\s*-->\s*$/;
30
+ /**
31
+ * Remove `<!--harness:claude-only--> ... <!--/harness-->` blocks.
32
+ * An opener without a closer drops the rest of the file, so Claude-only text never leaks.
33
+ */
34
+ export function stripClaudeOnlyBlocks(text) {
35
+ const out = [];
36
+ let inside = false;
37
+ for (const line of text.split(/(?<=\n)/)) {
38
+ const bare = line.replace(/\r?\n$/, '');
39
+ if (!inside && CLAUDE_ONLY_OPEN.test(bare))
40
+ inside = true;
41
+ else if (inside && CLAUDE_ONLY_CLOSE.test(bare))
42
+ inside = false;
43
+ else if (!inside)
44
+ out.push(line);
45
+ }
46
+ return { text: out.join(''), unterminated: inside };
47
+ }
48
+ export const stripClaudeOnly = (text) => stripClaudeOnlyBlocks(text).text;
49
+ /** Keep hook text from closing the tag it is wrapped in. */
50
+ export const escapeClosingTag = (text, tag) => String(text).replaceAll(`</${tag}`, `<\\/${tag}`);
51
+ /** Replace the Claude plugin root variables with the real plugin directory. */
52
+ export function expandPluginRoot(text, root) {
53
+ return text.replaceAll('${CLAUDE_PLUGIN_ROOT}', root).replaceAll('$CLAUDE_PLUGIN_ROOT', root);
54
+ }
55
+ export const kebab = (value) => String(value)
56
+ .toLowerCase()
57
+ .replace(/[^a-z0-9]+/g, '-')
58
+ .replace(/^-+|-+$/g, '');
59
+ export function readText(path) {
60
+ try {
61
+ return readFileSync(path, 'utf8');
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ function listDir(path) {
68
+ try {
69
+ return readdirSync(path, { withFileTypes: true });
70
+ }
71
+ catch {
72
+ return [];
73
+ }
74
+ }
75
+ /** Read the plugin manifest; the plugin name falls back to the directory name. */
76
+ export function readManifest(root) {
77
+ const raw = readText(join(root, '.claude-plugin', 'plugin.json'));
78
+ const manifest = (raw ? JSON.parse(raw) : {});
79
+ return { ...manifest, name: manifest.name || basename(root) };
80
+ }
81
+ /** Skill directories: `skills/<name>/SKILL.md`. */
82
+ export function discoverSkills(root, options = {}) {
83
+ const dir = join(root, 'skills');
84
+ const skip = new Set(options.exclude ?? []);
85
+ const out = [];
86
+ for (const entry of listDir(dir)) {
87
+ if (!entry.isDirectory() && !entry.isSymbolicLink())
88
+ continue;
89
+ if (skip.has(entry.name))
90
+ continue;
91
+ const path = join(dir, entry.name, 'SKILL.md');
92
+ const text = readText(path);
93
+ if (text === undefined)
94
+ continue;
95
+ const { meta } = parseFrontMatter(text);
96
+ const bare = kebab(meta.name || entry.name);
97
+ if (!bare || !meta.description)
98
+ continue;
99
+ const name = options.prefix ? `${options.prefix}-${bare}` : bare;
100
+ out.push({ name, description: meta.description, path, base: dirname(path), meta });
101
+ }
102
+ return out.sort((a, b) => a.name.localeCompare(b.name));
103
+ }
104
+ /** Command files: `commands/<name>.md`. */
105
+ export function discoverCommands(root, options = {}) {
106
+ const dir = join(root, 'commands');
107
+ const skip = new Set(options.exclude ?? []);
108
+ const out = [];
109
+ for (const entry of listDir(dir)) {
110
+ if (!entry.name.endsWith('.md'))
111
+ continue;
112
+ const stem = entry.name.slice(0, -3);
113
+ if (skip.has(stem))
114
+ continue;
115
+ const path = join(dir, entry.name);
116
+ const text = readText(path);
117
+ if (text === undefined)
118
+ continue;
119
+ const { meta, body } = parseFrontMatter(text);
120
+ out.push({ stem, name: kebab(meta.name || stem), description: meta.description || stem, hint: meta['argument-hint'] || '', body, path });
121
+ }
122
+ return out.sort((a, b) => a.name.localeCompare(b.name));
123
+ }
124
+ /** Agent definitions: `agents/<name>.md` plus any extra directories the bundle lists. */
125
+ export function discoverAgents(root, options = {}) {
126
+ const dirs = [join(root, 'agents'), ...(options.extraDirs ?? []).map((d) => resolve(root, d))];
127
+ const skip = new Set(options.exclude ?? []);
128
+ const out = [];
129
+ const seen = new Set();
130
+ for (const dir of dirs) {
131
+ for (const entry of listDir(dir)) {
132
+ if (!entry.name.endsWith('.md'))
133
+ continue;
134
+ const path = join(dir, entry.name);
135
+ const text = readText(path);
136
+ if (text === undefined)
137
+ continue;
138
+ const { meta, body } = parseFrontMatter(text);
139
+ const name = kebab(meta.name || entry.name.slice(0, -3));
140
+ if (skip.has(name) || seen.has(name) || !meta.description)
141
+ continue;
142
+ seen.add(name);
143
+ out.push({ name, description: meta.description, tools: meta.tools || '', model: meta.model || '', body, path });
144
+ }
145
+ }
146
+ return out.sort((a, b) => a.name.localeCompare(b.name));
147
+ }
148
+ /** hooks/hooks.json command hooks, flattened. Function-hook `modules` are Claude-only and skipped. */
149
+ export function readHooks(root) {
150
+ const raw = readText(join(root, 'hooks', 'hooks.json'));
151
+ if (!raw)
152
+ return [];
153
+ const hooks = JSON.parse(raw).hooks ?? {};
154
+ const out = [];
155
+ for (const [event, groups] of Object.entries(hooks)) {
156
+ for (const group of groups ?? []) {
157
+ for (const hook of group.hooks ?? []) {
158
+ if (hook.type !== 'command' || !hook.command)
159
+ continue;
160
+ const spec = { event, matcher: group.matcher ?? '', command: hook.command, timeout: hook.timeout ?? DEFAULT_HOOK_TIMEOUT_S };
161
+ if (hook.args !== undefined) {
162
+ // Running a malformed exec hook through a shell would quietly run something else.
163
+ if (!Array.isArray(hook.args) || !hook.args.every((arg) => typeof arg === 'string'))
164
+ throw new Error(`hooks.json: ${event} hook "${hook.command}" has args that are not a list of strings`);
165
+ spec.args = hook.args;
166
+ }
167
+ if (hook.onFailure === 'block' || hook.onFailure === 'continue')
168
+ spec.onFailure = hook.onFailure;
169
+ out.push(spec);
170
+ }
171
+ }
172
+ }
173
+ return out;
174
+ }
175
+ /** A Claude Code matcher: empty or `*` matches all, otherwise an anchored regex (`Bash`, `Skill|Agent|Task`). */
176
+ export function matcherMatches(matcher, toolName) {
177
+ if (!matcher || matcher === '*')
178
+ return true;
179
+ try {
180
+ return new RegExp(`^(?:${matcher})$`).test(toolName);
181
+ }
182
+ catch {
183
+ return matcher === toolName;
184
+ }
185
+ }
186
+ /** Expand `$ARGUMENTS`, `$1..$9` and `${CLAUDE_PLUGIN_ROOT}` in a command body. */
187
+ export function renderCommand(body, rawInput, root) {
188
+ const args = rawInput.trim();
189
+ const positional = args ? args.split(/\s+/) : [];
190
+ let text = expandPluginRoot(body, root);
191
+ const usesArgs = /\$ARGUMENTS|\$[1-9]/.test(text);
192
+ // One pass with a function: user text is never re-scanned or read as a replacement pattern.
193
+ text = text.replace(/\$(ARGUMENTS|[1-9])/g, (_, key) => (key === 'ARGUMENTS' ? args : (positional[Number(key) - 1] ?? '')));
194
+ if (!usesArgs && args)
195
+ text += `\n\nArguments: ${args}`;
196
+ return text;
197
+ }
198
+ //# sourceMappingURL=plugin-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-files.js","sourceRoot":"","sources":["../../src/plugin-files.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,mDAAmD;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAe,MAAM,SAAS,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAmExC,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC3C,MAAM,IAAI,GAAgB,EAAE,CAAA;IAC5B,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,EAAE,GAAG,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClD,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,SAAQ;QAC/D,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,I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I,CAAA;AACb,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type AgentOptions, type CommandOptions, type SkillOptions } from './plugin-files.js';
2
+ export declare const COMPAT_VERSION = "0.1.0";
3
+ export declare const SKILL_RANK = 450;
4
+ export type Part = 'skills' | 'commands' | 'agents' | 'instructions' | 'hooks';
5
+ export interface PluginSpec {
6
+ /** Plugin root, the directory holding `.claude-plugin/`. */
7
+ root: string;
8
+ /** Root-relative files put into the system prompt, claude-only blocks removed. */
9
+ instructions?: string[];
10
+ skills?: SkillOptions;
11
+ commands?: CommandOptions;
12
+ agents?: AgentOptions;
13
+ /** Limit which Claude hook events run; default all. */
14
+ hooks?: {
15
+ events?: string[];
16
+ };
17
+ /** Extra environment for hooks; values may use `${CLAUDE_PLUGIN_ROOT}`. */
18
+ env?: Record<string, string>;
19
+ /** Parts that stay off unless the row config sets `disable`. */
20
+ disableByDefault?: Part[];
21
+ }
22
+ export interface RowConfig {
23
+ /** Parts to turn off for this row; replaces `disableByDefault`. */
24
+ disable?: Part[];
25
+ }
26
+ export interface DshPlugin {
27
+ name: string;
28
+ /** Accept the host context without pinning DSH's version-specific branded types. */
29
+ apply(ctx: object, config?: RowConfig): void;
30
+ }
31
+ /** Build a Cordis plugin for one Claude Code plugin directory. */
32
+ export declare function createPlugin(spec: PluginSpec): DshPlugin;
33
+ /** The plugin root is the parent of the `dsh/` directory holding the caller. */
34
+ export declare function rootFrom(importMetaUrl: string): string;
35
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAcL,KAAK,YAAY,EACjB,KAAK,cAAc,EAEnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAA;AAG1B,eAAO,MAAM,cAAc,UAAU,CAAA;AACrC,eAAO,MAAM,UAAU,MAAM,CAAA;AAE7B,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,UAAU,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