- src/core/settings.ts: versioned DELTA record schema + sanitizer (unknown keys preserved)
— general/chat/agent{models,tools,prompts}/appearance/graph sections
- src/core/settings-resolution.ts: pure resolveSettings (factory defaults → user delta),
extraction/graph-context channel predicates
- src/store/settings.ts + prompt-overrides.ts: SettingsStore/PromptOverrideStore adapters
wired through stores.ts (effectiveSettings() fresh per call); lazy migration of
default-settings.json into record.chat
- app/api/settings/** routes (record, section bodies, prompt overrides per segment)
- chat-handler: graph gates at trigger call-sites + toolToggles injection seam
- config.ts: SETTINGS_FILE + PROMPTS_OVERRIDE_DIR paths
587/587 tests; typecheck/lint/build clean
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
/**
|
|
* GET /api/settings/prompts — the system-prompt segment view
|
|
* (settings-storage wave, 2026-09-19): the effective prompt segments for
|
|
* BOTH agents, derived from SOURCE at runtime (src/agent/prompts — the
|
|
* list adapts when the code ships/renames/removes fragments), each with
|
|
* its source text, override text (if a file exists), and effective switch
|
|
* state (settings record's agent.prompts map AND file presence).
|
|
*
|
|
* GET → 200 {prober: SegmentInfo[], teacher: SegmentInfo[]}
|
|
* SegmentInfo = {path, sourceText, overrideText, enabled, shared}
|
|
*
|
|
* The shared base appears in BOTH lists under the SAME path
|
|
* ("system-prompt.md") — the prompt-editor's "what's constant between the
|
|
* two agents" is discoverable by path equality. Writes: the switches go
|
|
* through PUT /api/settings/agent; the TEXT goes through
|
|
* PUT/DELETE /api/settings/prompts/[...segment].
|
|
*/
|
|
|
|
import { effectivePromptSegments, readSettingsRecord } from "@/src/server";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET() {
|
|
const switches = readSettingsRecord()?.agent?.prompts ?? {};
|
|
return Response.json({
|
|
prober: effectivePromptSegments("prober", switches),
|
|
teacher: effectivePromptSegments("teacher", switches),
|
|
});
|
|
}
|