@caupulican/pi-adaptative 0.80.47 → 0.80.49

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 (26) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/core/profile-resource-selection.d.ts +9 -0
  3. package/dist/core/profile-resource-selection.d.ts.map +1 -1
  4. package/dist/core/profile-resource-selection.js +49 -0
  5. package/dist/core/profile-resource-selection.js.map +1 -1
  6. package/dist/modes/interactive/components/profile-resource-editor.d.ts +23 -6
  7. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  8. package/dist/modes/interactive/components/profile-resource-editor.js +253 -23
  9. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  10. package/dist/modes/interactive/components/settings-selector.d.ts +1 -7
  11. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  12. package/dist/modes/interactive/components/settings-selector.js +41 -108
  13. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  14. package/dist/modes/interactive/interactive-mode.d.ts +13 -2
  15. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  16. package/dist/modes/interactive/interactive-mode.js +533 -95
  17. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  18. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  19. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  20. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  21. package/examples/extensions/sandbox/package-lock.json +2 -2
  22. package/examples/extensions/sandbox/package.json +1 -1
  23. package/examples/extensions/with-deps/package-lock.json +2 -2
  24. package/examples/extensions/with-deps/package.json +1 -1
  25. package/npm-shrinkwrap.json +12 -12
  26. package/package.json +4 -4
@@ -1,23 +1,118 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { isAbsolute, resolve } from "node:path";
1
4
  import { Container, fuzzyFilter, getKeybindings, Input, Key, matchesKey, Spacer, Text, } from "@caupulican/pi-tui";
2
- import { decodeResourceSelection, encodeResourceSelection } from "../../../core/profile-resource-selection.js";
5
+ import { decodeResourceSelection, detectResourceFraming, encodeResourceSelectionWithFraming, } from "../../../core/profile-resource-selection.js";
3
6
  import { theme } from "../theme/theme.js";
4
7
  import { DynamicBorder } from "./dynamic-border.js";
5
8
  import { keyText } from "./keybinding-hints.js";
