claude-plugin-dsh 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +178 -2
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +107 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/inspect.d.ts +2 -0
- package/dist/bin/inspect.d.ts.map +1 -0
- package/dist/bin/inspect.js +45 -0
- package/dist/bin/inspect.js.map +1 -0
- package/dist/bin/runtime.d.ts +2 -0
- package/dist/bin/runtime.d.ts.map +1 -0
- package/dist/bin/runtime.js +4 -0
- package/dist/bin/runtime.js.map +1 -0
- package/dist/bin/scaffold.d.ts +2 -0
- package/dist/bin/scaffold.d.ts.map +1 -0
- package/dist/bin/scaffold.js +44 -0
- package/dist/bin/scaffold.js.map +1 -0
- package/dist/bin/sync.d.ts +2 -0
- package/dist/bin/sync.d.ts.map +1 -0
- package/dist/bin/sync.js +24 -0
- package/dist/bin/sync.js.map +1 -0
- package/dist/bin/update.d.ts +27 -0
- package/dist/bin/update.d.ts.map +1 -0
- package/dist/bin/update.js +183 -0
- package/dist/bin/update.js.map +1 -0
- package/dist/claude-compat.js +825 -0
- package/dist/src/claude-compat.d.ts +8 -0
- package/dist/src/claude-compat.d.ts.map +1 -0
- package/dist/src/claude-compat.js +7 -0
- package/dist/src/claude-compat.js.map +1 -0
- package/dist/src/dsh-types.d.ts +252 -0
- package/dist/src/dsh-types.d.ts.map +1 -0
- package/dist/src/dsh-types.js +6 -0
- package/dist/src/dsh-types.js.map +1 -0
- package/dist/src/hooks.d.ts +38 -0
- package/dist/src/hooks.d.ts.map +1 -0
- package/dist/src/hooks.js +136 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/plugin-files.d.ts +92 -0
- package/dist/src/plugin-files.d.ts.map +1 -0
- package/dist/src/plugin-files.js +198 -0
- package/dist/src/plugin-files.js.map +1 -0
- package/dist/src/plugin.d.ts +35 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +422 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/transcript.d.ts +25 -0
- package/dist/src/transcript.d.ts.map +1 -0
- package/dist/src/transcript.js +198 -0
- package/dist/src/transcript.js.map +1 -0
- package/package.json +54 -4
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
// createPlugin: one Claude Code plugin tree -> one DSH (Cordis) plugin.
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { interpretHookResult, runHook } from './hooks.js';
|
|
7
|
+
import { discoverAgents, discoverCommands, discoverSkills, escapeClosingTag, expandPluginRoot, kebab, matcherMatches, parseFrontMatter, readHooks, readManifest, readText, renderCommand, stripClaudeOnlyBlocks, } from './plugin-files.js';
|
|
8
|
+
import { claudeToolName, dropTranscript, lastAssistantText, parseArguments, syncTranscript, textOf, toClaudeToolInput, toClaudeToolResponse, transcriptPath } from './transcript.js';
|
|
9
|
+
export const COMPAT_VERSION = '0.1.0';
|
|
10
|
+
export const SKILL_RANK = 450;
|
|
11
|
+
/** Build a Cordis plugin for one Claude Code plugin directory. */
|
|
12
|
+
export function createPlugin(spec) {
|
|
13
|
+
const root = resolve(spec.root);
|
|
14
|
+
const manifest = readManifest(root);
|
|
15
|
+
const pluginName = kebab(manifest.name);
|
|
16
|
+
const id = `claude-compat-${pluginName}`;
|
|
17
|
+
// An empty prefix means bare names (`/greet`), not `/-greet`.
|
|
18
|
+
const commandPrefix = spec.commands?.prefix ?? pluginName;
|
|
19
|
+
const hasAgents = () => !(spec.disableByDefault ?? []).includes('agents') && discoverAgents(root, spec.agents).length > 0;
|
|
20
|
+
const harnessNote = () => [
|
|
21
|
+
`> Loaded from the ${pluginName} Claude Code plugin into DeepSeek Harness. Plugin root: \`${root}\`.`,
|
|
22
|
+
`> A Claude command \`/${pluginName}:<cmd>\` is the DSH command \`/${commandPrefix ? `${commandPrefix}-` : ''}<cmd>\`; when you cannot run it, do what its section here says.`,
|
|
23
|
+
hasAgents()
|
|
24
|
+
? `> A Claude agent type \`${pluginName}:<agent>\` is the skill \`${pluginName}-agent-<agent>\`: load it and pass its role text to \`subagent\` or \`spawn_teammate\`.`
|
|
25
|
+
: '',
|
|
26
|
+
]
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.join('\n');
|
|
29
|
+
function apply(host, config = {}) {
|
|
30
|
+
// Keep the version-specific Cordis boundary here; internal registrations stay typed.
|
|
31
|
+
if (!('inject' in host) || typeof host.inject !== 'function' || !('on' in host) || typeof host.on !== 'function') {
|
|
32
|
+
throw new TypeError('claude-plugins-dsh: expected a Cordis context with inject() and on()');
|
|
33
|
+
}
|
|
34
|
+
const ctx = host;
|
|
35
|
+
const disabled = new Set(config.disable ?? spec.disableByDefault ?? []);
|
|
36
|
+
const enabled = (part) => !disabled.has(part);
|
|
37
|
+
const warn = (msg) => (ctx.logger ?? console).warn(`[${id}] ${msg}`);
|
|
38
|
+
// Each part waits for its own service, so a profile without one keeps the rest.
|
|
39
|
+
if (enabled('skills') || enabled('agents'))
|
|
40
|
+
ctx.inject(['skills'], (sub) => registerSkills(sub, enabled, warn));
|
|
41
|
+
if (enabled('commands'))
|
|
42
|
+
ctx.inject(['commands'], (sub) => registerCommands(sub, warn));
|
|
43
|
+
if (enabled('instructions'))
|
|
44
|
+
ctx.inject(['systemPrompt'], (sub) => registerInstructions(sub, warn));
|
|
45
|
+
if (enabled('hooks'))
|
|
46
|
+
registerHooks(ctx, warn);
|
|
47
|
+
}
|
|
48
|
+
// ---- skills and agent briefs
|
|
49
|
+
function registerSkills(ctx, enabled, warn) {
|
|
50
|
+
if (!ctx.skills?.registerProvider)
|
|
51
|
+
return warn('skills service missing, skills not registered');
|
|
52
|
+
const provider = {
|
|
53
|
+
name: id,
|
|
54
|
+
async list() {
|
|
55
|
+
const candidates = [];
|
|
56
|
+
if (enabled('skills')) {
|
|
57
|
+
for (const skill of discoverSkills(root, spec.skills)) {
|
|
58
|
+
candidates.push({
|
|
59
|
+
name: skill.name,
|
|
60
|
+
description: skill.description,
|
|
61
|
+
...(skill.meta.whenToUse ? { whenToUse: skill.meta.whenToUse } : {}),
|
|
62
|
+
invocation: { modelInvocable: skill.meta['disable-model-invocation'] !== 'true', userInvocable: skill.meta['user-invocable'] !== 'false' },
|
|
63
|
+
provider: id,
|
|
64
|
+
source: 'custom',
|
|
65
|
+
path: skill.path,
|
|
66
|
+
resourceBase: { kind: 'directory', path: skill.base },
|
|
67
|
+
rank: SKILL_RANK,
|
|
68
|
+
locator: { kind: 'skill', path: skill.path, base: skill.base },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (enabled('agents')) {
|
|
73
|
+
for (const agent of discoverAgents(root, spec.agents)) {
|
|
74
|
+
candidates.push({
|
|
75
|
+
name: `${pluginName}-agent-${agent.name}`,
|
|
76
|
+
description: `Role brief for a delegated worker (${pluginName} agent "${agent.name}"). ${agent.description}`,
|
|
77
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
78
|
+
provider: id,
|
|
79
|
+
source: 'custom',
|
|
80
|
+
path: agent.path,
|
|
81
|
+
resourceBase: { kind: 'directory', path: dirname(agent.path) },
|
|
82
|
+
rank: SKILL_RANK,
|
|
83
|
+
locator: { kind: 'agent', path: agent.path },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return candidates;
|
|
88
|
+
},
|
|
89
|
+
async get(candidate) {
|
|
90
|
+
const locator = candidate.locator;
|
|
91
|
+
const text = readText(locator.path);
|
|
92
|
+
if (text === undefined)
|
|
93
|
+
return undefined;
|
|
94
|
+
const { body } = parseFrontMatter(text);
|
|
95
|
+
let content = expandPluginRoot(body, root);
|
|
96
|
+
if (locator.kind === 'skill') {
|
|
97
|
+
content = `${harnessNote()}\n> Relative paths in this skill resolve from \`${locator.base}\`.\n\n${content}`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const agent = discoverAgents(root, spec.agents).find((a) => a.path === locator.path);
|
|
101
|
+
const tools = agent?.tools ? `\nOriginal tool allowlist: ${agent.tools}. Respect it: do not use tools outside that list.` : '';
|
|
102
|
+
content = [
|
|
103
|
+
`# Delegated role: ${agent?.name ?? candidate.name}`,
|
|
104
|
+
'',
|
|
105
|
+
`This is a Claude Code agent definition from the ${pluginName} plugin. DSH has no agent types, so use it as a brief:`,
|
|
106
|
+
'- To run this role, call `subagent` (or `spawn_teammate` for a durable teammate) with a prompt made of the role text below, then the concrete task, exact files, and the check that proves it done.',
|
|
107
|
+
'- Pick the provider/model yourself; the original pin does not apply in DSH.' + tools,
|
|
108
|
+
'',
|
|
109
|
+
'## Role text',
|
|
110
|
+
'',
|
|
111
|
+
content,
|
|
112
|
+
].join('\n');
|
|
113
|
+
}
|
|
114
|
+
const definition = {
|
|
115
|
+
name: candidate.name,
|
|
116
|
+
description: candidate.description,
|
|
117
|
+
invocation: candidate.invocation,
|
|
118
|
+
provider: id,
|
|
119
|
+
source: 'custom',
|
|
120
|
+
path: locator.path,
|
|
121
|
+
content,
|
|
122
|
+
};
|
|
123
|
+
if (candidate.resourceBase)
|
|
124
|
+
definition.resourceBase = candidate.resourceBase;
|
|
125
|
+
return definition;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
ctx.skills.registerProvider(() => provider);
|
|
129
|
+
}
|
|
130
|
+
// ---- slash commands
|
|
131
|
+
function registerCommands(ctx, warn) {
|
|
132
|
+
const commands = ctx.commands;
|
|
133
|
+
if (!commands?.register)
|
|
134
|
+
return;
|
|
135
|
+
for (const command of discoverCommands(root, spec.commands)) {
|
|
136
|
+
const name = commandPrefix ? `${commandPrefix}-${command.name}` : command.name;
|
|
137
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(name)) {
|
|
138
|
+
warn(`command name ${name} is not valid, skipped`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
commands.register({
|
|
143
|
+
name,
|
|
144
|
+
description: command.description,
|
|
145
|
+
...(command.hint ? { input: { hint: command.hint } } : {}),
|
|
146
|
+
handler(invocation) {
|
|
147
|
+
const text = readText(command.path);
|
|
148
|
+
const body = text === undefined ? command.body : parseFrontMatter(text).body;
|
|
149
|
+
invocation.agent.followup({
|
|
150
|
+
id: randomUUID(),
|
|
151
|
+
role: 'user',
|
|
152
|
+
content: [{ type: 'text', text: `<command-name>/${pluginName}:${command.stem}</command-name>\n\n${renderCommand(body, invocation.rawInput, root)}` }],
|
|
153
|
+
source: { kind: 'user' },
|
|
154
|
+
});
|
|
155
|
+
return { kind: 'success', text: `/${name} queued` };
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
warn(`command /${name} not registered: ${error.message}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// ---- instruction files
|
|
165
|
+
function registerInstructions(ctx, warn) {
|
|
166
|
+
const files = spec.instructions ?? [];
|
|
167
|
+
if (!files.length)
|
|
168
|
+
return;
|
|
169
|
+
if (!ctx.systemPrompt?.section)
|
|
170
|
+
return warn('systemPrompt service missing, instructions not registered');
|
|
171
|
+
ctx.systemPrompt.section({
|
|
172
|
+
name: `${id}-instructions`,
|
|
173
|
+
order: 450,
|
|
174
|
+
interpolate: false,
|
|
175
|
+
text: () => files
|
|
176
|
+
.map((file) => {
|
|
177
|
+
const raw = readText(resolve(root, file));
|
|
178
|
+
if (raw === undefined)
|
|
179
|
+
return '';
|
|
180
|
+
const stripped = stripClaudeOnlyBlocks(expandPluginRoot(raw, root));
|
|
181
|
+
if (stripped.unterminated)
|
|
182
|
+
warn(`${file}: <!--harness:claude-only--> has no closing <!--/harness-->, the rest of the file was dropped`);
|
|
183
|
+
return stripped.text.trim();
|
|
184
|
+
})
|
|
185
|
+
.filter(Boolean)
|
|
186
|
+
.join('\n\n'),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// ---- hooks
|
|
190
|
+
function registerHooks(ctx, warn) {
|
|
191
|
+
const only = spec.hooks?.events ? new Set(spec.hooks.events) : undefined;
|
|
192
|
+
const hooks = readHooks(root).filter((hook) => !only || only.has(hook.event));
|
|
193
|
+
if (!hooks.length)
|
|
194
|
+
return;
|
|
195
|
+
const byEvent = (event) => hooks.filter((hook) => hook.event === event);
|
|
196
|
+
const stopBlocks = new WeakMap();
|
|
197
|
+
const tag = `${pluginName}-hook`;
|
|
198
|
+
let workingDirectory;
|
|
199
|
+
ctx.inject(['workingDirectory'], (sub) => {
|
|
200
|
+
workingDirectory = sub.workingDirectory;
|
|
201
|
+
sub.effect(() => () => {
|
|
202
|
+
workingDirectory = undefined;
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
const cwdOf = (agent) => {
|
|
206
|
+
try {
|
|
207
|
+
return workingDirectory?.get(agent.session) || agent.session.header.cwd || process.cwd();
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return agent.session.header.cwd || process.cwd();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const envFor = (cwd) => {
|
|
214
|
+
const env = { ...process.env, CLAUDE_PLUGIN_ROOT: root, CLAUDE_PROJECT_DIR: cwd, CLAUDE_HARNESS: 'dsh', DSH_CLAUDE_COMPAT: COMPAT_VERSION };
|
|
215
|
+
for (const [key, value] of Object.entries(spec.env ?? {}))
|
|
216
|
+
env[key] = expandPluginRoot(String(value), root);
|
|
217
|
+
return env;
|
|
218
|
+
};
|
|
219
|
+
const inputFor = (agent, event, cwd, extra = {}) => {
|
|
220
|
+
let transcript = transcriptPath(agent);
|
|
221
|
+
try {
|
|
222
|
+
transcript = syncTranscript(agent, cwd);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
warn(`transcript export failed: ${error.message}`);
|
|
226
|
+
}
|
|
227
|
+
return { session_id: String(agent.session.header.id), transcript_path: transcript, cwd, hook_event_name: event, permission_mode: 'default', ...extra };
|
|
228
|
+
};
|
|
229
|
+
// Matching hooks run in parallel, as in Claude Code; results keep hooks.json order.
|
|
230
|
+
async function fire(event, agent, extra, options = {}) {
|
|
231
|
+
const list = byEvent(event).filter(options.filter ?? (() => true));
|
|
232
|
+
if (!list.length)
|
|
233
|
+
return [];
|
|
234
|
+
const cwd = cwdOf(agent);
|
|
235
|
+
const input = inputFor(agent, event, cwd, extra);
|
|
236
|
+
const env = envFor(cwd);
|
|
237
|
+
const settled = await Promise.all(list.map((hook) => runHook(hook, input, env, options.signal).catch((error) => ({ code: null, stdout: '', stderr: String(error?.message ?? error), timedOut: false }))));
|
|
238
|
+
return settled.map((result, index) => {
|
|
239
|
+
const failed = !result.aborted && (result.timedOut || (result.code !== 0 && result.code !== 2));
|
|
240
|
+
if (failed)
|
|
241
|
+
warn(`${event} hook exited ${result.code}: ${result.stderr.trim().slice(0, 300)}`);
|
|
242
|
+
const interpreted = interpretHookResult(result, event);
|
|
243
|
+
if (failed && list[index].onFailure === 'block') {
|
|
244
|
+
interpreted.decision = 'block';
|
|
245
|
+
interpreted.reason = `${pluginName} hook failed and its onFailure is "block": ${result.stderr.trim().slice(0, 300) || `exit ${result.code}`}`;
|
|
246
|
+
}
|
|
247
|
+
for (const notice of interpreted.notices)
|
|
248
|
+
warn(`${event}: ${notice}`);
|
|
249
|
+
return interpreted;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const hookMessage = (event, text) => ({
|
|
253
|
+
id: randomUUID(),
|
|
254
|
+
role: 'user',
|
|
255
|
+
content: [{ type: 'text', text: `<${tag} event="${event}">\n${escapeClosingTag(text, tag)}\n</${tag}>` }],
|
|
256
|
+
source: { kind: `plugin:${id}` },
|
|
257
|
+
});
|
|
258
|
+
const contextOf = (results) => results
|
|
259
|
+
.flatMap((r) => r.context)
|
|
260
|
+
.filter(Boolean)
|
|
261
|
+
.join('\n\n');
|
|
262
|
+
function injectContext(agent, event, results) {
|
|
263
|
+
const text = contextOf(results);
|
|
264
|
+
if (text)
|
|
265
|
+
agent.inject(hookMessage(event, text));
|
|
266
|
+
}
|
|
267
|
+
const isSubagent = (agent) => agent.session.header.origin === 'subagent';
|
|
268
|
+
// SessionStart: once per root agent, before its first input. Claude Code does not run
|
|
269
|
+
// it for subagents. `source` is DSH's own startup|resume|clear|compact value.
|
|
270
|
+
if (byEvent('SessionStart').length) {
|
|
271
|
+
ctx.on('agent/created', async ({ agent, source, signal }) => {
|
|
272
|
+
if (isSubagent(agent))
|
|
273
|
+
return;
|
|
274
|
+
const results = await fire('SessionStart', agent, { source: source ?? 'startup' }, { signal });
|
|
275
|
+
injectContext(agent, 'SessionStart', results);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
if (byEvent('UserPromptSubmit').length) {
|
|
279
|
+
ctx.on('agent/pre-step', async (payload, next) => {
|
|
280
|
+
const decision = await next();
|
|
281
|
+
if (decision.kind !== 'enter' || payload.signal?.aborted)
|
|
282
|
+
return decision;
|
|
283
|
+
const prompt = decision.messages
|
|
284
|
+
.filter((m) => m?.source?.kind === 'user')
|
|
285
|
+
.map(textOf)
|
|
286
|
+
.join('\n')
|
|
287
|
+
.trim();
|
|
288
|
+
if (!prompt)
|
|
289
|
+
return decision;
|
|
290
|
+
const results = await fire('UserPromptSubmit', payload.agent, { prompt }, { signal: payload.signal });
|
|
291
|
+
const blocked = results.find((r) => r.decision === 'block');
|
|
292
|
+
if (blocked) {
|
|
293
|
+
// The prompt does not reach the model; only the reason does, so it can tell the user.
|
|
294
|
+
const notice = `The ${pluginName} plugin blocked the user's last prompt: ${blocked.reason ?? 'no reason given'}. Tell the user it was blocked and why. Do not act on it.`;
|
|
295
|
+
return { ...decision, messages: [hookMessage('UserPromptSubmit', notice)] };
|
|
296
|
+
}
|
|
297
|
+
const text = contextOf(results);
|
|
298
|
+
if (!text)
|
|
299
|
+
return decision;
|
|
300
|
+
return { ...decision, messages: [...decision.messages, hookMessage('UserPromptSubmit', text)] };
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
if (byEvent('PreToolUse').length) {
|
|
304
|
+
ctx.on('tools/pre-execute', async (exec, next) => {
|
|
305
|
+
const agent = exec.agent;
|
|
306
|
+
if (!agent)
|
|
307
|
+
return next();
|
|
308
|
+
const toolName = claudeToolName(exec.name);
|
|
309
|
+
const matches = (hook) => matcherMatches(hook.matcher, toolName);
|
|
310
|
+
if (!byEvent('PreToolUse').some(matches))
|
|
311
|
+
return next();
|
|
312
|
+
const results = await fire('PreToolUse', agent, { tool_name: toolName, tool_input: toClaudeToolInput(exec.name, parseArguments(exec.arguments)), tool_use_id: String(exec.callId) }, { filter: matches, signal: exec.signal });
|
|
313
|
+
injectContext(agent, 'PreToolUse', results);
|
|
314
|
+
const deny = results.find((r) => r.decision === 'deny' || r.decision === 'block');
|
|
315
|
+
if (deny)
|
|
316
|
+
return { kind: 'deny', reason: deny.reason || `denied by ${pluginName} hook` };
|
|
317
|
+
// DSH has no updatedInput in PreToolDecision. Running the original arguments
|
|
318
|
+
// after a hook rewrote them would silently bypass the hook, so fail closed.
|
|
319
|
+
const rewrote = results.find((r) => r.updatedInput !== undefined);
|
|
320
|
+
if (rewrote) {
|
|
321
|
+
return {
|
|
322
|
+
kind: 'deny',
|
|
323
|
+
reason: `${pluginName} hook returned updatedInput, which DSH cannot apply; refusing to run the unmodified tool input`,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const ask = results.find((r) => r.decision === 'ask');
|
|
327
|
+
if (ask) {
|
|
328
|
+
const reason = ask.reason || `${pluginName} hook asks for confirmation`;
|
|
329
|
+
return { kind: 'ask', reason, displayReason: { en: reason } };
|
|
330
|
+
}
|
|
331
|
+
const decision = await next();
|
|
332
|
+
// A hook's explicit allow suppresses an approval prompt, but a later deny
|
|
333
|
+
// still wins, matching Claude Code's precedence.
|
|
334
|
+
const allow = results.find((r) => r.decision === 'allow');
|
|
335
|
+
if (allow && decision.kind === 'ask')
|
|
336
|
+
return { kind: 'allow' };
|
|
337
|
+
return decision;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (byEvent('PostToolUse').length) {
|
|
341
|
+
ctx.on('tools/post-execute', async (exec, result, next) => {
|
|
342
|
+
const decision = await next();
|
|
343
|
+
const agent = exec.agent;
|
|
344
|
+
if (!agent)
|
|
345
|
+
return decision;
|
|
346
|
+
const toolName = claudeToolName(exec.name);
|
|
347
|
+
const matches = (hook) => matcherMatches(hook.matcher, toolName);
|
|
348
|
+
if (!byEvent('PostToolUse').some(matches))
|
|
349
|
+
return decision;
|
|
350
|
+
const args = parseArguments(exec.arguments);
|
|
351
|
+
const results = await fire('PostToolUse', agent, {
|
|
352
|
+
tool_name: toolName,
|
|
353
|
+
tool_input: toClaudeToolInput(exec.name, args),
|
|
354
|
+
tool_response: toClaudeToolResponse(exec.name, args, result),
|
|
355
|
+
tool_use_id: String(exec.callId),
|
|
356
|
+
}, { filter: matches, signal: exec.signal });
|
|
357
|
+
const text = contextOf(results);
|
|
358
|
+
const contexts = text ? [hookMessage('PostToolUse', text)] : [];
|
|
359
|
+
const blocked = results.find((r) => r.decision === 'block' || r.decision === 'deny');
|
|
360
|
+
if (blocked) {
|
|
361
|
+
return {
|
|
362
|
+
kind: 'block',
|
|
363
|
+
feedback: [{ type: 'text', text: blocked.reason || `blocked by ${pluginName} hook` }],
|
|
364
|
+
...(contexts.length ? { additionalContexts: contexts } : {}),
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (!contexts.length)
|
|
368
|
+
return decision;
|
|
369
|
+
// PostToolDecision.additionalContexts reaches the model with the result; agent.inject
|
|
370
|
+
// can miss the next step when the turn ends on this tool call.
|
|
371
|
+
if (decision.kind === 'accept' || decision.kind === 'block') {
|
|
372
|
+
return { ...decision, additionalContexts: [...(decision.additionalContexts ?? []), ...contexts] };
|
|
373
|
+
}
|
|
374
|
+
return decision;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (byEvent('Stop').length || byEvent('SubagentStop').length) {
|
|
378
|
+
ctx.on('agent/turn-stopping', async ({ agent, signal }) => {
|
|
379
|
+
if (signal?.aborted)
|
|
380
|
+
return;
|
|
381
|
+
const event = isSubagent(agent) ? 'SubagentStop' : 'Stop';
|
|
382
|
+
if (!byEvent(event).length)
|
|
383
|
+
return;
|
|
384
|
+
const active = stopBlocks.get(agent) === true;
|
|
385
|
+
const results = await fire(event, agent, { stop_hook_active: active, last_assistant_message: lastAssistantText(agent.session) }, { signal });
|
|
386
|
+
const block = results.find((r) => r.decision === 'block');
|
|
387
|
+
if (block && !active) {
|
|
388
|
+
stopBlocks.set(agent, true);
|
|
389
|
+
agent.steer(hookMessage(event, block.reason ?? 'A plugin hook asked for one more step.'));
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
stopBlocks.set(agent, false);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
ctx.on('agent/disposed', ({ agent }) => {
|
|
397
|
+
const done = byEvent('SessionEnd').length ? fire('SessionEnd', agent, { reason: 'other' }) : Promise.resolve([]);
|
|
398
|
+
done
|
|
399
|
+
.catch((error) => {
|
|
400
|
+
warn(`SessionEnd: ${error.message}`);
|
|
401
|
+
return [];
|
|
402
|
+
})
|
|
403
|
+
.finally(() => {
|
|
404
|
+
try {
|
|
405
|
+
dropTranscript(agent);
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
// Best effort: a leftover export is only disk space.
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return { name: id, apply };
|
|
414
|
+
}
|
|
415
|
+
/** The plugin root is the parent of the `dsh/` directory holding the caller. */
|
|
416
|
+
export function rootFrom(importMetaUrl) {
|
|
417
|
+
const candidate = resolve(dirname(fileURLToPath(importMetaUrl)), '..');
|
|
418
|
+
if (!existsSync(join(candidate, '.claude-plugin')))
|
|
419
|
+
throw new Error(`claude-plugins-dsh: no .claude-plugin under ${candidate}`);
|
|
420
|
+
return candidate;
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAwC,MAAM,YAAY,CAAA;AAC/F,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAKtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEpL,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAA;AACrC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;AAuC7B,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA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C;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAChH,IAAI;iBACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACxB,IAAI,CAAC,eAAgB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;gBAC/C,OAAO,EAAE,CAAA;YACX,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,IAAI,CAAC;oBACH,cAAc,CAAC,KAAK,CAAC,CAAA;gBACvB,CAAC;gBAAC,MAAM,CAAC;oBACP,qDAAqD;gBACvD,CAAC;YACH,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CAAC,aAAqB;IAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,SAAS,EAAE,CAAC,CAAA;IAC/H,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Agent, ContentBlock, Session, SessionEvent, ToolExecutionResult } from './dsh-types.js';
|
|
2
|
+
export declare const TOOL_NAME_MAP: Readonly<Record<string, string>>;
|
|
3
|
+
export declare const claudeToolName: (dshName: string) => string;
|
|
4
|
+
export type ToolInput = Record<string, unknown>;
|
|
5
|
+
export declare function textOf(message: {
|
|
6
|
+
content?: readonly ContentBlock[];
|
|
7
|
+
} | undefined): string;
|
|
8
|
+
export declare function parseArguments(raw: unknown): ToolInput;
|
|
9
|
+
/** DSH tool arguments -> Claude Code `tool_input` shape. */
|
|
10
|
+
export declare function toClaudeToolInput(dshName: string, args: ToolInput | undefined): ToolInput;
|
|
11
|
+
/** DSH tool result -> the `tool_response` Claude Code hands to PostToolUse hooks. */
|
|
12
|
+
export declare function toClaudeToolResponse(dshName: string, args: ToolInput | undefined, result: ToolExecutionResult): ToolInput;
|
|
13
|
+
/**
|
|
14
|
+
* Export DSH session events as Claude Code transcript JSONL records:
|
|
15
|
+
* `{type:"user"|"assistant", message:{role, content:[...]}, sessionId, timestamp, cwd}`.
|
|
16
|
+
* Tool calls become `tool_use` blocks with Claude tool names; results become `tool_result`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toClaudeTranscript(events: readonly SessionEvent[], sessionId: string, cwd: string): string;
|
|
19
|
+
export declare function sessionEvents(session: Session): readonly SessionEvent[];
|
|
20
|
+
export declare function lastAssistantText(session: Session): string;
|
|
21
|
+
export declare function transcriptPath(agent: Agent): string;
|
|
22
|
+
/** Bring the Claude-shaped transcript up to date by appending events not yet written. */
|
|
23
|
+
export declare function syncTranscript(agent: Agent, cwd: string): string;
|
|
24
|
+
export declare function dropTranscript(agent: Agent): void;
|
|
25
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/transcript.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAe,MAAM,gBAAgB,CAAA;AAGlH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MA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