docks-kit 0.21.1 → 0.22.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/AGENTS.md +5 -4
- package/README.md +5 -6
- package/cli/docs/flags.md +3 -1
- package/cli/docs/install.md +1 -1
- package/cli/docs/platforms.md +6 -4
- package/cli/src/checklistPrompt.ts +464 -0
- package/cli/src/commands/docs.ts +1 -1
- package/cli/src/commands/harnesses.ts +20 -11
- package/cli/src/engine-native/DESIGN.md +4 -3
- package/cli/src/engine-native/os/targets.ts +3 -11
- package/cli/src/engine-native/os/windows.ts +1 -1
- package/cli/src/engine.ts +1 -1
- package/cli/src/generated/sotPayload.ts +1 -1
- package/cli/src/terminalCells.ts +191 -0
- package/docks-kit +1 -2
- package/docks-kit.ps1 +1 -2
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -21,7 +21,7 @@ Tool-specific instructions live alongside this file:
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
docks-kit runtime and standalone binary support covers Linux x64/arm64, macOS
|
|
24
|
-
|
|
24
|
+
arm64, and Windows x64. Hosts outside this matrix fail before either
|
|
25
25
|
launcher can fall back to Bun source.
|
|
26
26
|
|
|
27
27
|
## Repository layout (cross-cutting)
|
|
@@ -29,10 +29,11 @@ launcher can fall back to Bun source.
|
|
|
29
29
|
| Path | Purpose |
|
|
30
30
|
|------|---------|
|
|
31
31
|
| `docks-kit` / `docks-kit.ps1` | POSIX and Windows CLI launchers. On supported hosts, each runs the matching binary in `cli/dist/` only when its `--version` matches `package.json`. Otherwise it runs Bun-from-source and auto-installs Bun plus `node_modules`, and the mismatch warning names the rebuild remedy. A launcher never deletes a binary: on a host without Bun it is the only remaining recovery path. Hosts outside the support matrix fail before source fallback. The standalone platform release binary provides no-Bun recovery. |
|
|
32
|
-
| `cli/build-binaries.sh` | Compiles the
|
|
32
|
+
| `cli/build-binaries.sh` | Compiles the four release binaries (`docks-kit-linux-x64`, `docks-kit-linux-arm64`, `docks-kit-darwin-arm64`, `docks-kit-windows-x64.exe`). It checksums the four known artifact names rather than globbing `docks-kit-*`, so a packed `docks-kit-<version>.tgz` is never attested as a release binary. It stamps `cli/dist/VERSION` only when the directory holds one version, and on the next build discards every artifact that stamp attributes to a different version, because a launcher refuses to run one and keeping it makes `SHA256SUMS` span two versions. An artifact with no stamp has unknown provenance and may be a hand-built or downloaded recovery binary, so the script keeps it and warns; `--prune` discards those too. Nothing here removes an artifact the stamp vouches for. |
|
|
33
33
|
| `cli/src/engine-native/` | EngineNative implementation for `sync`, `model`, and `toolchain`; idempotent, flag-gated for destructive reconciliation |
|
|
34
34
|
| `cli/src/engine-native/ompSync.ts` | omp sync orchestration and summary |
|
|
35
35
|
| `cli/src/commands/omp.ts` | `docks-kit omp` session launcher: rejects model-selecting forwarded flags, checks the free catalog of each candidate profile, renders the free-model run overlay, and starts `omp launch` |
|
|
36
|
+
| `cli/src/checklistPrompt.ts` / `cli/src/terminalCells.ts` | Shared terminal checklist prompt on Effect's `Prompt.Custom`: items, a Save row, key hints, an ASCII fallback, and NO_COLOR; `docks-kit harnesses` uses it. `terminalCells.ts` measures text in terminal cells and rows from the pinned Unicode 18.0.0 East Asian Width table; derive the table again from a newer `EastAsianWidth.txt` the same way its header says |
|
|
36
37
|
| `cli/src/engine-native/ompOverlay.ts` | Free-model overlay render, omp argv and child environment, plus catalog parse and thinking-ceiling helpers |
|
|
37
38
|
| `cli/src/engine-native/scratch.ts` / `cli/src/commands/scratch.ts` | `docks-kit scratch new\|remove`: private agent temporary directories under `~/.cache/docks-kit/scratch/`; removal accepts only a real path strictly inside the scratch root, the system temporary directory, or `/var/tmp` |
|
|
38
39
|
| `cli/src/engine-native/tidy.ts` / `tidyReport.ts` / `cli/src/commands/tidy.ts` | `docks-kit tidy [--apply] [--repo <path>] [--report]`: plan and apply the safe leftover sweep (merged idle worktrees and their containers, orphaned processes in agent directories, idle scratch); Docker calls run only against a verified local endpoint (`unix:///…` or `npipe:////./pipe/…`); the report is read-only |
|
|
@@ -48,8 +49,8 @@ launcher can fall back to Bun source.
|
|
|
48
49
|
| `SoT/toolchain.json` | Toolchain floors manifest (verified pins consumed by EngineNative; optional `upstream` source read by `docks-kit toolchain outdated`) |
|
|
49
50
|
| `SoT/.claude/bin/` | Dependency-free Bun runtime programs for Claude's statusline, SessionStart, and Notification |
|
|
50
51
|
| `SoT/.omp/` | Kit-owned omp SoT: `AGENTS.md`, `config.yml`, `models.yml`, `mcp.json`, and `intercom.json` |
|
|
51
|
-
| `install.sh` / `install.ps1` | POSIX and Windows global installers |
|
|
52
|
-
| `.github/workflows/release-cli.yml` | `cli-v*` release:
|
|
52
|
+
| `install.sh` / `install.ps1` | POSIX and Windows global installers. Each installer stops on a host outside the support matrix before it downloads anything. |
|
|
53
|
+
| `.github/workflows/release-cli.yml` | `cli-v*` release: four binaries (Linux x64 and arm64, macOS arm64, Windows x64), plus `SHA256SUMS` and npm publish |
|
|
53
54
|
| `README.md` | Front door |
|
|
54
55
|
| `package.json` / `bun.lock` | npm package: `bin` = `cli/src/main.ts`; bundles `cli/` with the generated in-memory SoT payload |
|
|
55
56
|
| `SoT/.agents/skills.txt` | Universal-skill manifest, intentionally empty by default. Adding an [agentskills.io](https://agentskills.io/specification) slug opts it into EngineNative's shared `~/.agents/skills/` bootstrap and Claude symlink. |
|
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ cd ~/projects/public
|
|
|
19
19
|
./docks-kit status # doctor view: drift, toolchain, plugins, skills
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
POSIX hosts use the `./docks-kit` launcher on x64 and arm64
|
|
23
|
-
`.\docks-kit.ps1` on x64
|
|
22
|
+
POSIX hosts use the `./docks-kit` launcher on Linux x64 and arm64 and on macOS
|
|
23
|
+
arm64. Windows uses `.\docks-kit.ps1` on x64. Each launcher prefers the matching compiled
|
|
24
24
|
binary in `cli/dist/` only when its version matches the checkout. Otherwise it
|
|
25
25
|
runs from source via Bun and auto-installs Bun plus dependencies when needed.
|
|
26
26
|
Hosts outside this matrix fail immediately and never fall back to Bun source.
|
|
@@ -154,17 +154,16 @@ and a later flag-less sync reverts them. Full reference: `docks-kit docs flags`
|
|
|
154
154
|
|----------|--------------|------------------|-------------|
|
|
155
155
|
| Linux | x64 | ✅ | ✅ native |
|
|
156
156
|
| Linux | arm64 | ✅ | ✅ native |
|
|
157
|
-
| macOS | x64 | ✅ | ✅ native |
|
|
158
157
|
| macOS | arm64 | ✅ | ✅ native |
|
|
159
158
|
| Windows | x64 | ✅ | ✅ native |
|
|
160
|
-
| Windows | arm64 | ✅ | ✅ native |
|
|
161
159
|
|
|
162
160
|
Details: `docks-kit docs platforms`.
|
|
163
161
|
|
|
164
162
|
## Releases
|
|
165
163
|
|
|
166
|
-
Tagging `cli-v*` builds
|
|
167
|
-
|
|
164
|
+
Tagging `cli-v*` builds four standalone binaries: `docks-kit-linux-x64`,
|
|
165
|
+
`docks-kit-linux-arm64`, `docks-kit-darwin-arm64`, and
|
|
166
|
+
`docks-kit-windows-x64.exe`. The workflow attaches them plus `SHA256SUMS` to the GitHub
|
|
168
167
|
release. npm publishes the exact package tarball through trusted publishing
|
|
169
168
|
with OIDC provenance.
|
|
170
169
|
Published binaries, checksums, and release notes are available on
|
package/cli/docs/flags.md
CHANGED
|
@@ -18,7 +18,9 @@ Positional targets are `claude`, `codex`, `agents`, and `omp`. A flag-less
|
|
|
18
18
|
`codex`, and `agents`, and never selects `omp`. Choose the stored selection
|
|
19
19
|
with `docks-kit harnesses`. With no stored selection, its picker pre-ticks all
|
|
20
20
|
four harnesses, `omp` included; a flag-less `sync` does not change until the
|
|
21
|
-
picker saves a selection.
|
|
21
|
+
picker saves a selection. In the picker, Enter or Space ticks or unticks the
|
|
22
|
+
harness under the cursor, Enter on the Save row stores the selection, and
|
|
23
|
+
Escape leaves it unchanged.
|
|
22
24
|
|
|
23
25
|
## Global flags
|
|
24
26
|
|
package/cli/docs/install.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Installing docks-kit
|
|
2
2
|
|
|
3
|
-
Supported hosts are Linux x64/arm64, macOS
|
|
3
|
+
Supported hosts are Linux x64/arm64, macOS arm64, and Windows x64.
|
|
4
4
|
Hosts outside this matrix fail before a launcher can fall back to Bun source.
|
|
5
5
|
|
|
6
6
|
## 1. Repo checkout (development / current users)
|
package/cli/docs/platforms.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# Platform support
|
|
2
2
|
|
|
3
|
-
The supported host matrix is exact:
|
|
3
|
+
The supported host matrix is exact: Linux on x64 and arm64, macOS on arm64,
|
|
4
|
+
and Windows on x64.
|
|
4
5
|
|
|
5
6
|
| Platform | Architecture | docks-kit binary | Sync engine |
|
|
6
7
|
|----------|--------------|------------------|-------------|
|
|
7
8
|
| Linux | x64 | `docks-kit-linux-x64` | EngineNative (TS) |
|
|
8
9
|
| Linux | arm64 | `docks-kit-linux-arm64` | EngineNative (TS) |
|
|
9
|
-
| macOS | x64 | `docks-kit-darwin-x64` | EngineNative (TS) |
|
|
10
10
|
| macOS | arm64 | `docks-kit-darwin-arm64` | EngineNative (TS) |
|
|
11
11
|
| Windows | x64 | `docks-kit-windows-x64.exe` | EngineNative (TS) |
|
|
12
|
-
| Windows | arm64 | `docks-kit-windows-arm64.exe` | EngineNative (TS) |
|
|
13
12
|
|
|
14
13
|
POSIX hosts use the `docks-kit` launcher. Windows uses `docks-kit.ps1`.
|
|
15
14
|
Hosts outside this table fail before either launcher can fall back to Bun
|
|
16
|
-
source.
|
|
15
|
+
source. The POSIX launcher and `install.sh` read the architecture of the
|
|
16
|
+
shell with `uname -m`. On an Apple silicon Mac, a shell that runs under
|
|
17
|
+
Rosetta reports `x86_64` and gets the unsupported-host message, so run
|
|
18
|
+
docks-kit from a native arm64 shell.
|
|
17
19
|
|
|
18
20
|
EngineNative is the only supported engine on supported hosts.
|
|
19
21
|
`DOCKS_KIT_ENGINE=bash` exits with the removed-engine message and points at the
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { Effect, Terminal } from "effect";
|
|
2
|
+
import { Prompt } from "effect/unstable/cli";
|
|
3
|
+
import { terminalCells, terminalRows } from "./terminalCells";
|
|
4
|
+
|
|
5
|
+
/** One row of a checklist. The label and the description are each one line of text. */
|
|
6
|
+
export interface ChecklistItem<A> {
|
|
7
|
+
readonly value: A;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly checked: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ChecklistOptions<A> {
|
|
14
|
+
/** The text in the top border of the panel. */
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** A dimmed text under the message. */
|
|
18
|
+
readonly note?: string;
|
|
19
|
+
readonly items: ReadonlyArray<ChecklistItem<A>>;
|
|
20
|
+
/** The text on the Save row after a save with no ticked item. */
|
|
21
|
+
readonly emptySelectionError: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `Saved` lists the ticked values in item order. */
|
|
25
|
+
export type ChecklistResult<A> =
|
|
26
|
+
| { readonly _tag: "Saved"; readonly values: ReadonlyArray<A> }
|
|
27
|
+
| { readonly _tag: "Cancelled" };
|
|
28
|
+
|
|
29
|
+
interface ChecklistState {
|
|
30
|
+
/** An item index, or the item count for the Save row. */
|
|
31
|
+
readonly cursor: number;
|
|
32
|
+
readonly checked: ReadonlyArray<boolean>;
|
|
33
|
+
/** A save with no ticked item sets it; the next toggle clears it. */
|
|
34
|
+
readonly showError: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ChecklistAction<A> = Prompt.Action<ChecklistState, ChecklistResult<A>>;
|
|
38
|
+
|
|
39
|
+
type Style = "plain" | "bold" | "dim" | "accent" | "accentBold" | "green" | "red";
|
|
40
|
+
|
|
41
|
+
interface Span {
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly style: Style;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type Line = ReadonlyArray<Span>;
|
|
47
|
+
|
|
48
|
+
interface Glyphs {
|
|
49
|
+
readonly pointer: string;
|
|
50
|
+
readonly ticked: string;
|
|
51
|
+
readonly unticked: string;
|
|
52
|
+
readonly ellipsis: string;
|
|
53
|
+
readonly topLeft: string;
|
|
54
|
+
readonly topRight: string;
|
|
55
|
+
readonly bottomLeft: string;
|
|
56
|
+
readonly bottomRight: string;
|
|
57
|
+
readonly horizontal: string;
|
|
58
|
+
readonly vertical: string;
|
|
59
|
+
readonly hint: ReadonlyArray<string>;
|
|
60
|
+
readonly hintSeparator: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const UNICODE: Glyphs = {
|
|
64
|
+
pointer: "❯",
|
|
65
|
+
ticked: "●",
|
|
66
|
+
unticked: "○",
|
|
67
|
+
ellipsis: "…",
|
|
68
|
+
topLeft: "╭",
|
|
69
|
+
topRight: "╮",
|
|
70
|
+
bottomLeft: "╰",
|
|
71
|
+
bottomRight: "╯",
|
|
72
|
+
horizontal: "─",
|
|
73
|
+
vertical: "│",
|
|
74
|
+
hint: ["↑↓ move", "enter/space toggle", "enter on Save saves", "esc cancel"],
|
|
75
|
+
hintSeparator: " · ",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// The legacy Windows console can show the Unicode glyphs as boxes.
|
|
79
|
+
const ASCII: Glyphs = {
|
|
80
|
+
pointer: ">",
|
|
81
|
+
ticked: "[x]",
|
|
82
|
+
unticked: "[ ]",
|
|
83
|
+
ellipsis: "...",
|
|
84
|
+
topLeft: "+",
|
|
85
|
+
topRight: "+",
|
|
86
|
+
bottomLeft: "+",
|
|
87
|
+
bottomRight: "+",
|
|
88
|
+
horizontal: "-",
|
|
89
|
+
vertical: "|",
|
|
90
|
+
hint: ["up/down move", "enter/space toggle", "enter on Save saves", "esc cancel"],
|
|
91
|
+
hintSeparator: " - ",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const SGR: Record<Style, string> = {
|
|
95
|
+
plain: "",
|
|
96
|
+
bold: "\u001b[1m",
|
|
97
|
+
dim: "\u001b[2m",
|
|
98
|
+
accent: "\u001b[36m",
|
|
99
|
+
accentBold: "\u001b[1;36m",
|
|
100
|
+
green: "\u001b[32m",
|
|
101
|
+
red: "\u001b[31m",
|
|
102
|
+
};
|
|
103
|
+
const SGR_RESET = "\u001b[0m";
|
|
104
|
+
const CURSOR_HIDE = "\u001b[?25l";
|
|
105
|
+
const ERASE_LINE = "\u001b[2K";
|
|
106
|
+
const CURSOR_UP = "\u001b[1A";
|
|
107
|
+
const CURSOR_COLUMN_ONE = "\u001b[G";
|
|
108
|
+
|
|
109
|
+
/** A terminal that reports 0 columns does not know its width. */
|
|
110
|
+
const DEFAULT_COLUMNS = 80;
|
|
111
|
+
/** Below this width, the border takes too much of each line. */
|
|
112
|
+
const BORDER_MIN_COLUMNS = 40;
|
|
113
|
+
/** The columns of "│ " and " │" around the panel content. */
|
|
114
|
+
const BORDER_COLUMNS = 4;
|
|
115
|
+
/** The hint starts in the column of the panel content. */
|
|
116
|
+
const BORDERED_HINT_INDENT = 2;
|
|
117
|
+
const GAP = " ";
|
|
118
|
+
const SAVE_LABEL = "Save";
|
|
119
|
+
|
|
120
|
+
const CANCELLED = { _tag: "Submit", value: { _tag: "Cancelled" } } as const;
|
|
121
|
+
const IGNORED = { _tag: "Beep" } as const;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A checklist in a panel. Enter or Space toggles the item under the cursor and
|
|
125
|
+
* saves on the Save row; Escape, Ctrl+C, and Ctrl+D cancel.
|
|
126
|
+
*/
|
|
127
|
+
export function checklistPrompt<A>(
|
|
128
|
+
options: ChecklistOptions<A>,
|
|
129
|
+
): Prompt.Prompt<ChecklistResult<A>> {
|
|
130
|
+
const initial: ChecklistState = {
|
|
131
|
+
cursor: 0,
|
|
132
|
+
checked: options.items.map((item) => item.checked),
|
|
133
|
+
showError: false,
|
|
134
|
+
};
|
|
135
|
+
// The ANSI-free text of the lines on screen. `clear` erases these lines and
|
|
136
|
+
// not a frame that it builds again: the terminal width can change between
|
|
137
|
+
// the two calls, and then a new frame has a different number of lines. The
|
|
138
|
+
// first frame of a run always comes from `render`, so a reused prompt starts
|
|
139
|
+
// clean.
|
|
140
|
+
let shown: ReadonlyArray<string> = [];
|
|
141
|
+
return Prompt.Custom<ChecklistState, ChecklistResult<A>>(initial, {
|
|
142
|
+
render: (state, action) => {
|
|
143
|
+
// Beep shows no bell and no change. Submit leaves the panel erased, so
|
|
144
|
+
// the caller prints the result in its place.
|
|
145
|
+
if (action._tag !== "NextFrame") return Effect.succeed("");
|
|
146
|
+
// https://no-color.org: a NO_COLOR value that is set and not empty turns color off.
|
|
147
|
+
const color = (process.env.NO_COLOR ?? "") === "";
|
|
148
|
+
return Effect.map(frameOf(options, state), (frame) => {
|
|
149
|
+
shown = frame.map((line) => line.map((part) => part.text).join(""));
|
|
150
|
+
const lines = frame.map((line) => paint(line, color));
|
|
151
|
+
return CURSOR_HIDE + lines.join("\n");
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
process: (input, state) => Effect.succeed(nextAction(options.items, input.key, state)),
|
|
155
|
+
clear: () =>
|
|
156
|
+
Effect.gen(function* () {
|
|
157
|
+
const terminal = yield* Terminal.Terminal;
|
|
158
|
+
const reported = yield* terminal.columns;
|
|
159
|
+
const columns = reported > 0 ? reported : DEFAULT_COLUMNS;
|
|
160
|
+
// A terminal that reflows wraps a long line into more rows when it
|
|
161
|
+
// narrows. It never splits a character: a wide character that does not
|
|
162
|
+
// fit in the rest of a row moves to the next row.
|
|
163
|
+
const rows = shown.reduce((sum, line) => sum + terminalRows(line, columns), 0);
|
|
164
|
+
// The cursor stays on the last row of the frame: erase each row from
|
|
165
|
+
// there up to the first row.
|
|
166
|
+
const above = `${CURSOR_UP}${ERASE_LINE}`.repeat(Math.max(0, rows - 1));
|
|
167
|
+
return `${ERASE_LINE}${above}${CURSOR_COLUMN_ONE}`;
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function nextAction<A>(
|
|
173
|
+
items: ReadonlyArray<ChecklistItem<A>>,
|
|
174
|
+
key: Terminal.Key,
|
|
175
|
+
state: ChecklistState,
|
|
176
|
+
): ChecklistAction<A> {
|
|
177
|
+
const saveRow = items.length;
|
|
178
|
+
const rows = saveRow + 1;
|
|
179
|
+
// The cursor wraps over the items and the Save row.
|
|
180
|
+
const moveBy = (step: number): ChecklistAction<A> => ({
|
|
181
|
+
_tag: "NextFrame",
|
|
182
|
+
state: { ...state, cursor: (state.cursor + step + rows) % rows },
|
|
183
|
+
});
|
|
184
|
+
switch (key.name) {
|
|
185
|
+
case "up":
|
|
186
|
+
case "k":
|
|
187
|
+
return moveBy(-1);
|
|
188
|
+
case "down":
|
|
189
|
+
case "j":
|
|
190
|
+
return moveBy(1);
|
|
191
|
+
case "tab":
|
|
192
|
+
return moveBy(key.shift ? -1 : 1);
|
|
193
|
+
case "home":
|
|
194
|
+
return { _tag: "NextFrame", state: { ...state, cursor: 0 } };
|
|
195
|
+
case "end":
|
|
196
|
+
return { _tag: "NextFrame", state: { ...state, cursor: saveRow } };
|
|
197
|
+
case "return":
|
|
198
|
+
case "enter":
|
|
199
|
+
case "space": {
|
|
200
|
+
if (state.cursor === saveRow) return save(items, state);
|
|
201
|
+
const checked = state.checked.map((on, row) => (row === state.cursor ? !on : on));
|
|
202
|
+
return { _tag: "NextFrame", state: { ...state, checked, showError: false } };
|
|
203
|
+
}
|
|
204
|
+
case "escape":
|
|
205
|
+
return CANCELLED;
|
|
206
|
+
// Ctrl+C and Ctrl+D also end the terminal input: they must give a result
|
|
207
|
+
// here, or the prompt fails with a QuitError.
|
|
208
|
+
case "c":
|
|
209
|
+
case "d":
|
|
210
|
+
return key.ctrl ? CANCELLED : IGNORED;
|
|
211
|
+
default:
|
|
212
|
+
return IGNORED;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function save<A>(
|
|
217
|
+
items: ReadonlyArray<ChecklistItem<A>>,
|
|
218
|
+
state: ChecklistState,
|
|
219
|
+
): ChecklistAction<A> {
|
|
220
|
+
const values = items.filter((_item, index) => state.checked[index]).map((item) => item.value);
|
|
221
|
+
return values.length === 0
|
|
222
|
+
? { _tag: "NextFrame", state: { ...state, showError: true } }
|
|
223
|
+
: { _tag: "Submit", value: { _tag: "Saved", values } };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Read the host when the prompt renders, so that the values in effect at that
|
|
227
|
+
// time apply.
|
|
228
|
+
function frameOf<A>(options: ChecklistOptions<A>, state: ChecklistState) {
|
|
229
|
+
return Effect.gen(function* () {
|
|
230
|
+
const terminal = yield* Terminal.Terminal;
|
|
231
|
+
const columns = yield* terminal.columns;
|
|
232
|
+
// Windows Terminal sets WT_SESSION and shows the Unicode glyphs.
|
|
233
|
+
const glyphs =
|
|
234
|
+
process.platform === "win32" && (process.env.WT_SESSION ?? "") === "" ? ASCII : UNICODE;
|
|
235
|
+
return frameLines(options, state, columns, glyphs);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function paint(line: Line, color: boolean): string {
|
|
240
|
+
let text = "";
|
|
241
|
+
for (const part of line) {
|
|
242
|
+
const code = color ? SGR[part.style] : "";
|
|
243
|
+
text += code === "" ? part.text : `${code}${part.text}${SGR_RESET}`;
|
|
244
|
+
}
|
|
245
|
+
return text;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface Layout {
|
|
249
|
+
/** The most columns that one line can use. */
|
|
250
|
+
readonly width: number;
|
|
251
|
+
readonly bordered: boolean;
|
|
252
|
+
/** The columns of the panel content. */
|
|
253
|
+
readonly inner: number;
|
|
254
|
+
/** The columns of the marker, the label, and their padding, or of the Save label. */
|
|
255
|
+
readonly nameWidth: number;
|
|
256
|
+
/** The column where the descriptions and the Save status start. */
|
|
257
|
+
readonly statusColumn: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function measure<A>(options: ChecklistOptions<A>, columns: number, glyphs: Glyphs): Layout {
|
|
261
|
+
const known = columns > 0 ? columns : DEFAULT_COLUMNS;
|
|
262
|
+
// A line that fills the last column can wrap, and then `clear` erases too
|
|
263
|
+
// few lines.
|
|
264
|
+
const width = known - 1;
|
|
265
|
+
const bordered = known >= BORDER_MIN_COLUMNS;
|
|
266
|
+
const total = options.items.length;
|
|
267
|
+
const markerWidth = Math.max(terminalCells(glyphs.ticked), terminalCells(glyphs.unticked));
|
|
268
|
+
const labelWidth = Math.max(0, ...options.items.map((item) => terminalCells(item.label)));
|
|
269
|
+
const nameWidth = Math.max(markerWidth + 1 + labelWidth, terminalCells(SAVE_LABEL));
|
|
270
|
+
const statusColumn = terminalCells(glyphs.pointer) + 1 + nameWidth + GAP.length;
|
|
271
|
+
// Size the panel for its widest content in all states, so that its width
|
|
272
|
+
// stays the same when the error shows. The top border needs two columns
|
|
273
|
+
// more than the title.
|
|
274
|
+
const natural = Math.max(
|
|
275
|
+
terminalCells(options.title) + 2,
|
|
276
|
+
terminalCells(options.message),
|
|
277
|
+
terminalCells(options.note ?? ""),
|
|
278
|
+
...options.items.map((item) => statusColumn + terminalCells(item.description)),
|
|
279
|
+
statusColumn + terminalCells(`${total} of ${total} selected`),
|
|
280
|
+
statusColumn + terminalCells(options.emptySelectionError),
|
|
281
|
+
);
|
|
282
|
+
return {
|
|
283
|
+
width,
|
|
284
|
+
bordered,
|
|
285
|
+
inner: bordered ? Math.min(natural, width - BORDER_COLUMNS) : width,
|
|
286
|
+
nameWidth,
|
|
287
|
+
statusColumn,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function frameLines<A>(
|
|
292
|
+
options: ChecklistOptions<A>,
|
|
293
|
+
state: ChecklistState,
|
|
294
|
+
columns: number,
|
|
295
|
+
glyphs: Glyphs,
|
|
296
|
+
): Array<Line> {
|
|
297
|
+
const layout = measure(options, columns, glyphs);
|
|
298
|
+
const note: Array<string> =
|
|
299
|
+
options.note === undefined ? [] : pack(words(options.note), " ", layout.inner);
|
|
300
|
+
const body: Array<Line> = [
|
|
301
|
+
...pack(words(options.message), " ", layout.inner).map((text) => [span(text)]),
|
|
302
|
+
...note.map((text) => [span(text, "dim")]),
|
|
303
|
+
[],
|
|
304
|
+
...options.items.map((item, index) =>
|
|
305
|
+
itemRow(item, state.checked[index], state.cursor === index, layout, glyphs),
|
|
306
|
+
),
|
|
307
|
+
[],
|
|
308
|
+
...saveRows(options, state, layout, glyphs),
|
|
309
|
+
];
|
|
310
|
+
const hintIndent = layout.bordered ? BORDERED_HINT_INDENT : 0;
|
|
311
|
+
const hint = pack(glyphs.hint, glyphs.hintSeparator, layout.width - hintIndent).map((text) =>
|
|
312
|
+
fit([span(" ".repeat(hintIndent)), span(text, "dim")], layout.width, glyphs.ellipsis),
|
|
313
|
+
);
|
|
314
|
+
if (!layout.bordered) {
|
|
315
|
+
return [
|
|
316
|
+
fit([span(options.title, "bold")], layout.width, glyphs.ellipsis),
|
|
317
|
+
...body.map((line) => fit(line, layout.width, glyphs.ellipsis)),
|
|
318
|
+
[],
|
|
319
|
+
...hint,
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
return [
|
|
323
|
+
topBorder(options.title, layout.inner, glyphs),
|
|
324
|
+
...body.map((line) => boxed(line, layout.inner, glyphs)),
|
|
325
|
+
[
|
|
326
|
+
span(
|
|
327
|
+
`${glyphs.bottomLeft}${glyphs.horizontal.repeat(layout.inner + 2)}${glyphs.bottomRight}`,
|
|
328
|
+
"dim",
|
|
329
|
+
),
|
|
330
|
+
],
|
|
331
|
+
...hint,
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function itemRow<A>(
|
|
336
|
+
item: ChecklistItem<A>,
|
|
337
|
+
ticked: boolean,
|
|
338
|
+
current: boolean,
|
|
339
|
+
layout: Layout,
|
|
340
|
+
glyphs: Glyphs,
|
|
341
|
+
): Line {
|
|
342
|
+
const marker = ticked ? span(glyphs.ticked, "green") : span(glyphs.unticked, "dim");
|
|
343
|
+
const padding = layout.nameWidth - terminalCells(marker.text) - 1 - terminalCells(item.label);
|
|
344
|
+
return [
|
|
345
|
+
current ? span(glyphs.pointer, "accent") : span(" ".repeat(terminalCells(glyphs.pointer))),
|
|
346
|
+
span(" "),
|
|
347
|
+
marker,
|
|
348
|
+
span(" "),
|
|
349
|
+
span(item.label, current ? "bold" : "plain"),
|
|
350
|
+
span(" ".repeat(padding) + GAP),
|
|
351
|
+
span(item.description, "dim"),
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function saveRows<A>(
|
|
356
|
+
options: ChecklistOptions<A>,
|
|
357
|
+
state: ChecklistState,
|
|
358
|
+
layout: Layout,
|
|
359
|
+
glyphs: Glyphs,
|
|
360
|
+
): Array<Line> {
|
|
361
|
+
const current = state.cursor === options.items.length;
|
|
362
|
+
const count = state.checked.filter((ticked) => ticked).length;
|
|
363
|
+
const status = state.showError
|
|
364
|
+
? span(options.emptySelectionError, "red")
|
|
365
|
+
: span(`${count} of ${options.items.length} selected`, "dim");
|
|
366
|
+
// Wrap the status below its start column, so that a long error stays readable.
|
|
367
|
+
const [first = "", ...rest] = pack(words(status.text), " ", layout.inner - layout.statusColumn);
|
|
368
|
+
return [
|
|
369
|
+
[
|
|
370
|
+
current ? span(glyphs.pointer, "accent") : span(" ".repeat(terminalCells(glyphs.pointer))),
|
|
371
|
+
span(" "),
|
|
372
|
+
span(SAVE_LABEL, current ? "accentBold" : "plain"),
|
|
373
|
+
span(" ".repeat(layout.nameWidth - terminalCells(SAVE_LABEL)) + GAP),
|
|
374
|
+
span(first, status.style),
|
|
375
|
+
],
|
|
376
|
+
...rest.map((text) => [span(" ".repeat(layout.statusColumn)), span(text, status.style)]),
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function topBorder(title: string, inner: number, glyphs: Glyphs): Line {
|
|
381
|
+
// Keep at least one horizontal glyph between the title and the corner.
|
|
382
|
+
const shown = fit([span(title, "bold")], inner - 2, glyphs.ellipsis);
|
|
383
|
+
const fill = inner - 1 - lineWidth(shown);
|
|
384
|
+
return [
|
|
385
|
+
span(`${glyphs.topLeft}${glyphs.horizontal} `, "dim"),
|
|
386
|
+
...shown,
|
|
387
|
+
span(` ${glyphs.horizontal.repeat(fill)}${glyphs.topRight}`, "dim"),
|
|
388
|
+
];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function boxed(line: Line, inner: number, glyphs: Glyphs): Line {
|
|
392
|
+
const content = fit(line, inner, glyphs.ellipsis);
|
|
393
|
+
return [
|
|
394
|
+
span(`${glyphs.vertical} `, "dim"),
|
|
395
|
+
...content,
|
|
396
|
+
span(" ".repeat(inner - lineWidth(content))),
|
|
397
|
+
span(` ${glyphs.vertical}`, "dim"),
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function span(text: string, style: Style = "plain"): Span {
|
|
402
|
+
return { text, style };
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** The longest start of `text` that uses at most `cells` cells. */
|
|
406
|
+
function cutCells(text: string, cells: number): string {
|
|
407
|
+
let kept = "";
|
|
408
|
+
let used = 0;
|
|
409
|
+
for (const char of text) {
|
|
410
|
+
const next = used + terminalCells(char);
|
|
411
|
+
// A wide character that does not fit stops the cut: it never crosses the width.
|
|
412
|
+
if (next > cells) break;
|
|
413
|
+
kept += char;
|
|
414
|
+
used = next;
|
|
415
|
+
}
|
|
416
|
+
return kept;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function lineWidth(line: Line): number {
|
|
420
|
+
return line.reduce((sum, part) => sum + terminalCells(part.text), 0);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Cuts `line` to `width` cells and ends a cut line with the ellipsis. */
|
|
424
|
+
function fit(line: Line, width: number, ellipsis: string): Line {
|
|
425
|
+
if (lineWidth(line) <= width) return line;
|
|
426
|
+
const room = width - terminalCells(ellipsis);
|
|
427
|
+
if (room < 0) return [span(cutCells(ellipsis, Math.max(width, 0)))];
|
|
428
|
+
const kept: Array<Span> = [];
|
|
429
|
+
let used = 0;
|
|
430
|
+
for (const part of line) {
|
|
431
|
+
const cells = terminalCells(part.text);
|
|
432
|
+
if (used + cells > room) {
|
|
433
|
+
kept.push(span(cutCells(part.text, room - used).trimEnd() + ellipsis, part.style));
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
kept.push(part);
|
|
437
|
+
used += cells;
|
|
438
|
+
}
|
|
439
|
+
return kept;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function words(text: string): Array<string> {
|
|
443
|
+
return text.split(/\s+/).filter((word) => word !== "");
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Joins `parts` with `separator` into lines of at most `width` columns. A part
|
|
448
|
+
* never breaks; `fit` cuts a part that is wider than `width`.
|
|
449
|
+
*/
|
|
450
|
+
function pack(parts: ReadonlyArray<string>, separator: string, width: number): Array<string> {
|
|
451
|
+
const lines: Array<string> = [];
|
|
452
|
+
let current = "";
|
|
453
|
+
for (const part of parts) {
|
|
454
|
+
const joined = current === "" ? part : `${current}${separator}${part}`;
|
|
455
|
+
if (current !== "" && terminalCells(joined) > width) {
|
|
456
|
+
lines.push(current);
|
|
457
|
+
current = part;
|
|
458
|
+
} else {
|
|
459
|
+
current = joined;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
lines.push(current);
|
|
463
|
+
return lines;
|
|
464
|
+
}
|
package/cli/src/commands/docs.ts
CHANGED
|
@@ -39,7 +39,7 @@ const TOPICS: Record<string, { summary: string; body: string }> = {
|
|
|
39
39
|
body: install,
|
|
40
40
|
},
|
|
41
41
|
platforms: {
|
|
42
|
-
summary: "Platform support: Linux, macOS,
|
|
42
|
+
summary: "Platform support: Linux on x64 and arm64, macOS on arm64, Windows on x64",
|
|
43
43
|
body: platforms,
|
|
44
44
|
},
|
|
45
45
|
"omp-models": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from "effect/unstable/cli";
|
|
2
2
|
import { Console, Effect } from "effect";
|
|
3
|
+
import { checklistPrompt } from "../checklistPrompt";
|
|
3
4
|
import { bail } from "../engine";
|
|
4
5
|
import {
|
|
5
6
|
engineHome,
|
|
@@ -14,7 +15,7 @@ import { kitDbFile } from "../engine-native/kitDb";
|
|
|
14
15
|
const DESCRIPTIONS: Record<Harness, string> = {
|
|
15
16
|
claude: "Claude Code user configuration",
|
|
16
17
|
codex: "Codex user configuration",
|
|
17
|
-
agents: "
|
|
18
|
+
agents: "Universal agent skills",
|
|
18
19
|
omp: "Oh My Pi user configuration",
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -39,32 +40,40 @@ export const harnessesCommand = Command.make("harnesses", {}, () =>
|
|
|
39
40
|
|
|
40
41
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return;
|
|
41
42
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const result = yield* checklistPrompt({
|
|
44
|
+
title: "Harnesses",
|
|
45
|
+
message: "Choose what a plain docks-kit sync sets up.",
|
|
46
|
+
note:
|
|
47
|
+
stored === undefined
|
|
48
|
+
? "Every harness starts ticked. Nothing is stored until you save."
|
|
49
|
+
: undefined,
|
|
50
|
+
items: HARNESSES.map((harness) => ({
|
|
46
51
|
value: harness,
|
|
52
|
+
label: harness,
|
|
47
53
|
description: DESCRIPTIONS[harness],
|
|
48
54
|
// With no stored selection, pre-tick every harness, omp included, so a
|
|
49
55
|
// new machine opts out of omp instead of opting in. A flag-less sync
|
|
50
56
|
// keeps LEGACY_SELECTION until this picker saves a selection.
|
|
51
|
-
|
|
57
|
+
checked: (stored ?? HARNESSES).includes(harness),
|
|
52
58
|
})),
|
|
59
|
+
emptySelectionError: "Tick at least one harness.",
|
|
53
60
|
});
|
|
54
61
|
|
|
55
|
-
if (
|
|
56
|
-
|
|
62
|
+
if (result._tag === "Cancelled") {
|
|
63
|
+
yield* Console.log("Harness selection unchanged.");
|
|
64
|
+
return;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
yield* Effect.try({
|
|
60
|
-
try: () => writeHarnessSelection(home,
|
|
68
|
+
try: () => writeHarnessSelection(home, result.values),
|
|
61
69
|
catch: (error) => (error instanceof Error ? error.message : String(error)),
|
|
62
70
|
}).pipe(
|
|
63
71
|
Effect.catch((reason) =>
|
|
64
72
|
bail(`Cannot save the harness selection to ${kitDbFile(home)}: ${reason}`, 1),
|
|
65
73
|
),
|
|
66
74
|
);
|
|
67
|
-
|
|
75
|
+
const saved = result.values.join(", ");
|
|
76
|
+
yield* Console.log(`Saved harness selection: ${saved} (${kitDbFile(home)})`);
|
|
68
77
|
}),
|
|
69
78
|
).pipe(
|
|
70
79
|
Command.withDescription("Choose the harness selection that drives a flag-less docks-kit sync."),
|
|
@@ -180,7 +180,8 @@ active logger binding.
|
|
|
180
180
|
|
|
181
181
|
## Platform Support
|
|
182
182
|
|
|
183
|
-
- EngineNative supports Linux, macOS, and Windows on
|
|
183
|
+
- EngineNative supports Linux on x64 and arm64, macOS on arm64, and Windows on
|
|
184
|
+
x64.
|
|
184
185
|
- Unsupported hosts fail before launcher fallback, dependency probes, downloads,
|
|
185
186
|
settings writes, or sync work.
|
|
186
187
|
- Claude runtime settings use absolute Bun/script paths and materialize
|
|
@@ -204,8 +205,8 @@ active logger binding.
|
|
|
204
205
|
command checks, and compilation and execution of the native host artifact.
|
|
205
206
|
The Linux-canonical snapshot lane stays on Ubuntu and runs both golden suites
|
|
206
207
|
plus their prove-red checks.
|
|
207
|
-
- `.github/workflows/release-cli.yml` publishes
|
|
208
|
-
|
|
208
|
+
- `.github/workflows/release-cli.yml` publishes four binaries (Linux x64 and
|
|
209
|
+
arm64, macOS arm64, Windows x64), plus `SHA256SUMS` and the npm package.
|
|
209
210
|
|
|
210
211
|
## Non-Goals
|
|
211
212
|
|
|
@@ -10,13 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { platformName, type PlatformName } from "./index";
|
|
12
12
|
|
|
13
|
-
export type TargetId =
|
|
14
|
-
| "linux-x64"
|
|
15
|
-
| "linux-arm64"
|
|
16
|
-
| "darwin-x64"
|
|
17
|
-
| "darwin-arm64"
|
|
18
|
-
| "windows-x64"
|
|
19
|
-
| "windows-arm64";
|
|
13
|
+
export type TargetId = "linux-x64" | "linux-arm64" | "darwin-arm64" | "windows-x64";
|
|
20
14
|
|
|
21
15
|
export type TargetArch = "x64" | "arm64";
|
|
22
16
|
|
|
@@ -32,8 +26,8 @@ export interface HostTarget {
|
|
|
32
26
|
readonly unameKeys: ReadonlyArray<string>;
|
|
33
27
|
/**
|
|
34
28
|
* `$env:PROCESSOR_ARCHITECTURE` values the PowerShell launcher matches; empty
|
|
35
|
-
* off Windows.
|
|
36
|
-
*
|
|
29
|
+
* off Windows. A 32-bit shell on an x64 host reports `x86` there, so a
|
|
30
|
+
* launcher must read `PROCESSOR_ARCHITEW6432` first.
|
|
37
31
|
*/
|
|
38
32
|
readonly processorArchitectures: ReadonlyArray<string>;
|
|
39
33
|
}
|
|
@@ -57,10 +51,8 @@ const target = (
|
|
|
57
51
|
export const HOST_TARGETS: ReadonlyArray<HostTarget> = [
|
|
58
52
|
target("linux-x64", "linux", "x64", ["Linux-x86_64"], []),
|
|
59
53
|
target("linux-arm64", "linux", "arm64", ["Linux-aarch64"], []),
|
|
60
|
-
target("darwin-x64", "darwin", "x64", ["Darwin-x86_64"], []),
|
|
61
54
|
target("darwin-arm64", "darwin", "arm64", ["Darwin-arm64"], []),
|
|
62
55
|
target("windows-x64", "windows", "x64", [], ["AMD64"]),
|
|
63
|
-
target("windows-arm64", "windows", "arm64", [], ["ARM64"]),
|
|
64
56
|
];
|
|
65
57
|
|
|
66
58
|
function targetFor(platform: PlatformName, arch: string): HostTarget | undefined {
|
|
@@ -97,7 +97,7 @@ function commandShimInvocation(executablePath: string, args: ReadonlyArray<strin
|
|
|
97
97
|
} as const;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// Host module for the windows-x64
|
|
100
|
+
// Host module for the windows-x64 target admitted in os/targets.ts.
|
|
101
101
|
export const windows: HostOs = {
|
|
102
102
|
id: "windows",
|
|
103
103
|
toolchainOs: "windows",
|
package/cli/src/engine.ts
CHANGED
|
@@ -21,7 +21,7 @@ const requireSupportedHost = () => {
|
|
|
21
21
|
return targetForHost(platform, arch) !== undefined
|
|
22
22
|
? Effect.void
|
|
23
23
|
: bail(
|
|
24
|
-
`unsupported host ${platform}/${arch}; docks-kit supports
|
|
24
|
+
`unsupported host ${platform}/${arch}; docks-kit supports Linux on x64 and arm64, macOS on arm64, and Windows on x64`,
|
|
25
25
|
2,
|
|
26
26
|
);
|
|
27
27
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by cli/scripts/generate-sot-payload.ts. DO NOT EDIT.
|
|
2
2
|
// Edit SoT/, notification.mp3, or package.json, then run: bun cli/scripts/generate-sot-payload.ts
|
|
3
3
|
|
|
4
|
-
export const GENERATED_PACKAGE_VERSION = "0.
|
|
4
|
+
export const GENERATED_PACKAGE_VERSION = "0.22.0"
|
|
5
5
|
|
|
6
6
|
export const GENERATED_PAYLOAD_TEXT = {
|
|
7
7
|
"SoT/.agents/skills.txt": "# Universal AI-agent skill manifest intentionally empty.\n# Global skill discovery is opt-in: add one slug per installed skill: <owner>/<repo>@<skill-name> (or a path to one skill directory).\n# EngineNative ignores comments and blank lines.\n",
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Marks (variation selectors included), controls, and format characters such
|
|
2
|
+
// as the zero-width joiner use no cell.
|
|
3
|
+
const ZERO_WIDTH = /[\p{Mark}\p{Cc}\p{Cf}]/u;
|
|
4
|
+
|
|
5
|
+
// The code points with East Asian Width W or F, after UAX #11
|
|
6
|
+
// (https://www.unicode.org/reports/tr11/). The W data also holds the emoji
|
|
7
|
+
// presentation characters, so emoji need no separate rule.
|
|
8
|
+
// Source: https://www.unicode.org/Public/18.0.0/ucd/EastAsianWidth.txt
|
|
9
|
+
// (Unicode 18.0.0, sha256
|
|
10
|
+
// a0cf29eacd00cfcaec4381c6b7c281685f18dbb4e7ff82b4076ccb342ca839aa).
|
|
11
|
+
// Derivation: take every code point with East_Asian_Width W or F, then merge
|
|
12
|
+
// adjacent ranges. The ranges are sorted and do not overlap. To update the
|
|
13
|
+
// table, derive it again the same way from a newer EastAsianWidth.txt.
|
|
14
|
+
const WIDE_RANGES: ReadonlyArray<readonly [number, number]> = [
|
|
15
|
+
[0x1100, 0x115f],
|
|
16
|
+
[0x231a, 0x231b],
|
|
17
|
+
[0x2329, 0x232a],
|
|
18
|
+
[0x23e9, 0x23ec],
|
|
19
|
+
[0x23f0, 0x23f0],
|
|
20
|
+
[0x23f3, 0x23f3],
|
|
21
|
+
[0x25fd, 0x25fe],
|
|
22
|
+
[0x2614, 0x2615],
|
|
23
|
+
[0x2630, 0x2637],
|
|
24
|
+
[0x2648, 0x2653],
|
|
25
|
+
[0x267f, 0x267f],
|
|
26
|
+
[0x268a, 0x268f],
|
|
27
|
+
[0x2693, 0x2693],
|
|
28
|
+
[0x26a1, 0x26a1],
|
|
29
|
+
[0x26aa, 0x26ab],
|
|
30
|
+
[0x26bd, 0x26be],
|
|
31
|
+
[0x26c4, 0x26c5],
|
|
32
|
+
[0x26ce, 0x26ce],
|
|
33
|
+
[0x26d4, 0x26d4],
|
|
34
|
+
[0x26ea, 0x26ea],
|
|
35
|
+
[0x26f2, 0x26f3],
|
|
36
|
+
[0x26f5, 0x26f5],
|
|
37
|
+
[0x26fa, 0x26fa],
|
|
38
|
+
[0x26fd, 0x26fd],
|
|
39
|
+
[0x2705, 0x2705],
|
|
40
|
+
[0x270a, 0x270b],
|
|
41
|
+
[0x2728, 0x2728],
|
|
42
|
+
[0x274c, 0x274c],
|
|
43
|
+
[0x274e, 0x274e],
|
|
44
|
+
[0x2753, 0x2755],
|
|
45
|
+
[0x2757, 0x2757],
|
|
46
|
+
[0x2795, 0x2797],
|
|
47
|
+
[0x27b0, 0x27b0],
|
|
48
|
+
[0x27bf, 0x27bf],
|
|
49
|
+
[0x2b1b, 0x2b1c],
|
|
50
|
+
[0x2b50, 0x2b50],
|
|
51
|
+
[0x2b55, 0x2b55],
|
|
52
|
+
[0x2e80, 0x2e99],
|
|
53
|
+
[0x2e9b, 0x2ef3],
|
|
54
|
+
[0x2f00, 0x2fd5],
|
|
55
|
+
[0x2ff0, 0x303e],
|
|
56
|
+
[0x3041, 0x3096],
|
|
57
|
+
[0x3099, 0x30ff],
|
|
58
|
+
[0x3105, 0x312f],
|
|
59
|
+
[0x3131, 0x318e],
|
|
60
|
+
[0x3190, 0x31e5],
|
|
61
|
+
[0x31ef, 0x321e],
|
|
62
|
+
[0x3220, 0x3247],
|
|
63
|
+
[0x3250, 0xa48c],
|
|
64
|
+
[0xa490, 0xa4c6],
|
|
65
|
+
[0xa960, 0xa97c],
|
|
66
|
+
[0xac00, 0xd7a3],
|
|
67
|
+
[0xf900, 0xfaff],
|
|
68
|
+
[0xfe10, 0xfe19],
|
|
69
|
+
[0xfe30, 0xfe52],
|
|
70
|
+
[0xfe54, 0xfe66],
|
|
71
|
+
[0xfe68, 0xfe6b],
|
|
72
|
+
[0xff01, 0xff60],
|
|
73
|
+
[0xffe0, 0xffe6],
|
|
74
|
+
[0x16fe0, 0x16fe4],
|
|
75
|
+
[0x16ff0, 0x16ff6],
|
|
76
|
+
[0x17000, 0x18cda],
|
|
77
|
+
[0x18cff, 0x18d20],
|
|
78
|
+
[0x18d80, 0x18df2],
|
|
79
|
+
[0x18e00, 0x19191],
|
|
80
|
+
[0x191a0, 0x191d2],
|
|
81
|
+
[0x1aff0, 0x1aff3],
|
|
82
|
+
[0x1aff5, 0x1affb],
|
|
83
|
+
[0x1affd, 0x1affe],
|
|
84
|
+
[0x1b000, 0x1b128],
|
|
85
|
+
[0x1b132, 0x1b132],
|
|
86
|
+
[0x1b150, 0x1b152],
|
|
87
|
+
[0x1b155, 0x1b155],
|
|
88
|
+
[0x1b164, 0x1b168],
|
|
89
|
+
[0x1b170, 0x1b2fb],
|
|
90
|
+
[0x1d300, 0x1d356],
|
|
91
|
+
[0x1d360, 0x1d376],
|
|
92
|
+
[0x1f004, 0x1f004],
|
|
93
|
+
[0x1f0cf, 0x1f0cf],
|
|
94
|
+
[0x1f18e, 0x1f18e],
|
|
95
|
+
[0x1f191, 0x1f19a],
|
|
96
|
+
[0x1f1ae, 0x1f1ae],
|
|
97
|
+
[0x1f200, 0x1f202],
|
|
98
|
+
[0x1f210, 0x1f23b],
|
|
99
|
+
[0x1f240, 0x1f248],
|
|
100
|
+
[0x1f250, 0x1f251],
|
|
101
|
+
[0x1f260, 0x1f265],
|
|
102
|
+
[0x1f300, 0x1f320],
|
|
103
|
+
[0x1f32d, 0x1f335],
|
|
104
|
+
[0x1f337, 0x1f37c],
|
|
105
|
+
[0x1f37e, 0x1f393],
|
|
106
|
+
[0x1f3a0, 0x1f3ca],
|
|
107
|
+
[0x1f3cf, 0x1f3d3],
|
|
108
|
+
[0x1f3e0, 0x1f3f0],
|
|
109
|
+
[0x1f3f4, 0x1f3f4],
|
|
110
|
+
[0x1f3f8, 0x1f43e],
|
|
111
|
+
[0x1f440, 0x1f440],
|
|
112
|
+
[0x1f442, 0x1f4fc],
|
|
113
|
+
[0x1f4ff, 0x1f53d],
|
|
114
|
+
[0x1f54b, 0x1f54e],
|
|
115
|
+
[0x1f550, 0x1f567],
|
|
116
|
+
[0x1f57a, 0x1f57a],
|
|
117
|
+
[0x1f595, 0x1f596],
|
|
118
|
+
[0x1f5a4, 0x1f5a4],
|
|
119
|
+
[0x1f5fb, 0x1f64f],
|
|
120
|
+
[0x1f680, 0x1f6c5],
|
|
121
|
+
[0x1f6cc, 0x1f6cc],
|
|
122
|
+
[0x1f6d0, 0x1f6d2],
|
|
123
|
+
[0x1f6d5, 0x1f6d9],
|
|
124
|
+
[0x1f6dc, 0x1f6df],
|
|
125
|
+
[0x1f6eb, 0x1f6ec],
|
|
126
|
+
[0x1f6f4, 0x1f6fc],
|
|
127
|
+
[0x1f7da, 0x1f7da],
|
|
128
|
+
[0x1f7e0, 0x1f7eb],
|
|
129
|
+
[0x1f7f0, 0x1f7f0],
|
|
130
|
+
[0x1f90c, 0x1f93a],
|
|
131
|
+
[0x1f93c, 0x1f945],
|
|
132
|
+
[0x1f947, 0x1f9ff],
|
|
133
|
+
[0x1fa70, 0x1fa7c],
|
|
134
|
+
[0x1fa80, 0x1fac6],
|
|
135
|
+
[0x1fac8, 0x1fac8],
|
|
136
|
+
[0x1facc, 0x1fadd],
|
|
137
|
+
[0x1fadf, 0x1faeb],
|
|
138
|
+
[0x1faef, 0x1fafa],
|
|
139
|
+
[0x20000, 0x2fffd],
|
|
140
|
+
[0x30000, 0x3fffd],
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
function isWide(point: number): boolean {
|
|
144
|
+
let low = 0;
|
|
145
|
+
let high = WIDE_RANGES.length - 1;
|
|
146
|
+
while (low <= high) {
|
|
147
|
+
const middle = (low + high) >> 1;
|
|
148
|
+
const [first, last] = WIDE_RANGES[middle] ?? [0, -1];
|
|
149
|
+
if (point < first) high = middle - 1;
|
|
150
|
+
else if (point > last) low = middle + 1;
|
|
151
|
+
else return true;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function charCells(char: string): number {
|
|
157
|
+
if (ZERO_WIDTH.test(char)) return 0;
|
|
158
|
+
return isWide(char.codePointAt(0) ?? 0) ? 2 : 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The terminal cells of `text`: 0 for each mark, control, or format
|
|
163
|
+
* character; 2 for each character with East Asian Width W or F; else 1.
|
|
164
|
+
*/
|
|
165
|
+
export function terminalCells(text: string): number {
|
|
166
|
+
let cells = 0;
|
|
167
|
+
for (const char of text) cells += charCells(char);
|
|
168
|
+
return cells;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The rows that `text` uses on a terminal `columns` wide (a value below 1
|
|
173
|
+
* counts as 1). A terminal never splits a character: a wide character that
|
|
174
|
+
* does not fit in the rest of a row moves to the next row and leaves the last
|
|
175
|
+
* cell of the row empty. An empty text uses 1 row.
|
|
176
|
+
*/
|
|
177
|
+
export function terminalRows(text: string, columns: number): number {
|
|
178
|
+
const width = Math.max(1, columns);
|
|
179
|
+
let rows = 1;
|
|
180
|
+
let column = 0;
|
|
181
|
+
for (const char of text) {
|
|
182
|
+
const cells = charCells(char);
|
|
183
|
+
if (cells === 0) continue;
|
|
184
|
+
if (column !== 0 && column + cells > width) {
|
|
185
|
+
rows += 1;
|
|
186
|
+
column = 0;
|
|
187
|
+
}
|
|
188
|
+
column += cells;
|
|
189
|
+
}
|
|
190
|
+
return rows;
|
|
191
|
+
}
|
package/docks-kit
CHANGED
|
@@ -19,10 +19,9 @@ HOST="$(uname -s)-$(uname -m)"
|
|
|
19
19
|
case "$HOST" in
|
|
20
20
|
Linux-x86_64) KIT_BIN="docks-kit-linux-x64" ;;
|
|
21
21
|
Linux-aarch64) KIT_BIN="docks-kit-linux-arm64" ;;
|
|
22
|
-
Darwin-x86_64) KIT_BIN="docks-kit-darwin-x64" ;;
|
|
23
22
|
Darwin-arm64) KIT_BIN="docks-kit-darwin-arm64" ;;
|
|
24
23
|
*)
|
|
25
|
-
echo "[docks-kit] unsupported host $HOST;
|
|
24
|
+
echo "[docks-kit] unsupported host $HOST; docks-kit supports Linux on x64 and arm64, macOS on arm64, and Windows on x64 - on Windows run docks-kit.ps1 instead." >&2
|
|
26
25
|
exit 1
|
|
27
26
|
;;
|
|
28
27
|
esac
|
package/docks-kit.ps1
CHANGED
|
@@ -25,10 +25,9 @@ if ([string]::IsNullOrWhiteSpace($ProcessorArchitecture)) {
|
|
|
25
25
|
}
|
|
26
26
|
$KitBin = switch ($ProcessorArchitecture) {
|
|
27
27
|
'AMD64' { 'docks-kit-windows-x64.exe' }
|
|
28
|
-
'ARM64' { 'docks-kit-windows-arm64.exe' }
|
|
29
28
|
default {
|
|
30
29
|
$HostName = "Windows-$ProcessorArchitecture"
|
|
31
|
-
[Console]::Error.WriteLine("[docks-kit] unsupported host $HostName; docks-kit supports Linux, macOS, and Windows on x64
|
|
30
|
+
[Console]::Error.WriteLine("[docks-kit] unsupported host $HostName; docks-kit supports Linux on x64 and arm64, macOS on arm64, and Windows on x64.")
|
|
32
31
|
exit 1
|
|
33
32
|
}
|
|
34
33
|
}
|
package/package.json
CHANGED