@termwire/cli 0.4.0 → 0.5.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.
@@ -0,0 +1,92 @@
1
+ import { type AgentId, type AgentPaths } from "./agents.js";
2
+ import { type LayoutTemplate } from "./templates.js";
3
+ export declare const noLayout = "none";
4
+ export type InstallLayoutChoice = LayoutTemplate["id"] | typeof noLayout;
5
+ export interface InstallRequest {
6
+ layout?: string;
7
+ project?: boolean;
8
+ agents?: readonly AgentId[];
9
+ force?: boolean;
10
+ yes?: boolean;
11
+ }
12
+ /**
13
+ * `ready` takes the skill, `manual` is set up here but has no skills to take it, and
14
+ * `missing` is not installed at all.
15
+ */
16
+ export type AgentState = "ready" | "manual" | "missing";
17
+ export interface AgentCandidate {
18
+ id: AgentId;
19
+ title: string;
20
+ state: AgentState;
21
+ /** Where the skill would go, for the agents that can take one. */
22
+ path?: string;
23
+ }
24
+ /** Every prompt returns `undefined` when the user cancelled. */
25
+ export interface InstallPrompter {
26
+ layout: (options: {
27
+ templates: LayoutTemplate[];
28
+ path: string;
29
+ exists: boolean;
30
+ }) => Promise<InstallLayoutChoice | undefined>;
31
+ agents: (options: {
32
+ candidates: AgentCandidate[];
33
+ }) => Promise<readonly AgentId[] | undefined>;
34
+ /** Asked only when a config is already there and no --force settled it. */
35
+ replace: (options: {
36
+ path: string;
37
+ }) => Promise<boolean | undefined>;
38
+ confirm: (options: {
39
+ summary: string[];
40
+ }) => Promise<boolean | undefined>;
41
+ }
42
+ export interface InstallDependencies {
43
+ cwd: () => string;
44
+ findGitRoot: (cwd: string) => Promise<string | undefined>;
45
+ globalConfigPath: () => string;
46
+ agentPaths: AgentPaths;
47
+ /** The SKILL.md shipped with the package, copied verbatim into each agent. */
48
+ skillSource: string;
49
+ pathExists: (path: string) => Promise<boolean>;
50
+ readFile: (path: string) => Promise<string>;
51
+ /** Shared with the layout config: atomic, and never clobbers without force. */
52
+ writeConfig: (options: {
53
+ path: string;
54
+ contents: string;
55
+ force: boolean;
56
+ }) => Promise<void>;
57
+ write: (message: string) => void;
58
+ /** Absent when nothing can be asked, which makes the run non-interactive. */
59
+ prompt?: InstallPrompter;
60
+ isTerminal: boolean;
61
+ }
62
+ export type AgentOutcomeKind =
63
+ /** The skill was written. */
64
+ "installed"
65
+ /** The same skill was already there, so this run left it alone. */
66
+ | "present"
67
+ /** A different skill was there — edited by hand, most likely — and was kept. */
68
+ | "kept"
69
+ /** Installed here, but takes no skills: the user has to add a line themselves. */
70
+ | "manual" | "unavailable" | "failed";
71
+ export interface AgentOutcome {
72
+ id: AgentId;
73
+ outcome: AgentOutcomeKind;
74
+ detail?: string;
75
+ }
76
+ export interface InstallResult {
77
+ cancelled: boolean;
78
+ configPath?: string;
79
+ configWritten: boolean;
80
+ agents: AgentOutcome[];
81
+ failures: string[];
82
+ }
83
+ export declare function install(request: InstallRequest, dependencies: InstallDependencies): Promise<InstallResult>;
84
+ export type AgentAction = "install" | "replace" | "keep" | "present" | "manual" | "unavailable";
85
+ export interface AgentPlan {
86
+ id: AgentId;
87
+ title: string;
88
+ action: AgentAction;
89
+ path?: string;
90
+ /** Set when the skill could not be read at all. */
91
+ error?: string;
92
+ }
@@ -0,0 +1,363 @@
1
+ import { join } from "node:path";
2
+ import { agentDefinitions, findAgentDefinition, skillName, } from "./agents.js";
3
+ import { skillMarker } from "./skill.js";
4
+ import { findLayoutTemplate, layoutTemplates } from "./templates.js";
5
+ export const noLayout = "none";
6
+ export async function install(request, dependencies) {
7
+ const interactive = isInteractive(request, dependencies);
8
+ // A confirmation is only worth asking for what the user has not already said.
9
+ const asked = { any: false };
10
+ if (!interactive && !hasExplicitRequest(request)) {
11
+ throw new Error("install has nothing to do and no terminal to ask: pass --yes, --layout or --agents");
12
+ }
13
+ const configPath = await resolveConfigPath(request, dependencies);
14
+ const exists = await dependencies.pathExists(configPath);
15
+ const cancelled = {
16
+ cancelled: true,
17
+ configWritten: false,
18
+ agents: [],
19
+ failures: [],
20
+ };
21
+ const chosen = await resolveLayout(request, dependencies, interactive, configPath, exists, asked);
22
+ if (chosen === undefined)
23
+ return cancelled;
24
+ const decision = await decideExistingConfig({ chosen, exists, request, interactive, configPath, asked }, dependencies);
25
+ if (decision === undefined)
26
+ return cancelled;
27
+ const { layout, force } = decision;
28
+ const candidates = await agentCandidates(dependencies);
29
+ const selected = await resolveAgents(request, dependencies, interactive, candidates, asked);
30
+ if (selected === undefined)
31
+ return cancelled;
32
+ const skill = selected.length === 0 ? { contents: "" } : await readSkill(dependencies);
33
+ const agents = await planAgents({ selected, candidates, force: request.force === true, interactive, skill, asked }, dependencies);
34
+ if (agents === undefined)
35
+ return cancelled;
36
+ if (interactive && dependencies.prompt && asked.any) {
37
+ const summary = planSummary({ configPath, layout, exists, force, agents });
38
+ const accepted = await dependencies.prompt.confirm({ summary });
39
+ if (accepted === undefined || !accepted)
40
+ return cancelled;
41
+ }
42
+ return await apply({ configPath, layout, force, agents, skill }, dependencies);
43
+ }
44
+ /**
45
+ * A config that is already there is only replaced when the user said so: `--force`, or a
46
+ * yes to the prompt. A default layout nobody asked for keeps it instead of turning a run
47
+ * that was really about agent registration into an error.
48
+ */
49
+ async function decideExistingConfig(options, dependencies) {
50
+ const force = options.request.force === true;
51
+ if (options.chosen === noLayout || !options.exists || force) {
52
+ return { layout: options.chosen, force };
53
+ }
54
+ if (options.interactive && dependencies.prompt) {
55
+ options.asked.any = true;
56
+ const replace = await dependencies.prompt.replace({ path: options.configPath });
57
+ if (replace === undefined)
58
+ return undefined;
59
+ return replace ? { layout: options.chosen, force: true } : { layout: noLayout, force };
60
+ }
61
+ // A layout asked for by name conflicts with an existing file and is worth reporting;
62
+ // a layout that merely defaulted is not.
63
+ if (options.request.layout !== undefined)
64
+ return { layout: options.chosen, force };
65
+ dependencies.write(`Keeping ${options.configPath}; pass --layout <name> --force to replace it\n`);
66
+ return { layout: noLayout, force };
67
+ }
68
+ function isInteractive(request, dependencies) {
69
+ if (request.yes === true || dependencies.prompt === undefined)
70
+ return false;
71
+ return dependencies.isTerminal;
72
+ }
73
+ function hasExplicitRequest(request) {
74
+ return request.yes === true || request.layout !== undefined || request.agents !== undefined;
75
+ }
76
+ async function resolveConfigPath(request, dependencies) {
77
+ if (request.project !== true)
78
+ return dependencies.globalConfigPath();
79
+ const gitRoot = await dependencies.findGitRoot(dependencies.cwd());
80
+ if (gitRoot === undefined) {
81
+ throw new Error("--project requires a Git repository");
82
+ }
83
+ return join(gitRoot, ".termwire.jsonc");
84
+ }
85
+ async function resolveLayout(request, dependencies, interactive, path, exists, asked) {
86
+ if (request.layout !== undefined) {
87
+ if (request.layout === noLayout)
88
+ return noLayout;
89
+ const template = findLayoutTemplate(request.layout);
90
+ if (template === undefined) {
91
+ const known = [...layoutTemplates().map((entry) => entry.id), noLayout].join(", ");
92
+ throw new Error(`unknown layout: ${request.layout} (expected ${known})`);
93
+ }
94
+ return template.id;
95
+ }
96
+ // Asked for agents and nothing else: do not create a config nobody mentioned.
97
+ if (!interactive || dependencies.prompt === undefined) {
98
+ return request.agents === undefined ? "default" : noLayout;
99
+ }
100
+ asked.any = true;
101
+ return await dependencies.prompt.layout({ templates: layoutTemplates(), path, exists });
102
+ }
103
+ /**
104
+ * An agent counts as here when its own directory is: that is what proves it has been set
105
+ * up on this machine, and unlike a name on `PATH` it does not depend on a version
106
+ * manager's shim being healthy.
107
+ */
108
+ async function agentCandidates(dependencies) {
109
+ return await Promise.all(agentDefinitions().map((agent) => agentCandidate(agent, dependencies)));
110
+ }
111
+ async function agentCandidate(agent, dependencies) {
112
+ if (!(await dependencies.pathExists(agent.home(dependencies.agentPaths)))) {
113
+ return { id: agent.id, title: agent.title, state: "missing" };
114
+ }
115
+ if (agent.skillPath === undefined) {
116
+ return { id: agent.id, title: agent.title, state: "manual" };
117
+ }
118
+ return {
119
+ id: agent.id,
120
+ title: agent.title,
121
+ state: "ready",
122
+ path: agent.skillPath(dependencies.agentPaths),
123
+ };
124
+ }
125
+ async function resolveAgents(request, dependencies, interactive, candidates, asked) {
126
+ if (request.agents !== undefined)
127
+ return request.agents;
128
+ if (!interactive || dependencies.prompt === undefined)
129
+ return [];
130
+ asked.any = true;
131
+ return await dependencies.prompt.agents({ candidates });
132
+ }
133
+ /**
134
+ * Decides what happens to each selected agent, asking whatever needs asking. Doing it
135
+ * here rather than while writing keeps one promise: after the plan is confirmed, nothing
136
+ * else interrupts, and the summary says everything that is about to happen.
137
+ */
138
+ async function planAgents(options, dependencies) {
139
+ if (options.selected.length === 0)
140
+ return [];
141
+ const { skill } = options;
142
+ const plans = [];
143
+ for (const id of options.selected) {
144
+ const agent = findAgentDefinition(id);
145
+ const candidate = options.candidates.find((entry) => entry.id === id);
146
+ if (agent === undefined || candidate === undefined)
147
+ continue;
148
+ if (candidate.state === "missing") {
149
+ plans.push({ id, title: agent.title, action: "unavailable" });
150
+ continue;
151
+ }
152
+ if (candidate.state !== "ready" || candidate.path === undefined) {
153
+ plans.push({ id, title: agent.title, action: "manual" });
154
+ continue;
155
+ }
156
+ if ("error" in skill) {
157
+ plans.push({
158
+ id,
159
+ title: agent.title,
160
+ action: "install",
161
+ path: candidate.path,
162
+ error: skill.error,
163
+ });
164
+ continue;
165
+ }
166
+ const existing = await readExistingSkill(candidate.path, dependencies);
167
+ if ("error" in existing) {
168
+ plans.push({
169
+ id,
170
+ title: agent.title,
171
+ action: "install",
172
+ path: candidate.path,
173
+ error: existing.error,
174
+ });
175
+ continue;
176
+ }
177
+ if (existing.contents === skill.contents) {
178
+ plans.push({ id, title: agent.title, action: "present", path: candidate.path });
179
+ continue;
180
+ }
181
+ if (existing.contents === undefined) {
182
+ plans.push({ id, title: agent.title, action: "install", path: candidate.path });
183
+ continue;
184
+ }
185
+ if (options.force || existing.contents.includes(skillMarker)) {
186
+ plans.push({ id, title: agent.title, action: "replace", path: candidate.path });
187
+ continue;
188
+ }
189
+ // Theirs, not ours: the marker is gone, so ask rather than overwrite in passing.
190
+ if (!options.interactive || dependencies.prompt === undefined) {
191
+ plans.push({ id, title: agent.title, action: "keep", path: candidate.path });
192
+ continue;
193
+ }
194
+ options.asked.any = true;
195
+ const replace = await dependencies.prompt.replace({ path: candidate.path });
196
+ if (replace === undefined)
197
+ return undefined;
198
+ plans.push({
199
+ id,
200
+ title: agent.title,
201
+ action: replace ? "replace" : "keep",
202
+ path: candidate.path,
203
+ });
204
+ }
205
+ return plans;
206
+ }
207
+ function planSummary(plan) {
208
+ const lines = [];
209
+ if (plan.layout === noLayout) {
210
+ lines.push("Layout: leave the configuration alone");
211
+ }
212
+ else {
213
+ const replacing = plan.exists ? (plan.force ? "replace" : "keep, already exists") : "write";
214
+ lines.push(`Layout: ${plan.layout} — ${replacing} ${plan.configPath}`);
215
+ }
216
+ if (plan.agents.length === 0) {
217
+ lines.push("Agents: none");
218
+ return lines;
219
+ }
220
+ for (const agent of plan.agents) {
221
+ lines.push(`${agent.title}: ${summariseAction(agent)}`);
222
+ }
223
+ return lines;
224
+ }
225
+ function summariseAction(agent) {
226
+ if (agent.error !== undefined)
227
+ return `cannot install: ${agent.error}`;
228
+ if (agent.action === "manual")
229
+ return "no skills, print the line to add";
230
+ if (agent.action === "unavailable")
231
+ return "not set up here, skip";
232
+ if (agent.action === "present")
233
+ return `already current at ${agent.path}`;
234
+ if (agent.action === "keep")
235
+ return `keep your ${agent.path}`;
236
+ if (agent.action === "replace")
237
+ return `replace ${agent.path}`;
238
+ return `write ${agent.path}`;
239
+ }
240
+ async function apply(plan, dependencies) {
241
+ const result = {
242
+ cancelled: false,
243
+ configPath: plan.configPath,
244
+ configWritten: false,
245
+ agents: [],
246
+ failures: [],
247
+ };
248
+ if (plan.layout !== noLayout) {
249
+ const template = findLayoutTemplate(plan.layout);
250
+ if (template === undefined)
251
+ throw new Error(`unknown layout: ${plan.layout}`);
252
+ try {
253
+ await dependencies.writeConfig({
254
+ path: plan.configPath,
255
+ contents: template.contents,
256
+ force: plan.force,
257
+ });
258
+ result.configWritten = true;
259
+ dependencies.write(`Wrote ${plan.configPath} (${template.id})\n`);
260
+ }
261
+ catch (error) {
262
+ const message = error instanceof Error ? error.message : String(error);
263
+ result.failures.push(message);
264
+ dependencies.write(`Config not written: ${message}\n`);
265
+ }
266
+ }
267
+ for (const agent of plan.agents) {
268
+ result.agents.push(await runAgentPlan(agent, plan.skill, dependencies));
269
+ }
270
+ for (const outcome of result.agents) {
271
+ if (outcome.outcome === "failed" && outcome.detail !== undefined) {
272
+ result.failures.push(outcome.detail);
273
+ }
274
+ }
275
+ writeNextSteps(result, dependencies);
276
+ return result;
277
+ }
278
+ async function readSkill(dependencies) {
279
+ try {
280
+ return { contents: await dependencies.readFile(dependencies.skillSource) };
281
+ }
282
+ catch (error) {
283
+ const reason = error instanceof Error ? error.message : String(error);
284
+ return { error: `cannot read ${dependencies.skillSource}: ${reason}` };
285
+ }
286
+ }
287
+ async function runAgentPlan(plan, skill, dependencies) {
288
+ const agent = findAgentDefinition(plan.id);
289
+ if (plan.action === "unavailable") {
290
+ dependencies.write(`${plan.title} is not set up here, skipping\n`);
291
+ return { id: plan.id, outcome: "unavailable" };
292
+ }
293
+ if (plan.action === "manual") {
294
+ dependencies.write(`${plan.title} takes no skills:\n`);
295
+ if (agent !== undefined)
296
+ writeManual(agent, dependencies);
297
+ return { id: plan.id, outcome: "manual" };
298
+ }
299
+ if (plan.error !== undefined) {
300
+ const detail = `${plan.title}: ${plan.error}`;
301
+ dependencies.write(`${detail}\n`);
302
+ return { id: plan.id, outcome: "failed", detail };
303
+ }
304
+ if (plan.action === "present") {
305
+ dependencies.write(`${plan.title} already has the ${skillName} skill\n`);
306
+ return { id: plan.id, outcome: "present" };
307
+ }
308
+ if (plan.action === "keep") {
309
+ dependencies.write(`${plan.title}: keeping your ${plan.path}; pass --force to replace it\n`);
310
+ return { id: plan.id, outcome: "kept" };
311
+ }
312
+ const path = plan.path;
313
+ if (path === undefined) {
314
+ const detail = `${plan.title}: no skill path`;
315
+ return { id: plan.id, outcome: "failed", detail };
316
+ }
317
+ if ("error" in skill) {
318
+ const detail = `${plan.title}: ${skill.error}`;
319
+ return { id: plan.id, outcome: "failed", detail };
320
+ }
321
+ try {
322
+ await dependencies.writeConfig({
323
+ path,
324
+ contents: skill.contents,
325
+ force: plan.action === "replace",
326
+ });
327
+ dependencies.write(`Wrote ${path}\n`);
328
+ return { id: plan.id, outcome: "installed" };
329
+ }
330
+ catch (error) {
331
+ const detail = `${plan.title}: ${error instanceof Error ? error.message : String(error)}`;
332
+ dependencies.write(`${detail}\n`);
333
+ return { id: plan.id, outcome: "failed", detail };
334
+ }
335
+ }
336
+ /**
337
+ * The file that is there now, `undefined` contents when there is none. An unreadable file
338
+ * is an error rather than "different": treating it as different would report it as the
339
+ * user's own version and quietly keep whatever is broken there.
340
+ */
341
+ async function readExistingSkill(path, dependencies) {
342
+ if (!(await dependencies.pathExists(path)))
343
+ return { contents: undefined };
344
+ try {
345
+ return { contents: await dependencies.readFile(path) };
346
+ }
347
+ catch (error) {
348
+ const reason = error instanceof Error ? error.message : String(error);
349
+ return { error: `cannot read ${path}: ${reason}` };
350
+ }
351
+ }
352
+ function writeManual(agent, dependencies) {
353
+ for (const line of agent.manual) {
354
+ dependencies.write(line.length === 0 ? "\n" : ` ${line}\n`);
355
+ }
356
+ dependencies.write("\n");
357
+ }
358
+ function writeNextSteps(result, dependencies) {
359
+ if (!result.agents.some((agent) => agent.outcome === "installed"))
360
+ return;
361
+ dependencies.write("The skill runs `termwire open`, so it works in a shell created by `termwire up`. " +
362
+ "Allow it once with `Bash(termwire open:*)` to skip the approval prompt.\n");
363
+ }
@@ -0,0 +1,20 @@
1
+ export interface PreviewChoice {
2
+ label: string;
3
+ hint?: string;
4
+ preview: readonly string[];
5
+ }
6
+ export interface RenderChoicesOptions {
7
+ choices: readonly PreviewChoice[];
8
+ /** Index of the highlighted choice, whose preview is the one drawn. */
9
+ cursor: number;
10
+ /** Terminal width; below what the two columns need, the preview goes underneath. */
11
+ columns: number;
12
+ }
13
+ /**
14
+ * Draws the choices with the highlighted one's window layout beside them, so moving
15
+ * through the list shows what each template would create. The hint goes underneath
16
+ * rather than after the label, because a sentence in the left column pushes the
17
+ * drawing off a normal terminal. Too narrow for two columns and the drawing stacks
18
+ * under the list instead of wrapping the boxes into nonsense.
19
+ */
20
+ export declare function renderChoices({ choices, cursor, columns }: RenderChoicesOptions): string;
@@ -0,0 +1,38 @@
1
+ const gutter = " ";
2
+ const activeMarker = "●";
3
+ const inactiveMarker = "○";
4
+ /**
5
+ * Draws the choices with the highlighted one's window layout beside them, so moving
6
+ * through the list shows what each template would create. The hint goes underneath
7
+ * rather than after the label, because a sentence in the left column pushes the
8
+ * drawing off a normal terminal. Too narrow for two columns and the drawing stacks
9
+ * under the list instead of wrapping the boxes into nonsense.
10
+ */
11
+ export function renderChoices({ choices, cursor, columns }) {
12
+ const selected = Math.min(Math.max(cursor, 0), Math.max(choices.length - 1, 0));
13
+ const left = choices.map((choice, index) => `${index === selected ? activeMarker : inactiveMarker} ${choice.label}`);
14
+ const active = choices[selected];
15
+ const hint = active?.hint === undefined ? [] : [` ${active.hint}`];
16
+ const preview = active?.preview ?? [];
17
+ if (preview.length === 0)
18
+ return [...left, ...hint].join("\n");
19
+ const leftWidth = widestOf(left);
20
+ const previewWidth = widestOf(preview);
21
+ if (leftWidth + gutter.length + previewWidth > columns) {
22
+ return [...left, "", ...preview, ...hint].join("\n");
23
+ }
24
+ const height = Math.max(left.length, preview.length);
25
+ const rows = [];
26
+ for (let index = 0; index < height; index += 1) {
27
+ const text = left[index] ?? "";
28
+ const art = preview[index] ?? "";
29
+ rows.push(art.length === 0 ? text : `${pad(text, leftWidth)}${gutter}${art}`);
30
+ }
31
+ return [...rows, ...hint].join("\n");
32
+ }
33
+ function widestOf(lines) {
34
+ return lines.reduce((widest, line) => Math.max(widest, line.length), 0);
35
+ }
36
+ function pad(text, width) {
37
+ return text.length >= width ? text : text + " ".repeat(width - text.length);
38
+ }
package/dist/program.d.ts CHANGED
@@ -1,62 +1,25 @@
1
- import { createNvim } from "@termwire/nvim";
2
- import { createTmux } from "@termwire/tmux";
3
1
  import { Command } from "commander";
