@oh-my-pi/pi-coding-agent 16.3.4 → 16.3.6

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 (88) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/cli.js +3522 -3485
  3. package/dist/types/edit/file-snapshot-store.d.ts +4 -2
  4. package/dist/types/edit/renderer.d.ts +0 -1
  5. package/dist/types/extensibility/custom-tools/types.d.ts +2 -0
  6. package/dist/types/extensibility/shared-events.d.ts +8 -1
  7. package/dist/types/hindsight/content.d.ts +4 -0
  8. package/dist/types/internal-urls/artifact-protocol.d.ts +8 -0
  9. package/dist/types/internal-urls/types.d.ts +10 -0
  10. package/dist/types/lsp/config.d.ts +4 -0
  11. package/dist/types/lsp/edits.d.ts +2 -0
  12. package/dist/types/mcp/oauth-discovery.d.ts +30 -0
  13. package/dist/types/modes/components/assistant-message.d.ts +15 -10
  14. package/dist/types/modes/components/bash-execution.d.ts +6 -0
  15. package/dist/types/modes/components/eval-execution.d.ts +6 -0
  16. package/dist/types/modes/components/login-dialog.d.ts +10 -2
  17. package/dist/types/modes/components/tool-execution.d.ts +3 -13
  18. package/dist/types/modes/components/transcript-container.d.ts +26 -29
  19. package/dist/types/modes/controllers/mcp-command-controller.d.ts +20 -3
  20. package/dist/types/modes/rpc/rpc-client.d.ts +7 -3
  21. package/dist/types/modes/rpc/rpc-types.d.ts +6 -0
  22. package/dist/types/modes/utils/transcript-render-helpers.d.ts +15 -6
  23. package/dist/types/session/agent-session.d.ts +2 -0
  24. package/dist/types/subprocess/worker-runtime.d.ts +11 -0
  25. package/dist/types/tools/bash-skill-urls.d.ts +2 -2
  26. package/dist/types/tools/bash.d.ts +0 -2
  27. package/dist/types/tools/browser/tab-supervisor.d.ts +10 -0
  28. package/dist/types/tools/eval-render.d.ts +0 -2
  29. package/dist/types/tools/renderers.d.ts +0 -20
  30. package/dist/types/tools/ssh.d.ts +0 -2
  31. package/dist/types/tools/write.d.ts +1 -1
  32. package/dist/types/utils/git.d.ts +16 -0
  33. package/package.json +12 -12
  34. package/src/cli/auth-broker-cli.ts +13 -2
  35. package/src/cli/tiny-models-cli.ts +12 -5
  36. package/src/edit/file-snapshot-store.ts +5 -2
  37. package/src/edit/renderer.ts +0 -5
  38. package/src/extensibility/custom-tools/types.ts +2 -0
  39. package/src/extensibility/shared-events.ts +9 -1
  40. package/src/hindsight/content.ts +31 -0
  41. package/src/internal-urls/artifact-protocol.ts +97 -53
  42. package/src/internal-urls/types.ts +10 -0
  43. package/src/lsp/config.ts +15 -0
  44. package/src/lsp/edits.ts +28 -7
  45. package/src/lsp/index.ts +46 -4
  46. package/src/mcp/oauth-discovery.ts +88 -18
  47. package/src/mnemopi/state.ts +26 -2
  48. package/src/modes/components/assistant-message.ts +134 -82
  49. package/src/modes/components/bash-execution.ts +9 -0
  50. package/src/modes/components/chat-transcript-builder.ts +8 -4
  51. package/src/modes/components/eval-execution.ts +9 -0
  52. package/src/modes/components/login-dialog.ts +16 -2
  53. package/src/modes/components/mcp-add-wizard.ts +9 -1
  54. package/src/modes/components/tool-execution.ts +4 -50
  55. package/src/modes/components/transcript-container.ts +82 -458
  56. package/src/modes/components/tree-selector.ts +9 -3
  57. package/src/modes/controllers/command-controller.ts +0 -3
  58. package/src/modes/controllers/event-controller.ts +74 -14
  59. package/src/modes/controllers/extension-ui-controller.ts +0 -1
  60. package/src/modes/controllers/input-controller.ts +4 -10
  61. package/src/modes/controllers/mcp-command-controller.ts +106 -29
  62. package/src/modes/controllers/selector-controller.ts +9 -1
  63. package/src/modes/interactive-mode.ts +12 -8
  64. package/src/modes/rpc/rpc-client.ts +8 -4
  65. package/src/modes/rpc/rpc-mode.ts +1 -0
  66. package/src/modes/rpc/rpc-types.ts +13 -1
  67. package/src/modes/setup-wizard/scenes/sign-in.ts +18 -0
  68. package/src/modes/utils/transcript-render-helpers.ts +40 -13
  69. package/src/modes/utils/ui-helpers.ts +12 -7
  70. package/src/prompts/tools/read.md +1 -1
  71. package/src/sdk.ts +1 -0
  72. package/src/session/agent-session.ts +148 -1
  73. package/src/session/session-context.ts +7 -0
  74. package/src/subprocess/worker-runtime.ts +219 -2
  75. package/src/task/worktree.ts +28 -6
  76. package/src/tiny/worker.ts +14 -4
  77. package/src/tools/bash-skill-urls.ts +3 -3
  78. package/src/tools/bash.ts +0 -4
  79. package/src/tools/browser/tab-supervisor.ts +47 -3
  80. package/src/tools/eval-render.ts +0 -20
  81. package/src/tools/grep.ts +19 -2
  82. package/src/tools/path-utils.ts +4 -0
  83. package/src/tools/read.ts +261 -21
  84. package/src/tools/renderers.ts +0 -20
  85. package/src/tools/ssh.ts +0 -16
  86. package/src/tools/write.ts +13 -6
  87. package/src/utils/git.ts +20 -0
  88. package/src/utils/open.ts +51 -6
