mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-11 03:23:50 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71305da77e | ||
|
|
c4021cf58a | ||
|
|
9a18a03061 |
@@ -226,6 +226,39 @@
|
|||||||
"skills": [
|
"skills": [
|
||||||
"./SKILL.md"
|
"./SKILL.md"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dev-workflow",
|
||||||
|
"source": "./dev-workflow/",
|
||||||
|
"description": "Minimal lightweight development workflow with requirements clarification, parallel codex execution, and mandatory 90% test coverage",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": {
|
||||||
|
"name": "Claude Code Dev Workflows",
|
||||||
|
"url": "https://github.com/cexll/myclaude"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/cexll/myclaude",
|
||||||
|
"repository": "https://github.com/cexll/myclaude",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"workflow",
|
||||||
|
"codex",
|
||||||
|
"testing",
|
||||||
|
"coverage",
|
||||||
|
"concurrent",
|
||||||
|
"lightweight"
|
||||||
|
],
|
||||||
|
"category": "workflows",
|
||||||
|
"strict": false,
|
||||||
|
"commands": [
|
||||||
|
"./commands/dev.md"
|
||||||
|
],
|
||||||
|
"agents": [
|
||||||
|
"./agents/dev-plan-generator.md"
|
||||||
|
],
|
||||||
|
"skills": [
|
||||||
|
"../skills/codex/SKILL.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://claude.ai/code)
|
[](https://claude.ai/code)
|
||||||
[](https://github.com/cexll/myclaude)
|
[](https://github.com/cexll/myclaude)
|
||||||
[](https://docs.claude.com/en/docs/claude-code/plugins)
|
[](https://docs.claude.com/en/docs/claude-code/plugins)
|
||||||
|
|
||||||
> Enterprise-grade agile development automation with AI-powered multi-agent orchestration
|
> Enterprise-grade agile development automation with AI-powered multi-agent orchestration
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://claude.ai/code)
|
[](https://claude.ai/code)
|
||||||
[](https://github.com/cexll/myclaude)
|
[](https://github.com/cexll/myclaude)
|
||||||
[](https://docs.claude.com/en/docs/claude-code/plugins)
|
[](https://docs.claude.com/en/docs/claude-code/plugins)
|
||||||
|
|
||||||
> 企业级敏捷开发自动化与 AI 驱动的多智能体编排
|
> 企业级敏捷开发自动化与 AI 驱动的多智能体编排
|
||||||
|
|||||||
@@ -1,163 +1,163 @@
|
|||||||
# /dev - 极简开发工作流
|
# /dev - Minimal Dev Workflow
|
||||||
|
|
||||||
## 概述
|
## Overview
|
||||||
|
|
||||||
全新设计的轻量级开发工作流,无历史包袱,专注快速交付高质量代码。
|
A freshly designed lightweight development workflow with no legacy baggage, focused on delivering high-quality code fast.
|
||||||
|
|
||||||
## 工作流程
|
## Flow
|
||||||
|
|
||||||
```
|
```
|
||||||
/dev 触发
|
/dev trigger
|
||||||
↓
|
↓
|
||||||
AskUserQuestion(需求澄清)
|
AskUserQuestion (requirements clarification)
|
||||||
↓
|
↓
|
||||||
Codex 分析(提取要点和任务)
|
Codex analysis (extract key points and tasks)
|
||||||
↓
|
↓
|
||||||
develop-doc-generator(生成开发文档)
|
develop-doc-generator (create dev doc)
|
||||||
↓
|
↓
|
||||||
Codex 并发开发(2-5个任务)
|
Codex concurrent development (2–5 tasks)
|
||||||
↓
|
↓
|
||||||
Codex 测试验证(≥90%覆盖率)
|
Codex testing & verification (≥90% coverage)
|
||||||
↓
|
↓
|
||||||
完成(生成总结)
|
Done (generate summary)
|
||||||
```
|
```
|
||||||
|
|
||||||
## 6个步骤
|
## The 6 Steps
|
||||||
|
|
||||||
### 1. 需求澄清
|
### 1. Clarify Requirements
|
||||||
- 使用 **AskUserQuestion** 直接问用户
|
- Use **AskUserQuestion** to ask the user directly
|
||||||
- 无评分系统,无复杂逻辑
|
- No scoring system, no complex logic
|
||||||
- 2-3 轮问答直到需求明确
|
- 2–3 rounds of Q&A until the requirement is clear
|
||||||
|
|
||||||
### 2. Codex 分析
|
### 2. Codex Analysis
|
||||||
- 调用 codex 分析需求
|
- Call codex to analyze the request
|
||||||
- 提取:核心功能、技术要点、任务列表(2-5个)
|
- Extract: core functions, technical points, task list (2–5 items)
|
||||||
- 输出结构化分析结果
|
- Output a structured analysis
|
||||||
|
|
||||||
### 3. 生成开发文档
|
### 3. Generate Dev Doc
|
||||||
- 调用 **develop-doc-generator** agent
|
- Call the **develop-doc-generator** agent
|
||||||
- 生成 `dev-plan.md`(单一开发文档)
|
- Produce a single `dev-plan.md`
|
||||||
- 包含:任务分解、文件范围、依赖关系、测试命令
|
- Include: task breakdown, file scope, dependencies, test commands
|
||||||
|
|
||||||
### 4. 并发开发
|
### 4. Concurrent Development
|
||||||
- 基于 dev-plan.md 的任务列表
|
- Work from the task list in dev-plan.md
|
||||||
- 无依赖任务 → 并发执行
|
- Independent tasks → run in parallel
|
||||||
- 有冲突任务 → 串行执行
|
- Conflicting tasks → run serially
|
||||||
|
|
||||||
### 5. 测试验证
|
### 5. Testing & Verification
|
||||||
- 每个 codex 任务自己:
|
- Each codex task:
|
||||||
- 实现功能
|
- Implements the feature
|
||||||
- 编写测试
|
- Writes tests
|
||||||
- 运行覆盖率
|
- Runs coverage
|
||||||
- 报告结果(≥90%)
|
- Reports results (≥90%)
|
||||||
|
|
||||||
### 6. 完成
|
### 6. Complete
|
||||||
- 汇总任务状态
|
- Summarize task status
|
||||||
- 记录覆盖率
|
- Record coverage
|
||||||
|
|
||||||
## 使用方法
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/dev "实现用户登录功能,支持邮箱和密码验证"
|
/dev "Implement user login with email + password"
|
||||||
```
|
```
|
||||||
|
|
||||||
**无选项**,流程固定,开箱即用。
|
**No options**, fixed workflow, works out of the box.
|
||||||
|
|
||||||
## 输出结构
|
## Output Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
.claude/specs/{feature_name}/
|
.claude/specs/{feature_name}/
|
||||||
├── dev-plan.md # 开发文档(agent生成)
|
└── dev-plan.md # Dev document generated by agent
|
||||||
```
|
```
|
||||||
|
|
||||||
仅 2 个文件,极简清晰。
|
Only one file—minimal and clear.
|
||||||
|
|
||||||
## 核心组件
|
## Core Components
|
||||||
|
|
||||||
### 工具
|
### Tools
|
||||||
- **AskUserQuestion**:交互式需求澄清
|
- **AskUserQuestion**: interactive requirement clarification
|
||||||
- **codex**:分析、开发、测试
|
- **codex**: analysis, development, testing
|
||||||
- **develop-doc-generator**:生成开发文档(subagent,节省上下文)
|
- **develop-doc-generator**: generate dev doc (subagent, saves context)
|
||||||
|
|
||||||
## 核心特性
|
## Key Features
|
||||||
|
|
||||||
### ✅ 全新设计
|
### ✅ Fresh Design
|
||||||
- 无历史项目残留
|
- No legacy project residue
|
||||||
- 无复杂评分逻辑
|
- No complex scoring logic
|
||||||
- 无多余抽象层
|
- No extra abstraction layers
|
||||||
|
|
||||||
### ✅ 极简编排
|
### ✅ Minimal Orchestration
|
||||||
- orchestrator 直接控制流程
|
- Orchestrator controls the flow directly
|
||||||
- 只用 3 个工具/组件
|
- Only three tools/components
|
||||||
- 步骤清晰易懂
|
- Steps are straightforward
|
||||||
|
|
||||||
### ✅ 并发能力
|
### ✅ Concurrency
|
||||||
- 2-5 个任务并行
|
- 2–5 tasks in parallel
|
||||||
- 自动检测依赖和冲突
|
- Auto-detect dependencies and conflicts
|
||||||
- codex 独立执行
|
- Codex executes independently
|
||||||
|
|
||||||
### ✅ 质量保证
|
### ✅ Quality Assurance
|
||||||
- 强制 90% 覆盖率
|
- Enforces 90% coverage
|
||||||
- codex 自己测试和验证
|
- Codex tests and verifies its own work
|
||||||
- 失败自动重试
|
- Automatic retry on failure
|
||||||
|
|
||||||
## 示例
|
## Example
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 触发
|
# Trigger
|
||||||
/dev "添加用户登录功能"
|
/dev "Add user login feature"
|
||||||
|
|
||||||
# 步骤 1: 需求澄清
|
# Step 1: Clarify requirements
|
||||||
Q: 支持哪些登录方式?
|
Q: What login methods are supported?
|
||||||
A: 邮箱 + 密码
|
A: Email + password
|
||||||
Q: 需要记住登录状态吗?
|
Q: Should login be remembered?
|
||||||
A: 是,使用 JWT token
|
A: Yes, use JWT token
|
||||||
|
|
||||||
# 步骤 2: Codex 分析
|
# Step 2: Codex analysis
|
||||||
输出:
|
Output:
|
||||||
- 核心功能:邮箱密码登录 + JWT认证
|
- Core: email/password login + JWT auth
|
||||||
- 任务 1:后端 API
|
- Task 1: Backend API
|
||||||
- 任务 2:密码加密
|
- Task 2: Password hashing
|
||||||
- 任务 3:前端表单
|
- Task 3: Frontend form
|
||||||
|
|
||||||
# 步骤 3: 生成文档
|
# Step 3: Generate doc
|
||||||
dev-plan.md 已生成 ✓
|
dev-plan.md generated ✓
|
||||||
|
|
||||||
# 步骤 4-5: 并发开发
|
# Step 4-5: Concurrent development
|
||||||
[task-1] 后端API → 测试 → 92% ✓
|
[task-1] Backend API → tests → 92% ✓
|
||||||
[task-2] 密码加密 → 测试 → 95% ✓
|
[task-2] Password hashing → tests → 95% ✓
|
||||||
[task-3] 前端表单 → 测试 → 91% ✓
|
[task-3] Frontend form → tests → 91% ✓
|
||||||
```
|
```
|
||||||
|
|
||||||
## 目录结构
|
## Directory Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
dev-workflow/
|
dev-workflow/
|
||||||
├── README.md # 本文档
|
├── README.md # This doc
|
||||||
├── commands/
|
├── commands/
|
||||||
│ └── dev.md # 工作流定义
|
│ └── dev.md # Workflow definition
|
||||||
└── agents/
|
└── agents/
|
||||||
└── develop-doc-generator.md # 文档生成器
|
└── develop-doc-generator.md # Doc generator
|
||||||
```
|
```
|
||||||
|
|
||||||
极简结构,只有 3 个文件。
|
Minimal structure, only three files.
|
||||||
|
|
||||||
## 适用场景
|
## When to Use
|
||||||
|
|
||||||
✅ **适合**:
|
✅ **Good for**:
|
||||||
- 任何规模的功能开发
|
- Any feature size
|
||||||
- 需要快速迭代
|
- Fast iterations
|
||||||
- 需要高测试覆盖率
|
- High test coverage needs
|
||||||
- 希望并发提速
|
- Wanting concurrent speed-up
|
||||||
|
|
||||||
## 设计原则
|
## Design Principles
|
||||||
|
|
||||||
1. **KISS**:保持简单愚蠢
|
1. **KISS**: keep it simple
|
||||||
2. **即用即抛**:无持久化配置
|
2. **Disposable**: no persistent config
|
||||||
3. **质量优先**:强制 90% 覆盖率
|
3. **Quality first**: enforce 90% coverage
|
||||||
4. **并发优先**:充分利用 codex 能力
|
4. **Concurrency first**: leverage codex
|
||||||
5. **无历史包袱**:全新设计,不受其他项目影响
|
5. **No legacy baggage**: clean-slate design
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**哲学**:像 Linus 一样对复杂度零容忍,交付能立刻用的最小方案。
|
**Philosophy**: zero tolerance for complexity—ship the smallest usable solution, like Linus would.
|
||||||
|
|||||||
@@ -17,25 +17,40 @@ Execute Codex CLI commands and parse structured JSON responses. Supports file re
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
**Mandatory**: Run every automated invocation through the Bash tool in the foreground with the command below, keeping the `timeout` parameter fixed at `7200000` milliseconds (do not change it or use any other entry point).
|
**Mandatory**: Run every automated invocation through the Bash tool in the foreground with **HEREDOC syntax** to avoid shell quoting issues, keeping the `timeout` parameter fixed at `7200000` milliseconds (do not change it or use any other entry point).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
uv run ~/.claude/skills/codex/scripts/codex.py - [working_dir] <<'EOF'
|
||||||
|
<task content here>
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
**Foreground only (no background/BashOutput)**: Never set `background: true`, never accept Claude's “Running in the background” mode, and avoid `BashOutput` streaming loops. Keep a single foreground Bash call per Codex task; if work might be long, split it into smaller foreground runs instead of offloading to background execution.
|
**Why HEREDOC?** Tasks often contain code blocks, nested quotes, shell metacharacters (`$`, `` ` ``, `\`), and multiline text. HEREDOC (Here Document) syntax passes these safely without shell interpretation, eliminating quote-escaping nightmares.
|
||||||
|
|
||||||
**Optional methods** (direct execution or via Python):
|
**Foreground only (no background/BashOutput)**: Never set `background: true`, never accept Claude's "Running in the background" mode, and avoid `BashOutput` streaming loops. Keep a single foreground Bash call per Codex task; if work might be long, split it into smaller foreground runs instead of offloading to background execution.
|
||||||
|
|
||||||
|
**Simple tasks** (backward compatibility):
|
||||||
|
For simple single-line tasks without special characters, you can still use direct quoting:
|
||||||
```bash
|
```bash
|
||||||
~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
uv run ~/.claude/skills/codex/scripts/codex.py "simple task here" [working_dir]
|
||||||
# or
|
|
||||||
python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Resume a session:
|
**Resume a session with HEREDOC:**
|
||||||
```bash
|
```bash
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py resume <session_id> "<task>" [working_dir]
|
uv run ~/.claude/skills/codex/scripts/codex.py resume <session_id> - [working_dir] <<'EOF'
|
||||||
|
<task content>
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Cross-platform notes:**
|
||||||
|
- **Bash/Zsh**: Use `<<'EOF'` (single quotes prevent variable expansion)
|
||||||
|
- **PowerShell 5.1+**: Use `@'` and `'@` (here-string syntax)
|
||||||
|
```powershell
|
||||||
|
uv run ~/.claude/skills/codex/scripts/codex.py - @'
|
||||||
|
task content
|
||||||
|
'@
|
||||||
|
```
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
- **CODEX_TIMEOUT**: Override timeout in milliseconds (default: 7200000 = 2 hours)
|
- **CODEX_TIMEOUT**: Override timeout in milliseconds (default: 7200000 = 2 hours)
|
||||||
- Example: `export CODEX_TIMEOUT=3600000` for 1 hour
|
- Example: `export CODEX_TIMEOUT=3600000` for 1 hour
|
||||||
@@ -72,63 +87,82 @@ Return only the final agent message and session ID—do not paste raw `BashOutpu
|
|||||||
|
|
||||||
### Invocation Pattern
|
### Invocation Pattern
|
||||||
|
|
||||||
All automated executions may only invoke `uv run ~/.claude/skills/codex/scripts/codex.py "<task>" ...` through the Bash tool in the foreground, and the `timeout` must remain fixed at `7200000` (non-negotiable):
|
All automated executions must use HEREDOC syntax through the Bash tool in the foreground, with `timeout` fixed at `7200000` (non-negotiable):
|
||||||
|
|
||||||
```
|
```
|
||||||
Bash tool parameters:
|
Bash tool parameters:
|
||||||
- command: uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
- command: uv run ~/.claude/skills/codex/scripts/codex.py - [working_dir] <<'EOF'
|
||||||
|
<task content>
|
||||||
|
EOF
|
||||||
- timeout: 7200000
|
- timeout: 7200000
|
||||||
- description: <brief description of the task>
|
- description: <brief description of the task>
|
||||||
```
|
```
|
||||||
|
|
||||||
Run every call in the foreground—never append `&` to background it—so logs and errors stay visible for timely interruption or diagnosis.
|
Run every call in the foreground—never append `&` to background it—so logs and errors stay visible for timely interruption or diagnosis.
|
||||||
|
|
||||||
Alternatives:
|
**Important:** Use HEREDOC (`<<'EOF'`) for all but the simplest tasks. This prevents shell interpretation of quotes, variables, and special characters.
|
||||||
```
|
|
||||||
# Direct execution (simplest)
|
|
||||||
- command: ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
|
||||||
|
|
||||||
# Using python3
|
|
||||||
- command: python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
**Basic code analysis:**
|
**Basic code analysis:**
|
||||||
```bash
|
```bash
|
||||||
# Recommended: via uv run (auto-manages Python environment)
|
# Recommended: via uv run with HEREDOC (handles any special characters)
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts"
|
uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'
|
||||||
|
explain @src/main.ts
|
||||||
|
EOF
|
||||||
# timeout: 7200000
|
# timeout: 7200000
|
||||||
|
|
||||||
# Alternative: direct execution
|
# Alternative: simple direct quoting (if task is simple)
|
||||||
~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts"
|
uv run ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Refactoring with custom model (via environment variable):**
|
**Refactoring with multiline instructions:**
|
||||||
```bash
|
```bash
|
||||||
# Set model via environment variable
|
uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py "refactor @src/utils for performance"
|
refactor @src/utils for performance:
|
||||||
|
- Extract duplicate code into helpers
|
||||||
|
- Use memoization for expensive calculations
|
||||||
|
- Add inline comments for non-obvious logic
|
||||||
|
EOF
|
||||||
# timeout: 7200000
|
# timeout: 7200000
|
||||||
```
|
```
|
||||||
|
|
||||||
**Multi-file analysis:**
|
**Multi-file analysis:**
|
||||||
```bash
|
```bash
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py "analyze @. and find security issues" "/path/to/project"
|
uv run ~/.claude/skills/codex/scripts/codex.py - "/path/to/project" <<'EOF'
|
||||||
|
analyze @. and find security issues:
|
||||||
|
1. Check for SQL injection vulnerabilities
|
||||||
|
2. Identify XSS risks in templates
|
||||||
|
3. Review authentication/authorization logic
|
||||||
|
4. Flag hardcoded credentials or secrets
|
||||||
|
EOF
|
||||||
# timeout: 7200000
|
# timeout: 7200000
|
||||||
```
|
```
|
||||||
|
|
||||||
**Resume previous session:**
|
**Resume previous session:**
|
||||||
```bash
|
```bash
|
||||||
# First session
|
# First session
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py "add comments to @utils.js"
|
uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'
|
||||||
|
add comments to @utils.js explaining the caching logic
|
||||||
|
EOF
|
||||||
# Output includes: SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14
|
# Output includes: SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14
|
||||||
|
|
||||||
# Continue the conversation
|
# Continue the conversation with more context
|
||||||
uv run ~/.claude/skills/codex/scripts/codex.py resume 019a7247-ac9d-71f3-89e2-a823dbd8fd14 "now add type hints"
|
uv run ~/.claude/skills/codex/scripts/codex.py resume 019a7247-ac9d-71f3-89e2-a823dbd8fd14 - <<'EOF'
|
||||||
|
now add TypeScript type hints and handle edge cases where cache is null
|
||||||
|
EOF
|
||||||
# timeout: 7200000
|
# timeout: 7200000
|
||||||
```
|
```
|
||||||
|
|
||||||
**Using python3 directly (alternative):**
|
**Task with code snippets and special characters:**
|
||||||
```bash
|
```bash
|
||||||
python3 ~/.claude/skills/codex/scripts/codex.py "your task here"
|
uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'
|
||||||
|
Fix the bug in @app.js where the regex /\d+/ doesn't match "123"
|
||||||
|
The current code is:
|
||||||
|
const re = /\d+/;
|
||||||
|
if (re.test(input)) { ... }
|
||||||
|
Add proper escaping and handle $variables correctly.
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
### Large Task Protocol
|
### Large Task Protocol
|
||||||
@@ -139,8 +173,8 @@ python3 ~/.claude/skills/codex/scripts/codex.py "your task here"
|
|||||||
|
|
||||||
| ID | Description | Scope | Dependencies | Tests | Command |
|
| ID | Description | Scope | Dependencies | Tests | Command |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- | --- |
|
||||||
| T1 | Review @spec.md to extract requirements | docs/, @spec.md | None | None | uv run ~/.claude/skills/codex/scripts/codex.py "analyze requirements @spec.md" |
|
| T1 | Review @spec.md to extract requirements | docs/, @spec.md | None | None | `uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'`<br/>`analyze requirements @spec.md`<br/>`EOF` |
|
||||||
| T2 | Implement the module and add test cases | src/module | T1 | npm test -- --runInBand | uv run ~/.claude/skills/codex/scripts/codex.py "implement and test @src/module" |
|
| T2 | Implement the module and add test cases | src/module | T1 | npm test -- --runInBand | `uv run ~/.claude/skills/codex/scripts/codex.py - <<'EOF'`<br/>`implement and test @src/module`<br/>`EOF` |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ Codex CLI wrapper with cross-platform support and session management.
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
New session: uv run codex.py "task" [workdir]
|
New session: uv run codex.py "task" [workdir]
|
||||||
|
Stdin mode: uv run codex.py - [workdir]
|
||||||
Resume: uv run codex.py resume <session_id> "task" [workdir]
|
Resume: uv run codex.py resume <session_id> "task" [workdir]
|
||||||
|
Resume stdin: uv run codex.py resume <session_id> - [workdir]
|
||||||
Alternative: python3 codex.py "task"
|
Alternative: python3 codex.py "task"
|
||||||
Direct exec: ./codex.py "task"
|
Direct exec: ./codex.py "task"
|
||||||
|
|
||||||
@@ -80,19 +82,23 @@ def parse_args():
|
|||||||
if len(sys.argv) < 4:
|
if len(sys.argv) < 4:
|
||||||
log_error('Resume mode requires: resume <session_id> <task>')
|
log_error('Resume mode requires: resume <session_id> <task>')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
task_arg = sys.argv[3]
|
||||||
return {
|
return {
|
||||||
'mode': 'resume',
|
'mode': 'resume',
|
||||||
'session_id': sys.argv[2],
|
'session_id': sys.argv[2],
|
||||||
'task': sys.argv[3],
|
'task': task_arg,
|
||||||
'workdir': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_WORKDIR
|
'explicit_stdin': task_arg == '-',
|
||||||
}
|
'workdir': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_WORKDIR,
|
||||||
else:
|
|
||||||
return {
|
|
||||||
'mode': 'new',
|
|
||||||
'task': sys.argv[1],
|
|
||||||
'workdir': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_WORKDIR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task_arg = sys.argv[1]
|
||||||
|
return {
|
||||||
|
'mode': 'new',
|
||||||
|
'task': task_arg,
|
||||||
|
'explicit_stdin': task_arg == '-',
|
||||||
|
'workdir': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_WORKDIR,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def read_piped_task() -> Optional[str]:
|
def read_piped_task() -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
@@ -100,19 +106,10 @@ def read_piped_task() -> Optional[str]:
|
|||||||
- 如果 stdin 是管道(非 tty)且存在内容,返回读取到的字符串
|
- 如果 stdin 是管道(非 tty)且存在内容,返回读取到的字符串
|
||||||
- 否则返回 None
|
- 否则返回 None
|
||||||
"""
|
"""
|
||||||
import select
|
|
||||||
|
|
||||||
stdin = sys.stdin
|
stdin = sys.stdin
|
||||||
if stdin is None or stdin.isatty():
|
if stdin is None or stdin.isatty():
|
||||||
log_info("Stdin is tty or None, skipping pipe read")
|
log_info("Stdin is tty or None, skipping pipe read")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 使用 select 检查是否有数据可读(0 秒超时,非阻塞)
|
|
||||||
readable, _, _ = select.select([stdin], [], [], 0)
|
|
||||||
if not readable:
|
|
||||||
log_info("No data available on stdin")
|
|
||||||
return None
|
|
||||||
|
|
||||||
log_info("Reading from stdin pipe...")
|
log_info("Reading from stdin pipe...")
|
||||||
data = stdin.read()
|
data = stdin.read()
|
||||||
if not data:
|
if not data:
|
||||||
@@ -153,6 +150,7 @@ def build_codex_args(params: dict, target_arg: str) -> list:
|
|||||||
if params['mode'] == 'resume':
|
if params['mode'] == 'resume':
|
||||||
return [
|
return [
|
||||||
'codex', 'e',
|
'codex', 'e',
|
||||||
|
'-m', DEFAULT_MODEL,
|
||||||
'--skip-git-repo-check',
|
'--skip-git-repo-check',
|
||||||
'--json',
|
'--json',
|
||||||
'resume',
|
'resume',
|
||||||
@@ -276,16 +274,28 @@ def main():
|
|||||||
timeout_sec = resolve_timeout()
|
timeout_sec = resolve_timeout()
|
||||||
log_info(f"Timeout: {timeout_sec}s")
|
log_info(f"Timeout: {timeout_sec}s")
|
||||||
|
|
||||||
piped_task = read_piped_task()
|
explicit_stdin = params.get('explicit_stdin', False)
|
||||||
piped = piped_task is not None
|
|
||||||
task_text = piped_task if piped else params['task']
|
|
||||||
|
|
||||||
use_stdin = should_stream_via_stdin(task_text, piped)
|
if explicit_stdin:
|
||||||
|
log_info("Explicit stdin mode: reading task from stdin")
|
||||||
|
task_text = sys.stdin.read()
|
||||||
|
if not task_text:
|
||||||
|
log_error("Explicit stdin mode requires task input from stdin")
|
||||||
|
sys.exit(1)
|
||||||
|
piped = not sys.stdin.isatty()
|
||||||
|
else:
|
||||||
|
piped_task = read_piped_task()
|
||||||
|
piped = piped_task is not None
|
||||||
|
task_text = piped_task if piped else params['task']
|
||||||
|
|
||||||
|
use_stdin = explicit_stdin or should_stream_via_stdin(task_text, piped)
|
||||||
|
|
||||||
if use_stdin:
|
if use_stdin:
|
||||||
reasons = []
|
reasons = []
|
||||||
if piped:
|
if piped:
|
||||||
reasons.append('piped input')
|
reasons.append('piped input')
|
||||||
|
if explicit_stdin:
|
||||||
|
reasons.append('explicit "-"')
|
||||||
if '\n' in task_text:
|
if '\n' in task_text:
|
||||||
reasons.append('newline')
|
reasons.append('newline')
|
||||||
if '\\' in task_text:
|
if '\\' in task_text:
|
||||||
|
|||||||
Reference in New Issue
Block a user