terminal-pilot 0.0.42 → 0.0.43

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 (39) hide show
  1. package/README.md +7 -3
  2. package/dist/cli.js +99 -67
  3. package/dist/cli.js.map +4 -4
  4. package/dist/commands/index.js.map +2 -2
  5. package/dist/commands/install.js.map +2 -2
  6. package/dist/commands/installer.js.map +2 -2
  7. package/dist/commands/uninstall.js.map +2 -2
  8. package/dist/composition.json +35 -0
  9. package/dist/templates/terminal-pilot.md +1 -1
  10. package/dist/testing/cli-repl.js +99 -67
  11. package/dist/testing/cli-repl.js.map +4 -4
  12. package/dist/testing/qa-cli.js +99 -67
  13. package/dist/testing/qa-cli.js.map +4 -4
  14. package/node_modules/@poe-code/agent-defs/LICENSE +21 -0
  15. package/node_modules/@poe-code/agent-defs/package.json +12 -3
  16. package/node_modules/@poe-code/agent-skill-config/README.md +25 -17
  17. package/node_modules/@poe-code/agent-skill-config/dist/templates/poe-generate.md +16 -22
  18. package/node_modules/@poe-code/agent-skill-config/dist/templates/terminal-pilot.md +1 -1
  19. package/node_modules/@poe-code/agent-skill-config/package.json +1 -0
  20. package/node_modules/@poe-code/config-mutations/LICENSE +21 -0
  21. package/node_modules/@poe-code/config-mutations/README.md +8 -8
  22. package/node_modules/@poe-code/config-mutations/package.json +11 -2
  23. package/node_modules/@poe-code/frontmatter/LICENSE +21 -0
  24. package/node_modules/@poe-code/frontmatter/README.md +2 -2
  25. package/node_modules/@poe-code/frontmatter/package.json +11 -2
  26. package/node_modules/toolcraft-design/LICENSE +21 -0
  27. package/node_modules/toolcraft-design/README.md +8 -4
  28. package/node_modules/toolcraft-design/dist/dashboard/terminal.js +48 -6
  29. package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +4 -0
  30. package/node_modules/toolcraft-design/dist/explorer/actions.js +1 -0
  31. package/node_modules/toolcraft-design/dist/explorer/events.d.ts +4 -0
  32. package/node_modules/toolcraft-design/dist/explorer/reducer.js +52 -4
  33. package/node_modules/toolcraft-design/dist/explorer/render/list.js +47 -20
  34. package/node_modules/toolcraft-design/dist/explorer/render/modal.js +13 -1
  35. package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +1 -1
  36. package/node_modules/toolcraft-design/dist/explorer/runtime.js +3 -0
  37. package/node_modules/toolcraft-design/dist/explorer/state.d.ts +9 -0
  38. package/node_modules/toolcraft-design/package.json +3 -2
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Use it when plain stdio is not enough: menus, prompts, arrow-key navigation, confirmations, and terminal redraws such as `poe-code configure`.
6
6
 
7
- For design rationale and scope, see `docs/plans/terminal-pilot.md`.
7
+ For design history, see [terminal-pilot](../../docs/plans/archive/terminal-pilot.md).
8
8
 
9
9
  For the MCP server, see [terminal-pilot-mcp](../terminal-pilot-mcp).
10
10
 
@@ -218,12 +218,16 @@ class TerminalScreen {
218
218
  }
