技能尼克斯研究

文档 社区

技能解读

当前原文的自动摘译,尚未人工审校。

上下文参考

参考(不要急于加载): 路径:.opencode/context/core/formats/return-metadata-file.md - 元数据文件模式 路径:.opencode/context/core/patterns/postflight-control.md - 标记文件协议 路径:.opencode/context/core/patterns/jq-escaping-workarounds.md - jq 转义模式

触发条件

该技能在以下情况下激活: 任务语言为“nix” 需要对 Nix、NixOS 或 Home Manager 配置进行研究 需要收集包定义或模块模式

第一阶段:输入验证

验证所需的输入: task_number - 必须提供并存在于 state.json focus_prompt - 研究方向的可选焦点

第 2 阶段:预检状态更新

在调用子代理之前将任务状态更新为“正在研究”。

第 5 阶段:调用子代理

关键:您必须使用任务工具来生成子代理。子代理将: 使用 Read、Grep、Glob 搜索本地 Nix 配置 在 Web 上搜索 NixOS/Home Manager 文档 查询 MCP-NixOS 以获取软件包/选项信息(如果有)

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
文档
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@benbrastmckie · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Nix Research Skill

Thin wrapper that delegates Nix research to `nix-research-agent` subagent.

**IMPORTANT**: This skill implements the skill-internal postflight pattern. After the subagent returns,
this skill handles all postflight operations (status update, artifact linking, git commit) before returning.

## Context References

Reference (do not load eagerly):
- Path: `.opencode/context/core/formats/return-metadata-file.md` - Metadata file schema
- Path: `.opencode/context/core/patterns/postflight-control.md` - Marker file protocol
- Path: `.opencode/context/core/patterns/jq-escaping-workarounds.md` - jq escaping patterns

## Trigger Conditions

This skill activates when:
- Task language is "nix"
- Research is needed for Nix, NixOS, or Home Manager configuration
- Package definitions or module patterns need to be gathered

---

## Execution Flow

### Stage 1: Input Validation

Validate required inputs:
- `task_number` - Must be provided and exist in state.json
- `focus_prompt` - Optional focus for research direction

```bash
# Lookup task
task_data=$(jq -r --argjson num "$task_number" \
  '.active_projects[] | select(.project_number == $num)' \
  specs/state.json)

# Validate exists
if [ -z "$task_data" ]; then
  return error "Task $task_number not found"
fi

# Extract fields
language=$(echo "$task_data" | jq -r '.language // "nix"')
status=$(echo "$task_data" | jq -r '.status')
project_name=$(echo "$task_data" | jq -r '.project_name')
description=$(echo "$task_data" | jq -r '.description // ""')
```

---

### Stage 2: Preflight Status Update

Update task status to "researching" BEFORE invoking subagent.

```bash
bash .opencode/scripts/update-task-status.sh preflight "$task_number" research "$session_id"
```

---

### Stage 3: Create Postflight Marker

```bash
mkdir -p "specs/OC_${padded_num}_${project_name}"

cat > "specs/OC_${padded_num}_${project_name}/.postflight-pending" << EOF
{
  "session_id": "${session_id}",
  "skill": "skill-nix-research",
  "task_number": ${task_number},
  "operation": "research",
  "reason": "Postflight pending: status update, artifact linking, git commit",
  "created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
```

---

### Stage 4: Prepare Delegation Context

```json
{
  "session_id": "sess_{timestamp}_{random}",
  "delegation_depth": 1,
  "delegation_path": ["orchestrator", "research", "skill-nix-research"],
  "timeout": 3600,
  "task_context": {
    "task_number": N,
    "task_name": "{project_name}",
    "description": "{description}",
    "language": "nix"
  },
  "focus_prompt": "{optional focus}",
  "metadata_file_path": "specs/OC_{NNN}_{SLUG}/.return-meta.json"
}
```

---

### Stage 5: Invoke Subagent

**CRITICAL**: You MUST use the **Task** tool to spawn the subagent.

```
Tool: Task (NOT Skill)
Parameters:
  - subagent_type: "nix-research-agent"
  - prompt: [Include task_context, delegation_context, focus_prompt, metadata_file_path]
  - description: "Execute Nix research for task {N}"
```

The subagent will:
- Search local Nix configuration using Read, Grep, Glob
- Search web for NixOS/Home Manager documentation
- Query MCP-NixOS for package/option information (if available)
- Analyze findings and synthesize recommendations
- Create research report
- Write metadata file
- Return brief text summary

---

### Stage 6: Parse Subagent Return

```bash
metadata_file="specs/OC_${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")
    artifact_path=$(jq -r '.artifacts[0].path // ""' "$metadata_file")
    artifact_type=$(jq -r '.artifacts[0].type // ""' "$metadata_file")
    artifact_summary=$(jq -r '.artifacts[0].summary // ""' "$metadata_file")
else
    status="failed"
fi
```

---

### Stage 7: Update Task Status (Postflight)

If status is "researched", update state.json and TODO.md.

```bash
bash .opencode/scripts/update-task-status.sh postflight "$task_number" research "$session_id"
```

---

### Stage 8: Link Artifacts

Add artifact to state.json with summary.

---

### Stage 9: Git Commit

```bash
git add -A
git commit -m "task ${task_number}: complete research

Session: ${session_id}
```

---

### Stage 10: Cleanup

```bash
rm -f "specs/OC_${padded_num}_${project_name}/.postflight-pending"
rm -f "specs/OC_${padded_num}_${project_name}/.return-meta.json"
```

---

### Stage 11: Return Brief Summary

```
Research completed for task {N}:
- Found NixOS module patterns
- Identified package configuration
- Created report at specs/{NNN}_{SLUG}/reports/research-{NNN}.md
- Status updated to [RESEARCHED]
- Changes committed
```

---

## Error Handling

### Input Validation Errors
Return immediately if task not found.

### Metadata File Missing
Keep status as "researching" for resume.

### Git Commit Failure
Non-blocking: Log failure but continue.

---

## Return Format

Brief text summary (NOT JSON).

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。