Skip to content

Commit afd9729

Browse files
author
catlog22
committed
feat: add plan-converter skill for converting planning artifacts to unified JSONL format
- Implemented a new skill to convert various planning outputs (roadmap.jsonl, plan-note.md, conclusions.json, synthesis.json) into a standardized JSONL task format. - Included detailed documentation on supported input formats, unified JSONL schema, execution process, and error handling. - Added functions for parsing, transforming, and validating input data to ensure quality and consistency in the output.
1 parent c3fd062 commit afd9729

5 files changed

Lines changed: 1287 additions & 500 deletions

File tree

.codex/skills/analyze-with-file/EXECUTE.md

Lines changed: 71 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
## Execution Flow
88

99
```
10-
conclusions.json → execution-plan.jsonl → User Confirmation → Direct Inline Execution → execution.md + execution-events.md
10+
conclusions.json → tasks.jsonl → User Confirmation → Direct Inline Execution → execution.md + execution-events.md
1111
```
1212

1313
---
1414

15-
## Step 1: Generate execution-plan.jsonl
15+
## Step 1: Generate tasks.jsonl
1616

17-
Convert `conclusions.json` recommendations directly into JSONL execution list. Each line is a self-contained task with convergence criteria.
17+
Convert `conclusions.json` recommendations directly into unified JSONL task format. Each line is a self-contained task with convergence criteria, compatible with `unified-execute-with-file`.
1818

1919
**Conversion Logic**:
2020

