@selesai/code 0.3.8 → 0.3.10
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/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +4 -2
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -25
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session.d.ts +22 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +130 -49
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -5
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cache-stats.d.ts +49 -0
- package/dist/core/cache-stats.d.ts.map +1 -0
- package/dist/core/cache-stats.js +101 -0
- package/dist/core/cache-stats.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +1 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +56 -81
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +38 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +41 -12
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +28 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -6
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +34 -8
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +10 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +15 -18
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +4 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +68 -26
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js +0 -10
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -2
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +8 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +21 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +104 -72
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +14 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +29 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -3
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +20 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +12 -25
- package/dist/core/tools/read.js.map +1 -1
- package/dist/extensions/pi-subagents/agents/builder.md +1 -1
- package/dist/extensions/workflow/adapter.ts +58 -12
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +23 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +34 -3
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +280 -25
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +12 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +17 -6
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +25 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -2
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +19 -6
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +21 -10
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +417 -196
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +3 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +21 -6
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +17 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +20 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +2 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +71 -17
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +41 -0
- package/dist/utils/mime.js.map +1 -1
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/config-selector.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * TUI component for managing package resources (enable/disable)\n */\n\nimport { homedir } from \"node:os\";\nimport { basename, dirname, join, relative } from \"node:path\";\nimport {\n\ttype Component,\n\tContainer,\n\ttype Focusable,\n\tgetKeybindings,\n\tInput,\n\tmatchesKey,\n\tSpacer,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@earendil-works/pi-tui\";\nimport { CONFIG_DIR_NAME } from \"../../../config.ts\";\nimport type { PathMetadata, ResolvedPaths, ResolvedResource } from \"../../../core/package-manager.ts\";\nimport type { PackageSource, SettingsManager } from \"../../../core/settings-manager.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { rawKeyHint } from \"./keybinding-hints.ts\";\n\ntype ResourceType = \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\n\nconst RESOURCE_TYPE_LABELS: Record<ResourceType, string> = {\n\textensions: \"Extensions\",\n\tskills: \"Skills\",\n\tprompts: \"Prompts\",\n\tthemes: \"Themes\",\n};\n\ninterface ResourceItem {\n\tpath: string;\n\tenabled: boolean;\n\tmetadata: PathMetadata;\n\tresourceType: ResourceType;\n\tdisplayName: string;\n\tgroupKey: string;\n\tsubgroupKey: string;\n}\n\ninterface ResourceSubgroup {\n\ttype: ResourceType;\n\tlabel: string;\n\titems: ResourceItem[];\n}\n\ninterface ResourceGroup {\n\tkey: string;\n\tlabel: string;\n\tscope: \"user\" | \"project\" | \"temporary\";\n\torigin: \"package\" | \"top-level\";\n\tsource: string;\n\tsubgroups: ResourceSubgroup[];\n}\n\nfunction formatBaseDir(baseDir: string): string {\n\tconst homeDir = homedir();\n\tlet displayPath: string;\n\n\tif (baseDir === homeDir) {\n\t\tdisplayPath = \"~\";\n\t} else if (baseDir.startsWith(homeDir)) {\n\t\t// Replace home prefix with ~, normalize separators for display\n\t\tconst rest = baseDir.slice(homeDir.length);\n\t\tdisplayPath = `~${rest.replace(/\\\\/g, \"/\")}`;\n\t} else {\n\t\tdisplayPath = baseDir.replace(/\\\\/g, \"/\");\n\t}\n\n\treturn displayPath.endsWith(\"/\") ? displayPath : `${displayPath}/`;\n}\n\nfunction getGroupLabel(metadata: PathMetadata, agentDir: string): string {\n\tif (metadata.origin === \"package\") {\n\t\treturn `${metadata.source} (${metadata.scope})`;\n\t}\n\t// Top-level resources\n\tif (metadata.source === \"auto\") {\n\t\tif (metadata.baseDir) {\n\t\t\treturn metadata.scope === \"user\"\n\t\t\t\t? `User (${formatBaseDir(metadata.baseDir)})`\n\t\t\t\t: `Project (${formatBaseDir(metadata.baseDir)})`;\n\t\t}\n\t\treturn metadata.scope === \"user\" ? `User (${formatBaseDir(agentDir)})` : `Project (${CONFIG_DIR_NAME}/)`;\n\t}\n\treturn metadata.scope === \"user\" ? \"User settings\" : \"Project settings\";\n}\n\nfunction buildGroups(resolved: ResolvedPaths, agentDir: string): ResourceGroup[] {\n\tconst groupMap = new Map<string, ResourceGroup>();\n\n\tconst addToGroup = (resources: ResolvedResource[], resourceType: ResourceType) => {\n\t\tfor (const res of resources) {\n\t\t\tconst { path, enabled, metadata } = res;\n\t\t\tconst groupKey = `${metadata.origin}:${metadata.scope}:${metadata.source}:${metadata.baseDir ?? \"\"}`;\n\n\t\t\tif (!groupMap.has(groupKey)) {\n\t\t\t\tgroupMap.set(groupKey, {\n\t\t\t\t\tkey: groupKey,\n\t\t\t\t\tlabel: getGroupLabel(metadata, agentDir),\n\t\t\t\t\tscope: metadata.scope,\n\t\t\t\t\torigin: metadata.origin,\n\t\t\t\t\tsource: metadata.source,\n\t\t\t\t\tsubgroups: [],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst group = groupMap.get(groupKey)!;\n\t\t\tconst subgroupKey = `${groupKey}:${resourceType}`;\n\n\t\t\tlet subgroup = group.subgroups.find((sg) => sg.type === resourceType);\n\t\t\tif (!subgroup) {\n\t\t\t\tsubgroup = {\n\t\t\t\t\ttype: resourceType,\n\t\t\t\t\tlabel: RESOURCE_TYPE_LABELS[resourceType],\n\t\t\t\t\titems: [],\n\t\t\t\t};\n\t\t\t\tgroup.subgroups.push(subgroup);\n\t\t\t}\n\n\t\t\tconst fileName = basename(path);\n\t\t\tconst parentFolder = basename(dirname(path));\n\t\t\tlet displayName: string;\n\t\t\tif (resourceType === \"extensions\" && parentFolder !== \"extensions\") {\n\t\t\t\tdisplayName = `${parentFolder}/${fileName}`;\n\t\t\t} else if (resourceType === \"skills\" && fileName === \"SKILL.md\") {\n\t\t\t\tdisplayName = parentFolder;\n\t\t\t} else {\n\t\t\t\tdisplayName = fileName;\n\t\t\t}\n\t\t\tsubgroup.items.push({\n\t\t\t\tpath,\n\t\t\t\tenabled,\n\t\t\t\tmetadata,\n\t\t\t\tresourceType,\n\t\t\t\tdisplayName,\n\t\t\t\tgroupKey,\n\t\t\t\tsubgroupKey,\n\t\t\t});\n\t\t}\n\t};\n\n\taddToGroup(resolved.extensions, \"extensions\");\n\taddToGroup(resolved.skills, \"skills\");\n\taddToGroup(resolved.prompts, \"prompts\");\n\taddToGroup(resolved.themes, \"themes\");\n\n\t// Sort groups: packages first, then top-level; user before project\n\tconst groups = Array.from(groupMap.values());\n\tgroups.sort((a, b) => {\n\t\tif (a.origin !== b.origin) {\n\t\t\treturn a.origin === \"package\" ? -1 : 1;\n\t\t}\n\t\tif (a.scope !== b.scope) {\n\t\t\treturn a.scope === \"user\" ? -1 : 1;\n\t\t}\n\t\treturn a.source.localeCompare(b.source);\n\t});\n\n\t// Sort subgroups within each group by type order, and items by name\n\tconst typeOrder: Record<ResourceType, number> = { extensions: 0, skills: 1, prompts: 2, themes: 3 };\n\tfor (const group of groups) {\n\t\tgroup.subgroups.sort((a, b) => typeOrder[a.type] - typeOrder[b.type]);\n\t\tfor (const subgroup of group.subgroups) {\n\t\t\tsubgroup.items.sort((a, b) => a.displayName.localeCompare(b.displayName));\n\t\t}\n\t}\n\n\treturn groups;\n}\n\ntype FlatEntry =\n\t| { type: \"group\"; group: ResourceGroup }\n\t| { type: \"subgroup\"; subgroup: ResourceSubgroup; group: ResourceGroup }\n\t| { type: \"item\"; item: ResourceItem };\n\nclass ConfigSelectorHeader implements Component {\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst title = theme.bold(\"Resource Configuration\");\n\t\tconst sep = theme.fg(\"muted\", \" · \");\n\t\tconst hint = rawKeyHint(\"space\", \"toggle\") + sep + rawKeyHint(\"esc\", \"close\");\n\t\tconst hintWidth = visibleWidth(hint);\n\t\tconst titleWidth = visibleWidth(title);\n\t\tconst spacing = Math.max(1, width - titleWidth - hintWidth);\n\n\t\treturn [\n\t\t\ttruncateToWidth(`${title}${\" \".repeat(spacing)}${hint}`, width, \"\"),\n\t\t\ttheme.fg(\"muted\", \"Type to filter resources\"),\n\t\t];\n\t}\n}\n\nclass ResourceList implements Component, Focusable {\n\tprivate groups: ResourceGroup[];\n\tprivate flatItems: FlatEntry[] = [];\n\tprivate filteredItems: FlatEntry[] = [];\n\tprivate selectedIndex = 0;\n\tprivate searchInput: Input;\n\tprivate maxVisible: number;\n\tprivate settingsManager: SettingsManager;\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\n\tpublic onCancel?: () => void;\n\tpublic onExit?: () => void;\n\tpublic onToggle?: (item: ResourceItem, newEnabled: boolean) => void;\n\n\tprivate _focused = false;\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\tconstructor(\n\t\tgroups: ResourceGroup[],\n\t\tsettingsManager: SettingsManager,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tterminalHeight?: number,\n\t) {\n\t\tthis.groups = groups;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.cwd = cwd;\n\t\tthis.agentDir = agentDir;\n\t\tthis.searchInput = new Input();\n\t\t// 8 lines of chrome: top spacer + top border + spacer + header (2 lines) + spacer + bottom spacer + bottom border\n\t\tconst chrome = 8;\n\t\tthis.maxVisible = Math.max(5, (terminalHeight ?? 24) - chrome);\n\t\tthis.buildFlatList();\n\t\tthis.filteredItems = [...this.flatItems];\n\t}\n\n\tprivate buildFlatList(): void {\n\t\tthis.flatItems = [];\n\t\tfor (const group of this.groups) {\n\t\t\tthis.flatItems.push({ type: \"group\", group });\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tthis.flatItems.push({ type: \"subgroup\", subgroup, group });\n\t\t\t\tfor (const item of subgroup.items) {\n\t\t\t\t\tthis.flatItems.push({ type: \"item\", item });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Start selection on first item (not header)\n\t\tthis.selectedIndex = this.flatItems.findIndex((e) => e.type === \"item\");\n\t\tif (this.selectedIndex < 0) this.selectedIndex = 0;\n\t}\n\n\tprivate findNextItem(fromIndex: number, direction: 1 | -1): number {\n\t\tlet idx = fromIndex + direction;\n\t\twhile (idx >= 0 && idx < this.filteredItems.length) {\n\t\t\tif (this.filteredItems[idx].type === \"item\") {\n\t\t\t\treturn idx;\n\t\t\t}\n\t\t\tidx += direction;\n\t\t}\n\t\treturn fromIndex; // Stay at current if no item found\n\t}\n\n\tprivate filterItems(query: string): void {\n\t\tif (!query.trim()) {\n\t\t\tthis.filteredItems = [...this.flatItems];\n\t\t\tthis.selectFirstItem();\n\t\t\treturn;\n\t\t}\n\n\t\tconst lowerQuery = query.toLowerCase();\n\t\tconst matchingItems = new Set<ResourceItem>();\n\t\tconst matchingSubgroups = new Set<ResourceSubgroup>();\n\t\tconst matchingGroups = new Set<ResourceGroup>();\n\n\t\tfor (const entry of this.flatItems) {\n\t\t\tif (entry.type === \"item\") {\n\t\t\t\tconst item = entry.item;\n\t\t\t\tif (\n\t\t\t\t\titem.displayName.toLowerCase().includes(lowerQuery) ||\n\t\t\t\t\titem.resourceType.toLowerCase().includes(lowerQuery) ||\n\t\t\t\t\titem.path.toLowerCase().includes(lowerQuery)\n\t\t\t\t) {\n\t\t\t\t\tmatchingItems.add(item);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Find which subgroups and groups contain matching items\n\t\tfor (const group of this.groups) {\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tfor (const item of subgroup.items) {\n\t\t\t\t\tif (matchingItems.has(item)) {\n\t\t\t\t\t\tmatchingSubgroups.add(subgroup);\n\t\t\t\t\t\tmatchingGroups.add(group);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.filteredItems = [];\n\t\tfor (const entry of this.flatItems) {\n\t\t\tif (entry.type === \"group\" && matchingGroups.has(entry.group)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t} else if (entry.type === \"subgroup\" && matchingSubgroups.has(entry.subgroup)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t} else if (entry.type === \"item\" && matchingItems.has(entry.item)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t}\n\t\t}\n\n\t\tthis.selectFirstItem();\n\t}\n\n\tprivate selectFirstItem(): void {\n\t\tconst firstItemIndex = this.filteredItems.findIndex((e) => e.type === \"item\");\n\t\tthis.selectedIndex = firstItemIndex >= 0 ? firstItemIndex : 0;\n\t}\n\n\tupdateItem(item: ResourceItem, enabled: boolean): void {\n\t\titem.enabled = enabled;\n\t\t// Update in groups too\n\t\tfor (const group of this.groups) {\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tconst found = subgroup.items.find((i) => i.path === item.path && i.resourceType === item.resourceType);\n\t\t\t\tif (found) {\n\t\t\t\t\tfound.enabled = enabled;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\n\t\t// Search input\n\t\tlines.push(...this.searchInput.render(width));\n\t\tlines.push(\"\");\n\n\t\tif (this.filteredItems.length === 0) {\n\t\t\tlines.push(theme.fg(\"muted\", \" No resources found\"));\n\t\t\treturn lines;\n\t\t}\n\n\t\t// Calculate visible range\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 entry = this.filteredItems[i];\n\t\t\tconst isSelected = i === this.selectedIndex;\n\n\t\t\tif (entry.type === \"group\") {\n\t\t\t\t// Main group header (no cursor)\n\t\t\t\tconst groupLine = theme.fg(\"accent\", theme.bold(entry.group.label));\n\t\t\t\tlines.push(truncateToWidth(` ${groupLine}`, width, \"\"));\n\t\t\t} else if (entry.type === \"subgroup\") {\n\t\t\t\t// Subgroup header (indented, no cursor)\n\t\t\t\tconst subgroupLine = theme.fg(\"muted\", entry.subgroup.label);\n\t\t\t\tlines.push(truncateToWidth(` ${subgroupLine}`, width, \"\"));\n\t\t\t} else {\n\t\t\t\t// Resource item (cursor only on items)\n\t\t\t\tconst item = entry.item;\n\t\t\t\tconst cursor = isSelected ? \"> \" : \" \";\n\t\t\t\tconst checkbox = item.enabled ? theme.fg(\"success\", \"[x]\") : theme.fg(\"dim\", \"[ ]\");\n\t\t\t\tconst name = isSelected ? theme.bold(item.displayName) : item.displayName;\n\t\t\t\tlines.push(truncateToWidth(`${cursor} ${checkbox} ${name}`, width, \"...\"));\n\t\t\t}\n\t\t}\n\n\t\t// Scroll indicator\n\t\tif (startIndex > 0 || endIndex < this.filteredItems.length) {\n\t\t\tconst itemCount = this.filteredItems.filter((e) => e.type === \"item\").length;\n\t\t\tconst currentItemIndex =\n\t\t\t\tthis.filteredItems.slice(0, this.selectedIndex).filter((e) => e.type === \"item\").length + 1;\n\t\t\tlines.push(theme.fg(\"dim\", ` (${currentItemIndex}/${itemCount})`));\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\thandleInput(data: string): void {\n\t\tconst kb = getKeybindings();\n\n\t\tif (kb.matches(data, \"tui.select.up\")) {\n\t\t\tthis.selectedIndex = this.findNextItem(this.selectedIndex, -1);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.selectedIndex = this.findNextItem(this.selectedIndex, 1);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.pageUp\")) {\n\t\t\t// Jump up by maxVisible, then find nearest item\n\t\t\tlet target = Math.max(0, this.selectedIndex - this.maxVisible);\n\t\t\twhile (target < this.filteredItems.length && this.filteredItems[target].type !== \"item\") {\n\t\t\t\ttarget++;\n\t\t\t}\n\t\t\tif (target < this.filteredItems.length) {\n\t\t\t\tthis.selectedIndex = target;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.pageDown\")) {\n\t\t\t// Jump down by maxVisible, then find nearest item\n\t\t\tlet target = Math.min(this.filteredItems.length - 1, this.selectedIndex + this.maxVisible);\n\t\t\twhile (target >= 0 && this.filteredItems[target].type !== \"item\") {\n\t\t\t\ttarget--;\n\t\t\t}\n\t\t\tif (target >= 0) {\n\t\t\t\tthis.selectedIndex = target;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.onCancel?.();\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"ctrl+c\")) {\n\t\t\tthis.onExit?.();\n\t\t\treturn;\n\t\t}\n\t\tif (data === \" \" || kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tconst entry = this.filteredItems[this.selectedIndex];\n\t\t\tif (entry?.type === \"item\") {\n\t\t\t\tconst newEnabled = !entry.item.enabled;\n\t\t\t\tthis.toggleResource(entry.item, newEnabled);\n\t\t\t\tthis.updateItem(entry.item, newEnabled);\n\t\t\t\tthis.onToggle?.(entry.item, newEnabled);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Pass to search input\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.filterItems(this.searchInput.getValue());\n\t}\n\n\tprivate toggleResource(item: ResourceItem, enabled: boolean): void {\n\t\tif (item.metadata.origin === \"top-level\") {\n\t\t\tthis.toggleTopLevelResource(item, enabled);\n\t\t} else {\n\t\t\tthis.togglePackageResource(item, enabled);\n\t\t}\n\t}\n\n\tprivate toggleTopLevelResource(item: ResourceItem, enabled: boolean): void {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst settings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\n\t\tconst arrayKey = item.resourceType as \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\n\t\tconst current = (settings[arrayKey] ?? []) as string[];\n\n\t\t// Generate pattern for this resource\n\t\tconst pattern = this.getResourcePattern(item);\n\t\tconst disablePattern = `-${pattern}`;\n\t\tconst enablePattern = `+${pattern}`;\n\n\t\t// Filter out existing patterns for this resource\n\t\tconst updated = current.filter((p) => {\n\t\t\tconst stripped = p.startsWith(\"!\") || p.startsWith(\"+\") || p.startsWith(\"-\") ? p.slice(1) : p;\n\t\t\treturn stripped !== pattern;\n\t\t});\n\n\t\tif (enabled) {\n\t\t\tupdated.push(enablePattern);\n\t\t} else {\n\t\t\tupdated.push(disablePattern);\n\t\t}\n\n\t\tif (scope === \"project\") {\n\t\t\tif (arrayKey === \"extensions\") {\n\t\t\t\tthis.settingsManager.setProjectExtensionPaths(updated);\n\t\t\t} else if (arrayKey === \"skills\") {\n\t\t\t\tthis.settingsManager.setProjectSkillPaths(updated);\n\t\t\t} else if (arrayKey === \"prompts\") {\n\t\t\t\tthis.settingsManager.setProjectPromptTemplatePaths(updated);\n\t\t\t} else if (arrayKey === \"themes\") {\n\t\t\t\tthis.settingsManager.setProjectThemePaths(updated);\n\t\t\t}\n\t\t} else {\n\t\t\tif (arrayKey === \"extensions\") {\n\t\t\t\tthis.settingsManager.setExtensionPaths(updated);\n\t\t\t} else if (arrayKey === \"skills\") {\n\t\t\t\tthis.settingsManager.setSkillPaths(updated);\n\t\t\t} else if (arrayKey === \"prompts\") {\n\t\t\t\tthis.settingsManager.setPromptTemplatePaths(updated);\n\t\t\t} else if (arrayKey === \"themes\") {\n\t\t\t\tthis.settingsManager.setThemePaths(updated);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate togglePackageResource(item: ResourceItem, enabled: boolean): void {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst settings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\n\t\tconst packages = [...(settings.packages ?? [])] as PackageSource[];\n\t\tconst pkgIndex = packages.findIndex((pkg) => {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\treturn source === item.metadata.source;\n\t\t});\n\n\t\tif (pkgIndex === -1) return;\n\n\t\tlet pkg = packages[pkgIndex];\n\n\t\t// Convert string to object form if needed\n\t\tif (typeof pkg === \"string\") {\n\t\t\tpkg = { source: pkg };\n\t\t\tpackages[pkgIndex] = pkg;\n\t\t}\n\n\t\t// Get the resource array for this type\n\t\tconst arrayKey = item.resourceType as \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\n\t\tconst current = (pkg[arrayKey] ?? []) as string[];\n\n\t\t// Generate pattern relative to package root\n\t\tconst pattern = this.getPackageResourcePattern(item);\n\t\tconst disablePattern = `-${pattern}`;\n\t\tconst enablePattern = `+${pattern}`;\n\n\t\t// Filter out existing patterns for this resource\n\t\tconst updated = current.filter((p) => {\n\t\t\tconst stripped = p.startsWith(\"!\") || p.startsWith(\"+\") || p.startsWith(\"-\") ? p.slice(1) : p;\n\t\t\treturn stripped !== pattern;\n\t\t});\n\n\t\tif (enabled) {\n\t\t\tupdated.push(enablePattern);\n\t\t} else {\n\t\t\tupdated.push(disablePattern);\n\t\t}\n\n\t\t(pkg as Record<string, unknown>)[arrayKey] = updated.length > 0 ? updated : undefined;\n\n\t\t// Clean up empty filter object\n\t\tconst hasFilters = [\"extensions\", \"skills\", \"prompts\", \"themes\"].some(\n\t\t\t(k) => (pkg as Record<string, unknown>)[k] !== undefined,\n\t\t);\n\t\tif (!hasFilters) {\n\t\t\tpackages[pkgIndex] = (pkg as { source: string }).source;\n\t\t}\n\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(packages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(packages);\n\t\t}\n\t}\n\n\tprivate getTopLevelBaseDir(scope: \"user\" | \"project\"): string {\n\t\treturn scope === \"project\" ? join(this.cwd, CONFIG_DIR_NAME) : this.agentDir;\n\t}\n\n\tprivate getResourcePattern(item: ResourceItem): string {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst baseDir = item.metadata.baseDir ?? this.getTopLevelBaseDir(scope);\n\t\treturn relative(baseDir, item.path);\n\t}\n\n\tprivate getPackageResourcePattern(item: ResourceItem): string {\n\t\tconst baseDir = item.metadata.baseDir ?? dirname(item.path);\n\t\treturn relative(baseDir, item.path);\n\t}\n}\n\nexport class ConfigSelectorComponent extends Container implements Focusable {\n\tprivate resourceList: ResourceList;\n\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.resourceList.focused = value;\n\t}\n\n\tconstructor(\n\t\tresolvedPaths: ResolvedPaths,\n\t\tsettingsManager: SettingsManager,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tonClose: () => void,\n\t\tonExit: () => void,\n\t\trequestRender: () => void,\n\t\tterminalHeight?: number,\n\t) {\n\t\tsuper();\n\n\t\tconst groups = buildGroups(resolvedPaths, agentDir);\n\n\t\t// Add header\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new ConfigSelectorHeader());\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Resource list\n\t\tthis.resourceList = new ResourceList(groups, settingsManager, cwd, agentDir, terminalHeight);\n\t\tthis.resourceList.onCancel = onClose;\n\t\tthis.resourceList.onExit = onExit;\n\t\tthis.resourceList.onToggle = () => requestRender();\n\t\tthis.addChild(this.resourceList);\n\n\t\t// Bottom border\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tgetResourceList(): ResourceList {\n\t\treturn this.resourceList;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/config-selector.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * TUI component for managing package resources (enable/disable)\n */\n\nimport { homedir } from \"node:os\";\nimport { basename, dirname, join, relative } from \"node:path\";\nimport {\n\ttype Component,\n\tContainer,\n\ttype Focusable,\n\tgetKeybindings,\n\tInput,\n\tmatchesKey,\n\tSpacer,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@earendil-works/pi-tui\";\nimport { CONFIG_DIR_NAME } from \"../../../config.ts\";\nimport type { PathMetadata, ResolvedPaths, ResolvedResource } from \"../../../core/package-manager.ts\";\nimport type { PackageSource, SettingsManager } from \"../../../core/settings-manager.ts\";\nimport { canonicalizePath, isLocalPath, resolvePath } from \"../../../utils/paths.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint, rawKeyHint } from \"./keybinding-hints.ts\";\n\ntype ResourceType = \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\ntype ConfigWriteScope = \"global\" | \"project\";\ntype SettingsScope = \"user\" | \"project\";\ntype ProjectOverrideState = \"inherit\" | \"load\" | \"unload\";\nexport type ScopedResolvedPaths = Record<ConfigWriteScope, ResolvedPaths>;\n\nconst RESOURCE_TYPES = [\"extensions\", \"skills\", \"prompts\", \"themes\"] as const satisfies readonly ResourceType[];\n\nconst RESOURCE_TYPE_LABELS: Record<ResourceType, string> = {\n\textensions: \"Extensions\",\n\tskills: \"Skills\",\n\tprompts: \"Prompts\",\n\tthemes: \"Themes\",\n};\n\ninterface ResourceItem {\n\tpath: string;\n\tenabled: boolean;\n\tmetadata: PathMetadata;\n\tresourceType: ResourceType;\n\tdisplayName: string;\n\tgroupKey: string;\n\tsubgroupKey: string;\n}\n\ninterface ResourceSubgroup {\n\ttype: ResourceType;\n\tlabel: string;\n\titems: ResourceItem[];\n}\n\ninterface ResourceGroup {\n\tkey: string;\n\tlabel: string;\n\tscope: \"user\" | \"project\" | \"temporary\";\n\torigin: \"package\" | \"top-level\";\n\tsource: string;\n\tsubgroups: ResourceSubgroup[];\n}\n\nfunction formatBaseDir(baseDir: string): string {\n\tconst homeDir = homedir();\n\tlet displayPath: string;\n\n\tif (baseDir === homeDir) {\n\t\tdisplayPath = \"~\";\n\t} else if (baseDir.startsWith(homeDir)) {\n\t\t// Replace home prefix with ~, normalize separators for display\n\t\tconst rest = baseDir.slice(homeDir.length);\n\t\tdisplayPath = `~${rest.replace(/\\\\/g, \"/\")}`;\n\t} else {\n\t\tdisplayPath = baseDir.replace(/\\\\/g, \"/\");\n\t}\n\n\treturn displayPath.endsWith(\"/\") ? displayPath : `${displayPath}/`;\n}\n\nfunction getGroupLabel(metadata: PathMetadata, agentDir: string): string {\n\tif (metadata.origin === \"package\") {\n\t\treturn `${metadata.source} (${metadata.scope})`;\n\t}\n\t// Top-level resources\n\tif (metadata.source === \"auto\") {\n\t\tif (metadata.baseDir) {\n\t\t\treturn metadata.scope === \"user\"\n\t\t\t\t? `User (${formatBaseDir(metadata.baseDir)})`\n\t\t\t\t: `Project (${formatBaseDir(metadata.baseDir)})`;\n\t\t}\n\t\treturn metadata.scope === \"user\" ? `User (${formatBaseDir(agentDir)})` : `Project (${CONFIG_DIR_NAME}/)`;\n\t}\n\treturn metadata.scope === \"user\" ? \"User settings\" : \"Project settings\";\n}\n\nfunction buildGroups(resolved: ResolvedPaths, agentDir: string): ResourceGroup[] {\n\tconst groupMap = new Map<string, ResourceGroup>();\n\n\tconst addToGroup = (resources: ResolvedResource[], resourceType: ResourceType) => {\n\t\tfor (const res of resources) {\n\t\t\tconst { path, enabled, metadata } = res;\n\t\t\tconst groupKey = `${metadata.origin}:${metadata.scope}:${metadata.source}:${metadata.baseDir ?? \"\"}`;\n\n\t\t\tif (!groupMap.has(groupKey)) {\n\t\t\t\tgroupMap.set(groupKey, {\n\t\t\t\t\tkey: groupKey,\n\t\t\t\t\tlabel: getGroupLabel(metadata, agentDir),\n\t\t\t\t\tscope: metadata.scope,\n\t\t\t\t\torigin: metadata.origin,\n\t\t\t\t\tsource: metadata.source,\n\t\t\t\t\tsubgroups: [],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst group = groupMap.get(groupKey)!;\n\t\t\tconst subgroupKey = `${groupKey}:${resourceType}`;\n\n\t\t\tlet subgroup = group.subgroups.find((sg) => sg.type === resourceType);\n\t\t\tif (!subgroup) {\n\t\t\t\tsubgroup = {\n\t\t\t\t\ttype: resourceType,\n\t\t\t\t\tlabel: RESOURCE_TYPE_LABELS[resourceType],\n\t\t\t\t\titems: [],\n\t\t\t\t};\n\t\t\t\tgroup.subgroups.push(subgroup);\n\t\t\t}\n\n\t\t\tconst fileName = basename(path);\n\t\t\tconst parentFolder = basename(dirname(path));\n\t\t\tlet displayName: string;\n\t\t\tif (resourceType === \"extensions\" && parentFolder !== \"extensions\") {\n\t\t\t\tdisplayName = `${parentFolder}/${fileName}`;\n\t\t\t} else if (resourceType === \"skills\" && fileName === \"SKILL.md\") {\n\t\t\t\tdisplayName = parentFolder;\n\t\t\t} else {\n\t\t\t\tdisplayName = fileName;\n\t\t\t}\n\t\t\tsubgroup.items.push({\n\t\t\t\tpath,\n\t\t\t\tenabled,\n\t\t\t\tmetadata,\n\t\t\t\tresourceType,\n\t\t\t\tdisplayName,\n\t\t\t\tgroupKey,\n\t\t\t\tsubgroupKey,\n\t\t\t});\n\t\t}\n\t};\n\n\taddToGroup(resolved.extensions, \"extensions\");\n\taddToGroup(resolved.skills, \"skills\");\n\taddToGroup(resolved.prompts, \"prompts\");\n\taddToGroup(resolved.themes, \"themes\");\n\n\t// Sort groups: packages first, then top-level; user before project\n\tconst groups = Array.from(groupMap.values());\n\tgroups.sort((a, b) => {\n\t\tif (a.origin !== b.origin) {\n\t\t\treturn a.origin === \"package\" ? -1 : 1;\n\t\t}\n\t\tif (a.scope !== b.scope) {\n\t\t\treturn a.scope === \"user\" ? -1 : 1;\n\t\t}\n\t\treturn a.source.localeCompare(b.source);\n\t});\n\n\t// Sort subgroups within each group by type order, and items by name\n\tconst typeOrder: Record<ResourceType, number> = { extensions: 0, skills: 1, prompts: 2, themes: 3 };\n\tfor (const group of groups) {\n\t\tgroup.subgroups.sort((a, b) => typeOrder[a.type] - typeOrder[b.type]);\n\t\tfor (const subgroup of group.subgroups) {\n\t\t\tsubgroup.items.sort((a, b) => a.displayName.localeCompare(b.displayName));\n\t\t}\n\t}\n\n\treturn groups;\n}\n\ntype FlatEntry =\n\t| { type: \"group\"; group: ResourceGroup }\n\t| { type: \"subgroup\"; subgroup: ResourceSubgroup; group: ResourceGroup }\n\t| { type: \"item\"; item: ResourceItem };\n\nclass ConfigSelectorHeader implements Component {\n\tprivate writeScope: ConfigWriteScope;\n\tprivate projectModeAvailable: boolean;\n\n\tconstructor(writeScope: ConfigWriteScope, projectModeAvailable: boolean) {\n\t\tthis.writeScope = writeScope;\n\t\tthis.projectModeAvailable = projectModeAvailable;\n\t}\n\n\tsetWriteScope(writeScope: ConfigWriteScope): void {\n\t\tthis.writeScope = writeScope;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst title = theme.bold(this.writeScope === \"project\" ? \"Project Local Resources\" : \"Global Resources\");\n\t\tconst sep = theme.fg(\"muted\", \" · \");\n\t\tconst switchHint = this.projectModeAvailable ? keyHint(\"tui.input.tab\", \"switch mode\") + sep : \"\";\n\t\tconst actionHint =\n\t\t\tthis.writeScope === \"project\" ? rawKeyHint(\"space\", \"cycle inherit/+/-\") : rawKeyHint(\"space\", \"toggle\");\n\t\tconst hint = switchHint + actionHint + sep + rawKeyHint(\"esc\", \"close\");\n\t\tconst spacing = Math.max(1, width - visibleWidth(title) - visibleWidth(hint));\n\t\tconst scopeHint =\n\t\t\tthis.writeScope === \"project\"\n\t\t\t\t? theme.fg(\"muted\", `${CONFIG_DIR_NAME}/settings.json · inherited global resources are dimmed`)\n\t\t\t\t: theme.fg(\"muted\", `~/${CONFIG_DIR_NAME}/agent/settings.json`);\n\n\t\treturn [\n\t\t\ttruncateToWidth(`${title}${\" \".repeat(spacing)}${hint}`, width, \"\"),\n\t\t\ttruncateToWidth(scopeHint, width, \"\"),\n\t\t];\n\t}\n}\n\nclass ResourceList implements Component, Focusable {\n\tprivate groupsByScope: Record<ConfigWriteScope, ResourceGroup[]>;\n\tprivate flatItems: FlatEntry[] = [];\n\tprivate filteredItems: FlatEntry[] = [];\n\tprivate selectedIndex = 0;\n\tprivate searchInput: Input;\n\tprivate maxVisible: number;\n\tprivate settingsManager: SettingsManager;\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\tprivate writeScope: ConfigWriteScope;\n\tprivate inheritedEnabledByKey: Map<string, boolean>;\n\n\tpublic onCancel?: () => void;\n\tpublic onExit?: () => void;\n\tpublic onToggle?: (item: ResourceItem, newEnabled: boolean) => void;\n\tpublic onSwitchMode?: () => void;\n\n\tprivate _focused = false;\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\tconstructor(\n\t\tgroupsByScope: Record<ConfigWriteScope, ResourceGroup[]>,\n\t\tsettingsManager: SettingsManager,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tterminalHeight?: number,\n\t\twriteScope: ConfigWriteScope = \"global\",\n\t) {\n\t\tthis.groupsByScope = groupsByScope;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.cwd = cwd;\n\t\tthis.agentDir = agentDir;\n\t\tthis.writeScope = writeScope;\n\t\tthis.inheritedEnabledByKey = this.buildInheritedEnabledMap(groupsByScope.global);\n\t\tthis.searchInput = new Input();\n\t\t// 8 lines of chrome: top spacer + top border + spacer + header (2 lines) + spacer + bottom spacer + bottom border\n\t\tconst chrome = 8;\n\t\tthis.maxVisible = Math.max(5, (terminalHeight ?? 24) - chrome);\n\t\tthis.buildFlatList();\n\t\tthis.filteredItems = [...this.flatItems];\n\t}\n\n\tsetWriteScope(writeScope: ConfigWriteScope): void {\n\t\tthis.writeScope = writeScope;\n\t\tthis.buildFlatList();\n\t\tthis.filterItems(this.searchInput.getValue());\n\t}\n\n\tprivate get groups(): ResourceGroup[] {\n\t\treturn this.groupsByScope[this.writeScope];\n\t}\n\n\tprivate buildInheritedEnabledMap(groups: ResourceGroup[]): Map<string, boolean> {\n\t\tconst result = new Map<string, boolean>();\n\t\tfor (const group of groups) {\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tfor (const item of subgroup.items) {\n\t\t\t\t\tresult.set(this.getResourceItemKey(item), item.enabled);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate buildFlatList(): void {\n\t\tthis.flatItems = [];\n\t\tfor (const group of this.groups) {\n\t\t\tthis.flatItems.push({ type: \"group\", group });\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tthis.flatItems.push({ type: \"subgroup\", subgroup, group });\n\t\t\t\tfor (const item of subgroup.items) {\n\t\t\t\t\tthis.flatItems.push({ type: \"item\", item });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Start selection on first item (not header)\n\t\tthis.selectedIndex = this.flatItems.findIndex((e) => e.type === \"item\");\n\t\tif (this.selectedIndex < 0) this.selectedIndex = 0;\n\t}\n\n\tprivate findNextItem(fromIndex: number, direction: 1 | -1): number {\n\t\tlet idx = fromIndex + direction;\n\t\twhile (idx >= 0 && idx < this.filteredItems.length) {\n\t\t\tif (this.filteredItems[idx].type === \"item\") {\n\t\t\t\treturn idx;\n\t\t\t}\n\t\t\tidx += direction;\n\t\t}\n\t\treturn fromIndex; // Stay at current if no item found\n\t}\n\n\tprivate filterItems(query: string): void {\n\t\tif (!query.trim()) {\n\t\t\tthis.filteredItems = [...this.flatItems];\n\t\t\tthis.selectFirstItem();\n\t\t\treturn;\n\t\t}\n\n\t\tconst lowerQuery = query.toLowerCase();\n\t\tconst matchingItems = new Set<ResourceItem>();\n\t\tconst matchingSubgroups = new Set<ResourceSubgroup>();\n\t\tconst matchingGroups = new Set<ResourceGroup>();\n\n\t\tfor (const entry of this.flatItems) {\n\t\t\tif (entry.type === \"item\") {\n\t\t\t\tconst item = entry.item;\n\t\t\t\tif (\n\t\t\t\t\titem.displayName.toLowerCase().includes(lowerQuery) ||\n\t\t\t\t\titem.resourceType.toLowerCase().includes(lowerQuery) ||\n\t\t\t\t\titem.path.toLowerCase().includes(lowerQuery)\n\t\t\t\t) {\n\t\t\t\t\tmatchingItems.add(item);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Find which subgroups and groups contain matching items\n\t\tfor (const group of this.groups) {\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tfor (const item of subgroup.items) {\n\t\t\t\t\tif (matchingItems.has(item)) {\n\t\t\t\t\t\tmatchingSubgroups.add(subgroup);\n\t\t\t\t\t\tmatchingGroups.add(group);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.filteredItems = [];\n\t\tfor (const entry of this.flatItems) {\n\t\t\tif (entry.type === \"group\" && matchingGroups.has(entry.group)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t} else if (entry.type === \"subgroup\" && matchingSubgroups.has(entry.subgroup)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t} else if (entry.type === \"item\" && matchingItems.has(entry.item)) {\n\t\t\t\tthis.filteredItems.push(entry);\n\t\t\t}\n\t\t}\n\n\t\tthis.selectFirstItem();\n\t}\n\n\tprivate selectFirstItem(): void {\n\t\tconst firstItemIndex = this.filteredItems.findIndex((e) => e.type === \"item\");\n\t\tthis.selectedIndex = firstItemIndex >= 0 ? firstItemIndex : 0;\n\t}\n\n\tupdateItem(item: ResourceItem, enabled: boolean): void {\n\t\titem.enabled = enabled;\n\t\t// Update in groups too\n\t\tfor (const group of this.groups) {\n\t\t\tfor (const subgroup of group.subgroups) {\n\t\t\t\tconst found = subgroup.items.find((i) => i.path === item.path && i.resourceType === item.resourceType);\n\t\t\t\tif (found) {\n\t\t\t\t\tfound.enabled = enabled;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\n\t\t// Search input\n\t\tlines.push(...this.searchInput.render(width));\n\t\tlines.push(\"\");\n\n\t\tif (this.filteredItems.length === 0) {\n\t\t\tlines.push(theme.fg(\"muted\", \" No resources found\"));\n\t\t\treturn lines;\n\t\t}\n\n\t\t// Calculate visible range\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 entry = this.filteredItems[i];\n\t\t\tconst isSelected = i === this.selectedIndex;\n\n\t\t\tif (entry.type === \"group\") {\n\t\t\t\t// Main group header (no cursor)\n\t\t\t\tconst inherited = this.writeScope === \"project\" && entry.group.scope === \"user\";\n\t\t\t\tconst label = theme.bold(`${entry.group.label}${inherited ? \" · inherited global\" : \"\"}`);\n\t\t\t\tconst groupLine = theme.fg(inherited ? \"dim\" : \"accent\", label);\n\t\t\t\tlines.push(truncateToWidth(` ${groupLine}`, width, \"\"));\n\t\t\t} else if (entry.type === \"subgroup\") {\n\t\t\t\t// Subgroup header (indented, no cursor)\n\t\t\t\tconst color = this.writeScope === \"project\" && entry.group.scope === \"user\" ? \"dim\" : \"muted\";\n\t\t\t\tconst subgroupLine = theme.fg(color, entry.subgroup.label);\n\t\t\t\tlines.push(truncateToWidth(` ${subgroupLine}`, width, \"\"));\n\t\t\t} else {\n\t\t\t\t// Resource item (cursor only on items)\n\t\t\t\tconst item = entry.item;\n\t\t\t\tconst cursor = isSelected ? \"> \" : \" \";\n\t\t\t\tconst dimmed = this.isDimmedItem(item);\n\t\t\t\tconst nameText = isSelected && !dimmed ? theme.bold(item.displayName) : item.displayName;\n\t\t\t\tconst name = dimmed ? theme.fg(\"dim\", nameText) : nameText;\n\t\t\t\tlines.push(\n\t\t\t\t\ttruncateToWidth(\n\t\t\t\t\t\t`${cursor} ${this.renderCheckbox(item)} ${name}${this.getItemSuffix(item)}`,\n\t\t\t\t\t\twidth,\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}\n\n\t\t// Scroll indicator\n\t\tif (startIndex > 0 || endIndex < this.filteredItems.length) {\n\t\t\tconst itemCount = this.filteredItems.filter((e) => e.type === \"item\").length;\n\t\t\tconst currentItemIndex =\n\t\t\t\tthis.filteredItems.slice(0, this.selectedIndex).filter((e) => e.type === \"item\").length + 1;\n\t\t\tlines.push(theme.fg(\"dim\", ` (${currentItemIndex}/${itemCount})`));\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\thandleInput(data: string): void {\n\t\tconst kb = getKeybindings();\n\n\t\tif (kb.matches(data, \"tui.select.up\")) {\n\t\t\tthis.selectedIndex = this.findNextItem(this.selectedIndex, -1);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.selectedIndex = this.findNextItem(this.selectedIndex, 1);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.pageUp\")) {\n\t\t\t// Jump up by maxVisible, then find nearest item\n\t\t\tlet target = Math.max(0, this.selectedIndex - this.maxVisible);\n\t\t\twhile (target < this.filteredItems.length && this.filteredItems[target].type !== \"item\") {\n\t\t\t\ttarget++;\n\t\t\t}\n\t\t\tif (target < this.filteredItems.length) {\n\t\t\t\tthis.selectedIndex = target;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.pageDown\")) {\n\t\t\t// Jump down by maxVisible, then find nearest item\n\t\t\tlet target = Math.min(this.filteredItems.length - 1, this.selectedIndex + this.maxVisible);\n\t\t\twhile (target >= 0 && this.filteredItems[target].type !== \"item\") {\n\t\t\t\ttarget--;\n\t\t\t}\n\t\t\tif (target >= 0) {\n\t\t\t\tthis.selectedIndex = target;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.onCancel?.();\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, \"ctrl+c\")) {\n\t\t\tthis.onExit?.();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.input.tab\")) {\n\t\t\tthis.onSwitchMode?.();\n\t\t\treturn;\n\t\t}\n\t\tif (data === \" \" || kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tconst entry = this.filteredItems[this.selectedIndex];\n\t\t\tif (entry?.type === \"item\" && (this.writeScope === \"project\" || this.getItemScope(entry.item) === \"user\")) {\n\t\t\t\tconst newEnabled = this.toggleResource(entry.item);\n\t\t\t\tif (newEnabled !== undefined) {\n\t\t\t\t\tthis.updateItem(entry.item, newEnabled);\n\t\t\t\t\tthis.onToggle?.(entry.item, newEnabled);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Pass to search input\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.filterItems(this.searchInput.getValue());\n\t}\n\n\tprivate toggleResource(item: ResourceItem): boolean | undefined {\n\t\tif (this.writeScope === \"project\") {\n\t\t\tconst state = this.getNextOverrideState(item);\n\t\t\tif (!this.setProjectResourceOverride(item, state)) return undefined;\n\t\t\treturn state === \"inherit\" ? this.getInheritedEnabled(item) : state === \"load\";\n\t\t}\n\n\t\tconst enabled = !item.enabled;\n\t\tif (item.metadata.origin === \"top-level\") {\n\t\t\tthis.toggleTopLevelResource(item, enabled);\n\t\t} else {\n\t\t\tthis.togglePackageResource(item, enabled);\n\t\t}\n\t\treturn enabled;\n\t}\n\n\tprivate toggleTopLevelResource(item: ResourceItem, enabled: boolean): void {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst settings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\n\t\tconst arrayKey = item.resourceType as \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\n\t\tconst current = (settings[arrayKey] ?? []) as string[];\n\n\t\t// Generate pattern for this resource\n\t\tconst pattern = this.getResourcePattern(item);\n\t\tconst disablePattern = `-${pattern}`;\n\t\tconst enablePattern = `+${pattern}`;\n\n\t\t// Filter out existing patterns for this resource\n\t\tconst updated = current.filter((p) => {\n\t\t\tconst stripped = p.startsWith(\"!\") || p.startsWith(\"+\") || p.startsWith(\"-\") ? p.slice(1) : p;\n\t\t\treturn stripped !== pattern;\n\t\t});\n\n\t\tif (enabled) {\n\t\t\tupdated.push(enablePattern);\n\t\t} else {\n\t\t\tupdated.push(disablePattern);\n\t\t}\n\n\t\tif (scope === \"project\") {\n\t\t\tif (arrayKey === \"extensions\") {\n\t\t\t\tthis.settingsManager.setProjectExtensionPaths(updated);\n\t\t\t} else if (arrayKey === \"skills\") {\n\t\t\t\tthis.settingsManager.setProjectSkillPaths(updated);\n\t\t\t} else if (arrayKey === \"prompts\") {\n\t\t\t\tthis.settingsManager.setProjectPromptTemplatePaths(updated);\n\t\t\t} else if (arrayKey === \"themes\") {\n\t\t\t\tthis.settingsManager.setProjectThemePaths(updated);\n\t\t\t}\n\t\t} else {\n\t\t\tif (arrayKey === \"extensions\") {\n\t\t\t\tthis.settingsManager.setExtensionPaths(updated);\n\t\t\t} else if (arrayKey === \"skills\") {\n\t\t\t\tthis.settingsManager.setSkillPaths(updated);\n\t\t\t} else if (arrayKey === \"prompts\") {\n\t\t\t\tthis.settingsManager.setPromptTemplatePaths(updated);\n\t\t\t} else if (arrayKey === \"themes\") {\n\t\t\t\tthis.settingsManager.setThemePaths(updated);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate togglePackageResource(item: ResourceItem, enabled: boolean): void {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst settings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\n\t\tconst packages = [...(settings.packages ?? [])] as PackageSource[];\n\t\tconst pkgIndex = packages.findIndex((pkg) => {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\treturn source === item.metadata.source;\n\t\t});\n\n\t\tif (pkgIndex === -1) return;\n\n\t\tlet pkg = packages[pkgIndex];\n\n\t\t// Convert string to object form if needed\n\t\tif (typeof pkg === \"string\") {\n\t\t\tpkg = { source: pkg };\n\t\t\tpackages[pkgIndex] = pkg;\n\t\t}\n\n\t\t// Get the resource array for this type\n\t\tconst arrayKey = item.resourceType as \"extensions\" | \"skills\" | \"prompts\" | \"themes\";\n\t\tconst current = (pkg[arrayKey] ?? []) as string[];\n\n\t\t// Generate pattern relative to package root\n\t\tconst pattern = this.getPackageResourcePattern(item);\n\t\tconst disablePattern = `-${pattern}`;\n\t\tconst enablePattern = `+${pattern}`;\n\n\t\t// Filter out existing patterns for this resource\n\t\tconst updated = current.filter((p) => {\n\t\t\tconst stripped = p.startsWith(\"!\") || p.startsWith(\"+\") || p.startsWith(\"-\") ? p.slice(1) : p;\n\t\t\treturn stripped !== pattern;\n\t\t});\n\n\t\tif (enabled) {\n\t\t\tupdated.push(enablePattern);\n\t\t} else {\n\t\t\tupdated.push(disablePattern);\n\t\t}\n\n\t\t(pkg as Record<string, unknown>)[arrayKey] = updated.length > 0 ? updated : undefined;\n\n\t\t// Clean up empty filter object\n\t\tconst hasFilters = [\"extensions\", \"skills\", \"prompts\", \"themes\"].some(\n\t\t\t(k) => (pkg as Record<string, unknown>)[k] !== undefined,\n\t\t);\n\t\tif (!hasFilters) {\n\t\t\tpackages[pkgIndex] = (pkg as { source: string }).source;\n\t\t}\n\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(packages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(packages);\n\t\t}\n\t}\n\n\tprivate renderCheckbox(item: ResourceItem): string {\n\t\tif (this.writeScope === \"project\") {\n\t\t\tconst state = this.getProjectOverrideState(item);\n\t\t\tif (state === \"load\") return theme.fg(\"success\", \"[+]\");\n\t\t\tif (state === \"unload\") return theme.fg(\"warning\", \"[-]\");\n\t\t\treturn theme.fg(\"dim\", item.enabled ? \"[x]\" : \"[ ]\");\n\t\t}\n\t\treturn item.enabled ? theme.fg(\"success\", \"[x]\") : theme.fg(\"dim\", \"[ ]\");\n\t}\n\n\tprivate getItemSuffix(item: ResourceItem): string {\n\t\tif (this.writeScope !== \"project\") return \"\";\n\t\tconst state = this.getProjectOverrideState(item);\n\t\tif (state === \"load\") return theme.fg(\"muted\", \" project load\");\n\t\tif (state === \"unload\") return theme.fg(\"muted\", \" project unload\");\n\t\treturn this.isInheritedGlobalItem(item) ? theme.fg(\"dim\", \" inherited global\") : \"\";\n\t}\n\n\tprivate isDimmedItem(item: ResourceItem): boolean {\n\t\treturn (\n\t\t\tthis.writeScope === \"project\" &&\n\t\t\tthis.isInheritedGlobalItem(item) &&\n\t\t\tthis.getProjectOverrideState(item) === \"inherit\"\n\t\t);\n\t}\n\n\tprivate setProjectResourceOverride(item: ResourceItem, state: ProjectOverrideState): boolean {\n\t\treturn item.metadata.origin === \"top-level\"\n\t\t\t? this.setProjectTopLevelOverride(item, state)\n\t\t\t: this.setProjectPackageOverride(item, state);\n\t}\n\n\tprivate setProjectTopLevelOverride(item: ResourceItem, state: ProjectOverrideState): boolean {\n\t\tconst current = (this.settingsManager.getProjectSettings()[item.resourceType] ?? []) as string[];\n\t\tconst pattern = this.isInheritedGlobalItem(item) ? item.path : this.getResourcePatternForScope(item, \"project\");\n\t\tconst patterns = this.getTopLevelOverridePatterns(item, \"project\");\n\t\tconst updated = current.filter((entry) => {\n\t\t\tconst target = this.getPatternEntryTarget(entry);\n\t\t\tif ((entry.startsWith(\"!\") || entry.startsWith(\"+\") || entry.startsWith(\"-\")) && patterns.has(target))\n\t\t\t\treturn false;\n\t\t\treturn !(state === \"inherit\" && this.isInheritedGlobalItem(item) && target === pattern);\n\t\t});\n\t\tif (state !== \"inherit\") {\n\t\t\tif (this.isInheritedGlobalItem(item) && !updated.includes(pattern)) updated.push(pattern);\n\t\t\tupdated.push(`${state === \"load\" ? \"+\" : \"-\"}${pattern}`);\n\t\t}\n\t\tthis.setProjectTopLevelPaths(item.resourceType, updated);\n\t\treturn true;\n\t}\n\n\tprivate setProjectTopLevelPaths(key: ResourceType, paths: string[]): void {\n\t\tif (key === \"extensions\") this.settingsManager.setProjectExtensionPaths(paths);\n\t\telse if (key === \"skills\") this.settingsManager.setProjectSkillPaths(paths);\n\t\telse if (key === \"prompts\") this.settingsManager.setProjectPromptTemplatePaths(paths);\n\t\telse this.settingsManager.setProjectThemePaths(paths);\n\t}\n\n\tprivate setProjectPackageOverride(item: ResourceItem, state: ProjectOverrideState): boolean {\n\t\tconst packages = [...(this.settingsManager.getProjectSettings().packages ?? [])] as PackageSource[];\n\t\tlet pkgIndex = packages.findIndex((pkg) =>\n\t\t\tthis.packageSourceStringMatches(\n\t\t\t\titem.metadata.source,\n\t\t\t\tthis.getItemScope(item),\n\t\t\t\ttypeof pkg === \"string\" ? pkg : pkg.source,\n\t\t\t\t\"project\",\n\t\t\t),\n\t\t);\n\t\tif (pkgIndex === -1) {\n\t\t\tif (state === \"inherit\") return false;\n\t\t\tpackages.push(this.createPackageOverrideSource(item));\n\t\t\tpkgIndex = packages.length - 1;\n\t\t}\n\t\tlet pkg = packages[pkgIndex];\n\t\tif (pkg === undefined) return false;\n\t\tif (typeof pkg === \"string\") {\n\t\t\tpkg = { source: pkg };\n\t\t\tpackages[pkgIndex] = pkg;\n\t\t}\n\t\tconst pattern = this.getPackageResourcePattern(item);\n\t\tconst updated = ((pkg[item.resourceType] ?? []) as string[]).filter(\n\t\t\t(entry) => this.getPatternEntryTarget(entry) !== pattern,\n\t\t);\n\t\tif (state !== \"inherit\") updated.push(`${state === \"load\" ? \"+\" : \"-\"}${pattern}`);\n\t\t(pkg as Record<string, unknown>)[item.resourceType] = updated.length > 0 ? updated : undefined;\n\t\tif (!RESOURCE_TYPES.some((key) => (pkg as Record<string, unknown>)[key] !== undefined)) {\n\t\t\tif (pkg.autoload === false) packages.splice(pkgIndex, 1);\n\t\t\telse packages[pkgIndex] = pkg.source;\n\t\t}\n\t\tthis.settingsManager.setProjectPackages(packages);\n\t\treturn true;\n\t}\n\n\tprivate getNextOverrideState(item: ResourceItem): ProjectOverrideState {\n\t\tconst state = this.getProjectOverrideState(item);\n\t\tconst inheritedEnabled = this.getInheritedEnabled(item);\n\t\tif (state === \"inherit\") return inheritedEnabled ? \"unload\" : \"load\";\n\t\tif (state === \"unload\") return inheritedEnabled ? \"load\" : \"inherit\";\n\t\treturn inheritedEnabled ? \"inherit\" : \"unload\";\n\t}\n\n\tprivate getProjectOverrideState(item: ResourceItem): ProjectOverrideState {\n\t\tif (this.writeScope !== \"project\") return \"inherit\";\n\t\tif (item.metadata.origin === \"top-level\") {\n\t\t\treturn this.getOverrideStateFromEntries(\n\t\t\t\t(this.settingsManager.getProjectSettings()[item.resourceType] ?? []) as string[],\n\t\t\t\tthis.getTopLevelOverridePatterns(item, \"project\"),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t\tconst pkg = this.findMatchingPackageSource(item, \"project\");\n\t\tif (typeof pkg !== \"object\") return \"inherit\";\n\t\tconst entries = pkg[item.resourceType];\n\t\tif (entries === undefined) return \"inherit\";\n\t\treturn this.getOverrideStateFromEntries(\n\t\t\tentries,\n\t\t\tnew Set([this.getPackageResourcePattern(item)]),\n\t\t\tpkg.autoload !== false,\n\t\t);\n\t}\n\n\tprivate getOverrideStateFromEntries(\n\t\tentries: string[],\n\t\tpatterns: Set<string>,\n\t\temptyArrayIsUnload: boolean,\n\t): ProjectOverrideState {\n\t\tif (entries.length === 0 && emptyArrayIsUnload) return \"unload\";\n\t\tlet state: ProjectOverrideState = \"inherit\";\n\t\tfor (const entry of entries) {\n\t\t\tif (!patterns.has(this.getPatternEntryTarget(entry))) continue;\n\t\t\tif (entry.startsWith(\"!\") || entry.startsWith(\"-\")) state = \"unload\";\n\t\t\telse state = \"load\";\n\t\t}\n\t\treturn state;\n\t}\n\n\tprivate getInheritedEnabled(item: ResourceItem): boolean {\n\t\treturn (\n\t\t\tthis.inheritedEnabledByKey.get(this.getResourceItemKey(item)) ??\n\t\t\t(this.getItemScope(item) === \"user\" ? item.enabled : true)\n\t\t);\n\t}\n\n\tprivate isInheritedGlobalItem(item: ResourceItem): boolean {\n\t\treturn this.getItemScope(item) === \"user\" || this.inheritedEnabledByKey.has(this.getResourceItemKey(item));\n\t}\n\n\tprivate getTopLevelOverridePatterns(item: ResourceItem, scope: SettingsScope): Set<string> {\n\t\tconst baseDir = this.getTopLevelBaseDir(scope);\n\t\tconst patterns = new Set<string>([\n\t\t\tthis.getResourcePatternForScope(item, scope),\n\t\t\titem.path,\n\t\t\trelative(baseDir, item.path),\n\t\t]);\n\t\tif (item.metadata.baseDir) patterns.add(relative(item.metadata.baseDir, item.path));\n\t\treturn patterns;\n\t}\n\n\tprivate getResourcePatternForScope(item: ResourceItem, scope: SettingsScope): string {\n\t\tconst sourceScope = this.getItemScope(item);\n\t\tif (scope !== sourceScope) return item.path;\n\t\tconst baseDir = item.metadata.baseDir ?? this.getTopLevelBaseDir(sourceScope);\n\t\treturn relative(baseDir, item.path);\n\t}\n\n\tprivate createPackageOverrideSource(item: ResourceItem): PackageSource {\n\t\tconst source = item.metadata.source;\n\t\tif (!isLocalPath(source)) return { source, autoload: false };\n\t\tconst sourcePath = resolvePath(source, this.getTopLevelBaseDir(this.getItemScope(item)), { trim: true });\n\t\treturn { source: relative(this.getTopLevelBaseDir(\"project\"), sourcePath) || \".\", autoload: false };\n\t}\n\n\tprivate packageSourceStringMatches(\n\t\tleftSource: string,\n\t\tleftScope: SettingsScope,\n\t\trightSource: string,\n\t\trightScope: SettingsScope,\n\t): boolean {\n\t\tif (leftSource === rightSource) return true;\n\t\tif (!isLocalPath(leftSource) || !isLocalPath(rightSource)) return false;\n\t\tconst left = resolvePath(leftSource, this.getTopLevelBaseDir(leftScope), { trim: true });\n\t\tconst right = resolvePath(rightSource, this.getTopLevelBaseDir(rightScope), { trim: true });\n\t\treturn left === right;\n\t}\n\n\tprivate findMatchingPackageSource(item: ResourceItem, targetScope: SettingsScope): PackageSource | undefined {\n\t\tconst settings =\n\t\t\ttargetScope === \"project\"\n\t\t\t\t? this.settingsManager.getProjectSettings()\n\t\t\t\t: this.settingsManager.getGlobalSettings();\n\t\treturn (settings.packages ?? []).find((pkg) =>\n\t\t\tthis.packageSourceStringMatches(\n\t\t\t\titem.metadata.source,\n\t\t\t\tthis.getItemScope(item),\n\t\t\t\ttypeof pkg === \"string\" ? pkg : pkg.source,\n\t\t\t\ttargetScope,\n\t\t\t),\n\t\t);\n\t}\n\n\tprivate getPatternEntryTarget(entry: string): string {\n\t\treturn entry.startsWith(\"!\") || entry.startsWith(\"+\") || entry.startsWith(\"-\") ? entry.slice(1) : entry;\n\t}\n\n\tprivate getResourceItemKey(item: ResourceItem): string {\n\t\treturn `${item.resourceType}:${canonicalizePath(item.path)}`;\n\t}\n\n\tprivate getItemScope(item: ResourceItem): SettingsScope {\n\t\treturn item.metadata.scope === \"project\" ? \"project\" : \"user\";\n\t}\n\n\tprivate getTopLevelBaseDir(scope: \"user\" | \"project\"): string {\n\t\treturn scope === \"project\" ? join(this.cwd, CONFIG_DIR_NAME) : this.agentDir;\n\t}\n\n\tprivate getResourcePattern(item: ResourceItem): string {\n\t\tconst scope = item.metadata.scope as \"user\" | \"project\";\n\t\tconst baseDir = item.metadata.baseDir ?? this.getTopLevelBaseDir(scope);\n\t\treturn relative(baseDir, item.path);\n\t}\n\n\tprivate getPackageResourcePattern(item: ResourceItem): string {\n\t\tconst baseDir = item.metadata.baseDir ?? dirname(item.path);\n\t\treturn relative(baseDir, item.path);\n\t}\n}\n\nexport class ConfigSelectorComponent extends Container implements Focusable {\n\tprivate header: ConfigSelectorHeader;\n\tprivate resourceList: ResourceList;\n\tprivate writeScope: ConfigWriteScope;\n\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.resourceList.focused = value;\n\t}\n\n\tconstructor(\n\t\tresolvedPaths: ScopedResolvedPaths,\n\t\tsettingsManager: SettingsManager,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tonClose: () => void,\n\t\tonExit: () => void,\n\t\trequestRender: () => void,\n\t\tterminalHeight?: number,\n\t\twriteScope: ConfigWriteScope = \"global\",\n\t\tprojectModeAvailable = true,\n\t) {\n\t\tsuper();\n\n\t\tthis.writeScope = writeScope;\n\t\tconst groupsByScope = {\n\t\t\tglobal: buildGroups(resolvedPaths.global, agentDir),\n\t\t\tproject: buildGroups(resolvedPaths.project, agentDir),\n\t\t};\n\n\t\t// Add header\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.header = new ConfigSelectorHeader(this.writeScope, projectModeAvailable);\n\t\tthis.addChild(this.header);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Resource list\n\t\tthis.resourceList = new ResourceList(\n\t\t\tgroupsByScope,\n\t\t\tsettingsManager,\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tterminalHeight,\n\t\t\tthis.writeScope,\n\t\t);\n\t\tthis.resourceList.onCancel = onClose;\n\t\tthis.resourceList.onExit = onExit;\n\t\tthis.resourceList.onToggle = () => requestRender();\n\t\tif (projectModeAvailable) {\n\t\t\tthis.resourceList.onSwitchMode = () => {\n\t\t\t\tthis.switchWriteScope();\n\t\t\t\trequestRender();\n\t\t\t};\n\t\t}\n\t\tthis.addChild(this.resourceList);\n\n\t\t// Bottom border\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tprivate switchWriteScope(): void {\n\t\tthis.writeScope = this.writeScope === \"global\" ? \"project\" : \"global\";\n\t\tthis.header.setWriteScope(this.writeScope);\n\t\tthis.resourceList.setWriteScope(this.writeScope);\n\t}\n\n\tgetResourceList(): ResourceList {\n\t\treturn this.resourceList;\n\t}\n}\n"]}
|
|
@@ -5,9 +5,11 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { basename, dirname, join, relative } from "node:path";
|
|
6
6
|
import { Container, getKeybindings, Input, matchesKey, Spacer, truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
|
|
7
7
|
import { CONFIG_DIR_NAME } from "../../../config.js";
|
|
8
|
+
import { canonicalizePath, isLocalPath, resolvePath } from "../../../utils/paths.js";
|
|
8
9
|
import { theme } from "../theme/theme.js";
|
|
9
10
|
import { DynamicBorder } from "./dynamic-border.js";
|
|
10
|
-
import { rawKeyHint } from "./keybinding-hints.js";
|
|
11
|
+
import { keyHint, rawKeyHint } from "./keybinding-hints.js";
|
|
12
|
+
const RESOURCE_TYPES = ["extensions", "skills", "prompts", "themes"];
|
|
11
13
|
const RESOURCE_TYPE_LABELS = {
|
|
12
14
|
extensions: "Extensions",
|
|
13
15
|
skills: "Skills",
|
|
@@ -121,22 +123,34 @@ function buildGroups(resolved, agentDir) {
|
|
|
121
123
|
return groups;
|
|
122
124
|
}
|
|
123
125
|
class ConfigSelectorHeader {
|
|
126
|
+
writeScope;
|
|
127
|
+
projectModeAvailable;
|
|
128
|
+
constructor(writeScope, projectModeAvailable) {
|
|
129
|
+
this.writeScope = writeScope;
|
|
130
|
+
this.projectModeAvailable = projectModeAvailable;
|
|
131
|
+
}
|
|
132
|
+
setWriteScope(writeScope) {
|
|
133
|
+
this.writeScope = writeScope;
|
|
134
|
+
}
|
|
124
135
|
invalidate() { }
|
|
125
136
|
render(width) {
|
|
126
|
-
const title = theme.bold("
|
|
137
|
+
const title = theme.bold(this.writeScope === "project" ? "Project Local Resources" : "Global Resources");
|
|
127
138
|
const sep = theme.fg("muted", " · ");
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const spacing = Math.max(1, width -
|
|
139
|
+
const switchHint = this.projectModeAvailable ? keyHint("tui.input.tab", "switch mode") + sep : "";
|
|
140
|
+
const actionHint = this.writeScope === "project" ? rawKeyHint("space", "cycle inherit/+/-") : rawKeyHint("space", "toggle");
|
|
141
|
+
const hint = switchHint + actionHint + sep + rawKeyHint("esc", "close");
|
|
142
|
+
const spacing = Math.max(1, width - visibleWidth(title) - visibleWidth(hint));
|
|
143
|
+
const scopeHint = this.writeScope === "project"
|
|
144
|
+
? theme.fg("muted", `${CONFIG_DIR_NAME}/settings.json · inherited global resources are dimmed`)
|
|
145
|
+
: theme.fg("muted", `~/${CONFIG_DIR_NAME}/agent/settings.json`);
|
|
132
146
|
return [
|
|
133
147
|
truncateToWidth(`${title}${" ".repeat(spacing)}${hint}`, width, ""),
|
|
134
|
-
|
|
148
|
+
truncateToWidth(scopeHint, width, ""),
|
|
135
149
|
];
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
class ResourceList {
|
|
139
|
-
|
|
153
|
+
groupsByScope;
|
|
140
154
|
flatItems = [];
|
|
141
155
|
filteredItems = [];
|
|
142
156
|
selectedIndex = 0;
|
|
@@ -145,9 +159,12 @@ class ResourceList {
|
|
|
145
159
|
settingsManager;
|
|
146
160
|
cwd;
|
|
147
161
|
agentDir;
|
|
162
|
+
writeScope;
|
|
163
|
+
inheritedEnabledByKey;
|
|
148
164
|
onCancel;
|
|
149
165
|
onExit;
|
|
150
166
|
onToggle;
|
|
167
|
+
onSwitchMode;
|
|
151
168
|
_focused = false;
|
|
152
169
|
get focused() {
|
|
153
170
|
return this._focused;
|
|
@@ -156,11 +173,13 @@ class ResourceList {
|
|
|
156
173
|
this._focused = value;
|
|
157
174
|
this.searchInput.focused = value;
|
|
158
175
|
}
|
|
159
|
-
constructor(
|
|
160
|
-
this.
|
|
176
|
+
constructor(groupsByScope, settingsManager, cwd, agentDir, terminalHeight, writeScope = "global") {
|
|
177
|
+
this.groupsByScope = groupsByScope;
|
|
161
178
|
this.settingsManager = settingsManager;
|
|
162
179
|
this.cwd = cwd;
|
|
163
180
|
this.agentDir = agentDir;
|
|
181
|
+
this.writeScope = writeScope;
|
|
182
|
+
this.inheritedEnabledByKey = this.buildInheritedEnabledMap(groupsByScope.global);
|
|
164
183
|
this.searchInput = new Input();
|
|
165
184
|
// 8 lines of chrome: top spacer + top border + spacer + header (2 lines) + spacer + bottom spacer + bottom border
|
|
166
185
|
const chrome = 8;
|
|
@@ -168,6 +187,25 @@ class ResourceList {
|
|
|
168
187
|
this.buildFlatList();
|
|
169
188
|
this.filteredItems = [...this.flatItems];
|
|
170
189
|
}
|
|
190
|
+
setWriteScope(writeScope) {
|
|
191
|
+
this.writeScope = writeScope;
|
|
192
|
+
this.buildFlatList();
|
|
193
|
+
this.filterItems(this.searchInput.getValue());
|
|
194
|
+
}
|
|
195
|
+
get groups() {
|
|
196
|
+
return this.groupsByScope[this.writeScope];
|
|
197
|
+
}
|
|
198
|
+
buildInheritedEnabledMap(groups) {
|
|
199
|
+
const result = new Map();
|
|
200
|
+
for (const group of groups) {
|
|
201
|
+
for (const subgroup of group.subgroups) {
|
|
202
|
+
for (const item of subgroup.items) {
|
|
203
|
+
result.set(this.getResourceItemKey(item), item.enabled);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
171
209
|
buildFlatList() {
|
|
172
210
|
this.flatItems = [];
|
|
173
211
|
for (const group of this.groups) {
|
|
@@ -274,21 +312,25 @@ class ResourceList {
|
|
|
274
312
|
const isSelected = i === this.selectedIndex;
|
|
275
313
|
if (entry.type === "group") {
|
|
276
314
|
// Main group header (no cursor)
|
|
277
|
-
const
|
|
315
|
+
const inherited = this.writeScope === "project" && entry.group.scope === "user";
|
|
316
|
+
const label = theme.bold(`${entry.group.label}${inherited ? " · inherited global" : ""}`);
|
|
317
|
+
const groupLine = theme.fg(inherited ? "dim" : "accent", label);
|
|
278
318
|
lines.push(truncateToWidth(` ${groupLine}`, width, ""));
|
|
279
319
|
}
|
|
280
320
|
else if (entry.type === "subgroup") {
|
|
281
321
|
// Subgroup header (indented, no cursor)
|
|
282
|
-
const
|
|
322
|
+
const color = this.writeScope === "project" && entry.group.scope === "user" ? "dim" : "muted";
|
|
323
|
+
const subgroupLine = theme.fg(color, entry.subgroup.label);
|
|
283
324
|
lines.push(truncateToWidth(` ${subgroupLine}`, width, ""));
|
|
284
325
|
}
|
|
285
326
|
else {
|
|
286
327
|
// Resource item (cursor only on items)
|
|
287
328
|
const item = entry.item;
|
|
288
329
|
const cursor = isSelected ? "> " : " ";
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
|
|
330
|
+
const dimmed = this.isDimmedItem(item);
|
|
331
|
+
const nameText = isSelected && !dimmed ? theme.bold(item.displayName) : item.displayName;
|
|
332
|
+
const name = dimmed ? theme.fg("dim", nameText) : nameText;
|
|
333
|
+
lines.push(truncateToWidth(`${cursor} ${this.renderCheckbox(item)} ${name}${this.getItemSuffix(item)}`, width, "..."));
|
|
292
334
|
}
|
|
293
335
|
}
|
|
294
336
|
// Scroll indicator
|
|
@@ -339,13 +381,18 @@ class ResourceList {
|
|
|
339
381
|
this.onExit?.();
|
|
340
382
|
return;
|
|
341
383
|
}
|
|
384
|
+
if (kb.matches(data, "tui.input.tab")) {
|
|
385
|
+
this.onSwitchMode?.();
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
342
388
|
if (data === " " || kb.matches(data, "tui.select.confirm")) {
|
|
343
389
|
const entry = this.filteredItems[this.selectedIndex];
|
|
344
|
-
if (entry?.type === "item") {
|
|
345
|
-
const newEnabled =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
390
|
+
if (entry?.type === "item" && (this.writeScope === "project" || this.getItemScope(entry.item) === "user")) {
|
|
391
|
+
const newEnabled = this.toggleResource(entry.item);
|
|
392
|
+
if (newEnabled !== undefined) {
|
|
393
|
+
this.updateItem(entry.item, newEnabled);
|
|
394
|
+
this.onToggle?.(entry.item, newEnabled);
|
|
395
|
+
}
|
|
349
396
|
}
|
|
350
397
|
return;
|
|
351
398
|
}
|
|
@@ -353,13 +400,21 @@ class ResourceList {
|
|
|
353
400
|
this.searchInput.handleInput(data);
|
|
354
401
|
this.filterItems(this.searchInput.getValue());
|
|
355
402
|
}
|
|
356
|
-
toggleResource(item
|
|
403
|
+
toggleResource(item) {
|
|
404
|
+
if (this.writeScope === "project") {
|
|
405
|
+
const state = this.getNextOverrideState(item);
|
|
406
|
+
if (!this.setProjectResourceOverride(item, state))
|
|
407
|
+
return undefined;
|
|
408
|
+
return state === "inherit" ? this.getInheritedEnabled(item) : state === "load";
|
|
409
|
+
}
|
|
410
|
+
const enabled = !item.enabled;
|
|
357
411
|
if (item.metadata.origin === "top-level") {
|
|
358
412
|
this.toggleTopLevelResource(item, enabled);
|
|
359
413
|
}
|
|
360
414
|
else {
|
|
361
415
|
this.togglePackageResource(item, enabled);
|
|
362
416
|
}
|
|
417
|
+
return enabled;
|
|
363
418
|
}
|
|
364
419
|
toggleTopLevelResource(item, enabled) {
|
|
365
420
|
const scope = item.metadata.scope;
|
|
@@ -457,6 +512,188 @@ class ResourceList {
|
|
|
457
512
|
this.settingsManager.setPackages(packages);
|
|
458
513
|
}
|
|
459
514
|
}
|
|
515
|
+
renderCheckbox(item) {
|
|
516
|
+
if (this.writeScope === "project") {
|
|
517
|
+
const state = this.getProjectOverrideState(item);
|
|
518
|
+
if (state === "load")
|
|
519
|
+
return theme.fg("success", "[+]");
|
|
520
|
+
if (state === "unload")
|
|
521
|
+
return theme.fg("warning", "[-]");
|
|
522
|
+
return theme.fg("dim", item.enabled ? "[x]" : "[ ]");
|
|
523
|
+
}
|
|
524
|
+
return item.enabled ? theme.fg("success", "[x]") : theme.fg("dim", "[ ]");
|
|
525
|
+
}
|
|
526
|
+
getItemSuffix(item) {
|
|
527
|
+
if (this.writeScope !== "project")
|
|
528
|
+
return "";
|
|
529
|
+
const state = this.getProjectOverrideState(item);
|
|
530
|
+
if (state === "load")
|
|
531
|
+
return theme.fg("muted", " project load");
|
|
532
|
+
if (state === "unload")
|
|
533
|
+
return theme.fg("muted", " project unload");
|
|
534
|
+
return this.isInheritedGlobalItem(item) ? theme.fg("dim", " inherited global") : "";
|
|
535
|
+
}
|
|
536
|
+
isDimmedItem(item) {
|
|
537
|
+
return (this.writeScope === "project" &&
|
|
538
|
+
this.isInheritedGlobalItem(item) &&
|
|
539
|
+
this.getProjectOverrideState(item) === "inherit");
|
|
540
|
+
}
|
|
541
|
+
setProjectResourceOverride(item, state) {
|
|
542
|
+
return item.metadata.origin === "top-level"
|
|
543
|
+
? this.setProjectTopLevelOverride(item, state)
|
|
544
|
+
: this.setProjectPackageOverride(item, state);
|
|
545
|
+
}
|
|
546
|
+
setProjectTopLevelOverride(item, state) {
|
|
547
|
+
const current = (this.settingsManager.getProjectSettings()[item.resourceType] ?? []);
|
|
548
|
+
const pattern = this.isInheritedGlobalItem(item) ? item.path : this.getResourcePatternForScope(item, "project");
|
|
549
|
+
const patterns = this.getTopLevelOverridePatterns(item, "project");
|
|
550
|
+
const updated = current.filter((entry) => {
|
|
551
|
+
const target = this.getPatternEntryTarget(entry);
|
|
552
|
+
if ((entry.startsWith("!") || entry.startsWith("+") || entry.startsWith("-")) && patterns.has(target))
|
|
553
|
+
return false;
|
|
554
|
+
return !(state === "inherit" && this.isInheritedGlobalItem(item) && target === pattern);
|
|
555
|
+
});
|
|
556
|
+
if (state !== "inherit") {
|
|
557
|
+
if (this.isInheritedGlobalItem(item) && !updated.includes(pattern))
|
|
558
|
+
updated.push(pattern);
|
|
559
|
+
updated.push(`${state === "load" ? "+" : "-"}${pattern}`);
|
|
560
|
+
}
|
|
561
|
+
this.setProjectTopLevelPaths(item.resourceType, updated);
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
setProjectTopLevelPaths(key, paths) {
|
|
565
|
+
if (key === "extensions")
|
|
566
|
+
this.settingsManager.setProjectExtensionPaths(paths);
|
|
567
|
+
else if (key === "skills")
|
|
568
|
+
this.settingsManager.setProjectSkillPaths(paths);
|
|
569
|
+
else if (key === "prompts")
|
|
570
|
+
this.settingsManager.setProjectPromptTemplatePaths(paths);
|
|
571
|
+
else
|
|
572
|
+
this.settingsManager.setProjectThemePaths(paths);
|
|
573
|
+
}
|
|
574
|
+
setProjectPackageOverride(item, state) {
|
|
575
|
+
const packages = [...(this.settingsManager.getProjectSettings().packages ?? [])];
|
|
576
|
+
let pkgIndex = packages.findIndex((pkg) => this.packageSourceStringMatches(item.metadata.source, this.getItemScope(item), typeof pkg === "string" ? pkg : pkg.source, "project"));
|
|
577
|
+
if (pkgIndex === -1) {
|
|
578
|
+
if (state === "inherit")
|
|
579
|
+
return false;
|
|
580
|
+
packages.push(this.createPackageOverrideSource(item));
|
|
581
|
+
pkgIndex = packages.length - 1;
|
|
582
|
+
}
|
|
583
|
+
let pkg = packages[pkgIndex];
|
|
584
|
+
if (pkg === undefined)
|
|
585
|
+
return false;
|
|
586
|
+
if (typeof pkg === "string") {
|
|
587
|
+
pkg = { source: pkg };
|
|
588
|
+
packages[pkgIndex] = pkg;
|
|
589
|
+
}
|
|
590
|
+
const pattern = this.getPackageResourcePattern(item);
|
|
591
|
+
const updated = (pkg[item.resourceType] ?? []).filter((entry) => this.getPatternEntryTarget(entry) !== pattern);
|
|
592
|
+
if (state !== "inherit")
|
|
593
|
+
updated.push(`${state === "load" ? "+" : "-"}${pattern}`);
|
|
594
|
+
pkg[item.resourceType] = updated.length > 0 ? updated : undefined;
|
|
595
|
+
if (!RESOURCE_TYPES.some((key) => pkg[key] !== undefined)) {
|
|
596
|
+
if (pkg.autoload === false)
|
|
597
|
+
packages.splice(pkgIndex, 1);
|
|
598
|
+
else
|
|
599
|
+
packages[pkgIndex] = pkg.source;
|
|
600
|
+
}
|
|
601
|
+
this.settingsManager.setProjectPackages(packages);
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
604
|
+
getNextOverrideState(item) {
|
|
605
|
+
const state = this.getProjectOverrideState(item);
|
|
606
|
+
const inheritedEnabled = this.getInheritedEnabled(item);
|
|
607
|
+
if (state === "inherit")
|
|
608
|
+
return inheritedEnabled ? "unload" : "load";
|
|
609
|
+
if (state === "unload")
|
|
610
|
+
return inheritedEnabled ? "load" : "inherit";
|
|
611
|
+
return inheritedEnabled ? "inherit" : "unload";
|
|
612
|
+
}
|
|
613
|
+
getProjectOverrideState(item) {
|
|
614
|
+
if (this.writeScope !== "project")
|
|
615
|
+
return "inherit";
|
|
616
|
+
if (item.metadata.origin === "top-level") {
|
|
617
|
+
return this.getOverrideStateFromEntries((this.settingsManager.getProjectSettings()[item.resourceType] ?? []), this.getTopLevelOverridePatterns(item, "project"), false);
|
|
618
|
+
}
|
|
619
|
+
const pkg = this.findMatchingPackageSource(item, "project");
|
|
620
|
+
if (typeof pkg !== "object")
|
|
621
|
+
return "inherit";
|
|
622
|
+
const entries = pkg[item.resourceType];
|
|
623
|
+
if (entries === undefined)
|
|
624
|
+
return "inherit";
|
|
625
|
+
return this.getOverrideStateFromEntries(entries, new Set([this.getPackageResourcePattern(item)]), pkg.autoload !== false);
|
|
626
|
+
}
|
|
627
|
+
getOverrideStateFromEntries(entries, patterns, emptyArrayIsUnload) {
|
|
628
|
+
if (entries.length === 0 && emptyArrayIsUnload)
|
|
629
|
+
return "unload";
|
|
630
|
+
let state = "inherit";
|
|
631
|
+
for (const entry of entries) {
|
|
632
|
+
if (!patterns.has(this.getPatternEntryTarget(entry)))
|
|
633
|
+
continue;
|
|
634
|
+
if (entry.startsWith("!") || entry.startsWith("-"))
|
|
635
|
+
state = "unload";
|
|
636
|
+
else
|
|
637
|
+
state = "load";
|
|
638
|
+
}
|
|
639
|
+
return state;
|
|
640
|
+
}
|
|
641
|
+
getInheritedEnabled(item) {
|
|
642
|
+
return (this.inheritedEnabledByKey.get(this.getResourceItemKey(item)) ??
|
|
643
|
+
(this.getItemScope(item) === "user" ? item.enabled : true));
|
|
644
|
+
}
|
|
645
|
+
isInheritedGlobalItem(item) {
|
|
646
|
+
return this.getItemScope(item) === "user" || this.inheritedEnabledByKey.has(this.getResourceItemKey(item));
|
|
647
|
+
}
|
|
648
|
+
getTopLevelOverridePatterns(item, scope) {
|
|
649
|
+
const baseDir = this.getTopLevelBaseDir(scope);
|
|
650
|
+
const patterns = new Set([
|
|
651
|
+
this.getResourcePatternForScope(item, scope),
|
|
652
|
+
item.path,
|
|
653
|
+
relative(baseDir, item.path),
|
|
654
|
+
]);
|
|
655
|
+
if (item.metadata.baseDir)
|
|
656
|
+
patterns.add(relative(item.metadata.baseDir, item.path));
|
|
657
|
+
return patterns;
|
|
658
|
+
}
|
|
659
|
+
getResourcePatternForScope(item, scope) {
|
|
660
|
+
const sourceScope = this.getItemScope(item);
|
|
661
|
+
if (scope !== sourceScope)
|
|
662
|
+
return item.path;
|
|
663
|
+
const baseDir = item.metadata.baseDir ?? this.getTopLevelBaseDir(sourceScope);
|
|
664
|
+
return relative(baseDir, item.path);
|
|
665
|
+
}
|
|
666
|
+
createPackageOverrideSource(item) {
|
|
667
|
+
const source = item.metadata.source;
|
|
668
|
+
if (!isLocalPath(source))
|
|
669
|
+
return { source, autoload: false };
|
|
670
|
+
const sourcePath = resolvePath(source, this.getTopLevelBaseDir(this.getItemScope(item)), { trim: true });
|
|
671
|
+
return { source: relative(this.getTopLevelBaseDir("project"), sourcePath) || ".", autoload: false };
|
|
672
|
+
}
|
|
673
|
+
packageSourceStringMatches(leftSource, leftScope, rightSource, rightScope) {
|
|
674
|
+
if (leftSource === rightSource)
|
|
675
|
+
return true;
|
|
676
|
+
if (!isLocalPath(leftSource) || !isLocalPath(rightSource))
|
|
677
|
+
return false;
|
|
678
|
+
const left = resolvePath(leftSource, this.getTopLevelBaseDir(leftScope), { trim: true });
|
|
679
|
+
const right = resolvePath(rightSource, this.getTopLevelBaseDir(rightScope), { trim: true });
|
|
680
|
+
return left === right;
|
|
681
|
+
}
|
|
682
|
+
findMatchingPackageSource(item, targetScope) {
|
|
683
|
+
const settings = targetScope === "project"
|
|
684
|
+
? this.settingsManager.getProjectSettings()
|
|
685
|
+
: this.settingsManager.getGlobalSettings();
|
|
686
|
+
return (settings.packages ?? []).find((pkg) => this.packageSourceStringMatches(item.metadata.source, this.getItemScope(item), typeof pkg === "string" ? pkg : pkg.source, targetScope));
|
|
687
|
+
}
|
|
688
|
+
getPatternEntryTarget(entry) {
|
|
689
|
+
return entry.startsWith("!") || entry.startsWith("+") || entry.startsWith("-") ? entry.slice(1) : entry;
|
|
690
|
+
}
|
|
691
|
+
getResourceItemKey(item) {
|
|
692
|
+
return `${item.resourceType}:${canonicalizePath(item.path)}`;
|
|
693
|
+
}
|
|
694
|
+
getItemScope(item) {
|
|
695
|
+
return item.metadata.scope === "project" ? "project" : "user";
|
|
696
|
+
}
|
|
460
697
|
getTopLevelBaseDir(scope) {
|
|
461
698
|
return scope === "project" ? join(this.cwd, CONFIG_DIR_NAME) : this.agentDir;
|
|
462
699
|
}
|
|
@@ -471,7 +708,9 @@ class ResourceList {
|
|
|
471
708
|
}
|
|
472
709
|
}
|
|
473
710
|
export class ConfigSelectorComponent extends Container {
|
|
711
|
+
header;
|
|
474
712
|
resourceList;
|
|
713
|
+
writeScope;
|
|
475
714
|
_focused = false;
|
|
476
715
|
get focused() {
|
|
477
716
|
return this._focused;
|
|
@@ -480,25 +719,41 @@ export class ConfigSelectorComponent extends Container {
|
|
|
480
719
|
this._focused = value;
|
|
481
720
|
this.resourceList.focused = value;
|
|
482
721
|
}
|
|
483
|
-
constructor(resolvedPaths, settingsManager, cwd, agentDir, onClose, onExit, requestRender, terminalHeight) {
|
|
722
|
+
constructor(resolvedPaths, settingsManager, cwd, agentDir, onClose, onExit, requestRender, terminalHeight, writeScope = "global", projectModeAvailable = true) {
|
|
484
723
|
super();
|
|
485
|
-
|
|
724
|
+
this.writeScope = writeScope;
|
|
725
|
+
const groupsByScope = {
|
|
726
|
+
global: buildGroups(resolvedPaths.global, agentDir),
|
|
727
|
+
project: buildGroups(resolvedPaths.project, agentDir),
|
|
728
|
+
};
|
|
486
729
|
// Add header
|
|
487
730
|
this.addChild(new Spacer(1));
|
|
488
731
|
this.addChild(new DynamicBorder());
|
|
489
732
|
this.addChild(new Spacer(1));
|
|
490
|
-
this.
|
|
733
|
+
this.header = new ConfigSelectorHeader(this.writeScope, projectModeAvailable);
|
|
734
|
+
this.addChild(this.header);
|
|
491
735
|
this.addChild(new Spacer(1));
|
|
492
736
|
// Resource list
|
|
493
|
-
this.resourceList = new ResourceList(
|
|
737
|
+
this.resourceList = new ResourceList(groupsByScope, settingsManager, cwd, agentDir, terminalHeight, this.writeScope);
|
|
494
738
|
this.resourceList.onCancel = onClose;
|
|
495
739
|
this.resourceList.onExit = onExit;
|
|
496
740
|
this.resourceList.onToggle = () => requestRender();
|
|
741
|
+
if (projectModeAvailable) {
|
|
742
|
+
this.resourceList.onSwitchMode = () => {
|
|
743
|
+
this.switchWriteScope();
|
|
744
|
+
requestRender();
|
|
745
|
+
};
|
|
746
|
+
}
|
|
497
747
|
this.addChild(this.resourceList);
|
|
498
748
|
// Bottom border
|
|
499
749
|
this.addChild(new Spacer(1));
|
|
500
750
|
this.addChild(new DynamicBorder());
|
|
501
751
|
}
|
|
752
|
+
switchWriteScope() {
|
|
753
|
+
this.writeScope = this.writeScope === "global" ? "project" : "global";
|
|
754
|
+
this.header.setWriteScope(this.writeScope);
|
|
755
|
+
this.resourceList.setWriteScope(this.writeScope);
|
|
756
|
+
}
|
|
502
757
|
getResourceList() {
|
|
503
758
|
return this.resourceList;
|
|
504
759
|
}
|