feat(context): auto user-preference modeling — match the project's code style#22
Merged
Merged
Conversation
…de style The agent now learns the user's code style WITHOUT an explicit `remember`: it infers the project's conventions deterministically from its own source (plus .editorconfig when present) and injects a compact "Code style" block into the system prompt, so generated code blends in. - src/context/style-profile.ts (pure inference + thin scan): inferIndent (tab vs space + width, from the most common indent step), inferQuotes, inferSemicolons, inferNaming (camelCase vs snake_case); profileFromSamples (majority vote + confidence); scanProjectStyle samples up to 25 source files (skipping node_modules/dist/…) and lets a root .editorconfig override the indent. - Loop: computed ONCE per session (cached), injected at run start. On by default; off via context.styleProfile:false; skipped in plan mode. This is the "User Preference Modeling" gap (Phase 3) — the only genuinely-new item from the latest review; the others (auto-eval, stats, failure-learning, confidence) already shipped earlier this session. Live-verified on this repo: inferred 2-space / single-quote / semicolons / camelCase at confidence 1.0 across 25 files — exactly QodeX's house style. Tests: 10 (each inference dimension incl. tabs + 4-space + double + snake_case, the majority-vote profile + confidence scaling, and the block builder's floor). typecheck + full suite (1183) + build green.
QodeXcli
added a commit
that referenced
this pull request
Jun 25, 2026
… before (#23) Companion to user-preference modeling (#22). Instead of rediscovering a recurring job, QodeX records a lean episode after each objectively-successful task and, at the start of a new one, recalls the most SIMILAR past task on this project and injects a one-line reminder of what worked. Off by default (learning.episodicMemory.enabled). Clean + lightweight, same discipline as #22: - src/context/episodic-memory.ts (pure rank + thin I/O): records to ~/.qodex/episodes/<project>.jsonl; rankEpisodes scores a query against past episodes by lexical TF-cosine (reuses the tested similarity primitives — no embedding dependency), excludes near-identical re-runs (score ≥ 0.98), returns top-K above a similarity threshold; buildEpisodeBlock renders a concise block. - SMART, not always-on: an unrelated task injects nothing (below threshold), and only a one-line summary is injected, never full transcripts. - Loop hooks: record at the objective-success point (alongside capture/dataset); inject the recalled block into the system prompt at run start. - The lexical ranker is a pure function, so an embedding-backed variant can be swapped in later without touching call sites. Also: completed the README Self-learning section with the episodic-memory step, its config, and a worked end-to-end example. Live-verified: recorded two episodes, a pagination-shaped query recalled the pagination episode (with files), an unrelated k8s query recalled nothing. Tests: 6 (similar-retrieval, unrelated→empty, self-match excluded, topK/sort, empty guards). typecheck + full suite (1189) + build green. Co-authored-by: Louise Lau <QodeXcli@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The agent now learns your code style automatically — no explicit
rememberneeded. It infers the project's conventions deterministically from its own source (+.editorconfigwhen present) and injects a compact "Code style" block into the system prompt, so generated code blends in.How
src/context/style-profile.ts(pure inference + thin scan):inferIndent(tab vs space + width, from the most common indent step between lines),inferQuotes,inferSemicolons,inferNaming(camelCase vs snake_case).profileFromSamples— majority vote across files + a confidence from sample size.scanProjectStylesamples up to 25 source files (skipsnode_modules/dist/…); a root.editorconfigoverrides the inferred indent (authoritative).context.styleProfile: false, skipped in plan mode.This is the one genuinely-new item
From the latest review, this is the only gap that didn't already exist. The others — auto-eval after capture,
skill stats, failure-driven learning, confidence scoring — all shipped earlier this session and are onmain.Live-verified
Ran it on this repo: inferred 2-space / single-quote / semicolons / camelCase at confidence 1.0 across 25 files — exactly QodeX's house style.
Tests
10 — each inference dimension (incl. tabs, 4-space, double quotes, snake_case), the majority-vote profile + confidence scaling, and the block builder's confidence floor. ✅ typecheck · ✅ full suite (1183) · ✅ build.