@fbincon/claude-code-statusline 3.9.2 → 3.11.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 (184) hide show
  1. package/README.md +79 -78
  2. package/candidate.json +347 -256
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +8 -4
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js +7 -18
  6. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js.map +1 -1
  7. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.d.ts +5 -0
  8. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.js +36 -0
  9. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.js.map +1 -0
  10. package/node_modules/@fbincon/statusline-cli/dist/src/help.js +1 -1
  11. package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
  12. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.d.ts +1 -1
  13. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +4 -3
  14. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
  15. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js +1 -1
  16. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js.map +1 -1
  17. package/node_modules/@fbincon/statusline-cli/dist/src/main.js +5 -1
  18. package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
  19. package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.d.ts +8 -0
  20. package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js +147 -0
  21. package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js.map +1 -0
  22. package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.d.ts +14 -1
  23. package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.js +2 -1
  24. package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.js.map +1 -1
  25. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.d.ts +15 -0
  26. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js +90 -0
  27. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js.map +1 -0
  28. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.d.ts +1 -0
  29. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.js +33 -0
  30. package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.js.map +1 -0
  31. package/node_modules/@fbincon/statusline-cli/dist/src/management/review.d.ts +5 -0
  32. package/node_modules/@fbincon/statusline-cli/dist/src/management/review.js +44 -0
  33. package/node_modules/@fbincon/statusline-cli/dist/src/management/review.js.map +1 -0
  34. package/node_modules/@fbincon/statusline-cli/dist/src/management/service.d.ts +4 -0
  35. package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js +10 -3
  36. package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js.map +1 -1
  37. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js +2 -2
  38. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js.map +1 -1
  39. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.d.ts +1 -0
  40. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js +11 -4
  41. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js.map +1 -1
  42. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.d.ts +3 -0
  43. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.js +25 -0
  44. package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.js.map +1 -0
  45. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +6 -5
  46. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +40 -3
  47. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  48. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  49. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +103 -57
  50. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +13 -7
  51. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +13 -1
  52. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +7 -2
  53. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/color-manager.ts +177 -0
  54. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/diagnosis-view.ts +123 -0
  55. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +7 -0
  56. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/explanation.ts +2 -1
  57. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/gradients.ts +10 -0
  58. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-manager.ts +314 -0
  59. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-validation.ts +43 -0
  60. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/preview-settings.ts +8 -0
  61. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/setup.ts +7 -0
  62. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/task-viewer.ts +319 -0
  63. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/themes.ts +40 -0
  64. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +86 -15
  65. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +834 -6
  66. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +3 -1
  67. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +24 -17
  68. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +11 -3
  69. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +5 -2
  70. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  71. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  72. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +1 -1
  73. package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +1 -1
  74. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +6 -5
  75. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
  76. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +89 -8
  77. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +7 -10
  78. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
  79. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +14 -7
  80. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  81. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.d.ts +23 -0
  82. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js +153 -0
  83. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js.map +1 -0
  84. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.d.ts +29 -0
  85. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.js +107 -0
  86. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.js.map +1 -0
  87. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +7 -0
  88. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +7 -0
  89. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  90. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js +3 -1
  91. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js.map +1 -1
  92. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.d.ts +9 -0
  93. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js +9 -0
  94. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js.map +1 -1
  95. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.d.ts +41 -0
  96. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js +281 -0
  97. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js.map +1 -0
  98. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.d.ts +3 -0
  99. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js +42 -0
  100. package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js.map +1 -0
  101. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.d.ts +7 -0
  102. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.js +7 -0
  103. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.js.map +1 -0
  104. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.d.ts +4 -0
  105. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js +17 -0
  106. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js.map +1 -1
  107. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.d.ts +46 -0
  108. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.js +279 -0
  109. package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.js.map +1 -0
  110. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.d.ts +17 -0
  111. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.js +30 -0
  112. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.js.map +1 -0
  113. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +828 -0
  114. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +834 -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/management/compatibility.js +2 -1
  117. package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js.map +1 -1
  118. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  119. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  120. package/node_modules/@fbincon/statusline-core/dist/src/release.js.map +1 -1
  121. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.d.ts +2 -1
  122. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js +12 -13
  123. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js.map +1 -1
  124. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js +1 -1
  125. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js.map +1 -1
  126. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +2 -0
  127. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
  128. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.d.ts +1 -1
  129. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js +2 -1
  130. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js.map +1 -1
  131. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +5 -2
  132. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -1
  133. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +3 -3
  134. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
  135. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +4 -1
  136. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +2 -2
  137. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
  138. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.d.ts +2 -1
  139. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +8 -8
  140. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
  141. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.d.ts +11 -52
  142. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js +48 -7
  143. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js.map +1 -1
  144. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.d.ts +6 -0
  145. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.js +38 -0
  146. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.js.map +1 -0
  147. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.d.ts +2 -1
  148. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +14 -17
  149. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
  150. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +2 -1
  151. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js +19 -1
  152. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js.map +1 -1
  153. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +139 -1
  154. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +139 -1
  155. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +139 -1
  156. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +139 -1
  157. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +139 -1
  158. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +139 -1
  159. package/node_modules/@fbincon/statusline-platform/dist/src/diagnostic-files.js +3 -2
  160. package/node_modules/@fbincon/statusline-platform/dist/src/diagnostic-files.js.map +1 -1
  161. package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.d.ts +4 -0
  162. package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.js +22 -0
  163. package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.js.map +1 -0
  164. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +22 -0
  165. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  166. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +12 -0
  167. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  168. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +9 -0
  169. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  170. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +9 -6
  171. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  172. package/node_modules/@fbincon/statusline-tui/dist/src/session.d.ts +3 -2
  173. package/node_modules/@fbincon/statusline-tui/dist/src/session.js +53 -7
  174. package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
  175. package/node_modules/@fbincon/statusline-tui/dist/src/setup.d.ts +2 -1
  176. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js +7 -5
  177. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js.map +1 -1
  178. package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
  179. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +62 -3
  180. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  181. package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.d.ts +6 -0
  182. package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.js +34 -0
  183. package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.js.map +1 -0
  184. package/package.json +3 -3
