conare 0.1.4 → 0.1.5
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 +47 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -289,6 +289,7 @@ function cleanText(raw) {
|
|
|
289
289
|
let text = raw;
|
|
290
290
|
text = text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, "");
|
|
291
291
|
text = text.replace(/<attached-context[\s\S]*?<\/attached-context>/g, "");
|
|
292
|
+
text = text.replace(/<environment_context>[\s\S]*?<\/environment_context>/g, "");
|
|
292
293
|
return text.trim();
|
|
293
294
|
}
|
|
294
295
|
function createContentHash(content) {
|
|
@@ -450,6 +451,20 @@ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync a
|
|
|
450
451
|
import { join as join4, basename as basename2 } from "node:path";
|
|
451
452
|
import { homedir as homedir4 } from "node:os";
|
|
452
453
|
var MAX_CONTENT2 = 48000;
|
|
454
|
+
function isCodexBoilerplate(text) {
|
|
455
|
+
return text.startsWith("# AGENTS.md instructions for") || text.startsWith("<INSTRUCTIONS>") || text.startsWith("<user_instructions>") || text.startsWith("<user_action>");
|
|
456
|
+
}
|
|
457
|
+
function stripEnvironmentContext(text) {
|
|
458
|
+
let cwd = null;
|
|
459
|
+
const cwdMatch = text.match(/<cwd>([^<]+)<\/cwd>/);
|
|
460
|
+
if (cwdMatch)
|
|
461
|
+
cwd = cwdMatch[1];
|
|
462
|
+
const cleaned = text.replace(/<environment_context>[\s\S]*?<\/environment_context>/g, "").trim();
|
|
463
|
+
return { text: cleaned, cwd };
|
|
464
|
+
}
|
|
465
|
+
function projectFromCwd(cwd) {
|
|
466
|
+
return cwd.replace(/^\/Users\/[^/]+\//, "");
|
|
467
|
+
}
|
|
453
468
|
function ingestCodex() {
|
|
454
469
|
const memories = [];
|
|
455
470
|
const sessionIds = [];
|
|
@@ -476,10 +491,21 @@ function ingestCodex() {
|
|
|
476
491
|
for (const [sessionId, entries] of sessions) {
|
|
477
492
|
entries.sort((a, b) => a.ts - b.ts);
|
|
478
493
|
const date = new Date(entries[0].ts * 1000).toISOString().slice(0, 10);
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
494
|
+
let project = null;
|
|
495
|
+
const cleanEntries = [];
|
|
496
|
+
for (const e of entries) {
|
|
497
|
+
let text = cleanText(e.text);
|
|
498
|
+
if (isCodexBoilerplate(text))
|
|
499
|
+
continue;
|
|
500
|
+
const env = stripEnvironmentContext(text);
|
|
501
|
+
text = env.text;
|
|
502
|
+
if (!project && env.cwd)
|
|
503
|
+
project = projectFromCwd(env.cwd);
|
|
504
|
+
if (text.length === 0)
|
|
505
|
+
continue;
|
|
506
|
+
cleanEntries.push(text.length > 300 ? text.slice(0, 300) + "..." : text);
|
|
507
|
+
}
|
|
508
|
+
const body = cleanEntries.filter(Boolean).join(`
|
|
483
509
|
|
|
484
510
|
---
|
|
485
511
|
|
|
@@ -505,7 +531,14 @@ ${body}`;
|
|
|
505
531
|
memories.push({
|
|
506
532
|
content,
|
|
507
533
|
containerTag: "codex-chats",
|
|
508
|
-
metadata: {
|
|
534
|
+
metadata: {
|
|
535
|
+
dedupKey,
|
|
536
|
+
contentHash,
|
|
537
|
+
source: "codex",
|
|
538
|
+
sessionId,
|
|
539
|
+
date,
|
|
540
|
+
...project ? { project } : {}
|
|
541
|
+
}
|
|
509
542
|
});
|
|
510
543
|
sessionIds.push(sessionId);
|
|
511
544
|
}
|
|
@@ -536,17 +569,23 @@ function walkCodexSessions(dir, memories, sessionIds, stats) {
|
|
|
536
569
|
`).filter(Boolean);
|
|
537
570
|
const turns = [];
|
|
538
571
|
let date = null;
|
|
572
|
+
let project = null;
|
|
539
573
|
for (const line of lines) {
|
|
540
574
|
try {
|
|
541
575
|
const obj = JSON.parse(line);
|
|
542
576
|
if (!date && obj.timestamp)
|
|
543
577
|
date = obj.timestamp.slice(0, 10);
|
|
578
|
+
if (obj.type === "session_meta" && obj.payload?.cwd) {
|
|
579
|
+
project = projectFromCwd(obj.payload.cwd);
|
|
580
|
+
}
|
|
544
581
|
if (obj.type === "response_item" && obj.payload?.role === "user") {
|
|
545
582
|
const content2 = obj.payload.content;
|
|
546
583
|
if (Array.isArray(content2)) {
|
|
547
584
|
for (const block of content2) {
|
|
548
585
|
if (block.type === "input_text" && block.text) {
|
|
549
586
|
const text = cleanText(block.text);
|
|
587
|
+
if (isCodexBoilerplate(text))
|
|
588
|
+
continue;
|
|
550
589
|
if (text.length > 50)
|
|
551
590
|
turns.push(text);
|
|
552
591
|
}
|
|
@@ -588,7 +627,8 @@ ${body}`;
|
|
|
588
627
|
contentHash,
|
|
589
628
|
source: "codex-session",
|
|
590
629
|
sessionId,
|
|
591
|
-
date: date || "unknown"
|
|
630
|
+
date: date || "unknown",
|
|
631
|
+
...project ? { project } : {}
|
|
592
632
|
}
|
|
593
633
|
});
|
|
594
634
|
sessionIds.push(sessionId);
|
|
@@ -1009,7 +1049,7 @@ function indexCodebase(rootPath) {
|
|
|
1009
1049
|
|
|
1010
1050
|
// src/api.ts
|
|
1011
1051
|
var API_URL = "https://mcp.conare.ai";
|
|
1012
|
-
function createUploadBatches(memories, maxItems =
|
|
1052
|
+
function createUploadBatches(memories, maxItems = 10, maxChars = 1500000) {
|
|
1013
1053
|
const batches = [];
|
|
1014
1054
|
let current = [];
|
|
1015
1055
|
let currentChars = 0;
|