@fbincon/claude-code-statusline 3.1.4 → 3.2.0

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 (105) hide show
  1. package/README.md +73 -68
  2. package/candidate.json +197 -159
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +2 -1
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/main.js +2 -1
  6. package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
  7. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js +3 -1
  8. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js.map +1 -1
  9. package/node_modules/@fbincon/statusline-cli/dist/src/ui/explain.d.ts +4 -0
  10. package/node_modules/@fbincon/statusline-cli/dist/src/ui/explain.js +27 -0
  11. package/node_modules/@fbincon/statusline-cli/dist/src/ui/explain.js.map +1 -0
  12. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +4 -3
  13. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +12 -2
  14. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  15. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  16. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +12 -9
  17. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +16 -2
  18. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +35 -19
  19. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/messages.ts +12 -8
  20. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +2 -1
  21. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +5 -0
  22. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/explanation.ts +35 -0
  23. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/quick-setup.ts +82 -0
  24. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/text-input.ts +68 -0
  25. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +26 -4
  26. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +450 -6
  27. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +7 -4
  28. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +19 -16
  29. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +25 -6
  30. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +6 -3
  31. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/surface.ts +16 -3
  32. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  33. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  34. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.d.ts +7 -0
  35. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +5 -0
  36. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -1
  37. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +31 -13
  38. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +1 -1
  39. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -1
  40. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +65 -16
  41. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +3 -1
  42. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
  43. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +21 -2
  44. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  45. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +4 -0
  46. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +3 -0
  47. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  48. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.d.ts +13 -0
  49. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js +41 -0
  50. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js.map +1 -0
  51. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.d.ts +21 -0
  52. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js +105 -0
  53. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js.map +1 -0
  54. package/node_modules/@fbincon/statusline-core/dist/src/editor/text-input.d.ts +32 -0
  55. package/node_modules/@fbincon/statusline-core/dist/src/editor/text-input.js +89 -0
  56. package/node_modules/@fbincon/statusline-core/dist/src/editor/text-input.js.map +1 -0
  57. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +444 -0
  58. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +450 -6
  59. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  60. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  61. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  62. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.d.ts +3 -2
  63. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js +8 -3
  64. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js.map +1 -1
  65. package/node_modules/@fbincon/statusline-core/dist/src/rendering/context.d.ts +2 -0
  66. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.d.ts +14 -0
  67. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +37 -0
  68. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -0
  69. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +22 -7
  70. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
  71. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +3 -1
  72. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +7 -2
  73. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
  74. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js +1 -0
  75. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js.map +1 -1
  76. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +35 -12
  77. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
  78. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +13 -0
  79. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js +35 -0
  80. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js.map +1 -0
  81. package/node_modules/@fbincon/statusline-core/dist/src/terminal/key.d.ts +2 -0
  82. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +75 -1
  83. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +75 -1
  84. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +75 -1
  85. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +75 -1
  86. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +75 -1
  87. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +75 -1
  88. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.d.ts +2 -0
  89. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.js +11 -3
  90. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.js.map +1 -1
  91. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +15 -1
  92. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  93. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +4 -0
  94. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  95. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +15 -5
  96. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  97. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +3 -3
  98. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  99. package/node_modules/@fbincon/statusline-tui/dist/src/session.d.ts +1 -0
  100. package/node_modules/@fbincon/statusline-tui/dist/src/session.js +40 -3
  101. package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
  102. package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +6 -2
  103. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +87 -40
  104. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  105. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
1
  // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { ExplanationView } from './explanation.ts';
3
+ import type { QuickSetup } from './quick-setup.ts';
2
4
  import { t, type Language } from '../i18n/index.ts';
3
5
  import { nodes, newInstance, reconcileRows } from './instances.ts';
4
6
  import { isDraft } from '../backend.ts';
