@cmodjs/core 0.1.3 → 0.1.5
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 +4 -0
- package/connect.js +30 -30
- package/docs/commands.md +14 -6
- package/docs/index.md +3 -3
- package/docs/jobs.md +4 -6
- package/docs/mod.md +3 -3
- package/docs/testing.md +13 -29
- package/mod.d.ts +1 -0
- package/mod.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connect.ts +30 -30
- package/src/mod.ts +1 -0
- package/src/testing.ts +12 -4
- package/testing.d.ts.map +1 -1
- package/testing.js +10 -3
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/heyJordanParker/cmod/main/.claude-plugin/icon.png" alt="Claude Mod Manager" width="128">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# @cmodjs/core
|
|
2
6
|
|
|
3
7
|
The library every Claude Mod Manager mod imports. Claude Mod Manager (CMod) installs, tries, builds, checks, and publishes Claude Code mods: plugins with hooks, panes, slash commands, tools, permission rules, and an install step that runs with your consent.
|
package/connect.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createLifecycle, readPlugin } from './runtime/lifecycle.js';
|
|
2
2
|
let lifecycle;
|
|
3
|
-
async function
|
|
3
|
+
async function startMod($, e, next) {
|
|
4
4
|
await lifecycle.start(claudeOf($), readPlugin);
|
|
5
5
|
return next(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function routeToMod(_$, e, next) {
|
|
8
8
|
return lifecycle.route(next.event, e, (passed) => next(passed));
|
|
9
9
|
}
|
|
10
10
|
function claudeOf($) {
|
|
@@ -67,32 +67,32 @@ function claudeOf($) {
|
|
|
67
67
|
}
|
|
68
68
|
export function connect(on, definition) {
|
|
69
69
|
lifecycle = createLifecycle(definition);
|
|
70
|
-
on('session.start',
|
|
71
|
-
on('classic.SessionStart',
|
|
72
|
-
on('classic.SessionEnd',
|
|
73
|
-
on('classic.UserPromptSubmit',
|
|
74
|
-
on('classic.InstructionsLoaded',
|
|
75
|
-
on('classic.PreToolUse',
|
|
76
|
-
on('classic.PermissionRequest',
|
|
77
|
-
on('classic.PermissionDenied',
|
|
78
|
-
on('classic.PostToolUse',
|
|
79
|
-
on('classic.PostToolUseFailure',
|
|
80
|
-
on('classic.PostToolBatch',
|
|
81
|
-
on('classic.SubagentStart',
|
|
82
|
-
on('classic.SubagentStop',
|
|
83
|
-
on('classic.Notification',
|
|
84
|
-
on('classic.PreCompact',
|
|
85
|
-
on('classic.Stop',
|
|
86
|
-
on('classic.StopFailure',
|
|
87
|
-
on('tool.check',
|
|
88
|
-
on('tool.call',
|
|
89
|
-
on('prompt.submit',
|
|
90
|
-
on('prompt.context',
|
|
91
|
-
on('command.run',
|
|
92
|
-
on('session.measure',
|
|
93
|
-
on('skill.prompt',
|
|
94
|
-
on('ui.render',
|
|
95
|
-
on('ui.press',
|
|
96
|
-
on('ui.close',
|
|
97
|
-
on('cmod.call',
|
|
70
|
+
on('session.start', startMod);
|
|
71
|
+
on('classic.SessionStart', routeToMod);
|
|
72
|
+
on('classic.SessionEnd', routeToMod);
|
|
73
|
+
on('classic.UserPromptSubmit', routeToMod);
|
|
74
|
+
on('classic.InstructionsLoaded', routeToMod);
|
|
75
|
+
on('classic.PreToolUse', routeToMod);
|
|
76
|
+
on('classic.PermissionRequest', routeToMod);
|
|
77
|
+
on('classic.PermissionDenied', routeToMod);
|
|
78
|
+
on('classic.PostToolUse', routeToMod);
|
|
79
|
+
on('classic.PostToolUseFailure', routeToMod);
|
|
80
|
+
on('classic.PostToolBatch', routeToMod);
|
|
81
|
+
on('classic.SubagentStart', routeToMod);
|
|
82
|
+
on('classic.SubagentStop', routeToMod);
|
|
83
|
+
on('classic.Notification', routeToMod);
|
|
84
|
+
on('classic.PreCompact', routeToMod);
|
|
85
|
+
on('classic.Stop', routeToMod);
|
|
86
|
+
on('classic.StopFailure', routeToMod);
|
|
87
|
+
on('tool.check', routeToMod);
|
|
88
|
+
on('tool.call', routeToMod);
|
|
89
|
+
on('prompt.submit', routeToMod);
|
|
90
|
+
on('prompt.context', routeToMod);
|
|
91
|
+
on('command.run', routeToMod);
|
|
92
|
+
on('session.measure', routeToMod);
|
|
93
|
+
on('skill.prompt', routeToMod);
|
|
94
|
+
on('ui.render', routeToMod);
|
|
95
|
+
on('ui.press', routeToMod);
|
|
96
|
+
on('ui.close', routeToMod);
|
|
97
|
+
on('cmod.call', routeToMod);
|
|
98
98
|
}
|
package/docs/commands.md
CHANGED
|
@@ -82,22 +82,30 @@ cmod publish [path] [--dry-run]
|
|
|
82
82
|
|
|
83
83
|
Releases the mod at `path` (default: the current folder) at the version in its `plugin.json`:
|
|
84
84
|
|
|
85
|
-
1. Builds the release
|
|
86
|
-
2.
|
|
87
|
-
3.
|
|
88
|
-
4.
|
|
89
|
-
5.
|
|
85
|
+
1. Builds the release from the committed files, leaving out `cli/`, `.github/`, and `.claude/`.
|
|
86
|
+
2. Bundles the hooks module that `hooks/hooks.json` names, with the mod's source and packages, into one readable `.js` file, and points `hooks/hooks.json` at it. Anthropic's plugin directory reads a repository without installing its packages, so it can follow a mod only when all its code is in one file.
|
|
87
|
+
3. Checks the release with `claude plugin validate --strict`, and stops with the validator's message when it fails.
|
|
88
|
+
4. Commits the release as the `release` branch, and builds the release archive from that commit.
|
|
89
|
+
5. Builds the program `cli/` declares, and writes `SHA256SUMS` for every file of the release.
|
|
90
|
+
6. Writes `.claude-plugin/marketplace.json`, listing the archive and the CMod plugin.
|
|
91
|
+
7. Commits that file, tags `v<version>`, pushes the tag and the `release` branch, and creates the GitHub release.
|
|
92
|
+
8. Prints the link to paste as the Repository when you submit the mod at [claude.ai/directory/manage](https://claude.ai/directory/manage), such as `https://github.com/owner/greeter/tree/release`. The portal reads the branch from the link, so the directory follows `release`.
|
|
93
|
+
|
|
94
|
+
The release keeps `package.json` and `bun.lock`, so Claude Code still installs the mod's packages for its install and uninstall steps. `main` keeps the source only.
|
|
90
95
|
|
|
91
96
|
It needs, and refuses to start without:
|
|
92
97
|
|
|
93
98
|
- the mod's folder as the root of a git repository with at least one commit, because `git archive` builds from `HEAD`
|
|
99
|
+
- `node_modules` in the mod's folder, from `bun install`, when the hooks module imports a package
|
|
100
|
+
- a `register` declared as a function in the hooks module, as `cmod new` writes it, because the validator refuses a bundled `register` that is not one
|
|
101
|
+
- the `claude` command, which validates the release
|
|
94
102
|
- an `origin` remote on GitHub
|
|
95
103
|
- a `package.json` with no dependency on a `file:` or `link:` path, which no user has
|
|
96
104
|
- a `"program"` in the `cmod` key of `package.json` that names the program `cli/` declares, when `cli/` declares one
|
|
97
105
|
- the network, to hash the CMod plugin release it lists, unless the mod is CMod itself
|
|
98
106
|
- for a real publish, a working tree with no uncommitted changes, a `v<version>` tag that does not exist yet, a `git push` to `origin` that succeeds, and the `gh` command, which creates the GitHub release
|
|
99
107
|
|
|
100
|
-
`--dry-run` builds and writes everything, and pushes nothing. It allows uncommitted changes and an existing tag, and builds from the last commit.
|
|
108
|
+
`--dry-run` builds and writes everything, and pushes nothing. It allows uncommitted changes and an existing tag, and builds from the last commit. It prints the folder that holds the release, so you can read what the directory will read.
|
|
101
109
|
|
|
102
110
|
## Install mods
|
|
103
111
|
|
package/docs/index.md
CHANGED
|
@@ -30,7 +30,7 @@ my-mod/
|
|
|
30
30
|
|
|
31
31
|
The template is a working example to replace. It counts the prompts of the session in `state.session.prompts`, shows the count in a pane titled with the mod's name and above the prompt, and tests both. Replace the counter, the pane, the component, the Skill, and the tests with the mod's own.
|
|
32
32
|
|
|
33
|
-
A mod imports `@cmodjs/core` by path, such as `../node_modules/@cmodjs/core/mod.js`, because Claude Code loads a plugin's own files only. Types such as `RenderElement` and `
|
|
33
|
+
A mod imports `@cmodjs/core` by path, such as `../node_modules/@cmodjs/core/mod.js`, because Claude Code loads a plugin's own files only. Types such as `RenderElement` and `On` come from the `claude-code` module.
|
|
34
34
|
|
|
35
35
|
## Type-check after the first session
|
|
36
36
|
|
|
@@ -71,6 +71,7 @@ A mod imports from the files below, and every other file in this package is inte
|
|
|
71
71
|
| Import | Exports | Docs |
|
|
72
72
|
| --- | --- | --- |
|
|
73
73
|
| `mod.js` | `defineMod`, `ModDefinition`, `Mod`, `PartContext`, `Part`, `ProgressStep`, `PaneHandle`, `longestMs`, `messageOf` | [mod.md](mod.md), [jobs.md](jobs.md), [ui.md](ui.md) |
|
|
74
|
+
| `mod.js` | `Claude`, `RoutedEvent`, `RoutedHook`, `ToolCalls` | [jobs.md](jobs.md) |
|
|
74
75
|
| `mod.js` | `ModEvent`, `ModHook`, `HookAnswer` | [hooks.md](hooks.md) |
|
|
75
76
|
| `mod.js` | `notInstalled` | [dependencies.md](dependencies.md) |
|
|
76
77
|
| `connect.js` | `connect` | [mod.md](mod.md) |
|
|
@@ -86,8 +87,7 @@ A mod imports from the files below, and every other file in this package is inte
|
|
|
86
87
|
| `jobs/prompt.js` | `prompt` | [jobs.md](jobs.md) |
|
|
87
88
|
| `jobs/status-line.js` | `statusLine`, `Usage` | [jobs.md](jobs.md) |
|
|
88
89
|
| `jobs/program.js` | `program`, `Program` | [jobs.md](jobs.md) |
|
|
89
|
-
| `jobs/part-context.js` | `afterCall`, `modWithin`, `modOf`, `workspaceReader
|
|
90
|
-
| `jobs/permissions/match-target.js` | `targetOf`, `matchTarget`, `folderInScope`, `Target`, `TargetKey`, `TargetOf`, `TargetCalls`, `MatchedCall` | [jobs.md](jobs.md) |
|
|
90
|
+
| `jobs/part-context.js` | `afterCall`, `modWithin`, `modOf`, `workspaceReader` | [jobs.md](jobs.md) |
|
|
91
91
|
| `jobs/permissions/decide-permission.js` | `decidePermission`, `stricterVerdict`, `Rule`, `PermissionRules`, `Decision`, `Verdict` | [jobs.md](jobs.md) |
|
|
92
92
|
| `jobs/permissions/find-project-scope.js` | `findProjectScope`, `ProjectScope`, `Workspace` | [jobs.md](jobs.md) |
|
|
93
93
|
|
package/docs/jobs.md
CHANGED
|
@@ -255,7 +255,7 @@ prompt<State>(options: {
|
|
|
255
255
|
- With `when` or `after`, the text goes to Claude under the heading `# <name>`.
|
|
256
256
|
- A `prompt` function that returns `undefined` or `''` adds nothing. One that throws adds nothing, and the error goes to Claude Code's debug log.
|
|
257
257
|
- `name` cannot be blank. `when` and `after` together throw: add a second `prompt` for the other trigger. Two prompts with one name in a mod throw.
|
|
258
|
-
- A `when` prompt runs on `prompt.submit` and adds its text to the event it passes down
|
|
258
|
+
- A `when` prompt runs on `prompt.submit` and adds its text to the event it passes down. In a test, `fire('prompt.submit', …)` returns that text in the answer's `context`. [testing.md](testing.md#test-a-prompt-with-when) shows how.
|
|
259
259
|
|
|
260
260
|
```ts
|
|
261
261
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
@@ -387,7 +387,7 @@ export const timer = defineMod({
|
|
|
387
387
|
|
|
388
388
|
### The claude members
|
|
389
389
|
|
|
390
|
-
`mod.js`
|
|
390
|
+
`mod.js` exports the types `Claude`, `RoutedEvent`, `RoutedHook`, and `ToolCalls`, so a job of your own names them in its own helpers, such as `(claude: Claude, calls: ToolCalls): RoutedHook<'command.run'> => …`.
|
|
391
391
|
|
|
392
392
|
Each member calls the member of the same name in Claude Code's hooks API, `$`, with the same arguments. The `env` members read `$.env.get` instead.
|
|
393
393
|
|
|
@@ -440,13 +440,11 @@ The built-in jobs are written from these building blocks, which a job of your ow
|
|
|
440
440
|
| `jobs/part-context.js` | `modWithin(part, deadline, workTree?)` | A `mod` whose calls fail at `deadline`, `{ ms, job?, longestMs? }`. |
|
|
441
441
|
| `jobs/part-context.js` | `modOf(part, { call?, folder }, workspace, deadline)` | `modWithin`, with `mod.process` calls run in the call's work tree. |
|
|
442
442
|
| `jobs/part-context.js` | `workspaceReader(part)` | A function that reads the session's `projectRoot`, `cwd`, `home`, file access, and project scope. |
|
|
443
|
-
| `jobs/part-context.js` | `targetWords(target)` | A target in words, such as `edits to src/**`. |
|
|
444
|
-
| `jobs/permissions/match-target.js` | `targetOf`, `matchTarget`, `folderInScope`, and the types `Target`, `TargetKey`, `TargetOf`, `TargetCalls`, `MatchedCall` | Checks a target and matches it against a call. |
|
|
445
443
|
| `jobs/permissions/decide-permission.js` | `decidePermission`, `stricterVerdict`, and the types `Rule`, `PermissionRules`, `Decision`, `Verdict` | Decides a call against permission rules. |
|
|
446
444
|
| `jobs/permissions/find-project-scope.js` | `findProjectScope`, and the types `ProjectScope`, `Workspace` | Finds the repository a project plugin belongs to. |
|
|
447
445
|
|
|
448
|
-
|
|
446
|
+
A job of your own matches calls against targets through the `permissions`, `check`, and `prompt` jobs. A `prompt` with `after` runs any code after a matching call, and may add no text: `prompt({ name: 'commits', after: { command: 'git commit' }, prompt: (_input, mod) => { mod.state.project.commits += 1; return undefined } })`.
|
|
449
447
|
|
|
450
448
|
## Test a job
|
|
451
449
|
|
|
452
|
-
`tested.type('/todo milk')` runs a slash command. `tested.callTool('open_ticket', { title: 'Crash' })` runs the permission rules, then the tool. `tested.fire('tool.check', …)` asks the permission rules about any call. `tested.fire('prompt.submit', …)`
|
|
450
|
+
`tested.type('/todo milk')` runs a slash command. `tested.callTool('open_ticket', { title: 'Crash' })` runs the permission rules, then the tool. `tested.fire('tool.check', …)` asks the permission rules about any call. `tested.fire('prompt.submit', …)` returns the context a `when` prompt added. [testing.md](testing.md) covers each.
|
package/docs/mod.md
CHANGED
|
@@ -59,11 +59,11 @@ Each of these says `Fix it, then run /reload-plugins.`
|
|
|
59
59
|
`hooks/hooks.json` names `hooks/register.ts` as the plugin's hooks module. `register.ts` calls `connect` and does nothing else:
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
|
-
import type {
|
|
62
|
+
import type { On } from 'claude-code'
|
|
63
63
|
import { connect } from '../node_modules/@cmodjs/core/connect.js'
|
|
64
64
|
import { greeter } from '../src/mod.js'
|
|
65
65
|
|
|
66
|
-
export
|
|
66
|
+
export function register(on: On): void {
|
|
67
67
|
connect(on, greeter)
|
|
68
68
|
}
|
|
69
69
|
```
|
|
@@ -72,7 +72,7 @@ export const register: Register = (on) => {
|
|
|
72
72
|
connect<State>(on: On, definition: ModDefinition<State>): void
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
`connect` registers one handler per Claude Code event the mod can use, and routes each event to the mod. Keep `register.ts` this small. Claude Code checks a hooks module before it loads it, and refuses some shapes, such as a `$` passed to a function in another module.
|
|
75
|
+
`connect` registers one handler per Claude Code event the mod can use, and routes each event to the mod. Keep `register.ts` this small. Claude Code checks a hooks module before it loads it, and refuses some shapes, such as a `$` passed to a function in another module. Declare `register` as a function, as here: `cmod publish` bundles the hooks module into one file, and Claude Code refuses a bundled `register` that is not one.
|
|
76
76
|
|
|
77
77
|
## What `mod` can call
|
|
78
78
|
|
package/docs/testing.md
CHANGED
|
@@ -80,7 +80,8 @@ fire<N extends RoutedEvent>(event: N, input: Args<N>, below?): Promise<EventResu
|
|
|
80
80
|
|
|
81
81
|
- `fire('UserPromptSubmit', { prompt: 'hello' })` runs the mod's hooks on a `ModEvent`. `TestInput<E>` is the event's input without the fields `fire` fills: `session_id`, `transcript_path`, `cwd`, `hook_event_name`, and a new `tool_use_id` for each tool event.
|
|
82
82
|
- For a tool event, `files` is worked out from the call and the test's `files`, as in Claude Code.
|
|
83
|
-
- `below` is what the hooks beneath the mod answered
|
|
83
|
+
- `below` is what the hooks beneath the mod answered. Pass it to test how the mod's answer combines with another, such as a `deny` beneath. When nothing in the mod answers, `fire` returns `below` as it is.
|
|
84
|
+
- Left out, `below` is `{}`, except on `prompt.submit`, where it is what Claude Code answers: the prompt that entered, `{ text, context, origin }`, with the `context` the mod's hooks added.
|
|
84
85
|
- It returns the combined answer in Claude Code's own field names: `additionalContext` is a list, a `PreToolUse` decision is `allow: true`, or the key `ask` or `deny` with the reason as its value, and `decision: 'block'` is `block`.
|
|
85
86
|
- `fire('tool.check', { tool: 'Edit', input: { … }, tool_use_id: 'toolu_1' }, { decision: 'allow' })` asks the mod's permission rules about any call. A name with a dot fires that Claude Code hook-module event as it is.
|
|
86
87
|
|
|
@@ -100,10 +101,10 @@ test('a force push is denied with the reason', async () => {
|
|
|
100
101
|
|
|
101
102
|
### Test a prompt with when
|
|
102
103
|
|
|
103
|
-
A `prompt` with `when` runs on the hook-module event `prompt.submit`, not on `UserPromptSubmit`, so `fire('UserPromptSubmit', …)` never reaches it.
|
|
104
|
+
A `prompt` with `when` runs on the hook-module event `prompt.submit`, not on `UserPromptSubmit`, so `fire('UserPromptSubmit', …)` never reaches it. `fire('prompt.submit', …)` returns the prompt that entered, with the text the prompt added in its `context`:
|
|
104
105
|
|
|
105
106
|
- The `prompt.submit` input is `{ text, wait, origin }`. A prompt the person typed has `wait: false` and `origin: { kind: 'composer' }`.
|
|
106
|
-
- `context` is a list of strings, each `# <name>\n<text>`.
|
|
107
|
+
- `context` is a list of strings, each `# <name>\n<text>`. The answer has no `context` when no prompt added anything.
|
|
107
108
|
|
|
108
109
|
```ts
|
|
109
110
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
@@ -119,35 +120,18 @@ export const release = defineMod({
|
|
|
119
120
|
|
|
120
121
|
```ts
|
|
121
122
|
import { expect, test } from 'bun:test'
|
|
122
|
-
import { defineMod, type Part } from '../node_modules/@cmodjs/core/mod.js'
|
|
123
123
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
124
124
|
import { release } from '../src/mod.js'
|
|
125
125
|
|
|
126
|
-
function contextBelow(passedOn: unknown[]): Part<void> {
|
|
127
|
-
return ({ on }) => {
|
|
128
|
-
on('prompt.submit', async (e, next) => {
|
|
129
|
-
passedOn.push(e.context)
|
|
130
|
-
return next(e)
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
126
|
test('a prompt about a release gets the release steps, and another prompt gets nothing', async () => {
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}),
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
await tested.fire('prompt.submit', { text: 'Cut a release', wait: false, origin: { kind: 'composer' } }, { text: '' })
|
|
148
|
-
await tested.fire('prompt.submit', { text: 'Fix the bug', wait: false, origin: { kind: 'composer' } }, { text: '' })
|
|
149
|
-
|
|
150
|
-
expect(passedOn).toEqual([['# release-steps\nRun bun run release, then push the tag.'], undefined])
|
|
127
|
+
const tested = testMod(release)
|
|
128
|
+
const typed = { wait: false, origin: { kind: 'composer' } } as const
|
|
129
|
+
|
|
130
|
+
const aboutRelease = await tested.fire('prompt.submit', { text: 'Cut a release', ...typed })
|
|
131
|
+
const aboutBug = await tested.fire('prompt.submit', { text: 'Fix the bug', ...typed })
|
|
132
|
+
|
|
133
|
+
expect(aboutRelease).toEqual({ text: 'Cut a release', context: ['# release-steps\nRun bun run release, then push the tag.'], origin: typed.origin })
|
|
134
|
+
expect(aboutBug).toEqual({ text: 'Fix the bug', origin: typed.origin })
|
|
151
135
|
})
|
|
152
136
|
```
|
|
153
137
|
|
|
@@ -157,7 +141,7 @@ Waits until the work a hook started without awaiting it has run, such as a `void
|
|
|
157
141
|
|
|
158
142
|
### lines
|
|
159
143
|
|
|
160
|
-
- `lines(paneId)` draws an open pane and returns its rows of text. It rejects a pane that is not open: open it first with `tested.type('/<command>')` or `pane.open()` in the mod. The render gets the props `title`, `isFocused`, `bodyColumns`,
|
|
144
|
+
- `lines(paneId)` draws an open pane and returns its rows of text. It rejects a pane that is not open: open it first with `tested.type('/<command>')` or `pane.open()` in the mod. The render gets the props `title`, `isFocused: false`, `bodyColumns`, `placement: 'dock'`, `scroll: { offset: 0, bodyRows: 24 }`, and `view: {}`, the main conversation's view.
|
|
161
145
|
- `lines(slot, props, requestId?)` draws a slot render with `props` and returns its rows. `Default` draws a plain listing of the props it gets, so a test sees what the render changed. Draw `slots.AssistantMessage` with a reply's `text` to test a markdown slot render. Draws that pass one `requestId` grow one streamed reply.
|
|
162
146
|
|
|
163
147
|
```ts
|
package/mod.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type PaneHandle = {
|
|
|
16
16
|
toggle(): Promise<void>;
|
|
17
17
|
readonly isOpen: boolean;
|
|
18
18
|
};
|
|
19
|
+
export type { Claude, RoutedEvent, RoutedHook, ToolCalls };
|
|
19
20
|
export { longestMs } from './runtime/deadline.js';
|
|
20
21
|
export { notInstalled } from './runtime/dependencies.js';
|
|
21
22
|
export { messageOf } from './utils/text.js';
|
package/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,yBAAyB,EACzB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,gBAAgB,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG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AC,KAAK,EAAE,KAAK,CAAC,IAAI;IACrE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5D,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,MAAM,CAAA;AAE/G,wBAAgB,SAAS,CAAC,KAAK,SAAS,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAG5K"}
|
package/package.json
CHANGED
package/src/connect.ts
CHANGED
|
@@ -6,12 +6,12 @@ import { createLifecycle, readPlugin, type Lifecycle } from './runtime/lifecycle
|
|
|
6
6
|
|
|
7
7
|
let lifecycle: Lifecycle<object>
|
|
8
8
|
|
|
9
|
-
async function
|
|
9
|
+
async function startMod($: EngineInterface, e: Frozen<Args<'session.start'>>, next: Next<'session.start'>): Promise<EventResult<'session.start'>> {
|
|
10
10
|
await lifecycle.start(claudeOf($), readPlugin)
|
|
11
11
|
return next(e)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function routeToMod<N extends RoutedEvent>(_$: EngineInterface, e: Frozen<Args<N>>, next: Next<N>): Promise<EventResult<N>> {
|
|
15
15
|
return lifecycle.route(next.event, e, (passed: unknown) => next(passed as Args<N>) as Promise<EventResult<N>>)
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -76,32 +76,32 @@ function claudeOf($: EngineInterface): Claude {
|
|
|
76
76
|
|
|
77
77
|
export function connect<State extends object>(on: On, definition: ModDefinition<State>): void {
|
|
78
78
|
lifecycle = createLifecycle(definition)
|
|
79
|
-
on('session.start',
|
|
80
|
-
on('classic.SessionStart',
|
|
81
|
-
on('classic.SessionEnd',
|
|
82
|
-
on('classic.UserPromptSubmit',
|
|
83
|
-
on('classic.InstructionsLoaded',
|
|
84
|
-
on('classic.PreToolUse',
|
|
85
|
-
on('classic.PermissionRequest',
|
|
86
|
-
on('classic.PermissionDenied',
|
|
87
|
-
on('classic.PostToolUse',
|
|
88
|
-
on('classic.PostToolUseFailure',
|
|
89
|
-
on('classic.PostToolBatch',
|
|
90
|
-
on('classic.SubagentStart',
|
|
91
|
-
on('classic.SubagentStop',
|
|
92
|
-
on('classic.Notification',
|
|
93
|
-
on('classic.PreCompact',
|
|
94
|
-
on('classic.Stop',
|
|
95
|
-
on('classic.StopFailure',
|
|
96
|
-
on('tool.check',
|
|
97
|
-
on('tool.call',
|
|
98
|
-
on('prompt.submit',
|
|
99
|
-
on('prompt.context',
|
|
100
|
-
on('command.run',
|
|
101
|
-
on('session.measure',
|
|
102
|
-
on('skill.prompt',
|
|
103
|
-
on('ui.render',
|
|
104
|
-
on('ui.press',
|
|
105
|
-
on('ui.close',
|
|
106
|
-
on('cmod.call',
|
|
79
|
+
on('session.start', startMod)
|
|
80
|
+
on('classic.SessionStart', routeToMod)
|
|
81
|
+
on('classic.SessionEnd', routeToMod)
|
|
82
|
+
on('classic.UserPromptSubmit', routeToMod)
|
|
83
|
+
on('classic.InstructionsLoaded', routeToMod)
|
|
84
|
+
on('classic.PreToolUse', routeToMod)
|
|
85
|
+
on('classic.PermissionRequest', routeToMod)
|
|
86
|
+
on('classic.PermissionDenied', routeToMod)
|
|
87
|
+
on('classic.PostToolUse', routeToMod)
|
|
88
|
+
on('classic.PostToolUseFailure', routeToMod)
|
|
89
|
+
on('classic.PostToolBatch', routeToMod)
|
|
90
|
+
on('classic.SubagentStart', routeToMod)
|
|
91
|
+
on('classic.SubagentStop', routeToMod)
|
|
92
|
+
on('classic.Notification', routeToMod)
|
|
93
|
+
on('classic.PreCompact', routeToMod)
|
|
94
|
+
on('classic.Stop', routeToMod)
|
|
95
|
+
on('classic.StopFailure', routeToMod)
|
|
96
|
+
on('tool.check', routeToMod)
|
|
97
|
+
on('tool.call', routeToMod)
|
|
98
|
+
on('prompt.submit', routeToMod)
|
|
99
|
+
on('prompt.context', routeToMod)
|
|
100
|
+
on('command.run', routeToMod)
|
|
101
|
+
on('session.measure', routeToMod)
|
|
102
|
+
on('skill.prompt', routeToMod)
|
|
103
|
+
on('ui.render', routeToMod)
|
|
104
|
+
on('ui.press', routeToMod)
|
|
105
|
+
on('ui.close', routeToMod)
|
|
106
|
+
on('cmod.call', routeToMod)
|
|
107
107
|
}
|
package/src/mod.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type PaneHandle = {
|
|
|
36
36
|
readonly isOpen: boolean
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export type { Claude, RoutedEvent, RoutedHook, ToolCalls }
|
|
39
40
|
export { longestMs } from './runtime/deadline.js'
|
|
40
41
|
export { notInstalled } from './runtime/dependencies.js'
|
|
41
42
|
export { messageOf } from './utils/text.js'
|
package/src/testing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Args, ClassicHookInputs, CmodDependencies, CommandPresentation, CommandRunResult, EventResult, Frozen, PaneOpenArgs, RenderChildren, RenderComponent, RenderElement } from 'claude-code'
|
|
1
|
+
import type { Args, ClassicHookInputs, CmodDependencies, CommandPresentation, CommandRunResult, EventResult, Frozen, PaneOpenArgs, RenderChildren, RenderComponent, RenderElement, RenderPropsOf } from 'claude-code'
|
|
2
2
|
import type { Reply } from './jobs/slash-command.js'
|
|
3
3
|
import type { ModDefinition, ModEvent } from './mod.js'
|
|
4
4
|
import { storeFolder } from './records.js'
|
|
@@ -45,6 +45,8 @@ export type TestedMod<State extends object> = {
|
|
|
45
45
|
|
|
46
46
|
const defaultColumns = 80
|
|
47
47
|
|
|
48
|
+
const defaultRows = 24
|
|
49
|
+
|
|
48
50
|
const presentation: CommandPresentation = { isFullscreen: false, columns: defaultColumns }
|
|
49
51
|
|
|
50
52
|
const toolUseEvents: readonly string[] = ['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'PermissionDenied'] satisfies readonly ModEvent[]
|
|
@@ -87,7 +89,7 @@ export function testMod<State extends object>(definition: ModDefinition<State>,
|
|
|
87
89
|
|
|
88
90
|
const route = async <N extends RoutedEvent>(event: N, input: unknown, below: unknown): Promise<EventResult<N>> => {
|
|
89
91
|
await start()
|
|
90
|
-
return lifecycle.route(event, input as Frozen<Args<N>>, async () => below as EventResult<N>)
|
|
92
|
+
return lifecycle.route(event, input as Frozen<Args<N>>, async (e) => (below ?? claudeCodeAnswer(event, e)) as EventResult<N>)
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
const drawPane = async (paneId: string) => {
|
|
@@ -98,7 +100,7 @@ export function testMod<State extends object>(definition: ModDefinition<State>,
|
|
|
98
100
|
}
|
|
99
101
|
const opened = fake.calls.findLast((call) => call.call === 'ui.open' && (call.args[0] as PaneOpenArgs).id === paneId)?.args[0] as PaneOpenArgs | undefined
|
|
100
102
|
const columns = opened?.columns ?? defaultColumns
|
|
101
|
-
const props = { title: opened?.title ?? paneId, isFocused: false, bodyColumns: columns, placement: 'dock' }
|
|
103
|
+
const props: RenderPropsOf['Pane'] = { title: opened?.title ?? paneId, isFocused: false, bodyColumns: columns, placement: 'dock', scroll: { offset: 0, bodyRows: defaultRows }, view: {} }
|
|
102
104
|
const drawing = await route('ui.render', { surface: 'terminal', component: 'Pane', requestId: paneId, props }, elements.Box({}))
|
|
103
105
|
return { drawing, columns }
|
|
104
106
|
}
|
|
@@ -110,7 +112,7 @@ export function testMod<State extends object>(definition: ModDefinition<State>,
|
|
|
110
112
|
return { drawing, columns: defaultColumns }
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
const fire = ((event: string, input: object, below
|
|
115
|
+
const fire = ((event: string, input: object, below?: unknown) => {
|
|
114
116
|
if (event.includes('.')) return route(event as RoutedEvent, input, below)
|
|
115
117
|
if (event === 'SessionStart') sessionId = (input as { session_id?: string }).session_id ?? sessionId
|
|
116
118
|
if (event === 'UserPromptSubmit') {
|
|
@@ -192,6 +194,12 @@ function fakeDependencies(dependencies: NonNullable<TestOptions<object>['depende
|
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
197
|
+
function claudeCodeAnswer(event: RoutedEvent, e: unknown): unknown {
|
|
198
|
+
if (event !== 'prompt.submit') return {}
|
|
199
|
+
const { text, context, origin } = e as Args<'prompt.submit'>
|
|
200
|
+
return { text, ...(context === undefined ? {} : { context }), origin }
|
|
201
|
+
}
|
|
202
|
+
|
|
195
203
|
function plainOutput({ component, props }: Args<'ui.render'>): RenderElement {
|
|
196
204
|
const rows = Object.entries(props).map(([key, value]) => elements.Text({ children: `${key}: ${JSON.stringify(value)}` }))
|
|
197
205
|
return elements.Box({ flexDirection: 'column', children: [elements.Text({ children: component }), elements.Box({ flexDirection: 'column', paddingLeft: 2, children: rows })] })
|
package/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,gBAAgB,EAAyC,WAAW,EAAwC,eAAe,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["src/testing.ts"],"names":[],"mappings":"A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,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IACzF,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB,CAAA;AAUD,wBAAgB,OAAO,CAAC,KAAK,SAAS,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,OAAO,GAAE,WAAW,CAAC,KAAK,CAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAmIlI"}
|
package/testing.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fakeClaude } from './testing/fake-claude.js';
|
|
|
5
5
|
import { elements, findButton, rowsOf } from './testing/fake-elements.js';
|
|
6
6
|
import { fakeFiles } from './testing/fake-files.js';
|
|
7
7
|
const defaultColumns = 80;
|
|
8
|
+
const defaultRows = 24;
|
|
8
9
|
const presentation = { isFullscreen: false, columns: defaultColumns };
|
|
9
10
|
const toolUseEvents = ['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'PermissionDenied'];
|
|
10
11
|
export function testMod(definition, options = {}) {
|
|
@@ -44,7 +45,7 @@ export function testMod(definition, options = {}) {
|
|
|
44
45
|
};
|
|
45
46
|
const route = async (event, input, below) => {
|
|
46
47
|
await start();
|
|
47
|
-
return lifecycle.route(event, input, async () => below);
|
|
48
|
+
return lifecycle.route(event, input, async (e) => (below ?? claudeCodeAnswer(event, e)));
|
|
48
49
|
};
|
|
49
50
|
const drawPane = async (paneId) => {
|
|
50
51
|
await start();
|
|
@@ -54,7 +55,7 @@ export function testMod(definition, options = {}) {
|
|
|
54
55
|
}
|
|
55
56
|
const opened = fake.calls.findLast((call) => call.call === 'ui.open' && call.args[0].id === paneId)?.args[0];
|
|
56
57
|
const columns = opened?.columns ?? defaultColumns;
|
|
57
|
-
const props = { title: opened?.title ?? paneId, isFocused: false, bodyColumns: columns, placement: 'dock' };
|
|
58
|
+
const props = { title: opened?.title ?? paneId, isFocused: false, bodyColumns: columns, placement: 'dock', scroll: { offset: 0, bodyRows: defaultRows }, view: {} };
|
|
58
59
|
const drawing = await route('ui.render', { surface: 'terminal', component: 'Pane', requestId: paneId, props }, elements.Box({}));
|
|
59
60
|
return { drawing, columns };
|
|
60
61
|
};
|
|
@@ -64,7 +65,7 @@ export function testMod(definition, options = {}) {
|
|
|
64
65
|
const drawing = await lifecycle.route('ui.render', input, async (e) => plainOutput(e));
|
|
65
66
|
return { drawing, columns: defaultColumns };
|
|
66
67
|
};
|
|
67
|
-
const fire = ((event, input, below
|
|
68
|
+
const fire = ((event, input, below) => {
|
|
68
69
|
if (event.includes('.'))
|
|
69
70
|
return route(event, input, below);
|
|
70
71
|
if (event === 'SessionStart')
|
|
@@ -155,6 +156,12 @@ function fakeDependencies(dependencies) {
|
|
|
155
156
|
return answer.value;
|
|
156
157
|
};
|
|
157
158
|
}
|
|
159
|
+
function claudeCodeAnswer(event, e) {
|
|
160
|
+
if (event !== 'prompt.submit')
|
|
161
|
+
return {};
|
|
162
|
+
const { text, context, origin } = e;
|
|
163
|
+
return { text, ...(context === undefined ? {} : { context }), origin };
|
|
164
|
+
}
|
|
158
165
|
function plainOutput({ component, props }) {
|
|
159
166
|
const rows = Object.entries(props).map(([key, value]) => elements.Text({ children: `${key}: ${JSON.stringify(value)}` }));
|
|
160
167
|
return elements.Box({ flexDirection: 'column', children: [elements.Text({ children: component }), elements.Box({ flexDirection: 'column', paddingLeft: 2, children: rows })] });
|