@turri-dev/core 0.1.1-next.8cda3cc → 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
@@ -0,0 +1,32 @@
1
+ /**
2
+ * What turri throws when a call cannot be made as asked - a broken precondition, never an expected outcome (those are
3
+ * returned). A front end tells them apart by `code`, and recognises one with `isTurriError` rather than `instanceof`:
4
+ * a front end and a package it depends on can each have their own copy of turri installed.
5
+ */
6
+ export type TurriErrorCode =
7
+ /** A config.turri.yaml that does not parse: nothing is started on it. */
8
+ "config-invalid"
9
+ /** Asked of turri but refused: a module that cannot be built as it is, conformance tests turned off, two options that exclude each other. */
10
+ | "refused"
11
+ /** No room for another chat. */
12
+ | "chat-limit"
13
+ /** A chat asked of a session with no front end, which has none. */
14
+ | "no-chat"
15
+ /** A handle to a chat that has been closed. */
16
+ | "chat-closed"
17
+ /** A chat, a job, a notice or a module that is not there. */
18
+ | "not-found"
19
+ /** A front end's session made without turri's extension built into it. */
20
+ | "extension-not-built"
21
+ /** A second session opened in a process that has one open. */
22
+ | "session-open"
23
+ /** Stopped through its signal before it was done. */
24
+ | "aborted";
25
+ export declare class TurriError extends Error {
26
+ readonly code: TurriErrorCode;
27
+ constructor(code: TurriErrorCode, message: string, options?: {
28
+ cause?: unknown;
29
+ });
30
+ }
31
+ /** Whether `error` is a TurriError - from this copy of turri or another - and, given `code`, one with that code. */
32
+ export declare function isTurriError(error: unknown, code?: TurriErrorCode): error is TurriError;
package/dist/errors.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What turri throws when a call cannot be made as asked - a broken precondition, never an expected outcome (those are
3
+ * returned). A front end tells them apart by `code`, and recognises one with `isTurriError` rather than `instanceof`:
4
+ * a front end and a package it depends on can each have their own copy of turri installed.
5
+ */
6
+ const BRAND = Symbol.for("turri.error");
7
+ export class TurriError extends Error {
8
+ // The brand any copy of turri recognises, on the prototype - kept out of the class's type.
9
+ static {
10
+ Object.defineProperty(this.prototype, BRAND, { value: true });
11
+ }
12
+ code;
13
+ constructor(code, message, options) {
14
+ super(message, options);
15
+ this.name = "TurriError";
16
+ this.code = code;
17
+ }
18
+ }
19
+ /** Whether `error` is a TurriError - from this copy of turri or another - and, given `code`, one with that code. */
20
+ export function isTurriError(error, code) {
21
+ if (typeof error !== "object" || error === null || error[BRAND] !== true)
22
+ return false;
23
+ return code === undefined || error.code === code;
24
+ }
@@ -1,13 +1,13 @@
1
- import type { ExtensionAPI, ExtensionContext, ExtensionFactory } from "@earendil-works/pi-coding-agent";
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { stackOnMachine } from "./stack.ts";
3
3
  import { createAskUserTool } from "./tools.ts";
4
4
  import { fromWorkingDir } from "./loop-tools.ts";
5
5
  import { type SessionLaunches } from "./launch-session.ts";
6
6
  import { type WorkLoop } from "./regenerate/loop.ts";
7
7
  import { COMMAND_OUTCOME, type CommandOutcome, type Exchange } from "./chat-entries.ts";
8
- import type { QuestionView, TurriView } from "./view.ts";
9
8
  import { type AskUser, type AskUserIO } from "./ask.ts";
10
9
  import { type TurriCore, type TurriHost } from "./chats.ts";
10
+ import { type ClientInfo } from "./client.ts";
11
11
  import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
