memindex 1.4.6 → 1.6.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +15 -12
- package/.codex-plugin/plugin.json +17 -14
- package/.qoder-plugin/plugin.json +1 -1
- package/README.md +89 -110
- package/THIRD_PARTY_LICENSES +7 -0
- package/dist/bug-report/index.js +60 -60
- package/dist/npx-cli/index.js +316 -307
- package/dist/opencode-plugin/index.js +43 -43
- package/dist/pi-extension/index.js +6 -6
- package/integrations/dsh/lib/index.js +19 -19
- package/integrations/dsh/package.json +1 -1
- package/integrations/openclaw/install.sh +16 -10
- package/integrations/openclaw/openclaw.plugin.json +1 -1
- package/integrations/openclaw/test-install.sh +20 -13
- package/package.json +15 -12
- package/plugin/.claude-plugin/plugin.json +15 -12
- package/plugin/.codex-plugin/plugin.json +15 -12
- package/plugin/.qoder-plugin/plugin.json +1 -1
- package/plugin/hooks/codex-hooks.json +12 -0
- package/plugin/package.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/scripts/context-generator.cjs +62 -61
- package/plugin/scripts/context-generator.cjs.map +3 -3
- package/plugin/scripts/mcp-server.cjs +74 -73
- package/plugin/scripts/mcp-server.cjs.map +3 -3
- package/plugin/scripts/statusline.cjs +1 -1
- package/plugin/scripts/transcript-watcher.cjs +36 -35
- package/plugin/scripts/transcript-watcher.cjs.map +3 -3
- package/plugin/scripts/worker-service.cjs +638 -599
- package/plugin/scripts/worker-service.cjs.map +3 -3
- package/plugin/skills/cloud-sync/SKILL.md +5 -5
- package/plugin/skills/mode-creator/SKILL.md +7 -1
- package/plugin/skills/timeline-report/SKILL.md +8 -8
- package/plugin/skills/weekly-digests/SKILL.md +5 -5
- package/plugin/skills/worker-request.mjs +45 -0
- package/plugin/sqlite/SessionStore.js +128 -128
- package/plugin/sqlite/SessionStore.js.map +3 -3
- package/plugin/sqlite/observations/files.js +12 -9
- package/plugin/sqlite/observations/files.js.map +3 -3
- package/plugin/ui/assets/fonts/dm-sans-OFL.txt +93 -0
- package/plugin/ui/assets/fonts/dm-sans-latin.woff2 +0 -0
- package/plugin/ui/assets/fonts/ibm-plex-mono-OFL.txt +93 -0
- package/plugin/ui/assets/fonts/ibm-plex-mono-latin.woff2 +0 -0
- package/plugin/ui/assets/fonts/manrope-OFL.txt +93 -0
- package/plugin/ui/assets/fonts/manrope-latin.woff2 +0 -0
- package/plugin/ui/viewer-bundle.js +18 -18
- package/plugin/ui/viewer.html +450 -321
|
@@ -34,10 +34,10 @@ Resolve the worker port and query the always-registered status route:
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
PORT="${MEMINDEX_WORKER_PORT:-$(node -e "const fs=require('fs'),p=require('path'),os=require('os');const uid=(typeof process.getuid==='function'?process.getuid():77);const fallback=String(38700+(uid%100));try{const s=JSON.parse(fs.readFileSync(p.join(os.homedir(),'.memindex','settings.json'),'utf-8'));process.stdout.write(String(s.MEMINDEX_WORKER_PORT||fallback));}catch{process.stdout.write(fallback);}" 2>/dev/null)}"
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
memcurl
|
|
37
|
+
# Set MEMINDEX_SKILL_DIR to the absolute directory containing this SKILL.md.
|
|
38
|
+
# The helper checks the worker's identity before sending the install secret.
|
|
39
|
+
memcurl() { node "${MEMINDEX_SKILL_DIR:?Set the installed skill directory}/../worker-request.mjs" "$@"; }
|
|
40
|
+
memcurl "http://127.0.0.1:${PORT}/api/sync/status"
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
- `configured: true` and `hub.reachable: true` → the worker completed an
|
|
@@ -72,7 +72,7 @@ Once the settings are saved, poll the status route every five seconds for up to
|
|
|
72
72
|
30 seconds. If the worker was not restarted, restart it first:
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
memcurl
|
|
75
|
+
memcurl "http://127.0.0.1:${PORT}/api/admin/restart" POST
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
Success means `configured: true`, `hub.reachable: true`, and `lastError: null`.
|
|
@@ -105,9 +105,15 @@ Verify all of the following:
|
|
|
105
105
|
1. Restart reports a new healthy worker and exits successfully.
|
|
106
106
|
2. The installed file exists under the resolved data directory.
|
|
107
107
|
3. `settings.json` names the intended `MEMINDEX_MODE` without displaying secrets.
|
|
108
|
-
4. Request full startup context with the `session_start_context` MCP tool when available. Otherwise
|
|
108
|
+
4. Request full startup context with the `session_start_context` MCP tool when available. Otherwise use the helper below with the configured worker port. It checks the listener's identity before sending the install secret.
|
|
109
109
|
5. Startup context contains `Mode: <mode name> (<mode id>)`.
|
|
110
110
|
|
|
111
|
+
```bash
|
|
112
|
+
# Set MEMINDEX_SKILL_DIR to the absolute directory containing this SKILL.md.
|
|
113
|
+
memcurl() { node "${MEMINDEX_SKILL_DIR:?Set the installed skill directory}/../worker-request.mjs" "$@"; }
|
|
114
|
+
memcurl "http://127.0.0.1:${MEMINDEX_WORKER_PORT:?Set the configured worker port}/api/context/inject?project=mode-creator-verification&full=true"
|
|
115
|
+
```
|
|
116
|
+
|
|
111
117
|
If the worker falls back to `code`, inspect the worker log for a mode validation or lookup error, repair the mode, and repeat the restart. Do not describe a fallback as successful activation.
|
|
112
118
|
|
|
113
119
|
## 6. Hand off clearly
|
|
@@ -26,9 +26,9 @@ The memindex worker must be running. The project must have memindex observations
|
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
WORKER_PORT="${MEMINDEX_WORKER_PORT:-$(node -e "const fs=require('fs'),p=require('path'),os=require('os');const uid=(typeof process.getuid==='function'?process.getuid():77);const fallback=String(38700+(uid%100));try{const s=JSON.parse(fs.readFileSync(p.join(os.homedir(),'.memindex','settings.json'),'utf-8'));process.stdout.write(String(s.MEMINDEX_WORKER_PORT||fallback));}catch{process.stdout.write(fallback);}" 2>/dev/null)}"
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
# Set MEMINDEX_SKILL_DIR to the absolute directory containing this SKILL.md.
|
|
30
|
+
# The helper checks the worker's identity before sending the install secret.
|
|
31
|
+
memcurl() { node "${MEMINDEX_SKILL_DIR:?Set the installed skill directory}/../worker-request.mjs" "$@"; }
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
This honors `MEMINDEX_WORKER_PORT` env, then `~/.memindex/settings.json`, then falls back to the per-UID default `38700 + (uid % 100)` — matching how the worker itself picks its port. Required for multi-account setups (#2101) and any user who has overridden the default port (#2103).
|
|
@@ -61,7 +61,7 @@ If a worktree is detected, use `$parent_project` (the basename of the parent rep
|
|
|
61
61
|
Use Bash to fetch the complete timeline from the memindex worker API:
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
memcurl
|
|
64
|
+
memcurl "http://localhost:${WORKER_PORT}/api/context/inject?project=PROJECT_NAME&full=true"
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
This returns the entire compressed timeline -- every observation, session boundary, and summary across the project's full history. The response is pre-formatted markdown optimized for LLM consumption.
|
|
@@ -71,7 +71,7 @@ This returns the entire compressed timeline -- every observation, session bounda
|
|
|
71
71
|
- Medium project (1,000-10,000 observations): ~50-300K tokens
|
|
72
72
|
- Large project (10,000-35,000 observations): ~300-750K tokens
|
|
73
73
|
|
|
74
|
-
If the response is empty or returns an error, the worker may not be running or the project name may be wrong. Try `memcurl
|
|
74
|
+
If the response is empty or returns an error, the worker may not be running or the project name may be wrong. Try `memcurl "http://localhost:${WORKER_PORT}/api/search?query=*&limit=1"` to verify the worker is healthy.
|
|
75
75
|
|
|
76
76
|
### Step 3: Estimate Token Count
|
|
77
77
|
|
|
@@ -198,15 +198,15 @@ Tell the user:
|
|
|
198
198
|
|
|
199
199
|
## Error Handling
|
|
200
200
|
|
|
201
|
-
- **Empty timeline:** "No observations found for project 'X'. Check the project name with: `memcurl
|
|
201
|
+
- **Empty timeline:** "No observations found for project 'X'. Check the project name with: `memcurl \"http://localhost:${WORKER_PORT}/api/search?query=*&limit=1\"`"
|
|
202
202
|
- **Worker not running:** "The memindex worker is not responding on port ${WORKER_PORT}. Start it with your usual method or check `ps aux | grep worker-service`."
|
|
203
|
-
- **Timeline too large:** For projects with 50,000+ observations, the timeline may exceed context limits. Suggest using date range filtering: `memcurl
|
|
203
|
+
- **Timeline too large:** For projects with 50,000+ observations, the timeline may exceed context limits. Suggest using date range filtering: `memcurl "http://localhost:${WORKER_PORT}/api/context/inject?project=X&full=true"` -- the current endpoint returns all observations; for extremely large projects, the user may want to analyze in time-windowed segments.
|
|
204
204
|
|
|
205
205
|
## Example
|
|
206
206
|
|
|
207
207
|
User: "Write a journey report for the tokyo project"
|
|
208
208
|
|
|
209
|
-
1. Fetch: `memcurl
|
|
209
|
+
1. Fetch: `memcurl "http://localhost:${WORKER_PORT}/api/context/inject?project=tokyo&full=true"`
|
|
210
210
|
2. Estimate: "Timeline fetched: ~34,722 observations, estimated ~718K tokens. Proceed?"
|
|
211
211
|
3. User confirms
|
|
212
212
|
4. Deploy analysis agent with full timeline
|
|
@@ -32,9 +32,9 @@ If the user wants a single sweeping report, use `timeline-report` instead. This
|
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
WORKER_PORT="${MEMINDEX_WORKER_PORT:-$(node -e "const fs=require('fs'),p=require('path'),os=require('os');const uid=(typeof process.getuid==='function'?process.getuid():77);const fallback=String(38700+(uid%100));try{const s=JSON.parse(fs.readFileSync(p.join(os.homedir(),'.memindex','settings.json'),'utf-8'));process.stdout.write(String(s.MEMINDEX_WORKER_PORT||fallback));}catch{process.stdout.write(fallback);}" 2>/dev/null)}"
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
# Set MEMINDEX_SKILL_DIR to the absolute directory containing this SKILL.md.
|
|
36
|
+
# The helper checks the worker's identity before sending the install secret.
|
|
37
|
+
memcurl() { node "${MEMINDEX_SKILL_DIR:?Set the installed skill directory}/../worker-request.mjs" "$@"; }
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Workflow
|
|
@@ -58,7 +58,7 @@ echo "$parent_project"
|
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
60
|
mkdir -p .scratch
|
|
61
|
-
memcurl
|
|
61
|
+
memcurl "http://localhost:${WORKER_PORT}/api/context/inject?project=PROJECT_NAME&full=true" \
|
|
62
62
|
> .scratch/cm-timeline.md
|
|
63
63
|
wc -l .scratch/cm-timeline.md
|
|
64
64
|
```
|
|
@@ -232,7 +232,7 @@ These rules emerged from running the pipeline end-to-end. Encode them every time
|
|
|
232
232
|
|
|
233
233
|
## Error Handling
|
|
234
234
|
|
|
235
|
-
- **Empty timeline**: project name wrong, or worker not running. `memcurl
|
|
235
|
+
- **Empty timeline**: project name wrong, or worker not running. `memcurl "http://localhost:${WORKER_PORT}/api/search?query=*&limit=1"` to verify.
|
|
236
236
|
- **Worker not running**: start it via your usual method or check `ps aux | grep worker-service`.
|
|
237
237
|
- **Subagent returns malformed carry-forward**: extract the carry-forward block by regex (` ```carry-forward ... ``` `) and pass forward verbatim. If missing, ask the agent to retry with the explicit instruction "your reply MUST include the carry-forward block fenced as ```carry-forward ... ``` at the very end."
|
|
238
238
|
- **One agent fails mid-pipeline**: retry that week with the same carry-forward. Don't skip — the chain breaks.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { closeSync, constants, fstatSync, openSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const target = new URL(process.argv[2]);
|
|
8
|
+
const method = process.argv[3] ?? 'GET';
|
|
9
|
+
if (target.protocol !== 'http:' || !['localhost', '127.0.0.1', '[::1]'].includes(target.hostname)
|
|
10
|
+
|| target.username || target.password || !['GET', 'POST'].includes(method)) {
|
|
11
|
+
throw new Error('Expected a loopback worker URL and GET or POST.');
|
|
12
|
+
}
|
|
13
|
+
const dataDir = process.env.MEMINDEX_DATA_DIR || join(homedir(), '.memindex');
|
|
14
|
+
const fd = openSync(join(dataDir, 'worker-secret'), constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
15
|
+
let secret;
|
|
16
|
+
try {
|
|
17
|
+
const stat = fstatSync(fd);
|
|
18
|
+
if (!stat.isFile() || (process.getuid && stat.uid !== process.getuid())
|
|
19
|
+
|| (process.platform !== 'win32' && (stat.mode & 0o077) !== 0)) {
|
|
20
|
+
throw new Error('The worker secret must be an owner-only file.');
|
|
21
|
+
}
|
|
22
|
+
secret = readFileSync(fd, 'utf8');
|
|
23
|
+
if (!/^[a-f0-9]{64}$/.test(secret)) throw new Error('Invalid worker secret.');
|
|
24
|
+
} finally {
|
|
25
|
+
closeSync(fd);
|
|
26
|
+
}
|
|
27
|
+
const challenge = randomBytes(32).toString('hex');
|
|
28
|
+
const health = new URL('/api/health', target);
|
|
29
|
+
health.searchParams.set('challenge', challenge);
|
|
30
|
+
const response = await fetch(health, { redirect: 'error', signal: AbortSignal.timeout(2000) });
|
|
31
|
+
const { proof } = await response.json();
|
|
32
|
+
const expected = createHmac('sha256', secret).update('memindex-worker-identity:' + challenge).digest('hex');
|
|
33
|
+
if (!response.ok || typeof proof !== 'string' || !/^[a-f0-9]{64}$/.test(proof)
|
|
34
|
+
|| !timingSafeEqual(Buffer.from(proof), Buffer.from(expected))) {
|
|
35
|
+
throw new Error('The listener could not prove it is this install’s worker; nothing was sent.');
|
|
36
|
+
}
|
|
37
|
+
const result = await fetch(target, {
|
|
38
|
+
method, headers: { 'X-Memindex-Secret': secret }, redirect: 'error', signal: AbortSignal.timeout(30000),
|
|
39
|
+
});
|
|
40
|
+
if (!result.ok) throw new Error(`Worker request failed (${result.status}).`);
|
|
41
|
+
for await (const chunk of result.body ?? []) process.stdout.write(chunk);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(error instanceof Error ? error.message : 'Worker request failed.');
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|