distill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/distill

/distill

Distill agent instruction files into structured imperatives, compose with policy algebra, and visualize the rule system. Three-stage pipeline.
将Agent指令文件提炼为结构化指令,结合策略代数(policy algebra)并可视化规则系统。这是一个三阶段流程。

Usage

使用方法

/distill                                    # full pipeline on default files
/distill ai-workspace/rules/*.md            # specific targets
/distill --stage imperatives                # run only extraction
/distill --stage compose                    # run only policy algebra (requires prior extraction)
/distill --stage visualize                  # run only visualization (requires prior composition)
/distill                                    # 对默认文件执行完整流程
/distill ai-workspace/rules/*.md            # 指定目标文件
/distill --stage imperatives                # 仅运行提取阶段
/distill --stage compose                    # 仅运行策略代数阶段(需先完成提取)
/distill --stage visualize                  # 仅运行可视化阶段(需先完成组合)

Pipeline

流程

  ┌─────────────┐     ┌──────────────┐     ┌─────────────┐
  │ /imperatives │────▶│/policy-algebra│────▶│ /visualize  │
  │  extract     │     │  compose     │     │  render     │
  └─────────────┘     └──────────────┘     └─────────────┘
        │                    │                    │
    JSONL file         Starlark block      Mermaid diagrams
  ┌─────────────┐     ┌──────────────┐     ┌─────────────┐
  │ /imperatives │────▶│/policy-algebra│────▶│ /visualize  │
  │  extract     │     │  compose     │     │  render     │
  └─────────────┘     └──────────────┘     └─────────────┘
        │                    │                    │
    JSONL file         Starlark block      Mermaid diagrams

Stage 1 — Extract (
/imperatives
)

阶段1 — 提取(
/imperatives

  1. Invoke
    /imperatives
    with the target files (or defaults:
    ai-workspace/rules/*.md
    +
    AGENTS.md
    ).
  2. Save output to
    ai-workspace/research/<name>-imperatives.jsonl
    .
  3. Present the summary (count, level breakdown, scope breakdown).
Ask the user: "Review the extraction before composing? (y/continue)"
  • If yes: present the JSONL for review, wait for feedback, re-extract if needed.
  • If continue: proceed to Stage 2.
  1. 调用
    /imperatives
    处理目标文件(或默认文件:
    ai-workspace/rules/*.md
    +
    AGENTS.md
    )。
  2. 将输出保存至
    ai-workspace/research/<name>-imperatives.jsonl
  3. 展示提取摘要(数量、级别划分、范围划分)。
询问用户:“在组合前是否要审核提取结果?(y/继续)”
  • 如果选择“是”:展示JSONL文件供审核,等待反馈,必要时重新提取。
  • 如果选择“继续”:进入阶段2。

Stage 2 — Compose (
/policy-algebra
)

阶段2 — 组合(
/policy-algebra

  1. Project the JSONL to natural-language bullets:
    <level>[ NOT] <subject> <predicate>[ when <when>]
    — one bullet per imperative.
  2. Invoke
    /policy-algebra
    with the projected bullets.
  3. Save the Starlark composition to
    ai-workspace/research/<name>-policy.md
    .
  4. Present the surfaced structure (decision functions, branching points).
  1. 将JSONL转换为自然语言项目符号:
    <level>[ NOT] <subject> <predicate>[ when <when>]
    — 每条指令对应一个项目符号。
  2. 调用
    /policy-algebra
    处理转换后的项目符号。
  3. 将Starlark组合结果保存至
    ai-workspace/research/<name>-policy.md
  4. 展示提炼出的结构(决策函数、分支点)。

Stage 3 — Visualize (
/visualize
)

阶段3 — 可视化(
/visualize

  1. For each major decision function in the Starlark output, invoke
    /visualize
    .
  2. Content shape is typically graph (decision trees) → Mermaid flowcharts.
  3. Append diagrams to the policy doc.
  1. 针对Starlark输出中的每个主要决策函数,调用
    /visualize
  2. 内容形态通常为图形(决策树)→ Mermaid流程图。
  3. 将图表追加到策略文档中。

Naming

命名规则

The
<name>
slug defaults to the current date + "distill" (e.g.,
2026-05-04-distill
). Override with
--name <slug>
.
<name>
默认格式为当前日期 + "distill"(例如:
2026-05-04-distill
)。可通过
--name <slug>
参数自定义。

Output

输出

All artifacts land in
ai-workspace/research/
:
  • <name>-imperatives.jsonl
    — structured extraction
  • <name>-policy.md
    — Starlark composition + diagrams
所有产物均保存在
ai-workspace/research/
目录下:
  • <name>-imperatives.jsonl
    — 结构化提取结果
  • <name>-policy.md
    — Starlark组合结果 + 图表

Failure modes

故障模式

ConditionBehavior
/imperatives finds zero imperativesReport and stop. No point composing empty input.
/policy-algebra unavailableSkip Stage 2, warn. Stage 3 can still visualize the JSONL directly.
User interrupts between stagesArtifacts from completed stages are preserved. Resume with
--stage
.
条件行为
/imperatives未找到任何指令报告并终止流程。空输入无需进行组合。
/policy-algebra不可用跳过阶段2并发出警告。阶段3仍可直接可视化JSONL文件。
用户在阶段间中断流程已完成阶段的产物会被保留。可通过
--stage
参数恢复流程。

When to use

使用场景

  • AGENTS.md or rules/ grew past a size threshold and needs trimming
  • Before a major restructuring of agent instruction files
  • To audit what rules actually exist vs what you think exists
  • As input to a plan that modifies the rule system
  • AGENTS.md或rules/目录规模超出阈值,需要精简
  • 对Agent指令文件进行重大重构之前
  • 审核实际存在的规则与预期规则是否一致
  • 作为修改规则系统的计划输入