@fbincon/claude-code-statusline 3.12.0 → 3.14.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.
- package/README.md +82 -79
- package/candidate.json +365 -286
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js +9 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +23 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +7 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/reuse.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/reuse.js +62 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/reuse.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/structural-review.d.ts +5 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/structural-review.js +45 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/structural-review.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js +20 -6
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +52 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +14 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-config/SKILL.md +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +7 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +7 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +10 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +8 -5
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/alignment-manager.ts +2 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/change-review.ts +109 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/color-manager.ts +5 -4
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +70 -21
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +7 -13
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts +2 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/groups.ts +2 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/history.ts +33 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/import-selection.ts +2 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/indicators.ts +2 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/quick-setup.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/reuse-manager.ts +150 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/reuse.ts +96 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-compatibility.ts +7 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-manager.ts +12 -5
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/structure.ts +30 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +18 -8
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/en.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/ja.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/ko.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-CN.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-HK.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-TW.ts +95 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +34 -28
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +4 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +3 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +6 -4
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +15 -3
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.d.ts +6 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +5 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/scenario-presets.d.ts +11 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/scenario-presets.js +49 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/scenario-presets.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +40 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +96 -7
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +4 -3
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +9 -3
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/change-review.d.ts +32 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/change-review.js +155 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/change-review.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js +6 -4
- package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +17 -3
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +114 -23
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +8 -14
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js +2 -5
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/history.d.ts +22 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/history.js +37 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/history.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.js +3 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse-manager.d.ts +39 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse-manager.js +271 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse-manager.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse.js +135 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/reuse.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-compatibility.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-compatibility.js +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-compatibility.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js +12 -5
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/structure.d.ts +16 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/structure.js +28 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/structure.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +564 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +570 -6
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.js +20 -4
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.js +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js +8 -4
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/fitting.d.ts +12 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/fitting.js +22 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/fitting.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js +9 -8
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +15 -6
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js +30 -4
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +33 -15
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +21 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +67 -5
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +18 -8
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js +8 -2
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +95 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +95 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +95 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +95 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +95 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +95 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +6 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +3 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +16 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +35 -9
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
- package/package.json +3 -3
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts
CHANGED
|
@@ -7,7 +7,9 @@ import type { SourceManager } from './source-manager.ts';
|
|
|
7
7
|
import type { ProfileManager } from './profile-manager.ts';
|
|
8
8
|
import type { QuickSetup } from './quick-setup.ts';
|
|
9
9
|
import { t, text, type Language } from '../i18n/index.ts';
|
|
10
|
-
import {
|
|
10
|
+
import { emptyHistory, remember, snapshot, boundHistory, semantic, type DraftHistory } from './history.ts';
|
|
11
|
+
import { repairStructure, type StructureProposal } from './structure.ts';
|
|
12
|
+
import { openChanges, targetIdentity, type ChangeReview } from './change-review.ts';
|
|
11
13
|
import { nodes, newInstance, reconcileRows } from './instances.ts';
|
|
12
14
|
import { isDraft } from '../backend.ts';
|
|
13
15
|
import type {
|
|
@@ -44,6 +46,11 @@ export interface PendingSave {
|
|
|
44
46
|
/** Pure tool draft. Persistence and host configuration calls live in the hook. */
|
|
45
47
|
export class Editor {
|
|
46
48
|
draft: Draft;
|
|
49
|
+
reuse: import('./reuse-manager.js').ReuseManager | null = null;
|
|
50
|
+
history: DraftHistory = emptyHistory();
|
|
51
|
+
changeReview: ChangeReview | null = null;
|
|
52
|
+
structureProposal: StructureProposal | null = null;
|
|
53
|
+
numericBefore: Draft | null = null;
|
|
47
54
|
baseline: ReadResult;
|
|
48
55
|
page: Page = 'main';
|
|
49
56
|
previewScenario: import('./preview-settings.js').PreviewScenario = 'normal';
|
|
@@ -135,8 +142,7 @@ export class Editor {
|
|
|
135
142
|
};
|
|
136
143
|
}
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
if (!this.canMutateDraft()) return;
|
|
145
|
+
private restoreDraft(draft: Draft): void {
|
|
140
146
|
this.draft = copyDraft(draft);
|
|
141
147
|
for (const scope of ['main', 'subagent'] as const) {
|
|
142
148
|
this.order[scope] = nodes(this.draft,scope).map(i=>i.id);
|
|
@@ -152,6 +158,50 @@ export class Editor {
|
|
|
152
158
|
this.review = null; this.alignmentManager = null;
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
/** The only accepted draft transition; tentative input and candidates stay separate. */
|
|
162
|
+
commitDraft(draft: Draft, label: LocalizedText = text('history.edit')): boolean {
|
|
163
|
+
if (!this.canMutateDraft() || !isDraft(draft)) return false;
|
|
164
|
+
if (semantic(this.draft) === semantic(draft)) return true;
|
|
165
|
+
remember(this.history, this.draft, label);
|
|
166
|
+
this.draft = copyDraft(draft); this.mutationGeneration++;
|
|
167
|
+
for (const scope of ['main', 'subagent'] as const) {
|
|
168
|
+
this.order[scope] = nodes(this.draft, scope).map(n => n.id);
|
|
169
|
+
if (!this.order[scope].includes(this.selected[scope])) this.selected[scope] = this.order[scope][0] ?? '';
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
replaceDraft(draft: Draft, label: LocalizedText = text('history.replace')): void {
|
|
174
|
+
if (this.commitDraft(draft, label)) this.restoreDraft(draft);
|
|
175
|
+
}
|
|
176
|
+
undo(redo = false): boolean {
|
|
177
|
+
if (!this.canMutateDraft() || this.numericBefore) return false;
|
|
178
|
+
const source = redo ? this.history.redo : this.history.undo, target = redo ? this.history.undo : this.history.redo;
|
|
179
|
+
const entry = source.pop(); if (!entry) return false;
|
|
180
|
+
target.push(snapshot(this.draft, entry.label)); boundHistory(this.history);
|
|
181
|
+
this.restoreDraft(entry.draft); this.mutationGeneration++;
|
|
182
|
+
this.groupManager = null; this.colors = null; this.structureProposal = null; this.changeReview = null;
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
applyStructure(draft: Draft): boolean {
|
|
186
|
+
if (!this.canMutateDraft()) return false;
|
|
187
|
+
try {
|
|
188
|
+
const proposal = repairStructure(this.draft, draft);
|
|
189
|
+
if (!proposal.repairs.length) return this.commitDraft(proposal.draft, text('history.structure'));
|
|
190
|
+
this.structureProposal = { ...proposal, generation: this.mutationGeneration, target: targetIdentity(this.baseline) };
|
|
191
|
+
openChanges(this, true); return true;
|
|
192
|
+
} catch { this.compositionError = text('composition.invalid'); return false; }
|
|
193
|
+
}
|
|
194
|
+
acceptProposal(): boolean {
|
|
195
|
+
const proposal = this.structureProposal;
|
|
196
|
+
if (!proposal || !this.canMutateDraft(proposal.generation) || targetIdentity(this.baseline) !== proposal.target || semantic(this.draft) !== semantic(proposal.base)) return false;
|
|
197
|
+
if (!this.commitDraft(proposal.draft, text('history.structure'))) return false;
|
|
198
|
+
this.structureProposal = null; this.changeReview = null; this.groupManager = null; this.alignmentManager = null; return true;
|
|
199
|
+
}
|
|
200
|
+
adoptRevision(current: ReadResult, generation: number, target: string): boolean {
|
|
201
|
+
if (!this.canMutateDraft(generation) || targetIdentity(current) !== target || targetIdentity(this.baseline) !== target || !current.installed) return false;
|
|
202
|
+
this.baseline = { ...current, draft: copyDraft(current.draft) }; this.mutationGeneration++; return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
155
205
|
get modified(): boolean {
|
|
156
206
|
return (
|
|
157
207
|
!sameDraft(this.draft, this.baseline.draft) ||
|
|
@@ -224,9 +274,9 @@ export class Editor {
|
|
|
224
274
|
const target = scope === 'main' ? draft.display : draft.display.subagents;
|
|
225
275
|
target.groups = reconcileGroups(target.groups, list);
|
|
226
276
|
if(scope==='main')reconcileRows(draft);
|
|
227
|
-
if(!this.
|
|
277
|
+
if(!this.applyStructure(draft))return false;
|
|
228
278
|
if(this.adding){this.closePicker(scope);this.search[scope]='';this.category[scope]='all';}
|
|
229
|
-
this.
|
|
279
|
+
if (!this.structureProposal) { this.order[scope]=list.map(i=>i.id);this.selected[scope]=next; }
|
|
230
280
|
return true;
|
|
231
281
|
}
|
|
232
282
|
|
|
@@ -260,7 +310,7 @@ export class Editor {
|
|
|
260
310
|
if(!node)return false;
|
|
261
311
|
node.enabled=!node.enabled;
|
|
262
312
|
if(!isDraft(draft))return false;
|
|
263
|
-
this.draft
|
|
313
|
+
return this.commitDraft(draft, text('history.edit'));
|
|
264
314
|
}
|
|
265
315
|
|
|
266
316
|
move(scope: Scope, delta: -1 | 1): boolean {
|
|
@@ -278,20 +328,14 @@ export class Editor {
|
|
|
278
328
|
const [moving] = ordered.splice(sourceIndex, 1);
|
|
279
329
|
ordered.splice(ordered.findIndex(node => node.id === target) + (delta > 0 ? 1 : 0), 0, moving!);
|
|
280
330
|
if (scope === 'main') reconcileRows(draft);
|
|
281
|
-
if (!this.
|
|
282
|
-
this.
|
|
283
|
-
this.order[scope] = ordered.map(node => node.id);
|
|
331
|
+
if (!this.applyStructure(draft)) return false;
|
|
332
|
+
if (!this.structureProposal) this.order[scope] = ordered.map(node => node.id);
|
|
284
333
|
return true;
|
|
285
334
|
}
|
|
286
335
|
|
|
287
|
-
private acceptStructure(draft: Draft): boolean {
|
|
288
|
-
const ids = alignmentConflicts(draft.display);
|
|
289
|
-
if (ids.length) this.compositionError = text('alignment.references', { ids: ids.join(', ') });
|
|
290
|
-
return isDraft(draft);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
336
|
setBuffer(field: NumericField, value: string): void {
|
|
294
337
|
if (!this.canMutateDraft()) return;
|
|
338
|
+
this.numericBefore ??= copyDraft(this.draft);
|
|
295
339
|
this.activeNumeric = field;
|
|
296
340
|
this.buffers[field] = value;
|
|
297
341
|
delete this.fieldErrors[field];
|
|
@@ -299,6 +343,7 @@ export class Editor {
|
|
|
299
343
|
}
|
|
300
344
|
|
|
301
345
|
cancelNumeric(field?: NumericField): void {
|
|
346
|
+
if (this.numericBefore) { this.draft = copyDraft(this.numericBefore); this.numericBefore = null; }
|
|
302
347
|
for (const key of field ? [field] : NUMERIC_FIELDS) {
|
|
303
348
|
this.buffers[key] = String(this.draft.host[key]);
|
|
304
349
|
delete this.fieldErrors[key];
|
|
@@ -307,7 +352,7 @@ export class Editor {
|
|
|
307
352
|
if (!field || this.activeNumeric === field) this.activeNumeric = null;
|
|
308
353
|
}
|
|
309
354
|
|
|
310
|
-
acceptNumeric(field?: NumericField): boolean {
|
|
355
|
+
acceptNumeric(field?: NumericField, preview = false): boolean {
|
|
311
356
|
if (!this.canMutateDraft()) return false;
|
|
312
357
|
const values: Partial<Record<NumericField, number | 'event'>> = {};
|
|
313
358
|
const fields = field ? [field] : NUMERIC_FIELDS;
|
|
@@ -319,18 +364,22 @@ export class Editor {
|
|
|
319
364
|
else values[key] = parsed.value;
|
|
320
365
|
}
|
|
321
366
|
if (fields.some((key) => this.fieldErrors[key])) return false;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (values.refresh_interval !== undefined)
|
|
325
|
-
|
|
367
|
+
const candidate = copyDraft(this.draft);
|
|
368
|
+
if (values.padding !== undefined) candidate.host.padding = values.padding as number;
|
|
369
|
+
if (values.refresh_interval !== undefined) candidate.host.refresh_interval = values.refresh_interval;
|
|
370
|
+
if (preview) { this.draft = candidate; return true; }
|
|
371
|
+
if (this.numericBefore) this.draft = copyDraft(this.numericBefore);
|
|
372
|
+
this.numericBefore = null;
|
|
373
|
+
if (!this.commitDraft(candidate)) return false;
|
|
326
374
|
this.cancelNumeric(field);
|
|
327
375
|
return true;
|
|
328
376
|
}
|
|
329
377
|
|
|
330
378
|
committed(current: ReadResult): void {
|
|
331
379
|
this.pendingSave=null;this.setSaveState('idle');
|
|
380
|
+
this.numericBefore = null; this.history = emptyHistory(); this.structureProposal = null; this.changeReview = null;
|
|
332
381
|
this.baseline = { ...current, draft: copyDraft(current.draft) };
|
|
333
|
-
this.
|
|
382
|
+
this.restoreDraft(current.draft); this.mutationGeneration++;
|
|
334
383
|
this.cancelNumeric();
|
|
335
384
|
}
|
|
336
385
|
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
2
|
import { GRADIENT_KEYS, GRADIENT_DEFAULTS, GRADIENT_PRESETS, parseGradient, gradientName } from './gradients.ts';
|
|
3
|
-
import { alignmentConflicts } from './alignments.ts';
|
|
4
3
|
import { COST_RATE_DEFAULTS } from './cost-rate.ts';
|
|
5
4
|
import { INDICATOR_DEFAULTS } from './indicators.ts';
|
|
6
5
|
import { nodes } from './instances.ts';
|
|
@@ -40,6 +39,7 @@ export function fieldMessage(row: SettingRow, view: FormView) {
|
|
|
40
39
|
}
|
|
41
40
|
if (key.startsWith('break:'))
|
|
42
41
|
return localizedText('layout.break_before', { item: view.editor!.instanceLabel('main', key.slice(6), view.language) });
|
|
42
|
+
if (['reuse-style', 'reuse-groups', 'change-history'].includes(key)) return localizedText('settings.' + key);
|
|
43
43
|
return localizedText('native.settings.' + key);
|
|
44
44
|
}
|
|
45
45
|
export interface FormRow extends SettingRow {
|
|
@@ -59,7 +59,7 @@ function format(raw: unknown): string {
|
|
|
59
59
|
return raw === null ? 'inherit' : typeof raw === 'boolean' ? raw ? 'on' : 'off' : String(raw);
|
|
60
60
|
}
|
|
61
61
|
function row(spec: EditorField, key: string, valueRaw: unknown): FormRow {
|
|
62
|
-
return { ...spec, spec, key, valueRaw, value: (GRADIENT_KEYS as readonly string[]).includes(spec.key) ? gradientName(valueRaw) : format(valueRaw), editable: true };
|
|
62
|
+
return { ...spec, spec, key, valueRaw, value: ((GRADIENT_KEYS as readonly string[]).includes(spec.key) || spec.key === 'powerline.row_background_gradient') ? gradientName(valueRaw) : format(valueRaw), editable: true };
|
|
63
63
|
}
|
|
64
64
|
export function formRows(view: FormView): FormRow[] {
|
|
65
65
|
const e = view.editor!;
|
|
@@ -88,7 +88,7 @@ export function formRows(view: FormView): FormRow[] {
|
|
|
88
88
|
}
|
|
89
89
|
return result;
|
|
90
90
|
}
|
|
91
|
-
return e.description.editor_fields.global!.map((spec) => row(spec, 'field:' + spec.key, read(d, spec.key)));
|
|
91
|
+
return e.description.editor_fields.global!.map((spec) => row(spec, 'field:' + spec.key, read(d, spec.key) ?? null));
|
|
92
92
|
}
|
|
93
93
|
function options(draft: Draft, scope: 'main' | 'subagent', id: string) {
|
|
94
94
|
return nodes(draft, scope).find(i => i.id === id)!.options;
|
|
@@ -112,7 +112,7 @@ export function setFormValue(view: FormView, current: FormRow, raw: string | boo
|
|
|
112
112
|
return false;
|
|
113
113
|
if (spec.key === "foreground" || spec.key === "background")
|
|
114
114
|
value = normalizeColor(value);
|
|
115
|
-
if ((GRADIENT_KEYS as readonly string[]).includes(spec.key)) {
|
|
115
|
+
if (((GRADIENT_KEYS as readonly string[]).includes(spec.key) || spec.key === 'powerline.row_background_gradient')) {
|
|
116
116
|
try { value = parseGradient(value); } catch { setMessage(view, 'message', localizedText('gradients.invalid')); return false; }
|
|
117
117
|
}
|
|
118
118
|
const draft = copyDraft(e.draft);
|
|
@@ -154,21 +154,15 @@ export function setFormValue(view: FormView, current: FormRow, raw: string | boo
|
|
|
154
154
|
}
|
|
155
155
|
else
|
|
156
156
|
write(draft.display, spec.key, value);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (ids.length) {
|
|
160
|
-
setMessage(view, 'message', localizedText('alignment.references', { ids: ids.join(', ') }));
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
setMessage(view, "message", localizedText("native.lib.client.forms.invalid_value_check_thresholds_text_and_width_constraints"));
|
|
157
|
+
if (!e.applyStructure(draft)) {
|
|
158
|
+
setMessage(view, 'message', e.compositionError.key === 'composition.invalid' ? localizedText('native.lib.client.forms.invalid_value_check_thresholds_text_and_width_constraints') : e.compositionError);
|
|
164
159
|
return false;
|
|
165
160
|
}
|
|
166
|
-
e.draft = draft;
|
|
167
161
|
return true;
|
|
168
162
|
}
|
|
169
163
|
export function adjustForm(view: FormView, current: FormRow, delta: -1 | 1): boolean {
|
|
170
164
|
const spec = current.spec;
|
|
171
|
-
if ((GRADIENT_KEYS as readonly string[]).includes(spec.key)) {
|
|
165
|
+
if (((GRADIENT_KEYS as readonly string[]).includes(spec.key) || spec.key === 'powerline.row_background_gradient')) {
|
|
172
166
|
const choices = ['off', ...Object.keys(GRADIENT_PRESETS)], index = choices.indexOf(gradientName(current.valueRaw));
|
|
173
167
|
return setFormValue(view, current, choices[(index + delta + choices.length) % choices.length]!);
|
|
174
168
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts
CHANGED
|
@@ -34,9 +34,8 @@ function apply(e: Editor, edit: GroupEdit): void {
|
|
|
34
34
|
const m = e.groupManager!;
|
|
35
35
|
if (!e.canMutateDraft()) { m.error=true;m.errorMessage=e.compositionError;return; }
|
|
36
36
|
try {
|
|
37
|
-
const display = editGroup(e.draft.display, m.scope, edit, () => newInstance('text', groupScope(e.draft.display, m.scope).instances).id);
|
|
38
|
-
if (!
|
|
39
|
-
e.draft = { ...e.draft, display }; e.order[m.scope] = groupScope(display, m.scope).instances.map(n => n.id);
|
|
37
|
+
const display = editGroup(e.draft.display, m.scope, edit, () => newInstance('text', groupScope(e.draft.display, m.scope).instances).id, false);
|
|
38
|
+
if (!e.applyStructure({ ...e.draft, display })) throw new Error('invalid');
|
|
40
39
|
m.page = 'list'; m.cursor = 0; m.error = false;
|
|
41
40
|
} catch (error) { m.error = true; m.errorMessage = error instanceof AlignmentReferenceError ? text('alignment.references', { ids: error.ids.join(', ') }) : undefined; }
|
|
42
41
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/groups.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface GroupEdit {
|
|
|
40
40
|
link_visibility?: boolean; shared_powerline?: boolean;
|
|
41
41
|
before?: string; after?: string;
|
|
42
42
|
}
|
|
43
|
-
export function editGroup(original: DisplayDraft, scope: Scope, edit: GroupEdit, nextId: () => string): DisplayDraft {
|
|
43
|
+
export function editGroup(original: DisplayDraft, scope: Scope, edit: GroupEdit, nextId: () => string, protectAlignments = true): DisplayDraft {
|
|
44
44
|
const display = JSON.parse(JSON.stringify(original)) as DisplayDraft, target = groupScope(display, scope);
|
|
45
45
|
const invalid = (): never => { throw new Error('composition.groups.invalid'); };
|
|
46
46
|
const fresh = () => { const value = nextId(); if (!id(value) || target.instances.some(n => n.id === value) || target.groups.some(g => g.id === value)) invalid(); return value; };
|
|
@@ -86,6 +86,6 @@ export function editGroup(original: DisplayDraft, scope: Scope, edit: GroupEdit,
|
|
|
86
86
|
} else invalid();
|
|
87
87
|
}
|
|
88
88
|
if (!validGroups(target.groups, target.instances, scope === 'main' ? display.layout : undefined)) invalid();
|
|
89
|
-
if (scope === 'main') requireAlignments(display);
|
|
89
|
+
if (scope === 'main' && protectAlignments) requireAlignments(display);
|
|
90
90
|
return display;
|
|
91
91
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/history.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
/** Session-only snapshots. These are host state, never presentation props or disk data. */
|
|
3
|
+
import type { Draft } from '../generated-contracts.ts';
|
|
4
|
+
import type { LocalizedText } from '../i18n/index.ts';
|
|
5
|
+
|
|
6
|
+
export const HISTORY_STEPS = 100;
|
|
7
|
+
export const HISTORY_BYTES = 16 * 1024 * 1024;
|
|
8
|
+
export interface HistoryEntry { draft: Draft; label: LocalizedText; bytes: number }
|
|
9
|
+
export interface DraftHistory { undo: HistoryEntry[]; redo: HistoryEntry[]; trimmed: boolean }
|
|
10
|
+
export const emptyHistory = (): DraftHistory => ({ undo: [], redo: [], trimmed: false });
|
|
11
|
+
export const clone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
|
|
12
|
+
export function semantic(value: unknown): string {
|
|
13
|
+
if (Array.isArray(value)) return '[' + value.map(semantic).join(',') + ']';
|
|
14
|
+
if (value !== null && typeof value === 'object') return '{' + Object.keys(value).sort().map(key => JSON.stringify(key) + ':' + semantic((value as Record<string, unknown>)[key])).join(',') + '}';
|
|
15
|
+
return JSON.stringify(value);
|
|
16
|
+
}
|
|
17
|
+
/** Count UTF-8 without depending on Node or a host-specific TextEncoder. */
|
|
18
|
+
export function snapshot(draft: Draft, label: LocalizedText): HistoryEntry {
|
|
19
|
+
const raw = JSON.stringify(draft); let bytes = 0;
|
|
20
|
+
for (const c of raw) { const n = c.codePointAt(0)!; bytes += n < 128 ? 1 : n < 2048 ? 2 : n < 65536 ? 3 : 4; }
|
|
21
|
+
return { draft: clone(draft), label: clone(label), bytes };
|
|
22
|
+
}
|
|
23
|
+
export function boundHistory(history: DraftHistory): void {
|
|
24
|
+
let bytes = [...history.undo, ...history.redo].reduce((sum, entry) => sum + entry.bytes, 0);
|
|
25
|
+
while (history.undo.length + history.redo.length > HISTORY_STEPS || bytes > HISTORY_BYTES) {
|
|
26
|
+
const removed = history.undo.length ? history.undo.shift() : history.redo.shift();
|
|
27
|
+
if (!removed) break;
|
|
28
|
+
bytes -= removed.bytes; history.trimmed = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function remember(history: DraftHistory, before: Draft, label: LocalizedText): void {
|
|
32
|
+
history.redo = []; history.undo.push(snapshot(before, label)); boundHistory(history);
|
|
33
|
+
}
|
|
@@ -4,7 +4,7 @@ import type { Draft } from '../generated-contracts.ts';
|
|
|
4
4
|
|
|
5
5
|
export const IMPORT_FIELDS = [
|
|
6
6
|
'main', 'subagent', 'use_colors', 'palette', 'theme', 'directory_style', 'separator_style', 'scope_labels',
|
|
7
|
-
'powerline_glyph', 'powerline.padding', 'powerline.separator', 'powerline.start_cap', 'powerline.end_cap', 'powerline.color_mode',
|
|
7
|
+
'powerline.row_background_gradient', 'powerline_glyph', 'powerline.padding', 'powerline.separator', 'powerline.start_cap', 'powerline.end_cap', 'powerline.color_mode',
|
|
8
8
|
'statusline_language', 'formatting.model_name', 'formatting.number_format', 'formatting.labels', 'formatting.icons',
|
|
9
9
|
'formatting.allowance', 'formatting.reset_format', 'formatting.reset_timezone', 'formatting.thresholds',
|
|
10
10
|
] as const;
|
|
@@ -34,5 +34,6 @@ export function selectImport(base: Draft, incoming: Draft, requested: unknown):
|
|
|
34
34
|
target[parts.at(-1)!] = origin[parts.at(-1)!];
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
if (result.display.powerline.row_background_gradient === undefined) delete result.display.powerline.row_background_gradient;
|
|
37
38
|
return result;
|
|
38
39
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/indicators.ts
CHANGED
|
@@ -8,13 +8,13 @@ export function supportsIndicator(scope: Scope, id: string): boolean {
|
|
|
8
8
|
return ['context-used', 'context-remaining'].includes(id) || scope === 'main' && ['five-hour-limit', 'weekly-limit', 'spend-limit'].includes(id);
|
|
9
9
|
}
|
|
10
10
|
export const INDICATOR_FIELDS: EditorField[] = [
|
|
11
|
-
{ key: 'presentation', label: 'Indicator presentation', group: 'Item format', kind: 'choice', choices: ['numeric', 'bar'], minimum: 0, maximum: 0, nullable: false },
|
|
11
|
+
{ key: 'presentation', label: 'Indicator presentation', group: 'Item format', kind: 'choice', choices: ['numeric', 'bar', 'adaptive'], minimum: 0, maximum: 0, nullable: false },
|
|
12
12
|
{ key: 'bar_width', label: 'Bar width', group: 'Item format', kind: 'integer', choices: [], minimum: 4, maximum: 20, nullable: false },
|
|
13
13
|
{ key: 'bar_style', label: 'Bar characters', group: 'Item format', kind: 'choice', choices: ['auto', 'unicode', 'ascii'], minimum: 0, maximum: 0, nullable: false },
|
|
14
14
|
];
|
|
15
15
|
export function validIndicatorOptions(value: Record<string, unknown>, scope?: Scope, id?: string): boolean {
|
|
16
16
|
if (scope && id && !supportsIndicator(scope, id) && INDICATOR_KEYS.some(key => Object.hasOwn(value, key))) return false;
|
|
17
|
-
return (value.presentation === undefined || typeof value.presentation === 'string' && ['numeric', 'bar'].includes(value.presentation)) &&
|
|
17
|
+
return (value.presentation === undefined || typeof value.presentation === 'string' && ['numeric', 'bar', 'adaptive'].includes(value.presentation)) &&
|
|
18
18
|
(value.bar_style === undefined || typeof value.bar_style === 'string' && ['auto', 'unicode', 'ascii'].includes(value.bar_style)) &&
|
|
19
19
|
(value.bar_width === undefined || typeof value.bar_width === 'number' && Number.isInteger(value.bar_width) && value.bar_width >= 4 && value.bar_width <= 20);
|
|
20
20
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/quick-setup.ts
CHANGED
|
@@ -63,7 +63,7 @@ export function quickView(quick: QuickSetup, language: Language, width: number,
|
|
|
63
63
|
] : [tr('quick.fine_tune'),tr('quick.save'),tr('quick.copy'),tr('quick.back')];
|
|
64
64
|
const paragraphs=[...(quick.step === 'review' && quick.selected === 1 && sharedProjects.length ? [tr('profiles.shared',{count:sharedProjects.length}), ...sharedProjects] : []),
|
|
65
65
|
tr(preset.requirements_key),tr('quick.sample'),
|
|
66
|
-
...(!d.subagents.enabled && ['multi-agent','agent-focus'].includes(preset.id) ? [tr('quick.subagents_off')] : []),
|
|
66
|
+
...(!d.subagents.enabled && ['multi-agent','agent-focus','agent-workbench'].includes(preset.id) ? [tr('quick.subagents_off')] : []),
|
|
67
67
|
...(quick.step==='review' ? [tr('quick.replace')] : [])];
|
|
68
68
|
const detail=wrapText(paragraphs,width), menuHeight=Math.max(1, Math.min(rows.length,Math.floor(height/2)));
|
|
69
69
|
const start=Math.max(0, Math.min(quick.selected,rows.length-menuHeight,quick.selected-menuHeight+1));
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/reuse-manager.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import type { Draft, ProfilesResult, ReuseRequest, ReuseReviewResult, Scope } from '../generated-contracts.ts';
|
|
3
|
+
import type { Editor } from './draft.ts';
|
|
4
|
+
import type { ReviewBackend } from './change-review.ts';
|
|
5
|
+
import { targetIdentity } from './change-review.ts';
|
|
6
|
+
import { clip } from '../unicode.ts';
|
|
7
|
+
import { clone } from './history.ts';
|
|
8
|
+
import { STYLE_FIELDS, styleFields, reuseDraft } from './reuse.ts';
|
|
9
|
+
import { createReview, navigateReview, reviewRows, type ReviewState } from './import-review.ts';
|
|
10
|
+
import { newInstance } from './instances.ts';
|
|
11
|
+
import { openSources } from './source-manager.ts';
|
|
12
|
+
import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
|
|
13
|
+
import { text, t, renderMessage, type Language, type LocalizedText } from '../i18n/index.ts';
|
|
14
|
+
|
|
15
|
+
export interface ReuseManager {
|
|
16
|
+
kind: 'style' | 'groups'; page: 'source' | 'path' | 'profiles' | 'select' | 'fields' | 'review' | 'complete';
|
|
17
|
+
generation: number; target: string; scope: Scope; fromScope: Scope; destination: string; incoming: Draft; local: boolean;
|
|
18
|
+
from: string; groups: string[]; fields: string[]; references: 'review' | 'expand' | 'exclude'; explicit: boolean;
|
|
19
|
+
cursor: number; scroll: number; details: boolean; input: TextInput; profileFile: boolean; library: ProfilesResult | null;
|
|
20
|
+
result: ReuseReviewResult | null; review: ReviewState | null; message: LocalizedText | null; effect: 'file' | 'profiles' | null;
|
|
21
|
+
}
|
|
22
|
+
export function openReuse(e: Editor, kind: ReuseManager['kind']): void {
|
|
23
|
+
const scope = e.detail?.scope ?? (e.page === 'subagents' ? 'subagent' : 'main');
|
|
24
|
+
e.reuse = { kind, page: 'source', generation: e.mutationGeneration, target: targetIdentity(e.baseline), scope, fromScope: scope, destination: e.detail?.id ?? e.selected[scope],
|
|
25
|
+
incoming: clone(e.draft), local: true, from: '', groups: [], fields: [], references: 'review', explicit: false, cursor: 0, scroll: 0, details: false,
|
|
26
|
+
input: textInput('statusline.json'), profileFile: false, library: null, result: null, review: null, message: null, effect: null };
|
|
27
|
+
}
|
|
28
|
+
function source(e: Editor) { const m=e.reuse!; return m.fromScope === 'main' ? m.incoming.display : m.incoming.display.subagents; }
|
|
29
|
+
function request(m: ReuseManager): ReuseRequest {
|
|
30
|
+
return m.kind === 'style' ? { kind:'style',scope:m.scope,from_scope:m.fromScope,from_id:m.from,to_ids:[m.destination],fields:[...m.fields] }
|
|
31
|
+
: {kind:'groups',scope:m.scope,group_ids:[...m.groups],references:m.references,explicit:m.explicit};
|
|
32
|
+
}
|
|
33
|
+
function refresh(e: Editor): void {
|
|
34
|
+
const m=e.reuse!;
|
|
35
|
+
try {
|
|
36
|
+
m.result = reuseDraft(e.draft,m.incoming,request(m),()=>newInstance('text',[]).id,e.description.catalog,m.local);
|
|
37
|
+
m.review = createReview(m.result); m.details = m.result.blocked.length > 0; m.scroll=0; m.message = m.result.blocked.length ? text(m.result.blocked[0]!) : null;
|
|
38
|
+
} catch (error) { m.result=null;m.review=null;m.message=text(error instanceof Error && error.message==='reuse.incompatible'?'reuse.incompatible':'reuse.invalid'); }
|
|
39
|
+
}
|
|
40
|
+
function reviewCapacity(m: ReuseManager,height:number):number {
|
|
41
|
+
const headers=1+Number(height>=4)+Number(m.kind==='style'&&height>=5)+Number(m.kind==='groups'&&height>=6)+Number(m.kind==='groups'&&height>=7);
|
|
42
|
+
return Math.max(1,height-headers-1);
|
|
43
|
+
}
|
|
44
|
+
function rows(e: Editor, language: Language): string[] {
|
|
45
|
+
const m=e.reuse!,tr=(key:string)=>t('reuse.'+key,language);
|
|
46
|
+
if(m.page==='source')return ['current','portable','profile_file','profiles'].map(tr);
|
|
47
|
+
if(m.page==='profiles')return m.library?.profiles.map(p=>p.name)??[];
|
|
48
|
+
if(m.page==='complete')return [tr('accepted'),...(m.result?.unresolved.map(u=>`${u.id} · ${u.hint} · ${tr('unbound')}`)??[]),tr('bind_help')];
|
|
49
|
+
if(m.page==='select'){
|
|
50
|
+
const values=m.kind==='style'?source(e).instances.filter(n=>n.type_id!=='spacer').map(n=>`${n.id} · ${n.options.label??t('items.'+m.fromScope+'.'+n.type_id+'.label',language)}`)
|
|
51
|
+
:source(e).groups.map(g=>`[${m.groups.includes(g.id)?'x':' '}] ${g.id} · ${g.member_ids.join(', ')}`);
|
|
52
|
+
return [tr('scope')+': '+m.fromScope,...values,...(m.kind==='groups'?[tr('review')]:[])];
|
|
53
|
+
}
|
|
54
|
+
if(m.page==='fields'){
|
|
55
|
+
const origin=source(e).instances.find(n=>n.id===m.from),destination=e.instance(m.scope,m.destination);
|
|
56
|
+
const available=origin&&destination?styleFields(origin,m.fromScope,e.description.catalog).filter(f=>styleFields(destination,m.scope,e.description.catalog).includes(f)):[];
|
|
57
|
+
return [...STYLE_FIELDS.map(f=>`[${m.fields.includes(f)?'x':' '}] ${t('reuse.field.'+f,language)}${available.includes(f)?'':' · '+tr('unsupported')}`),tr('review')];
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
export function reuseKey(e: Editor,event:TextKey,language:Language,width:number,height:number):'reuse'|'sources'|null {
|
|
62
|
+
const m=e.reuse!,key=event.key==='enter'?'return':event.key;
|
|
63
|
+
if(event.overflow)return null;
|
|
64
|
+
if(!event.text&&!event.paste&&(key==='escape'||event.ctrl&&key.toLowerCase()==='g')){e.reuse=null;return null;}
|
|
65
|
+
if(m.page==='path'){
|
|
66
|
+
if(key==='return'&&!event.text&&!event.paste){m.effect='file';return 'reuse';}
|
|
67
|
+
m.input=inputKey(m.input.value,m.input,event,4096).state;return null;
|
|
68
|
+
}
|
|
69
|
+
if(event.text||event.paste||event.ctrl||event.meta)return null;
|
|
70
|
+
if(key.toLowerCase()==='q'){e.reuse=null;return null;}
|
|
71
|
+
if(m.page==='complete'){if(key.toLowerCase()==='b'){e.reuse=null;openSources(e);return 'sources';}const total=rows(e,language).length;if(['up','down','pageup','pagedown','home','end'].includes(key))m.cursor=Math.max(0,Math.min(total-1,key==='home'?0:key==='end'?total-1:m.cursor+(key==='up'?-1:key==='down'?1:key==='pageup'?-Math.max(1,height-3):Math.max(1,height-3))));return null;}
|
|
72
|
+
if(m.generation!==e.mutationGeneration||m.target!==targetIdentity(e.baseline)||!e.canMutateDraft()){m.message=text('history.stale');return null;}
|
|
73
|
+
if(m.page==='review'){
|
|
74
|
+
if(key==='tab'&&m.kind==='groups'){m.details=!m.details;m.scroll=0;return null;}
|
|
75
|
+
if(m.details&&['up','down','pageup','pagedown','home','end'].includes(key)) {const capacity=reviewCapacity(m,height),maximum=Math.max(0,detailRows(m,language).length-capacity);m.scroll=Math.max(0,Math.min(maximum,key==='home'?0:key==='end'?maximum:m.scroll+(key==='up'?-1:key==='down'?1:key==='pageup'?-capacity:capacity)));return null;}
|
|
76
|
+
if(key.toLowerCase()==='a'){
|
|
77
|
+
if(m.result&&!m.result.blocked.length&&e.commitDraft(m.result.draft,text('reuse.action'))){m.page='complete';m.cursor=0;m.scroll=0;}
|
|
78
|
+
}else if(key.toLowerCase()==='x'&&m.kind==='groups'){m.references=m.references==='review'?'expand':m.references==='expand'?'exclude':'review';refresh(e);}
|
|
79
|
+
else if(key.toLowerCase()==='l'&&m.kind==='groups'){m.explicit=!m.explicit;refresh(e);}
|
|
80
|
+
else if(key==='backspace'){m.page=m.kind==='style'?'fields':'select';m.cursor=0;}
|
|
81
|
+
else if(m.review)navigateReview(m.review,key,language,width,reviewCapacity(m,height));
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const values=rows(e,language),length=values.length;
|
|
85
|
+
if(['up','down','pageup','pagedown','home','end'].includes(key))m.cursor=Math.max(0,Math.min(length-1,key==='home'?0:key==='end'?length-1:m.cursor+(key==='up'?-1:key==='down'?1:key==='pageup'?-Math.max(1,height-3):Math.max(1,height-3))));
|
|
86
|
+
if(!['return',' ','space','left','right'].includes(key))return null;
|
|
87
|
+
if(m.page==='source'){
|
|
88
|
+
if(m.cursor===0){m.page='select';m.cursor=0;}
|
|
89
|
+
else if(m.cursor===3){m.effect='profiles';return 'reuse';}
|
|
90
|
+
else {m.profileFile=m.cursor===2;m.page='path';}
|
|
91
|
+
}else if(m.page==='profiles'){
|
|
92
|
+
const profile=m.library?.profiles[m.cursor];if(profile){m.incoming={display:clone(profile.display),host:clone(e.draft.host)};m.local=false;m.page='select';m.cursor=0;}
|
|
93
|
+
}else if(m.page==='select'){
|
|
94
|
+
if(m.cursor===0){m.fromScope=m.fromScope==='main'?'subagent':'main';if(m.kind==='groups'){m.scope=m.fromScope;m.groups=[];}return null;}
|
|
95
|
+
if(m.kind==='style'){
|
|
96
|
+
const node=source(e).instances.filter(n=>n.type_id!=='spacer')[m.cursor-1];
|
|
97
|
+
if(node){m.from=node.id;const destination=e.instance(m.scope,m.destination);m.fields=destination?STYLE_FIELDS.slice(0,6).filter(f=>styleFields(node,m.fromScope,e.description.catalog).includes(f)&&styleFields(destination,m.scope,e.description.catalog).includes(f)):[];m.page='fields';m.cursor=0;}
|
|
98
|
+
}else{
|
|
99
|
+
const group=source(e).groups[m.cursor-1];
|
|
100
|
+
if(group)m.groups=m.groups.includes(group.id)?m.groups.filter(id=>id!==group.id):[...m.groups,group.id];
|
|
101
|
+
else if(m.groups.length){refresh(e);m.page='review';m.cursor=0;}
|
|
102
|
+
}
|
|
103
|
+
}else if(m.page==='fields'){
|
|
104
|
+
const field=STYLE_FIELDS[m.cursor];
|
|
105
|
+
if(!field){refresh(e);m.page='review';m.cursor=0;}
|
|
106
|
+
else {const origin=source(e).instances.find(n=>n.id===m.from)!,destination=e.instance(m.scope,m.destination);if(destination&&styleFields(origin,m.fromScope,e.description.catalog).includes(field)&&styleFields(destination,m.scope,e.description.catalog).includes(field))m.fields=m.fields.includes(field)?m.fields.filter(f=>f!==field):[...m.fields,field];else m.message=text('reuse.incompatible');}
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function detailRows(m:ReuseManager,language:Language):{text:string;heading:boolean;section:string}[]{
|
|
111
|
+
const tr=(key:string)=>t('reuse.'+key,language);
|
|
112
|
+
return [
|
|
113
|
+
...(m.kind==='groups'?[
|
|
114
|
+
{text:tr(m.references)+' · '+tr('reference_policy'),heading:false,section:''},
|
|
115
|
+
{text:t('values.'+(m.explicit?'on':'off'),language)+': '+tr('layout'),heading:false,section:''}
|
|
116
|
+
]:[]),
|
|
117
|
+
...(m.result?.dependencies.map(id=>({text:tr('dependency')+': '+id,heading:false,section:''}))??[]),
|
|
118
|
+
...Object.entries(m.result?.mappings??{}).flatMap(([kind,map])=>Object.entries(map).map(([a,b])=>({text:kind+': '+a+' → '+b,heading:false,section:''}))),
|
|
119
|
+
...(m.result?.unresolved.map(u=>({text:tr('unbound')+': '+u.id+' · '+u.hint,heading:false,section:''}))??[])
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
export function reuseView(e:Editor,language:Language,width:number,height:number):{text:string;selected?:boolean}[]{
|
|
123
|
+
const m=e.reuse!,tr=(key:string)=>t('reuse.'+key,language),header=tr(m.kind==='style'?'style':'groups');
|
|
124
|
+
if(m.page==='path')return [{text:header},{text:tr('path')},{text:inputView({...m.input},width)},{text:tr('path_help')}].slice(0,height).map(row=>({...row,text:clip(row.text,width)}));
|
|
125
|
+
if(m.page==='review'){
|
|
126
|
+
const capacity=reviewCapacity(m,height),review=m.review;
|
|
127
|
+
const values=m.details?detailRows(m,language):review?reviewRows(review,language,width):[];
|
|
128
|
+
const offset=m.details?Math.max(0,Math.min(m.scroll,values.length-capacity)):Math.max(0,Math.min(review?.scroll??0,values.length-capacity));
|
|
129
|
+
return [{text:header},...(height>=4?[{text:m.message?renderMessage(m.message,language):tr('draft_only')}]:[]),
|
|
130
|
+
...(m.kind==='groups'&&height>=6?[{text:tr(m.references)+' · '+tr('reference_policy')}]:[]),
|
|
131
|
+
...(m.kind==='groups'&&height>=7?[{text:t('values.'+(m.explicit?'on':'off'),language)+': '+tr('layout')}]:[]),
|
|
132
|
+
...(m.kind==='style'&&height>=5?[{text:tr('scope')+': '+m.fromScope+' · '+m.from+' → '+m.destination}]:[]),
|
|
133
|
+
...values.slice(offset,offset+capacity).map(r=>({text:r.text,selected:r.heading&&r.section===review?.selected})),{text:tr(m.kind==='groups'?'review_groups_help':'review_style_help')}].slice(0,height).map(row=>({...row,text:clip(row.text,width)}));
|
|
134
|
+
}
|
|
135
|
+
const values=rows(e,language),capacity=Math.max(1,height-3);let start=Math.max(0,Math.min(m.scroll,m.cursor));if(m.cursor>=start+capacity)start=m.cursor-capacity+1;
|
|
136
|
+
return [{text:header},{text:m.message?renderMessage(m.message,language):tr('help')},...values.slice(start,start+capacity).map((value,index)=>({text:(start+index===m.cursor?'› ':' ')+value,selected:start+index===m.cursor})),{text:tr('cancel_help')}].slice(0,height).map(row=>({...row,text:clip(row.text,width)}));
|
|
137
|
+
}
|
|
138
|
+
export async function performReuse(e:Editor,backend:ReviewBackend):Promise<void>{
|
|
139
|
+
const m=e.reuse,effect=m?.effect;if(!m||!effect)return;m.effect=null;
|
|
140
|
+
try{
|
|
141
|
+
if(!e.canMutateDraft(m.generation)||m.target!==targetIdentity(e.baseline))throw new Error('history.stale');
|
|
142
|
+
if(effect==='profiles'){
|
|
143
|
+
const library=await backend.request('profiles_read',{});if(e.reuse!==m||m.generation!==e.mutationGeneration)return;m.library=library;m.page='profiles';m.cursor=0;
|
|
144
|
+
}else{
|
|
145
|
+
const incoming=m.profileFile?{display:(await backend.request('profile_import',{path:m.input.value})).display,host:clone(e.draft.host)}:(await backend.request('review_import',{draft:e.draft,path:m.input.value})).draft;
|
|
146
|
+
if(e.reuse!==m||m.generation!==e.mutationGeneration)return;m.incoming=clone(incoming);m.local=false;m.page='select';m.cursor=0;m.groups=[];
|
|
147
|
+
}
|
|
148
|
+
m.message=null;
|
|
149
|
+
}catch(error){if(e.reuse===m)m.message=text('history.failed',{detail:error instanceof Error?error.message:String(error)});}
|
|
150
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
/** Pure style selection and whole-group reference closure, shared by all frontends. */
|
|
3
|
+
import type { CatalogItem, Draft, InstanceDraft, ReuseRequest, ReuseReviewResult, Scope } from '../generated-contracts.ts';
|
|
4
|
+
import { FORMAT_CHOICES } from '../generated-contracts.ts';
|
|
5
|
+
import { clone } from './history.ts';
|
|
6
|
+
import { supportedFormats } from './appearance.ts';
|
|
7
|
+
import { alignmentUnits, refKey } from './alignments.ts';
|
|
8
|
+
import { isDraft } from '../backend.ts';
|
|
9
|
+
import { differences } from './import-differences.ts';
|
|
10
|
+
|
|
11
|
+
export const STYLE_FIELDS = ['foreground', 'background', 'foreground_gradient', 'background_gradient', 'label', 'icon', ...Object.keys(FORMAT_CHOICES).map(key => 'formatting.' + key)];
|
|
12
|
+
const area = (draft: Draft, scope: Scope) => scope === 'main' ? draft.display : draft.display.subagents;
|
|
13
|
+
export function styleFields(node: InstanceDraft, scope: Scope, catalog: readonly CatalogItem[] = []): string[] {
|
|
14
|
+
if (node.type_id === 'spacer') return [];
|
|
15
|
+
const formats = supportedFormats(scope, node.type_id, catalog.find(c => c.scope === scope && c.id === node.type_id)?.capabilities);
|
|
16
|
+
return STYLE_FIELDS.filter(field => !field.startsWith('formatting.') || formats.includes(field.slice(11)));
|
|
17
|
+
}
|
|
18
|
+
export function reuseRequest(value: unknown): ReuseRequest {
|
|
19
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('reuse.invalid');
|
|
20
|
+
const r = value as Record<string, unknown>, ids = (v: unknown): v is string[] => Array.isArray(v) && v.length <= 10000 && v.every(id => typeof id === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,95}$/u.test(id)) && new Set(v).size === v.length;
|
|
21
|
+
const keys = r.kind === 'style' ? ['kind','scope','from_scope','from_id','to_ids','fields'] : ['kind','scope','group_ids','references','explicit'];
|
|
22
|
+
if (Object.keys(r).length !== keys.length || keys.some(key => !Object.hasOwn(r,key)) || !['main','subagent'].includes(String(r.scope))) throw new Error('reuse.invalid');
|
|
23
|
+
if (r.kind === 'style') {
|
|
24
|
+
if (!['main','subagent'].includes(String(r.from_scope)) || !ids([r.from_id]) || !ids(r.to_ids) || !r.to_ids.length || !Array.isArray(r.fields) || r.fields.some(f => !STYLE_FIELDS.includes(String(f))) || new Set(r.fields).size !== r.fields.length) throw new Error('reuse.invalid');
|
|
25
|
+
} else if (r.kind !== 'groups' || !ids(r.group_ids) || !r.group_ids.length || !['review','expand','exclude'].includes(String(r.references)) || typeof r.explicit !== 'boolean') throw new Error('reuse.invalid');
|
|
26
|
+
return clone(value as ReuseRequest);
|
|
27
|
+
}
|
|
28
|
+
export function reuseDraft(base: Draft, incoming: Draft, raw: ReuseRequest, nextId: () => string, catalog: readonly CatalogItem[] = [], local = false): ReuseReviewResult {
|
|
29
|
+
const request = reuseRequest(raw), draft = clone(base), source = area(incoming, request.kind === 'style' ? request.from_scope : request.scope), target = area(draft, request.scope);
|
|
30
|
+
const mappings: ReuseReviewResult['mappings'] = { instances: {}, groups: {}, alignments: {} }, dependencies: string[] = [], blocked: string[] = [];
|
|
31
|
+
if (request.kind === 'style') {
|
|
32
|
+
const origin = source.instances.find(n => n.id === request.from_id);
|
|
33
|
+
if (!origin) throw new Error('reuse.invalid');
|
|
34
|
+
for (const id of request.to_ids) {
|
|
35
|
+
const destination = target.instances.find(n => n.id === id);
|
|
36
|
+
if (!destination || request.fields.some(field => !styleFields(origin, request.from_scope, catalog).includes(field) || !styleFields(destination, request.scope, catalog).includes(field))) throw new Error('reuse.incompatible');
|
|
37
|
+
for (const field of request.fields) {
|
|
38
|
+
const formatting = field.startsWith('formatting.'), key = formatting ? field.slice(11) : field;
|
|
39
|
+
const from = (formatting ? origin.options.formatting : origin.options) as unknown as Record<string, unknown>;
|
|
40
|
+
const to = (formatting ? destination.options.formatting : destination.options) as unknown as Record<string, unknown>;
|
|
41
|
+
if (Object.hasOwn(from,key)) to[key] = clone(from[key]); else delete to[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const selected = new Set<string>(), selectedGroups = new Set(request.group_ids);
|
|
46
|
+
const addGroup = (id: string) => { const group = source.groups.find(g => g.id === id); if (!group) throw new Error('reuse.invalid'); selectedGroups.add(id); group.member_ids.forEach(member => selected.add(member)); };
|
|
47
|
+
request.group_ids.forEach(addGroup);
|
|
48
|
+
const alignments = request.scope === 'main' ? incoming.display.layout.alignments ?? [] : [];
|
|
49
|
+
const included = (ref: { kind: string; id: string }) => ref.kind === 'group' ? selectedGroups.has(ref.id) : selected.has(ref.id);
|
|
50
|
+
let growing = true;
|
|
51
|
+
while (growing) {
|
|
52
|
+
growing = false;
|
|
53
|
+
for (const a of alignments.filter(a => a.columns.flat().some(included))) for (const ref of a.columns.flat().filter(ref => !included(ref))) {
|
|
54
|
+
const dependency = refKey(ref); if (!dependencies.includes(dependency)) dependencies.push(dependency);
|
|
55
|
+
if (request.references === 'expand') {
|
|
56
|
+
if (ref.kind === 'group') addGroup(ref.id);
|
|
57
|
+
else { const group = source.groups.find(g => g.member_ids.includes(ref.id)); if (group) addGroup(group.id); else selected.add(ref.id); }
|
|
58
|
+
growing = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (request.references !== 'expand') break;
|
|
62
|
+
}
|
|
63
|
+
const retained = alignments.filter(a => a.columns.flat().some(included) && a.columns.flat().every(included));
|
|
64
|
+
if (dependencies.length && request.references === 'review') blocked.push('reuse.references');
|
|
65
|
+
// Alignment side is part of the relationship: retain each necessary row spacer.
|
|
66
|
+
if (request.scope === 'main') for (const unit of alignmentUnits(incoming.display.layout, source.instances, source.groups)) {
|
|
67
|
+
if (unit.side === 'right' && included(unit.ref)) {
|
|
68
|
+
const spacer = incoming.display.layout.rows[unit.row]!.find(id => source.instances.find(n => n.id === id)?.type_id === 'spacer');
|
|
69
|
+
if (spacer) selected.add(spacer);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const nodes = source.instances.filter(n => selected.has(n.id));
|
|
73
|
+
if (nodes.length !== selected.size) throw new Error('reuse.invalid');
|
|
74
|
+
const occupied = new Set([...target.instances.map(n => n.id), ...target.groups.map(g => g.id), ...(draft.display.layout.alignments ?? []).map(a => a.id)]);
|
|
75
|
+
const fresh = () => { for (let i = 0; i < 100; i++) { const id = nextId(); if (/^[A-Za-z0-9][A-Za-z0-9_-]{0,95}$/u.test(id) && !occupied.has(id)) { occupied.add(id); return id; } } throw new Error('reuse.invalid'); };
|
|
76
|
+
for (const node of nodes) mappings.instances[node.id] = fresh();
|
|
77
|
+
for (const id of selectedGroups) mappings.groups[id] = fresh();
|
|
78
|
+
for (const a of retained) mappings.alignments[a.id] = fresh();
|
|
79
|
+
const copies = nodes.map(node => ({ ...clone(node), id: mappings.instances[node.id]!, ...(node.source && !local ? { source: { binding: null, hint: node.source.hint } } : {}) }));
|
|
80
|
+
target.instances.push(...copies);
|
|
81
|
+
target.groups.push(...source.groups.filter(g => selectedGroups.has(g.id)).map(g => ({ ...clone(g), id: mappings.groups[g.id]!, primary_id: mappings.instances[g.primary_id]!, member_ids: g.member_ids.map(id => mappings.instances[id]!) })));
|
|
82
|
+
if (request.scope === 'main') {
|
|
83
|
+
const layout = draft.display.layout, importedRows = (incoming.display.layout.mode === 'explicit' ? incoming.display.layout.rows : [nodes.map(n => n.id)]).map(row => row.filter(id => selected.has(id)).map(id => mappings.instances[id]!)).filter(row => row.length);
|
|
84
|
+
const needsExplicit = importedRows.length > 1 || retained.length > 0 || nodes.some(n => n.type_id === 'spacer');
|
|
85
|
+
if (layout.mode === 'auto' && needsExplicit) {
|
|
86
|
+
if (!request.explicit) blocked.push('reuse.explicit');
|
|
87
|
+
layout.mode = 'explicit'; layout.rows = base.display.instances.length ? [base.display.instances.map(n => n.id)] : [];
|
|
88
|
+
}
|
|
89
|
+
if (layout.mode === 'explicit') layout.rows.push(...importedRows);
|
|
90
|
+
if (retained.length) layout.alignments = [...(layout.alignments ?? []), ...retained.map(a => ({ id: mappings.alignments[a.id]!, columns: a.columns.map(column => column.map(ref => ({ kind: ref.kind, id: mappings[ref.kind === 'group' ? 'groups' : 'instances'][ref.id]! }))) }))];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!blocked.length && !isDraft(draft)) blocked.push('reuse.incompatible');
|
|
94
|
+
const unresolved = (['main','subagent'] as const).flatMap(scope => area(draft, scope).instances.filter(n => n.source && !n.source.binding && Object.values(mappings.instances).includes(n.id)).map(n => ({ scope, id: n.id, hint: n.source!.hint })));
|
|
95
|
+
return { draft: blocked.length ? clone(base) : draft, changes: blocked.length ? [] : differences(base, draft), mappings, dependencies, unresolved, blocked };
|
|
96
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import type { InstanceDraft, SourceContext, SourceDefinition } from '../generated-contracts.ts';
|
|
3
|
+
/** Matching a local source never authorizes it or collects an observation. */
|
|
4
|
+
export function compatibleSource(node: InstanceDraft, source: SourceDefinition, context: SourceContext | null): boolean {
|
|
5
|
+
if (node.type_id === 'external-value' ? !['json','command'].includes(source.kind) : !['github-pr','github-ci'].includes(node.type_id) || source.kind !== 'github') return false;
|
|
6
|
+
return (['project','session','agent'] as const).every(key => source.scope[key] === null || source.scope[key] === context?.[key]);
|
|
7
|
+
}
|