github-router 0.3.372 → 0.3.373

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 (38) hide show
  1. package/dist/ado-tools-WDyisN8w.js +1 -0
  2. package/dist/{attribution-settings-HI_5bN_-.js → attribution-settings-DZ8fEfvP.js} +5 -5
  3. package/dist/{attribution-settings-HI_5bN_-.js.map → attribution-settings-DZ8fEfvP.js.map} +1 -1
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/{claude-BBSsqwln.js → claude-8ksmV0dC.js} +10 -10
  6. package/dist/{claude-BBSsqwln.js.map → claude-8ksmV0dC.js.map} +1 -1
  7. package/dist/{claude-md-injection-BMon6WUD.js → claude-md-injection-BnzVv_aB.js} +2 -2
  8. package/dist/{claude-md-injection-BMon6WUD.js.map → claude-md-injection-BnzVv_aB.js.map} +1 -1
  9. package/dist/{codex-PRWoBiOH.js → codex-C89FoaaG.js} +6 -6
  10. package/dist/{codex-PRWoBiOH.js.map → codex-C89FoaaG.js.map} +1 -1
  11. package/dist/engine-C207cikp.js +1 -0
  12. package/dist/{gate-discovery-BNy8GKsC.js → gate-discovery-Bc9FdRwg.js} +2 -2
  13. package/dist/{gate-discovery-BNy8GKsC.js.map → gate-discovery-Bc9FdRwg.js.map} +1 -1
  14. package/dist/{index-cmd-CjRcmYk3.js → index-cmd-DOhwt92u.js} +2 -2
  15. package/dist/{index-cmd-CjRcmYk3.js.map → index-cmd-DOhwt92u.js.map} +1 -1
  16. package/dist/{internal-stop-hook-CXlOsW63.js → internal-stop-hook-nS91Jkda.js} +2 -2
  17. package/dist/{internal-stop-hook-CXlOsW63.js.map → internal-stop-hook-nS91Jkda.js.map} +1 -1
  18. package/dist/main.js +7 -7
  19. package/dist/{peer-mcp-personas-Dxxw5X1g.js → peer-mcp-personas-BSxDj9sJ.js} +2 -2
  20. package/dist/{peer-mcp-personas-Dxxw5X1g.js.map → peer-mcp-personas-BSxDj9sJ.js.map} +1 -1
  21. package/dist/{pi-IYAvKF50.js → pi-BglhJ6n_.js} +286 -62
  22. package/dist/pi-BglhJ6n_.js.map +1 -0
  23. package/dist/{provision-CIn6I4w_.js → provision-B0GNohdl.js} +3 -3
  24. package/dist/{provision-CIn6I4w_.js.map → provision-B0GNohdl.js.map} +1 -1
  25. package/dist/{serve-CttHP8dJ.js → serve-BxZq9vNl.js} +7 -7
  26. package/dist/{serve-CttHP8dJ.js.map → serve-BxZq9vNl.js.map} +1 -1
  27. package/dist/{server-setup-D7XHUrhM.js → server-setup-BLdWCcby.js} +4 -4
  28. package/dist/{server-setup-D7XHUrhM.js.map → server-setup-BLdWCcby.js.map} +1 -1
  29. package/dist/{service-backend-B6D_DY1Z.js → service-backend-BV2hHjuB.js} +35 -17
  30. package/dist/service-backend-BV2hHjuB.js.map +1 -0
  31. package/dist/{start-XU5HwLd9.js → start-C3Zb8XMT.js} +4 -4
  32. package/dist/{start-XU5HwLd9.js.map → start-C3Zb8XMT.js.map} +1 -1
  33. package/dist/{workiq-tools-CMoDjrO0.js → workiq-tools-C6LAF_vA.js} +1 -1
  34. package/package.json +2 -3
  35. package/dist/ado-tools-CAtopk36.js +0 -1
  36. package/dist/engine-CDZdAx8N.js +0 -1
  37. package/dist/pi-IYAvKF50.js.map +0 -1
  38. package/dist/service-backend-B6D_DY1Z.js.map +0 -1
@@ -1,14 +1,14 @@
1
- import { P as warmTreeSitterPool } from "./service-backend-B6D_DY1Z.js";
1
+ import { P as warmTreeSitterPool } from "./service-backend-BV2hHjuB.js";
2
2
  import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
3
3
  import { t as PATHS } from "./paths-C5477RGC.js";
4
4
  import { t as state } from "./state-DzsaGHr9.js";
