aismemory 0.2.0 → 0.3.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/__tests__/cli-review.test.d.ts +1 -0
- package/dist/__tests__/cli-review.test.js +26 -0
- package/dist/__tests__/cli-review.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +1 -0
- package/dist/__tests__/config.test.js +54 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/local-claude-source.test.d.ts +1 -0
- package/dist/__tests__/local-claude-source.test.js +97 -0
- package/dist/__tests__/local-claude-source.test.js.map +1 -0
- package/dist/__tests__/local-mirror.test.d.ts +1 -0
- package/dist/__tests__/local-mirror.test.js +95 -0
- package/dist/__tests__/local-mirror.test.js.map +1 -0
- package/dist/__tests__/pipeline-ingestion.test.d.ts +1 -0
- package/dist/__tests__/pipeline-ingestion.test.js +161 -0
- package/dist/__tests__/pipeline-ingestion.test.js.map +1 -0
- package/dist/__tests__/pipeline-scope-resolver.test.d.ts +1 -0
- package/dist/__tests__/pipeline-scope-resolver.test.js +51 -0
- package/dist/__tests__/pipeline-scope-resolver.test.js.map +1 -0
- package/dist/__tests__/pipeline-trust-tagger.test.d.ts +1 -0
- package/dist/__tests__/pipeline-trust-tagger.test.js +24 -0
- package/dist/__tests__/pipeline-trust-tagger.test.js.map +1 -0
- package/dist/__tests__/read-claude-memory-tree.test.d.ts +1 -0
- package/dist/__tests__/read-claude-memory-tree.test.js +37 -0
- package/dist/__tests__/read-claude-memory-tree.test.js.map +1 -0
- package/dist/__tests__/trust-ledger.test.d.ts +1 -0
- package/dist/__tests__/trust-ledger.test.js +55 -0
- package/dist/__tests__/trust-ledger.test.js.map +1 -0
- package/dist/cli/read-claude-memory-tree.d.ts +7 -0
- package/dist/cli/read-claude-memory-tree.js +65 -0
- package/dist/cli/read-claude-memory-tree.js.map +1 -0
- package/dist/cli/sync-memory.d.ts +2 -0
- package/dist/cli/sync-memory.js +155 -0
- package/dist/cli/sync-memory.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +51 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +46 -18
- package/dist/index.js.map +1 -1
- package/dist/local-mirror.d.ts +15 -0
- package/dist/local-mirror.js +56 -0
- package/dist/local-mirror.js.map +1 -0
- package/dist/pipeline/dedupe.d.ts +11 -0
- package/dist/pipeline/dedupe.js +21 -0
- package/dist/pipeline/dedupe.js.map +1 -0
- package/dist/pipeline/ingestion.d.ts +56 -0
- package/dist/pipeline/ingestion.js +86 -0
- package/dist/pipeline/ingestion.js.map +1 -0
- package/dist/pipeline/scope-resolver.d.ts +15 -0
- package/dist/pipeline/scope-resolver.js +28 -0
- package/dist/pipeline/scope-resolver.js.map +1 -0
- package/dist/pipeline/trust-tagger.d.ts +10 -0
- package/dist/pipeline/trust-tagger.js +12 -0
- package/dist/pipeline/trust-tagger.js.map +1 -0
- package/dist/pipeline/types.d.ts +41 -0
- package/dist/pipeline/types.js +6 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/review/cli-review.d.ts +10 -0
- package/dist/review/cli-review.js +47 -0
- package/dist/review/cli-review.js.map +1 -0
- package/dist/sources/local-claude.d.ts +11 -0
- package/dist/sources/local-claude.js +137 -0
- package/dist/sources/local-claude.js.map +1 -0
- package/dist/sources/types.d.ts +53 -0
- package/dist/sources/types.js +9 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/trust-ledger.d.ts +8 -0
- package/dist/trust-ledger.js +61 -0
- package/dist/trust-ledger.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source Adapter interface — the plug-in contract for each memory provider.
|
|
3
|
+
*
|
|
4
|
+
* Each memory source (Claude local files, Claude.ai paste, ChatGPT paste, etc.)
|
|
5
|
+
* implements this interface in a self-contained file. Adapters PARSE and NORMALIZE;
|
|
6
|
+
* they never write to AIS directly. The ingestion pipeline does all writes.
|
|
7
|
+
*/
|
|
8
|
+
import type { SyncScope, AisMemoryDraft } from '../pipeline/types.js';
|
|
9
|
+
export type SourceKind = 'filesystem' | 'paste' | 'api';
|
|
10
|
+
export interface SourceAdapter {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly displayName: string;
|
|
13
|
+
readonly kind: SourceKind;
|
|
14
|
+
readonly icon?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Return the prompt the human should paste into the source provider, or an
|
|
17
|
+
* empty string for filesystem-kind adapters.
|
|
18
|
+
*/
|
|
19
|
+
extractionPrompt(scope: SyncScope): string;
|
|
20
|
+
/**
|
|
21
|
+
* Parse whatever the provider returned. MUST NOT throw on partial/malformed
|
|
22
|
+
* data — return what can be parsed in `memories`, surface problems in
|
|
23
|
+
* `warnings`. `raw` is string for paste, FilesystemResult for filesystem.
|
|
24
|
+
*/
|
|
25
|
+
parseResponse(raw: string | FilesystemResult): ParseResult;
|
|
26
|
+
/**
|
|
27
|
+
* Map a SourceMemory to an AIS memory draft. Applies provider-specific
|
|
28
|
+
* category→type mapping. Does NOT set trust/provenance — the trust-tagger
|
|
29
|
+
* stage does that.
|
|
30
|
+
*/
|
|
31
|
+
mapToAis(src: SourceMemory, scope: SyncScope, agentId: string): AisMemoryDraft;
|
|
32
|
+
/**
|
|
33
|
+
* Deterministic dedupe key for this memory. Default: sha256(content + source + sourceCategory).
|
|
34
|
+
*/
|
|
35
|
+
dedupeKey(src: SourceMemory): string;
|
|
36
|
+
}
|
|
37
|
+
export interface SourceMemory {
|
|
38
|
+
content: string;
|
|
39
|
+
sourceCategory?: string;
|
|
40
|
+
sourceDate?: string | null;
|
|
41
|
+
sourceMetadata?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export interface ParseResult {
|
|
44
|
+
memories: SourceMemory[];
|
|
45
|
+
warnings: string[];
|
|
46
|
+
}
|
|
47
|
+
export interface FilesystemResult {
|
|
48
|
+
rootPath: string;
|
|
49
|
+
files: Array<{
|
|
50
|
+
path: string;
|
|
51
|
+
content: string;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source Adapter interface — the plug-in contract for each memory provider.
|
|
3
|
+
*
|
|
4
|
+
* Each memory source (Claude local files, Claude.ai paste, ChatGPT paste, etc.)
|
|
5
|
+
* implements this interface in a self-contained file. Adapters PARSE and NORMALIZE;
|
|
6
|
+
* they never write to AIS directly. The ingestion pipeline does all writes.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sources/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class TrustLedger {
|
|
2
|
+
private readonly filePath;
|
|
3
|
+
private data;
|
|
4
|
+
constructor(home?: string);
|
|
5
|
+
isTrusted(agentId: string, sourceId: string, scopeKey: string): boolean;
|
|
6
|
+
recordSync(agentId: string, sourceId: string, scopeKey: string): void;
|
|
7
|
+
private persist;
|
|
8
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
const TRUST_AFTER_SYNCS = 2;
|
|
5
|
+
export class TrustLedger {
|
|
6
|
+
filePath;
|
|
7
|
+
data;
|
|
8
|
+
constructor(home = homedir()) {
|
|
9
|
+
const dir = join(home, '.aismemory');
|
|
10
|
+
this.filePath = join(dir, 'trust-ledger.json');
|
|
11
|
+
if (!existsSync(dir)) {
|
|
12
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
13
|
+
}
|
|
14
|
+
if (existsSync(this.filePath)) {
|
|
15
|
+
try {
|
|
16
|
+
this.data = JSON.parse(readFileSync(this.filePath, 'utf8'));
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
const backup = `${this.filePath}.corrupt-${Date.now()}`;
|
|
20
|
+
try {
|
|
21
|
+
renameSync(this.filePath, backup);
|
|
22
|
+
console.warn(`[TrustLedger] Corrupt ledger file renamed to ${backup}; starting fresh.`);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
console.warn(`[TrustLedger] Corrupt ledger file could not be backed up; starting fresh.`);
|
|
26
|
+
}
|
|
27
|
+
this.data = {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.data = {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
isTrusted(agentId, sourceId, scopeKey) {
|
|
35
|
+
return this.data[agentId]?.[sourceId]?.[scopeKey]?.trusted === true;
|
|
36
|
+
}
|
|
37
|
+
recordSync(agentId, sourceId, scopeKey) {
|
|
38
|
+
const now = new Date().toISOString();
|
|
39
|
+
const agent = this.data[agentId] ?? {};
|
|
40
|
+
const source = agent[sourceId] ?? {};
|
|
41
|
+
const existing = source[scopeKey];
|
|
42
|
+
const entry = existing
|
|
43
|
+
? {
|
|
44
|
+
firstSyncAt: existing.firstSyncAt,
|
|
45
|
+
lastSyncAt: now,
|
|
46
|
+
syncCount: existing.syncCount + 1,
|
|
47
|
+
trusted: existing.syncCount + 1 >= TRUST_AFTER_SYNCS,
|
|
48
|
+
}
|
|
49
|
+
: { firstSyncAt: now, lastSyncAt: now, syncCount: 1, trusted: false };
|
|
50
|
+
source[scopeKey] = entry;
|
|
51
|
+
agent[sourceId] = source;
|
|
52
|
+
this.data[agentId] = agent;
|
|
53
|
+
this.persist();
|
|
54
|
+
}
|
|
55
|
+
persist() {
|
|
56
|
+
const tmp = `${this.filePath}.tmp`;
|
|
57
|
+
writeFileSync(tmp, JSON.stringify(this.data, null, 2), { mode: 0o600 });
|
|
58
|
+
renameSync(tmp, this.filePath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61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