Connect Echodo to itself: Cursor sessions can now call this repo's MCP server (`claim_task`, `complete_task`) over stdio, and operators can bootstrap the DB from `plans/` without leaving a long-running file watcher in place. - `.cursor/mcp.json`: register `echodo` MCP server. Spawns `pnpm -s --filter @tasks/mcp-server mcp`. The `mcp` script invokes tsx with `--env-file=../../.env` so DATABASE_URL is picked up at the per-session process boundary without leaking into committed config. - `import:markdown-backlog`: new one-shot importer (sibling of the existing watch script). Until the DB → markdown export side lands (see follow-up task), running the watcher continuously would clobber agent-driven status flips on every sweep. The one-shot variant runs a single `syncMarkdownBacklogScan` pass and exits. - File `Task-export-db-to-markdown-frontmatter.md` documenting the remaining direction of the sync loop. Smoke-tested end-to-end against the homelab DB: full `claim_task` → `complete_task` round-trip via real MCP stdio protocol, with agent_runs + audit_log rows landing as expected and the backlog item status restored via `finalStatus`. Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
/**
|
|
* One-shot markdown backlog import.
|
|
*
|
|
* Sibling of `watch-markdown-backlog.ts` but runs ONE sweep and exits. Use
|
|
* this when you want to bootstrap or refresh the DB from `plans/**` without
|
|
* leaving a long-running file watcher in place — particularly important
|
|
* during agent sessions, because the watcher's upsert overwrites
|
|
* `markdown_backlog_items.status` from frontmatter on every sweep and would
|
|
* clobber `claim_task` / `complete_task` state.
|
|
*
|
|
* Until the DB → markdown export side ships (see follow-up task), the
|
|
* convention is:
|
|
* - Edit `.md` files to author / refine intent.
|
|
* - Run this script when you want the changes in the DB.
|
|
* - Let agents drive runtime status via MCP tools BETWEEN syncs.
|
|
*
|
|
* Env:
|
|
* - DATABASE_URL (required)
|
|
* - MARKDOWN_BACKLOG_WORKSPACE_ID — UUID of the target workspace (required)
|
|
* - MARKDOWN_BACKLOG_REPO_ROOT — absolute path to repo root (default: cwd)
|
|
*/
|
|
import { resolve } from "node:path";
|
|
|
|
import { db } from "../client";
|
|
import { syncMarkdownBacklogScan } from "../markdown-backlog/sync";
|
|
|
|
const workspaceId = process.env.MARKDOWN_BACKLOG_WORKSPACE_ID?.trim();
|
|
const repoRootAbs = resolve(
|
|
process.env.MARKDOWN_BACKLOG_REPO_ROOT?.trim() || process.cwd(),
|
|
);
|
|
|
|
if (!workspaceId) {
|
|
console.error(
|
|
"[import-markdown-backlog] Set MARKDOWN_BACKLOG_WORKSPACE_ID to your workspace UUID.",
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
void (async () => {
|
|
try {
|
|
const result = await syncMarkdownBacklogScan(db, {
|
|
workspaceId,
|
|
repoRootAbs,
|
|
});
|
|
console.log(
|
|
`[import-markdown-backlog] done — scanned ${result.scannedFiles} files, upserted ${result.upsertedRows} rows, deleted ${result.deletedRows} stale rows. Repo root: ${repoRootAbs}`,
|
|
);
|
|
process.exit(0);
|
|
} catch (e) {
|
|
console.error("[import-markdown-backlog] sync failed:", e);
|
|
process.exit(1);
|
|
}
|
|
})();
|