@hasna/brains 0.0.30 → 0.0.31
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/dist/cli/index.js +20 -6
- package/dist/lib/gatherers/mementos.d.ts.map +1 -1
- package/dist/lib/gatherers/tags.d.ts +2 -0
- package/dist/lib/gatherers/tags.d.ts.map +1 -0
- package/dist/lib/gatherers/todos.d.ts.map +1 -1
- package/dist/lib/gatherers/types.d.ts +1 -0
- package/dist/lib/gatherers/types.d.ts.map +1 -1
- package/dist/mcp/index.js +22 -6
- package/dist/server/index.js +22 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -13151,6 +13151,20 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
13151
13151
|
init_adapter();
|
|
13152
13152
|
});
|
|
13153
13153
|
|
|
13154
|
+
// src/lib/gatherers/tags.ts
|
|
13155
|
+
function parseTagList(value) {
|
|
13156
|
+
if (!value?.trim())
|
|
13157
|
+
return [];
|
|
13158
|
+
try {
|
|
13159
|
+
const parsed = JSON.parse(value);
|
|
13160
|
+
if (!Array.isArray(parsed))
|
|
13161
|
+
return [];
|
|
13162
|
+
return parsed.filter((tag) => typeof tag === "string");
|
|
13163
|
+
} catch {
|
|
13164
|
+
return [];
|
|
13165
|
+
}
|
|
13166
|
+
}
|
|
13167
|
+
|
|
13154
13168
|
// src/lib/gatherers/todos.ts
|
|
13155
13169
|
var exports_todos = {};
|
|
13156
13170
|
__export(exports_todos, {
|
|
@@ -13169,7 +13183,7 @@ Description: ${task.description}` : ""}`;
|
|
|
13169
13183
|
description: task.description ?? "",
|
|
13170
13184
|
status: task.status,
|
|
13171
13185
|
priority: task.priority,
|
|
13172
|
-
tags:
|
|
13186
|
+
tags: parseTagList(task.tags),
|
|
13173
13187
|
created_at: task.created_at
|
|
13174
13188
|
};
|
|
13175
13189
|
return {
|
|
@@ -13208,7 +13222,7 @@ ${matched.map((t) => `- [${t.short_id ?? t.id}] ${t.title} (${t.status})`).join(
|
|
|
13208
13222
|
};
|
|
13209
13223
|
}
|
|
13210
13224
|
async function gatherFromTodos(options = {}) {
|
|
13211
|
-
const dbPath = join9(homedir8(), ".todos", "todos.db");
|
|
13225
|
+
const dbPath = join9(options.homeDir ?? homedir8(), ".todos", "todos.db");
|
|
13212
13226
|
const db = new Database3(dbPath, { readonly: true, create: false });
|
|
13213
13227
|
try {
|
|
13214
13228
|
let query = "SELECT * FROM tasks WHERE 1=1";
|
|
@@ -13270,7 +13284,7 @@ Summary: ${memory.summary}` : memory.value
|
|
|
13270
13284
|
};
|
|
13271
13285
|
}
|
|
13272
13286
|
function memoryToSaveExample(memory) {
|
|
13273
|
-
const tags =
|
|
13287
|
+
const tags = parseTagList(memory.tags);
|
|
13274
13288
|
return {
|
|
13275
13289
|
messages: [
|
|
13276
13290
|
{ role: "system", content: SYSTEM_PROMPT2 },
|
|
@@ -13301,7 +13315,7 @@ ${matched.map((m) => `- ${m.key}: ${m.value.slice(0, 120)}${m.value.length > 120
|
|
|
13301
13315
|
};
|
|
13302
13316
|
}
|
|
13303
13317
|
async function gatherFromMementos(options = {}) {
|
|
13304
|
-
const dbPath = join10(homedir9(), ".mementos", "mementos.db");
|
|
13318
|
+
const dbPath = join10(options.homeDir ?? homedir9(), ".mementos", "mementos.db");
|
|
13305
13319
|
const db = new Database4(dbPath, { readonly: true, create: false });
|
|
13306
13320
|
try {
|
|
13307
13321
|
let query = "SELECT * FROM memories WHERE status = 'active'";
|
|
@@ -13372,7 +13386,7 @@ function windowToExample(window2) {
|
|
|
13372
13386
|
return { messages };
|
|
13373
13387
|
}
|
|
13374
13388
|
async function gatherFromConversations(options = {}) {
|
|
13375
|
-
const dbPath = join11(homedir10(), ".conversations", "messages.db");
|
|
13389
|
+
const dbPath = join11(options.homeDir ?? homedir10(), ".conversations", "messages.db");
|
|
13376
13390
|
const db = new Database5(dbPath, { readonly: true, create: false });
|
|
13377
13391
|
try {
|
|
13378
13392
|
let query = "SELECT * FROM messages WHERE 1=1";
|
|
@@ -13433,7 +13447,7 @@ function extractText(content) {
|
|
|
13433
13447
|
async function gatherFromSessions(options = {}) {
|
|
13434
13448
|
const { limit: limit2 = 1000 } = options;
|
|
13435
13449
|
const examples = [];
|
|
13436
|
-
const claudeDir = join12(homedir11(), ".claude", "projects");
|
|
13450
|
+
const claudeDir = join12(options.homeDir ?? homedir11(), ".claude", "projects");
|
|
13437
13451
|
if (!existsSync10(claudeDir)) {
|
|
13438
13452
|
return { source: "sessions", examples: [], count: 0 };
|
|
13439
13453
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mementos.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/mementos.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"mementos.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/mementos.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAA;AAsEhF,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4C7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/tags.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,CAUvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todos.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/todos.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"todos.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/todos.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAA;AAsEhF,wBAAsB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CA+C1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;QACrC,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC,CAAA;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/gatherers/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;QACrC,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC,CAAA;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -19789,6 +19789,22 @@ class ThinkerLabsProvider {
|
|
|
19789
19789
|
import { Database as Database3 } from "bun:sqlite";
|
|
19790
19790
|
import { homedir as homedir8 } from "os";
|
|
19791
19791
|
import { join as join7 } from "path";
|
|
19792
|
+
|
|
19793
|
+
// src/lib/gatherers/tags.ts
|
|
19794
|
+
function parseTagList(value) {
|
|
19795
|
+
if (!value?.trim())
|
|
19796
|
+
return [];
|
|
19797
|
+
try {
|
|
19798
|
+
const parsed = JSON.parse(value);
|
|
19799
|
+
if (!Array.isArray(parsed))
|
|
19800
|
+
return [];
|
|
19801
|
+
return parsed.filter((tag) => typeof tag === "string");
|
|
19802
|
+
} catch {
|
|
19803
|
+
return [];
|
|
19804
|
+
}
|
|
19805
|
+
}
|
|
19806
|
+
|
|
19807
|
+
// src/lib/gatherers/todos.ts
|
|
19792
19808
|
var SYSTEM_PROMPT = "You are a task management assistant that helps users create, update, search, and manage tasks and projects.";
|
|
19793
19809
|
function taskToCreateExample(task) {
|
|
19794
19810
|
const userMsg = `Create a task: ${task.title}${task.description ? `
|
|
@@ -19800,7 +19816,7 @@ Description: ${task.description}` : ""}`;
|
|
|
19800
19816
|
description: task.description ?? "",
|
|
19801
19817
|
status: task.status,
|
|
19802
19818
|
priority: task.priority,
|
|
19803
|
-
tags:
|
|
19819
|
+
tags: parseTagList(task.tags),
|
|
19804
19820
|
created_at: task.created_at
|
|
19805
19821
|
};
|
|
19806
19822
|
return {
|
|
@@ -19839,7 +19855,7 @@ ${matched.map((t) => `- [${t.short_id ?? t.id}] ${t.title} (${t.status})`).join(
|
|
|
19839
19855
|
};
|
|
19840
19856
|
}
|
|
19841
19857
|
async function gatherFromTodos(options = {}) {
|
|
19842
|
-
const dbPath = join7(homedir8(), ".todos", "todos.db");
|
|
19858
|
+
const dbPath = join7(options.homeDir ?? homedir8(), ".todos", "todos.db");
|
|
19843
19859
|
const db = new Database3(dbPath, { readonly: true, create: false });
|
|
19844
19860
|
try {
|
|
19845
19861
|
let query = "SELECT * FROM tasks WHERE 1=1";
|
|
@@ -19896,7 +19912,7 @@ Summary: ${memory.summary}` : memory.value
|
|
|
19896
19912
|
};
|
|
19897
19913
|
}
|
|
19898
19914
|
function memoryToSaveExample(memory) {
|
|
19899
|
-
const tags =
|
|
19915
|
+
const tags = parseTagList(memory.tags);
|
|
19900
19916
|
return {
|
|
19901
19917
|
messages: [
|
|
19902
19918
|
{ role: "system", content: SYSTEM_PROMPT2 },
|
|
@@ -19927,7 +19943,7 @@ ${matched.map((m) => `- ${m.key}: ${m.value.slice(0, 120)}${m.value.length > 120
|
|
|
19927
19943
|
};
|
|
19928
19944
|
}
|
|
19929
19945
|
async function gatherFromMementos(options = {}) {
|
|
19930
|
-
const dbPath = join9(homedir9(), ".mementos", "mementos.db");
|
|
19946
|
+
const dbPath = join9(options.homeDir ?? homedir9(), ".mementos", "mementos.db");
|
|
19931
19947
|
const db = new Database4(dbPath, { readonly: true, create: false });
|
|
19932
19948
|
try {
|
|
19933
19949
|
let query = "SELECT * FROM memories WHERE status = 'active'";
|
|
@@ -19993,7 +20009,7 @@ function windowToExample(window2) {
|
|
|
19993
20009
|
return { messages };
|
|
19994
20010
|
}
|
|
19995
20011
|
async function gatherFromConversations(options = {}) {
|
|
19996
|
-
const dbPath = join10(homedir10(), ".conversations", "messages.db");
|
|
20012
|
+
const dbPath = join10(options.homeDir ?? homedir10(), ".conversations", "messages.db");
|
|
19997
20013
|
const db = new Database5(dbPath, { readonly: true, create: false });
|
|
19998
20014
|
try {
|
|
19999
20015
|
let query = "SELECT * FROM messages WHERE 1=1";
|
|
@@ -20049,7 +20065,7 @@ function extractText(content) {
|
|
|
20049
20065
|
async function gatherFromSessions(options = {}) {
|
|
20050
20066
|
const { limit: limit2 = 1000 } = options;
|
|
20051
20067
|
const examples = [];
|
|
20052
|
-
const claudeDir = join11(homedir11(), ".claude", "projects");
|
|
20068
|
+
const claudeDir = join11(options.homeDir ?? homedir11(), ".claude", "projects");
|
|
20053
20069
|
if (!existsSync5(claudeDir)) {
|
|
20054
20070
|
return { source: "sessions", examples: [], count: 0 };
|
|
20055
20071
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -13392,6 +13392,22 @@ function getPackageVersion() {
|
|
|
13392
13392
|
import { Database as Database3 } from "bun:sqlite";
|
|
13393
13393
|
import { homedir as homedir6 } from "os";
|
|
13394
13394
|
import { join as join4 } from "path";
|
|
13395
|
+
|
|
13396
|
+
// src/lib/gatherers/tags.ts
|
|
13397
|
+
function parseTagList(value) {
|
|
13398
|
+
if (!value?.trim())
|
|
13399
|
+
return [];
|
|
13400
|
+
try {
|
|
13401
|
+
const parsed = JSON.parse(value);
|
|
13402
|
+
if (!Array.isArray(parsed))
|
|
13403
|
+
return [];
|
|
13404
|
+
return parsed.filter((tag) => typeof tag === "string");
|
|
13405
|
+
} catch {
|
|
13406
|
+
return [];
|
|
13407
|
+
}
|
|
13408
|
+
}
|
|
13409
|
+
|
|
13410
|
+
// src/lib/gatherers/todos.ts
|
|
13395
13411
|
var SYSTEM_PROMPT = "You are a task management assistant that helps users create, update, search, and manage tasks and projects.";
|
|
13396
13412
|
function taskToCreateExample(task) {
|
|
13397
13413
|
const userMsg = `Create a task: ${task.title}${task.description ? `
|
|
@@ -13403,7 +13419,7 @@ Description: ${task.description}` : ""}`;
|
|
|
13403
13419
|
description: task.description ?? "",
|
|
13404
13420
|
status: task.status,
|
|
13405
13421
|
priority: task.priority,
|
|
13406
|
-
tags:
|
|
13422
|
+
tags: parseTagList(task.tags),
|
|
13407
13423
|
created_at: task.created_at
|
|
13408
13424
|
};
|
|
13409
13425
|
return {
|
|
@@ -13442,7 +13458,7 @@ ${matched.map((t) => `- [${t.short_id ?? t.id}] ${t.title} (${t.status})`).join(
|
|
|
13442
13458
|
};
|
|
13443
13459
|
}
|
|
13444
13460
|
async function gatherFromTodos(options = {}) {
|
|
13445
|
-
const dbPath = join4(homedir6(), ".todos", "todos.db");
|
|
13461
|
+
const dbPath = join4(options.homeDir ?? homedir6(), ".todos", "todos.db");
|
|
13446
13462
|
const db = new Database3(dbPath, { readonly: true, create: false });
|
|
13447
13463
|
try {
|
|
13448
13464
|
let query = "SELECT * FROM tasks WHERE 1=1";
|
|
@@ -13499,7 +13515,7 @@ Summary: ${memory.summary}` : memory.value
|
|
|
13499
13515
|
};
|
|
13500
13516
|
}
|
|
13501
13517
|
function memoryToSaveExample(memory) {
|
|
13502
|
-
const tags =
|
|
13518
|
+
const tags = parseTagList(memory.tags);
|
|
13503
13519
|
return {
|
|
13504
13520
|
messages: [
|
|
13505
13521
|
{ role: "system", content: SYSTEM_PROMPT2 },
|
|
@@ -13530,7 +13546,7 @@ ${matched.map((m) => `- ${m.key}: ${m.value.slice(0, 120)}${m.value.length > 120
|
|
|
13530
13546
|
};
|
|
13531
13547
|
}
|
|
13532
13548
|
async function gatherFromMementos(options = {}) {
|
|
13533
|
-
const dbPath = join7(homedir8(), ".mementos", "mementos.db");
|
|
13549
|
+
const dbPath = join7(options.homeDir ?? homedir8(), ".mementos", "mementos.db");
|
|
13534
13550
|
const db = new Database4(dbPath, { readonly: true, create: false });
|
|
13535
13551
|
try {
|
|
13536
13552
|
let query = "SELECT * FROM memories WHERE status = 'active'";
|
|
@@ -13596,7 +13612,7 @@ function windowToExample(window) {
|
|
|
13596
13612
|
return { messages };
|
|
13597
13613
|
}
|
|
13598
13614
|
async function gatherFromConversations(options = {}) {
|
|
13599
|
-
const dbPath = join9(homedir9(), ".conversations", "messages.db");
|
|
13615
|
+
const dbPath = join9(options.homeDir ?? homedir9(), ".conversations", "messages.db");
|
|
13600
13616
|
const db = new Database5(dbPath, { readonly: true, create: false });
|
|
13601
13617
|
try {
|
|
13602
13618
|
let query = "SELECT * FROM messages WHERE 1=1";
|
|
@@ -13652,7 +13668,7 @@ function extractText(content) {
|
|
|
13652
13668
|
async function gatherFromSessions(options = {}) {
|
|
13653
13669
|
const { limit = 1000 } = options;
|
|
13654
13670
|
const examples = [];
|
|
13655
|
-
const claudeDir = join10(homedir10(), ".claude", "projects");
|
|
13671
|
+
const claudeDir = join10(options.homeDir ?? homedir10(), ".claude", "projects");
|
|
13656
13672
|
if (!existsSync5(claudeDir)) {
|
|
13657
13673
|
return { source: "sessions", examples: [], count: 0 };
|
|
13658
13674
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/brains",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "Fine-tuned model tracker and trainer — wraps OpenAI + Thinker Labs, gathers training data from todos/mementos/conversations/sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|