import { N as CliDoctor, Y as CliJsonValue, Z as CliDiagnostic, c as OpenSpecCliContractExecutor, j as CliContext, lt as CliExecutor, q as CliCommandResult, st as CliRootSource, t as CliRootSelector, tt as CliDoctorReferenceEntry, ut as CliResult } from "./index-CajHC-38.mjs"; import { z } from "zod"; //#region src/open-spec-data-scope.d.ts /** Directory name appended to the selected platform user-data root. */ declare const OPEN_SPEC_DATA_DIRECTORY_NAME = "openspec"; /** Provenance categories for the effective OpenSpec user-data root. */ type OpenSpecDataScopeSource = 'xdg-data-home' | 'local-app-data' | 'user-home-default'; /** Effective OpenSpec user-data root and its selection provenance. */ interface OpenSpecDataScope { /** Effective OpenSpec user-data root used by the inherited process environment. */ path: string; /** Objective provenance for the selected path. */ source: OpenSpecDataScopeSource; /** Environment variable that selected the path, or null for the home-directory fallback. */ environmentVariable: 'XDG_DATA_HOME' | 'LOCALAPPDATA' | null; } /** Optional process/platform inputs used to resolve OpenSpec data scope deterministically. */ interface ResolveOpenSpecDataScopeOptions { env?: NodeJS.ProcessEnv; platform?: NodeJS.Platform; homedir?: string; } /** Resolve the read-only data-scope diagnostic using OpenSpec 1.6's platform rules. */ declare function resolveOpenSpecDataScope(options?: ResolveOpenSpecDataScopeOptions): OpenSpecDataScope; //#endregion //#region src/root-context.d.ts /** OpenSpec CLI availability and runner provenance observed by Root Context resolution. */ interface RootContextCliAvailability { available: boolean; version?: string; error?: string; effectiveCommand?: string; tried?: string[]; } /** Minimal typed CLI surface required to resolve Root Context. */ interface RootContextCli { checkAvailability(timeout?: number): Promise; contracts: Pick; } /** Raw public evidence for one Root Context CLI command. */ interface RootContextCommandEvidence { success: boolean; /** Raw CLI JSON document, preserved byte-for-byte as process stdout. */ stdout: string; stderr: string; exitCode: number | null; diagnostics: CliDiagnostic[]; contractError?: string; } /** Complete launch-project, planning-root, Context, Reference, and data-scope projection. */ interface RootContext { launchProject: { /** Absolute launch-project path used as the CLI working directory. */ path: string; /** Canonical physical identity used only to compare Root topology. */ physicalPath?: string; }; /** CLI Doctor root projection. Null means root selection did not resolve. */ planningRoot: NonNullable | null; /** Effective Store identity when Doctor reports one. */ storeId: string | null; /** Opaque Server-owned planning-root generation, when resolved through a manager lease. */ generation?: string; cli: RootContextCliAvailability; /** Direct one-level Reference index from CLI Doctor. */ references: CliDoctorReferenceEntry[]; /** Direct Context members from `openspec context --json`. */ contextMembers: CliContext['members']; /** Read-only effective OpenSpec user-data root diagnostic. */ dataScope: OpenSpecDataScope; diagnostics: { root: CliDiagnostic[]; doctor: CliDiagnostic[]; context: CliDiagnostic[]; }; evidence: { doctor: RootContextCommandEvidence | null; context: RootContextCommandEvidence | null; }; observedAt: number; } /** Stable error categories emitted by Root Context resolution. */ type RootContextErrorCode = 'cli-unavailable' | 'doctor-command-failed' | 'doctor-contract-drift' | 'root-unresolved' | 'root-unhealthy' | 'context-command-failed' | 'context-contract-drift' | 'context-root-mismatch' | 'references-unresolved' | 'resolver-failed'; /** Root Context resolution failure with objective category and message. */ interface RootContextError { code: RootContextErrorCode; message: string; } /** Full subscription lifecycle for Root Context, including stale-data failure. */ type RootContextState = { state: 'loading'; data: null; attempt: null; error: null; observedAt: number; } | { state: 'ready'; data: RootContext; attempt: null; error: null; observedAt: number; } | { state: 'refreshing'; data: RootContext; attempt: null; error: null; observedAt: number; } | { state: 'error'; /** Last successful snapshot retained by a subscription, if one exists. */ data: RootContext | null; /** Current failed attempt with complete CLI evidence. */ attempt: RootContext; error: RootContextError; observedAt: number; }; /** Terminal ready/error result of one Root Context resolution attempt. */ type RootContextResolvedState = Extract; /** Derive the only CLI selector that preserves an already resolved Root Context. */ declare function getRootContextCliSelector(rootContext: RootContext): CliRootSelector; /** Inputs required to resolve one Root Context attempt. */ interface ResolveRootContextOptions extends ResolveOpenSpecDataScopeOptions { launchProjectDir: string; cliExecutor: RootContextCli; now?: () => number; } /** Resolve one current Root Context attempt from official CLI projections and process scope. */ declare function resolveRootContext(options: ResolveRootContextOptions): Promise; /** Concrete CliExecutor surface that satisfies Root Context resolution. */ type RootContextCliExecutor = Pick & { contracts: Pick; }; //#endregion //#region src/planning-config.d.ts /** Runtime schema for JSON values accepted by OpenSpec global configuration. */ declare const PlanningConfigJsonValueSchema: z.ZodType; /** Runtime schema for the complete environment-global OpenSpec configuration document. */ declare const EnvironmentGlobalConfigValueSchema: z.ZodRecord>; /** Runtime schema for setting or explicitly clearing the machine default Store id. */ declare const EnvironmentDefaultStoreUpdateSchema: z.ZodObject<{ value: z.ZodNullable; }, "strip", z.ZodTypeAny, { value: string | null; }, { value: string | null; }>; /** Validated mutation for the machine default Store id. */ type EnvironmentDefaultStoreUpdate = z.infer; /** Runtime schema for one project-declared Store Reference entry. */ declare const PlanningConfigReferenceSchema: z.ZodObject<{ id: z.ZodString; remote: z.ZodOptional; }, "strict", z.ZodTypeAny, { id: string; remote?: string | undefined; }, { id: string; remote?: string | undefined; }>; /** Normalized project-declared Store Reference entry. */ type PlanningConfigReference = z.infer; /** Runtime schema for project binding mutations. */ declare const ProjectBindingUpdateSchema: z.ZodEffects>; references: z.ZodOptional; }, "strict", z.ZodTypeAny, { id: string; remote?: string | undefined; }, { id: string; remote?: string | undefined; }>, "many">>>; }, "strip", z.ZodTypeAny, { store?: string | null | undefined; references?: { id: string; remote?: string | undefined; }[] | null | undefined; }, { store?: string | null | undefined; references?: { id: string; remote?: string | undefined; }[] | null | undefined; }>, { store?: string | null | undefined; references?: { id: string; remote?: string | undefined; }[] | null | undefined; }, { store?: string | null | undefined; references?: { id: string; remote?: string | undefined; }[] | null | undefined; }>; /** Validated project binding mutation. */ type ProjectBindingUpdate = z.infer; /** One configuration file and its current source content. */ interface PlanningConfigFile { path: string | null; format: 'yaml' | 'yml' | 'json'; exists: boolean; content: string | null; } /** Objective parse or ownership diagnostic for a configuration projection. */ interface PlanningConfigDiagnostic { code: 'config-unparseable' | 'config-not-mapping' | 'store-not-string' | 'references-not-array' | 'reference-entry-invalid'; message: string; } /** Project Store binding state without registry inference. */ type ProjectBindingStore = { state: 'absent'; id: null; } | { state: 'declared'; id: string; } | { state: 'invalid'; id: null; }; /** Project Reference declaration state and normalized entries. */ interface ProjectBindingReferences { state: 'absent' | 'declared' | 'invalid'; entries: PlanningConfigReference[]; } /** Read-only inspection of project binding source and diagnostics. */ interface ProjectBindingInspection { store: ProjectBindingStore; references: ProjectBindingReferences; diagnostics: PlanningConfigDiagnostic[]; } /** Writable project binding projection. */ interface ProjectBindingConfig { kind: 'project-binding'; owner: { kind: 'launch-project'; path: string; }; file: PlanningConfigFile; binding: ProjectBindingInspection; rootPreview: RootContextResolvedState; } /** Evidence that the launch project's binding file write completed. */ interface ProjectBindingLaunchWrite { state: 'write-complete'; owner: { kind: 'launch-project'; path: string; }; file: PlanningConfigFile; binding: ProjectBindingInspection; completedAt: number; } /** Typed preview/convergence evidence for the asynchronous Planning-root transition. */ type ProjectBindingTransition = { id: string; state: 'converging'; observedAt: number; } | { id: string; /** The detached preview failed; the Manager transition has not been declared failed. */ state: 'preview-error'; observedAt: number; error: RootContextError; }; /** * Public mutation result: the completed launch write carries one correlated detached preview outcome. * A ready preview can only converge; an error preview can only report preview-error. */ type ProjectBindingUpdateResult = { kind: 'project-binding-update'; launchWrite: ProjectBindingLaunchWrite; rootPreview: Extract; transition: Extract; } | { kind: 'project-binding-update'; launchWrite: ProjectBindingLaunchWrite; rootPreview: Extract; transition: Extract; }; /** CLI-owned profile and project-drift facts observed with environment-global config. */ interface EnvironmentGlobalProfileState { available: boolean; profile: 'core' | 'custom' | null; delivery: 'both' | 'skills' | 'commands' | null; workflows: string[]; driftStatus: 'in-sync' | 'drift' | 'unknown'; warningText: string | null; error?: string; } /** Authored machine default Store state without registry or effective-root inference. */ type EnvironmentDefaultStoreState = { state: 'absent'; id: null; } | { state: 'configured'; id: string; } | { state: 'invalid'; id: null; value: CliJsonValue; }; /** CLI-owned Environment Global path, parsed config, profile, drift, and command evidence. */ interface EnvironmentGlobalCliProjection { kind: 'environment-global'; owner: { kind: 'runtime-environment'; dataScope: OpenSpecDataScope; }; configPath: string | null; config: Record | null; defaultStore: EnvironmentDefaultStoreState; profileState: EnvironmentGlobalProfileState; evidence: { path: CliResult; config: CliCommandResult>; drift: CliResult; }; } /** File-native Environment Global document selected by the CLI projection. */ interface EnvironmentGlobalFileProjection { kind: 'environment-global-file'; owner: { kind: 'runtime-environment'; dataScope: OpenSpecDataScope; }; file: PlanningConfigFile; } /** Combined compatibility view for consumers that need CLI facts and editable file bytes. */ interface EnvironmentGlobalConfig extends Omit { kind: 'environment-global'; file: PlanningConfigFile; } /** Inspect only the authored machine fallback; Root Context remains the effective authority. */ declare function inspectEnvironmentDefaultStore(config: Record | null): EnvironmentDefaultStoreState; /** Inspect only launch-project binding declarations; Root Context remains the effective projection. */ declare function inspectProjectBinding(content: string | null): ProjectBindingInspection; /** Update only `store` and `references`, retaining all unrelated YAML nodes and comments. */ declare function updateProjectBindingContent(content: string | null, update: ProjectBindingUpdate): string; //#endregion //#region src/active-root-config-contract.d.ts /** OpenSpec 1.7 hard limit for project context encoded as UTF-8. */ declare const MAX_ACTIVE_ROOT_CONTEXT_BYTES: number; /** Runtime schema for the resilient official-field projection. */ declare const ActiveRootOfficialConfigSchema: z.ZodObject<{ schema: z.ZodNullable; context: z.ZodNullable>; rules: z.ZodNullable>>; operations: z.ZodNullable; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; archive: z.ZodOptional; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; }, "strict", z.ZodTypeAny, { apply?: { guidance: string[]; } | undefined; archive?: { guidance: string[]; } | undefined; }, { apply?: { guidance: string[]; } | undefined; archive?: { guidance: string[]; } | undefined; }>>; }, "strict", z.ZodTypeAny, { context: string | null; schema: string | null; rules: Record | null; operations: { apply?: { guidance: string[]; } | undefined; archive?: { guidance: string[]; } | undefined; } | null; }, { context: string | null; schema: string | null; rules: Record | null; operations: { apply?: { guidance: string[]; } | undefined; archive?: { guidance: string[]; } | undefined; } | null; }>; /** Official OpenSpec 1.7 fields projected independently from custom YAML nodes. */ type ActiveRootOfficialConfig = z.infer; /** Runtime schema for one complete Structured-mode update. */ declare const ActiveRootStructuredUpdateSchema: z.ZodObject<{ schema: z.ZodString; context: z.ZodNullable>; rules: z.ZodNullable>>; operations: z.ZodNullable; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; archive: z.ZodNullable; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; }, "strict", z.ZodTypeAny, { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; }, { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; }>>; }, "strict", z.ZodTypeAny, { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }, { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }>; /** Validated official-field replacement authored by Structured mode. */ type ActiveRootStructuredUpdate = z.infer; /** Opaque digest proving the exact Active Root owner, file, presence, and source bytes read by an editor. */ declare const ActiveRootRevisionSchema: z.ZodString; /** Opaque loaded revision token. */ type ActiveRootRevision = z.infer; /** Runtime schema for Structured or Raw mutation admission at one exact physical revision. */ declare const ActiveRootMutationSchema: z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{ mode: z.ZodLiteral<"structured">; update: z.ZodObject<{ schema: z.ZodString; context: z.ZodNullable>; rules: z.ZodNullable>>; operations: z.ZodNullable; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; archive: z.ZodNullable; }, "strict", z.ZodTypeAny, { guidance: string[]; }, { guidance: string[]; }>>; }, "strict", z.ZodTypeAny, { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; }, { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; }>>; }, "strict", z.ZodTypeAny, { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }, { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }>; ownerPath: z.ZodString; filePath: z.ZodString; revision: z.ZodString; }, "strict", z.ZodTypeAny, { revision: string; mode: "structured"; filePath: string; update: { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }; ownerPath: string; }, { revision: string; mode: "structured"; filePath: string; update: { context: string | null; schema: string; rules: Record | null; operations: { apply: { guidance: string[]; } | null; archive: { guidance: string[]; } | null; } | null; }; ownerPath: string; }>, z.ZodObject<{ mode: z.ZodLiteral<"raw">; content: z.ZodString; ownerPath: z.ZodString; filePath: z.ZodString; revision: z.ZodString; }, "strict", z.ZodTypeAny, { revision: string; mode: "raw"; content: string; filePath: string; ownerPath: string; }, { revision: string; mode: "raw"; content: string; filePath: string; ownerPath: string; }>]>; /** Revision-aware Active Root mutation request. */ type ActiveRootMutation = z.infer; /** Objective syntax or official-field diagnostic without claiming ownership of unknown YAML keys. */ interface ActiveRootConfigDiagnostic { code: 'config-unparseable' | 'config-not-mapping' | 'schema-missing' | 'schema-invalid' | 'context-invalid' | 'context-too-large' | 'rules-invalid' | 'rules-entry-invalid' | 'rules-entry-empty' | 'operations-invalid' | 'operation-invalid' | 'operation-guidance-invalid' | 'operation-guidance-empty'; severity: 'error' | 'warning'; path: string; message: string; } /** Resilient official projection plus diagnostics for fields the official CLI may ignore. */ interface ActiveRootConfigInspection { official: ActiveRootOfficialConfig; diagnostics: ActiveRootConfigDiagnostic[]; } /** Exact YAML file selected under the active writable Planning root. */ interface ActiveRootConfigFile extends Omit { path: string; format: 'yaml' | 'yml'; } /** Active Planning-root configuration, official projection, and CLI-owned root provenance. */ interface ActiveRootConfig extends ActiveRootConfigInspection { kind: 'active-root'; owner: { kind: 'planning-root'; path: string; source: CliRootSource; storeId: string | null; externalToLaunchProject: boolean; }; file: ActiveRootConfigFile; revision: ActiveRootRevision; } /** Structured or Raw mutation result with recoverable latest physical evidence. */ type ActiveRootMutationResult = { state: 'applied'; config: ActiveRootConfig; } | { state: 'conflict'; reason: 'owner-changed' | 'file-changed' | 'revision-changed'; latest: ActiveRootConfig; } | { state: 'invalid'; reason: 'raw-syntax' | 'structured-source'; diagnostics: ActiveRootConfigDiagnostic[]; latest: ActiveRootConfig; }; /** Raw YAML syntax validation performed before any physical mutation. */ interface ActiveRootRawValidation { valid: boolean; diagnostics: ActiveRootConfigDiagnostic[]; } //#endregion //#region src/active-root-config-yaml.d.ts /** Inspect official OpenSpec 1.7 Active Root fields independently and retain recoverable diagnostics. */ declare function inspectActiveRootOfficialConfig(content: string | null): ActiveRootConfigInspection; /** Validate Raw-mode YAML syntax while allowing any syntactically valid document shape and custom keys. */ declare function validateActiveRootRawYaml(content: string): ActiveRootRawValidation; /** Patch only Structured-owned official nodes and retain all representable unowned YAML evidence. */ declare function patchActiveRootOfficialFields(content: string | null, update: ActiveRootStructuredUpdate): string; //#endregion export { RootContextState as $, PlanningConfigReference as A, ProjectBindingUpdateSchema as B, EnvironmentGlobalConfig as C, PlanningConfigDiagnostic as D, EnvironmentGlobalProfileState as E, ProjectBindingReferences as F, RootContext as G, inspectProjectBinding as H, ProjectBindingStore as I, RootContextCliExecutor as J, RootContextCli as K, ProjectBindingTransition as L, ProjectBindingConfig as M, ProjectBindingInspection as N, PlanningConfigFile as O, ProjectBindingLaunchWrite as P, RootContextResolvedState as Q, ProjectBindingUpdate as R, EnvironmentGlobalCliProjection as S, EnvironmentGlobalFileProjection as T, updateProjectBindingContent as U, inspectEnvironmentDefaultStore as V, ResolveRootContextOptions as W, RootContextError as X, RootContextCommandEvidence as Y, RootContextErrorCode as Z, ActiveRootStructuredUpdateSchema as _, ActiveRootConfigDiagnostic as a, ResolveOpenSpecDataScopeOptions as at, EnvironmentDefaultStoreUpdate as b, ActiveRootMutation as c, ActiveRootOfficialConfig as d, getRootContextCliSelector as et, ActiveRootOfficialConfigSchema as f, ActiveRootStructuredUpdate as g, ActiveRootRevisionSchema as h, ActiveRootConfig as i, OpenSpecDataScopeSource as it, PlanningConfigReferenceSchema as j, PlanningConfigJsonValueSchema as k, ActiveRootMutationResult as l, ActiveRootRevision as m, patchActiveRootOfficialFields as n, OPEN_SPEC_DATA_DIRECTORY_NAME as nt, ActiveRootConfigFile as o, resolveOpenSpecDataScope as ot, ActiveRootRawValidation as p, RootContextCliAvailability as q, validateActiveRootRawYaml as r, OpenSpecDataScope as rt, ActiveRootConfigInspection as s, inspectActiveRootOfficialConfig as t, resolveRootContext as tt, ActiveRootMutationSchema as u, MAX_ACTIVE_ROOT_CONTEXT_BYTES as v, EnvironmentGlobalConfigValueSchema as w, EnvironmentDefaultStoreUpdateSchema as x, EnvironmentDefaultStoreState as y, ProjectBindingUpdateResult as z };