@fbincon/claude-code-statusline 3.3.0 → 3.4.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 (106) hide show
  1. package/README.md +73 -70
  2. package/candidate.json +190 -139
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.d.ts +12 -0
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +101 -0
  5. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -0
  6. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.d.ts +54 -0
  7. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js +199 -0
  8. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js.map +1 -0
  9. package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js +5 -1
  10. package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js.map +1 -1
  11. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.d.ts +1 -0
  12. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js +4 -1
  13. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js.map +1 -1
  14. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js +9 -2
  15. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js.map +1 -1
  16. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.d.ts +8 -2
  17. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js +6 -3
  18. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js.map +1 -1
  19. package/node_modules/@fbincon/statusline-cli/dist/src/help.js +9 -0
  20. package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
  21. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.d.ts +2 -1
  22. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +3 -1
  23. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
  24. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js +4 -1
  25. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js.map +1 -1
  26. package/node_modules/@fbincon/statusline-cli/dist/src/main.js +30 -8
  27. package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
  28. package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js +1 -1
  29. package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js.map +1 -1
  30. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.d.ts +12 -0
  31. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.js +59 -0
  32. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.js.map +1 -0
  33. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js +15 -2
  34. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js.map +1 -1
  35. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.d.ts +3 -0
  36. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js +25 -0
  37. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js.map +1 -0
  38. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.d.ts +4 -0
  39. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.js +93 -0
  40. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.js.map +1 -0
  41. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +5 -3
  42. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +33 -8
  43. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  44. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  45. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +89 -3
  46. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +54 -4
  47. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +8 -1
  48. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +1 -0
  49. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +2 -0
  50. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/profile-manager.ts +239 -0
  51. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/task-detail.ts +27 -0
  52. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +53 -3
  53. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +768 -6
  54. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +2 -1
  55. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +16 -14
  56. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +6 -2
  57. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +1 -0
  58. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  59. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  60. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.d.ts +16 -0
  61. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js +69 -0
  62. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js.map +1 -0
  63. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +82 -3
  64. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +1 -1
  65. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +71 -4
  66. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  67. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +2 -0
  68. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +1 -0
  69. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  70. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.d.ts +60 -0
  71. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js +330 -0
  72. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js.map +1 -0
  73. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.d.ts +4 -0
  74. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.js +25 -0
  75. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.js.map +1 -0
  76. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +762 -0
  77. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +768 -6
  78. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  79. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  80. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  81. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.d.ts +24 -0
  82. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.js +153 -0
  83. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.js.map +1 -0
  84. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +128 -1
  85. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +128 -1
  86. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +128 -1
  87. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +128 -1
  88. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +128 -1
  89. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +128 -1
  90. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.d.ts +8 -0
  91. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.js +41 -0
  92. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.js.map +1 -0
  93. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +5 -0
  94. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  95. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +2 -0
  96. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  97. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +2 -0
  98. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  99. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +3 -2
  100. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  101. package/node_modules/@fbincon/statusline-tui/dist/src/session.js +7 -3
  102. package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
  103. package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
  104. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +18 -2
  105. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  106. package/package.json +1 -1
