ECC/scripts/lib
Gaurav Dubey 5987bd4dc6
feat(session-start): rank injected instincts by project/stack relevance (#2466)
* feat(session-start): rank injected instincts by project/stack relevance

Instinct selection at SessionStart ranked purely by confidence, so a
high-confidence instinct about an unrelated stack could take an injection
slot from a lower-confidence instinct that is actually relevant to the
current project.

Rank by confidence + location/stack relevance instead: project-scoped
instincts, and instincts whose domain/trigger matches the detected stack
(languages/frameworks via detectProjectType, plus terraform/dbt markers),
get a small additive boost. The confidence>=threshold floor and the
injection cap are unchanged, and ranking degrades to confidence-only when
nothing matches or when ECC_INSTINCT_RELEVANCE_RANKING is set to off.

The ranking helpers live in scripts/lib/instinct-relevance.js with unit
coverage in tests/lib/, plus an end-to-end ordering test in tests/hooks/.

Completes part (b) of #2371; part (a) (configurable count + threshold)
shipped in #2413.

Fixes #2371

* refactor(session-start): drop redundant confidence tiebreaker in instinct sort

Greptile flagged that the secondary `right.confidence` comparison in
summarizeActiveInstincts' sort was dead code when relevance ranking is
disabled and, when enabled, was reached only on a floating-point tie of the
combined score — where it skipped the intended scope-label tiebreaker.

Remove it: the primary combined-score comparison already reduces to
confidence-only ordering when relevance is off, so behavior there is
unchanged; a genuine combined-score tie now falls through to the documented
scope-first, then id, order.

* test: isolate instinct relevance environment

---------

Co-authored-by: haelyra <49814733+haelyra@users.noreply.github.com>
2026-08-10 21:46:24 -04:00
..
agent-proximity feat(layer4): line-range channel + trigger firing 2026-06-20 17:30:52 -04:00
control-pane feat: Plan Canvas, a browser review canvas for plans (#2467) 2026-07-08 17:12:48 -04:00
github-coordination docs+chore: add README Security section; fix lint regressions on main 2026-06-16 02:08:14 -04:00
install feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
install-targets feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
mcp-inventory feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
plan-canvas fix(plan-canvas): deliver browser chat to the agent every time (#2739) 2026-08-09 18:15:25 -04:00
session-adapters feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
skill-evolution
skill-improvement fix: port safe ci cleanup from backlog 2026-04-01 16:09:54 -07:00
state-store feat: add work items CLI 2026-05-11 12:24:12 -04:00
worktree-lifecycle feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
agent-compress.js fix: use scalar Claude agent tools (#2583) 2026-07-26 03:20:15 -07:00
agent-data-home.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
agent-tools.js fix: use scalar Claude agent tools (#2583) 2026-07-26 03:20:15 -07:00
atomic-write.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
claude-plugin-setup.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
claude-scope-migration.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
codex-plugin-setup.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
compute-sponsor.js feat: connect ECC to canonical Ito compute CLI (#2558) 2026-07-23 19:28:55 -07:00
cost-estimate.js feat: add ECC statusline observability hooks 2026-05-11 23:44:06 -04:00
cursor-agent-names.js fix: namespace cursor agent installs 2026-04-30 02:19:57 -04:00
ecc_dashboard_runtime.py fix: port hook session and dashboard safety fixes 2026-05-11 02:53:28 -04:00
feedback-links.js feat: add retention feedback loop and honest support matrix (#2681) 2026-08-04 21:42:25 -04:00
github-coordination.js refactor: apply code-review findings to github-native coordination 2026-06-11 14:05:42 -04:00
github-discussions.js fix: skip disabled discussion queries in platform audit 2026-05-17 20:32:09 -04:00
github-origin.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
harness-adapter-compliance.js feat: add zed install target 2026-05-17 07:06:49 -04:00
harness-capabilities.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
hook-flags.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
inspection.js
install-executor.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
install-lifecycle.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
install-manifests.js fix(repair): build opencode payload so `repair` clears doctor's `opencode-plugin-not-built` warning (#2414) (#2438) 2026-07-08 17:14:33 -04:00
install-state.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
instinct-relevance.js feat(session-start): rank injected instincts by project/stack relevance (#2466) 2026-08-10 21:46:24 -04:00
ito-environment.js fix(ito-compute): complete device auth lifecycle (#2706) 2026-08-07 14:53:13 -04:00
llm-summary.js feat(session): LLM-powered session summary via claude -p (#2388) 2026-06-29 15:55:01 -07:00
loopback-guard.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
mcp-config.js feat: support disabling bundled mcp servers 2026-04-05 14:37:28 -07:00
memory-vault-format.js feat: add cross-harness memory vault (#2581) 2026-07-26 02:46:59 -07:00
memory-vault.js fix(memory-vault): compare dev only when both stats report one (#2637) 2026-08-08 17:06:18 -04:00
multi-harness-setup.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
observer-sessions.js fix: port continuous-learning observer fixes 2026-05-11 03:35:42 -04:00
orchestration-session.js
package-manager.d.ts
package-manager.js fix(scripts): detect modern bun.lock, ignore stray root lockfiles 2026-07-19 19:39:23 +02:00
path-safety.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
project-detect.js fix(project-detect): parse Python deps pinned with `~` and `@` (was losing framework detection on compatible-release pins) (#2498) 2026-07-17 17:11:09 -04:00
resolve-ecc-root.js fix(resolve-ecc-root): require ECC skills, not just scripts, before accepting a root (#2544) (#2577) 2026-07-25 22:21:27 -07:00
resolve-formatter.js fix(tests): resolve 10 failing tests on Windows (#2307) 2026-06-29 15:54:49 -07:00
session-aliases.d.ts feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
session-aliases.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
session-bridge.js fix(lib): retry rename on Windows EPERM/EACCES/EBUSY in writeBridgeAtomic 2026-05-19 04:57:10 -04:00
session-manager.d.ts fix: fold session manager blockers into one candidate 2026-03-24 23:08:27 -04:00
session-manager.js fix: resolve open-issue cluster (#2295, #2298, #2303–#2306, #2340) + createdTime fallback bug (#2408) 2026-07-03 21:10:45 -07:00
shell-split.js
shell-substitution.js fix(hooks,lib): fix hook detection and parsing edge cases (#2405) 2026-07-28 21:32:42 -04:00
terminal-spinner.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
terminal-welcome.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
tmux-worktree-orchestrator.js
transcript-context.js fix: add claude-opus-5 to KNOWN_MODEL_WINDOW_TOKENS (#2609) 2026-08-04 00:27:33 -04:00
utils.d.ts feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
utils.js fix(hooks,lib): fix hook detection and parsing edge cases (#2405) 2026-07-28 21:32:42 -04:00