@vheins/local-memory-mcp 0.16.3 → 0.17.0
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/{chunk-MSP4MIT7.js → chunk-SITVJ6EA.js} +396 -181
- package/dist/dashboard/server.js +61 -35
- package/dist/mcp/server.js +104 -60
- package/package.json +1 -1
package/dist/dashboard/server.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
handleTaskClaim,
|
|
17
17
|
listResources,
|
|
18
18
|
logger
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-SITVJ6EA.js";
|
|
20
20
|
|
|
21
21
|
// src/dashboard/server.ts
|
|
22
22
|
import express from "express";
|
|
@@ -328,7 +328,7 @@ var SystemController = class {
|
|
|
328
328
|
try {
|
|
329
329
|
await db.refresh();
|
|
330
330
|
const repo = req.query.repo;
|
|
331
|
-
const stats = repo ? db.system.getDashboardStats(repo) : db.system.getGlobalDashboardStats();
|
|
331
|
+
const stats = repo ? db.system.getDashboardStats("", repo) : db.system.getGlobalDashboardStats();
|
|
332
332
|
res.json(jsonApiRes(stats, "system-stats"));
|
|
333
333
|
} catch (err) {
|
|
334
334
|
const message = err instanceof Error ? err.message : "Internal server error";
|
|
@@ -341,7 +341,7 @@ var SystemController = class {
|
|
|
341
341
|
const repo = req.query.repo;
|
|
342
342
|
const pageSize = Math.min(50, Math.max(1, parseInt(req.query.pageSize) || 10));
|
|
343
343
|
const page = Math.max(1, parseInt(req.query.page) || 1);
|
|
344
|
-
const rawActions = db.actions.getRecentActions(repo, 100);
|
|
344
|
+
const rawActions = db.actions.getRecentActions("", repo, 100);
|
|
345
345
|
const actions = rawActions.map((a) => ({
|
|
346
346
|
...a,
|
|
347
347
|
query: a.query || void 0,
|
|
@@ -389,9 +389,9 @@ var SystemController = class {
|
|
|
389
389
|
await db.refresh();
|
|
390
390
|
const { repo } = req.query;
|
|
391
391
|
if (!repo) return res.status(400).json(jsonApiError("repo is required", 400));
|
|
392
|
-
const memories = db.memories.getAllMemoriesWithStats(repo);
|
|
393
|
-
const tasks = db.tasks.getTasksByRepo(repo);
|
|
394
|
-
const allComments = db.taskComments.getAllTaskCommentsByRepo(repo);
|
|
392
|
+
const memories = db.memories.getAllMemoriesWithStats("", repo);
|
|
393
|
+
const tasks = db.tasks.getTasksByRepo("", repo);
|
|
394
|
+
const allComments = db.taskComments.getAllTaskCommentsByRepo("", repo);
|
|
395
395
|
const commentsByTaskId = allComments.reduce(
|
|
396
396
|
(acc, comment) => {
|
|
397
397
|
if (!acc[comment.task_id]) acc[comment.task_id] = [];
|
|
@@ -499,7 +499,7 @@ var MemoriesController = class {
|
|
|
499
499
|
await db.refresh();
|
|
500
500
|
const memory = db.memories.getByIdWithStats(req.params.id);
|
|
501
501
|
if (!memory) throw new Error("Memory not found");
|
|
502
|
-
db.actions.logAction("read", memory.scope.repo, { memoryId: memory.id, resultCount: 1 });
|
|
502
|
+
db.actions.logAction("read", memory.scope.owner, memory.scope.repo, { memoryId: memory.id, resultCount: 1 });
|
|
503
503
|
res.json(jsonApiRes(memory, "memory"));
|
|
504
504
|
} catch (err) {
|
|
505
505
|
const message = err instanceof Error ? err.message : "Memory not found";
|
|
@@ -521,7 +521,7 @@ var MemoriesController = class {
|
|
|
521
521
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
522
522
|
scope: { repo }
|
|
523
523
|
});
|
|
524
|
-
db.actions.logAction("write", repo, { memoryId: id });
|
|
524
|
+
db.actions.logAction("write", "", repo, { memoryId: id });
|
|
525
525
|
});
|
|
526
526
|
res.json(jsonApiRes({ id }, "memory"));
|
|
527
527
|
} catch (err) {
|
|
@@ -550,9 +550,14 @@ var MemoriesController = class {
|
|
|
550
550
|
};
|
|
551
551
|
await db.withWrite(() => {
|
|
552
552
|
db.memories.update(id, updates);
|
|
553
|
-
db.actions.logAction(
|
|
554
|
-
|
|
555
|
-
|
|
553
|
+
db.actions.logAction(
|
|
554
|
+
"update",
|
|
555
|
+
existing.scope?.owner || "",
|
|
556
|
+
existing.scope?.repo || attributes.repo || "",
|
|
557
|
+
{
|
|
558
|
+
memoryId: id
|
|
559
|
+
}
|
|
560
|
+
);
|
|
556
561
|
});
|
|
557
562
|
res.json(jsonApiRes({ message: "Updated" }, "status"));
|
|
558
563
|
} catch (err) {
|
|
@@ -568,7 +573,12 @@ var MemoriesController = class {
|
|
|
568
573
|
if (!existing) return res.status(404).json(jsonApiError("Memory not found", 404));
|
|
569
574
|
await db.withWrite(() => {
|
|
570
575
|
db.memories.delete(id);
|
|
571
|
-
db.actions.logAction(
|
|
576
|
+
db.actions.logAction(
|
|
577
|
+
"delete",
|
|
578
|
+
existing.scope?.owner || "",
|
|
579
|
+
existing.scope?.repo || "",
|
|
580
|
+
{ memoryId: id }
|
|
581
|
+
);
|
|
572
582
|
});
|
|
573
583
|
res.json(jsonApiRes({ message: "Deleted" }, "status"));
|
|
574
584
|
} catch (err) {
|
|
@@ -591,7 +601,7 @@ var MemoriesController = class {
|
|
|
591
601
|
}));
|
|
592
602
|
const count = await db.withWrite(() => {
|
|
593
603
|
const insertedCount = db.memories.bulkInsertMemories(entries);
|
|
594
|
-
db.actions.logAction("write", repo, { query: `Bulk imported ${insertedCount} memories` });
|
|
604
|
+
db.actions.logAction("write", "", repo, { query: `Bulk imported ${insertedCount} memories` });
|
|
595
605
|
return insertedCount;
|
|
596
606
|
});
|
|
597
607
|
res.json(jsonApiRes({ count }, "status"));
|
|
@@ -617,7 +627,7 @@ var MemoriesController = class {
|
|
|
617
627
|
}
|
|
618
628
|
if (ids.length > 0) {
|
|
619
629
|
const mem = db.memories.getById(ids[0]);
|
|
620
|
-
db.actions.logAction(action, mem?.scope?.repo || "unknown", {
|
|
630
|
+
db.actions.logAction(action, mem?.scope?.owner || "", mem?.scope?.repo || "unknown", {
|
|
621
631
|
query: `Bulk ${action} applied to ${n} memories`
|
|
622
632
|
});
|
|
623
633
|
}
|
|
@@ -661,22 +671,24 @@ var TasksController = class {
|
|
|
661
671
|
if (status && status.includes(",")) {
|
|
662
672
|
const statuses = status.split(",");
|
|
663
673
|
tasks = db.tasks.getTasksByMultipleStatuses(
|
|
674
|
+
"",
|
|
664
675
|
repo,
|
|
665
676
|
statuses,
|
|
666
677
|
pageSize,
|
|
667
678
|
(page - 1) * pageSize,
|
|
668
679
|
search
|
|
669
680
|
);
|
|
670
|
-
totalItems = db.tasks.countTasksByMultipleStatuses(repo, statuses, search);
|
|
681
|
+
totalItems = db.tasks.countTasksByMultipleStatuses("", repo, statuses, search);
|
|
671
682
|
} else {
|
|
672
683
|
tasks = db.tasks.getTasksByRepo(
|
|
684
|
+
"",
|
|
673
685
|
repo,
|
|
674
686
|
status,
|
|
675
687
|
pageSize,
|
|
676
688
|
(page - 1) * pageSize,
|
|
677
689
|
search
|
|
678
690
|
);
|
|
679
|
-
totalItems = db.tasks.countTasks(repo, status, search);
|
|
691
|
+
totalItems = db.tasks.countTasks("", repo, status, search);
|
|
680
692
|
}
|
|
681
693
|
const totalPages = Math.ceil(totalItems / pageSize);
|
|
682
694
|
res.json(jsonApiRes(tasks, "task", { meta: { page, pageSize, totalItems, totalPages } }));
|
|
@@ -690,7 +702,7 @@ var TasksController = class {
|
|
|
690
702
|
await db.refresh();
|
|
691
703
|
const task = db.tasks.getTaskById(req.params.id);
|
|
692
704
|
if (!task) throw new Error("Task not found");
|
|
693
|
-
db.actions.logAction("read", task.repo, { taskId: task.id });
|
|
705
|
+
db.actions.logAction("read", task.owner || "", task.repo, { taskId: task.id });
|
|
694
706
|
res.json(jsonApiRes(task, "task"));
|
|
695
707
|
} catch (err) {
|
|
696
708
|
const message = err instanceof Error ? err.message : "Task not found";
|
|
@@ -702,7 +714,7 @@ var TasksController = class {
|
|
|
702
714
|
await db.refresh();
|
|
703
715
|
const { repo, task_code } = req.query;
|
|
704
716
|
if (!repo || !task_code) return res.status(400).json(jsonApiError("repo and task_code are required", 400));
|
|
705
|
-
const task = db.tasks.getTaskByCode(repo, task_code);
|
|
717
|
+
const task = db.tasks.getTaskByCode("", repo, task_code);
|
|
706
718
|
if (!task) return res.status(404).json(jsonApiError("Task not found", 404));
|
|
707
719
|
res.json(jsonApiRes(task, "task"));
|
|
708
720
|
} catch (err) {
|
|
@@ -716,7 +728,7 @@ var TasksController = class {
|
|
|
716
728
|
const attributes = getAttributes(req);
|
|
717
729
|
const { repo, task_code, title } = attributes;
|
|
718
730
|
if (!repo || !task_code || !title) return res.status(400).json(jsonApiError("Required fields missing", 400));
|
|
719
|
-
if (db.tasks.isTaskCodeDuplicate(repo, task_code))
|
|
731
|
+
if (db.tasks.isTaskCodeDuplicate("", repo, task_code))
|
|
720
732
|
return res.status(400).json(jsonApiError("Duplicate task_code", 400));
|
|
721
733
|
const id = randomUUID2();
|
|
722
734
|
await db.withWrite(() => {
|
|
@@ -726,7 +738,7 @@ var TasksController = class {
|
|
|
726
738
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
727
739
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
728
740
|
});
|
|
729
|
-
db.actions.logAction("write", repo, { taskId: id });
|
|
741
|
+
db.actions.logAction("write", "", repo, { taskId: id });
|
|
730
742
|
});
|
|
731
743
|
res.json(jsonApiRes({ id }, "task"));
|
|
732
744
|
} catch (err) {
|
|
@@ -791,7 +803,7 @@ var TasksController = class {
|
|
|
791
803
|
if (!task) return res.status(404).json(jsonApiError("Task not found", 404));
|
|
792
804
|
await db.withWrite(() => {
|
|
793
805
|
db.tasks.deleteTask(id);
|
|
794
|
-
db.actions.logAction("delete", task.repo, { taskId: id });
|
|
806
|
+
db.actions.logAction("delete", task.owner || "", task.repo, { taskId: id });
|
|
795
807
|
});
|
|
796
808
|
res.json(jsonApiRes({ message: "Deleted" }, "status"));
|
|
797
809
|
} catch (err) {
|
|
@@ -808,6 +820,7 @@ var TasksController = class {
|
|
|
808
820
|
const tasks = items.map((item) => ({
|
|
809
821
|
...item,
|
|
810
822
|
id: item.id || randomUUID2(),
|
|
823
|
+
owner: item.owner || "",
|
|
811
824
|
repo,
|
|
812
825
|
task_code: item.task_code || randomUUID2().substring(0, 8),
|
|
813
826
|
created_at: item.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -815,7 +828,7 @@ var TasksController = class {
|
|
|
815
828
|
}));
|
|
816
829
|
const count = await db.withWrite(() => {
|
|
817
830
|
const n = db.tasks.bulkInsertTasks(tasks);
|
|
818
|
-
db.actions.logAction("write", repo, { query: `Bulk imported ${n} tasks` });
|
|
831
|
+
db.actions.logAction("write", "", repo, { query: `Bulk imported ${n} tasks` });
|
|
819
832
|
return n;
|
|
820
833
|
});
|
|
821
834
|
res.json(jsonApiRes({ count }, "status"));
|
|
@@ -831,20 +844,20 @@ var TasksController = class {
|
|
|
831
844
|
const targetRepo = typeof repo === "string" && repo.length > 0 ? repo : null;
|
|
832
845
|
const stats = {
|
|
833
846
|
daily: {
|
|
834
|
-
...db.taskStats.getTaskTimeStats(targetRepo, "daily"),
|
|
835
|
-
history: db.taskStats.getTaskComparisonSeries(targetRepo, "daily")
|
|
847
|
+
...db.taskStats.getTaskTimeStats("", targetRepo, "daily"),
|
|
848
|
+
history: db.taskStats.getTaskComparisonSeries("", targetRepo, "daily")
|
|
836
849
|
},
|
|
837
850
|
weekly: {
|
|
838
|
-
...db.taskStats.getTaskTimeStats(targetRepo, "weekly"),
|
|
839
|
-
history: db.taskStats.getTaskComparisonSeries(targetRepo, "weekly")
|
|
851
|
+
...db.taskStats.getTaskTimeStats("", targetRepo, "weekly"),
|
|
852
|
+
history: db.taskStats.getTaskComparisonSeries("", targetRepo, "weekly")
|
|
840
853
|
},
|
|
841
854
|
monthly: {
|
|
842
|
-
...db.taskStats.getTaskTimeStats(targetRepo, "monthly"),
|
|
843
|
-
history: db.taskStats.getTaskComparisonSeries(targetRepo, "monthly")
|
|
855
|
+
...db.taskStats.getTaskTimeStats("", targetRepo, "monthly"),
|
|
856
|
+
history: db.taskStats.getTaskComparisonSeries("", targetRepo, "monthly")
|
|
844
857
|
},
|
|
845
858
|
overall: {
|
|
846
|
-
...db.taskStats.getTaskTimeStats(targetRepo, "overall"),
|
|
847
|
-
history: db.taskStats.getTaskComparisonSeries(targetRepo, "overall")
|
|
859
|
+
...db.taskStats.getTaskTimeStats("", targetRepo, "overall"),
|
|
860
|
+
history: db.taskStats.getTaskComparisonSeries("", targetRepo, "overall")
|
|
848
861
|
}
|
|
849
862
|
};
|
|
850
863
|
res.json(jsonApiRes(stats, "performance-stats"));
|
|
@@ -916,6 +929,7 @@ function normalizeStandardForImport(value) {
|
|
|
916
929
|
language: typeof item.language === "string" && item.language ? item.language : null,
|
|
917
930
|
stack: Array.isArray(item.stack) ? item.stack.map(String).filter(Boolean) : [],
|
|
918
931
|
is_global: item.is_global !== false,
|
|
932
|
+
owner: typeof item.owner === "string" ? item.owner : "",
|
|
919
933
|
repo: typeof item.repo === "string" && item.repo ? item.repo : null,
|
|
920
934
|
tags: Array.isArray(item.tags) ? item.tags.map(String).filter(Boolean) : [],
|
|
921
935
|
metadata: item.metadata && typeof item.metadata === "object" && !Array.isArray(item.metadata) ? item.metadata : { source: "standards-import" },
|
|
@@ -991,7 +1005,10 @@ var StandardsController = class {
|
|
|
991
1005
|
const standard = db.standards.getById(req.params.id);
|
|
992
1006
|
if (!standard) throw new Error("Coding standard not found");
|
|
993
1007
|
db.standards.incrementHitCounts([standard.id]);
|
|
994
|
-
db.actions.logAction("read", standard.repo || "global", {
|
|
1008
|
+
db.actions.logAction("read", standard.owner, standard.repo || "global", {
|
|
1009
|
+
query: standard.title,
|
|
1010
|
+
resultCount: 1
|
|
1011
|
+
});
|
|
995
1012
|
res.json(jsonApiRes(standard, "standard"));
|
|
996
1013
|
} catch (err) {
|
|
997
1014
|
const message = err instanceof Error ? err.message : "Coding standard not found";
|
|
@@ -1080,7 +1097,7 @@ var StandardsController = class {
|
|
|
1080
1097
|
imported.push(standard.id);
|
|
1081
1098
|
}
|
|
1082
1099
|
}
|
|
1083
|
-
db.actions.logAction("write", "standards-import", {
|
|
1100
|
+
db.actions.logAction("write", "", "standards-import", {
|
|
1084
1101
|
query: "standards-import",
|
|
1085
1102
|
resultCount: imported.length + updated.length
|
|
1086
1103
|
});
|
|
@@ -1122,6 +1139,7 @@ var StandardsController = class {
|
|
|
1122
1139
|
language: attributes.language || null,
|
|
1123
1140
|
stack: Array.isArray(attributes.stack) ? attributes.stack : [],
|
|
1124
1141
|
is_global: attributes.is_global !== false,
|
|
1142
|
+
owner: attributes.owner || "",
|
|
1125
1143
|
repo: attributes.repo || null,
|
|
1126
1144
|
tags,
|
|
1127
1145
|
metadata,
|
|
@@ -1135,7 +1153,7 @@ var StandardsController = class {
|
|
|
1135
1153
|
await db.withWrite(async () => {
|
|
1136
1154
|
db.standards.insert(entry);
|
|
1137
1155
|
await vectors.upsert(entry.id, buildStandardVectorText(entry), "standard");
|
|
1138
|
-
db.actions.logAction("write", entry.repo || "global", { query: entry.title, resultCount: 1 });
|
|
1156
|
+
db.actions.logAction("write", entry.owner, entry.repo || "global", { query: entry.title, resultCount: 1 });
|
|
1139
1157
|
});
|
|
1140
1158
|
res.json(jsonApiRes(entry, "standard"));
|
|
1141
1159
|
} catch (err) {
|
|
@@ -1172,7 +1190,10 @@ var StandardsController = class {
|
|
|
1172
1190
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1173
1191
|
};
|
|
1174
1192
|
await vectors.upsert(existing.id, buildStandardVectorText(merged), "standard");
|
|
1175
|
-
db.actions.logAction("update", existing.repo || "global", {
|
|
1193
|
+
db.actions.logAction("update", existing.owner, existing.repo || "global", {
|
|
1194
|
+
query: existing.title,
|
|
1195
|
+
resultCount: 1
|
|
1196
|
+
});
|
|
1176
1197
|
});
|
|
1177
1198
|
res.json(jsonApiRes({ message: "Updated" }, "status"));
|
|
1178
1199
|
} catch (err) {
|
|
@@ -1188,7 +1209,10 @@ var StandardsController = class {
|
|
|
1188
1209
|
await db.withWrite(async () => {
|
|
1189
1210
|
db.standards.delete(existing.id);
|
|
1190
1211
|
await vectors.remove(existing.id, "standard");
|
|
1191
|
-
db.actions.logAction("delete", existing.repo || "global", {
|
|
1212
|
+
db.actions.logAction("delete", existing.owner, existing.repo || "global", {
|
|
1213
|
+
query: existing.title,
|
|
1214
|
+
resultCount: 1
|
|
1215
|
+
});
|
|
1192
1216
|
});
|
|
1193
1217
|
res.json(jsonApiRes({ message: "Deleted" }, "status"));
|
|
1194
1218
|
} catch (err) {
|
|
@@ -1222,6 +1246,7 @@ var CoordinationController = class {
|
|
|
1222
1246
|
const pageSize = Math.min(100, Math.max(1, parseInt(req.query.pageSize || "20", 10)));
|
|
1223
1247
|
if (!repo) return res.status(400).json(jsonApiError("repo is required", 400));
|
|
1224
1248
|
const claims = db.handoffs.listClaims({
|
|
1249
|
+
owner: "",
|
|
1225
1250
|
repo,
|
|
1226
1251
|
agent: typeof agent === "string" ? agent : void 0,
|
|
1227
1252
|
active_only: active_only === void 0 ? true : String(active_only) === "true",
|
|
@@ -1229,6 +1254,7 @@ var CoordinationController = class {
|
|
|
1229
1254
|
offset: (page - 1) * pageSize
|
|
1230
1255
|
});
|
|
1231
1256
|
const total = db.handoffs.listClaims({
|
|
1257
|
+
owner: "",
|
|
1232
1258
|
repo,
|
|
1233
1259
|
agent: typeof agent === "string" ? agent : void 0,
|
|
1234
1260
|
active_only: active_only === void 0 ? true : String(active_only) === "true",
|