ubiquitous-invention/apps/web
Randall Stillwell 56b697b81c feat(markdown-backlog): close the sync loop with DB → frontmatter export
Until now the markdown importer was one-way (plans/*.md → DB). Any
agent-driven status flip via claim_task / complete_task would be
clobbered on the next importer sweep. This change closes the loop: the
DB now projects status, priority, agent_prompt, and updated_at back
into the file's frontmatter, preserving body bytes, key order, and
every other frontmatter key.

New: packages/database/src/markdown-backlog/export.ts
  - `rewriteFrontmatter()` — pure function, covered by 10 Vitest cases
    (round-trip identity, status flip, priority flip, agent_prompt
    null/block-scalar/single-line variants, body preservation,
    trailing-newline preservation, idempotent re-application).
  - `exportBacklogItemToMarkdown()` — DB-loading wrapper with atomic
    write (tmp + rename) and tenant fencing. Returns a structured
    result so callers can surface what happened in their response.

Wired into:
  - `claim_task` MCP tool — exports on the ready → in_progress flip.
  - `complete_task` MCP tool — exports on any finalStatus transition.
  - `backlog.updateWorkflowPrompt` tRPC mutation — exports on prompt
    edits made through the app UI.

Robust repo-root resolution (`apps/{mcp-server,web}/src/lib/repo-root.ts`,
plus a copy in `import-markdown-backlog.ts`): walk up from the source
file looking for `pnpm-workspace.yaml`, falling back to env var or cwd.
This fixes a class of bug where `pnpm --filter <pkg>` cd's into the
package directory and breaks naive cwd-based path resolution — the
importer was deleting all 44 rows during smoke testing before this fix
because it found zero files in `packages/database/plans/`.

`config/CursorSync.md`: documents the new two-way contract, the
DB-wins-on-allow-list conflict policy, and the
MARKDOWN_BACKLOG_REPO_ROOT=off escape hatch for production deployments
where `plans/` isn't checked out.

Smoke verified end-to-end against the homelab DB: claim flips file
status to in_progress, complete flips it back to ready, importer
round-trips with stable content_hash (true no-op), agent identity
preserved throughout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 10:21:22 -05:00
..
app feat(agent-runs): capture client + model identity on claim/complete 2026-06-03 10:11:35 -05:00
components feat(runs): agent_runs table + tRPC router + settings UI 2026-06-02 22:16:04 -05:00
lib feat(security): in-process rate limit for sign-in and invite creation 2026-06-02 13:26:19 -05:00
public docker: ensure apps/web/public exists so web runtime COPY succeeds 2026-04-27 14:46:47 -05:00
server feat(markdown-backlog): close the sync loop with DB → frontmatter export 2026-06-03 10:21:22 -05:00
styles feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
eslint.config.mjs chore(lint+types): green pnpm lint && pnpm type-check from a clean clone 2026-06-02 00:11:52 -05:00
middleware.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
next-env.d.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
next.config.ts fix(web): import @tasks/ai via workspace alias instead of relative path 2026-04-27 12:57:27 -05:00
package.json feat(web): wire AI chat page to streaming /api/chat handler 2026-06-02 00:23:21 -05:00
postcss.config.mjs feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
tailwind.config.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
tsconfig.json feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00