π v1.0.162 β multilingual prompt analytics, accurate cost, 13 new extractors
13 commits Β· 8 PRD issues Β· 2 verify-gap fixes Β· 13 new test files Β· 80+ tracers since v1.0.161. Cross-repo PRD-driven sprint β wire-format expansion, privacy-first multilingual analytics, and a pricing accuracy catch-up that had been stale since v1.0.103. π
β¨ Highlights
- π Β§11 multilingual prompt features β Layer 1 expanded from 5 β 10 typed columns plus a new
prompt_word_tokens[]Layer 3 array, fully script-agnostic via Unicode property escapes (\p{L},\p{Script=X}). Latin, Cyrillic, Han, Hangul, Arabic, Hebrew, Thai, Greek, Devanagari, Hiragana, Katakana β one code path, nofranc/fasttext/compromisedependency. Bundle unchanged. - π° Honest cost accounting β
MODEL_PRICING_USD_PER_MTOKlands with verified 2026-06 Anthropic rates (Opus 4.7/4.8 $5/$25, Sonnet 4.6 $3/$15, Haiku 4.5 $1/$5).extractAgentUsagederivescost_usdfrom per-model rates Γ usage block.ctx-statsheadline corrected from$1399.73 of Opus 4 tokensto$466.58 of Opus 4.7 tokensβ same fixture, accurate rate (Opus 4 β Opus 4.7 was a 3Γ price cut that never propagated toanalytics.ts). - πͺ 9 new event types from existing tool calls β
bash_outcome,file_read_metadata,webfetch_metadata,worktree_exit,agent_usage,session_settings_snapshot,git_commit(discriminated from genericgit),plan_enter(slash variant), and enrichedplan_exitwithplan_bytes/plan_hash. All ride the existing{...ev}envelope per ABI Β§5.4 β zero platform-side schema migrations. - π©Ή commit_message capture finally works β symmetric rollup stamp + per-event gate on
type='git_commit'. POSIX argv tokenizer handles-m,-am,--message=,--message ARG, env-prefixed (GIT_AUTHOR=... git commit -m ...),--amendfallback, empty-m "". Closes the ~92% NULL-on-has_commit=1ingestion drift surfaced by prod D1 telemetry. - π§ Cross-project attribution β
git -C /other/path commit -m "x"fromcwd=projectAnow attributes to project B's canonical identity. Tilde (~/path) and equals-form (--directory=/path) both parsed correctly across macOS / Linux / Windows. - π
/planslash fallback β Claude Code Bug #15660 workaround. The slash command emitsplan_entervia UserPromptSubmit; ~60-80% of plan-mode entries that were previously telemetry-invisible (slash + Shift+Tab don't fire PostToolUse) are now captured. Shift+Tab remains upstream-blocked. - π‘οΈ Zero new runtime dependencies β 13 extractors, 22 multilingual feature paths, and a per-model pricing table added. Bundle stays at
58 KB totalacross all 5 hook bundles. Algorithmic POSIX argv parsing, FNV-1a hashing, Unicode regex via stdlib only.
π Bug Fixes
Commit message capture (Bug 1 + Bug 2)
- POSIX argv tokenizer for commit messages β
extractGitparses-m,-am,--message=, separate-token--message, env-prefixed invocations,--amendfallback, and empty-m "". Emitstype='git_commit'(distinct from genericgit) when a message is captured. Symmetric rollup stamp viagetSessionRollupso every event in a commit-bearing session carriescommit_message, closing the asymmetric-NULL drift seen on platform D1. - Cross-project attribution (Bug 8) β
git -C <dir>scope hint now flows throughparseGitInvocationand shadows the in-batchinputProjectDir. Subsequent events in the same Bash call attribute to the scoped directory, not the hook's startupcwd.
Cost derivation (verify-gap Gap #1)
cost_usdonagent_usageβ derives fromtokens Γ per-MTok rateusing the newMODEL_PRICINGtable. Model resolution:tool_input.modelβinput.modelβresponse.modelβdefault(Sonnet rates). Prefix match for date-suffixed ids (claude-haiku-4-5-20251001βclaude-haiku-4-5). Zero-token sessions skipcost_usdso dashboards don't render$0.00 for nothing. Unknown model id falls back to default β never null.
Git parsing (verify-gap Gap #2)
- Tilde expansion β
git -C ~/repos/myrepo statusnow expands to$HOME/repos/myrepo(orUSERPROFILEon Windows, withHOMEDRIVE+HOMEPATHfallback).~user/path(other-user form) intentionally NOT expanded β bridge does not do passwd lookups. --directory=valueequals-form β parsed alongside the existing space-form--directory <value>. Tokenizer kept the equals-attached argument as one token; parser now slices on the--directory=prefix.
Prompt analytics (Issue #5 + Issue #8 Β§11)
- Multilingual Layer 1 alignment β replaced the F1 Β§2 5-field stub with Β§11's 10-field shape:
prompt_length,prompt_word_count,prompt_uppercase_ratio,prompt_file_ref_count,prompt_path_ref_count,prompt_script_primary,prompt_script_count,prompt_question_glyph_count(counts ASCII?, fullwidthοΌ, ArabicΨ),prompt_code_block_count,prompt_url_count. Theprompt_first_wordfield from the stub was removed βprompt_word_countcovers the same insight script-agnostically. - Layer 3 word tokens β
prompt_word_tokens: string[]carries letter-only words β₯3 chars, lowercased, deduplicated within the prompt. Platform UPSERTs intoprompt_word_count(org_id, week, word, count)for emergent vocabulary surfacing at 5%-50% rate thresholds. Aggregated per org+week; no individual prompt token surfaces in any UI.
CI / cross-platform
- Windows statusline timeout parity β slice-2 multi-adapter test now reuses
STATUSLINE_SQLITE_TIMEOUT_MS(300s Windows / 30s elsewhere) instead of a stale hardcoded 60s. CI #401 had observed 186s with retry x2 onwindows-latestβ flake fixed. - 2 stale pricing-test assertions β
format-cost.test.ts($1399.73 β $466.58 of Opus 4.7 tokens) andformat-report-real-bytes.test.ts(regex updated). Both surfaced by the pricing-constant sync.
π¨ Features
- 9 new event types for prompt analytics, cost accounting, and tool-response metadata β all ride the existing universal envelope (
{...ev, platform, ts}per ABI Β§5.4). Platform Zod schema is forward-compatible; no wire-side migration required. extractAgentUsageβ fires ontool_name === "Task"(sub-agent dispatcher). CapturestotalTokens,totalDurationMs,tokens_in,tokens_out,cache_create,cache_read,tier, plus derivedcost_usd.extractBashOutcomeβ three real signals fromBashOutput:interrupted(bool),returnCodeInterpretation(semantic non-zero hint),stderrlength-only (privacy). Noexit_codefield exists in the SDK; the verify-gap PRD's anti-hallucination block specifically flagged this.extractFileReadMetadataβ branches on text vs image variant. Text:numLines/totalLines/startLine. Image:originalSize/dimensions(formatted asWxH).extractWebFetchMetadataβcode/bytes/durMs/host. URL host extracted algorithmically (no regex), query string stripped before stamping. Noredirect_urlfield exists; temporal correlation handles redirect-loop detection at the platform.extractWorktreeextended forExitWorktreeβ emitsworktree_exitwithdiscard_changesflag, alongside the existingEnterWorktreehandler.extractPlanExitPlanMode metadata βplan_bytes(length) +plan_hash(8-char FNV-1a hex) on the existingplan_exitevent. Plan source:tool_input.planfirst, fall back totool_response.plan(SDK actually carries it on the OUTPUT per ExitPlanModeOutput @ sdk-tools.d.ts:2222).extractSessionSettingsβ emitssession_settings_snapshotfrom SessionStart withmcp_count,mcp_servers(first 8 names),model,permission_mode. Wired intoemitSessionStartLifecycleopportunistically β never blocks lifecycle on snapshot failure.extractUserPlanβ UserPromptSubmit-driven/planslash detector. Algorithmic char-code scan (no regex), word-boundary check so/plansdoes not match, argument truncated at 120 chars.
β‘ Performance
- Zero bundle bloat β
hooks/session-extract.bundle.mjsis13,694 bytes, total of all 5 hook bundles is58 KB. 13 new extractors + multilingual feature engine added with zero new runtime dependencies. esbuild minifies; nothing leaks. - Β§11 multilingual is O(n) per feature on the prompt string β
prompt.match(/\p{L}+/gu)and the 11-script loop bound the cost. Spec-mandated p95 β€ 15 ms on a 10 KB prompt. - FNV-1a 32-bit hash for
plan_hashβ deterministic, stable across platforms, no crypto library required.
π Docs / Ops
- Cross-PRD cross-repo workflow β this release closes 8 issues from 09-oss-handoff-prd.md and 2 gaps from 16-oss-verify-gap-prd.md. The verify-gap PRD is a separate-LLM verification pass on the OSS work β a novel cross-agent OSS workflow.
STYLE-ANCHOR-v1.0.152.mdadded to repo (developer-facing) β documents the v1.0.152 release-notes template so future releases stay community-grade. v1.0.153 through v1.0.161 will be rewritten to this style.- Anti-hallucination ground truth β every cited SDK line in the PRDs was re-verified against
refs/platforms/claude-code/sdk-tools.d.tsbefore implementation. The verify-gap PRD specifically flagged stale citations (BashOutput.exit_codedoes not exist;WebFetchOutput.redirect_urldoes not exist) β both correctly worked around in the new extractors.
π PRD-driven work
This release is the first end-to-end product of the OSS handoff + verify-gap cross-PRD pipeline:
| PRD | Repo | Issues / Gaps closed |
|---|---|---|
09-oss-handoff-prd.md v3
| context-mode-platform
| #1 release, #2 AgentOutput.usage, #3 FileReadOutput, #4 SessionStart settings, #5 Β§11 alignment, #6 ExitPlanMode, #7 ExitWorktree, #8 Layer 3 word_tokens |
16-oss-verify-gap-prd.md
| context-mode-platform
| Gap #1 (P1) cost_usd, Gap #2 (P2) tilde / --directory= git parsing
|
10-prompt-analytics-strategy.md
| context-mode-platform
| F1 Β§2 β Β§11 alignment (signal catalog reference) |
11-multilingual-prompt-algorithm.md
| context-mode-platform
| Verbatim mirror in src/session/extract.ts:extractUserPromptFeatures
|
PRD design, verification, and cross-repo authoring by @mksglu. Verify-gap PRD authored by a separate LLM-as-PO instance to ensure the OSS bridge didn't over-promise.
π« Intentionally out of scope
To keep the release scope honest:
- Shift+Tab plan-mode detection β Claude Code Bug #15660 needs an upstream SDK fix. Only
/planslash is captured. - OpenCode / Qwen / Kilo hook bridges β deferred to a future adapter-coverage release.
- Bash
exit_codeβ SDK does not expose it. The three real signals (interrupted,returnCodeInterpretation,stderr length) are captured instead. WebFetchredirect_url β does not exist on the SDK. Redirect-loop detection is temporal-correlation on the platform.- Top-level typed DB columns for
agent_usagetoken fields β stays inevent.datauntil platform observes and auto-migrates per ABI Β§5.4. Local SessionDB stays slim deliberately. - Fast-mode Opus / Sonnet pricing tiers β separate model ids not mapped; would dilute standard-tier dashboards.
ποΈ Closed issues / Gaps
#3 Β· #4 Β· #5 Β· #6 Β· #7 Β· #8 β v1.0.162 PRD. Gap #1 + Gap #2 β verify-gap PRD. Bug 1 + Bug 2 + Bug 8 β pre-release hotfixes folded into this release.
π¦ Install / upgrade
# Fresh install (Claude Code plugin marketplace)
/plugin add https://github.com/mksglu/context-mode
# npm global
npm install -g context-mode@1.0.162
# Existing install β in-place upgrade
context-mode upgradeThen restart your MCP session (or run /reload-plugins in Claude Code).
π Full changelog
π€ Powered by context-mode-ops parallel orchestration β 3 paralel research agent + grill-me discipline + cross-PRD doΔrulama + verify-gap LLM kontrolΓΌ. Codex EM bot'unu geΓ§tik mi acaba? π