DSCC
主页 / cookbook / 01-code-review

01 · Code Review (read-only)

同事丢给你一段 Rust 代码问“有啥明显问题?“。本案例预先埋 2-3 处 bug,让 DSCC 在不改动仓库的前提下找出来。这是试用 DSCC 的最低风险方式:权限模式禁止写入,最坏情况只是消耗 token。

演示能力

准备

在仓库根目录创建一个带已知问题的小文件:

mkdir -p src
cat > src/foo.rs <<'RS'
pub fn first_word(s: &str) -> &str {
    let bytes = s.as_bytes();
    for i in 0..bytes.len() {
        if bytes[i] == b' ' {
            return &s[0..i + 1];   // off-by-one: includes the space
        }
    }
    &s[..]
}

pub fn read_port() -> u16 {
    let raw = std::env::var("PORT").unwrap();
    raw.parse().unwrap()
}
RS

运行命令

dscc --model claude-sonnet-4-6 \
  --permission-mode read-only \
  prompt "$(cat docs/cookbook/01-code-review/PROMPT.md)"

针对 doubao-seed-2.0-code 的真实运行产物见 report_dscc.md / dscc_run.log

预期行为

模型通常会:

  1. glob_searchgrep_search 确认 src/foo.rs 存在。
  2. read_file 读取内容。
  3. 返回一张 Markdown 表格加一行总评。

不应出现 edit_file / write_file / bash。若模型尝试写入,ReadOnly 权限会拒绝。

验收