@@ -32,22 +32,28 @@ const tasks = conclusions.recommendations.map((rec, index) => ({
3232
description: rec.rationale,
3333
type: inferTaskType(rec), // fix | refactor | feature | enhancement | testing
3434
priority: rec.priority, // high | medium | low
35-
files_to_modify: extractFilesFromEvidence(rec, explorations),
35+
effort: inferEffort(rec), // small | medium | large
36+
files: extractFilesFromEvidence(rec, explorations).map(f => ({
37+
path: f,
38+
action: 'modify' // modify | create | delete
39+
})),
3640
depends_on: [], // Serial by default; add dependencies if task ordering matters
3741
convergence: {
3842
criteria: generateCriteria(rec), // Testable conditions
3943
verification: generateVerification(rec), // Executable command or steps
4044
definition_of_done: generateDoD(rec) // Business language
4145
},
42-
context: {
43-
source_conclusions: conclusions.key_conclusions,
44-
evidence: rec.evidence || []
46+
evidence: rec.evidence || [],
47+
source: {
48+
tool: 'analyze-with-file',
49+
session_id: sessionId,
50+
original_id: `TASK-${String(index + 1).padStart(3, '0')}`
4551
}
4652
}))
4753

4854
// Write one task per line
4955
const jsonlContent = tasks.map(t => JSON.stringify(t)).join('\n')
50-
Write(`${sessionFolder}/execution-plan.jsonl`, jsonlContent)
56+
Write(`${sessionFolder}/tasks.jsonl`, jsonlContent)
5157
```
5258

5359
**Task Type Inference**:
@@ -64,7 +70,15 @@ Write(`${sessionFolder}/execution-plan.jsonl`, jsonlContent)
6470
- Parse evidence from `explorations.json` or `perspectives.json`
6571
- Match recommendation action keywords to `relevant_files`
6672
- If no specific files found, use pattern matching from findings
67-
- Include both files to modify and files as read-only context
73+
- Return file paths as strings (converted to `{path, action}` objects in the task)
74+
75+
**Effort Inference**:
76+
77+
| Signal | Effort |
78+
|--------|--------|
79+
| Priority high + multiple files | `large` |
80+
| Priority medium or 1-2 files | `medium` |
81+
| Priority low or single file | `small` |
6882

6983
**Convergence Generation**:
7084

@@ -92,13 +106,13 @@ tasks.forEach(task => {
92106
})
93107
```
94108

95-
**Output**: `${sessionFolder}/execution-plan.jsonl`
109+
**Output**: `${sessionFolder}/tasks.jsonl`
96110

97111
**JSONL Schema** (one task per line):
98112

99113
```jsonl
100-
{"id":"TASK-001","title":"Fix authentication token refresh","description":"Token refresh fails silently when...","type":"fix","priority":"high","files_to_modify":["src/auth/token.ts","src/middleware/auth.ts"],"depends_on":[],"convergence":{"criteria":["Token refresh returns new valid token","Expired token triggers refresh automatically","Failed refresh redirects to login"],"verification":"jest --testPathPattern=token.test.ts","definition_of_done":"Users remain logged in across token expiration without manual re-login"},"context":{"source_conclusions":[...],"evidence":[...]}}
101-
{"id":"TASK-002","title":"Add input validation to user endpoints","description":"Missing validation allows...","type":"enhancement","priority":"medium","files_to_modify":["src/routes/user.ts","src/validators/user.ts"],"depends_on":["TASK-001"],"convergence":{"criteria":["All user inputs validated against schema","Invalid inputs return 400 with specific error message","SQL injection patterns rejected"],"verification":"jest --testPathPattern=user.validation.test.ts","definition_of_done":"All user-facing inputs are validated with clear error feedback"},"context":{"source_conclusions":[...],"evidence":[...]}}
114+
{"id":"TASK-001","title":"Fix authentication token refresh","description":"Token refresh fails silently when...","type":"fix","priority":"high","effort":"large","files":[{"path":"src/auth/token.ts","action":"modify"},{"path":"src/middleware/auth.ts","action":"modify"}],"depends_on":[],"convergence":{"criteria":["Token refresh returns new valid token","Expired token triggers refresh automatically","Failed refresh redirects to login"],"verification":"jest --testPathPattern=token.test.ts","definition_of_done":"Users remain logged in across token expiration without manual re-login"},"evidence":[...],"source":{"tool":"analyze-with-file","session_id":"ANL-xxx","original_id":"TASK-001"}}
115+
{"id":"TASK-002","title":"Add input validation to user endpoints","description":"Missing validation allows...","type":"enhancement","priority":"medium","effort":"medium","files":[{"path":"src/routes/user.ts","action":"modify"},{"path":"src/validators/user.ts","action":"create"}],"depends_on":["TASK-001"],"convergence":{"criteria":["All user inputs validated against schema","Invalid inputs return 400 with specific error message","SQL injection patterns rejected"],"verification":"jest --testPathPattern=user.validation.test.ts","definition_of_done":"All user-facing inputs are validated with clear error feedback"},"evidence":[...],"source":{"tool":"analyze-with-file","session_id":"ANL-xxx","original_id":"TASK-002"}}
102116
```
103117

104118
---
@@ -110,7 +124,7 @@ Validate feasibility before starting execution. Reference: unified-execute-with-
110124
##### Step 2.1: Build Execution Order
111125

112126
```javascript
113-
const tasks = Read(`${sessionFolder}/execution-plan.jsonl`)
127+
const tasks = Read(`${sessionFolder}/tasks.jsonl`)
114128
.split('\n').filter(l => l.trim()).map(l => JSON.parse(l))
115129

116130
// 1. Dependency validation
@@ -169,9 +183,9 @@ const executionOrder = topoSort(tasks)
169183
// Check files modified by multiple tasks
170184
const fileTaskMap = new Map() // file → [taskIds]
171185
tasks.forEach(task => {
172-
task.files_to_modify.forEach(file => {
173-
if (!fileTaskMap.has(file)) fileTaskMap.set(file, [])
174-
fileTaskMap.get(file).push(task.id)
186+
(task.files || []).forEach(f => {
187+
if (!fileTaskMap.has(f.path)) fileTaskMap.set(f.path, [])
188+
fileTaskMap.get(f.path).push(task.id)
175189
})
176190
})
177191

@@ -185,8 +199,10 @@ fileTaskMap.forEach((taskIds, file) => {
185199
// Check file existence
186200
const missingFiles = []
187201
tasks.forEach(task => {
188-
task.files_to_modify.forEach(file => {
189-
if (!file_exists(file)) missingFiles.push({ file, task: task.id, action: "Will be created" })
202+
(task.files || []).forEach(f => {
203+
if (f.action !== 'create' && !file_exists(f.path)) {
204+
missingFiles.push({ file: f.path, task: task.id, action: "Will be created" })
205+
}
190206
})
191207
})
192208
```
@@ -204,7 +220,7 @@ const executionMd = `# Execution Overview
204220
205221
## Session Info
206222
- **Session ID**: ${sessionId}
207-
- **Plan Source**: execution-plan.jsonl (from analysis conclusions)
223+
- **Plan Source**: tasks.jsonl (from analysis conclusions)
208224
- **Started**: ${getUtc8ISOString()}
209225
- **Total Tasks**: ${tasks.length}
210226
- **Execution Mode**: Direct inline (serial)
@@ -254,7 +270,7 @@ const eventsHeader = `# Execution Events
254270
255271
**Session**: ${sessionId}
256272
**Started**: ${getUtc8ISOString()}
257-
**Source**: execution-plan.jsonl
273+
**Source**: tasks.jsonl
258274
259275
---
260276
@@ -341,15 +357,16 @@ for (const taskId of executionOrder) {
341357
342358
**Type**: ${task.type} | **Priority**: ${task.priority}
343359
**Status**: ⏳ IN PROGRESS
344-
**Files**: ${task.files_to_modify.join(', ')}
360+
**Files**: ${(task.files || []).map(f => f.path).join(', ')}
345361
**Description**: ${task.description}
346362
347363
### Execution Log
348364
`)
349365

350366
// 3. Execute task directly
351-
// - Read each file in task.files_to_modify
367+
// - Read each file in task.files (if specified)
352368
// - Analyze what changes satisfy task.description + task.convergence.criteria
369+
// - If task.files has detailed changes, use them as guidance
353370
// - Apply changes using Edit (preferred) or Write (for new files)
354371
// - Use Grep/Glob for discovery if needed
355372
// - Use Bash for build/test verification commands
@@ -409,6 +426,12 @@ ${attemptedChanges}
409426
updateTaskStatus(task.id, 'failed', [], errorMessage)
410427
failedTasks.add(task.id)
411428

429+
// Set _execution state
430+
task._execution = {
431+
status: 'failed', executed_at: getUtc8ISOString(),
432+
result: { success: false, error: errorMessage, files_modified: [] }
433+
}
434+
412435
// Ask user how to proceed
413436
if (!autoYes) {
414437
const decision = AskUserQuestion({
@@ -431,7 +454,7 @@ if (!autoYes) {
431454
After each successful task, optionally commit changes:
432455

433456
```javascript
434-
if (autoCommit && task.status === 'completed') {
457+
if (autoCommit && task._execution?.status === 'completed') {
435458
// 1. Stage modified files
436459
Bash(`git add ${filesModified.join(' ')}`)
437460

@@ -473,17 +496,17 @@ const summary = `
473496
474497
| ID | Title | Status | Files Modified |
475498
|----|-------|--------|----------------|
476-
${tasks.map(t => `| ${t.id} | ${t.title} | ${t.status} | ${(t.result?.files_modified || []).join(', ') || '-'} |`).join('\n')}
499+
${tasks.map(t => `| ${t.id} | ${t.title} | ${t._execution?.status || 'pending'} | ${(t._execution?.result?.files_modified || []).join(', ') || '-'} |`).join('\n')}
477500
478501
${failedTasks.size > 0 ? `### Failed Tasks Requiring Attention
479502
480503
${[...failedTasks].map(id => {
481504
const t = tasks.find(t => t.id === id)
482-
return `- **${t.id}**: ${t.title}${t.result?.error || 'Unknown error'}`
505+
return `- **${t.id}**: ${t.title}${t._execution?.result?.error || 'Unknown error'}`
483506
}).join('\n')}
484507
` : ''}
485508
### Artifacts
486-
- **Execution Plan**: ${sessionFolder}/execution-plan.jsonl
509+
- **Execution Plan**: ${sessionFolder}/tasks.jsonl
487510
- **Execution Overview**: ${sessionFolder}/execution.md
488511
- **Execution Events**: ${sessionFolder}/execution-events.md
489512
`
@@ -507,23 +530,26 @@ appendToEvents(`
507530
`)
508531
```
509532
510-
##### Step 6.3: Update execution-plan.jsonl
533+
##### Step 6.3: Update tasks.jsonl
511534
512-
Rewrite JSONL with execution results per task:
535+
Rewrite JSONL with `_execution` state per task:
513536
514537
```javascript
515538
const updatedJsonl = tasks.map(task => JSON.stringify({
516539
...task,
517-
status: task.status, // "completed" | "failed" | "skipped" | "pending"
518-
executed_at: task.executed_at, // ISO timestamp
519-
result: {
520-
success: task.status === 'completed',
521-
files_modified: task.result?.files_modified || [],
522-
summary: task.result?.summary || '',
523-
error: task.result?.error || null
540+
_execution: {
541+
status: task._status, // "completed" | "failed" | "skipped" | "pending"
542+
executed_at: task._executed_at, // ISO timestamp
543+
result: {
544+
success: task._status === 'completed',
545+
files_modified: task._result?.files_modified || [],
546+
summary: task._result?.summary || '',
547+
error: task._result?.error || null,
548+
convergence_verified: task._result?.convergence_verified || []
549+
}
524550
}
525551
})).join('\n')
526-
Write(`${sessionFolder}/execution-plan.jsonl`, updatedJsonl)
552+
Write(`${sessionFolder}/tasks.jsonl`, updatedJsonl)
527553
```
528554
529555
---
@@ -560,10 +586,10 @@ if (!autoYes) {
560586
| Done | Display artifact paths, end workflow |
561587
562588
**Retry Logic**:
563-
- Filter tasks with `status: "failed"`
589+
- Filter tasks with `_execution.status === 'failed'`
564590
- Re-execute in original dependency order
565591
- Append retry events to execution-events.md with `[RETRY]` prefix
566-
- Update execution.md and execution-plan.jsonl
592+
- Update execution.md and tasks.jsonl
567593
568594
---
569595
@@ -574,14 +600,14 @@ When Quick Execute is activated, session folder expands with:
574600
```
575601
{projectRoot}/.workflow/.analysis/ANL-{slug}-{date}/
576602
├── ... # Phase 1-4 artifacts
577-
├── execution-plan.jsonl # ⭐ JSONL execution list (one task per line, with convergence)
603+
├── tasks.jsonl # ⭐ Unified JSONL (one task per line, with convergence + source)
578604
├── execution.md # Plan overview + task table + execution summary
579605
└── execution-events.md # ⭐ Unified event log (all task executions with details)
580606
```
581607
582608
| File | Purpose |
583609
|------|---------|
584-
| `execution-plan.jsonl` | Self-contained task list from conclusions, each line has convergence criteria |
610+
| `tasks.jsonl` | Unified task list from conclusions, each line has convergence criteria and source provenance |
585611
| `execution.md` | Overview: plan source, task table, pre-execution analysis, execution timeline, final summary |
586612
| `execution-events.md` | Chronological event stream: task start/complete/fail with details, changes, verification results |
587613
@@ -594,7 +620,7 @@ When Quick Execute is activated, session folder expands with:
594620
595621
**Session**: ANL-xxx-2025-01-21
596622
**Started**: 2025-01-21T10:00:00+08:00
597-
**Source**: execution-plan.jsonl
623+
**Source**: tasks.jsonl
598624
599625
---
600626
@@ -655,19 +681,20 @@ When Quick Execute is activated, session folder expands with:
655681
|-----------|--------|----------|
656682
| Task execution fails | Record failure in execution-events.md, ask user | Retry, skip, or abort |
657683
| Verification command fails | Mark criterion as unverified, continue | Note in events, manual check needed |
658-
| No recommendations in conclusions | Cannot generate execution-plan.jsonl | Inform user, suggest lite-plan |
684+
| No recommendations in conclusions | Cannot generate tasks.jsonl | Inform user, suggest lite-plan |
659685
| File conflict during execution | Document in execution-events.md | Resolve in dependency order |
660-
| Circular dependencies detected | Stop, report error | Fix dependencies in execution-plan.jsonl |
686+
| Circular dependencies detected | Stop, report error | Fix dependencies in tasks.jsonl |
661687
| All tasks fail | Record all failures, suggest analysis review | Re-run analysis or manual intervention |
662688
| Missing target file | Attempt to create if task.type is "feature" | Log as warning for other types |
663689
664690
---
665691
666692
## Success Criteria
667693
668-
- `execution-plan.jsonl` generated with convergence criteria per task
694+
- `tasks.jsonl` generated with convergence criteria and source provenance per task
669695
- `execution.md` contains plan overview, task table, pre-execution analysis, final summary
670696
- `execution-events.md` contains chronological event stream with convergence verification
671697
- All tasks executed (or explicitly skipped) via direct inline execution
672698
- Each task's convergence criteria checked and recorded
699+
- `_execution` state written back to tasks.jsonl after completion
673700
- User informed of results and next steps

0 commit comments

Comments
 (0)