@@ -39,6 +41,8 @@ export class Editor {
39
41
  detail: { scope: Scope; id: string } | null = null;
40
42
  guidanceScroll: number | null = null;
41
43
  review: ReviewState | null = null;
44
+ quick: QuickSetup | null = null;
45
+ explanation: ExplanationView | null = null;
42
46
  preset = 'minimal';
43
47
  path = 'statusline.json';
44
48
  pendingTransfer: 'import' | 'export' | 'preset' | null = null;
@@ -83,6 +87,7 @@ export class Editor {
83
87
  this.activeNumeric = null;
84
88
  this.detail = null;
85
89
  this.guidanceScroll = null;
90
+ this.explanation = null;
86
91
  this.review = null;
87
92
  }
88
93
 
@@ -0,0 +1,35 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { ExplainResult, Scope } from '../generated-contracts.ts';
3
+ import type { Editor } from './draft.ts';
4
+ import { t, type Language } from '../i18n/index.ts';
5
+ import { wrapText } from '../../ui/text.ts';
6
+
7
+ export interface ExplanationView { scope: Scope; id: string; scroll: number; result: ExplainResult | null; error: string }
8
+ export function openExplanation(scope:Scope,id:string): ExplanationView { return {scope,id,scroll:0,result:null,error:''}; }
9
+ export function explanationKey(view:ExplanationView,key:string,capacity:number): boolean {
10
+ if(key==='cancel'||key==='escape') return false;
11
+ if(key==='up'||key==='pageup') view.scroll=Math.max(0,view.scroll-(key==='up'?1:capacity));
12
+ if(key==='down'||key==='pagedown') view.scroll+=key==='down'?1:capacity;
13
+ if(key==='home') view.scroll=0;
14
+ if(key==='end') view.scroll=1000000;
15
+ return true;
16
+ }
17
+ export function explanationLines(editor:Editor,language:Language,width:number): string[] {
18
+ const view=editor.explanation!;
19
+ const tr=(key:string,params:Record<string,unknown>={})=>t('explain.'+key,language,params);
20
+ const item=view.result?.instances.find(item=>item.id===view.id);
21
+ const lines=[tr('sample'),editor.instanceLabel(view.scope,view.id,language)+' ('+view.id+')'];
22
+ if(!item) return wrapText([...lines,view.error||tr('loading')],width);
23
+ for(const [heading,origins] of [['configuration',['configuration']],['requirements',['local_configuration','host_capability','unknown']]] as const) {
24
+ lines.push('',tr(heading));
25
+ for(const reason of item.reasons) if((origins as readonly string[]).includes(reason.origin)) lines.push(tr('reason.'+reason.code));
26
+ }
27
+ lines.push('',tr('sample_result',{width:view.result!.width}));
28
+ if(!item.samples.length) lines.push(tr('no_sample'));
29
+ for(const sample of item.samples) {
30
+ lines.push(tr('row.'+sample.row_id)+': '+tr('reason.'+sample.outcome));
31
+ if(sample.truncated) lines.push(tr('reason.sample_truncated'));
32
+ }
33
+ lines.push('',tr('panel_note'));
34
+ return wrapText(lines,width);
35
+ }
@@ -0,0 +1,82 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { Editor } from './draft.ts';
3
+ import type { Draft, Scope } from '../generated-contracts.ts';
4
+ import { THEME_VALUES, PALETTE_VALUES, SEPARATORSTYLE_VALUES, PRESETS } from '../generated-contracts.ts';
5
+ import { copyDraft } from './draft.ts';
6
+ import { t, type Language } from '../i18n/index.ts';
7
+ import { wrapText } from '../../ui/text.ts';
8
+
9
+ export interface QuickSetup {
10
+ base: Draft;
11
+ candidate: Draft;
12
+ step: 'scenario' | 'appearance' | 'review';
13
+ selected: number;
14
+ preset: string;
15
+ previewScope: Scope;
16
+ detailScroll: number;
17
+ }
18
+ export function openQuick(draft: Draft): QuickSetup {
19
+ return {base:copyDraft(draft),candidate:copyDraft(draft),step:'scenario',selected:0,preset:'developer',previewScope:'main',detailScroll:0};
20
+ }
21
+ export function receivePreset(quick: QuickSetup, draft: Draft): void {
22
+ quick.candidate = copyDraft(draft); quick.step = 'appearance'; quick.selected = 0; quick.detailScroll = 0;
23
+ }
24
+ export function quickKey(quick: QuickSetup, key: string): 'preset' | 'accept' | 'save' | 'cancel' | null {
25
+ const count = quick.step === 'scenario' ? PRESETS.length : quick.step === 'appearance' ? 5 : 3;
26
+ if (key === 'escape' || key === 'cancel') return 'cancel';
27
+ if (key === 'pageup' || key === 'pagedown') { quick.detailScroll = Math.max(0, quick.detailScroll + (key === 'pageup' ? -1 : 1)); return null; }
28
+ if (key === 'tab') { quick.previewScope = quick.previewScope === 'main' ? 'subagent' : 'main'; return null; }
29
+ if (key === 'backspace' || quick.step === 'review' && quick.selected === 2 && key === 'return') {
30
+ if (quick.step === 'scenario') return 'cancel';
31
+ quick.step = quick.step === 'review' ? 'appearance' : 'scenario';
32
+ quick.selected = quick.step === 'scenario' ? Math.max(0, PRESETS.findIndex(p => p.id === quick.preset)) : 0;
33
+ quick.detailScroll = 0; return null;
34
+ }
35
+ if (key === 'up' || key === 'down' || key === 'home' || key === 'end') {
36
+ quick.selected = key === 'home' ? 0 : key === 'end' ? count - 1 : Math.max(0,Math.min(count-1,quick.selected+(key==='up'?-1:1)));
37
+ quick.detailScroll = 0; return null;
38
+ }
39
+ if (quick.step === 'scenario' && key === 'return') { quick.preset = PRESETS[quick.selected]!.id; return 'preset'; }
40
+ if (quick.step === 'review' && key === 'return') return quick.selected === 0 ? 'accept' : 'save';
41
+ if (quick.step !== 'appearance' || !['left','right','return'].includes(key)) return null;
42
+ const d = quick.candidate.display, delta = key === 'left' ? -1 : 1;
43
+ const cycle = <T>(values: readonly T[], value: T): T => values[(values.indexOf(value)+delta+values.length)%values.length]!;
44
+ if (quick.selected === 0) d.theme = cycle(THEME_VALUES,d.theme);
45
+ if (quick.selected === 1) d.use_colors = !d.use_colors;
46
+ if (quick.selected === 2) d.palette = cycle(PALETTE_VALUES,d.palette);
47
+ if (quick.selected === 3) d.separator_style = cycle(SEPARATORSTYLE_VALUES,d.separator_style);
48
+ if (quick.selected === 4 && key === 'return') { quick.step='review'; quick.selected=0; quick.detailScroll=0; }
49
+ return null;
50
+ }
51
+ /** Both adapters use the same menu, selection window and scrollable requirement text. */
52
+ export function quickView(quick: QuickSetup, language: Language, width: number, height: number): {text:string;selected:boolean}[] {
53
+ const tr = (key:string,params:Record<string,unknown>={}) => t(key,language,params);
54
+ const preset = PRESETS.find(p=>p.id === (quick.step === 'scenario' ? PRESETS[quick.selected]!.id : quick.preset))!;
55
+ const d=quick.candidate.display;
56
+ const rows = quick.step === 'scenario' ? PRESETS.map(p=>(p.example ? tr('quick.example')+': ' : '')+tr('quick.purpose.'+p.id))
57
+ : quick.step === 'appearance' ? [
58
+ tr('fields.global.theme.label')+': '+tr('values.'+d.theme),
59
+ tr('settings.colors')+': '+tr('values.'+(d.use_colors?'on':'off')),
60
+ tr('settings.palette')+': '+d.palette,
61
+ tr('settings.separator-style')+': '+tr('values.'+d.separator_style), tr('quick.next'),
62
+ ] : [tr('quick.fine_tune'),tr('quick.save'),tr('quick.back')];
63
+ const paragraphs=[tr(preset.requirements_key),tr('quick.sample'),
64
+ ...(!d.subagents.enabled && preset.id==='multi-agent' ? [tr('quick.subagents_off')] : []),
65
+ ...(quick.step==='review' ? [tr('quick.replace')] : [])];
66
+ const detail=wrapText(paragraphs,width), menuHeight=Math.max(1, Math.min(rows.length,Math.floor(height/2)));
67
+ const start=Math.max(0, Math.min(quick.selected,rows.length-menuHeight,quick.selected-menuHeight+1));
68
+ const result=rows.slice(start,start+menuHeight).map((text,index)=>({text:(start+index===quick.selected?'› ':' ')+text,selected:start+index===quick.selected}));
69
+ const capacity=Math.max(0,height-result.length), offset=Math.min(quick.detailScroll,Math.max(0,detail.length-capacity));
70
+ result.push(...detail.slice(offset,offset+capacity).map(text=>({text,selected:false})));
71
+ return result;
72
+ }
73
+
74
+ export function controlQuick(editor: Editor, key: string): 'transfer' | 'save' | null {
75
+ const quick = editor.quick;
76
+ if (!quick) return null;
77
+ const effect = quickKey(quick,key);
78
+ if (effect === 'cancel') editor.quick = null;
79
+ if (effect === 'preset') { editor.preset=quick.preset; editor.pendingTransfer='preset'; return 'transfer'; }
80
+ if (effect === 'accept' || effect === 'save') { editor.replaceDraft(quick.candidate); editor.quick=null; return effect === 'save' ? 'save' : null; }
81
+ return null;
82
+ }
@@ -0,0 +1,68 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import { graphemes, displayWidth } from '../unicode.ts';
3
+
4
+ /** Offsets always lie on extended-grapheme boundaries; values retain their original bytes. */
5
+ export interface TextInput { value: string; cursor: number; scroll: number }
6
+ export interface TextKey { key: string; ctrl?: boolean; meta?: boolean; paste?: boolean; text?: boolean; overflow?: boolean }
7
+ export type TextAction = { kind: 'insert'; value: string } | { kind: 'left' | 'right' | 'home' | 'end' | 'backspace' | 'delete' | 'clear' };
8
+ export function textInput(value: string): TextInput { return { value, cursor: value.length, scroll: 0 }; }
9
+ function boundaries(value: string): number[] {
10
+ let position = 0;
11
+ return [0, ...graphemes(value).map(cluster => position += cluster.length)];
12
+ }
13
+ export function textAction(event: TextKey): TextAction | null {
14
+ if (event.paste || event.text) return { kind: 'insert', value: event.key };
15
+ if (event.meta) return null;
16
+ if (event.ctrl) return event.key.toLowerCase() === 'u' ? { kind: 'clear' } : null;
17
+ if (['left', 'right', 'home', 'end', 'backspace', 'delete'].includes(event.key))
18
+ return { kind: event.key as 'left' };
19
+ return [...event.key].length === 1 ? { kind: 'insert', value: event.key } : null;
20
+ }
21
+ export function editText(state: TextInput, action: TextAction, limit: number): { state: TextInput; error?: 'invalid' | 'limit' } {
22
+ const points = boundaries(state.value), index = Math.max(0, points.indexOf(state.cursor));
23
+ let value = state.value, cursor = points[index]!;
24
+ switch (action.kind) {
25
+ case 'home': cursor = 0; break;
26
+ case 'end': cursor = value.length; break;
27
+ case 'left': cursor = points[Math.max(0, index - 1)]!; break;
28
+ case 'right': cursor = points[Math.min(points.length - 1, index + 1)]!; break;
29
+ case 'clear': value = ''; cursor = 0; break;
30
+ case 'backspace': {
31
+ const before = points[Math.max(0, index - 1)]!;
32
+ value = value.slice(0, before) + value.slice(cursor); cursor = before; break;
33
+ }
34
+ case 'delete': value = value.slice(0, cursor) + value.slice(points[Math.min(points.length - 1, index + 1)]!); break;
35
+ case 'insert':
36
+ if (/[\p{Cc}\p{Cs}\p{Zl}\p{Zp}]/u.test(action.value)) return { state, error: 'invalid' };
37
+ value = value.slice(0, cursor) + action.value + value.slice(cursor);
38
+ if ([...value].length > limit) return { state, error: 'limit' };
39
+ cursor += action.value.length;
40
+ break;
41
+ }
42
+ // Insertion/deletion can join adjacent clusters (combining marks, flags or ZWJ).
43
+ cursor = boundaries(value).find(point => point >= cursor) ?? value.length;
44
+ return { state: { value, cursor, scroll: Math.min(state.scroll, cursor) } };
45
+ }
46
+ export function inputKey(value: string, previous: TextInput | undefined, event: TextKey, limit: number) {
47
+ const state = previous?.value === value ? previous : textInput(value), action = textAction(event);
48
+ return action ? editText(state, action, limit) : { state };
49
+ }
50
+ /** A visible caret takes one cell; resize only adjusts the viewport, never the value. */
51
+ export function inputView(state: TextInput, width: number): string {
52
+ width = Math.max(1, Math.trunc(width));
53
+ const points = boundaries(state.value);
54
+ let start = points.includes(state.scroll) ? Math.min(state.scroll, state.cursor) : 0;
55
+ while (start < state.cursor && displayWidth(state.value.slice(start, state.cursor)) + 1 > width)
56
+ start = points[points.indexOf(start) + 1]!;
57
+ state.scroll = start;
58
+ let output = '', used = 0;
59
+ for (let index = points.indexOf(start); index < points.length; index++) {
60
+ const point = points[index]!;
61
+ if (point === state.cursor) { output += '▏'; used++; }
62
+ if (index === points.length - 1) break;
63
+ const cluster = state.value.slice(point, points[index + 1]), cells = displayWidth(cluster);
64
+ if (used + cells > width) break;
65
+ output += cluster; used += cells;
66
+ }
67
+ return output;
68
+ }
@@ -1,10 +1,10 @@
1
1
  // Generated by tools/generation/resources.ts; do not edit.
2
- export const PROTOCOL_VERSION = 12 as const;
2
+ export const PROTOCOL_VERSION = 13 as const;
3
3
  export const ITEM_DEFAULTS = {"label": null, "icon": null, "priority": 50, "max_width": null, "formatting": {}, "foreground": null, "background": null, "visibility": "always", "visibility_threshold": 70};
4
4
  export const VISIBILITY_ITEMS = {"main": {"git": "git-dirty", "git-changes": "git-dirty", "active-agents": "nonzero", "task-progress": "nonzero", "context-used": "used-at-least", "context-remaining": "used-at-least", "five-hour-limit": "used-at-least", "weekly-limit": "used-at-least", "spend-limit": "used-at-least"}, "subagent": {"context-used": "used-at-least", "context-remaining": "used-at-least"}} as const;
5
5
  export const GUIDANCE_KEYS = {"source_kinds": ["configuration", "official_input", "local_git", "local_system", "transcript", "local_state", "lifecycle", "native_timing", "live_metrics", "telemetry"], "scopes": ["main", "main_context", "session", "all_sessions", "task", "subagent", "subagent_context", "repository", "local", "latest_request"], "requirements": ["observed_field", "subagent_rows", "agent_context", "configured_effort", "agent_effort_optional", "git_repository", "git_upstream", "git_base", "pull_request", "worktree_session", "usage_records", "task_observation", "native_timing", "complete_waits", "live_metrics", "owned_agents", "checklist_events", "tool_events", "complete_stream", "request_coverage", "existing_telemetry", "gateway", "gateway_284", "valid_window", "warm_cache", "fast_mode", "thinking", "agent_mode", "vim_mode", "context_observation"]} as const;
6
6
  export const EDITOR_FIELDS = {"global": [{"key": "theme", "label": "Statusline theme", "group": "Appearance", "kind": "choice", "choices": ["classic", "dark", "light", "terminal"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "powerline_glyph", "label": "Powerline separator", "group": "Appearance", "kind": "choice", "choices": ["ascii", "powerline"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "statusline_language", "label": "Statusline language (save with display settings)", "group": "Appearance", "kind": "choice", "choices": ["en", "zh-CN", "zh-TW", "zh-HK", "ja", "ko"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "metrics.branch_diff_base_ref", "label": "Branch diff base (inherit = auto)", "group": "Git metrics", "kind": "text", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "formatting.model_name", "label": "Model Name", "group": "Formatting", "kind": "choice", "choices": ["original", "short"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.number_format", "label": "Number Format", "group": "Formatting", "kind": "choice", "choices": ["legacy", "compact", "full", "grouped"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.labels", "label": "Labels", "group": "Formatting", "kind": "choice", "choices": ["legacy", "short", "off"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.icons", "label": "Icons", "group": "Formatting", "kind": "choice", "choices": ["legacy", "unicode", "ascii", "off"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.allowance", "label": "Allowance", "group": "Formatting", "kind": "choice", "choices": ["remaining", "used"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.reset_format", "label": "Reset Format", "group": "Formatting", "kind": "choice", "choices": ["countdown", "time", "datetime"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.reset_timezone", "label": "Reset Timezone", "group": "Formatting", "kind": "choice", "choices": ["local", "UTC"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.thresholds.enabled", "label": "Threshold colors", "group": "Risk colors", "kind": "boolean", "choices": [], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "formatting.thresholds.warning", "label": "Warning (%)", "group": "Risk colors", "kind": "integer", "choices": [], "minimum": 0, "maximum": 100, "nullable": false}, {"key": "formatting.thresholds.critical", "label": "Critical (%)", "group": "Risk colors", "kind": "integer", "choices": [], "minimum": 0, "maximum": 100, "nullable": false}, {"key": "subagents.visibility", "label": "Visible agents", "group": "Subagent visibility", "kind": "choice", "choices": ["all", "running"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "subagents.hide_completed", "label": "Hide completed", "group": "Subagent visibility", "kind": "boolean", "choices": [], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "subagents.row_limit", "label": "Agent row limit", "group": "Subagent visibility", "kind": "integer", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "subagents.task_max_width", "label": "Task text width", "group": "Subagent visibility", "kind": "integer", "choices": [], "minimum": 2, "maximum": 10000, "nullable": true}], "item": [{"key": "foreground", "label": "Foreground (inherit/default/ansi:N/#RRGGBB)", "group": "Item colors", "kind": "text", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "background", "label": "Background (inherit/default/ansi:N/#RRGGBB)", "group": "Item colors", "kind": "text", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "visibility", "label": "Visibility rule", "group": "Conditional visibility", "kind": "choice", "choices": ["always", "git-dirty", "nonzero", "used-at-least"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "visibility_threshold", "label": "Minimum used (%)", "group": "Conditional visibility", "kind": "integer", "choices": [], "minimum": 0, "maximum": 100, "nullable": false}, {"key": "label", "label": "Label (inherit = default)", "group": "Item format", "kind": "text", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "icon", "label": "Icon (inherit = default)", "group": "Item format", "kind": "text", "choices": [], "minimum": 0, "maximum": 10000, "nullable": true}, {"key": "priority", "label": "Priority", "group": "Item fitting", "kind": "integer", "choices": [], "minimum": 0, "maximum": 100, "nullable": false}, {"key": "max_width", "label": "Maximum width", "group": "Item fitting", "kind": "integer", "choices": [], "minimum": 2, "maximum": 10000, "nullable": true}, {"key": "model_name", "label": "Model Name", "group": "Item format", "kind": "choice", "choices": ["inherit", "original", "short"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "number_format", "label": "Number Format", "group": "Item format", "kind": "choice", "choices": ["inherit", "legacy", "compact", "full", "grouped"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "labels", "label": "Labels", "group": "Item format", "kind": "choice", "choices": ["inherit", "legacy", "short", "off"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "icons", "label": "Icons", "group": "Item format", "kind": "choice", "choices": ["inherit", "legacy", "unicode", "ascii", "off"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "allowance", "label": "Allowance", "group": "Item format", "kind": "choice", "choices": ["inherit", "remaining", "used"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "reset_format", "label": "Reset Format", "group": "Item format", "kind": "choice", "choices": ["inherit", "countdown", "time", "datetime"], "minimum": 0, "maximum": 10000, "nullable": false}, {"key": "reset_timezone", "label": "Reset Timezone", "group": "Item format", "kind": "choice", "choices": ["inherit", "local", "UTC"], "minimum": 0, "maximum": 10000, "nullable": false}]} as const;
7
- export const PRESETS = [{"id": "left-right", "label": "Left Right", "rows": [["model-with-effort", "git", "spacer", "context-remaining"]], "layout_mode": "explicit"}, {"id": "repeated-metrics", "label": "Repeated Metrics", "rows": [["input-tokens", "input-tokens"]], "layout_mode": "explicit"}, {"id": "minimal", "label": "Minimal", "rows": [["model-with-effort", "current-dir", "context-remaining", "task-timer"]], "layout_mode": "auto"}, {"id": "developer", "label": "Developer", "rows": [["model-with-effort", "current-dir", "git"], ["context-remaining", "tokens", "task-timer", "session-cost"]], "layout_mode": "explicit"}, {"id": "monitoring", "label": "Monitoring", "rows": [["context-used", "five-hour-limit", "weekly-limit", "spend-limit"], ["five-hour-reset", "weekly-reset", "cache-state", "cache-expires"], ["session-cost", "session-duration", "api-duration", "api-requests", "cache-misses"]], "layout_mode": "explicit"}, {"id": "multi-agent", "label": "Multi Agent", "rows": [["model-with-effort", "current-dir", "git"], ["context-remaining", "tokens", "task-timer"]], "layout_mode": "explicit"}] as const;
7
+ export const PRESETS = [{"id": "developer", "purpose_key": "quick.purpose.developer", "requirements_key": "quick.requirements.developer", "example": false, "label": "Developer", "rows": [["model-with-effort", "current-dir", "git"], ["context-remaining", "tokens", "task-timer", "session-cost"]], "layout_mode": "explicit"}, {"id": "minimal", "purpose_key": "quick.purpose.minimal", "requirements_key": "quick.requirements.minimal", "example": false, "label": "Minimal", "rows": [["model-with-effort", "current-dir", "context-remaining", "task-timer"]], "layout_mode": "auto"}, {"id": "monitoring", "purpose_key": "quick.purpose.monitoring", "requirements_key": "quick.requirements.monitoring", "example": false, "label": "Monitoring", "rows": [["context-used", "five-hour-limit", "weekly-limit", "spend-limit"], ["five-hour-reset", "weekly-reset", "cache-state", "cache-expires"], ["session-cost", "session-duration", "api-duration", "api-requests", "cache-misses"]], "layout_mode": "explicit"}, {"id": "multi-agent", "purpose_key": "quick.purpose.multi-agent", "requirements_key": "quick.requirements.multi-agent", "example": false, "label": "Multi Agent", "rows": [["model-with-effort", "current-dir", "git"], ["context-remaining", "tokens", "task-timer"]], "layout_mode": "explicit"}, {"id": "left-right", "purpose_key": "quick.purpose.left-right", "requirements_key": "quick.requirements.left-right", "example": true, "label": "Left Right", "rows": [["model-with-effort", "git", "spacer", "context-remaining"]], "layout_mode": "explicit"}, {"id": "repeated-metrics", "purpose_key": "quick.purpose.repeated-metrics", "requirements_key": "quick.requirements.repeated-metrics", "example": true, "label": "Repeated Metrics", "rows": [["input-tokens", "input-tokens"]], "layout_mode": "explicit"}] as const;
8
8
  export const FORMAT_CHOICES = {"model_name": ["original", "short"], "number_format": ["legacy", "compact", "full", "grouped"], "labels": ["legacy", "short", "off"], "icons": ["legacy", "unicode", "ascii", "off"], "allowance": ["remaining", "used"], "reset_format": ["countdown", "time", "datetime"], "reset_timezone": ["local", "UTC"]} as const;
9
9
  export const FORMAT_DEFAULTS = {"model_name": "original", "number_format": "legacy", "labels": "legacy", "icons": "legacy", "allowance": "remaining", "reset_format": "countdown", "reset_timezone": "local", "thresholds": {"enabled": false, "warning": 70, "critical": 90}} as const;
10
10
  export type MainItemId = "model-with-effort" | "model" | "effort" | "fast-mode" | "thinking" | "current-dir" | "project-name" | "hostname" | "git" | "git-branch" | "git-changes" | "git-ahead-behind" | "branch-diff" | "pr" | "repo" | "worktree" | "context-remaining" | "context-used" | "context-window-size" | "context-tokens" | "five-hour-limit" | "five-hour-reset" | "weekly-limit" | "weekly-reset" | "spend-limit" | "spend-amount" | "spend-period" | "tokens" | "input-tokens" | "output-tokens" | "prompt-cache" | "cache-state" | "cache-expires" | "cache-misses" | "api-requests" | "task-timer" | "task-active-timer" | "version" | "session" | "session-name" | "session-id" | "session-id-short" | "output-style" | "cost" | "session-cost" | "session-duration" | "api-duration" | "lines-changed" | "agent" | "vim-mode" | "run-state" | "permission-mode" | "active-agents" | "task-progress" | "last-tool" | "ttft" | "output-rate" | "prompt-input-tokens" | "prompt-output-tokens" | "prompt-cost" | "text" | "spacer";
@@ -30,7 +30,7 @@ export const SEPARATORSTYLE_VALUES = ["classic", "compact", "powerline"] as cons
30
30
  export const SCOPELABELS_VALUES = ["off", "when-subagents", "always"] as const;
31
31
  export const STATUSLINELANGUAGE_VALUES = ["en", "zh-CN", "zh-TW", "zh-HK", "ja", "ko"] as const;
32
32
  export const UNAVAILABLEREASON_VALUES = ["not_observed", "unsupported_host", "unknown_host_version", "source_unavailable", "condition_not_met", "runtime_disabled", "native_timing_disabled", "wait_coverage_missing", "stale", "incomplete", "ambiguous_owner", "observed_only", "missing_stream", "synthetic_response", "abnormal_clock", "inconsistent_request", "request_join_unavailable"] as const;
33
- export type Operation = "describe" | "read" | "preview" | "apply" | "import" | "export" | "preset" | "read_ui_preferences" | "set_ui_language" | "review_import";
33
+ export type Operation = "describe" | "read" | "preview" | "apply" | "import" | "export" | "preset" | "read_ui_preferences" | "set_ui_language" | "review_import" | "explain";
34
34
  export interface ItemGuidance {
35
35
  source_kinds: string[];
36
36
  measurement_scope: string;
@@ -175,6 +175,24 @@ export interface PreviewResult {
175
175
  main: Span[][];
176
176
  subagents: Span[][];
177
177
  }
178
+ export const SAMPLE_REASONS = ['sample_visible','sample_empty','sample_condition_hidden','sample_truncated','sample_priority_omitted','sample_width_omitted','sample_row_hidden','sample_spacer'] as const;
179
+ export type SampleReason = typeof SAMPLE_REASONS[number];
180
+ export const EXPLAIN_REASONS = ['configured_on','configured_off','scope_disabled','installation_owned','installation_absent','installation_foreign','installation_unknown','unknown_host_version','host_supported','unsupported_host','host_requirement_unknown','collector_unknown','native_timing_on','native_timing_off','live_metrics_on','live_metrics_off','actual_not_observed'] as const;
181
+ export interface ExplainReason { code: string; origin: 'configuration' | 'local_configuration' | 'host_capability' | 'unknown'; }
182
+ export interface InstanceSample { row_id: string; outcome: SampleReason; truncated: boolean; }
183
+ export interface ExplainInstance {
184
+ id: string; type_id: string; enabled: boolean;
185
+ reasons: ExplainReason[];
186
+ samples: InstanceSample[];
187
+ }
188
+ export interface ExplainResult {
189
+ sample: true;
190
+ scope: Scope;
191
+ width: number;
192
+ actual_availability: 'not_observed';
193
+ preview: PreviewResult;
194
+ instances: ExplainInstance[];
195
+ }
178
196
  export interface LocalizedMessage {
179
197
  key: string;
180
198
  params: Record<string, unknown>;
@@ -209,6 +227,9 @@ export interface EditorField {
209
227
  nullable: boolean;
210
228
  }
211
229
  export interface PresetDescription {
230
+ purpose_key: string;
231
+ requirements_key: string;
232
+ example: boolean;
212
233
  id: string;
213
234
  label: string;
214
235
  rows: string[][];
@@ -258,6 +279,7 @@ export interface ResultMap {
258
279
  describe: DescribeResult;
259
280
  read: ReadResult;
260
281
  preview: PreviewResult;
282
+ explain: ExplainResult;
261
283
  apply: ApplyResult;
262
284
  import: TransferResult;
263
285
  review_import: ImportReviewResult;
@@ -272,5 +294,5 @@ export interface Request {
272
294
  operation: Operation;
273
295
  payload: unknown;
274
296
  }
275
- export type Result = PreviewResult | UiPreferencesResult | ReadResult | TransferResult | ImportReviewResult | ExportResult | DescribeResult | ApplyResult;
297
+ export type Result = ExplainResult | PreviewResult | UiPreferencesResult | ReadResult | TransferResult | ImportReviewResult | ExportResult | DescribeResult | ApplyResult;
276
298
  export type Response = { protocol_version: typeof PROTOCOL_VERSION; result: Result } | { protocol_version: typeof PROTOCOL_VERSION; error: ProtocolError };