@herbertgao/pi-extensions 2026.10.8 → 2026.10.10

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 (68) hide show
  1. package/README.md +4 -3
  2. package/THIRD_PARTY_NOTICES.md +0 -26
  3. package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
  4. package/node_modules/@dietrichgebert/ponytail/README.md +16 -0
  5. package/node_modules/@dietrichgebert/ponytail/hooks/band/board.ts +560 -0
  6. package/node_modules/@dietrichgebert/ponytail/hooks/band/logo.ts +3 -0
  7. package/node_modules/@dietrichgebert/ponytail/hooks/band/metrics.ts +317 -0
  8. package/node_modules/@dietrichgebert/ponytail/hooks/band/register.tsx +472 -0
  9. package/node_modules/@dietrichgebert/ponytail/hooks/band/types.d.ts +35 -0
  10. package/node_modules/@dietrichgebert/ponytail/hooks/claude-band.json +6 -0
  11. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-band-import.js +274 -0
  12. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +43 -5
  13. package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
  14. package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +1 -1
  15. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +1 -2
  16. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +0 -1
  17. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +6 -0
  18. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +7 -5
  19. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -1
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +5 -0
  21. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +11 -0
  22. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/token-rate.ts +21 -5
  23. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts +23 -4
  24. package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +1 -1
  25. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -128
  26. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  27. package/package.json +3 -8
  28. package/node_modules/pi-multi-account/CHANGELOG.md +0 -1264
  29. package/node_modules/pi-multi-account/CONTRIBUTING.md +0 -61
  30. package/node_modules/pi-multi-account/LICENSE +0 -21
  31. package/node_modules/pi-multi-account/README.md +0 -277
  32. package/node_modules/pi-multi-account/SECURITY.md +0 -27
  33. package/node_modules/pi-multi-account/auth-file-transaction.ts +0 -56
  34. package/node_modules/pi-multi-account/child-usability.ts +0 -233
  35. package/node_modules/pi-multi-account/compaction-summary.ts +0 -32
  36. package/node_modules/pi-multi-account/completion-route-planner.ts +0 -224
  37. package/node_modules/pi-multi-account/config-file-transaction.ts +0 -42
  38. package/node_modules/pi-multi-account/context-guard.ts +0 -420
  39. package/node_modules/pi-multi-account/cursor/LICENSE +0 -21
  40. package/node_modules/pi-multi-account/cursor/NOTICE +0 -2
  41. package/node_modules/pi-multi-account/cursor/auth.ts +0 -165
  42. package/node_modules/pi-multi-account/cursor/bridge-handle.ts +0 -155
  43. package/node_modules/pi-multi-account/cursor/conversation-registry.ts +0 -104
  44. package/node_modules/pi-multi-account/cursor/cursor-models-raw.json +0 -611
  45. package/node_modules/pi-multi-account/cursor/cursor-shared.ts +0 -192
  46. package/node_modules/pi-multi-account/cursor/h2-bridge.mjs +0 -175
  47. package/node_modules/pi-multi-account/cursor/index.ts +0 -572
  48. package/node_modules/pi-multi-account/cursor/message-parsing.ts +0 -323
  49. package/node_modules/pi-multi-account/cursor/prompt-usage.ts +0 -53
  50. package/node_modules/pi-multi-account/cursor/proto/agent_pb.ts +0 -15294
  51. package/node_modules/pi-multi-account/cursor/proxy.ts +0 -2510
  52. package/node_modules/pi-multi-account/cursor/session-lifecycle.ts +0 -40
  53. package/node_modules/pi-multi-account/cursor/sse-keepalive.ts +0 -24
  54. package/node_modules/pi-multi-account/cursor/stream-lifecycle.ts +0 -193
  55. package/node_modules/pi-multi-account/cursor/upstream-watchdog.ts +0 -88
  56. package/node_modules/pi-multi-account/cursor-bridge.ts +0 -240
  57. package/node_modules/pi-multi-account/cursor-model-name.ts +0 -12
  58. package/node_modules/pi-multi-account/index.ts +0 -12340
  59. package/node_modules/pi-multi-account/model-catalog.ts +0 -354
  60. package/node_modules/pi-multi-account/model-pins.ts +0 -36
  61. package/node_modules/pi-multi-account/package.json +0 -104
  62. package/node_modules/pi-multi-account/pi-contract.ts +0 -281
  63. package/node_modules/pi-multi-account/provider-payload-stream.ts +0 -52
  64. package/node_modules/pi-multi-account/provider-priority.ts +0 -189
  65. package/node_modules/pi-multi-account/slot-proxy-auth.ts +0 -177
  66. package/node_modules/pi-multi-account/slot-proxy.ts +0 -366
  67. package/node_modules/pi-multi-account/state-file-transaction.ts +0 -67
  68. package/node_modules/pi-multi-account/usage.ts +0 -1128
