terminal-pilot 0.0.6 → 0.0.7

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.
Files changed (45) hide show
  1. package/dist/cli.js +5708 -1261
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +249 -4
  4. package/dist/commands/close-session.js.map +4 -4
  5. package/dist/commands/create-session.js +249 -4
  6. package/dist/commands/create-session.js.map +4 -4
  7. package/dist/commands/fill.js +249 -4
  8. package/dist/commands/fill.js.map +4 -4
  9. package/dist/commands/get-session.js +249 -4
  10. package/dist/commands/get-session.js.map +4 -4
  11. package/dist/commands/index.js +2376 -184
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +1377 -16
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +181 -15
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +249 -4
  18. package/dist/commands/list-sessions.js.map +4 -4
  19. package/dist/commands/press-key.js +249 -4
  20. package/dist/commands/press-key.js.map +4 -4
  21. package/dist/commands/read-history.js +249 -4
  22. package/dist/commands/read-history.js.map +4 -4
  23. package/dist/commands/read-screen.js +249 -4
  24. package/dist/commands/read-screen.js.map +4 -4
  25. package/dist/commands/resize.js +249 -4
  26. package/dist/commands/resize.js.map +4 -4
  27. package/dist/commands/runtime.js +8 -2
  28. package/dist/commands/runtime.js.map +3 -3
  29. package/dist/commands/screenshot.js +1014 -8
  30. package/dist/commands/screenshot.js.map +4 -4
  31. package/dist/commands/send-signal.js +249 -4
  32. package/dist/commands/send-signal.js.map +4 -4
  33. package/dist/commands/type.js +249 -4
  34. package/dist/commands/type.js.map +4 -4
  35. package/dist/commands/uninstall.js +421 -16
  36. package/dist/commands/uninstall.js.map +4 -4
  37. package/dist/commands/wait-for-exit.js +249 -4
  38. package/dist/commands/wait-for-exit.js.map +4 -4
  39. package/dist/commands/wait-for.js +249 -4
  40. package/dist/commands/wait-for.js.map +4 -4
  41. package/dist/testing/cli-repl.js +5633 -1185
  42. package/dist/testing/cli-repl.js.map +4 -4
  43. package/dist/testing/qa-cli.js +5674 -1226
  44. package/dist/testing/qa-cli.js.map +4 -4
  45. package/package.json +17 -8
