claude-brain 0.27.3 → 0.28.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.27.3
1
+ 0.28.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-brain",
3
- "version": "0.27.3",
3
+ "version": "0.28.1",
4
4
  "description": "Local development assistant bridging Obsidian vaults with Claude Code via MCP",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -73,10 +73,12 @@
73
73
  "hono": "4.11.5",
74
74
  "lru-cache": "11.2.5",
75
75
  "minisearch": "^6.3.0",
76
+ "onnxruntime-web": "1.24.1",
76
77
  "ora": "9.2.0",
77
78
  "pino": "^10.1.1",
78
79
  "pino-pretty": "^13.1.3",
79
80
  "prompts": "2.4.2",
81
+ "tiktoken": "1.0.22",
80
82
  "tree-sitter-wasms": "0.1.13",
81
83
  "web-tree-sitter": "0.24.7",
82
84
  "zod": "^4.3.5"
package/src/cli/bin.ts CHANGED
@@ -44,6 +44,8 @@ function printHelp() {
44
44
  ['status', 'Show system overview'],
45
45
  ['reindex', 'Rebuild code intelligence index'],
46
46
  ['export', 'Export observations (--project, --format md|json)'],
47
+ ['export-training', 'Export SLM training data (intent|entity|query|knowledge|compress|pattern)'],
48
+ ['models', 'Manage SLM models (list/download/enable/disable/benchmark/stats)'],
47
49
  ['health', 'Run health checks'],
48
50
  ['diagnose', 'Run diagnostics'],
49
51
  ['version', 'Show version'],
@@ -212,6 +214,18 @@ async function main() {
212
214
  break
213
215
  }
214
216
 
217
+ case 'export-training': {
218
+ const { runExportTraining } = await import('./commands/export-training')
219
+ await runExportTraining()
220
+ break
221
+ }
222
+
223
+ case 'models': {
224
+ const { runModels } = await import('./commands/models')
225
+ await runModels()
226
+ break
227
+ }
228
+
215
229
  case 'health': {
216
230
  const { runHealthCheck } = await import('@/health')
217
231
  await runHealthCheck()
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Export Training Data Command — Phase 1A (SLM Upgrade)
3
+ * Exports logged classification data as JSONL for model training.
4
+ *
5
+ * Usage:
6
+ * claude-brain export-training intent
7
+ * claude-brain export-training entity --verified-only
8
+ * claude-brain export-training compress --limit 500
9
+ * claude-brain export-training --stats
10
+ */
11
+
12
+ import { parseArgs } from 'citty'
13
+ import { exportTrainingData, getTrainingStats, type TrainingTask } from '@/training/data-store'
14
+
15
+ const VALID_TASKS: TrainingTask[] = ['intent', 'entity', 'query', 'knowledge', 'compress', 'pattern']
16
+
17
+ export async function runExportTraining() {
18
+ const args = parseArgs(process.argv.slice(3), {
19
+ task: { type: 'positional', description: 'Task to export: intent, entity, query, knowledge, compress, pattern' },
20
+ verifiedOnly: { type: 'boolean', alias: ['verified-only'], description: 'Only export human-verified examples' },
21
+ limit: { type: 'string', description: 'Max examples to export' },
22
+ stats: { type: 'boolean', description: 'Show training data statistics' },
23
+ format: { type: 'string', default: 'jsonl', description: 'Output format: jsonl or csv' },
24
+ })
25
+
26
+ // Stats mode
27
+ if (args.stats) {
28
+ const stats = getTrainingStats()
29
+ console.log('Training Data Statistics:')
30
+ console.log('========================')
31
+ let grandTotal = 0
32
+ let grandVerified = 0
33
+ for (const [task, counts] of Object.entries(stats)) {
34
+ console.log(` ${task.padEnd(12)} ${String(counts.total).padStart(6)} total ${String(counts.verified).padStart(6)} verified`)
35
+ grandTotal += counts.total
36
+ grandVerified += counts.verified
37
+ }
38
+ console.log(' ' + '-'.repeat(40))
39
+ console.log(` ${'TOTAL'.padEnd(12)} ${String(grandTotal).padStart(6)} total ${String(grandVerified).padStart(6)} verified`)
40
+ return
41
+ }
42
+
43
+ const task = args.task as TrainingTask
44
+ if (!task || !VALID_TASKS.includes(task)) {
45
+ console.error(`Error: task must be one of: ${VALID_TASKS.join(', ')}`)
46
+ console.error('Usage: claude-brain export-training <task> [--verified-only] [--limit N]')
47
+ console.error(' claude-brain export-training --stats')
48
+ process.exit(1)
49
+ }
50
+
51
+ const limit = args.limit ? parseInt(args.limit, 10) : undefined
52
+ const lines = exportTrainingData(task, {
53
+ verifiedOnly: args.verifiedOnly || false,
54
+ limit,
55
+ })
56
+
57
+ if (lines.length === 0) {
58
+ console.error(`No training data found for task "${task}".`)
59
+ console.error('Training data is collected automatically as Claude Brain processes requests.')
60
+ process.exit(0)
61
+ }
62
+
63
+ // Output to stdout (pipe-friendly)
64
+ for (const line of lines) {
65
+ console.log(line)
66
+ }
67
+
68
+ // Summary to stderr so it doesn't pollute piped output
69
+ console.error(`\nExported ${lines.length} examples for task "${task}"`)
70
+ }