@codexhost/cli-darwin-x64 0.9.2 → 0.10.0

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.
@@ -15282,10 +15282,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15282
15282
  invocation: commandInvocationSchema,
15283
15283
  label: commandLabelSchema,
15284
15284
  description: commandDescriptionSchema.optional(),
15285
- argumentMode: external_exports.enum(["none", "text"])
15285
+ argumentMode: external_exports.enum(["none", "text"]),
15286
+ /**
15287
+ * Native distinction reported by the Harness. Omitted when the Harness does
15288
+ * not tell skills and commands apart; consumers treat that as "command".
15289
+ */
15290
+ kind: external_exports.enum(["command", "skill"]).optional()
15286
15291
  }).strict();
15287
15292
  var harnessCommandCatalogSchema = external_exports.object({
15288
- commands: external_exports.array(harnessCommandDescriptorSchema)
15293
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15294
+ /**
15295
+ * `live` when the catalog includes what a native Session reports for its
15296
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15297
+ * Omitted by Adapters; set by the Host on inspection results.
15298
+ */
15299
+ source: external_exports.enum(["live", "static"]).optional()
15289
15300
  }).strict().superRefine((catalog, context) => {
15290
15301
  const ids = /* @__PURE__ */ new Set();
15291
15302
  for (const [index, command] of catalog.commands.entries()) {
@@ -15299,7 +15310,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15299
15310
  ids.add(command.id);
15300
15311
  }
15301
15312
  });
15302
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15313
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15314
+ harnessId: harnessIdSchema,
15315
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15316
+ cwd: external_exports.string().min(1).optional()
15317
+ }).strict();
15303
15318
  var threadCommandsInspectParamsSchema = external_exports.object({
15304
15319
  threadId: hostThreadIdSchema
15305
15320
  }).strict();
@@ -15287,10 +15287,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15287
15287
  invocation: commandInvocationSchema,
15288
15288
  label: commandLabelSchema,
15289
15289
  description: commandDescriptionSchema.optional(),
15290
- argumentMode: external_exports.enum(["none", "text"])
15290
+ argumentMode: external_exports.enum(["none", "text"]),
15291
+ /**
15292
+ * Native distinction reported by the Harness. Omitted when the Harness does
15293
+ * not tell skills and commands apart; consumers treat that as "command".
15294
+ */
15295
+ kind: external_exports.enum(["command", "skill"]).optional()
15291
15296
  }).strict();
15292
15297
  var harnessCommandCatalogSchema = external_exports.object({
15293
- commands: external_exports.array(harnessCommandDescriptorSchema)
15298
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15299
+ /**
15300
+ * `live` when the catalog includes what a native Session reports for its
15301
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15302
+ * Omitted by Adapters; set by the Host on inspection results.
15303
+ */
15304
+ source: external_exports.enum(["live", "static"]).optional()
15294
15305
  }).strict().superRefine((catalog, context) => {
15295
15306
  const ids = /* @__PURE__ */ new Set();
15296
15307
  for (const [index, command] of catalog.commands.entries()) {
@@ -15304,7 +15315,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15304
15315
  ids.add(command.id);
15305
15316
  }
15306
15317
  });
15307
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15318
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15319
+ harnessId: harnessIdSchema,
15320
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15321
+ cwd: external_exports.string().min(1).optional()
15322
+ }).strict();
15308
15323
  var threadCommandsInspectParamsSchema = external_exports.object({
15309
15324
  threadId: hostThreadIdSchema
15310
15325
  }).strict();
@@ -17635,6 +17650,124 @@ function parseHostUsage(value) {
17635
17650
  return { ...value };
17636
17651
  }
17637
17652
 