219
219
  ```
220
220
 
221
- ## Environment variables
221
+ ## Environment Variables
222
222
 
223
223
  There are **no terminal-pilot-specific environment variables**.
224
224
 
225
225
  Runtime environment is controlled per session via `newSession({ env })`. There are no package-level config files or config options beyond the per-session options.
226
226
 
227
+ ## Configuration Options
228
+
229
+ Configure sessions with `newSession({ command, args, cwd, env, cols, rows, observe })`. CLI skill installation is controlled by `install`/`uninstall` flags: target agent plus optional `--local` or `--global`.
230
+
227
231
  ## Testing
228
232
 
229
233
  Interactive fixtures live under `packages/terminal-pilot/src/testing/`:
@@ -232,7 +236,7 @@ Interactive fixtures live under `packages/terminal-pilot/src/testing/`:
232
236
  - `menu-cli.ts` - arrow-key menu fixture
233
237
  - `fixtures.test.ts` - examples of driving both fixtures
234
238
 
235
- Run just the fixture tests:
239
+ Run the fixture tests only:
236
240
 
237
241
  ```sh
238
242
  npx vitest run packages/terminal-pilot/src/testing/fixtures.test.ts
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ var globalWithRequire = globalThis;
17
17
  globalWithRequire.require ??= createRequire(path.join(process.cwd(), "package.json"));
18
18
 
19
19
  // ../toolcraft/src/cli.ts
20
- import { access, lstat, readFile, rename, unlink, writeFile as writeFile2 } from "node:fs/promises";
20
+ import { readFile as readFile2 } from "node:fs/promises";
21
21
  import path5 from "node:path";