@@ -0,0 +1,239 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { ConfigTarget, DisplayDraft, Operation, ProfilesResult, ResultFor } from '../generated-contracts.ts';
3
+ import { t, text, type Language, type LocalizedText } from '../i18n/index.ts';
4
+ import type { Editor } from './draft.ts';
5
+ import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
6
+ import { wrapText } from '../../ui/text.ts';
7
+ import { BackendError } from '../backend.ts';
8
+
9
+ type Action = 'edit' | 'activate' | 'save' | 'save_bind' | 'rename' | 'delete' | 'bind' | 'unbind' | 'import' | 'export';
10
+ type Switch = { target: ConfigTarget; display?: DisplayDraft };
11
+ type Effect = { kind: 'load' } | { kind: 'switch'; next: Switch; save: boolean } |
12
+ { kind: 'mutation'; payload: Record<string, unknown> } | { kind: 'import'; path: string } |
13
+ { kind: 'export'; path: string; name: string; display: DisplayDraft; overwrite: boolean };
14
+ export interface ProfileManager {
15
+ library: ProfilesResult | null;
16
+ page: 'list' | 'actions' | 'form' | 'confirm' | 'dirty';
17
+ selected: string | null;
18
+ projectRoot: string | null;
19
+ cursor: number;
20
+ action: Action | null;
21
+ fields: { key: 'name' | 'path'; input: TextInput }[];
22
+ field: number;
23
+ candidate: DisplayDraft | null;
24
+ confirmation: Effect | null;
25
+ next: Switch | null;
26
+ effect: Effect | null;
27
+ message: LocalizedText | null;
28
+ uncertain: boolean;
29
+ }
30
+ export interface ProfileBackend { request<O extends Operation>(operation: O, payload?: unknown): ResultFor<O> | Promise<ResultFor<O>> }
31
+ export function openProfiles(editor: Editor): void {
32
+ editor.profiles = { library: null, page: 'list', selected: null, projectRoot: null, cursor: 0, action: null, fields: [], field: 0, candidate: null,
33
+ confirmation: null, next: null, effect: { kind: 'load' }, message: null, uncertain: false };
34
+ }
35
+ export function targetLabel(editor: Editor, language: Language): string {
36
+ const c = editor.baseline.configuration;
37
+ if (!c) return t('profiles.user', language);
38
+ return t('profiles.target', language, { name: c.profile_name ?? t('profiles.user', language),
39
+ root: c.project_root ?? '—', count: c.shared_projects.length });
40
+ }
41
+ function entries(m: ProfileManager): { key: string; label: string; raw?: boolean }[] {
42
+ if (m.page === 'actions') return ['edit','activate','rename','delete','bind','export'].map(key => ({ key, label: 'profiles.action.' + key }));
43
+ return [{ key: 'user', label: 'profiles.user' }, ...(m.library?.profiles ?? []).map(p => ({ key: p.id, label: p.name, raw: true })),
44
+ ...(m.library?.bindings ?? []).map(b=>({key:'binding:'+b.root,label:b.root+' → '+(m.library!.profiles.find(p=>p.id===b.profile_id)?.name ?? b.profile_id),raw:true})),
45
+ ...['save','save_bind','import','unbind'].map(key => ({ key: 'action:' + key, label: 'profiles.action.' + key }))];
46
+ }
47
+ function startForm(e: Editor, action: Action): void {
48
+ const m = e.profiles!, profile = m.library?.profiles.find(p => p.id === m.selected), project = e.baseline.configuration;
49
+ const path = m.projectRoot ?? (project?.target.kind === 'project' ? project.target.path : project?.project_root ?? '');
50
+ m.action = action; m.page = 'form'; m.field = 0; m.message = null;
51
+ const keys = ['save','rename'].includes(action) ? ['name'] : action === 'save_bind' ? ['name','path'] : ['path'];
52
+ m.fields = keys.map(key => ({ key: key as 'name' | 'path', input: textInput(key === 'name' ? action === 'rename' ? profile?.name ?? '' : '' : ['bind','unbind','save_bind'].includes(action) ? path : 'profile.json') }));
53
+ }
54
+ function switching(e: Editor, next: Switch): void {
55
+ const m = e.profiles!;
56
+ if (e.modified) { m.next = next; m.page = 'dirty'; m.cursor = 0; }
57
+ else m.effect = { kind: 'switch', next, save: false };
58
+ }
59
+ function submitForm(e: Editor): void {
60
+ const m = e.profiles!, values = Object.fromEntries(m.fields.map(f => [f.key, f.input.value]));
61
+ const profile = m.library?.profiles.find(p => p.id === m.selected);
62
+ if (m.fields.some(f => !f.input.value.trim())) { m.message = text('profiles.required'); return; }
63
+ if (m.action === 'import') { m.effect = { kind: 'import', path: values.path! }; return; }
64
+ if (m.action === 'export' && profile) {
65
+ m.confirmation = { kind: 'export', path: values.path!, name: profile.name, display: profile.display, overwrite: false };
66
+ } else {
67
+ const payload: Record<string, unknown> = { action: m.action === 'save_bind' ? 'save' : m.action, expected_revision: m.library!.revision, overwrite: false };
68
+ if (m.action === 'save' || m.action === 'save_bind') Object.assign(payload, { name: values.name, display: m.candidate ?? e.draft.display, ...(m.action === 'save_bind' ? { bind_path: values.path } : {}) });
69
+ if (m.action === 'rename') Object.assign(payload, { id: m.selected, name: values.name });
70
+ if (m.action === 'bind') Object.assign(payload, { id: m.selected, path: values.path });
71
+ if (m.action === 'unbind') payload.path = values.path;
72
+ m.confirmation = { kind: 'mutation', payload };
73
+ }
74
+ m.page = 'confirm'; m.cursor = 0;
75
+ }
76
+ /** One reducer supplies both editors; text never dispatches shortcuts. */
77
+ export function profilesKey(e: Editor, event: TextKey): 'profiles' | null {
78
+ const m = e.profiles;
79
+ if (!m) return null;
80
+ const key = event.key === 'return' ? 'enter' : event.key, plain = !event.ctrl && !event.meta && !event.text && !event.paste;
81
+ const cancel = !event.text && !event.paste && (key === 'escape' || event.ctrl && key.toLowerCase() === 'g');
82
+ if (event.overflow) { m.message = text('input.overflow'); return null; }
83
+ if (cancel) {
84
+ if (m.uncertain) { m.message = text('profiles.uncertain'); return null; }
85
+ if (m.page === 'list') e.profiles = null;
86
+ else { m.page = 'list'; m.cursor = 0; m.candidate = null; m.confirmation = null; }
87
+ return null;
88
+ }
89
+ if (m.page === 'form') {
90
+ if (plain && key === 'enter') {
91
+ if (m.field + 1 < m.fields.length) m.field++;
92
+ else submitForm(e);
93
+ } else if (plain && key === 'tab') m.field = (m.field + 1) % m.fields.length;
94
+ else {
95
+ const field = m.fields[m.field]!, edited = inputKey(field.input.value, field.input, event, field.key === 'name' ? 128 : 4096);
96
+ field.input = edited.state;
97
+ m.message = edited.error ? text('input.' + edited.error, { limit: field.key === 'name' ? 128 : 4096 }) : null;
98
+ }
99
+ return m.effect ? 'profiles' : null;
100
+ }
101
+ if (!plain) return null;
102
+ if (key.toLowerCase() === 'r') { m.effect = { kind: 'load' }; return 'profiles'; }
103
+ if (m.uncertain) { m.message = text('profiles.uncertain'); return null; }
104
+ if (m.page === 'dirty') {
105
+ const choices = ['save','discard','cancel'];
106
+ if (key === 'up') m.cursor = Math.max(0, m.cursor - 1);
107
+ if (key === 'down') m.cursor = Math.min(2, m.cursor + 1);
108
+ if (key === 'enter') {
109
+ if (choices[m.cursor] === 'cancel') { m.page = 'list'; m.cursor = 0; }
110
+ else m.effect = { kind: 'switch', next: m.next!, save: m.cursor === 0 };
111
+ }
112
+ return m.effect ? 'profiles' : null;
113
+ }
114
+ if (m.page === 'confirm') {
115
+ if (key === 'up' || key === 'down') m.cursor = 1 - m.cursor;
116
+ if (key === 'enter') {
117
+ if (m.cursor === 1) { m.page = 'list'; m.cursor = 0; m.confirmation = null; }
118
+ else { m.effect = m.confirmation; return 'profiles'; }
119
+ }
120
+ return null;
121
+ }
122
+ const rows = entries(m);
123
+ if (key === 'up') m.cursor = Math.max(0, m.cursor - 1);
124
+ if (key === 'down') m.cursor = Math.min(rows.length - 1, m.cursor + 1);
125
+ if (key === 'home') m.cursor = 0;
126
+ if (key === 'end') m.cursor = rows.length - 1;
127
+ if (key === 'pageup') m.cursor = Math.max(0, m.cursor - 5);
128
+ if (key === 'pagedown') m.cursor = Math.min(rows.length - 1, m.cursor + 5);
129
+ if (key === 'enter') {
130
+ const row = rows[m.cursor]!;
131
+ if (m.page === 'list') {
132
+ if (row.key === 'user') switching(e, { target: { kind: 'user' } });
133
+ else if (row.key.startsWith('action:')) { m.candidate = null; startForm(e, row.key.slice(7) as Action); }
134
+ else {
135
+ m.projectRoot = row.key.startsWith('binding:') ? row.key.slice(8) : null;
136
+ m.selected = m.projectRoot ? m.library!.bindings.find(b=>b.root===m.projectRoot)!.profile_id : row.key;
137
+ const selected = m.library!.profiles.find(p=>p.id===m.selected);
138
+ if (!selected) { m.message=text('profiles.error.missing',{value:m.selected}); return null; }
139
+ m.candidate=selected.display; m.page='actions';m.cursor=0;
140
+ }
141
+ } else if (row.key === 'edit') switching(e, { target: m.projectRoot ? {kind:'project',path:m.projectRoot} : { kind: 'profile', id: m.selected! } });
142
+ else if (row.key === 'activate') switching(e, { target: { kind: 'user' }, display: m.candidate! });
143
+ else if (row.key === 'delete') {
144
+ m.action = 'delete'; m.confirmation = { kind: 'mutation', payload: { action: 'delete', id: m.selected, expected_revision: m.library!.revision } };
145
+ m.page = 'confirm'; m.cursor = 1;
146
+ } else startForm(e, row.key as Action);
147
+ }
148
+ return m.effect ? 'profiles' : null;
149
+ }
150
+ export async function performProfileAction(e: Editor, backend: ProfileBackend): Promise<void> {
151
+ const m = e.profiles, effect = m?.effect;
152
+ if (!m || !effect) return;
153
+ m.effect = null;
154
+ let writing = false;
155
+ try {
156
+ if (effect.kind === 'load') {
157
+ m.library = await backend.request('profiles_read'); m.page = 'list'; m.cursor = 0;
158
+ m.message = m.uncertain ? text('profiles.review_saved') : null; m.uncertain = false; return;
159
+ }
160
+ if (effect.kind === 'switch') {
161
+ if (effect.save) {
162
+ if (!e.acceptNumeric()) throw new BackendError('invalid_draft', text('profiles.invalid_draft'));
163
+ writing = true;
164
+ const saved = await backend.request('apply', { draft: e.draft, expected_revision: e.baseline.revision,
165
+ ...(e.baseline.configuration ? { target: e.baseline.configuration.target } : {}) });
166
+ e.committed(saved); writing = false;
167
+ }
168
+ const current = await backend.request('read', { target: effect.next.target });
169
+ e.committed(current);
170
+ e.replaceDraft(current.draft);
171
+ if (effect.next.display) e.replaceDraft({ ...current.draft, display: JSON.parse(JSON.stringify(effect.next.display)) as DisplayDraft });
172
+ e.profiles = null; return;
173
+ }
174
+ if (effect.kind === 'import') {
175
+ const result = await backend.request('profile_import', { path: effect.path });
176
+ m.candidate = result.display; startForm(e, 'save'); m.fields[0]!.input = textInput(result.name);
177
+ m.message = text('profiles.import_review'); return;
178
+ }
179
+ writing = true;
180
+ if (effect.kind === 'export') {
181
+ await backend.request('profile_export', { path: effect.path, name: effect.name, display: effect.display, overwrite: effect.overwrite });
182
+ } else {
183
+ m.library = await backend.request('profiles_apply', effect.payload);
184
+ writing = false;
185
+ if (effect.payload.bind_path && typeof effect.payload.bind_path === 'string') {
186
+ const host = e.draft.host;
187
+ const current = await backend.request('read', { target: { kind: 'project', path: effect.payload.bind_path } });
188
+ e.committed(current); e.replaceDraft({ ...current.draft, host });
189
+ } else if (e.baseline.configuration && (e.baseline.configuration.target.kind !== 'profile' ||
190
+ m.library.profiles.some(p=>p.id===e.baseline.configuration!.profile_id))) {
191
+ const current = await backend.request('read', { target: e.baseline.configuration.target });
192
+ if (current.configuration?.profile_id === e.baseline.configuration.profile_id &&
193
+ JSON.stringify(current.draft) === JSON.stringify(e.baseline.draft)) e.baseline = current;
194
+ }
195
+ }
196
+ m.page = 'list'; m.cursor = 0; m.candidate = null; m.confirmation = null; m.message = text('profiles.saved');
197
+ } catch (error) {
198
+ const code = error instanceof BackendError ? error.code : '';
199
+ if (code === 'profile_duplicate' || code === 'profile_bound' || effect.kind === 'export' && code === 'io_error' && /EEXIST/u.test(String(error))) {
200
+ m.confirmation = effect.kind === 'mutation' ? { ...effect, payload: { ...effect.payload, overwrite: true } }
201
+ : effect.kind === 'export' ? { ...effect, overwrite: true } : null;
202
+ m.page = 'confirm'; m.cursor = 1; m.message = text('profiles.overwrite');
203
+ } else {
204
+ m.uncertain = writing && !['profile_conflict','profile_referenced','profile_invalid','profile_name','profile_path','ownership_mismatch','configuration_conflict','invalid_request','profile_size'].includes(code);
205
+ m.message = error instanceof BackendError && error.localization ? error.localization : text('profiles.failed', { value: error instanceof Error ? error.message : String(error) });
206
+ }
207
+ }
208
+ }
209
+ export function profilesView(e: Editor, language: Language, width: number, height: number): { text: string; selected: boolean }[] {
210
+ const m = e.profiles!;
211
+ const tr = (key: string) => t(key, language);
212
+ const lines: { text: string; selected: boolean }[] = [];
213
+ const add = (value: string, selected = false) => lines.push({ text: value, selected });
214
+ if (m.message) for (const line of wrapText([t(m.message.key, language, m.message.params)], width)) add(line);
215
+ if (m.uncertain) add(tr('profiles.uncertain'));
216
+ if (!m.library) { add(tr('profiles.loading')); return lines.slice(0, height); }
217
+ if (m.page === 'form') {
218
+ add(tr('profiles.action.' + m.action));
219
+ m.fields.forEach((f,i) => add(tr('profiles.field.' + f.key) + ': ' + inputView({ ...f.input }, Math.max(1, width - 12)), i === m.field));
220
+ add(tr('profiles.form_help')); return lines.slice(0, height);
221
+ }
222
+ const rows = m.page === 'confirm' ? [{ key:'confirm',label:'profiles.confirm' },{ key:'cancel',label:'profiles.cancel' }] :
223
+ m.page === 'dirty' ? ['save','discard','cancel'].map(key => ({ key, label:'profiles.'+key })) : entries(m);
224
+ if (m.page === 'dirty') add(tr('profiles.dirty'));
225
+ if (m.page === 'confirm') {
226
+ const value = m.confirmation;
227
+ add(tr('profiles.action.' + (m.action ?? 'export')));
228
+ if (value?.kind === 'mutation') add(String(value.payload.name ?? value.payload.path ?? m.library.profiles.find(p=>p.id===value.payload.id)?.name ?? ''));
229
+ if (value?.kind === 'export') add(value.path);
230
+ }
231
+ if (m.page === 'actions') {
232
+ add(m.library.profiles.find(p => p.id === m.selected)?.name ?? '');
233
+ add(t('profiles.shared', language, { count: m.library.bindings.filter(b => b.profile_id === m.selected).length }));
234
+ }
235
+ const capacity = Math.max(1, height - lines.length - 1), start = Math.max(0, Math.min(m.cursor, rows.length - capacity));
236
+ rows.slice(start,start+capacity).forEach((row,i) => add(('raw' in row && row.raw ? row.label : tr(row.label)), start+i === m.cursor));
237
+ add(tr('profiles.navigation'));
238
+ return lines.slice(0,height);
239
+ }
@@ -0,0 +1,27 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { TaskDetails } from '../generated-contracts.ts';
3
+ import { t, type Language } from '../i18n/index.ts';
4
+ import { wrapText } from '../../ui/text.ts';
5
+
6
+ /** Both native and CLI presentations retain every evidence source and timestamp. */
7
+ export function taskDetailLines(report: TaskDetails, language: Language, width = 100): string[] {
8
+ const tr = (key: string, params: Record<string, unknown> = {}) => t(key, language, params);
9
+ const status = (value: string | null) => value === null ? tr('task.unknown') : t('task.value.' + value, language, {}, value);
10
+ const duration = (value: number | null) => value === null ? tr('task.unknown') : value.toFixed(1) + 's';
11
+ const lines = [
12
+ tr('task.session', { value: report.session_id }), tr('task.prompt', { value: report.prompt_id ?? tr('task.unknown') }),
13
+ tr('task.captured', { value: report.captured_at }),
14
+ tr('task.status', { value: status(report.status), phase: status(report.phase) }),
15
+ tr('task.elapsed', { value: duration(report.elapsed_seconds) }), tr('task.active', { value: duration(report.active_seconds) }),
16
+ tr('task.progress', { value: report.progress ? report.progress.completed + '/' + report.progress.total : tr('task.unknown') }),
17
+ tr('task.agents'),
18
+ ...report.agents.flatMap(agent => [
19
+ `${agent.parent_id ? agent.parent_id + ' → ' : ''}${agent.name ?? agent.id} [${agent.id}]: ${status(agent.status)}`,
20
+ ...agent.evidence.map(e => tr('task.evidence', { source:e.source, scope:e.scope, status:status(e.status), time:e.observed_at ?? tr('task.unknown'), freshness:status(e.freshness) })),
21
+ ]),
22
+ tr('task.sources'),
23
+ ...report.evidence.map(e => tr('task.evidence', { source:e.source, scope:e.scope, status:status(e.status), time:e.observed_at ?? tr('task.unknown'), freshness:status(e.freshness) })),
24
+ ...report.limitations.map(reason => t('task.limit.' + reason, language, {}, reason)),
25
+ ];
26
+ return wrapText(lines.map(line=>line.replace(/\x1b\[[0-?]*[ -/]*[@-~]/gu,'').replace(/[\p{Cc}\p{Cs}]/gu,'')), Math.max(2,width));
27
+ }
@@ -1,5 +1,5 @@
1
1
  // Generated by tools/generation/resources.ts; do not edit.
2
- export const PROTOCOL_VERSION = 14 as const;
2
+ export const PROTOCOL_VERSION = 15 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;
@@ -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" | "explain" | "diagnose";
33
+ export type Operation = "describe" | "read" | "preview" | "apply" | "import" | "export" | "preset" | "read_ui_preferences" | "set_ui_language" | "review_import" | "explain" | "diagnose" | "profiles_read" | "profiles_apply" | "profile_import" | "profile_export" | "task_details";
34
34
  export interface ItemGuidance {
35
35
  source_kinds: string[];
36
36
  measurement_scope: string;
@@ -223,6 +223,7 @@ export interface DiagnoseResult {
223
223
  prompt_id: string | null;
224
224
  host_version: string | null;
225
225
  include_local: boolean;
226
+ configuration?: ResolvedConfiguration;
226
227
  output: { id: string; spans: Span[] }[];
227
228
  instances: DiagnoseInstance[];
228
229
  host_fields: {
@@ -252,6 +253,49 @@ export interface ReadResult {
252
253
  installation: Record<string, unknown>;
253
254
  capabilities: Capabilities;
254
255
  backend_version: string;
256
+ configuration?: ResolvedConfiguration;
257
+ }
258
+ export type ConfigTarget = { kind: "user" } | { kind: "profile"; id: string } | { kind: "project"; path: string };
259
+ export interface DisplayProfile { id: string; name: string; display: DisplayDraft }
260
+ export interface ProjectBinding { root: string; profile_id: string }
261
+ export interface ProfileCollection { version: 1; profiles: DisplayProfile[]; bindings: ProjectBinding[] }
262
+ export interface ResolvedConfiguration {
263
+ target: ConfigTarget;
264
+ profile_id: string | null;
265
+ profile_name: string | null;
266
+ project_root: string | null;
267
+ reason: string;
268
+ shared_projects: string[];
269
+ }
270
+ export interface ProfilesResult extends ProfileCollection { revision: string; changed?: boolean; backup_dir?: string | null }
271
+ export interface ProfileImportResult { name: string; display: DisplayDraft }
272
+ export interface TaskEvidence {
273
+ source: string;
274
+ scope: string;
275
+ status: string;
276
+ observed_at: string | null;
277
+ freshness: "current" | "stale" | "unknown" | "newer_than_input";
278
+ }
279
+ export interface TaskAgentDetail {
280
+ id: string;
281
+ parent_id: string | null;
282
+ name: string | null;
283
+ status: string | null;
284
+ evidence: TaskEvidence[];
285
+ }
286
+ export interface TaskDetails {
287
+ version: 1;
288
+ session_id: string;
289
+ prompt_id: string | null;
290
+ captured_at: string;
291
+ status: string | null;
292
+ phase: string | null;
293
+ elapsed_seconds: number | null;
294
+ active_seconds: number | null;
295
+ progress: { completed: number; total: number } | null;
296
+ agents: TaskAgentDetail[];
297
+ evidence: TaskEvidence[];
298
+ limitations: string[];
255
299
  }
256
300
  export interface EditorField {
257
301
  key: string;
@@ -311,6 +355,7 @@ export interface ApplyResult {
311
355
  backend_version: string;
312
356
  changed: boolean;
313
357
  backup_dir: string | null;
358
+ configuration?: ResolvedConfiguration;
314
359
  }
315
360
  export interface ResultMap {
316
361
  describe: DescribeResult;
@@ -325,6 +370,11 @@ export interface ResultMap {
325
370
  preset: TransferResult;
326
371
  read_ui_preferences: UiPreferencesResult;
327
372
  set_ui_language: UiPreferencesResult;
373
+ profiles_read: ProfilesResult;
374
+ profiles_apply: ProfilesResult;
375
+ profile_import: ProfileImportResult;
376
+ profile_export: ExportResult;
377
+ task_details: TaskDetails;
328
378
  }
329
379
  export type ResultFor<O extends Operation> = ResultMap[O];
330
380
  export interface Request {
@@ -332,5 +382,5 @@ export interface Request {
332
382
  operation: Operation;
333
383
  payload: unknown;
334
384
  }
335
- export type Result = DiagnoseResult | ExplainResult | PreviewResult | UiPreferencesResult | ReadResult | TransferResult | ImportReviewResult | ExportResult | DescribeResult | ApplyResult;
385
+ export type Result = DiagnoseResult | ExplainResult | PreviewResult | UiPreferencesResult | ReadResult | TransferResult | ImportReviewResult | ExportResult | DescribeResult | ApplyResult | ProfilesResult | ProfileImportResult | TaskDetails;
336
386
  export type Response = { protocol_version: typeof PROTOCOL_VERSION; result: Result } | { protocol_version: typeof PROTOCOL_VERSION; error: ProtocolError };