ln-005-environment-scanner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePaths: File paths (,shared/,references/) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.../ln-*
路径说明: 文件路径(、shared/、references/)均相对于技能仓库根目录。如果在当前工作目录未找到,请定位到本SKILL.md所在目录,再向上一级即为仓库根目录。../ln-*
Environment Scanner (Standalone Utility)
环境扫描器(独立工具)
Type: Standalone Utility
Category: 0XX Shared
Probes CLI agents (Codex, Gemini) and writes . Skills read this file to check flags before live-probing agents.
docs/environment_state.jsondisabled类型: 独立工具
分类: 0XX 共享工具
探测CLI代理(Codex、Gemini)并生成文件。其他技能会在实时探测代理前读取该文件,检查标记。
docs/environment_state.jsondisabledWhen to Use This Skill
何时使用本技能
- First-time project setup (no yet)
docs/environment_state.json - After installing/removing CLI agents (Codex, Gemini)
- After (sync may change agent availability)
ln-004-agent-config-sync - When a skill reports unexpected agent unavailability
- 首次项目搭建(尚未生成文件时)
docs/environment_state.json - 安装/移除CLI代理(Codex、Gemini)后
- 执行后(同步操作可能会改变代理可用性)
ln-004-agent-config-sync - 当某技能报告代理意外不可用时
Output File
输出文件
docs/environment_state.jsonreferences/environment_state_schema.jsonjson
{
"$schema": "environment_state_v1",
"scanned_at": "2026-03-08T14:30:00Z",
"agents": {
"codex": { "available": true, "version": "0.1.2503" },
"gemini": { "available": false, "detail": "Command not found in PATH" }
}
}docs/environment_state.jsonreferences/environment_state_schema.jsonjson
{
"$schema": "environment_state_v1",
"scanned_at": "2026-03-08T14:30:00Z",
"agents": {
"codex": { "available": true, "version": "0.1.2503" },
"gemini": { "available": false, "detail": "Command not found in PATH" }
}
}User Override
用户自定义覆盖
Users can add to any agent entry to opt out without losing detection state:
"disabled": truejson
"codex": { "available": true, "disabled": true, "version": "0.1.2503" }Scanner preserves field on rescan — it overwrites , , but never touches .
disabledavailabledetailversiondisabledHow skills use this: Before running , skills read this file. If → agent is skipped immediately (no probe). If or absent → live health-check runs.
--health-checkdisabled: truedisabled: false用户可在任意代理条目添加标记,无需丢失探测状态即可选择禁用该代理:
"disabled": truejson
"codex": { "available": true, "disabled": true, "version": "0.1.2503" }扫描器在重新扫描时会保留字段——它会覆盖、、字段,但绝不会修改字段。
disabledavailabledetailversiondisabled技能如何使用该文件: 在执行前,技能会先读取此文件。如果 → 直接跳过该代理(不进行实时探测)。如果或未设置 → 执行实时健康检查。
--health-checkdisabled: truedisabled: falseWorkflow
工作流程
Probe Agents → Write JSON → Summary探测代理 → 生成JSON文件 → 生成汇总报告Phase 1: Probe CLI Agents
阶段1:探测CLI代理
Single call to probes all registered agents:
agent_runner.py --health-checkbash
python shared/agents/agent_runner.py --health-checkPath resolution: is relative to skills repo root. Locate via this SKILL.md directory → parent.
shared/agents/agent_runner.pyParse output (JSON with per-agent status):
| Agent | Registry Key | State Fields |
|---|---|---|
| Codex | | |
| Gemini | | |
If not found or errors: Set both agents to , .
agent_runner.pyavailable: falsedetail: "agent_runner.py not available"调用一次即可探测所有已注册的代理:
agent_runner.py --health-checkbash
python shared/agents/agent_runner.py --health-check路径解析: 相对于技能仓库根目录。可通过本SKILL.md所在目录向上一级定位到该文件。
shared/agents/agent_runner.py解析输出(包含各代理状态的JSON数据):
| 代理 | 注册表键 | 状态字段 |
|---|---|---|
| Codex | | |
| Gemini | | |
如果未找到或执行出错: 将两个代理的状态均设为,。
agent_runner.pyavailable: falsedetail: "agent_runner.py not available"Phase 2: Write JSON
阶段2:生成JSON文件
- Read existing state (if exists):
docs/environment_state.json- Preserve fields from existing entries
disabled - Preserve any user-added custom fields
- Preserve
- Build new state:
- :
$schema"environment_state_v1" - : current ISO 8601 timestamp
scanned_at - : merge probe results (new
agents/available/detail) with preservedversionflagsdisabled
- Ensure directory exists (create if missing)
docs/ - Write with 2-space indentation
docs/environment_state.json - Validate written file against structure (key presence check)
references/environment_state_schema.json
- 读取现有状态(如果已存在):
docs/environment_state.json- 保留现有条目中的字段
disabled - 保留所有用户添加的自定义字段
- 保留现有条目中的
- 构建新状态:
- :
$schema"environment_state_v1" - : 当前ISO 8601格式时间戳
scanned_at - : 将探测结果(新的
agents/available/detail)与保留的version标记合并disabled
- 确保目录存在(如果不存在则创建)
docs/ - 写入文件,使用2空格缩进
docs/environment_state.json - 校验写入的文件是否符合的结构要求(检查必填键是否存在)
references/environment_state_schema.json
Phase 3: Summary Report
阶段3:汇总报告
Display results as a table:
Environment Scan Complete:
| Agent | Status | Detail |
|--------|-------------|---------------------------|
| Codex | available | 0.1.2503 |
| Gemini | unavailable | Command not found in PATH |
State written to: docs/environment_state.jsonIf any agent has , show status as (not available/unavailable).
disabled: truedisabled以表格形式展示结果:
环境扫描完成:
| 代理 | 状态 | 详情 |
|--------|-------------|---------------------------|
| Codex | 可用 | 0.1.2503 |
| Gemini | 不可用 | Command not found in PATH |
状态已写入:docs/environment_state.json如果任何代理的,则状态显示为(而非可用/不可用)。
disabled: true已禁用Critical Rules
核心规则
- Probe all agents. This skill always probes ALL agents, regardless of existing state. It is the full rescan.
- Preserve . Never overwrite user's
disabledflags. Detection state updates, user preference stays.disabled: true - No side effects. This skill only writes . No other files modified.
docs/environment_state.json - Fail gracefully. Each probe is independent. One failure = one entry, scan continues.
available: false - No TTL. State file has no expiration. It is refreshed only by running this skill.
- 探测所有代理:本技能始终会探测所有代理,不受现有状态影响。这是一次完整的重新扫描。
- 保留标记:绝不能覆盖用户设置的
disabled标记。探测状态会更新,但用户偏好会被保留。disabled: true - 无副作用:本技能仅会写入文件,不会修改其他任何文件。
docs/environment_state.json - 优雅容错:每个探测操作都是独立的。某一个探测失败只会对应一个条目,扫描仍会继续。
available: false - 无过期时间:状态文件没有过期时间,仅在运行本技能时才会刷新。
Anti-Patterns
反模式
| DON'T | DO |
|---|---|
| Skip probes for "known" agents | Always probe all agents — this is a full scan |
Delete | Merge: overwrite detection fields, preserve |
| Retry failed probes | One attempt per agent. Failure = |
| Probe MCP tools or platform | Only probe CLI agents (Codex, Gemini). MCP tools configured elsewhere |
| Add TTL or cache expiry logic | State is manual-refresh only |
| 禁止操作 | 正确做法 |
|---|---|
| 跳过对"已知"代理的探测 | 始终探测所有代理——这是一次完整扫描 |
重新扫描时删除 | 合并数据:覆盖探测字段,保留 |
| 重试失败的探测 | 每个代理仅尝试一次。失败则设为 |
| 探测MCP工具或平台 | 仅探测CLI代理(Codex、Gemini)。MCP工具的配置在其他地方进行 |
| 添加过期时间或缓存过期逻辑 | 状态仅支持手动刷新 |
版本: 2.0.0
最后更新: 2026-03-08
Definition of Done
—
| # | Criterion |
|---|---|
| 1 | Both agents probed (Codex, Gemini) |
| 2 | |
| 3 | Existing |
| 4 | Summary table displayed to user |
Version: 2.0.0
Last Updated: 2026-03-08
—