22
22
  import {
23
23
  Command as CommanderCommand,
@@ -4582,6 +4582,12 @@ function buildReport(context) {
4582
4582
  return `${lines.join("\n")}
4583
4583
  `;
4584
4584
  }
4585
+ function renderErrorReport(context) {
4586
+ return {
4587
+ content: buildReport(context),
4588
+ redactedKeys: commandSecretEnvNames(context.command?.secrets)
4589
+ };
4590
+ }
4585
4591
  async function writeErrorReport(context) {
4586
4592
  const env = context.env ?? process.env;
4587
4593
  if (!reportsEnabled(context.errorReports, env) || isSkippedError(context.error)) {
@@ -4595,7 +4601,7 @@ async function writeErrorReport(context) {
4595
4601
  if (reportDirMustStayWithinProject(context.errorReports)) {
4596
4602
  await assertReportDirWithinProject(projectRoot, reportDir);
4597
4603
  }
4598
- await writeFile(absolutePath, buildReport(context));
4604
+ await writeFile(absolutePath, renderErrorReport(context).content);
4599
4605
  return {
4600
4606
  absolutePath,
4601
4607
  displayPath: relativeDisplayPath(projectRoot, absolutePath)
@@ -5193,8 +5199,8 @@ function throwValidationErrors(errors) {
5193
5199
  ${rendered.join("\n")}`);
5194
5200
  }
5195
5201
 
5196
- // ../toolcraft/src/cli.ts
5197
- configureTheme({ brand: "blue", label: "Toolcraft" });
5202
+ // ../toolcraft/src/runtime/io.ts
5203
+ import { access, lstat, readFile, rename, unlink, writeFile as writeFile2 } from "node:fs/promises";
5198
5204
  var RESERVED_SERVICE_NAMES = /* @__PURE__ */ new Set([
5199
5205
  "params",
5200
5206
  "secrets",
@@ -5207,6 +5213,47 @@ var RESERVED_SERVICE_NAMES = /* @__PURE__ */ new Set([
5207
5213
  "root"
5208
5214
  ]);
5209
5215
  var RESERVED_SERVICE_NAMES_MESSAGE = "Available reserved names: params, secrets, fetch, fs, env, diagnostics, progress, runtimeOptions, root.";
5216
+ function createFs(fs4) {
5217
+ if (fs4 !== void 0) {
5218
+ return fs4;
5219
+ }
5220
+ return {
5221
+ readFile: async (path16, encoding = "utf8") => readFile(path16, { encoding }),
5222
+ writeFile: async (path16, contents, options) => {
5223
+ await writeFile2(path16, contents, options);
5224
+ },
5225
+ exists: async (path16) => {
5226
+ try {
5227
+ await access(path16);
5228
+ return true;
5229
+ } catch {
5230
+ return false;
5231
+ }
5232
+ },
5233
+ lstat: async (path16) => lstat(path16),
5234
+ rename: async (fromPath, toPath) => rename(fromPath, toPath),
5235
+ unlink: async (path16) => unlink(path16)
5236
+ };
5237
+ }
5238
+ function createEnv(values = process.env) {
5239
+ return {
5240
+ get(key) {
5241
+ return values[key];
5242
+ }
5243
+ };
5244
+ }
5245
+ function validateServices(services) {
5246
+ for (const name of Object.keys(services)) {
5247
+ if (RESERVED_SERVICE_NAMES.has(name)) {
5248
+ throw new Error(
5249
+ `Service name "${name}" is reserved. Choose a different name. ${RESERVED_SERVICE_NAMES_MESSAGE}`
5250
+ );
5251
+ }
5252
+ }
5253
+ }
5254
+
5255
+ // ../toolcraft/src/cli.ts
5256
+ configureTheme({ brand: "blue", label: "Toolcraft" });
5210
5257
  var NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
5211
5258
  var optionalModulePaths = {
5212
5259
  approvals: "./human-in-loop/approvals-commands.js",
@@ -7015,32 +7062,6 @@ async function withOutputFormat2(output, fn) {
7015
7062
  resetOutputFormatCache();
7016
7063
  }
7017
7064
  }
7018
- function createFs() {
7019
- return {
7020
- readFile: async (path16, encoding = "utf8") => readFile(path16, { encoding }),
7021
- writeFile: async (path16, contents, options) => {
7022
- await writeFile2(path16, contents, options);
7023
- },
7024
- exists: async (path16) => {
7025
- try {
7026
- await access(path16);
7027
- return true;
7028
- } catch {
7029
- return false;
7030
- }
7031
- },
7032
- lstat: async (path16) => lstat(path16),
7033
- rename: async (fromPath, toPath) => rename(fromPath, toPath),
7034
- unlink: async (path16) => unlink(path16)
7035
- };
7036
- }
7037
- function createEnv(values = process.env) {
7038
- return {
7039
- get(key) {
7040
- return values[key];
7041
- }
7042
- };
7043
- }
7044
7065
  function isPlainObject4(value) {
7045
7066
  return typeof value === "object" && value !== null && !Array.isArray(value);
7046
7067
  }
@@ -7152,7 +7173,7 @@ function validatePresetFieldValue(value, field, presetPath) {
7152
7173
  async function loadPresetValues(fields, presetPath) {
7153
7174
  let rawPreset;
7154
7175
  try {
7155
- rawPreset = await readFile(presetPath, {
7176
+ rawPreset = await readFile2(presetPath, {
7156
7177
  encoding: "utf8"
7157
7178
  });
7158
7179
  } catch (error3) {
@@ -7419,7 +7440,7 @@ async function loadFixtureScenario(command, selector) {
7419
7440
  const fixturePath = resolveFixturePath(commandPath);
7420
7441
  let rawFixture;
7421
7442
  try {
7422
- rawFixture = await readFile(fixturePath, {
7443
+ rawFixture = await readFile2(fixturePath, {
7423
7444
  encoding: "utf8"
7424
7445
  });
7425
7446
  } catch {
@@ -7456,16 +7477,16 @@ function createFixtureEnvValues(command) {
7456
7477
  }
7457
7478
  return values;
7458
7479
  }
7459
- async function resolveFixtureRuntime(command, services, requirementOptions, runtimeFetch) {
7480
+ async function resolveFixtureRuntime(command, services, requirementOptions, runtimeFetch, runtimeEnv, runtimeFs) {
7460
7481
  const selector = process.env.TOOLCRAFT_FIXTURE;
7461
7482
  if (selector === void 0 || selector.length === 0) {
7462
7483
  return {
7463
- env: createEnv(),
7484
+ env: createEnv(runtimeEnv),
7464
7485
  fetch: runtimeFetch,
7465
- fs: createFs(),
7486
+ fs: createFs(runtimeFs),
7466
7487
  isFixture: false,
7467
7488
  requirementOptions,
7468
- secrets: resolveCommandSecrets(command),
7489
+ secrets: resolveCommandSecrets(command, runtimeEnv),
7469
7490
  services
7470
7491
  };
7471
7492
  }
@@ -7513,8 +7534,8 @@ function renderApprovalDeclined(error3) {
7513
7534
  logger2.error(error3.message);
7514
7535
  process.exitCode = 1;
7515
7536
  }
7516
- function renderCliErrorPattern(pattern) {
7517
- const logger2 = createLogger();
7537
+ function renderCliErrorPattern(pattern, outputEmitter) {
7538
+ const logger2 = createLogger(outputEmitter);
7518
7539
  if (pattern.kind === "usage") {
7519
7540
  logger2.error(
7520
7541
  appendUsagePointer(pattern.message, {
@@ -7564,15 +7585,6 @@ This is a bug in toolcraft or in the command definition; it cannot be worked aro
7564
7585
  }
7565
7586
  process.exitCode = 1;
7566
7587
  }
7567
- function validateServices(services) {
7568
- for (const name of Object.keys(services)) {
7569
- if (RESERVED_SERVICE_NAMES.has(name)) {
7570
- throw new Error(
7571
- `Service name "${name}" is reserved. Choose a different name. ${RESERVED_SERVICE_NAMES_MESSAGE}`
7572
- );
7573
- }
7574
- }
7575
- }
7576
7588
  function getNestedValue(target, path16) {
7577
7589
  return path16.reduce(
7578
7590
  (current, segment) => current !== null && typeof current === "object" ? current[segment] : void 0,
@@ -8205,8 +8217,8 @@ function getResolvedFlags(command) {
8205
8217
  const flags = command.optsWithGlobals();
8206
8218
  return flags;
8207
8219
  }
8208
- async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, diagnosticsOptions, onErrorReportContext) {
8209
- const logger2 = createLogger();
8220
+ async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, runtimeEnv, runtimeFs, outputEmitter, diagnosticsOptions, onErrorReportContext) {
8221
+ const logger2 = createLogger(outputEmitter);
8210
8222
  const primitives = {
8211
8223
  logger: logger2,
8212
8224
  renderTable,
@@ -8225,7 +8237,9 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
8225
8237
  state.command,
8226
8238
  services,
8227
8239
  requirementOptions,
8228
- runtimeFetch
8240
+ runtimeFetch,
8241
+ runtimeEnv,
8242
+ runtimeFs
8229
8243
  );
8230
8244
  const preflightContext = {
8231
8245
  ...runtime.services,
@@ -8293,7 +8307,13 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
8293
8307
  renderHumanInLoopPending(result);
8294
8308
  return;
8295
8309
  }
8296
- const renderStatus = renderResult(state.command, result, output, primitives);
8310
+ const renderStatus = renderResult(
8311
+ state.command,
8312
+ result,
8313
+ output,
8314
+ primitives,
8315
+ outputEmitter === void 0 ? void 0 : (chunk) => outputEmitter(chunk.endsWith("\n") ? chunk.slice(0, -1) : chunk)
8316
+ );
8297
8317
  if (renderStatus.mcpError) {
8298
8318
  process.exitCode = 1;
8299
8319
  }
@@ -8505,7 +8525,7 @@ function renderHttpError(error3, options) {
8505
8525
  }
8506
8526
  }
8507
8527
  async function handleRunError(error3, options) {
8508
- const logger2 = createLogger();
8528
+ const logger2 = createLogger(options.outputEmitter);
8509
8529
  await withOutputFormat2(options.output, async () => {
8510
8530
  if (error3 instanceof UserError) {
8511
8531
  renderCliErrorPattern(
@@ -8521,16 +8541,20 @@ async function handleRunError(error3, options) {
8521
8541
  } : {
8522
8542
  kind: "runtime-user",
8523
8543
  message: error3.message
8524
- }
8544
+ },
8545
+ options.outputEmitter
8525
8546
  );
8526
8547
  return;
8527
8548
  }
8528
8549
  if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
8529
- renderCliErrorPattern({
8530
- kind: "toolcraft-bug",
8531
- error: error3,
8532
- debugStackMode: options.debugStackMode
8533
- });
8550
+ renderCliErrorPattern(
8551
+ {
8552
+ kind: "toolcraft-bug",
8553
+ error: error3,
8554
+ debugStackMode: options.debugStackMode
8555
+ },
8556
+ options.outputEmitter
8557
+ );
8534
8558
  return;
8535
8559
  }
8536
8560
  if (error3 instanceof CommanderError2) {
@@ -8574,12 +8598,15 @@ async function handleRunError(error3, options) {
8574
8598
  return;
8575
8599
  }
8576
8600
  const message2 = error3 instanceof Error ? error3.message : String(error3);
8577
- renderCliErrorPattern({
8578
- kind: "unexpected",
8579
- message: message2,
8580
- stack: error3 instanceof Error ? error3.stack : void 0,
8581
- debugStackMode: options.debugStackMode
8582
- });
8601
+ renderCliErrorPattern(
8602
+ {
8603
+ kind: "unexpected",
8604
+ message: message2,
8605
+ stack: error3 instanceof Error ? error3.stack : void 0,
8606
+ debugStackMode: options.debugStackMode
8607
+ },
8608
+ options.outputEmitter
8609
+ );
8583
8610
  });
8584
8611
  }
8585
8612
  function formatCommanderErrorMessage(error3) {
@@ -8855,7 +8882,8 @@ async function runCLI(roots, options = {}) {
8855
8882
  root
8856
8883
  };
8857
8884
  const requirementOptions = {
8858
- apiVersion: options.apiVersion
8885
+ apiVersion: options.apiVersion,
8886
+ env: options.env
8859
8887
  };
8860
8888
  validateServices(services);
8861
8889
  if (hasHelpFlag(argv)) {
@@ -8897,6 +8925,9 @@ async function runCLI(roots, options = {}) {
8897
8925
  requirementOptions,
8898
8926
  runtimeFetch,
8899
8927
  runtimeOptions,
8928
+ options.env,
8929
+ options.fs,
8930
+ options.outputEmitter,
8900
8931
  {
8901
8932
  logLevel: options.logLevel,
8902
8933
  logger: options.logger,
@@ -8972,6 +9003,7 @@ async function runCLI(roots, options = {}) {
8972
9003
  argv,
8973
9004
  rootUsageName,
8974
9005
  commandPath: resolvedCommandPath,
9006
+ outputEmitter: options.outputEmitter,
8975
9007
  userErrorPattern: errorReportContext?.params === void 0 ? userErrorPattern : "runtime-user"
8976
9008
  });
8977
9009
  }
@@ -12251,7 +12283,7 @@ function hasOwnErrorCode4(error3, code) {
12251
12283
  }
12252
12284
 
12253
12285
  // ../agent-skill-config/src/templates.ts
12254
- import { readFile as readFile2, stat } from "node:fs/promises";
12286
+ import { readFile as readFile3, stat } from "node:fs/promises";
12255
12287
  import path9 from "node:path";
12256
12288
  import { fileURLToPath as fileURLToPath3 } from "node:url";
12257
12289
 
@@ -14375,7 +14407,7 @@ function sleep2(ms) {
14375
14407
  // src/cli.ts
14376
14408
  configureTheme({ brand: "green", label: "Terminal Pilot" });
14377
14409
  function getBundledPackageVersion() {
14378
- return true ? "0.0.42" : void 0;
14410
+ return true ? "0.0.43" : void 0;
14379
14411
  }
14380
14412
  function normalizeArgv(argv) {
14381
14413
  if (argv.includes("--json") && !argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {