perchai-cli 2.4.10 → 2.4.11

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@ Run Perch from a terminal without installing the Desktop app.
4
4
 
5
5
  ```sh
6
6
  npm install -g perchai-cli
7
- perch login --app-url https://app.perchai.app
7
+ perch login
8
8
  perch status
9
9
  perch --cwd ~/Desktop/Project --permission take_the_wheel
10
10
  perch run "Summarize this folder" --cwd .
@@ -13,8 +13,6 @@ perch ap packet ./01-ap
13
13
 
14
14
  `perch login` opens your browser, completes OAuth through Perch, and saves the CLI session in the macOS Keychain or `~/.perch/cli-auth-session.json` on other platforms.
15
15
 
16
- The CLI uses the hosted Perch model proxy by default when `--app-url` or `PERCH_CLI_APP_URL` points at a Perch app.
17
-
18
16
  ## Interactive Commands
19
17
 
20
18
  Run `perch`, then use these commands inside the terminal chat:
@@ -26,7 +24,7 @@ Run `perch`, then use these commands inside the terminal chat:
26
24
  - `/permissions [default|auto_review|take_the_wheel|plan]` — alias for `/permission`.
27
25
  - `/mode [ask|agents|plan]` — show or change chat mode.
28
26
  - `/persona [saffron|quill]` — show or change persona.
29
- - `/app-url [url]` — show or change the Perch app/model proxy URL.
27
+ - `/context` — show context meter and compaction details.
30
28
  - `/local-tools [on|off]` — show or toggle local shell/file tools.
31
29
  - `/thread [new|id]` — show, reset, or set the current thread id.
32
30
  - `/clear` — clear local conversation memory for this terminal session.
package/dist/perch.mjs CHANGED
@@ -82915,7 +82915,7 @@ function buildMessageHistory(recentMessages, currentInput, options) {
82915
82915
  ${compactedSummary}`
82916
82916
  });
82917
82917
  }
82918
- const wireReplayMessages = sanitizeWireMessagesForThread(
82918
+ const wireReplayMessages = shouldUseCompactedHistory ? [] : sanitizeWireMessagesForThread(
82919
82919
  options?.wireReplayMessages,
82920
82920
  wireTranscriptSanitizeOptionsForContextLimit(
82921
82921
  options?.wireReplayContextLimitTokens
@@ -199442,6 +199442,7 @@ function containsBrowserDeliveryTask(tasks) {
199442
199442
  var BROWSER_DELIVERY_ROLE_IDS;
199443
199443
  var init_browserDeliveryLock = __esm({
199444
199444
  "features/perchTerminal/agentPlatform/browserDeliveryLock.ts"() {
199445
+ "use strict";
199445
199446
  BROWSER_DELIVERY_ROLE_IDS = /* @__PURE__ */ new Set([
199446
199447
  "doc_writer",
199447
199448
  "email_sender",
@@ -278330,6 +278331,10 @@ ${HELP_TEXT}`);
278330
278331
  appendRecentMessage(nextRecentMessages, "assistant", result3.assistantText.trim());
278331
278332
  }
278332
278333
  trimRecentMessages(nextRecentMessages);
278334
+ writeCliTurnResult(result3, parsed.json, writer, {
278335
+ personaId: parsed.personaId,
278336
+ color: shouldUseCliColor()
278337
+ });
278333
278338
  await admitCliLearningMemory(connection, {
278334
278339
  prompt: parsed.prompt,
278335
278340
  assistantText: result3.assistantText,
@@ -278343,10 +278348,6 @@ ${HELP_TEXT}`);
278343
278348
  recentMessages: nextRecentMessages,
278344
278349
  contextSnapshot: result3.contextSnapshot ?? persisted?.contextSnapshot ?? null
278345
278350
  });
278346
- writeCliTurnResult(result3, parsed.json, writer, {
278347
- personaId: parsed.personaId,
278348
- color: shouldUseCliColor()
278349
- });
278350
278351
  return cliExitCodeForTurn(result3);
278351
278352
  } finally {
278352
278353
  connection.restore();
@@ -278802,7 +278803,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
278802
278803
  if (!isCliModelConnectionReady(connection)) {
278803
278804
  addItem({
278804
278805
  label: "need",
278805
- text: "Sign in with /login before chatting. Hosted model calls require an authenticated Perch session.",
278806
+ text: "Sign in with /login before chatting. Perch needs an authenticated session.",
278806
278807
  tone: "danger"
278807
278808
  });
278808
278809
  return;
@@ -278903,11 +278904,6 @@ async function runInkInteractivePerchCli(writer, deps, options) {
278903
278904
  if (assistantText) appendRecentMessage(state.recentMessages, "assistant", assistantText);
278904
278905
  trimRecentMessages(state.recentMessages);
278905
278906
  state.contextSnapshot = result2.contextSnapshot ?? state.contextSnapshot;
278906
- addItem({
278907
- label: "context",
278908
- text: renderCliContextMeter(state.contextSnapshot),
278909
- tone: "muted"
278910
- });
278911
278907
  const admitted = await admitCliLearningMemory(connection, {
278912
278908
  prompt,
278913
278909
  assistantText,
@@ -278950,7 +278946,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
278950
278946
  const spinnerGlyph = inkSpinnerFrame(pulse);
278951
278947
  const auth = renderCliAuthSummary(connection);
278952
278948
  const meta = `${state.personaId} \xB7 ${state.chatMode} \xB7 ${state.permissionMode}`;
278953
- const route = connection.authenticated && connection.appUrl ? connection.appUrl.replace(/^https?:\/\//, "") : "run /login";
278949
+ const route = isCliModelConnectionReady(connection) ? "connected to Perch" : "run /login";
278954
278950
  const renderTranscriptRow = (key, label, line, tone, showLabel) => React11.createElement(
278955
278951
  Ink2.Box,
278956
278952
  { key },
@@ -279103,6 +279099,9 @@ async function runInteractiveSlashCommand(input) {
279103
279099
  input.writer.stdout(renderInteractiveStatus(input.state, input.getConnection?.() ?? null, session));
279104
279100
  return "continue";
279105
279101
  }
279102
+ case "context":
279103
+ input.writer.stdout(renderCliContextDetails(input.state.contextSnapshot));
279104
+ return "continue";
279106
279105
  case "cwd":
279107
279106
  if (!parsed.value) {
279108
279107
  writeModeLine(input.writer, "cwd", input.state.cwd);
@@ -279202,6 +279201,8 @@ function parseInteractiveSlashCommand(input) {
279202
279201
  return { ok: true, kind: "help" };
279203
279202
  case "status":
279204
279203
  return { ok: true, kind: "status" };
279204
+ case "context":
279205
+ return { ok: true, kind: "context" };
279205
279206
  case "cwd":
279206
279207
  return { ok: true, kind: "cwd", ...value ? { value } : {} };
279207
279208
  case "permission":
@@ -279242,27 +279243,26 @@ function parseInteractiveSlashCommand(input) {
279242
279243
  }
279243
279244
  function renderInteractiveStatus(state, connection, session) {
279244
279245
  const storedAuth = session === void 0 ? renderCliAuthSummary(connection) : isStoredCliAuthSessionUsable(session) ? `signed in${session.email ? ` as ${session.email}` : ""}` : "not signed in";
279245
- const modelRoute = isCliModelConnectionReady(connection) ? `connected \xB7 ${connection.appUrl ?? "(unknown)"}` : "locked \xB7 run /login";
279246
+ const connectionStatus = isCliModelConnectionReady(connection) ? "connected" : "locked \xB7 run /login";
279246
279247
  const color = shouldUseCliColor();
279247
279248
  const lines = [
279248
279249
  ["cwd", state.cwd],
279249
279250
  ["auth", storedAuth],
279250
- ["model-route", modelRoute],
279251
+ ["connection", connectionStatus],
279251
279252
  ["permission", state.permissionMode],
279252
279253
  ["mode", state.chatMode],
279253
279254
  ["persona", state.personaId],
279254
279255
  ["thread", state.threadId],
279255
279256
  ["context", renderCliContextMeter(state.contextSnapshot)],
279256
279257
  ["saved", state.persistedThreadUpdatedAt ? new Date(state.persistedThreadUpdatedAt).toLocaleString() : "(new thread)"],
279257
- ["local-tools", state.cliLocalTools ? "on" : "off"],
279258
- ["app-url", state.appUrl ?? connection?.appUrl ?? "(none)"]
279258
+ ["local-tools", state.cliLocalTools ? "on" : "off"]
279259
279259
  ];
279260
279260
  return lines.map(([key, value]) => `${paint(key.padEnd(11), "muted", color)} ${value}`).join("\n") + "\n";
279261
279261
  }
279262
279262
  function renderInteractiveStartup(state, connection) {
279263
279263
  const color = shouldUseCliColor();
279264
279264
  const auth = renderCliAuthSummary(connection);
279265
- const route = connection.authenticated && connection.appUrl ? connection.appUrl.replace(/^https?:\/\//, "") : connection.appUrl ?? state.appUrl ?? "run /login";
279265
+ const route = isCliModelConnectionReady(connection) ? "connected to Perch" : "run /login";
279266
279266
  const commandLines = PERCH_SPLASH_COMMANDS.map(
279267
279267
  ([command, description]) => ` ${paint(command.padEnd(13), "bronze", color)}${paint(description, "muted", color)}`
279268
279268
  );
@@ -279497,9 +279497,27 @@ function renderCliContextMeter(snapshot) {
279497
279497
  const parts = [`${meter.composerLabel}`, `${Math.max(0, Math.min(100, percent2))}%`];
279498
279498
  const compacted = snapshot.compactedRowCount ?? 0;
279499
279499
  if (snapshot.compacted || compacted > 0) parts.push(`compacted ${compacted}`);
279500
- if (snapshot.modelLabel) parts.push(snapshot.modelLabel);
279501
279500
  return parts.join(" \xB7 ");
279502
279501
  }
279502
+ function renderCliContextDetails(snapshot) {
279503
+ if (!snapshot) return "context no meter yet\n";
279504
+ const meter = resolveContextMeterDisplay(snapshot);
279505
+ const percent2 = snapshot.contextPercentage ?? Math.round(meter.committedTokens / Math.max(1, meter.limitTokens) * 100);
279506
+ const lines = [
279507
+ ["context", renderCliContextMeter(snapshot)],
279508
+ ["thread", `${formatCliTokenCount(meter.threadTokens)} tokens`],
279509
+ ["limit", `${formatCliTokenCount(meter.limitTokens)} tokens`],
279510
+ ["fill", `${Math.max(0, Math.min(100, percent2))}%`],
279511
+ ["compacted", snapshot.compacted || (snapshot.compactedRowCount ?? 0) > 0 ? `${snapshot.compactedRowCount ?? 0} row(s)` : "no"],
279512
+ ["not-found", `${snapshot.notFoundRowCount ?? 0} row(s)`]
279513
+ ];
279514
+ const color = shouldUseCliColor();
279515
+ return lines.map(([key, value]) => `${paint(key.padEnd(11), "muted", color)} ${value}`).join("\n") + "\n";
279516
+ }
279517
+ function formatCliTokenCount(value) {
279518
+ if (value < 1e3) return `${Math.max(0, Math.round(value))}`;
279519
+ return `${Math.round(value).toLocaleString("en-US")}`;
279520
+ }
279503
279521
  function humanizeCliToolName(name) {
279504
279522
  return name.replace(/^mcp__/, "").replace(/_/g, " ");
279505
279523
  }
@@ -279882,11 +279900,11 @@ var init_perch_cli = __esm({
279882
279900
  HELP_TEXT = `Perch CLI
279883
279901
 
279884
279902
  Usage:
279885
- perch [--cwd <dir>] [--permission default|auto_review|take_the_wheel|plan] [--mode ask|agents|plan] [--persona saffron|quill] [--app-url <url>]
279886
- perch login [--app-url <url>]
279903
+ perch [--cwd <dir>] [--permission default|auto_review|take_the_wheel|plan] [--mode ask|agents|plan] [--persona saffron|quill]
279904
+ perch login
279887
279905
  perch status
279888
279906
  perch logout
279889
- perch run "<task>" [--json] [--cwd <dir>] [--mode ask|agents|plan] [--persona saffron|quill] [--app-url <url>]
279907
+ perch run "<task>" [--json] [--cwd <dir>] [--mode ask|agents|plan] [--persona saffron|quill]
279890
279908
  perch ap evidence <folder> [--json] [--out <dir>] [--timestamp <id>]
279891
279909
  perch ap packet <folder> [--json] [--out <dir>] [--timestamp <id>]
279892
279910
  perch test ap <folder> [--json] [--out <dir>] [--timestamp <id>] [--profile financial-lab-v2] [--expect key=value]
@@ -279900,10 +279918,6 @@ Commands:
279900
279918
  ap evidence Prepare AP evidence, cases, metrics, and graph artifacts.
279901
279919
  ap packet Generate the full AP audit packet and report artifacts.
279902
279920
  test ap Run AP evidence + packet and emit a pass/fail receipt.
279903
-
279904
- Model connection:
279905
- --app-url Send model calls through a running Perch app, e.g. http://localhost:3000.
279906
- You can also set PERCH_CLI_APP_URL.
279907
279921
  `;
279908
279922
  INTERACTIVE_HELP_TEXT = `Interactive commands:
279909
279923
  /help Show this list.
@@ -279913,7 +279927,7 @@ Model connection:
279913
279927
  /permissions [mode] Alias for /permission.
279914
279928
  /mode [ask|agents|plan] Show or set chat mode.
279915
279929
  /persona [saffron|quill] Show or set persona.
279916
- /app-url [url] Show or change the Perch app/model proxy URL.
279930
+ /context Show context meter and compaction details.
279917
279931
  /local-tools [on|off] Show or toggle local shell/file tools.
279918
279932
  /thread [new|id] Show, reset, or set the current thread id.
279919
279933
  /clear Clear local conversation memory for this terminal session.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perchai-cli",
3
- "version": "2.4.10",
3
+ "version": "2.4.11",
4
4
  "description": "Perch AI command-line interface",
5
5
  "bin": {
6
6
  "perch": "bin/perch"