5
- import { H as profileDescriptor, I as formatBalancedPrerequisiteFailure, S as enableFileLogging, U as resolveLaunchProfile, V as formatLocalPrerequisiteFailure, W as validateBalancedProfilePrerequisites, Y as validateLocalProfilePrerequisites, Z as runSelfUpdate, _ as sweepStalePiAgentMirrors, a as setupAndServe, c as PI_MIN_VERSION, d as meetsPiMinVersion, f as refreshPiInBackground, g as removeOwnPiAgentMirror, h as ensurePiAgentMirror, i as parseSharedArgs, l as ensurePiInstalled, m as updatePi, o as sharedServerArgs, p as resolvePiRegistry, q as validateCheapestProfilePrerequisites, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as getInstalledPiVersion, v as startKeepAwake, y as stopKeepAwake, z as formatCheapestPrerequisiteFailure } from "./server-setup-D7XHUrhM.js";
6
- import { Bn as colbertDegradedWarning, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, Dt as artifactToolsEnabled, Gn as LOCAL_CONSULT_REDACTION_NOTE, Mn as provisionBrowserAssets, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, Sn as unregisterLaunch, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Wn as LOCAL_CONSULT_REDACTION_LINE, bn as registerLaunch, fn as configureLocalEgress, jt as browseAgentEnabled, pn as localBaseUrl, sn as workiqToolsEnabled } from "./peer-mcp-personas-Dxxw5X1g.js";
5
+ import { H as profileDescriptor, I as formatBalancedPrerequisiteFailure, S as enableFileLogging, U as resolveLaunchProfile, V as formatLocalPrerequisiteFailure, W as validateBalancedProfilePrerequisites, Y as validateLocalProfilePrerequisites, Z as runSelfUpdate, _ as sweepStalePiAgentMirrors, a as setupAndServe, c as PI_MIN_VERSION, d as meetsPiMinVersion, f as refreshPiInBackground, g as removeOwnPiAgentMirror, h as ensurePiAgentMirror, i as parseSharedArgs, l as ensurePiInstalled, m as updatePi, o as sharedServerArgs, p as resolvePiRegistry, q as validateCheapestProfilePrerequisites, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as getInstalledPiVersion, v as startKeepAwake, y as stopKeepAwake, z as formatCheapestPrerequisiteFailure } from "./server-setup-BLdWCcby.js";
6
+ import { Bn as colbertDegradedWarning, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, Dt as artifactToolsEnabled, Gn as LOCAL_CONSULT_REDACTION_NOTE, Mn as provisionBrowserAssets, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, Sn as unregisterLaunch, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Wn as LOCAL_CONSULT_REDACTION_LINE, bn as registerLaunch, fn as configureLocalEgress, jt as browseAgentEnabled, pn as localBaseUrl, sn as workiqToolsEnabled } from "./peer-mcp-personas-BSxDj9sJ.js";
7
7
  import { C as localContractFor, O as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, h as consultIsLocalTransport, p as cheapestContractFor, v as isCheapestFamily, y as isCheaplocalProfile } from "./static-context-pack-CsOAC87F.js";
8
8
  import { r as resolveSelfInvocation } from "./self-invocation-BtcGj-lY.js";
9
- import { i as launchChild, t as provisionToolbelt } from "./provision-CIn6I4w_.js";
9
+ import { i as launchChild, t as provisionToolbelt } from "./provision-B0GNohdl.js";
10
10
  import { d as removeAicLedgerFile, f as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath } from "./aic-ledger-Cp7Yk9-Q.js";
11
- import { t as FRESH_CONSULT_CONTRACT } from "./claude-md-injection-BMon6WUD.js";
11
+ import { t as FRESH_CONSULT_CONTRACT } from "./claude-md-injection-BnzVv_aB.js";
12
12
  import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as AIC_LEDGER_ENV } from "./aic-statusline-settings-B5EMMSFC.js";
13
13
  import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-T-cfWmc4.js";
14
14
  import { defineCommand } from "citty";
