terminal-pilot 0.0.46 → 0.0.48

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 (56) hide show
  1. package/dist/cli.d.ts +5 -0
  2. package/dist/cli.js +179 -28
  3. package/dist/cli.js.map +4 -4
  4. package/dist/commands/close-session.js.map +1 -1
  5. package/dist/commands/create-session.js.map +1 -1
  6. package/dist/commands/daemon-runtime.js.map +1 -1
  7. package/dist/commands/fill.js.map +1 -1
  8. package/dist/commands/get-session.js.map +1 -1
  9. package/dist/commands/index.js +17 -0
  10. package/dist/commands/index.js.map +3 -3
  11. package/dist/commands/install.js +17 -0
  12. package/dist/commands/install.js.map +3 -3
  13. package/dist/commands/installer.js +17 -0
  14. package/dist/commands/installer.js.map +3 -3
  15. package/dist/commands/list-sessions.js.map +1 -1
  16. package/dist/commands/press-key.js.map +1 -1
  17. package/dist/commands/read-history.js.map +1 -1
  18. package/dist/commands/read-screen.js.map +1 -1
  19. package/dist/commands/resize.js.map +1 -1
  20. package/dist/commands/runtime.js.map +1 -1
  21. package/dist/commands/screenshot.js.map +1 -1
  22. package/dist/commands/send-signal.js.map +1 -1
  23. package/dist/commands/type.js.map +1 -1
  24. package/dist/commands/uninstall.js +17 -0
  25. package/dist/commands/uninstall.js.map +3 -3
  26. package/dist/commands/wait-for-exit.js.map +1 -1
  27. package/dist/commands/wait-for.js.map +1 -1
  28. package/dist/composition.json +1 -1
  29. package/dist/testing/cli-repl.js +177 -27
  30. package/dist/testing/cli-repl.js.map +4 -4
  31. package/dist/testing/qa-cli.js +177 -27
  32. package/dist/testing/qa-cli.js.map +4 -4
  33. package/node_modules/@poe-code/agent-defs/README.md +1 -1
  34. package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +1 -0
  35. package/node_modules/@poe-code/agent-defs/dist/agents/index.js +1 -0
  36. package/node_modules/@poe-code/agent-defs/dist/agents/pi.d.ts +2 -0
  37. package/node_modules/@poe-code/agent-defs/dist/agents/pi.js +14 -0
  38. package/node_modules/@poe-code/agent-defs/dist/index.d.ts +1 -1
  39. package/node_modules/@poe-code/agent-defs/dist/index.js +1 -1
  40. package/node_modules/@poe-code/agent-defs/dist/registry.js +2 -1
  41. package/node_modules/@poe-code/agent-defs/dist/types.d.ts +1 -1
  42. package/node_modules/@poe-code/agent-defs/package.json +0 -2
  43. package/node_modules/@poe-code/agent-skill-config/package.json +0 -2
  44. package/node_modules/@poe-code/config-mutations/package.json +0 -2
  45. package/node_modules/@poe-code/frontmatter/package.json +0 -2
  46. package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +1 -1
  47. package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +2 -0
  48. package/node_modules/toolcraft-design/dist/components/help-formatter.js +1 -1
  49. package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +1 -0
  50. package/node_modules/toolcraft-design/dist/explorer/actions.js +1 -0
  51. package/node_modules/toolcraft-design/dist/explorer/reducer.js +1 -0
  52. package/node_modules/toolcraft-design/dist/explorer/runtime.js +21 -2
  53. package/node_modules/toolcraft-design/dist/explorer/state.d.ts +6 -0
  54. package/node_modules/toolcraft-design/dist/explorer/state.js +9 -6
  55. package/node_modules/toolcraft-design/package.json +0 -2
  56. package/package.json +3 -3
