@shahmilsaari/memory-core 1.0.25 → 1.0.27

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.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ApprovalQueue
4
+ } from "./chunk-W6WEAV3S.js";
5
+ export {
6
+ ApprovalQueue
7
+ };
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ collectResolvedImports,
4
+ parseImports
5
+ } from "./chunk-ZZBQEXEO.js";
6
+
7
+ // src/core/ast-analyzer.ts
8
+ import { existsSync } from "fs";
9
+ import { resolve } from "path";
10
+ var ASTAnalyzer = class {
11
+ constructor(cwd = process.cwd()) {
12
+ this.cwd = cwd;
13
+ }
14
+ cwd;
15
+ analyze(filepath) {
16
+ const absPath = resolve(this.cwd, filepath);
17
+ if (!existsSync(absPath)) {
18
+ return { file: filepath, imports: [] };
19
+ }
20
+ const resolved = collectResolvedImports(absPath, this.cwd);
21
+ const imports = resolved.map((imp) => ({
22
+ module: imp.specifier,
23
+ items: [],
24
+ isDefault: false,
25
+ line: imp.line,
26
+ isExternal: imp.isExternal
27
+ }));
28
+ return { file: filepath, imports };
29
+ }
30
+ analyzeSource(filepath, source) {
31
+ const parsed = parseImports(source);
32
+ const imports = parsed.map((imp) => ({
33
+ module: imp.specifier,
34
+ items: [],
35
+ isDefault: false,
36
+ line: imp.line,
37
+ isExternal: !imp.specifier.startsWith(".") && !imp.specifier.startsWith("/")
38
+ }));
39
+ return { file: filepath, imports };
40
+ }
41
+ };
42
+ export {
43
+ ASTAnalyzer
44
+ };
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/check-cache.ts
4
+ import { createHash } from "crypto";
5
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from "fs";
6
+ import { join } from "path";
7
+ var CACHE_TTL_MS = 5 * 60 * 1e3;
8
+ var CheckCache = class {
9
+ cacheDir;
10
+ constructor(rootPath) {
11
+ this.cacheDir = join(rootPath, ".archmind", "cache");
12
+ }
13
+ key(diffOutput, memoriesHash, rulesHash) {
14
+ return createHash("sha256").update(diffOutput + "||" + memoriesHash + "||" + (rulesHash ?? "")).digest("hex").slice(0, 16);
15
+ }
16
+ rulesHash(configDir) {
17
+ const rulesPath = join(configDir, "rules.json");
18
+ try {
19
+ const mtime = statSync(rulesPath).mtimeMs;
20
+ return mtime.toString();
21
+ } catch {
22
+ return "0";
23
+ }
24
+ }
25
+ memoriesHash(memories) {
26
+ const combined = memories.map((m) => m.content).join("|");
27
+ return createHash("sha256").update(combined).digest("hex").slice(0, 8);
28
+ }
29
+ get(key) {
30
+ const path = join(this.cacheDir, key + ".json");
31
+ if (!existsSync(path)) return null;
32
+ try {
33
+ const entry = JSON.parse(readFileSync(path, "utf-8"));
34
+ const age = Date.now() - new Date(entry.cachedAt).getTime();
35
+ if (age > CACHE_TTL_MS) return null;
36
+ return entry;
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+ set(key, entry) {
42
+ try {
43
+ mkdirSync(this.cacheDir, { recursive: true });
44
+ const full = { ...entry, key, cachedAt: (/* @__PURE__ */ new Date()).toISOString() };
45
+ writeFileSync(join(this.cacheDir, key + ".json"), JSON.stringify(full, null, 2), "utf-8");
46
+ } catch {
47
+ }
48
+ }
49
+ };
50
+ export {
51
+ CheckCache
52
+ };
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/check-logger.ts
4
+ import { appendFileSync, mkdirSync } from "fs";
5
+ import { join, dirname } from "path";
6
+ var CheckLogger = class {
7
+ logPath;
8
+ constructor(rootPath) {
9
+ this.logPath = join(rootPath, ".archmind", "check.log");
10
+ }
11
+ append(entry) {
12
+ try {
13
+ mkdirSync(dirname(this.logPath), { recursive: true });
14
+ appendFileSync(this.logPath, JSON.stringify(entry) + "\n", "utf-8");
15
+ } catch {
16
+ }
17
+ }
18
+ };
19
+ export {
20
+ CheckLogger
21
+ };