litcodex-ai 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/bin/litcodex.js +12 -0
  4. package/dist/cli.d.ts +23 -0
  5. package/dist/cli.js +183 -0
  6. package/dist/config-migration/backup.d.ts +2 -0
  7. package/dist/config-migration/backup.js +42 -0
  8. package/dist/config-migration/catalog.d.ts +22 -0
  9. package/dist/config-migration/catalog.js +99 -0
  10. package/dist/config-migration/cli.d.ts +14 -0
  11. package/dist/config-migration/cli.js +85 -0
  12. package/dist/config-migration/config-paths.d.ts +4 -0
  13. package/dist/config-migration/config-paths.js +64 -0
  14. package/dist/config-migration/errors.d.ts +11 -0
  15. package/dist/config-migration/errors.js +28 -0
  16. package/dist/config-migration/index.d.ts +44 -0
  17. package/dist/config-migration/index.js +210 -0
  18. package/dist/config-migration/multi-agent-v2-guard.d.ts +2 -0
  19. package/dist/config-migration/multi-agent-v2-guard.js +106 -0
  20. package/dist/config-migration/root-settings.d.ts +6 -0
  21. package/dist/config-migration/root-settings.js +104 -0
  22. package/dist/config-migration/state.d.ts +16 -0
  23. package/dist/config-migration/state.js +40 -0
  24. package/dist/config-migration/toml-shape.d.ts +8 -0
  25. package/dist/config-migration/toml-shape.js +107 -0
  26. package/dist/install/codex.d.ts +34 -0
  27. package/dist/install/codex.js +94 -0
  28. package/dist/install/doctor.d.ts +12 -0
  29. package/dist/install/doctor.js +83 -0
  30. package/dist/install/errors.d.ts +19 -0
  31. package/dist/install/errors.js +43 -0
  32. package/dist/install/execute.d.ts +39 -0
  33. package/dist/install/execute.js +193 -0
  34. package/dist/install/index.d.ts +19 -0
  35. package/dist/install/index.js +193 -0
  36. package/dist/install/marketplace.d.ts +5 -0
  37. package/dist/install/marketplace.js +10 -0
  38. package/dist/install/plan.d.ts +3 -0
  39. package/dist/install/plan.js +54 -0
  40. package/dist/install/render-plan.d.ts +3 -0
  41. package/dist/install/render-plan.js +10 -0
  42. package/dist/install/types.d.ts +45 -0
  43. package/dist/install/types.js +5 -0
  44. package/model-catalog.json +31 -0
  45. package/node_modules/@litcodex/lit-loop/CHANGELOG.md +19 -0
  46. package/node_modules/@litcodex/lit-loop/LICENSE +21 -0
  47. package/node_modules/@litcodex/lit-loop/NOTICE +8 -0
  48. package/node_modules/@litcodex/lit-loop/README.md +37 -0
  49. package/node_modules/@litcodex/lit-loop/agents/litcodex-explorer.toml +75 -0
  50. package/node_modules/@litcodex/lit-loop/agents/litcodex-librarian.toml +98 -0
  51. package/node_modules/@litcodex/lit-loop/agents/litcodex-litwork-reviewer.toml +21 -0
  52. package/node_modules/@litcodex/lit-loop/agents/litcodex-metis.toml +64 -0
  53. package/node_modules/@litcodex/lit-loop/agents/litcodex-momus.toml +68 -0
  54. package/node_modules/@litcodex/lit-loop/agents/litcodex-plan.toml +163 -0
  55. package/node_modules/@litcodex/lit-loop/directive.md +85 -0
  56. package/node_modules/@litcodex/lit-loop/directives/lit-plan.md +286 -0
  57. package/node_modules/@litcodex/lit-loop/directives/litgoal.md +103 -0
  58. package/node_modules/@litcodex/lit-loop/directives/litwork.md +363 -0
  59. package/node_modules/@litcodex/lit-loop/dist/_scaffold.d.ts +1 -0
  60. package/node_modules/@litcodex/lit-loop/dist/_scaffold.js +3 -0
  61. package/node_modules/@litcodex/lit-loop/dist/cli.d.ts +6 -0
  62. package/node_modules/@litcodex/lit-loop/dist/cli.js +44 -0
  63. package/node_modules/@litcodex/lit-loop/dist/codex-goal-instruction.d.ts +18 -0
  64. package/node_modules/@litcodex/lit-loop/dist/codex-goal-instruction.js +94 -0
  65. package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +38 -0
  66. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +126 -0
  67. package/node_modules/@litcodex/lit-loop/dist/directive.d.ts +35 -0
  68. package/node_modules/@litcodex/lit-loop/dist/directive.js +80 -0
  69. package/node_modules/@litcodex/lit-loop/dist/goal-status.d.ts +12 -0
  70. package/node_modules/@litcodex/lit-loop/dist/goal-status.js +25 -0
  71. package/node_modules/@litcodex/lit-loop/dist/guards.d.ts +73 -0
  72. package/node_modules/@litcodex/lit-loop/dist/guards.js +215 -0
  73. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +17 -0
  74. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +94 -0
  75. package/node_modules/@litcodex/lit-loop/dist/loop-cli.d.ts +19 -0
  76. package/node_modules/@litcodex/lit-loop/dist/loop-cli.js +106 -0
  77. package/node_modules/@litcodex/lit-loop/dist/loop-doctor-render.d.ts +7 -0
  78. package/node_modules/@litcodex/lit-loop/dist/loop-doctor-render.js +39 -0
  79. package/node_modules/@litcodex/lit-loop/dist/loop-doctor-types.d.ts +52 -0
  80. package/node_modules/@litcodex/lit-loop/dist/loop-doctor-types.js +7 -0
  81. package/node_modules/@litcodex/lit-loop/dist/loop-doctor.d.ts +21 -0
  82. package/node_modules/@litcodex/lit-loop/dist/loop-doctor.js +283 -0
  83. package/node_modules/@litcodex/lit-loop/dist/loop-errors.d.ts +15 -0
  84. package/node_modules/@litcodex/lit-loop/dist/loop-errors.js +43 -0
  85. package/node_modules/@litcodex/lit-loop/dist/loop-handlers.d.ts +18 -0
  86. package/node_modules/@litcodex/lit-loop/dist/loop-handlers.js +311 -0
  87. package/node_modules/@litcodex/lit-loop/dist/loop-model.d.ts +51 -0
  88. package/node_modules/@litcodex/lit-loop/dist/loop-model.js +165 -0
  89. package/node_modules/@litcodex/lit-loop/dist/loop-stdout.d.ts +6 -0
  90. package/node_modules/@litcodex/lit-loop/dist/loop-stdout.js +11 -0
  91. package/node_modules/@litcodex/lit-loop/dist/loop-types.d.ts +26 -0
  92. package/node_modules/@litcodex/lit-loop/dist/loop-types.js +8 -0
  93. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +9 -0
  94. package/node_modules/@litcodex/lit-loop/dist/markers.js +14 -0
  95. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +15 -0
  96. package/node_modules/@litcodex/lit-loop/dist/modes.js +56 -0
  97. package/node_modules/@litcodex/lit-loop/dist/state-paths.d.ts +41 -0
  98. package/node_modules/@litcodex/lit-loop/dist/state-paths.js +111 -0
  99. package/node_modules/@litcodex/lit-loop/dist/state-store.d.ts +39 -0
  100. package/node_modules/@litcodex/lit-loop/dist/state-store.js +419 -0
  101. package/node_modules/@litcodex/lit-loop/dist/state-types.d.ts +90 -0
  102. package/node_modules/@litcodex/lit-loop/dist/state-types.js +61 -0
  103. package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +54 -0
  104. package/node_modules/@litcodex/lit-loop/dist/trigger.js +75 -0
  105. package/node_modules/@litcodex/lit-loop/package.json +27 -0
  106. package/package.json +30 -0
