@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.
- package/CHANGELOG.md +56 -0
- package/README.md +17 -11
- package/dist/api/models.d.ts +9 -0
- package/dist/api/models.js +15 -0
- package/dist/api/plain.d.ts +6 -6
- package/dist/api/plain.js +4 -7
- package/dist/api/project.d.ts +35 -0
- package/dist/api/project.js +47 -0
- package/dist/api/session.d.ts +48 -0
- package/dist/api/session.js +17 -0
- package/dist/api/system.d.ts +18 -0
- package/dist/api/system.js +23 -0
- package/dist/btw.d.ts +1 -1
- package/dist/capture/capture.js +11 -8
- package/dist/capture/chat.d.ts +0 -11
- package/dist/capture/chat.js +0 -29
- package/dist/capture/config.d.ts +4 -5
- package/dist/capture/config.js +34 -20
- package/dist/capture/models.d.ts +2 -1
- package/dist/capture/models.js +1 -0
- package/dist/chat-entries.d.ts +81 -39
- package/dist/chat-entries.js +125 -11
- package/dist/chat-model.d.ts +37 -0
- package/dist/chat-model.js +61 -0
- package/dist/chats.d.ts +54 -42
- package/dist/chats.js +86 -80
- package/dist/client.d.ts +30 -0
- package/dist/client.js +12 -0
- package/dist/config-edit.d.ts +54 -1
- package/dist/config-edit.js +103 -33
- package/dist/config.d.ts +12 -9
- package/dist/config.js +38 -9
- package/dist/doctor-checks.d.ts +42 -0
- package/dist/doctor-checks.js +39 -0
- package/dist/environment.d.ts +2 -23
- package/dist/environment.js +5 -68
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +24 -0
- package/dist/extension.d.ts +23 -16
- package/dist/extension.js +170 -234
- package/dist/identity.d.ts +1 -1
- package/dist/identity.js +13 -9
- package/dist/init-config.d.ts +11 -9
- package/dist/init-config.js +15 -7
- package/dist/launch-session.d.ts +2 -0
- package/dist/launch-session.js +17 -1
- package/dist/loop-tools.js +11 -10
- package/dist/module-check.d.ts +13 -0
- package/dist/module-check.js +117 -0
- package/dist/notice.d.ts +5 -0
- package/dist/parse-tool.js +3 -2
- package/dist/plain/check.d.ts +27 -13
- package/dist/plain/check.js +51 -116
- package/dist/plain/files.d.ts +2 -0
- package/dist/plain/files.js +13 -0
- package/dist/plain/graph.js +2 -2
- package/dist/plain/highlight.d.ts +4 -20
- package/dist/plain/highlight.js +7 -5
- package/dist/project.d.ts +19 -0
- package/dist/project.js +34 -0
- package/dist/quiet.d.ts +0 -2
- package/dist/quiet.js +0 -14
- package/dist/regenerate/command-check.d.ts +0 -8
- package/dist/regenerate/command-check.js +133 -53
- package/dist/regenerate/conversation-writes.d.ts +5 -1
- package/dist/regenerate/conversation-writes.js +7 -3
- package/dist/regenerate/jobs.d.ts +25 -2
- package/dist/regenerate/jobs.js +3 -0
- package/dist/regenerate/launch.d.ts +1 -0
- package/dist/regenerate/launch.js +9 -0
- package/dist/regenerate/ledger-view.d.ts +14 -14
- package/dist/regenerate/ledger.d.ts +1 -0
- package/dist/regenerate/ledger.js +4 -2
- package/dist/regenerate/loop.d.ts +2 -1
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/os-sandbox.d.ts +4 -2
- package/dist/regenerate/os-sandbox.js +0 -1
- package/dist/regenerate/regenerate.js +2 -1
- package/dist/regenerate/requires-chain.d.ts +44 -0
- package/dist/regenerate/requires-chain.js +174 -0
- package/dist/regenerate/requires.d.ts +2 -40
- package/dist/regenerate/requires.js +14 -171
- package/dist/regenerate/resources.d.ts +0 -2
- package/dist/regenerate/resources.js +2 -14
- package/dist/regenerate/shell.js +20 -9
- package/dist/regenerate/spec-map.d.ts +2 -0
- package/dist/regenerate/spec-map.js +4 -0
- package/dist/regenerate/standing.d.ts +5 -2
- package/dist/run-report.js +2 -2
- package/dist/self-invocation.d.ts +1 -1
- package/dist/self-invocation.js +2 -3
- package/dist/sentinel-chat.js +7 -11
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +12 -5
- package/dist/session-events.d.ts +14 -0
- package/dist/session.d.ts +594 -0
- package/dist/session.js +672 -0
- package/dist/settings.d.ts +28 -2
- package/dist/settings.js +92 -56
- package/dist/setup.d.ts +6 -30
- package/dist/setup.js +28 -105
- package/dist/stack.d.ts +25 -12
- package/dist/stack.js +77 -12
- package/dist/surface.d.ts +2 -2
- package/dist/surface.js +4 -5
- package/dist/work.d.ts +125 -0
- package/dist/work.js +250 -0
- package/docs/README.md +2 -3
- package/docs/capture.md +4 -4
- package/docs/chats.md +5 -3
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +4 -4
- package/docs/core.md +105 -128
- package/docs/development.md +9 -9
- package/docs/headless.md +1 -1
- package/docs/installation.md +4 -2
- package/docs/launch.md +2 -2
- package/docs/parser.md +1 -1
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +4 -4
- package/docs/sentinel.md +4 -4
- package/docs/skills-and-gates.md +1 -1
- package/docs/using.md +2 -2
- package/genome/rules/integration-embedded-testing.md +3 -3
- package/genome/rules/integration-embedded.md +3 -3
- package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
- package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
- package/package.json +19 -32
- package/dist/api/commands.d.ts +0 -45
- package/dist/api/commands.js +0 -54
- package/dist/api/config.d.ts +0 -8
- package/dist/api/config.js +0 -8
- package/dist/api/ledger.d.ts +0 -3
- package/dist/api/ledger.js +0 -3
- package/dist/api/startup.d.ts +0 -8
- package/dist/api/startup.js +0 -8
- package/dist/api/terminal.d.ts +0 -18
- package/dist/api/terminal.js +0 -16
- package/dist/chat-models.d.ts +0 -11
- package/dist/chat-models.js +0 -11
- package/dist/chat-ui.d.ts +0 -33
- package/dist/chat-ui.js +0 -192
- package/dist/headless.d.ts +0 -99
- package/dist/headless.js +0 -226
- package/dist/host-session.d.ts +0 -136
- package/dist/host-session.js +0 -139
- package/dist/host.d.ts +0 -8
- package/dist/host.js +0 -17
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -7
- package/dist/notifications.d.ts +0 -21
- package/dist/notifications.js +0 -44
- package/dist/reopen.d.ts +0 -29
- package/dist/reopen.js +0 -47
- package/dist/turri-versions.d.ts +0 -71
- package/dist/turri-versions.js +0 -276
- package/dist/view.d.ts +0 -78
- package/dist/view.js +0 -1
- package/docs/hosting.md +0 -284
package/dist/plain/check.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { existsSync, readdirSync,
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { testDirOf } from "../config.js";
|
|
4
4
|
import { projectDirOf, resolveTemplateDirs } from "../regenerate/paths.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
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
|
|
188
|
-
const
|
|
189
|
-
for (const project of
|
|
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);
|
package/dist/plain/files.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/plain/files.js
CHANGED
|
@@ -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);
|
package/dist/plain/graph.js
CHANGED
|
@@ -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
|
|
22
|
-
export
|
|
23
|
-
|
|
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 {};
|
package/dist/plain/highlight.js
CHANGED
|
@@ -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>;
|
package/dist/project.js
ADDED
|
@@ -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;
|