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
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ the messaging branch are the remaining follow-on work this ADR authorizes.
do not eliminate it the way symlink or in-place would.
- A new marker file and a new detection branch add moving parts to the update checker,
which is security-sensitive (it runs at session start).
- Session-start health checks must resolve through the binary, not hardcoded
`~/.claude/...` paths. Under symlink projection those paths are links into the subdir
repo, so a path-based check is topology-fragile — the embedding-engine notice in
`check-setup.sh` checked the wrong `way-embed` location and went stale once already.
The durable contract: probe the engine *functionally* (`ways match`), which resolves
identically across in-place, copy-subdir, and symlink-subdir installs.

### Neutral

Expand Down
49 changes: 30 additions & 19 deletions hooks/ways/check-setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# SessionStart: Check if ways installation is complete.
# Runs as the first startup hook. If setup is incomplete, emits a
# one-time diagnostic and exits cleanly so other hooks don't error.
# diagnostic and exits cleanly so other hooks don't error.
#
# Checks: ways binary → embedding model (optional) → corpus
# Checks: ways binary → corpus → embedding engine (functional probe)

WAYS_BIN="${HOME}/.claude/bin/ways"
XDG_WAY="${XDG_CACHE_HOME:-$HOME/.cache}/claude-ways/user"
Expand Down Expand Up @@ -43,25 +43,36 @@ MSG
exit 0
fi

# Warn loudly if embedding model is missing — ADR-125 made it a hard dependency
MODEL="${XDG_WAY}/minilm-l6-v2.gguf"
EMBED_BIN="${XDG_WAY}/way-embed"
if [[ ! -f "$MODEL" ]] || [[ ! -x "$EMBED_BIN" ]]; then
# Only mention this once per day (rate limit via marker file).
# Resolve a writable temp dir portably: TMPDIR/TEMP/TMP are set on Windows
# (Git Bash) and most CI; /tmp is the Unix fallback.
MARKER="${TMPDIR:-${TEMP:-${TMP:-/tmp}}}/.claude-embed-notice-$(date +%Y%m%d)"
if [[ ! -f "$MARKER" ]]; then
cat <<'MSG'
# Embedding engine — a hard dependency (ADR-125). Probe it *functionally* rather
# than checking file paths. Two reasons:
# 1. Path checks go stale. The old check looked for way-embed at $XDG_WAY/way-embed,
# but it actually lives at ~/.claude/bin/way-embed — so on a healthy install it
# false-positived "not installed" (masked by a once-a-day marker).
# 2. ADR-140 symlink projection makes ~/.claude/{bin,hooks,...} symlinks into a
# subdir repo. Asking the binary to actually embed a query resolves identically
# across all topologies (in-place / copy-subdir / symlink-subdir) and also
# catches a corrupt model or a binary that loads-but-errors — which existence
# checks miss entirely.
# Loud EVERY session while broken (no per-day suppression): a degraded engine means
# only coarse pattern:/commands:/files: triggers fire, and that must not be skimmable.
# Silent when it works.
probe_embed() {
if command -v timeout >/dev/null 2>&1; then
timeout 10 "$WAYS_BIN" match "$1" 2>/dev/null
else
"$WAYS_BIN" match "$1" 2>/dev/null
fi
}
if ! probe_embed "embedding engine health probe" | grep -qE '[0-9]\.[0-9]'; then
cat <<'MSG'

⚠ Embedding engine not installed — semantic way matching is unavailable.
Only explicit pattern:/commands:/files: triggers will fire.
⚠ Embedding engine is NOT functional — semantic way matching is OFF.
Only explicit pattern:/commands:/files: triggers will fire (coarse — expect ways
to over- and under-fire until this is fixed). It is a hard dependency (ADR-125).

To install:

cd ~/.claude && make setup
Repair:
in-place install: cd ~/.claude && make setup
subdirectory install: cd <repo-subdir> && make setup && make sync-to-home

MSG
touch "$MARKER" 2>/dev/null
fi
fi
2 changes: 1 addition & 1 deletion hooks/ways/softwaredev/code/errors/errors.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: error handling patterns, exception management, try-catch boundaries, error wrapping and propagation
vocabulary: exception handling catch throw boundary wrap rethrow fallback graceful recovery propagate unhandled
pattern: error.?handl|exception|try.?catch|throw|catch
pattern: error.?handl|exception|try.?catch|throw
scope: agent, subagent
refire: 0.2
---
Expand Down
2 changes: 1 addition & 1 deletion hooks/ways/softwaredev/code/performance/performance.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: performance optimization, profiling, benchmarking, latency
vocabulary: optimize profile benchmark latency throughput memory cache bottleneck flamegraph allocation heap speed slow
pattern: slow|optimi|latency|profile|performance|speed.?up|benchmark|bottleneck|throughput|memory.?leak
pattern: slow|optimi|latency|cpu.?profil|flamegraph|performance|speed.?up|benchmark|bottleneck|throughput|memory.?leak
scope: agent, subagent
refire: 0.2
---
Expand Down
2 changes: 1 addition & 1 deletion hooks/ways/softwaredev/delivery/migrations/migrations.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: database migrations, schema changes, table alterations, rollback procedures
vocabulary: migration schema alter table column index rollback seed ddl prisma alembic knex flyway
pattern: migrat|schema|database.?change|alter.?table|alembic|prisma.?migrate|knex.?migrate|flyway|liquibase
pattern: migrat|database.?change|alter.?table|add.?column|drop.?(table|column)|alembic|prisma.?migrate|knex.?migrate|flyway|liquibase
scope: agent, subagent
refire: 0.15
---
Expand Down
2 changes: 1 addition & 1 deletion hooks/ways/softwaredev/delivery/patches/patches.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: creating and applying patch files, git diff generation, patch series management
vocabulary: patch diff apply hunk unified series format-patch
pattern: patch|\.diff|apply.*change
pattern: \.patch\b|git.?(apply|am)|patch.?(set|series)
files: \.(patch|diff)$
commands: git\ apply|git\ diff.*\>
scope: agent, subagent
Expand Down
2 changes: 1 addition & 1 deletion hooks/ways/softwaredev/delivery/release/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: software releases, changelog generation, version bumping, semantic versioning, tagging
vocabulary: release changelog version bump semver tag publish ship major minor breaking
refire: 0.15
pattern: release|changelog|tag|version.?bump|bump.?version|npm.?publish|cargo.?publish
pattern: release|changelog|semver|git.?tag|release.?(notes|candidate)|npm.?publish|cargo.?publish
scope: agent, subagent
---
<!-- epistemic: heuristic -->
Expand Down
Loading