opencode-fractal-memory 0.4.1 → 0.4.2
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/README.md +13 -3
- package/dist/hooks/auto-retrieve/index.js +14 -1
- package/dist/logging.js +7 -2
- package/dist/mcp/logging.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,11 +60,11 @@ Add the plugin name to `~/.config/opencode/opencode.json`:
|
|
|
60
60
|
|
|
61
61
|
```json
|
|
62
62
|
{
|
|
63
|
-
"
|
|
63
|
+
"plugin": ["opencode-fractal-memory"]
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
OpenCode installs it automatically at startup. Model files (~24 MB) download on first plugin load via `ensureModels()` — no manual steps needed.
|
|
67
|
+
OpenCode installs it automatically at startup from npm. Model files (~24 MB) download on first plugin load via `ensureModels()` — no manual steps needed.
|
|
68
68
|
|
|
69
69
|
### For development / manual install
|
|
70
70
|
|
|
@@ -317,6 +317,9 @@ Skills are specialized instruction sets stored as memory nodes. When a task matc
|
|
|
317
317
|
| `svelte-core-bestpractices` | svelte, component, runes |
|
|
318
318
|
| `svelte-code-writer` | svelte 5, sveltekit, component |
|
|
319
319
|
| `customize-opencode` | opencode config, agent, plugin |
|
|
320
|
+
| `context-engineering` | context, prompt, system message |
|
|
321
|
+
| `git-workflow-and-versioning` | git, commit, branch, version, publish |
|
|
322
|
+
| `incremental-implementation` | step by step, increment, gradual |
|
|
320
323
|
|
|
321
324
|
### Loading a skill
|
|
322
325
|
|
|
@@ -410,13 +413,20 @@ When OpenCode loads the plugin, `initStorage()` runs automatically:
|
|
|
410
413
|
6. **Background embeddings** — after 1s, generates embeddings for nodes that lack them
|
|
411
414
|
7. **Auto-retrieve hook** — if enabled in config, injects relevant context into prompts
|
|
412
415
|
|
|
416
|
+
Every initialization step is logged with timing in `logs/memory-plugin.log`, making it easy to diagnose startup issues.
|
|
417
|
+
|
|
413
418
|
All of this happens automatically — no manual intervention required.
|
|
414
419
|
|
|
415
420
|
## Logs
|
|
416
421
|
|
|
422
|
+
All plugin logs are consolidated under `~/.config/opencode/logs/`:
|
|
423
|
+
|
|
417
424
|
| Log | Path | Contents |
|
|
418
425
|
|-----|------|----------|
|
|
419
|
-
|
|
|
426
|
+
| Plugin | `logs/memory-plugin.log` | Plugin operations, init steps with timing, auto-retrieve, session events |
|
|
427
|
+
| MCP server | `logs/mcp-server.log` | MCP tool calls, resources, errors |
|
|
428
|
+
| Injection debug | `logs/memory-injection.log` | Full auto-retrieve injection payloads (rotated at 1 MB) |
|
|
429
|
+
| Context dump | `logs/context-dump.log` | Full context snapshots for debugging |
|
|
420
430
|
| OpenCode | `~/.local/share/opencode/log/` | Application lifecycle, tool calls |
|
|
421
431
|
|
|
422
432
|
## Development
|
|
@@ -7,7 +7,13 @@ import { scoreCandidates } from "./scoring";
|
|
|
7
7
|
import { detectRelevantSkills, detectRelevantPlaybooks } from "./detection";
|
|
8
8
|
import { formatPlaybooksAsAvailable, formatSkillsAsAvailable } from "./formatting";
|
|
9
9
|
import { formatNodeForInjection } from "./content";
|
|
10
|
-
const
|
|
10
|
+
const INJECTION_LOG_DIR = path.join(os.homedir(), ".config", "opencode", "logs");
|
|
11
|
+
const INJECTION_LOG_FILE = path.join(INJECTION_LOG_DIR, "memory-injection.log");
|
|
12
|
+
const INJECTION_LOG_MAX_SIZE = 1024 * 1024;
|
|
13
|
+
try {
|
|
14
|
+
fs.mkdirSync(INJECTION_LOG_DIR, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
11
17
|
export function createAutoRetrieveHook(deps) {
|
|
12
18
|
const { store, config, log } = deps;
|
|
13
19
|
const autoConfig = config.autoRetrieve;
|
|
@@ -136,6 +142,13 @@ ${JSON.stringify(memoriesJson, null, 2)}
|
|
|
136
142
|
return;
|
|
137
143
|
const debugLine = `[${new Date().toISOString()}] Query: ${userText.slice(0, 100)}...\n${fullBlock}\n\n`;
|
|
138
144
|
try {
|
|
145
|
+
try {
|
|
146
|
+
const stat = fs.statSync(INJECTION_LOG_FILE);
|
|
147
|
+
if (stat.size > INJECTION_LOG_MAX_SIZE) {
|
|
148
|
+
fs.renameSync(INJECTION_LOG_FILE, INJECTION_LOG_FILE + ".old");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch { }
|
|
139
152
|
fs.appendFileSync(INJECTION_LOG_FILE, debugLine);
|
|
140
153
|
}
|
|
141
154
|
catch { /* silent fail */ }
|
package/dist/logging.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const LOG_DIR = path.join(os.homedir(), ".config", "opencode", "logs");
|
|
5
|
+
const LOG_FILE = path.join(LOG_DIR, "memory-plugin.log");
|
|
6
|
+
const CONTEXT_DUMP_FILE = path.join(LOG_DIR, "context-dump.log");
|
|
6
7
|
const MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
8
|
+
try {
|
|
9
|
+
fs.mkdirSync(LOG_DIR, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
catch { }
|
|
7
12
|
let currentSessionId = null;
|
|
8
13
|
let logLevel = "info";
|
|
9
14
|
// Categories to always skip (OpenCode core noise)
|
package/dist/mcp/logging.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import * as os from "node:os";
|
|
4
|
-
const
|
|
4
|
+
const MCP_LOG_DIR = path.join(os.homedir(), ".config", "opencode", "logs");
|
|
5
|
+
const MCP_LOG_FILE = path.join(MCP_LOG_DIR, "mcp-server.log");
|
|
5
6
|
const MAX_LOG_SIZE = 1024 * 1024;
|
|
7
|
+
try {
|
|
8
|
+
fs.mkdirSync(MCP_LOG_DIR, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
catch { }
|
|
6
11
|
export function mcpLog(level, msg, data) {
|
|
7
12
|
try {
|
|
8
13
|
const ts = new Date().toISOString().slice(0, 19).replace("T", " ");
|