@@ -61,6 +61,15 @@ export class EvalExecutionComponent extends Container {
61
61
  this.#contentContainer.addChild(this.#loader);
62
62
  }
63
63
 
64
+ /**
65
+ * Transcript finalization contract (see `FinalizableBlock`): the collapsed
66
+ * streaming preview rewrites its tail window every chunk, so the block must
67
+ * stay out of native scrollback until the cell completes.
68
+ */
69
+ isTranscriptBlockFinalized(): boolean {
70
+ return this.#status !== "running";
71
+ }
72
+
64
73
  setExpanded(expanded: boolean): void {
65
74
  this.#expanded = expanded;
66
75
  this.#updateDisplay();
@@ -68,9 +68,17 @@ export class LoginDialogComponent extends Container {
68
68
  }
69
69
 
70
70
  /**
71
- * Called by onAuth callback - show URL and optional instructions
71
+ * Called by the OAuth `onAuth` callback. Renders the full authorization URL
72
+ * as the primary copy target — that works from any machine, including
73
+ * SSH/WSL/headless sessions where the OMP-hosted `launchUrl` would resolve
74
+ * against the user's local browser and fail. When `launchUrl` is present it
75
+ * is offered as an additional local shortcut so narrow local terminals still
76
+ * have a truncation-safe copy target (viewport clipping on a long authorize
77
+ * URL silently drops trailing OAuth query parameters — e.g.
78
+ * `code_challenge_method=S256`). The OSC 8 hyperlink carries the full URL
79
+ * for terminals that support click-through.
72
80
  */
73
- showAuth(url: string, instructions?: string): void {
81
+ showAuth(url: string, instructions?: string, launchUrl?: string): void {
74
82
  this.#contentContainer.clear();
75
83
  this.#contentContainer.addChild(new Spacer(1));
76
84
  this.#contentContainer.addChild(new Text(theme.fg("accent", url), 1, 0));
@@ -79,6 +87,12 @@ export class LoginDialogComponent extends Container {
79
87
  const hyperlink = `\x1b]8;;${url}\x07${clickHint}\x1b]8;;\x07`;
80
88
  this.#contentContainer.addChild(new Text(theme.fg("dim", hyperlink), 1, 0));
81
89
 
90
+ if (launchUrl && launchUrl !== url) {
91
+ this.#contentContainer.addChild(
92
+ new Text(theme.fg("dim", `Local shortcut (this machine only): ${launchUrl}`), 1, 0),
93
+ );
94
+ }
95
+
82
96
  if (instructions) {
83
97
  this.#contentContainer.addChild(new Spacer(1));
84
98
  this.#contentContainer.addChild(new Text(theme.fg("warning", instructions), 1, 0));
@@ -15,7 +15,7 @@ import {
15
15
  } from "@oh-my-pi/pi-tui";
16
16
  import { getMCPConfigPath, getProjectDir } from "@oh-my-pi/pi-utils";
17
17
  import { validateServerName } from "../../mcp/config-writer";
18
- import { analyzeAuthError, discoverOAuthEndpoints } from "../../mcp/oauth-discovery";
18
+ import { analyzeAuthError, discoverOAuthEndpoints, fetchResourceMetadataScopes } from "../../mcp/oauth-discovery";
19
19
  import type { MCPHttpServerConfig, MCPServerConfig, MCPSseServerConfig, MCPStdioServerConfig } from "../../mcp/types";
20
20
  import { shortenPath } from "../../tools/render-utils";
21
21
  import { theme } from "../theme/theme";
@@ -1009,11 +1009,19 @@ export class MCPAddWizard extends Container {
1009
1009
  this.#state.url,
1010
1010
  authResult.authServerUrl,
1011
1011
  authResult.resourceMetadataUrl,
1012
+ { protectedScopes: authResult.scopes },
1012
1013
  );
1013
1014
  } catch {
1014
1015
  // Ignore discovery failures and fallback to manual auth.
1015
1016
  }
1016
1017
  }
1018
+ if (oauth && !oauth.scopes && authResult.resourceMetadataUrl) {
1019
+ // JSON-error-body path skips `discoverOAuthEndpoints` when the body
1020
+ // already carries endpoints, so scopes advertised only in the
1021
+ // protected-resource metadata document never reach the grant.
1022
+ const scopes = await fetchResourceMetadataScopes(authResult.resourceMetadataUrl);
1023
+ if (scopes) oauth = { ...oauth, scopes };
1024
+ }
1017
1025
 
1018
1026
  if (oauth) {
1019
1027
  this.#state.oauthAuthUrl = oauth.authorizationUrl;
@@ -697,12 +697,12 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
697
697
  /**
698
698
  * Standalone harnesses may mount a tool component directly under `TUI`
699
699
  * instead of inside `TranscriptContainer`. In that shape the component must
700
- * report its own live-region seam for provisional previews, or the core
701
- * renderer treats it like shell output and commits tail-window edit/eval/bash
702
- * previews to immutable native scrollback before the result replaces them.
700
+ * report its own live-region seam while unfinalized, or the core renderer
701
+ * treats it like shell output and commits still-mutating preview rows to
702
+ * immutable native scrollback before the result replaces them.
703
703
  */
704
704
  getNativeScrollbackLiveRegionStart(): number | undefined {
705
- return !this.isTranscriptBlockFinalized() && !this.isTranscriptBlockCommitStable() ? 0 : undefined;
705
+ return this.isTranscriptBlockFinalized() ? undefined : 0;
706
706
  }
707
707
 
708
708
  /**
@@ -726,52 +726,6 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
726
726
  return (this.#result.details as { async?: { state?: string } } | undefined)?.async?.state === "running";
727
727
  }
728
728
 
729
- /**
730
- * Whether this still-live block's settled rows may enter native scrollback
731
- * (see `FinalizableBlock.isTranscriptBlockCommitStable`). Renderers classify
732
- * pending views by durability instead of by tool name: a provisional view is
733
- * allowed to be useful on screen, but finalization may replace or re-anchor
734
- * it wholesale, so committing any of its rows would strand stale preview
735
- * bytes in immutable scrollback. Non-provisional views stream rows whose
736
- * committed prefix survives the remaining transitions.
737
- */
738
- isTranscriptBlockCommitStable(): boolean {
739
- if (this.#displaceableByToolName) return false;
740
- if (this.isTranscriptBlockFinalized()) return true;
741
- // `provisionalPendingPreview` describes only the PENDING call preview
742
- // (`renderCall`, before any result): the result render may re-anchor it
743
- // wholesale, so its rows must never commit. Once a (streaming partial)
744
- // result exists the result renderer is usually the live shape — its body
745
- // is top-anchored and grows append-only, and `deriveLiveCommitState`
746
- // gates per-row durability — so the block is commit-stable like any
747
- // settled stream. Gating the flag on the pending phase is what keeps a
748
- // collapsed streaming eval/bash/ssh whose box outgrows the viewport from
749
- // stranding its head: while commit-unstable its scrolled-off top
750
- // committed nowhere and repainted nowhere, so it read as truncated until
751
- // ctrl+o (expanded) flipped it stable.
752
- //
753
- // Renderers whose partial-result chrome (header glyph, frame state)
754
- // differs from the final result render set `provisionalPartialResult`
755
- // to opt out of stream-commit while `isPartial` holds: the ratchet
756
- // would otherwise promote the stable partial chrome to native scrollback
757
- // after `STABLE_PREFIX_COMMIT_FRAMES` and leave it stranded above the
758
- // final frame once the chrome flips. Once the result settles
759
- // (`isPartial === false`) the block is commit-stable again.
760
- if (this.#result !== undefined) {
761
- if (this.#isPartial) {
762
- const tool = this.#tool as { provisionalPartialResult?: boolean } | undefined;
763
- const provisionalPartialResult =
764
- tool?.provisionalPartialResult ?? toolRenderers[this.#toolName]?.provisionalPartialResult;
765
- if (provisionalPartialResult) return false;
766
- }
767
- return true;
768
- }
769
- const tool = this.#tool as { provisionalPendingPreview?: boolean | "collapsed" } | undefined;
770
- const provisionalPendingPreview =
771
- tool?.provisionalPendingPreview ?? toolRenderers[this.#toolName]?.provisionalPendingPreview;
772
- return provisionalPendingPreview !== true && (provisionalPendingPreview !== "collapsed" || this.#expanded);
773
- }
774
-
775
729
  /**
776
730
  * Mark the tool terminal even though no result arrived (the turn aborted or
777
731
  * abandoned it) and stop animating, so it can freeze and stops pinning the