@@ -1719,7 +1719,7 @@ function formatColumns(opts) {
1719
1719
  function formatCommandList(commands) {
1720
1720
  return formatColumns({
1721
1721
  rows: commands.map((cmd) => ({
1722
- left: text.command(cmd.name),
1722
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${text.command(cmd.name)}`,
1723
1723
  right: cmd.description
1724
1724
  }))
1725
1725
  });
@@ -1856,7 +1856,7 @@ function formatColumns2(opts) {
1856
1856
  function formatCommandList2(commands) {
1857
1857
  return formatColumns2({
1858
1858
  rows: commands.map((cmd) => ({
1859
- left: cmd.name,
1859
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${cmd.name}`,
1860
1860
  right: cmd.description
1861
1861
  }))
1862
1862
  });
@@ -4820,6 +4820,41 @@ async function writeErrorReport(context) {
4820
4820
  };
4821
4821
  }
4822
4822
 
4823
+ // ../toolcraft/src/human-in-loop/wiring.ts
4824
+ var WIRING_HINT = 'pass { humanInLoop: createHumanInLoop({ provider, ... }) } from "toolcraft/human-in-loop"';
4825
+ function assertHumanInLoopWired(root, humanInLoop) {
4826
+ if (humanInLoop !== void 0) {
4827
+ return;
4828
+ }
4829
+ const commandPath = findHumanInLoopCommandPath(root, []);
4830
+ if (commandPath !== void 0) {
4831
+ throw new UserError(
4832
+ `command '${commandPath}' declares humanInLoop but no runtime is wired \u2014 ${WIRING_HINT}`
4833
+ );
4834
+ }
4835
+ }
4836
+ function mergeApprovalsRoot(root, options) {
4837
+ if (options.approvals !== true) {
4838
+ return root;
4839
+ }
4840
+ if (options.humanInLoop === void 0) {
4841
+ throw new UserError(`approvals: true requires a wired humanInLoop runtime \u2014 ${WIRING_HINT}`);
4842
+ }
4843
+ return options.humanInLoop.mergeApprovalsGroup(root);
4844
+ }
4845
+ function findHumanInLoopCommandPath(node, path18) {
4846
+ if (node.kind === "command") {
4847
+ return node.humanInLoop ? path18.join(".") || node.name : void 0;
4848
+ }
4849
+ for (const child of node.children) {
4850
+ const found = findHumanInLoopCommandPath(child, [...path18, child.name]);
4851
+ if (found !== void 0) {
4852
+ return found;
4853
+ }
4854
+ }
4855
+ return void 0;
4856
+ }
4857
+
4823
4858
  // ../toolcraft/src/number-schema.ts
4824
4859
  function isValidNumberSchemaValue(value, schema) {
4825
4860
  return typeof value === "number" && Number.isFinite(value) && (schema.jsonType !== "integer" || Number.isInteger(value)) && (schema.minimum === void 0 || value >= schema.minimum) && (schema.maximum === void 0 || value <= schema.maximum);
@@ -5468,8 +5503,6 @@ function validateServices(services) {
5468
5503
  configureTheme({ brand: "blue", label: "Toolcraft" });
5469
5504
  var NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
5470
5505
  var optionalModulePaths = {
5471
- approvals: "./human-in-loop/approvals-commands.js",
5472
- humanInLoop: "./human-in-loop/gate.js",
5473
5506
  mcpProxy: "./mcp-proxy.js"
5474
5507
  };
5475
5508
  function importOptionalModule(specifier) {
@@ -6112,6 +6145,7 @@ function resolveCLIControls(controls) {
6112
6145
  validateOutputFormats(outputFormats);
6113
6146
  return {
6114
6147
  debug: controls?.debug === true,
6148
+ help: controls?.help === "concise" ? "concise" : "extended",
6115
6149
  logLevel: controls?.logLevel === true,
6116
6150
  output: controls?.output === true || typeof controls?.output === "object",
6117
6151
  outputFormats,
@@ -6608,11 +6642,31 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
6608
6642
  const name = parameterTokens.length === 0 ? baseName : `${baseName} ${parameterTokens.join(" ")}`;
6609
6643
  return name;
6610
6644
  }
6611
- function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
6612
- return getHelpChildren(group, scope).map((child) => ({
6613
- name: formatCommandRowName(child, casing, globalLongOptionFlags),
6614
- description: child.description ?? ""
6615
- }));
6645
+ function formatCommandRows(group, scope, casing, globalLongOptionFlags, help) {
6646
+ if (help === "concise") {
6647
+ return getHelpChildren(group, scope).map((child) => ({
6648
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6649
+ description: child.description ?? "",
6650
+ kind: child.kind,
6651
+ depth: 0
6652
+ }));
6653
+ }
6654
+ const rows = [];
6655
+ const visit = (node, depth) => {
6656
+ for (const child of getHelpChildren(node, scope)) {
6657
+ rows.push({
6658
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6659
+ description: child.description ?? "",
6660
+ kind: child.kind,
6661
+ depth
6662
+ });
6663
+ if (child.kind === "group") {
6664
+ visit(child, depth + 1);
6665
+ }
6666
+ }
6667
+ };
6668
+ visit(group, 0);
6669
+ return rows;
6616
6670
  }
6617
6671
  function formatGlobalOptionsLine(ctx) {
6618
6672
  const flags = [];
@@ -6700,7 +6754,13 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
6700
6754
  globalOptions.showVersion,
6701
6755
  globalOptions.controls
6702
6756
  );
6703
- const commandRows = formatCommandRows(group, scope, casing, globalLongOptionFlags);
6757
+ const commandRows = formatCommandRows(
6758
+ group,
6759
+ scope,
6760
+ casing,
6761
+ globalLongOptionFlags,
6762
+ globalOptions.controls.help
6763
+ );
6704
6764
  if (commandRows.length > 0) {
6705
6765
  sections.push(`${text.sectionHeader("Commands")}
6706
6766
  ${formatHelpCommandList(commandRows)}`);
@@ -6789,7 +6849,13 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6789
6849
  );
6790
6850
  const node = target.node;
6791
6851
  if (node.kind === "group") {
6792
- const commandRows = formatCommandRows(node, "cli", casing, globalLongOptionFlags);
6852
+ const commandRows = formatCommandRows(
6853
+ node,
6854
+ "cli",
6855
+ casing,
6856
+ globalLongOptionFlags,
6857
+ globalOptions.controls.help
6858
+ );
6793
6859
  const isRoot = node === root;
6794
6860
  return `${JSON.stringify(
6795
6861
  {
@@ -6803,7 +6869,12 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6803
6869
  formatGroupUsageSuffix(node, "cli", casing, globalLongOptionFlags)
6804
6870
  ),
6805
6871
  ...node.description === void 0 ? {} : { description: node.description },
6806
- commands: commandRows.map((row) => ({ name: row.name, description: row.description })),
6872
+ commands: commandRows.map((row) => ({
6873
+ name: row.name,
6874
+ description: row.description,
6875
+ kind: row.kind,
6876
+ depth: row.depth
6877
+ })),
6807
6878
  options: isRoot ? collectSchemaGlobalFieldRows(node, "cli", casing, globalLongOptionFlags).map((row) => ({
6808
6879
  name: row.flags.split(/[ ,]+/)[0]?.replace(/^--/, "") ?? row.flags,
6809
6880
  flags: row.flags.split(", "),
@@ -8537,7 +8608,7 @@ function getResolvedFlags(command) {
8537
8608
  const flags = command.optsWithGlobals();
8538
8609
  return flags;
8539
8610
  }
8540
- async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8611
+ async function executeCommand(state, services, requirementOptions, runtimeFetch, humanInLoop, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8541
8612
  const logger2 = createLogger(outputEmitter);
8542
8613
  const optionValues = state.actionCommand.optsWithGlobals();
8543
8614
  const resolvedFlags = optionValues;
@@ -8688,9 +8759,7 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
8688
8759
  throw new UserError("Operation cancelled.");
8689
8760
  }
8690
8761
  }
8691
- const result = state.command.humanInLoop ? await (await importOptionalModule(
8692
- optionalModulePaths.humanInLoop
8693
- )).invokeWithHumanInLoop(state.command, context, runtimeOptions, state.commandPath) : await state.command.handler(context);
8762
+ const result = state.command.humanInLoop && humanInLoop !== void 0 ? await humanInLoop.invoke(state.command, context, state.commandPath) : await state.command.handler(context);
8694
8763
  if (output === "rich" && runtime.isFixture) {
8695
8764
  writeRichHeader(`${state.command.name} (fixture)`);
8696
8765
  }
@@ -9276,20 +9345,19 @@ async function runCLI(roots, options = {}) {
9276
9345
  let errorReportContext;
9277
9346
  try {
9278
9347
  const normalizedRoot = normalizeRoots(roots, argv);
9279
- const root = options.approvals === true ? (await importOptionalModule(
9280
- optionalModulePaths.approvals
9281
- )).mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
9348
+ const root = mergeApprovalsRoot(normalizedRoot, options);
9349
+ assertHumanInLoopWired(root, options.humanInLoop);
9282
9350
  if (hasMcpProxyConfig(root)) {
9283
9351
  await (await importOptionalModule(optionalModulePaths.mcpProxy)).resolveMcpProxies(root, { projectRoot: options.projectRoot });
9284
9352
  }
9285
9353
  const casing = options.casing ?? "kebab";
9286
9354
  const services = options.services ?? {};
9287
- const runtimeOptions = options.humanInLoop ?? {};
9355
+ const humanInLoop = options.humanInLoop;
9288
9356
  const runtimeFetch = options.fetch ?? globalThis.fetch;
9289
9357
  version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
9290
9358
  const servicesWithBuiltIns = {
9291
9359
  ...services,
9292
- runtimeOptions,
9360
+ humanInLoop,
9293
9361
  root
9294
9362
  };
9295
9363
  const requirementOptions = {
@@ -9335,7 +9403,7 @@ async function runCLI(roots, options = {}) {
9335
9403
  servicesWithBuiltIns,
9336
9404
  requirementOptions,
9337
9405
  runtimeFetch,
9338
- runtimeOptions,
9406
+ humanInLoop,
9339
9407
  options.env,
9340
9408
  options.fs,
9341
9409
  options.outputEmitter,
@@ -11160,6 +11228,22 @@ var gooseAgent = {
11160
11228
  }
11161
11229
  };
11162
11230
 
11231
+ // ../agent-defs/src/agents/pi.ts
11232
+ var piAgent = {
11233
+ id: "pi",
11234
+ name: "pi",
11235
+ aliases: ["pi-agent"],
11236
+ label: "Pi",
11237
+ summary: "Pi coding agent (spawn-only; uses local Pi auth/settings).",
11238
+ binaryName: "pi",
11239
+ branding: {
11240
+ colors: {
11241
+ dark: "#F2F2F2",
11242
+ light: "#242424"
11243
+ }
11244
+ }
11245
+ };
11246
+
11163
11247
  // ../agent-defs/src/agents/poe-agent.ts
11164
11248
  var poeAgentAgent = {
11165
11249
  id: "poe-agent",
@@ -11203,6 +11287,7 @@ var allAgents = Object.freeze([
11203
11287
  freezeAgent(openCodeAgent),
11204
11288
  freezeAgent(kimiAgent),
11205
11289
  freezeAgent(gooseAgent),
11290
+ freezeAgent(piAgent),
11206
11291
  freezeAgent(poeAgentAgent)
11207
11292
  ]);
11208
11293
  var lookup2 = /* @__PURE__ */ new Map();
@@ -14750,13 +14835,78 @@ function sleep2(ms) {
14750
14835
  // src/cli.ts
14751
14836
  configureTheme({ brand: "green", label: "Terminal Pilot" });
14752
14837
  function getBundledPackageVersion() {
14753
- return true ? "0.0.46" : void 0;
14754
- }
14838
+ return true ? "0.0.48" : void 0;
14839
+ }
14840
+ var pilotOptionsWithValues = /* @__PURE__ */ new Set([
14841
+ "--session",
14842
+ "-s",
14843
+ "--cwd",
14844
+ "--cols",
14845
+ "--rows",
14846
+ "--timeout",
14847
+ "-t",
14848
+ "--last",
14849
+ "-n",
14850
+ "--output",
14851
+ "-o",
14852
+ "--scope",
14853
+ "--padding",
14854
+ "-p",
14855
+ "--log-level",
14856
+ "--preset",
14857
+ "--signal"
14858
+ ]);
14755
14859
  function normalizeArgv(argv) {
14756
- if (argv.includes("--json") && !argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14757
- return argv.flatMap((argument) => argument === "--json" ? ["--output", "json"] : [argument]);
14860
+ if (!argv.includes("--json")) {
14861
+ return argv;
14862
+ }
14863
+ if (argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14864
+ return argv;
14865
+ }
14866
+ const normalized = [];
14867
+ let index = 0;
14868
+ let bareTokenCount = 0;
14869
+ let expectOptionValue = false;
14870
+ while (index < argv.length) {
14871
+ const token = argv[index];
14872
+ if (index < 2) {
14873
+ normalized.push(token);
14874
+ index += 1;
14875
+ continue;
14876
+ }
14877
+ if (token === "--") {
14878
+ normalized.push(token, ...argv.slice(index + 1));
14879
+ break;
14880
+ }
14881
+ if (expectOptionValue) {
14882
+ normalized.push(token);
14883
+ expectOptionValue = false;
14884
+ index += 1;
14885
+ continue;
14886
+ }
14887
+ if (token === "--json") {
14888
+ normalized.push("--output", "json");
14889
+ index += 1;
14890
+ continue;
14891
+ }
14892
+ if (token.startsWith("-") && token !== "-") {
14893
+ normalized.push(token);
14894
+ const optionName = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
14895
+ if (!token.includes("=") && (pilotOptionsWithValues.has(optionName) || optionName === "--debug" && argv[index + 1] !== void 0 && !argv[index + 1].startsWith("-"))) {
14896
+ expectOptionValue = true;
14897
+ }
14898
+ index += 1;
14899
+ continue;
14900
+ }
14901
+ bareTokenCount += 1;
14902
+ if (bareTokenCount >= 2) {
14903
+ normalized.push(...argv.slice(index));
14904
+ break;
14905
+ }
14906
+ normalized.push(token);
14907
+ index += 1;
14758
14908
  }
14759
- return argv;
14909
+ return normalized;
14760
14910
  }
14761
14911
  async function main(argv = process.argv, options = {}) {
14762
14912
  if (isTerminalPilotDaemonArgv(argv)) {