fix: 为所有 skill 的 .workflow/ 路径添加 projectRoot 前缀

从子目录执行 skill 时,相对路径 .workflow/ 会导致产物落到错误位置。
通过 git rev-parse --show-toplevel || pwd 检测项目根目录,
所有 .workflow/ 路径引用统一加上 {projectRoot} 前缀确保路径正确。

涉及 72 个文件,覆盖 20+ 个 skill。
This commit is contained in:
catlog22
2026-02-08 13:46:48 +08:00
parent 71faaf43a8
commit 54c3234d84
72 changed files with 904 additions and 482 deletions

View File

@@ -30,7 +30,7 @@ if (!existingCycleId && !task) {
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
function readCycleState(cycleId) {
const stateFile = `.workflow/.cycle/${cycleId}.json`
const stateFile = `${projectRoot}/.workflow/.cycle/${cycleId}.json`
if (!fs.existsSync(stateFile)) {
return null
}
@@ -54,18 +54,18 @@ console.log(`Creating new cycle: ${cycleId}`)
#### Create Directory Structure
```bash
mkdir -p .workflow/.cycle/${cycleId}.progress/{ra,ep,cd,vas,coordination}
mkdir -p .workflow/.cycle/${cycleId}.progress/ra/history
mkdir -p .workflow/.cycle/${cycleId}.progress/ep/history
mkdir -p .workflow/.cycle/${cycleId}.progress/cd/history
mkdir -p .workflow/.cycle/${cycleId}.progress/vas/history
mkdir -p ${projectRoot}/.workflow/.cycle/${cycleId}.progress/{ra,ep,cd,vas,coordination}
mkdir -p ${projectRoot}/.workflow/.cycle/${cycleId}.progress/ra/history
mkdir -p ${projectRoot}/.workflow/.cycle/${cycleId}.progress/ep/history
mkdir -p ${projectRoot}/.workflow/.cycle/${cycleId}.progress/cd/history
mkdir -p ${projectRoot}/.workflow/.cycle/${cycleId}.progress/vas/history
```
#### Initialize State File
```javascript
function createCycleState(cycleId, taskDescription) {
const stateFile = `.workflow/.cycle/${cycleId}.json`
const stateFile = `${projectRoot}/.workflow/.cycle/${cycleId}.json`
const now = getUtc8ISOString()
const state = {
@@ -151,7 +151,7 @@ function checkControlSignals(cycleId) {
- **Variable**: `cycleId` - Unique cycle identifier
- **Variable**: `state` - Initialized or resumed cycle state object
- **Variable**: `progressDir` - `.workflow/.cycle/${cycleId}.progress`
- **Variable**: `progressDir` - `${projectRoot}/.workflow/.cycle/${cycleId}.progress`
- **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress
## Next Phase

View File

@@ -33,9 +33,9 @@ function spawnRAAgent(cycleId, state, progressDir) {
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/requirements-analyst.md
2. Read: .workflow/project-tech.json (if exists)
3. Read: .workflow/project-guidelines.json (if exists)
4. Read: .workflow/.cycle/${cycleId}.progress/coordination/feedback.md (if exists)
2. Read: ${projectRoot}/.workflow/project-tech.json (if exists)
3. Read: ${projectRoot}/.workflow/project-guidelines.json (if exists)
4. Read: ${projectRoot}/.workflow/.cycle/${cycleId}.progress/coordination/feedback.md (if exists)
---
@@ -94,8 +94,8 @@ function spawnEPAgent(cycleId, state, progressDir) {
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/exploration-planner.md
2. Read: .workflow/project-tech.json
3. Read: .workflow/project-guidelines.json
2. Read: ${projectRoot}/.workflow/project-tech.json
3. Read: ${projectRoot}/.workflow/project-guidelines.json
4. Read: ${progressDir}/ra/requirements.md
---

View File

@@ -83,7 +83,7 @@ state.completed_phases.push(...['ra', 'ep', 'cd', 'vas'])
state.updated_at = getUtc8ISOString()
// Persist state
Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
Write(`${projectRoot}/.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
```
### Step 3.4: Issue Detection

View File

@@ -16,7 +16,7 @@ Generate unified summary report, update final state, close all agents, and provi
```javascript
function generateFinalSummary(cycleId, state) {
const summaryFile = `.workflow/.cycle/${cycleId}.progress/coordination/summary.md`
const summaryFile = `${projectRoot}/.workflow/.cycle/${cycleId}.progress/coordination/summary.md`
const summary = `# Cycle Summary - ${cycleId}
@@ -40,10 +40,10 @@ function generateFinalSummary(cycleId, state) {
- Test Results: ${state.test_results?.pass_rate || '0'}% passing
## Generated Files
- .workflow/.cycle/${cycleId}.progress/ra/requirements.md
- .workflow/.cycle/${cycleId}.progress/ep/plan.json
- .workflow/.cycle/${cycleId}.progress/cd/changes.log
- .workflow/.cycle/${cycleId}.progress/vas/summary.md
- ${projectRoot}/.workflow/.cycle/${cycleId}.progress/ra/requirements.md
- ${projectRoot}/.workflow/.cycle/${cycleId}.progress/ep/plan.json
- ${projectRoot}/.workflow/.cycle/${cycleId}.progress/cd/changes.log
- ${projectRoot}/.workflow/.cycle/${cycleId}.progress/vas/summary.md
## Continuation Instructions
@@ -65,7 +65,7 @@ This will spawn agents for iteration ${state.current_iteration + 1}.
```javascript
state.status = 'completed'
state.completed_at = getUtc8ISOString()
Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
Write(`${projectRoot}/.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
```
### Step 4.3: Close All Agents
@@ -95,13 +95,13 @@ return {
## Output
- **File**: `.workflow/.cycle/{cycleId}.progress/coordination/summary.md`
- **File**: `.workflow/.cycle/{cycleId}.json` (final state)
- **File**: `{projectRoot}/.workflow/.cycle/{cycleId}.progress/coordination/summary.md`
- **File**: `{projectRoot}/.workflow/.cycle/{cycleId}.json` (final state)
- **TodoWrite**: Mark Phase 4 completed (all tasks done)
## Completion
Parallel Dev Cycle has completed. The cycle report is at `.workflow/.cycle/{cycleId}.progress/coordination/summary.md`.
Parallel Dev Cycle has completed. The cycle report is at `{projectRoot}/.workflow/.cycle/{cycleId}.progress/coordination/summary.md`.
To continue iterating:
```bash