@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.
- 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/reopen.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
/**
|
|
3
|
-
* turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
|
|
4
|
-
* the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
|
|
5
|
-
* (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
|
|
6
|
-
* it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
|
|
7
|
-
* starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
|
|
8
|
-
* A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
|
|
9
|
-
*/
|
|
10
|
-
/** The file the chat `turri` started writes where it is to open again. */
|
|
11
|
-
export const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
|
|
12
|
-
/** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
|
|
13
|
-
export const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
|
|
14
|
-
/** Whether this chat can open again in another folder: `turri` started it. */
|
|
15
|
-
export function canReopen() {
|
|
16
|
-
return (process.env[REOPEN_FILE_ENV] ?? "") !== "";
|
|
17
|
-
}
|
|
18
|
-
/** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
|
|
19
|
-
export function reopenIn(dir, options = {}) {
|
|
20
|
-
const file = process.env[REOPEN_FILE_ENV];
|
|
21
|
-
if (file === undefined || file === "")
|
|
22
|
-
return false;
|
|
23
|
-
const reopening = { dir, args: options.args ?? [], env: options.env ?? {} };
|
|
24
|
-
writeFileSync(file, JSON.stringify(reopening));
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
/** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
|
|
28
|
-
export function takeReopening(file) {
|
|
29
|
-
let text;
|
|
30
|
-
try {
|
|
31
|
-
text = readFileSync(file, "utf8");
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
rmSync(file, { force: true });
|
|
37
|
-
try {
|
|
38
|
-
const parsed = JSON.parse(text);
|
|
39
|
-
if (typeof parsed.dir !== "string" || !Array.isArray(parsed.args) || parsed.args.some((arg) => typeof arg !== "string"))
|
|
40
|
-
return undefined;
|
|
41
|
-
const env = Object.fromEntries(Object.entries(parsed.env ?? {}).filter((entry) => typeof entry[1] === "string"));
|
|
42
|
-
return { dir: parsed.dir, args: parsed.args, env };
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
}
|
package/dist/turri-versions.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which turri runs, which is newest, and which others are on this machine - so a person who installed a new turri and
|
|
3
|
-
* is still running an old one is told so, and how to fix it, where they look: the banner as turri starts (from what the
|
|
4
|
-
* last check found, never waiting on the network), and `turri --version` and `turri doctor` (asking npm then and there).
|
|
5
|
-
* A turri run from a clone is the developer's: it is never told to update.
|
|
6
|
-
*/
|
|
7
|
-
export declare const PACKAGE_NAME = "@turri-dev/cli";
|
|
8
|
-
/** Whether version `a` is newer than `b`: major, minor, patch - and a release over a prerelease of the same. */
|
|
9
|
-
export declare function newerThan(a: string, b: string): boolean;
|
|
10
|
-
/** The newest version npm had when it was last asked, and when - nothing when it never was. */
|
|
11
|
-
export declare function latestKnown(): {
|
|
12
|
-
version: string;
|
|
13
|
-
checkedAt: number;
|
|
14
|
-
} | undefined;
|
|
15
|
-
/** The newest version npm has now, kept for the next start - nothing when npm does not answer in time. */
|
|
16
|
-
export declare function fetchLatest(timeoutMs?: number): Promise<string | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Ask npm again in the background when what it said last is old: what it says now, once it answers - undefined when it
|
|
19
|
-
* was not asked, or did not answer. Never waited for by what starts turri.
|
|
20
|
-
*/
|
|
21
|
-
export declare function refreshLatestLater(): Promise<string | undefined>;
|
|
22
|
-
/** A turri on this machine's PATH. */
|
|
23
|
-
export interface TurriOnPath {
|
|
24
|
-
/** The command, as the PATH has it. */
|
|
25
|
-
path: string;
|
|
26
|
-
/** The package it runs. */
|
|
27
|
-
root: string;
|
|
28
|
-
version?: string;
|
|
29
|
-
/** Run from a clone - npm link, or a script pointing into one. */
|
|
30
|
-
clone: boolean;
|
|
31
|
-
/** The one a bare `turri` runs: the first on the PATH. */
|
|
32
|
-
runs: boolean;
|
|
33
|
-
/** The one running now. */
|
|
34
|
-
self: boolean;
|
|
35
|
-
}
|
|
36
|
-
/** Every turri on the PATH, in its order - the first is what a bare `turri` runs. */
|
|
37
|
-
export declare function turrisOnPath(path?: string, self?: string, platform?: NodeJS.Platform): TurriOnPath[];
|
|
38
|
-
/** How to take a turri off the PATH, by where it is: another Node version of nvm, a linked clone, or an npm prefix. */
|
|
39
|
-
export declare function removalOf(turri: Pick<TurriOnPath, "path" | "clone" | "root">, platform?: NodeJS.Platform): string;
|
|
40
|
-
/** What is wrong with the turri running, and what to do: each a line, with its fixes. */
|
|
41
|
-
export interface VersionFinding {
|
|
42
|
-
/** Updating is all it needs. */
|
|
43
|
-
kind: "outdated" | "shadowed" | "behind";
|
|
44
|
-
text: string;
|
|
45
|
-
/** The same, as the banner says it in a line: what is newer, and what to run. */
|
|
46
|
-
short: string;
|
|
47
|
-
fixes: string[];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* What the turri running, the newest npm has (`latest`, when known) and the turris on the PATH say together: nothing when
|
|
51
|
-
* all is well. A turri from a clone is told nothing of npm's.
|
|
52
|
-
*/
|
|
53
|
-
export declare function versionFindings(options?: {
|
|
54
|
-
latest?: string;
|
|
55
|
-
onPath?: TurriOnPath[];
|
|
56
|
-
self?: {
|
|
57
|
-
version?: string;
|
|
58
|
-
clone: boolean;
|
|
59
|
-
root: string;
|
|
60
|
-
};
|
|
61
|
-
}): VersionFinding[];
|
|
62
|
-
/** `turri --version`: the version line, then where this turri is, what npm has - asked now - and every turri on the PATH. */
|
|
63
|
-
export declare function describeVersion(versionLine: string): Promise<string>;
|
|
64
|
-
/**
|
|
65
|
-
* What the banner says as turri starts: a line a finding, short - what is newer and what to run - from what npm said at
|
|
66
|
-
* the last check and the turris on the PATH, never waiting on the network; the check for next time started behind it.
|
|
67
|
-
*/
|
|
68
|
-
export declare function bannerWarnings(): {
|
|
69
|
-
lines: string[];
|
|
70
|
-
later: Promise<string | undefined>;
|
|
71
|
-
};
|
package/dist/turri-versions.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { accessSync, constants, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { delimiter, dirname, join, resolve, win32 } from "node:path";
|
|
3
|
-
import { AGENT_DIR, turriIdentity, turriRoot } from "./environment.js";
|
|
4
|
-
/**
|
|
5
|
-
* Which turri runs, which is newest, and which others are on this machine - so a person who installed a new turri and
|
|
6
|
-
* is still running an old one is told so, and how to fix it, where they look: the banner as turri starts (from what the
|
|
7
|
-
* last check found, never waiting on the network), and `turri --version` and `turri doctor` (asking npm then and there).
|
|
8
|
-
* A turri run from a clone is the developer's: it is never told to update.
|
|
9
|
-
*/
|
|
10
|
-
export const PACKAGE_NAME = "@turri-dev/cli";
|
|
11
|
-
const INSTALL = `npm install -g ${PACKAGE_NAME}@latest`;
|
|
12
|
-
/** Where the newest version npm has is kept between starts. */
|
|
13
|
-
const CACHE = join(AGENT_DIR, "turri-latest.json");
|
|
14
|
-
/** How long what npm said is trusted before the banner asks again, in the background. */
|
|
15
|
-
const STALE_MS = 6 * 60 * 60 * 1000;
|
|
16
|
-
/** The check is off in turri's own tests, and when TURRI_UPDATE_CHECK=off. */
|
|
17
|
-
const checkOff = () => process.env.TURRI_UPDATE_CHECK === "off";
|
|
18
|
-
/** Whether version `a` is newer than `b`: major, minor, patch - and a release over a prerelease of the same. */
|
|
19
|
-
export function newerThan(a, b) {
|
|
20
|
-
const parse = (version) => {
|
|
21
|
-
const [core = "", pre] = version.split("-", 2);
|
|
22
|
-
return { parts: core.split(".").map((part) => Number.parseInt(part, 10) || 0), pre: pre !== undefined };
|
|
23
|
-
};
|
|
24
|
-
const [x, y] = [parse(a), parse(b)];
|
|
25
|
-
for (let at = 0; at < 3; at += 1) {
|
|
26
|
-
if ((x.parts[at] ?? 0) !== (y.parts[at] ?? 0))
|
|
27
|
-
return (x.parts[at] ?? 0) > (y.parts[at] ?? 0);
|
|
28
|
-
}
|
|
29
|
-
return !x.pre && y.pre;
|
|
30
|
-
}
|
|
31
|
-
/** The newest version npm had when it was last asked, and when - nothing when it never was. */
|
|
32
|
-
export function latestKnown() {
|
|
33
|
-
try {
|
|
34
|
-
const cached = JSON.parse(readFileSync(CACHE, "utf8"));
|
|
35
|
-
return typeof cached.version === "string" && typeof cached.checkedAt === "number" ? { version: cached.version, checkedAt: cached.checkedAt } : undefined;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/** The newest version npm has now, kept for the next start - nothing when npm does not answer in time. */
|
|
42
|
-
export async function fetchLatest(timeoutMs = 3000) {
|
|
43
|
-
if (checkOff())
|
|
44
|
-
return undefined;
|
|
45
|
-
try {
|
|
46
|
-
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME.replace("/", "%2F")}/latest`, { signal: AbortSignal.timeout(timeoutMs) });
|
|
47
|
-
if (!response.ok)
|
|
48
|
-
return undefined;
|
|
49
|
-
const version = (await response.json()).version;
|
|
50
|
-
if (typeof version !== "string")
|
|
51
|
-
return undefined;
|
|
52
|
-
try {
|
|
53
|
-
mkdirSync(dirname(CACHE), { recursive: true });
|
|
54
|
-
writeFileSync(CACHE, `${JSON.stringify({ version, checkedAt: Date.now() })}\n`);
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
/* not kept: asked again next time */
|
|
58
|
-
}
|
|
59
|
-
return version;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Ask npm again in the background when what it said last is old: what it says now, once it answers - undefined when it
|
|
67
|
-
* was not asked, or did not answer. Never waited for by what starts turri.
|
|
68
|
-
*/
|
|
69
|
-
export function refreshLatestLater() {
|
|
70
|
-
if (checkOff())
|
|
71
|
-
return Promise.resolve(undefined);
|
|
72
|
-
const known = latestKnown();
|
|
73
|
-
if (known !== undefined && Date.now() - known.checkedAt < STALE_MS)
|
|
74
|
-
return Promise.resolve(undefined);
|
|
75
|
-
return fetchLatest().catch(() => undefined);
|
|
76
|
-
}
|
|
77
|
-
/** Whether a command is a link - npm's on macOS and Linux - rather than a launcher file. */
|
|
78
|
-
const isLink = (command) => {
|
|
79
|
-
try {
|
|
80
|
-
return lstatSync(command).isSymbolicLink();
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
/** The package a turri command runs: up from where it really is, to the folder whose package.json is turri's. */
|
|
87
|
-
function packageOf(command) {
|
|
88
|
-
// Beside its command, where npm puts it when the command is a launcher rather than a link: <prefix>/node_modules on
|
|
89
|
-
// Windows, <prefix>/lib/node_modules elsewhere.
|
|
90
|
-
for (const beside of [join(dirname(command), "node_modules", "@turri-dev", "cli"), join(dirname(command), "..", "lib", "node_modules", "@turri-dev", "cli")]) {
|
|
91
|
-
try {
|
|
92
|
-
if (JSON.parse(readFileSync(join(beside, "package.json"), "utf8")).name === PACKAGE_NAME && !isLink(command))
|
|
93
|
-
return resolve(beside);
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
/* not there */
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
let dir;
|
|
100
|
-
try {
|
|
101
|
-
dir = dirname(realpathSync(command));
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
for (let at = 0; at < 6; at += 1) {
|
|
107
|
-
try {
|
|
108
|
-
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
109
|
-
if (pkg.name === PACKAGE_NAME)
|
|
110
|
-
return dir;
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
/* not here: up */
|
|
114
|
-
}
|
|
115
|
-
const up = dirname(dir);
|
|
116
|
-
if (up === dir)
|
|
117
|
-
return undefined;
|
|
118
|
-
dir = up;
|
|
119
|
-
}
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
/** Every turri on the PATH, in its order - the first is what a bare `turri` runs. */
|
|
123
|
-
export function turrisOnPath(path = process.env.PATH ?? "", self = turriRoot(), platform = process.platform) {
|
|
124
|
-
// On Windows npm writes three launchers for one install - turri.cmd, turri.ps1, turri - side by side: one is taken.
|
|
125
|
-
const names = platform === "win32" ? ["turri.cmd", "turri.ps1", "turri"] : ["turri"];
|
|
126
|
-
const found = [];
|
|
127
|
-
const seen = new Set();
|
|
128
|
-
for (const dir of path.split(delimiter).filter((entry) => entry !== "")) {
|
|
129
|
-
for (const name of names) {
|
|
130
|
-
const command = join(dir, name);
|
|
131
|
-
if (seen.has(command))
|
|
132
|
-
continue;
|
|
133
|
-
try {
|
|
134
|
-
if (!statSync(command).isFile())
|
|
135
|
-
continue;
|
|
136
|
-
// Windows has no execute bit: a launcher there is a file.
|
|
137
|
-
if (platform !== "win32")
|
|
138
|
-
accessSync(command, constants.X_OK);
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
seen.add(command);
|
|
144
|
-
const root = packageOf(command);
|
|
145
|
-
if (root === undefined)
|
|
146
|
-
continue;
|
|
147
|
-
if (platform === "win32" && found.some((turri) => dirname(turri.path) === dir))
|
|
148
|
-
continue;
|
|
149
|
-
let version;
|
|
150
|
-
try {
|
|
151
|
-
version = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version;
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
version = undefined;
|
|
155
|
-
}
|
|
156
|
-
found.push({ path: command, root, ...(version !== undefined ? { version } : {}), clone: existsSync(join(root, ".git")), runs: found.length === 0, self: resolve(root) === resolve(self) });
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return found;
|
|
160
|
-
}
|
|
161
|
-
/** How to take a turri off the PATH, by where it is: another Node version of nvm, a linked clone, or an npm prefix. */
|
|
162
|
-
export function removalOf(turri, platform = process.platform) {
|
|
163
|
-
const nvm = /[/\\]\.nvm[/\\]versions[/\\]node[/\\](v[^/\\]+)[/\\]bin[/\\]turri/.exec(turri.path);
|
|
164
|
-
if (nvm !== null)
|
|
165
|
-
return `nvm exec ${nvm[1]} npm uninstall -g ${PACKAGE_NAME}`;
|
|
166
|
-
// nvm for Windows keeps each Node version in a folder of its own: switched to it, npm uninstalls from there.
|
|
167
|
-
const nvmWindows = /[/\\]nvm[/\\](v?\d+\.\d+\.\d+)[/\\]turri/i.exec(turri.path);
|
|
168
|
-
if (nvmWindows !== null)
|
|
169
|
-
return `nvm use ${nvmWindows[1]}, then npm uninstall -g ${PACKAGE_NAME}`;
|
|
170
|
-
if (turri.clone)
|
|
171
|
-
return `npm unlink -g ${PACKAGE_NAME} (it links a clone, ${turri.root})`;
|
|
172
|
-
// npm's prefix: the launcher's own folder on Windows, the folder above bin elsewhere.
|
|
173
|
-
const prefix = platform === "win32" ? win32.dirname(turri.path) : dirname(dirname(turri.path));
|
|
174
|
-
return `npm uninstall -g ${PACKAGE_NAME} --prefix ${prefix} (or delete ${turri.path})`;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* What the turri running, the newest npm has (`latest`, when known) and the turris on the PATH say together: nothing when
|
|
178
|
-
* all is well. A turri from a clone is told nothing of npm's.
|
|
179
|
-
*/
|
|
180
|
-
export function versionFindings(options = {}) {
|
|
181
|
-
const identity = options.self ?? (() => {
|
|
182
|
-
const own = turriIdentity();
|
|
183
|
-
// An image built from a clone (docker/Dockerfile) has no .git, and is updated by building it again from a newer clone.
|
|
184
|
-
return { ...(own.version !== null ? { version: own.version } : {}), clone: own.git_commit !== null || process.env.TURRI_FROM_CLONE === "1", root: turriRoot() };
|
|
185
|
-
})();
|
|
186
|
-
const onPath = options.onPath ?? turrisOnPath();
|
|
187
|
-
const findings = [];
|
|
188
|
-
// A newer turri installed than the one running, behind it on the PATH: the person installed it, and runs the old one.
|
|
189
|
-
const newest = onPath.filter((turri) => !turri.clone && turri.version !== undefined).sort((a, b) => (newerThan(a.version, b.version) ? -1 : 1))[0];
|
|
190
|
-
const runs = onPath.find((turri) => turri.runs);
|
|
191
|
-
if (!identity.clone && identity.version !== undefined && newest !== undefined && newest.version !== undefined && newerThan(newest.version, identity.version) && !newest.self) {
|
|
192
|
-
// Every turri in front of the newest one: a bare `turri` finds each before it.
|
|
193
|
-
const inFront = onPath.slice(0, onPath.indexOf(newest));
|
|
194
|
-
findings.push({
|
|
195
|
-
kind: "shadowed",
|
|
196
|
-
text: `turri ${newest.version} is installed too, at ${newest.path}, but ${runs?.self === true ? `this turri ${identity.version} comes first on your PATH` : `turri ${runs?.version ?? identity.version} comes before it on your PATH`} - a bare \`turri\` runs the older one`,
|
|
197
|
-
short: `turri ${newest.version} is installed, but this older turri ${identity.version} comes first on your PATH - turri doctor shows which, and how to fix it`,
|
|
198
|
-
fixes: [
|
|
199
|
-
...inFront.map((turri) => `take ${turri.path} (turri ${turri.version ?? "?"}${turri.self ? ", this one" : ""}) off the PATH: ${removalOf(turri)}`),
|
|
200
|
-
process.platform === "win32" ? "then open a new terminal" : "then `hash -r`, or a new terminal - the shell remembers where it last found turri",
|
|
201
|
-
`meanwhile, run the newer one by its path - ${newest.path} - or npx ${PACKAGE_NAME}@latest`,
|
|
202
|
-
],
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
// A newer turri on npm than the newest here.
|
|
206
|
-
const here = newest?.version !== undefined && identity.version !== undefined && newerThan(newest.version, identity.version) ? newest.version : identity.version;
|
|
207
|
-
if (!identity.clone && options.latest !== undefined && here !== undefined && newerThan(options.latest, here)) {
|
|
208
|
-
findings.push({ kind: "outdated", text: `turri ${options.latest} is out - this is turri ${identity.version}`, short: `This turri, ${identity.version}, is out of date: ${options.latest} is out. Upgrade: ${INSTALL}`, fixes: [`update: ${INSTALL}`] });
|
|
209
|
-
}
|
|
210
|
-
// The turri a bare `turri` runs is not this one, and older: it is run by its whole path, the old one in front.
|
|
211
|
-
if (runs !== undefined && !runs.self && !runs.clone && runs.version !== undefined && identity.version !== undefined && newerThan(identity.version, runs.version) && findings.every((finding) => finding.kind !== "shadowed")) {
|
|
212
|
-
findings.push({
|
|
213
|
-
kind: "behind",
|
|
214
|
-
text: `a bare \`turri\` runs ${runs.path}, turri ${runs.version} - older than this turri ${identity.version}`,
|
|
215
|
-
short: `a bare turri runs an older turri, ${runs.version}, from ${runs.path} - turri doctor shows how to fix it`,
|
|
216
|
-
fixes: [`take it off the PATH: ${removalOf(runs)}`, process.platform === "win32" ? "then open a new terminal" : "then `hash -r`, or a new terminal"],
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
return findings;
|
|
220
|
-
}
|
|
221
|
-
/** `turri --version`: the version line, then where this turri is, what npm has - asked now - and every turri on the PATH. */
|
|
222
|
-
export async function describeVersion(versionLine) {
|
|
223
|
-
const own = turriIdentity();
|
|
224
|
-
const onPath = turrisOnPath();
|
|
225
|
-
const latest = own.git_commit === null ? await fetchLatest() : undefined;
|
|
226
|
-
const lines = [versionLine, ` this turri: ${turriRoot()}`];
|
|
227
|
-
if (own.git_commit === null) {
|
|
228
|
-
lines.push(latest === undefined
|
|
229
|
-
? " newest on npm: not known - npm did not answer"
|
|
230
|
-
: ` newest on npm: ${latest}${own.version !== null && !newerThan(latest, own.version) ? " - this is it" : ""}`);
|
|
231
|
-
}
|
|
232
|
-
if (onPath.length > 0) {
|
|
233
|
-
lines.push(" turri on PATH:");
|
|
234
|
-
for (const turri of onPath) {
|
|
235
|
-
const marks = [turri.runs ? "runs" : "hidden", ...(turri.self ? ["this one"] : []), ...(turri.clone ? ["a clone"] : [])].join(", ");
|
|
236
|
-
lines.push(` ${turri.path} turri ${turri.version ?? "?"} (${marks})`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
lines.push(" turri on PATH: none - this one was run by its path");
|
|
241
|
-
}
|
|
242
|
-
const findings = versionFindings({ ...(latest !== undefined ? { latest } : {}), onPath, self: { ...(own.version !== null ? { version: own.version } : {}), clone: own.git_commit !== null, root: turriRoot() } });
|
|
243
|
-
for (const finding of findings)
|
|
244
|
-
lines.push("", `! ${finding.text}`, ...finding.fixes.map((fix) => ` → ${fix}`));
|
|
245
|
-
return lines.join("\n");
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* What the banner says as turri starts: a line a finding, short - what is newer and what to run - from what npm said at
|
|
249
|
-
* the last check and the turris on the PATH, never waiting on the network; the check for next time started behind it.
|
|
250
|
-
*/
|
|
251
|
-
export function bannerWarnings() {
|
|
252
|
-
if (checkOff())
|
|
253
|
-
return { lines: [], later: Promise.resolve(undefined) };
|
|
254
|
-
let findings;
|
|
255
|
-
try {
|
|
256
|
-
const latest = latestKnown()?.version;
|
|
257
|
-
findings = versionFindings(latest !== undefined ? { latest } : {});
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
260
|
-
findings = [];
|
|
261
|
-
}
|
|
262
|
-
const lines = findings.map((finding) => finding.short);
|
|
263
|
-
// What npm says now, once it answers: a turri newer than the banner knew of is said then, in the same chat.
|
|
264
|
-
const later = refreshLatestLater().then((latest) => {
|
|
265
|
-
if (latest === undefined)
|
|
266
|
-
return undefined;
|
|
267
|
-
try {
|
|
268
|
-
const outdated = versionFindings({ latest }).find((finding) => finding.kind === "outdated");
|
|
269
|
-
return outdated !== undefined && !lines.includes(outdated.short) ? outdated.short : undefined;
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
return undefined;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
return { lines, later };
|
|
276
|
-
}
|
package/dist/view.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AskUserIO } from "./ask.ts";
|
|
3
|
-
import type { CaptureStatus } from "./capture/progress.ts";
|
|
4
|
-
import type { ChatLink, TurriCore } from "./chats.ts";
|
|
5
|
-
import type { Job } from "./regenerate/jobs.ts";
|
|
6
|
-
import type { SkillProgress } from "./session-events.ts";
|
|
7
|
-
/**
|
|
8
|
-
* What a front-end draws of a turri session that the core does not: the terminal's (turri's CLI) - its entry renderers,
|
|
9
|
-
* banner, side panel, question dialog and keys. The core decides and does everything; a view only shows it. A host
|
|
10
|
-
* (turri-app) and a headless run pass none, and the core behaves for them as it always has.
|
|
11
|
-
*
|
|
12
|
-
* Given to `createTurriCore(host, { view })` - never as a TurriHost field: a host with any key is a host to the ledger.
|
|
13
|
-
*/
|
|
14
|
-
export interface TurriView {
|
|
15
|
-
/**
|
|
16
|
-
* Built into every chat - the sentinel's too - inside the chat's scope, where turri's extension registers its own
|
|
17
|
-
* terminal parts: after its handlers that remember the chat's context, before its capture and skill commands, so
|
|
18
|
-
* a banner drawn on session_start comes before a capture's report. Registers what only a screen needs: entry and
|
|
19
|
-
* message renderers, the banner's painting, the side panel's key.
|
|
20
|
-
*/
|
|
21
|
-
chat?(pi: ExtensionAPI, chat: ViewChat): void;
|
|
22
|
-
/**
|
|
23
|
-
* Built into every chat of a terminal session (`TurriCore.terminal`), inside the chat's scope, where turri's extension
|
|
24
|
-
* registers the terminal's chat commands: after its conversation's commands (`/btw` the last of them), before its
|
|
25
|
-
* capture and skill commands - so pi's command list keeps turri's order. Registers `/chat` and its keys.
|
|
26
|
-
*/
|
|
27
|
-
chatCommands?(pi: ExtensionAPI, chat: ViewChat): void;
|
|
28
|
-
/** How a question is put to the person in a chat that has a screen and no host dialogs. */
|
|
29
|
-
questions?: QuestionView;
|
|
30
|
-
/** The session's side panel - one for every chat. `/pulses`, `/notifications` and the chat header's toggle open it. */
|
|
31
|
-
panel?(session: TurriCore): SidePanelView;
|
|
32
|
-
/** A pulse ended and was not replaced by another: just before the session tells its chats (`TurriCore.jobFinished`). */
|
|
33
|
-
pulseFinished?(job: Job): void;
|
|
34
|
-
/** A `/capture` running in a chat with a screen: its status, drawn above the input until it ends. */
|
|
35
|
-
captureProgress?(ctx: ExtensionContext): CaptureProgressView;
|
|
36
|
-
/** A foreground skill starts or changes step/attempt; null clears the chat's widget on every exit. */
|
|
37
|
-
skillProgress?(ctx: ExtensionContext, progress: SkillProgress | null): void;
|
|
38
|
-
/** pi's own settings menu, where the screen has one: true once opened. */
|
|
39
|
-
openPiSettings?(): boolean;
|
|
40
|
-
}
|
|
41
|
-
/** A chat, as its view sees it. */
|
|
42
|
-
export interface ViewChat {
|
|
43
|
-
readonly session: TurriCore;
|
|
44
|
-
readonly link: ChatLink;
|
|
45
|
-
/** The context the chat's tools and handlers were last given - undefined until its session starts. */
|
|
46
|
-
context(): ExtensionContext | undefined;
|
|
47
|
-
}
|
|
48
|
-
/** A question open in a dialog: whether the person declined it, and how to close the dialog from outside. */
|
|
49
|
-
export interface Declining {
|
|
50
|
-
declined: boolean;
|
|
51
|
-
/** Set by the dialog shown, so a stopped turn closes it. */
|
|
52
|
-
close: (() => void) | undefined;
|
|
53
|
-
}
|
|
54
|
-
/** The terminal's way of asking: dialogs over the chat, and keys they let through. */
|
|
55
|
-
export interface QuestionView {
|
|
56
|
-
/**
|
|
57
|
-
* The dialogs one question is put in, in ctx's chat. `decline` is the person declining at a dialog - turri's answer
|
|
58
|
-
* says so - and the dialog shown sets `declining.close`. Once the question is declined (`declining.declined`), turri
|
|
59
|
-
* opens none of them again: a dialog asked for then never reaches the view, and comes back with no answer.
|
|
60
|
-
*/
|
|
61
|
-
dialogs(ctx: ExtensionContext, declining: Declining, decline: () => void): AskUserIO;
|
|
62
|
-
/** While a question waits in ctx's chat: the keys its dialog lets through (the side panel's peek). Returns its undo. */
|
|
63
|
-
whileAsking?(ctx: ExtensionContext): () => void;
|
|
64
|
-
}
|
|
65
|
-
/** What the side panel shows: the regeneration (regen), the pulses, or finished pulses and sentinel notices. */
|
|
66
|
-
export type PanelPage = "map" | "pulses" | "notifications";
|
|
67
|
-
export interface SidePanelView {
|
|
68
|
-
/** Opened on a page - the one it was on when none is named - over the screen, or beside the chat. */
|
|
69
|
-
open(ctx: ExtensionContext, page?: PanelPage, placement?: "beside"): void;
|
|
70
|
-
/** On the screen, beside the chat or over it. */
|
|
71
|
-
visible(): boolean;
|
|
72
|
-
close(): void;
|
|
73
|
-
}
|
|
74
|
-
/** A capture's status above the input. `close` may be called more than once. */
|
|
75
|
-
export interface CaptureProgressView {
|
|
76
|
-
update(status: CaptureStatus): void;
|
|
77
|
-
close(): void;
|
|
78
|
-
}
|
package/dist/view.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|