@fbincon/claude-code-statusline 3.3.0 → 3.5.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 (161) hide show
  1. package/README.md +78 -73
  2. package/candidate.json +291 -215
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/operations.js +5 -0
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/operations.js.map +1 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.d.ts +12 -0
  6. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +101 -0
  7. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -0
  8. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.d.ts +54 -0
  9. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js +199 -0
  10. package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js.map +1 -0
  11. package/node_modules/@fbincon/statusline-cli/dist/src/config/service.d.ts +2 -0
  12. package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js +19 -1
  13. package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js.map +1 -1
  14. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.d.ts +1 -0
  15. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js +4 -1
  16. package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js.map +1 -1
  17. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js +9 -2
  18. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js.map +1 -1
  19. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.d.ts +8 -2
  20. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js +6 -3
  21. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js.map +1 -1
  22. package/node_modules/@fbincon/statusline-cli/dist/src/help.js +14 -2
  23. package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
  24. package/node_modules/@fbincon/statusline-cli/dist/src/integration/arguments.js +1 -1
  25. package/node_modules/@fbincon/statusline-cli/dist/src/integration/arguments.js.map +1 -1
  26. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.d.ts +2 -1
  27. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +3 -1
  28. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
  29. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js +6 -1
  30. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js.map +1 -1
  31. package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.d.ts +2 -0
  32. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup-service.d.ts +23 -0
  33. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup-service.js +168 -0
  34. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup-service.js.map +1 -0
  35. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.d.ts +3 -0
  36. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js +64 -0
  37. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js.map +1 -0
  38. package/node_modules/@fbincon/statusline-cli/dist/src/main.js +35 -9
  39. package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
  40. package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js +1 -1
  41. package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js.map +1 -1
  42. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.d.ts +12 -0
  43. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.js +59 -0
  44. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/configuration.js.map +1 -0
  45. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js +15 -2
  46. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js.map +1 -1
  47. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.d.ts +3 -0
  48. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js +25 -0
  49. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js.map +1 -0
  50. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.d.ts +4 -0
  51. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.js +93 -0
  52. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/service.js.map +1 -0
  53. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +5 -3
  54. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +34 -8
  55. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  56. package/node_modules/@fbincon/statusline-cli/resources/statusline-config/SKILL.md +5 -0
  57. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  58. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +89 -3
  59. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +61 -7
  60. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +8 -1
  61. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +1 -0
  62. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +2 -0
  63. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/profile-manager.ts +258 -0
  64. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/quick-setup.ts +14 -11
  65. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/setup.ts +60 -0
  66. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/task-detail.ts +27 -0
  67. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +552 -6
  68. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +1194 -6
  69. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +2 -1
  70. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +18 -15
  71. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +7 -3
  72. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +1 -0
  73. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  74. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  75. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.d.ts +1 -0
  76. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +5 -2
  77. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js.map +1 -1
  78. package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +1 -1
  79. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +12 -10
  80. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
  81. package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.d.ts +3 -0
  82. package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +11 -0
  83. package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -1
  84. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.d.ts +4 -0
  85. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +37 -3
  86. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -1
  87. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.d.ts +16 -0
  88. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js +69 -0
  89. package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js.map +1 -0
  90. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +24 -0
  91. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +1 -1
  92. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -1
  93. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +212 -4
  94. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +485 -2
  95. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
  96. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +78 -7
  97. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  98. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +2 -0
  99. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +1 -0
  100. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  101. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.d.ts +63 -0
  102. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js +355 -0
  103. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js.map +1 -0
  104. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.d.ts +4 -4
  105. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js +16 -9
  106. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js.map +1 -1
  107. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.d.ts +30 -0
  108. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js +96 -0
  109. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js.map +1 -0
  110. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.d.ts +4 -0
  111. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.js +25 -0
  112. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-detail.js.map +1 -0
  113. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +1188 -0
  114. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +1194 -6
  115. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  116. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  117. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  118. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.d.ts +3 -1
  119. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js +24 -2
  120. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js.map +1 -1
  121. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.d.ts +3 -1
  122. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js +18 -5
  123. package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js.map +1 -1
  124. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +4 -4
  125. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
  126. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +15 -5
  127. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +78 -48
  128. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
  129. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +6 -0
  130. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
  131. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +3 -3
  132. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
  133. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.d.ts +24 -0
  134. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.js +153 -0
  135. package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/details.js.map +1 -0
  136. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +199 -1
  137. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +199 -1
  138. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +199 -1
  139. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +199 -1
  140. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +199 -1
  141. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +199 -1
  142. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.d.ts +8 -0
  143. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.js +41 -0
  144. package/node_modules/@fbincon/statusline-platform/dist/src/project-paths.js.map +1 -0
  145. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +6 -1
  146. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  147. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +2 -0
  148. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  149. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +2 -0
  150. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  151. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +3 -2
  152. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  153. package/node_modules/@fbincon/statusline-tui/dist/src/session.js +7 -3
  154. package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
  155. package/node_modules/@fbincon/statusline-tui/dist/src/setup.d.ts +12 -0
  156. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js +75 -0
  157. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js.map +1 -0
  158. package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
  159. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +18 -2
  160. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  161. package/package.json +1 -1
