@turri-dev/cli 0.1.6 → 0.1.7-next.9aec40e

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 (140) hide show
  1. package/dist/ask.d.ts +83 -0
  2. package/dist/brand.d.ts +13 -0
  3. package/dist/btw.d.ts +67 -0
  4. package/dist/chat-models.d.ts +22 -0
  5. package/dist/chat-skills.d.ts +17 -0
  6. package/dist/cli-options.d.ts +25 -0
  7. package/dist/cli.d.ts +9 -0
  8. package/dist/config-command.d.ts +26 -0
  9. package/dist/config-edit.d.ts +69 -0
  10. package/dist/config.d.ts +321 -0
  11. package/dist/conform-cli.d.ts +1 -0
  12. package/dist/cultivate-cli.d.ts +1 -0
  13. package/dist/drift-cli.d.ts +1 -0
  14. package/dist/environment.d.ts +39 -0
  15. package/dist/extension.d.ts +147 -0
  16. package/dist/extension.js +36 -10
  17. package/dist/genome.d.ts +62 -0
  18. package/dist/graph.d.ts +52 -0
  19. package/dist/host.d.ts +20 -0
  20. package/dist/host.js +23 -0
  21. package/dist/identity.d.ts +2 -0
  22. package/dist/init-config.d.ts +106 -0
  23. package/dist/jellyfish.d.ts +25 -0
  24. package/dist/judge.d.ts +25 -0
  25. package/dist/lineage-cli.d.ts +1 -0
  26. package/dist/loop-cli.d.ts +34 -0
  27. package/dist/loop-tools.d.ts +80 -0
  28. package/dist/mature-tools.d.ts +53 -0
  29. package/dist/model-check.d.ts +42 -0
  30. package/dist/module-report.d.ts +9 -0
  31. package/dist/pi-launch.d.ts +1 -0
  32. package/dist/pi.d.ts +246 -0
  33. package/dist/picture-row.d.ts +10 -0
  34. package/dist/plain/check.d.ts +23 -0
  35. package/dist/plain/concepts.d.ts +11 -0
  36. package/dist/plain/errors.d.ts +22 -0
  37. package/dist/plain/files.d.ts +12 -0
  38. package/dist/plain/highlight.d.ts +42 -0
  39. package/dist/plain/index.d.ts +15 -0
  40. package/dist/plain/liquid.d.ts +22 -0
  41. package/dist/plain/markdown.d.ts +74 -0
  42. package/dist/plain/parser.d.ts +87 -0
  43. package/dist/plain/spec.d.ts +90 -0
  44. package/dist/plain/stdlib.d.ts +14 -0
  45. package/dist/question-dialog.d.ts +51 -0
  46. package/dist/questioning.d.ts +55 -0
  47. package/dist/quiet.d.ts +34 -0
  48. package/dist/regenerate/activity.d.ts +207 -0
  49. package/dist/regenerate/agent-env.d.ts +44 -0
  50. package/dist/regenerate/agent-shell.d.ts +49 -0
  51. package/dist/regenerate/arbiter.d.ts +68 -0
  52. package/dist/regenerate/audit.d.ts +69 -0
  53. package/dist/regenerate/cases.d.ts +9 -0
  54. package/dist/regenerate/change-view.d.ts +18 -0
  55. package/dist/regenerate/choose-conformance.d.ts +32 -0
  56. package/dist/regenerate/chunk-plan.d.ts +164 -0
  57. package/dist/regenerate/codebase.d.ts +21 -0
  58. package/dist/regenerate/command-check.d.ts +40 -0
  59. package/dist/regenerate/compaction.d.ts +13 -0
  60. package/dist/regenerate/confine.d.ts +62 -0
  61. package/dist/regenerate/conform.d.ts +63 -0
  62. package/dist/regenerate/conformance-agents.d.ts +405 -0
  63. package/dist/regenerate/conformance.d.ts +189 -0
  64. package/dist/regenerate/conversation-writes.d.ts +10 -0
  65. package/dist/regenerate/credentials.d.ts +18 -0
  66. package/dist/regenerate/debug-log.d.ts +54 -0
  67. package/dist/regenerate/debugger.d.ts +31 -0
  68. package/dist/regenerate/delivery.d.ts +6 -0
  69. package/dist/regenerate/diagnose-job.d.ts +2 -0
  70. package/dist/regenerate/diagnose.d.ts +46 -0
  71. package/dist/regenerate/diff-view.d.ts +61 -0
  72. package/dist/regenerate/drift.d.ts +84 -0
  73. package/dist/regenerate/engine.d.ts +52 -0
  74. package/dist/regenerate/environment-error.d.ts +136 -0
  75. package/dist/regenerate/job-log.d.ts +28 -0
  76. package/dist/regenerate/job-panel.d.ts +122 -0
  77. package/dist/regenerate/jobs-tree.d.ts +71 -0
  78. package/dist/regenerate/jobs.d.ts +186 -0
  79. package/dist/regenerate/lanes.d.ts +16 -0
  80. package/dist/regenerate/lineage.d.ts +95 -0
  81. package/dist/regenerate/list-arguments.d.ts +21 -0
  82. package/dist/regenerate/loop.d.ts +392 -0
  83. package/dist/regenerate/masking.d.ts +19 -0
  84. package/dist/regenerate/notes.d.ts +159 -0
  85. package/dist/regenerate/os-sandbox.d.ts +89 -0
  86. package/dist/regenerate/panel-dock.d.ts +23 -0
  87. package/dist/regenerate/paths.d.ts +92 -0
  88. package/dist/regenerate/plain-palette.d.ts +34 -0
  89. package/dist/regenerate/prompt.d.ts +192 -0
  90. package/dist/regenerate/records.d.ts +88 -0
  91. package/dist/regenerate/regenerate.d.ts +108 -0
  92. package/dist/regenerate/regression.d.ts +58 -0
  93. package/dist/regenerate/release.d.ts +123 -0
  94. package/dist/regenerate/requires.d.ts +96 -0
  95. package/dist/regenerate/resources.d.ts +53 -0
  96. package/dist/regenerate/self-check.d.ts +29 -0
  97. package/dist/regenerate/services.d.ts +28 -0
  98. package/dist/regenerate/shell.d.ts +91 -0
  99. package/dist/regenerate/side-panel.d.ts +57 -0
  100. package/dist/regenerate/spec-map-view.d.ts +139 -0
  101. package/dist/regenerate/spec-map.d.ts +138 -0
  102. package/dist/regenerate/spec-steps.d.ts +137 -0
  103. package/dist/regenerate/state.d.ts +20 -0
  104. package/dist/regenerate/steer.d.ts +34 -0
  105. package/dist/regenerate/steering.d.ts +56 -0
  106. package/dist/regenerate/stop-report.d.ts +43 -0
  107. package/dist/regenerate/submit-work.d.ts +42 -0
  108. package/dist/regenerate/test-kinds.d.ts +42 -0
  109. package/dist/regenerate/test-scripts.d.ts +221 -0
  110. package/dist/regenerate/testing.d.ts +141 -0
  111. package/dist/regenerate/transcript-view.d.ts +21 -0
  112. package/dist/regenerate/unit-gate.d.ts +27 -0
  113. package/dist/regenerate/unit-review.d.ts +152 -0
  114. package/dist/regenerate/web.d.ts +61 -0
  115. package/dist/regenerate/workspace.d.ts +12 -0
  116. package/dist/regenerate-cli.d.ts +1 -0
  117. package/dist/release-agent.d.ts +26 -0
  118. package/dist/release-cli.d.ts +1 -0
  119. package/dist/release-tools.d.ts +38 -0
  120. package/dist/resume-line.d.ts +2 -0
  121. package/dist/review/live.d.ts +72 -0
  122. package/dist/rules.d.ts +20 -0
  123. package/dist/run-report.d.ts +88 -0
  124. package/dist/screen-padding.d.ts +28 -0
  125. package/dist/self-invocation.d.ts +25 -0
  126. package/dist/setup.d.ts +43 -0
  127. package/dist/skill-progress.d.ts +46 -0
  128. package/dist/skill.d.ts +98 -0
  129. package/dist/skills.d.ts +30 -0
  130. package/dist/spec-diff-cli.d.ts +1 -0
  131. package/dist/spec-tools.d.ts +36 -0
  132. package/dist/stack.d.ts +58 -0
  133. package/dist/stacks.d.ts +12 -0
  134. package/dist/stdlib.d.ts +27 -0
  135. package/dist/terminal-images.d.ts +2 -0
  136. package/dist/tools.d.ts +101 -0
  137. package/dist/validate-cli.d.ts +1 -0
  138. package/docs/README.md +2 -0
  139. package/docs/hosting.md +51 -0
  140. package/package.json +8 -1
