@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
@@ -1,14 +1,9 @@
1
- import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
1
+ import { existsSync, readdirSync, statSync } from "node:fs";
2
2
  import { basename, extname, join, relative, resolve, sep } from "node:path";
3
- import { configModuleFor, testDirOf } from "../config.js";
3
+ import { testDirOf } from "../config.js";
4
4
  import { projectDirOf, resolveTemplateDirs } from "../regenerate/paths.js";
5
- import { isImportModule } from "../regenerate/requires.js";
6
- import { testingGap } from "../regenerate/testing-steps.js";
7
- import { missingBaseFolder } from "../regenerate/base-folder.js";
8
- import { conformanceTestsOn } from "../conformance-switch.js";
9
- import { testedFuncIds } from "../regenerate/records.js";
10
- import { projectModules, projectTestFiles, testPlainFileRefusal } from "../test-plain-files.js";
11
- import { plainFileParser, PLAIN_SOURCE_FILE_EXTENSION, PREVIOUS_SYNTAX_HINT, readPlainSourceMetadata, REQUIRES_DIRECTIVE } from "./parser.js";
5
+ import { projectTestFiles, testPlainFileRefusal } from "../test-plain-files.js";
6
+ import { plainFileParser, PLAIN_SOURCE_FILE_EXTENSION, PREVIOUS_SYNTAX_HINT } from "./parser.js";
12
7
  import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, getFunctionalSpecs, TEST_PLAIN_FILES, } from "./spec.js";
13
8
  /** Whether a parser error is one the previous ***plain syntax makes. */
