@herbertgao/pi-extensions 2026.10.9 → 2026.10.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 +13 -9
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/README.md +16 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/board.ts +560 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/logo.ts +3 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/metrics.ts +317 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/register.tsx +472 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/types.d.ts +35 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-band.json +6 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-band-import.js +274 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +43 -5
- package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +1 -2
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +0 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +10 -5
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +14 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/token-rate.ts +21 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts +23 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +126 -42
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -128
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +24 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +69 -16
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/sol-pi/README.md +7 -1
- package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +28 -4
- package/node_modules/@herbertgao/sol-pi/docs/configuration.md +17 -4
- package/node_modules/@herbertgao/sol-pi/package.json +1 -1
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/index.ts +35 -25
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/then-run.ts +95 -26
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/candidate.ts +39 -2
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/index.ts +24 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/observation-pack/index.ts +12 -7
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/extension.ts +138 -130
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/projection.ts +88 -14
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/tools.ts +9 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/index.ts +14 -5
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/shell-options.ts +22 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/tui.ts +11 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/answer-channel.ts +109 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +117 -71
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +2 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/startup-performance.md +83 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +74 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/events.ts +84 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/index.ts +10 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/reconcile.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +5 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +19 -19
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/i18n-bridge.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +10 -10
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/row-intent.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/contract.ts +6 -6
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/focus.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +9 -9
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +5 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/external-answer.ts +125 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/validate-questionnaire.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/component-binding.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/option-list-view.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/markdown-content-cache.ts +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +5 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-layout-decider.ts +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +10 -10
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/submit-picker.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/tab-bar.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/wrapping-select.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +9 -9
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/props-adapter.ts +8 -8
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-components.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +10 -10
- package/node_modules/@narumitw/pi-btw/dist/index.ts +3 -0
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +6 -0
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +1 -1
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +1 -0
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +1 -0
- package/node_modules/pi-antigravity/README.md +6 -2
- package/node_modules/pi-antigravity/package.json +2 -2
- package/node_modules/pi-antigravity/src/client/client.ts +44 -52
- package/node_modules/pi-antigravity/src/index.ts +13 -0
- package/node_modules/pi-antigravity/src/models/discovery.ts +25 -2
- package/node_modules/pi-antigravity/src/models/grouping.ts +107 -68
- package/node_modules/pi-antigravity/src/models/models.ts +10 -0
- package/node_modules/pi-antigravity/src/search/search.ts +581 -43
- package/node_modules/pi-antigravity/src/stream/stream.ts +53 -13
- package/node_modules/pi-antigravity/src/types/types.ts +13 -0
- package/node_modules/pi-antigravity/src/usage/usage.ts +11 -3
- package/node_modules/pi-web-access/CHANGELOG.md +21 -0
- package/node_modules/pi-web-access/README.md +22 -7
- package/node_modules/pi-web-access/credential-source.ts +54 -4
- package/node_modules/pi-web-access/curator-page.ts +3 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/deepseek.ts +204 -0
- package/node_modules/pi-web-access/dist/index.js +927 -642
- package/node_modules/pi-web-access/dist/mcp-cli.js +877 -615
- package/node_modules/pi-web-access/gemini-adc.ts +48 -1
- package/node_modules/pi-web-access/gemini-search.ts +8 -4
- package/node_modules/pi-web-access/index.ts +16 -1
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/page-query.ts +12 -6
- package/node_modules/pi-web-access/query-rewrite.ts +16 -13
- package/node_modules/pi-web-access/summary-review.ts +16 -6
- package/node_modules/pi-web-access/utils.ts +3 -0
- package/node_modules/pi-web-access/web-tool-core.ts +2 -0
- package/package.json +10 -10
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ponytail — imports past Claude Code sessions into the band's task ledger, so the board can
|
|
3
|
+
// compare them: cost, agent time, tokens, turns, name and model. Started in the background by
|
|
4
|
+
// `/ponytail band import`; also runs by hand. Sessions already in the ledger are left alone.
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const { spawnSync } = require('child_process');
|
|
10
|
+
const { StringDecoder } = require('string_decoder');
|
|
11
|
+
const { getClaudeDir } = require('./ponytail-config');
|
|
12
|
+
|
|
13
|
+
// The band's columns (CSV_HEADER in hooks/band/metrics.ts; a test keeps the two equal).
|
|
14
|
+
const CSV_HEADER = 'key,started,project,name,cost_usd,turns,agent_minutes,tokens_total,tokens_output,reuse_pct,reused,new,callers_open,tests,level,model';
|
|
15
|
+
|
|
16
|
+
// USD per million tokens from https://platform.claude.com/docs/en/about-claude/pricing, checked
|
|
17
|
+
// 2026-10-17: [input, 5-minute cache write, 1-hour cache write, cache read, output]. Opus 5.5 and
|
|
18
|
+
// Fable 5.1 also match Claude Code's own totals in real transcripts. A model missing here, or a
|
|
19
|
+
// fast-mode reply, gets no estimate: an empty cost beats a guessed one.
|
|
20
|
+
const OPUS = [5, 6.25, 10, 0.5, 25];
|
|
21
|
+
const PRICES = {
|
|
22
|
+
'claude-fable-5-1': [10, 12.5, 20, 0.25, 50],
|
|
23
|
+
'claude-fable-5': [10, 12.5, 20, 1, 50],
|
|
24
|
+
'claude-opus-5-5': [4, 5, 8, 0.2, 20],
|
|
25
|
+
'claude-opus-5': OPUS,
|
|
26
|
+
'claude-opus-4-8': OPUS,
|
|
27
|
+
'claude-opus-4-7': OPUS,
|
|
28
|
+
'claude-opus-4-6': OPUS,
|
|
29
|
+
'claude-opus-4-5': OPUS,
|
|
30
|
+
'claude-sonnet-5-5': [2, 2.5, 4, 0.1, 10],
|
|
31
|
+
'claude-sonnet-5': [2, 2.5, 4, 0.2, 10],
|
|
32
|
+
'claude-sonnet-4-6': [3, 3.75, 6, 0.3, 15],
|
|
33
|
+
'claude-sonnet-4-5': [3, 3.75, 6, 0.3, 15],
|
|
34
|
+
'claude-haiku-5-5': [0.1, 0.125, 0.2, 0.01, 0.5],
|
|
35
|
+
'claude-haiku-4-5': [1, 1.25, 2, 0.1, 5],
|
|
36
|
+
};
|
|
37
|
+
// Haiku 5.5 bills a request whose prompt (input, cache reads and writes) is over 100,000 tokens higher.
|
|
38
|
+
const HAIKU_55_LONG = [0.5, 0.625, 1, 0.05, 2.5];
|
|
39
|
+
const WEB_SEARCH = 10 / 1000;
|
|
40
|
+
const IDLE_MS = 30 * 60000;
|
|
41
|
+
const modelId = m => m.replace(/\[.*\]$/, '').replace(/-\d{8}$/, '');
|
|
42
|
+
|
|
43
|
+
// One reply's price from its usage, or null when the price is not known.
|
|
44
|
+
function replyCost(model, u) {
|
|
45
|
+
let p = PRICES[modelId(model)];
|
|
46
|
+
if (!p || u.speed === 'fast') return null;
|
|
47
|
+
const cc = u.cache_creation || {};
|
|
48
|
+
const split = cc.ephemeral_5m_input_tokens !== undefined || cc.ephemeral_1h_input_tokens !== undefined;
|
|
49
|
+
const w5 = split ? cc.ephemeral_5m_input_tokens || 0 : u.cache_creation_input_tokens || 0;
|
|
50
|
+
const w1 = split ? cc.ephemeral_1h_input_tokens || 0 : 0;
|
|
51
|
+
const input = u.input_tokens || 0;
|
|
52
|
+
const read = u.cache_read_input_tokens || 0;
|
|
53
|
+
if (modelId(model) === 'claude-haiku-5-5' && input + read + w5 + w1 > 100000) p = HAIKU_55_LONG;
|
|
54
|
+
const searches = (u.server_tool_use && u.server_tool_use.web_search_requests) || 0;
|
|
55
|
+
return (input * p[0] + w5 * p[1] + w1 * p[2] + read * p[3] + (u.output_tokens || 0) * p[4]) / 1e6 + searches * WEB_SEARCH;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const human = r => r.type === 'user' && (r.turnOrigin === 'human' || (r.origin && r.origin.kind === 'human'));
|
|
59
|
+
const promptText = r => {
|
|
60
|
+
const c = r.message && r.message.content;
|
|
61
|
+
const t = typeof c === 'string' ? c : Array.isArray(c) ? (c.find(b => b && b.type === 'text') || {}).text || '' : '';
|
|
62
|
+
return t.trim();
|
|
63
|
+
};
|
|
64
|
+
const ms = r => (r.timestamp ? Date.parse(r.timestamp) : NaN);
|
|
65
|
+
const toolResult = r => (r.toolResult !== undefined ? r.toolResult
|
|
66
|
+
: Array.isArray(r.message && r.message.content) && r.message.content.some(b => b && b.type === 'tool_result'));
|
|
67
|
+
|
|
68
|
+
// Only what the numbers need from one record: a long session's transcript can pass 500 MB.
|
|
69
|
+
function slim(r) {
|
|
70
|
+
const m = r.message || {};
|
|
71
|
+
const c = human(r) ? m.content : undefined;
|
|
72
|
+
const text = typeof c === 'string' ? c.slice(0, 500)
|
|
73
|
+
: Array.isArray(c) ? c.filter(b => b && b.type === 'text').slice(0, 1).map(b => ({ type: 'text', text: String(b.text).slice(0, 500) })) : undefined;
|
|
74
|
+
return {
|
|
75
|
+
type: r.type, timestamp: r.timestamp, turnOrigin: r.turnOrigin, origin: r.origin && { kind: r.origin.kind },
|
|
76
|
+
isMeta: r.isMeta, toolResult: toolResult(r),
|
|
77
|
+
sessionId: r.sessionId, customTitle: r.customTitle, totalCostUSD: r.totalCostUSD,
|
|
78
|
+
message: { id: m.id, model: m.model, usage: m.usage, content: text },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// A JSONL file line by line, so no transcript is too big to read (one string stops at 512 MB).
|
|
83
|
+
function readRecords(file) {
|
|
84
|
+
const out = [];
|
|
85
|
+
const take = l => { if (l.startsWith('{')) try { out.push(slim(JSON.parse(l))); } catch (e) {} };
|
|
86
|
+
const fd = fs.openSync(file, 'r');
|
|
87
|
+
const buf = Buffer.alloc(1 << 20);
|
|
88
|
+
const dec = new StringDecoder('utf8');
|
|
89
|
+
let rest = '';
|
|
90
|
+
try {
|
|
91
|
+
for (let n; (n = fs.readSync(fd, buf, 0, buf.length, null)) > 0;) {
|
|
92
|
+
const parts = (rest + dec.write(buf.subarray(0, n))).split('\n');
|
|
93
|
+
rest = parts.pop();
|
|
94
|
+
parts.forEach(take);
|
|
95
|
+
}
|
|
96
|
+
take(rest + dec.end());
|
|
97
|
+
} finally {
|
|
98
|
+
fs.closeSync(fd);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// One session's numbers from its transcript records and its subagents' records. Null for a session
|
|
104
|
+
// nobody typed into (benchmarks, `claude -p`, scripts) or one without a model reply.
|
|
105
|
+
function sessionStats(records, subagentRecords = [], sessionId = '') {
|
|
106
|
+
const prompts = records.filter(human);
|
|
107
|
+
if (prompts.length === 0) return null;
|
|
108
|
+
|
|
109
|
+
// Usage repeats on every record of one message: count each message id once, subagents included.
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
const replies = {};
|
|
112
|
+
let tokens = 0;
|
|
113
|
+
let output = 0;
|
|
114
|
+
let estimate = 0;
|
|
115
|
+
const reply = r => r.type === 'assistant' && r.message && r.message.model && r.message.model !== '<synthetic>';
|
|
116
|
+
for (const r of records) if (reply(r)) replies[r.message.model] = (replies[r.message.model] || 0) + 1;
|
|
117
|
+
for (const r of [...records, ...subagentRecords]) {
|
|
118
|
+
if (!reply(r)) continue;
|
|
119
|
+
const { id, model, usage } = r.message;
|
|
120
|
+
if (!usage || !id || seen.has(id)) continue;
|
|
121
|
+
seen.add(id);
|
|
122
|
+
tokens += (usage.input_tokens || 0) + (usage.output_tokens || 0) + (usage.cache_read_input_tokens || 0) + (usage.cache_creation_input_tokens || 0);
|
|
123
|
+
output += usage.output_tokens || 0;
|
|
124
|
+
const c = replyCost(model, usage);
|
|
125
|
+
estimate = estimate === null || c === null ? null : estimate + c;
|
|
126
|
+
}
|
|
127
|
+
const models = Object.keys(replies);
|
|
128
|
+
if (models.length === 0) return null;
|
|
129
|
+
|
|
130
|
+
// A turn starts with any new message: a typed prompt, a slash command (not marked as typed) or a
|
|
131
|
+
// background notification. It lasts until the model's last reply or tool result before the next
|
|
132
|
+
// one, so time waiting between messages, even days before a session is reopened, never counts.
|
|
133
|
+
let turns = 0;
|
|
134
|
+
let agentMs = 0;
|
|
135
|
+
const starts = r => r.type === 'user' && !toolResult(r) && !r.isMeta;
|
|
136
|
+
const at = records.map((r, i) => (starts(r) ? i : -1)).filter(i => i >= 0);
|
|
137
|
+
for (let k = 0; k < at.length; k++) {
|
|
138
|
+
const work = records.slice(at[k] + 1, k + 1 < at.length ? at[k + 1] : records.length)
|
|
139
|
+
.filter(r => r.type === 'assistant' || (r.type === 'user' && toolResult(r)));
|
|
140
|
+
if (!work.some(r => r.type === 'assistant')) continue;
|
|
141
|
+
turns++;
|
|
142
|
+
// A pause of over 30 minutes inside a turn is someone not answering a permission prompt, not work.
|
|
143
|
+
// shortcut: a single tool run over 30 minutes counts as zero; raise IDLE_MS if long builds go missing.
|
|
144
|
+
let prev = ms(records[at[k]]);
|
|
145
|
+
for (const t of work.map(ms).filter(Number.isFinite)) {
|
|
146
|
+
if (Number.isFinite(prev) && t > prev && t - prev <= IDLE_MS) agentMs += t - prev;
|
|
147
|
+
prev = Math.max(Number.isFinite(prev) ? prev : t, t);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (turns === 0) return null;
|
|
151
|
+
|
|
152
|
+
// Two sources, and each can only miss calls: Claude Code's own total covers just its last
|
|
153
|
+
// process run (a reopened session can say $0), the estimate misses side calls the transcript
|
|
154
|
+
// does not log (titles, compaction, internal Haiku). So the larger one wins.
|
|
155
|
+
// shortcut: without an own total the estimate runs 0-15% low in real sessions; nothing better is logged.
|
|
156
|
+
const last = (a, f) => { for (let i = a.length - 1; i >= 0; i--) if (f(a[i])) return i; return -1; };
|
|
157
|
+
const costAt = last(records, r => r.type === 'cost-state' && (!sessionId || r.sessionId === sessionId));
|
|
158
|
+
const own = costAt >= 0 && last(records, r => r.type === 'assistant') < costAt ? records[costAt].totalCostUSD : null;
|
|
159
|
+
const known = [own, estimate].filter(v => typeof v === 'number' && Number.isFinite(v) && v > 0);
|
|
160
|
+
const cost = known.length ? Math.max(...known) : null;
|
|
161
|
+
const titled = records.filter(r => r.type === 'custom-title' && typeof r.customTitle === 'string' && r.customTitle.trim());
|
|
162
|
+
const first = prompts.map(promptText).find(t => t && !t.startsWith('<') && !t.startsWith('/')) || '';
|
|
163
|
+
const started = records.map(ms).find(Number.isFinite);
|
|
164
|
+
return {
|
|
165
|
+
startedMs: started,
|
|
166
|
+
name: (titled.length ? titled[titled.length - 1].customTitle.trim() : first.split('\n')[0]).slice(0, 60),
|
|
167
|
+
model: models.sort((a, b) => replies[b] - replies[a])[0],
|
|
168
|
+
cost,
|
|
169
|
+
own,
|
|
170
|
+
estimate,
|
|
171
|
+
turns,
|
|
172
|
+
agentMs,
|
|
173
|
+
tokens,
|
|
174
|
+
output,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Same stamp and quoting as the band (hooks/band/metrics.ts), so the board reads both alike.
|
|
179
|
+
const two = n => String(n).padStart(2, '0');
|
|
180
|
+
const stamp = t => { const d = new Date(t); return `${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())} ${two(d.getHours())}:${two(d.getMinutes())}`; };
|
|
181
|
+
const field = v => { const s = v === null || v === undefined ? '' : String(v); return /[",\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s; };
|
|
182
|
+
|
|
183
|
+
function csvRow(sessionId, project, s) {
|
|
184
|
+
return [`${sessionId.slice(0, 8)}-${s.startedMs}`, stamp(s.startedMs), project, s.name, s.cost === null ? '' : s.cost.toFixed(2), s.turns,
|
|
185
|
+
(s.agentMs / 60000).toFixed(1), s.tokens, s.output, '', '', '', '', '', 'import', s.model].map(field).join(',');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// New rows go in after the ledger's own: a newer header replaces an older one, and a session
|
|
189
|
+
// already recorded anywhere in the ledger (same session id prefix) is never imported twice.
|
|
190
|
+
const sessionOf = row => row.slice(0, 9);
|
|
191
|
+
function mergeRows(existing, rows, have = new Set()) {
|
|
192
|
+
const kept = existing.split('\n').filter(l => l !== '' && !l.startsWith('key,'));
|
|
193
|
+
const added = rows.filter(r => !have.has(sessionOf(r)) && !kept.some(l => sessionOf(l) === sessionOf(r)));
|
|
194
|
+
return { text: [CSV_HEADER, ...kept, ...added].join('\n') + '\n', added: added.length };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const TEMP = [os.tmpdir(), '/tmp/', '/private/tmp/', '/var/folders/', '/private/var/folders/'];
|
|
198
|
+
// A worktree counts for its main repo: the desktop app's <repo>/.claude/worktrees/<name> even
|
|
199
|
+
// after it is gone, and any git worktree through its common .git dir.
|
|
200
|
+
function projectOf(cwd, cache) {
|
|
201
|
+
if (!cache.has(cwd)) {
|
|
202
|
+
let root = cwd.split(/[\\/]\.claude[\\/]worktrees[\\/]/)[0];
|
|
203
|
+
if (fs.existsSync(root)) {
|
|
204
|
+
const git = spawnSync('git', ['-C', root, 'rev-parse', '--path-format=absolute', '--git-common-dir'], { encoding: 'utf8' });
|
|
205
|
+
if (git.status === 0 && /[\\/]\.git$/.test(git.stdout.trim())) root = path.dirname(git.stdout.trim());
|
|
206
|
+
}
|
|
207
|
+
cache.set(cwd, path.basename(root.replace(/[\\/]+$/, '')));
|
|
208
|
+
}
|
|
209
|
+
return cache.get(cwd);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function ledgerDir() {
|
|
213
|
+
return path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'ponytail', 'band');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function run() {
|
|
217
|
+
const root = path.join(getClaudeDir(), 'projects');
|
|
218
|
+
const byProject = new Map();
|
|
219
|
+
const roots = new Map();
|
|
220
|
+
let dirs = [];
|
|
221
|
+
try { dirs = fs.readdirSync(root); } catch (e) { return { sessions: 0, added: 0 }; }
|
|
222
|
+
let sessions = 0;
|
|
223
|
+
for (const dir of dirs) {
|
|
224
|
+
let files = [];
|
|
225
|
+
try { files = fs.readdirSync(path.join(root, dir)).filter(f => f.endsWith('.jsonl')); } catch (e) { continue; }
|
|
226
|
+
for (const file of files) {
|
|
227
|
+
const p = path.join(root, dir, file);
|
|
228
|
+
// The working dir sits in the first records; scratch and temp dirs are never real projects.
|
|
229
|
+
let head = '';
|
|
230
|
+
try { const fd = fs.openSync(p, 'r'); const b = Buffer.alloc(65536); head = b.toString('utf8', 0, fs.readSync(fd, b, 0, b.length, 0)); fs.closeSync(fd); } catch (e) { continue; }
|
|
231
|
+
const m = /"cwd":"((?:[^"\\]|\\.)*)"/.exec(head);
|
|
232
|
+
if (!m) continue;
|
|
233
|
+
const cwd = JSON.parse(`"${m[1]}"`);
|
|
234
|
+
if (TEMP.some(t => cwd.startsWith(t)) || cwd === '/tmp') continue;
|
|
235
|
+
// A session's first prompt is typed by a person; automated runs (benchmarks, `claude -p`) never are.
|
|
236
|
+
if (head.includes('"type":"user"') && !/"turnOrigin":"human"|"origin":\{"kind":"human"/.test(head)) continue;
|
|
237
|
+
const id = file.slice(0, -'.jsonl'.length);
|
|
238
|
+
let records;
|
|
239
|
+
try { records = readRecords(p); } catch (e) { continue; }
|
|
240
|
+
const sub = path.join(root, dir, id, 'subagents');
|
|
241
|
+
let subRecords = [];
|
|
242
|
+
try { subRecords = fs.readdirSync(sub).filter(f => /^agent-.*\.jsonl$/.test(f)).flatMap(f => readRecords(path.join(sub, f))); } catch (e) {}
|
|
243
|
+
const stats = sessionStats(records, subRecords, id);
|
|
244
|
+
if (!stats || !Number.isFinite(stats.startedMs)) continue;
|
|
245
|
+
sessions++;
|
|
246
|
+
const project = projectOf(cwd, roots);
|
|
247
|
+
if (!byProject.has(project)) byProject.set(project, []);
|
|
248
|
+
byProject.get(project).push(csvRow(id, project, stats));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const dir = ledgerDir();
|
|
252
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
253
|
+
const have = new Set();
|
|
254
|
+
for (const f of fs.readdirSync(dir).filter(f => f.endsWith('.csv'))) {
|
|
255
|
+
try { fs.readFileSync(path.join(dir, f), 'utf8').split('\n').forEach(l => l && !l.startsWith('key,') && have.add(sessionOf(l))); } catch (e) {}
|
|
256
|
+
}
|
|
257
|
+
let added = 0;
|
|
258
|
+
for (const [project, rows] of byProject) {
|
|
259
|
+
const file = path.join(dir, `${project.replace(/[^\w.-]/g, '_')}.csv`);
|
|
260
|
+
let existing = '';
|
|
261
|
+
try { existing = fs.readFileSync(file, 'utf8'); } catch (e) {}
|
|
262
|
+
const merged = mergeRows(existing, rows, have);
|
|
263
|
+
if (merged.added > 0) fs.writeFileSync(file, merged.text);
|
|
264
|
+
added += merged.added;
|
|
265
|
+
}
|
|
266
|
+
return { sessions, added };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (require.main === module) {
|
|
270
|
+
const { sessions, added } = run();
|
|
271
|
+
process.stdout.write(`ponytail band import: ${sessions} past sessions found, ${added} new rows in the board.\n`);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
module.exports = { CSV_HEADER, PRICES, replyCost, sessionStats, csvRow, mergeRows, readRecords, run };
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// ponytail — UserPromptSubmit hook to track which ponytail mode is active
|
|
3
3
|
// Inspects user input for /ponytail commands and writes mode to flag file
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
const { getClaudeDir, getDefaultMode, isDeactivationCommand, writeDefaultMode } = require('./ponytail-config');
|
|
6
9
|
const {
|
|
7
10
|
clearMode,
|
|
8
11
|
cursorRuleNotice,
|
|
9
12
|
cursorRulePath,
|
|
13
|
+
isCodeBuddy,
|
|
10
14
|
isCodex,
|
|
15
|
+
isCopilot,
|
|
11
16
|
isCursor,
|
|
12
17
|
isQoder,
|
|
13
18
|
readMode,
|
|
@@ -42,6 +47,7 @@ function finish() {
|
|
|
42
47
|
// Match /ponytail commands
|
|
43
48
|
let modeSwitched = false;
|
|
44
49
|
let deactivated = false;
|
|
50
|
+
let defaultNotice = '';
|
|
45
51
|
if (/^[/@$]ponytail/.test(prompt)) {
|
|
46
52
|
const parts = prompt.split(/\s+/);
|
|
47
53
|
const cmd = parts[0].replace(/^[@$]/, '/');
|
|
@@ -62,9 +68,39 @@ function finish() {
|
|
|
62
68
|
const dmode = parts[2];
|
|
63
69
|
if (dmode === 'off' || dmode === 'lite' || dmode === 'full' || dmode === 'ultra') {
|
|
64
70
|
writeDefaultMode(dmode);
|
|
65
|
-
|
|
71
|
+
defaultNotice = 'PONYTAIL DEFAULT SET — new sessions start in ' + dmode + '.';
|
|
72
|
+
if (!isQoder) writeHookOutput('UserPromptSubmit', dmode, defaultNotice);
|
|
66
73
|
}
|
|
67
|
-
|
|
74
|
+
// Qoder still needs this turn's ruleset: the block below folds the
|
|
75
|
+
// notice into it. mode stays null, so the session level is untouched.
|
|
76
|
+
if (!isQoder) return; // don't fall through to the session-mode switch
|
|
77
|
+
}
|
|
78
|
+
// `/ponytail band [on|off]` shows or hides the band above the Claude Code
|
|
79
|
+
// prompt (hooks/band reads this flag). It outlives the session; absent = shown.
|
|
80
|
+
// Other hosts have no band, so there the word stays an unknown argument.
|
|
81
|
+
if (arg === 'band' && !isCopilot && !isCodex && !isQoder && !isCodeBuddy && !isCursor) {
|
|
82
|
+
// `/ponytail band import`: past sessions into the board, in the background, so the prompt
|
|
83
|
+
// is answered right away while the transcripts are read. Detached, it outlives this hook's
|
|
84
|
+
// process.exit below.
|
|
85
|
+
if (parts[2] === 'import') {
|
|
86
|
+
spawn(process.execPath, [path.join(__dirname, 'ponytail-band-import.js')], { detached: true, stdio: 'ignore' });
|
|
87
|
+
writeHookOutput('UserPromptSubmit', readMode() || 'off', 'PONYTAIL BAND IMPORT: past Claude Code sessions (cost, agent time, tokens) are being added to the board in the background. Open the board in a minute. Confirm in one short line.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const flag = path.join(getClaudeDir(), '.ponytail-band');
|
|
91
|
+
let hidden = false;
|
|
92
|
+
try { hidden = fs.readFileSync(flag, 'utf8').trim() === 'off'; } catch (e) {}
|
|
93
|
+
const show = parts[2] === 'on' ? true : parts[2] === 'off' ? false : hidden;
|
|
94
|
+
if (show) {
|
|
95
|
+
try { fs.unlinkSync(flag); } catch (e) {}
|
|
96
|
+
} else {
|
|
97
|
+
fs.mkdirSync(path.dirname(flag), { recursive: true });
|
|
98
|
+
fs.writeFileSync(flag, 'off');
|
|
99
|
+
}
|
|
100
|
+
writeHookOutput('UserPromptSubmit', readMode() || 'off', show
|
|
101
|
+
? 'PONYTAIL BAND ON: the band shows above the prompt again. The ponytail level is unchanged. Confirm in one short line.'
|
|
102
|
+
: 'PONYTAIL BAND OFF: the band above the prompt is hidden, `/ponytail band` brings it back. The ponytail level is unchanged. Confirm in one short line.');
|
|
103
|
+
return;
|
|
68
104
|
}
|
|
69
105
|
if (arg === 'lite') mode = 'lite';
|
|
70
106
|
else if (arg === 'full') mode = 'full';
|
|
@@ -146,10 +182,12 @@ function finish() {
|
|
|
146
182
|
if (currentMode && currentMode !== 'off') {
|
|
147
183
|
// ponytail: one JSON per invocation — mode-switch confirmation is
|
|
148
184
|
// folded into the ruleset header so Qoder gets both in one write.
|
|
149
|
-
const header = modeSwitched
|
|
185
|
+
const header = (defaultNotice ? defaultNotice + '\n\n' : '') + (modeSwitched
|
|
150
186
|
? 'PONYTAIL MODE CHANGED — level: ' + currentMode + '\n\n'
|
|
151
|
-
: '';
|
|
187
|
+
: '');
|
|
152
188
|
writeHookOutput('UserPromptSubmit', currentMode, header + getPonytailInstructions(currentMode));
|
|
189
|
+
} else if (defaultNotice) {
|
|
190
|
+
writeHookOutput('UserPromptSubmit', currentMode, defaultNotice);
|
|
153
191
|
}
|
|
154
192
|
}
|
|
155
193
|
} catch (e) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dietrichgebert/ponytail",
|
|
3
|
-
"version": "5.2
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"description": "Lazy senior dev mode for AI agents. The best code is the code you never wrote.",
|
|
5
5
|
"keywords": ["opencode-plugin", "opencode", "ponytail", "pi-package", "pi", "skills", "qoder"],
|
|
6
6
|
"license": "MIT",
|
|
@@ -6,7 +6,7 @@ description: >
|
|
|
6
6
|
fixing, refactoring, reviewing, choosing dependencies) and when the user says
|
|
7
7
|
"ponytail", "be lazy", "simplest solution", "yagni", or complains about
|
|
8
8
|
over-engineering or bloat. Levels: lite, full (default), ultra.
|
|
9
|
-
argument-hint: "[lite|full|ultra]"
|
|
9
|
+
argument-hint: "[lite|full|ultra|off]"
|
|
10
10
|
license: MIT
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -41,5 +41,4 @@ End with `<N> markers, <M> with no trigger.` Nothing found: `No shortcut debt. C
|
|
|
41
41
|
## Boundaries
|
|
42
42
|
|
|
43
43
|
Reads and reports only, changes nothing. To persist it, ask and it writes the
|
|
44
|
-
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot.
|
|
45
|
-
"normal mode" to revert.
|
|
44
|
+
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot.
|
|
@@ -40,6 +40,12 @@ slash-command forms above (OpenCode ships all six as slash commands).
|
|
|
40
40
|
Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
|
|
41
41
|
`/ponytail off` also works.
|
|
42
42
|
|
|
43
|
+
## Band (Claude Code)
|
|
44
|
+
|
|
45
|
+
`/ponytail band` hides the band above the prompt, the same command brings it back.
|
|
46
|
+
`/ponytail band on` and `/ponytail band off` set it directly. The level stays.
|
|
47
|
+
`/ponytail band import` adds your past Claude Code sessions (cost, agent time, tokens) to the board.
|
|
48
|
+
|
|
43
49
|
## Configure Default Mode
|
|
44
50
|
|
|
45
51
|
Default mode = `full`, auto-active every session. Change it:
|
|
@@ -28,7 +28,7 @@ Run `/reload` after installation.
|
|
|
28
28
|
| Feature | Description | Entry point |
|
|
29
29
|
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
30
30
|
| Claude Code UI | Tool summaries, expand/collapse, rich edit/write diffs, and `on` / `compact` / `off` modes | `/ccstyle` |
|
|
31
|
-
| Markdown enhancements | Mermaid
|
|
31
|
+
| Markdown enhancements | Mermaid dialects and circled-number conversion | Automatic; turn off with `enableMarkdownEnhance: false` |
|
|
32
32
|
| Fullscreen mode | Tool card/group expand and collapse on click, previews, hover highlight, and a back-to-bottom button | `TUIMODE=fullscreen` or `--tui-mode fullscreen` |
|
|
33
33
|
| Settings panel | `Style / Features / UI / Diff / Thinking / Footer` tabs | `/ccstyle` |
|
|
34
34
|
| Context inspection | Usage breakdown and previews for the system prompt, memory, skills, tools definition, and messages | `/context` |
|
|
@@ -55,6 +55,7 @@ Renderer snapshots for `on` / `compact` modes: [default](./docs/tool-render-exam
|
|
|
55
55
|
"enableAgentSummary": true, // per-turn tool summary
|
|
56
56
|
"enableWorkingMessage": true, // Working... bottom token/elapsed
|
|
57
57
|
"enableAliases": true, // /clear, /exit aliases
|
|
58
|
+
"enableMarkdownEnhance": true, // markdown pass: Mermaid dialects and circled-number conversion; false hands it to other extensions
|
|
58
59
|
"enableEditorPrefix": true, // editor ❯ prefix
|
|
59
60
|
|
|
60
61
|
// ui
|
|
@@ -97,6 +98,8 @@ Renderer snapshots for `on` / `compact` modes: [default](./docs/tool-render-exam
|
|
|
97
98
|
|
|
98
99
|
> [!TIP]
|
|
99
100
|
> **Fullscreen**: click `click to show more` to expand tool cards, thinking, Skill, and compact summaries. An expanded diff always shows every line; when expanded Input/Output exceeds the line cap, the footer `… +N more lines · click to show more` opens a full preview. Click to collapse.
|
|
101
|
+
>
|
|
102
|
+
> Both `scrollButtonMode` values show the same `Back to bottom` / `N new message(s)` text: `dock` draws it in a dedicated row, `native` in Pi’s floating overlay.
|
|
100
103
|
|
|
101
104
|
> [!NOTE]
|
|
102
105
|
> **Mermaid rendering**: set `markdown.mermaid` to `final` via `~/.pi/agent/settings.json` or the Mermaid diagrams option in `/settings`. Default `streaming` redraws per frame; `final` renders once at completion.
|
|
@@ -117,13 +120,15 @@ pi -e . # one run, does not edit settings.json
|
|
|
117
120
|
|
|
118
121
|
## Recommended companions
|
|
119
122
|
|
|
120
|
-
| Extension
|
|
121
|
-
|
|
|
122
|
-
| `npm:pi-web-access`
|
|
123
|
-
| `npm:@narumitw/pi-usage`
|
|
123
|
+
| Extension | Purpose |
|
|
124
|
+
| ---------------------------------------- | ----------------------------------------------------------- |
|
|
125
|
+
| `npm:pi-web-access` | Web search, URL fetching, GitHub cloning, PDF/video parsing |
|
|
126
|
+
| `npm:@narumitw/pi-usage` | Current-account usage for Codex / Copilot / OpenRouter |
|
|
127
|
+
| `npm:@juicesharp/rpiv-ask-user-question` | Multiple-choice questionnaire the model can ask you |
|
|
124
128
|
|
|
125
129
|
## Credits
|
|
126
130
|
|
|
131
|
+
- Based on [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.8 (MIT), upstream baseline [`2cb2c1e`](https://github.com/minuque/pi-cc-extensions/commit/2cb2c1ec7240f183ff68cbab0ea6ae3239529f23), with this repository's configuration migration and compatibility patches retained.
|
|
127
132
|
- Rich diffs are adapted from [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display) (MIT). See [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md).
|
|
128
133
|
|
|
129
134
|
## License
|
|
@@ -28,7 +28,7 @@ pi install git:github.com/HerbertGao/pi-extensions
|
|
|
28
28
|
| 功能 | 说明 | 入口 |
|
|
29
29
|
| --------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
30
30
|
| Claude Code UI | 工具摘要、折叠展开、rich edit/write diff,以及`on` / `compact` / `off` 三种模式 | `/ccstyle` |
|
|
31
|
-
| Markdown 增强 | Mermaid
|
|
31
|
+
| Markdown 增强 | Mermaid 方言渲染、圈数字转半角括号 | 自动生效;`enableMarkdownEnhance: false` 关闭 |
|
|
32
32
|
| Fullscreen mode | 工具卡/group 单击展开与收起、预览、hover 高亮、回到底部按钮 | `TUIMODE=fullscreen` 或 `--tui-mode fullscreen` |
|
|
33
33
|
| 配置面板 | `Style / Features / UI / Diff / Thinking / Footer` 六页签 | `/ccstyle` |
|
|
34
34
|
| 上下文检查 | 查看上下文占用,并预览 System prompt、Memory、Skills、Tools definition 和消息内容 | `/context` |
|
|
@@ -55,6 +55,7 @@ pi install git:github.com/HerbertGao/pi-extensions
|
|
|
55
55
|
"enableAgentSummary": true, // 每回合工具摘要
|
|
56
56
|
"enableWorkingMessage": true, // Working... 底部 token/耗时
|
|
57
57
|
"enableAliases": true, // /clear、/exit 别名
|
|
58
|
+
"enableMarkdownEnhance": true, // markdown 转换:Mermaid 方言渲染、圈数字转半角括号;false 让位给其他扩展
|
|
58
59
|
"enableEditorPrefix": true, // 输入框 ❯ 前缀
|
|
59
60
|
|
|
60
61
|
// ui
|
|
@@ -96,6 +97,8 @@ pi install git:github.com/HerbertGao/pi-extensions
|
|
|
96
97
|
|
|
97
98
|
> [!TIP]
|
|
98
99
|
> **全屏模式**:单击 `click to show more` 展开工具卡、思考、Skill 和 compact 摘要;工具卡展开态 diff 全量显示,Input/Output 超行时末行 `… +N more lines · click to show more` 打开全量预览,单击收起。
|
|
100
|
+
>
|
|
101
|
+
> `scrollButtonMode` 两种模式文案相同(`Back to bottom` / `N new message(s)`):`dock` 画在独占行,`native` 画在 Pi 原生浮层。
|
|
99
102
|
|
|
100
103
|
> [!NOTE]
|
|
101
104
|
> **Mermaid 渲染**:建议把 `markdown.mermaid` 设为 `final`(`~/.pi/agent/settings.json` 或 `/settings` 面板的 Mermaid diagrams 选项)。默认 `streaming` 逐帧重绘,`final` 渲染最终版更稳定。
|
|
@@ -120,9 +123,11 @@ pi -e . # 只跑一次,不改 settings.json
|
|
|
120
123
|
| ---------------------------------------- | ------------------------------------------------ |
|
|
121
124
|
| `npm:pi-web-access` | 网页搜索、URL 抓取、GitHub 克隆、PDF/视频解析 |
|
|
122
125
|
| `npm:@narumitw/pi-usage` | 查看当前账号用量(Codex / Copilot / OpenRouter) |
|
|
126
|
+
| `npm:@juicesharp/rpiv-ask-user-question` | 模型拿不准时向你提问的选择题面板 |
|
|
123
127
|
|
|
124
128
|
## 致谢
|
|
125
129
|
|
|
130
|
+
- 基于 [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.8(MIT),上游基线 [`2cb2c1e`](https://github.com/minuque/pi-cc-extensions/commit/2cb2c1ec7240f183ff68cbab0ea6ae3239529f23);保留本仓库的配置迁移与兼容性补丁。
|
|
126
131
|
- Rich diff 改编自 [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display)(MIT);详见 [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md)。
|
|
127
132
|
|
|
128
133
|
## 许可证
|
|
@@ -66,7 +66,7 @@ export type Config = {
|
|
|
66
66
|
showStartupHeader: boolean;
|
|
67
67
|
/** fullscreen:userMessage 正文首行滚出视口上沿后钉住,直到下一条指令接手。 */
|
|
68
68
|
stickyUserMessage: boolean;
|
|
69
|
-
/** fullscreen 回到底部按钮:扩展 dock 行,或 Pi
|
|
69
|
+
/** fullscreen 回到底部按钮:扩展 dock 行,或 Pi 原生浮层;两者文案相同。 */
|
|
70
70
|
scrollButtonMode: ScrollButtonMode;
|
|
71
71
|
enableSessionReference: boolean;
|
|
72
72
|
enableSubagentAutocomplete: boolean;
|
|
@@ -74,6 +74,8 @@ export type Config = {
|
|
|
74
74
|
enableAgentSummary: boolean;
|
|
75
75
|
enableWorkingMessage: boolean;
|
|
76
76
|
enableAliases: boolean;
|
|
77
|
+
/** markdown 转换:Mermaid 方言渲染、圈数字转半角括号。关掉让位给其他扩展。 */
|
|
78
|
+
enableMarkdownEnhance: boolean;
|
|
77
79
|
/** 输入框 `❯ ` 前缀(占左侧 2 列,颜色随 thinking/bash mode 联动)。 */
|
|
78
80
|
enableEditorPrefix: boolean;
|
|
79
81
|
enableCustomFooter: boolean;
|
|
@@ -157,6 +159,7 @@ export const DEFAULT_CONFIG: Config = {
|
|
|
157
159
|
enableAgentSummary: true,
|
|
158
160
|
enableWorkingMessage: true,
|
|
159
161
|
enableAliases: true,
|
|
162
|
+
enableMarkdownEnhance: true,
|
|
160
163
|
enableEditorPrefix: true,
|
|
161
164
|
enableCustomFooter: true,
|
|
162
165
|
footerTokenRate: true,
|
|
@@ -290,6 +293,7 @@ export function normalizeConfig(input: unknown): Config {
|
|
|
290
293
|
enableAgentSummary: source.enableAgentSummary !== false,
|
|
291
294
|
enableWorkingMessage: source.enableWorkingMessage !== false,
|
|
292
295
|
enableAliases: source.enableAliases !== false,
|
|
296
|
+
enableMarkdownEnhance: source.enableMarkdownEnhance !== false,
|
|
293
297
|
enableEditorPrefix: (source.enableEditorPrefix ?? source.enableInputPrompt) !== false, // 兼容旧配置键
|
|
294
298
|
enableCustomFooter: source.enableCustomFooter !== false,
|
|
295
299
|
footerTokenRate: source.footerTokenRate !== false,
|
|
@@ -361,6 +365,7 @@ export function formatConfigStatus(source: Config = config): string {
|
|
|
361
365
|
`agentSummary=${source.enableAgentSummary ? "on" : "off"}`,
|
|
362
366
|
`workingMsg=${source.enableWorkingMessage ? "on" : "off"}`,
|
|
363
367
|
`aliases=${source.enableAliases ? "on" : "off"}`,
|
|
368
|
+
`markdownEnhance=${source.enableMarkdownEnhance ? "on" : "off"}`,
|
|
364
369
|
`editorPrefix=${source.enableEditorPrefix ? "on" : "off"}`,
|
|
365
370
|
`footer=${source.enableCustomFooter ? "on" : "off"}`,
|
|
366
371
|
`footerTokenRate=${source.footerTokenRate ? "on" : "off"}`,
|
|
@@ -181,6 +181,7 @@ function buildFooterChipsSubmenu(
|
|
|
181
181
|
() => onClose(),
|
|
182
182
|
{ enableSearch: false },
|
|
183
183
|
);
|
|
184
|
+
// SAFETY: SettingsList stores these as plain fields; disabled search keeps indices in items.
|
|
184
185
|
const listState = list as unknown as { selectedIndex: number; items: typeof items };
|
|
185
186
|
|
|
186
187
|
const mutate = (transform: (layout: FooterChipLayout, key: string) => FooterChipLayout) => {
|
|
@@ -604,11 +605,11 @@ export async function showCcstylePanel(
|
|
|
604
605
|
};
|
|
605
606
|
const scrollButtonSetting = {
|
|
606
607
|
id: "scrollButtonMode",
|
|
607
|
-
label: "Scroll
|
|
608
|
+
label: "Scroll button mode",
|
|
608
609
|
description:
|
|
609
610
|
config.scrollButtonMode === "dock"
|
|
610
611
|
? "Fullscreen: show the extension's dedicated Back to bottom row."
|
|
611
|
-
: "Fullscreen:
|
|
612
|
+
: "Fullscreen: show the same Back to bottom text in Pi's native floating overlay.",
|
|
612
613
|
currentValue: config.scrollButtonMode,
|
|
613
614
|
values: [...SCROLL_BUTTON_MODES],
|
|
614
615
|
};
|
|
@@ -656,6 +657,13 @@ export async function showCcstylePanel(
|
|
|
656
657
|
"Aliases disabled.",
|
|
657
658
|
config.enableAliases,
|
|
658
659
|
);
|
|
660
|
+
const markdownEnhanceToggle = featureToggleSetting(
|
|
661
|
+
"enableMarkdownEnhance",
|
|
662
|
+
"Markdown enhance",
|
|
663
|
+
"Mermaid dialects and circled-number conversion. Next restart applies.",
|
|
664
|
+
"Markdown enhancements off; another extension can own the markdown pass.",
|
|
665
|
+
config.enableMarkdownEnhance,
|
|
666
|
+
);
|
|
659
667
|
const footerCurrencySetting = {
|
|
660
668
|
id: "footerCurrency",
|
|
661
669
|
label: "Cost currency",
|
|
@@ -798,6 +806,7 @@ export async function showCcstylePanel(
|
|
|
798
806
|
enableAgentSummary: agentSummaryToggle,
|
|
799
807
|
enableWorkingMessage: workingMessageToggle,
|
|
800
808
|
enableAliases: aliasesToggle,
|
|
809
|
+
enableMarkdownEnhance: markdownEnhanceToggle,
|
|
801
810
|
};
|
|
802
811
|
|
|
803
812
|
const onSettingChange = (id: string, value: string) => {
|
|
@@ -1012,7 +1021,7 @@ export async function showCcstylePanel(
|
|
|
1012
1021
|
scrollButtonSetting.description =
|
|
1013
1022
|
config.scrollButtonMode === "dock"
|
|
1014
1023
|
? "Fullscreen: show the extension's dedicated Back to bottom row."
|
|
1015
|
-
: "Fullscreen:
|
|
1024
|
+
: "Fullscreen: show the same Back to bottom text in Pi's native floating overlay.";
|
|
1016
1025
|
break;
|
|
1017
1026
|
}
|
|
1018
1027
|
case "showStartupHeader": {
|
|
@@ -1049,6 +1058,7 @@ export async function showCcstylePanel(
|
|
|
1049
1058
|
agentSummaryToggle.setting,
|
|
1050
1059
|
workingMessageToggle.setting,
|
|
1051
1060
|
aliasesToggle.setting,
|
|
1061
|
+
markdownEnhanceToggle.setting,
|
|
1052
1062
|
],
|
|
1053
1063
|
},
|
|
1054
1064
|
{
|
|
@@ -1122,6 +1132,7 @@ export async function showCcstylePanel(
|
|
|
1122
1132
|
|
|
1123
1133
|
/** 数值项:当前选中项有 submenu + values 时,Space 仅循环预设,不打开子面板。 */
|
|
1124
1134
|
const cyclePresetInList = (list: InstanceType<typeof SettingsList>): boolean => {
|
|
1135
|
+
// SAFETY: SettingsList exposes these runtime fields, and these lists disable search.
|
|
1125
1136
|
const internal = list as unknown as {
|
|
1126
1137
|
submenuComponent: unknown;
|
|
1127
1138
|
items: {
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* average:一次用户指令的墙钟平均(工具等待计入分母),显示 `avg`。
|
|
5
5
|
* live:最近 1 秒的瞬时速率,生成期暂停时钟,显示 `live`;指令结束定格为整段平均。
|
|
6
|
-
* token 与 working-message
|
|
7
|
-
* (CJK 1 token,其余 chars/4
|
|
6
|
+
* token 与 working-message 同源:变大的 provider `usage.output` 覆盖估算,否则按 delta 累加
|
|
7
|
+
* (CJK 1 token,其余 chars/4)。没有变大的 usage 不当作累计值:Anthropic 的 message_start
|
|
8
|
+
* 会给出一个很小的 output_tokens,并在每个 partial 上重复,直到最后的 message_delta。
|
|
9
|
+
* 消息结束时用 message_end 上的 usage 定格本段总量。
|
|
8
10
|
* Pi 的 turn 是单次 assistant 消息,工具调用结束会开新 turn。token 跨 turn 累加,
|
|
9
11
|
* 计时与 TTFT 直到下一条用户指令才重置。
|
|
10
12
|
* TTFT:用户指令开始到第一个内容块(text/thinking/toolcall)开始的毫秒数,
|
|
@@ -120,15 +122,29 @@ export function sampleTokenDelta(delta: string, now = Date.now()): void {
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
|
-
* 记录本段 provider `usage.output
|
|
125
|
+
* 记录本段 provider `usage.output`。变大的 usage 按锚点摊回窗口:
|
|
124
126
|
* 首次报告从消息起点铺到现在,之后每次把增量摊在上次报告之后。
|
|
127
|
+
* 没有变大的报告直接忽略,避免 message_start 的占位值反复覆盖 delta 累计。
|
|
128
|
+
* `final` 用于消息结束:以本次 output 为本段总量,估算偏高偏低都按它修正。
|
|
129
|
+
* 结束值含未逐字流出的思考 token,它们不属于最近一秒,所以窗口只整体平移,不回填。
|
|
125
130
|
*/
|
|
126
|
-
export function recordProviderUsage(output: number, now = Date.now()): void {
|
|
131
|
+
export function recordProviderUsage(output: number, now = Date.now(), final = false): void {
|
|
127
132
|
if (!runStartTime || output <= 0) return;
|
|
133
|
+
if (final) {
|
|
134
|
+
const shift = output - currentTokens;
|
|
135
|
+
for (const sample of samples) sample.cum += shift;
|
|
136
|
+
countedUsage = output;
|
|
137
|
+
currentTokens = output;
|
|
138
|
+
usageAnchorTime = now;
|
|
139
|
+
usageAnchorTokens = output;
|
|
140
|
+
updateRates(now);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (output <= countedUsage) return;
|
|
128
144
|
const firstReport = countedUsage === 0;
|
|
129
145
|
const jump = output - countedUsage;
|
|
130
146
|
countedUsage = output;
|
|
131
|
-
// provider
|
|
147
|
+
// 变大的 provider 计数是权威值,覆盖本段估算。
|
|
132
148
|
currentTokens = output;
|
|
133
149
|
if (firstReport) {
|
|
134
150
|
samples = samples.filter((sample) => sample.t < usageAnchorTime);
|