mirror of
https://github.com/Patiun/com.gregkilmer.www.git
synced 2026-11-08 04:08:24 +00:00
Add the content service and MCP server (phase 2)
services/content watches the vault's Site folder, runs every change through fixed rules, keeps the last accepted version of each note with its history, and serves one write API. The HTTP API, the MCP server for agents, and the admin page and editing tools to come all write through it. - SQLite store with history, review queue, redirects, links and full-text search - Rules: invalid, misplaced, duplicate name or slug, text loss, secrets, agent contact details, agent edits, agent publishing, agent batches - Watcher with debounce and a periodic full scan - HTTP API with reader, agent, editor and admin tokens - MCP tools: search, get_note, get_schema, list_held, set_status, add_library_item, update_fields, draft_post - Tests, including taking in all 545 migrated notes with nothing held Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aSbo2D1qP8cMFQCykf7kx
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* The shapes the HTTP API and the MCP server hand out. Both use these, so a
|
||||
* note looks the same to the site, the admin page and an agent.
|
||||
*/
|
||||
import type { HeldChange, Revision, StoredNote } from "./store.ts";
|
||||
import type { Outcome } from "./service.ts";
|
||||
|
||||
export const noteView = (n: StoredNote, opts: { text?: boolean } = {}) => ({
|
||||
path: n.path,
|
||||
type: n.type,
|
||||
name: n.name,
|
||||
slug: n.slug,
|
||||
title: n.title,
|
||||
publish: n.publish,
|
||||
data: n.data,
|
||||
body: n.body,
|
||||
rev: n.rev,
|
||||
acceptedAt: n.acceptedAt,
|
||||
author: n.author,
|
||||
...(opts.text ? { text: n.text } : {}),
|
||||
});
|
||||
|
||||
export const summaryView = (n: StoredNote) => ({
|
||||
path: n.path,
|
||||
type: n.type,
|
||||
title: n.title,
|
||||
slug: n.slug,
|
||||
publish: n.publish,
|
||||
acceptedAt: n.acceptedAt,
|
||||
});
|
||||
|
||||
export const revisionView = (r: Revision, opts: { text?: boolean } = {}) => ({
|
||||
rev: r.rev,
|
||||
author: r.author,
|
||||
at: r.at,
|
||||
action: r.action,
|
||||
...(opts.text ? { text: r.text } : {}),
|
||||
});
|
||||
|
||||
export const heldView = (h: HeldChange, opts: { text?: boolean } = {}) => ({
|
||||
id: h.id,
|
||||
path: h.path,
|
||||
author: h.author,
|
||||
source: h.source,
|
||||
reasons: h.reasons,
|
||||
at: h.at,
|
||||
status: h.status,
|
||||
decidedAt: h.decidedAt,
|
||||
...(opts.text ? { text: h.text } : {}),
|
||||
});
|
||||
|
||||
export const outcomeView = (o: Outcome) => {
|
||||
switch (o.status) {
|
||||
case "accepted":
|
||||
return { status: o.status, path: o.path, note: summaryView(o.note) };
|
||||
case "held":
|
||||
return { status: o.status, path: o.path, held: heldView(o.held) };
|
||||
default:
|
||||
return o;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user