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
@@ -53,7 +53,7 @@
53
53
  },
54
54
  {
55
55
  "name": "terminal-pilot",
56
- "version": "0.0.46",
56
+ "version": "0.0.48",
57
57
  "license": "MIT"
58
58
  },
59
59
  {
@@ -1712,7 +1712,7 @@ function formatColumns(opts) {
1712
1712
  function formatCommandList(commands) {
1713
1713
  return formatColumns({
1714
1714
  rows: commands.map((cmd) => ({
1715
- left: text.command(cmd.name),
1715
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${text.command(cmd.name)}`,
1716
1716
  right: cmd.description
1717
1717
  }))
1718
1718
  });
@@ -1849,7 +1849,7 @@ function formatColumns2(opts) {
1849
1849
  function formatCommandList2(commands) {
1850
1850
  return formatColumns2({
1851
1851
  rows: commands.map((cmd) => ({
1852
- left: cmd.name,
1852
+ left: `${" ".repeat((cmd.depth ?? 0) * 2)}${cmd.name}`,
1853
1853
  right: cmd.description
1854
1854
  }))
1855
1855
  });
@@ -4813,6 +4813,41 @@ async function writeErrorReport(context) {
4813
4813
  };
4814
4814
  }
4815
4815
 
4816
+ // ../toolcraft/src/human-in-loop/wiring.ts
4817
+ var WIRING_HINT = 'pass { humanInLoop: createHumanInLoop({ provider, ... }) } from "toolcraft/human-in-loop"';
4818
+ function assertHumanInLoopWired(root, humanInLoop) {
4819
+ if (humanInLoop !== void 0) {
4820
+ return;
4821
+ }
4822
+ const commandPath = findHumanInLoopCommandPath(root, []);
4823
+ if (commandPath !== void 0) {
4824
+ throw new UserError(
4825
+ `command '${commandPath}' declares humanInLoop but no runtime is wired \u2014 ${WIRING_HINT}`
4826
+ );
4827
+ }
4828
+ }
4829
+ function mergeApprovalsRoot(root, options) {
4830
+ if (options.approvals !== true) {
4831
+ return root;
4832
+ }
4833
+ if (options.humanInLoop === void 0) {
4834
+ throw new UserError(`approvals: true requires a wired humanInLoop runtime \u2014 ${WIRING_HINT}`);
4835
+ }
4836
+ return options.humanInLoop.mergeApprovalsGroup(root);
4837
+ }
4838
+ function findHumanInLoopCommandPath(node, path17) {
4839
+ if (node.kind === "command") {
4840
+ return node.humanInLoop ? path17.join(".") || node.name : void 0;
4841
+ }
4842
+ for (const child of node.children) {
4843
+ const found = findHumanInLoopCommandPath(child, [...path17, child.name]);
4844
+ if (found !== void 0) {
4845
+ return found;
4846
+ }
4847
+ }
4848
+ return void 0;
4849
+ }
4850
+
4816
4851
  // ../toolcraft/src/number-schema.ts
4817
4852
  function isValidNumberSchemaValue(value, schema) {
4818
4853
  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);
@@ -5461,8 +5496,6 @@ function validateServices(services) {
5461
5496
  configureTheme({ brand: "blue", label: "Toolcraft" });
5462
5497
  var NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
5463
5498
  var optionalModulePaths = {
5464
- approvals: "./human-in-loop/approvals-commands.js",
5465
- humanInLoop: "./human-in-loop/gate.js",
5466
5499
  mcpProxy: "./mcp-proxy.js"
5467
5500
  };
5468
5501
  function importOptionalModule(specifier) {
@@ -6105,6 +6138,7 @@ function resolveCLIControls(controls) {
6105
6138
  validateOutputFormats(outputFormats);
6106
6139
  return {
6107
6140
  debug: controls?.debug === true,
6141
+ help: controls?.help === "concise" ? "concise" : "extended",
6108
6142
  logLevel: controls?.logLevel === true,
6109
6143
  output: controls?.output === true || typeof controls?.output === "object",
6110
6144
  outputFormats,
@@ -6601,11 +6635,31 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
6601
6635
  const name = parameterTokens.length === 0 ? baseName : `${baseName} ${parameterTokens.join(" ")}`;
6602
6636
  return name;
6603
6637
  }
6604
- function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
6605
- return getHelpChildren(group, scope).map((child) => ({
6606
- name: formatCommandRowName(child, casing, globalLongOptionFlags),
6607
- description: child.description ?? ""
6608
- }));
6638
+ function formatCommandRows(group, scope, casing, globalLongOptionFlags, help) {
6639
+ if (help === "concise") {
6640
+ return getHelpChildren(group, scope).map((child) => ({
6641
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6642
+ description: child.description ?? "",
6643
+ kind: child.kind,
6644
+ depth: 0
6645
+ }));
6646
+ }
6647
+ const rows = [];
6648
+ const visit = (node, depth) => {
6649
+ for (const child of getHelpChildren(node, scope)) {
6650
+ rows.push({
6651
+ name: formatCommandRowName(child, casing, globalLongOptionFlags),
6652
+ description: child.description ?? "",
6653
+ kind: child.kind,
6654
+ depth
6655
+ });
6656
+ if (child.kind === "group") {
6657
+ visit(child, depth + 1);
6658
+ }
6659
+ }
6660
+ };
6661
+ visit(group, 0);
6662
+ return rows;
6609
6663
  }
6610
6664
  function formatGlobalOptionsLine(ctx) {
6611
6665
  const flags = [];
@@ -6693,7 +6747,13 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
6693
6747
  globalOptions.showVersion,
6694
6748
  globalOptions.controls
6695
6749
  );
6696
- const commandRows = formatCommandRows(group, scope, casing, globalLongOptionFlags);
6750
+ const commandRows = formatCommandRows(
6751
+ group,
6752
+ scope,
6753
+ casing,
6754
+ globalLongOptionFlags,
6755
+ globalOptions.controls.help
6756
+ );
6697
6757
  if (commandRows.length > 0) {
6698
6758
  sections.push(`${text.sectionHeader("Commands")}
6699
6759
  ${formatHelpCommandList(commandRows)}`);
@@ -6782,7 +6842,13 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6782
6842
  );
6783
6843
  const node = target.node;
6784
6844
  if (node.kind === "group") {
6785
- const commandRows = formatCommandRows(node, "cli", casing, globalLongOptionFlags);
6845
+ const commandRows = formatCommandRows(
6846
+ node,
6847
+ "cli",
6848
+ casing,
6849
+ globalLongOptionFlags,
6850
+ globalOptions.controls.help
6851
+ );
6786
6852
  const isRoot = node === root;
6787
6853
  return `${JSON.stringify(
6788
6854
  {
@@ -6796,7 +6862,12 @@ function renderJsonHelp(target, root, casing, globalOptions, rootUsageName) {
6796
6862
  formatGroupUsageSuffix(node, "cli", casing, globalLongOptionFlags)
6797
6863
  ),
6798
6864
  ...node.description === void 0 ? {} : { description: node.description },
6799
- commands: commandRows.map((row) => ({ name: row.name, description: row.description })),
6865
+ commands: commandRows.map((row) => ({
6866
+ name: row.name,
6867
+ description: row.description,
6868
+ kind: row.kind,
6869
+ depth: row.depth
6870
+ })),
6800
6871
  options: isRoot ? collectSchemaGlobalFieldRows(node, "cli", casing, globalLongOptionFlags).map((row) => ({
6801
6872
  name: row.flags.split(/[ ,]+/)[0]?.replace(/^--/, "") ?? row.flags,
6802
6873
  flags: row.flags.split(", "),
@@ -8530,7 +8601,7 @@ function getResolvedFlags(command) {
8530
8601
  const flags = command.optsWithGlobals();
8531
8602
  return flags;
8532
8603
  }
8533
- async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8604
+ async function executeCommand(state, services, requirementOptions, runtimeFetch, humanInLoop, runtimeEnv, runtimeFs, outputEmitter, outputFormats, promptStreams, diagnosticsOptions, onErrorReportContext) {
8534
8605
  const logger2 = createLogger(outputEmitter);
8535
8606
  const optionValues = state.actionCommand.optsWithGlobals();
8536
8607
  const resolvedFlags = optionValues;
@@ -8681,9 +8752,7 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
8681
8752
  throw new UserError("Operation cancelled.");
8682
8753
  }
8683
8754
  }
8684
- const result = state.command.humanInLoop ? await (await importOptionalModule(
8685
- optionalModulePaths.humanInLoop
8686
- )).invokeWithHumanInLoop(state.command, context, runtimeOptions, state.commandPath) : await state.command.handler(context);
8755
+ const result = state.command.humanInLoop && humanInLoop !== void 0 ? await humanInLoop.invoke(state.command, context, state.commandPath) : await state.command.handler(context);
8687
8756
  if (output === "rich" && runtime.isFixture) {
8688
8757
  writeRichHeader(`${state.command.name} (fixture)`);
8689
8758
  }
@@ -9269,20 +9338,19 @@ async function runCLI(roots, options = {}) {
9269
9338
  let errorReportContext;
9270
9339
  try {
9271
9340
  const normalizedRoot = normalizeRoots(roots, argv);
9272
- const root = options.approvals === true ? (await importOptionalModule(
9273
- optionalModulePaths.approvals
9274
- )).mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
9341
+ const root = mergeApprovalsRoot(normalizedRoot, options);
9342
+ assertHumanInLoopWired(root, options.humanInLoop);
9275
9343
  if (hasMcpProxyConfig(root)) {
9276
9344
  await (await importOptionalModule(optionalModulePaths.mcpProxy)).resolveMcpProxies(root, { projectRoot: options.projectRoot });
9277
9345
  }
9278
9346
  const casing = options.casing ?? "kebab";
9279
9347
  const services = options.services ?? {};
9280
- const runtimeOptions = options.humanInLoop ?? {};
9348
+ const humanInLoop = options.humanInLoop;
9281
9349
  const runtimeFetch = options.fetch ?? globalThis.fetch;
9282
9350
  version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
9283
9351
  const servicesWithBuiltIns = {
9284
9352
  ...services,
9285
- runtimeOptions,
9353
+ humanInLoop,
9286
9354
  root
9287
9355
  };
9288
9356
  const requirementOptions = {
@@ -9328,7 +9396,7 @@ async function runCLI(roots, options = {}) {
9328
9396
  servicesWithBuiltIns,
9329
9397
  requirementOptions,
9330
9398
  runtimeFetch,
9331
- runtimeOptions,
9399
+ humanInLoop,
9332
9400
  options.env,
9333
9401
  options.fs,
9334
9402
  options.outputEmitter,
@@ -11153,6 +11221,22 @@ var gooseAgent = {
11153
11221
  }
11154
11222
  };
11155
11223
 
11224
+ // ../agent-defs/src/agents/pi.ts
11225
+ var piAgent = {
11226
+ id: "pi",
11227
+ name: "pi",
11228
+ aliases: ["pi-agent"],
11229
+ label: "Pi",
11230
+ summary: "Pi coding agent (spawn-only; uses local Pi auth/settings).",
11231
+ binaryName: "pi",
11232
+ branding: {
11233
+ colors: {
11234
+ dark: "#F2F2F2",
11235
+ light: "#242424"
11236
+ }
11237
+ }
11238
+ };
11239
+
11156
11240
  // ../agent-defs/src/agents/poe-agent.ts
11157
11241
  var poeAgentAgent = {
11158
11242
  id: "poe-agent",
@@ -11196,6 +11280,7 @@ var allAgents = Object.freeze([
11196
11280
  freezeAgent(openCodeAgent),
11197
11281
  freezeAgent(kimiAgent),
11198
11282
  freezeAgent(gooseAgent),
11283
+ freezeAgent(piAgent),
11199
11284
  freezeAgent(poeAgentAgent)
11200
11285
  ]);
11201
11286
  var lookup2 = /* @__PURE__ */ new Map();
@@ -14743,13 +14828,78 @@ function sleep2(ms) {
14743
14828
  // src/cli.ts
14744
14829
  configureTheme({ brand: "green", label: "Terminal Pilot" });
14745
14830
  function getBundledPackageVersion() {
14746
- return true ? "0.0.46" : void 0;
14747
- }
14831
+ return true ? "0.0.48" : void 0;
14832
+ }
14833
+ var pilotOptionsWithValues = /* @__PURE__ */ new Set([
14834
+ "--session",
14835
+ "-s",
14836
+ "--cwd",
14837
+ "--cols",
14838
+ "--rows",
14839
+ "--timeout",
14840
+ "-t",
14841
+ "--last",
14842
+ "-n",
14843
+ "--output",
14844
+ "-o",
14845
+ "--scope",
14846
+ "--padding",
14847
+ "-p",
14848
+ "--log-level",
14849
+ "--preset",
14850
+ "--signal"
14851
+ ]);
14748
14852
  function normalizeArgv(argv) {
14749
- if (argv.includes("--json") && !argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14750
- return argv.flatMap((argument) => argument === "--json" ? ["--output", "json"] : [argument]);
14853
+ if (!argv.includes("--json")) {
14854
+ return argv;
14855
+ }
14856
+ if (argv.some((argument) => argument === "--output" || argument.startsWith("--output="))) {
14857
+ return argv;
14858
+ }
14859
+ const normalized = [];
14860
+ let index = 0;
14861
+ let bareTokenCount = 0;
14862
+ let expectOptionValue = false;
14863
+ while (index < argv.length) {
14864
+ const token = argv[index];
14865
+ if (index < 2) {
14866
+ normalized.push(token);
14867
+ index += 1;
14868
+ continue;
14869
+ }
14870
+ if (token === "--") {
14871
+ normalized.push(token, ...argv.slice(index + 1));
14872
+ break;
14873
+ }
14874
+ if (expectOptionValue) {
14875
+ normalized.push(token);
14876
+ expectOptionValue = false;
14877
+ index += 1;
14878
+ continue;
14879
+ }
14880
+ if (token === "--json") {
14881
+ normalized.push("--output", "json");
14882
+ index += 1;
14883
+ continue;
14884
+ }
14885
+ if (token.startsWith("-") && token !== "-") {
14886
+ normalized.push(token);
14887
+ const optionName = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
14888
+ if (!token.includes("=") && (pilotOptionsWithValues.has(optionName) || optionName === "--debug" && argv[index + 1] !== void 0 && !argv[index + 1].startsWith("-"))) {
14889
+ expectOptionValue = true;
14890
+ }
14891
+ index += 1;
14892
+ continue;
14893
+ }
14894
+ bareTokenCount += 1;
14895
+ if (bareTokenCount >= 2) {
14896
+ normalized.push(...argv.slice(index));
14897
+ break;
14898
+ }
14899
+ normalized.push(token);
14900
+ index += 1;
14751
14901
  }
14752
- return argv;
14902
+ return normalized;
14753
14903
  }
14754
14904
  async function main(argv = process.argv, options = {}) {
14755
14905
  if (isTerminalPilotDaemonArgv(argv)) {