6
- /**
7
- * TUI component for editing per-kind resource toggles in a profile.
8
- * Shows a selectable list of resources for each kind (tools, skills, etc.),
9
- * with space-to-toggle, search filtering, and save/cancel callbacks.
10
- */
9
+ const TOOL_DESCRIPTIONS = {
10
+ read: "Read files from the filesystem.",
11
+ bash: "Execute arbitrary commands in the shell.",
12
+ edit: "Edit files surgically.",
13
+ write: "Create new files or overwrite existing files.",
14
+ grep: "Search for text patterns using ripgrep.",
15
+ find: "Locate files matching a search query.",
16
+ ls: "List files and directories.",
17
+ skill_audit: "Inspect and audit local skills.",
18
+ skillify: "Convert a set of files/instructions into a skill.",
19
+ extensionify: "Package a tool or script as an extension.",
20
+ };
21
+ export function resolveResourceEditPath(_id, filePath, kind) {
22
+ if (kind === "tools") {
23
+ return undefined;
24
+ }
25
+ if (!filePath) {
26
+ return undefined;
27
+ }
28
+ if (kind === "extensions") {
29
+ try {
30
+ const stats = fs.statSync(filePath);
31
+ if (stats.isDirectory()) {
32
+ const indexTs = path.join(filePath, "index.ts");
33
+ if (fs.existsSync(indexTs)) {
34
+ return indexTs;
35
+ }
36
+ const indexJs = path.join(filePath, "index.js");
37
+ if (fs.existsSync(indexJs)) {
38
+ return indexJs;
39
+ }
40
+ const pkgJsonPath = path.join(filePath, "package.json");
41
+ if (fs.existsSync(pkgJsonPath)) {
42
+ try {
43
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
44
+ if (typeof pkg.main === "string") {
45
+ const resolvedMain = path.resolve(filePath, pkg.main);
46
+ if (fs.existsSync(resolvedMain)) {
47
+ return resolvedMain;
48
+ }
49
+ }
50
+ }
51
+ catch { }
52
+ }
53
+ return indexTs;
54
+ }
55
+ }
56
+ catch { }
57
+ return filePath;
58
+ }
59
+ if (kind === "skills") {
60
+ try {
61
+ const stats = fs.statSync(filePath);
62
+ if (stats.isDirectory()) {
63
+ const skillMd = path.join(filePath, "SKILL.md");
64
+ if (fs.existsSync(skillMd)) {
65
+ return skillMd;
66
+ }
67
+ }
68
+ }
69
+ catch { }
70
+ return filePath;
71
+ }
72
+ return filePath;
73
+ }
74
+ export function classifyResourceSource(filePath, cwd, agentDir, externalRoots) {
75
+ if (!filePath) {
76
+ return "bundled";
77
+ }
78
+ const absolutePath = isAbsolute(filePath) ? filePath : resolve(cwd, filePath);
79
+ const normPath = resolve(absolutePath);
80
+ const normCwd = resolve(cwd);
81
+ const normAgentDir = agentDir ? resolve(agentDir) : "";
82
+ for (const extRoot of externalRoots) {
83
+ const normExt = resolve(extRoot);
84
+ if (normPath.startsWith(normExt)) {
85
+ return "catalog";
86
+ }
87
+ }
88
+ if (normAgentDir && normPath.startsWith(normAgentDir)) {
89
+ return "user";
90
+ }
91
+ if (normPath.startsWith(normCwd)) {
92
+ return "project";
93
+ }
94
+ if (normPath.includes("node_modules")) {
95
+ return "bundled";
96
+ }
97
+ return "bundled";
98
+ }
11
99
  export class ProfileResourceEditorComponent extends Container {
12
100
  profileName;
101
+ profileScope;
13
102
  kinds;
14
103
  enabledByKind = new Map();
104
+ framingByKind = new Map();
105
+ missingIdsByKind = new Map();
15
106
  currentKindIndex = 0;
107
+ cwd;
108
+ agentDir;
109
+ externalResourceRoots;
16
110
  filteredItems = [];
17
111
  selectedIndex = 0;
18
112
  searchInput;
19
113
  kindHeaderText;
20
114
  listContainer;
115
+ descriptionText;
21
116
  footerText;
22
117
  isDirty = false;
23
118
  maxVisible = 8;
@@ -31,24 +126,58 @@ export class ProfileResourceEditorComponent extends Container {
31
126
  }
32
127
  onSave;
33
128
  onCancel;
129
+ onScopeChange;
130
+ onEdit;
34
131
  constructor(options) {
35
132
  super();
36
133
  this.profileName = options.profileName;
134
+ this.profileScope = options.profileScope;
37
135
  this.kinds = options.kinds;
38
136
  this.onSave = options.onSave;
39
137
  this.onCancel = options.onCancel;
40
- // Initialize enabled sets for each kind via decoding
138
+ this.onScopeChange = options.onScopeChange;
139
+ this.onEdit = options.onEdit;
140
+ this.cwd = options.cwd || process.cwd();
141
+ this.agentDir = options.agentDir || "";
142
+ this.externalResourceRoots = options.externalResourceRoots || [];
143
+ // Initialize enabled, framing, and missing sets for each kind
41
144
  for (const kind of this.kinds) {
42
145
  const filter = options.initialResources[kind.kind];
43
- const enabledSet = decodeResourceSelection(filter, kind.allIds);
146
+ const allIds = kind.items.map((item) => item.id);
147
+ const enabledSet = decodeResourceSelection(filter, allIds);
44
148
  this.enabledByKind.set(kind.kind, enabledSet);
149
+ this.framingByKind.set(kind.kind, detectResourceFraming(filter));
150
+ // Compute missing items
151
+ const mentionedIds = new Set();
152
+ if (filter) {
153
+ if (filter.allow) {
154
+ for (const id of filter.allow) {
155
+ mentionedIds.add(id);
156
+ }
157
+ }
158
+ if (filter.block) {
159
+ for (const id of filter.block) {
160
+ if (id !== "*") {
161
+ mentionedIds.add(id);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ const availableIds = new Set(allIds);
167
+ const missingSet = new Set();
168
+ for (const id of mentionedIds) {
169
+ if (!availableIds.has(id)) {
170
+ missingSet.add(id);
171
+ }
172
+ }
173
+ this.missingIdsByKind.set(kind.kind, missingSet);
45
174
  }
46
175
  // Header
47
176
  this.addChild(new DynamicBorder());
48
- this.addChild(new Text(theme.fg("accent", theme.bold(`Edit Resources: ${this.profileName}`)), 0, 0));
49
- this.addChild(new Text(theme.fg("muted", `Navigate kinds with ${keyText("tui.input.tab")}. Toggle with ${keyText("tui.select.confirm")}.`), 0, 0));
177
+ this.addChild(new Text(theme.fg("accent", theme.bold(`Library editing "${this.profileName}" (${this.profileScope})`)), 0, 0));
178
+ this.addChild(new Text(theme.fg("muted", `Navigate kinds: ${keyText("tui.input.tab")}. Toggle: ${keyText("tui.select.confirm")}. Mode: ${theme.fg("accent", "a")} allow / ${theme.fg("accent", "b")} block. Scope: ${theme.fg("accent", "s")} change. Edit: ${theme.fg("accent", "e")}.`), 0, 0));
50
179
  this.addChild(new Spacer(1));
51
- // Kind selector header (shows current kind label and count)
180
+ // Kind selector header
52
181
  this.kindHeaderText = new Text(this.getKindHeaderText(), 0, 0);
53
182
  this.addChild(this.kindHeaderText);
54
183
  this.addChild(new Spacer(1));
@@ -59,17 +188,23 @@ export class ProfileResourceEditorComponent extends Container {
59
188
  // List container
60
189
  this.listContainer = new Container();
61
190
  this.addChild(this.listContainer);
191
+ // Description area
192
+ this.descriptionText = new Text("", 0, 0);
193
+ this.addChild(new Spacer(1));
194
+ this.addChild(this.descriptionText);
62
195
  // Footer hint
63
196
  this.addChild(new Spacer(1));
64
197
  this.footerText = new Text(this.getFooterText(), 0, 0);
65
198
  this.addChild(this.footerText);
66
199
  this.addChild(new DynamicBorder());
67
- this.updateList();
200
+ this.refresh();
68
201
  }
69
202
  getKindHeaderText() {
70
203
  const kind = this.kinds[this.currentKindIndex];
71
204
  const enabledSet = this.enabledByKind.get(kind.kind);
72
- const countText = `${enabledSet.size}/${kind.allIds.length} enabled`;
205
+ const framing = this.framingByKind.get(kind.kind);
206
+ const framingText = framing === "allow" ? "allow-list" : "block-list";
207
+ const countText = `${enabledSet.size}/${kind.items.length} enabled (${framingText})`;
73
208
  const kindIndicator = this.kinds
74
209
  .map((k, i) => {
75
210
  const marker = i === this.currentKindIndex ? "●" : "○";
@@ -88,15 +223,43 @@ export class ProfileResourceEditorComponent extends Container {
88
223
  buildItems() {
89
224
  const kind = this.getCurrentKind();
90
225
  const enabledSet = this.getCurrentEnabledSet();
91
- // Return items sorted: enabled first (in order), then disabled
226
+ const items = [];
227
+ // Add all available items
228
+ for (const availableItem of kind.items) {
229
+ const isEnabled = enabledSet.has(availableItem.id);
230
+ let desc = availableItem.description;
231
+ if (kind.kind === "tools" && !desc) {
232
+ desc = TOOL_DESCRIPTIONS[availableItem.id];
233
+ }
234
+ items.push({
235
+ id: availableItem.id,
236
+ enabled: isEnabled,
237
+ path: availableItem.path,
238
+ description: desc,
239
+ sourceLabel: classifyResourceSource(availableItem.path, this.cwd, this.agentDir, this.externalResourceRoots),
240
+ isMissing: false,
241
+ });
242
+ }
243
+ // Add missing items
244
+ const missingSet = this.missingIdsByKind.get(kind.kind) || new Set();
245
+ for (const missingId of missingSet) {
246
+ const isEnabled = enabledSet.has(missingId);
247
+ items.push({
248
+ id: missingId,
249
+ enabled: isEnabled,
250
+ isMissing: true,
251
+ description: "Referenced in profile but missing from available resources.",
252
+ });
253
+ }
254
+ // Sort: enabled first, then disabled
92
255
  const enabled = [];
93
256
  const disabled = [];
94
- for (const id of kind.allIds) {
95
- if (enabledSet.has(id)) {
96
- enabled.push({ id, enabled: true });
257
+ for (const item of items) {
258
+ if (item.enabled) {
259
+ enabled.push(item);
97
260
  }
98
261
  else {
99
- disabled.push({ id, enabled: false });
262
+ disabled.push(item);
100
263
  }
101
264
  }
102
265
  return [...enabled, ...disabled];
@@ -104,11 +267,12 @@ export class ProfileResourceEditorComponent extends Container {
104
267
  getFooterText() {
105
268
  const kind = this.getCurrentKind();
106
269
  const enabledSet = this.getCurrentEnabledSet();
107
- const countText = `${enabledSet.size}/${kind.allIds.length} enabled`;
270
+ const countText = `${enabledSet.size}/${kind.items.length} enabled`;
108
271
  const parts = [
109
272
  `${keyText("tui.select.confirm")} toggle`,
110
273
  `${keyText("tui.input.tab")} kind`,
111
274
  `${keyText("app.models.save")} save`,
275
+ `${theme.fg("accent", "e")} edit`,
112
276
  countText,
113
277
  ];
114
278
  return this.isDirty
@@ -118,15 +282,24 @@ export class ProfileResourceEditorComponent extends Container {
118
282
  refresh() {
119
283
  const query = this.searchInput.getValue();
120
284
  const items = this.buildItems();
121
- this.filteredItems = query ? fuzzyFilter(items, query, (i) => i.id) : items;
285
+ this.filteredItems = query ? fuzzyFilter(items, query, (i) => `${i.id} ${i.description ?? ""}`) : items;
122
286
  this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredItems.length - 1));
123
287
  this.updateList();
124
288
  this.footerText.setText(this.getFooterText());
125
289
  }
126
290
  updateList() {
127
291
  this.listContainer.clear();
292
+ const kind = this.getCurrentKind();
293
+ const missingSet = this.missingIdsByKind.get(kind.kind) || new Set();
294
+ const totalAvailableCount = kind.items.length + missingSet.size;
295
+ if (totalAvailableCount === 0) {
296
+ this.listContainer.addChild(new Text(theme.fg("muted", " (none available — add a Source or install resources)"), 0, 0));
297
+ this.descriptionText.setText(theme.fg("muted", " No description available"));
298
+ return;
299
+ }
128
300
  if (this.filteredItems.length === 0) {
129
301
  this.listContainer.addChild(new Text(theme.fg("muted", " No matching resources"), 0, 0));
302
+ this.descriptionText.setText(theme.fg("muted", " No description available"));
130
303
  return;
131
304
  }
132
305
  const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
@@ -135,7 +308,21 @@ export class ProfileResourceEditorComponent extends Container {
135
308
  const item = this.filteredItems[i];
136
309
  const isSelected = i === this.selectedIndex;
137
310
  const prefix = isSelected ? theme.fg("accent", "→ ") : " ";
138
- const resourceText = isSelected ? theme.fg("accent", item.id) : item.id;
311
+ let resourceText = isSelected ? theme.fg("accent", item.id) : item.id;
312
+ if (item.isMissing) {
313
+ resourceText = theme.fg("muted", `${item.id} [missing]`);
314
+ }
315
+ else if (item.sourceLabel) {
316
+ const labelColor = item.sourceLabel === "catalog"
317
+ ? "thinkingText"
318
+ : item.sourceLabel === "project"
319
+ ? "success"
320
+ : item.sourceLabel === "user"
321
+ ? "warning"
322
+ : "muted";
323
+ const labelText = theme.fg(labelColor, ` [${item.sourceLabel}]`);
324
+ resourceText = `${resourceText}${labelText}`;
325
+ }
139
326
  const status = item.enabled ? theme.fg("success", " ✓") : theme.fg("dim", " ✗");
140
327
  this.listContainer.addChild(new Text(`${prefix}${resourceText}${status}`, 0, 0));
141
328
  }
@@ -143,6 +330,14 @@ export class ProfileResourceEditorComponent extends Container {
143
330
  if (startIndex > 0 || endIndex < this.filteredItems.length) {
144
331
  this.listContainer.addChild(new Text(theme.fg("muted", ` (${this.selectedIndex + 1}/${this.filteredItems.length})`), 0, 0));
145
332
  }
333
+ // Update description area for current selection
334
+ const selectedItem = this.filteredItems[this.selectedIndex];
335
+ if (selectedItem?.description) {
336
+ this.descriptionText.setText(theme.fg("muted", ` Description: ${selectedItem.description}`));
337
+ }
338
+ else {
339
+ this.descriptionText.setText(theme.fg("muted", " No description available"));
340
+ }
146
341
  }
147
342
  handleInput(data) {
148
343
  const kb = getKeybindings();
@@ -170,6 +365,40 @@ export class ProfileResourceEditorComponent extends Container {
170
365
  this.refresh();
171
366
  return;
172
367
  }
368
+ // Switch framing: Allow-list
369
+ if (matchesKey(data, Key.ctrl("a")) || (this.searchInput.getValue() === "" && data === "a")) {
370
+ this.framingByKind.set(this.getCurrentKind().kind, "allow");
371
+ this.isDirty = true;
372
+ this.kindHeaderText.setText(this.getKindHeaderText());
373
+ this.refresh();
374
+ return;
375
+ }
376
+ // Switch framing: Block-list
377
+ if (matchesKey(data, Key.ctrl("b")) || (this.searchInput.getValue() === "" && data === "b")) {
378
+ this.framingByKind.set(this.getCurrentKind().kind, "block");
379
+ this.isDirty = true;
380
+ this.kindHeaderText.setText(this.getKindHeaderText());
381
+ this.refresh();
382
+ return;
383
+ }
384
+ // Edit highlighted resource
385
+ if (data === "e" && this.searchInput.getValue() === "") {
386
+ const item = this.filteredItems[this.selectedIndex];
387
+ if (item && !item.isMissing && item.path) {
388
+ const kind = this.getCurrentKind().kind;
389
+ if (this.onEdit) {
390
+ this.onEdit(item.id, item.path, kind);
391
+ }
392
+ }
393
+ return;
394
+ }
395
+ // Switch scope: Scope selector
396
+ if (matchesKey(data, Key.ctrl("o")) || (this.searchInput.getValue() === "" && data === "s")) {
397
+ if (this.onScopeChange) {
398
+ this.onScopeChange();
399
+ }
400
+ return;
401
+ }
173
402
  // Toggle on space/enter
174
403
  if (kb.matches(data, "tui.select.confirm")) {
175
404
  const item = this.filteredItems[this.selectedIndex];
@@ -212,11 +441,12 @@ export class ProfileResourceEditorComponent extends Container {
212
441
  this.refresh();
213
442
  }
214
443
  persistChanges() {
215
- // Encode each kind and build the result
216
444
  const resources = {};
217
445
  for (const kind of this.kinds) {
218
446
  const enabledSet = this.enabledByKind.get(kind.kind);
219
- const encoded = encodeResourceSelection(enabledSet, kind.allIds);
447
+ const framing = this.framingByKind.get(kind.kind);
448
+ const allIds = kind.items.map((item) => item.id);
449
+ const encoded = encodeResourceSelectionWithFraming(enabledSet, allIds, framing);
220
450
  if (encoded !== undefined) {
221
451
  resources[kind.kind] = encoded;
222
452
  }
@@ -1 +1 @@
1
- {"version":3,"file":"profile-resource-editor.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/profile-resource-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EAET,WAAW,EACX,cAAc,EACd,KAAK,EACL,GAAG,EACH,UAAU,EACV,MAAM,EACN,IAAI,GACJ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAE/G,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAqBhD;;;;GAIG;AACH,MAAM,OAAO,8BAA+B,SAAQ,SAAS;IACpD,WAAW,CAAS;IACpB,KAAK,CAA8B;IACnC,aAAa,GAA0C,IAAI,GAAG,EAAE,CAAC;IACjE,gBAAgB,GAAG,CAAC,CAAC;IAErB,aAAa,GAAmB,EAAE,CAAC;IACnC,aAAa,GAAG,CAAC,CAAC;IAClB,WAAW,CAAQ;IACnB,cAAc,CAAO;IACrB,aAAa,CAAY;IACzB,UAAU,CAAO;IACjB,OAAO,GAAG,KAAK,C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CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,OAAO;QACR,CAAC;QAED,uCAAuC;QACvC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;IAAA,CACf;IAEO,cAAc,GAAS;QAC9B,wCAAwC;QACxC,MAAM,SAAS,GAA4B,EAAE,CAAC;QAC9C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC;YACtD,MAAM,OAAO,GAAG,uBAAuB,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACjE,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC3B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;YAChC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAAA,CAC9C;IAED,cAAc,GAAU;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC;IAAA,CACxB;CACD","sourcesContent":["import {\n\tContainer,\n\ttype Focusable,\n\tfuzzyFilter,\n\tgetKeybindings,\n\tInput,\n\tKey,\n\tmatchesKey,\n\tSpacer,\n\tText,\n} from \"@caupulican/pi-tui\";\nimport { decodeResourceSelection, encodeResourceSelection } from \"../../../core/profile-resource-selection.ts\";\nimport type { ResourceProfileKind, ResourceProfileSettings } from \"../../../core/settings-manager.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyText } from \"./keybinding-hints.ts\";\n\nexport interface ProfileResourceEditorKind {\n\tkind: ResourceProfileKind; // \"tools\" | \"skills\" | \"extensions\" | \"agents\" | \"prompts\" | \"themes\"\n\tlabel: string; // display label, e.g. \"Tools\"\n\tallIds: string[]; // the full universe of selectable ids for this kind\n}\n\nexport interface ProfileResourceEditorOptions {\n\tprofileName: string;\n\tinitialResources: ResourceProfileSettings; // existing profile.resources; may be {}\n\tkinds: ProfileResourceEditorKind[]; // the six kinds, with their universes\n\tonSave: (resources: ResourceProfileSettings) => void; // called on ctrl+s with the encoded result\n\tonCancel: () => void; // called on esc\n}\n\ninterface ResourceItem {\n\tid: string;\n\tenabled: boolean;\n}\n\n/**\n * TUI component for editing per-kind resource toggles in a profile.\n * Shows a selectable list of resources for each kind (tools, skills, etc.),\n * with space-to-toggle, search filtering, and save/cancel callbacks.\n */\nexport class ProfileResourceEditorComponent extends Container implements Focusable {\n\tprivate profileName: string;\n\tprivate kinds: ProfileResourceEditorKind[];\n\tprivate enabledByKind: Map<ResourceProfileKind, Set<string>> = new Map();\n\tprivate currentKindIndex = 0;\n\n\tprivate filteredItems: ResourceItem[] = [];\n\tprivate selectedIndex = 0;\n\tprivate searchInput: Input;\n\tprivate kindHeaderText: Text;\n\tprivate listContainer: Container;\n\tprivate footerText: Text;\n\tprivate isDirty = false;\n\tprivate maxVisible = 8;\n\n\tprivate _focused = false;\n\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\n\tprivate onSave: (resources: ResourceProfileSettings) => void;\n\tprivate onCancel: () => void;\n\n\tconstructor(options: ProfileResourceEditorOptions) {\n\t\tsuper();\n\t\tthis.profileName = options.profileName;\n\t\tthis.kinds = options.kinds;\n\t\tthis.onSave = options.onSave;\n\t\tthis.onCancel = options.onCancel;\n\n\t\t// Initialize enabled sets for each kind via decoding\n\t\tfor (const kind of this.kinds) {\n\t\t\tconst filter = options.initialResources[kind.kind];\n\t\t\tconst enabledSet = decodeResourceSelection(filter, kind.allIds);\n\t\t\tthis.enabledByKind.set(kind.kind, enabledSet);\n\t\t}\n\n\t\t// Header\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Text(theme.fg(\"accent\", theme.bold(`Edit Resources: ${this.profileName}`)), 0, 0));\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"muted\",\n\t\t\t\t\t`Navigate kinds with ${keyText(\"tui.input.tab\")}. Toggle with ${keyText(\"tui.select.confirm\")}.`,\n\t\t\t\t),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Kind selector header (shows current kind label and count)\n\t\tthis.kindHeaderText = new Text(this.getKindHeaderText(), 0, 0);\n\t\tthis.addChild(this.kindHeaderText);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Search input\n\t\tthis.searchInput = new Input();\n\t\tthis.addChild(this.searchInput);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// List container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\t// Footer hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.footerText = new Text(this.getFooterText(), 0, 0);\n\t\tthis.addChild(this.footerText);\n\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.updateList();\n\t}\n\n\tprivate getKindHeaderText(): string {\n\t\tconst kind = this.kinds[this.currentKindIndex]!;\n\t\tconst enabledSet = this.enabledByKind.get(kind.kind)!;\n\t\tconst countText = `${enabledSet.size}/${kind.allIds.length} enabled`;\n\t\tconst kindIndicator = this.kinds\n\t\t\t.map((k, i) => {\n\t\t\t\tconst marker = i === this.currentKindIndex ? \"●\" : \"○\";\n\t\t\t\treturn theme.fg(i === this.currentKindIndex ? \"accent\" : \"muted\", `${marker} ${k.label}`);\n\t\t\t})\n\t\t\t.join(\" \");\n\t\treturn `${kindIndicator} ${theme.fg(\"muted\", countText)}`;\n\t}\n\n\tprivate getCurrentKind(): ProfileResourceEditorKind {\n\t\treturn this.kinds[this.currentKindIndex]!;\n\t}\n\n\tprivate getCurrentEnabledSet(): Set<string> {\n\t\tconst kind = this.getCurrentKind();\n\t\treturn this.enabledByKind.get(kind.kind)!;\n\t}\n\n\tprivate buildItems(): ResourceItem[] {\n\t\tconst kind = this.getCurrentKind();\n\t\tconst enabledSet = this.getCurrentEnabledSet();\n\t\t// Return items sorted: enabled first (in order), then disabled\n\t\tconst enabled: ResourceItem[] = [];\n\t\tconst disabled: ResourceItem[] = [];\n\t\tfor (const id of kind.allIds) {\n\t\t\tif (enabledSet.has(id)) {\n\t\t\t\tenabled.push({ id, enabled: true });\n\t\t\t} else {\n\t\t\t\tdisabled.push({ id, enabled: false });\n\t\t\t}\n\t\t}\n\t\treturn [...enabled, ...disabled];\n\t}\n\n\tprivate getFooterText(): string {\n\t\tconst kind = this.getCurrentKind();\n\t\tconst enabledSet = this.getCurrentEnabledSet();\n\t\tconst countText = `${enabledSet.size}/${kind.allIds.length} enabled`;\n\t\tconst parts = [\n\t\t\t`${keyText(\"tui.select.confirm\")} toggle`,\n\t\t\t`${keyText(\"tui.input.tab\")} kind`,\n\t\t\t`${keyText(\"app.models.save\")} save`,\n\t\t\tcountText,\n\t\t];\n\t\treturn this.isDirty\n\t\t\t? theme.fg(\"dim\", ` ${parts.join(\" · \")} `) + theme.fg(\"warning\", \"(unsaved)\")\n\t\t\t: theme.fg(\"dim\", ` ${parts.join(\" · \")}`);\n\t}\n\n\tprivate refresh(): void {\n\t\tconst query = this.searchInput.getValue();\n\t\tconst items = this.buildItems();\n\t\tthis.filteredItems = query ? fuzzyFilter(items, query, (i) => i.id) : items;\n\t\tthis.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredItems.length - 1));\n\t\tthis.updateList();\n\t\tthis.footerText.setText(this.getFooterText());\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tif (this.filteredItems.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No matching resources\"), 0, 0));\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.filteredItems[i]!;\n\t\t\tconst isSelected = i === this.selectedIndex;\n\t\t\tconst prefix = isSelected ? theme.fg(\"accent\", \"→ \") : \" \";\n\t\t\tconst resourceText = isSelected ? theme.fg(\"accent\", item.id) : item.id;\n\t\t\tconst status = item.enabled ? theme.fg(\"success\", \" ✓\") : theme.fg(\"dim\", \" ✗\");\n\t\t\tthis.listContainer.addChild(new Text(`${prefix}${resourceText}${status}`, 0, 0));\n\t\t}\n\n\t\t// Add scroll indicator if needed\n\t\tif (startIndex > 0 || endIndex < this.filteredItems.length) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${this.filteredItems.length})`), 0, 0),\n\t\t\t);\n\t\t}\n\t}\n\n\thandleInput(data: string): void {\n\t\tconst kb = getKeybindings();\n\n\t\t// Navigation within list\n\t\tif (kb.matches(data, \"tui.select.up\")) {\n\t\t\tif (this.filteredItems.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === 0 ? this.filteredItems.length - 1 : this.selectedIndex - 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.down\")) {\n\t\t\tif (this.filteredItems.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === this.filteredItems.length - 1 ? 0 : this.selectedIndex + 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\t// Switch kind with Tab (cycles forward)\n\t\tif (kb.matches(data, \"tui.input.tab\")) {\n\t\t\tthis.currentKindIndex = (this.currentKindIndex + 1) % this.kinds.length;\n\t\t\tthis.selectedIndex = 0;\n\t\t\tthis.searchInput.setValue(\"\");\n\t\t\tthis.kindHeaderText.setText(this.getKindHeaderText());\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\n\t\t// Toggle on space/enter\n\t\tif (kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tconst item = this.filteredItems[this.selectedIndex];\n\t\t\tif (item) {\n\t\t\t\tconst enabledSet = this.getCurrentEnabledSet();\n\t\t\t\tif (enabledSet.has(item.id)) {\n\t\t\t\t\tenabledSet.delete(item.id);\n\t\t\t\t} else {\n\t\t\t\t\tenabledSet.add(item.id);\n\t\t\t\t}\n\t\t\t\tthis.isDirty = true;\n\t\t\t\tthis.refresh();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Save/persist to settings\n\t\tif (kb.matches(data, \"app.models.save\")) {\n\t\t\tthis.persistChanges();\n\t\t\treturn;\n\t\t}\n\n\t\t// Ctrl+C - clear search or cancel if empty\n\t\tif (matchesKey(data, Key.ctrl(\"c\"))) {\n\t\t\tif (this.searchInput.getValue()) {\n\t\t\t\tthis.searchInput.setValue(\"\");\n\t\t\t\tthis.refresh();\n\t\t\t} else {\n\t\t\t\tthis.onCancel();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Escape - cancel\n\t\tif (matchesKey(data, Key.escape)) {\n\t\t\tthis.onCancel();\n\t\t\treturn;\n\t\t}\n\n\t\t// Pass everything else to search input\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.refresh();\n\t}\n\n\tprivate persistChanges(): void {\n\t\t// Encode each kind and build the result\n\t\tconst resources: ResourceProfileSettings = {};\n\t\tfor (const kind of this.kinds) {\n\t\t\tconst enabledSet = this.enabledByKind.get(kind.kind)!;\n\t\t\tconst encoded = encodeResourceSelection(enabledSet, kind.allIds);\n\t\t\tif (encoded !== undefined) {\n\t\t\t\tresources[kind.kind] = encoded;\n\t\t\t}\n\t\t}\n\t\tthis.onSave(resources);\n\t\tthis.isDirty = false;\n\t\tthis.footerText.setText(this.getFooterText());\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
1
+ {"version":3,"file":"profile-resource-editor.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/profile-resource-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACN,SAAS,EAET,WAAW,EACX,cAAc,EACd,KAAK,EACL,GAAG,EACH,UAAU,EACV,MAAM,EACN,IAAI,GACJ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,kCAAkC,GAElC,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAqChD,MAAM,iBAAiB,GAA2B;IACjD,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,0CAA0C;IAChD,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,+CAA+C;IACtD,IAAI,EAAE,yCAAyC;IAC/C,IAAI,EAAE,uCAAuC;IAC7C,EAAE,EAAE,6BAA6B;IACjC,WAAW,EAAE,iCAAiC;IAC9C,QAAQ,EAAE,mDAAmD;IAC7D,YAAY,EAAE,2CAA2C;CACzD,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACtC,GAAW,EACX,QAA4B,EAC5B,IAAyB,EACJ;IACrB,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;IA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AAC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAAA,CAC9C;IAED,cAAc,GAAU;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC;IAAA,CACxB;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { isAbsolute, resolve } from \"node:path\";\nimport {\n\tContainer,\n\ttype Focusable,\n\tfuzzyFilter,\n\tgetKeybindings,\n\tInput,\n\tKey,\n\tmatchesKey,\n\tSpacer,\n\tText,\n} from \"@caupulican/pi-tui\";\nimport {\n\tdecodeResourceSelection,\n\tdetectResourceFraming,\n\tencodeResourceSelectionWithFraming,\n\ttype ResourceFraming,\n} from \"../../../core/profile-resource-selection.ts\";\nimport type { ResourceProfileKind, ResourceProfileSettings } from \"../../../core/settings-manager.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyText } from \"./keybinding-hints.ts\";\n\nexport interface ProfileResourceItem {\n\tid: string;\n\tpath?: string;\n\tdescription?: string;\n}\n\nexport interface ProfileResourceEditorKind {\n\tkind: ResourceProfileKind; // \"tools\" | \"skills\" | \"extensions\" | \"agents\" | \"prompts\" | \"themes\"\n\tlabel: string; // display label, e.g. \"Tools\"\n\titems: ProfileResourceItem[]; // the available items of this kind\n}\n\nexport interface ProfileResourceEditorOptions {\n\tprofileName: string;\n\tprofileScope: string; // e.g. \"directory\" | \"project\" | \"global\" | \"session\" | \"reusable-file\"\n\tinitialResources: ResourceProfileSettings; // existing profile.resources; may be {}\n\tkinds: ProfileResourceEditorKind[]; // the six kinds, with their universes\n\tonSave: (resources: ResourceProfileSettings) => void; // called on ctrl+s with the encoded result\n\tonCancel: () => void; // called on esc\n\tonScopeChange?: () => void;\n\tonEdit?: (id: string, path: string, kind: ResourceProfileKind) => void;\n\tcwd?: string;\n\tagentDir?: string;\n\texternalResourceRoots?: string[];\n}\n\ninterface ResourceItem {\n\tid: string;\n\tenabled: boolean;\n\tpath?: string;\n\tdescription?: string;\n\tsourceLabel?: \"catalog\" | \"user\" | \"project\" | \"bundled\";\n\tisMissing?: boolean;\n}\n\nconst TOOL_DESCRIPTIONS: Record<string, string> = {\n\tread: \"Read files from the filesystem.\",\n\tbash: \"Execute arbitrary commands in the shell.\",\n\tedit: \"Edit files surgically.\",\n\twrite: \"Create new files or overwrite existing files.\",\n\tgrep: \"Search for text patterns using ripgrep.\",\n\tfind: \"Locate files matching a search query.\",\n\tls: \"List files and directories.\",\n\tskill_audit: \"Inspect and audit local skills.\",\n\tskillify: \"Convert a set of files/instructions into a skill.\",\n\textensionify: \"Package a tool or script as an extension.\",\n};\n\nexport function resolveResourceEditPath(\n\t_id: string,\n\tfilePath: string | undefined,\n\tkind: ResourceProfileKind,\n): string | undefined {\n\tif (kind === \"tools\") {\n\t\treturn undefined;\n\t}\n\n\tif (!filePath) {\n\t\treturn undefined;\n\t}\n\n\tif (kind === \"extensions\") {\n\t\ttry {\n\t\t\tconst stats = fs.statSync(filePath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tconst indexTs = path.join(filePath, \"index.ts\");\n\t\t\t\tif (fs.existsSync(indexTs)) {\n\t\t\t\t\treturn indexTs;\n\t\t\t\t}\n\t\t\t\tconst indexJs = path.join(filePath, \"index.js\");\n\t\t\t\tif (fs.existsSync(indexJs)) {\n\t\t\t\t\treturn indexJs;\n\t\t\t\t}\n\t\t\t\tconst pkgJsonPath = path.join(filePath, \"package.json\");\n\t\t\t\tif (fs.existsSync(pkgJsonPath)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf-8\"));\n\t\t\t\t\t\tif (typeof pkg.main === \"string\") {\n\t\t\t\t\t\t\tconst resolvedMain = path.resolve(filePath, pkg.main);\n\t\t\t\t\t\t\tif (fs.existsSync(resolvedMain)) {\n\t\t\t\t\t\t\t\treturn resolvedMain;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {}\n\t\t\t\t}\n\t\t\t\treturn indexTs;\n\t\t\t}\n\t\t} catch {}\n\t\treturn filePath;\n\t}\n\n\tif (kind === \"skills\") {\n\t\ttry {\n\t\t\tconst stats = fs.statSync(filePath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tconst skillMd = path.join(filePath, \"SKILL.md\");\n\t\t\t\tif (fs.existsSync(skillMd)) {\n\t\t\t\t\treturn skillMd;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t\treturn filePath;\n\t}\n\n\treturn filePath;\n}\n\nexport function classifyResourceSource(\n\tfilePath: string | undefined,\n\tcwd: string,\n\tagentDir: string,\n\texternalRoots: string[],\n): \"catalog\" | \"user\" | \"project\" | \"bundled\" {\n\tif (!filePath) {\n\t\treturn \"bundled\";\n\t}\n\n\tconst absolutePath = isAbsolute(filePath) ? filePath : resolve(cwd, filePath);\n\tconst normPath = resolve(absolutePath);\n\tconst normCwd = resolve(cwd);\n\tconst normAgentDir = agentDir ? resolve(agentDir) : \"\";\n\n\tfor (const extRoot of externalRoots) {\n\t\tconst normExt = resolve(extRoot);\n\t\tif (normPath.startsWith(normExt)) {\n\t\t\treturn \"catalog\";\n\t\t}\n\t}\n\n\tif (normAgentDir && normPath.startsWith(normAgentDir)) {\n\t\treturn \"user\";\n\t}\n\n\tif (normPath.startsWith(normCwd)) {\n\t\treturn \"project\";\n\t}\n\n\tif (normPath.includes(\"node_modules\")) {\n\t\treturn \"bundled\";\n\t}\n\n\treturn \"bundled\";\n}\n\nexport class ProfileResourceEditorComponent extends Container implements Focusable {\n\tprivate profileName: string;\n\tprivate profileScope: string;\n\tprivate kinds: ProfileResourceEditorKind[];\n\tprivate enabledByKind: Map<ResourceProfileKind, Set<string>> = new Map();\n\tprivate framingByKind: Map<ResourceProfileKind, ResourceFraming> = new Map();\n\tprivate missingIdsByKind: Map<ResourceProfileKind, Set<string>> = new Map();\n\tprivate currentKindIndex = 0;\n\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\tprivate externalResourceRoots: string[];\n\n\tprivate filteredItems: ResourceItem[] = [];\n\tprivate selectedIndex = 0;\n\tprivate searchInput: Input;\n\tprivate kindHeaderText: Text;\n\tprivate listContainer: Container;\n\tprivate descriptionText: Text;\n\tprivate footerText: Text;\n\tprivate isDirty = false;\n\tprivate maxVisible = 8;\n\n\tprivate _focused = false;\n\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\n\tprivate onSave: (resources: ResourceProfileSettings) => void;\n\tprivate onCancel: () => void;\n\tprivate onScopeChange?: () => void;\n\tprivate onEdit?: (id: string, path: string, kind: ResourceProfileKind) => void;\n\n\tconstructor(options: ProfileResourceEditorOptions) {\n\t\tsuper();\n\t\tthis.profileName = options.profileName;\n\t\tthis.profileScope = options.profileScope;\n\t\tthis.kinds = options.kinds;\n\t\tthis.onSave = options.onSave;\n\t\tthis.onCancel = options.onCancel;\n\t\tthis.onScopeChange = options.onScopeChange;\n\t\tthis.onEdit = options.onEdit;\n\t\tthis.cwd = options.cwd || process.cwd();\n\t\tthis.agentDir = options.agentDir || \"\";\n\t\tthis.externalResourceRoots = options.externalResourceRoots || [];\n\n\t\t// Initialize enabled, framing, and missing sets for each kind\n\t\tfor (const kind of this.kinds) {\n\t\t\tconst filter = options.initialResources[kind.kind];\n\t\t\tconst allIds = kind.items.map((item) => item.id);\n\t\t\tconst enabledSet = decodeResourceSelection(filter, allIds);\n\t\t\tthis.enabledByKind.set(kind.kind, enabledSet);\n\t\t\tthis.framingByKind.set(kind.kind, detectResourceFraming(filter));\n\n\t\t\t// Compute missing items\n\t\t\tconst mentionedIds = new Set<string>();\n\t\t\tif (filter) {\n\t\t\t\tif (filter.allow) {\n\t\t\t\t\tfor (const id of filter.allow) {\n\t\t\t\t\t\tmentionedIds.add(id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (filter.block) {\n\t\t\t\t\tfor (const id of filter.block) {\n\t\t\t\t\t\tif (id !== \"*\") {\n\t\t\t\t\t\t\tmentionedIds.add(id);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst availableIds = new Set(allIds);\n\t\t\tconst missingSet = new Set<string>();\n\t\t\tfor (const id of mentionedIds) {\n\t\t\t\tif (!availableIds.has(id)) {\n\t\t\t\t\tmissingSet.add(id);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.missingIdsByKind.set(kind.kind, missingSet);\n\t\t}\n\n\t\t// Header\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\"accent\", theme.bold(`Library — editing \"${this.profileName}\" (${this.profileScope})`)),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"muted\",\n\t\t\t\t\t`Navigate kinds: ${keyText(\"tui.input.tab\")}. Toggle: ${keyText(\"tui.select.confirm\")}. Mode: ${theme.fg(\"accent\", \"a\")} allow / ${theme.fg(\"accent\", \"b\")} block. Scope: ${theme.fg(\"accent\", \"s\")} change. Edit: ${theme.fg(\"accent\", \"e\")}.`,\n\t\t\t\t),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Kind selector header\n\t\tthis.kindHeaderText = new Text(this.getKindHeaderText(), 0, 0);\n\t\tthis.addChild(this.kindHeaderText);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Search input\n\t\tthis.searchInput = new Input();\n\t\tthis.addChild(this.searchInput);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// List container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\t// Description area\n\t\tthis.descriptionText = new Text(\"\", 0, 0);\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(this.descriptionText);\n\n\t\t// Footer hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.footerText = new Text(this.getFooterText(), 0, 0);\n\t\tthis.addChild(this.footerText);\n\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.refresh();\n\t}\n\n\tprivate getKindHeaderText(): string {\n\t\tconst kind = this.kinds[this.currentKindIndex]!;\n\t\tconst enabledSet = this.enabledByKind.get(kind.kind)!;\n\t\tconst framing = this.framingByKind.get(kind.kind)!;\n\t\tconst framingText = framing === \"allow\" ? \"allow-list\" : \"block-list\";\n\t\tconst countText = `${enabledSet.size}/${kind.items.length} enabled (${framingText})`;\n\t\tconst kindIndicator = this.kinds\n\t\t\t.map((k, i) => {\n\t\t\t\tconst marker = i === this.currentKindIndex ? \"●\" : \"○\";\n\t\t\t\treturn theme.fg(i === this.currentKindIndex ? \"accent\" : \"muted\", `${marker} ${k.label}`);\n\t\t\t})\n\t\t\t.join(\" \");\n\t\treturn `${kindIndicator} ${theme.fg(\"muted\", countText)}`;\n\t}\n\n\tprivate getCurrentKind(): ProfileResourceEditorKind {\n\t\treturn this.kinds[this.currentKindIndex]!;\n\t}\n\n\tprivate getCurrentEnabledSet(): Set<string> {\n\t\tconst kind = this.getCurrentKind();\n\t\treturn this.enabledByKind.get(kind.kind)!;\n\t}\n\n\tprivate buildItems(): ResourceItem[] {\n\t\tconst kind = this.getCurrentKind();\n\t\tconst enabledSet = this.getCurrentEnabledSet();\n\n\t\tconst items: ResourceItem[] = [];\n\n\t\t// Add all available items\n\t\tfor (const availableItem of kind.items) {\n\t\t\tconst isEnabled = enabledSet.has(availableItem.id);\n\t\t\tlet desc = availableItem.description;\n\t\t\tif (kind.kind === \"tools\" && !desc) {\n\t\t\t\tdesc = TOOL_DESCRIPTIONS[availableItem.id];\n\t\t\t}\n\t\t\titems.push({\n\t\t\t\tid: availableItem.id,\n\t\t\t\tenabled: isEnabled,\n\t\t\t\tpath: availableItem.path,\n\t\t\t\tdescription: desc,\n\t\t\t\tsourceLabel: classifyResourceSource(\n\t\t\t\t\tavailableItem.path,\n\t\t\t\t\tthis.cwd,\n\t\t\t\t\tthis.agentDir,\n\t\t\t\t\tthis.externalResourceRoots,\n\t\t\t\t),\n\t\t\t\tisMissing: false,\n\t\t\t});\n\t\t}\n\n\t\t// Add missing items\n\t\tconst missingSet = this.missingIdsByKind.get(kind.kind) || new Set<string>();\n\t\tfor (const missingId of missingSet) {\n\t\t\tconst isEnabled = enabledSet.has(missingId);\n\t\t\titems.push({\n\t\t\t\tid: missingId,\n\t\t\t\tenabled: isEnabled,\n\t\t\t\tisMissing: true,\n\t\t\t\tdescription: \"Referenced in profile but missing from available resources.\",\n\t\t\t});\n\t\t}\n\n\t\t// Sort: enabled first, then disabled\n\t\tconst enabled: ResourceItem[] = [];\n\t\tconst disabled: ResourceItem[] = [];\n\t\tfor (const item of items) {\n\t\t\tif (item.enabled) {\n\t\t\t\tenabled.push(item);\n\t\t\t} else {\n\t\t\t\tdisabled.push(item);\n\t\t\t}\n\t\t}\n\t\treturn [...enabled, ...disabled];\n\t}\n\n\tprivate getFooterText(): string {\n\t\tconst kind = this.getCurrentKind();\n\t\tconst enabledSet = this.getCurrentEnabledSet();\n\t\tconst countText = `${enabledSet.size}/${kind.items.length} enabled`;\n\t\tconst parts = [\n\t\t\t`${keyText(\"tui.select.confirm\")} toggle`,\n\t\t\t`${keyText(\"tui.input.tab\")} kind`,\n\t\t\t`${keyText(\"app.models.save\")} save`,\n\t\t\t`${theme.fg(\"accent\", \"e\")} edit`,\n\t\t\tcountText,\n\t\t];\n\t\treturn this.isDirty\n\t\t\t? theme.fg(\"dim\", ` ${parts.join(\" · \")} `) + theme.fg(\"warning\", \"(unsaved)\")\n\t\t\t: theme.fg(\"dim\", ` ${parts.join(\" · \")}`);\n\t}\n\n\tprivate refresh(): void {\n\t\tconst query = this.searchInput.getValue();\n\t\tconst items = this.buildItems();\n\t\tthis.filteredItems = query ? fuzzyFilter(items, query, (i) => `${i.id} ${i.description ?? \"\"}`) : items;\n\t\tthis.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredItems.length - 1));\n\t\tthis.updateList();\n\t\tthis.footerText.setText(this.getFooterText());\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tconst kind = this.getCurrentKind();\n\t\tconst missingSet = this.missingIdsByKind.get(kind.kind) || new Set<string>();\n\t\tconst totalAvailableCount = kind.items.length + missingSet.size;\n\n\t\tif (totalAvailableCount === 0) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", \" (none available — add a Source or install resources)\"), 0, 0),\n\t\t\t);\n\t\t\tthis.descriptionText.setText(theme.fg(\"muted\", \" No description available\"));\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.filteredItems.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No matching resources\"), 0, 0));\n\t\t\tthis.descriptionText.setText(theme.fg(\"muted\", \" No description available\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.filteredItems[i]!;\n\t\t\tconst isSelected = i === this.selectedIndex;\n\t\t\tconst prefix = isSelected ? theme.fg(\"accent\", \"→ \") : \" \";\n\t\t\tlet resourceText = isSelected ? theme.fg(\"accent\", item.id) : item.id;\n\n\t\t\tif (item.isMissing) {\n\t\t\t\tresourceText = theme.fg(\"muted\", `${item.id} [missing]`);\n\t\t\t} else if (item.sourceLabel) {\n\t\t\t\tconst labelColor =\n\t\t\t\t\titem.sourceLabel === \"catalog\"\n\t\t\t\t\t\t? \"thinkingText\"\n\t\t\t\t\t\t: item.sourceLabel === \"project\"\n\t\t\t\t\t\t\t? \"success\"\n\t\t\t\t\t\t\t: item.sourceLabel === \"user\"\n\t\t\t\t\t\t\t\t? \"warning\"\n\t\t\t\t\t\t\t\t: \"muted\";\n\t\t\t\tconst labelText = theme.fg(labelColor, ` [${item.sourceLabel}]`);\n\t\t\t\tresourceText = `${resourceText}${labelText}`;\n\t\t\t}\n\n\t\t\tconst status = item.enabled ? theme.fg(\"success\", \" ✓\") : theme.fg(\"dim\", \" ✗\");\n\t\t\tthis.listContainer.addChild(new Text(`${prefix}${resourceText}${status}`, 0, 0));\n\t\t}\n\n\t\t// Add scroll indicator if needed\n\t\tif (startIndex > 0 || endIndex < this.filteredItems.length) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${this.filteredItems.length})`), 0, 0),\n\t\t\t);\n\t\t}\n\n\t\t// Update description area for current selection\n\t\tconst selectedItem = this.filteredItems[this.selectedIndex];\n\t\tif (selectedItem?.description) {\n\t\t\tthis.descriptionText.setText(theme.fg(\"muted\", ` Description: ${selectedItem.description}`));\n\t\t} else {\n\t\t\tthis.descriptionText.setText(theme.fg(\"muted\", \" No description available\"));\n\t\t}\n\t}\n\n\thandleInput(data: string): void {\n\t\tconst kb = getKeybindings();\n\n\t\t// Navigation within list\n\t\tif (kb.matches(data, \"tui.select.up\")) {\n\t\t\tif (this.filteredItems.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === 0 ? this.filteredItems.length - 1 : this.selectedIndex - 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.down\")) {\n\t\t\tif (this.filteredItems.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === this.filteredItems.length - 1 ? 0 : this.selectedIndex + 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\t// Switch kind with Tab (cycles forward)\n\t\tif (kb.matches(data, \"tui.input.tab\")) {\n\t\t\tthis.currentKindIndex = (this.currentKindIndex + 1) % this.kinds.length;\n\t\t\tthis.selectedIndex = 0;\n\t\t\tthis.searchInput.setValue(\"\");\n\t\t\tthis.kindHeaderText.setText(this.getKindHeaderText());\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\n\t\t// Switch framing: Allow-list\n\t\tif (matchesKey(data, Key.ctrl(\"a\")) || (this.searchInput.getValue() === \"\" && data === \"a\")) {\n\t\t\tthis.framingByKind.set(this.getCurrentKind().kind, \"allow\");\n\t\t\tthis.isDirty = true;\n\t\t\tthis.kindHeaderText.setText(this.getKindHeaderText());\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\n\t\t// Switch framing: Block-list\n\t\tif (matchesKey(data, Key.ctrl(\"b\")) || (this.searchInput.getValue() === \"\" && data === \"b\")) {\n\t\t\tthis.framingByKind.set(this.getCurrentKind().kind, \"block\");\n\t\t\tthis.isDirty = true;\n\t\t\tthis.kindHeaderText.setText(this.getKindHeaderText());\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\n\t\t// Edit highlighted resource\n\t\tif (data === \"e\" && this.searchInput.getValue() === \"\") {\n\t\t\tconst item = this.filteredItems[this.selectedIndex];\n\t\t\tif (item && !item.isMissing && item.path) {\n\t\t\t\tconst kind = this.getCurrentKind().kind;\n\t\t\t\tif (this.onEdit) {\n\t\t\t\t\tthis.onEdit(item.id, item.path, kind);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Switch scope: Scope selector\n\t\tif (matchesKey(data, Key.ctrl(\"o\")) || (this.searchInput.getValue() === \"\" && data === \"s\")) {\n\t\t\tif (this.onScopeChange) {\n\t\t\t\tthis.onScopeChange();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Toggle on space/enter\n\t\tif (kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tconst item = this.filteredItems[this.selectedIndex];\n\t\t\tif (item) {\n\t\t\t\tconst enabledSet = this.getCurrentEnabledSet();\n\t\t\t\tif (enabledSet.has(item.id)) {\n\t\t\t\t\tenabledSet.delete(item.id);\n\t\t\t\t} else {\n\t\t\t\t\tenabledSet.add(item.id);\n\t\t\t\t}\n\t\t\t\tthis.isDirty = true;\n\t\t\t\tthis.refresh();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Save/persist to settings\n\t\tif (kb.matches(data, \"app.models.save\")) {\n\t\t\tthis.persistChanges();\n\t\t\treturn;\n\t\t}\n\n\t\t// Ctrl+C - clear search or cancel if empty\n\t\tif (matchesKey(data, Key.ctrl(\"c\"))) {\n\t\t\tif (this.searchInput.getValue()) {\n\t\t\t\tthis.searchInput.setValue(\"\");\n\t\t\t\tthis.refresh();\n\t\t\t} else {\n\t\t\t\tthis.onCancel();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Escape - cancel\n\t\tif (matchesKey(data, Key.escape)) {\n\t\t\tthis.onCancel();\n\t\t\treturn;\n\t\t}\n\n\t\t// Pass everything else to search input\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.refresh();\n\t}\n\n\tprivate persistChanges(): void {\n\t\tconst resources: ResourceProfileSettings = {};\n\t\tfor (const kind of this.kinds) {\n\t\t\tconst enabledSet = this.enabledByKind.get(kind.kind)!;\n\t\t\tconst framing = this.framingByKind.get(kind.kind)!;\n\t\t\tconst allIds = kind.items.map((item) => item.id);\n\t\t\tconst encoded = encodeResourceSelectionWithFraming(enabledSet, allIds, framing);\n\t\t\tif (encoded !== undefined) {\n\t\t\t\tresources[kind.kind] = encoded;\n\t\t\t}\n\t\t}\n\t\tthis.onSave(resources);\n\t\tthis.isDirty = false;\n\t\tthis.footerText.setText(this.getFooterText());\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
@@ -75,13 +75,7 @@ export interface SettingsCallbacks {
75
75
  onSelfModificationChange: (settings: SelfModificationSettings, scope: SettingsScope) => void;
76
76
  onAutonomyChange: (settings: AutonomySettings, scope: SettingsScope) => void;
77
77
  onAutoLearnChange: (settings: AutoLearnSettings, scope: SettingsScope) => void;
78
- onProfileChange?: (profileName: string) => void;
79
- onProfileCreate?: () => void;
80
- onProfileEdit?: (profileName: string) => void;
81
- onProfilePersistActive?: (scope: "session" | "directory" | "project" | "global") => void;
82
- onProfileDelete?: (profileName: string) => void;
83
- onAddExternalResourceRoot?: () => void;
84
- onRemoveExternalResourceRoot?: (root: string) => void;
78
+ onResourcesHubAction?: (action: string) => void;
85
79
  onCancel: () => void;
86
80
  }
87
81
  export declare class SelectSubmenu extends Container {