name: skill-neovim-implementation description: 从计划中实现Neovim配置更改。为Neovim实现任务调用。 allowed-tools: Task, Bash, Edit, Read, Write, Read(/tmp/.json), Bash(rm:)
Neovim实现技能
薄包装器,将Neovim实现委托给neovim-implementation-agent子代理。
重要:此技能实现技能内部后处理模式。在子代理返回后,此技能处理所有后处理操作(状态更新、工件链接、Git提交)然后返回。
上下文引用
参考(不要急切加载):
- 路径:
.opencode/context/core/formats/return-metadata-file.md- 元数据文件模式 - 路径:
.opencode/context/core/patterns/postflight-control.md- 标记文件协议 - 路径:
.opencode/context/core/patterns/jq-escaping-workarounds.md- jq转义模式
触发条件
此技能在以下情况激活:
- 任务语言为“neovim”
- 任务存在实现计划
- 需要应用Neovim配置更改
执行流程
阶段1:输入验证
验证必需输入:
task_number- 必须提供且存在于state.json中plan_path- 实现计划必须存在
# 查找任务
task_data=$(jq -r --argjson num "$task_number" \
'.active_projects[] | select(.project_number == $num)' \
specs/state.json)
# 验证存在
if [ -z "$task_data" ]; then
return error "Task $task_number not found"
fi
# 提取字段
language=$(echo "$task_data" | jq -r '.language // "neovim"')
status=$(echo "$task_data" | jq -r '.status')
project_name=$(echo "$task_data" | jq -r '.project_name')
# 查找计划文件(使用填充目录号)
padded_num=$(printf "%03d" "$task_number")
plan_path="specs/${padded_num}_${project_name}/plans/implementation-001.md"
if [ ! -f "$plan_path" ]; then
return error "Plan not found: $plan_path"
fi
阶段2:预检状态更新
在调用子代理之前更新任务状态为“implementing”。
更新state.json:
jq --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg status "implementing" \
--arg sid "$session_id" \
'(.active_projects[] | select(.project_number == '$task_number')) |= . + {
status: $status,
last_updated: $ts,
session_id: $sid
}' specs/state.json > /tmp/state.json && mv /tmp/state.json specs/state.json
更新TODO.md:使用Edit工具将状态标记更改为[IMPLEMENTING]。
更新计划文件(如果存在):更新计划元数据中的状态字段:
# 查找最新计划文件
plan_file=$(ls -1 "specs/${padded_num}_${project_name}/plans/implementation-"*.md 2>/dev/null | sort -V | tail -1)
if [ -n "$plan_file" ] && [ -f "$plan_file" ]; then
sed -i 's/^\- \*\*Status\*\*: \[.*\]$/- **Status**: [IMPLEMENTING]/' "$plan_file"
sed -i 's/^\*\*Status\*\*: \[.*\]$/**Status**: [IMPLEMENTING]/' "$plan_file"
fi
阶段3:创建后处理标记
mkdir -p "specs/${padded_num}_${project_name}"
cat > "specs/${padded_num}_${project_name}/.postflight-pending" << EOF
{
"session_id": "${session_id}",
"skill": "skill-neovim-implementation",
"task_number": ${task_number},
"operation": "implement",
"reason": "Postflight pending: status update, artifact linking, git commit",
"created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
阶段4:准备委托上下文
{
"session_id": "sess_{timestamp}_{random}",
"delegation_depth": 1,
"delegation_path": ["orchestrator", "implement", "skill-neovim-implementation"],
"timeout": 3600,
"task_context": {
"task_number": N,
"task_name": "{project_name}",
"description": "{description}",
"language": "neovim"
},
"plan_path": "specs/{NNN}_{SLUG}/plans/implementation-001.md",
"metadata_file_path": "specs/{NNN}_{SLUG}/.return-meta.json"
}
阶段5:调用子代理
关键:必须使用Task工具生成子代理。
Tool: Task (NOT Skill)
Parameters:
- subagent_type: "neovim-implementation-agent"
- prompt: [Include task_context, delegation_context, plan_path, metadata_file_path]
- description: "Execute Neovim implementation for task {N}"
子代理将:
- 读取并解析实现计划
- 按顺序执行阶段
- 创建/修改Neovim配置文件
- 使用nvim --headless验证更改
- 创建实现摘要
- 写入元数据文件
- 返回简要文本摘要
阶段6:解析子代理返回
metadata_file="specs/${padded_num}_${project_name}/.return-meta.json"
if [ -f "$metadata_file" ] && jq empty "$metadata_file" 2>/dev/null; then
status=$(jq -r '.status' "$metadata_file")
phases_completed=$(jq -r '.metadata.phases_completed // 0' "$metadata_file")
phases_total=$(jq -r '.metadata.phases_total // 0' "$metadata_file")
else
status="failed"
fi
阶段7:更新任务状态(后处理)
如果状态为“implemented”,更新state.json和TODO.md。
更新state.json:
jq --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg status "completed" \
'(.active_projects[] | select(.project_number == '$task_number')) |= . + {
status: $status,
last_updated: $ts,
completed: $ts
}' specs/state.json > /tmp/state.json && mv /tmp/state.json specs/state.json
更新TODO.md:使用Edit工具将状态标记更改为[COMPLETED]。
更新计划文件(如果存在):将状态字段更新为[COMPLETED]并进行验证:
plan_file=$(ls -1 "specs/${padded_num}_${project_name}/plans/implementation-"*.md 2>/dev/null | sort -V | tail -1)
if [ -n "$plan_file" ] && [ -f "$plan_file" ]; then
# 先尝试项目符号模式,然后非项目符号模式
sed -i 's/^\- \*\*Status\*\*: \[.*\]$/- **Status**: [COMPLETED]/' "$plan_file"
sed -i 's/^\*\*Status\*\*: \[.*\]$/**Status**: [COMPLETED]/' "$plan_file"
# 验证更新
if grep -qE '^\*\*Status\*\*: \[COMPLETED\]|^\- \*\*Status\*\*: \[COMPLETED\]' "$plan_file"; then
echo "Plan file status updated to [COMPLETED]"
else
echo "WARNING: Could not verify plan file status update"
fi
else
echo "INFO: No plan file found to update (directory: specs/${padded_num}_${project_name}/plans/)"
fi
在部分/失败时:保持状态为“implementing”以便恢复。
更新计划文件(如果存在):将状态字段更新为[PARTIAL]并进行验证:
plan_file=$(ls -1 "specs/${padded_num}_${project_name}/plans/implementation-"*.md 2>/dev/null | sort -V | tail -1)
if [ -n "$plan_file" ] && [ -f "$plan_file" ]; then
# 先尝试项目符号模式,然后非项目符号模式
sed -i 's/^\- \*\*Status\*\*: \[.*\]$/- **Status**: [PARTIAL]/' "$plan_file"
sed -i 's/^\*\*Status\*\*: \[.*\]$/**Status**: [PARTIAL]/' "$plan_file"
# 验证更新
if grep -qE '^\*\*Status\*\*: \[PARTIAL\]|^\- \*\*Status\*\*: \[PARTIAL\]' "$plan_file"; then
echo "Plan file status updated to [PARTIAL]"
else
echo "WARNING: Could not verify plan file status update"
fi
else
echo "INFO: No plan file found to update (directory: specs/${padded_num}_${project_name}/plans/)"
fi
阶段8:链接工件
将实现工件添加到state.json。
更新TODO.md:添加摘要工件链接。
去除TODO.md的specs/前缀(TODO.md在specs/内):todo_link_path="${artifact_path#specs/}"
- **Summary**: [implementation-summary-{DATE}.md]({todo_link_path})
阶段9:Git提交
git add -A
git commit -m "task ${task_number}: complete implementation
Session: ${session_id}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
阶段10:清理
rm -f "specs/${padded_num}_${project_name}/.postflight-pending"
rm -f "specs/${padded_num}_${project_name}/.return-meta.json"
阶段11:返回简要摘要
Implementation completed for task {N}:
- Executed {phases_completed}/{phases_total} phases
- Created/modified Neovim config files
- Verified startup and module loading
- Created summary at specs/{NNN}_{SLUG}/summaries/implementation-summary-{DATE}.md
- Status updated to [COMPLETED]
- Changes committed
错误处理
计划未找到
如果实现计划不存在,返回错误。
验证失败
如果nvim --headless失败:
- 保持状态为“implementing”
- 将阶段标记为[PARTIAL]
- 报告验证错误
Git提交失败
非阻塞:记录失败但继续。
返回格式
简要文本摘要(NOT JSON)。