# deepsec - Doramagic AI Context Pack

> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。

## 充分原则

- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。
- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 deepsec 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。

## Claim 消费规则

- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。
- **事实最低状态**：`supported`
- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。
- `weak`：只能作为低置信度线索，必须要求用户继续核实。
- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。
- `unverified`：不得作为事实使用，应明确说证据不足。
- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。

## 它最适合谁

- **正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**：README 或插件配置提到多个宿主 AI。 证据：`README.md` Claim：`clm_0003` supported 0.86
- **希望把专业流程带进宿主 AI 的用户**：仓库包含 Skill 文档。 证据：`packages/deepsec/SKILL.md` Claim：`clm_0004` supported 0.86

## 它能做什么

- **AI Skill / Agent 指令资产库**（可做安装前预览）：项目包含可被宿主 AI 读取的 Skill 或 Agent 指令文件，可用于把专业流程带入 Claude、Codex、Cursor 等宿主。 证据：`packages/deepsec/SKILL.md` Claim：`clm_0001` supported 0.86
- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0002` supported 0.86

## 怎么开始

- `npx deepsec init       # creates .deepsec/ with this repo as the first project` 证据：`README.md` Claim：`clm_0005` supported 0.86

## 继续前判断卡

- **当前建议**：需要管理员/安全审批
- **为什么**：继续前可能涉及密钥、账号、外部服务或敏感上下文，建议先经过管理员或安全审批。

### 30 秒判断

- **现在怎么做**：需要管理员/安全审批
- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装
- **先别相信**：真实输出质量不能在安装前相信。
- **继续会触碰**：命令执行、宿主 AI 配置、本地环境或项目文件

### 现在可以相信

- **适合人群线索：正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0003` supported 0.86
- **适合人群线索：希望把专业流程带进宿主 AI 的用户**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`packages/deepsec/SKILL.md` Claim：`clm_0004` supported 0.86
- **能力存在：AI Skill / Agent 指令资产库**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`packages/deepsec/SKILL.md` Claim：`clm_0001` supported 0.86
- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0005` supported 0.86

### 现在还不能相信

- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。 证据：`CLAUDE.md`, `packages/deepsec/SKILL.md`
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。
- **安装命令是否需要网络、权限或全局写入？**（unverified）：这影响企业环境和个人环境的安装风险。 证据：`README.md`

### 继续会触碰什么

- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`
- **宿主 AI 配置**：Claude/Codex/Cursor/Gemini/OpenCode 等宿主的 plugin、Skill 或规则加载配置。 原因：宿主配置会改变 AI 后续工作方式，可能和用户已有规则冲突。 证据：`CLAUDE.md`, `packages/deepsec/SKILL.md`
- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`
- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`.deepsec/data/deepsec/INFO.md`, `.deepsec/data/deepsec/files/.github/workflows/deepsec.yml.json`, `.deepsec/data/deepsec/files/packages/deepsec/src/preflight.ts.json`, `.deepsec/data/deepsec/files/packages/deepsec/src/sandbox/setup.ts.json` 等
- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：用安装前交互式试用判断工作方式是否匹配，不需要授权或改环境。（适用：任何项目都适用，尤其是输出质量未知时。）
- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）
- **先备份宿主 AI 配置**：Skill、plugin、规则文件可能改变 Claude/Cursor/Codex 的默认行为。（适用：存在插件 manifest、Skill 或宿主规则入口时。）
- **不要使用真实生产凭证**：环境变量/API key 一旦进入宿主或工具链，可能产生账号和合规风险。（适用：出现 API、TOKEN、KEY、SECRET 等环境线索时。）
- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）

### 退出方式

- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。
- **准备移除宿主 plugin / Skill / 规则入口**：如果试装后行为异常，可以把宿主 AI 恢复到试装前状态。
- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。
- **准备撤销测试 API key 或 token**：测试凭证泄露或误用时，可以快速止损。
- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。

## 哪些只能预览

- 解释项目适合谁和能做什么
- 基于项目文档演示典型对话流程
- 帮助用户判断是否值得安装或继续研究

## 哪些必须安装后验证

- 真实安装 Skill、插件或 CLI
- 执行脚本、修改本地文件或访问外部服务
- 验证真实输出质量、性能和兼容性

## 边界与风险判断卡

- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0006` inferred 0.45
- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0007` supported 0.86
- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。
- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。
- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。

## 开工前工作上下文

### 加载顺序

- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。
- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。
- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。
- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。
- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。

### 任务路由

- **AI Skill / Agent 指令资产库**：先基于 role_skill_index / evidence_index 帮用户挑选可用角色、Skill 或工作流。 边界：可做安装前 Prompt 体验。 证据：`packages/deepsec/SKILL.md` Claim：`clm_0001` supported 0.86
- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0002` supported 0.86

### 上下文规模

- 文件总数：665
- 重要文件覆盖：40/665
- 证据索引条目：78
- 角色 / Skill 条目：1

### 证据不足时的处理

- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。
- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。
- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。
- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。

## Prompt Recipes

### 适配判断

- 目标：判断这个项目是否适合用户当前任务。
- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。

```text
请基于 deepsec 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。
```

### 安装前体验

- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。
- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。

```text
请把 deepsec 当作安装前体验资产，而不是已安装工具或真实运行环境。

请严格输出四段：
1. 先问我 3 个必要问题。
2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。
3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。
4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。

硬性边界：
- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。
- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。
- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。
- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。
- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。
- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。