12
12
  /**
13
13
  * Puts a skill step's question to the person, when there is one to ask.
@@ -26,10 +26,8 @@ export declare const NO_USER_ANSWER: string;
26
26
  export declare function askUserVia(ctx: ExtensionContext, onExchange: (question: string, answer: string, said?: string) => void,
27
27
  /** Given, "/btw ..." typed as an answer is a side question: answered with this, and the question asked again. */
28
28
  aside?: (question: string) => Promise<string>,
29
- /** A host's own dialogs (TurriHost.dialogs), the question put in them instead of the terminal's. */
30
- dialogs?: AskUserIO,
31
- /** The view's way of asking (TurriView.questions), for a chat with a screen and no host dialogs: else pi's own dialogs. */
32
- questions?: QuestionView): AskUser;
29
+ /** The front end's own dialogs, the question put in them - else pi's own, in a chat with a screen. */
30
+ dialogs?: AskUserIO): AskUser;
33
31
  /**
34
32
  * ask_user, for the conversation's agent too - the same dialog a skill's interview uses: options to
35
33
  * pick from, several at once, "Something else…" to type instead, "Chat about this" to talk it over in
@@ -39,27 +37,36 @@ questions?: QuestionView): AskUser;
39
37
  * ask_user, for the conversation. `afterAnswer` may add to what an answer tells the model - a skill the person picked,
40
38
  * to start at once.
41
39
  */
42
- export declare function chatAskUserTool(dialogs?: AskUserIO, afterAnswer?: (answer: string) => string | undefined, questions?: QuestionView): ReturnType<typeof createAskUserTool>;
40
+ export declare function chatAskUserTool(dialogs?: AskUserIO, afterAnswer?: (answer: string) => string | undefined): ReturnType<typeof createAskUserTool>;
43
41
  export type { TurriHost } from "./chats.ts";
44
42
  /**
45
43
  * A turri session: its job registry and work loop, the ledger, and its chats, each with turri's extension in it
46
- * (chats.ts). The terminal makes one as it starts (pi-launch.ts), a host with `createTurri` (host.ts); `persist`
44
+ * (chats.ts). Every front end makes one through `createTurri` (session.ts); `persist`
47
45
  * records the open chats for `turri --continue`; `view` is what a front-end draws of it (view.ts) - none for a host.
48
46
  */
49
47
  export declare function createTurriCore(host?: TurriHost, options?: {
50
48
  persist?: boolean;
51
49
  dialogs?: (chat: string) => AskUserIO | undefined;
52
- view?: TurriView;
53
- /** A host can run the session without supplying any callbacks. */
54
- mode?: "chat" | "host";
50
+ /** How the ledger records the run (`run.started`'s `mode`): the front end's word for it. Default: `unattended`. */
51
+ mode?: string;
52
+ /** Who runs turri: the front end's name and version, for the banner, the ledger and run reports. Default: the core. */
53
+ client?: ClientInfo;
54
+ /**
55
+ * A capture wrote a project of its own: open it, as the front end opens projects - the person asked, if it asks -
56
+ * and tell its report there. True when it does; false leaves the report to the chat that started the capture.
57
+ */
58
+ openProject?: (dir: string, context: {
59
+ summary: string;
60
+ reportFile: string;
61
+ }) => Promise<boolean>;
62
+ /** This session is opened in the project a capture wrote: its report, told in the first chat. */
63
+ captured?: {
64
+ summary: string;
65
+ };
55
66
  }): TurriCore;
56
- /** The session of this process: pi-launch.ts's, or one made as pi first builds the extension (`pi -e src/extension.ts`). */
57
- export declare function processSession(make?: () => TurriCore): TurriCore;
58
- declare const extension: ExtensionFactory;
59
- export default extension;
60
67
  /**
61
68
  * The session's work loop, for a host to read: made with the first chat's context - the models it plans with - when no
62
- * chat has asked for work yet.
69
+ * chat has asked for work yet, or with the config's models when no chat is open.
63
70
  */
64
71
  export declare function sessionLoop(session: TurriCore): WorkLoop;
65
72
  /** The functional specs a command's words name first, each as module:func-id - a comma after one allowed - and the words after them. */