@@ -0,0 +1,23 @@
1
+ /** The columns the panel takes beside the chat: half of what they share, the rule between them in the middle - 0 when that is too narrow to share. */
2
+ export declare function dockedWidth(columns: number): number;
3
+ /**
4
+ * The chat narrowed by `panelWidth()` columns, read at each frame - 0 gives it the whole width. Returns what gives it the
5
+ * whole width back for good.
6
+ */
7
+ export declare function narrowChat(tui: object, panelWidth: () => number): () => void;
8
+ /**
9
+ * A press of a mouse button, as pi's full screen takes it - `side` told whether it was in the chat, left of `chatWidth()`
10
+ * columns, or in the panel - before the press goes on as it would have. Motion and the wheel are not presses. pi's
11
+ * regular screen reads no mouse: nothing is done there. Returns what takes the watch off.
12
+ */
13
+ export declare function clickToFocus(tui: object, chatWidth: () => number, side: (side: "chat" | "panel") => void): () => void;
14
+ /**
15
+ * A line drawn faint - the side that does not have the keys, in the shade. Faint (SGR 2) holds through a line's colours;
16
+ * only a reset - SGR 0, or 22 - ends it, so it is set again after each one. A line holding an image is left as it is.
17
+ */
18
+ export declare function shade(line: string): string;
19
+ /**
20
+ * The chat in the shade while `shaded()`: each of its rows drawn faint as the screen lays the overlays over it - the
21
+ * docked panel the last of them, which covers its own columns. Returns what takes the shade off.
22
+ */
23
+ export declare function shadeChat(tui: object, shaded: () => boolean): () => void;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The ***plain standard library: import modules for generic pieces of software that ship with turri,
3
+ * imported as `stdlib/backend/python-fastapi` - a reserved name (see plain/stdlib.ts).
4
+ */
5
+ export declare const STDLIB_DIR: string;
6
+ /**
7
+ * Where a module's generated code and tests live.
8
+ *
9
+ * Everything a module produces sits under `plain_modules/<module>/`, next to the specs it
10
+ * came from and inside the project's own repository: `code/` holds the implementation and
11
+ * its unit tests, `tests/` the black-box conformance tests - of every functionality built so
12
+ * far, the required modules' included, organised however suits them.
13
+ * The build state is written into `code/`, so what a codebase contains travels with that
14
+ * codebase instead of living in a scratch directory that can be cleared without anyone
15
+ * noticing the specs and the code have drifted apart.
16
+ */
17
+ export declare const MODULES_DIR = "plain_modules";
18
+ export declare function moduleDir(moduleName: string, cwd?: string): string;
19
+ /** Implementation and unit tests: `plain_modules/<module>/code`. */
20
+ export declare function defaultBuildDir(moduleName: string, cwd?: string): string;
21
+ /**
22
+ * The directory every module's output hangs off, `plain_modules` by default.
23
+ *
24
+ * Callers override this to build somewhere else - a sandbox, a test fixture - and the
25
+ * layout underneath it stays the same.
26
+ */
27
+ /**
28
+ * The project a spec belongs to: the nearest folder, from the spec's own up, that holds a
29
+ * `config.turri.yaml`, a stack's `config.turri.<stack>.yaml`, the `config.yaml` turri read before it had a file of
30
+ * its own, or a `plain_modules` - where its code is built, its config read, its testing scripts found. Without any, the
31
+ * spec's own folder. So `plain/hubspot.plain`, beside `plain/config.turri.yaml` and `plain/plain_modules`, is built there,
32
+ * wherever turri was started;
33
+ * specs at the root of their project are built where they always were.
34
+ */
35
+ export declare function projectDirOf(plainFile: string): string;
36
+ export declare function modulesRoot(cwd?: string): string;
37
+ export declare function buildDirUnder(root: string, moduleName: string): string;
38
+ export declare function testsDirUnder(root: string, moduleName: string): string;
39
+ /**
40
+ * The `plain_modules` a directory sits in: what holds every module's code and tests. A
41
+ * directory outside one - a sandbox, an explicit `--build-dir` - is its own root, so this
42
+ * never silently widens to a whole disk.
43
+ */
44
+ export declare function modulesRootOf(dir: string): string;
45
+ /**
46
+ * `.turri` inside the modules root: what turri keeps beside the code - the package
47
+ * caches, the modules' homes and temporary folders, the copies test runs happen in, the
48
+ * outputs kept for read_output. Ignored by the project's history.
49
+ */
50
+ export declare function modulesScratchDir(dir: string): string;
51
+ /** Make `path` inside the modules' scratch, which ignores itself. Returns `path`. */
52
+ export declare function ensureInModulesScratch(dir: string, path: string): string;
53
+ /** Where the project keeps what `deploy` puts out: `dist/`, beside `plain_modules`. */
54
+ export declare const DIST_DIR = "dist";
55
+ /**
56
+ * Where a person tries a module: `<project>/dist/<module>`, the module's code as its last commit has
57
+ * it. Outside `plain_modules`, so no agent can reach it, and replaced whole by every deploy.
58
+ */
59
+ export declare function distDirFor(projectDir: string, moduleName: string): string;
60
+ /**
61
+ * The project a directory belongs to: the one `plain_modules` sits in, when the directory is
62
+ * inside it; otherwise the directory's parent for a build folder, or the directory itself.
63
+ */
64
+ export declare function projectRootOf(dir: string): string;
65
+ /**
66
+ * `.turri` in the project: the harness's own scratch space - copies to try things in,
67
+ * saved agent sessions. Never part of the project's history, so it ignores itself - but for `skills/`, the
68
+ * project's own skills.
69
+ */
70
+ export declare function scratchDir(dir: string): string;
71
+ /**
72
+ * Where a skill run keeps its state - the manifest an interrupted run resumes from, the evidence
73
+ * each phase's gate is judged on: `.turri/runs/<skill>` in the project, beside the rest of
74
+ * turri's scratch, ignored by the project's history like it.
75
+ */
76
+ export declare function skillRunDir(cwd: string, skillName: string): string;
77
+ /**
78
+ * What the scratch dir's .gitignore says: everything in it is ignored but `skills/` - the project's own skills
79
+ * (skills.ts), which are written by hand and kept in its history.
80
+ */
81
+ export declare const SCRATCH_IGNORE = "*\n!skills/\n!skills/**\n";
82
+ /** Make `path`, inside a scratch dir, and see that the scratch dir ignores itself, its skills apart. Returns `path`. */
83
+ export declare function ensureInScratch(scratch: string, path: string): string;
84
+ /** Where agent sessions are saved, so what an agent did can be read - and resumed - later. */
85
+ export declare function sessionsDir(project: string): string;
86
+ /**
87
+ * Template search order, matching file_utils.get_template_directories: the plain file's
88
+ * own directory first, then a sibling `template/` directory if there is one (where a
89
+ * project keeps its import modules), then anything passed in, then PLAIN_TEMPLATE_DIRS.
90
+ * A `stdlib/...` import is not looked for in them: it is turri's (see plain/stdlib.ts).
91
+ */
92
+ export declare function resolveTemplateDirs(plainFile: string, extra?: string[]): string[];
@@ -0,0 +1,34 @@
1
+ import type { DiffPaint } from "./diff-view.ts";
2
+ /** A colour's SGR parameters: 24-bit, or the nearest of the 256 where the terminal has no more. */
3
+ export declare function sgr(hex: string, background: boolean, truecolor: boolean): string;
4
+ /**
5
+ * Neon, for what is shown to do what its spec says - regen's ◆: the design system's colour for what can be followed,
6
+ * 12.2:1 on abyss. On a light surface, where neon is illegible (1.6:1 on white), blue whale, 12.9:1 on white.
7
+ */
8
+ export declare const BRAND_NEON: {
9
+ light: string;
10
+ dark: string;
11
+ };
12
+ /**
13
+ * Pink, the one pink thing in a view - the banner's wordmark: 6.54:1 on abyss. On a light surface, where pink is
14
+ * too pale (2.9:1 on white), eggplant, 9.9:1 on white.
15
+ */
16
+ export declare const BRAND_PINK: {
17
+ light: string;
18
+ dark: string;
19
+ };
20
+ /** Text in neon on a theme - blue whale on a light one - in as many colours as the terminal has. */
21
+ export declare const brandNeon: (theme: {
22
+ appearance?: "dark" | "light";
23
+ getColorMode?(): string;
24
+ }) => ((text: string) => string);
25
+ /** Text in pink on a theme - eggplant on a light one - in as many colours as the terminal has. */
26
+ export declare const brandPink: (theme: {
27
+ appearance?: "dark" | "light";
28
+ getColorMode?(): string;
29
+ }) => ((text: string) => string);
30
+ /** How a spec diff is painted on a theme: its palette by whether the theme is dark or light, in as many colours as the terminal has. */
31
+ export declare function plainPaint(theme: {
32
+ appearance?: "dark" | "light";
33
+ getColorMode?(): string;
34
+ }): DiffPaint;
@@ -0,0 +1,192 @@
1
+ import { type MarshalledPlainSource, type Specifications } from "../plain/spec.ts";
2
+ import { type LoadedResource } from "./resources.ts";
3
+ import type { JobCases } from "./drift.ts";
4
+ import type { RequiredSpec } from "./state.ts";
5
+ import { type SpecChange } from "./spec-steps.ts";
6
+ /**
7
+ * Functional specs grouped by the module they belong to - in the order the modules are built on
8
+ * one another, the current module marked - and each tagged with its module and its id there. A codebase holds the
9
+ * functionalities of every module it is built on, and each module numbers its own from 1, so
10
+ * "functionality 1" alone is ambiguous: the first listed may be base's 1 and the next top's 3.
11
+ * (the reference implementation's implemented functional requirements prompt section, as tags.)
12
+ */
13
+ export declare function functionalitiesByModule(entries: Array<{
14
+ module: string;
15
+ frid: string;
16
+ spec: string;
17
+ }>, currentModule: string, status?: string): string;
18
+ /** "functionality 3 of module `app`": a functionality, named so that no other module's can be meant. */
19
+ export declare function functionalityOf(frid: string, moduleName: string): string;
20
+ /**
21
+ * How to read a ***plain specification: what each section is, and what the predefined concepts
22
+ * mean. At the head of every prompt for an agent that builds, tests or judges from a spec - the
23
+ * spec-writing agents have it from the authoring rules. Without it an agent reads
24
+ * "- :Implementation: uses FastAPI." as a term it should have found in the definitions.
25
+ *
26
+ * `testReqs`: whether this agent is given the test reqs - the agents that write and judge the
27
+ * conformance tests are, the ones that write code are not.
28
+ */
29
+ export declare function specPrimer(options: {
30
+ testReqs: boolean;
31
+ }): string;
32
+ /**
33
+ * How a failure is fixed without being hidden - for every agent that fixes code or tests. The
34
+ * point of a failing test is the failure: a fix that makes it go away without making the software
35
+ * right leaves the defect in, and the test unable to catch it again.
36
+ */
37
+ export declare const INTEGRITY_RULES: string[];
38
+ /**
39
+ * How a failure is fixed - for every agent sent back with one: understand it, reproduce it, fix the
40
+ * cause, check the fix the way the harness will. A fix made from the last line of the output alone
41
+ * fixes the symptom, if anything, and comes back next round.
42
+ */
43
+ export declare function fixMethod(options: {
44
+ what: "unit tests" | "conformance tests";
45
+ fixes: "code" | "tests";
46
+ runTool: string;
47
+ }): string[];
48
+ /**
49
+ * Why something failed is never lost - for every agent that writes or fixes code. A failure answered
50
+ * with a bare "failed" and logged nowhere leaves whoever has to fix it guessing, round after round.
51
+ */
52
+ export declare const ERROR_CAUSE_RULES: string[];
53
+ /** A section's tag - its name in every prompt: `<implementation reqs>`, `<acceptance tests>`. */
54
+ export declare function sectionTag(key: string): string;
55
+ export declare function section(key: string, items: string[]): string | null;
56
+ /**
57
+ * The module each item of a spec's sections belongs to, in order, by section. A codebase is built from the spec of its
58
+ * whole requires chain: an item of a module below carries that module's name (records.ts `chainTree`); the module's
59
+ * own - and what it imports, which is its own - carry none, and are `moduleName`'s.
60
+ */
61
+ export type SectionModules = Partial<Record<string, string[]>>;
62
+ export declare function sectionModules(tree: MarshalledPlainSource, moduleName: string): SectionModules;
63
+ /**
64
+ * A section of the spec, its items grouped under the module each belongs to - the modules in the order they are built on
65
+ * one another, the current one marked - as the functional specs are (`functionalitiesByModule`). Without `modules`, or
66
+ * when they do not match the items one for one, every item is the current module's.
67
+ */
68
+ export declare function moduleSection(key: string, items: string[], moduleName: string, modules?: SectionModules): string | null;
69
+ export interface SpecDiffPromptInput {
70
+ moduleName: string;
71
+ /** The spec change, as a diff of the .plain files. */
72
+ diff: string;
73
+ /** The change item by item, from what the code is built from to the spec it ends on: shown section by section in place of the diff. */
74
+ changes?: SpecChange[];
75
+ /** The module's sections and its functional specs, as they stand after the change. */
76
+ specifications: Specifications;
77
+ /** Functional specs of the modules this one requires, as they stand after the change. */
78
+ required: RequiredSpec[];
79
+ linkedResources: LoadedResource[];
80
+ codebase?: string | null;
81
+ /** Nothing is built yet: the change is the whole spec. */
82
+ empty: boolean;
83
+ /** What the job does to each functional spec (work.ts): the agent is told case by case. Not given: in general. */
84
+ cases?: JobCases;
85
+ /** The module each definition and req belongs to: see `sectionModules`. */
86
+ modules?: SectionModules;
87
+ }
88
+ /**
89
+ * The specification a review of some work is given: laid out exactly as the coding agent had it - how to read a
90
+ * ***plain spec, the definitions, the implementation reqs, what was already implemented - and then what is new, in
91
+ * a block of its own: the change the work made, section by section. The reviewer reads what the coding agent read,
92
+ * and knows exactly what this work was.
93
+ */
94
+ export declare function reviewedSpec(input: {
95
+ moduleName: string;
96
+ specifications: Specifications;
97
+ /** Functional specs of the modules this one requires: already in the code. */
98
+ required?: RequiredSpec[];
99
+ /** The change, section by section. */
100
+ change?: string;
101
+ /** The module each definition and req belongs to: see `sectionModules`. */
102
+ modules?: SectionModules;
103
+ }): string;
104
+ /** A change in its tag: told section by section, or - when it could not be - the raw diff, with which tag each heading is. */
105
+ export declare function specChangeBlock(change: string): string;
106
+ /**
107
+ * A spec change as an agent reads it: section by section, what was added, what changed - before and now - and what
108
+ * was removed. A definition taken out and put back reworded, or moved, is one change to it, not two. Every item is
109
+ * named so no other module's can be meant: a functional spec by its module and number, and a definition or req of a
110
+ * module below by its module; `moduleName` is the module whose codebase it is - whose own items carry no module.
111
+ */
112
+ export declare function describeSpecChange(changes: SpecChange[], moduleName?: string): string;
113
+ /**
114
+ * Build the prompt for rendering a change to the specs.
115
+ *
116
+ * The change is given as the person made it - a diff of the .plain files - and the specs as
117
+ * they stand after it come with it, so the agent has both what moved and what it must add up
118
+ * to. Additions, changes and removals, in any section, are one task: make the code match.
119
+ */
120
+ export declare function buildSpecDiffPrompt(input: SpecDiffPromptInput): string;
121
+ export interface ConformancePromptInput {
122
+ /** What the job does to each functional spec (work.ts): the agent is told case by case. Not given: in general. */
123
+ cases?: JobCases;
124
+ moduleName: string;
125
+ /** The functionality under test; for a spec change, the last there is - none before the first is written. */
126
+ frid?: string;
127
+ specifications: Specifications;
128
+ linkedResources: LoadedResource[];
129
+ /** File names in the build directory. */
130
+ manifest: string[];
131
+ /** Where the code is, for fixing it when it is what is wrong. */
132
+ codeDir?: string;
133
+ /**
134
+ * How to invoke the built software from outside, as an agent that explored the code wrote it.
135
+ * Given, the author works from this and fixes only tests - when a run fails, another agent decides
136
+ * whether the test or the code is wrong.
137
+ */
138
+ invocation?: string;
139
+ /** The code, which the author may read but never change. */
140
+ readCode?: string;
141
+ /** The code's build files, read by the harness: the exact name, coordinates and version a test project points at. */
142
+ manifests?: Array<{
143
+ path: string;
144
+ content: string;
145
+ }>;
146
+ /** For a spec change: the functionalities it touches, with their acceptance tests - each implemented and labelled. */
147
+ touched?: Array<{
148
+ frid: string;
149
+ acceptanceTests: string[];
150
+ }>;
151
+ /** Tests already in the conformance directory, from an earlier version of the spec. */
152
+ existingTests?: string[];
153
+ /** Functional specs of the modules this one requires, transitively. */
154
+ required?: RequiredSpec[];
155
+ /**
156
+ * A change to the specs, as a diff, instead of one functionality: the tests are brought in
157
+ * line with the specs as they stand after it.
158
+ */
159
+ diff?: string;
160
+ /** The module each definition and req belongs to: see `sectionModules`. */
161
+ modules?: SectionModules;
162
+ }
163
+ /**
164
+ * Build the prompt for conformance tests.
165
+ *
166
+ * These are black-box in shape: they invoke the built functionality from outside and check
167
+ * it does what the specification says. The agent can read the implementation - it needs to
168
+ * know how to call the thing - but the prompt leads with the specification, because a test
169
+ * written from the code can only ever agree with it.
170
+ */
171
+ export declare function buildConformancePrompt(input: ConformancePromptInput): string;
172
+ /** What a conformance test covering no functional spec yet - a definition, a req - is labelled. */
173
+ export declare const CHANGE_LABEL = "conformance tests of the spec";
174
+ export interface RegressionFixPromptInput {
175
+ moduleName: string;
176
+ /** Functionalities built so far, in order. */
177
+ frids: string[];
178
+ specifications: Specifications;
179
+ failure: string;
180
+ /** Functional specs of the modules this one requires, transitively. */
181
+ required?: RequiredSpec[];
182
+ /** The module each definition and req belongs to: see `sectionModules`. */
183
+ modules?: SectionModules;
184
+ }
185
+ /**
186
+ * Build the prompt for repairing a regression.
187
+ *
188
+ * A regression means the newest functionality broke an older one, so the whole module's
189
+ * conformance suite is the subject. The tests are not editable from here - they state
190
+ * what the specification requires of every functionality built so far.
191
+ */
192
+ export declare function buildRegressionFixPrompt(input: RegressionFixPromptInput): string;
@@ -0,0 +1,88 @@
1
+ import { type MarshalledPlainSource } from "../plain/spec.ts";
2
+ /**
3
+ * What a module is built from, in two records - see docs/regenerating.md.
4
+ *
5
+ * - The code record, `code/.turri.json`: the spec the code is built from, without what is only
6
+ * for conformance - the test reqs, and the acceptance tests under each functional spec.
7
+ * - The tests record, `tests/.turri.json`: the functional specs the conformance tests are
8
+ * written for - a subset of the code record's, each with its number and its acceptance tests - the
9
+ * definitions and implementation reqs they were written against, and the test reqs they follow.
10
+ *
11
+ * The tests record is always a substate of the code record: a conformance test exercises
12
+ * functionality, and only functionality in the code can be tested. Each record is committed with
13
+ * what it describes, in the module's `.plaingit`, so rolling a unit of work back puts it back too.
14
+ */
15
+ export declare const RECORD_FILE = ".turri.json";
16
+ /**
17
+ * A functional spec in the code record marked to regenerate again: its code is built, and is to be regenerated again
18
+ * all the same - `regenerate` with functionalities named. The mark makes the record differ from the spec at that item,
19
+ * so the work loop plans it as it plans any change, and the job that regenerates it writes the item back without it.
20
+ */
21
+ export declare const REGENERATE_AGAIN = "regenerate_again";
22
+ /** Whether a record's item is marked to regenerate again. */
23
+ export declare function marksRegenerateAgain(item: unknown): boolean;
24
+ /** The spec as the code is built from it: no test reqs, and no acceptance tests under the functional specs. */
25
+ export declare function codeTree(tree: MarshalledPlainSource): MarshalledPlainSource;
26
+ /**
27
+ * A module's tree with the hash of each linked resource's content beside its link: the file is part of the spec,
28
+ * so a change to what it holds is a change to the item that links it - and, a definition linking it, to every
29
+ * functional spec using the concept. Found as the parser finds it: the spec's own folder first, then the other
30
+ * template folders, then the current directory.
31
+ */
32
+ export declare function withResourceDigests(tree: MarshalledPlainSource, dirs: string[]): MarshalledPlainSource;
33
+ /**
34
+ * A record written before linked resources were hashed, with the hashes of `spec` where its links are the same:
35
+ * what it was built from is taken to be the resource as it is now, rather than every item linking one built again.
36
+ */
37
+ export declare function adoptDigests(record: MarshalledPlainSource | null, spec: MarshalledPlainSource): MarshalledPlainSource | null;
38
+ /**
39
+ * The spec a codebase is built from: the spec of its whole requires chain, as its code holds it. A
40
+ * codebase is built on the code of the modules below it, so its code implements their definitions and
41
+ * implementation reqs too: those come tagged with their module, bottom of the chain first, and the
42
+ * module's own untagged after them. An item a lower module already has - the same text, from an import
43
+ * they share - is not the module's own again: its code implements it already. The functional specs of the
44
+ * modules below are the ones it inherits, as the parser gives them; its test reqs are its own.
45
+ *
46
+ * `trees`: every module of the chain, bottom first - the module itself last.
47
+ */
48
+ export declare function chainTree(trees: Array<{
49
+ module: string;
50
+ tree: MarshalledPlainSource;
51
+ }>): MarshalledPlainSource;
52
+ /**
53
+ * What a new module's codebase starts from, copied from the code of the module it requires: that module's
54
+ * record, as a lower module's - its own definitions and implementation reqs tagged with it, its functional
55
+ * specs among the ones inherited. The new module has built nothing of its own yet.
56
+ */
57
+ export declare function inheritedRecord(source: MarshalledPlainSource, sourceModule: string): MarshalledPlainSource;
58
+ /** Which functional specs are to have conformance tests, by number. Default: every one. */
59
+ export type Chosen = (frid: string) => boolean;
60
+ /**
61
+ * What the conformance tests are to be written for, now: of the functional specs the code is built
62
+ * from, those chosen, each as the spec has it now with its acceptance tests - and the code's
63
+ * definitions and implementation reqs, with the test reqs as the spec has them now.
64
+ *
65
+ * Conformance follows the code, never goes ahead of it: a functional spec whose code is not caught up
66
+ * with the spec - its text in the code record is not the spec's, or the code record does not have it at
67
+ * all, as while it is regenerated again - stays as the tests record has it, until the code lands. Its tests are
68
+ * taken out only once the spec and the code have both dropped it.
69
+ */
70
+ export declare function conformanceTarget(code: MarshalledPlainSource | null, tests: MarshalledPlainSource | null, spec: MarshalledPlainSource, chosen?: Chosen): MarshalledPlainSource;
71
+ /**
72
+ * Of the functional specs given, by number, those the code record does not have as `tree` has them - not built,
73
+ * or built from other text: no conformance test can be written for them yet. `tree` is a spec, its functional
74
+ * specs numbered by place, or what conformance tests are written for, each with its number.
75
+ */
76
+ export declare function notBuilt(code: MarshalledPlainSource | null, tree: MarshalledPlainSource, frids: string[]): string[];
77
+ /**
78
+ * A record in `dir`: as the module's last commit has it, by default - what the harness itself wrote
79
+ * when the last unit of work landed, never what an agent's shell changed since - or, with `onDisk`,
80
+ * the file as it is. Null when there is none.
81
+ */
82
+ export declare function readRecord(dir: string, options?: {
83
+ onDisk?: boolean;
84
+ }): MarshalledPlainSource | null;
85
+ /** Write the code record: the tree, as the code sees it. */
86
+ export declare function writeCodeRecord(codeDir: string, tree: MarshalledPlainSource): void;
87
+ /** Write the tests record: a conformance target, as it now is built. */
88
+ export declare function writeTestsRecord(testsDir: string, tree: MarshalledPlainSource): void;
@@ -0,0 +1,108 @@
1
+ import { type MarshalledPlainSource } from "../plain/spec.ts";
2
+ import type { JobCases } from "./drift.ts";
3
+ import { type SpecGap } from "./notes.ts";
4
+ import { type ChainEntry } from "./requires.ts";
5
+ import { type JobSteering } from "./steering.ts";
6
+ import { type TestRemoval, type TestRun, type MissingToolchain } from "./testing.ts";
7
+ /**
8
+ * Bring the .plain files to the state the diff describes, with git. A diff that is already
9
+ * applied is fine - the person may have made the edit themselves and sent its diff - but
10
+ * one that fits neither way is refused: rendering it would mean guessing.
11
+ */
12
+ export declare function applySpecDiff(diff: string, cwd: string): "applied" | "already applied";
13
+ /** Undo a spec diff this process applied, when what it produced cannot be used. */
14
+ export declare function revertSpecDiff(diff: string, cwd: string): void;
15
+ /** The .plain files a diff writes to, relative to where it applies. */
16
+ export declare function plainFilesOf(diff: string): string[];
17
+ /** A module's .plain file and every one it imports, transitively - the files its spec is read from. */
18
+ export declare function specFilesOf(plainFile: string, templateDirs?: string[]): string[];
19
+ /** A git diff cut into what it does to each file, in order: the file's path (the new side's), and its part of the diff. */
20
+ export declare function diffByFile(diff: string): Array<{
21
+ file: string;
22
+ diff: string;
23
+ }>;
24
+ /**
25
+ * The spec as it stands with a change in: the codebase the change is rendered in, and that
26
+ * module parsed - its sections, the functional specs it inherits and its own.
27
+ */
28
+ export interface SpecSnapshot {
29
+ moduleName: string;
30
+ plainFile: string;
31
+ tree: MarshalledPlainSource;
32
+ /** The codebase's requires chain, bottom first; the last entry is the codebase itself. */
33
+ chain: ChainEntry[];
34
+ }
35
+ /** Parse the spec as it stands now, for a change to `plainFile`'s module. */
36
+ export declare function snapshotSpec(plainFile: string, options?: {
37
+ cwd?: string;
38
+ templateDirs?: string[];
39
+ inModule?: string;
40
+ }): SpecSnapshot;
41
+ export interface RenderSpecDiffOptions {
42
+ /** A .plain file of the module the change is rendered for. */
43
+ plainFile: string;
44
+ /** The change, as a git diff of the .plain files. */
45
+ diff: string;
46
+ /** Where the diff's paths are relative to. Default: the working directory. */
47
+ cwd?: string;
48
+ templateDirs?: string[];
49
+ /** The codebase to render in, when modules built on this one branch. */
50
+ inModule?: string;
51
+ /**
52
+ * The diff was already put in when it was written - how that went - and is not to be applied
53
+ * again. A render queued behind the interview runs after later changes have gone on top of
54
+ * it, so its diff no longer fits the file either way - but it is in, and that is what matters.
55
+ */
56
+ applied?: "applied" | "already applied";
57
+ /** The spec as parsed with the diff in. Taken now, after applying it, when not given. */
58
+ spec?: SpecSnapshot;
59
+ model?: string;
60
+ /** Review the code and unit tests once they pass - that they do what the change says. Default: the config's `review:`, else false. */
61
+ unitReview?: boolean;
62
+ /** What the job does to each functional spec (work.ts): its agents are told case by case. Not given: in general. */
63
+ cases?: JobCases;
64
+ /** Build the coding agent's task and stop there: nothing is started, and what the render did is rolled back. */
65
+ dryRun?: boolean;
66
+ /** The unit test review's model. Default: the project's judge-model, else `model`. */
67
+ judgeModel?: string;
68
+ onDelta?: (delta: string) => void;
69
+ /** The loop's: steers the coding agent when the spec changes inside what it regenerates, and holds the record it lands. */
70
+ steering?: JobSteering;
71
+ }
72
+ export interface RenderSpecDiffResult {
73
+ /** The codebase the change was rendered in. */
74
+ moduleName: string;
75
+ buildDir: string;
76
+ diff: "applied" | "already applied";
77
+ response: string;
78
+ runs: TestRun[];
79
+ /** How many times the harness ran the unit testing script on it: the attempts it judged. */
80
+ attempts: number;
81
+ testRemovals: TestRemoval[];
82
+ files: {
83
+ added: string[];
84
+ changed: string[];
85
+ removed: string[];
86
+ };
87
+ passed: boolean;
88
+ stoppedAt: "unit tests" | null;
89
+ /** Stopped because the unit testing script cannot run: what it needs is not installed where it runs. */
90
+ missingToolchain?: MissingToolchain;
91
+ /** Stopped with the unit tests passing and the unit testing script's static checks not. */
92
+ staticChecks?: boolean;
93
+ /** What the spec changed while it regenerated that its agent was told - a line each. */
94
+ steered?: string[];
95
+ /** The specs were only restructured: nothing was rendered, the spec as now laid out was recorded. */
96
+ restructured?: boolean;
97
+ /** A dry run: the task the coding agent would be given. */
98
+ task?: string;
99
+ /** Spec gaps its agents reported: what the spec should say and does not, for the person to decide. */
100
+ specGaps?: SpecGap[];
101
+ /** What the debugger found, each time it was asked - its root cause. */
102
+ diagnosed?: string[];
103
+ }
104
+ export declare function renderSpecDiff(options: RenderSpecDiffOptions): Promise<RenderSpecDiffResult>;
105
+ /** Spec gaps a pulse's agents met, as its report says them: for the conversation to put to the person. */
106
+ export declare function specGapsText(gaps: SpecGap[] | undefined): string[];
107
+ /** What a rendered spec change did, for the agent and the person. */
108
+ export declare function describeSpecDiff(result: RenderSpecDiffResult): string;
@@ -0,0 +1,58 @@
1
+ import { type MarshalledPlainSource } from "../plain/spec.ts";
2
+ import { type WorkStart } from "./lineage.ts";
3
+ import { type TestScripts } from "./test-scripts.ts";
4
+ import type { RequiredSpec } from "./state.ts";
5
+ import { type TestRun } from "./testing.ts";
6
+ /** What a regression run reports as it goes: a run of the suite, a repair. */
7
+ export type RegressionEvent = {
8
+ type: "run";
9
+ command: string;
10
+ exitCode: number;
11
+ frids?: string[];
12
+ } | {
13
+ type: "repair";
14
+ frids: string[];
15
+ };
16
+ export interface RegressionRun extends TestRun {
17
+ /** Functionalities whose tests took part in this run. */
18
+ frids: string[];
19
+ }
20
+ export interface RegressionResult {
21
+ passed: boolean;
22
+ runs: RegressionRun[];
23
+ /** Each time the implementation was changed to repair a regression. */
24
+ repairs: string[];
25
+ /** The conformance testing script that ran the suite; null when there were no tests to run. */
26
+ command: string | null;
27
+ /** Conformance was turned off, so the conformance tests already here were not run. */
28
+ conformanceOff?: boolean;
29
+ }
30
+ /**
31
+ * Run every conformance test built so far, and repair the code until they all pass.
32
+ *
33
+ * This is the gate between one functionality and the next. A functionality that passed on
34
+ * its own is not finished until the ones before it still pass alongside it, and each
35
+ * repair changes the code - so the suite is run again after every one.
36
+ */
37
+ export declare function ensureRegressionPasses(input: {
38
+ buildDir: string;
39
+ conformanceRoot: string;
40
+ moduleName: string;
41
+ frids: string[];
42
+ tree: MarshalledPlainSource;
43
+ /** The required modules' functional specs, for the repair agent. */
44
+ required: RequiredSpec[];
45
+ /**
46
+ * The unit of work the run belongs to, undone whole when the suite still fails. Without one,
47
+ * only what the repairs did is undone.
48
+ */
49
+ start?: WorkStart;
50
+ /** The step the regression run is for, as a repair's notes say; the last functionality by default. */
51
+ step?: string;
52
+ /** The codebase's testing scripts: its conformance testing script runs the suite. */
53
+ scripts: TestScripts;
54
+ model?: string;
55
+ maxRounds?: number;
56
+ onDelta?: (delta: string) => void;
57
+ onEvent?: (event: RegressionEvent) => void;
58
+ }): Promise<RegressionResult>;