```

### 角色 / Skill 选择

- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。
- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。

```text
请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。
```

### 风险预检

- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。
- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。

```text
请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。
```

### 宿主 AI 开工指令

- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。
- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。

```text
请基于 deepsec 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```

## 角色 / Skill 索引

- 共索引 1 个角色 / Skill / 项目文档条目。

- **deepsec**（skill）：Use deepsec an AI-powered vulnerability scanner — running scans, configuring projects, writing matchers, and authoring plugins. Activates when the user asks how to scan, configure, or extend deepsec in a project that has deepsec installed. 激活提示：当用户任务与“deepsec”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`packages/deepsec/SKILL.md`

## 证据索引

- 共索引 78 条证据。

- **deepsec**（documentation）：This directory holds the deepsec https://www.npmjs.com/package/deepsec config for the parent repo. Checked into git so teammates inherit project context auth shape, threat model, custom matchers AND the per-file investigation cache — committing data/ /files/ is what lets CI re-investigate only the files in the PR diff instead of starting from scratch every run. 证据：`.deepsec/README.md`
- **deepsec**（documentation）：deepsec an agent-powered vulnerability scanner that you can run in your own infrastructure, optimized to perform on-demand review of all code in existing large-scale repos. 证据：`README.md`
- **Samples**（documentation）：Copy-paste starting points showing how deepsec looks in practice. 证据：`samples/README.md`
- **Getting Started**（documentation）：This is a Next.js https://nextjs.org project bootstrapped with create-next-app https://nextjs.org/docs/app/api-reference/cli/create-next-app . 证据：`packages/website/README.md`
- **webapp sample**（documentation）：A fictional inventory webapp "Acme" with deepsec wired up. This is the rich reference — a worked plugin + custom matchers + filled-in INFO.md showing what a scanning workspace looks like once it's been loved on for a while. 证据：`samples/webapp/README.md`
- **Agent setup**（documentation）：This is a deepsec scanning workspace. Each registered project has its own setup prompt at data/ /SETUP.md — open the relevant one when asked to set a project up. 证据：`.deepsec/AGENTS.md`
- **CLAUDE.md**（documentation）：Pointer file for Claude Code working in this repo. User-facing docs are in README.md ./README.md ; contributor docs in CONTRIBUTING.md ./CONTRIBUTING.md . Read those first. 证据：`CLAUDE.md`
- **Pipeline**（documentation）：Each stage is a separate CLI subcommand and reads/writes a consistent on-disk representation. Stages are idempotent: re-running merges new information rather than overwriting. 证据：`docs/architecture.md`
- **project.json — ProjectConfig**（documentation）：data/ is deepsec's on-disk state. Each project owns a subdirectory; the files inside are append-only across runs. 证据：`docs/data-layout.md`
- **Install**（documentation）：Requires Node.js 22+ . The recipe below uses pnpm; npm and yarn work the same way. 证据：`docs/getting-started.md`
- **CLI selection**（documentation）：deepsec talks to LLMs through interchangeable agent backends: 证据：`docs/models.md`
- **When to write one**（documentation）：This doc is for users running deepsec inside a .deepsec/ workspace — i.e. you ran npx deepsec init , deepsec is installed in node modules/ , and you have a data/ / directory with at least one scan in it. The matchers you write here live in your config; they ship alongside deepsec's built-ins for the projects in this workspace. 证据：`docs/writing-matchers.md`
- **Package**（package_manifest）：{ "name": "deepsec-workspace", "version": "0.1.0", "private": true, "description": "deepsec scanning workspace", "type": "module", "scripts": { "deepsec": "pnpm -s -C ../packages/deepsec bundle && pnpm exec deepsec" }, "dependencies": { "deepsec": "link:../packages/deepsec" } } 证据：`.deepsec/package.json`
- **Package**（package_manifest）：{ "name": "deepsec-monorepo", "version": "0.1.0", "private": true, "type": "module", "description": "AI-powered vulnerability scanner for any codebase", "license": "Apache-2.0", "engines": { "node": " =22" }, "packageManager": "pnpm@8.15.9", "repository": { "type": "git", "url": "https://github.com/vercel-labs/deepsec" }, "scripts": { "build": "pnpm -r build", "bundle": "pnpm --filter deepsec bundle", "deepsec": "tsx packages/deepsec/src/cli.ts", "test": "vitest run", "test:unit": "vitest run --project core --project scanner --project processor --project cli", "test:e2e": "vitest run --project e2e", "test:e2e:live": "LIVE AGENT=1 vitest run --project e2e", "test:bundle": "pnpm bundle && vit… 证据：`package.json`
- **Contributing to deepsec**（documentation）：The most useful contributions are new matchers and new plugins . Both have dedicated guides: 证据：`CONTRIBUTING.md`
- **Package**（package_manifest）：{ "name": "@deepsec/core", "version": "0.1.0", "private": true, "type": "module", "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "tsc" }, "dependencies": { "zod": "^3.24.0" } } 证据：`packages/core/package.json`
- **Package**（package_manifest）：{ "name": "deepsec", "version": "2.2.3", "description": "AI-powered vulnerability scanner for any codebase", "license": "Apache-2.0", "repository": { "type": "git", "url": "https://github.com/vercel-labs/deepsec" }, "type": "module", "bin": { "deepsec": "./dist/cli.mjs" }, "exports": { ".": "./dist/cli.mjs", "./config": { "types": "./dist/config.d.ts", "import": "./dist/config.mjs" } }, "files": "dist", "README.md", "LICENSE", "NOTICE", "SKILL.md" , "scripts": { "build": "tsc --noEmit", "bundle": "pnpm --filter @deepsec/core --filter @deepsec/scanner build && node build.mjs", "prepack": "pnpm bundle", "prepublishOnly": "pnpm -w validate && node -e \"const fs=require 'node:fs' ;for const f o… 证据：`packages/deepsec/package.json`
- **Package**（package_manifest）：{ "name": "@deepsec/processor", "version": "0.1.0", "private": true, "type": "module", "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "tsc" }, "dependencies": { "@anthropic-ai/claude-agent-sdk": "^0.3.158", "@deepsec/core": "workspace: ", "@deepsec/scanner": "workspace: ", "@earendil-works/pi-coding-agent": "0.79.10", "@openai/codex": "^0.144.0", "@openai/codex-sdk": "^0.144.0", "jsonrepair": "^3.14.0" } } 证据：`packages/processor/package.json`
- **Package**（package_manifest）：{ "name": "@deepsec/scanner", "version": "0.1.0", "private": true, "type": "module", "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "tsc" }, "dependencies": { "@deepsec/core": "workspace: ", "glob": "^11.0.0", "minimatch": "^10.0.0" } } 证据：`packages/scanner/package.json`
- **Package**（package_manifest）：{ "name": "website", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "eslint", "postinstall": "fumadocs-mdx" }, "dependencies": { "@vercel/analytics": "2.0.1", "@vercel/geistdocs": "1.8.0", "@vercel/speed-insights": "2.0.0", "feed": "^5.2.1", "fumadocs-mdx": "14.0.4", "next": "16.2.6", "react": "19.2.6", "react-dom": "19.2.6" }, "devDependencies": { "@tailwindcss/postcss": "^4.3.0", "@types/mdx": "^2.0.14", "@types/node": "^25.9.1", "@types/react": "^19.2.15", "@types/react-dom": "^19.2.3", "eslint": "^9", "eslint-config-next": "16.2.6", "postcss": "^8.5.19", "typescript": "^5" }, "pnpm": { "overrides": { "postcss@ =… 证据：`packages/website/package.json`
- **Package**（package_manifest）：{ "name": "deepsec-workspace-sample", "version": "0.1.0", "private": true, "description": "deepsec workspace for the webapp sample.", "type": "module", "dependencies": { "deepsec": "^0.1.0" } } 证据：`samples/webapp/package.json`
- **deepsec**（skill_instruction）：deepsec is an AI-powered vulnerability scanner. This skill activates when deepsec ships inside node modules/ — typically because the user ran npx deepsec … which caches the package locally . In the more common dedicated-git setup the user works inside a clone of vercel-labs/deepsec and the same docs sit at docs/ from the repo root — read those instead when this skill fires from outside a node modules. 证据：`packages/deepsec/SKILL.md`
- **License**（source_file）：Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ 证据：`LICENSE`
- **Top-level fields**（documentation）：deepsec reads deepsec.config.{ts,mjs,js,cjs} from the current working directory, walking up. The CLI inherits whatever the file declares. 证据：`docs/configuration.md`
- **How should I install deepsec?**（documentation）：deepsec lives in a .deepsec/ directory at the root of the repo you want to scan, checked into git so teammates inherit project context. From the codebase's repo root: 证据：`docs/faq.md`
- **Where to put your plugin**（documentation）：A deepsec plugin can fill any of five slots: 证据：`docs/plugins.md`
- **How it differs from a full scan**（documentation）：deepsec process has a direct-invocation mode for reviewing a specific set of files — typically the files changed in a pull request. This is the right tool when you want a fast, scoped read of changed code in CI, rather than a whole-repo audit. 证据：`docs/reviewing-changes.md`
- **TypeScript / JavaScript Node, Bun, Deno, Workers**（documentation）：Canonical list of frameworks and ecosystems deepsec recognizes out of the box. Each entry tells you three things: 证据：`docs/supported-tech.md`
- **AI Gateway**（documentation）：deepsec uses two Vercel products. Most people only need the first. 证据：`docs/vercel-setup.md`
- **Run.Ts**（structured_config）：{ "filePath": "packages/core/src/run.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "rce", "lineNumbers": 31, 36 , "snippet": "function detectGithubUrl rootPath: string : string undefined {\n try {\n const remote = execSync \"git remote get-url origin\", {\n cwd: rootPath,\n encoding: \"utf-8\",", "matchedPattern": "execSync" }, { "vulnSlug": "path-traversal", "lineNumbers": 99 , "snippet": " runId,\n projectId: params.projectId,\n rootPath: path.resolve params.rootPath ,\n createdAt: new Date .toISOString ,\n type: params.type,", "matchedPattern": "path.resolve with request-derived input" }, { "vulnSlug": "insecure-crypto", "lineNumbers": 43 , "snippet": " // Convert SSH to HTTPS… 证据：`.deepsec/data/deepsec/files/packages/core/src/run.ts.json`
- **Cli.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/cli.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 27, 45, 77, 97, 125, 156, 166, 195, 211, 225, 234, 271, 278, 305 , "snippet": "program\n .name \"deepsec\" \n .description \"AI-powered vulnerability scanner for any codebase\" \n .version \"0.1.0\" \n .addHelpText ", "matchedPattern": "weak cipher algorithm" }, { "vulnSlug": "process-env-access", "lineNumbers": 326 , "snippet": "function printFatal err: unknown : never {\n const verbose = process.env.DEEPSEC DEBUG === \"1\";\n console.error \\n${err instanceof Error ? err.message : err} ;", "matchedPattern": "process.env.DEEPSEC DEBUG" }, { "vulnSlug": "insecur… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/cli.ts.json`
- **Export.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/commands/export.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 235 , "snippet": "function findingFilename f: ExportedFinding : string {\n const hash = crypto\n .createHash \"sha1\" \n .update \n ${f.metadata.projectId}\\0${f.metadata.filePath}\\0${f.metadata.lineNumbers.join \",\" }\\0${f.metadata.vulnSlug} ,", "matchedPattern": "SHA1 hash" }, { "vulnSlug": "insecure-crypto", "lineNumbers": 29, 120, 173, 265, 428 , "snippet": "interface ExportedFinding {\n title: string;\n description: string;\n severity: Severity;\n labels: string ;", "matchedPattern": "weak cipher algorithm" }, { "vulnSlug": "git-provider-url-… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/commands/export.ts.json`
- **Process.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/commands/process.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 213 , "snippet": " 3. Run a scoped scanFiles so each path has a FileRecord — this\n gives the agent regex-derived signals to anchor on, even when the\n diff includes files outside any matcher's pattern set.\n 4. Run process over those exact paths.\n 5. Optionally render a PR-comment markdown.", "matchedPattern": "weak cipher algorithm" } , "lastScannedAt": "2026-05-06T21:46:56.501Z", "lastScannedRunId": "20260506214655-aa977d40dc0c6524", "fileHash": "bd653022287a4e678a348ce889ff8c046dd506bb4bf5d0d0098025c9953e13fe", "findings": , "analysisHistory":… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/commands/process.ts.json`
- **Scan.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/commands/scan.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "xss", "lineNumbers": 43 , "snippet": " No root path for project \"${opts.projectId}\".\\n +\n Pass --root , or add the project to deepsec.config.ts:\\n +\n projects: { id: \"${opts.projectId}\", root: \" \" } ,\n ;\n}", "matchedPattern": "template literal in HTML" }, { "vulnSlug": "xss", "lineNumbers": 43, 302 , "snippet": " No root path for project \"${opts.projectId}\".\\n +\n Pass --root , or add the project to deepsec.config.ts:\\n +\n projects: { id: \"${opts.projectId}\", root: \" \" } ,\n ;\n}", "matchedPattern": "template literal in HTML" }, { "vulnSlug": "insecure-crypto", "l… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/commands/scan.ts.json`
- **Pr Comment.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/pr-comment.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "xss", "lineNumbers": 94, 106 , "snippet": " if source {\n lines.push \"\" ;\n lines.push scope: \\ ${source}\\ · run \\ ${runId}\\ ;\n }\n lines.push \"\" ;", "matchedPattern": "template literal in HTML" }, { "vulnSlug": "insecure-crypto", "lineNumbers": 109, 110 , "snippet": " }\n lines.push \"\" ;\n if finding.description {\n lines.push truncate finding.description, 600 ;\n lines.push \"\" ;", "matchedPattern": "weak cipher algorithm" } , "lastScannedAt": "2026-05-06T21:46:56.473Z", "lastScannedRunId": "20260506214655-aa977d40dc0c6524", "fileHash": "ff95db08517f0ec6245f94bb8aa35e34a06b… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/pr-comment.ts.json`
- **Preflight.Ts**（structured_config）：{ "filePath": "packages/deepsec/src/preflight.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "env-var-as-bool", "lineNumbers": 32, 34, 35, 51, 52, 80, 83 , "snippet": " /\nexport function applyAiGatewayDefaults : void {\n const key = process.env.AI GATEWAY API KEY;\n if !key return;\n if !process.env.ANTHROPIC AUTH TOKEN process.env.ANTHROPIC AUTH TOKEN = key;", "matchedPattern": "Secret env var used as boolean" }, { "vulnSlug": "process-env-access", "lineNumbers": 32 , "snippet": "export function applyAiGatewayDefaults : void {\n const key = process.env.AI GATEWAY API KEY;\n if !key return;", "matchedPattern": "process.env.AI GATEWAY API KEY" }, { "vulnSlug": "process-env-access"… 证据：`.deepsec/data/deepsec/files/packages/deepsec/src/preflight.ts.json`
- **Claude Agent Sdk.Ts**（structured_config）：{ "filePath": "packages/processor/src/agents/claude-agent-sdk.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 31 , "snippet": " but its claude binary is absent . Setting this env var lets CI\n point at a separately-installed @anthropic-ai/claude-code and\n sidestep the resolution path entirely.\n /\nconst CLAUDE CODE EXECUTABLE = process.env.CLAUDE CODE EXECUTABLE;", "matchedPattern": "weak cipher algorithm" }, { "vulnSlug": "process-env-access", "lineNumbers": 33 , "snippet": " /\nconst CLAUDE CODE EXECUTABLE = process.env.CLAUDE CODE EXECUTABLE;\n", "matchedPattern": "process.env.CLAUDE CODE EXECUTABLE" } , "lastScannedAt": "2026-05-06T21:46:56.6… 证据：`.deepsec/data/deepsec/files/packages/processor/src/agents/claude-agent-sdk.ts.json`
- **Codex Sdk.Ts**（structured_config）：{ "filePath": "packages/processor/src/agents/codex-sdk.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 63, 70 , "snippet": "\nfunction makeCodexHome : string {\n const id = ${process.pid}-${++codexHomeCounter}-${Math.random .toString 36 .slice 2, 10 } ;\n const dir = path.join os.tmpdir , codex-home-${id} ;\n fs.mkdirSync dir, { recursive: true } ;", "matchedPattern": "Math.random in security context" }, { "vulnSlug": "env-var-as-bool", "lineNumbers": 135 , "snippet": " // OPENAI BASE URL takes precedence when both are set.\n const baseUrl = process.env.OPENAI BASE URL ?? process.env.ANTHROPIC BASE URL ?? undefined;\n const apiKey = process.env.OPE… 证据：`.deepsec/data/deepsec/files/packages/processor/src/agents/codex-sdk.ts.json`
- **Detect Tech.Ts**（structured_config）：{ "filePath": "packages/scanner/src/detect-tech.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "insecure-crypto", "lineNumbers": 133, 135, 136, 325, 326 , "snippet": " if keys.some k = k.startsWith \"laravel/\" exists root, \"artisan\" tags.push \"laravel\" ;\n if keys.some k = k.startsWith \"symfony/\" tags.push \"symfony\" ;\n if keys.includes \"slim/slim\" tags.push \"slim\" ;\n if keys.some k = k === \"yiisoft/yii2\" k.startsWith \"yiisoft/\" tags.push \"yii\" ;\n if keys.includes \"cakephp/cakephp\" tags.push \"cakephp\" ;", "matchedPattern": "weak cipher algorithm" } , "lastScannedAt": "2026-05-06T21:46:56.471Z", "lastScannedRunId": "20260506214655-aa977d40dc0c6524", "fileHa… 证据：`.deepsec/data/deepsec/files/packages/scanner/src/detect-tech.ts.json`
- **Index.Ts**（structured_config）：{ "filePath": "packages/scanner/src/index.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "path-traversal", "lineNumbers": 260, 272 , "snippet": " if !ignorePaths {\n try {\n const cfgPath = path.resolve data/${params.projectId}/config.json ;\n if fs.existsSync cfgPath {\n const cfg = JSON.parse fs.readFileSync cfgPath, \"utf-8\" ;", "matchedPattern": "path.resolve with request-derived input" }, { "vulnSlug": "crypto-usage", "lineNumbers": 1, 186 , "snippet": "import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";", "matchedPattern": "Node crypto import, Node crypto.create " }, { "vulnSlug": "path-traversal", "lineNumbers": 261, 273 , "sni… 证据：`.deepsec/data/deepsec/files/packages/scanner/src/index.ts.json`
- **Index.Ts**（structured_config）：{ "filePath": "packages/scanner/src/matchers/index.ts", "projectId": "deepsec", "candidates": { "vulnSlug": "auth-bypass", "lineNumbers": 11, 24 , "snippet": "import { allServerActionsMatcher } from \"./all-server-actions.js\";\n// --- Core security matchers ---\nimport { authBypassMatcher } from \"./auth-bypass.js\";\nimport { cacheKeyPoisoningMatcher } from \"./cache-key-poisoning.js\";\nimport { cacheKeyScopeMatcher } from \"./cache-key-scope.js\";", "matchedPattern": "auth skip/bypass" }, { "vulnSlug": "auth-bypass", "lineNumbers": 66, 168 , "snippet": "import { missingAwaitMatcher } from \"./missing-await.js\";\nimport { nextjsMiddlewareMatcher } from \"./nextjs-middleware.js\";\nimpor… 证据：`.deepsec/data/deepsec/files/packages/scanner/src/matchers/index.ts.json`
- **Run**（source_file）：import { execSync } from "node:child process"; import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { dataDir, fileRecordPath, filesDir, projectConfigPath, runMetaPath, runsDir, } from "./paths.js"; import { fileRecordSchema, projectConfigSchema, runMetaSchema } from "./schemas.js"; import type { FileRecord, ProjectConfig, RunMeta } from "./types.js"; ⋮---- export function defaultConcurrency : number ⋮---- export function generateRunId : string ⋮---- const ts = now.toISOString .replace / -:T /g, "" .slice 0, 14 ; // YYYYMMDDHHmmss ⋮---- function detectGithubUrl rootPath: string : string undefined ⋮---- export function ens… 证据：`packages/core/src/run.ts`
- **Types**（source_file）：export interface RunMeta { runId: string; projectId: string; rootPath: string; createdAt: string; completedAt?: string; type: "scan" "process" "revalidate"; phase: "running" "done" "error"; pid?: number; hostname?: string; scannerConfig?: { matcherSlugs: string ; mode?: "full" "files"; source?: string; fileCount?: number; }; processorConfig?: { agentType: string; model: string; modelConfig: Record ; invocationMode?: "scan" "direct"; source?: string; }; stats: { filesScanned?: number; candidatesFound?: number; filesProcessed?: number; findingsCount?: number; totalCostUsd?: number; totalInputTokens?: number; totalOutputTokens?: number; totalDurationMs?: number; findingsRevalidated?: number; t… 证据：`packages/core/src/types.ts`
- **Cli**（source_file）：import { config as dotenvConfig } from "dotenv"; ⋮---- import { getRegistry } from "@deepsec/core"; import { Command } from "commander"; import { collectRepeatable } from "./agent-config.js"; import { enrichCommand } from "./commands/enrich.js"; import { exportCommand } from "./commands/export.js"; import { initCommand } from "./commands/init.js"; import { initProjectCommand } from "./commands/init-project.js"; import { metricsCommand } from "./commands/metrics.js"; import { processCommand } from "./commands/process.js"; import { reportCommand } from "./commands/report.js"; import { revalidateCommand } from "./commands/revalidate.js"; import { sandboxAllCommand } from "./commands/sandbox-al… 证据：`packages/deepsec/src/cli.ts`
- **Export**（source_file）：import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import type { FileRecord, Finding, Severity } from "@deepsec/core"; import { dataDir, getDataRoot, loadAllFileRecords } from "@deepsec/core"; import { BOLD, DIM, GREEN, RESET, YELLOW } from "../formatters.js"; import { resolveAgentType } from "../resolve-agent-type.js"; ⋮---- interface OwnerSummary { assignee?: string; assigneeSource?: "oncall" "manager" "top-contributor" "last-committer"; teams: { name: string; slug: string } ; oncall: { name: string; email: string; slack user id?: string; github username?: string } ; managers: { email: string; slack user id?: string } ; contributors: { name: string;… 证据：`packages/deepsec/src/commands/export.ts`
- **Process**（source_file）：import fs from "node:fs"; import path from "node:path"; import { ensureProject, readProjectConfig } from "@deepsec/core"; import { process as processRun } from "@deepsec/processor"; import { scanFiles } from "@deepsec/scanner"; import { buildAgentConfig } from "../agent-config.js"; import { defaultModelForAgent } from "../agent-defaults.js"; import { resolveFiles } from "../file-sources.js"; import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW } from "../formatters.js"; import { renderPrComment } from "../pr-comment.js"; import { assertAgentCredential } from "../preflight.js"; import { renderQuotaMessage } from "../quota-message.js"; import { resolveAgentType } from "../resolve-agent-type.js… 证据：`packages/deepsec/src/commands/process.ts`
- **Revalidate**（source_file）：import type { Severity } from "@deepsec/core"; import { readProjectConfig } from "@deepsec/core"; import { revalidate } from "@deepsec/processor"; import { buildAgentConfig } from "../agent-config.js"; import { defaultModelForAgent } from "../agent-defaults.js"; import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW } from "../formatters.js"; import { assertAgentCredential } from "../preflight.js"; import { renderQuotaMessage } from "../quota-message.js"; import { resolveAgentType } from "../resolve-agent-type.js"; import { resolveProjectId } from "../resolve-project-id.js"; ⋮---- function logProgress progress: { type: string; message: string; batchIndex?: number; totalBatches?: number; agentP… 证据：`packages/deepsec/src/commands/revalidate.ts`
- **Sandbox Process**（source_file）：import { defaultModelForAgent } from "../agent-defaults.js"; import { BOLD, CYAN, DIM, GREEN, RED, RESET } from "../formatters.js"; import { assertAgentCredential, assertSandboxCredential } from "../preflight.js"; import { resolveAgentType } from "../resolve-agent-type.js"; import { resolveProjectId } from "../resolve-project-id.js"; import { checkStatus, collect, launch, orchestrate } from "../sandbox/orchestrator.js"; import type { SandboxConfig, SandboxSubcommand } from "../sandbox/types.js"; ⋮---- interface SandboxOpts { projectId?: string; sandboxes?: number; vcpus?: number; snapshotId?: string; saveSnapshot?: boolean; keepAlive?: boolean; detach?: boolean; runId?: string; timeout?: nu… 证据：`packages/deepsec/src/commands/sandbox-process.ts`
- **Scan**（source_file）：import fs from "node:fs"; import path from "node:path"; import { findProject, getConfigPath, loadAllFileRecords, projectConfigPath } from "@deepsec/core"; import { scan } from "@deepsec/scanner"; import { BOLD, CYAN, DIM, GREEN, RESET, YELLOW } from "../formatters.js"; import { requireExistingDir } from "../require-dir.js"; import { resolveProjectId } from "../resolve-project-id.js"; ⋮---- function resolveScanRoot opts: ⋮---- function pad s: string, width: number : string ⋮---- export async function scanCommand opts: ⋮---- // Per-matcher hit counts collected from progress events. Used in the // post-scan summary so we don't have to re-derive it from records. ⋮---- // Progress-bar state. We… 证据：`packages/deepsec/src/commands/scan.ts`
- **Pr Comment**（source_file）：import { type FileRecord, loadAllFileRecords, type Severity } from "@deepsec/core"; ⋮---- export function renderPrComment params: { projectId: string; runId: string; source?: string; } : string null ⋮---- // Tally for the header. ⋮---- function truncate s: string, max: number : string 证据：`packages/deepsec/src/pr-comment.ts`
- **Preflight**（source_file）：import { existsSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; import { getVercelOidcToken } from "@vercel/oidc"; ⋮---- export async function applyAiGatewayDefaults : Promise ⋮---- function isCodex agentType: string undefined : boolean ⋮---- function isPi agentType: string undefined : boolean ⋮---- function whichSync bin: string : boolean ⋮---- function hasLocalClaudeAgent : boolean ⋮---- function hasLocalCodexAgent : boolean ⋮---- function hasLocalPiAgent : boolean ⋮---- export function assertAgentCredential agentType: string undefined, options: { inSandbox?: boolean; aiApiKeyEnv?: string } = {}, : void ⋮---- export function assertSandboxCredenti… 证据：`packages/deepsec/src/preflight.ts`
- **Types**（source_file）：import type { Sandbox } from "@vercel/sandbox"; ⋮---- export type SandboxSubcommand = "process" "revalidate" "triage" "scan" "report"; ⋮---- export interface SandboxConfig { projectId: string; command: SandboxSubcommand; sandboxCount: number; vcpus: number; limit?: number; concurrency: number; batchSize: number; agentType?: string; aiApiKeyEnv?: string; aiBaseUrl?: string; model: string; snapshotId?: string; saveSnapshot: boolean; keepAlive: boolean; reinvestigate: boolean number; force: boolean; minSeverity?: string; filter?: string; matchers?: string; timeout: number; allowedHosts?: string ; extraArgs: string ; } ⋮---- export interface SandboxInstance { sandbox: Sandbox; index: number; sa… 证据：`packages/deepsec/src/sandbox/types.ts`
- **Claude Agent Sdk**（source_file）：import { query, type SandboxSettings } from "@anthropic-ai/claude-agent-sdk"; import type { RefusalReport } from "@deepsec/core"; import { backoff, buildInvestigateJsonRepairPrompt, buildInvestigatePrompt, buildRevalidateJsonRepairPrompt, buildRevalidatePrompt, classifyQuotaError, formatJsonRepairFailureDebugText, isTransientError, jsonRepairFailureError, MAX ATTEMPTS, parseInvestigateResults, parseRefusalReport, parseRevalidateVerdicts, QuotaExhaustedError, REFUSAL FOLLOWUP PROMPT, writeParseFailureDebug, } from "./shared.js"; import type { AgentPlugin, AgentProgress, BatchMeta, InvestigateOutput, InvestigateParams, InvestigateResult, RevalidateOutput, RevalidateParams, RevalidateVerdict,… 证据：`packages/processor/src/agents/claude-agent-sdk.ts`
- **Codex Sdk**（source_file）：import { createRequire } from "node:module"; ⋮---- import { fileURLToPath } from "node:url"; import type { RefusalReport } from "@deepsec/core"; import { Codex, type CodexOptions, type ModelReasoningEffort, type ThreadEvent, type ThreadItem, } from "@openai/codex-sdk"; import { backoff, buildInvestigateJsonRepairPrompt, buildInvestigatePrompt, buildRevalidateJsonRepairPrompt, buildRevalidatePrompt, classifyQuotaError, formatJsonRepairFailureDebugText, isTransientError, jsonRepairFailureError, MAX ATTEMPTS, parseInvestigateResults, parseRefusalReport, parseRevalidateVerdicts, QuotaExhaustedError, REFUSAL FOLLOWUP PROMPT, writeParseFailureDebug, } from "./shared.js"; import type { AgentPlugin… 证据：`packages/processor/src/agents/codex-sdk.ts`
- **Pi Sdk**（source_file）：import fs from "node:fs"; import path from "node:path"; import type { RefusalReport } from "@deepsec/core"; import { type AgentSession, type AgentSessionEvent, AuthStorage, createAgentSession, createFindToolDefinition, createGrepToolDefinition, createLsToolDefinition, createReadToolDefinition, DefaultResourceLoader, getAgentDir, ModelRegistry, SessionManager, SettingsManager, type ToolDefinition, } from "@earendil-works/pi-coding-agent"; import { backoff, buildInvestigateJsonRepairPrompt, buildInvestigatePrompt, buildRevalidateJsonRepairPrompt, buildRevalidatePrompt, classifyQuotaError, formatJsonRepairFailureDebugText, isTransientError, isUsingAiGateway, jsonRepairFailureError, MAX ATTEMPT… 证据：`packages/processor/src/agents/pi-sdk.ts`
- **Registry**（source_file）：import type { AgentPlugin } from "./types.js"; ⋮---- export class AgentRegistry ⋮---- register plugin: AgentPlugin : void ⋮---- get type: string : AgentPlugin undefined ⋮---- types : string 证据：`packages/processor/src/agents/registry.ts`
- **Types**（source_file）：import type { FileRecord, Finding, RefusalReport, RevalidationVerdict } from "@deepsec/core"; ⋮---- export interface AgentProgress { type: "started" "tool use" "thinking" "complete" "error"; message: string; candidateFile?: string; } ⋮---- export interface InvestigateParams { batch: FileRecord ; projectRoot: string; promptTemplate: string; projectInfo: string; config: Record ; signal?: AbortSignal; projectId?: string; } ⋮---- export interface InvestigateResult { filePath: string; findings: Finding ; } ⋮---- export interface BatchMeta { durationMs: number; durationApiMs?: number; numTurns?: number; costUsd?: number; agentSessionId?: string; usage?: { inputTokens: number; outputTokens: number… 证据：`packages/processor/src/agents/types.ts`
- **Index**（source_file）：import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import type { FileRecord, Severity } from "@deepsec/core"; import { acquireProcessLock, completeRun, createRunMeta, dataDir, defaultConcurrency, getRegistry, isPidAlive, loadAllFileRecords, readFileRecord, readProjectConfig, readRunMeta, registerActiveRun, writeFileRecord, writeRunMeta, } from "@deepsec/core"; import { noiseScore, readTechJson } from "@deepsec/scanner"; import { ClaudeAgentSdkPlugin } from "./agents/claude-agent-sdk.js"; import { CodexAgentSdkPlugin } from "./agents/codex-sdk.js"; import { PiAgentPlugin } from "./agents/pi-sdk.js"; import { AgentRegistry } from "./agents/registry.js"; import {… 证据：`packages/processor/src/index.ts`
- **Detect Tech**（source_file）：import fs from "node:fs"; import path from "node:path"; import { dataDir } from "@deepsec/core"; ⋮---- export interface DetectedTech { tags: string ; sentinels: string ; detectedAt: string; rootPath: string; } ⋮---- function readSafe rootPath: string, rel: string, cache: Map : string null ⋮---- function exists rootPath: string, rel: string : boolean ⋮---- function listDir rootPath: string, rel: string : string ⋮---- type Detector = rootPath: string, cache: Map = string ; ⋮---- const has = name: string const startsWith = prefix: string ⋮---- const hasDep = re: RegExp ⋮---- export function detectTech rootPath: string : DetectedTech ⋮---- export function writeTechJson projectId: string, detect… 证据：`packages/scanner/src/detect-tech.ts`
- **Index**（source_file）：import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import type { FileRecord, MatcherGate } from "@deepsec/core"; import { completeRun, createRunMeta, dataDir, ensureProject, getDataRoot, getRegistry, projectConfigSchema, readFileRecord, writeFileRecord, writeRunMeta, } from "@deepsec/core"; import { glob, globSync } from "glob"; import { escape as escapeGlob, minimatch } from "minimatch"; import { type DetectedTech, detectTech, readTechJson, writeTechJson } from "./detect-tech.js"; import type { MatcherRegistry } from "./matcher-registry.js"; import { createDefaultRegistry } from "./matchers/index.js"; import type { MatcherPlugin, ScannerDriver, ScanPr… 证据：`packages/scanner/src/index.ts`
- 其余 18 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

## 宿主 AI 必须遵守的规则

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`.deepsec/README.md`, `README.md`, `samples/README.md`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`.deepsec/README.md`, `README.md`, `samples/README.md`

## 用户开工前应该回答的问题

- 你准备在哪个宿主 AI 或本地环境中使用它？
- 你只是想先体验工作流，还是准备真实安装？
- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？

## 验收标准

- 所有能力声明都能回指到 evidence_refs 中的文件路径。
- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。
- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。

---

## Doramagic Context Augmentation

下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。

## Human Manual 骨架

使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。

宿主 AI 硬性规则：
- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。
- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。
- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。

- **系统架构与流水线概览**：importance `high`
  - source_paths: README.md, docs/architecture.md, docs/data-layout.md, docs/getting-started.md, packages/core/src/run.ts
- **AI 智能体后端与模型配置**：importance `high`
  - source_paths: packages/processor/src/agents/registry.ts, packages/processor/src/agents/claude-agent-sdk.ts, packages/processor/src/agents/codex-sdk.ts, packages/processor/src/agents/pi-sdk.ts, packages/processor/src/agents/types.ts
- **扫描器与匹配器生态系统**：importance `high`
  - source_paths: packages/scanner/src/index.ts, packages/scanner/src/detect-tech.ts, packages/scanner/src/matcher-registry.ts, packages/scanner/src/matchers/index.ts, packages/scanner/src/matchers/utils.ts
- **运维工作流、常见故障与导出集成**：importance `high`
  - source_paths: packages/deepsec/src/commands/export.ts, packages/deepsec/src/commands/process.ts, packages/deepsec/src/commands/revalidate.ts, packages/deepsec/src/commands/scan.ts, packages/deepsec/src/preflight.ts

## Repo Inspection Evidence / 源码检查证据

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `8779666b2b0715f66e254f5f0308dd8a65c8820b`
- inspected_files: `README.md`, `package.json`, `pnpm-lock.yaml`, `docs/architecture.md`, `docs/configuration.md`, `docs/data-layout.md`, `docs/faq.md`, `docs/getting-started.md`, `docs/meta.json`, `docs/models.md`, `docs/plugins.md`, `docs/reviewing-changes.md`, `docs/supported-tech.md`, `docs/vercel-setup.md`, `docs/writing-matchers.md`, `packages/core/package.json`, `packages/core/src/__tests__/paths.test.ts`, `packages/core/src/__tests__/run.test.ts`, `packages/core/src/__tests__/schemas.test.ts`, `packages/core/src/__tests__/severity.test.ts`

宿主 AI 硬性规则：
- 没有 repo_clone_verified=true 时，不得声称已经读过源码。
- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。
- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。

## Doramagic Pitfall Constraints / 踩坑约束

这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。

### Constraint 1: 来源证据：Codex process fails with SIGKILL then ENOENT after bundled codex binary is removed

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex process fails with SIGKILL then ENOENT after bundled codex binary is removed
- Host AI rule: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- Why it matters: 可能阻塞安装或首次运行。
- Evidence: community_evidence:github | https://github.com/vercel-labs/deepsec/issues/100 | 来源讨论提到 node 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 可能修改宿主 AI 配置

- Trigger: 项目面向 Claude/Cursor/Codex/Gemini/OpenCode 等宿主，或安装命令涉及用户配置目录。
- Host AI rule: 列出会写入的配置文件、目录和卸载/回滚步骤。
- Why it matters: 安装可能改变本机 AI 工具行为，用户需要知道写入位置和回滚方法。
- Evidence: capability.host_targets | https://news.ycombinator.com/item?id=48964215 | host_targets=claude, chatgpt
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 3: 能力判断依赖假设

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: 将假设转成下游验证清单。
- Why it matters: 假设不成立时，用户拿不到承诺的能力。
- Evidence: capability.assumptions | https://news.ycombinator.com/item?id=48964215 | README/documentation is current enough for a first validation pass.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 维护活跃度未知

- Trigger: 未记录 last_activity_observed。
- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Evidence: evidence.maintainer_signals | https://news.ycombinator.com/item?id=48964215 | last_activity_observed missing
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

- Trigger: no_demo
- Evidence: downstream_validation.risk_items | https://news.ycombinator.com/item?id=48964215 | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 6: 存在评分风险

- Trigger: no_demo
- Why it matters: 风险会影响是否适合普通用户安装。
- Evidence: risks.scoring_risks | https://news.ycombinator.com/item?id=48964215 | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 7: issue/PR 响应质量未知

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: 抽样最近 issue/PR，判断是否长期无人处理。
- Why it matters: 用户无法判断遇到问题后是否有人维护。
- Evidence: evidence.maintainer_signals | https://news.ycombinator.com/item?id=48964215 | issue_or_pr_quality=unknown
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 8: 发布节奏不明确

- Trigger: release_recency=unknown。
- Host AI rule: 确认最近 release/tag 和 README 安装命令是否一致。
- Why it matters: 安装命令和文档可能落后于代码，用户踩坑概率升高。
- Evidence: evidence.maintainer_signals | https://news.ycombinator.com/item?id=48964215 | release_recency=unknown
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
