misec-0.1.2 is not a library.
mise
mise 是一个本地上下文准备工具,用于将项目中的文件、片段和锚点整理成 Agent 可直接消费的上下文候选集合。
它不生成答案,只负责把材料摆好。
特点
• 面向 Agent 的 结构化输出(jsonl / json / md)
• 压缩并编排 find / grep / cat 类操作
• 支持显式 Anchor(锚点),精准圈定上下文
• 依赖分析与变更影响追踪
• 项目内缓存,可随时重建
平台支持
• ✅ Linux
• ✅ macOS
• ❌ Windows(不支持,WSL 不保证)
安装
cargo install mise
或本地构建:
cargo build --release
命令速查
| 命令 |
用途 |
示例 |
scan |
扫描项目结构 |
mise scan --type file --max-depth 2 |
find |
按名称查找文件 |
mise find readme --scope docs |
extract |
提取文件片段 |
mise extract src/main.rs --lines 10:50 |
match |
文本搜索 (ripgrep) |
mise match "TODO|FIXME" src/ |
ast |
AST 结构搜索 |
mise ast "fn main" --scope src |
deps |
依赖分析 |
mise deps src/cli.rs --reverse |
impact |
变更影响分析 |
mise impact --staged |
anchor |
锚点管理 |
mise anchor list --tag chapter |
flow |
组合工作流 |
mise flow pack --anchors intro |
doctor |
检查依赖状态 |
mise doctor |
rebuild |
重建缓存 |
mise rebuild |
基本用法
扫描项目
mise scan mise scan --type file mise scan --type dir --max-depth 2 mise scan --scope src --hidden
查找文件
mise find cargo mise find readme --scope docs
文本匹配(ripgrep 后端)
mise match "TODO" src/ mise match "TODO|FIXME" mise match "unsafe" src tests
提取指定范围内容
mise extract README.md --lines 1:40 mise extract src/main.rs --lines 10:60 --max-bytes 20000
AST 结构搜索(ast-grep 后端)
mise ast "console.log(\$A)" src mise ast "unsafe { \$A }"
默认输出格式为 jsonl,适合 Agent 解析。
依赖分析(deps)
分析代码文件之间的依赖关系,支持 Rust、TypeScript/JavaScript、Python。
mise deps src/cli.rs mise deps src/cli.rs --reverse mise deps
输出格式
mise deps --deps-format jsonl mise deps --deps-format json mise deps --deps-format dot mise deps --deps-format mermaid mise deps --deps-format tree mise deps --deps-format table
生成依赖图可视化:
mise deps --deps-format dot | dot -Tpng -o deps.png
mise deps --deps-format mermaid >> README.md
变更影响分析(impact)
结合 git diff 与依赖图,分析代码变更的影响范围。
mise impact mise impact --staged mise impact --commit abc123 mise impact --diff main..feature mise impact --max-depth 5
输出格式
mise impact --impact-format jsonl mise impact --impact-format json mise impact --impact-format summary mise impact --impact-format table
Anchor(锚点)
在文本中定义显式语义范围:
这里是第一章的背景设定。
锚点查询
mise anchor list mise anchor list --tag chapter mise anchor get ch01.bg mise anchor get intro --with-neighbors 3 mise anchor lint
锚点标记(mark)
Agent 可以用 mark 命令在代码中插入锚点标记:
mise anchor mark README.md --start 10 --end 25 --id intro
mise anchor mark src/main.rs --start 1 --end 50 --id main.entry --tags entry,core
mise anchor mark doc.md --start 5 --end 10 --id sec1 --dry-run
mise anchor batch --json '[
{"path": "README.md", "start_line": 1, "end_line": 10, "id": "intro", "tags": ["doc"]},
{"path": "src/main.rs", "start_line": 5, "end_line": 20, "id": "main"}
]'
mise anchor batch --file marks.json --dry-run
mise anchor unmark README.md --id intro
Anchor 用于作者主动声明上下文边界,而不是自动推断。
Flow(工作流)
Flow 是对多个基础操作的固定组合,用于快速准备可用上下文。
writing - 写作上下文
mise flow writing --anchor ch01.bg mise flow writing --anchor intro --max-items 12
pack - 上下文打包
将锚点和文件打包成适合 AI 的上下文包:
mise flow pack --anchors cli.scan,core.model mise flow pack --anchors intro --files README.md mise flow pack --anchors api --max-tokens 8000 mise flow pack --anchors api --priority confidence mise flow pack --anchors api --stats
stats - 项目统计
mise flow stats mise flow stats --stats-format summary mise flow stats --stats-format json mise flow stats --stats-format table mise flow stats --scope docs --exts md,txt mise flow stats --top 20
统计内容包括:
- 字符数、词数、行数
- CJK 字符计数(中日韩)
- 估算 Token 数
- 锚点按标签分布
- 最大文件排名
outline - 文档大纲
基于锚点生成项目大纲:
mise flow outline mise flow outline --tag chapter mise flow outline --scope docs mise flow outline --outline-format tree mise flow outline --outline-format json mise flow outline --outline-format markdown
Flow 输出的是组织后的材料,不是结论。
输出格式
--format jsonl --format json --format md --format raw --pretty
所有格式来自同一内部结果模型,仅展示方式不同。
缓存
• 项目内缓存目录:.mise/
• 缓存可随时删除并重建
• 不跨项目共享任何状态
mise rebuild
第三方依赖
mise 会自动集成以下工具(如存在):
• ripgrep (rg):文本匹配 mise match
• ast-grep (sg):AST 结构匹配 mise ast
• watchexec(可选):文件变更触发 mise watch
检查依赖状态:
mise doctor
典型工作流组合
1. 探索陌生代码库
mise scan --type file --max-depth 3
mise match "fn main|async fn" src/
mise anchor list
mise deps src/main.rs --deps-format tree
2. 理解变更影响
mise impact --staged --impact-format summary
mise deps src/cli.rs --reverse
mise deps --deps-format dot | dot -Tpng -o impact.png
3. 为 AI 准备上下文
mise flow pack --anchors core.model,cli.commands --max-tokens 4000
mise flow stats --stats-format summary
mise flow outline --outline-format markdown
4. 长期维护标记
mise anchor mark src/core/model.rs --start 1 --end 100 --id core.model --tags core,data
mise anchor mark src/cli.rs --start 500 --end 600 --id cli.commands --tags cli,entry
mise anchor batch --json '[
{"path": "src/main.rs", "start_line": 1, "end_line": 30, "id": "main.entry", "tags": ["entry"]},
{"path": "src/lib.rs", "start_line": 1, "end_line": 50, "id": "lib.exports", "tags": ["api"]}
]'
mise anchor lint
5. 代码审查辅助
mise impact --diff main..feature --impact-format summary
mise impact --staged --impact-format json | jq '.affected_anchors'
mise flow pack --anchors affected.module --files CHANGELOG.md
设计边界(重要)
mise 不会:
• 生成答案或结论
• 保证上下文完整或正确
• 做语义理解或向量检索
• 替代 Agent 的判断
mise 提供的是 上下文候选集合,不是事实来源。
适用场景
• 写作项目(章节、设定、素材管理)
• 需要反复探索的代码仓库
• Agent 工作流中频繁调用文件检索的场景
• 接受噪音,但要求可回溯的上下文准备
一句话
mise 负责备料,不负责出菜。