codemem 0.27.0 → 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/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { DEDUP_KEY_BACKFILL_JOB, DEFAULT_COORDINATOR_DB_PATH, DedupKeyBackfillRunner, MUTATING_TOOL_NAMES, MemoryStore, ObserverClient, REF_BACKFILL_JOB, RawEventSweeper, RefBackfillRunner, SESSION_CONTEXT_BACKFILL_JOB, SessionContextBackfillRunner, SyncRetentionRunner, VERSION, VectorModelMigrationRunner, aiBackfillStructuredContent, applyBootstrapSnapshot, backfillMemoryDedupKeys, backfillNarrativeFromBody, backfillTagsText, backfillVectors, buildAuthHeaders, buildBaseUrl, buildRawEventEnvelopeFromHook, compareMemoryRoleReports, connect, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorDisableDeviceAction, coordinatorEnrollDeviceAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, createBetterSqliteCoordinatorApp, deactivateLowSignalMemories, deactivateLowSignalObservations, dedupNearDuplicateMemories, ensureDeviceIdentity, ensureSchemaBootstrapped, exportMemories, extractApplyPatchPaths, fetchAllSnapshotPages, fingerprintPublicKey, flushRawEvents, getExtractionBenchmarkProfile, getInjectionEvalScenarioPack, getInjectionEvalScenarioPrompts, getMaintenanceJob, getMemoryRoleReport, getRawEventRelinkPlan, getRawEventRelinkReport, getRawEventStatus, getSemanticIndexDiagnostics, getSessionExtractionEval, getSessionExtractionEvalScenario, getWorkspaceCodememConfigPath, hasPendingDedupKeyBackfill, hasPendingRefBackfill, hasPendingSessionContextBackfill, hasUnsyncedSharedMemoryChanges, importMemories, initDatabase, isEmbeddingDisabled, loadObserverConfig, loadPublicKey, loadSqliteVec, planReplicationOpsAgePrune, pruneReplicationOpsUntilCaughtUp, rawEventsGate, readCodememConfigFile, readCodememConfigFileAtPath, readCoordinatorSyncConfig, readImportPayload, replayBatchExtraction, replayBatchExtractionWithTierRouting, requestJson, resolveCodememConfigPath, resolveDbPath, resolveHookProject, resolveProject, retryRawEventFailures, runSyncDaemon, runSyncPass, schema, setPeerProjectFilter, stripJsonComments, stripPrivateObj, stripTrailingCommas, syncPassPreflight, updatePeerAddresses, vacuumDatabase, writeCodememConfigFile } from "@codemem/core";
|
|
2
|
+
import { DEDUP_KEY_BACKFILL_JOB, DEFAULT_COORDINATOR_DB_PATH, DedupKeyBackfillRunner, MUTATING_TOOL_NAMES, MemoryStore, ObserverClient, REF_BACKFILL_JOB, RawEventSweeper, RefBackfillRunner, SESSION_CONTEXT_BACKFILL_JOB, SUMMARY_DEDUP_BACKFILL_JOB, SessionContextBackfillRunner, SummaryDedupBackfillRunner, SyncRetentionRunner, VERSION, VectorModelMigrationRunner, aiBackfillStructuredContent, applyBootstrapSnapshot, backfillMemoryDedupKeys, backfillNarrativeFromBody, backfillTagsText, backfillVectors, buildAuthHeaders, buildBaseUrl, buildRawEventEnvelopeFromHook, compareMemoryRoleReports, connect, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorDisableDeviceAction, coordinatorEnrollDeviceAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, createBetterSqliteCoordinatorApp, deactivateLowSignalMemories, deactivateLowSignalObservations, dedupNearDuplicateMemories, ensureDeviceIdentity, ensureSchemaBootstrapped, exportMemories, extractApplyPatchPaths, fetchAllSnapshotPages, fingerprintPublicKey, flushRawEvents, getExtractionBenchmarkProfile, getInjectionEvalScenarioPack, getInjectionEvalScenarioPrompts, getMaintenanceJob, getMemoryRoleReport, getRawEventRelinkPlan, getRawEventRelinkReport, getRawEventStatus, getSemanticIndexDiagnostics, getSessionExtractionEval, getSessionExtractionEvalScenario, getWorkspaceCodememConfigPath, hasPendingDedupKeyBackfill, hasPendingRefBackfill, hasPendingSessionContextBackfill, hasPendingSummaryDedupBackfill, hasUnsyncedSharedMemoryChanges, importMemories, initDatabase, isEmbeddingDisabled, loadObserverConfig, loadPublicKey, loadSqliteVec, planReplicationOpsAgePrune, pruneReplicationOpsUntilCaughtUp, rawEventsGate, readCodememConfigFile, readCodememConfigFileAtPath, readCoordinatorSyncConfig, readImportPayload, replayBatchExtraction, replayBatchExtractionWithTierRouting, requestJson, resolveCodememConfigPath, resolveDbPath, resolveHookProject, resolveProject, retryRawEventFailures, runSyncDaemon, runSyncPass, schema, setPeerProjectFilter, stripJsonComments, stripPrivateObj, stripTrailingCommas, syncPassPreflight, updatePeerAddresses, vacuumDatabase, writeCodememConfigFile } from "@codemem/core";
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import omelette from "omelette";
|
|
5
5
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
|
-
import {
|
|
7
|
+
import { randomInt } from "node:crypto";
|
|
8
8
|
import { homedir, networkInterfaces } from "node:os";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import * as p from "@clack/prompts";
|
|
@@ -536,6 +536,15 @@ var MAX_FILES_MODIFIED = 64;
|
|
|
536
536
|
var MAX_WORKING_SET_PATHS = 8;
|
|
537
537
|
var MAX_QUERY_CHARS = 500;
|
|
538
538
|
var MAX_QUERY_FILE_BASENAMES = 5;
|
|
539
|
+
var SESSION_FILE_LABEL_CHARS = 24;
|
|
540
|
+
function stableSessionSuffix(sessionId) {
|
|
541
|
+
let hash = 14695981039346656037n;
|
|
542
|
+
for (const byte of Buffer.from(sessionId, "utf8")) {
|
|
543
|
+
hash ^= BigInt(byte);
|
|
544
|
+
hash = BigInt.asUintN(64, hash * 1099511628211n);
|
|
545
|
+
}
|
|
546
|
+
return hash.toString(16).padStart(16, "0");
|
|
547
|
+
}
|
|
539
548
|
function defaultSessionState() {
|
|
540
549
|
return {
|
|
541
550
|
first_prompt: "",
|
|
@@ -553,9 +562,13 @@ function contextDir() {
|
|
|
553
562
|
const override = process.env.CODEMEM_CLAUDE_HOOK_CONTEXT_DIR;
|
|
554
563
|
return expandHome(override?.trim() ? override : "~/.codemem/claude-hook-context");
|
|
555
564
|
}
|
|
565
|
+
function sessionFileStem(sessionId) {
|
|
566
|
+
const trimmed = sessionId.trim();
|
|
567
|
+
if (!trimmed) return "session-state";
|
|
568
|
+
return `${trimmed.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, SESSION_FILE_LABEL_CHARS) || "session"}-${stableSessionSuffix(trimmed)}`;
|
|
569
|
+
}
|
|
556
570
|
function statePathForSession(sessionId) {
|
|
557
|
-
|
|
558
|
-
return join(contextDir(), `${digest}.json`);
|
|
571
|
+
return join(contextDir(), `${sessionFileStem(sessionId)}.json`);
|
|
559
572
|
}
|
|
560
573
|
/**
|
|
561
574
|
* Normalize a prompt-shaped payload field: drop non-strings, trim
|
|
@@ -3896,6 +3909,16 @@ async function startForegroundViewer(invocation) {
|
|
|
3896
3909
|
dbPath,
|
|
3897
3910
|
signal: backfillAbort.signal
|
|
3898
3911
|
})
|
|
3912
|
+
},
|
|
3913
|
+
{
|
|
3914
|
+
name: "Session-summary dedup",
|
|
3915
|
+
kind: SUMMARY_DEDUP_BACKFILL_JOB,
|
|
3916
|
+
isPending: hasPendingSummaryDedupBackfill,
|
|
3917
|
+
createRunner: () => new SummaryDedupBackfillRunner({
|
|
3918
|
+
dbPath,
|
|
3919
|
+
deviceId: store.deviceId,
|
|
3920
|
+
signal: backfillAbort.signal
|
|
3921
|
+
})
|
|
3899
3922
|
}
|
|
3900
3923
|
], backfillAbort.signal);
|
|
3901
3924
|
const syncRuntimeStatus = {
|