@@ -1,20 +1,425 @@
1
- // src/commands/uninstall.ts
2
- import { defineCommand, S } from "@poe-code/cmdkit";
1
+ // ../cmdkit/src/index.ts
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ // ../cmdkit-schema/src/index.ts
5
+ function assertValidEnumValues(values) {
6
+ if (values.length === 0) {
7
+ throw new Error("Enum schema requires at least one value");
8
+ }
9
+ const uniqueValues = new Set(values);
10
+ if (uniqueValues.size !== values.length) {
11
+ throw new Error("Enum schema values must be unique");
12
+ }
13
+ }
14
+ var S = {
15
+ String(options = {}) {
16
+ return {
17
+ kind: "string",
18
+ ...options
19
+ };
20
+ },
21
+ Number(options = {}) {
22
+ return {
23
+ kind: "number",
24
+ ...options
25
+ };
26
+ },
27
+ Boolean(options = {}) {
28
+ return {
29
+ kind: "boolean",
30
+ ...options
31
+ };
32
+ },
33
+ Enum(values, options = {}) {
34
+ assertValidEnumValues(values);
35
+ return {
36
+ kind: "enum",
37
+ values,
38
+ ...options
39
+ };
40
+ },
41
+ Array(item, options = {}) {
42
+ return {
43
+ kind: "array",
44
+ item,
45
+ ...options
46
+ };
47
+ },
48
+ Object(shape) {
49
+ return {
50
+ kind: "object",
51
+ shape
52
+ };
53
+ },
54
+ Optional(inner) {
55
+ return {
56
+ kind: "optional",
57
+ inner
58
+ };
59
+ }
60
+ };
61
+
62
+ // ../cmdkit/src/index.ts
63
+ var commandConfigSymbol = /* @__PURE__ */ Symbol("cmdkit.command.config");
64
+ var commandSourcePathSymbol = /* @__PURE__ */ Symbol("cmdkit.command.sourcePath");
65
+ var UserError = class extends Error {
66
+ constructor(message) {
67
+ super(message);
68
+ this.name = "UserError";
69
+ }
70
+ };
71
+ function cloneScope(scope) {
72
+ return scope === void 0 ? void 0 : [...scope];
73
+ }
74
+ function cloneSecretDefinition(secret) {
75
+ return {
76
+ env: secret.env,
77
+ description: secret.description,
78
+ optional: secret.optional
79
+ };
80
+ }
81
+ function cloneSecrets(secrets) {
82
+ if (secrets === void 0) {
83
+ return {};
84
+ }
85
+ return Object.fromEntries(
86
+ Object.entries(secrets).map(([key, secret]) => [key, cloneSecretDefinition(secret)])
87
+ );
88
+ }
89
+ function cloneRequires(requires) {
90
+ if (requires === void 0) {
91
+ return void 0;
92
+ }
93
+ return {
94
+ auth: requires.auth,
95
+ apiVersion: requires.apiVersion,
96
+ check: requires.check
97
+ };
98
+ }
99
+ function parseStackPath(candidate) {
100
+ if (candidate.startsWith("file://")) {
101
+ try {
102
+ return fileURLToPath(candidate);
103
+ } catch {
104
+ return void 0;
105
+ }
106
+ }
107
+ if (candidate.startsWith("/")) {
108
+ return candidate;
109
+ }
110
+ return void 0;
111
+ }
112
+ function extractStackPath(line) {
113
+ const trimmed = line.trim();
114
+ const fileIndex = trimmed.indexOf("file://");
115
+ if (fileIndex >= 0) {
116
+ const location2 = trimmed.slice(fileIndex);
117
+ const separatorIndex2 = location2.lastIndexOf(":");
118
+ const previousSeparatorIndex2 = separatorIndex2 >= 0 ? location2.lastIndexOf(":", separatorIndex2 - 1) : -1;
119
+ const candidate2 = separatorIndex2 >= 0 && previousSeparatorIndex2 >= 0 ? location2.slice(0, previousSeparatorIndex2) : location2;
120
+ return parseStackPath(candidate2);
121
+ }
122
+ const slashIndex = trimmed.indexOf("/");
123
+ if (slashIndex < 0) {
124
+ return void 0;
125
+ }
126
+ const location = trimmed.slice(slashIndex);
127
+ const separatorIndex = location.lastIndexOf(":");
128
+ const previousSeparatorIndex = separatorIndex >= 0 ? location.lastIndexOf(":", separatorIndex - 1) : -1;
129
+ const candidate = separatorIndex >= 0 && previousSeparatorIndex >= 0 ? location.slice(0, previousSeparatorIndex) : location;
130
+ return parseStackPath(candidate);
131
+ }
132
+ function inferCommandSourcePath() {
133
+ const stack = new Error().stack;
134
+ if (typeof stack !== "string") {
135
+ return void 0;
136
+ }
137
+ for (const line of stack.split("\n").slice(1)) {
138
+ const candidate = extractStackPath(line);
139
+ if (candidate === void 0) {
140
+ continue;
141
+ }
142
+ if (candidate.includes("/packages/cmdkit/src/index.ts") || candidate.includes("/packages/cmdkit/dist/index.js")) {
143
+ continue;
144
+ }
145
+ return candidate;
146
+ }
147
+ return void 0;
148
+ }
149
+ function composeChecks(parentCheck, childCheck) {
150
+ if (parentCheck === void 0) {
151
+ return childCheck;
152
+ }
153
+ if (childCheck === void 0) {
154
+ return parentCheck;
155
+ }
156
+ return async (ctx) => {
157
+ const parentResult = await parentCheck(ctx);
158
+ if (!parentResult.ok) {
159
+ return parentResult;
160
+ }
161
+ return childCheck(ctx);
162
+ };
163
+ }
164
+ function mergeRequires(parent, child) {
165
+ if (parent === void 0 && child === void 0) {
166
+ return void 0;
167
+ }
168
+ const merged = {
169
+ auth: child?.auth ?? parent?.auth,
170
+ apiVersion: child?.apiVersion ?? parent?.apiVersion,
171
+ check: composeChecks(parent?.check, child?.check)
172
+ };
173
+ if (merged.auth === void 0 && merged.apiVersion === void 0 && merged.check === void 0) {
174
+ return void 0;
175
+ }
176
+ return merged;
177
+ }
178
+ function mergeSecrets(parent, child) {
179
+ return cloneSecrets({
180
+ ...parent,
181
+ ...child
182
+ });
183
+ }
184
+ function resolveCommandScope(ownScope, inheritedScope) {
185
+ return cloneScope(ownScope ?? inheritedScope) ?? ["cli", "sdk"];
186
+ }
187
+ function createBaseCommand(config) {
188
+ const command = {
189
+ kind: "command",
190
+ name: config.name,
191
+ description: config.description,
192
+ aliases: [...config.aliases ?? []],
193
+ positional: [...config.positional ?? []],
194
+ params: config.params,
195
+ secrets: cloneSecrets(config.secrets),
196
+ scope: resolveCommandScope(config.scope, void 0),
197
+ confirm: config.confirm ?? false,
198
+ requires: cloneRequires(config.requires),
199
+ handler: config.handler,
200
+ render: config.render
201
+ };
202
+ Object.defineProperty(command, commandConfigSymbol, {
203
+ value: {
204
+ scope: cloneScope(config.scope),
205
+ secrets: cloneSecrets(config.secrets),
206
+ requires: cloneRequires(config.requires),
207
+ sourcePath: inferCommandSourcePath()
208
+ }
209
+ });
210
+ return command;
211
+ }
212
+ function getInternalCommandConfig(command) {
213
+ return command[commandConfigSymbol];
214
+ }
215
+ function materializeCommand(command, inherited) {
216
+ const internal = getInternalCommandConfig(command);
217
+ const materialized = {
218
+ kind: "command",
219
+ name: command.name,
220
+ description: command.description,
221
+ aliases: [...command.aliases],
222
+ positional: [...command.positional],
223
+ params: command.params,
224
+ secrets: mergeSecrets(inherited.secrets, internal.secrets),
225
+ scope: resolveCommandScope(internal.scope, inherited.scope),
226
+ confirm: command.confirm,
227
+ requires: mergeRequires(inherited.requires, internal.requires),
228
+ handler: command.handler,
229
+ render: command.render
230
+ };
231
+ Object.defineProperty(materialized, commandConfigSymbol, {
232
+ value: {
233
+ scope: cloneScope(internal.scope),
234
+ secrets: cloneSecrets(internal.secrets),
235
+ requires: cloneRequires(internal.requires),
236
+ sourcePath: internal.sourcePath
237
+ }
238
+ });
239
+ Object.defineProperty(materialized, commandSourcePathSymbol, {
240
+ value: internal.sourcePath
241
+ });
242
+ return materialized;
243
+ }
244
+ function defineCommand(config) {
245
+ return materializeCommand(createBaseCommand(config), {
246
+ scope: void 0,
247
+ secrets: {},
248
+ requires: void 0
249
+ });
250
+ }
3
251
 
