@dexh/shannon 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HumanLayer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # Shannon
2
+
3
+ Shannon is a CLI and SDK wrapper around the interactive Claude Code CLI. It starts a real `claude` session inside tmux, sends a prompt, tails Claude's on-disk transcript, emits stream JSON, and cleans up the tmux session on exit.
4
+
5
+ The first supported path is:
6
+
7
+ ```sh
8
+ shannon -p "hi i'm tom" --output-format=stream-json --verbose
9
+ ```
10
+
11
+ Shannon does not use `claude -p` internally.
12
+
13
+ ## Requirements
14
+
15
+ - Bun
16
+ - `claude` on `PATH`
17
+ - `tmux` on `PATH`
18
+ - A working Claude Code login/configuration
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ bun install
24
+ bun link
25
+ ```
26
+
27
+ After linking, `shannon` should resolve from your Bun bin directory:
28
+
29
+ ```sh
30
+ which shannon
31
+ ```
32
+
33
+ ## CLI
34
+
35
+ ```sh
36
+ shannon -p "Reply with exactly: hello" --output-format=stream-json --verbose
37
+ ```
38
+
39
+ Incremental stdin JSONL input is supported for one or more user messages:
40
+
41
+ ```sh
42
+ printf '%s\n' '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Reply with exactly: hello"}]},"parent_tool_use_id":null,"session_id":""}' \
43
+ | shannon --input-format=stream-json --output-format=stream-json --verbose --replay-user-messages
44
+ ```
45
+
46
+ Current stream shape:
47
+
48
+ - `system` / `hook_response` when interactive transcript hook attachments are present
49
+ - `system` / `init`
50
+ - `assistant`
51
+ - synthesized `result` / `success`
52
+ - final `shannon_session` / `metadata`
53
+
54
+ The final metadata row includes the Claude session id, transcript path, project session folder, tmux session name, cwd, and cleanup status.
55
+
56
+ `--output-format=json` emits one JSON array containing Shannon's supported
57
+ message rows. `--output-format=text` emits the final result text.
58
+
59
+ ## SDK
60
+
61
+ ```ts
62
+ import { query } from "@humanlayer/shannon";
63
+
64
+ for await (const message of query({
65
+ prompt: "Reply with exactly: hello",
66
+ options: {
67
+ outputFormat: "stream-json",
68
+ verbose: true,
69
+ },
70
+ })) {
71
+ console.log(JSON.stringify(message));
72
+ }
73
+ ```
74
+
75
+ Async input is also accepted for finite user-message streams:
76
+
77
+ ```ts
78
+ import { query, type ShannonUserMessage } from "@humanlayer/shannon";
79
+
80
+ async function* messages(): AsyncIterable<ShannonUserMessage> {
81
+ yield {
82
+ type: "user",
83
+ message: {
84
+ role: "user",
85
+ content: [{ type: "text", text: "Reply with exactly: hello" }],
86
+ },
87
+ parent_tool_use_id: null,
88
+ session_id: "",
89
+ };
90
+ }
91
+
92
+ for await (const message of query({ prompt: messages() })) {
93
+ console.log(JSON.stringify(message));
94
+ }
95
+ ```
96
+
97
+ Queries accept an `AbortController` in options; aborting it terminates the
98
+ underlying Shannon subprocess.
99
+
100
+ The SDK also exports zod schemas for the current Shannon message, options, and
101
+ query parameter surface:
102
+
103
+ ```ts
104
+ import { shannonMessageSchema, shannonQueryOptionsSchema } from "@humanlayer/shannon";
105
+ ```
106
+
107
+ The SDK facade shells out to the `shannon` executable and parses JSONL stdout into an async iterable.
108
+
109
+ The repo also includes `packages/shannon-agent-sdk`, a thin
110
+ `@humanlayer/shannon-agent-sdk` facade over the implemented Shannon SDK surface.
111
+ It is not full Claude Agent SDK parity yet.
112
+
113
+ ## Development
114
+
115
+ ```sh
116
+ bun test
117
+ bun run typecheck
118
+ ```
119
+
120
+ CI runs the same non-live checks plus package dry-runs for both packages.
121
+ The publish workflow publishes `@humanlayer/shannon` and
122
+ `@humanlayer/shannon-agent-sdk` from a GitHub release or manual dispatch when
123
+ `NPM_TOKEN` is configured.
124
+
125
+ Run the CLI directly:
126
+
127
+ ```sh
128
+ bun ./index.ts -p "hello" --output-format=stream-json --verbose
129
+ ```
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { dirname, join } from "node:path";
5
+
6
+ const here = dirname(fileURLToPath(import.meta.url));
7
+ const entry = join(here, "..", "index.ts");
8
+
9
+ const result = spawnSync("bun", [entry, ...process.argv.slice(2)], {
10
+ stdio: "inherit",
11
+ });
12
+
13
+ if (result.error) {
14
+ if (result.error.code === "ENOENT") {
15
+ console.error(
16
+ "shannon requires Bun (https://bun.sh). Install it and try again.",
17
+ );
18
+ process.exit(127);
19
+ }
20
+ console.error(result.error.message);
21
+ process.exit(1);
22
+ }
23
+
24
+ process.exit(result.status ?? 0);