@@ -0,0 +1,147 @@
1
+ import * as fs from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { VERSION } from '@fbincon/statusline-core/release';
4
+ import { PackageError } from '@fbincon/statusline-core/management/package';
5
+ import { compatibility, runtimeCompatibility } from '@fbincon/statusline-core/management/compatibility';
6
+ import { globalPackageRoot, productIdentity, productRoot } from '@fbincon/statusline-platform/npm';
7
+ import { resolvedPath, which } from '@fbincon/statusline-platform/commands';
8
+ import { sha256 } from '@fbincon/statusline-platform/hash';
9
+ import { processMatches } from '@fbincon/statusline-platform/processes';
10
+ import { previousBinding } from '../integration/ownership.js';
11
+ import { safeTarget } from '../integration/paths.js';
12
+ import { createStorage } from '../config/storage.js';
13
+ import { readRegular } from '../recovery/journal.js';
14
+ import { configurationBytes, configurationHashes, configurationCompatibility, readSnapshot } from './configuration.js';
15
+ import { MANAGEMENT_ROOT, operationPath, pendingPath, readInstallation, readOperation } from './store.js';
16
+ export const packageReason = (error) => error instanceof PackageError ? error.code : 'io_error';
17
+ function prefixFor(entry) {
18
+ const root = productRoot(resolvedPath(entry));
19
+ if (!root)
20
+ return null;
21
+ let prefix = root;
22
+ for (let i = 0; i < (process.platform === 'win32' ? 3 : 4); i++)
23
+ prefix = dirname(prefix);
24
+ return resolvedPath(globalPackageRoot(prefix)) === root ? prefix : null;
25
+ }
26
+ export function inspectPackage(context, explicit = null, offset = 0) {
27
+ const reasons = [], { configDir } = context;
28
+ let prefix = explicit ? resolvedPath(explicit) : null;
29
+ if (!prefix) {
30
+ const candidates = new Set();
31
+ try {
32
+ const binding = previousBinding(configDir, createStorage());
33
+ const path = binding?.args.length === 1 ? binding.args[0] : binding?.executable;
34
+ for (const entry of [path, context.origin, which('claude-statusline')])
35
+ if (entry) {
36
+ const candidate = prefixFor(entry);
37
+ if (candidate)
38
+ candidates.add(candidate);
39
+ }
40
+ }
41
+ catch (error) {
42
+ reasons.push(packageReason(error));
43
+ }
44
+ if (candidates.size === 1)
45
+ prefix = [...candidates][0];
46
+ else
47
+ reasons.push(candidates.size ? 'prefix_ambiguous' : 'not_installed');
48
+ }
49
+ let identity = null, history = null, pending = null;
50
+ let host = null;
51
+ try {
52
+ host = context.hostVersion()?.join('.') ?? null;
53
+ }
54
+ catch {
55
+ reasons.push('host');
56
+ }
57
+ let hashes = {};
58
+ try {
59
+ hashes = configurationHashes(configurationBytes(configDir));
60
+ }
61
+ catch (error) {
62
+ reasons.push(packageReason(error));
63
+ }
64
+ if (prefix) {
65
+ try {
66
+ identity = productIdentity(globalPackageRoot(prefix), prefix);
67
+ if (!identity)
68
+ reasons.push('not_installed');
69
+ else {
70
+ const manifest = JSON.parse(readRegular(join(identity.root, 'package.json'), 1024 * 1024).toString('utf8'));
71
+ const declared = compatibility(manifest.statuslineCompatibility, identity.version);
72
+ const binding = previousBinding(configDir, createStorage());
73
+ reasons.push(...runtimeCompatibility(declared, process.versions.node, process.platform + '-' + process.arch, host, binding !== null));
74
+ if (binding && (binding.args.length !== 1 || resolvedPath(binding.args[0]) !== identity.entry))
75
+ reasons.push('prefix_ambiguous');
76
+ if (configurationCompatibility(configurationBytes(configDir), declared).length)
77
+ reasons.push('configuration');
78
+ }
79
+ }
80
+ catch (error) {
81
+ reasons.push(packageReason(error));
82
+ }
83
+ try {
84
+ history = readInstallation(configDir, prefix);
85
+ if (history && (!identity || history.current.version !== identity.version || history.current.inventory_sha256 !== identity.inventory_sha256 || history.current.entry !== identity.entry)) {
86
+ reasons.push('conflict');
87
+ history = null;
88
+ }
89
+ }
90
+ catch (error) {
91
+ reasons.push(packageReason(error));
92
+ }
93
+ try {
94
+ if (fs.existsSync(pendingPath(prefix)))
95
+ pending = readOperation(configDir, prefix);
96
+ }
97
+ catch (error) {
98
+ reasons.push(packageReason(error));
99
+ }
100
+ }
101
+ const row = (operation) => {
102
+ let backup = 'missing';
103
+ if (operation.snapshot)
104
+ try {
105
+ readSnapshot(configDir, dirname(operationPath(operation)), operation.snapshot);
106
+ backup = 'verified';
107
+ }
108
+ catch {
109
+ backup = 'invalid';
110
+ }
111
+ return { id: operation.id, version: operation.version, created: operation.created, stage: operation.stage, backup,
112
+ running: operation.executors?.some(p => processMatches(p.pid, p.token)) ?? false };
113
+ };
114
+ const records = [];
115
+ let total = 0;
116
+ const folder = join(configDir, MANAGEMENT_ROOT, 'transactions');
117
+ try {
118
+ safeTarget(configDir, folder);
119
+ if (fs.existsSync(folder)) {
120
+ const ids = fs.readdirSync(folder).filter(id => /^pkg-[0-9a-f-]{36}$/u.test(id)).sort();
121
+ total = ids.length;
122
+ if (prefix)
123
+ for (const id of ids.slice(offset, offset + 16)) {
124
+ try {
125
+ const path = join(folder, id, 'operation.json');
126
+ safeTarget(configDir, path);
127
+ const raw = JSON.parse(readRegular(path, 1024 * 1024).toString('utf8'));
128
+ if (raw.prefix !== prefix)
129
+ continue;
130
+ records.push(row(readOperation(configDir, prefix, id)));
131
+ }
132
+ catch {
133
+ records.push({ id, version: null, created: null, stage: 'invalid', backup: 'invalid', running: false });
134
+ }
135
+ }
136
+ }
137
+ }
138
+ catch (error) {
139
+ reasons.push(packageReason(error));
140
+ }
141
+ const unique = [...new Set(reasons)];
142
+ return { version: 1, backend_version: VERSION, captured_at: new Date().toISOString(),
143
+ revision: sha256(JSON.stringify({ identity, history, pending, hashes, prefix, configDir, host })), prefix, entry: identity?.entry ?? null, config_dir: configDir,
144
+ current: identity?.version ?? null, previous: history?.previous?.version ?? null, channel: history?.channel ?? null, node_version: process.versions.node, host,
145
+ compatible: !!identity && !unique.length, reasons: unique, pending: pending ? row(pending) : null, history: records, offset, total };
146
+ }
147
+ //# sourceMappingURL=inspection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection.js","sourceRoot":"","sources":["../../../src/management/inspection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAExG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAA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AAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAChF,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,UAAU,EAAE,SAAS;QAChK,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI;QAC9J,UAAU,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC7I,CAAC"}
@@ -1,3 +1,16 @@
1
1
  import { type Language } from '@fbincon/statusline-core/i18n/messages';
