@princetheprogrammerbtw/husk 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 +21 -0
- package/README.md +125 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1146 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +702 -0
- package/dist/index.js +1110 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 princetheprogrammerbtw
|
|
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,125 @@
|
|
|
1
|
+
# Husk
|
|
2
|
+
|
|
3
|
+
> The agent harness that gives your LLM memory, hands, and a nervous system.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@princetheprogrammerbtw/husk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](./.github/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
## What is Husk?
|
|
11
|
+
|
|
12
|
+
Most LLM calls are a brain in a jar — they can think, but can't act, remember, verify their own work, or show you what they did. **Husk** is the body, hands, memory, and nervous system you wrap around any LLM (Claude, GPT, Gemini, local models) to turn it into a real agent.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Agent, AnthropicProvider, Read, Write, Edit, Bash, Grep, FileStore } from '@princetheprogrammerbtw/husk';
|
|
16
|
+
|
|
17
|
+
const agent = new Agent({
|
|
18
|
+
model: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY }),
|
|
19
|
+
tools: [Read, Write, Edit, Bash, Grep],
|
|
20
|
+
memory: new FileStore({ path: './.husk/memory' }),
|
|
21
|
+
steering: {
|
|
22
|
+
systemPrompt: 'You are a careful code reviewer. Cite specific line numbers.',
|
|
23
|
+
rules: [
|
|
24
|
+
'Read the file in full before commenting.',
|
|
25
|
+
'Prioritize security and correctness over style.',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const result = await agent.run('Review src/core/agent.ts');
|
|
31
|
+
console.log(result.output);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- 🧠 **Provider-agnostic** — Anthropic, OpenAI, more coming. Bring your own model.
|
|
37
|
+
- 🛠️ **5 built-in tools** — `Read`, `Write`, `Edit`, `Bash` (with safety denylist), `Grep` (ripgrep with grep fallback)
|
|
38
|
+
- 💾 **Memory** — `InMemoryStore` for sessions, `FileStore` for persistence
|
|
39
|
+
- 👀 **Observability** — typed event emitter, drop in any logger or tracer
|
|
40
|
+
- 🧭 **Steering** — system prompts, numbered rules, few-shot examples
|
|
41
|
+
- 🤝 **Sub-agents** — compose agents inside agents (see [multi-agent example](./examples/03-multi-agent))
|
|
42
|
+
- 📦 **Batteries included** — 35KB ESM bundle, full TypeScript types
|
|
43
|
+
- 🖥️ **CLI** — `husk run "<prompt>"` for one-shot invocations
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @princetheprogrammerbtw/husk
|
|
49
|
+
# or
|
|
50
|
+
pnpm add @princetheprogrammerbtw/husk
|
|
51
|
+
# or
|
|
52
|
+
bun add @princetheprogrammerbtw/husk
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You'll also need an API key for the provider you choose:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export ANTHROPIC_API_KEY=sk-ant-... # for Claude
|
|
59
|
+
export OPENAI_API_KEY=sk-... # for GPT
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quickstart
|
|
63
|
+
|
|
64
|
+
The smallest possible agent:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { Agent, AnthropicProvider } from '@princetheprogrammerbtw/husk';
|
|
68
|
+
|
|
69
|
+
const agent = new Agent({
|
|
70
|
+
model: new AnthropicProvider({ model: 'claude-opus-4-6' }),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const result = await agent.run('What is the capital of France? Answer in one sentence.');
|
|
74
|
+
console.log(result.output); // "Paris"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## CLI
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Run an agent from the command line
|
|
81
|
+
husk run "What is the capital of France?"
|
|
82
|
+
husk run "Refactor src/foo.ts" --tools read,edit,write
|
|
83
|
+
husk run "Summarize README.md" --provider openai --model gpt-5
|
|
84
|
+
husk run --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
Three worked examples in the `examples/` directory:
|
|
90
|
+
|
|
91
|
+
- **[01-hello-agent](./examples/01-hello-agent)** — minimal agent, no tools
|
|
92
|
+
- **[02-code-reviewer](./examples/02-code-reviewer)** — full tool set + steering for code review
|
|
93
|
+
- **[03-multi-agent](./examples/03-multi-agent)** — three agents composed in sequence (planner → coder → reviewer)
|
|
94
|
+
|
|
95
|
+
Run any example with `bun run examples/0X-name/index.ts`.
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- **[Learning Journal](./LEARNING.md)** — design decisions, trade-offs, and lessons learned
|
|
100
|
+
- **[Changelog](./CHANGELOG.md)** — release history
|
|
101
|
+
- **[Contributing](./CONTRIBUTING.md)** — how to contribute
|
|
102
|
+
|
|
103
|
+
## Architecture
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
src/
|
|
107
|
+
├── core/ # agent loop, types, events, memory, steering
|
|
108
|
+
├── providers/ # anthropic, openai (more coming)
|
|
109
|
+
├── tools/ # registry helpers + 5 built-ins
|
|
110
|
+
├── cli/ # the husk command
|
|
111
|
+
└── index.ts # public API surface
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Every piece composes through a typed event stream. The agent loop is ~150 lines. Provider adapters are the only files that know about provider-specific wire formats.
|
|
115
|
+
|
|
116
|
+
## Roadmap
|
|
117
|
+
|
|
118
|
+
- **v0.1.0** ✅ Core loop, Anthropic + OpenAI, 5 built-in tools, memory, observability, CLI
|
|
119
|
+
- **v0.2.0** Eval runner, OTel export, Ollama adapter
|
|
120
|
+
- **v0.3.0** Vector memory, hosted dashboard
|
|
121
|
+
- **v1.0.0** Stable API, marketplace, enterprise features
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT © 2026 princetheprogrammerbtw
|