|
1 | | -import { GSTACK_BADGE_AGENT_IDS } from '@/shared/constants' |
| 1 | +import { isGStackManagedForAgent } from '@/renderer/src/utils/gstackSkill' |
2 | 2 | import type { AgentId, Skill, SymlinkInfo } from '@/shared/types' |
3 | 3 |
|
4 | 4 | /** |
@@ -37,31 +37,6 @@ export interface SkillItemVisibility { |
37 | 37 | */ |
38 | 38 | export type SkillVisibilityInput = Pick<Skill, 'symlinks' | 'isOrphan'> |
39 | 39 |
|
40 | | -/** |
41 | | - * Path-segment matcher for `.../skills/gstack/...` on both POSIX and Windows |
42 | | - * paths. Requires a `skills/` parent so a user-created directory literally |
43 | | - * named `gstack` outside any agent's skills tree (e.g. `~/projects/gstack/foo`) |
44 | | - * cannot trigger the badge — a finding raised by the Codex review. |
45 | | - */ |
46 | | -const GSTACK_SEGMENT_PATTERN = /[\\/]skills[\\/]gstack([\\/]|$)/i |
47 | | - |
48 | | -/** |
49 | | - * Detect whether a filesystem-like path points to a G-Stack-managed location. |
50 | | - * @param candidatePath - Path candidate from symlink target or link path. |
51 | | - * @returns |
52 | | - * - `true`: Path contains a `skills/gstack/` segment. |
53 | | - * - `false`: Empty path, or `gstack/` lives outside any `skills/` parent. |
54 | | - * @example |
55 | | - * isGStackBundlePath('/Users/me/.claude/skills/gstack/skill-a') // => true |
56 | | - * @example |
57 | | - * isGStackBundlePath('/Users/me/.agents/skills/task') // => false |
58 | | - * @example |
59 | | - * isGStackBundlePath('/Users/me/projects/gstack/skill-a') // => false |
60 | | - */ |
61 | | -function isGStackBundlePath(candidatePath: string): boolean { |
62 | | - return GSTACK_SEGMENT_PATTERN.test(candidatePath) |
63 | | -} |
64 | | - |
65 | 40 | /** |
66 | 41 | * Compute which action buttons to show on a SkillItem card. |
67 | 42 | * |
@@ -128,23 +103,7 @@ export function getSkillItemVisibility( |
128 | 103 | const hasSkillInSelectedAgent = !!selectedAgentSymlink || isLocalSkill |
129 | 104 | // Orphan handling — see Skill.isOrphan for why the Add button is gated. |
130 | 105 | // Source: scanOrphanSymlinks() in src/main/services/skillScanner.ts. |
131 | | - // |
132 | | - // gStackPathCandidates — paths inspected for the `skills/gstack/` segment |
133 | | - // that identifies a gstack-managed skill. `skillMdSymlinkTarget` is read |
134 | | - // ONLY from the selected agent's slot (per-agent attribution): a sibling |
135 | | - // agent's gstack-managed twin must not flip the badge on this agent's |
136 | | - // unrelated local skill that happens to share a name. |
137 | | - const gStackPathCandidates = [ |
138 | | - selectedAgentSymlink?.targetPath ?? '', |
139 | | - selectedAgentSymlink?.linkPath ?? '', |
140 | | - selectedLocalSkillInfo?.linkPath ?? '', |
141 | | - selectedLocalSkillInfo?.skillMdSymlinkTarget ?? '', |
142 | | - ] |
143 | | - const isGStackEligibleAgent = |
144 | | - selectedAgentId !== null && |
145 | | - GSTACK_BADGE_AGENT_IDS.some((agentId) => agentId === selectedAgentId) |
146 | | - const showGStackBadge = |
147 | | - isGStackEligibleAgent && gStackPathCandidates.some(isGStackBundlePath) |
| 106 | + const showGStackBadge = isGStackManagedForAgent(skill, selectedAgentId) |
148 | 107 |
|
149 | 108 | return { |
150 | 109 | // Delete is the primary cleanup action for orphans in global view — |
|
0 commit comments