2
2
  import type { ManagementOptions } from './arguments.js';
3
- export declare function restoreConfiguration(flags: ManagementOptions, configDir: string, prefix: string, language: Language, stdout: (value: string) => void, confirm?: () => Promise<boolean>, signal?: AbortSignal): Promise<number>;
3
+ export interface ConfigurationRestoreReview {
4
+ schema_version: number;
5
+ action: 'restore-config';
6
+ backup_id: string;
7
+ source_version: string;
8
+ prefix: string;
9
+ files: {
10
+ path: string;
11
+ current: string | null;
12
+ backup: string | null;
13
+ }[];
14
+ preserved: string[];
15
+ }
16
+ export declare function restoreConfiguration(flags: ManagementOptions, configDir: string, prefix: string, language: Language, stdout: (value: string) => void, confirm?: () => Promise<boolean>, signal?: AbortSignal, onReview?: (review: ConfigurationRestoreReview) => void): Promise<number>;
@@ -17,7 +17,7 @@ import { detectClaudeVersion } from '@fbincon/statusline-platform/commands';
17
17
  import { t } from '@fbincon/statusline-core/i18n/messages';
18
18
  import { confirmPackage } from './first-entry.js';
19
19
  import { equalSettings } from '@fbincon/statusline-core/json-equality';
