Skip to content
This repository was archived by the owner on Jul 15, 2026. It is now read-only.

feat(x-trace): automate session_start/end via hook instead of LLM - #1

Merged
JINWOO-J merged 25 commits into
mainfrom
develop
Apr 10, 2026
Merged

feat(x-trace): automate session_start/end via hook instead of LLM#1
JINWOO-J merged 25 commits into
mainfrom
develop

Conversation

@JINWOO-J

Copy link
Copy Markdown
Member

session_start/end were SKILL.md instructions that LLM could skip
(especially after compaction), causing "no such file" errors when
session_end ran without prior session_start.

Now a PreToolUse/PostToolUse hook handles both automatically for all
x-kit skills, with mkdir -p guaranteeing the traces directory exists.
Semantic entries (agent_step) remain LLM best-effort via SKILL.md.

JINWOO-J added 25 commits April 10, 2026 21:08
session_start/end were SKILL.md instructions that LLM could skip
(especially after compaction), causing "no such file" errors when
session_end ran without prior session_start.

Now a PreToolUse/PostToolUse hook handles both automatically for all
x-kit skills, with mkdir -p guaranteeing the traces directory exists.
Semantic entries (agent_step) remain LLM best-effort via SKILL.md.
x-kit init copies hooks and merges settings.json from marketplace.
x-kit update now reminds users to run init for hook updates.
- x-build: Cost Engine v2 — adaptive model routing with outcome feedback loop
  - cost-engine.mjs extracted from core.mjs (modular architecture)
  - cost-learner.mjs for adaptive learning (90-day window, success-rate scoring)
  - model_learned config key with 4-level priority chain
  - budget: rolling window, cached spend, per-project limits
  - forecast: token-actuals.json for data-driven estimates
  - escalation cascade with quality threshold gates
  - appendMetric spinlock for concurrent write safety
  - routing correlation IDs (ce-XXXXXXXX)
  - MODEL_COSTS updated for Claude 4.x pricing
- x-kit: marketplace sync (cost-engine, cost-learner, core, tasks)
…ckBudget, static import

- Extract root.mjs with ROOT resolution logic (eliminates duplication)
- Extract config-loader.mjs with loadSharedConfig (eliminates duplication)
- Rewire cost-engine.mjs to use shared root + config modules
- Split checkBudget (130 LOC) into scanMetrics + evaluateBudget + mergeProjectBudget
- Replace dynamic import of cost-learner.mjs with static import
- refreshModelLearned converted from async to sync
- 542 tests pass, zero regressions
- x-build: internal refactoring — extract root.mjs + config-loader.mjs, split checkBudget, static import for cost-learner, evaluateEscalation unknown model guard, mergeProjectBudget dedup
- Gantt Timeline: SVG-based model swim lanes with parallel execution view
- Cost Waterfall: Chart.js stepped line showing cumulative cost over time
- Model Distribution: doughnut chart with calls/cost/duration per model
- Chart.js CDN added, dark theme matched to BRUTALIST EDITION
- Empty data graceful handling ("No agent data for charts")
@JINWOO-J
JINWOO-J merged commit 00e5e17 into main Apr 10, 2026
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant