@hasna/brains 0.0.26 → 0.0.28

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/index.js CHANGED
@@ -3702,13 +3702,13 @@ import { join, relative } from "path";
3702
3702
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
3703
3703
  import { homedir as homedir2 } from "os";
3704
3704
  import { join as join2 } from "path";
3705
- import { readdirSync as readdirSync2, existsSync as existsSync3 } from "fs";
3706
- import { join as join3 } from "path";
3705
+ import { readdirSync as readdirSync3, existsSync as existsSync6 } from "fs";
3706
+ import { join as join6 } from "path";
3707
+ import { homedir as homedir5 } from "os";
3707
3708
  import { homedir as homedir3 } from "os";
3708
- import { homedir as homedir4 } from "os";
3709
- import { join as join4 } from "path";
3710
- import { join as join6, dirname } from "path";
3711
- import { homedir as homedir5, platform } from "os";
3709
+ import { join as join3 } from "path";
3710
+ import { join as join5, dirname } from "path";
3711
+ import { homedir as homedir4, platform } from "os";
3712
3712
  var __create = Object.create;
3713
3713
  var __getProtoOf = Object.getPrototypeOf;
3714
3714
  var __defProp2 = Object.defineProperty;
@@ -13051,7 +13051,7 @@ var exports_discover = {};
13051
13051
  __export2(exports_discover, {
13052
13052
  isSyncExcludedTable: () => isSyncExcludedTable,
13053
13053
  getServiceDbPath: () => getServiceDbPath,
13054
- discoverSyncableServices: () => discoverSyncableServices,
13054
+ discoverSyncableServices: () => discoverSyncableServices2,
13055
13055
  discoverServices: () => discoverServices,
13056
13056
  SYNC_EXCLUDED_TABLE_PATTERNS: () => SYNC_EXCLUDED_TABLE_PATTERNS,
13057
13057
  KNOWN_PG_SERVICES: () => KNOWN_PG_SERVICES
@@ -13060,11 +13060,11 @@ function isSyncExcludedTable(table) {
13060
13060
  return SYNC_EXCLUDED_TABLE_PATTERNS.some((p) => p.test(table));
13061
13061
  }
13062
13062
  function discoverServices() {
13063
- const dataDir = join3(homedir3(), ".hasna");
13064
- if (!existsSync3(dataDir))
13063
+ const dataDir = join6(homedir5(), ".hasna");
13064
+ if (!existsSync6(dataDir))
13065
13065
  return [];
13066
13066
  try {
13067
- const entries = readdirSync2(dataDir, { withFileTypes: true });
13067
+ const entries = readdirSync3(dataDir, { withFileTypes: true });
13068
13068
  return entries.filter((e) => {
13069
13069
  if (!e.isDirectory())
13070
13070
  return false;
@@ -13076,30 +13076,30 @@ function discoverServices() {
13076
13076
  return [];
13077
13077
  }
13078
13078
  }
13079
- function discoverSyncableServices() {
13079
+ function discoverSyncableServices2() {
13080
13080
  const local = discoverServices();
13081
13081
  const pgSet = new Set(KNOWN_PG_SERVICES);
13082
13082
  return local.filter((s) => pgSet.has(s));
13083
13083
  }
13084
13084
  function getServiceDbPath(service) {
13085
- const dataDir = join3(homedir3(), ".hasna", service);
13086
- if (!existsSync3(dataDir))
13085
+ const dataDir = join6(homedir5(), ".hasna", service);
13086
+ if (!existsSync6(dataDir))
13087
13087
  return null;
13088
13088
  const candidates = [
13089
- join3(dataDir, `${service}.db`),
13090
- join3(dataDir, "data.db"),
13091
- join3(dataDir, "database.db")
13089
+ join6(dataDir, `${service}.db`),
13090
+ join6(dataDir, "data.db"),
13091
+ join6(dataDir, "database.db")
13092
13092
  ];
13093
13093
  try {
13094
- const files = readdirSync2(dataDir);
13094
+ const files = readdirSync3(dataDir);
13095
13095
  for (const f of files) {
13096
13096
  if (f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm")) {
13097
- candidates.push(join3(dataDir, f));
13097
+ candidates.push(join6(dataDir, f));
13098
13098
  }
13099
13099
  }
13100
13100
  } catch {}
13101
13101
  for (const p of candidates) {
13102
- if (existsSync3(p))
13102
+ if (existsSync6(p))
13103
13103
  return p;
13104
13104
  }
13105
13105
  return null;
@@ -13289,15 +13289,13 @@ class SyncProgressTracker {
13289
13289
  }
13290
13290
  }
13291
13291
  }
13292
- init_adapter();
13293
13292
  init_config();
13294
- init_discover();
13295
- var AUTO_SYNC_CONFIG_PATH = join4(homedir4(), ".hasna", "cloud", "config.json");
13293
+ var AUTO_SYNC_CONFIG_PATH = join3(homedir3(), ".hasna", "cloud", "config.json");
13296
13294
  init_config();
13297
13295
  init_adapter();
13298
13296
  init_dotfile();
13299
13297
  init_config();
13300
- var CONFIG_DIR2 = join6(homedir5(), ".hasna", "cloud");
13298
+ var CONFIG_DIR2 = join5(homedir4(), ".hasna", "cloud");
13301
13299
  init_adapter();
13302
13300
  init_config();
13303
13301
  init_discover();
@@ -18986,20 +18984,20 @@ var openai_default = OpenAI;
18986
18984
  import { readFileSync as readFileSync3 } from "fs";
18987
18985
 
18988
18986
  // src/lib/config.ts
18989
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync4, readdirSync as readdirSync3, copyFileSync as copyFileSync2, statSync } from "fs";
18990
- import { join as join5, dirname as dirname2 } from "path";
18987
+ import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync3, readdirSync as readdirSync2, copyFileSync as copyFileSync2, statSync } from "fs";
18988
+ import { join as join4, dirname as dirname2 } from "path";
18991
18989
  import { homedir as homedir6 } from "os";
18992
18990
  var CONFIG_KEYS = ["OPENAI_API_KEY", "THINKER_LABS_API_KEY", "THINKER_LABS_BASE_URL"];
18993
18991
  function resolveConfigPath() {
18994
18992
  const home = process.env["HOME"] || process.env["USERPROFILE"] || homedir6();
18995
- const newDir = join5(home, ".hasna", "brains");
18996
- const oldDir = join5(home, ".brains");
18997
- if (existsSync4(oldDir) && !existsSync4(newDir)) {
18993
+ const newDir = join4(home, ".hasna", "brains");
18994
+ const oldDir = join4(home, ".brains");
18995
+ if (existsSync3(oldDir) && !existsSync3(newDir)) {
18998
18996
  mkdirSync3(newDir, { recursive: true });
18999
18997
  try {
19000
- for (const file of readdirSync3(oldDir)) {
19001
- const oldPath = join5(oldDir, file);
19002
- const newPath = join5(newDir, file);
18998
+ for (const file of readdirSync2(oldDir)) {
18999
+ const oldPath = join4(oldDir, file);
19000
+ const newPath = join4(newDir, file);
19003
19001
  try {
19004
19002
  if (statSync(oldPath).isFile()) {
19005
19003
  copyFileSync2(oldPath, newPath);
@@ -19009,11 +19007,11 @@ function resolveConfigPath() {
19009
19007
  } catch {}
19010
19008
  }
19011
19009
  mkdirSync3(newDir, { recursive: true });
19012
- return join5(newDir, "config.json");
19010
+ return join4(newDir, "config.json");
19013
19011
  }
19014
19012
  var CONFIG_PATH2 = resolveConfigPath();
19015
19013
  function readConfigFile() {
19016
- if (!existsSync4(CONFIG_PATH2))
19014
+ if (!existsSync3(CONFIG_PATH2))
19017
19015
  return {};
19018
19016
  try {
19019
19017
  return JSON.parse(readFileSync2(CONFIG_PATH2, "utf-8"));
@@ -19268,7 +19266,7 @@ class ThinkerLabsProvider {
19268
19266
  }
19269
19267
  }
19270
19268
  // src/lib/package-metadata.ts
19271
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
19269
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
19272
19270
  import { dirname as dirname3, resolve as resolve2 } from "path";
19273
19271
  import { fileURLToPath } from "url";
19274
19272
  var DEFAULT_VERSION = "0.0.0";
@@ -19281,7 +19279,7 @@ function getPackageVersion() {
19281
19279
  return cachedVersion;
19282
19280
  }
19283
19281
  const packageJsonPath = getPackageJsonPath();
19284
- if (!existsSync6(packageJsonPath)) {
19282
+ if (!existsSync5(packageJsonPath)) {
19285
19283
  cachedVersion = DEFAULT_VERSION;
19286
19284
  return cachedVersion;
19287
19285
  }
package/dist/mcp/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  CallToolRequestSchema,
24
24
  ListToolsRequestSchema
25
25
  } from "@modelcontextprotocol/sdk/types.js";
26
- import { readFileSync as readFileSync5, existsSync as existsSync8 } from "fs";
26
+ import { readFileSync as readFileSync5, existsSync as existsSync9 } from "fs";
27
27
  import { resolve as resolve3 } from "path";
28
28
  import { homedir as homedir12 } from "os";
29
29
 
@@ -3716,14 +3716,14 @@ import { join, relative } from "path";
3716
3716
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
3717
3717
  import { homedir as homedir2 } from "os";
3718
3718
  import { join as join2 } from "path";
3719
- import { readdirSync as readdirSync2, existsSync as existsSync3 } from "fs";
3720
- import { join as join3 } from "path";
3721
- import { homedir as homedir3 } from "os";
3719
+ import { readdirSync as readdirSync3, existsSync as existsSync6 } from "fs";
3720
+ import { join as join6 } from "path";
3721
+ import { homedir as homedir5 } from "os";
3722
3722
  import { hostname } from "os";
3723
- import { homedir as homedir4 } from "os";
3724
- import { join as join4 } from "path";
3725
- import { join as join6, dirname } from "path";
3726
- import { homedir as homedir5, platform } from "os";
3723
+ import { homedir as homedir3 } from "os";
3724
+ import { join as join3 } from "path";
3725
+ import { join as join5, dirname } from "path";
3726
+ import { homedir as homedir4, platform } from "os";
3727
3727
  var __create = Object.create;
3728
3728
  var __getProtoOf = Object.getPrototypeOf;
3729
3729
  var __defProp2 = Object.defineProperty;
@@ -13066,7 +13066,7 @@ var exports_discover = {};
13066
13066
  __export2(exports_discover, {
13067
13067
  isSyncExcludedTable: () => isSyncExcludedTable,
13068
13068
  getServiceDbPath: () => getServiceDbPath,
13069
- discoverSyncableServices: () => discoverSyncableServices,
13069
+ discoverSyncableServices: () => discoverSyncableServices2,
13070
13070
  discoverServices: () => discoverServices,
13071
13071
  SYNC_EXCLUDED_TABLE_PATTERNS: () => SYNC_EXCLUDED_TABLE_PATTERNS,
13072
13072
  KNOWN_PG_SERVICES: () => KNOWN_PG_SERVICES
@@ -13075,11 +13075,11 @@ function isSyncExcludedTable(table) {
13075
13075
  return SYNC_EXCLUDED_TABLE_PATTERNS.some((p) => p.test(table));
13076
13076
  }
13077
13077
  function discoverServices() {
13078
- const dataDir = join3(homedir3(), ".hasna");
13079
- if (!existsSync3(dataDir))
13078
+ const dataDir = join6(homedir5(), ".hasna");
13079
+ if (!existsSync6(dataDir))
13080
13080
  return [];
13081
13081
  try {
13082
- const entries = readdirSync2(dataDir, { withFileTypes: true });
13082
+ const entries = readdirSync3(dataDir, { withFileTypes: true });
13083
13083
  return entries.filter((e) => {
13084
13084
  if (!e.isDirectory())
13085
13085
  return false;
@@ -13091,30 +13091,30 @@ function discoverServices() {
13091
13091
  return [];
13092
13092
  }
13093
13093
  }
13094
- function discoverSyncableServices() {
13094
+ function discoverSyncableServices2() {
13095
13095
  const local = discoverServices();
13096
13096
  const pgSet = new Set(KNOWN_PG_SERVICES);
13097
13097
  return local.filter((s) => pgSet.has(s));
13098
13098
  }
13099
13099
  function getServiceDbPath(service) {
13100
- const dataDir = join3(homedir3(), ".hasna", service);
13101
- if (!existsSync3(dataDir))
13100
+ const dataDir = join6(homedir5(), ".hasna", service);
13101
+ if (!existsSync6(dataDir))
13102
13102
  return null;
13103
13103
  const candidates = [
13104
- join3(dataDir, `${service}.db`),
13105
- join3(dataDir, "data.db"),
13106
- join3(dataDir, "database.db")
13104
+ join6(dataDir, `${service}.db`),
13105
+ join6(dataDir, "data.db"),
13106
+ join6(dataDir, "database.db")
13107
13107
  ];
13108
13108
  try {
13109
- const files = readdirSync2(dataDir);
13109
+ const files = readdirSync3(dataDir);
13110
13110
  for (const f of files) {
13111
13111
  if (f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm")) {
13112
- candidates.push(join3(dataDir, f));
13112
+ candidates.push(join6(dataDir, f));
13113
13113
  }
13114
13114
  }
13115
13115
  } catch {}
13116
13116
  for (const p of candidates) {
13117
- if (existsSync3(p))
13117
+ if (existsSync6(p))
13118
13118
  return p;
13119
13119
  }
13120
13120
  return null;
@@ -13471,9 +13471,9 @@ async function syncTransfer(source, target, options, _direction) {
13471
13471
  const batch = rows.slice(offset, offset + batchSize);
13472
13472
  try {
13473
13473
  if (isAsyncAdapter(target)) {
13474
- await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
13474
+ await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch);
13475
13475
  } else {
13476
- batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
13476
+ batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch);
13477
13477
  }
13478
13478
  result.rowsWritten += batch.length;
13479
13479
  } catch (err) {
@@ -13520,7 +13520,7 @@ async function syncTransfer(source, target, options, _direction) {
13520
13520
  }
13521
13521
  return results;
13522
13522
  }
13523
- async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
13523
+ async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch) {
13524
13524
  if (batch.length === 0)
13525
13525
  return;
13526
13526
  const colList = columns.map((c) => `"${c}"`).join(", ");
@@ -13530,22 +13530,20 @@ async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, ba
13530
13530
  }).join(", ");
13531
13531
  const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
13532
13532
  const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
13533
- const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
13534
13533
  const sql2 = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
13535
- ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
13534
+ ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
13536
13535
  const params = batch.flatMap((row) => columns.map((c) => row[c] ?? null));
13537
13536
  await target.run(sql2, ...params);
13538
13537
  }
13539
- function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
13538
+ function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch) {
13540
13539
  if (batch.length === 0)
13541
13540
  return;
13542
13541
  const colList = columns.map((c) => `"${c}"`).join(", ");
13543
13542
  const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
13544
13543
  const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
13545
13544
  const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
13546
- const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
13547
13545
  const sql2 = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
13548
- ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
13546
+ ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
13549
13547
  const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
13550
13548
  target.run(sql2, ...params);
13551
13549
  }
@@ -13782,15 +13780,13 @@ class SyncProgressTracker {
13782
13780
  }
13783
13781
  }
13784
13782
  }
13785
- init_adapter();
13786
13783
  init_config();
13787
- init_discover();
13788
- var AUTO_SYNC_CONFIG_PATH = join4(homedir4(), ".hasna", "cloud", "config.json");
13784
+ var AUTO_SYNC_CONFIG_PATH = join3(homedir3(), ".hasna", "cloud", "config.json");
13789
13785
  init_config();
13790
13786
  init_adapter();
13791
13787
  init_dotfile();
13792
13788
  init_config();
13793
- var CONFIG_DIR2 = join6(homedir5(), ".hasna", "cloud");
13789
+ var CONFIG_DIR2 = join5(homedir4(), ".hasna", "cloud");
13794
13790
  init_adapter();
13795
13791
  init_config();
13796
13792
  init_discover();
@@ -19499,19 +19495,19 @@ var openai_default = OpenAI;
19499
19495
  import { readFileSync as readFileSync3 } from "fs";
19500
19496
 
19501
19497
  // src/lib/config.ts
19502
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync4, readdirSync as readdirSync3, copyFileSync as copyFileSync2, statSync } from "fs";
19503
- import { join as join5, dirname as dirname2 } from "path";
19498
+ import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync3, readdirSync as readdirSync2, copyFileSync as copyFileSync2, statSync } from "fs";
19499
+ import { join as join4, dirname as dirname2 } from "path";
19504
19500
  import { homedir as homedir6 } from "os";
19505
19501
  function resolveConfigPath() {
19506
19502
  const home = process.env["HOME"] || process.env["USERPROFILE"] || homedir6();
19507
- const newDir = join5(home, ".hasna", "brains");
19508
- const oldDir = join5(home, ".brains");
19509
- if (existsSync4(oldDir) && !existsSync4(newDir)) {
19503
+ const newDir = join4(home, ".hasna", "brains");
19504
+ const oldDir = join4(home, ".brains");
19505
+ if (existsSync3(oldDir) && !existsSync3(newDir)) {
19510
19506
  mkdirSync3(newDir, { recursive: true });
19511
19507
  try {
19512
- for (const file of readdirSync3(oldDir)) {
19513
- const oldPath = join5(oldDir, file);
19514
- const newPath = join5(newDir, file);
19508
+ for (const file of readdirSync2(oldDir)) {
19509
+ const oldPath = join4(oldDir, file);
19510
+ const newPath = join4(newDir, file);
19515
19511
  try {
19516
19512
  if (statSync(oldPath).isFile()) {
19517
19513
  copyFileSync2(oldPath, newPath);
@@ -19521,11 +19517,11 @@ function resolveConfigPath() {
19521
19517
  } catch {}
19522
19518
  }
19523
19519
  mkdirSync3(newDir, { recursive: true });
19524
- return join5(newDir, "config.json");
19520
+ return join4(newDir, "config.json");
19525
19521
  }
19526
19522
  var CONFIG_PATH2 = resolveConfigPath();
19527
19523
  function readConfigFile() {
19528
- if (!existsSync4(CONFIG_PATH2))
19524
+ if (!existsSync3(CONFIG_PATH2))
19529
19525
  return {};
19530
19526
  try {
19531
19527
  return JSON.parse(readFileSync2(CONFIG_PATH2, "utf-8"));
@@ -19850,7 +19846,7 @@ async function gatherFromTodos(options = {}) {
19850
19846
  // src/lib/gatherers/mementos.ts
19851
19847
  import { Database as Database4 } from "bun:sqlite";
19852
19848
  import { homedir as homedir9 } from "os";
19853
- import { join as join8 } from "path";
19849
+ import { join as join9 } from "path";
19854
19850
  var SYSTEM_PROMPT2 = "You are an AI assistant with persistent memory. You can remember and recall information across sessions to provide better, more personalized assistance.";
19855
19851
  function memoryToRecallExample(memory) {
19856
19852
  return {
@@ -19898,7 +19894,7 @@ ${matched.map((m) => `- ${m.key}: ${m.value.slice(0, 120)}${m.value.length > 120
19898
19894
  };
19899
19895
  }
19900
19896
  async function gatherFromMementos(options = {}) {
19901
- const dbPath = join8(homedir9(), ".mementos", "mementos.db");
19897
+ const dbPath = join9(homedir9(), ".mementos", "mementos.db");
19902
19898
  const db = new Database4(dbPath, { readonly: true, create: false });
19903
19899
  try {
19904
19900
  let query = "SELECT * FROM memories WHERE status = 'active'";
@@ -19936,7 +19932,7 @@ async function gatherFromMementos(options = {}) {
19936
19932
  // src/lib/gatherers/conversations.ts
19937
19933
  import { Database as Database5 } from "bun:sqlite";
19938
19934
  import { homedir as homedir10 } from "os";
19939
- import { join as join9 } from "path";
19935
+ import { join as join10 } from "path";
19940
19936
  var SYSTEM_PROMPT3 = "You are a helpful AI assistant participating in multi-agent conversations. You communicate clearly and collaboratively with other agents and users.";
19941
19937
  function windowToExample(window2) {
19942
19938
  if (window2.length < 2)
@@ -19964,7 +19960,7 @@ function windowToExample(window2) {
19964
19960
  return { messages };
19965
19961
  }
19966
19962
  async function gatherFromConversations(options = {}) {
19967
- const dbPath = join9(homedir10(), ".conversations", "messages.db");
19963
+ const dbPath = join10(homedir10(), ".conversations", "messages.db");
19968
19964
  const db = new Database5(dbPath, { readonly: true, create: false });
19969
19965
  try {
19970
19966
  let query = "SELECT * FROM messages WHERE 1=1";
@@ -20007,8 +20003,8 @@ async function gatherFromConversations(options = {}) {
20007
20003
 
20008
20004
  // src/lib/gatherers/sessions.ts
20009
20005
  import { readdir, readFile, stat } from "fs/promises";
20010
- import { existsSync as existsSync6 } from "fs";
20011
- import { join as join10 } from "path";
20006
+ import { existsSync as existsSync5 } from "fs";
20007
+ import { join as join11 } from "path";
20012
20008
  import { homedir as homedir11 } from "os";
20013
20009
  var SYSTEM_PROMPT4 = "You are Claude Code, an AI assistant built by Anthropic that helps developers with coding, architecture, debugging, and software engineering tasks.";
20014
20010
  function extractText(content) {
@@ -20020,22 +20016,22 @@ function extractText(content) {
20020
20016
  async function gatherFromSessions(options = {}) {
20021
20017
  const { limit: limit2 = 1000 } = options;
20022
20018
  const examples = [];
20023
- const claudeDir = join10(homedir11(), ".claude", "projects");
20024
- if (!existsSync6(claudeDir)) {
20019
+ const claudeDir = join11(homedir11(), ".claude", "projects");
20020
+ if (!existsSync5(claudeDir)) {
20025
20021
  return { source: "sessions", examples: [], count: 0 };
20026
20022
  }
20027
20023
  const projectDirs = await readdir(claudeDir).catch(() => []);
20028
20024
  for (const projectDir of projectDirs) {
20029
20025
  if (examples.length >= limit2)
20030
20026
  break;
20031
- const projectPath = join10(claudeDir, projectDir);
20027
+ const projectPath = join11(claudeDir, projectDir);
20032
20028
  const files = await readdir(projectPath).catch(() => []);
20033
20029
  for (const file of files) {
20034
20030
  if (examples.length >= limit2)
20035
20031
  break;
20036
20032
  if (!file.endsWith(".jsonl"))
20037
20033
  continue;
20038
- const filePath = join10(projectPath, file);
20034
+ const filePath = join11(projectPath, file);
20039
20035
  if (options.since) {
20040
20036
  const fileStat = await stat(filePath).catch(() => null);
20041
20037
  if (fileStat && fileStat.mtime < options.since)
@@ -24427,7 +24423,7 @@ function buildServer() {
24427
24423
  }
24428
24424
  resolvedPath = latest.filePath;
24429
24425
  }
24430
- if (!existsSync8(resolvedPath)) {
24426
+ if (!existsSync9(resolvedPath)) {
24431
24427
  return {
24432
24428
  content: [
24433
24429
  {
@@ -24512,7 +24508,7 @@ function buildServer() {
24512
24508
  }
24513
24509
  const { sources, limit: limit2, output_dir } = parsed.data;
24514
24510
  const { mkdirSync: mkdirSync4, writeFileSync: writeFileSync3 } = await import("fs");
24515
- const { join: join11 } = await import("path");
24511
+ const { join: join8 } = await import("path");
24516
24512
  const outDir = output_dir ?? defaultOutputDir();
24517
24513
  mkdirSync4(outDir, { recursive: true });
24518
24514
  const datasets = [];
@@ -24534,7 +24530,7 @@ function buildServer() {
24534
24530
  } else {
24535
24531
  examples = [];
24536
24532
  }
24537
- const filePath = join11(outDir, `${source}-${Date.now()}.jsonl`);
24533
+ const filePath = join8(outDir, `${source}-${Date.now()}.jsonl`);
24538
24534
  const jsonl = examples.map((ex) => JSON.stringify(ex)).join(`
24539
24535
  `);
24540
24536
  writeFileSync3(filePath, jsonl, "utf-8");
@@ -24553,7 +24549,7 @@ function buildServer() {
24553
24549
  case "preview_training_data": {
24554
24550
  const { file_path, limit: limit2 = 5 } = args;
24555
24551
  const resolvedPath = resolve3(file_path);
24556
- if (!existsSync8(resolvedPath)) {
24552
+ if (!existsSync9(resolvedPath)) {
24557
24553
  return {
24558
24554
  content: [
24559
24555
  { type: "text", text: `File not found: ${resolvedPath}` }