@@ -0,0 +1,258 @@
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
+ detailScroll: number;
21
+ action: Action | null;
22
+ fields: { key: 'name' | 'path'; input: TextInput }[];
23
+ field: number;
24
+ candidate: DisplayDraft | null;
25
+ confirmation: Effect | null;
26
+ next: Switch | null;
27
+ effect: Effect | null;
28
+ message: LocalizedText | null;
29
+ uncertain: boolean;
30
+ }
31
+ export interface ProfileBackend { request<O extends Operation>(operation: O, payload?: unknown): ResultFor<O> | Promise<ResultFor<O>> }
32
+ export function openProfiles(editor: Editor): void {
33
+ editor.profiles = { library: null, page: 'list', selected: null, projectRoot: null, cursor: 0, detailScroll: 0, action: null, fields: [], field: 0, candidate: null,
34
+ confirmation: null, next: null, effect: { kind: 'load' }, message: null, uncertain: false };
35
+ }
36
+ /** Open Save as without replacing the caller's unsaved draft. */
37
+ export function saveProfileCopy(editor: Editor, display: DisplayDraft): void {
38
+ openProfiles(editor);
39
+ editor.profiles!.candidate = JSON.parse(JSON.stringify(display)) as DisplayDraft;
40
+ editor.profiles!.action = 'save';
41
+ }
42
+ export function targetLabel(editor: Editor, language: Language): string {
43
+ const c = editor.baseline.configuration;
44
+ if (!c) return t('profiles.user', language);
45
+ return t('profiles.target', language, { name: c.profile_name ?? t('profiles.user', language),
46
+ root: c.project_root ?? '—', count: c.shared_projects.length });
47
+ }
48
+ function entries(m: ProfileManager): { key: string; label: string; raw?: boolean }[] {
49
+ if (m.page === 'actions') return ['edit','activate','rename','delete','bind','export'].map(key => ({ key, label: 'profiles.action.' + key }));
50
+ return [{ key: 'user', label: 'profiles.user' }, ...(m.library?.profiles ?? []).map(p => ({ key: p.id, label: p.name, raw: true })),
51
+ ...(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})),
52
+ ...['save','save_bind','import','unbind'].map(key => ({ key: 'action:' + key, label: 'profiles.action.' + key }))];
53
+ }
54
+ function startForm(e: Editor, action: Action): void {
55
+ const m = e.profiles!, profile = m.library?.profiles.find(p => p.id === m.selected), project = e.baseline.configuration;
56
+ const path = m.projectRoot ?? (project?.target.kind === 'project' ? project.target.path : project?.project_root ?? '');
57
+ m.action = action; m.page = 'form'; m.field = 0; m.message = null;
58
+ const keys = ['save','rename'].includes(action) ? ['name'] : action === 'save_bind' ? ['name','path'] : ['path'];
59
+ 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') }));
60
+ }
61
+ function switching(e: Editor, next: Switch): void {
62
+ const m = e.profiles!;
63
+ if (e.modified) { m.next = next; m.page = 'dirty'; m.cursor = 0; }
64
+ else m.effect = { kind: 'switch', next, save: false };
65
+ }
66
+ function submitForm(e: Editor): void {
67
+ const m = e.profiles!, values = Object.fromEntries(m.fields.map(f => [f.key, f.input.value]));
68
+ const profile = m.library?.profiles.find(p => p.id === m.selected);
69
+ if (m.fields.some(f => !f.input.value.trim())) { m.message = text('profiles.required'); return; }
70
+ if (m.action === 'import') { m.effect = { kind: 'import', path: values.path! }; return; }
71
+ if (m.action === 'export' && profile) {
72
+ m.confirmation = { kind: 'export', path: values.path!, name: profile.name, display: profile.display, overwrite: false };
73
+ } else {
74
+ const payload: Record<string, unknown> = { action: m.action === 'save_bind' ? 'save' : m.action, expected_revision: m.library!.revision, overwrite: false };
75
+ 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 } : {}) });
76
+ if (m.action === 'rename') Object.assign(payload, { id: m.selected, name: values.name });
77
+ if (m.action === 'bind') Object.assign(payload, { id: m.selected, path: values.path });
78
+ if (m.action === 'unbind') payload.path = values.path;
79
+ m.confirmation = { kind: 'mutation', payload };
80
+ }
81
+ m.page = 'confirm'; m.cursor = 0; m.detailScroll = 0;
82
+ }
83
+ /** One reducer supplies both editors; text never dispatches shortcuts. */
84
+ export function profilesKey(e: Editor, event: TextKey): 'profiles' | null {
85
+ const m = e.profiles;
86
+ if (!m) return null;
87
+ const key = event.key === 'return' ? 'enter' : event.key, plain = !event.ctrl && !event.meta && !event.text && !event.paste;
88
+ const cancel = !event.text && !event.paste && (key === 'escape' || event.ctrl && key.toLowerCase() === 'g');
89
+ if (event.overflow) { m.message = text('input.overflow'); return null; }
90
+ if (cancel) {
91
+ if (m.uncertain) { m.message = text('profiles.uncertain'); return null; }
92
+ if (m.page === 'list') e.profiles = null;
93
+ else { m.page = 'list'; m.cursor = 0; m.candidate = null; m.confirmation = null; }
94
+ return null;
95
+ }
96
+ if (m.page === 'form') {
97
+ if (plain && key === 'enter') {
98
+ if (m.field + 1 < m.fields.length) m.field++;
99
+ else submitForm(e);
100
+ } else if (plain && key === 'tab') m.field = (m.field + 1) % m.fields.length;
101
+ else {
102
+ const field = m.fields[m.field]!, edited = inputKey(field.input.value, field.input, event, field.key === 'name' ? 128 : 4096);
103
+ field.input = edited.state;
104
+ m.message = edited.error ? text('input.' + edited.error, { limit: field.key === 'name' ? 128 : 4096 }) : null;
105
+ }
106
+ return m.effect ? 'profiles' : null;
107
+ }
108
+ if (!plain) return null;
109
+ if (key.toLowerCase() === 'r') { m.effect = { kind: 'load' }; return 'profiles'; }
110
+ if (m.uncertain) { m.message = text('profiles.uncertain'); return null; }
111
+ if (m.page === 'dirty') {
112
+ const choices = ['save','discard','cancel'];
113
+ if (key === 'up') m.cursor = Math.max(0, m.cursor - 1);
114
+ if (key === 'down') m.cursor = Math.min(2, m.cursor + 1);
115
+ if (key === 'enter') {
116
+ if (choices[m.cursor] === 'cancel') { m.page = 'list'; m.cursor = 0; }
117
+ else m.effect = { kind: 'switch', next: m.next!, save: m.cursor === 0 };
118
+ }
119
+ return m.effect ? 'profiles' : null;
120
+ }
121
+ if (m.page === 'confirm') {
122
+ if (key === 'pageup' || key === 'pagedown') { m.detailScroll = Math.max(0, m.detailScroll + (key === 'pageup' ? -1 : 1)); return null; }
123
+ if (key === 'up' || key === 'down') m.cursor = 1 - m.cursor;
124
+ if (key === 'enter') {
125
+ if (m.cursor === 1) { m.page = 'list'; m.cursor = 0; m.confirmation = null; }
126
+ else { m.effect = m.confirmation; return 'profiles'; }
127
+ }
128
+ return null;
129
+ }
130
+ const rows = entries(m);
131
+ if (key === 'up') m.cursor = Math.max(0, m.cursor - 1);
132
+ if (key === 'down') m.cursor = Math.min(rows.length - 1, m.cursor + 1);
133
+ if (key === 'home') m.cursor = 0;
134
+ if (key === 'end') m.cursor = rows.length - 1;
135
+ if (key === 'pageup') m.cursor = Math.max(0, m.cursor - 5);
136
+ if (key === 'pagedown') m.cursor = Math.min(rows.length - 1, m.cursor + 5);
137
+ if (key === 'enter') {
138
+ const row = rows[m.cursor]!;
139
+ if (m.page === 'list') {
140
+ if (row.key === 'user') switching(e, { target: { kind: 'user' } });
141
+ else if (row.key.startsWith('action:')) { m.candidate = null; startForm(e, row.key.slice(7) as Action); }
142
+ else {
143
+ m.projectRoot = row.key.startsWith('binding:') ? row.key.slice(8) : null;
144
+ m.selected = m.projectRoot ? m.library!.bindings.find(b=>b.root===m.projectRoot)!.profile_id : row.key;
145
+ const selected = m.library!.profiles.find(p=>p.id===m.selected);
146
+ if (!selected) { m.message=text('profiles.error.missing',{value:m.selected}); return null; }
147
+ m.candidate=selected.display; m.page='actions';m.cursor=0;
148
+ }
149
+ } else if (row.key === 'edit') switching(e, { target: m.projectRoot ? {kind:'project',path:m.projectRoot} : { kind: 'profile', id: m.selected! } });
150
+ else if (row.key === 'activate') switching(e, { target: { kind: 'user' }, display: m.candidate! });
151
+ else if (row.key === 'delete') {
152
+ m.action = 'delete'; m.confirmation = { kind: 'mutation', payload: { action: 'delete', id: m.selected, expected_revision: m.library!.revision } };
153
+ m.page = 'confirm'; m.cursor = 1;
154
+ } else startForm(e, row.key as Action);
155
+ }
156
+ return m.effect ? 'profiles' : null;
157
+ }
158
+ export async function performProfileAction(e: Editor, backend: ProfileBackend): Promise<void> {
159
+ const m = e.profiles, effect = m?.effect;
160
+ if (!m || !effect) return;
161
+ m.effect = null;
162
+ let writing = false;
163
+ try {
164
+ if (effect.kind === 'load') {
165
+ const copy = m.action === 'save' && m.candidate !== null;
166
+ m.library = await backend.request('profiles_read'); m.page = 'list'; m.cursor = 0;
167
+ if (copy) startForm(e, 'save');
168
+ m.message = m.uncertain ? text('profiles.review_saved') : null; m.uncertain = false; return;
169
+ }
170
+ if (effect.kind === 'switch') {
171
+ if (effect.save) {
172
+ if (!e.acceptNumeric()) throw new BackendError('invalid_draft', text('profiles.invalid_draft'));
173
+ writing = true;
174
+ const saved = await backend.request('apply', { draft: e.draft, expected_revision: e.baseline.revision,
175
+ ...(e.baseline.configuration ? { target: e.baseline.configuration.target } : {}) });
176
+ e.committed(saved); writing = false;
177
+ }
178
+ const current = await backend.request('read', { target: effect.next.target });
179
+ e.committed(current);
180
+ e.replaceDraft(current.draft);
181
+ if (effect.next.display) e.replaceDraft({ ...current.draft, display: JSON.parse(JSON.stringify(effect.next.display)) as DisplayDraft });
182
+ e.profiles = null; return;
183
+ }
184
+ if (effect.kind === 'import') {
185
+ const result = await backend.request('profile_import', { path: effect.path });
186
+ m.candidate = result.display; startForm(e, 'save'); m.fields[0]!.input = textInput(result.name);
187
+ m.message = text('profiles.import_review'); return;
188
+ }
189
+ writing = true;
190
+ if (effect.kind === 'export') {
191
+ await backend.request('profile_export', { path: effect.path, name: effect.name, display: effect.display, overwrite: effect.overwrite });
192
+ } else {
193
+ m.library = await backend.request('profiles_apply', effect.payload);
194
+ writing = false;
195
+ if (effect.payload.bind_path && typeof effect.payload.bind_path === 'string') {
196
+ const host = e.draft.host;
197
+ const current = await backend.request('read', { target: { kind: 'project', path: effect.payload.bind_path } });
198
+ e.committed(current); e.replaceDraft({ ...current.draft, host });
199
+ } else if (e.baseline.configuration && (e.baseline.configuration.target.kind !== 'profile' ||
200
+ m.library.profiles.some(p=>p.id===e.baseline.configuration!.profile_id))) {
201
+ const current = await backend.request('read', { target: e.baseline.configuration.target });
202
+ if (current.configuration?.profile_id === e.baseline.configuration.profile_id &&
203
+ JSON.stringify(current.draft) === JSON.stringify(e.baseline.draft)) e.baseline = current;
204
+ }
205
+ }
206
+ m.page = 'list'; m.cursor = 0; m.candidate = null; m.confirmation = null; m.message = text('profiles.saved');
207
+ } catch (error) {
208
+ const code = error instanceof BackendError ? error.code : '';
209
+ if (code === 'profile_duplicate' || code === 'profile_bound' || effect.kind === 'export' && code === 'io_error' && /EEXIST/u.test(String(error))) {
210
+ m.confirmation = effect.kind === 'mutation' ? { ...effect, payload: { ...effect.payload, overwrite: true } }
211
+ : effect.kind === 'export' ? { ...effect, overwrite: true } : null;
212
+ m.page = 'confirm'; m.cursor = 1; m.message = text('profiles.overwrite');
213
+ } else {
214
+ m.uncertain = writing && !['profile_conflict','profile_referenced','profile_invalid','profile_name','profile_path','ownership_mismatch','configuration_conflict','invalid_request','profile_size'].includes(code);
215
+ m.message = error instanceof BackendError && error.localization ? error.localization : text('profiles.failed', { value: error instanceof Error ? error.message : String(error) });
216
+ }
217
+ }
218
+ }
219
+ export function profilesView(e: Editor, language: Language, width: number, height: number): { text: string; selected: boolean }[] {
220
+ const m = e.profiles!;
221
+ const tr = (key: string) => t(key, language);
222
+ const lines: { text: string; selected: boolean }[] = [];
223
+ const add = (value: string, selected = false) => lines.push({ text: value, selected });
224
+ if (m.message) for (const line of wrapText([t(m.message.key, language, m.message.params)], width)) add(line);
225
+ if (m.uncertain) add(tr('profiles.uncertain'));
226
+ if (!m.library) { add(tr('profiles.loading')); return lines.slice(0, height); }
227
+ if (m.page === 'form') {
228
+ add(tr('profiles.action.' + m.action));
229
+ m.fields.forEach((f,i) => add(tr('profiles.field.' + f.key) + ': ' + inputView({ ...f.input }, Math.max(1, width - 12)), i === m.field));
230
+ add(tr('profiles.form_help')); return lines.slice(0, height);
231
+ }
232
+ const rows = m.page === 'confirm' ? [{ key:'confirm',label:'profiles.confirm' },{ key:'cancel',label:'profiles.cancel' }] :
233
+ m.page === 'dirty' ? ['save','discard','cancel'].map(key => ({ key, label:'profiles.'+key })) : entries(m);
234
+ if (m.page === 'dirty') add(tr('profiles.dirty'));
235
+ if (m.page === 'confirm') {
236
+ const value = m.confirmation;
237
+ add(tr('profiles.action.' + (m.action ?? 'export')));
238
+ if (value?.kind === 'mutation') add(String(value.payload.name ?? value.payload.path ?? m.library.profiles.find(p=>p.id===value.payload.id)?.name ?? ''));
239
+ if (value?.kind === 'export') add(value.path);
240
+ if (value?.kind === 'mutation' && value.payload.action === 'save' && typeof value.payload.name === 'string') {
241
+ const profile = m.library.profiles.find(profile => profile.name === (value.payload.name as string).trim().normalize('NFC'));
242
+ const roots = m.library.bindings.filter(binding => binding.profile_id === profile?.id).map(binding => binding.root);
243
+ if (roots.length) for (const line of wrapText([t('profiles.shared', language, { count: roots.length }), ...roots], width)) add(line);
244
+ }
245
+ // Keep both confirmation actions reachable even with many bound projects.
246
+ const capacity = Math.max(0, height - 3), start = Math.min(m.detailScroll, Math.max(0, lines.length - capacity));
247
+ return [...lines.slice(start, start + capacity), ...rows.map((row, index) => ({ text: tr(row.label), selected: index === m.cursor })),
248
+ { text: tr('profiles.navigation'), selected: false }].slice(0, height);
249
+ }
250
+ if (m.page === 'actions') {
251
+ add(m.library.profiles.find(p => p.id === m.selected)?.name ?? '');
252
+ add(t('profiles.shared', language, { count: m.library.bindings.filter(b => b.profile_id === m.selected).length }));
253
+ }
254
+ const capacity = Math.max(1, height - lines.length - 1), start = Math.max(0, Math.min(m.cursor, rows.length - capacity));
255
+ rows.slice(start,start+capacity).forEach((row,i) => add(('raw' in row && row.raw ? row.label : tr(row.label)), start+i === m.cursor));
256
+ add(tr('profiles.navigation'));
257
+ return lines.slice(0,height);
258
+ }
@@ -5,6 +5,7 @@ import { THEME_VALUES, PALETTE_VALUES, SEPARATORSTYLE_VALUES, PRESETS } from '..
5
5
  import { copyDraft } from './draft.ts';
