Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ Disable counting:
CD_USAGE_ENABLED=0
```

Disable the primer by itself, leaving counting and guide seeding in place:

```bash
CD_PRIMER=0
```

The primer is fixed cost paid on every session, and whether it earns that cost
is a question about your workload rather than a claim this project can settle
for you. This switch is what makes it answerable: run the same tasks with it on
and off, and compare.

## Project guide seeding

On the first session inside a Git repository, the plugin creates an empty guide
Expand Down
10 changes: 10 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ bash plugins/coding-discipline/hooks/skills-count.sh
CD_USAGE_ENABLED=0
```

只关闭纪律总纲,保留计数和引导文档生成:

```bash
CD_PRIMER=0
```

总纲是每个 session 都要付的固定开销。它值不值这个开销,取决于你自己的工作
负载,不是本项目单方面能替你下结论的事。这个开关的意义就在于让它可被回答:
同样一批任务,开和关各跑一遍,比较结果。

## 自动生成项目引导文档

第一次在 Git 仓库中开启 session 时,如果目标文件不存在,插件会创建一份
Expand Down
8 changes: 8 additions & 0 deletions plugins/coding-discipline/hooks/session-start-skills
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ seed_agent_doc() {
}
seed_agent_doc || true

# The primer is the one piece worth isolating: it is fixed cost paid on every
# session, and whether it earns that cost can only be measured by turning it off
# on its own. Counting and seeding already ran above, so this changes nothing but
# the injected text.
case "${CD_PRIMER:-1}" in
0|false|False|FALSE|no|No|NO|off|Off|OFF) exit 0 ;;
esac

# Cursor uses additional_context; Copilot/SDK uses top-level additionalContext;
# Claude Code, Codex, and the default path use
# hookSpecificOutput.additionalContext.
Expand Down
27 changes: 27 additions & 0 deletions tests/test-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,31 @@ case "$output" in
*'Skill tool'*) fail 'a non-primary host received Claude Code wording' ;;
esac

# The primer can be switched off on its own. Measuring what those characters buy
# means changing that one variable and nothing else, so usage counting and guide
# seeding have to survive the opt-out.
repo_primer_off="${TMP_ROOT}/repo-primer-off"
make_repo "$repo_primer_off"
output="$({
cd "$repo_primer_off"
CD_PRIMER=0 CD_USAGE_LOG="${TMP_ROOT}/usage-primer-off.jsonl" "$HOOK" claude-code
})"
[ -z "$output" ] || fail 'CD_PRIMER=0 still emitted a primer payload'
[ -f "${repo_primer_off}/CLAUDE.md" ] || fail 'CD_PRIMER=0 also suppressed guide seeding'
grep -q '"platform":"claude-code"' "${TMP_ROOT}/usage-primer-off.jsonl" \
|| fail 'CD_PRIMER=0 also suppressed usage counting'

# Leaving it unset keeps the current behavior.
repo_primer_on="${TMP_ROOT}/repo-primer-on"
make_repo "$repo_primer_on"
output="$({
cd "$repo_primer_on"
CD_USAGE_ENABLED=0 "$HOOK" claude-code
})"
printf '%s\n' "$output" | assert_json_output
case "$output" in
*'Skill discipline'*) ;;
*) fail 'the default path stopped injecting the primer' ;;
esac

printf 'hook behavior tests passed\n'
Loading