9c82d2aa7d
* chore(release): v0.9.29 with project-scope parity across surfaces Version trio + plugin manifests + supportedVersions + ExportData union bumped to 0.9.29; CHANGELOG entry covering everything since v0.9.28 with upgrade notes for the four visible behavior changes. Fixes the endpoint-count drift on main (130 registered routes vs docs saying 129 after #1132 landed in parallel with #1136). Project-scope parity: OpenCode plugin, Hermes plugin, Pi extension, and JSONL replay now resolve project the same way the hooks do (env override, git toplevel basename, cwd basename) instead of sending raw filesystem paths, closing #903 and #1135 and pre-empting the same bug in pi. The filesystem watcher accepts AGENTMEMORY_PROJECT_NAME with the old AGENTMEMORY_PROJECT kept as a deprecated alias, replay handles Windows-recorded paths, and OpenCode file enrichment matches the agent's lowercase tool names (the capitalized set never matched). Tests: opencode fallback expectations updated to basenames per the canonicalization, git-toplevel resolution covered with a fixture repo, new project-scope-parity suite for replay and fs-watcher. * fix(release): review findings, git-toplevel parity, doc counts - skills generator dedupes routes on method plus path, so the REST reference lists all 130 registered routes instead of hiding the second method on ten dual-method paths (header said 119) - fs-watcher trims AGENTMEMORY_PROJECT_NAME and the deprecated alias, treating whitespace as unset, and derives the git toplevel basename when watching a subdirectory - replay resolves the git toplevel basename when the recorded cwd still exists locally (memoized per cwd), keeping the basename fallback for historical or cross-platform paths; no env override here since a bulk import spans many projects - parity tests for replay git-root resolution, watcher git-root and trim behavior - stat-tests badge updated from 1428+ to 1550+ passing * fix(cli): refuse second-instance boot over a live daemon Closes the class behind issue 1140: agentmemory consolidate (or any unrecognized word) fell through the command table into the full server boot, registering a duplicate worker on the running engine; on iii 0.11.2 the second instance's shutdown tears down the daemon's HTTP trigger routing until a full engine restart. Unknown subcommands now error with the supported list, and main() probes livez on the resolved port and refuses to boot over a live daemon, so multi-instance setups on other ports are unaffected. Verified behaviorally against the built CLI: both paths refuse with exit 1. Also from review: the watcher stamps each event with its own root's project via a per-root map (an explicit config.project still overrides for every root), and replay only accepts a non-empty string cwd from parsed JSONL so malformed entries cannot reach the filesystem probe. * test(watcher): two-repository flush events scope to their own project * chore(release): bump packages/mcp, guard it, refresh CONTRIBUTING packages/mcp was still 0.9.28 after the release bump because nothing guarded it; a consistency test now pins it to package.json. CONTRIBUTING release list corrected to the files a bump actually touches (no tracked lockfile, the two extra plugin manifests, the export test derives from VERSION now), and the subsystems table gains src/cli, integrations/pi, and the generated-manifest note. * fix(export): refuse over-frame export instead of dropping the worker Closes the availability bug in issue 1142: GET /agentmemory/export assembles the full store and returns it through sdk.trigger, so a store whose serialized export passes the engine's 16 MiB WebSocket frame (tungstenite max_frame_size, not raisable under the 0.11.2 pin) dies on the worker->engine hop, drops the worker, and 404s every endpoint for ~1s. The session collections page on maxSessions/offset but ~18 others do not, so a large store hits this at any parameter combination. A shared frame-guard measures the serialized size before returning: mem::export returns a small oversized error instead of the giant object, and api::mesh-export returns 413 (same dead-end as #890). Either way the over-frame payload never crosses the boundary, so the daemon stays up and the failure is one clean request with a hint to narrow the range. Full pagination of the non-session collections is a follow-up. Layer 1 of the fix; verified with a synthetic oversized export returning the error object (tiny) rather than the payload. * ci: collapse to a single npm install to fix Node 24/26 CI The two-step install (npm install --package-lock-only then npm ci) failed only on the Node 24/26 matrix rows: their stricter npm rejects rolldown's optional platform bindings (@rolldown/binding-android-arm64) that a --package-lock-only pass does not fully enumerate. Lockfiles are gitignored, so npm ci re-validation buys no reproducibility here. A single lenient npm install resolves and installs in one pass. * fix(mesh): scope exported memories by project like actions api::mesh-export filtered actions by ?project but returned every project's memories. On a mesh instance federating one project to a peer, the peer pulled other projects' memories (cross-project leak), and those extras could push the payload past the 16 MiB transport frame into a 413 even when the requested project's own slice fit. Memories carry the same optional project field as actions, so filter both before the frame-size guard runs. Adds a regression test asserting a project-scoped export excludes other projects' memories and that an oversized memory in another project no longer 413s the scoped request. * chore(release): credit the Antigravity native hooks adapter in 0.9.29 notes * chore(release): sweep stale 0.9.28 refs for 0.9.29 Deploy Dockerfiles/compose/render pins, AGENTS.md stats header, opencode plugin manifest, website meta snapshot, test-count claims (1,428 -> 1,596) in README/AGENTS/stat SVGs, and the missing 0.9.29 CHANGELOG compare link. * chore(release): sync stat-tests badge to 1596+ and commit bridge exec bit * refactor: trim frame-guard comments and drop issue refs from code
177 lines
6.6 KiB
TypeScript
177 lines
6.6 KiB
TypeScript
import { readFileSync, writeFileSync, readdirSync, existsSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { getAllTools, ESSENTIAL_TOOLS } from "../../src/mcp/tools-registry.js";
|
|
import { ADAPTERS } from "../../src/cli/connect/index.js";
|
|
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = join(HERE, "..", "..");
|
|
const SKILLS = join(ROOT, "plugin", "skills");
|
|
const SRC = join(ROOT, "src");
|
|
|
|
const check = process.argv.includes("--check");
|
|
|
|
function clean(s: string): string {
|
|
return s.replace(/\s*[—–]\s*/g, ", ");
|
|
}
|
|
|
|
function block(key: string, body: string): { open: string; close: string; full: string } {
|
|
const open = `<!-- AUTOGEN:${key} START - generated by scripts/skills/generate.ts, do not edit by hand -->`;
|
|
const close = `<!-- AUTOGEN:${key} END -->`;
|
|
return { open, close, full: `${open}\n${body.trim()}\n${close}` };
|
|
}
|
|
|
|
function applyBlock(file: string, key: string, body: string): void {
|
|
const { open, close, full } = block(key, body);
|
|
const existing = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
let next: string;
|
|
if (existing.includes(open) && existing.includes(close)) {
|
|
const start = existing.indexOf(open);
|
|
const end = existing.indexOf(close) + close.length;
|
|
next = existing.slice(0, start) + full + existing.slice(end);
|
|
} else if (existing.trim()) {
|
|
next = `${existing.trimEnd()}\n\n${full}\n`;
|
|
} else {
|
|
next = `${full}\n`;
|
|
}
|
|
if (check) {
|
|
if (existing !== next) {
|
|
console.error(`DRIFT: ${file.replace(ROOT + "/", "")} (AUTOGEN:${key} out of date — run \`npm run skills:gen\`)`);
|
|
process.exitCode = 1;
|
|
}
|
|
return;
|
|
}
|
|
if (existing !== next) {
|
|
writeFileSync(file, next);
|
|
console.log(`wrote AUTOGEN:${key} -> ${file.replace(ROOT + "/", "")}`);
|
|
}
|
|
}
|
|
|
|
function walk(dir: string, out: string[] = []): string[] {
|
|
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
const full = join(dir, e.name);
|
|
if (e.isDirectory()) {
|
|
if (e.name === "node_modules" || e.name === "dist") continue;
|
|
walk(full, out);
|
|
} else if (e.name.endsWith(".ts")) {
|
|
out.push(full);
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function mdEscape(s: string): string {
|
|
return clean(s.replace(/\|/g, "\\|").replace(/\n/g, " ")).trim();
|
|
}
|
|
|
|
function tools(): string {
|
|
const all = getAllTools();
|
|
const lines = [
|
|
`agentmemory exposes ${all.length} MCP tools. ${ESSENTIAL_TOOLS.size} are in the lean core set (\`--tools core\` or \`AGENTMEMORY_TOOLS=core\`); the rest load with \`--tools all\` (default).`,
|
|
"",
|
|
"| Tool | Core | Parameters | Purpose |",
|
|
"| --- | --- | --- | --- |",
|
|
];
|
|
for (const t of all.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
const required = new Set(t.inputSchema.required ?? []);
|
|
const params = Object.entries(t.inputSchema.properties ?? {})
|
|
.map(([n, s]) => `\`${n}\`${required.has(n) ? "*" : ""}: ${s.type}`)
|
|
.join(", ") || "none";
|
|
const core = ESSENTIAL_TOOLS.has(t.name) ? "yes" : "";
|
|
lines.push(`| \`${t.name}\` | ${core} | ${mdEscape(params)} | ${mdEscape(t.description)} |`);
|
|
}
|
|
lines.push("", "`*` marks required parameters.");
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function rest(): string {
|
|
const text = readFileSync(join(SRC, "triggers", "api.ts"), "utf8");
|
|
const found: { path: string; method: string }[] = [];
|
|
const re = /api_path:\s*"([^"]+)"/g;
|
|
let m: RegExpExecArray | null;
|
|
while ((m = re.exec(text)) !== null) {
|
|
const path = m[1];
|
|
const win = text.slice(Math.max(0, m.index - 140), m.index + 140);
|
|
const mm = /http_method:\s*"([A-Z]+)"/.exec(win);
|
|
found.push({ path, method: mm ? mm[1] : "POST" });
|
|
}
|
|
// Dedupe on method+path, not path alone: ten paths register both GET and
|
|
// POST, and a path-only dedupe hid the second method and undercounted the
|
|
// surface (119 listed vs 130 registered).
|
|
const seen = new Set<string>();
|
|
const rows = found
|
|
.filter((e) => {
|
|
const key = `${e.method} ${e.path}`;
|
|
return seen.has(key) ? false : (seen.add(key), true);
|
|
})
|
|
.sort((a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method));
|
|
const lines = [
|
|
`The REST API is the primary surface. All paths are under \`http://localhost:3111\` (override with \`--port\`). When \`AGENTMEMORY_SECRET\` is set, send \`Authorization: Bearer $AGENTMEMORY_SECRET\`; localhost is otherwise open.`,
|
|
"",
|
|
`${rows.length} registered endpoints:`,
|
|
"",
|
|
"| Method | Path |",
|
|
"| --- | --- |",
|
|
...rows.map((e) => `| ${e.method} | \`${e.path}\` |`),
|
|
];
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function env(): string {
|
|
const files = walk(SRC);
|
|
const vars = new Set<string>();
|
|
for (const f of files) {
|
|
const text = readFileSync(f, "utf8");
|
|
const re = /AGENTMEMORY_[A-Z0-9_]+/g;
|
|
let m: RegExpExecArray | null;
|
|
while ((m = re.exec(text)) !== null) {
|
|
if (!m[0].endsWith("__")) vars.add(m[0]);
|
|
}
|
|
}
|
|
const sorted = [...vars].sort();
|
|
const lines = [
|
|
`Configuration is read from the environment and from \`~/.agentmemory/.env\` (no \`export\` prefix). ${sorted.length} recognized variables:`,
|
|
"",
|
|
...sorted.map((v) => `- \`${v}\``),
|
|
];
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function agents(): string {
|
|
const lines = [
|
|
`\`agentmemory connect <agent>\` wires the memory server into a host agent. ${ADAPTERS.length} adapters:`,
|
|
"",
|
|
"| Agent | Name | Protocol |",
|
|
"| --- | --- | --- |",
|
|
];
|
|
for (const a of [...ADAPTERS].sort((x, y) => x.name.localeCompare(y.name))) {
|
|
const note = (a.protocolNote ?? "").replace(/^[→\s]+/, "");
|
|
lines.push(`| ${mdEscape(a.displayName)} | \`${a.name}\` | ${mdEscape(note) || "MCP"} |`);
|
|
}
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function hooks(): string {
|
|
const file = join(ROOT, "plugin", "hooks", "hooks.json");
|
|
const json = JSON.parse(readFileSync(file, "utf8")) as { hooks?: Record<string, unknown> };
|
|
const events = Object.keys(json.hooks ?? {}).sort();
|
|
const lines = [
|
|
`The Claude Code plugin registers hooks on ${events.length} lifecycle events to capture observations automatically:`,
|
|
"",
|
|
...events.map((e) => `- \`${e}\``),
|
|
];
|
|
return lines.join("\n");
|
|
}
|
|
|
|
applyBlock(join(SKILLS, "agentmemory-mcp-tools", "REFERENCE.md"), "tools", tools());
|
|
applyBlock(join(SKILLS, "agentmemory-rest-api", "REFERENCE.md"), "rest", rest());
|
|
applyBlock(join(SKILLS, "agentmemory-config", "REFERENCE.md"), "env", env());
|
|
applyBlock(join(SKILLS, "agentmemory-agents", "REFERENCE.md"), "agents", agents());
|
|
applyBlock(join(SKILLS, "agentmemory-hooks", "REFERENCE.md"), "hooks", hooks());
|
|
|
|
if (check && process.exitCode) {
|
|
console.error("\nSkill reference docs are stale. Run: npm run skills:gen");
|
|
} else if (!check) {
|
|
console.log("skills reference generation complete");
|
|
}
|