reasonix 0.15.0 → 0.16.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.
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  CODE_SYSTEM_PROMPT,
4
4
  codeSystemPrompt
5
- } from "./chunk-7546PPEL.js";
5
+ } from "./chunk-3ALFOYE6.js";
6
6
  export {
7
7
  CODE_SYSTEM_PROMPT,
8
8
  codeSystemPrompt
9
9
  };
10
- //# sourceMappingURL=prompt-XPEUBA46.js.map
10
+ //# sourceMappingURL=prompt-MAHJTS7Q.js.map
package/dist/index.js CHANGED
@@ -1149,7 +1149,7 @@ function blockToString(block) {
1149
1149
  return `[unknown block: ${JSON.stringify(block)}]`;
1150
1150
  }
1151
1151
 
1152
- // src/memory.ts
1152
+ // src/memory/runtime.ts
1153
1153
  import { createHash } from "crypto";
1154
1154
  var ImmutablePrefix = class {
1155
1155
  system;
@@ -1241,6 +1241,110 @@ var VolatileScratch = class {
1241
1241
  }
1242
1242
  };
1243
1243
 
1244
+ // src/memory/session.ts
1245
+ import {
1246
+ appendFileSync,
1247
+ chmodSync,
1248
+ existsSync as existsSync3,
1249
+ mkdirSync,
1250
+ readFileSync as readFileSync3,
1251
+ readdirSync,
1252
+ statSync,
1253
+ unlinkSync,
1254
+ writeFileSync
1255
+ } from "fs";
1256
+ import { homedir as homedir2 } from "os";
1257
+ import { dirname as dirname2, join as join3 } from "path";
1258
+ function sessionsDir() {
1259
+ return join3(homedir2(), ".reasonix", "sessions");
1260
+ }
1261
+ function sessionPath(name) {
1262
+ return join3(sessionsDir(), `${sanitizeName(name)}.jsonl`);
1263
+ }
1264
+ function sanitizeName(name) {
1265
+ const cleaned = name.replace(/[^\w\-\u4e00-\u9fa5]/g, "_").slice(0, 64);
1266
+ return cleaned || "default";
1267
+ }
1268
+ function loadSessionMessages(name) {
1269
+ const path = sessionPath(name);
1270
+ if (!existsSync3(path)) return [];
1271
+ try {
1272
+ const raw = readFileSync3(path, "utf8");
1273
+ const out = [];
1274
+ for (const line of raw.split(/\r?\n/)) {
1275
+ const trimmed = line.trim();
1276
+ if (!trimmed) continue;
1277
+ try {
1278
+ const msg = JSON.parse(trimmed);
1279
+ if (msg && typeof msg === "object" && "role" in msg) out.push(msg);
1280
+ } catch {
1281
+ }
1282
+ }
1283
+ return out;
1284
+ } catch {
1285
+ return [];
1286
+ }
1287
+ }
1288
+ function appendSessionMessage(name, message) {
1289
+ const path = sessionPath(name);
1290
+ mkdirSync(dirname2(path), { recursive: true });
1291
+ appendFileSync(path, `${JSON.stringify(message)}
1292
+ `, "utf8");
1293
+ try {
1294
+ chmodSync(path, 384);
1295
+ } catch {
1296
+ }
1297
+ }
1298
+ function listSessions() {
1299
+ const dir = sessionsDir();
1300
+ if (!existsSync3(dir)) return [];
1301
+ try {
1302
+ const files = readdirSync(dir).filter((f) => f.endsWith(".jsonl"));
1303
+ return files.map((file) => {
1304
+ const path = join3(dir, file);
1305
+ const stat2 = statSync(path);
1306
+ const name = file.replace(/\.jsonl$/, "");
1307
+ const messageCount = countLines(path);
1308
+ return { name, path, size: stat2.size, messageCount, mtime: stat2.mtime };
1309
+ }).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
1310
+ } catch {
1311
+ return [];
1312
+ }
1313
+ }
1314
+ function deleteSession(name) {
1315
+ const path = sessionPath(name);
1316
+ try {
1317
+ unlinkSync(path);
1318
+ const sidecar = path.replace(/\.jsonl$/, ".pending.json");
1319
+ try {
1320
+ unlinkSync(sidecar);
1321
+ } catch {
1322
+ }
1323
+ return true;
1324
+ } catch {
1325
+ return false;
1326
+ }
1327
+ }
1328
+ function rewriteSession(name, messages) {
1329
+ const path = sessionPath(name);
1330
+ mkdirSync(dirname2(path), { recursive: true });
1331
+ const body = messages.map((m) => JSON.stringify(m)).join("\n");
1332
+ writeFileSync(path, body ? `${body}
1333
+ ` : "", "utf8");
1334
+ try {
1335
+ chmodSync(path, 384);
1336
+ } catch {
1337
+ }
1338
+ }
1339
+ function countLines(path) {
1340
+ try {
1341
+ const raw = readFileSync3(path, "utf8");
1342
+ return raw.split(/\r?\n/).filter((l) => l.trim()).length;
1343
+ } catch {
1344
+ return 0;
1345
+ }
1346
+ }
1347
+
1244
1348
  // src/repair/scavenge.ts
