@turri-dev/core 0.1.1-next.35d4c49 → 0.1.1-next.ad4aa8f

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 (163) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +17 -11
  3. package/dist/api/models.d.ts +9 -0
  4. package/dist/api/models.js +15 -0
  5. package/dist/api/plain.d.ts +6 -6
  6. package/dist/api/plain.js +4 -7
  7. package/dist/api/project.d.ts +35 -0
  8. package/dist/api/project.js +47 -0
  9. package/dist/api/session.d.ts +48 -0
  10. package/dist/api/session.js +17 -0
  11. package/dist/api/system.d.ts +18 -0
  12. package/dist/api/system.js +23 -0
  13. package/dist/btw.d.ts +1 -1
  14. package/dist/capture/capture.js +11 -8
  15. package/dist/capture/chat.d.ts +0 -11
  16. package/dist/capture/chat.js +0 -29
  17. package/dist/capture/config.d.ts +4 -5
  18. package/dist/capture/config.js +34 -20
  19. package/dist/capture/models.d.ts +2 -1
  20. package/dist/capture/models.js +1 -0
  21. package/dist/chat-entries.d.ts +81 -39
  22. package/dist/chat-entries.js +125 -11
  23. package/dist/chat-model.d.ts +37 -0
  24. package/dist/chat-model.js +61 -0
  25. package/dist/chats.d.ts +54 -42
  26. package/dist/chats.js +86 -80
  27. package/dist/client.d.ts +30 -0
  28. package/dist/client.js +12 -0
  29. package/dist/config-edit.d.ts +54 -1
  30. package/dist/config-edit.js +103 -33
  31. package/dist/config.d.ts +12 -9
  32. package/dist/config.js +38 -9
  33. package/dist/doctor-checks.d.ts +42 -0
  34. package/dist/doctor-checks.js +39 -0
  35. package/dist/environment.d.ts +2 -23
  36. package/dist/environment.js +5 -68
  37. package/dist/errors.d.ts +32 -0
  38. package/dist/errors.js +24 -0
  39. package/dist/extension.d.ts +23 -16
  40. package/dist/extension.js +170 -234
  41. package/dist/identity.d.ts +1 -1
  42. package/dist/identity.js +13 -9
  43. package/dist/init-config.d.ts +11 -9
  44. package/dist/init-config.js +15 -7
  45. package/dist/launch-session.d.ts +2 -0
  46. package/dist/launch-session.js +17 -1
  47. package/dist/loop-tools.js +11 -10
  48. package/dist/module-check.d.ts +13 -0
  49. package/dist/module-check.js +117 -0
  50. package/dist/notice.d.ts +5 -0
  51. package/dist/parse-tool.js +3 -2
  52. package/dist/plain/check.d.ts +27 -13
  53. package/dist/plain/check.js +51 -116
  54. package/dist/plain/files.d.ts +2 -0
  55. package/dist/plain/files.js +13 -0
  56. package/dist/plain/graph.js +2 -2
  57. package/dist/plain/highlight.d.ts +4 -20
  58. package/dist/plain/highlight.js +7 -5
  59. package/dist/project.d.ts +19 -0
  60. package/dist/project.js +34 -0
  61. package/dist/quiet.d.ts +0 -2
  62. package/dist/quiet.js +0 -14
  63. package/dist/regenerate/command-check.d.ts +0 -8
  64. package/dist/regenerate/command-check.js +133 -53
  65. package/dist/regenerate/conversation-writes.d.ts +5 -1
  66. package/dist/regenerate/conversation-writes.js +7 -3
  67. package/dist/regenerate/jobs.d.ts +25 -2
  68. package/dist/regenerate/jobs.js +3 -0
  69. package/dist/regenerate/launch.d.ts +1 -0
  70. package/dist/regenerate/launch.js +9 -0
  71. package/dist/regenerate/ledger-view.d.ts +14 -14
  72. package/dist/regenerate/ledger.d.ts +1 -0
  73. package/dist/regenerate/ledger.js +4 -2
  74. package/dist/regenerate/loop.d.ts +2 -1
  75. package/dist/regenerate/loop.js +9 -1
  76. package/dist/regenerate/os-sandbox.d.ts +4 -2
  77. package/dist/regenerate/os-sandbox.js +0 -1
  78. package/dist/regenerate/regenerate.js +2 -1
  79. package/dist/regenerate/requires-chain.d.ts +44 -0
  80. package/dist/regenerate/requires-chain.js +174 -0
  81. package/dist/regenerate/requires.d.ts +2 -40
  82. package/dist/regenerate/requires.js +14 -171
  83. package/dist/regenerate/resources.d.ts +0 -2
  84. package/dist/regenerate/resources.js +2 -14
  85. package/dist/regenerate/shell.js +20 -9
  86. package/dist/regenerate/spec-map.d.ts +2 -0
  87. package/dist/regenerate/spec-map.js +4 -0
  88. package/dist/regenerate/standing.d.ts +5 -2
  89. package/dist/run-report.js +2 -2
  90. package/dist/self-invocation.d.ts +1 -1
  91. package/dist/self-invocation.js +2 -3
  92. package/dist/sentinel-chat.js +7 -11
  93. package/dist/sentinel.d.ts +1 -1
  94. package/dist/sentinel.js +12 -5
  95. package/dist/session-events.d.ts +14 -0
  96. package/dist/session.d.ts +594 -0
  97. package/dist/session.js +672 -0
  98. package/dist/settings.d.ts +28 -2
  99. package/dist/settings.js +92 -56
  100. package/dist/setup.d.ts +6 -30
  101. package/dist/setup.js +28 -105
  102. package/dist/stack.d.ts +25 -12
  103. package/dist/stack.js +77 -12
  104. package/dist/surface.d.ts +2 -2
  105. package/dist/surface.js +4 -5
  106. package/dist/work.d.ts +125 -0
  107. package/dist/work.js +250 -0
  108. package/docs/README.md +2 -3
  109. package/docs/capture.md +4 -4
  110. package/docs/chats.md +5 -3
  111. package/docs/claude-subscription.md +2 -2
  112. package/docs/config.md +4 -4
  113. package/docs/core.md +105 -128
  114. package/docs/development.md +9 -9
  115. package/docs/headless.md +1 -1
  116. package/docs/installation.md +4 -2
  117. package/docs/launch.md +2 -2
  118. package/docs/parser.md +1 -1
  119. package/docs/regenerating.md +1 -1
  120. package/docs/sandbox.md +4 -4
  121. package/docs/sentinel.md +4 -4
  122. package/docs/skills-and-gates.md +1 -1
  123. package/docs/using.md +2 -2
  124. package/genome/rules/integration-embedded-testing.md +3 -3
  125. package/genome/rules/integration-embedded.md +3 -3
  126. package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
  127. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
  128. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
  129. package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
  130. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
  131. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
  132. package/package.json +19 -32
  133. package/dist/api/commands.d.ts +0 -45
  134. package/dist/api/commands.js +0 -54
  135. package/dist/api/config.d.ts +0 -8
  136. package/dist/api/config.js +0 -8
  137. package/dist/api/ledger.d.ts +0 -3
  138. package/dist/api/ledger.js +0 -3
  139. package/dist/api/startup.d.ts +0 -8
  140. package/dist/api/startup.js +0 -8
  141. package/dist/api/terminal.d.ts +0 -18
  142. package/dist/api/terminal.js +0 -16
  143. package/dist/chat-models.d.ts +0 -11
  144. package/dist/chat-models.js +0 -11
  145. package/dist/chat-ui.d.ts +0 -33
  146. package/dist/chat-ui.js +0 -192
  147. package/dist/headless.d.ts +0 -99
  148. package/dist/headless.js +0 -226
  149. package/dist/host-session.d.ts +0 -136
  150. package/dist/host-session.js +0 -139
  151. package/dist/host.d.ts +0 -8
  152. package/dist/host.js +0 -17
  153. package/dist/index.d.ts +0 -16
  154. package/dist/index.js +0 -7
  155. package/dist/notifications.d.ts +0 -21
  156. package/dist/notifications.js +0 -44
  157. package/dist/reopen.d.ts +0 -29
  158. package/dist/reopen.js +0 -47
  159. package/dist/turri-versions.d.ts +0 -71
  160. package/dist/turri-versions.js +0 -276
  161. package/dist/view.d.ts +0 -78
  162. package/dist/view.js +0 -1
  163. package/docs/hosting.md +0 -284
