@hasna/brains 0.0.6 → 0.0.8
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 +190 -0
- package/dist/cli/index.js +1172 -809
- package/dist/db/index.d.ts.map +1 -1
- package/dist/index.js +4294 -142
- package/dist/lib/config.d.ts +11 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/gatherers/assistants.d.ts +3 -0
- package/dist/lib/gatherers/assistants.d.ts.map +1 -0
- package/dist/lib/gatherers/economy.d.ts +3 -0
- package/dist/lib/gatherers/economy.d.ts.map +1 -0
- package/dist/lib/gatherers/index.d.ts +3 -0
- package/dist/lib/gatherers/index.d.ts.map +1 -1
- package/dist/lib/gatherers/protocol.d.ts +29 -0
- package/dist/lib/gatherers/protocol.d.ts.map +1 -0
- package/dist/lib/gatherers/recordings.d.ts +3 -0
- package/dist/lib/gatherers/recordings.d.ts.map +1 -0
- package/dist/lib/gatherers/registry.d.ts +7 -0
- package/dist/lib/gatherers/registry.d.ts.map +1 -0
- package/dist/lib/gatherers/researcher.d.ts +3 -0
- package/dist/lib/gatherers/researcher.d.ts.map +1 -0
- package/dist/lib/gatherers/styles.d.ts +3 -0
- package/dist/lib/gatherers/styles.d.ts.map +1 -0
- package/dist/lib/gatherers/tickets.d.ts +3 -0
- package/dist/lib/gatherers/tickets.d.ts.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/providers/openai.d.ts +2 -0
- package/dist/lib/providers/openai.d.ts.map +1 -1
- package/dist/lib/providers/thinker-labs.d.ts +1 -0
- package/dist/lib/providers/thinker-labs.d.ts.map +1 -1
- package/dist/lib/retry.d.ts +7 -0
- package/dist/lib/retry.d.ts.map +1 -0
- package/dist/lib/schemas.d.ts +87 -0
- package/dist/lib/schemas.d.ts.map +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4585 -196
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4638 -9
- package/drizzle/0000_foamy_daimon_hellstrom.sql +36 -0
- package/drizzle/meta/0000_snapshot.json +259 -0
- package/drizzle/meta/_journal.json +13 -0
- package/package.json +6 -2
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# @hasna/brains
|
|
2
|
+
|
|
3
|
+
Fine-tuned model tracker and trainer. Gathers training data from your AI agent ecosystem (todos, mementos, conversations, Claude sessions), submits fine-tuning jobs to OpenAI or Thinker Labs, and tracks models locally in SQLite.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @hasna/brains # as a library
|
|
9
|
+
bun add -g @hasna/brains # for CLI globally
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or with npm/npx:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @hasna/brains
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configure
|
|
19
|
+
|
|
20
|
+
Set your API keys via the config command (stored in `~/.brains/config.json`):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
brains config set OPENAI_API_KEY sk-...
|
|
24
|
+
brains config set THINKER_LABS_API_KEY tl-... # optional
|
|
25
|
+
brains config set THINKER_LABS_BASE_URL https://... # optional
|
|
26
|
+
brains config list # view all (values masked)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or set as environment variables — env vars take precedence over the config file:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
export OPENAI_API_KEY=sk-...
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quickstart
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 1. Gather training data from all agent memory sources
|
|
39
|
+
brains data gather --source all --limit 500
|
|
40
|
+
|
|
41
|
+
# 2. Preview examples from the gathered file
|
|
42
|
+
brains data preview ~/.brains/datasets/todos-1234567890.jsonl -n 3
|
|
43
|
+
|
|
44
|
+
# 3. Start a fine-tuning job (auto-detects latest dataset)
|
|
45
|
+
brains finetune start --provider openai --base-model gpt-4o-mini-2024-07-18 --name my-model
|
|
46
|
+
|
|
47
|
+
# 4. Watch the job until it completes
|
|
48
|
+
brains finetune watch <job-id> --interval 30
|
|
49
|
+
|
|
50
|
+
# 5. List your tracked models
|
|
51
|
+
brains models list
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## CLI Reference
|
|
55
|
+
|
|
56
|
+
### `brains models`
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
brains models list # list all tracked models
|
|
60
|
+
brains models list --json # as JSON (pipe-friendly)
|
|
61
|
+
brains models show <id> # show full details
|
|
62
|
+
brains models rename <id> <displayName> # set display name
|
|
63
|
+
brains models describe <id> <description> # set description
|
|
64
|
+
brains models tag <id> <tag> # add tag
|
|
65
|
+
brains models untag <id> <tag> # remove tag
|
|
66
|
+
brains models collection <id> <name> # assign to collection
|
|
67
|
+
brains models import <job-id> # import externally created model
|
|
68
|
+
--provider openai # provider (default: openai)
|
|
69
|
+
--name "My Model" # optional display name
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `brains finetune`
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
brains finetune start # start a fine-tuning job
|
|
76
|
+
--provider openai # required: openai | thinker-labs
|
|
77
|
+
--base-model gpt-4o-mini-2024-07-18 # required: base model
|
|
78
|
+
--name "My Model" # required: display name
|
|
79
|
+
--dataset /path/to/data.jsonl # optional: auto-detects latest if omitted
|
|
80
|
+
|
|
81
|
+
brains finetune status <job-id> # check job status
|
|
82
|
+
--provider openai
|
|
83
|
+
--json
|
|
84
|
+
|
|
85
|
+
brains finetune watch <job-id> # poll until complete
|
|
86
|
+
--provider openai
|
|
87
|
+
--interval 30 # poll interval in seconds (default: 30)
|
|
88
|
+
|
|
89
|
+
brains finetune list # list jobs from provider
|
|
90
|
+
--provider openai
|
|
91
|
+
--json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `brains data`
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
brains data gather # gather training data
|
|
98
|
+
--source all # todos|mementos|conversations|sessions|all
|
|
99
|
+
--output ~/.brains/datasets # output directory
|
|
100
|
+
--limit 500 # max examples per source
|
|
101
|
+
|
|
102
|
+
brains data preview <file> # preview JSONL examples
|
|
103
|
+
-n 5 # number of examples to show
|
|
104
|
+
|
|
105
|
+
brains data merge <file1> <file2> ... # merge multiple JSONL files
|
|
106
|
+
--output merged.jsonl
|
|
107
|
+
--no-dedupe # skip deduplication
|
|
108
|
+
|
|
109
|
+
brains data list # list gathered datasets
|
|
110
|
+
--json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### `brains collections`
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
brains collections list # list collections with model counts
|
|
117
|
+
--json
|
|
118
|
+
brains collections show <name> # list models in a collection
|
|
119
|
+
brains collections rename <old> <new> # rename across all models
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `brains config`
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
brains config list # show all config (values masked)
|
|
126
|
+
brains config get OPENAI_API_KEY # get a specific value
|
|
127
|
+
brains config set OPENAI_API_KEY sk-... # set a value
|
|
128
|
+
brains config unset OPENAI_API_KEY # remove from config file
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `brains remove`
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
brains remove <id> # auto-detect type (model or job)
|
|
135
|
+
brains remove <id> --type model
|
|
136
|
+
brains remove <id> --type job
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## MCP Server
|
|
140
|
+
|
|
141
|
+
Use `brains-mcp` as a Claude Code MCP server to manage fine-tuning directly from Claude:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
claude mcp add --transport stdio --scope user brains -- brains-mcp
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Available tools: `list_models`, `get_model`, `start_finetune`, `get_finetune_status`, `gather_training_data`, `preview_training_data`
|
|
148
|
+
|
|
149
|
+
## HTTP Server
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
brains-serve # starts on port 7020
|
|
153
|
+
PORT=8080 brains-serve # custom port
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Endpoints:
|
|
157
|
+
|
|
158
|
+
| Method | Path | Description |
|
|
159
|
+
|--------|------|-------------|
|
|
160
|
+
| GET | `/health` | Version and status |
|
|
161
|
+
| GET | `/models` | List all models |
|
|
162
|
+
| GET | `/models/:id` | Get model details |
|
|
163
|
+
| PATCH | `/models/:id` | Update name/description/tags/collection |
|
|
164
|
+
| GET | `/jobs` | List all training jobs |
|
|
165
|
+
| GET | `/jobs/:id` | Get job details |
|
|
166
|
+
| GET | `/datasets` | List all gathered datasets |
|
|
167
|
+
| POST | `/datasets/gather` | Trigger gather (`{ sources, limit, output_dir }`) |
|
|
168
|
+
|
|
169
|
+
## Data Storage
|
|
170
|
+
|
|
171
|
+
All data is stored locally:
|
|
172
|
+
|
|
173
|
+
| Path | Contents |
|
|
174
|
+
|------|----------|
|
|
175
|
+
| `~/.brains/brains.db` | SQLite — models, jobs, datasets |
|
|
176
|
+
| `~/.brains/datasets/` | JSONL training files |
|
|
177
|
+
| `~/.brains/config.json` | API keys and settings |
|
|
178
|
+
|
|
179
|
+
## Training Data Sources
|
|
180
|
+
|
|
181
|
+
| Source | Reads from | What it generates |
|
|
182
|
+
|--------|-----------|-------------------|
|
|
183
|
+
| `todos` | `~/.todos/todos.db` | Task creation, status update, search examples |
|
|
184
|
+
| `mementos` | `~/.mementos/mementos.db` | Memory recall, save, category search examples |
|
|
185
|
+
| `conversations` | `~/.conversations/messages.db` | Multi-agent conversation windows |
|
|
186
|
+
| `sessions` | `~/.claude/projects/` | Claude Code development session transcripts |
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
Apache-2.0
|