@vaur94/agz-memory 0.4.0-beta.1
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/ARCHITECTURE.md +173 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +237 -0
- package/README.tr.md +240 -0
- package/dist/admin.js +1494 -0
- package/dist/core.js +2434 -0
- package/dist/server.js +1790 -0
- package/dist/types/admin/doctor.d.ts +10 -0
- package/dist/types/admin/index.d.ts +2 -0
- package/dist/types/capture/contract.d.ts +102 -0
- package/dist/types/capture/identity.d.ts +25 -0
- package/dist/types/capture/policy.d.ts +9 -0
- package/dist/types/capture/projection.d.ts +17 -0
- package/dist/types/capture/redact.d.ts +12 -0
- package/dist/types/config.d.ts +4 -0
- package/dist/types/context.d.ts +1 -0
- package/dist/types/core.d.ts +30 -0
- package/dist/types/db/backup.d.ts +25 -0
- package/dist/types/db/health.d.ts +11 -0
- package/dist/types/db/migration-lock.d.ts +17 -0
- package/dist/types/db/migrations/v009.d.ts +3 -0
- package/dist/types/db/schema.d.ts +5 -0
- package/dist/types/db.d.ts +6 -0
- package/dist/types/identity.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/project.d.ts +4 -0
- package/dist/types/retrieval/backends/none.d.ts +9 -0
- package/dist/types/retrieval/contract.d.ts +42 -0
- package/dist/types/retrieval/derived.d.ts +11 -0
- package/dist/types/retrieval/formatter.d.ts +5 -0
- package/dist/types/retrieval/fusion.d.ts +8 -0
- package/dist/types/server.d.ts +5 -0
- package/dist/types/store/capture.d.ts +46 -0
- package/dist/types/store/outbox.d.ts +14 -0
- package/dist/types/store/retrieval.d.ts +18 -0
- package/dist/types/store.d.ts +95 -0
- package/dist/types/tools.d.ts +3 -0
- package/dist/types/types.d.ts +54 -0
- package/docs/backup-restore-runbook.md +73 -0
- package/package.json +63 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const SCHEMA_VERSION = 9;
|
|
2
|
+
export declare const INLINE_LIMIT = 1200;
|
|
3
|
+
export declare const KINDS: readonly ["decision", "fact", "procedure", "context", "research", "preference", "task"];
|
|
4
|
+
export type Kind = (typeof KINDS)[number];
|
|
5
|
+
export declare const PREDICATES: readonly ["SUPPORTS", "DERIVED_FROM", "PART_OF", "ABOUT", "PRECEDES", "SUPERSEDES"];
|
|
6
|
+
export type Predicate = (typeof PREDICATES)[number];
|
|
7
|
+
export type SizeClass = "inline" | "indexed";
|
|
8
|
+
export interface Project {
|
|
9
|
+
projectID: string;
|
|
10
|
+
projectName: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ProjectSummary extends Project {
|
|
15
|
+
noteCount: number;
|
|
16
|
+
pinnedCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Note {
|
|
19
|
+
id: string;
|
|
20
|
+
projectID: string;
|
|
21
|
+
projectName: string;
|
|
22
|
+
kind: Kind;
|
|
23
|
+
title: string;
|
|
24
|
+
summary: string;
|
|
25
|
+
content: string;
|
|
26
|
+
sizeClass: SizeClass;
|
|
27
|
+
pinned: boolean;
|
|
28
|
+
status: "active" | "superseded" | "archived";
|
|
29
|
+
supersedesID: string | null;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
updatedAt: number;
|
|
32
|
+
}
|
|
33
|
+
export interface Edge {
|
|
34
|
+
id: string;
|
|
35
|
+
projectID: string;
|
|
36
|
+
projectName: string;
|
|
37
|
+
sourceID: string;
|
|
38
|
+
targetID: string;
|
|
39
|
+
predicate: Predicate;
|
|
40
|
+
createdAt: number;
|
|
41
|
+
}
|
|
42
|
+
export interface RecallCard {
|
|
43
|
+
id: string;
|
|
44
|
+
projectID: string;
|
|
45
|
+
projectName: string;
|
|
46
|
+
kind: Kind;
|
|
47
|
+
title: string;
|
|
48
|
+
summary: string;
|
|
49
|
+
content?: string;
|
|
50
|
+
sizeClass: SizeClass;
|
|
51
|
+
pinned: boolean;
|
|
52
|
+
via: "match" | "neighbor";
|
|
53
|
+
predicates?: string[];
|
|
54
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Backup And Restore Runbook
|
|
2
|
+
|
|
3
|
+
## Preconditions
|
|
4
|
+
|
|
5
|
+
1. Record `OPENCODE_MEMORY_DATABASE_PATH`.
|
|
6
|
+
2. Disable the OpenCode memory plugin or keep it in `off` mode.
|
|
7
|
+
3. Stop every MCP/plugin process that can write the database. Version `0.3.0`
|
|
8
|
+
does not understand the v9 migration lock.
|
|
9
|
+
4. Confirm the database and backup directory are owned by the current user.
|
|
10
|
+
|
|
11
|
+
## Upgrade To Schema V9
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
export OPENCODE_MEMORY_DATABASE_PATH="$HOME/.local/share/opencode-memory/memory.sqlite"
|
|
15
|
+
|
|
16
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin doctor
|
|
17
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin backup
|
|
18
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin upgrade --to 9
|
|
19
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin doctor
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Do not start a writer if the final doctor report has `ok: false`. Preserve the
|
|
23
|
+
manifest path and SHA-256 printed by `backup`.
|
|
24
|
+
|
|
25
|
+
## Restore Rehearsal
|
|
26
|
+
|
|
27
|
+
The first invocation is a dry run:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin restore \
|
|
31
|
+
"$OPENCODE_MEMORY_DATABASE_PATH.backup/<backup>.manifest.json"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Verify `targetPath`, `sourceSchema`, row counts, and `sha256`. Then run:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin restore \
|
|
38
|
+
"$OPENCODE_MEMORY_DATABASE_PATH.backup/<backup>.manifest.json" \
|
|
39
|
+
--sha256 <manifest-database-sha256> \
|
|
40
|
+
--confirm RESTORE_DATABASE_FROM_VERIFIED_BACKUP
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The prior database is retained as `failed-restore-source-*`. Run `doctor` and a
|
|
44
|
+
read-only MCP `project_list`/`memory_recall` smoke before enabling writers.
|
|
45
|
+
|
|
46
|
+
## Stale Migration Lock
|
|
47
|
+
|
|
48
|
+
Inspect `<database>.migration.lock/owner.json`. Never break a live owner.
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin unlock \
|
|
52
|
+
--owner <exact-owner-id> \
|
|
53
|
+
--confirm BREAK_STALE_MIGRATION_LOCK
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The command refuses a live process with the same process-start marker.
|
|
57
|
+
If `owner.json` is missing or unreadable, inspect the lock directory first and
|
|
58
|
+
use `--owner ORPHANED` with the same confirmation phrase. Never use this while
|
|
59
|
+
another migration process may still be starting.
|
|
60
|
+
|
|
61
|
+
## Backup Pruning
|
|
62
|
+
|
|
63
|
+
Pruning is dry-run by default and returns a digest:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin backup prune
|
|
67
|
+
bunx --package @vaur94/agz-memory@0.4.0-beta.1 agz-memory-admin backup prune \
|
|
68
|
+
--digest <dry-run-digest> \
|
|
69
|
+
--confirm DELETE_VERIFIED_BACKUPS
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Do not prune the last known-good pre-upgrade backup until migration and restore
|
|
73
|
+
rehearsals are complete.
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vaur94/agz-memory",
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
4
|
+
"description": "Project-scoped persistent linked memory MCP server for OpenCode V2",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/server.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/server.js",
|
|
9
|
+
"./core": {
|
|
10
|
+
"types": "./dist/types/core.d.ts",
|
|
11
|
+
"default": "./dist/core.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"agz-memory": "dist/server.js",
|
|
16
|
+
"agz-memory-admin": "dist/admin.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"README.md",
|
|
20
|
+
"README.tr.md",
|
|
21
|
+
"dist/server.js",
|
|
22
|
+
"dist/core.js",
|
|
23
|
+
"dist/admin.js",
|
|
24
|
+
"dist/types/**/*.d.ts",
|
|
25
|
+
"ARCHITECTURE.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"docs/backup-restore-runbook.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"types": "rm -rf dist/types && bunx tsc -p tsconfig.build.json",
|
|
32
|
+
"build": "rm -rf dist && bun build src/index.ts --target bun --format esm --packages external --outfile dist/server.js && bun build src/core.ts --target bun --format esm --packages external --outfile dist/core.js && bun build src/admin/index.ts --target bun --format esm --packages external --outfile dist/admin.js && bunx tsc -p tsconfig.build.json && bun run --cwd packages/opencode-plugin build",
|
|
33
|
+
"check": "bunx tsc --noEmit && bun run types && bun run --cwd packages/opencode-plugin check",
|
|
34
|
+
"test": "bun test",
|
|
35
|
+
"benchmark": "bun benchmark/run.ts",
|
|
36
|
+
"prepack": "bun run check && bun run test && bun run build"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"bun": ">=1.3.14"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/ugur-murat-alt/agz-memory.git"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/ugur-murat-alt/agz-memory#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/ugur-murat-alt/agz-memory/issues"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
55
|
+
"@opencode-ai/plugin": "0.0.0-beta-18743",
|
|
56
|
+
"@types/bun": "^1.3.14",
|
|
57
|
+
"typescript": "^7.0.2"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
61
|
+
"zod": "^4.2.0"
|
|
62
|
+
}
|
|
63
|
+
}
|