1245
1349
  function scavengeToolCalls(reasoningContent, opts) {
1246
1350
  if (!reasoningContent) return { calls: [], notes: [] };
@@ -1542,111 +1646,7 @@ function signature(call) {
1542
1646
  return `${call.function?.name ?? ""}::${call.function?.arguments ?? ""}`;
1543
1647
  }
1544
1648
 
1545
- // src/session.ts
1546
- import {
1547
- appendFileSync,
1548
- chmodSync,
1549
- existsSync as existsSync3,
1550
- mkdirSync,
1551
- readFileSync as readFileSync3,
1552
- readdirSync,
1553
- statSync,
1554
- unlinkSync,
1555
- writeFileSync
1556
- } from "fs";
1557
- import { homedir as homedir2 } from "os";
1558
- import { dirname as dirname2, join as join3 } from "path";
1559
- function sessionsDir() {
1560
- return join3(homedir2(), ".reasonix", "sessions");
1561
- }
1562
- function sessionPath(name) {
1563
- return join3(sessionsDir(), `${sanitizeName(name)}.jsonl`);
1564
- }
1565
- function sanitizeName(name) {
1566
- const cleaned = name.replace(/[^\w\-\u4e00-\u9fa5]/g, "_").slice(0, 64);
1567
- return cleaned || "default";
1568
- }
1569
- function loadSessionMessages(name) {
1570
- const path = sessionPath(name);
1571
- if (!existsSync3(path)) return [];
1572
- try {
1573
- const raw = readFileSync3(path, "utf8");
1574
- const out = [];
1575
- for (const line of raw.split(/\r?\n/)) {
1576
- const trimmed = line.trim();
1577
- if (!trimmed) continue;
1578
- try {
1579
- const msg = JSON.parse(trimmed);
1580
- if (msg && typeof msg === "object" && "role" in msg) out.push(msg);
1581
- } catch {
1582
- }
1583
- }
1584
- return out;
1585
- } catch {
1586
- return [];
1587
- }
1588
- }
1589
- function appendSessionMessage(name, message) {
1590
- const path = sessionPath(name);
1591
- mkdirSync(dirname2(path), { recursive: true });
1592
- appendFileSync(path, `${JSON.stringify(message)}
1593
- `, "utf8");
1594
- try {
1595
- chmodSync(path, 384);
1596
- } catch {
1597
- }
1598
- }
1599
- function listSessions() {
1600
- const dir = sessionsDir();
1601
- if (!existsSync3(dir)) return [];
1602
- try {
1603
- const files = readdirSync(dir).filter((f) => f.endsWith(".jsonl"));
1604
- return files.map((file) => {
1605
- const path = join3(dir, file);
1606
- const stat2 = statSync(path);
1607
- const name = file.replace(/\.jsonl$/, "");
1608
- const messageCount = countLines(path);
1609
- return { name, path, size: stat2.size, messageCount, mtime: stat2.mtime };
1610
- }).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
1611
- } catch {
1612
- return [];
1613
- }
1614
- }
1615
- function deleteSession(name) {
1616
- const path = sessionPath(name);
1617
- try {
1618
- unlinkSync(path);
1619
- const sidecar = path.replace(/\.jsonl$/, ".pending.json");
1620
- try {
1621
- unlinkSync(sidecar);
1622
- } catch {
1623
- }
1624
- return true;
1625
- } catch {
1626
- return false;
1627
- }
1628
- }
1629
- function rewriteSession(name, messages) {
1630
- const path = sessionPath(name);
1631
- mkdirSync(dirname2(path), { recursive: true });
1632
- const body = messages.map((m) => JSON.stringify(m)).join("\n");
1633
- writeFileSync(path, body ? `${body}
1634
- ` : "", "utf8");
1635
- try {
1636
- chmodSync(path, 384);
1637
- } catch {
1638
- }
1639
- }
1640
- function countLines(path) {
1641
- try {
1642
- const raw = readFileSync3(path, "utf8");
1643
- return raw.split(/\r?\n/).filter((l) => l.trim()).length;
1644
- } catch {
1645
- return 0;
1646
- }
1647
- }
1648
-
1649
- // src/telemetry.ts
1649
+ // src/telemetry/stats.ts
1650
1650
  var DEEPSEEK_PRICING = {
1651
1651
  "deepseek-v4-flash": { inputCacheHit: 0.028, inputCacheMiss: 0.139, output: 0.278 },
1652
1652
  "deepseek-v4-pro": { inputCacheHit: 0.139, inputCacheMiss: 1.667, output: 3.333 },
@@ -2651,7 +2651,7 @@ ${summary}`;
2651
2651
  assistantMessage(content, toolCalls, producingModel, reasoningContent) {
2652
2652
  const msg = { role: "assistant", content };
2653
2653
  if (toolCalls.length > 0) msg.tool_calls = toolCalls;
2654
- if (isThinkingModeModel(producingModel)) {
2654
+ if (isThinkingModeModel(producingModel) || reasoningContent && reasoningContent.length > 0) {
2655
2655
  msg.reasoning_content = reasoningContent ?? "";
2656
2656
  }
2657
2657
  return msg;
@@ -3166,7 +3166,7 @@ var defaultFs = {
3166
3166
  read: (p) => readFileSync4(p, "utf8")
3167
3167
  };
3168
3168
 
3169
- // src/project-memory.ts
3169
+ // src/memory/project.ts
3170
3170
  import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
3171
3171
  import { join as join5 } from "path";
3172
3172
  var PROJECT_MEMORY_FILE = "REASONIX.md";
@@ -3209,7 +3209,7 @@ ${mem.content}
3209
3209
  `;
3210
3210
  }
3211
3211
 
3212
- // src/user-memory.ts
3212
+ // src/memory/user.ts
3213
3213
  import { createHash as createHash2 } from "crypto";
3214
3214
  import {
3215
3215
  existsSync as existsSync7,
@@ -3598,7 +3598,7 @@ var BUILTIN_SKILLS = Object.freeze([
3598
3598
  })
3599
3599
  ]);