14
9
  export function isPreviousSyntaxError(message) {
@@ -23,133 +18,69 @@ export function previousSyntaxStep(file) {
23
18
  function shown(path, projectDir) {
24
19
  return relative(projectDir, resolve(path)).split(sep).join("/");
25
20
  }
26
- /**
27
- * The modules of a project whose requires chains a module is in and that nothing requires: the tips its conformance
28
- * tests are written in, by name with their files. None when nothing requires it - it is a tip itself.
29
- */
30
- export function tipsAbove(moduleName, projectDir) {
31
- const modules = projectModules(projectDir);
32
- const requiredBy = new Map();
33
- for (const [name, file] of modules) {
34
- let requires = [];
35
- try {
36
- requires = readPlainSourceMetadata(readFileSync(file, "utf8")).metadata[REQUIRES_DIRECTIVE] ?? [];
37
- }
38
- catch {
39
- continue;
40
- }
41
- for (const required of requires) {
42
- const below = basename(required.replace(/^\.\//, ""), PLAIN_SOURCE_FILE_EXTENSION);
43
- requiredBy.set(below, [...(requiredBy.get(below) ?? []), name]);
44
- }
45
- }
46
- const tips = new Set();
47
- const seen = new Set();
48
- const up = (name) => {
49
- if (seen.has(name))
50
- return;
51
- seen.add(name);
52
- const above = requiredBy.get(name) ?? [];
53
- if (above.length === 0 && name !== moduleName)
54
- tips.add(name);
55
- for (const next of above)
56
- up(next);
57
- };
58
- up(moduleName);
59
- return [...tips].sort().flatMap((name) => (modules.has(name) ? [{ name, file: modules.get(name) }] : []));
60
- }
61
- /**
62
- * The steps of adding tests a module skipped, as warnings. A module another requires has its conformance tests
63
- * written in the tips above it, from their test reqs and with their script: it is judged by each of them, which says so.
64
- */
65
- function testingGapsOf(moduleName, path, tree, projectDir, templateDirs) {
66
- // Conformance tests off: no step of adding them is skipped - and scenarios written are said not to be tested.
67
- if (!conformanceTestsOn(path)) {
68
- const tested = testedFuncIds(tree);
69
- return tested.length > 0
70
- ? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset). /conform in the chat turns them on, or conformance-tests: true in config.turri.yaml.`]
71
- : [];
72
- }
73
- const tips = tipsAbove(moduleName, projectDir);
74
- if (tips.length === 0) {
75
- const gap = testingGap({ moduleName, plainFile: path, tree });
76
- return gap !== undefined ? [gap.text] : [];
77
- }
78
- return tips.flatMap((tip) => {
79
- let tipTree;
80
- try {
81
- [, tipTree] = plainFileParser(basename(tip.file), resolveTemplateDirs(tip.file, templateDirs), {
82
- allowNoFunctionalities: true,
83
- testDir: testDirOf(tip.file),
84
- requireTestPlainFiles: false,
85
- });
86
- }
87
- catch {
88
- // A tip that does not parse is reported when it is checked itself.
89
- return [];
90
- }
91
- const gap = testingGap({ moduleName: tip.name, plainFile: tip.file, tree: tipTree });
92
- return gap !== undefined ? [`${moduleName}'s conformance tests are written in ${tip.name}, which requires it: ${gap.text}`] : [];
93
- });
94
- }
95
- export function checkPlainFile(file, templateDirs = []) {
21
+ /** The language's check of a module, with what it parsed - for the project's check to go on from. */
22
+ export function checkParsed(file, templateDirs = []) {
96
23
  const path = resolve(file);
97
24
  if (extname(path) !== PLAIN_SOURCE_FILE_EXTENSION) {
98
- return { file, ok: false, error: `Not a ${PLAIN_SOURCE_FILE_EXTENSION} file.`, errorType: "UsageError" };
25
+ return { result: { file, ok: false, error: `Not a ${PLAIN_SOURCE_FILE_EXTENSION} file.`, errorType: "UsageError" } };
99
26
  }
100
27
  if (!existsSync(path)) {
101
- return { file, ok: false, error: "File does not exist.", errorType: "UsageError" };
28
+ return { result: { file, ok: false, error: "File does not exist.", errorType: "UsageError" } };
102
29
  }
103
30
  const refusal = testPlainFileRefusal(path);
104
31
  if (refusal !== undefined)
105
- return { file, ok: false, error: refusal, errorType: "UsageError" };
32
+ return { result: { file, ok: false, error: refusal, errorType: "UsageError" } };
106
33
  const projectDir = projectDirOf(path);
107
- const testDir = testDirOf(path);
108
34
  try {
109
35
  const dirs = resolveTemplateDirs(path, templateDirs);
110
36
  // A module with no functional specs yet is valid - it is how every module starts, and how
111
37
  // an import module always is. It is reported, not failed.
112
38
  const [moduleName, tree, requiredModules] = plainFileParser(basename(path), dirs, {
113
39
  allowNoFunctionalities: true,
114
- testDir,
40
+ testDir: testDirOf(path),
115
41
  requireTestPlainFiles: false,
116
42
  });
117
- // Two config files among the modules it requires: which one builds it cannot be told - an error, as a syntax one is.
118
- configModuleFor(path);
119
- // Scenarios with a step of adding tests skipped - the test reqs, or the conformance testing script: a warning, never a failure.
120
- const gaps = testingGapsOf(moduleName, path, tree, projectDir, templateDirs);
121
- // A codebase that requires nothing starts from its base folder: one named and not there stops its first pulse.
122
- const base = requiredModules.length === 0 && !isImportModule(path) ? missingBaseFolder(path) : undefined;
123
- if (base !== undefined)
124
- gaps.push(base);
125
43
  const bindings = Object.entries(tree[TEST_PLAIN_FILES] ?? {});
126
44
  return {
127
- file,
128
- ok: true,
129
- moduleName,
130
- ...(gaps.length > 0 ? { warnings: gaps } : {}),
131
- functionalSpecs: getFunctionalSpecs(tree).map((item) => ({
132
- funcId: item.id,
133
- testPlainFiles: bindings
134
- .filter(([, binding]) => binding.module === moduleName && binding.func_id === item.id)
135
- .map(([name]) => shown(join(dirs[0], name), projectDir)),
136
- conformance: item[CONFORMANCE_TESTS].length,
137
- acceptance: item[ACCEPTANCE_TESTS].length,
138
- })),
139
- requiredModules,
45
+ result: {
46
+ file,
47
+ ok: true,
48
+ moduleName,
49
+ functionalSpecs: getFunctionalSpecs(tree).map((item) => ({
50
+ funcId: item.id,
51
+ testPlainFiles: bindings
52
+ .filter(([, binding]) => binding.module === moduleName && binding.func_id === item.id)
53
+ .map(([name]) => shown(join(dirs[0], name), projectDir)),
54
+ conformance: item[CONFORMANCE_TESTS].length,
55
+ acceptance: item[ACCEPTANCE_TESTS].length,
56
+ })),
57
+ requiredModules,
58
+ },
59
+ parsed: { path, moduleName, tree, requiredModules, dirs },
140
60
  };
141
61
  }
142
62
  catch (error) {
143
- const message = error instanceof Error ? error.message : String(error);
144
- return {
145
- file,
146
- ok: false,
147
- error: message,
148
- errorType: error instanceof Error ? error.name : "Error",
149
- ...(isPreviousSyntaxError(message) ? { nextStep: previousSyntaxStep(path) } : {}),
150
- };
63
+ return { result: failedCheck(file, error) };
151
64
  }
152
65
  }
66
+ /** A check that failed on an error: its message verbatim, and turri's next step when it has one. */
67
+ export function failedCheck(file, error) {
68
+ const message = error instanceof Error ? error.message : String(error);
69
+ return {
70
+ file,
71
+ ok: false,
72
+ error: message,
73
+ errorType: error instanceof Error ? error.name : "Error",
74
+ ...(isPreviousSyntaxError(message) ? { nextStep: previousSyntaxStep(resolve(file)) } : {}),
75
+ };
76
+ }
77
+ /**
78
+ * The ***plain language's check of one module: parsed with its test plain files, its imports and required modules
79
+ * resolved. `checkModule` (`@turri-dev/core/project`) adds what the project says of it.
80
+ */
81
+ export function checkPlainFile(file, templateDirs = []) {
82
+ return checkParsed(file, templateDirs).result;
83
+ }
153
84
  /** The check of a project's test folder: every test plain file not where it belongs. Undefined when there is none. */
154
85
  export function checkTestFolder(projectDir) {
155
86
  const strays = projectTestFiles(projectDir).filter((file) => file.problem !== undefined);
@@ -178,15 +109,19 @@ export function resolvePlainTargets(target) {
178
109
  * project's test folder, once, at the end.
179
110
  */
180
111
  export function checkPlainTargets(target, templateDirs = []) {
112
+ return checkTargets(target, (file) => checkPlainFile(file, templateDirs));
113
+ }
114
+ /** `checkPlainTargets` with each module checked by `check`. */
115
+ export function checkTargets(target, check) {
181
116
  const path = resolve(target);
182
117
  if (existsSync(path) && statSync(path).isDirectory()) {
183
118
  const refusal = testPlainFileRefusal(path);
184
119
  if (refusal !== undefined)
185
120
  return [{ file: target, ok: false, error: refusal, errorType: "UsageError" }];
186
121
  }
187
- const results = resolvePlainTargets(target).map((file) => checkPlainFile(file, templateDirs));
188
- const projects = [...new Set(resolvePlainTargets(target).map((file) => projectDirOf(file)))];
189
- for (const project of projects) {
122
+ const files = resolvePlainTargets(target);
123
+ const results = files.map(check);
124
+ for (const project of new Set(files.map((file) => projectDirOf(file)))) {
190
125
  const folder = checkTestFolder(project);
191
126
  if (folder !== undefined)
192
127
  results.push(folder);
@@ -23,6 +23,8 @@ export declare function readsHold(reads: Reads): boolean;
23
23
  * the result onto `baseDir` names the same file as joining `target` onto `resourceDir`.
24
24
  */
25
25
  export declare function relativeResourcePath(baseDir: string, resourceDir: string, target: string): string;
26
+ /** The file a linked resource is read from: the first template folder that has it, else the current folder - or null. */
27
+ export declare function resourceFile(target: string, templateDirs: string[]): string | null;
26
28
  /** First contiguous base64 blob at or above the threshold, or null. */
27
29
  export declare function findLargeBase64Blob(text: string): string | null;
28
30
  /**
@@ -100,6 +100,19 @@ export function relativeResourcePath(baseDir, resourceDir, target) {
100
100
  }
101
101
  const MAX_BASE64_BLOB_LENGTH = 8192;
102
102
  const BASE64_BLOB_PATTERN = new RegExp(`(?:data:[\\w.+-]+/[\\w.+-]+;base64,)?[A-Za-z0-9+/_-]{${MAX_BASE64_BLOB_LENGTH},}={0,2}`);
103
+ /** The file a linked resource is read from: the first template folder that has it, else the current folder - or null. */
104
+ export function resourceFile(target, templateDirs) {
105
+ const found = [...templateDirs.map((dir) => join(dir, target)), target].find((path) => isFileAt(path));
106
+ return found === undefined ? null : resolve(found);
107
+ }
108
+ function isFileAt(path) {
109
+ try {
110
+ return statSync(path).isFile();
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ }
103
116
  /** First contiguous base64 blob at or above the threshold, or null. */
104
117
  export function findLargeBase64Blob(text) {
105
118
  const match = BASE64_BLOB_PATTERN.exec(text);
@@ -1,9 +1,9 @@
1
1
  import { readdirSync, readFileSync } from "node:fs";
2
2
  import { basename, dirname, join, resolve } from "node:path";
3
3
  import { resolveTemplateDirs } from "../regenerate/paths.js";
4
- import { locateModule } from "../regenerate/requires.js";
5
- import { resourceFile } from "../regenerate/resources.js";
4
+ import { locateModule } from "../regenerate/requires-chain.js";
6
5
  import { DEFAULT_CONCEPT_DEFINITIONS, DEFAULT_CONCEPTS, definitionText, extractConceptsFromDefinition, findConcepts } from "./concepts.js";
6
+ import { resourceFile } from "./files.js";
7
7
  import { lineNumber, renderToMarkdown, renderTokens } from "./markdown.js";
8
8
  import { attempt, namesIn, readModule } from "./module-concepts.js";
9
9
  import { IMPORT_DIRECTIVE, linksIn, modulePlainFile, sharedPlainFileParse, PLAIN_SOURCE_FILE_EXTENSION, plainFileParser, readPlainSourceMetadata, REQUIRES_DIRECTIVE, functionalitiesOf, sectionOf, withParseCache, } from "./parser.js";
@@ -1,27 +1,12 @@
1
- /** A rule, read: its expression compiled, its includes followed. */
2
- type Rule = {
3
- kind: "match";
4
- name?: string;
5
- re: RegExp;
6
- captures?: Record<string, string | undefined>;
7
- } | {
8
- kind: "block";
9
- name?: string;
10
- begin: RegExp;
11
- end: RegExp;
12
- patterns: Rule[];
13
- beginCaptures?: Record<string, string | undefined>;
14
- endCaptures?: Record<string, string | undefined>;
15
- };
16
1
  /** A piece of a line, and the scopes it is in, outermost first. */
17
2
  export interface Token {
18
3
  text: string;
19
4
  scopes: string[];
20
5
  }
21
- /** Where the lines so far leave off: the blocks open at the end of the last one. */
22
- export type HighlightState = ReadonlyArray<Extract<Rule, {
23
- kind: "block";
24
- }>>;
6
+ /** Where the lines so far leave off - the blocks open at the end of the last one - to give back with the next line. Opaque. */
7
+ export interface HighlightState {
8
+ readonly __highlightState: true;
9
+ }
25
10
  /**
26
11
  * One line of ***plain, highlighted: its tokens, and the state the next line starts from - the blocks
27
12
  * still open at its end.
@@ -40,4 +25,3 @@ export declare function highlightLines(lines: string[]): Token[][];
40
25
  export type PlainRole = "section" | "concept" | "link" | "literal" | "keyword" | "module" | "comment" | "bullet" | "id";
41
26
  /** A token's role: its innermost scope that has one. */
42
27
  export declare function roleOf(scopes: string[]): PlainRole | undefined;
43
- export {};
@@ -1,4 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
+ const blocksOf = (state) => state ?? [];
3
+ const stateOf = (blocks) => blocks;
2
4
  const compile = (source) => new RegExp(source, "dg");
3
5
  const namesOf = (captures) => captures === undefined ? undefined : Object.fromEntries(Object.entries(captures).map(([group, capture]) => [group, capture.name]));
4
6
  function readGrammar(raw) {
@@ -92,11 +94,11 @@ function piecesOf(match, scopes, name, captures) {
92
94
  * One line of ***plain, highlighted: its tokens, and the state the next line starts from - the blocks
93
95
  * still open at its end.
94
96
  */
95
- export function highlightLine(line, state = []) {
97
+ export function highlightLine(line, state) {
96
98
  const rules = plainGrammar();
97
99
  if (rules === null)
98
- return { tokens: line === "" ? [] : [{ text: line, scopes: [] }], state };
99
- const stack = [...state];
100
+ return { tokens: line === "" ? [] : [{ text: line, scopes: [] }], state: stateOf(blocksOf(state)) };
101
+ const stack = [...blocksOf(state)];
100
102
  const tokens = [];
101
103
  const scopesNow = () => stack.map((block) => block.name).filter((name) => name !== undefined);
102
104
  const push = (text, scopes) => {
@@ -159,11 +161,11 @@ export function highlightLine(line, state = []) {
159
161
  if (at >= line.length)
160
162
  break;
161
163
  }
162
- return { tokens, state: stack };
164
+ return { tokens, state: stateOf(stack) };
163
165
  }
164
166
  /** Lines of ***plain, highlighted one after another - a block opened on one carried to the next. */
165
167
  export function highlightLines(lines) {
166
- let state = [];
168
+ let state;
167
169
  return lines.map((line) => {
168
170
  const result = highlightLine(line, state);
169
171
  state = result.state;
@@ -0,0 +1,19 @@
1
+ import { type DriftReport } from "./regenerate/loop.ts";
2
+ import type { Launch } from "./launch-track.ts";
3
+ /**
4
+ * What can be asked of a project on disk with no session open: how far its code has drifted from its spec, and a launch
5
+ * of its code on its own - the unattended `turri drift` and `turri launch`.
6
+ */
7
+ /** What is left to regenerate in each codebase of the module's chain - planning nothing, starting nothing, calling no model. */
8
+ export declare function readDrift(plainFile: string, cwd?: string): DriftReport[];
9
+ /**
10
+ * Launch a module's code on its own, outside any session: the launch agent, on the codebase's coding model unless one is
11
+ * named, follows the project's guidance - its words as they stream to `onOutput`. Resolves when the launch ends.
12
+ */
13
+ export declare function launchModule(plainFile: string, options?: {
14
+ cwd?: string;
15
+ inModule?: string;
16
+ guidance?: string;
17
+ model?: string;
18
+ onOutput?: (text: string) => void;
19
+ }): Promise<Launch>;
@@ -0,0 +1,34 @@
1
+ import { resolve } from "node:path";
2
+ import { configForSpec, modelSpec, projectModels } from "./config.js";
3
+ import { createLaunchTrack } from "./launch-track.js";
4
+ import { runLaunchAgent } from "./launch-agent.js";
5
+ import { createJobRegistry } from "./regenerate/jobs.js";
6
+ import { createWorkLoop } from "./regenerate/loop.js";
7
+ import { refuseTestPlainFile } from "./test-plain-files.js";
8
+ import { applyBedrockRegion } from "./bedrock-region.js";
9
+ import { projectDirOf } from "./regenerate/paths.js";
10
+ /**
11
+ * What can be asked of a project on disk with no session open: how far its code has drifted from its spec, and a launch
12
+ * of its code on its own - the unattended `turri drift` and `turri launch`.
13
+ */
14
+ /** What is left to regenerate in each codebase of the module's chain - planning nothing, starting nothing, calling no model. */
15
+ export function readDrift(plainFile, cwd = process.cwd()) {
16
+ const file = resolve(cwd, plainFile);
17
+ refuseTestPlainFile(file);
18
+ return createWorkLoop({ registry: createJobRegistry(), cwd, planner: false }).drift(file);
19
+ }
20
+ /**
21
+ * Launch a module's code on its own, outside any session: the launch agent, on the codebase's coding model unless one is
22
+ * named, follows the project's guidance - its words as they stream to `onOutput`. Resolves when the launch ends.
23
+ */
24
+ export async function launchModule(plainFile, options = {}) {
25
+ const cwd = options.cwd ?? process.cwd();
26
+ const file = resolve(cwd, plainFile);
27
+ refuseTestPlainFile(file);
28
+ const model = options.model ?? modelSpec(projectModels(configForSpec(file)).coding);
29
+ // The AWS region its Bedrock model needs, set as a session sets it as it opens: this launch has none open.
30
+ applyBedrockRegion(projectDirOf(file), model !== undefined ? { also: [model] } : {});
31
+ const track = createLaunchTrack({ cwd, run: (launch, code, signal, freed) => runLaunchAgent({ cwd, launch, code, signal, freed, model, ...(options.onOutput !== undefined ? { onDelta: options.onOutput } : {}) }) });
32
+ const { launch } = track.request({ plainFile: file, ...(options.inModule !== undefined ? { inModule: options.inModule } : {}), ...(options.guidance !== undefined ? { guidance: options.guidance } : {}), cause: {} });
33
+ return track.done(launch.id);
34
+ }
package/dist/quiet.d.ts CHANGED
@@ -10,8 +10,6 @@
10
10
  * how pi draws the TUI, and silencing it would blank the screen. Library noise goes
11
11
  * through `console`; pi's rendering does not.
12
12
  */
13
- /** Drop the NOISE warnings for good, from here on - captured or not. Safe to call more than once. */
14
- export declare function dropNoise(): void;
15
13
  export interface Captured<T> {
16
14
  result: T;
17
15
  /** Whatever the libraries tried to print, in order. */
package/dist/quiet.js CHANGED
@@ -20,20 +20,6 @@ const NOISE = [/^Both GOOGLE_API_KEY and GEMINI_API_KEY are set\. Using GOOGLE_A
20
20
  function isNoise(args) {
21
21
  return args.length === 1 && typeof args[0] === "string" && NOISE.some((pattern) => pattern.test(args[0]));
22
22
  }
23
- let noiseDropped = false;
24
- /** Drop the NOISE warnings for good, from here on - captured or not. Safe to call more than once. */
25
- export function dropNoise() {
26
- if (noiseDropped)
27
- return;
28
- noiseDropped = true;
29
- for (const method of ["warn", "error", "log", "info", "debug"]) {
30
- const print = console[method];
31
- console[method] = (...args) => {
32
- if (!isNoise(args))
33
- print.apply(console, args);
34
- };
35
- }
36
- }
37
23
  /** Buffers currently collecting. Nested and concurrent captures all see the same writes. */
38
24
  const active = new Set();
39
25
  const original = new Map();
@@ -53,14 +53,6 @@ export declare function writesPlain(command: string): string | undefined;
53
53
  export declare function runsBuiltCode(command: string): string | undefined;
54
54
  /** What turri says when a command would change the machine: what it does instead. */
55
55
  export declare function machineChangeReason(why: string): string;
56
- /**
57
- * The command as the shell reads its operators, the same length: what quotes hold has its `<`, `>`, `|`, `&`, `;` and
58
- * newlines put out of the way - a `>` in `grep "</content>"` redirects nothing, a `;` in a string ends no command - and
59
- * the body of a here-document fed to cat or tee with a quoted delimiter, so not expanded, is blanked: it is the text of
60
- * a file being written, and a `../lib/logger` or a `>` in it is code, not a path or a redirection. A `$(...)` in double
61
- * quotes, an unquoted delimiter's body and a here-document fed to anything else - a shell, an interpreter - run, and are
62
- * read as they are.
63
- */
64
56
  export declare function shellCode(command: string): string;
65
57
  /** Check one command line against a role's fence: `{ ok: true }`, or which rule it breaks and what to do instead. */
66
58
  export declare function checkCommand(command: string, fence: CommandFence): CheckResult;