memorix 0.9.2 → 0.9.4
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/CHANGELOG.md +14 -0
- package/dist/cli/index.js +84 -44
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +54 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -808,37 +808,30 @@ async function getObservationsByIds(ids, projectId) {
|
|
|
808
808
|
}
|
|
809
809
|
return results;
|
|
810
810
|
}
|
|
811
|
-
async function getTimeline(anchorId,
|
|
812
|
-
const
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
};
|
|
817
|
-
if (projectId) {
|
|
818
|
-
searchParams.where = { projectId };
|
|
819
|
-
}
|
|
820
|
-
const allResults = await search(database, searchParams);
|
|
821
|
-
const docs = allResults.hits.map((h) => h.document).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
822
|
-
const anchorIndex = docs.findIndex((d) => d.observationId === anchorId);
|
|
811
|
+
async function getTimeline(anchorId, _projectId, depthBefore = 3, depthAfter = 3) {
|
|
812
|
+
const { getAllObservations: getAllObservations2 } = await Promise.resolve().then(() => (init_observations(), observations_exports));
|
|
813
|
+
const allObs = getAllObservations2();
|
|
814
|
+
const sorted = allObs.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
815
|
+
const anchorIndex = sorted.findIndex((o) => o.id === anchorId);
|
|
823
816
|
if (anchorIndex === -1) {
|
|
824
817
|
return { before: [], anchor: null, after: [] };
|
|
825
818
|
}
|
|
826
|
-
const toIndexEntry = (
|
|
827
|
-
const obsType =
|
|
819
|
+
const toIndexEntry = (obs) => {
|
|
820
|
+
const obsType = obs.type;
|
|
828
821
|
return {
|
|
829
|
-
id:
|
|
830
|
-
time: formatTime(
|
|
822
|
+
id: obs.id,
|
|
823
|
+
time: formatTime(obs.createdAt),
|
|
831
824
|
type: obsType,
|
|
832
825
|
icon: OBSERVATION_ICONS[obsType] ?? "\u2753",
|
|
833
|
-
title:
|
|
834
|
-
tokens:
|
|
826
|
+
title: obs.title,
|
|
827
|
+
tokens: obs.tokens
|
|
835
828
|
};
|
|
836
829
|
};
|
|
837
|
-
const before =
|
|
838
|
-
const after =
|
|
830
|
+
const before = sorted.slice(Math.max(0, anchorIndex - depthBefore), anchorIndex).map(toIndexEntry);
|
|
831
|
+
const after = sorted.slice(anchorIndex + 1, anchorIndex + 1 + depthAfter).map(toIndexEntry);
|
|
839
832
|
return {
|
|
840
833
|
before,
|
|
841
|
-
anchor: toIndexEntry(
|
|
834
|
+
anchor: toIndexEntry(sorted[anchorIndex]),
|
|
842
835
|
after
|
|
843
836
|
};
|
|
844
837
|
}
|
|
@@ -1018,6 +1011,7 @@ var init_entity_extractor = __esm({
|
|
|
1018
1011
|
// src/memory/observations.ts
|
|
1019
1012
|
var observations_exports = {};
|
|
1020
1013
|
__export(observations_exports, {
|
|
1014
|
+
getAllObservations: () => getAllObservations,
|
|
1021
1015
|
getObservation: () => getObservation,
|
|
1022
1016
|
getObservationCount: () => getObservationCount2,
|
|
1023
1017
|
getProjectObservations: () => getProjectObservations,
|
|
@@ -1185,6 +1179,9 @@ function getObservation(id) {
|
|
|
1185
1179
|
function getProjectObservations(projectId) {
|
|
1186
1180
|
return observations.filter((o) => o.projectId === projectId);
|
|
1187
1181
|
}
|
|
1182
|
+
function getAllObservations() {
|
|
1183
|
+
return [...observations];
|
|
1184
|
+
}
|
|
1188
1185
|
function getObservationCount2() {
|
|
1189
1186
|
return observations.length;
|
|
1190
1187
|
}
|
|
@@ -1290,18 +1287,23 @@ function resolveHookCommand() {
|
|
|
1290
1287
|
}
|
|
1291
1288
|
function generateClaudeConfig() {
|
|
1292
1289
|
const cmd = `${resolveHookCommand()} hook`;
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1290
|
+
const hookGroup = {
|
|
1291
|
+
matcher: {},
|
|
1292
|
+
hooks: [
|
|
1293
|
+
{
|
|
1294
|
+
type: "command",
|
|
1295
|
+
command: cmd,
|
|
1296
|
+
timeout: 10
|
|
1297
|
+
}
|
|
1298
|
+
]
|
|
1297
1299
|
};
|
|
1298
1300
|
return {
|
|
1299
1301
|
hooks: {
|
|
1300
|
-
SessionStart: [
|
|
1301
|
-
PostToolUse: [
|
|
1302
|
-
UserPromptSubmit: [
|
|
1303
|
-
PreCompact: [
|
|
1304
|
-
Stop: [
|
|
1302
|
+
SessionStart: [hookGroup],
|
|
1303
|
+
PostToolUse: [hookGroup],
|
|
1304
|
+
UserPromptSubmit: [hookGroup],
|
|
1305
|
+
PreCompact: [hookGroup],
|
|
1306
|
+
Stop: [hookGroup]
|
|
1305
1307
|
}
|
|
1306
1308
|
};
|
|
1307
1309
|
}
|
|
@@ -5465,8 +5467,10 @@ Use this as the \`topicKey\` parameter in \`memorix_store\` to enable upsert beh
|
|
|
5465
5467
|
maxTokens: safeMaxTokens,
|
|
5466
5468
|
since,
|
|
5467
5469
|
until,
|
|
5468
|
-
//
|
|
5469
|
-
projectId
|
|
5470
|
+
// Data isolation is handled at the directory level (each project has its own data dir).
|
|
5471
|
+
// No projectId filter needed — avoids cross-IDE search failures when different IDEs
|
|
5472
|
+
// resolve different projectIds for the same directory.
|
|
5473
|
+
projectId: void 0
|
|
5470
5474
|
});
|
|
5471
5475
|
let text = result.formatted;
|
|
5472
5476
|
if (!syncAdvisoryShown && syncAdvisory) {
|
|
@@ -5563,13 +5567,24 @@ ${result.remaining} active observations remaining.
|
|
|
5563
5567
|
Archived memories can be restored manually if needed.` }]
|
|
5564
5568
|
};
|
|
5565
5569
|
}
|
|
5566
|
-
const
|
|
5567
|
-
const
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5570
|
+
const { getAllObservations: getAllObservations2 } = await Promise.resolve().then(() => (init_observations(), observations_exports));
|
|
5571
|
+
const allObs = getAllObservations2();
|
|
5572
|
+
const docs = allObs.map((obs) => ({
|
|
5573
|
+
id: `obs-${obs.id}`,
|
|
5574
|
+
observationId: obs.id,
|
|
5575
|
+
entityName: obs.entityName,
|
|
5576
|
+
type: obs.type,
|
|
5577
|
+
title: obs.title,
|
|
5578
|
+
narrative: obs.narrative,
|
|
5579
|
+
facts: obs.facts.join("\n"),
|
|
5580
|
+
filesModified: obs.filesModified.join("\n"),
|
|
5581
|
+
concepts: obs.concepts.join(", "),
|
|
5582
|
+
tokens: obs.tokens,
|
|
5583
|
+
createdAt: obs.createdAt,
|
|
5584
|
+
projectId: obs.projectId,
|
|
5585
|
+
accessCount: 0,
|
|
5586
|
+
lastAccessedAt: ""
|
|
5587
|
+
}));
|
|
5573
5588
|
if (docs.length === 0) {
|
|
5574
5589
|
return {
|
|
5575
5590
|
content: [{ type: "text", text: "No observations found for this project." }]
|