4
252
  // src/commands/installer.ts
253
+ import os2 from "node:os";
254
+ import path3 from "node:path";
255
+ import * as nodeFs from "node:fs/promises";
256
+ import { readFile as readFile2 } from "node:fs/promises";
257
+
258
+ // ../agent-skill-config/src/configs.ts
5
259
  import os from "node:os";
6
260
  import path from "node:path";
7
- import * as nodeFs from "node:fs/promises";
261
+
262
+ // ../agent-defs/src/agents/claude-code.ts
263
+ var claudeCodeAgent = {
264
+ id: "claude-code",
265
+ name: "claude-code",
266
+ label: "Claude Code",
267
+ summary: "Configure Claude Code to route through Poe.",
268
+ aliases: ["claude"],
269
+ binaryName: "claude",
270
+ configPath: "~/.claude/settings.json",
271
+ branding: {
272
+ colors: {
273
+ dark: "#C15F3C",
274
+ light: "#C15F3C"
275
+ }
276
+ }
277
+ };
278
+
279
+ // ../agent-defs/src/agents/claude-desktop.ts
280
+ var claudeDesktopAgent = {
281
+ id: "claude-desktop",
282
+ name: "claude-desktop",
283
+ label: "Claude Desktop",
284
+ summary: "Anthropic's official desktop application for Claude",
285
+ configPath: "~/.claude/settings.json",
286
+ branding: {
287
+ colors: {
288
+ dark: "#D97757",
289
+ light: "#D97757"
290
+ }
291
+ }
292
+ };
293
+
294
+ // ../agent-defs/src/agents/codex.ts
295
+ var codexAgent = {
296
+ id: "codex",
297
+ name: "codex",
298
+ label: "Codex",
299
+ summary: "Configure Codex to use Poe as the model provider.",
300
+ binaryName: "codex",
301
+ configPath: "~/.codex/config.toml",
302
+ branding: {
303
+ colors: {
304
+ dark: "#D5D9DF",
305
+ light: "#7A7F86"
306
+ }
307
+ }
308
+ };
309
+
310
+ // ../agent-defs/src/agents/opencode.ts
311
+ var openCodeAgent = {
312
+ id: "opencode",
313
+ name: "opencode",
314
+ label: "OpenCode CLI",
315
+ summary: "Configure OpenCode CLI to use the Poe API.",
316
+ binaryName: "opencode",
317
+ configPath: "~/.config/opencode/config.json",
318
+ branding: {
319
+ colors: {
320
+ dark: "#4A4F55",
321
+ light: "#2F3338"
322
+ }
323
+ }
324
+ };
325
+
326
+ // ../agent-defs/src/agents/kimi.ts
327
+ var kimiAgent = {
328
+ id: "kimi",
329
+ name: "kimi",
330
+ label: "Kimi",
331
+ summary: "Configure Kimi CLI to use Poe API",
332
+ aliases: ["kimi-cli"],
333
+ binaryName: "kimi",
334
+ configPath: "~/.kimi/config.toml",
335
+ branding: {
336
+ colors: {
337
+ dark: "#7B68EE",
338
+ light: "#6A5ACD"
339
+ }
340
+ }
341
+ };
342
+
343
+ // ../agent-defs/src/registry.ts
344
+ var allAgents = [
345
+ claudeCodeAgent,
346
+ claudeDesktopAgent,
347
+ codexAgent,
348
+ openCodeAgent,
349
+ kimiAgent
350
+ ];
351
+ var lookup = /* @__PURE__ */ new Map();
352
+ for (const agent of allAgents) {
353
+ const values = [agent.id, agent.name, ...agent.aliases ?? []];
354
+ for (const value of values) {
355
+ const normalized = value.toLowerCase();
356
+ if (!lookup.has(normalized)) {
357
+ lookup.set(normalized, agent.id);
358
+ }
359
+ }
360
+ }
361
+ function resolveAgentId(input) {
362
+ if (!input) {
363
+ return void 0;
364
+ }
365
+ return lookup.get(input.toLowerCase());
366
+ }
367
+
368
+ // ../agent-skill-config/src/configs.ts
369
+ var agentSkillConfigs = {
370
+ "claude-code": {
371
+ globalSkillDir: "~/.claude/skills",
372
+ localSkillDir: ".claude/skills"
373
+ },
374
+ codex: {
375
+ globalSkillDir: "~/.codex/skills",
376
+ localSkillDir: ".codex/skills"
377
+ },
378
+ opencode: {
379
+ globalSkillDir: "~/.config/opencode/skills",
380
+ localSkillDir: ".opencode/skills"
381
+ }
382
+ };
383
+ var supportedAgents = Object.keys(agentSkillConfigs);
384
+ function resolveAgentSupport(input, registry = agentSkillConfigs) {
385
+ const resolvedId = resolveAgentId(input);
386
+ if (!resolvedId) {
387
+ return { status: "unknown", input };
388
+ }
389
+ const config = registry[resolvedId];
390
+ if (!config) {
391
+ return { status: "unsupported", input, id: resolvedId };
392
+ }
393
+ return { status: "supported", input, id: resolvedId, config };
394
+ }
395
+ function getAgentConfig(agentId) {
396
+ const support = resolveAgentSupport(agentId);
397
+ return support.status === "supported" ? support.config : void 0;
398
+ }
399
+
400
+ // ../config-mutations/src/execution/apply-mutation.ts
401
+ import Mustache from "mustache";
402
+
403
+ // ../config-mutations/src/formats/json.ts
404
+ import * as jsonc from "jsonc-parser";
405
+
406
+ // ../config-mutations/src/formats/toml.ts
407
+ import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
408
+
409
+ // ../config-mutations/src/execution/path-utils.ts
410
+ import path2 from "node:path";
411
+
412
+ // ../config-mutations/src/template/render.ts
413
+ import Mustache2 from "mustache";
414
+ var originalEscape = Mustache2.escape;
415
+
416
+ // ../agent-skill-config/src/templates.ts
8
417
  import { readFile } from "node:fs/promises";
