@lh8ppl/claude-memory-kit 0.2.2 → 0.2.4
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 +5 -4
- package/package.json +1 -1
- package/src/audit-log.mjs +1 -0
- package/src/auto-extract.mjs +1 -1
- package/src/auto-persona.mjs +40 -8
- package/src/capture-turn.mjs +48 -1
- package/src/compressor.mjs +1 -1
- package/src/conflict-queue.mjs +14 -0
- package/src/doctor.mjs +53 -126
- package/src/forget.mjs +29 -0
- package/src/index-rebuild.mjs +42 -0
- package/src/install.mjs +17 -2
- package/src/mcp-server.mjs +354 -125
- package/src/merge-facts.mjs +4 -0
- package/src/persona-portability.mjs +24 -1
- package/src/read-core.mjs +87 -0
- package/src/register-crons.mjs +64 -33
- package/src/remember-core.mjs +91 -0
- package/src/result-shapes.mjs +2 -2
- package/src/review-queue.mjs +13 -0
- package/src/search.mjs +6 -5
- package/src/settings-hooks.mjs +56 -2
- package/src/spawn-bin.mjs +7 -2
- package/src/subcommands.mjs +425 -169
- package/src/weekly-curate.mjs +5 -0
- package/src/write-fact.mjs +25 -1
- package/template/.claude/skills/memory-write/SKILL.md +52 -35
- package/template/.gitignore.fragment +6 -0
- package/template/support/cron-jobs/nightly-memsearch-index.md +0 -17
- package/template/support/milvus-deploy/README.md +0 -57
- package/template/support/milvus-deploy/docker-compose.yml +0 -66
- package/template/support/scripts/memsearch-index-with-flush.sh +0 -59
package/src/weekly-curate.mjs
CHANGED
|
@@ -339,6 +339,11 @@ export async function weeklyCurate({
|
|
|
339
339
|
backend,
|
|
340
340
|
now: ts,
|
|
341
341
|
cooldownMs: 0,
|
|
342
|
+
// Task 111 (F-2): the weekly janitor sweeps the whole-project `facts`
|
|
343
|
+
// corpus (heavier than a session summary) and runs as a cron/lazy child
|
|
344
|
+
// with no 60s hook ceiling — give the classifier headroom so a large
|
|
345
|
+
// corpus doesn't time out. (Corpus is byte-capped at PERSONA_CORPUS_BYTES.)
|
|
346
|
+
timeoutMs: 120_000,
|
|
342
347
|
});
|
|
343
348
|
}
|
|
344
349
|
|
package/src/write-fact.mjs
CHANGED
|
@@ -248,7 +248,7 @@ export function writeFact(opts = {}) {
|
|
|
248
248
|
// Keep INDEX.md consistent on every create — the index is a derived view of
|
|
249
249
|
// the fact files, so the writer owns keeping it current. Without this, a fresh
|
|
250
250
|
// `cmk remember` left INDEX.md stale until a manual `cmk reindex`, and
|
|
251
|
-
// `cmk doctor` HC-5 failed from the first capture (Task 85;
|
|
251
|
+
// `cmk doctor` HC-5 failed from the first capture (Task 85; live-test-7
|
|
252
252
|
// 2026-06-03 — "users should get it working from the start"). Best-effort: the
|
|
253
253
|
// fact is already durably on disk, so an index-rebuild hiccup must not turn a
|
|
254
254
|
// successful capture into an error — the next reindex/search self-heals.
|
|
@@ -258,5 +258,29 @@ export function writeFact(opts = {}) {
|
|
|
258
258
|
// index rebuild is best-effort; capture already succeeded
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
// Default create-audit (Task 123.A / D-103). writeFact is the single boundary
|
|
262
|
+
// every fact create flows through, so it owns the operational audit entry —
|
|
263
|
+
// the prior "caller's responsibility" design left 3 of 4 create paths
|
|
264
|
+
// (auto-extract, explicit-remember, graduation) silently unaudited (cut-gate7:
|
|
265
|
+
// 6 creates → 0 audit lines). Callers that emit a richer-semantic audit for
|
|
266
|
+
// the same write (merge-facts → `merged`/CURATED_MERGE) pass `audit:false` to
|
|
267
|
+
// avoid a redundant `created` entry. Best-effort: a successful capture must
|
|
268
|
+
// not be turned into an error by an audit-log hiccup.
|
|
269
|
+
if (opts.audit !== false) {
|
|
270
|
+
try {
|
|
271
|
+
appendAuditEntry(tierRoot, {
|
|
272
|
+
ts: createdAt,
|
|
273
|
+
action: 'created',
|
|
274
|
+
tier: opts.tier,
|
|
275
|
+
id,
|
|
276
|
+
reasonCode: REASON_CODES.FACT_CREATED,
|
|
277
|
+
paths: { after: path },
|
|
278
|
+
extra: { writeSource: factOpts.writeSource, trust: factOpts.trust },
|
|
279
|
+
});
|
|
280
|
+
} catch {
|
|
281
|
+
// audit append is best-effort; the fact is already durably on disk
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
261
285
|
return { action: 'created', id, path };
|
|
262
286
|
}
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memory-write
|
|
3
|
-
description: Captures a durable fact to project memory
|
|
4
|
-
allowed-tools: Bash(cmk remember *) Bash(cmk forget *) Read
|
|
3
|
+
description: Captures a durable fact to project memory through the kit's safe write path (Poison_Guard secret/injection screening + home-path sanitization + dedup + conflict detection) — preferring the cmk MCP tools (mk_remember / mk_forget / mk_trust) when connected, falling back to the cmk CLI. Use when the user says "remember this", "note this", "save this", "from now on", "going forward", "I prefer", "I don't like", "we decided", "we agreed", or otherwise states a durable preference, decision, or environment fact worth carrying across sessions. Also covers correcting a saved fact ("update memory: X is now Y"), removing one ("forget about X"), and adjusting how much a saved fact is trusted ("trust this", "that's important — keep it", "that's not important / I'm not sure about that / low priority"). Skip throwaway chatter and facts that only matter to the current task.
|
|
4
|
+
allowed-tools: mcp__cmk__mk_remember mcp__cmk__mk_forget mcp__cmk__mk_trust Bash(cmk remember *) Bash(cmk forget *) Bash(cmk trust *) Read
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Capturing durable memory
|
|
8
8
|
|
|
9
|
-
Durable facts — preferences, decisions, environment state — are saved
|
|
10
|
-
|
|
9
|
+
Durable facts — preferences, decisions, environment state — are saved through the
|
|
10
|
+
kit's safe write path (Poison_Guard secret screening + home-path sanitization +
|
|
11
|
+
dedup + conflict detection).
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
to remove). Run the command as shown; do not modify its shape.
|
|
16
|
-
- **NEVER** hand-edit `context/MEMORY.md`, `context/USER.md`, or any file under
|
|
17
|
-
`context/memory/`. Direct edits bypass secret screening and home-path
|
|
18
|
-
sanitization and can leak a credential or a local path into a committed file.
|
|
13
|
+
- **NEVER hand-edit** `context/MEMORY.md`, `context/USER.md`, or any file under
|
|
14
|
+
`context/memory/`. Direct edits bypass screening and can leak a credential or a
|
|
15
|
+
local path into a committed file.
|
|
19
16
|
- **Silent on success.** Do not announce "saved to memory" unless the user asked.
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
There are two equivalent surfaces onto the same safe path. **Prefer the MCP tools
|
|
19
|
+
when the `cmk` server is connected** — params are structured data, so backtick /
|
|
20
|
+
`$()` / quote-heavy rationale can't be mangled by a shell, and there's no
|
|
21
|
+
per-command approval prompt.
|
|
22
|
+
|
|
23
|
+
## Preferred: the cmk MCP tools (when connected)
|
|
24
|
+
|
|
25
|
+
- **Capture** → call `mk_remember` with `text`. For a preference, working-style
|
|
26
|
+
rule, or constraint, also pass `why`, `how`, `title`, and `type` — this writes a
|
|
27
|
+
rich Why/How fact file, not just a bullet.
|
|
28
|
+
- **Remove** → call `mk_forget` with the fact `id`. Two-step: the first call
|
|
29
|
+
previews what would be removed and returns a `confirm_token`; call again with
|
|
30
|
+
that token to tombstone (audit trail preserved). Confirm with the user first.
|
|
31
|
+
- **Adjust trust** → call `mk_trust` with the fact `id` and a `level` of `low`,
|
|
32
|
+
`medium`, or `high`. Use when the user signals how much a saved fact matters:
|
|
33
|
+
"trust this" / "that's important — keep it" → `high`; "that's not important / I'm
|
|
34
|
+
not sure / low priority" → `low`. Trust drives what gets injected first and what
|
|
35
|
+
ages out, so this is the user steering their own memory without editing files.
|
|
36
|
+
|
|
37
|
+
`type` is one of:
|
|
38
|
+
|
|
39
|
+
- `feedback` — how the user wants you to work
|
|
40
|
+
- `user` — who the user is (role, expertise)
|
|
41
|
+
- `project` — an ongoing goal or constraint
|
|
42
|
+
- `reference` — a pointer to an external resource (URL, ticket, dashboard)
|
|
43
|
+
|
|
44
|
+
## Fallback: the cmk CLI (when the MCP server isn't connected)
|
|
45
|
+
|
|
46
|
+
Capture a bullet:
|
|
22
47
|
|
|
23
48
|
```
|
|
24
49
|
cmk remember "<the fact, one sentence>"
|
|
25
50
|
```
|
|
26
51
|
|
|
27
|
-
|
|
28
|
-
tool versions, paths, and environment facts.
|
|
29
|
-
|
|
30
|
-
When the fact is not active work, pick its section:
|
|
52
|
+
Pick a section for facts that are not active work:
|
|
31
53
|
|
|
32
54
|
```
|
|
33
55
|
cmk remember "<fact>" --section "Environment Notes"
|
|
@@ -35,32 +57,21 @@ cmk remember "<fact>" --section "Environment Notes"
|
|
|
35
57
|
|
|
36
58
|
Sections: `Active Threads` (default), `Environment Notes`, `Pending Decisions`.
|
|
37
59
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
When the fact carries a reason or a how-to — a user preference, a working-style
|
|
41
|
-
rule, a project constraint — capture it richly so the reasoning survives:
|
|
60
|
+
Capture WITH rationale (preference, working-style rule, project constraint):
|
|
42
61
|
|
|
43
62
|
```
|
|
44
63
|
cmk remember "<headline>" --type <type> --why "<why it holds>" --how "<how to apply it>" --title "<short title>"
|
|
45
64
|
```
|
|
46
65
|
|
|
47
|
-
|
|
66
|
+
For backtick / quote-heavy rationale, pass it off-shell as a JSON object so the
|
|
67
|
+
shell can't corrupt it (the D-81 fix):
|
|
48
68
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- `reference` — a pointer to an external resource (URL, ticket, dashboard)
|
|
53
|
-
|
|
54
|
-
This writes a granular fact file with the rationale attached, not just a bullet.
|
|
55
|
-
|
|
56
|
-
## Correct a fact
|
|
57
|
-
|
|
58
|
-
Capture the corrected version with `cmk remember`, then remove the stale entry
|
|
59
|
-
with `cmk forget` (below) if it is now wrong. Do not hand-edit the old bullet.
|
|
60
|
-
|
|
61
|
-
## Remove a fact
|
|
69
|
+
```
|
|
70
|
+
cmk remember --from-file fact.json
|
|
71
|
+
```
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
Remove a fact (after confirming with the user — never remove one they did not ask
|
|
74
|
+
to forget):
|
|
64
75
|
|
|
65
76
|
```
|
|
66
77
|
cmk forget "<substring or citation id>" --yes --reason "<why>"
|
|
@@ -68,6 +79,12 @@ cmk forget "<substring or citation id>" --yes --reason "<why>"
|
|
|
68
79
|
|
|
69
80
|
Tombstones the fact — it keeps an audit trail and is never a silent delete.
|
|
70
81
|
|
|
82
|
+
Adjust how much a saved fact is trusted (`<id>` comes from `cmk search`):
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
cmk trust <id> <low|medium|high>
|
|
86
|
+
```
|
|
87
|
+
|
|
71
88
|
## What NOT to capture
|
|
72
89
|
|
|
73
90
|
- Throwaway chatter ("user said hi").
|
|
@@ -16,3 +16,9 @@ context/.locks/
|
|
|
16
16
|
# must never be committed). The durable memory lives in the scratchpads +
|
|
17
17
|
# fact files, not these logs.
|
|
18
18
|
context/sessions/*.extract.log
|
|
19
|
+
|
|
20
|
+
# Transcript-extraction temp buffer. capture-turn writes
|
|
21
|
+
# context/transcripts/.extract-<ts>.tmp as the turn buffer for the detached
|
|
22
|
+
# auto-extract child, which consumes + deletes it. Gitignored so a crash-orphaned
|
|
23
|
+
# partial (raw, un-screened turn content) never travels with `git clone`.
|
|
24
|
+
context/transcripts/.extract-*.tmp
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Nightly MemSearch Index
|
|
3
|
-
time: '02:00'
|
|
4
|
-
days: daily
|
|
5
|
-
active: 'true'
|
|
6
|
-
description: 'Re-indexes context/ markdown files for vector search'
|
|
7
|
-
timeout: 10m
|
|
8
|
-
job_type: shell_command
|
|
9
|
-
command: 'bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts'
|
|
10
|
-
working_directory: '${CLAUDE_PROJECT_DIR}'
|
|
11
|
-
# Requires Layer 5 installed (memsearch on PATH + a reachable Milvus backend).
|
|
12
|
-
# On Windows: Docker Desktop running with Milvus container — see context/SETUP.md.
|
|
13
|
-
# If memsearch isn't installed or backend isn't reachable, the task will fail;
|
|
14
|
-
# HC-7 (backend reachability) will flag it on the next session start.
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
Updates the memsearch vector index with any new content from `context/memory/`, `context/sessions/`, and `context/transcripts/`. Idempotent: only re-embeds chunks whose hash changed since the last run.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Milvus deployment (Windows + optional)
|
|
2
|
-
|
|
3
|
-
This compose stack runs Milvus v2.6.16 plus its required dependencies (etcd, MinIO) as three local containers. It's used by **Layer 5** (memsearch vector search) of the memory system.
|
|
4
|
-
|
|
5
|
-
## When you need this
|
|
6
|
-
|
|
7
|
-
- **Windows**: required. `milvus-lite` (the default embedded vector store memsearch ships) has no Windows wheels on PyPI. Use this Docker stack instead.
|
|
8
|
-
- **Linux / macOS**: optional. memsearch auto-installs milvus-lite and uses it at `~/.memsearch/milvus.db`. Skip this directory entirely unless you specifically want a remote Milvus.
|
|
9
|
-
|
|
10
|
-
## Bring it up
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
cd milvus-deploy
|
|
14
|
-
docker compose up -d
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Wait ~30-60 seconds for all three containers to report `(healthy)`:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
docker compose ps
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
You should see `milvus-etcd`, `milvus-minio`, `milvus-standalone` all `Up (healthy)`.
|
|
24
|
-
|
|
25
|
-
## Configure memsearch to use it
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
memsearch config set milvus.uri "http://localhost:19530"
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Bring it down
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
docker compose down
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Volumes persist in `./volumes/` — re-running `up -d` reuses the same data.
|
|
38
|
-
|
|
39
|
-
## Why a multi-container stack and not just `milvus-standalone`?
|
|
40
|
-
|
|
41
|
-
Milvus standalone needs etcd (metadata store) and MinIO (object storage for segments and index data). On Linux/macOS, `milvus-lite` bundles all of that into one Python wheel; on Windows there's no equivalent wheel, so the three services run as separate containers.
|
|
42
|
-
|
|
43
|
-
The single-container `docker run milvusdb/milvus:latest standalone` pattern referenced in some older docs is no longer supported — `latest` is `v3.0-beta` whose entrypoint doesn't accept `standalone` as a command. Use this compose file with the pinned versions instead.
|
|
44
|
-
|
|
45
|
-
## Known quirk: memsearch index without flush
|
|
46
|
-
|
|
47
|
-
memsearch v0.4.x doesn't call `flush()` after `MilvusStore.upsert()`. On Milvus v2.6+ (Woodpecker WAL), this means `memsearch index` reports success but the data isn't searchable until a flush forces the growing segment to seal.
|
|
48
|
-
|
|
49
|
-
Use `scripts/memsearch-index-with-flush.sh` instead of raw `memsearch index` until upstream ships a fix. Tracked as [memsearch issue #534](https://github.com/zilliztech/memsearch/issues/534).
|
|
50
|
-
|
|
51
|
-
## Pinned versions
|
|
52
|
-
|
|
53
|
-
| Image | Version | Why pinned |
|
|
54
|
-
|---|---|---|
|
|
55
|
-
| `milvusdb/milvus` | `v2.6.16` | Latest stable v2.6 line. `latest` tag is v3.0-beta and crashes. |
|
|
56
|
-
| `quay.io/coreos/etcd` | `v3.5.25` | Compatible with milvus v2.6. |
|
|
57
|
-
| `minio/minio` | `RELEASE.2024-12-18T13-15-44Z` | Recent stable RELEASE tag. |
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
version: '3.5'
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
etcd:
|
|
5
|
-
container_name: milvus-etcd
|
|
6
|
-
image: quay.io/coreos/etcd:v3.5.25
|
|
7
|
-
environment:
|
|
8
|
-
- ETCD_AUTO_COMPACTION_MODE=revision
|
|
9
|
-
- ETCD_AUTO_COMPACTION_RETENTION=1000
|
|
10
|
-
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
|
11
|
-
- ETCD_SNAPSHOT_COUNT=50000
|
|
12
|
-
volumes:
|
|
13
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
|
|
14
|
-
command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
|
|
15
|
-
healthcheck:
|
|
16
|
-
test: ["CMD", "etcdctl", "endpoint", "health"]
|
|
17
|
-
interval: 30s
|
|
18
|
-
timeout: 20s
|
|
19
|
-
retries: 3
|
|
20
|
-
|
|
21
|
-
minio:
|
|
22
|
-
container_name: milvus-minio
|
|
23
|
-
image: minio/minio:RELEASE.2024-12-18T13-15-44Z
|
|
24
|
-
environment:
|
|
25
|
-
MINIO_ACCESS_KEY: minioadmin
|
|
26
|
-
MINIO_SECRET_KEY: minioadmin
|
|
27
|
-
ports:
|
|
28
|
-
- "9001:9001"
|
|
29
|
-
- "9000:9000"
|
|
30
|
-
volumes:
|
|
31
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
|
|
32
|
-
command: minio server /minio_data --console-address ":9001"
|
|
33
|
-
healthcheck:
|
|
34
|
-
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
35
|
-
interval: 30s
|
|
36
|
-
timeout: 20s
|
|
37
|
-
retries: 3
|
|
38
|
-
|
|
39
|
-
standalone:
|
|
40
|
-
container_name: milvus-standalone
|
|
41
|
-
image: milvusdb/milvus:v2.6.16
|
|
42
|
-
command: ["milvus", "run", "standalone"]
|
|
43
|
-
security_opt:
|
|
44
|
-
- seccomp:unconfined
|
|
45
|
-
environment:
|
|
46
|
-
ETCD_ENDPOINTS: etcd:2379
|
|
47
|
-
MINIO_ADDRESS: minio:9000
|
|
48
|
-
MQ_TYPE: woodpecker
|
|
49
|
-
volumes:
|
|
50
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
|
|
51
|
-
healthcheck:
|
|
52
|
-
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
|
|
53
|
-
interval: 30s
|
|
54
|
-
start_period: 90s
|
|
55
|
-
timeout: 20s
|
|
56
|
-
retries: 3
|
|
57
|
-
ports:
|
|
58
|
-
- "19530:19530"
|
|
59
|
-
- "9091:9091"
|
|
60
|
-
depends_on:
|
|
61
|
-
- "etcd"
|
|
62
|
-
- "minio"
|
|
63
|
-
|
|
64
|
-
networks:
|
|
65
|
-
default:
|
|
66
|
-
name: milvus
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Wraps `memsearch index` to also force a Milvus flush afterward.
|
|
4
|
-
#
|
|
5
|
-
# Why: Milvus v2.6+ uses the Woodpecker WAL backend, which (unlike v2.5's
|
|
6
|
-
# Pulsar) does not auto-flush growing segments on a short timer. As a result,
|
|
7
|
-
# `memsearch index` reports "Indexed N chunks" successfully but
|
|
8
|
-
# `get_collection_stats` returns 0 rows and search returns no results until
|
|
9
|
-
# a manual flush forces the growing segment to seal.
|
|
10
|
-
#
|
|
11
|
-
# This wrapper runs the index, then issues a flush via pymilvus.
|
|
12
|
-
#
|
|
13
|
-
# Usage:
|
|
14
|
-
# bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts
|
|
15
|
-
#
|
|
16
|
-
# Reads MILVUS_URI from env (falls back to the memsearch config value, then localhost).
|
|
17
|
-
# Reads MILVUS_COLLECTION from env (falls back to memsearch config, then "memsearch_chunks").
|
|
18
|
-
|
|
19
|
-
# Task Scheduler / launchd / unattended cron contexts don't always inherit
|
|
20
|
-
# the user's PATH. Set it up explicitly for the common locations.
|
|
21
|
-
case ":$PATH:" in
|
|
22
|
-
*":/usr/bin:"*) ;;
|
|
23
|
-
*) export PATH="/usr/bin:/usr/local/bin:/opt/homebrew/bin:/c/Program Files/Git/usr/bin:$PATH" ;;
|
|
24
|
-
esac
|
|
25
|
-
|
|
26
|
-
# On Windows, also add the Python Scripts dir where `memsearch.exe` lands.
|
|
27
|
-
if [ -d "/c/Users/$USERNAME/AppData/Local/Programs/Python" ]; then
|
|
28
|
-
for d in /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*/Scripts \
|
|
29
|
-
/c/Users/$USERNAME/AppData/Local/Programs/Python/Python*; do
|
|
30
|
-
[ -d "$d" ] && export PATH="$d:$PATH"
|
|
31
|
-
done
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
set -euo pipefail
|
|
35
|
-
|
|
36
|
-
# Step 1 — index. Pass through all args.
|
|
37
|
-
memsearch index "$@"
|
|
38
|
-
|
|
39
|
-
# Step 2 — flush.
|
|
40
|
-
MILVUS_URI="${MILVUS_URI:-$(memsearch config get milvus.uri 2>/dev/null | tail -n1 | tr -d '\r')}"
|
|
41
|
-
MILVUS_COLLECTION="${MILVUS_COLLECTION:-$(memsearch config get milvus.collection 2>/dev/null | tail -n1 | tr -d '\r')}"
|
|
42
|
-
MILVUS_URI="${MILVUS_URI:-http://localhost:19530}"
|
|
43
|
-
MILVUS_COLLECTION="${MILVUS_COLLECTION:-memsearch_chunks}"
|
|
44
|
-
|
|
45
|
-
# Flush only if we're using a remote Milvus (milvus-lite auto-flushes).
|
|
46
|
-
case "$MILVUS_URI" in
|
|
47
|
-
http://*|https://*|tcp://*)
|
|
48
|
-
python -c "
|
|
49
|
-
from pymilvus import MilvusClient
|
|
50
|
-
client = MilvusClient(uri='${MILVUS_URI}')
|
|
51
|
-
client.flush('${MILVUS_COLLECTION}')
|
|
52
|
-
stats = client.get_collection_stats('${MILVUS_COLLECTION}')
|
|
53
|
-
print(f'Flushed. Collection {stats!r}')
|
|
54
|
-
"
|
|
55
|
-
;;
|
|
56
|
-
*)
|
|
57
|
-
echo "Local milvus-lite detected (${MILVUS_URI}); skipping flush (auto-flush)."
|
|
58
|
-
;;
|
|
59
|
-
esac
|