4
- import { type Exec } from "./exec.js";
2
+ import { type InstallRequest, type InstallResult } from "./install.js";
5
3
  import { type OpenRequest, type OpenResult } from "./open.js";
6
- import { type KillOutcome, type ReapSignal } from "./reap.js";
4
+ import type { CliRuntime } from "./runtime.js";
7
5
  import { type UpRequest } from "./up.js";
8
- import { type GitExec } from "./worktree.js";
9
6
  export interface ProgramDependencies {
10
7
  up: (request: UpRequest) => Promise<void>;
11
8
  open: (request: OpenRequest) => Promise<OpenResult>;
12
9
  reap: (session: string) => Promise<void>;
10
+ install: (request: InstallRequest) => Promise<InstallResult>;
13
11
  writeError: (message: string) => void;
14
12
  writeOutput: (message: string) => void;
15
13
  }
16
- export interface RuntimeDependencies {
17
- createTmux: () => ReturnType<typeof createTmux>;
18
- cwd: () => string;
19
- env: Record<string, string | undefined>;
20
- homedir: () => string;
21
- execPath: string;
22
- scriptPath: string | undefined;
23
- warn: (message: string) => void;
24
- readFile: (path: string, encoding: "utf8") => Promise<string>;
25
- gitExec: GitExec;
26
- mkdir: (path: string, options: {
27
- recursive: true;
28
- }) => Promise<unknown>;
29
- pathExists: (path: string) => Promise<boolean>;
30
- unlink: (path: string) => Promise<void>;
31
- }
32
- export interface RuntimeReapDependencies {
33
- env: Record<string, string | undefined>;
34
- homedir: () => string;
35
- platform: string;
36
- uid: number;
37
- pid: number;
38
- exec: Exec;
39
- readdir: (path: string) => Promise<string[]>;
40
- readFile: (path: string) => Promise<string>;
41
- kill: (pid: number, signal: ReapSignal) => KillOutcome;
42
- wait: (milliseconds: number) => Promise<void>;
43
- appendFile: (path: string, contents: string) => Promise<void>;
44
- mkdir: (path: string, options: {
45
- recursive: true;
46
- }) => Promise<unknown>;
47
- now: () => Date;
48
- }
49
- export interface RuntimeOpenDependencies {
50
- createNvim: () => ReturnType<typeof createNvim>;
51
- createTmux: () => ReturnType<typeof createTmux>;
52
- cwd: () => string;
53
- env: Record<string, string | undefined>;
54
- }
55
- export declare const executeGit: GitExec;
56
14
  export declare function removeStaleSocket(path: string, unlink: (path: string) => Promise<void>): Promise<void>;