9
- import { UserError } from "@poe-code/cmdkit";
10
- import {
11
- getAgentConfig,
12
- resolveAgentSupport as resolveSkillAgentSupport,
13
- supportedAgents as skillSupportedAgents
14
- } from "@poe-code/agent-skill-config";
418
+
419
+ // src/commands/installer.ts
15
420
  var DEFAULT_INSTALL_AGENT = "claude-code";
16
421
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
17
- var installableAgents = skillSupportedAgents;
422
+ var installableAgents = supportedAgents;
18
423
  function isNotFoundError(error) {
19
424
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
20
425
  }
@@ -22,7 +427,7 @@ function resolveInstallerServices(installer) {
22
427
  return {
23
428
  fs: installer?.fs ?? nodeFs,
24
429
  cwd: installer?.cwd ?? process.cwd(),
25
- homeDir: installer?.homeDir ?? os.homedir(),
430
+ homeDir: installer?.homeDir ?? os2.homedir(),
26
431
  platform: installer?.platform ?? process.platform
27
432
  };
28
433
  }
@@ -30,7 +435,7 @@ function throwUnsupportedAgent(agent) {
30
435
  throw new UserError(`Unsupported agent: ${agent}`);
31
436
  }
32
437
  function resolveInstallableAgent(agent) {
33
- const skillSupport = resolveSkillAgentSupport(agent);
438
+ const skillSupport = resolveAgentSupport(agent);
34
439
  if (skillSupport.status !== "supported" || !skillSupport.id) {
35
440
  throwUnsupportedAgent(agent);
36
441
  }
@@ -41,7 +446,7 @@ function resolveHomeRelativePath(targetPath, homeDir) {
41
446
  return homeDir;
42
447
  }
43
448
  if (targetPath.startsWith("~/")) {
44
- return path.join(homeDir, targetPath.slice(2));
449
+ return path3.join(homeDir, targetPath.slice(2));
45
450
  }
46
451
  return targetPath;
47
452
  }
@@ -51,12 +456,12 @@ function getSkillFolderWithHome(agent, scope, cwd, homeDir) {
51
456
  throwUnsupportedAgent(agent);
52
457
  }
53
458
  return {
54
- displayPath: path.join(
459
+ displayPath: path3.join(
55
460
  scope === "global" ? config.globalSkillDir : config.localSkillDir,
56
461
  TERMINAL_PILOT_SKILL_NAME
57
462
  ),
58
- fullPath: path.join(
59
- scope === "global" ? resolveHomeRelativePath(config.globalSkillDir, homeDir) : path.resolve(cwd, config.localSkillDir),
463
+ fullPath: path3.join(
464
+ scope === "global" ? resolveHomeRelativePath(config.globalSkillDir, homeDir) : path3.resolve(cwd, config.localSkillDir),
60
465
  TERMINAL_PILOT_SKILL_NAME
61
466
  )
62
467
  };