Files
AirCoding ae44be31d5 chore: push all design docs, V2 plan specs, and current working state
Includes AirPlan design documents, AircOding-alpha1-plan, AirPlanV2,
AirPlan-ParaV2, AirPlan-Para V1 reference docs, and all working code
changes across packages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-12 17:12:29 +08:00

66 lines
1.9 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: "AirPlan ctx mode - context manager: compression, token estimation, stale lock detection"
argument-hint: "[enter|compress|validate|estimate|status]"
allowed-tools: "[Read, Glob, Grep, Bash, Write, Edit]"
---
# /ctx
AirContext 管理上下文压缩、Token 估算、陈旧锁检测。三级降级压缩策略:重试 → 换模型 → 截断。
## 硬规则
1. **压缩质量校验** — 压缩后必须调用 `--sub validate` 验证关键信息ADR 引用、TODO、文件路径保留率 ≥70%
2. **压缩前备份** — 每次压缩自动备份原文件为 `.bak`
3. **陈旧锁清理** — 检测到锁持有进程已死则自动清理
## 三级降级压缩
1. **RETRY** — 重新压缩(换 prompt
2. **FALLBACK_MODEL** — 换模型压缩
3. **TRUNCATE** — 放弃压缩,保留原始上下文,通知用户
## 子命令
### enter — 初始化上下文管理器
```bash
python scripts/airplan.py --mode ctx --project . --sub enter
```
### compress — 压缩上下文
```bash
python scripts/airplan.py --mode ctx --project . --sub compress
```
读取 `AirPlan/context.md`执行三级降级压缩。emit `context.compacted` 事件。
### validate — 校验压缩质量
```bash
python scripts/airplan.py --mode ctx --project . --sub validate
```
检查压缩是否保留关键模式文件路径、ADR-XXXX、TODO/FIXME、INV-X。返回 `{validation_ok, level, tokens}`
### estimate — Token 估算
```bash
python scripts/airplan.py --mode ctx --project . --sub estimate
```
按内容类型(中文/英文/代码/Markdown分比率估算 token 数。
### status — 查看状态
```bash
python scripts/airplan.py --mode ctx --project . --sub status
```
## 集成路径
**Eng 压缩检查**:每轮 `monitor_engine()` 后可调 `--sub validate` 检查上下文质量。
**Do Worker 压缩**:长任务 Worker 可在执行前调 `--sub compress` 精简上下文。