mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat: add CLI settings export/import functionality
- Implemented exportSettings and importSettings APIs for CLI settings. - Added hooks useExportSettings and useImportSettings for managing export/import operations in the frontend. - Updated SettingsPage to include buttons for exporting and importing CLI settings. - Enhanced backend to handle export and import requests, including validation and conflict resolution. - Introduced new data structures for exported settings and import options. - Updated localization files to support new export/import features. - Refactored CLI tool configurations to remove hardcoded model defaults, allowing dynamic model retrieval.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: planex-executor
|
||||
description: |
|
||||
PlanEx 执行角色。加载 solution plan → 代码实现 → 测试验证 → git commit。
|
||||
PlanEx 执行角色。从中间产物文件加载 solution plan(兼容 CLI fallback)→ 代码实现 → 测试验证 → git commit。
|
||||
每个 executor 实例处理一个 issue 的 solution。
|
||||
color: green
|
||||
skill: issue-devpipeline
|
||||
@@ -9,11 +9,11 @@ skill: issue-devpipeline
|
||||
|
||||
# PlanEx Executor
|
||||
|
||||
代码实现角色。接收编排器派发的 issue + solution 信息,加载 solution plan,实现代码变更,运行测试验证,提交变更。每个 executor 实例独立处理一个 issue。
|
||||
代码实现角色。接收编排器派发的 issue + solution 信息,从中间产物文件加载 solution plan(兼容 CLI fallback),实现代码变更,运行测试验证,提交变更。每个 executor 实例独立处理一个 issue。
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
1. **Solution 加载**: 通过 `ccw issue solutions <id> --json` 加载绑定的 solution plan
|
||||
1. **Solution 加载**: 从中间产物文件加载 solution plan(兼容 `ccw issue solutions <id> --json` fallback)
|
||||
2. **代码实现**: 按 solution plan 的任务列表顺序实现代码变更
|
||||
3. **测试验证**: 运行相关测试确保变更正确且不破坏现有功能
|
||||
4. **变更提交**: 将实现的代码 commit 到 git
|
||||
@@ -179,10 +179,24 @@ function getUtc8ISOString() {
|
||||
### Step 2: Solution Loading & Implementation
|
||||
|
||||
```javascript
|
||||
// ── Load solution plan ──
|
||||
// ── Load solution plan (dual-mode: artifact file first, CLI fallback) ──
|
||||
const issueId = taskAssignment.issue_id
|
||||
const solJson = shell(`ccw issue solutions ${issueId} --json`)
|
||||
const solution = JSON.parse(solJson)
|
||||
const solutionFile = taskAssignment.solution_file
|
||||
|
||||
let solution
|
||||
if (solutionFile) {
|
||||
try {
|
||||
const solutionData = JSON.parse(read_file(solutionFile))
|
||||
solution = solutionData.bound ? solutionData : { bound: solutionData }
|
||||
} catch {
|
||||
// Fallback to CLI
|
||||
const solJson = shell(`ccw issue solutions ${issueId} --json`)
|
||||
solution = JSON.parse(solJson)
|
||||
}
|
||||
} else {
|
||||
const solJson = shell(`ccw issue solutions ${issueId} --json`)
|
||||
solution = JSON.parse(solJson)
|
||||
}
|
||||
|
||||
if (!solution.bound) {
|
||||
outputError(`No bound solution for ${issueId}`)
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
---
|
||||
name: planex-planner
|
||||
description: |
|
||||
PlanEx 规划角色。需求拆解 → issue 创建 → 方案设计 → 队列编排。
|
||||
按波次 (wave) 输出执行队列,支持 Deep Interaction 多轮交互。
|
||||
PlanEx 规划角色。需求拆解 → issue 创建 → 方案设计 → inline 冲突检查。
|
||||
逐 issue 输出执行信息,支持 Deep Interaction 多轮交互。
|
||||
color: blue
|
||||
skill: issue-devpipeline
|
||||
---
|
||||
|
||||
# PlanEx Planner
|
||||
|
||||
需求分析和规划角色。接收需求输入(issue IDs / 文本 / plan 文件),完成需求拆解、issue 创建、方案设计(调用 issue-plan-agent)、队列编排(调用 issue-queue-agent),按波次输出执行队列供编排器派发 executor。
|
||||
需求分析和规划角色。接收需求输入(issue IDs / 文本 / plan 文件),完成需求拆解、issue 创建、方案设计(调用 issue-plan-agent)、inline 冲突检查,逐 issue 输出执行信息供编排器即时派发 executor。
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
1. **需求分析**: 解析输入类型,提取需求要素
|
||||
2. **Issue 创建**: 将文本/plan 拆解为结构化 issue(通过 `ccw issue new`)
|
||||
3. **方案设计**: 调用 issue-plan-agent 为每个 issue 生成 solution
|
||||
4. **队列编排**: 调用 issue-queue-agent 按依赖排序形成执行队列
|
||||
5. **波次输出**: 每波最多 5 个 issues,输出结构化 JSON 队列
|
||||
4. **Inline 冲突检查**: 基于 files_touched 重叠检测 + 显式依赖排序
|
||||
5. **中间产物**: 将 solution 写入文件供 executor 直接加载
|
||||
6. **逐 issue 输出**: 每完成一个 issue 立即输出 JSON,编排器即时派发
|
||||
|
||||
## Execution Process
|
||||
|
||||
@@ -32,6 +33,7 @@ skill: issue-devpipeline
|
||||
- **Goal**: What to achieve
|
||||
- **Scope**: What's allowed and forbidden
|
||||
- **Input**: Input payload with type, issueIds, text, planFile
|
||||
- **Session Dir**: Path for writing solution artifacts
|
||||
- **Deliverables**: Expected JSON output format
|
||||
|
||||
### Step 2: Input Processing & Issue Creation
|
||||
@@ -40,6 +42,7 @@ skill: issue-devpipeline
|
||||
|
||||
```javascript
|
||||
const input = taskAssignment.input
|
||||
const sessionDir = taskAssignment.session_dir
|
||||
|
||||
if (input.type === 'issue_ids') {
|
||||
// Issue IDs 已提供,直接使用
|
||||
@@ -68,28 +71,24 @@ if (input.type === 'plan_file') {
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Solution Planning & Queue Formation
|
||||
### Step 3: Per-Issue Solution Planning & Artifact Writing
|
||||
|
||||
分波次处理 issues。每波最多 5 个。
|
||||
逐 issue 处理:plan-agent → 写中间产物 → 冲突检查 → 输出 JSON。
|
||||
|
||||
```javascript
|
||||
const WAVE_SIZE = 5
|
||||
const allIssues = [...issueIds]
|
||||
const waves = []
|
||||
const projectRoot = shell('pwd').trim()
|
||||
const dispatchedSolutions = []
|
||||
const remainingIssues = [...issueIds]
|
||||
|
||||
for (let i = 0; i < allIssues.length; i += WAVE_SIZE) {
|
||||
waves.push(allIssues.slice(i, i + WAVE_SIZE))
|
||||
}
|
||||
shell(`mkdir -p "${sessionDir}/artifacts/solutions"`)
|
||||
|
||||
// 处理第一个 wave(后续 wave 通过 send_input 触发)
|
||||
const currentWave = waves[0]
|
||||
const remainingWaves = waves.slice(1)
|
||||
const remainingIssues = remainingWaves.flat()
|
||||
for (let i = 0; i < issueIds.length; i++) {
|
||||
const issueId = issueIds[i]
|
||||
remainingIssues.shift()
|
||||
|
||||
// ── Solution Planning ──
|
||||
// 调用 issue-plan-agent 为当前 wave 的 issues 生成 solutions
|
||||
const planAgent = spawn_agent({
|
||||
message: `
|
||||
// --- Step 3a: Spawn issue-plan-agent for single issue ---
|
||||
const planAgent = spawn_agent({
|
||||
message: `
|
||||
## TASK ASSIGNMENT
|
||||
|
||||
### MANDATORY FIRST STEPS (Agent Execute)
|
||||
@@ -97,89 +96,112 @@ const planAgent = spawn_agent({
|
||||
|
||||
---
|
||||
|
||||
issue_ids: ${JSON.stringify(currentWave)}
|
||||
project_root: "${shell('pwd').trim()}"
|
||||
issue_ids: ["${issueId}"]
|
||||
project_root: "${projectRoot}"
|
||||
|
||||
## Requirements
|
||||
- Generate solutions for each issue
|
||||
- Auto-bind single solutions
|
||||
- Generate solution for this issue
|
||||
- Auto-bind single solution
|
||||
- For multiple solutions, select the most pragmatic one
|
||||
`
|
||||
})
|
||||
const planResult = wait({ ids: [planAgent], timeout_ms: 600000 })
|
||||
close_agent({ id: planAgent })
|
||||
})
|
||||
const planResult = wait({ ids: [planAgent], timeout_ms: 600000 })
|
||||
|
||||
// ── Queue Formation ──
|
||||
// 调用 issue-queue-agent 形成执行队列
|
||||
const queueAgent = spawn_agent({
|
||||
message: `
|
||||
## TASK ASSIGNMENT
|
||||
if (planResult.timed_out) {
|
||||
send_input({ id: planAgent, message: "Please finalize solution and output results." })
|
||||
wait({ ids: [planAgent], timeout_ms: 120000 })
|
||||
}
|
||||
|
||||
### MANDATORY FIRST STEPS (Agent Execute)
|
||||
1. **Read role definition**: ~/.codex/agents/issue-queue-agent.md (MUST read first)
|
||||
close_agent({ id: planAgent })
|
||||
|
||||
---
|
||||
// --- Step 3b: Load solution + write artifact file ---
|
||||
const solJson = shell(`ccw issue solution ${issueId} --json`)
|
||||
const solution = JSON.parse(solJson)
|
||||
|
||||
issue_ids: ${JSON.stringify(currentWave)}
|
||||
project_root: "${shell('pwd').trim()}"
|
||||
const solutionFile = `${sessionDir}/artifacts/solutions/${issueId}.json`
|
||||
write_file(solutionFile, JSON.stringify({
|
||||
issue_id: issueId,
|
||||
...solution,
|
||||
timestamp: new Date().toISOString()
|
||||
}, null, 2))
|
||||
|
||||
## Requirements
|
||||
- Order solutions by dependency (DAG)
|
||||
- Detect conflicts between solutions
|
||||
- Output execution queue
|
||||
`
|
||||
})
|
||||
const queueResult = wait({ ids: [queueAgent], timeout_ms: 300000 })
|
||||
close_agent({ id: queueAgent })
|
||||
// --- Step 3c: Inline conflict check ---
|
||||
const dependsOn = inlineConflictCheck(issueId, solution, dispatchedSolutions)
|
||||
|
||||
// 读取生成的 queue 文件
|
||||
const queuePath = '.workflow/issues/queue/execution-queue.json'
|
||||
const queue = JSON.parse(readFile(queuePath))
|
||||
// --- Step 3d: Track + output per-issue JSON ---
|
||||
dispatchedSolutions.push({ issueId, solution, solutionFile })
|
||||
|
||||
const isLast = remainingIssues.length === 0
|
||||
|
||||
// Output per-issue JSON for orchestrator
|
||||
console.log(JSON.stringify({
|
||||
status: isLast ? "all_planned" : "issue_ready",
|
||||
issue_id: issueId,
|
||||
solution_id: solution.bound?.id || 'N/A',
|
||||
title: solution.bound?.title || issueId,
|
||||
priority: "normal",
|
||||
depends_on: dependsOn,
|
||||
solution_file: solutionFile,
|
||||
remaining_issues: remainingIssues,
|
||||
summary: `${issueId} solution ready` + (isLast ? ` (all ${issueIds.length} issues planned)` : '')
|
||||
}, null, 2))
|
||||
|
||||
// Wait for orchestrator send_input before continuing
|
||||
// (orchestrator will send: "Issue dispatched. Continue.")
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Output Delivery
|
||||
|
||||
输出严格遵循编排器要求的 JSON 格式。
|
||||
输出格式(每个 issue 独立输出):
|
||||
|
||||
```json
|
||||
{
|
||||
"wave": 1,
|
||||
"status": "wave_ready",
|
||||
"issues": ["ISS-xxx", "ISS-yyy"],
|
||||
"queue": [
|
||||
{
|
||||
"issue_id": "ISS-xxx",
|
||||
"solution_id": "SOL-xxx",
|
||||
"title": "实现功能A",
|
||||
"priority": "normal",
|
||||
"depends_on": []
|
||||
},
|
||||
{
|
||||
"issue_id": "ISS-yyy",
|
||||
"solution_id": "SOL-yyy",
|
||||
"title": "实现功能B",
|
||||
"priority": "normal",
|
||||
"depends_on": ["ISS-xxx"]
|
||||
}
|
||||
],
|
||||
"remaining_issues": ["ISS-zzz"],
|
||||
"summary": "Wave 1 规划完成: 2 个 issues, 按依赖排序"
|
||||
"status": "issue_ready",
|
||||
"issue_id": "ISS-xxx",
|
||||
"solution_id": "SOL-xxx",
|
||||
"title": "实现功能A",
|
||||
"priority": "normal",
|
||||
"depends_on": [],
|
||||
"solution_file": ".workflow/.team/PEX-xxx/artifacts/solutions/ISS-xxx.json",
|
||||
"remaining_issues": ["ISS-yyy", "ISS-zzz"],
|
||||
"summary": "ISS-xxx solution ready"
|
||||
}
|
||||
```
|
||||
|
||||
**status 取值**:
|
||||
- `"wave_ready"` — 本波次完成,还有后续波次
|
||||
- `"all_planned"` — 所有 issues 已规划完毕(包含最后一个波次的 queue)
|
||||
- `"issue_ready"` — 本 issue 完成,还有后续 issues
|
||||
- `"all_planned"` — 所有 issues 已规划完毕(最后一个 issue 的输出)
|
||||
|
||||
### Multi-Round: 处理后续 Wave
|
||||
## Inline Conflict Check
|
||||
|
||||
编排器会通过 `send_input` 触发后续波次规划。收到 send_input 后:
|
||||
```javascript
|
||||
function inlineConflictCheck(issueId, solution, dispatchedSolutions) {
|
||||
const currentFiles = solution.bound?.files_touched
|
||||
|| solution.bound?.affected_files || []
|
||||
const blockedBy = []
|
||||
|
||||
1. 解析 `remaining_issues` 列表
|
||||
2. 取下一批(最多 WAVE_SIZE 个)
|
||||
3. 重复 Step 3 的 solution planning + queue formation
|
||||
4. 输出下一个 wave 的 JSON
|
||||
5. 如果没有剩余 issues,`status` 设为 `"all_planned"`
|
||||
// 1. File conflict detection
|
||||
for (const prev of dispatchedSolutions) {
|
||||
const prevFiles = prev.solution.bound?.files_touched
|
||||
|| prev.solution.bound?.affected_files || []
|
||||
const overlap = currentFiles.filter(f => prevFiles.includes(f))
|
||||
if (overlap.length > 0) {
|
||||
blockedBy.push(prev.issueId)
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Explicit dependencies
|
||||
const explicitDeps = solution.bound?.dependencies?.on_issues || []
|
||||
for (const depId of explicitDeps) {
|
||||
if (!blockedBy.includes(depId)) {
|
||||
blockedBy.push(depId)
|
||||
}
|
||||
}
|
||||
|
||||
return blockedBy
|
||||
}
|
||||
```
|
||||
|
||||
## Plan File Parsing
|
||||
|
||||
@@ -219,11 +241,11 @@ function parsePlanPhases(planContent) {
|
||||
|
||||
### MUST
|
||||
|
||||
- 仅执行规划相关工作(需求分析、issue 创建、方案设计、队列编排)
|
||||
- 仅执行规划相关工作(需求分析、issue 创建、方案设计、冲突检查)
|
||||
- 输出严格遵循 JSON 格式
|
||||
- 每波最多 5 个 issues
|
||||
- 按依赖关系排序队列
|
||||
- 复用已有 issue-plan-agent 和 issue-queue-agent
|
||||
- 按依赖关系标记 depends_on
|
||||
- 将 solution 写入中间产物文件
|
||||
- 每个 issue 完成后立即输出 JSON
|
||||
|
||||
### MUST NOT
|
||||
|
||||
@@ -237,17 +259,19 @@ function parsePlanPhases(planContent) {
|
||||
|
||||
**ALWAYS**:
|
||||
- Read role definition file as FIRST action
|
||||
- Output strictly formatted JSON for each wave
|
||||
- Output strictly formatted JSON for each issue
|
||||
- Include `remaining_issues` for orchestrator to track progress
|
||||
- Set correct `status` (`wave_ready` vs `all_planned`)
|
||||
- Set correct `status` (`issue_ready` vs `all_planned`)
|
||||
- Write solution artifact file before outputting JSON
|
||||
- Include `solution_file` path in output
|
||||
- Use `ccw issue new --json` for issue creation
|
||||
- Clean up spawned sub-agents (issue-plan-agent, issue-queue-agent)
|
||||
- Clean up spawned sub-agents (issue-plan-agent)
|
||||
|
||||
**NEVER**:
|
||||
- Implement code (executor's job)
|
||||
- Output free-form text instead of structured JSON
|
||||
- Skip solution planning (every issue needs a bound solution)
|
||||
- Hold more than 5 issues in a single wave
|
||||
- Skip writing solution artifact file
|
||||
|
||||
## Error Handling
|
||||
|
||||
@@ -255,7 +279,8 @@ function parsePlanPhases(planContent) {
|
||||
|----------|--------|
|
||||
| Issue creation fails | Retry once with simplified text, skip if still fails |
|
||||
| issue-plan-agent timeout | Retry once, output partial results |
|
||||
| issue-queue-agent timeout | Output queue without dependency ordering |
|
||||
| Inline conflict check failure | Use empty depends_on, continue |
|
||||
| Solution artifact write failure | Report error in JSON output, continue |
|
||||
| Plan file not found | Report in output JSON: `"error": "plan file not found"` |
|
||||
| Empty input | Output: `"status": "all_planned", "queue": [], "error": "no input"` |
|
||||
| Empty input | Output: `"status": "all_planned", "error": "no input"` |
|
||||
| Sub-agent parse failure | Use raw output, include in summary |
|
||||
|
||||
Reference in New Issue
Block a user