memorix 0.6.4 → 0.6.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/cli/index.js +147 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/static/app.js +236 -10
- package/dist/dashboard/static/style.css +101 -11
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -5405,13 +5405,32 @@ async function handleHookEvent(input) {
|
|
|
5405
5405
|
"discovery": 2,
|
|
5406
5406
|
"how-it-works": 1
|
|
5407
5407
|
};
|
|
5408
|
-
const
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5408
|
+
const LOW_QUALITY_PATTERNS2 = [
|
|
5409
|
+
/^Session activity/i,
|
|
5410
|
+
/^Updated \S+\.\w+$/i,
|
|
5411
|
+
// "Updated foo.ts" — too generic
|
|
5412
|
+
/^Created \S+\.\w+$/i,
|
|
5413
|
+
// "Created bar.js"
|
|
5414
|
+
/^Deleted \S+\.\w+$/i,
|
|
5415
|
+
/^Modified \S+\.\w+$/i
|
|
5416
|
+
];
|
|
5417
|
+
const isLowQuality2 = (title) => LOW_QUALITY_PATTERNS2.some((p3) => p3.test(title));
|
|
5418
|
+
const scored = allObs.map((obs, i) => {
|
|
5419
|
+
const title = obs.title ?? "";
|
|
5420
|
+
const hasFacts = (obs.facts?.length ?? 0) > 0;
|
|
5421
|
+
const hasSubstance = title.length > 20 || hasFacts;
|
|
5422
|
+
const quality = isLowQuality2(title) ? 0.1 : hasSubstance ? 1 : 0.5;
|
|
5423
|
+
return {
|
|
5424
|
+
obs,
|
|
5425
|
+
priority: PRIORITY_ORDER[obs.type ?? ""] ?? 0,
|
|
5426
|
+
quality,
|
|
5427
|
+
recency: i
|
|
5428
|
+
// higher index = more recent
|
|
5429
|
+
};
|
|
5430
|
+
}).sort((a, b) => {
|
|
5431
|
+
const scoreA = a.priority * a.quality;
|
|
5432
|
+
const scoreB = b.priority * b.quality;
|
|
5433
|
+
if (scoreB !== scoreA) return scoreB - scoreA;
|
|
5415
5434
|
return b.recency - a.recency;
|
|
5416
5435
|
});
|
|
5417
5436
|
const top = scored.slice(0, 5);
|
|
@@ -5831,13 +5850,130 @@ var init_dashboard = __esm({
|
|
|
5831
5850
|
}
|
|
5832
5851
|
});
|
|
5833
5852
|
|
|
5853
|
+
// src/cli/commands/cleanup.ts
|
|
5854
|
+
var cleanup_exports = {};
|
|
5855
|
+
__export(cleanup_exports, {
|
|
5856
|
+
default: () => cleanup_default
|
|
5857
|
+
});
|
|
5858
|
+
import { defineCommand as defineCommand10 } from "citty";
|
|
5859
|
+
function isLowQuality(title) {
|
|
5860
|
+
return LOW_QUALITY_PATTERNS.some((p3) => p3.test(title.trim()));
|
|
5861
|
+
}
|
|
5862
|
+
var LOW_QUALITY_PATTERNS, cleanup_default;
|
|
5863
|
+
var init_cleanup = __esm({
|
|
5864
|
+
"src/cli/commands/cleanup.ts"() {
|
|
5865
|
+
"use strict";
|
|
5866
|
+
init_esm_shims();
|
|
5867
|
+
init_detector();
|
|
5868
|
+
init_persistence();
|
|
5869
|
+
LOW_QUALITY_PATTERNS = [
|
|
5870
|
+
/^Session activity/i,
|
|
5871
|
+
/^Updated \S+\.\w+$/i,
|
|
5872
|
+
/^Created \S+\.\w+$/i,
|
|
5873
|
+
/^Deleted \S+\.\w+$/i,
|
|
5874
|
+
/^Modified \S+\.\w+$/i,
|
|
5875
|
+
/^Ran command:/i,
|
|
5876
|
+
/^Read file:/i
|
|
5877
|
+
];
|
|
5878
|
+
cleanup_default = defineCommand10({
|
|
5879
|
+
meta: {
|
|
5880
|
+
name: "cleanup",
|
|
5881
|
+
description: "Remove low-quality auto-generated observations"
|
|
5882
|
+
},
|
|
5883
|
+
args: {
|
|
5884
|
+
dry: {
|
|
5885
|
+
type: "boolean",
|
|
5886
|
+
description: "Preview only \u2014 do not delete anything",
|
|
5887
|
+
default: false
|
|
5888
|
+
},
|
|
5889
|
+
force: {
|
|
5890
|
+
type: "boolean",
|
|
5891
|
+
description: "Delete without confirmation",
|
|
5892
|
+
default: false
|
|
5893
|
+
}
|
|
5894
|
+
},
|
|
5895
|
+
async run({ args }) {
|
|
5896
|
+
const project = detectProject();
|
|
5897
|
+
if (project.id === "__invalid__") {
|
|
5898
|
+
console.error("\u274C Not in a valid project directory.");
|
|
5899
|
+
process.exit(1);
|
|
5900
|
+
}
|
|
5901
|
+
console.log(`
|
|
5902
|
+
\u{1F4E6} Project: ${project.name} (${project.id})
|
|
5903
|
+
`);
|
|
5904
|
+
const dataDir = await getProjectDataDir(project.id);
|
|
5905
|
+
const allObs = await loadObservationsJson(dataDir);
|
|
5906
|
+
if (allObs.length === 0) {
|
|
5907
|
+
console.log("\u2705 No observations found \u2014 nothing to clean up.");
|
|
5908
|
+
return;
|
|
5909
|
+
}
|
|
5910
|
+
const lowQuality = allObs.filter((o) => isLowQuality(o.title ?? ""));
|
|
5911
|
+
const highQuality = allObs.filter((o) => !isLowQuality(o.title ?? ""));
|
|
5912
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5913
|
+
const duplicates = [];
|
|
5914
|
+
const unique = [];
|
|
5915
|
+
for (const obs of highQuality) {
|
|
5916
|
+
const key = `${obs.type}|${obs.title}|${obs.entityName}`;
|
|
5917
|
+
if (seen.has(key)) {
|
|
5918
|
+
duplicates.push(obs);
|
|
5919
|
+
} else {
|
|
5920
|
+
seen.add(key);
|
|
5921
|
+
unique.push(obs);
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
const toRemove = [...lowQuality, ...duplicates];
|
|
5925
|
+
console.log(`\u{1F4CA} Analysis:`);
|
|
5926
|
+
console.log(` Total observations: ${allObs.length}`);
|
|
5927
|
+
console.log(` \u{1F7E2} High quality: ${unique.length}`);
|
|
5928
|
+
console.log(` \u{1F534} Low quality: ${lowQuality.length}`);
|
|
5929
|
+
console.log(` \u{1F7E1} Duplicates: ${duplicates.length}`);
|
|
5930
|
+
console.log(` \u{1F5D1}\uFE0F To remove: ${toRemove.length}`);
|
|
5931
|
+
console.log();
|
|
5932
|
+
if (toRemove.length === 0) {
|
|
5933
|
+
console.log("\u2705 All observations are high quality \u2014 nothing to clean up!");
|
|
5934
|
+
return;
|
|
5935
|
+
}
|
|
5936
|
+
console.log("\u{1F50D} Examples of items to remove:");
|
|
5937
|
+
toRemove.slice(0, 10).forEach((o) => {
|
|
5938
|
+
const tag = isLowQuality(o.title ?? "") ? "(low-quality)" : "(duplicate)";
|
|
5939
|
+
console.log(` ${tag} #${o.id ?? "?"} "${o.title}" [${o.type}]`);
|
|
5940
|
+
});
|
|
5941
|
+
if (toRemove.length > 10) {
|
|
5942
|
+
console.log(` ... and ${toRemove.length - 10} more`);
|
|
5943
|
+
}
|
|
5944
|
+
console.log();
|
|
5945
|
+
if (args.dry) {
|
|
5946
|
+
console.log("\u{1F512} Dry run \u2014 no changes made.");
|
|
5947
|
+
return;
|
|
5948
|
+
}
|
|
5949
|
+
if (!args.force) {
|
|
5950
|
+
const readline = await import("readline");
|
|
5951
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
5952
|
+
const answer = await new Promise((resolve2) => {
|
|
5953
|
+
rl.question(`\u26A0\uFE0F Delete ${toRemove.length} observations? (y/N) `, resolve2);
|
|
5954
|
+
});
|
|
5955
|
+
rl.close();
|
|
5956
|
+
if (answer.trim().toLowerCase() !== "y") {
|
|
5957
|
+
console.log("\u274C Cancelled.");
|
|
5958
|
+
return;
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5961
|
+
const removeIds = new Set(toRemove.map((o) => JSON.stringify(o)));
|
|
5962
|
+
const remaining = allObs.filter((o) => !removeIds.has(JSON.stringify(o)));
|
|
5963
|
+
await saveObservationsJson(dataDir, remaining);
|
|
5964
|
+
console.log(`\u2705 Removed ${toRemove.length} observations. ${remaining.length} remaining.`);
|
|
5965
|
+
}
|
|
5966
|
+
});
|
|
5967
|
+
}
|
|
5968
|
+
});
|
|
5969
|
+
|
|
5834
5970
|
// src/cli/index.ts
|
|
5835
5971
|
init_esm_shims();
|
|
5836
|
-
import { defineCommand as
|
|
5972
|
+
import { defineCommand as defineCommand11, runMain } from "citty";
|
|
5837
5973
|
import { createRequire as createRequire2 } from "module";
|
|
5838
5974
|
var require2 = createRequire2(import.meta.url);
|
|
5839
5975
|
var pkg = require2("../../package.json");
|
|
5840
|
-
var main =
|
|
5976
|
+
var main = defineCommand11({
|
|
5841
5977
|
meta: {
|
|
5842
5978
|
name: "memorix",
|
|
5843
5979
|
version: pkg.version,
|
|
@@ -5849,7 +5985,8 @@ var main = defineCommand10({
|
|
|
5849
5985
|
sync: () => Promise.resolve().then(() => (init_sync(), sync_exports)).then((m) => m.default),
|
|
5850
5986
|
hook: () => Promise.resolve().then(() => (init_hook(), hook_exports)).then((m) => m.default),
|
|
5851
5987
|
hooks: () => Promise.resolve().then(() => (init_hooks(), hooks_exports)).then((m) => m.default),
|
|
5852
|
-
dashboard: () => Promise.resolve().then(() => (init_dashboard(), dashboard_exports)).then((m) => m.default)
|
|
5988
|
+
dashboard: () => Promise.resolve().then(() => (init_dashboard(), dashboard_exports)).then((m) => m.default),
|
|
5989
|
+
cleanup: () => Promise.resolve().then(() => (init_cleanup(), cleanup_exports)).then((m) => m.default)
|
|
5853
5990
|
},
|
|
5854
5991
|
run() {
|
|
5855
5992
|
}
|