forked from bchanot/claude
feat(graphify): usage rules print from session-start only where a graph exists
This commit is contained in:
1 parent
4bbb3c58d4
commit
de6e51ce7a
3 files changed
+38
-11
No files matched your search
+3
-7
@@ -303,10 +303,6 @@ office-hours…) are gone: use the fallback above, else say so.
|
|||||||
|
|
||||||
Threshold: graphify from 200 tracked code files, never below (banner line
|
Threshold: graphify from 200 tracked code files, never below (banner line
|
||||||
`graphify? N code files ≥ 200, no graph` informs, the user decides; never
|
`graphify? N code files ≥ 200, no graph` informs, the user decides; never
|
||||||
build or `graphify claude install` without that go). ALL rules below apply
|
build or `graphify claude install` without that go). With a graph
|
||||||
only if `graphify-out/graph.json` exists — else read files directly.
|
(`graphify-out/graph.json`): `graphify query` before raw grep,
|
||||||
- Codebase-wide question → `graphify query`; relationships → `path A B`;
|
`graphify update .` after code edits; the session banner prints the rest.
|
||||||
concept → `explain`. Scoped subgraph beats raw grep.
|
|
||||||
- Known file / small task → read directly, no graphify.
|
|
||||||
- `wiki/index.md` → broad-nav entry; `GRAPH_REPORT.md` → whole-architecture.
|
|
||||||
- After editing code → `graphify update .` (AST-only, free).
|
|
||||||
+19
-4
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# ── Quick health check (filesystem only, no subprocesses) ──
|
# ── Quick health check (filesystem only, no subprocesses) ──
|
||||||
BROKEN=()
|
BROKEN=()
|
||||||
for f in CLAUDE.md settings.json agents skills; do
|
for f in CLAUDE.md settings.json agents skills rules; do
|
||||||
[ ! -e "$HOME/.claude/$f" ] && BROKEN+=("$f")
|
[ ! -e "$HOME/.claude/$f" ] && BROKEN+=("$f")
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -254,9 +254,9 @@ if [ -n "$GRAPHIFY_HINT" ]; then
|
|||||||
printf "│ 🕸️ %-44s│\n" "${GRAPHIFY_HINT:0:44}"
|
printf "│ 🕸️ %-44s│\n" "${GRAPHIFY_HINT:0:44}"
|
||||||
printf "│ %-40s│\n" "→ /graphify (AST, seconds) — you decide"
|
printf "│ %-40s│\n" "→ /graphify (AST, seconds) — you decide"
|
||||||
fi
|
fi
|
||||||
# CLAUDE.global.md line-count guard (anti-regression). BDR-062 supersedes
|
# CLAUDE.global.md line-count guard (anti-regression, BDR-062): warn past
|
||||||
# BDR-031's 275 target: 305 is the assumed reality (extraction done at
|
# 320. BDR-125 phase 1 moved Design work, the graphify usage and the
|
||||||
# job1; further compression costs clarity > token gain) — warn past 320.
|
# architecture defaults to their carriers (333 → ~285 lines).
|
||||||
if [ -n "$REPO_DIR" ] && [ -f "$REPO_DIR/CLAUDE.global.md" ]; then
|
if [ -n "$REPO_DIR" ] && [ -f "$REPO_DIR/CLAUDE.global.md" ]; then
|
||||||
_claude_lines=$(wc -l < "$REPO_DIR/CLAUDE.global.md")
|
_claude_lines=$(wc -l < "$REPO_DIR/CLAUDE.global.md")
|
||||||
if [ "$_claude_lines" -gt 320 ]; then
|
if [ "$_claude_lines" -gt 320 ]; then
|
||||||
@@ -293,5 +293,20 @@ echo "│ 💡 /plugin-check before starting a new project │"
|
|||||||
echo "│ 🩺 make doctor full diagnostic │"
|
echo "│ 🩺 make doctor full diagnostic │"
|
||||||
echo "└───────────────────────────────────────────────────┘"
|
echo "└───────────────────────────────────────────────────┘"
|
||||||
[ -n "$EFFORT_WARN" ] && printf '%s\n' "$EFFORT_WARN"
|
[ -n "$EFFORT_WARN" ] && printf '%s\n' "$EFFORT_WARN"
|
||||||
|
# graphify usage (BDR-125 phase 1): the rules left CLAUDE.global.md, which
|
||||||
|
# keeps the 200-file threshold and a one-line reminder; they print where a
|
||||||
|
# graph exists.
|
||||||
|
_gx_root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
if [ -n "$_gx_root" ] && [ -f "$_gx_root/graphify-out/graph.json" ]; then
|
||||||
|
cat <<'EOF'
|
||||||
|
graphify (graphify-out/graph.json present):
|
||||||
|
- Codebase-wide question → `graphify query`; relationships → `path A B`;
|
||||||
|
concept → `explain`. Scoped subgraph beats raw grep.
|
||||||
|
- Known file / small task → read directly, no graphify.
|
||||||
|
- `wiki/index.md` → broad-nav entry; `GRAPH_REPORT.md` → whole-architecture.
|
||||||
|
- After editing code → `graphify update .` (AST-only, free).
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
unset _gx_root
|
||||||
echo ""
|
echo ""
|
||||||
unset TOKEN_WARN
|
unset TOKEN_WARN
|
||||||
@@ -56,5 +56,21 @@ for i in $(seq 1 300); do echo "# $i" > "$d/doc$i.md"; done
|
|||||||
git -C "$d" add -A; git -C "$d" commit -q -m docs
|
git -C "$d" add -A; git -C "$d" commit -q -m docs
|
||||||
check T9-non-code-not-counted "$(gate "$d")" silent
|
check T9-non-code-not-counted "$(gate "$d")" silent
|
||||||
|
|
||||||
|
# ── session-start prints the usage rules only where a graph exists
|
||||||
|
# (BDR-125 phase 1: the body left CLAUDE.global.md) ──
|
||||||
|
SS="$(cd "$(dirname "$0")/../.." && pwd)/hooks/session-start.sh"
|
||||||
|
banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$SS" </dev/null 2>/dev/null); }
|
||||||
|
d=$(mkrepo ss 1)
|
||||||
|
out=$(banner "$d")
|
||||||
|
check S1-banner-control "$(grep -c 'Claude Code config' <<<"$out")" 1
|
||||||
|
check S1b-no-graph-silent "$(grep -c 'graphify query' <<<"$out")" 0
|
||||||
|
mkdir -p "$d/graphify-out" "$d/app/sub"; echo '{}' > "$d/graphify-out/graph.json"
|
||||||
|
out=$(banner "$d")
|
||||||
|
check S2-graph-prints "$(grep -c 'graphify query' <<<"$out")" 1
|
||||||
|
check S2b-update-rule "$(grep -c 'graphify update \.' <<<"$out")" 1
|
||||||
|
check S3-from-subdir "$(banner "$d/app/sub" | grep -c 'graphify query')" 1
|
||||||
|
out=$(banner "$WORK/plain")
|
||||||
|
check S4-not-a-repo "$(grep -c 'graphify query' <<<"$out")/$(grep -c 'Claude Code config' <<<"$out")" 0/1
|
||||||
|
|
||||||
echo "PASS=$pass FAIL=$fail"
|
echo "PASS=$pass FAIL=$fail"
|
||||||
[ "$fail" -eq 0 ]
|
[ "$fail" -eq 0 ]
|
||||||
Reference in new issue
Block a user