#!/usr/bin/env node import { readFile, readdir } from "node:fs/promises"; import { extname, join } from "node:path"; import { fileURLToPath } from "node:url"; const root = process.argv[2] || fileURLToPath(new URL("../apps/zcode-cli/packages", import.meta.url)); const extensions = new Set([".md", ".sh", ".ps1", ".py", ".js", ".mjs", ".ts"]); const selection = /\$\(command -v zcode-python \|\| command -v python3\)/g; // 只匹配命令形态;语言名、包名、围栏标签、shebang 和字典键不是调用。 function hasBareCommand(line, extension) { if (line.startsWith("#!")) return false; // Markdown 表格里的管道符必须转义,扫描时还原呈现给 Agent 的命令。 const command = extension === ".md" && line.trimStart().startsWith("|") ? line.replaceAll("\\|", "|") : line; const text = command.replace(selection, "SELECTED_PYTHON"); return ( /(?