singularity-forge/src/headless-types.ts
Mikael Hugo a611cd5792 feat: introduce repo-vcs skill and add JSDoc annotations across core modules
- Add repository-vcs-context.ts to detect and inject VCS context (Git/Jujutsu)
  into the agent system prompt; wire in repo-vcs bundled skill trigger
- Add src/resources/skills/repo-vcs/ skill for commit, push, and safe-push workflows
- Add JSDoc Purpose/Consumer annotations to app-paths, bundled-extension-paths,
  errors, extension-discovery, extension-registry, headless-types, headless, and traces
- Add justfile and just to flake.nix devShell
- Fill out new-user-onboarding.md spec (Draft) and core-beliefs.md (Status: Accepted)
- Add notification-event-model.md design doc and notification-source-hygiene.md spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:36:32 +02:00

74 lines
2.3 KiB
TypeScript

/**
* headless-types.ts — shared types for the headless orchestrator surface.
*
* Purpose: provide a single source of truth for the structured result type
* emitted in --output-format json mode and the output format discriminator,
* so headless.ts, consumers, and tests agree on shape without circular deps.
*
* Consumer: headless.ts (orchestrator), external CI scripts parsing batch JSON.
*/
// ---------------------------------------------------------------------------
// Output Format
// ---------------------------------------------------------------------------
/**
* Discriminates the three headless output modes.
*
* Purpose: let callers declare how they want to receive session results
* (human-readable text, single JSON blob, or streaming JSONL) so the
* orchestrator can select the right serializer upfront.
*
* Consumer: parseHeadlessArgs in headless.ts when handling --output-format.
*/
export type OutputFormat = "text" | "json" | "stream-json";
/**
* Set of supported output-format string values.
*
* Purpose: guard against typos in CLI arguments and provide a fast
* membership test without repeating the literal list.
*
* Consumer: parseHeadlessArgs validation and unit tests.
*/
export const VALID_OUTPUT_FORMATS: ReadonlySet<string> = new Set([
"text",
"json",
"stream-json",
]);
// ---------------------------------------------------------------------------
// Structured JSON Result
// ---------------------------------------------------------------------------
/**
* Shape of the single JSON object written to stdout when --output-format json
* is used in batch (non-streaming) mode.
*
* Purpose: give non-interactive callers (CI pipelines, test harnesses,
* parent processes) a machine-readable contract for session outcome,
* cost, and metadata without scraping stderr.
*
* Consumer: emitBatchJsonResult in headless.ts; live-regression tests.
*/
export interface HeadlessJsonResult {
schemaVersion: 1;
status: "success" | "error" | "blocked" | "cancelled" | "timeout";
exitCode: number;
sessionId?: string;
duration: number;
cost: {
total: number;
input_tokens: number;
output_tokens: number;
cache_read_tokens: number;
cache_write_tokens: number;
};
toolCalls: number;
events: number;
milestone?: string;
phase?: string;
nextAction?: string;
artifacts?: string[];
commits?: string[];
}