extend the daemon thin-client surface to two more verb families: state get/set/list now routes through `/v1/state`, and remember/recall/forget through `/v1/memory`. same warm-path pattern as 1.25.0 — try the unix socket first, fall back to the cold ws path when the daemon is absent. multi-mesh aware (aggregates on read, requires `--mesh` for writes when ambiguous). also ships an early `claudemesh workspace <verb>` alias surface — bare teaser for the 1.28.0 mesh→workspace public rename. no-arg falls through to launch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { withMesh } from "./connect.js";
|
|
import { tryRememberViaDaemon } from "~/services/bridge/daemon-route.js";
|
|
import { render } from "~/ui/render.js";
|
|
import { dim } from "~/ui/styles.js";
|
|
import { EXIT } from "~/constants/exit-codes.js";
|
|
|
|
export async function remember(
|
|
content: string,
|
|
opts: { mesh?: string; tags?: string; json?: boolean } = {},
|
|
): Promise<number> {
|
|
if (!content) {
|
|
render.err("Usage: claudemesh remember <text>");
|
|
return EXIT.INVALID_ARGS;
|
|
}
|
|
const tags = opts.tags?.split(",").map((t) => t.trim()).filter(Boolean);
|
|
|
|
// Daemon path first.
|
|
const daemonRes = await tryRememberViaDaemon(content, tags, opts.mesh);
|
|
if (daemonRes) {
|
|
if (opts.json) {
|
|
console.log(JSON.stringify({ id: daemonRes.id, content, tags, mesh: daemonRes.mesh }));
|
|
return EXIT.SUCCESS;
|
|
}
|
|
render.ok("remembered", dim(daemonRes.id.slice(0, 8)));
|
|
return EXIT.SUCCESS;
|
|
}
|
|
|
|
return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
|
|
const id = await client.remember(content, tags);
|
|
|
|
if (opts.json) {
|
|
console.log(JSON.stringify({ id, content, tags }));
|
|
return EXIT.SUCCESS;
|
|
}
|
|
|
|
if (id) {
|
|
render.ok("remembered", dim(id.slice(0, 8)));
|
|
return EXIT.SUCCESS;
|
|
}
|
|
render.err("failed to store memory");
|
|
return EXIT.INTERNAL_ERROR;
|
|
});
|
|
}
|