···114114 npxDependencies: extractNpxDependencies(scripts),
115115 }
116116}
117117+118118+/**
119119+ * Pattern to match scripts that are just `node <file-path>`
120120+ * Captures the file path (relative paths with alphanumeric chars, dots, hyphens, underscores, and slashes)
121121+ */
122122+const NODE_SCRIPT_PATTERN = /^node\s+([\w./-]+)$/
123123+124124+/**
125125+ * Get the file path for an install script link.
126126+ * - If the script is `node <file-path>`, returns that file path
127127+ * - Otherwise, returns 'package.json'
128128+ *
129129+ * @param scriptContent - The content of the script
130130+ * @returns The file path to link to in the code tab
131131+ */
132132+export function getInstallScriptFilePath(scriptContent: string): string {
133133+ const match = NODE_SCRIPT_PATTERN.exec(scriptContent)
134134+135135+ if (match?.[1]) {
136136+ // Script is `node <file-path>`, link to that file
137137+ // Normalize path: strip leading ./
138138+ const filePath = match[1].replace(/^\.\//, '')
139139+140140+ // Fall back to package.json if path contains navigational elements (the client-side routing can't handle these well)
141141+ if (filePath.includes('../') || filePath.includes('./')) {
142142+ return 'package.json'
143143+ }
144144+145145+ return filePath
146146+ }
147147+148148+ // Default: link to package.json
149149+ return 'package.json'
150150+}
151151+152152+/**
153153+ * Parse an install script into a prefix and a linkable file path.
154154+ * - If the script is `node <file-path>`, returns { prefix: 'node ', filePath: '<file-path>' }
155155+ * so only the file path portion can be rendered as a link.
156156+ * - Otherwise, returns null (the entire script content should link to package.json).
157157+ *
158158+ * @param scriptContent - The content of the script
159159+ * @returns Parsed parts, or null if no node file path was extracted
160160+ */
161161+export function parseNodeScript(
162162+ scriptContent: string,
163163+): { prefix: string; filePath: string } | null {
164164+ const match = NODE_SCRIPT_PATTERN.exec(scriptContent)
165165+166166+ if (match?.[1]) {
167167+ const filePath = match[1].replace(/^\.\//, '')
168168+169169+ // Fall back if path contains navigational elements
170170+ if (filePath.includes('../') || filePath.includes('./')) {
171171+ return null
172172+ }
173173+174174+ // Reconstruct the prefix (everything before the captured file path)
175175+ const prefix = scriptContent.slice(0, match.index + match[0].indexOf(match[1]))
176176+ return { prefix, filePath }
177177+ }
178178+179179+ return null
180180+}