@@ -471,6 +471,28 @@ function piThinkingLevelMapFor(efforts) {
471
471
  /** Provider key used in models.json and agent `provider/model` references. */
472
472
  const PI_PROVIDER_NAME = "gh-router";
473
473
  const PI_MIN_VERSION_NOTE = `Requires Pi >= ${PI_MIN_VERSION} and Node >= 22.19.`;
474
+ /**
475
+ * The tool-preference steer the digest carries.
476
+ *
477
+ * Pi's own per-tool guidelines cover `read`/`write`/`edit` but leave `grep`,
478
+ * `find` and `ls` with empty arrays (`dist/core/tools/*.js`), and its "use bash
479
+ * for ls, rg, find" rule fires only when those dedicated tools are ABSENT
480
+ * (`dist/core/system-prompt.js:46`). A launch with all eight active is told
481
+ * nothing, so the digest has to say it.
482
+ *
483
+ * Both halves are load-bearing. The first half stops the model shelling out to
484
+ * `sed`/`cat`/`python` for work the dedicated tools do better and with the
485
+ * harness's own approval and diff handling. The second half exists because the
486
+ * first is not true without it: a `jq` pipeline over a JSON blob, an `ast-grep`
487
+ * structural query, `git log -S`, or a build/test command all belong in bash,
488
+ * and a blanket "never shell out" would make the agent worse at exactly the
489
+ * tasks where the shell is the right instrument. Naming the tools is the point
490
+ * — "use the best tool" alone gives no signal.
491
+ *
492
+ * Single constant so the test suite pins one sentence rather than scraping the
493
+ * digest for keywords.
494
+ */
495
+ const PI_TOOL_PREFERENCE_LINE = "- Use the dedicated tools where they fit — read/write/edit for files and grep/find/ls for search — instead of shelling out to cat, sed, or python; but reach for rg, jq, ast-grep, git, and the build/test commands whenever those are the better tool for the job.";
474
496
  function piCopilotContractFor(profileId) {
475
497
  return isCheapestFamily(profileId) ? cheapestContractFor(profileId) : balancedContractFor(profileId);
476
498
  }
@@ -968,6 +990,70 @@ const PI_DEFAULT_TOOLS = Object.freeze([
968
990
  "ls"
969
991
  ]);
970
992
  /**
993
+ * The pi keybinding action that owns `shift+tab` by default.
994
+ *
995
+ * Named rather than spelled inline so the keybindings writer and the test that
996
+ * pins it cannot drift: `dist/core/keybindings.js:13` declares this action with
997
+ * `defaultKeys: "shift+tab"`, and `RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS`
998
+ * in `dist/core/extensions/runner.js:9-26` lists it, which is what makes an
999
+ * extension's `shift+tab` registration die with "conflicts with built-in
1000
+ * shortcut. Skipping."
1001
+ */
1002
+ const PI_THINKING_CYCLE_ACTION = "app.thinking.cycle";
1003
+ /** The key `shift+tab` moves to when plan mode claims it. */
1004
+ const PI_THINKING_CYCLE_REBIND = "ctrl+shift+t";
1005
+ /**
1006
+ * Build the per-launch `keybindings.json` that frees `shift+tab` for plan mode.
1007
+ *
1008
+ * Claude Code binds `shift+tab` to its permission-mode ring, and the whole point
1009
+ * of this file is that a user arriving from Claude Code presses the same key
1010
+ * here. Pi routes the key to `app.thinking.cycle` and *reserves* it against
1011
+ * extension overrides, so an extension cannot claim it — but
1012
+ * `buildBuiltinKeybindings` skips every action whose configured value is an
1013
+ * empty list (`runner.js:31-49`), which leaves the key unbound and free for an
1014
+ * extension registration to take.
1015
+ *
1016
+ * The action is MOVED rather than emptied. Emptying was the first cut and it
1017
+ * costs a working pi binding for a plan-mode toggle that `/plan` already
1018
+ * provides; moving it keeps thinking-level cycling reachable. `ctrl+shift+t`
1019
+ * is free in pi's own table (`keybindings.js`) and among every shortcut the
1020
+ * bundled packages register (verified: ctrl+shift+o/e/r, ctrl+., alt+t).
1021
+ *
1022
+ * Only this one action is touched. Every other pi default is left to pi, so
1023
+ * this file cannot silently re-map a binding the user relies on. A user's own
1024
+ * `keybindings.json` is merged UNDER it, matching how `settings.json` is
1025
+ * layered — with one refinement in `mergePiKeybindingsSettings`: a user who
1026
+ * already moved thinking-cycle off `shift+tab` keeps their key, because the
1027
+ * invariant this file enforces is "shift+tab is unbound", not "our value wins".
1028
+ */
1029
+ function buildPiKeybindingsJson() {
1030
+ return { [PI_THINKING_CYCLE_ACTION]: [PI_THINKING_CYCLE_REBIND] };
1031
+ }
1032
+ /** Does this configured binding still claim `shift+tab`? */
1033
+ function boundToShiftTab(value) {
1034
+ return (Array.isArray(value) ? value : [value]).some((k) => typeof k === "string" && k.trim().toLowerCase() === "shift+tab");
1035
+ }
1036
+ /**
1037
+ * Lay our freed key over a snapshotted user `keybindings.json`.
1038
+ *
1039
+ * The invariant is "`shift+tab` is unbound", not "our value wins". So the
1040
+ * built value is applied only when the user's file still routes `shift+tab`
1041
+ * through `app.thinking.cycle` (absent counts as still-bound: that is the pi
1042
+ * default). A user who already moved it elsewhere — `F2`, `ctrl+shift+t`,
1043
+ * anything without `shift+tab` — keeps their binding, and the key is free
1044
+ * either way. Forcing our value there would silently undo a preference with no
1045
+ * gain to plan mode.
1046
+ *
1047
+ * Every other user binding survives untouched. Non-object input (corrupt JSON
1048
+ * parsed to a string, or an array) is discarded rather than spread, so a broken
1049
+ * file cannot plant junk keys in the launch mirror.
1050
+ */
1051
+ function mergePiKeybindingsSettings(userKeybindings, built) {
1052
+ const merged = { ...userKeybindings && typeof userKeybindings === "object" && !Array.isArray(userKeybindings) ? userKeybindings : {} };
1053
+ for (const [action, keys] of Object.entries(built)) if (!(action in merged) || boundToShiftTab(merged[action])) merged[action] = keys;
1054
+ return merged;
1055
+ }
1056
+ /**
971
1057
  * Build the per-launch `settings.json`. Additive over the snapshotted
972
1058
  * user settings (the launcher merges lists it owns): narrow model
973
1059
  * scope, fixed thinking, limited toolset, derived compaction, and the
@@ -1268,7 +1354,8 @@ function buildPiAppendSystem(profileId, opts = {}) {
1268
1354
  const lines = [
1269
1355
  `# gh-router ${profileId} mode`,
1270
1356
  "",
1271
- `- Lead owns planning directly; there is no Plan subagent.`
1357
+ `- Lead owns planning directly; there is no Plan subagent.`,
1358
+ PI_TOOL_PREFERENCE_LINE
1272
1359
  ];
1273
1360
  if (peers) {
1274
1361
  const oracle = piOracleEnabled(profileId);
@@ -1412,16 +1499,82 @@ const PLAN_BLOCKED_TOOLS = Object.freeze([
1412
1499
  "apply_patch"
1413
1500
  ]);
1414
1501
  /**
1415
- * The plan file, relative to the workspace.
1502
+ * The plan file for ONE session, relative to the workspace.
1503
+ *
1504
+ * A fixed path was the original design and it does not survive parallel use.
1505
+ * Two sessions in the same repo both passed the path gate — the gate compares a
1506
+ * resolved path against this value and has no notion of ownership — so the
1507
+ * second plan silently replaced the first, and an `edit` written against the
1508
+ * old text failed with a message about fuzzy matching instead of naming the
1509
+ * collision. The rest of plan mode was already per-session: the mode flag, the
1510
+ * steps and the execution flag live in a `PLAN_MODE_ENTRY` in each session's
1511
+ * own transcript. The file was the last piece of shared mutable state.
1512
+ *
1513
+ * The Claude front-end already does this — its artifact hook reads
1514
+ * `tool_input.planFilePath` "per-session; never the globally-newest file in the
1515
+ * shared plans dir" (`src/internal-artifact-open.ts`). This is the same
1516
+ * contract, with the name derived rather than model-chosen:
1416
1517
  *
1417
- * Claude Code pins one path per session and tells the model "this is the only
1418
- * file you are allowed to edit". Ours is the repository's existing convention
1419
- * (`.github-router/plans/<slug>/plan.md`, the same artifact `/gh-plan` writes and
1420
- * `/gh-implement` reads), with a stable slug so a resumed session keeps editing
1421
- * the plan it started rather than opening a second one.
1518
+ * - **Derived, not chosen.** A generated three-word name would have to survive
1519
+ * the model restating it, and a resumed session that picked a different name
1520
+ * would fork the plan. A session id is unforgeable and resume-stable for
1521
+ * free, and it keeps the gate an exact-path comparison.
1522
+ * - **Full id, not a hash or a prefix.** The id already appears in the
1523
+ * transcript filename, so a plan directory traces back to the session that
1524
+ * wrote it. UUIDv7 is time-ordered at the front, so a prefix would collide
1525
+ * for launches in the same millisecond.
1526
+ * - **One `<slug>` segment**, so the repository's existing convention
1527
+ * (`.github-router/plans/<slug>/plan.md`, what `/gh-plan` writes and
1528
+ * `/gh-implement` reads, `.complete` beside it) still describes the shape.
1529
+ *
1530
+ * Sanitized to `[A-Za-z0-9._-]` as belt-and-braces: the id is host-generated,
1531
+ * but sanitizing also makes traversal structurally impossible — path separators
1532
+ * cannot survive, and a segment that is entirely dots is unreachable anyway
1533
+ * because every one of these starts with `pi-plan-`.
1534
+ *
1535
+ * Sanitizing is LOSSY, and lossy is a collision. pi's own id validator
1536
+ * (`assertValidSessionId`) admits `.`, so `a.b` and `a-b` are both legal ids,
1537
+ * and `--session-id` lets an operator pick either; mapping one onto the other
1538
+ * would reinstate, for that pair, the very bug this function exists to prevent.
1539
+ * Dots are therefore KEPT (they are inert inside a prefixed segment). Anything
1540
+ * that still had to be ALTERED — a character dropped, or the length cap hit —
1541
+ * carries a digest of its original bytes instead of silently merging with its
1542
+ * neighbours. Generated UUIDv7 ids are `[0-9a-f-]` and are untouched, so the
1543
+ * readable form that traces to the transcript filename stays the common case.
1544
+ * FNV-1a rather than a cryptographic digest because this has to survive being
1545
+ * inlined into the emitted extension (a `toString()` copy cannot import
1546
+ * `node:crypto`), and telling two host-generated ids apart does not need
1547
+ * resistance to an attacker who could pick the path outright.
1548
+ *
1549
+ * Emitted via `.toString()`, so this body carries no module-scope references —
1550
+ * the layout strings are inline for that reason, not by preference, and the
1551
+ * digest is hand-rolled because `node:crypto` is not importable there.
1422
1552
  */
1423
- function planFilePath() {
1424
- return ".github-router/plans/pi-plan/plan.md";
1553
+ function planFilePathForSession(sessionId) {
1554
+ const raw = typeof sessionId === "string" ? sessionId.trim() : "";
1555
+ let slug = "";
1556
+ let altered = false;
1557
+ for (const ch of raw) if (/[A-Za-z0-9._-]/.test(ch)) slug += ch;
1558
+ else {
1559
+ altered = true;
1560
+ if (slug.length > 0 && !slug.endsWith("-")) slug += "-";
1561
+ }
1562
+ slug = slug.replace(/^[.-]+|[.-]+$/g, "");
1563
+ if (slug.length > 96) {
1564
+ slug = slug.slice(0, 96).replace(/[.-]+$/g, "");
1565
+ altered = true;
1566
+ }
1567
+ if (slug !== raw) altered = true;
1568
+ if (!slug) return ".github-router/plans/pi-plan/plan.md";
1569
+ if (altered) {
1570
+ let hash = 2166136261;
1571
+ for (let i = 0; i < raw.length; i++) {
1572
+ hash ^= raw.charCodeAt(i);
1573
+ hash = Math.imul(hash, 16777619) >>> 0;
1574
+ }
1575
+ slug += "-" + hash.toString(16).padStart(8, "0");
1576
+ }
1577
+ return ".github-router/plans/pi-plan-" + slug + "/plan.md";
1425
1578
  }
1426
1579
  /** Session entry type for persisting plan state across resume. */
1427
1580
  const PLAN_MODE_ENTRY = "gh-router-plan-mode";
@@ -1447,9 +1600,10 @@ const PLAN_LIST_TYPE = "gh-router-plan-list";
1447
1600
  * module have different allowed specifiers), so it carries its own tiny
1448
1601
  * resolver: POSIX normalisation plus a Windows drive/UNC guard. It is not a
1449
1602
  * general path library — it only has to agree with itself between the
1450
- * comparison here and the value `planFilePath()` produces, which is why the
1451
- * relative plan path is a PARAMETER: a `toString()`-serialized function cannot
1452
- * see module scope, and a captured constant would be `undefined` at runtime.
1603
+ * comparison here and the value `planFilePathForSession()` produces, which is
1604
+ * why the relative plan path is a PARAMETER: a `toString()`-serialized function
1605
+ * cannot see module scope, and a captured constant would be `undefined` at
1606
+ * runtime.
1453
1607
  */
1454
1608
  function isPlanFilePath(cwd, target, rel) {
1455
1609
  const raw = typeof target === "string" ? target.trim() : "";
@@ -1485,7 +1639,9 @@ function isPlanFilePath(cwd, target, rel) {
1485
1639
  function buildPiPlanModeSection() {
1486
1640
  return [
1487
1641
  ` // ---- plan mode: Claude-Code-style planning (always on) ----`,
1488
- ` // /plan or Ctrl+Alt+P toggles it. The tool set is NEVER touched: it used to`,
1642
+ ` // /plan, Shift+Tab (freed: the mirror's keybindings.json moves thinking-`,
1643
+ ` // level cycling to Ctrl+Shift+T) or Ctrl+Alt+P (the fallback on a host`,
1644
+ ` // without that file) toggles it. The tool set is NEVER touched: it used to`,
1489
1645
  ` // be snapshotted on entry and restored on exit, and removing the writers from`,
1490
1646
  ` // it made the path gate below unreachable (pi answers "Tool write not found"`,
1491
1647
  ` // before any handler runs), plus a restored snapshot could widen the roster a`,
@@ -1502,7 +1658,7 @@ function buildPiPlanModeSection() {
1502
1658
  ` const PLAN_DONE_TYPE = ${JSON.stringify(PLAN_DONE_TYPE)};`,
1503
1659
  ` const PLAN_LIST_TYPE = ${JSON.stringify(PLAN_LIST_TYPE)};`,
1504
1660
  ` const PLAN_BLOCKED = new Set(${JSON.stringify([...PLAN_BLOCKED_TOOLS])});`,
1505
- ` const PLAN_FILE_REL = ${JSON.stringify(planFilePath())};`,
1661
+ ` const planFilePathForSession = (${planFilePathForSession.toString()});`,
1506
1662
  ` const isPlanFilePath = (${isPlanFilePath.toString()});`,
1507
1663
  ` const cleanPlanStepText = (${cleanPlanStepText.toString()});`,
1508
1664
  ` const extractPlanSteps = (${extractPlanSteps.toString()});`,
@@ -1514,12 +1670,38 @@ function buildPiPlanModeSection() {
1514
1670
  ` let planExecuting = false;`,
1515
1671
  ` let planSteps = [];`,
1516
1672
  ` let planCwd = "";`,
1673
+ ` // The plan file, resolved from THIS session's id and cached for the run.`,
1674
+ ` // A fixed path was the original design and it does not survive parallel`,
1675
+ ` // use: two sessions in one repo both cleared the gate, so the second plan`,
1676
+ ` // silently replaced the first. Resolving from the session id gives each`,
1677
+ ` // session its own file with no lock and no coordination, and because the`,
1678
+ ` // id is stable across resume the same session keeps editing the same file.`,
1679
+ ` // Cached, then re-resolved on every session_start: the derive is cheap but`,
1680
+ ` // it must run once per (possibly changing) session, not once per gate hit.`,
1681
+ ` let planRel = "";`,
1517
1682
  ` // Set while the "what next?" prompt is open. agent_end can fire again for`,
1518
1683
  ` // the same plan (a queued follow-up run ends too), and a second prompt on`,
1519
1684
  ` // top of the first would let two Execute answers each send an execution`,
1520
1685
  ` // kick, resetting progress and paying for a redundant turn.`,
1521
1686
  ` let planPromptOpen = false;`,
1522
1687
  ``,
1688
+ ` // Resolve (once per session) the ONE file this session may write. Every`,
1689
+ ` // read site goes through here so the notify, the status line, the brief`,
1690
+ ` // and the gate can never disagree about the path.`,
1691
+ ` function planRelFor(ctx) {`,
1692
+ ` if (planRel) return planRel;`,
1693
+ ` let id = "";`,
1694
+ ` try {`,
1695
+ ` const sm = ctx && ctx.sessionManager;`,
1696
+ ` if (sm && typeof sm.getSessionId === "function") id = sm.getSessionId();`,
1697
+ ` } catch {}`,
1698
+ ` // No second fallback here: planFilePathForSession ALWAYS returns a usable`,
1699
+ ` // path (an unusable id becomes the shared fallback inside it), so a`,
1700
+ ` // "|| fallback" would be dead code that reads like a live guard.`,
1701
+ ` planRel = planFilePathForSession(id);`,
1702
+ ` return planRel;`,
1703
+ ` }`,
1704
+ ``,
1523
1705
  ` function planPaint(ctx, text, color) {`,
1524
1706
  ` try {`,
1525
1707
  ` const theme = ctx && ctx.ui && ctx.ui.theme;`,
@@ -1582,7 +1764,7 @@ function buildPiPlanModeSection() {
1582
1764
  ` planPromptOpen = false;`,
1583
1765
  ` planSteps = [];`,
1584
1766
  ` try { if (ctx && typeof ctx.cwd === "string" && ctx.cwd) planCwd = ctx.cwd; } catch {}`,
1585
- ` try { ctx.ui.notify("Plan mode on: writes refused except " + PLAN_FILE_REL + ". Investigate, then write the plan there. Ctrl+Alt+P or /plan to leave.", "info"); } catch {}`,
1767
+ ` try { ctx.ui.notify("Plan mode on: writes refused except " + planRelFor(ctx) + ". Investigate, then write the plan there. Shift+Tab (or /plan) to leave.", "info"); } catch {}`,
1586
1768
  ` planUpdateUi(ctx);`,
1587
1769
  ` planPersist();`,
1588
1770
  ` }`,
@@ -1610,12 +1792,26 @@ function buildPiPlanModeSection() {
1610
1792
  ` });`,
1611
1793
  ` } catch {}`,
1612
1794
  ` try {`,
1795
+ ` // Claude Code's plan-mode key. Pi binds app.thinking.cycle to shift+tab`,
1796
+ ` // and reserves it against extension overrides, so the launcher moves that`,
1797
+ ` // action off shift+tab in the mirror's keybindings.json — this`,
1798
+ ` // registration takes the freed key. Registering anyway is safe when the`,
1799
+ ` // key is still bound: pi drops the extension shortcut with a diagnostic`,
1800
+ ` // instead of throwing, which is the honest failure mode.`,
1801
+ ` pi.registerShortcut("shift+tab", {`,
1802
+ ` description: "Toggle plan mode",`,
1803
+ ` handler: async (ctx) => { planToggle(ctx); },`,
1804
+ ` });`,
1805
+ ` } catch {}`,
1806
+ ` try {`,
1613
1807
  ` // Literal KeyId rather than Key.ctrlAlt("p"): the generated source then`,
1614
1808
  ` // needs no pi-tui import at all, which keeps it loadable on every build`,
1615
1809
  ` // whose host-provided specifier list is smaller than today's. The value`,
1616
1810
  ` // is exactly what Key.ctrlAlt("p") returns (pi-tui keys.js:118).`,
1811
+ ` // Kept as the fallback for a host whose keybindings.json we did not`,
1812
+ ` // write (older launcher, hand-run pi against this extension).`,
1617
1813
  ` pi.registerShortcut("ctrl+alt+p", {`,
1618
- ` description: "Toggle plan mode",`,
1814
+ ` description: "Toggle plan mode (alternate)",`,
1619
1815
  ` handler: async (ctx) => { planToggle(ctx); },`,
1620
1816
  ` });`,
1621
1817
  ` } catch {}`,
@@ -1624,7 +1820,7 @@ function buildPiPlanModeSection() {
1624
1820
  ` description: "Show plan mode state and the current step list",`,
1625
1821
  ` handler: async (_args, ctx) => {`,
1626
1822
  ` if (!planEnabled && !planExecuting && planSteps.length === 0) {`,
1627
- ` try { ctx.ui.notify("Plan mode is off. /plan (or Ctrl+Alt+P) to start planning.", "info"); } catch {}`,
1823
+ ` try { ctx.ui.notify("Plan mode is off. /plan (or Shift+Tab) to start planning.", "info"); } catch {}`,
1628
1824
  ` return;`,
1629
1825
  ` }`,
1630
1826
  ` const done = planSteps.filter((s) => s.completed).length;`,
@@ -1632,7 +1828,9 @@ function buildPiPlanModeSection() {
1632
1828
  ` ? "No steps parsed yet. Ask for a numbered Plan: block."`,
1633
1829
  ` : planSteps.map((s) => (s.completed ? "\\u2713 " : "\\u25CB ") + s.step + ". " + s.text).join("\\n");`,
1634
1830
  ` const head = planExecuting ? "Executing plan (" + done + "/" + planSteps.length + ")" : "Plan mode active";`,
1635
- ` try { ctx.ui.notify(head + "\\n" + body, "info"); } catch {}`,
1831
+ ` // Name THIS session's file: with a per-session path, "the plan file"`,
1832
+ ` // is no longer a single answer, and the human needs the real one.`,
1833
+ ` try { ctx.ui.notify(head + "\\n" + planRelFor(ctx) + "\\n" + body, "info"); } catch {}`,
1636
1834
  ` },`,
1637
1835
  ` });`,
1638
1836
  ` } catch {}`,
@@ -1653,10 +1851,11 @@ function buildPiPlanModeSection() {
1653
1851
  ` try { if (ctx && typeof ctx.cwd === "string" && ctx.cwd) planCwd = ctx.cwd; } catch {}`,
1654
1852
  ` const input = (event.input || {});`,
1655
1853
  ` const target = input.path !== undefined ? input.path : input.file_path;`,
1656
- ` if (isPlanFilePath(planCwd, target, PLAN_FILE_REL)) return undefined;`,
1854
+ ` const planFileRel = planRelFor(ctx);`,
1855
+ ` if (isPlanFilePath(planCwd, target, planFileRel)) return undefined;`,
1657
1856
  ` return {`,
1658
1857
  ` block: true,`,
1659
- ` reason: "Plan mode: this write is refused. The only file you may write is " + PLAN_FILE_REL + " (pass exactly that path). Record the plan there, or leave plan mode (/plan or Ctrl+Alt+P) to change code.",`,
1858
+ ` reason: "Plan mode: this write is refused. The only file you may write is " + planFileRel + " (pass exactly that path). Record the plan there, or leave plan mode (/plan or Shift+Tab) to change code.",`,
1660
1859
  ` };`,
1661
1860
  ` });`,
1662
1861
  ` } catch {}`,
@@ -1722,46 +1921,56 @@ function buildPiPlanModeSection() {
1722
1921
  ` // only write. The workflow is Claude's five phases compressed to what Pi`,
1723
1922
  ` // has: Explore/General-Purpose subagents exist, but the roster is`,
1724
1923
  ` // profile-dependent, so the phase text names the intent, not an agent.`,
1725
- ` const PLAN_BRIEF = [`,
1726
- ` "[PLAN MODE ACTIVE]",`,
1727
- ` "",`,
1728
- ` "Plan mode is active. The user does not want you to execute yet -- you must not edit files,",`,
1729
- ` "run a command that changes the code, or otherwise act on the plan. This supersedes any other",`,
1730
- ` "instruction you have received about doing the work now.",`,
1731
- ` "",`,
1732
- ` "One exception, and it is the whole of it: you may write your plan to",`,
1733
- ` " " + PLAN_FILE_REL,`,
1734
- ` "Edit and write are refused for every other path. Read, search, and run read-only commands",`,
1735
- ` "freely -- explore enough that the plan is grounded in what the code actually does.",`,
1736
- ` "",`,
1737
- ` "Work the plan like this:",`,
1738
- ` "1. Understand the request, and look for what already exists (functions, utilities, patterns)",`,
1739
- ` " before proposing anything new. Delegate broad or parallel discovery when that is faster",`,
1740
- ` " than reading serially yourself.",`,
1741
- ` "2. Ask the user whatever you cannot settle from the code. Do it once, up front, and never",`,
1742
- ` " ask what exploration could answer.",`,
1743
- ` "3. Design the approach far enough that an implementer would have no open decisions left:",`,
1744
- ` " which files, what changes in each, what each change is done when, and what would prove it.",`,
1745
- ` "4. Write the plan to the plan file: a short Context section, the recommended approach only,",`,
1746
- ` " the critical files, the verification steps, and any residual risk. Keep it scannable.",`,
1747
- ` "5. Summarise the plan in your reply too, so the user can answer without opening the file,",`,
1748
- ` " finishing with a numbered list of the steps -- that list becomes the checklist.",`,
1749
- ` "",`,
1750
- ` "Do NOT open an ask_user question or a prose prompt for plan approval. Leaving plan mode is",`,
1751
- ` "the user's action (/plan or Ctrl+Alt+P) -- asking permission to stop planning is the one",`,
1752
- ` "question this mode does not want, and approval you grant yourself is not approval.",`,
1753
- ` "If the user asks for changes, revise the SAME plan file rather than writing a second one.",`,
1754
- ` "The test for every other action: if it would reasonably be described as DOING the work",`,
1755
- ` "rather than planning it, it waits until plan mode is off.",`,
1756
- ` ].join("\\n");`,
1924
+ ` // Built per resolved path rather than as a module constant: the plan file`,
1925
+ ` // is per-session now, so a constant would name the wrong file for every`,
1926
+ ` // session but one. Called once per session (the result is cached on the`,
1927
+ ` // resolved path), not once per turn.`,
1928
+ ` let planBriefCache = { rel: "", text: "" };`,
1929
+ ` function planBriefFor(rel) {`,
1930
+ ` if (planBriefCache.rel === rel) return planBriefCache.text;`,
1931
+ ` const planBriefLines = [`,
1932
+ ` "[PLAN MODE ACTIVE]",`,
1933
+ ` "",`,
1934
+ ` "Plan mode is active. The user does not want you to execute yet -- you must not edit files,",`,
1935
+ ` "run a command that changes the code, or otherwise act on the plan. This supersedes any other",`,
1936
+ ` "instruction you have received about doing the work now.",`,
1937
+ ` "",`,
1938
+ ` "One exception, and it is the whole of it: you may write your plan to",`,
1939
+ ` " " + rel,`,
1940
+ ` "Edit and write are refused for every other path. Read, search, and run read-only commands",`,
1941
+ ` "freely -- explore enough that the plan is grounded in what the code actually does.",`,
1942
+ ` "",`,
1943
+ ` "Work the plan like this:",`,
1944
+ ` "1. Understand the request, and look for what already exists (functions, utilities, patterns)",`,
1945
+ ` " before proposing anything new. Delegate broad or parallel discovery when that is faster",`,
1946
+ ` " than reading serially yourself.",`,
1947
+ ` "2. Ask the user whatever you cannot settle from the code. Do it once, up front, and never",`,
1948
+ ` " ask what exploration could answer.",`,
1949
+ ` "3. Design the approach far enough that an implementer would have no open decisions left:",`,
1950
+ ` " which files, what changes in each, what each change is done when, and what would prove it.",`,
1951
+ ` "4. Write the plan to the plan file: a short Context section, the recommended approach only,",`,
1952
+ ` " the critical files, the verification steps, and any residual risk. Keep it scannable.",`,
1953
+ ` "5. Summarise the plan in your reply too, so the user can answer without opening the file,",`,
1954
+ ` " finishing with a numbered list of the steps -- that list becomes the checklist.",`,
1955
+ ` "",`,
1956
+ ` "Do NOT open an ask_user question or a prose prompt for plan approval. Leaving plan mode is",`,
1957
+ ` "the user's action (/plan or Shift+Tab) -- asking permission to stop planning is the one",`,
1958
+ ` "question this mode does not want, and approval you grant yourself is not approval.",`,
1959
+ ` "If the user asks for changes, revise this one plan file in place rather than writing a second plan.",`,
1960
+ ` "The test for every other action: if it would reasonably be described as DOING the work",`,
1961
+ ` "rather than planning it, it waits until plan mode is off.",`,
1962
+ ` ].join("\\n");`,
1963
+ ` planBriefCache = { rel: rel, text: planBriefLines };`,
1964
+ ` return planBriefLines;`,
1965
+ ` }`,
1757
1966
  ``,
1758
1967
  ` // Cost contract: inject NOTHING unless plan mode is actually engaged, and`,
1759
1968
  ` // only for a real user turn (a background notification must not re-add it).`,
1760
1969
  ` try {`,
1761
- ` pi.on("before_agent_start", async (event) => {`,
1970
+ ` pi.on("before_agent_start", async (event, ctx) => {`,
1762
1971
  ` if (!event || event.messageType !== "user") return undefined;`,
1763
1972
  ` if (planEnabled) {`,
1764
- ` return { message: { customType: PLAN_CONTEXT_TYPE, content: PLAN_BRIEF, display: false } };`,
1973
+ ` return { message: { customType: PLAN_CONTEXT_TYPE, content: planBriefFor(planRelFor(ctx)), display: false } };`,
1765
1974
  ` }`,
1766
1975
  ` if (planExecuting && planSteps.length > 0) {`,
1767
1976
  ` const remaining = planSteps.filter((s) => !s.completed).map((s) => s.step + ". " + s.text).join("\\n");`,
@@ -1852,7 +2061,7 @@ function buildPiPlanModeSection() {
1852
2061
  ` planPromptOpen = false;`,
1853
2062
  ` if (!choice) return;`,
1854
2063
  ` // The user may have left plan mode while the prompt was open (slash`,
1855
- ` // /plan, Ctrl+Alt+P, /new). Honouring Execute there would silently`,
2064
+ ` // /plan, Shift+Tab, /new). Honouring Execute there would silently`,
1856
2065
  ` // re-enter a mode they just exited.`,
1857
2066
  ` if (!planEnabled) return;`,
1858
2067
  ` if (String(choice).indexOf("Execute") === 0) {`,
@@ -1886,6 +2095,11 @@ function buildPiPlanModeSection() {
1886
2095
  ` pi.on("session_start", async (_event, ctx) => {`,
1887
2096
  ` try {`,
1888
2097
  ` if (ctx && typeof ctx.cwd === "string" && ctx.cwd) planCwd = ctx.cwd;`,
2098
+ ` // Re-resolve the plan file for THIS session. The id is stable across`,
2099
+ ` // resume, so a resumed session lands back on the file it started; a`,
2100
+ ` // fork or a new session gets its own, which is the whole point.`,
2101
+ ` planRel = "";`,
2102
+ ` planRelFor(ctx);`,
1889
2103
  ` const entries = ctx.sessionManager && typeof ctx.sessionManager.getEntries === "function"`,
1890
2104
  ` ? ctx.sessionManager.getEntries()`,
1891
2105
  ` : [];`,
@@ -3109,6 +3323,16 @@ const pi = defineCommand({
3109
3323
  ...cosmeticOverrides,
3110
3324
  ...mergedSubagents ? { subagents: mergedSubagents } : {}
3111
3325
  });
3326
+ const keybindingsPath = path.join(mirror, "keybindings.json");
3327
+ let userKeybindings = {};
3328
+ try {
3329
+ const raw = await fs$1.readFile(keybindingsPath, "utf8");
3330
+ const parsedKeybindings = JSON.parse(raw);
3331
+ if (parsedKeybindings && typeof parsedKeybindings === "object") userKeybindings = parsedKeybindings;
3332
+ } catch {
3333
+ userKeybindings = {};
3334
+ }
3335
+ await writeJsonFile(keybindingsPath, { ...mergePiKeybindingsSettings(userKeybindings, buildPiKeybindingsJson()) });
3112
3336
  packagesForCache = [...builtSettings.packages];
3113
3337
  if (await seedPiPackageCache(mirror, packagesForCache)) consola.debug("Pi package cache hit: mirror pre-seeded, skipping registry install.");
3114
3338
  const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
@@ -3250,7 +3474,7 @@ const pi = defineCommand({
3250
3474
  })}\n`);
3251
3475
  if (sweEnabled && !peersEnabled) process$1.stderr.write("Note: --swe without --peers emits no delegate/review skills or prompts (no agents behind them in a peerless launch).\n");
3252
3476
  const { disposeBluebirdClients } = await import("./bluebird-client-CY6NBHQu.js");
3253
- const { disposeAdoClients } = await import("./ado-tools-CAtopk36.js");
3477
+ const { disposeAdoClients } = await import("./ado-tools-WDyisN8w.js");
3254
3478
  launchChild({
3255
3479
  kind: "pi",
3256
3480
  envVars: {
@@ -3288,4 +3512,4 @@ const pi = defineCommand({
3288
3512
  //#endregion
3289
3513
  export { pi };
3290
3514
 
3291
- //# sourceMappingURL=pi-IYAvKF50.js.map
3515
+ //# sourceMappingURL=pi-BglhJ6n_.js.map