17653
+ // ../../harness-adapter/dist/live-command-catalog.js
17654
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
17655
+ // Session lifecycle
17656
+ "branch",
17657
+ "clear",
17658
+ "exit",
17659
+ "fork",
17660
+ "fresh",
17661
+ "new",
17662
+ "quit",
17663
+ "rename",
17664
+ "rename-chat",
17665
+ "reset",
17666
+ "resume",
17667
+ "rewind",
17668
+ "session",
17669
+ "sessions",
17670
+ // Desktop-owned configuration
17671
+ "autocompact",
17672
+ "color",
17673
+ "config",
17674
+ "effort",
17675
+ "fast",
17676
+ "keybindings",
17677
+ "model",
17678
+ "models",
17679
+ "output-style",
17680
+ "permissions",
17681
+ "settings",
17682
+ "statusline",
17683
+ "terminal-setup",
17684
+ "theme",
17685
+ "vim",
17686
+ // Trust and approval policy
17687
+ "always-approve",
17688
+ "auto-mode-setup",
17689
+ // Native login
17690
+ "login",
17691
+ "logout",
17692
+ // Work outliving the Turn
17693
+ "autopilot",
17694
+ "background",
17695
+ "bg",
17696
+ "goal",
17697
+ "jobs",
17698
+ "loop",
17699
+ "multitask",
17700
+ "queue",
17701
+ "remote-control",
17702
+ "schedule",
17703
+ "steer",
17704
+ // Native terminal UI
17705
+ "copy",
17706
+ "debug",
17707
+ "feedback",
17708
+ "heapdump",
17709
+ "share",
17710
+ "shell",
17711
+ // Plugin and MCP management
17712
+ "marketplace",
17713
+ "mcp",
17714
+ "plugins",
17715
+ "reload-plugins"
17716
+ ]);
17717
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
17718
+ function isExcludedLiveCommand(name, kind, extra = {}) {
17719
+ const normalized = name.trim().replace(/^\//u, "");
17720
+ if (new Set(extra.names ?? []).has(normalized))
17721
+ return true;
17722
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
17723
+ return true;
17724
+ if (kind === "skill")
17725
+ return false;
17726
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
17727
+ }
17728
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
17729
+ if (!commandId.startsWith(idPrefix))
17730
+ return null;
17731
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
17732
+ if (!descriptor)
17733
+ return null;
17734
+ const text2 = typeof argumentText === "string" ? argumentText.trim() : "";
17735
+ return text2 ? `${descriptor.invocation} ${text2}` : descriptor.invocation;
17736
+ }
17737
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
17738
+ if (!live)
17739
+ return builtIns;
17740
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
17741
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
17742
+ const dynamic = [];
17743
+ for (const command of live) {
17744
+ const name = command.name.trim().replace(/^\//u, "");
17745
+ if (!name || /\s/u.test(name))
17746
+ continue;
17747
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
17748
+ continue;
17749
+ const invocation = `/${name}`;
17750
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
17751
+ if (invocations.has(invocation) || ids.has(id))
17752
+ continue;
17753
+ const description = command.description?.trim().slice(0, 512);
17754
+ const parsed = harnessCommandDescriptorSchema.safeParse({
17755
+ id,
17756
+ invocation,
17757
+ label: name.slice(0, 128),
17758
+ ...description ? { description } : {},
17759
+ argumentMode: "text",
17760
+ kind: command.kind
17761
+ });
17762
+ if (!parsed.success)
17763
+ continue;
17764
+ invocations.add(invocation);
17765
+ ids.add(id);
17766
+ dynamic.push(parsed.data);
17767
+ }
17768
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
17769
+ }
17770
+
17638
17771
  // dist/pi-workflow-child-history.js
17639
17772
  import { createHash as createHash2 } from "node:crypto";
17640
17773
  import { constants } from "node:fs";
@@ -18120,6 +18253,50 @@ import { spawn, spawnSync } from "node:child_process";
18120
18253
  import { randomUUID as randomUUID4 } from "node:crypto";
18121
18254
  import path8 from "node:path";
18122
18255
 
