MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / walk

Function walk

source code/utils/plugins/dependencyResolver.ts:108–156  ·  view source on GitHub ↗
(
    id: PluginId,
    requiredBy: PluginId,
  )

Source from the content-addressed store, hash-verified

106 const stack: PluginId[] = []
107
108 async function walk(
109 id: PluginId,
110 requiredBy: PluginId,
111 ): Promise<ResolutionResult | null> {
112 // Skip already-enabled DEPENDENCIES (avoids surprise settings writes),
113 // but NEVER skip the root: installing an already-enabled plugin must
114 // still cache/register it. Without this guard, re-installing a plugin
115 // that's in settings but missing from disk (e.g., cache cleared,
116 // installed_plugins.json stale) would return an empty closure and
117 // `cacheAndRegisterPlugin` would never fire — user sees
118 // "✔ Successfully installed" but nothing materializes.
119 if (id !== rootId && alreadyEnabled.has(id)) return null
120 // Security: block auto-install across marketplace boundaries. Runs AFTER
121 // the alreadyEnabled check — if the user manually installed a cross-mkt
122 // dep, it's in alreadyEnabled and we never reach this.
123 const idMarketplace = parsePluginIdentifier(id).marketplace
124 if (
125 idMarketplace !== rootMarketplace &&
126 !(idMarketplace && allowedCrossMarketplaces.has(idMarketplace))
127 ) {
128 return {
129 ok: false,
130 reason: 'cross-marketplace',
131 dependency: id,
132 requiredBy,
133 }
134 }
135 if (stack.includes(id)) {
136 return { ok: false, reason: 'cycle', chain: [...stack, id] }
137 }
138 if (visited.has(id)) return null
139 visited.add(id)
140
141 const entry = await lookup(id)
142 if (!entry) {
143 return { ok: false, reason: 'not-found', missing: id, requiredBy }
144 }
145
146 stack.push(id)
147 for (const rawDep of entry.dependencies ?? []) {
148 const dep = qualifyDependency(rawDep, id)
149 const err = await walk(dep, id)
150 if (err) return err
151 }
152 stack.pop()
153
154 closure.push(id)
155 return null
156 }
157
158 const err = await walk(rootId, rootId)
159 if (err) return err

Callers 1

resolveDependencyClosureFunction · 0.70

Calls 4

parsePluginIdentifierFunction · 0.85
qualifyDependencyFunction · 0.85
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected