UNPKG

framework

Version:

The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.

70 lines 2.53 kB
import { DEFAULT_HANDOFF } from './handoff-level.js'; import { BOOLEAN_CONFIG_KEYS, CONFIG_KEYS } from './config.js'; /** What a key resolves to when no layer set it. */ export const RUN_CONFIG_DEFAULTS = { vanilla: false, transparent: false, // `pr` by default (#1102): the zero-config handoff is what makes a session left alone hand // itself back. Merging is the rung above, because landing work on the default branch is not // reversible the way pushing a branch is (#1216). handoff: DEFAULT_HANDOFF, }; /** * The nearest layer that set `key`, or `undefined` when none did. Layers are ordered * nearest-first: run flags > project user > repo yml > global. */ export function resolveConfigKey(layers, key) { for (const layer of layers) { const value = layer.values[key]; if (value !== undefined) return { value: value, from: layer.name }; } return undefined; } /** Resolve every agent setting over `layers` (nearest first), falling back to {@link RUN_CONFIG_DEFAULTS}. */ export function resolveAgentConfig(layers) { const sources = {}; const pick = (key) => { const hit = resolveConfigKey(layers, key); if (!hit) return undefined; sources[key] = hit.from; return hit.value; }; const modes = {}; for (const key of BOOLEAN_CONFIG_KEYS) modes[key] = pick(key) ?? RUN_CONFIG_DEFAULTS[key]; return { ...modes, handoff: pick('handoff') ?? RUN_CONFIG_DEFAULTS.handoff, sources, }; } /** The repo tier: `the-framework.yml` as a layer. */ export function fileConfigLayer(file, name = 'the-framework.yml') { const values = {}; for (const key of CONFIG_KEYS) { if (file[key] !== undefined) Object.assign(values, { [key]: file[key] }); } return { name, values }; } /** * A one-line summary of what a layer set and which one won, e.g. * `vanilla=off (flag), handoff=local (the-framework.yml)`. Keys nobody set are * left out, so an agent with no config anywhere narrates nothing. */ export function describeResolvedConfig(config) { const shown = [ ...BOOLEAN_CONFIG_KEYS.map((key) => [key, onOff(config[key])]), ['handoff', config.handoff], ]; return shown .filter(([key]) => config.sources[key]) .map(([key, value]) => `${key}=${value} (${config.sources[key]})`) .join(', '); } function onOff(value) { return value ? 'on' : 'off'; } //# sourceMappingURL=config-layers.js.map