20
- export async function restoreConfiguration(flags, configDir, prefix, language, stdout, confirm, signal) {
20
+ export async function restoreConfiguration(flags, configDir, prefix, language, stdout, confirm, signal, onReview) {
21
21
  const operation = readOperation(configDir, prefix, flags.restoreConfig), current = configurationBytes(configDir), hashes = configurationHashes(current);
22
22
  if (!operation.snapshot || !operation.before)
23
23
  throw new PackageError('backup');
@@ -40,6 +40,7 @@ export async function restoreConfiguration(flags, configDir, prefix, language, s
40
40
  changes.push({ ...artifact(join(configDir, 'settings.json'), raw), desired: jsonBytes(updated) });
41
41
  }
42
42
  const review = { schema_version: 1, action: 'restore-config', backup_id: operation.id, source_version: operation.before.version, prefix, files: changes.map(change => ({ path: change.path, current: hashes[change.name] ?? null, backup: operation.snapshot[change.name] ?? null })), preserved: ['source_authorization', 'runtime_preferences', 'editor_preferences', 'unrelated_claude_settings'] };
43
+ onReview?.(review);
43
44
  if (!flags.json)
44
45
  stdout(t('management.restore_review', language) + '\n');
45
46
  stdout(JSON.stringify(review, null, 2) + '\n');
@@ -1 +1 @@
1
- {"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/management/restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAm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C;IAC5D,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,MAAM;QACZ,OAAO,CAAC,CAAC;IACb,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9E,OAAO,CAAC,CAAC;IACb,IAAI,MAAM,EAAE,OAAO;QACf,MAAM,IAAI,YAAY,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;QACtC,WAAW,CAAC,SAAS,CAAC,CAAC;QACvB,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACvC,yEAAyE;QACzE,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,QAAS,CAAC,CAAC;QAChF,OAAO,MAAM,CAAC,SAAS,EAAE,wBAAwB,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,CAAC,CAAC,qBAAqB,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAChF,OAAO,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { PackageReviewJob } from '@fbincon/statusline-core/contracts/ui';
2
+ import { type InspectionContext } from './inspection.js';
3
+ export interface ReviewRecord {
4
+ job: PackageReviewJob;
5
+ configDir: string;
6
+ origin: string;
7
+ pid: number | null;
8
+ token: string | null;
9
+ }
10
+ export declare const REVIEW_DEADLINE_MS: number;
11
+ export declare function reviewFolder(id: string): string;
12
+ export declare function readReviewRecord(id: string): ReviewRecord;
13
+ export declare function writeReviewRecord(record: ReviewRecord): void;
14
+ export declare function startPackageReview(context: InspectionContext, request: unknown, owner: unknown): PackageReviewJob;
15
+ export declare function packageReviewJob(context: InspectionContext, id: unknown, owner: unknown, cancel?: boolean): PackageReviewJob;
@@ -0,0 +1,90 @@
1
+ import * as fs from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { tmpdir } from 'node:os';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { PackageError } from '@fbincon/statusline-core/management/package';
7
+ import { isPackageRequest, isPackageResult } from '@fbincon/statusline-core/editor/package-validation';
8
+ import { atomicWrite, privateDirectory } from '@fbincon/statusline-platform/files';
9
+ import { productRoot, productIdentity } from '@fbincon/statusline-platform/npm';
10
+ import { copyPackage } from '@fbincon/statusline-platform/package-copy';
11
+ import { startReviewWorker, waitReviewExit } from '@fbincon/statusline-platform/review-worker';
12
+ import { processMatches } from '@fbincon/statusline-platform/processes';
13
+ import { removeTree } from '@fbincon/statusline-platform/remove-tree';
14
+ import { readRegular } from '../recovery/journal.js';
15
+ import { safeTarget } from '../integration/paths.js';
16
+ import { inspectPackage } from './inspection.js';
17
+ export const REVIEW_DEADLINE_MS = 10 * 60 * 1000;
18
+ export function reviewFolder(id) {
19
+ if (!/^review-[0-9a-f-]{36}$/u.test(id))
20
+ throw new PackageError('arguments');
21
+ const root = fs.realpathSync.native(tmpdir()), folder = join(root, 'claude-statusline-' + id);
22
+ safeTarget(root, folder);
23
+ return folder;
24
+ }
25
+ export function readReviewRecord(id) {
26
+ const folder = reviewFolder(id), path = join(folder, 'job.json');
27
+ safeTarget(folder, path);
28
+ const value = JSON.parse(readRegular(path, 1024 * 1024).toString('utf8'));
29
+ if (!isPackageResult('package_review_status', value.job) || value.job.id !== id || typeof value.configDir !== 'string' || typeof value.origin !== 'string' ||
30
+ !(value.pid === null || Number.isSafeInteger(value.pid) && value.pid > 0) || !(value.token === null || typeof value.token === 'string'))
31
+ throw new PackageError('journal');
32
+ return value;
33
+ }
34
+ export function writeReviewRecord(record) { atomicWrite(join(reviewFolder(record.job.id), 'job.json'), JSON.stringify(record) + '\n'); }
35
+ export function startPackageReview(context, request, owner) {
36
+ if (!isPackageRequest(request) || typeof owner !== 'string' || !/^viewer-[a-z0-9-]{10,100}$/u.test(owner))
37
+ throw new PackageError('arguments');
38
+ if (inspectPackage(context, request.prefix).revision !== request.expected_revision)
39
+ throw new PackageError('conflict');
40
+ const job = { version: 1, id: 'review-' + randomUUID(), owner, state: 'running', started_at: new Date().toISOString(), finished_at: null, request, review: null, error: null };
41
+ const folder = reviewFolder(job.id);
42
+ privateDirectory(folder);
43
+ const record = { job, configDir: context.configDir, origin: context.origin, pid: null, token: null };
44
+ try {
45
+ writeReviewRecord(record);
46
+ let entry = fileURLToPath(new URL('./review-worker-entry.js', import.meta.url));
47
+ const origin = productRoot(context.origin);
48
+ if (origin) {
49
+ const runner = join(folder, 'runner');
50
+ copyPackage(origin, runner);
51
+ if (!productIdentity(runner))
52
+ throw new PackageError('identity');
53
+ entry = join(runner, 'node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.js');
54
+ }
55
+ startReviewWorker(entry, [job.id], folder);
56
+ return job;
57
+ }
58
+ catch (error) {
59
+ removeTree(folder);
60
+ throw error;
61
+ }
62
+ }
63
+ export function packageReviewJob(context, id, owner, cancel = false) {
64
+ if (typeof id !== 'string' || typeof owner !== 'string')
65
+ throw new PackageError('arguments');
66
+ const record = readReviewRecord(id), job = record.job;
67
+ if (record.configDir !== context.configDir || job.owner !== owner)
68
+ throw new PackageError('identity');
69
+ if (cancel) {
70
+ atomicWrite(join(reviewFolder(id), 'cancel.json'), '{}\n');
71
+ const stopped = waitReviewExit(() => {
72
+ const latest = readReviewRecord(id);
73
+ return !!latest.pid && !!latest.token && !processMatches(latest.pid, latest.token);
74
+ });
75
+ if (stopped) {
76
+ const finished = readReviewRecord(id).job;
77
+ removeTree(reviewFolder(id));
78
+ return { ...finished, state: 'cancelled', finished_at: new Date().toISOString() };
79
+ }
80
+ // Cancellation was requested, but a live/unverifiable executor still owns its files.
81
+ return readReviewRecord(id).job;
82
+ }
83
+ if (job.state === 'running' && (Date.now() - Date.parse(job.started_at) > REVIEW_DEADLINE_MS ||
84
+ Date.now() - Date.parse(job.started_at) > 15000 && (!record.pid || !record.token || !processMatches(record.pid, record.token))))
85
+ return { ...job, state: 'failed', error: 'interrupted', finished_at: new Date().toISOString() };
86
+ if (job.state === 'complete' && inspectPackage(context, job.request.prefix).revision !== job.request.expected_revision)
87
+ return { ...job, state: 'failed', review: null, error: 'conflict' };
88
+ return job;
89
+ }
90
+ //# sourceMappingURL=review-jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-jobs.js","sourceRoot":"","sources":["../../../src/management/review-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAEvG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,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IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/H,OAAO,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IACpG,IAAI,GAAG,CAAC,KAAK,KAAK,UAAU,IAAI,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,GAAG,CAAC,OAAO,CAAC,iBAAiB;QAClH,OAAO,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IACxE,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,33 @@
1
+ import * as fs from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { detectClaudeVersion } from '@fbincon/statusline-platform/commands';
4
+ import { processToken } from '@fbincon/statusline-platform/processes';
5
+ import { readReviewRecord, writeReviewRecord, reviewFolder, REVIEW_DEADLINE_MS } from './review-jobs.js';
6
+ import { reviewPackage } from './review.js';
7
+ import { packageReason } from './inspection.js';
8
+ const id = process.argv[2], record = readReviewRecord(id), folder = reviewFolder(id), controller = new AbortController();
9
+ record.pid = process.pid;
10
+ record.token = processToken(process.pid);
11
+ writeReviewRecord(record);
12
+ const cancelled = () => fs.existsSync(join(folder, 'cancel.json'));
13
+ const watcher = setInterval(() => {
14
+ if (cancelled() || Date.now() - Date.parse(record.job.started_at) > REVIEW_DEADLINE_MS)
15
+ controller.abort();
16
+ }, 200);
17
+ try {
18
+ if (cancelled())
19
+ controller.abort();
20
+ record.job.review = await reviewPackage(record.job.request, { configDir: record.configDir, origin: record.origin, hostVersion: detectClaudeVersion }, { signal: controller.signal });
21
+ record.job.state = controller.signal.aborted ? 'cancelled' : 'complete';
22
+ }
23
+ catch (error) {
24
+ record.job.state = controller.signal.aborted ? 'cancelled' : 'failed';
25
+ record.job.error = packageReason(error);
26
+ }
27
+ finally {
28
+ clearInterval(watcher);
29
+ record.job.finished_at = new Date().toISOString();
30
+ // The caller removes the independent runner only after this process exits.
31
+ writeReviewRecord(record);
32
+ }
33
+ //# sourceMappingURL=review-worker-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-worker-entry.js","sourceRoot":"","sources":["../../../src/management/review-worker-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAE,EAAE,MAAM,GAAG,gBAAgB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,EAAE,CAAC,EAAE,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;AAC1H,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AACzB,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACzC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AACnE,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;IAC7B,IAAI,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,kBAAkB;QAClF,UAAU,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;AACR,IAAI,CAAC;IACD,IAAI,SAAS,EAAE;QACX,UAAU,CAAC,KAAK,EAAE,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IACrL,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC;AAC5E,CAAC;AACD,OAAO,KAAK,EAAE,CAAC;IACX,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;IACtE,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;QACO,CAAC;IACL,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,2EAA2E;IAC3E,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { PackageReviewRequest, PackageReviewView } from '@fbincon/statusline-core/contracts/ui';
2
+ import { type ManagementEnvironment } from './service.js';
3
+ import { type InspectionContext } from './inspection.js';
4
+ /** The only adapter used by editor jobs: every branch is check or dry-run. */
5
+ export declare function reviewPackage(request: PackageReviewRequest, context: InspectionContext, environment?: Partial<ManagementEnvironment>): Promise<PackageReviewView>;
@@ -0,0 +1,44 @@
1
+ import { PackageError } from '@fbincon/statusline-core/management/package';
2
+ import { manage } from './service.js';
3
+ import { inspectPackage } from './inspection.js';
4
+ /** The only adapter used by editor jobs: every branch is check or dry-run. */
5
+ export async function reviewPackage(request, context, environment = {}) {
6
+ const current = inspectPackage(context, request.prefix);
7
+ if (current.revision !== request.expected_revision)
8
+ throw new PackageError('conflict');
9
+ let result = null, failure = null;
10
+ const command = request.action === 'check' ? 'update' : request.action === 'recover-package' || request.action === 'restore-config' ? 'recover' : request.action;
11
+ const args = [command, '--prefix', request.prefix, '--config-dir', context.configDir, '--json', request.action === 'check' ? '--check' : '--dry-run'];
12
+ if (request.action === 'recover-package')
13
+ args.push('--package');
14
+ if (request.action === 'restore-config')
15
+ args.push('--restore-config', request.backup_id);
16
+ else if (request.target)
17
+ args.push('--version', request.target);
18
+ else if (request.channel && command === 'update')
19
+ args.push('--channel', request.channel);
20
+ const code = await manage(args, { ...environment, origin: context.origin, host: context.hostVersion, stdout: () => { }, stderr: () => { },
21
+ review(value) {
22
+ if (value.action !== 'restore-config' && request.expected_integrity && value.integrity !== request.expected_integrity)
23
+ throw new PackageError('integrity');
24
+ result = value.action === 'restore-config' ? {
25
+ action: request.action, current: current.current, target: value.source_version, prefix: request.prefix, entry: current.entry, config_dir: context.configDir,
26
+ channel: current.channel, registry: null, integrity: null, node_engine: null, host: current.host, artifact_verified: false, compatible: true,
27
+ reasons: [], configuration_conflicts: [], backup_id: value.backup_id, files: value.files.map(file => file.path),
28
+ } : { action: request.action, current: value.current, target: value.target, prefix: value.prefix, entry: value.entry, config_dir: value.config_dir,
29
+ channel: value.channel, registry: value.registry, integrity: value.integrity, node_engine: value.node_engine, host: value.host,
30
+ artifact_verified: value.artifact_verified, compatible: value.compatible, reasons: [...value.reasons], configuration_conflicts: [...value.configuration_conflicts], backup_id: value.backup_id, files: [] };
31
+ }, failure: reason => { failure = reason; },
32
+ });
33
+ if (failure || !result)
34
+ throw new PackageError(failure ?? 'metadata');
35
+ const review = result;
36
+ if (request.expected_integrity && review.integrity !== request.expected_integrity)
37
+ throw new PackageError('integrity');
38
+ if (inspectPackage(context, request.prefix).revision !== request.expected_revision)
39
+ throw new PackageError('conflict');
40
+ if (code !== 0 && review.compatible)
41
+ throw new PackageError('io_error');
42
+ return review;
43
+ }
44
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../../src/management/review.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,MAAM,EAA8B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AACzE,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B,EAAE,OAA0B,EAAE,cAA8C,EAAE;IAC3I,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,iBAAiB;QAC9C,MAAM,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,MAAM,GAA6B,IAAI,EAAE,OAAO,GAAkB,IAAI,CAAC;IAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,iBAAiB,IAAI,OAAO,CAAC,MAAM,KAAK,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACjK,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,U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OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;KAC9C,CAAC,CAAC;IACH,IAAI,OAAO,IAAI,CAAC,MAAM;QAClB,MAAM,IAAI,YAAY,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAA2B,CAAC;IAC3C,IAAI,OAAO,CAAC,kBAAkB,IAAI,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC,kBAAkB;QAC7E,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,iBAAiB;QAC9E,MAAM,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU;QAC/B,MAAM,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -1,9 +1,13 @@
1
+ import { type PackageReview } from '@fbincon/statusline-core/management/package';
1
2
  import { Npm } from '@fbincon/statusline-platform/npm';
2
3
  import { type ManagementOptions } from './arguments.js';
3
4
  import { type PackageOperation } from './store.js';
4
5
  import { refreshIntegration } from './integration.js';
5
6
  export interface ManagementEnvironment {
6
7
  origin: string;
8
+ signal?: AbortSignal;
9
+ review?: (review: PackageReview | import('./restore.js').ConfigurationRestoreReview) => void;
10
+ failure?: (reason: string) => void;
7
11
  stdout: (text: string) => void;
8
12
  stderr: (text: string) => void;
9
13
  environment?: NodeJS.ProcessEnv;
@@ -98,6 +98,9 @@ export async function manage(argv, options) {
98
98
  const { stdout, stderr } = options, environment = options.environment ?? process.env;
99
99
  let flags, language = 'en', temporary, release, operation;
100
100
  const controller = new AbortController(), cancel = () => controller.abort();
101
+ options.signal?.addEventListener('abort', cancel, { once: true });
102
+ if (options.signal?.aborted)
103
+ controller.abort();
101
104
  process.on('SIGINT', cancel);
102
105
  process.on('SIGTERM', cancel);
103
106
  try {
@@ -110,13 +113,13 @@ export async function manage(argv, options) {
110
113
  const prefix = resolvedPath(flags.prefix);
111
114
  if (within(configDir, globalPackageRoot(prefix)))
112
115
  throw new PackageError('prefix');
113
- return await restoreConfiguration(flags, configDir, prefix, language, stdout, options.confirm, controller.signal);
116
+ return await restoreConfiguration(flags, configDir, prefix, language, stdout, options.confirm, controller.signal, options.review);
114
117
  }
115
118
  const npm = options.npm ?? new Npm(environment, undefined, undefined, controller.signal), layout = await npm.layout(flags.prefix);
116
119
  if (within(configDir, layout.root))
117
120
  throw new PackageError('prefix');
118
121
  if (flags.restoreConfig)
119
- return await restoreConfiguration(flags, configDir, layout.prefix, language, stdout, options.confirm, controller.signal);
122
+ return await restoreConfiguration(flags, configDir, layout.prefix, language, stdout, options.confirm, controller.signal, options.review);
120
123
  let before = null;
121
124
  if (!flags.package)
122
125
  before = currentPackage(layout);
@@ -162,6 +165,7 @@ export async function manage(argv, options) {
162
165
  if (configReasons.length)
163
166
  reasons.push('configuration');
164
167
  const review = { schema_version: 1, action: flags.package ? 'recover-package' : flags.command, current: before?.version ?? null, observed_package: observed ?? before?.version ?? null, target: target.version, registry: target.registry, prefix: layout.prefix, entry: join(layout.root, 'node_modules/@fbincon/statusline-cli/dist/src/entry.js'), node: process.execPath, npm_entry: npm.entry, config_dir: configDir, node_version: process.versions.node, node_engine: target.nodeEngine, host: host?.join('.') ?? null, channel, integrated, compatibility: target.compatibility, integrity: target.integrity, compatible: !reasons.length, reasons, configuration_conflicts: configReasons, backup_id: operation?.id ?? history?.transaction ?? null, artifact_verified: false };
168
+ options.review?.(review);
165
169
  if (flags.check) {
166
170
  stdout(JSON.stringify(review, null, 2) + '\n');
167
171
  return reasons.length ? 2 : 0;
@@ -172,7 +176,7 @@ export async function manage(argv, options) {
172
176
  stderr(t('package.reason_' + reasons[0], language) + '\n');
173
177
  return 2;
174
178
  }
175
- if (!flags.package && target.version === before.version) {
179
+ if (!flags.package && target.version === before.version && !(flags.dryRun && options.review)) {
176
180
  stdout(flags.json ? JSON.stringify({ ...review, unchanged: true }) + '\n' : t('management.current', language, { version: target.version }) + '\n');
177
181
  return 0;
178
182
  }
@@ -196,6 +200,7 @@ export async function manage(argv, options) {
196
200
  if (integrated)
197
201
  await (options.integrate ?? refreshIntegration)(staged.root, expected, configDir, host, hashes, temporary, true, environment, controller.signal);
198
202
  review.artifact_verified = true;
203
+ options.review?.(review);
199
204
  if (!flags.json)
200
205
  stdout(t('management.review', language) + '\n');
201
206
  stdout(JSON.stringify(review, null, 2) + '\n');
@@ -306,6 +311,7 @@ export async function manage(argv, options) {
306
311
  }
307
312
  catch { /* Preserve the last durable phase if the journal volume is unavailable. */ }
308
313
  }
314
+ options.failure?.(reason);
309
315
  const message = t('package.reason_' + reason, language);
310
316
  if (flags?.json)
311
317
  stdout(JSON.stringify({ schema_version: 1, error: { code: reason, message } }) + '\n');
@@ -316,6 +322,7 @@ export async function manage(argv, options) {
316
322
  return reason === 'interrupted' ? 130 : 2;
317
323
  }
318
324
  finally {
325
+ options.signal?.removeEventListener('abort', cancel);
319
326
  release?.();
320
327
  process.off('SIGINT', cancel);
321
328
  process.off('SIGTERM', cancel);