package/docs/hosting.md DELETED
@@ -1,284 +0,0 @@
1
- # Running turri in a host
2
-
3
- `turri` runs its chats in a terminal. A host - a desktop app, an editor - can run the same session itself, its chats in its own windows, and show the jobs, the questions and the \*\*\*plain description in its own way. Import `createTurri` from `@turri-dev/core`.
4
-
5
- ## What a host can use
6
-
7
- The root entry owns the session; `/host` adds desktop operations, `/plain` the parser and project reader, `/config` settings and `/ledger` recorded facts. See the [import map](core.md#importing-the-core) for the full boundary.
8
-
9
- | export | what it is |
10
- | --- | --- |
11
- | `createTurri(options)` | a turri session: its [chats](chats.md), each a [pi](https://pi.dev) session with every tool, slash command, rule and skill the terminal has, on one job registry and work loop. The host opens, closes and shows them, is told of their jobs and asks their questions, and asks the sentinel to check functional specs (`check`) - see [the session in a host](#the-session-in-a-host). |
12
- | `SENTINEL`, `SENTINEL_START`, `Notice`, `NoticeAnswer`, `Conclusion`, `SentinelCheck`, `CheckRequest` | the [sentinel](sentinel.md)'s chat role, the answers to the question before it starts, its notices and how they are answered, its conclusions - a pulse's by `job`, a check's by `check` - and the checks a host asks of it - see [the sentinel](#the-sentinel). |
13
- | `MAX_CHATS`, `ChatInfo`, `ChatStatus` | the most chats a session has open - nine - and what the host is told of each. |
14
- | `savedChatFiles`, `credentialsFile`, `loginDeviceId` | desktop operations from `/host`: list saved conversation paths, locate the credential store or get the device id for sign-in. For pi extensions use the shared pi peer. |
15
- | `readProjectConfig`, `projectModels`, `modelSpec`, `configForSpec`, `hasProjectConfig`, `moduleConfigsOf` | the project's settings, as [config.turri.yaml](config.md) has them. |
16
- | `configuredModel(config, key)` | the model and thinking set **on that key** from `configSettings()` (`coding-model`, `models.planner`, etc.). A role with only a turn limit gives `undefined`. A settings sheet uses this to edit a value; `projectModels(config)` says what will actually run after inheritance. |
17
- | `configLines(projectDir)` | current config findings, even before a chat opens. Each has `kind`, `file` and `text`. Like the banner, it applies turri's automatic key renames and reports them. |
18
- | `configSettings`, `currentValue`, `readConfigText`, `overriddenBy`, `EFFECT_TEXT` | every setting of config.turri.yaml as [/settings](config.md#changing-it-from-the-chat) knows it - its key, what it does, its kind (a yes or no, one of a few words, a number, a model, a list, a path, a budget), its words or the values offered first, what it is unset and when a change takes effect - and what the file has now (`currentValue(readConfigText(dir), key)`), and what wins over it. Change one as the person would, by sending `/settings <key> <value>` to the chat: turri checks it and writes it with the file's comments kept. A setting's values for a list are the session's `settingChoices(key, typed?)`: what /settings's completions offer after `typed`, in their order, but whole - uncapped, where the terminal shows forty - and without unset, which the host draws itself; the values alone. A model setting's are every model of every provider signed in to, from the model registry the chats use, whether or not one has run /settings - and after a colon, that model's thinking levels. An unknown key gives `[]`. |
19
- | `debugMode` | whether turri keeps, in a project, what it writes only for debugging it - `debug:`, or `TURRI_DEBUG` over it (see [debug mode](config.md#debug-mode)). |
20
- | `initConfig(dir, { vendor, bedrock, models, force, catalogue })`, `VENDORS`, `BEDROCK_REGIONS`, `BEDROCK_DEFAULT` | a project's first config.turri.yaml, as `turri init-config` writes it - async, it may read [pi](https://pi.dev)'s catalogue - see [a project's first config](#a-projects-first-config). |
21
- | `machineChange(command)`, `machineChangeReason(why)` | whether a command line would install something on the machine or change a setting of the machine's or the person's shell - and why - and what turri says instead: for a host's own tool that types into a shell, which turri cannot see a command in. |
22
- | `installedModelRuntime(cwd?)`, `EXTENSION_PROVIDERS` | pi's model runtime with the providers the person's installed pi extensions register - for a host's sign-in sheet before a chat is open - and the providers turri knows come from an extension - see [models from a pi extension in a host](#models-from-a-pi-extension-in-a-host). |
23
- | `piModelCatalogue`, `bedrockMakers`, `bedrockModelsIn`, `bedrockDefaultModels`, `bedrockModels`, `bedrockPlaceOf`, `makerLabel`, `BEDROCK_GEOGRAPHIES`, `BEDROCK_IN_REGION` | [pi](https://pi.dev)'s model catalogue, read without a request, and Bedrock in it: whose models it serves, in which geographies, which two turri offers for a maker and geography. |
24
- | `bedrockAwsRegion`, `bedrockNeedsAwsRegion` | the AWS region turri calls a Bedrock geography's models in, and whether that geography needs a region of its own - every one but `global`, `us` and `in-region`, which [pi](https://pi.dev)'s default `us-east-1` serves. |
25
- | `bedrockRegionFor(projectDir)`, `BedrockRegion`, `BedrockRegionSource` | the AWS region the project's Bedrock models are called in, read without setting anything: `{ region?, source, models, needs?, conflict? }` - `source` `set` (the person's `AWS_REGION` or `AWS_DEFAULT_REGION`, never touched), `turri` (turri sets `AWS_REGION` as the session starts, the models needing it and none set), `profile` (the `AWS_PROFILE`'s region, in the models' geography) or `default` (nothing names one: `us-east-1`); `models` the Bedrock models the config names, each stack's too; `needs` the region and geography they need, when one; `conflict`, the models needing two regions, each with its models - then no region is set, one `AWS_REGION` serving every model. `region` is undefined with no Bedrock model, or with a conflict and nothing set. Undefined on an older turri. |
26
- | `checkPlainFile`, `plainFileParser`, `resolveTemplateDirs`, `iterateFunctionalSpecs`, `FUNCTIONAL_REQUIREMENTS` | \*\*\*plain checked and parsed, with its test plain files, its functional specs one by one - `{ funcId, specifications }`, the specifications with the functional spec's conformance and acceptance scenarios, each `{ id, text }` - as `turri parse` reads it. |
27
- | `highlightLines`, `roleOf` | \*\*\*plain's lines coloured by turri's own [\*\*\*plain](https://plainlang.org/docs/) grammar, each piece by its `PlainRole`: `section`, `concept`, `link`, `literal`, `keyword`, `module`, `comment`, `bullet` and `id` - the `# <id>` heading of a functional spec or a scenario, and a test plain file's `func_id:` value, the functional spec it binds to. A test plain file's `module:` value is a `module`, whole - `my-app`, `billing.v2` - as a module name listed under `import:` or `requires:` is. |
28
- | `plainGraph(projectDir)` | a project's \*\*\*plain as a graph to move around in: its modules with what each imports and requires and what imports and requires it, each item of their sections with its line, and the concepts - an item linked to those it names and to where each is defined - see [\*\*\*plain for a host](#plain-for-a-host). |
29
- | `testDirOf(plainFile)`, `DEFAULT_TEST_DIR` | the absolute folder a module's test plain files are in - `test-dir`, its module's own file's over the project's, else `tests` (`DEFAULT_TEST_DIR`), from the project's folder - for a host that lists a project's modules by walking its .plain files and leaves the test plain files out. It is a module's, not a project's, because a module's `config.turri.<module>.yaml` may name a folder of its own. |
30
- | Scenario links in `plainGraph(projectDir)` | Modules can share a test folder, inherit one or use separate ones. The graph lists a file once even when roots overlap. A copy left in the wrong root is reported without replacing the correct link. |
31
- | `conceptsOf(plainFile)`, `findConcepts(text)`, `conceptBeingTyped(text)` | the concepts a module can name, with what each is and the module that defines it; the concepts written in a piece of text; the one being typed at its end. |
32
- | `stdlibTemplates()`, `isStack`, `STDLIB_KINDS` | turri's standard library: every template with its kind, file, text, imports and its conformance template or the stack it tests, and the kinds in order with their titles. |
33
- | `session.standing(files?)`, `projectStanding(projectDir, files?)` | how every module stands, live or from disk, in one call - see [how a project stands](#how-a-project-stands). |
34
- | `requiresOrder(projectDir, { files? })` | a project's .plain files, absolute, in the order they are built: each after every module it requires, as its requires chain (`resolveRequiresChain`) has them - the files taken in the order given, by name without `files`, each brought in after what it requires. A module whose chain does not resolve - it does not parse, a module it requires is not there, a cycle - goes after what its front matter says it requires, as far as those are found; none is left out. Only the files given are in it: `files`, absolute or from the project, else every .plain file in the project's folder. |
35
- | `session.lookAhead(plainFile)` | with a chat open, plan as regenerate would and hold that plan. Returns `{ statuses, next }`, including each available next pulse's cases and prompt. Starts no pulse ([looking ahead](regenerating.md#a-whole-module)). |
36
- | `session.status()`, `session.jobs()`, `session.job(id)` | module status, unreplaced jobs and planned rows; every job including retries; an individual job. |
37
- | `session.launches()` | this run's launches in request order, each with its latest state, including stopped or replaced launches. A reopened window can read them even if it missed every `onLaunch` callback. |
38
- | `session.spending()` | dollars spent since the project session opened: `chat`, `sentinel`, `regeneration`, and `other` calls grouped by `{ role, cost }` (`role: null` if unlabelled). Available without any event subscriber. |
39
- | `onEvent`, `session.entries(chat)` | typed session events, including skill progress, transcript entries, provider incidents and non-pulse agent costs; a chat's current branch of turri entries. |
40
- | `onLedgerEvent`, `readLedger`, `ledgerDir`, `runViews`, `pulseView`, `describePulseView`, `describeRuns`, `ledgerProjects`, `earlierPulses`, `asJob` | what turri did, as facts - the [ledger](using.md#the-ledger): each event heard as it is recorded, and every run and pulse read back, earlier sessions' too - see [the ledger in a host](#the-ledger-in-a-host). |
41
- | `doctor({ dir, models, env })`, `Check`, `Level` | whether the machine - and, with `dir`, that project - is ready for turri, as `turri doctor` checks it: a list of checks to show in the host's own way - see [doctor in a host](#doctor-in-a-host). |
42
- | `orphansStopped` | the session stops orphaned process groups itself at startup and reports their count when it stopped any. |
43
-
44
- It is turri's own code, as the terminal runs it: a 0.x release may change any of it.
45
-
46
- ## A project's first config
47
-
48
- ```js
49
- import { initConfig, piModelCatalogue, bedrockMakers, bedrockModelsIn, bedrockDefaultModels } from "@turri-dev/core/config";
50
-
51
- const catalogue = await piModelCatalogue();
52
- bedrockMakers(catalogue); // [{ maker: "xai", label: "xAI", regions: ["global", "us", "in-region"] }, ...]
53
- bedrockModelsIn(catalogue, { maker: "xai", region: "global" }); // the maker's chat models there, with their prices
54
- const offered = bedrockDefaultModels(catalogue, { maker: "xai", region: "global" });
55
- const { written, message } = await initConfig(project, { models: { harness, coding }, catalogue });
56
- ```
57
-
58
- `initConfig` writes config.turri.yaml as `turri init-config` does, and returns what it did - `written`, and `message`, the lines the terminal prints. It is async.
59
-
60
- - `vendor` - `anthropic`, `openai`, `google`, `amazon-bedrock`, `claude-code` (a Claude subscription, through the [pi-claude-code](https://github.com/earendil-works/pi-claude-code) extension) or `other` - fills in that vendor's own two models (`VENDORS` has each one's label and models).
61
- - `bedrock: { maker?, region }`, on Amazon Bedrock, says whose and where. turri's own pair is written where it has one - Anthropic's and OpenAI's in `BEDROCK_REGIONS` - and otherwise the pair `bedrockDefaultModels` offers from [pi](https://pi.dev)'s catalogue: any maker and geography it has.
62
- - `models: { harness, coding, strong? }` writes those two instead - any pair [pi](https://pi.dev)'s catalogue has as chat models, full model ids without a thinking level (`amazon-bedrock/global.xai.grok-4.7`). They go wherever the vendor's own would: the two models with the thinking turri writes, the commented-out `judge-model` and `models:` examples, `strong` - the judging examples' model - being `harness` unless given. The vendor, the Bedrock maker and the geography are read from them, so neither `vendor` nor `bedrock` is needed. A model the catalogue does not have, or that is not a chat model, writes nothing: `written` is false and `message` says which, with the closest the catalogue has.
63
- - `catalogue`, the one the host already read, saves reading it again.
64
-
65
- The message says whose models were written - "with xAI's models on Amazon Bedrock (global)" - and how to sign in: an `AWS_PROFILE` or a Bedrock API key, never a region. For a geography that needs one, it says which turri calls it in - `turri calls eu's models in eu-central-1. AWS_REGION, set, overrides it - and so does your AWS profile's region, when it is in eu.` - `bedrockAwsRegion(geography)` being that region, and `bedrockNeedsAwsRegion(geography)` whether the geography needs one. turri sets it itself: `createTurri` - and `turri` in a terminal, and every command that calls a model - sets `AWS_REGION` for the project's Bedrock models before any is called, when they need a region and neither `AWS_REGION` nor `AWS_DEFAULT_REGION` is set, and works it out again when the config's models change through `/settings` and as each pulse takes its model. A host that shows the person where their models run reads `bedrockRegionFor(projectDir)` - "turri calls these models in eu-central-1" - rather than asking them to set anything.
66
-
67
- ## How a project stands
68
-
69
- ```js
70
- import { projectStanding } from "@turri-dev/core/plain";
71
-
72
- for (const { plainFile, module, drift, driftError, completion, completionError } of projectStanding(projectDir)) {
73
- // From the records on disk. With a session, turri.standing() also knows running pulses and halts.
74
- }
75
- ```
76
-
77
- `projectStanding` gives each module of the project what `drift` and `functionalityCompletion` give it asked alone - `drift`, every codebase of its requires chain with what is left to regenerate there, and `completion`, its chain's functional specs completed and conformance tested - in one call. Asked module by module, each call parses and reads the whole chain below the module again: on a project of a dozen modules in one chain, seconds. Asked of the project, each file is parsed once and each codebase's record read once, the modules below shared by every chain they are in.
78
-
79
- - Both standing readers plan and start nothing. A worker needs no session, job registry or work loop.
80
- - `files` are the .plain files to look at, absolute or from the project. Without them, every .plain file in the project's folder.
81
- - A module drift or completion cannot say - one that does not parse, a module it requires not there - has `driftError` or `completionError`, the message, in place of the answer; the others are answered all the same.
82
-
83
- What it reads is kept between calls while it holds: a parse while the files it read are as they were - their text, and the files it looked for still not there - a codebase's record by the commit its history is at, a config file by its size and modification time. Asked again with nothing changed, it costs a fraction of the first call; a change is seen at the next. `plainGraph`, `checkPlainFile`, `plainFileParser`, `drift` and `functionalityCompletion` keep the same.
84
-
85
- ## Models from a pi extension in a host
86
-
87
- A provider a [pi](https://pi.dev) extension registers - `claude-code`, a Claude subscription through Claude Code ([a Claude subscription](claude-subscription.md)), or a company's own gateway - is in a host's chats as in the terminal's: each chat's resource loader loads the person's installed pi packages, and turri's agents take the providers from the chat. Without a chat, turri loads the installed extensions itself - `piModelCatalogue`, `doctor` and `initConfig` see their providers. What a host does with pi's model runtime itself before a chat is open - its sign-in sheet listing the providers and whether each is connected, say - takes `installedModelRuntime(cwd?)`: pi's runtime with the installed extensions' providers in it, loaded once a process. A `ModelRuntime.create()` of the host's own has none of them, and `claude-code` would be missing from the list until a chat is open. `EXTENSION_PROVIDERS` names the providers turri knows come from an extension - `claude-code` - each with its label, the command that installs its extension, and how it is signed in to: `claude-code`'s sign-in is Claude Code's own, `claude auth login` in a terminal, and pi's login for it refuses, saying so. The host's process needs the person's PATH, as for doctor below, to find `claude`.
88
-
89
- ## doctor in a host
90
-
91
- ```js
92
- import { doctor } from "@turri-dev/core/host";
93
-
94
- const checks = await doctor({ dir: project, env: engineEnv });
95
- // [{ level: "ok" | "missing" | "limited" | "info", name, detail, more?, fix? }, ...]
96
- ```
97
-
98
- `doctor` runs the checks `turri doctor` prints, and returns them: Node, bash, git, which OS sandbox is up under the agents' commands, and whether any model provider has credentials. With `dir`, the project too: whether this machine has the toolchains its modules' implementation reqs name, what in its testing scripts it does not have, and - when its config names a `claude-code/...` model - the `Claude subscription` check: pi-claude-code installed, Claude Code on the PATH, signed in to a subscription, and nothing set that the extension refuses. It prints nothing and asks nothing; each check's `fix` is plain text, to show as it is. A check `missing` means turri cannot run until it is fixed, `limited` that it runs with less.
99
-
100
- - `dir` is the project to check - not the process's working folder, which in a host is not the project. Without it, only the machine is checked.
101
- - `models: true` asks each model the project's config.turri.yaml names for a word, with this machine's credentials - a request a model, which costs money. It is off by default: run it when the person asks.
102
- - `env` is the environment whose PATH is looked in - for bash, git, the sandbox, the toolchains and what the testing scripts run - by default the process's own. A Mac app opened from Finder runs with `/usr/bin:/bin:/usr/sbin:/sbin`, not the person's shell's PATH: pass the environment the host's engine runs turri with, so doctor checks the PATH turri will actually have.
103
-
104
- It never holds the host's thread up: every command it runs - bash, git, the sandbox, `java_home`, a base folder's `git ls-files` - runs without blocking, side by side, and the project's modules are parsed one at a time, the thread given back between them.
105
-
106
- What matters only in a terminal - `turri` on the PATH, a plain `pi` an older turri made load turri - is left to `turri doctor`.
107
-
108
- ## The session in a host
109
-
110
- Run one project session per engine process, with the project as its working directory. `createTurri()` records host mode even with no callbacks; its banner reports the embedded version and project config, without the terminal's CLI update and PATH checks. Supply `onEvent` to observe startup as well as later events:
111
-
112
- | `event.type` | what to read |
113
- | --- | --- |
114
- | `orphansStopped` | `count` process groups cleaned up by turri at startup |
115
- | `incident` | the model `event` (with `job` when part of a pulse) and `text` for display |
116
- | `agentCost` | a model call outside a pulse: optional `role`, this call's `cost`, and the session's `total` for that role. Pulse costs are already in the job's usage. |
117
- | `skillProgress` | `chat` and `progress`: skill name, phase names, current index (`-1` while starting), attempt and optional description. `null` clears it. |
118
- | `captureProgress` | `chat` and a `CaptureStatus` snapshot for the `/capture` that chat started. `capturePhases(status)` returns the phase names and current index for the actual pipeline. |
119
- | `captureEnded` | `chat`, the source `root` and `state`. On `completed`, `result.plainDir` is the project to offer to open, and `result.reportFile` the report. On `failed`, `error` says why; `stopped` means the run was interrupted. |
120
- | `entry` | `chat` and the typed turri transcript `entry`. Use `entries(chat)` to replay the current branch; subscribe to the chat's pi session for its ordinary messages. |
121
-
122
- ```js
123
- import { createTurri } from "@turri-dev/core";
124
-
125
- process.chdir(project); // the session is the project's in the process's working folder
126
- const turri = await createTurri({
127
- onEvent: (event) => { // registered before startup and before any restored chat opens
128
- if (event.type === "skillProgress") showSkill(event.chat, event.progress); // null clears it
129
- if (event.type === "entry") showTranscriptEntry(event.chat, event.entry);
130
- },
131
- onJobChange: (job) => {}, // a job started, moved on, did something, or ended - any chat's
132
- onPlanChange: () => {}, // what is planned changed with no job
133
- dialogs: (chat) => ({ select, input }), // a chat's questions, put in the host's own dialogs - each with a signal to close it
134
- uiContext: (chat) => uiContext, // a chat's other UI calls - notices, the working line
135
- surface: SURFACE, // the host's UI, in its own words, told to the model in place of the terminal's
136
- systemPrompt: (prompt) => prompt, // the last word on the whole system prompt, each turn
137
- extensions: [browser, terminal], // the host's own extensions, built into every chat after turri's
138
- restore: true, // reopen the last session's chats here, as `turri --continue` does
139
- onNotice: (notice) => {}, // the sentinel puts something to the person: draw it in notice.chat
140
- onNoticeOver: (notice) => {}, // ...answered, dismissed, ignored or superseded: take its card down
141
- onConcluded: (conclusion) => {}, // the sentinel is done with a pulse - or a check: holds, wrong or unchecked, told to conclusion.chat
142
- pulseEndsShown: true, // the host shows each pulse that lands and each conclusion itself: the chat is told without a turn
143
- onChatSession: (chat, session) => {}, // a chat's session replaced, same id: the sentinel's, fresh for each pulse - follow this one
144
- sentinel: {
145
- tools: [browserTool], // the sentinel's own tools, beside turri's: what it tests a launch with
146
- surface: "...", // where the person watches it use them, in the host's words
147
- },
148
- });
149
-
150
- const chat = await turri.openChat(); // { id, title, status, shown, session }: a fresh chat, shown
151
- chat.session.subscribe((event) => {}); // pi's session: its events, prompt(), abort()
152
- await chat.session.prompt("add a cart to the shop");
153
- turri.focus(other.id); // the chat the person looks at now
154
- await turri.interrupt(chat.id); // ctrl+c: "stopped" what it was doing, else "ended" the session - "ignored", "missing"
155
- await turri.decline(chat.id); // ctrl+c at a question: "declined", the turn going on - "none", "missing"
156
- turri.chats(); // [{ id, title, status: "idle" | "working" | "question" | "unread", shown, role? }]
157
- turri.notices(); // the notices open now
158
- turri.check({ module: "app", funcIds: ["add-task"] }); // the sentinel to test these in what is launched of app: { check: id } or { refused: why }
159
- turri.settingChoices("harness-model"); // every value /settings offers for a setting, whole: every model signed in to
160
- turri.settingChoices("harness-model", "openai/gpt-6-astra:"); // after a colon, that model's thinking levels
161
- turri.turnOnConformanceTests("app.plain"); // conformance tests on: the file written - config.turri.yaml, or the stack's
162
- await turri.answer(notice.id, { action: 0 }); // or { steer: "…" }, { dismiss: true }, { ignore: true }: "done", "dismissed", "ignored", "refused", "over", "missing"
163
- turri.onChats((chats) => {}); // a chat opened, closed, renamed, working or done
164
- await turri.closeChat(chat.id); // its turn stopped, its conversation deleted - its pulses run on
165
- turri.jobs(); // every pulse any chat started
166
- turri.status(); // modules, unreplaced jobs, planned rows (including held previews)
167
- turri.launches(); // current state of all launches, oldest first; onLaunch reports changes
168
- turri.spending(); // this run's costs, across live and closed conversations and all jobs
169
- turri.entries(other.id); // turri's typed entries and custom messages, in branch order
170
- await turri.dispose(); // every chat let go, what launches started stopped
171
- ```
172
-
173
- - **The chats.** Up to nine, each its own history, model, thinking level and stack, all on the session's one job registry and work loop - see [chats](chats.md). `openChat({ sessionFile })` reopens a saved one. A pulse's end goes to the sentinel (below), and is shown in the chat `focus` last named - its agent told of a pulse that landed only to say so and what the sentinel is doing with it, and not told of one that went wrong. What the `surface` says to do once something is launched is then not done after a pulse: the sentinel tests what was launched. With `sentinel: false`, it is told to the chat that asked for it, its agent reacting there - to the chat `focus` last named when that one is closed. A chat is never hidden from turri's side: what the host does not show, it still runs, and its questions go to the host's dialogs at once - the host decides where they wait. `status` says a turn is running (`working`) or that it said something since it was last focused (`unread`).
174
- - **Interrupting.** `interrupt(id)` is the terminal's ctrl+c for a host's key or button: it stops what that chat is doing - its turn, a skill or a tool in it, a `!` command, a compaction - and nothing in the other chats (`stopped`). A skill stopped keeps its run, to be continued. A question of the chat's open in the host's dialogs when its turn is stopped is over - declined - and its dialog's `signal` aborted, for the host to close it. A chat doing nothing ends the session, every chat with it, as `dispose` does (`ended`): turri never exits the host's process, so the host closes what showed it. An interrupt straight after one that stopped something is `ignored`, so pressing twice to be sure ends nothing. `session.abort()` is the chat's turn alone, and never ends the session.
175
- - **Declining a question.** `decline(id)` is ctrl+c at a question in turri's terminal: the question the chat asks now - its ask_user, a skill's interview, a review gate's escalation, whatever goes through the host's dialogs - declined. The asker is told "The user declined to answer the question." and the turn goes on; a review gate declined stands. It declines each question it is called at, however many in a row, and never stops the turn - that is `interrupt`. `none` when the chat asks nothing now, `missing` for a chat not open. A dialog that resolves with `undefined` is something else - dismissed, and in a question of several answers "done" with the boxes ticked so far.
176
- - **The record.** The chats are recorded in `.turri/chats.json` as the terminal records them, and `restore: true` reopens the last ended session's - without it, a host starts with none and deletes nothing. A chat closed is deleted; a session's chats are kept until five newer sessions have recorded theirs.
177
- - **Spending.** Closing a chat or starting a fresh conversation for the sentinel keeps its cost in the same total. Reopening a saved chat adds only its new costs; pi's `getSessionStats().cost` on that chat still shows its whole conversation. `regeneration` includes all job usage, even for a failed or replaced job. `other` excludes those calls. Read `spending()` when drawing the window and after a chat usage change, `onJobChange` or an `agentCost` event.
178
- - **The jobs.** Read `turri.status()` after `onPlanChange` or `onJobChange`. `turri.lookAhead(file)` previews the plan; to run it, send the chat `/regenerate app.plain`. No model turn stands between the command and the pulse. `turri.jobs()` includes replaced jobs; `status().jobs` leaves them out.
179
- - `job.diff` is the \*\*\*plain diff. `job.diffWhere` maps lines to their `file`, `line`, `section` and `written` text. Match `written` after a later edit: the diff may show a resource marker instead of the source link. Older ledgers may lack `written`.
180
- - `job.cases` groups `{ module, funcId }` by `add`, `patch`, `again` and `delete`. Use `again` to mark unchanged specs regenerated on request. A mechanical pulse has no functional specs; a non-pulse job has no `cases`. `job.queued` records them in the ledger too.
181
- - `job.building`, when present, names one functional spec: `{ spec: { module, funcId }, label, text, since }`. A single-spec conformance run can set it; a planned pulse covers its functional specs together, through `cases`.
182
- - **The questions.** `dialogs(chat)` gives a chat's two dialogs: `select(title, options, context, at, { signal })` and `input(title, context, { signal })`, each resolving with the answer, or undefined when the person dismissed it. `signal` is aborted when the question is over without the dialog's answer - declined by `decline`, or its turn stopped (`interrupt`, `session.abort()`): the host closes the dialog it opened for it, whatever it resolves with then being ignored. A host may leave it unread. The chat's questions, a skill's interview and a review gate's escalation are put in them; without them, in the `uiContext`'s own dialogs.
183
- - **The surface.** What turri tells the model of where the person watches the work is the terminal's by default: regen, the side panel on `ctrl+h`, `/pulses`. In a host none of that is there, and the model would send the person to keys and panels that do not exist. `surface` is the host's own description of its UI - the views it has in place of the terminal's, what its marks and buttons mean, where questions appear - in its own words. Given, turri leaves every terminal instruction out of what the model is told and puts the surface in turri's identity, as a `<surface>` block, where the identity speaks of regen. It reaches the side questions and the tools' own words too: a pulse not found says the `pulses` tool lists them, not `/pulses`. Text only the person sees in the terminal - the job panel, the side panel - is the terminal's and stays as it is. Without `surface`, the prompt is the terminal's, byte for byte. What the conversation is to do once something is launched belongs there too - open it in the host's preview, say what to test: it is told once each launch it asked for ends, and - with `sentinel: false` - each launch after a pulse under `launch-after-pulse`, and does then what it was told to do once something is launched. With the sentinel on, the sentinel tests what is launched after a pulse, and the conversation only says it landed. With `sentinel: false`, the chat that asked for a pulse that lands under `launch-after-pulse` is told as it lands that its commit is being launched in the background - to say so in a line and offer nothing else - and then told the launch's end. Every launch, as it is asked for, starts and ends, comes to the host as `onLaunch(launch)` - its codebase, commit, status and summary. `summary` is what the launch agent said - where it runs, or why it did not come up - and nothing of turri's: show its first line as the launch's line. What turri stopped for the launch comes apart, in `stopped`, one entry a process, as it stops them - while the launch runs too: `why` (`below` - a launch of a module below it in its chain, whose code it holds; `held` - a server of another module's launch that held what it needs, `held` saying what, "port 5173"; `left-behind` - one an earlier turri session left running), the `module` whose launch started it, that `launch` and its `commit` when known, the process's `name`, `pid` and `url`. Show it beside the launch from those fields - "stopped bestiary's launch at befa07f - upgrades holds its code" - never by reading a sentence. `launchText(launch)`, exported beside the type, is the two together as the chat and the terminal read them - turri's lines, then the summary - for a host that shows the whole at a click. One whose code runs already - the chat asking for what runs, a pulse that landed only tests - comes once, `status: "launched"` with `already: true`, its own cause and the commit it was asked for; the launch that started what runs is not told again. One that ended with a newer launch of its codebase - or of a module built on it - waiting comes with its real status and `replacedBy`, the newer one's id: that one starts at once and stops what it started, so draw it as replaced rather than as running - the chat that asked for it is told so, and hears the newer one's end instead, as for one `superseded` as it waited (`supersededBy`). A launch whose servers a newer launch stopped later - one of a module built on it, which holds its code, or one that needed a port or anything else they held - comes again too, with `replacedBy` set: nothing of it runs, and the newer launch's `stopped` says what it stopped, whose it was and why (see [across a project](launch.md#across-a-project)). The newer launch may be of another codebase: what runs of a module is its own newest launch's unless one has `replacedBy`, and then the launch that id names. What a launch started, halted on request (`/halt launched`, the `halt` tool) with nothing of it left running, comes again as `status: "stopped"`, "Stopped on request.": nothing of the codebase is launched from then on, and its next launch launches anew. A launch that said a server runs is `launched` only while one it started itself runs: something else answering at its port - another turri's server, another program - makes it `failed`, its summary saying what holds the port, whose it is and how to free it. What an earlier turri's launches left running - a host that quit without `dispose`, a turri killed outright - is stopped as the session starts and before each launch of its codebase, and the next launch's `stopped` has it, `why: "left-behind"` (see [what an earlier session left running](launch.md#what-an-earlier-session-left-running)).
184
- - **The banner.** The first chat's session starts with turri's banner, an entry `customType: "turri_banner"`. Its `data.config` is what turri says of the project's config files, a line each - `{ kind, file, text }`, `text` as the terminal shows it: `renamed`, a key turri renamed in the file itself, its value kept (`release-after-pulse` to `launch-after-pulse`) - information, nothing to do; `old-beside-new`, a file that sets an old name beside its new one, the old doing nothing - take it out; `unknown`, keys turri does not read - a setting it no longer has, a misspelt one. Draw `renamed` as information, the others as warnings, by `kind`, never by the words. `ConfigLine` and `ConfigLineKind` are exported.
185
- - **The system prompt.** `systemPrompt(prompt)` gets the whole system prompt for the turn - [pi](https://pi.dev)'s, turri's identity and blocks, the rules - after turri's own `before_agent_start` work, and returns what is sent. It is for what `surface` does not cover; to describe the UI, use `surface`, rather than words appended after turri's that contradict them.
186
- - **The mode.** Each chat is bound in [pi](https://pi.dev)'s `tui` mode: the work runs in the background and keeps the chat free, as the terminal does. Its other UI calls - its notices, its working line, a confirm - come to `uiContext(chat)`, as [pi](https://pi.dev)'s [SDK](https://github.com/earendil-works/pi) describes it.
187
-
188
- ### Conformance tests
189
-
190
- Conformance tests are on only with `conformance-tests: true` ([config](config.md#conformance-tests)) - off when unset: then no conformance pulse runs, and the chats' `conform` is refused - turning them on is the person's decision; `conformance-tests` is one of `configSettings()`, and `settingChoices("conformance-tests")` gives `true` and `false`. To turn them on from the host's own button, the session's `turnOnConformanceTests(plainFile?)` does what `/conform` does before it tests, with no model call: it writes `conformance-tests: true` where the module's value comes from - its own `config.turri.<module>.yaml`, or a required module's, when that sets the key, which `/settings` alone would not change, else `config.turri.yaml` - the chats' `conform` no longer refused, and returns the file it wrote, from the project. `plainFile`, absolute or from the project, picks the module; omitted, the project's. It starts no conformance pulse: the host offers that itself, with `/conform`. With them on, the chats write scenarios for a functional spec they judge needs them, as a \*\*\*plain change like any other - its test plain file, `<test-dir>/<module>/<func-id>.plain` - which the work loop then tests.
191
-
192
- A host's chats run the [background skills](skills-and-gates.md) in the background, as the terminal's do - the two that write the testing scripts: `cultivate` returns at once, and nothing of the run shows while it runs. Its result's `details` say what it started: `{ background: true, kind?, plainFile? }` - `kind` the testing script it writes, `unit` or `conformance`, and `plainFile` the module it is for, relative to the project, each left out when there is none; `started: false` too when the skill was running already and nothing new was started - enough to show "writing the unit testing script for hello.plain, in the background" with no table of which skill writes which. Its end goes to the chat that started it, once that chat is idle: a run that did its work as an entry of its session, `turri_skill_run` (`data.text`, the line - `Unit testing script written: test_scripts/run_unittests_python.sh.`), that starts no turn; one that did not as a hidden message to its agent, `customType: "turri_skill_run"` (`details.skills`), that starts a turn in which the chat tells the person what went wrong, its `details` `{ skills, runs }` - `runs` one `{ skill, kind?, plainFile? }` for each run in it, for a turn marked "unit testing script not written · hello.plain". Meanwhile a module that lacks the script waits for it, its `why` in `mapPlan()` and `status()` `waiting for its unit testing script, which is being written` - or its conformance testing script - and starts by itself once it is written. `onPlanChange` fires as it starts waiting and as it stops - the script written, or the run ended without it - as it does whenever a module's `why` changes.
193
-
194
- A codebase that started from a [base folder](regenerating.md#the-base-folder) says so in `turri.status().modules`: `base: { folder, files }` gives the configured folder and how many of its files remain. A module built on it inherits `base`; a codebase with no base or no code yet omits it. turri refreshes it when a pulse lands.
195
-
196
- ### The sentinel
197
-
198
- The [sentinel](sentinel.md) is one of the host's chats: turri opens it with the first pulse that finishes, through the host's own `create` like any chat - `onChats` hears of it, `role: "sentinel"` - and never moves `focus` to it. It closes like any chat, and the next pulse that finishes opens it again; with it on, `openChat` opens up to eight.
199
-
200
- - **A conversation a pulse.** The sentinel checks each pulse from scratch, in a conversation of its own - one pulse at a time, the others waiting their turn. The chat keeps its id; its session is replaced. As it starts on a pulse, the session it had is stopped and let go (`abort`, `dispose`), a new one is made in its place, and `onChatSession(chat, session)` comes with it - before the pulse is put to it - then `onChats`; `session(id)` returns the new one from then on. A host that follows the sentinel's chat subscribes to that session in place of the old - an `onChats` listener that follows only the ids it has not seen would hear nothing more of it. The first pulse goes to the session the chat was opened with: there is no `onChatSession` for it. Each conversation's first message is the hidden brief of its pulse - `customType: "turri_sentinel_pulse"`, `details.jobId` - so a host that splits the sentinel's work by pulse on it still can; the conversations before are not in the new session, and what the host showed of them is its own to keep.
201
-
202
- - **Notices.** What it finds wrong comes as `onNotice(notice)`: `{ id, chat, severity: "error" | "warning" | "info", summary, evidence: string[], actions: [{ label, task }], module?, pulse?, job?, ignorable?, state: "open" }`. Draw it in the chat `chat` names - the one `focus` last named, or, while that is the sentinel, the chat that asked for the pulse. It is drawn there as a card in the transcript too. A host given `onNotice` answers it itself - the terminal's dialog is not opened - with `answer(id, …)`: `{ action: index | label }` starts that chat's agent on the action's task, `{ steer: text }` on the person's words, `{ dismiss: true }` on nothing, this once. A notice with `ignorable: true` - a gap in the \*\*\*plain the build settled with an assumption, which the person may leave as it is - takes `{ ignore: true }` too: offer it as its own button beside the actions. Nothing is done in the chat, the notice ends `state: "ignored"` (`"ignored"`), and turri writes it to the sentinel's guidance, so it is not raised again in this session or the next; on a notice without `ignorable`, `{ ignore: true }` is `"refused"` and the notice stays open. `onNoticeOver(notice)` comes as it is answered - and when a newer notice about its module supersedes it (`state: "superseded"`) - for the host to take the card down. `notices()` lists the open ones.
203
- - **Fixes it made.** The sentinel fixes the project's testing scripts and their config itself ([what it may do](sentinel.md#what-it-may-do)), and says so as a notice with `kind: "fixed"`, `severity: "info"`, no actions, the lines before and after in `evidence`: a note, with nothing to answer. Draw it as one - its card with a way to put it away (`answer(id, { dismiss: true })`), no "say what to do instead". It never supersedes a notice about its module. The terminal puts it in notifications.
204
- - **The machine is the person's.** turri installs nothing and changes no setting of the machine's or the person's shell, in any chat, the sentinel's included - and through a host's tools as through its own: a tool call whose input has a `command` string - a host's `terminal_run` - is refused when the command would (`machineChange`), with what to do instead (`machineChangeReason`), as turri's own `bash` is; and the sentinel's, also when it writes a `.plain` file, or starts or runs the code in `plain_modules` - what nobody launched: it tests what is launched. A tool that types into what already runs - a terminal's `terminal_type` at a shell prompt - is the host's to check: `machineChange(text)` says whether a line would change the machine, and why.
205
- - **Starting it.** Under `sentinel: ask` - as it is unset - the person is asked before it first opens in the session: a notice with `kind: "sentinel-start"`, `severity: "info"`, in the chat `chat` names, its `summary` the question in one sentence, no `evidence`, and its actions the answers - `Start the sentinel`, `Start it, and don't ask again`, `Not this session`, `Turn it off for this project`. Draw it as a question rather than as something wrong. `answer(id, { action })` answers it, by index or label - `"done"` - and `{ dismiss: true }` is not this session; turri writes `sentinel:` itself for the two that choose for the project. Until it is answered, the pulses that finish are held: neither the sentinel nor the chat hears of them. A host that offers the setting too writes it as `/settings` does - `ask`, `true` or `false` (see `configSettings`).
206
- - **Conclusions.** As the sentinel is done with each pulse - all well or not - `onConcluded({ job, verdict: "holds" | "wrong", summary, module, pulse, chat })` comes, and the chat `chat` names - the one `focus` last named, as for a notice - shows it and its agent says so in a line. A pulse turri cannot brief it on - what runs cannot hold the pulse's commit, turri's own error - ends `verdict: "unchecked"`, with an error shown in that chat as well.
207
- - **A host that shows them itself.** With the sentinel on, the default host has the chat report each landed pulse and each conclusion in a turn of its own. A host with a notification centre passes `pulseEndsShown: true` and presents them from `onJobChange` and `onConcluded`. Both still reach the chat - `customType: "turri_job_landed"` and `"turri_sentinel_concluded"`, hidden and starting no turn - so it can answer when asked. The terminal uses this quiet delivery with its own notifications tab. Host notice actions, the sentinel's briefs and checks, and delivery with the sentinel off are unchanged.
208
- - **Checks.** `check({ module, funcIds })` asks the sentinel to test functional specs of one module - the person picked them on a list of its built ones, say - in the background, on its own judgement, reported as a pulse is. `module` is the module whose launch is checked, by name; `funcIds` the functional specs to test, each `module:func-id` - of that module, or of any module its requires chain builds on, whose code its codebase holds: `check({ module: "predators", funcIds: ["depths:gene-fragments"] })`. A bare func-id is the module's own. The check and its brief name each as `module:func-id`. It returns `{ check: id }` at once, or `{ refused: why }`, saying which: the sentinel off (`sentinel: false`), or not started this session; a module not in the project's folder, an import module, one that does not parse; a name outside its chain - `Not in predators' codebase: arena:waves - arena is not predators or a module its requires chain builds on (depths, ocean).`; a func-id its module does not have; one not built in the module's own codebase as its \*\*\*plain has it now - with where the module's code is built on instead, when it is. What is tested is what is launched of the module - its own codebase's code, which holds the code of every module its requires chain builds on - never what a pulse is writing, and never another module's: turri does not choose one for it. Under `sentinel: ask`, a check asked before the sentinel was started puts the start question first, as a pulse does - `check` set on the notice - and waits for the answer.
209
- - **Queued with the pulses.** It waits its turn behind the sentinel's work, and is taken in a conversation of its own: `onChatSession`, then the conversation's first message, the hidden brief of the check - `customType: "turri_sentinel_check"`, `details: { checkId, module, funcIds }`. A pulse of its module that lands meanwhile waits for it, rather than stopping it.
210
- - **In what is launched.** The sentinel launches nothing. Once the module's launches are settled - nothing launching, nothing waiting to - it is told what runs and where, as for a pulse, and each functional spec's text and scenarios, as turri reads them, to test those and not the module's others. With nothing of the module launched - never, or halted - the check ends unchecked, its summary saying so in the person's words - `Not checked: nothing of app is launched to test it in - ask the chat to try it first, which launches it.` - and with no notice: it is an answer, not an error. When the module's last launch did not come up, the sentinel is told why, and that is its finding.
211
- - **Reported as a pulse is.** Its notices come as `onNotice`, with `check` - its id - and its module. It ends with `onConcluded({ check, verdict, summary, module, chat })` - `check` in place of `job`, which it has none of. A check that never runs - nothing of the module launched, the person did not start the sentinel when asked, it could not be opened, it was closed before it got to it - ends `verdict: "unchecked"`, the summary saying why, which the sentinel itself never gives. The ledger has `sentinel.asked` as it is asked for, and `sentinel.checking` and `sentinel.concluded` with `check`.
212
- - **Its model.** The `sentinel` role in `models:`, else the chat's model - `models.chat`, else `harness-model` - with its thinking, set as its chat opens: not pi's default model, which may not be one the project's provider has. What the person then picks in its chat stands. See [its model](sentinel.md#its-model).
213
- - **Its tools.** `sentinel: { tools }` are [pi](https://pi.dev) tool definitions registered in the sentinel's chat alone and told to it in its prompt - the host's browser, say, for it to test what is launched with. The rest of the host's `extensions` are built into its chat too, but their tools are refused it: only its own read, and these.
214
- - **Its surface.** `sentinel: { surface }` is where the person watches the sentinel use those tools, in the host's own words - the preview pane its browser and terminal show in, say. Given, the sentinel's prompt has it, as a `<surface>` block, in place of the person not watching it: it tries what is launched with the host's tools, where the person can watch, and keeps its own shell for what those cannot show - logs, exit codes, files. Without it, the person does not watch the sentinel, and the host's tools are only to test with as well. As for the conversation, `systemPrompt` has the last word on its prompt.
215
- - **Its surface.** What it is told is its own prompt, not the conversation's: the host's `surface` is not in it; `systemPrompt` still has the last word.
216
-
217
- A surface for a desktop app might read:
218
-
219
- ```js
220
- const SURFACE = `The person uses turri's desktop app, not a terminal: there are no keys to press. Slash commands are typed in
221
- the chat, and the toolbar's buttons send them too.
222
- - The Specs view shows each .plain file, every functional spec marked: a green dot is built, a pulsing ring regenerating,
223
- a hollow ring planned, grey waiting.
224
- - The Pulses view lists every pulse - running, planned and finished. A row opens what its agents did and its log; its
225
- Halt button stops it.
226
- - Your questions appear as cards above the message box: the person picks an option or types an answer there.
227
- - The Run button launches what is built and opens it.`;
228
- ```
229
-
230
- ## \*\*\*plain for a host
231
-
232
- ```js
233
- import { conceptBeingTyped, conceptsOf, findConcepts, plainGraph, stdlibTemplates, STDLIB_KINDS } from "@turri-dev/core/plain";
234
-
235
- const { modules, items, concepts, testPlainFiles } = plainGraph(projectDir);
236
- const app = modules.find((module) => module.module === "app");
237
- app.requires; // [{ name: "base", file: "/…/base.plain" }] - and imports, importedBy, requiredBy, the same way
238
- app.items; // ["/…/app.plain:11", "/…/app.plain:15"] - its own items, in order
239
- items.find((item) => item.id === app.items[1]);
240
- // { id, file, module: "app", section: "functional specs", line: 15, funcId: "fill-cart", text: ":User: can fill :Cart:.",
241
- // defines: [], uses: [{ concept: ":User:", definition: "/…/base.plain:8" }, { concept: ":Cart:", definition: "/…/app.plain:11" }],
242
- // resources: [{ text: "the schema", target: "schema.json", file: "/…/schema.json", line: 15 }],
243
- // testPlainFile: "/…/tests/app/fill-cart.plain", scenarios: { conformance: [{ id: "adds-an-item", text: "…", line: 8 }], acceptance: [] } }
244
- testPlainFiles[0];
245
- // { file: "/…/tests/app/fill-cart.plain", module: "app", funcId: "fill-cart", item: "/…/app.plain:15", conformance: [...], acceptance: [...] }
246
- concepts.find((concept) => concept.definition === "/…/base.plain:8");
247
- // { concept: ":User:", definition: "/…/base.plain:8", module: "base", text: "is a person who signs up.", usedBy: [...] }
248
- ```
249
-
250
- - **The graph.** `plainGraph` reads every .plain file in the project's folder and its `template/` folder, and every module they import or require, wherever the parser finds it - the standard library's templates too. A **module** is a file: its imports, resolved as the parser reads an import (a `stdlib/` module from turri's own folder), its required modules, resolved as the requires chain finds them - `file: null` when one is not found - and the reverse of both, `importedBy` and `requiredBy`, so a host goes up and down the requires chain without inverting anything. An **item** is one item of a section - a definition, an implementation req, a test req, a functional spec - with its file, the line it starts on (a functional spec's, its `# <func-id>` heading's), its text (a functional spec's, its body), a functional spec's `funcId`, its `testPlainFile` - null when it has none - and its `scenarios`, `{ conformance, acceptance }`, each `{ id, text, line }`, the concepts a definition defines, and each concept it names with the item that defines it: its own module's definitions, its imports', and those its required modules export, as the parser sees them from that module. `definition` is null for \*\*\*plain's own concepts, and for one defined nowhere the module can see. Its `resources` are the linked resources it names - `[text](target)`, as the parser reads them - each with `file`, the file regenerating reads it from (the template folders first, then the current folder), null when it is not there, and `line`, the line the link is on. `resources` is on every item, `[]` when it names none: a turri that gives no resources has no field. A **concept** is one definition of it - or \*\*\*plain's own, `definition: null` - with every item that names it there. An item's id is `<file>:<line>`: the file to open and the line to go to. A **test plain file** - each `.plain` file under the project's test folder (`test-dir`, `tests` by default) - is a node of its own: its `module` and `funcId` as its front matter binds it, `item`, the id of the functional spec it binds to, and its `conformance` and `acceptance` scenarios, each with the line its `# <scenario-id>` heading is on. One that does not parse, is outside its module's folder, or binds to no functional spec has `error`, and `item` null.
251
- - **What does not parse.** Nothing throws. A file that does not parse has `error`, the parser's message; its links are what its front matter says, and its items what of its own text reads without its imports. A file whose items Liquid moves keeps the lines of its own text.
252
- - **Concepts.** `conceptsOf(plainFile)` is what one module can name - `{ concept, definition, module }`, `definition` the text after its concepts, `module` null for \*\*\*plain's own - for suggestions as the person types. Inside a test plain file, call it with the module's file the test plain file binds to: its scenarios name that module's concepts. `findConcepts(text)` is every concept written in a piece of text, `{ concept, start, end }`, and `conceptBeingTyped(text)` the one at its end still open - `{ typed: ":Us", start }`, or undefined - both with the parser's own pattern.
253
- - **The standard library.** `stdlibTemplates()` is every template in turri's `stdlib/`, sorted: `name` - what a module imports it as - `file`, `kind` (`backend`, `frontend`, `cli`, `library` or `lang`), `description`, `text`, `imports` as the parser reads its front matter, a stack's `conformance` template when it has one, and a conformance template's stack as `tests`. `isStack(template)` says whether it is a stack to import; `STDLIB_KINDS` is the kinds in order, each with its title.
254
-
255
- ## The ledger in a host
256
-
257
- `createTurri` starts the ledger itself, in the process's working folder - the project's - so a host needs nothing to have one: its pulses are recorded as `host` runs, each event with the chat its work was asked for in, and the chats' `pulses` already tells the model of earlier sessions' pulses. What the host can do with it is show it.
258
-
259
- ```js
260
- import { onLedgerEvent, pulseView, readLedger, runViews, earlierPulses, ledgerProjects } from "@turri-dev/core/ledger";
261
-
262
- // Each event as it is recorded - written or not, so a project with ledger-keep: 0 is heard too.
263
- const stop = onLedgerEvent((entry, project) => {
264
- if (entry.kind === "healer.failed") notify(`the ${entry.healer} failed: ${entry.error}`);
265
- if (entry.kind === "provider.error" && !entry.transient) notify(`the model provider: ${entry.error}`);
266
- });
267
-
268
- // The project's runs, the most recent first, each with its pulses, the most recent first - how each ended, how long, what it cost.
269
- const runs = runViews(projectDir);
270
-
271
- // One pulse, from this session or an earlier one: its rounds, test runs, verdicts, healers, refusals, history.
272
- const view = pulseView("646d", readLedger(projectDir, { job: "646d" }));
273
-
274
- // Earlier sessions' pulses as jobs, to list beside this session's - none this session's registry knows.
275
- const { jobs, more } = earlierPulses(ledgerProjects(projectDir), new Set(turri.jobs().map((job) => job.id)));
276
- ```
277
-
278
- - **Live.** `onLedgerEvent(listener)` is told every event as turri records it, with the project it is about, until what it returns is called; a listener that throws misses that event and nothing else. It is the pulse's own detail - its stages, test runs, verdicts, refusals - where `onJobChange` is the job as a whole.
279
- - **Read back.** `readLedger(project, { job, run, kinds, since })` is the project's events, oldest first, the gzipped runs too; `runViews` and `pulseView` gather them into runs and pulses, and `describePulseView` and `describeRuns` say them in lines, as the chat's `pulses` tells them. `ledgerProjects(dir)` finds the ledgers of a folder and the projects under it. `earlierPulses(projects, known, runs = 3)` gives the last runs before this one as `Job`s - the shape a host already draws for this session's - each marked `earlier: { run, runMode, lines }`, `lines` what the ledger says of it, and with its `cases`, `diff` and `diffWhere` - the \*\*\*plain diff it regenerated, as last steered, and where its lines are written - as a pulse of this session has them (a pulse recorded before `job.diff` was has none); `more` is how many runs are beyond them. They are read only: never started, halted or waited for. turri's own side panel lists them so, as **earlier sessions**.
280
- - **What it is for.** Looking up, never deciding: what is built and what is left come from the records and the work loop, as before. Its events and their fields are `LedgerEvent`'s - a kind is added, never changed, and every event carries `v: 1`.
281
-
282
- ## Running it
283
-
284
- The host entry is compiled JavaScript, so any Node from 22.19 runs it - Electron's own included; nothing strips types. It finds turri's own folders - `genome/`, `stdlib/` - beside `dist/` in the package, wherever npm installed it; `.pi/`, the themes, is turri's CLI's.