6
6
  import { t, type Language } from '../i18n/index.ts';
7
7
  import { wrapText } from '../../ui/text.ts';
8
+ import { saveProfileCopy } from './profile-manager.ts';
8
9
 
9
10
  export interface QuickSetup {
10
11
  base: Draft;
@@ -15,18 +16,18 @@ export interface QuickSetup {
15
16
  previewScope: Scope;
16
17
  detailScroll: number;
17
18
  }
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};
19
+ export function openQuick(draft: Draft, preset = 'developer'): QuickSetup {
20
+ return {base:copyDraft(draft),candidate:copyDraft(draft),step:'scenario',selected:Math.max(0, PRESETS.findIndex(p=>p.id===preset)),preset,previewScope:'main',detailScroll:0};
20
21
  }
21
22
  export function receivePreset(quick: QuickSetup, draft: Draft): void {
22
23
  quick.candidate = copyDraft(draft); quick.step = 'appearance'; quick.selected = 0; quick.detailScroll = 0;
23
24
  }
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;
25
+ export function quickKey(quick: QuickSetup, key: string): 'preset' | 'accept' | 'save' | 'copy' | 'cancel' | null {
26
+ const count = quick.step === 'scenario' ? PRESETS.length : quick.step === 'appearance' ? 5 : 4;
26
27
  if (key === 'escape' || key === 'cancel') return 'cancel';
27
28
  if (key === 'pageup' || key === 'pagedown') { quick.detailScroll = Math.max(0, quick.detailScroll + (key === 'pageup' ? -1 : 1)); return null; }
28
29
  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 (key === 'backspace' || quick.step === 'review' && quick.selected === 3 && key === 'return') {
30
31
  if (quick.step === 'scenario') return 'cancel';
31
32
  quick.step = quick.step === 'review' ? 'appearance' : 'scenario';
32
33
  quick.selected = quick.step === 'scenario' ? Math.max(0, PRESETS.findIndex(p => p.id === quick.preset)) : 0;
@@ -37,7 +38,7 @@ export function quickKey(quick: QuickSetup, key: string): 'preset' | 'accept' |
37
38
  quick.detailScroll = 0; return null;
38
39
  }
39
40
  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 === 'review' && key === 'return') return quick.selected === 0 ? 'accept' : quick.selected === 1 ? 'save' : 'copy';
