claude-coder 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,123 +1,118 @@
1
- <!--
2
- Scan Protocol for Claude Coder.
3
- Only injected during scan sessions — not used in coding sessions.
4
- Contains: scan steps, project_profile.json format.
5
- -->
6
-
7
- # 项目扫描协议(首次运行时执行)
8
-
9
- 当 `project_profile.json` 不存在时,按以下步骤扫描项目并生成配置文件。
10
-
11
- ## 步骤 1:判断项目类型
12
-
13
- 检查项目根目录:
14
- - 如果存在代码文件(`.py`, `.js`, `.ts`, `package.json`, `requirements.txt` 等)→ **旧项目**(已有代码)
15
- - 如果根目录几乎为空(仅有 `.claude-coder/` 和少量文件)→ **新项目**(从零开始)
16
-
17
- ## 步骤 2A:旧项目 — 扫描现有代码,**优先整理文档**
18
-
19
- **文档先行**:旧项目在扫描前,必须先确保项目文档可读、可用。文档是后续 session 高质量执行的基础 — AI Agent 会在每次编码前读取文档来了解架构和接口约定。
20
-
21
- **文档标准(按优先级)**:
22
- 1. **README.md**(必须有):项目简介、技术栈、目录结构、如何运行。若缺失或过于简略,先补充
23
- 2. **`.claude/CLAUDE.md`**(推荐有):检查 `.claude/` 目录下是否已有 `CLAUDE.md`。若无,生成一份项目指令文件,采用 WHAT/WHY/HOW 格式:WHAT(项目是什么、技术栈)、WHY(关键技术决策)、HOW(开发命令、测试命令、关键路径表、编码规则)。此文件会被 Claude Code 自动加载为项目上下文
24
- 3. **API 文档**:如果项目有 API 且无文档,在 `.claude/CLAUDE.md` 的 HOW 部分或 README 中补充主要端点列表
25
-
26
- 按顺序检查以下文件,**存在则读取**,不存在则跳过:
27
-
28
- 1. `package.json` → Node.js 项目,读取 dependencies 判断框架(React/Vue/Express 等)
29
- 2. `pyproject.toml` / `requirements.txt` / `setup.py` / `setup.cfg` → Python 项目,判断框架(FastAPI/Django/Flask 等)
30
- 3. `Cargo.toml` → Rust,`go.mod` → Go,`pom.xml` / `build.gradle` → Java
31
- 4. `docker-compose.yml` / `Dockerfile` → 容器化配置,提取服务定义
32
- 5. `Makefile` → 构建方式
33
- 6. `README.md` / `docs/` → 现有文档(若缺失或过简,**先整理再扫描**;在 session_result.json 的 notes 中记录文档状态)
34
- 7. `.env` / `.env.example` → 环境变量配置
35
- 8. 运行 `ls` 查看顶层目录结构
36
-
37
- 根据扫描结果,生成 `.claude-coder/project_profile.json`(格式见下方)。若项目有自定义初始化步骤(如 `python manage.py migrate`),填充 `custom_init` 字段。`existing_docs` 须如实列出项目中**所有**可读文档路径(包括本次扫描中新生成的文档)。
38
-
39
- ## 步骤 2B:新项目 — 脚手架搭建
40
-
41
- 1. **优先检查项目根目录是否存在 `requirements.md`**,如果存在,以其中的技术约束和设计要求为准
42
- 2. 根据需求(`requirements.md` 或 harness 传入的需求文本),设计技术架构
43
- 3. 创建项目目录结构和基础文件(入口文件、配置文件、依赖文件等)
44
- 4. 生成 `README.md`(项目用途、技术栈、如何运行)
45
- 5. 如果 `.claude/CLAUDE.md` 不存在,生成项目指令文件(WHAT/WHY/HOW 格式),包含模块职责、数据流、API 路由、开发和测试命令
46
- 6. 初始化包管理(`npm init` / `pip freeze` 等)
47
- 7. 完成后,执行**步骤 2A 的扫描流程**生成 `project_profile.json`
48
-
49
- ## 步骤 3:生成 tasks.json
50
-
51
- 根据用户需求和 user prompt 中的「任务分解指导」,将功能分解为任务。
52
- 格式参见 CLAUDE.md 中的 tasks.json 章节。
53
-
54
- ## 步骤 4:收尾
55
-
56
- 1. 写入 `.claude-coder/session_result.json`(notes 中记录初始化摘要)
57
- 3. `git add -A && git commit -m "init: 项目扫描 + 任务分解"`
58
-
59
- ---
60
-
61
- ## project_profile.json 格式
62
-
63
- ```json
64
- {
65
- "name": "项目名称(从 package.json 或目录名自动检测)",
66
- "detected_at": "2026-02-13T10:00:00",
67
- "project_type": "existing | new",
68
- "tech_stack": {
69
- "languages": ["python", "typescript"],
70
- "backend": {
71
- "framework": "fastapi | django | express | none",
72
- "runtime": "uvicorn | gunicorn | node | none",
73
- "entry": "main:app | app.py | index.js"
74
- },
75
- "frontend": {
76
- "framework": "react | vue | none",
77
- "bundler": "vite | webpack | none",
78
- "dir": "web | frontend | client | ."
79
- },
80
- "database": "mongodb | postgresql | sqlite | none",
81
- "package_managers": ["pip", "npm", "cargo"]
82
- },
83
- "services": [
84
- {
85
- "name": "backend",
86
- "command": "启动命令",
87
- "port": 8000,
88
- "health_check": "http://localhost:8000/health",
89
- "cwd": "."
90
- },
91
- {
92
- "name": "frontend",
93
- "command": "npm run dev",
94
- "port": 5173,
95
- "health_check": "http://localhost:5173",
96
- "cwd": "web"
97
- }
98
- ],
99
- "env_setup": {
100
- "python_env": "conda:env_name | venv | system",
101
- "node_version": "20 | 18 | none"
102
- },
103
- "existing_docs": ["README.md", ".claude/CLAUDE.md"],
104
- "has_tests": false,
105
- "has_docker": false,
106
- "mcp_tools": {
107
- "playwright": false
108
- },
109
- "custom_init": ["python manage.py migrate"],
110
- "scan_files_checked": [
111
- "package.json", "pyproject.toml", "requirements.txt",
112
- "Dockerfile", "docker-compose.yml", "Makefile", "README.md"
113
- ]
114
- }
115
- ```
116
-
117
- **注意**:
118
- - `existing_docs`:列出项目中所有可读文档路径,Agent 实现前按需读取与任务相关的文档;扫描时须如实填写全部文档
119
- - 字段值必须基于实际扫描结果,**禁止猜测**
120
- - 如果某个字段无法确定,使用 `"none"` 或空数组 `[]`
121
- - `services` 中的 `command` 必须来自实际的配置文件(package.json scripts、Procfile 等)或标准命令
122
- - `mcp_tools` 字段:检查 `.claude-coder/.env` 中的 `MCP_PLAYWRIGHT` 等变量。如果 `.env` 不存在,则全部设为 `false`
123
- - `custom_init`:可选,数组格式。若项目需要额外的初始化命令(如数据库迁移、静态文件收集等),按执行顺序列出。无额外步骤则填 `[]` 或省略
1
+ <!--
2
+ Scan Protocol for Claude Coder.
3
+ Only injected during scan sessions — not used in coding sessions.
4
+ Contains: scan steps, project_profile.json format.
5
+ -->
6
+
7
+ # 项目扫描协议(首次运行时执行)
8
+
9
+ 当 `project_profile.json` 不存在时,按以下步骤扫描项目并生成配置文件。
10
+
11
+ ## 步骤 1:判断项目类型
12
+
13
+ 检查项目根目录:
14
+ - 如果存在代码文件(`.py`, `.js`, `.ts`, `package.json`, `requirements.txt` 等)→ **旧项目**(已有代码)
15
+ - 如果根目录几乎为空(仅有 `.claude-coder/` 和少量文件)→ **新项目**(从零开始)
16
+
17
+ ## 步骤 2A:旧项目 — 扫描现有代码,**优先整理文档**
18
+
19
+ **文档先行**:旧项目在扫描前,必须先确保项目文档可读、可用。文档是后续 session 高质量执行的基础 — AI Agent 会在每次编码前读取文档来了解架构和接口约定。
20
+
21
+ **文档标准(按优先级)**:
22
+ 1. **README.md**(必须有):项目简介、技术栈、目录结构、如何运行。若缺失或过于简略,先补充
23
+ 2. **`.claude/CLAUDE.md`**(推荐有):检查 `.claude/` 目录下是否已有 `CLAUDE.md`。若无,生成一份项目指令文件,采用 WHAT/WHY/HOW 格式:WHAT(项目是什么、技术栈)、WHY(关键技术决策)、HOW(开发命令、测试命令、关键路径表、编码规则)。此文件会被 Claude Code 自动加载为项目上下文
24
+ 3. **API 文档**:如果项目有 API 且无文档,在 `.claude/CLAUDE.md` 的 HOW 部分或 README 中补充主要端点列表
25
+
26
+ 按顺序检查以下文件,**存在则读取**,不存在则跳过:
27
+
28
+ 1. `package.json` → Node.js 项目,读取 dependencies 判断框架(React/Vue/Express 等)
29
+ 2. `pyproject.toml` / `requirements.txt` / `setup.py` / `setup.cfg` → Python 项目,判断框架(FastAPI/Django/Flask 等)
30
+ 3. `Cargo.toml` → Rust,`go.mod` → Go,`pom.xml` / `build.gradle` → Java
31
+ 4. `docker-compose.yml` / `Dockerfile` → 容器化配置,提取服务定义
32
+ 5. `Makefile` → 构建方式
33
+ 6. `README.md` / `docs/` → 现有文档(若缺失或过简,**先整理再扫描**;在 session_result.json 的 notes 中记录文档状态)
34
+ 7. `.env` / `.env.example` → 环境变量配置
35
+ 8. 运行 `ls` 查看顶层目录结构
36
+
37
+ 根据扫描结果,生成 `.claude-coder/project_profile.json`(格式见下方)。若项目有自定义初始化步骤(如 `python manage.py migrate`),填充 `custom_init` 字段。`existing_docs` 须如实列出项目中**所有**可读文档路径(包括本次扫描中新生成的文档)。
38
+
39
+ ## 步骤 2B:新项目 — 脚手架搭建
40
+
41
+ 1. **优先检查项目根目录是否存在 `requirements.md`**,如果存在,以其中的技术约束和设计要求为准
42
+ 2. 根据需求(`requirements.md` 或 harness 传入的需求文本),设计技术架构
43
+ 3. 创建项目目录结构和基础文件(入口文件、配置文件、依赖文件等)
44
+ 4. 生成 `README.md`(项目用途、技术栈、如何运行)
45
+ 5. 如果 `.claude/CLAUDE.md` 不存在,生成项目指令文件(WHAT/WHY/HOW 格式),包含模块职责、数据流、API 路由、开发和测试命令
46
+ 6. 初始化包管理(`npm init` / `pip freeze` 等)
47
+ 7. 完成后,执行**步骤 2A 的扫描流程**生成 `project_profile.json`
48
+
49
+ ## 步骤 3:收尾
50
+
51
+ 1. 写入 `.claude-coder/session_result.json`(notes 中记录扫描摘要:项目类型、技术栈、服务列表)
52
+ 2. `git add -A && git commit -m "init: 项目扫描"`
53
+
54
+ ---
55
+
56
+ ## project_profile.json 格式
57
+
58
+ ```json
59
+ {
60
+ "name": "项目名称(从 package.json 或目录名自动检测)",
61
+ "detected_at": "2026-02-13T10:00:00",
62
+ "project_type": "existing | new",
63
+ "tech_stack": {
64
+ "languages": ["python", "typescript"],
65
+ "backend": {
66
+ "framework": "fastapi | django | express | none",
67
+ "runtime": "uvicorn | gunicorn | node | none",
68
+ "entry": "main:app | app.py | index.js"
69
+ },
70
+ "frontend": {
71
+ "framework": "react | vue | none",
72
+ "bundler": "vite | webpack | none",
73
+ "dir": "web | frontend | client | ."
74
+ },
75
+ "database": "mongodb | postgresql | sqlite | none",
76
+ "package_managers": ["pip", "npm", "cargo"]
77
+ },
78
+ "services": [
79
+ {
80
+ "name": "backend",
81
+ "command": "启动命令",
82
+ "port": 8000,
83
+ "health_check": "http://localhost:8000/health",
84
+ "cwd": "."
85
+ },
86
+ {
87
+ "name": "frontend",
88
+ "command": "npm run dev",
89
+ "port": 5173,
90
+ "health_check": "http://localhost:5173",
91
+ "cwd": "web"
92
+ }
93
+ ],
94
+ "env_setup": {
95
+ "python_env": "conda:env_name | venv | system",
96
+ "node_version": "20 | 18 | none"
97
+ },
98
+ "existing_docs": ["README.md", ".claude/CLAUDE.md"],
99
+ "has_tests": false,
100
+ "has_docker": false,
101
+ "mcp_tools": {
102
+ "playwright": false
103
+ },
104
+ "custom_init": ["python manage.py migrate"],
105
+ "scan_files_checked": [
106
+ "package.json", "pyproject.toml", "requirements.txt",
107
+ "Dockerfile", "docker-compose.yml", "Makefile", "README.md"
108
+ ]
109
+ }
110
+ ```
111
+
112
+ **注意**:
113
+ - `existing_docs`:列出项目中所有可读文档路径,Agent 实现前按需读取与任务相关的文档;扫描时须如实填写全部文档
114
+ - 字段值必须基于实际扫描结果,**禁止猜测**
115
+ - 如果某个字段无法确定,使用 `"none"` 或空数组 `[]`
116
+ - `services` 中的 `command` 必须来自实际的配置文件(package.json scripts、Procfile 等)或标准命令
117
+ - `mcp_tools` 字段:检查 `.claude-coder/.env` 中的 `MCP_PLAYWRIGHT` 等变量。如果 `.env` 不存在,则全部设为 `false`
118
+ - `custom_init`:可选,数组格式。若项目需要额外的初始化命令(如数据库迁移、静态文件收集等),按执行顺序列出。无额外步骤则填 `[]` 或省略
@@ -0,0 +1,24 @@
1
+ 你是资深需求分析师,擅长将模糊需求分解为可执行的原子任务。
2
+ 这是任务追加 session,不是编码 session。你只分解任务,不实现代码。
3
+
4
+ {{profileContext}}
5
+ {{taskContext}}
6
+ {{recentExamples}}
7
+ 项目绝对路径: {{projectRoot}}
8
+
9
+ 执行步骤(按顺序,不可跳过):
10
+ 1. 读取 .claude-coder/tasks.json 和 .claude-coder/project_profile.json,全面了解项目现状
11
+ 2. 分析用户指令:识别核心功能点,判断是单任务还是需要拆分为多任务
12
+ 3. 检查重复:对比已有任务,避免功能重叠
13
+ 4. 确定依赖:新任务的 depends_on 引用已有或新增任务的 id,形成 DAG
14
+ 5. 分解任务:按下方任务分解指南的规则,每个任务独立可测试
15
+ 6. 追加到 tasks.json,id 和 priority 从已有最大值递增,status: pending
16
+ 7. git add -A && git commit -m "chore: add new tasks"
17
+ 8. 写入 session_result.json(格式:{ "session_result": "success", "status_before": "N/A", "status_after": "N/A", "notes": "追加了 N 个任务:简述" })
18
+
19
+ {{addGuide}}
20
+
21
+ {{testRuleHint}}
22
+ 不修改已有任务,不实现代码。
23
+
24
+ 用户指令:{{instruction}}
@@ -0,0 +1,23 @@
1
+ Session {{sessionNum}}。执行 6 步流程。
2
+ 效率要求:先规划后编码,完成全部编码后再统一测试,禁止编码-测试反复跳转。后端任务用 curl 验证,不启动浏览器。
3
+ {{mcpHint}}
4
+ {{testHint}}
5
+ {{docsHint}}
6
+ {{envHint}}
7
+ {{taskHint}}
8
+ {{testEnvHint}}
9
+ {{playwrightAuthHint}}
10
+ {{memoryHint}}
11
+ {{serviceHint}}
12
+
13
+ 可用工具与使用规范(严格遵守):
14
+ - 搜索文件名: Glob(如 **/*.ts),禁止 bash find
15
+ - 搜索文件内容: Grep(正则,基于 ripgrep),禁止 bash grep
16
+ - 读文件: Read(支持批量多文件同时读取),禁止 bash cat/head/tail
17
+ - 列目录: LS,禁止 bash ls
18
+ - 编辑文件: 同一文件多处修改用 MultiEdit(一次原子调用),单处用 Edit
19
+ - 复杂搜索: Task(启动子 Agent 并行搜索,不消耗主 context),适合开放式探索
20
+ - 查文档/API: WebSearch + WebFetch
21
+ - 效率: 多个 Read/Glob/Grep 尽量合并为一次批量调用,减少工具轮次
22
+
23
+ 完成后写入 session_result.json。{{retryContext}}
@@ -0,0 +1,17 @@
1
+ 你是项目初始化 Agent。你的职责是扫描项目并生成 project_profile.json,不分解任务。
2
+
3
+ 项目类型: {{projectType}}
4
+ {{requirement}}
5
+
6
+ 按「项目扫描协议」(SCAN_PROTOCOL.md)执行步骤 1-3:
7
+ 1. 判断项目类型(新项目 / 旧项目)
8
+ 2. 扫描项目(旧项目扫描代码和文档 / 新项目搭建脚手架)
9
+ 3. 收尾:写入 session_result.json 并 git commit
10
+
11
+ profile 质量要求(必须遵守,harness 会校验):
12
+ - services 数组必须包含所有可启动服务(command、port、health_check),不得为空
13
+ - existing_docs 必须列出所有实际存在的文档路径
14
+ - 检查 .claude/CLAUDE.md 是否存在,若无则生成(WHAT/WHY/HOW 格式:技术栈、关键决策、开发命令、关键路径、编码规则),并加入 existing_docs
15
+ - scan_files_checked 必须列出所有实际扫描过的文件
16
+
17
+ 注意:本次只扫描项目,不分解任务。任务分解将在后续步骤由 harness 自动调用 add 完成。