archymedes-cli 2.5.0 → 3.0.0
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/bin/archymedes.mjs +62 -0
- package/dist/{archymedes-bmtdqqwt.mjs → archymedes-2emwtckp.mjs} +1 -1
- package/dist/{archymedes-138genyy.mjs → archymedes-e8vb7ty3.mjs} +3 -3
- package/dist/{archymedes-d3azqkay.mjs → archymedes-ebm17h2q.mjs} +56 -56
- package/dist/{archymedes-2kvjaajw.mjs → archymedes-hf7kq83m.mjs} +2 -2
- package/dist/archymedes-main.mjs +6967 -6438
- package/dist/{archymedes-w4bjfye7.mjs → archymedes-qm9bwbe7.mjs} +2 -2
- package/dist/{archymedes-5vhvv8kr.mjs → archymedes-qsrxyhb3.mjs} +1 -1
- package/dist/{archymedes-a3ms7jvr.mjs → archymedes-v1ydhsp9.mjs} +2 -2
- package/dist/{archymedes-130jt0wr.mjs → archymedes-y64yssbc.mjs} +21 -2
- package/dist/{editor-screen-e01mn7dd.mjs → editor-screen-jckemg13.mjs} +3 -3
- package/dist/{file-screen-stcxznwy.mjs → file-screen-ddw903zr.mjs} +3 -3
- package/dist/{guide-screen-w5nb9sry.mjs → guide-screen-x2wa7kf6.mjs} +4 -4
- package/dist/{projection-x6x6hm9t.mjs → projection-4jjdaf41.mjs} +1 -1
- package/dist/{workspace-screen-62k6hnq7.mjs → workspace-screen-y3th9fj9.mjs} +4 -4
- package/package.json +9 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The `archymedes` command, as npm installs it.
|
|
3
|
+
//
|
|
4
|
+
// The interface is a Go binary, shipped per platform as an optional dependency
|
|
5
|
+
// (@archymedes/cli-<platform>-<arch>, one static binary each). The agent behind it is the bundled
|
|
6
|
+
// dist/archymedes.mjs, run with this same Node: the binary is told where it is through
|
|
7
|
+
// ARCHYMEDES_AGENT, as a JSON array so an install path with spaces survives.
|
|
8
|
+
//
|
|
9
|
+
// Where no binary matches the platform — an unusual architecture, or optional dependencies turned
|
|
10
|
+
// off — the bundled CLI runs directly instead, with one line saying so. A missing binary is never a
|
|
11
|
+
// reason for `archymedes` not to start.
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const agentEntry = path.join(import.meta.dirname, "..", "dist", "archymedes.mjs");
|
|
19
|
+
|
|
20
|
+
function interfaceBinary() {
|
|
21
|
+
if (process.env.ARCHYMEDES_GO_BINARY) return process.env.ARCHYMEDES_GO_BINARY;
|
|
22
|
+
const name = `@archymedes/cli-${process.platform}-${process.arch}`;
|
|
23
|
+
try {
|
|
24
|
+
const directory = path.dirname(require.resolve(`${name}/package.json`));
|
|
25
|
+
const binary = path.join(directory, "bin", process.platform === "win32" ? "archymedes.exe" : "archymedes");
|
|
26
|
+
return existsSync(binary) ? binary : undefined;
|
|
27
|
+
} catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function runBundled(reason) {
|
|
33
|
+
if (reason && process.stderr.isTTY) process.stderr.write(`archymedes: ${reason}; using the bundled interface.\n`);
|
|
34
|
+
await import(agentEntry);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const binary = interfaceBinary();
|
|
38
|
+
if (!binary) {
|
|
39
|
+
await runBundled(`no prebuilt interface for ${process.platform}-${process.arch}`);
|
|
40
|
+
} else {
|
|
41
|
+
const env = { ...process.env, ARCHYMEDES_AGENT: process.env.ARCHYMEDES_AGENT || JSON.stringify([process.execPath, agentEntry]) };
|
|
42
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit", env });
|
|
43
|
+
|
|
44
|
+
// The terminal sends Ctrl+C and Ctrl+\ to the whole process group, so the interface already has
|
|
45
|
+
// them and decides what they mean (stop a turn, not quit). This process only waits. A signal
|
|
46
|
+
// aimed at this process alone is passed on.
|
|
47
|
+
for (const signal of ["SIGINT", "SIGQUIT"]) process.on(signal, () => {});
|
|
48
|
+
for (const signal of ["SIGTERM", "SIGHUP"]) process.on(signal, () => child.kill(signal));
|
|
49
|
+
|
|
50
|
+
child.on("error", (error) => {
|
|
51
|
+
// Present but not runnable (a stripped executable bit, a foreign architecture under emulation).
|
|
52
|
+
void runBundled(`the interface binary could not start (${error.code ?? error.message})`);
|
|
53
|
+
});
|
|
54
|
+
child.on("exit", (code, signal) => {
|
|
55
|
+
if (signal) {
|
|
56
|
+
process.removeAllListeners(signal);
|
|
57
|
+
process.kill(process.pid, signal);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
process.exit(code ?? 1);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
scrollIndicator,
|
|
5
5
|
scrollPercent,
|
|
6
6
|
sliceToWidth
|
|
7
|
-
} from "./archymedes-
|
|
7
|
+
} from "./archymedes-qsrxyhb3.mjs";
|
|
8
8
|
import {
|
|
9
9
|
clip
|
|
10
|
-
} from "./archymedes-
|
|
10
|
+
} from "./archymedes-2emwtckp.mjs";
|
|
11
11
|
import {
|
|
12
12
|
ASCII_GLYPHS,
|
|
13
13
|
UNICODE_GLYPHS,
|
|
14
14
|
visibleWidth
|
|
15
|
-
} from "./archymedes-
|
|
15
|
+
} from "./archymedes-y64yssbc.mjs";
|
|
16
16
|
|
|
17
17
|
// packages/archymedes-cli/src/render/canvas.ts
|
|
18
18
|
var BRAILLE_DOTS = [
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
note,
|
|
5
5
|
panel,
|
|
6
6
|
rule
|
|
7
|
-
} from "./archymedes-
|
|
7
|
+
} from "./archymedes-2emwtckp.mjs";
|
|
8
8
|
import {
|
|
9
9
|
BOLD,
|
|
10
10
|
DIM,
|
|
@@ -12,60 +12,7 @@ import {
|
|
|
12
12
|
paint,
|
|
13
13
|
paintAll,
|
|
14
14
|
visibleWidth
|
|
15
|
-
} from "./archymedes-
|
|
16
|
-
|
|
17
|
-
// packages/archymedes-cli/src/terminal/viewport.ts
|
|
18
|
-
function newViewport(lines, height) {
|
|
19
|
-
return clamp({ lines, height: Math.max(1, Math.floor(height)), top: 0 });
|
|
20
|
-
}
|
|
21
|
-
function maxTop(state) {
|
|
22
|
-
return Math.max(0, state.lines.length - state.height);
|
|
23
|
-
}
|
|
24
|
-
function clamp(state) {
|
|
25
|
-
const height = Math.max(1, Math.floor(state.height));
|
|
26
|
-
const bounded = { ...state, height };
|
|
27
|
-
const top = Math.max(0, Math.min(Math.floor(bounded.top) || 0, maxTop(bounded)));
|
|
28
|
-
return { ...bounded, top };
|
|
29
|
-
}
|
|
30
|
-
function applyViewport(state, action) {
|
|
31
|
-
switch (action.kind) {
|
|
32
|
-
case "up":
|
|
33
|
-
return clamp({ ...state, top: state.top - Math.max(1, action.rows ?? 1) });
|
|
34
|
-
case "down":
|
|
35
|
-
return clamp({ ...state, top: state.top + Math.max(1, action.rows ?? 1) });
|
|
36
|
-
case "halfUp":
|
|
37
|
-
return clamp({ ...state, top: state.top - Math.max(1, Math.floor(state.height / 2)) });
|
|
38
|
-
case "halfDown":
|
|
39
|
-
return clamp({ ...state, top: state.top + Math.max(1, Math.floor(state.height / 2)) });
|
|
40
|
-
case "pageUp":
|
|
41
|
-
return clamp({ ...state, top: state.top - Math.max(1, state.height - 1) });
|
|
42
|
-
case "pageDown":
|
|
43
|
-
return clamp({ ...state, top: state.top + Math.max(1, state.height - 1) });
|
|
44
|
-
case "top":
|
|
45
|
-
return clamp({ ...state, top: 0 });
|
|
46
|
-
case "bottom":
|
|
47
|
-
return clamp({ ...state, top: maxTop(state) });
|
|
48
|
-
case "resize":
|
|
49
|
-
return clamp({ ...state, height: action.height });
|
|
50
|
-
case "content": {
|
|
51
|
-
const next = clamp({ ...state, lines: action.lines });
|
|
52
|
-
return action.follow ? clamp({ ...next, top: maxTop(next) }) : next;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function visibleLines(state) {
|
|
57
|
-
return state.lines.slice(state.top, state.top + state.height);
|
|
58
|
-
}
|
|
59
|
-
function atTop(state) {
|
|
60
|
-
return state.top <= 0;
|
|
61
|
-
}
|
|
62
|
-
function atBottom(state) {
|
|
63
|
-
return state.top >= maxTop(state);
|
|
64
|
-
}
|
|
65
|
-
function scrollFraction(state) {
|
|
66
|
-
const furthest = maxTop(state);
|
|
67
|
-
return furthest === 0 ? 1 : state.top / furthest;
|
|
68
|
-
}
|
|
15
|
+
} from "./archymedes-y64yssbc.mjs";
|
|
69
16
|
|
|
70
17
|
// packages/archymedes-cli/src/platform/i18n.ts
|
|
71
18
|
var CONTROL_LANGUAGES = {
|
|
@@ -714,6 +661,59 @@ function renderKeyboardShortcuts(language = "en") {
|
|
|
714
661
|
`);
|
|
715
662
|
}
|
|
716
663
|
|
|
664
|
+
// packages/archymedes-cli/src/terminal/viewport.ts
|
|
665
|
+
function newViewport(lines, height) {
|
|
666
|
+
return clamp({ lines, height: Math.max(1, Math.floor(height)), top: 0 });
|
|
667
|
+
}
|
|
668
|
+
function maxTop(state) {
|
|
669
|
+
return Math.max(0, state.lines.length - state.height);
|
|
670
|
+
}
|
|
671
|
+
function clamp(state) {
|
|
672
|
+
const height = Math.max(1, Math.floor(state.height));
|
|
673
|
+
const bounded = { ...state, height };
|
|
674
|
+
const top = Math.max(0, Math.min(Math.floor(bounded.top) || 0, maxTop(bounded)));
|
|
675
|
+
return { ...bounded, top };
|
|
676
|
+
}
|
|
677
|
+
function applyViewport(state, action) {
|
|
678
|
+
switch (action.kind) {
|
|
679
|
+
case "up":
|
|
680
|
+
return clamp({ ...state, top: state.top - Math.max(1, action.rows ?? 1) });
|
|
681
|
+
case "down":
|
|
682
|
+
return clamp({ ...state, top: state.top + Math.max(1, action.rows ?? 1) });
|
|
683
|
+
case "halfUp":
|
|
684
|
+
return clamp({ ...state, top: state.top - Math.max(1, Math.floor(state.height / 2)) });
|
|
685
|
+
case "halfDown":
|
|
686
|
+
return clamp({ ...state, top: state.top + Math.max(1, Math.floor(state.height / 2)) });
|
|
687
|
+
case "pageUp":
|
|
688
|
+
return clamp({ ...state, top: state.top - Math.max(1, state.height - 1) });
|
|
689
|
+
case "pageDown":
|
|
690
|
+
return clamp({ ...state, top: state.top + Math.max(1, state.height - 1) });
|
|
691
|
+
case "top":
|
|
692
|
+
return clamp({ ...state, top: 0 });
|
|
693
|
+
case "bottom":
|
|
694
|
+
return clamp({ ...state, top: maxTop(state) });
|
|
695
|
+
case "resize":
|
|
696
|
+
return clamp({ ...state, height: action.height });
|
|
697
|
+
case "content": {
|
|
698
|
+
const next = clamp({ ...state, lines: action.lines });
|
|
699
|
+
return action.follow ? clamp({ ...next, top: maxTop(next) }) : next;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function visibleLines(state) {
|
|
704
|
+
return state.lines.slice(state.top, state.top + state.height);
|
|
705
|
+
}
|
|
706
|
+
function atTop(state) {
|
|
707
|
+
return state.top <= 0;
|
|
708
|
+
}
|
|
709
|
+
function atBottom(state) {
|
|
710
|
+
return state.top >= maxTop(state);
|
|
711
|
+
}
|
|
712
|
+
function scrollFraction(state) {
|
|
713
|
+
const furthest = maxTop(state);
|
|
714
|
+
return furthest === 0 ? 1 : state.top / furthest;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
717
|
// packages/archymedes-cli/src/render/guide.ts
|
|
718
718
|
var GUIDE_TOPICS = [
|
|
719
719
|
{
|
|
@@ -1116,4 +1116,4 @@ function parseGuideCommand(input) {
|
|
|
1116
1116
|
return findTopic(rest) ? { kind: "topic", id: findTopic(rest).id } : { kind: "unknown", id: rest };
|
|
1117
1117
|
}
|
|
1118
1118
|
|
|
1119
|
-
export {
|
|
1119
|
+
export { CONTROL_LANGUAGES, resolveControlLanguage, controlLabel, t, COMMANDS2 as COMMANDS, renderCommandHelp, suggestionsFor, inlineCompletion, isKnownCommand, parseModeCommand, suggestCommand, renderKeyboardShortcuts, newViewport, maxTop, applyViewport, visibleLines, atTop, atBottom, scrollFraction, GUIDE_TOPICS, findTopic, searchTopics, wrapText, renderGuideIndex, renderGuideTopic, renderWholeGuide, parseGuideCommand };
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
GUTTER,
|
|
3
3
|
clip,
|
|
4
4
|
panel
|
|
5
|
-
} from "./archymedes-
|
|
5
|
+
} from "./archymedes-2emwtckp.mjs";
|
|
6
6
|
import {
|
|
7
7
|
BOLD,
|
|
8
8
|
DIM,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
paintAll,
|
|
15
15
|
roleCode,
|
|
16
16
|
visibleWidth
|
|
17
|
-
} from "./archymedes-
|
|
17
|
+
} from "./archymedes-y64yssbc.mjs";
|
|
18
18
|
|
|
19
19
|
// packages/archymedes-cli/src/render/code-view.ts
|
|
20
20
|
var MAX_DIFF_CELLS = 250000;
|