@@ -0,0 +1,14 @@
1
+ // Single source of the lit-family directive markers (A3 C1).
2
+ // Zero-dependency on purpose: guards.ts, directive.ts, and modes.ts import (and
3
+ // re-export) from here so the dedupe markers can never drift between them
4
+ // while preserving the no-cycle invariant (guards never imports directive).
5
+ export const LIT_LOOP_DIRECTIVE_MARKER = "<lit-loop-mode>";
6
+ export const LIT_LOOP_DIRECTIVE_CLOSE = "</lit-loop-mode>";
7
+ // lit-family modes (multi-mode hook router): each mode owns its open/close marker pair so the
8
+ // per-mode idempotency guard (RC1) scans the transcript for the MATCHED mode's marker only.
9
+ export const LITWORK_DIRECTIVE_MARKER = "<litwork-mode>";
10
+ export const LITWORK_DIRECTIVE_CLOSE = "</litwork-mode>";
11
+ export const LIT_PLAN_DIRECTIVE_MARKER = "<lit-plan-mode>";
12
+ export const LIT_PLAN_DIRECTIVE_CLOSE = "</lit-plan-mode>";
13
+ export const LITGOAL_DIRECTIVE_MARKER = "<litgoal-mode>";
14
+ export const LITGOAL_DIRECTIVE_CLOSE = "</litgoal-mode>";
@@ -0,0 +1,15 @@
1
+ import type { LitTriggerToken } from "./trigger.js";
2
+ /** The four lit-family modes. Multiple tokens may map to one mode (lit/litcodex/lit-loop → lit-loop). */
3
+ export type LitMode = "lit-loop" | "litwork" | "lit-plan" | "litgoal";
4
+ /** Per-mode routing spec: its marker pair (guard) + resolved directive path (loader). */
5
+ export interface LitModeSpec {
6
+ readonly mode: LitMode;
7
+ readonly openMarker: string;
8
+ readonly closeMarker: string;
9
+ /** Absolute path to the mode's directive.md, resolved from this module. */
10
+ readonly directivePath: string;
11
+ }
12
+ /** Token → mode spec. Frozen; the single source the hook router branches on. */
13
+ export declare const MODE_BY_TOKEN: Readonly<Record<LitTriggerToken, LitModeSpec>>;
14
+ /** The mode spec for a matched token. Total over the token union (every token has a spec). */
15
+ export declare function modeForToken(token: LitTriggerToken): LitModeSpec;
@@ -0,0 +1,56 @@
1
+ // src/modes.ts — multi-mode hook router table (RC1/RC2).
2
+ //
3
+ // Maps each bounded trigger token (trigger.ts) to its mode spec: the open/close directive markers
4
+ // (for the per-mode idempotency guard, RC1) and the absolute directive path (for the generic loader,
5
+ // RC2). The three lit-loop-family tokens (lit-loop / litcodex / lit) share the single lit-loop mode;
6
+ // litwork / lit-plan / litgoal each own a distinct mode + directive.
7
+ //
8
+ // Layout decision (SDD RC4): lit-loop keeps the authored `directive.md` at the COMPONENT ROOT (zero
9
+ // churn to its lockstep points); the three new directives live under `directives/<mode>.md`. Paths
10
+ // resolve relative to THIS module so they land correctly from both layouts (src/modes.ts →
11
+ // <component>/… in dev/vitest; dist/modes.js → <pkg>/… in the published tarball, where files[] ships
12
+ // `directive.md` and the `directives/` dir beside dist/). Path resolution never reads the file; the
13
+ // loader reads lazily + fail-silent, so a not-yet-authored directive simply degrades to a noop.
14
+ //
15
+ // Imports markers + the trigger token type only (no cycle: hook → modes → {markers, trigger}).
16
+ import { fileURLToPath } from "node:url";
17
+ import { LIT_LOOP_DIRECTIVE_CLOSE, LIT_LOOP_DIRECTIVE_MARKER, LIT_PLAN_DIRECTIVE_CLOSE, LIT_PLAN_DIRECTIVE_MARKER, LITGOAL_DIRECTIVE_CLOSE, LITGOAL_DIRECTIVE_MARKER, LITWORK_DIRECTIVE_CLOSE, LITWORK_DIRECTIVE_MARKER, } from "./markers.js";
18
+ /** Resolve a path relative to this module (percent-decoding, space/#/Hangul-safe). */
19
+ function resolveFromHere(rel) {
20
+ return fileURLToPath(new URL(rel, import.meta.url));
21
+ }
22
+ // lit-loop keeps the component-root directive.md (A3 G6); shared by lit / litcodex / lit-loop tokens.
23
+ const LIT_LOOP_SPEC = Object.freeze({
24
+ mode: "lit-loop",
25
+ openMarker: LIT_LOOP_DIRECTIVE_MARKER,
26
+ closeMarker: LIT_LOOP_DIRECTIVE_CLOSE,
27
+ directivePath: resolveFromHere("../directive.md"),
28
+ });
29
+ /** Token → mode spec. Frozen; the single source the hook router branches on. */
30
+ export const MODE_BY_TOKEN = Object.freeze({
31
+ "lit-loop": LIT_LOOP_SPEC,
32
+ litcodex: LIT_LOOP_SPEC,
33
+ lit: LIT_LOOP_SPEC,
34
+ litwork: Object.freeze({
35
+ mode: "litwork",
36
+ openMarker: LITWORK_DIRECTIVE_MARKER,
37
+ closeMarker: LITWORK_DIRECTIVE_CLOSE,
38
+ directivePath: resolveFromHere("../directives/litwork.md"),
39
+ }),
40
+ "lit-plan": Object.freeze({
41
+ mode: "lit-plan",
42
+ openMarker: LIT_PLAN_DIRECTIVE_MARKER,
43
+ closeMarker: LIT_PLAN_DIRECTIVE_CLOSE,
44
+ directivePath: resolveFromHere("../directives/lit-plan.md"),
45
+ }),
46
+ litgoal: Object.freeze({
47
+ mode: "litgoal",
48
+ openMarker: LITGOAL_DIRECTIVE_MARKER,
49
+ closeMarker: LITGOAL_DIRECTIVE_CLOSE,
50
+ directivePath: resolveFromHere("../directives/litgoal.md"),
51
+ }),
52
+ });
53
+ /** The mode spec for a matched token. Total over the token union (every token has a spec). */
54
+ export function modeForToken(token) {
55
+ return MODE_BY_TOKEN[token];
56
+ }
@@ -0,0 +1,41 @@
1
+ export declare const LIT_LOOP_DIR = ".litcodex/lit-loop";
2
+ export declare const LIT_LOOP_BRIEF = "brief.md";
3
+ export declare const LIT_LOOP_GOALS = "goals.json";
4
+ export declare const LIT_LOOP_LEDGER = "ledger.jsonl";
5
+ export declare const LIT_LOOP_EVIDENCE = "evidence";
6
+ /** Optional session partition. Absent / null ⇒ the unscoped root dir. */
7
+ export interface LitLoopScope {
8
+ readonly sessionId?: string | null;
9
+ }
10
+ /**
11
+ * Sanitize an arbitrary session id into a single safe path segment, OR null.
12
+ * Splits on `/` and `\`, drops "", ".", ".." segments, joins survivors with "-", whitelists
13
+ * `[A-Za-z0-9._-]` (everything else → "-"), collapses repeats, strips leading dots and
14
+ * leading/trailing `[.-]`. Provably contains no "/", "\", or ".." and is never "."/""/null-unsafe.
15
+ */
16
+ export declare function normalizeSessionId(sessionId: string | null | undefined): string | null;
17
+ /** Relative dir: `.litcodex/lit-loop` or `.litcodex/lit-loop/<normalizedSessionId>`. */
18
+ export declare function litLoopRelativeDir(scope?: LitLoopScope): string;
19
+ /** Absolute scope dir. repoRoot MUST be absolute. */
20
+ export declare function litLoopDir(repoRoot: string, scope?: LitLoopScope): string;
21
+ export declare function litLoopBriefPath(repoRoot: string, scope?: LitLoopScope): string;
22
+ export declare function litLoopGoalsPath(repoRoot: string, scope?: LitLoopScope): string;
23
+ export declare function litLoopLedgerPath(repoRoot: string, scope?: LitLoopScope): string;
24
+ export declare function litLoopEvidenceDir(repoRoot: string, scope?: LitLoopScope): string;
25
+ /**
26
+ * Resolve an evidence file path under the scope's evidence/ dir. Rejects an escaping `name`
27
+ * (contains "/", "\", "..", or is ""/".") with LIT_LOOP_EVIDENCE_NAME_UNSAFE BEFORE any fs op.
28
+ */
29
+ export declare function evidencePath(repoRoot: string, name: string, scope?: LitLoopScope): string;
30
+ /** repoRoot-relative, forward-slash form of an absolute path (for messages / plan fields). */
31
+ export declare function repoRelative(absolutePath: string, repoRoot: string): string;
32
+ /**
33
+ * Resolve a LitLoopScope from argv/env. Precedence (first non-blank wins): `--session <id>` /
34
+ * `--session=<id>` → env `LITCODEX_LOOP_SESSION` → env `LIT_LOOP_SESSION`. The chosen raw id is
35
+ * normalized; returns `{ sessionId }` when a non-null id results, else `undefined`. Pure aside
36
+ * from reading the provided `env` object (NEVER `process.env`); zero I/O.
37
+ */
38
+ export declare function resolveLoopScope(source: {
39
+ argv?: readonly string[];
40
+ env?: Record<string, string | undefined>;
41
+ }): LitLoopScope | undefined;
@@ -0,0 +1,111 @@
1
+ // src/state-paths.ts — M08/T13 pure path algebra (A3 C9 flat layout, Part D constants).
2
+ //
3
+ // The literal runtime-layout name constants, the LitLoopScope type, the path-traversal-safe
4
+ // session-id normalizer, every absolute/relative path builder, the evidence-name escape guard,
5
+ // the repo-relative formatter, and the CLI/hook scope resolver. ZERO I/O — pure, deterministic.
6
+ // The state root is LITERALLY `.litcodex/lit-loop` and is NEVER the legacy runtime dir, never absolute here.
7
+ import { isAbsolute, join, relative, sep } from "node:path";
8
+ import { LitLoopStateError } from "./state-types.js";
9
+ // ── Name constants (A3 Part D) ───────────────────────────────────────────────
10
+ export const LIT_LOOP_DIR = ".litcodex/lit-loop";
11
+ export const LIT_LOOP_BRIEF = "brief.md";
12
+ export const LIT_LOOP_GOALS = "goals.json";
13
+ export const LIT_LOOP_LEDGER = "ledger.jsonl";
14
+ export const LIT_LOOP_EVIDENCE = "evidence";
15
+ // ── Session-id normalization (path-traversal guard) ──────────────────────────
16
+ /**
17
+ * Sanitize an arbitrary session id into a single safe path segment, OR null.
18
+ * Splits on `/` and `\`, drops "", ".", ".." segments, joins survivors with "-", whitelists
19
+ * `[A-Za-z0-9._-]` (everything else → "-"), collapses repeats, strips leading dots and
20
+ * leading/trailing `[.-]`. Provably contains no "/", "\", or ".." and is never "."/""/null-unsafe.
21
+ */
22
+ export function normalizeSessionId(sessionId) {
23
+ const trimmed = sessionId?.trim();
24
+ if (!trimmed) {
25
+ return null;
26
+ }
27
+ const survivors = trimmed.split(/[\\/]+/).filter((seg) => seg !== "" && seg !== "." && seg !== "..");
28
+ const joined = survivors.length > 0 ? survivors.join("-") : trimmed;
29
+ const cleaned = joined
30
+ .replace(/[^A-Za-z0-9._-]+/g, "-")
31
+ .replace(/-+/g, "-")
32
+ .replace(/^\.+/, "")
33
+ .replace(/^[.-]+/, "")
34
+ .replace(/[.-]+$/, "");
35
+ return cleaned.length > 0 ? cleaned : null;
36
+ }
37
+ // ── repoRoot guard ───────────────────────────────────────────────────────────
38
+ function assertAbsoluteRepoRoot(repoRoot) {
39
+ if (typeof repoRoot !== "string" || !isAbsolute(repoRoot)) {
40
+ throw new LitLoopStateError(`repoRoot must be an absolute path (got ${JSON.stringify(repoRoot)})`, "LIT_LOOP_REPO_ROOT_INVALID", { details: { repoRoot } });
41
+ }
42
+ }
43
+ // ── Path builders (pure) ─────────────────────────────────────────────────────
44
+ /** Relative dir: `.litcodex/lit-loop` or `.litcodex/lit-loop/<normalizedSessionId>`. */
45
+ export function litLoopRelativeDir(scope) {
46
+ const id = normalizeSessionId(scope?.sessionId);
47
+ return id === null ? LIT_LOOP_DIR : `${LIT_LOOP_DIR}/${id}`;
48
+ }
49
+ /** Absolute scope dir. repoRoot MUST be absolute. */
50
+ export function litLoopDir(repoRoot, scope) {
51
+ assertAbsoluteRepoRoot(repoRoot);
52
+ return join(repoRoot, litLoopRelativeDir(scope));
53
+ }
54
+ export function litLoopBriefPath(repoRoot, scope) {
55
+ return join(litLoopDir(repoRoot, scope), LIT_LOOP_BRIEF);
56
+ }
57
+ export function litLoopGoalsPath(repoRoot, scope) {
58
+ return join(litLoopDir(repoRoot, scope), LIT_LOOP_GOALS);
59
+ }
60
+ export function litLoopLedgerPath(repoRoot, scope) {
61
+ return join(litLoopDir(repoRoot, scope), LIT_LOOP_LEDGER);
62
+ }
63
+ export function litLoopEvidenceDir(repoRoot, scope) {
64
+ return join(litLoopDir(repoRoot, scope), LIT_LOOP_EVIDENCE);
65
+ }
66
+ /**
67
+ * Resolve an evidence file path under the scope's evidence/ dir. Rejects an escaping `name`
68
+ * (contains "/", "\", "..", or is ""/".") with LIT_LOOP_EVIDENCE_NAME_UNSAFE BEFORE any fs op.
69
+ */
70
+ export function evidencePath(repoRoot, name, scope) {
71
+ if (typeof name !== "string" ||
72
+ name === "" ||
73
+ name === "." ||
74
+ name.includes("/") ||
75
+ name.includes("\\") ||
76
+ name.includes("..")) {
77
+ throw new LitLoopStateError(`evidence name escapes the evidence dir: ${JSON.stringify(name)}`, "LIT_LOOP_EVIDENCE_NAME_UNSAFE", { details: { name } });
78
+ }
79
+ return join(litLoopEvidenceDir(repoRoot, scope), name);
80
+ }
81
+ /** repoRoot-relative, forward-slash form of an absolute path (for messages / plan fields). */
82
+ export function repoRelative(absolutePath, repoRoot) {
83
+ const rel = relative(repoRoot, absolutePath);
84
+ return sep === "\\" ? rel.split(sep).join("/") : rel;
85
+ }
86
+ // ── Scope resolver (CLI/hook callers) ────────────────────────────────────────
87
+ function readSessionFlag(argv) {
88
+ for (let i = 0; i < argv.length; i++) {
89
+ const arg = argv[i];
90
+ if (arg === "--session") {
91
+ return argv[i + 1];
92
+ }
93
+ if (arg?.startsWith("--session=")) {
94
+ return arg.slice("--session=".length);
95
+ }
96
+ }
97
+ return undefined;
98
+ }
99
+ /**
100
+ * Resolve a LitLoopScope from argv/env. Precedence (first non-blank wins): `--session <id>` /
101
+ * `--session=<id>` → env `LITCODEX_LOOP_SESSION` → env `LIT_LOOP_SESSION`. The chosen raw id is
102
+ * normalized; returns `{ sessionId }` when a non-null id results, else `undefined`. Pure aside
103
+ * from reading the provided `env` object (NEVER `process.env`); zero I/O.
104
+ */
105
+ export function resolveLoopScope(source) {
106
+ const argv = source.argv ?? [];
107
+ const env = source.env ?? {};
108
+ const raw = readSessionFlag(argv) ?? env["LITCODEX_LOOP_SESSION"] ?? env["LIT_LOOP_SESSION"];
109
+ const sessionId = normalizeSessionId(raw);
110
+ return sessionId === null ? undefined : { sessionId };
111
+ }
@@ -0,0 +1,39 @@
1
+ import { type LitLoopScope } from "./state-paths.js";
2
+ import { type LitLoopLedgerEntry, type LitLoopLedgerInput, type LitLoopPlan } from "./state-types.js";
3
+ export { evidencePath, resolveLoopScope } from "./state-paths.js";
4
+ /** Alias of `litLoopDir` under the name M09 (loop model) and M11 (doctor) import. */
5
+ export declare function resolveLoopStateDir(repoRoot: string, scope?: LitLoopScope): string;
6
+ export declare function statExists(absPath: string): Promise<boolean>;
7
+ export declare class BriefFileMissingError extends Error {
8
+ readonly name = "BriefFileMissingError";
9
+ readonly path: string;
10
+ constructor(path: string, cause?: unknown);
11
+ }
12
+ export declare class BriefFileUnreadableError extends Error {
13
+ readonly name = "BriefFileUnreadableError";
14
+ readonly path: string;
15
+ constructor(path: string, cause?: unknown);
16
+ }
17
+ /**
18
+ * Read `briefFilePath` as INERT UTF-8 text. The path is used AS GIVEN — no normalization, no
19
+ * re-rooting against `repoRoot`, no rejection (the bytes are data, never re-interpreted as a
20
+ * path/flag). ENOENT/EISDIR → BriefFileMissingError; EACCES/EIO → BriefFileUnreadableError.
21
+ */
22
+ export declare function readBriefFile(_repoRoot: string, briefFilePath: string): Promise<string>;
23
+ export declare function withMutationLock<T>(repoRoot: string, scope: LitLoopScope | undefined, body: () => Promise<T>): Promise<T>;
24
+ /** @deprecated Alias of `withMutationLock` (SAME function reference, same lock map). */
25
+ export declare const withStateMutationLock: typeof withMutationLock;
26
+ export declare function writePlan(repoRoot: string, plan: LitLoopPlan, scope?: LitLoopScope): Promise<void>;
27
+ export declare function writeBrief(repoRoot: string, brief: string, scope?: LitLoopScope): Promise<void>;
28
+ export declare function appendLedger(repoRoot: string, entry: LitLoopLedgerInput, scope?: LitLoopScope): Promise<void>;
29
+ export declare function readLedger(repoRoot: string, scope?: LitLoopScope): Promise<{
30
+ entries: LitLoopLedgerEntry[];
31
+ skipped: number;
32
+ }>;
33
+ export declare function ensureEvidenceDir(repoRoot: string, scope?: LitLoopScope): Promise<string>;
34
+ export declare function readPlan(repoRoot: string, scope?: LitLoopScope): Promise<LitLoopPlan>;
35
+ export declare function initState(repoRoot: string, args: {
36
+ brief: string;
37
+ sessionId?: string | null;
38
+ }): Promise<LitLoopPlan>;
39
+ export declare function exitCodeFor(err: unknown): number;