Add the schulcloud CLI, and document the split
The CLI talks only to the Pi's /api surface and holds no Schulcloud credential — only the same bearer token the Claude connector uses. That is not layering for its own sake: a Schulcloud session dies after two hours idle and a CLI process lives for seconds, so a CLI with its own token would be dead most times you reached for it. Routing through the Pi means one session, one keepalive, one monthly cookie paste. sync is a one-way mirror, which follows from the data rather than from scope-cutting: file records are immutable upstream, so there is no versioning, no conflict resolution and no merge. State is keyed by file record id with the path as derived output, so an upstream rename moves the local file instead of duplicating it — verified against the live server. Verification is size-only because the download endpoint exposes no ETag and Schulcloud publishes no hash; size still catches the failure that happens, a truncated download. Downloads land on a .part neighbour and are renamed, so an interrupted run leaves no half-file that a later run mistakes for complete. Deletions are reported but not propagated — a teacher removing a worksheet is no reason to destroy the student's copy — with --prune to opt in. what_changed now clamps to the oldest stored generation instead of refusing, and says it did: "what's new this week" is a reasonable question to ask a two-day-old index. Two build bugs caught by the checks rather than by luck: the smoke harness constructed the app without services, so the index-backed tools were never exercised; and the Docker build could not see scripts/copy-assets.mjs, so the image would have shipped without migrations and silently degraded to live-only. 67 unit tests (9 needing Postgres), smoke green both ways — 34 checks with an index, 32 without, because graceful degradation is a supported mode and not a fallback nobody runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,16 +80,25 @@ export function registerIndexTools(server: McpServer, context: ServerContext): v
|
||||
async ({ since, kinds, limit }) => {
|
||||
if (!context.store) return failure(indexUnavailable('what_changed'));
|
||||
try {
|
||||
const from = await context.store.resolveCursor(since);
|
||||
const to = await context.store.latestCrawlId();
|
||||
if (to === undefined) {
|
||||
return failure('The index is empty — run refresh_index first.');
|
||||
}
|
||||
|
||||
let from = await context.store.resolveCursor(since);
|
||||
let clamped = false;
|
||||
if (from === undefined) {
|
||||
return failure(
|
||||
`No crawl exists at or before "${since}". The index only goes back as far as its oldest ` +
|
||||
`stored crawl; try a more recent date.`,
|
||||
);
|
||||
// Asking about a time before the index existed is a reasonable
|
||||
// question ("what's new this week?" on a two-day-old index). Fall
|
||||
// back to the oldest generation and say so, rather than refusing.
|
||||
const oldest = await context.store.oldestCrawlId();
|
||||
if (oldest === undefined || Number.isNaN(new Date(since).getTime())) {
|
||||
return failure(
|
||||
`Could not interpret "${since}". Give an ISO date like "2026-09-10", or a generation id.`,
|
||||
);
|
||||
}
|
||||
from = oldest;
|
||||
clamped = true;
|
||||
}
|
||||
if (from === to) {
|
||||
return text(`Nothing has changed since ${since} — the index has not been re-crawled since then.`);
|
||||
@@ -111,6 +120,10 @@ export function registerIndexTools(server: McpServer, context: ServerContext): v
|
||||
return text(
|
||||
joinSections([
|
||||
heading(2, `Changes since ${since} (generations ${from} → ${to})`),
|
||||
clamped
|
||||
? `_The index does not reach back to ${since}; showing everything since its oldest ` +
|
||||
`stored crawl (generation ${from}). Changes before that are not recorded._`
|
||||
: undefined,
|
||||
section('New', added.map((node) => `- ${node.kind}: **${node.title}** — ${node.path} (\`${node.nodeId}\`)`)),
|
||||
section('Changed', changed.map((node) => `- ${node.kind}: **${node.title}** — ${node.path} (\`${node.nodeId}\`)`)),
|
||||
section('Gone', removed.map((node) => `- ${node.kind}: ${node.title} — ${node.path}`)),
|
||||
|
||||
Reference in New Issue
Block a user