41
42
  if (quick.step !== 'appearance' || !['left','right','return'].includes(key)) return null;
42
43
  const d = quick.candidate.display, delta = key === 'left' ? -1 : 1;
43
44
  const cycle = <T>(values: readonly T[], value: T): T => values[(values.indexOf(value)+delta+values.length)%values.length]!;
@@ -49,7 +50,7 @@ export function quickKey(quick: QuickSetup, key: string): 'preset' | 'accept' |
49
50
  return null;
50
51
  }
51
52
  /** 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
+ export function quickView(quick: QuickSetup, language: Language, width: number, height: number, sharedProjects: readonly string[] = []): {text:string;selected:boolean}[] {
53
54
  const tr = (key:string,params:Record<string,unknown>={}) => t(key,language,params);
54
55
  const preset = PRESETS.find(p=>p.id === (quick.step === 'scenario' ? PRESETS[quick.selected]!.id : quick.preset))!;
55
56
  const d=quick.candidate.display;
@@ -59,9 +60,10 @@ export function quickView(quick: QuickSetup, language: Language, width: number,
59
60
  tr('settings.colors')+': '+tr('values.'+(d.use_colors?'on':'off')),
60
61
  tr('settings.palette')+': '+d.palette,
61
62
  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')] : []),
63
+ ] : [tr('quick.fine_tune'),tr('quick.save'),tr('quick.copy'),tr('quick.back')];
64
+ const paragraphs=[...(quick.step === 'review' && quick.selected === 1 && sharedProjects.length ? [tr('profiles.shared',{count:sharedProjects.length}), ...sharedProjects] : []),
65
+ tr(preset.requirements_key),tr('quick.sample'),
66
+ ...(!d.subagents.enabled && ['multi-agent','agent-focus'].includes(preset.id) ? [tr('quick.subagents_off')] : []),
65
67
  ...(quick.step==='review' ? [tr('quick.replace')] : [])];
66
68
  const detail=wrapText(paragraphs,width), menuHeight=Math.max(1, Math.min(rows.length,Math.floor(height/2)));
67
69
  const start=Math.max(0, Math.min(quick.selected,rows.length-menuHeight,quick.selected-menuHeight+1));
@@ -71,12 +73,13 @@ export function quickView(quick: QuickSetup, language: Language, width: number,
71
73
  return result;
72
74
  }
73
75
 
74
- export function controlQuick(editor: Editor, key: string): 'transfer' | 'save' | null {
76
+ export function controlQuick(editor: Editor, key: string): 'transfer' | 'save' | 'profiles' | null {
75
77
  const quick = editor.quick;
76
78
  if (!quick) return null;
77
79
  const effect = quickKey(quick,key);
78
80
  if (effect === 'cancel') editor.quick = null;
79
81
  if (effect === 'preset') { editor.preset=quick.preset; editor.pendingTransfer='preset'; return 'transfer'; }
82
+ if (effect === 'copy') { saveProfileCopy(editor, quick.candidate.display); editor.quick=null; return 'profiles'; }
80
83
  if (effect === 'accept' || effect === 'save') { editor.replaceDraft(quick.candidate); editor.quick=null; return effect === 'save' ? 'save' : null; }
81
84
  return null;
82
85
  }
@@ -0,0 +1,60 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { Draft } from '../generated-contracts.ts';
3
+ import { LANGUAGES, type Language, type LocalizedText } from '../i18n/index.ts';
4
+ import { copyDraft } from './draft.ts';
5
+ import { openQuick, quickKey, receivePreset, type QuickSetup } from './quick-setup.ts';
6
+
7
+ export interface SetupFacts {
8
+ checks: { level: 'OK' | 'WARN' | 'ERROR'; message: string | LocalizedText }[];
9
+ resources: string[];
10
+ notes: LocalizedText[];
11
+ draft: Draft | null;
12
+ hasDisplay: boolean;
13
+ canSave: boolean;
14
+ canIntegrate: boolean;
15
+ }
16
+ export type SetupEffect = 'cancel' | 'interrupt' | 'preset' | 'language' | 'save' | 'integrate' | null;
17
+ /** The wizard holds only drafts; effects are executed by its CLI/TUI adapters. */
18
+ export class SetupState {
19
+ phase: 'checks' | 'choice' | 'quick' | 'review' = 'checks';
20
+ selected = 0;
21
+ scroll = 0;
22
+ quick: QuickSetup | null = null;
23
+ candidate: Draft | null;
24
+ message: LocalizedText | null = null;
25
+ constructor(readonly facts: SetupFacts, public language: Language) { this.candidate = facts.draft ? copyDraft(facts.draft) : null; }
26
+ receive(draft: Draft): void { receivePreset(this.quick!, draft); }
27
+ key(key: string): SetupEffect {
28
+ if (key === 'interrupt') return 'interrupt';
29
+ if (key === 'escape' || key === 'cancel') return 'cancel';
30
+ if (key === 'l') { this.language = LANGUAGES[(LANGUAGES.indexOf(this.language) + 1) % LANGUAGES.length]!; return 'language'; }
31
+ if (this.phase === 'quick') {
32
+ if (key === 'backspace' && this.quick!.step === 'scenario') { this.phase = 'choice'; this.selected = 1; return null; }
33
+ const result = quickKey(this.quick!, key);
34
+ if (result === 'preset') return 'preset';
35
+ if (this.quick!.step === 'review') { this.candidate = copyDraft(this.quick!.candidate); this.phase = 'review'; this.selected = 0; this.scroll = 0; }
36
+ return null;
37
+ }
38
+ if (key === 'pageup' || key === 'pagedown') { this.scroll = Math.max(0, this.scroll + (key === 'pageup' ? -1 : 1)); return null; }
39
+ if (key === 'backspace' && this.phase !== 'checks') {
40
+ this.phase = this.phase === 'review' && this.quick ? 'quick' : 'checks';
41
+ if (this.phase === 'quick') { this.quick!.step = 'appearance'; this.quick!.selected = 4; }
42
+ this.scroll = 0; this.selected = 0; return null;
43
+ }
44
+ const count = this.phase === 'checks' ? 1 : this.phase === 'choice' ? 2 : 3;
45
+ if (['up','down','home','end'].includes(key)) {
46
+ this.selected = key === 'home' ? 0 : key === 'end' ? count - 1 : Math.max(0, Math.min(count - 1, this.selected + (key === 'up' ? -1 : 1)));
47
+ return null;
48
+ }
49
+ if (key !== 'return') return null;
50
+ if (this.phase === 'checks') { if (this.facts.canSave) { this.phase = 'choice'; this.selected = this.facts.hasDisplay ? 0 : 1; this.scroll = 0; } }
51
+ else if (this.phase === 'choice') {
52
+ this.scroll = 0;
53
+ if (this.selected === 0) { this.candidate = copyDraft(this.facts.draft!); this.quick = null; this.phase = 'review'; this.selected = 0; }
54
+ else { this.quick = openQuick(this.facts.draft!, 'daily-development'); this.phase = 'quick'; }
55
+ } else if (this.selected === 2) return 'cancel';
56
+ else if (this.selected === 1 && this.facts.canSave) return 'save';
57
+ else if (this.selected === 0 && this.facts.canIntegrate) return 'integrate';
58
+ return null;
59
+ }
60
+ }
@@ -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
+ }