@@ -1,155 +0,0 @@
1
- /**
2
- * The handle around one bridge child process.
3
- *
4
- * Cursor talks over a long-lived HTTP/2 stream, and the conversation is genuinely
5
- * bidirectional: while the model streams its answer, Cursor keeps asking us for blobs and we
6
- * keep answering on the same pipe. So the pipe can be closed from our side — a cancelled turn,
7
- * a session teardown, a compaction that starts a new conversation — while replies to Cursor's
8
- * requests are still in flight.
9
- *
10
- * A write into a closed pipe does not fail where it is written. Node reports
11
- * ERR_STREAM_WRITE_AFTER_END on a later tick, as an `error` event on the stream, which walks
12
- * straight past the try/catch at the call site and, with no listener, becomes an
13
- * uncaughtException that takes Pi down with it. That is exactly what happened after a
14
- * compaction closed the bridge and Cursor asked for one more blob.
15
- *
16
- * Hence two rules, both enforced here rather than at each of the dozen call sites:
17
- * - once ended, the handle is not alive and silently drops writes;
18
- * - every stream we own carries an error listener, so nothing the bridge does can ever
19
- * surface as an uncaught exception in the host process.
20
- */
21
-
22
- export interface BridgeStreams {
23
- stdin: {
24
- write(chunk: Uint8Array): unknown;
25
- end(): unknown;
26
- on(event: "error", listener: (error: Error) => void): unknown;
27
- readonly writableEnded?: boolean;
28
- readonly destroyed?: boolean;
29
- } | null;
30
- stdout: {
31
- on(event: "data" | "error", listener: (payload: never) => void): unknown;
32
- } | null;
33
- on(event: "exit" | "error", listener: (payload: never) => void): unknown;
34
- kill(signal?: NodeJS.Signals | number): unknown;
35
- }
36
-
37
- export interface BridgeHandle {
38
- proc: { kill(signal?: NodeJS.Signals | number): unknown };
39
- readonly alive: boolean;
40
- write(data: Uint8Array): void;
41
- end(): void;
42
- destroy(): void;
43
- onData(cb: (chunk: Buffer) => void): void;
44
- onClose(cb: (code: number) => void): void;
45
- }
46
-
47
- /** Length-prefix a frame the way the bridge process expects it. */
48
- export function lpEncode(data: Uint8Array): Buffer {
49
- const buf = Buffer.alloc(4 + data.length);
50
- buf.writeUInt32BE(data.length, 0);
51
- buf.set(data, 4);
52
- return buf;
53
- }
54
-
55
- export function createBridgeHandle(
56
- proc: BridgeStreams,
57
- hooks: { debug?: (event: string, data: Record<string, unknown>) => void } = {},
58
- ): BridgeHandle {
59
- const debug = hooks.debug ?? (() => {});
60
- const cbs = {
61
- data: null as ((chunk: Buffer) => void) | null,
62
- close: null as ((code: number) => void) | null,
63
- };
64
-
65
- let exited = false;
66
- let ended = false;
67
- let exitCode = 1;
68
-
69
- // The safety net. A late write, a broken pipe, a bridge that could not be spawned at all —
70
- // none of them may reach the host's uncaughtException handler.
71
- proc.stdin?.on("error", (error: Error) => {
72
- debug("bridge.stdin_error", { error: String(error) });
73
- });
74
- proc.stdout?.on("error", ((error: Error) => {
75
- debug("bridge.stdout_error", { error: String(error) });
76
- }) as never);
77
- proc.on("error", ((error: Error) => {
78
- debug("bridge.process_error", { error: String(error) });
79
- }) as never);
80
-
81
- let pending = Buffer.alloc(0);
82
- proc.stdout?.on("data", ((chunk: Buffer) => {
83
- pending = Buffer.concat([pending, chunk]);
84
- while (pending.length >= 4) {
85
- const len = pending.readUInt32BE(0);
86
- if (pending.length < 4 + len) break;
87
- const payload = pending.subarray(4, 4 + len);
88
- pending = pending.subarray(4 + len);
89
- cbs.data?.(Buffer.from(payload));
90
- }
91
- }) as never);
92
-
93
- proc.on("exit", ((code: number | null) => {
94
- exited = true;
95
- exitCode = code ?? 1;
96
- debug("bridge.exit", { exitCode });
97
- cbs.close?.(exitCode);
98
- }) as never);
99
-
100
- const writable = (): boolean => {
101
- if (exited || ended) return false;
102
- const stdin = proc.stdin;
103
- if (!stdin) return false;
104
- return !stdin.writableEnded && !stdin.destroyed;
105
- };
106
-
107
- const end = (): void => {
108
- if (ended) return;
109
- if (writable()) {
110
- try {
111
- proc.stdin!.write(lpEncode(new Uint8Array(0)));
112
- proc.stdin!.end();
113
- } catch (error) {
114
- debug("bridge.end_failed", { error: String(error) });
115
- }
116
- }
117
- ended = true;
118
- };
119
-
120
- return {
121
- proc,
122
- // Ended counts as dead: a caller that asks `alive` is deciding whether to keep talking on
123
- // this pipe, and the answer for a pipe we closed ourselves is no.
124
- get alive() { return !exited && !ended; },
125
- write(data: Uint8Array) {
126
- if (!writable()) {
127
- debug("bridge.write_after_end", { bytes: data.length, exited, ended });
128
- return;
129
- }
130
- try {
131
- proc.stdin!.write(lpEncode(data));
132
- } catch (error) {
133
- debug("bridge.write_failed", { error: String(error) });
134
- }
135
- },
136
- end,
137
- destroy() {
138
- end();
139
- if (exited) return;
140
- try {
141
- proc.kill();
142
- } catch (error) {
143
- debug("bridge.kill_failed", { error: String(error) });
144
- }
145
- },
146
- onData(cb: (chunk: Buffer) => void) { cbs.data = cb; },
147
- onClose(cb: (code: number) => void) {
148
- if (exited) {
149
- queueMicrotask(() => cb(exitCode));
150
- } else {
151
- cbs.close = cb;
152
- }
153
- },
154
- };
155
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * Where a Cursor conversation lives between requests.
3
- *
4
- * Cursor is stateful: once we hold a checkpoint for a conversation, the bridge replays that
5
- * checkpoint instead of the message list Pi sent, and Cursor answers from its own copy of the
6
- * history. That is fine while Pi and Cursor agree on what the history is — and wrong the moment
7
- * Pi compacts, because Pi's short summary never reaches Cursor and Cursor's `usedTokens` keeps
8
- * reporting the full pre-compaction size back to Pi.
9
- *
10
- * So the registry owns two things: the stored conversations, and a per-conversation generation
11
- * counter. Bumping the generation mints a new Cursor conversation id, which is how a compaction
12
- * is made to actually take effect — the checkpoint is dropped AND the old server-side
13
- * conversation is left behind rather than resumed under the same id.
14
- *
15
- * It is a separate module from proxy.ts on purpose: proxy.ts pulls in generated protobuf code
16
- * with non-erasable `enum`s, which Node's type stripping refuses to load, so nothing in it can
17
- * be unit-tested directly.
18
- */
19
- import { createHash } from "node:crypto";
20
-
21
- export interface StoredConversation {
22
- conversationId: string;
23
- checkpoint: Uint8Array | null;
24
- sessionScoped: boolean;
25
- blobStore: Map<string, Uint8Array>;
26
- lastAccessMs: number;
27
- /**
28
- * How many completed turns of Pi's transcript this conversation has actually seen. Cursor
29
- * answers from its own copy of the history, so anything that happened while the session was
30
- * on another provider is invisible to it — and rotation moves the session between accounts
31
- * constantly. See {@link isStaleForTranscript}.
32
- */
33
- turnsCovered: number;
34
- }
35
-
36
- /**
37
- * Has the session moved on without Cursor?
38
- *
39
- * Between two consecutive requests on this conversation the transcript grows by at most one
40
- * completed turn — the one we just answered. A bigger jump means turns were completed
41
- * somewhere Cursor never saw: a failover to another provider and back, a branch, another
42
- * client. Its checkpoint is then a conversation with a hole in it, and resuming from it hands
43
- * the model a past that is missing whatever happened while it was away.
44
- *
45
- * Rebuilding costs tokens; resuming a stale checkpoint costs correctness, silently. So the
46
- * doubt is resolved toward rebuilding.
47
- */
48
- export function isStaleForTranscript(stored: StoredConversation, completedTurns: number): boolean {
49
- if (!stored.checkpoint) return false;
50
- return completedTurns > stored.turnsCovered + 1;
51
- }
52
-
53
- export const conversationStates = new Map<string, StoredConversation>();
54
-
55
- /** How many times this conversation has been restarted (compaction, mostly). */
56
- const conversationGenerations = new Map<string, number>();
57
-
58
- export function deriveBridgeKeyFromSessionId(sessionId: string): string {
59
- return createHash("sha256").update(`bridge:${sessionId}`).digest("hex").slice(0, 16);
60
- }
61
-
62
- export function deriveConversationKeyFromSessionId(sessionId: string): string {
63
- return createHash("sha256").update(`conv:${sessionId}`).digest("hex").slice(0, 16);
64
- }
65
-
66
- export function conversationGeneration(convKey: string): number {
67
- return conversationGenerations.get(convKey) ?? 0;
68
- }
69
-
70
- /**
71
- * Stable per (conversation, generation) so a retried request rejoins the same Cursor
72
- * conversation, while a post-compaction request starts a new one.
73
- */
74
- export function deterministicConversationId(convKey: string, generation = conversationGeneration(convKey)): string {
75
- const seed = generation > 0 ? `cursor-conv-id:${convKey}#${generation}` : `cursor-conv-id:${convKey}`;
76
- const hex = createHash("sha256").update(seed).digest("hex").slice(0, 32);
77
- return [
78
- hex.slice(0, 8), hex.slice(8, 12),
79
- `4${hex.slice(13, 16)}`,
80
- `${(0x8 | (parseInt(hex[16], 16) & 0x3)).toString(16)}${hex.slice(17, 20)}`,
81
- hex.slice(20, 32),
82
- ].join("-");
83
- }
84
-
85
- /**
86
- * Forget everything Cursor is holding for this conversation and move to a fresh id.
87
- * Returns whether a conversation was actually stored, for logging.
88
- */
89
- export function forgetConversation(convKey: string): boolean {
90
- const existed = conversationStates.delete(convKey);
91
- conversationGenerations.set(convKey, conversationGeneration(convKey) + 1);
92
- return existed;
93
- }
94
-
95
- /** Drop a conversation for good — the session itself is gone, so its generation is noise. */
96
- export function dropConversation(convKey: string): boolean {
97
- conversationGenerations.delete(convKey);
98
- return conversationStates.delete(convKey);
99
- }
100
-
101
- export function clearConversationRegistry(): void {
102
- conversationStates.clear();
103
- conversationGenerations.clear();
104
- }