3600
3600
 
3601
- // src/user-memory.ts
3601
+ // src/memory/user.ts
3602
3602
  var USER_MEMORY_DIR = "memory";
3603
3603
  var MEMORY_INDEX_FILE = "MEMORY.md";
3604
3604
  var MEMORY_INDEX_MAX_CHARS = 4e3;
@@ -6238,7 +6238,7 @@ function loadDotenv(path = ".env") {
6238
6238
  }
6239
6239
  }
6240
6240
 
6241
- // src/transcript.ts
6241
+ // src/transcript/log.ts
6242
6242
  import { createWriteStream, readFileSync as readFileSync9 } from "fs";
6243
6243
  function recordFromLoopEvent(ev, extra) {
6244
6244
  const rec = {
@@ -6320,7 +6320,7 @@ function parseTranscript(raw) {
6320
6320
  return out;
6321
6321
  }
6322
6322
 
6323
- // src/replay.ts
6323
+ // src/transcript/replay.ts
6324
6324
  function replayFromFile(path) {
6325
6325
  const parsed = readTranscript(path);
6326
6326
  return { parsed, stats: computeReplayStats(parsed.records) };
@@ -6409,7 +6409,7 @@ function round2(n, digits) {
6409
6409
  return Math.round(n * f) / f;
6410
6410
  }
6411
6411
 
6412
- // src/diff.ts
6412
+ // src/transcript/diff.ts
6413
6413
  function diffTranscripts(a, b) {
6414
6414
  const aSide = {
6415
6415
  label: a.label,
@@ -7971,7 +7971,7 @@ function redactKey(key) {
7971
7971
  return `${key.slice(0, 6)}\u2026${key.slice(-4)}`;
7972
7972
  }
7973
7973
 
7974
- // src/usage.ts
7974
+ // src/telemetry/usage.ts
7975
7975
  import {
7976
7976
  appendFileSync as appendFileSync2,
7977
7977
  existsSync as existsSync12,