docks-kit 0.22.28 → 0.24.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 +42 -89
- package/README.md +35 -72
- package/cli/docs/command-guards.md +233 -197
- package/cli/docs/flags.md +17 -65
- package/cli/docs/install.md +2 -3
- package/cli/docs/omp-context.md +79 -7
- package/cli/docs/omp-models.md +27 -12
- package/cli/docs/overview.md +7 -18
- package/cli/docs/platforms.md +2 -2
- package/cli/docs/sync-layers.md +14 -60
- package/cli/docs/toolchain.md +12 -81
- package/cli/src/argv.ts +0 -12
- package/cli/src/argvValidate.ts +3 -54
- package/cli/src/commands/docs.ts +3 -15
- package/cli/src/commands/omp.ts +1 -1
- package/cli/src/commands/scratch.ts +1 -1
- package/cli/src/commands/sync.ts +5 -120
- package/cli/src/commands/tidy.ts +1 -1
- package/cli/src/commands/toolchain.ts +4 -12
- package/cli/src/engine-native/DESIGN.md +69 -100
- package/cli/src/engine-native/deps.ts +7 -92
- package/cli/src/engine-native/engineCtx.ts +9 -103
- package/cli/src/engine-native/exec.ts +1 -18
- package/cli/src/engine-native/index.ts +6 -8
- package/cli/src/engine-native/jq.ts +4 -37
- package/cli/src/engine-native/kitDb.ts +21 -37
- package/cli/src/engine-native/modes.ts +3 -132
- package/cli/src/engine-native/ompFastMode.ts +1 -1
- package/cli/src/engine-native/ompOverlay.ts +1 -1
- package/cli/src/engine-native/ompRemovals.ts +24 -3
- package/cli/src/engine-native/ompSession.ts +67 -0
- package/cli/src/engine-native/ompSync.ts +1 -1
- package/cli/src/engine-native/os/darwin.ts +0 -4
- package/cli/src/engine-native/os/index.ts +1 -2
- package/cli/src/engine-native/os/linux.ts +0 -3
- package/cli/src/engine-native/os/posix.ts +2 -47
- package/cli/src/engine-native/os/types.ts +1 -36
- package/cli/src/engine-native/os/windows.ts +0 -50
- package/cli/src/engine-native/parseArgs.ts +7 -180
- package/cli/src/engine-native/parseHelp.ts +4 -44
- package/cli/src/engine-native/scratch.ts +1 -1
- package/cli/src/engine-native/services.ts +1 -2
- package/cli/src/engine-native/sharedTypes.d.ts +1 -41
- package/cli/src/engine-native/syncConcurrency.ts +3 -15
- package/cli/src/engine-native/syncDispatch.ts +30 -143
- package/cli/src/engine-native/toolchain.ts +6 -45
- package/cli/src/engine.ts +0 -75
- package/cli/src/generated/sotPayload.ts +14 -43
- package/cli/src/main.ts +8 -24
- package/cli/src/payload.ts +2 -8
- package/cli/tsconfig.json +1 -3
- package/package.json +3 -5
- package/cli/docs/models.md +0 -58
- package/cli/docs/modifiers.md +0 -52
- package/cli/docs/plugins.md +0 -70
- package/cli/src/checklistPrompt.ts +0 -464
- package/cli/src/commands/harnesses.ts +0 -80
- package/cli/src/commands/model.ts +0 -68
- package/cli/src/commands/models.ts +0 -75
- package/cli/src/commands/plugins.ts +0 -35
- package/cli/src/commands/skills.ts +0 -40
- package/cli/src/commands/status.ts +0 -206
- package/cli/src/efforts.ts +0 -89
- package/cli/src/engine-native/claudeLsp.ts +0 -301
- package/cli/src/engine-native/claudeOptionalPlugins.ts +0 -126
- package/cli/src/engine-native/claudePluginPasses.ts +0 -426
- package/cli/src/engine-native/claudeRemovals.ts +0 -383
- package/cli/src/engine-native/claudeRetired.ts +0 -165
- package/cli/src/engine-native/claudeRuntime.ts +0 -157
- package/cli/src/engine-native/claudeSettings.ts +0 -201
- package/cli/src/engine-native/claudeSettingsModifiers.ts +0 -115
- package/cli/src/engine-native/claudeSync.ts +0 -312
- package/cli/src/engine-native/codexConfig.ts +0 -214
- package/cli/src/engine-native/codexHooks.ts +0 -91
- package/cli/src/engine-native/codexPaths.ts +0 -14
- package/cli/src/engine-native/codexPlugins.ts +0 -315
- package/cli/src/engine-native/codexStatus.ts +0 -25
- package/cli/src/engine-native/codexSync.ts +0 -314
- package/cli/src/engine-native/codexToml.ts +0 -303
- package/cli/src/engine-native/harnesses.ts +0 -138
- package/cli/src/engine-native/liveModels.ts +0 -264
- package/cli/src/engine-native/models.ts +0 -101
- package/cli/src/engine-native/parseModifiers.ts +0 -225
- package/cli/src/engine-native/settings.ts +0 -42
- package/cli/src/engine-native/skillsInstall.ts +0 -135
- package/cli/src/engine-native/skillsLinks.ts +0 -216
- package/cli/src/engine-native/skillsManifest.ts +0 -36
- package/cli/src/engine-native/skillsPrune.ts +0 -117
- package/cli/src/engine-native/skillsRecords.ts +0 -138
- package/cli/src/engine-native/skillsSync.ts +0 -57
- package/cli/src/engine-native/tomlLines.ts +0 -92
- package/cli/src/manifests.ts +0 -145
- package/cli/src/terminalCells.ts +0 -191
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
import { Effect, Terminal } from "effect";
|
|
2
|
-
import { Prompt } from "effect/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
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Command } from "effect/cli";
|
|
2
|
-
import { Console, Effect } from "effect";
|
|
3
|
-
import { checklistPrompt } from "../checklistPrompt";
|
|
4
|
-
import { bail } from "../engine";
|
|
5
|
-
import {
|
|
6
|
-
engineHome,
|
|
7
|
-
HARNESSES,
|
|
8
|
-
LEGACY_SELECTION,
|
|
9
|
-
loadHarnessSelection,
|
|
10
|
-
writeHarnessSelection,
|
|
11
|
-
type Harness,
|
|
12
|
-
} from "../engine-native/harnesses";
|
|
13
|
-
import { kitDbFile } from "../engine-native/kitDb";
|
|
14
|
-
|
|
15
|
-
const DESCRIPTIONS: Record<Harness, string> = {
|
|
16
|
-
claude: "Claude Code user configuration",
|
|
17
|
-
codex: "Codex user configuration",
|
|
18
|
-
agents: "Universal agent skills",
|
|
19
|
-
omp: "Oh My Pi user configuration",
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const harnessesCommand = Command.make("harnesses", {}, () =>
|
|
23
|
-
Effect.gen(function* () {
|
|
24
|
-
const home = engineHome(process.env);
|
|
25
|
-
const loaded = yield* Effect.sync(() => loadHarnessSelection(home));
|
|
26
|
-
if (loaded.kind === "unreadable") {
|
|
27
|
-
return yield* bail(`Cannot read ${kitDbFile(home)}: ${loaded.reason}`, 1);
|
|
28
|
-
}
|
|
29
|
-
const stored = loaded.kind === "stored" ? loaded.selection : undefined;
|
|
30
|
-
const selection = stored ?? LEGACY_SELECTION;
|
|
31
|
-
const names = selection.join(", ");
|
|
32
|
-
|
|
33
|
-
if (stored === undefined) {
|
|
34
|
-
yield* Console.log(
|
|
35
|
-
`Harness selection: ${names} (no selection is stored yet; the legacy default applies)`,
|
|
36
|
-
);
|
|
37
|
-
} else {
|
|
38
|
-
yield* Console.log(`Harness selection: ${names}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) return;
|
|
42
|
-
|
|
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) => ({
|
|
51
|
-
value: harness,
|
|
52
|
-
label: harness,
|
|
53
|
-
description: DESCRIPTIONS[harness],
|
|
54
|
-
// With no stored selection, pre-tick every harness, omp included, so a
|
|
55
|
-
// new machine opts out of omp instead of opting in. A flag-less sync
|
|
56
|
-
// keeps LEGACY_SELECTION until this picker saves a selection.
|
|
57
|
-
checked: (stored ?? HARNESSES).includes(harness),
|
|
58
|
-
})),
|
|
59
|
-
emptySelectionError: "Tick at least one harness.",
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
if (result._tag === "Cancelled") {
|
|
63
|
-
yield* Console.log("Harness selection unchanged.");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
yield* Effect.try({
|
|
68
|
-
try: () => writeHarnessSelection(home, result.values),
|
|
69
|
-
catch: (error) => (error instanceof Error ? error.message : String(error)),
|
|
70
|
-
}).pipe(
|
|
71
|
-
Effect.catch((reason) =>
|
|
72
|
-
bail(`Cannot save the harness selection to ${kitDbFile(home)}: ${reason}`, 1),
|
|
73
|
-
),
|
|
74
|
-
);
|
|
75
|
-
const saved = result.values.join(", ");
|
|
76
|
-
yield* Console.log(`Saved harness selection: ${saved} (${kitDbFile(home)})`);
|
|
77
|
-
}),
|
|
78
|
-
).pipe(
|
|
79
|
-
Command.withDescription("Choose the harness selection that drives a flag-less docks-kit sync."),
|
|
80
|
-
);
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Argument, Command, Flag, Prompt } from "effect/cli";
|
|
2
|
-
import { Effect, Option } from "effect";
|
|
3
|
-
import { bail, engine } from "../engine";
|
|
4
|
-
import { engineHome } from "../engine-native/harnesses";
|
|
5
|
-
import { defaultLiveInputs, resolveCatalog } from "../engine-native/liveModels";
|
|
6
|
-
import type { Tool } from "../manifests";
|
|
7
|
-
|
|
8
|
-
const tool = Argument.String("tool").pipe(Argument.withDescription("Which tool: claude | codex"));
|
|
9
|
-
const value = Argument.String("value").pipe(
|
|
10
|
-
Argument.withDescription("Model to set (omit to view current + pick interactively on a TTY)"),
|
|
11
|
-
Argument.optional,
|
|
12
|
-
);
|
|
13
|
-
const dryRun = Flag.Boolean("dry-run").pipe(
|
|
14
|
-
Flag.withDescription("Preview without applying"),
|
|
15
|
-
Flag.withDefault(false),
|
|
16
|
-
);
|
|
17
|
-
const verbose = Flag.Boolean("verbose").pipe(
|
|
18
|
-
Flag.withAlias("v"),
|
|
19
|
-
Flag.withDescription("Also print no-op confirmations (already in sync, up to date)"),
|
|
20
|
-
Flag.withDefault(false),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const KEEP = "__keep__";
|
|
24
|
-
|
|
25
|
-
export const modelCommand = Command.make("model", { tool, value, dryRun, verbose }, (config) =>
|
|
26
|
-
Effect.gen(function* () {
|
|
27
|
-
if (config.tool !== "claude" && config.tool !== "codex") {
|
|
28
|
-
return yield* bail(`Unknown tool '${config.tool}' (valid: claude, codex)`);
|
|
29
|
-
}
|
|
30
|
-
const t = config.tool as Tool;
|
|
31
|
-
const dry = [...(config.dryRun ? ["--dry-run"] : []), ...(config.verbose ? ["--verbose"] : [])];
|
|
32
|
-
|
|
33
|
-
if (Option.isSome(config.value)) {
|
|
34
|
-
if (config.value.value.trim() === "") {
|
|
35
|
-
return yield* bail("Model value must not be empty or blank");
|
|
36
|
-
}
|
|
37
|
-
return yield* engine(["model", t, config.value.value, ...dry]);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// No value: show current (engine prints deployed + SoT + catalog) …
|
|
41
|
-
yield* engine(["model", t, ...(config.verbose ? ["--verbose"] : [])]);
|
|
42
|
-
|
|
43
|
-
// … and offer an interactive picker when attached to a terminal.
|
|
44
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) return;
|
|
45
|
-
|
|
46
|
-
const catalog = yield* Effect.promise(() =>
|
|
47
|
-
resolveCatalog(t, defaultLiveInputs(engineHome(process.env))),
|
|
48
|
-
);
|
|
49
|
-
const chosen = yield* Prompt.Select({
|
|
50
|
-
message: `Set the deployed ${t} model (deployed config only; a flag-less sync reverts to SoT)`,
|
|
51
|
-
choices: [
|
|
52
|
-
{ title: "(keep current)", value: KEEP },
|
|
53
|
-
...catalog.models.map((m) => ({
|
|
54
|
-
title: m.id,
|
|
55
|
-
value: m.id,
|
|
56
|
-
description: m.note ?? "",
|
|
57
|
-
})),
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
if (chosen !== KEEP) {
|
|
61
|
-
yield* engine(["model", t, chosen, ...dry]);
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
).pipe(
|
|
65
|
-
Command.withDescription(
|
|
66
|
-
"Get or set the DEPLOYED model for one tool without a full sync (deploy-time modifier semantics: SoT untouched; flag-less sync reverts).",
|
|
67
|
-
),
|
|
68
|
-
);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Argument, Command, Flag } from "effect/cli";
|
|
2
|
-
import { Console, Effect, Option } from "effect";
|
|
3
|
-
import { bail } from "../engine";
|
|
4
|
-
import { engineHome, LEGACY_SELECTION, readHarnessSelection } from "../engine-native/harnesses";
|
|
5
|
-
import { defaultLiveInputs, resolveCatalog } from "../engine-native/liveModels";
|
|
6
|
-
import type { CatalogTool, ResolvedCatalog } from "../engine-native/sharedTypes";
|
|
7
|
-
|
|
8
|
-
const tool = Argument.String("tool").pipe(
|
|
9
|
-
Argument.withDescription("claude | codex | omp (omit for enabled harnesses)"),
|
|
10
|
-
Argument.optional,
|
|
11
|
-
);
|
|
12
|
-
const json = Flag.Boolean("json").pipe(
|
|
13
|
-
Flag.withDescription("Machine-readable output"),
|
|
14
|
-
Flag.withDefault(false),
|
|
15
|
-
);
|
|
16
|
-
const refresh = Flag.Boolean("refresh").pipe(
|
|
17
|
-
Flag.withDescription("Bypass the kit cache (~/.docks-kit/kit.db) and fetch live lists again"),
|
|
18
|
-
Flag.withDefault(false),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
function isCatalogTool(value: string): value is CatalogTool {
|
|
22
|
-
return value === "claude" || value === "codex" || value === "omp";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const renderTool = (t: CatalogTool, catalog: ResolvedCatalog) =>
|
|
26
|
-
Effect.gen(function* () {
|
|
27
|
-
yield* Console.log(
|
|
28
|
-
catalog.source === "curated"
|
|
29
|
-
? `${t} models (kit-verified ${catalog.verified}):`
|
|
30
|
-
: `${t} models (live — ${catalog.source}, fetched ${catalog.fetchedAt ?? "?"}):`,
|
|
31
|
-
);
|
|
32
|
-
if (catalog.fallbackReason !== undefined) {
|
|
33
|
-
yield* Console.log(` (live list unavailable: ${catalog.fallbackReason})`);
|
|
34
|
-
}
|
|
35
|
-
for (const m of catalog.models) {
|
|
36
|
-
yield* Console.log(` ${m.id.padEnd(28)} ${m.kind.padEnd(6)} ${m.note ?? ""}`);
|
|
37
|
-
}
|
|
38
|
-
if (t === "claude") {
|
|
39
|
-
yield* Console.log(
|
|
40
|
-
" (full claude-* model IDs outside the catalog are accepted with a warning)",
|
|
41
|
-
);
|
|
42
|
-
} else if (t === "codex") {
|
|
43
|
-
yield* Console.log(" (well-formed IDs outside the catalog are accepted with a warning)");
|
|
44
|
-
}
|
|
45
|
-
yield* Console.log("");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const modelsCommand = Command.make("models", { tool, json, refresh }, (config) =>
|
|
49
|
-
Effect.gen(function* () {
|
|
50
|
-
const requested = Option.getOrUndefined(config.tool);
|
|
51
|
-
if (requested !== undefined && !isCatalogTool(requested)) {
|
|
52
|
-
return yield* bail(`Unknown tool '${requested}' (valid: claude, codex, omp)`);
|
|
53
|
-
}
|
|
54
|
-
const home = engineHome(process.env);
|
|
55
|
-
const tools: ReadonlyArray<CatalogTool> =
|
|
56
|
-
requested !== undefined
|
|
57
|
-
? [requested]
|
|
58
|
-
: (readHarnessSelection(home) ?? LEGACY_SELECTION).filter(isCatalogTool);
|
|
59
|
-
const inputs = defaultLiveInputs(home, config.refresh);
|
|
60
|
-
const out: Partial<Record<CatalogTool, ResolvedCatalog>> = {};
|
|
61
|
-
for (const t of tools) {
|
|
62
|
-
const catalog = yield* Effect.promise(() => resolveCatalog(t, inputs));
|
|
63
|
-
if (config.json) {
|
|
64
|
-
out[t] = catalog;
|
|
65
|
-
} else {
|
|
66
|
-
yield* renderTool(t, catalog);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (config.json) yield* Console.log(JSON.stringify(out, null, 2));
|
|
70
|
-
}),
|
|
71
|
-
).pipe(
|
|
72
|
-
Command.withDescription(
|
|
73
|
-
"List models per enabled harness: live from each harness's login or cache, with SoT/models.json aliases and notes as overlay and offline fallback.",
|
|
74
|
-
),
|
|
75
|
-
);
|