18256
+ // dist/pi-slash-commands.js
18257
+ var DYNAMIC_ID_PREFIX = "pi.slash.";
18258
+ var PI_EXCLUDED_COMMANDS = [
18259
+ "subagents-detach",
18260
+ "subagents-fleet",
18261
+ "subagents-generate-profiles",
18262
+ "subagents-inspect-rpc",
18263
+ "subagents-load-profile",
18264
+ "subagents-refresh-provider-models",
18265
+ "subagents-steer",
18266
+ "subagents-stop",
18267
+ "subagents-watchdog"
18268
+ ];
18269
+ function parsePiNativeCommands(response) {
18270
+ const data = typeof response === "object" && response !== null ? response.data : void 0;
18271
+ if (!Array.isArray(data?.commands))
18272
+ return [];
18273
+ return data.commands.flatMap((entry) => {
18274
+ if (typeof entry !== "object" || entry === null)
18275
+ return [];
18276
+ const record6 = entry;
18277
+ const name = typeof record6.name === "string" ? record6.name.trim().replace(/^\//u, "") : "";
18278
+ if (!name)
18279
+ return [];
18280
+ return [
18281
+ {
18282
+ name,
18283
+ ...typeof record6.description === "string" ? { description: record6.description } : {},
18284
+ ...typeof record6.source === "string" ? { source: record6.source } : {}
18285
+ }
18286
+ ];
18287
+ });
18288
+ }
18289
+ function piLiveCommandCatalog(builtIns, native) {
18290
+ return mergeLiveHarnessCommands(builtIns, DYNAMIC_ID_PREFIX, native?.map((command) => ({
18291
+ name: command.name,
18292
+ ...command.description ? { description: command.description } : {},
18293
+ kind: command.source === "skill" ? "skill" : "command"
18294
+ })) ?? null, { names: PI_EXCLUDED_COMMANDS });
18295
+ }
18296
+ function piDynamicCommandPrompt(catalog, commandId, argumentText) {
18297
+ return liveHarnessCommandPrompt(catalog, DYNAMIC_ID_PREFIX, commandId, argumentText);
18298
+ }
18299
+
18123
18300
  // dist/pi-usage.js
18124
18301
  function isRecord5(value) {
18125
18302
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -18599,6 +18776,10 @@ var PiRpcSession = class {
18599
18776
  }
18600
18777
  return this;
18601
18778
  }
18779
+ /** Live slash commands, prompt templates and skills of the running Pi Session. */
18780
+ async getCommands() {
18781
+ return parsePiNativeCommands(await this.#send("get_commands", {}));
18782
+ }
18602
18783
  async getEntries() {
18603
18784
  try {
18604
18785
  return parseSessionHistory(await this.#send("get_entries", {}));
@@ -19760,6 +19941,7 @@ var PiHarnessSession = class {
19760
19941
  #starting = null;
19761
19942
  #state = {};
19762
19943
  #transport = null;
19944
+ #liveCommands = piCommandCatalog;
19763
19945
  #usage;
19764
19946
  #usageGeneration = 0;
19765
19947
  #usageRefreshSequence = 0;
@@ -19783,7 +19965,7 @@ var PiHarnessSession = class {
19783
19965
  subagents: { observe: true, readTranscript: true }
19784
19966
  };
19785
19967
  this.commands = {
19786
- list: async () => ({ ok: true, value: piCommandCatalog }),
19968
+ list: async () => ({ ok: true, value: await this.#refreshLiveCommands() }),
19787
19969
  execute: (command) => this.#executeHarnessCommand(command)
19788
19970
  };
19789
19971
  this.#transport = options.startedTransport ?? null;
@@ -20190,7 +20372,31 @@ var PiHarnessSession = class {
20190
20372
  return { ok: false, error: normalized };
20191
20373
  }
20192
20374
  }
20375
+ /**
20376
+ * Built-ins plus the running Session's commands. Never starts the process
20377
+ * just to list commands; an unstarted Session reports the built-ins.
20378
+ */
20379
+ async #refreshLiveCommands() {
20380
+ const transport = this.#transport;
20381
+ if (this.#phase === "open" && transport?.getCommands) {
20382
+ try {
20383
+ this.#liveCommands = piLiveCommandCatalog(piCommandCatalog, await transport.getCommands());
20384
+ } catch {
20385
+ }
20386
+ }
20387
+ return this.#liveCommands;
20388
+ }
20193
20389
  async #executeHarnessCommand(command) {
20390
+ const argumentText = command.arguments?.text;
20391
+ const dynamicPrompt = piDynamicCommandPrompt(this.#liveCommands, command.commandId, typeof argumentText === "string" ? argumentText : void 0);
20392
+ if (dynamicPrompt !== null) {
20393
+ const started = await this.execute({
20394
+ type: "turn.start",
20395
+ turnId: command.turnId,
20396
+ input: [{ type: "text", text: dynamicPrompt }]
20397
+ });
20398
+ return started.ok ? { ok: true, value: { turnId: command.turnId } } : started;
20399
+ }
20194
20400
  if (command.commandId !== "pi.compact") {
20195
20401
  return {
20196
20402
  ok: false,
@@ -20916,6 +21122,7 @@ var PiHarnessSession = class {
20916
21122
  var PiAdapter = class {
20917
21123
  credentialImports;
20918
21124
  commandCatalog = piCommandCatalog;
21125
+ liveCommandCatalog = true;
20919
21126
  harnessId = piHarnessId2;
20920
21127
  subagents = {
20921
21128
  readSnapshot: async ({ parent, nativeSubagentId, cwd }) => {