57
- export declare function createRuntimeUp(dependencies?: Partial<RuntimeDependencies>): (request: UpRequest) => Promise<void>;
58
- export declare function killProcess(pid: number, signal: ReapSignal): KillOutcome;
59
- export declare function createRuntimeReap(dependencies?: Partial<RuntimeReapDependencies>): (session: string) => Promise<void>;
60
- export declare function createRuntimeOpen(dependencies?: Partial<RuntimeOpenDependencies>): (request: OpenRequest) => Promise<OpenResult>;
15
+ export declare function createUp({ fs, host, git, tmux, }: CliRuntime): (request: UpRequest) => Promise<void>;
16
+ export declare function createOpen({ host, nvim, tmux, }: CliRuntime): (request: OpenRequest) => Promise<OpenResult>;
17
+ export declare function createReap({ fs, host, exec }: CliRuntime): (session: string) => Promise<void>;
18
+ export declare function createInstall({ fs, host, git, createPrompter, }: CliRuntime): (request: InstallRequest) => Promise<InstallResult>;
19
+ /** Binds every command to one runtime. The only caller that needs the real one. */
20
+ export declare function createCommands(runtime: CliRuntime): ProgramDependencies;
61
21
  export declare function createProgram(dependencies: ProgramDependencies): Command;
62
- export declare function run(argv: readonly string[], dependencies?: Partial<ProgramDependencies>): Promise<number>;
22
+ /** The composition root's entry: one runtime in, an exit code out. */
23
+ export declare function run(argv: readonly string[], runtime: CliRuntime): Promise<number>;
24
+ /** Parsing and exit-code mapping, indifferent to how the commands were built. */
25
+ export declare function runCommands(argv: readonly string[], commands: ProgramDependencies): Promise<number>;