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
package/dist/cli.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import type { TerminalPilotRuntime } from "./commands/runtime.js";
3
+ /**
4
+ * Rewrite pilot-level `--json` to toolcraft's `--output json`.
5
+ * Stop once create-session (and similar) child argv begins so nested tools keep their own `--json`.
6
+ */
7
+ export declare function normalizeArgv(argv: string[]): string[];
3
8
  export declare function main(argv?: string[], options?: {
4
9
  terminalPilotRuntime?: TerminalPilotRuntime;
5
10
  packageVersion?: string;
package/dist/cli.js CHANGED
@@ -1636,7 +1636,7 @@ function formatColumns(opts) {
1636
1636
  function formatCommandList(commands) {
1637
1637
  return formatColumns({
1638
1638
  rows: commands.map((cmd) => ({
1639
- left: text.command(cmd.name),
1639
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${text.command(cmd.name)}`,
1640
1640
  right: cmd.description
1641
1641
  }))
1642
1642
  });
@@ -1773,7 +1773,7 @@ function formatColumns2(opts) {
1773
1773
  function formatCommandList2(commands) {
1774
1774
  return formatColumns2({
1775
1775
  rows: commands.map((cmd) => ({
1776
- left: cmd.name,
1776
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${cmd.name}`,
1777
1777
  right: cmd.description
1778
1778
  }))
1779
1779
  });
@@ -4737,6 +4737,41 @@ async function writeErrorReport(context) {
4737
4737
  };
4738
4738
  }
4739
4739
 
4740
+ // ../toolcraft/src/human-in-loop/wiring.ts
4741
+ var WIRING_HINT = 'pass { humanInLoop: createHumanInLoop({ provider, ... }) } from "toolcraft/human-in-loop"';
4742
+ function assertHumanInLoopWired(root, humanInLoop) {
4743
+ if (humanInLoop !== void 0) {
4744
+ return;
4745
+ }
4746
+ const commandPath = findHumanInLoopCommandPath(root, []);
4747
+ if (commandPath !== void 0) {
4748
+ throw new UserError(
4749
+ `command '${commandPath}' declares humanInLoop but no runtime is wired \u2014 ${WIRING_HINT}`
4750
+ );
4751
+ }
4752
+ }
4753
+ function mergeApprovalsRoot(root, options) {
4754
+ if (options.approvals !== true) {
4755
+ return root;
4756
+ }
4757
+ if (options.humanInLoop === void 0) {
4758
+ throw new UserError(`approvals: true requires a wired humanInLoop runtime \u2014 ${WIRING_HINT}`);
4759
+ }
4760
+ return options.humanInLoop.mergeApprovalsGroup(root);
4761
+ }
4762
+ function findHumanInLoopCommandPath(node, path16) {
4763
+ if (node.kind === "command") {
4764
+ return node.humanInLoop ? path16.join(".") || node.name : void 0;
4765
+ }
4766
+ for (const child of node.children) {
4767
+ const found = findHumanInLoopCommandPath(child, [...path16, child.name]);
4768
+ if (found !== void 0) {
4769
+ return found;
4770
+ }
4771
+ }
4772
+ return void 0;
4773
+ }
4774
+
4740
4775
  // ../toolcraft/src/number-schema.ts
4741
4776
  function isValidNumberSchemaValue(value, schema) {
4742
4777
  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);
@@ -5385,8 +5420,6 @@ function validateServices(services) {
5385
5420
  configureTheme({ brand: "blue", label: "Toolcraft" });
5386
5421
  var NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
5387
5422
  var optionalModulePaths = {
5388
- approvals: "./human-in-loop/approvals-commands.js",
5389
- humanInLoop: "./human-in-loop/gate.js",
5390
5423
  mcpProxy: "./mcp-proxy.js"
5391
5424
  };
5392
5425
  function importOptionalModule(specifier) {
@@ -6029,6 +6062,7 @@ function resolveCLIControls(controls) {
6029
6062
  validateOutputFormats(outputFormats);
6030
6063
  return {
6031
6064
  debug: controls?.debug === true,
6065
+ help: controls?.help === "concise" ? "concise" : "extended",
6032
6066
  logLevel: controls?.logLevel === true,
6033
6067
  output: controls?.output === true || typeof controls?.output === "object",
6034
6068
  outputFormats,
@@ -6525,11 +6559,31 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
6525
6559
  const name = parameterTokens.length === 0 ? baseName : `${baseName} ${parameterTokens.join(" ")}`;
6526
6560
  return name;
6527
6561
  }
6528
- function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
6529
- return getHelpChildren(group, scope).map((child) => ({
6530
- name: formatCommandRowName(child, casing, globalLongOptionFlags),
6531
- description: child.description ?? ""
6532
- }));
6562
+ function formatCommandRows(group, scope, casing, globalLongOptionFlags, help) {
6563
+ if (help === "concise") {
6564
+ return getHelpChildren(group, scope).map((child) => ({
6565
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6566
+ description: child.description ?? "",
6567
+ kind: child.kind,
6568
+ depth: 0
6569
+ }));
6570
+ }
6571
+ const rows = [];
6572
+ const visit = (node, depth) => {
6573
+ for (const child of getHelpChildren(node, scope)) {
6574
+ rows.push({
6575
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6576
+ description: child.description ?? "",
6577
+ kind: child.kind,
6578
+ depth
6579
+ });
6580
+ if (child.kind === "group") {
6581
+ visit(child, depth + 1);
6582
+ }
6583
+ }
6584
+ };
6585
+ visit(group, 0);
6586
+ return rows;
6533
6587
  }
6534
6588
  function formatGlobalOptionsLine(ctx) {
6535
6589
  const flags = [];
@@ -6617,7 +6671,13 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
6617
6671
  globalOptions.showVersion,
6618
6672
  globalOptions.controls
6619
6673
  );
6620
- const commandRows = formatCommandRows(group, scope, casing, globalLongOptionFlags);
6674
+ const commandRows = formatCommandRows(
6675
+ group,
6676
+ scope,
6677
+ casing,
6678
+ globalLongOptionFlags,
6679
+ globalOptions.controls.help
6680
+ );
6621
6681
  if (commandRows.length > 0) {
6622
6682
  sections.push(`${text.sectionHeader("Commands")}
6623
6683
  ${formatHelpCommandList(commandRows)}`);
@@ -6706,7 +6766,13 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6706
6766
  );
6707
6767
  const node = target.node;
6708
6768
  if (node.kind === "group") {
6709
- const commandRows = formatCommandRows(node, "cli", casing, globalLongOptionFlags);
6769
+ const commandRows = formatCommandRows(
6770
+ node,
6771
+ "cli",
6772
+ casing,
6773
+ globalLongOptionFlags,
6774
+ globalOptions.controls.help
6775
+ );
6710
6776
  const isRoot = node === root;
6711
6777
  return `${JSON.stringify(
6712
6778
  {
@@ -6720,7 +6786,12 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6720
6786
  formatGroupUsageSuffix(node, "cli", casing, globalLongOptionFlags)
6721
6787
  ),
6722
6788
  ...node.description === void 0 ? {} : { description: node.description },
6723
- commands: commandRows.map((row) => ({ name: row.name, description: row.description })),
6789
+ commands: commandRows.map((row) => ({
6790
+ name: row.name,
6791
+ description: row.description,
6792
+ kind: row.kind,
6793
+ depth: row.depth
6794
+ })),
6724
6795
  options: isRoot ? collectSchemaGlobalFieldRows(node, "cli", casing, globalLongOptionFlags).map((row) => ({
6725
6796
  name: row.flags.split(/[ ,]+/)[0]?.replace(/^--/, "") ?? row.flags,
6726
6797
  flags: row.flags.split(", "),
@@ -8454,7 +8525,7 @@ function getResolvedFlags(command) {
8454
8525
  const flags = command.optsWithGlobals();
8455
8526
  return flags;
8456
8527
  }
8457
- async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8528
+ async function executeCommand(state, services, requirementOptions, runtimeFetch, humanInLoop, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8458
8529
  const logger2 = createLogger(outputEmitter);
8459
8530
  const optionValues = state.actionCommand.optsWithGlobals();
8460
8531
  const resolvedFlags = optionValues;
@@ -8605,9 +8676,7 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
8605
8676
  throw new UserError("Operation cancelled.");
8606
8677
  }
8607
8678
  }
8608
- const result = state.command.humanInLoop ? await (await importOptionalModule(
8609
- optionalModulePaths.humanInLoop
8610
- )).invokeWithHumanInLoop(state.command, context, runtimeOptions, state.commandPath) : await state.command.handler(context);
8679
+ const result = state.command.humanInLoop && humanInLoop !== void 0 ? await humanInLoop.invoke(state.command, context, state.commandPath) : await state.command.handler(context);
8611
8680
  if (output === "rich" && runtime.isFixture) {
8612
8681
  writeRichHeader(`${state.command.name} (fixture)`);
8613
8682
  }
@@ -9193,20 +9262,19 @@ async function runCLI(roots, options = {}) {
9193
9262
  let errorReportContext;
9194
9263
  try {
9195
9264
  const normalizedRoot = normalizeRoots(roots, argv);
9196
- const root = options.approvals === true ? (await importOptionalModule(
9197
- optionalModulePaths.approvals
9198
- )).mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
9265
+ const root = mergeApprovalsRoot(normalizedRoot, options);
9266
+ assertHumanInLoopWired(root, options.humanInLoop);
9199
9267
  if (hasMcpProxyConfig(root)) {
9200
9268
  await (await importOptionalModule(optionalModulePaths.mcpProxy)).resolveMcpProxies(root, { projectRoot: options.projectRoot });
9201
9269
  }
9202
9270
  const casing = options.casing ?? "kebab";
9203
9271
  const services = options.services ?? {};
9204
- const runtimeOptions = options.humanInLoop ?? {};
9272
+ const humanInLoop = options.humanInLoop;
9205
9273
  const runtimeFetch = options.fetch ?? globalThis.fetch;
9206
9274
  version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
9207
9275
  const servicesWithBuiltIns = {
9208
9276
  ...services,
9209
- runtimeOptions,
9277
+ humanInLoop,
9210
9278
  root
9211
9279
  };
9212
9280
  const requirementOptions = {
@@ -9252,7 +9320,7 @@ async function runCLI(roots, options = {}) {
9252
9320
  servicesWithBuiltIns,
9253
9321
  requirementOptions,
9254
9322
  runtimeFetch,
9255
- runtimeOptions,
9323
+ humanInLoop,
9256
9324
  options.env,
9257
9325
  options.fs,
9258
9326
  options.outputEmitter,
@@ -11150,6 +11218,22 @@ var gooseAgent = {
11150
11218
  }
11151
11219
  };
11152
11220
 
11221
+ // ../agent-defs/src/agents/pi.ts
11222
+ var piAgent = {
11223
+ id: "pi",
11224
+ name: "pi",
11225
+ aliases: ["pi-agent"],
11226
+ label: "Pi",
11227
+ summary: "Pi coding agent (spawn-only; uses local Pi auth/settings).",
11228
+ binaryName: "pi",
11229
+ branding: {
11230
+ colors: {
11231
+ dark: "#F2F2F2",
11232
+ light: "#242424"
11233
+ }
11234
+ }
11235
+ };
11236
+
11153
11237
  // ../agent-defs/src/agents/poe-agent.ts
11154
11238
  var poeAgentAgent = {
11155
11239
  id: "poe-agent",
@@ -11193,6 +11277,7 @@ var allAgents = Object.freeze([
11193
11277
  freezeAgent(openCodeAgent),
11194
11278
  freezeAgent(kimiAgent),
11195
11279
  freezeAgent(gooseAgent),
11280
+ freezeAgent(piAgent),
11196
11281
  freezeAgent(poeAgentAgent)
11197
11282
  ]);
11198
11283
  var lookup2 = /* @__PURE__ */ new Map();
@@ -14740,13 +14825,78 @@ function sleep2(ms) {
14740
14825
  // src/cli.ts
14741
14826
  configureTheme({ brand: "green", label: "Terminal Pilot" });
14742
14827
  function getBundledPackageVersion() {
14743
- return true ? "0.0.46" : void 0;
14744
- }
14828
+ return true ? "0.0.48" : void 0;
14829
+ }
14830
+ var pilotOptionsWithValues = /* @__PURE__ */ new Set([
14831
+ "--session",
14832
+ "-s",
14833
+ "--cwd",
14834
+ "--cols",
14835
+ "--rows",
14836
+ "--timeout",
14837
+ "-t",
14838
+ "--last",
14839
+ "-n",
14840
+ "--output",
14841
+ "-o",
14842
+ "--scope",
14843
+ "--padding",
14844
+ "-p",
14845
+ "--log-level",
14846
+ "--preset",
14847
+ "--signal"
14848
+ ]);
14745
14849
  function normalizeArgv(argv) {
14746
- if (argv.includes("--json") && !argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14747
- return argv.flatMap((argument) => argument === "--json" ? ["--output", "json"] : [argument]);
14850
+ if (!argv.includes("--json")) {
14851
+ return argv;
14852
+ }
14853
+ if (argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14854
+ return argv;
14855
+ }
14856
+ const normalized = [];
14857
+ let index = 0;
14858
+ let bareTokenCount = 0;
14859
+ let expectOptionValue = false;
14860
+ while (index < argv.length) {
14861
+ const token = argv[index];
14862
+ if (index < 2) {
14863
+ normalized.push(token);
14864
+ index += 1;
14865
+ continue;
14866
+ }
14867
+ if (token === "--") {
14868
+ normalized.push(token, ...argv.slice(index + 1));
14869
+ break;
14870
+ }
14871
+ if (expectOptionValue) {
14872
+ normalized.push(token);
14873
+ expectOptionValue = false;
14874
+ index += 1;
14875
+ continue;
14876
+ }
14877
+ if (token === "--json") {
14878
+ normalized.push("--output", "json");
14879
+ index += 1;
14880
+ continue;
14881
+ }
14882
+ if (token.startsWith("-") && token !== "-") {
14883
+ normalized.push(token);
14884
+ const optionName = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
14885
+ if (!token.includes("=") && (pilotOptionsWithValues.has(optionName) || optionName === "--debug" && argv[index + 1] !== void 0 && !argv[index + 1].startsWith("-"))) {
14886
+ expectOptionValue = true;
14887
+ }
14888
+ index += 1;
14889
+ continue;
14890
+ }
14891
+ bareTokenCount += 1;
14892
+ if (bareTokenCount >= 2) {
14893
+ normalized.push(...argv.slice(index));
14894
+ break;
14895
+ }
14896
+ normalized.push(token);
14897
+ index += 1;
14748
14898
  }
14749
- return argv;
14899
+ return normalized;
14750
14900
  }
14751
14901
  async function main(argv = process.argv, options = {}) {
14752
14902
  if (isTerminalPilotDaemonArgv(argv)) {
@@ -14793,6 +14943,7 @@ if (await isDirectExecution(process.argv)) {
14793
14943
  await main();
14794
14944
  }
14795
14945
  export {
14796
- main
14946
+ main,
14947
+ normalizeArgv
14797
14948
  };
14798
14949
  //# sourceMappingURL=cli.js.map