reflex-skills 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,7 +35,7 @@ alias reflex="node $PWD/apps/cli/dist/reflex.js"
35
35
  | Command | What it does |
36
36
  | --- | --- |
37
37
  | `doctor` | Node and SQLite check, detected history locations and file counts, install targets, agent CLIs |
38
- | `scan --days <n>` | Ask per source, then read and store redacted workflow traces. `--source <claude-code\|codex\|cursor>` (repeatable), `--claude-dir`, `--codex-dir`, `--cursor-dir`, `--yes`, `--full` (re-read every file instead of reusing unchanged ones) |
38
+ | `scan --days <n>` | Ask per source, then read and store redacted workflow traces. `--source <claude-code\|codex\|cursor>` (repeatable), `--claude-dir`, `--codex-dir`, `--cursor-dir`, `--yes`, `--full` (re-read every file instead of reusing unchanged ones), `--embed-minutes <n>` (most time spent comparing new sessions by meaning; default 5, the rest continue next scan) |
39
39
  | `sessions` | Sessions from the last scan, redacted |
40
40
  | `suggest` | Detect repeated workflows and review them interactively (`--no-interactive`, `--all`) |
41
41
  | `show <n\|name>` | A suggestion in detail: steps, support, uncertainty |
@@ -53,9 +53,11 @@ alias reflex="node $PWD/apps/cli/dist/reflex.js"
53
53
  | `run <request>` | Start Claude Code or Codex on the model the router picks for this kind of task. `--dry-run` shows the pick and why, `--tool`, `--model`, `--yes`. Asks first unless autopilot is on |
54
54
  | `route` | The router: picks per kind of task, settings, randomized trials and bench results. `autopilot on\|off`, `explore <percent>\|off [--protect <kind...>]` |
55
55
  | `bench <task>` | Run one task on several Claude Code models, each in a fresh copy of the current repository, scored by `--check "<command>"`. `--models`, `--setup`, `--runs`, `--timeout`, `--keep`, `--yes` |
56
+ | `improve [skill]` | For skills you already have: lists them with the sessions that loaded each; with a name, compares the skill with those sessions and proposes an edit (asks before reading the skill and before changing it; keeps a backup). `--file`, `--yes` |
57
+ | `agents` | Sessions that launched agents (Cursor): how many, which kinds, and how many tool calls the agents made |
56
58
  | `stats` | Counts from local data |
57
59
  | `reset` | Delete Reflex's own data (not installed skills or the model) |
58
- | `model [status\|fetch\|remove]` | Optional local embedding model for matching requests by meaning (`fetch` downloads 23 MB) |
60
+ | `model [status\|fetch\|use\|remove]` | Optional local embedding model for matching requests by meaning. `fetch` downloads bge-m3 (multilingual, 587 MB); `fetch --light` the English-only all-MiniLM-L6-v2 (23 MB); `use <name>` switches between installed ones |
59
61
 
60
62
  Prompts default to No. Without a terminal, nothing is read or written unless you pass `--yes`.
61
63
 
@@ -90,8 +92,12 @@ as inspect CI, install dependencies, patch, run tests, inspect the diff), normal
90
92
  file categories and outcome. Copies, resumed sessions and quick retries count once. Traces are
91
93
  compared on intent (0.40), action sequence (0.30), commands and tools (0.15), file categories
92
94
  (0.10) and repository (0.05), then clustered. Intent compares the requests' words (stemmed terms,
93
- phrases and a small concept lexicon); with the optional model (`reflex model fetch`) it also compares
94
- their meaning, so "make the login page load faster" and "the sign-in screen is really slow" match. A cluster becomes a suggestion only if it has at
95
+ phrases and a small concept lexicon) in any language: Japanese, Chinese and Thai are split into
96
+ words, Korean particles are stripped (배포를 → 배포), filler words are dropped (published lists plus
97
+ everyday fillers, `casual-stopwords.ts`) and words your own history uses across unrelated kinds of
98
+ work are quieted, more so as the history grows; with the optional model (`reflex model fetch`) it also compares
99
+ their meaning, so "make the login page load faster", "the sign-in screen is really slow" and
100
+ "로그인 화면이 너무 느려" match. A cluster becomes a suggestion only if it has at
95
101
  least 3 independent sessions with consistent behavior; one-offs, read-and-answer sessions and
96
102
  generic "read, edit, test" patterns are not suggested.
97
103
 
@@ -101,6 +107,72 @@ follow-up messages ("don't change the CI workflow") become constraints when the
101
107
  appears in at least 2 sessions; only the words those sessions share are kept. No transcript excerpts.
102
108
  Details: [docs/architecture.md](docs/architecture.md).
103
109
 
110
+ ## Matching by meaning: which model
111
+
112
+ Matching by words always runs. A local embedding model adds matching by meaning; it is optional and
113
+ runs on your machine (WebAssembly, no native code, no network after the download).
114
+
115
+ | | `reflex model fetch` (default) | `reflex model fetch --light` |
116
+ | --- | --- | --- |
117
+ | Model | bge-m3, int8 | all-MiniLM-L6-v2, int8 |
118
+ | Reads | 100+ languages, and requests that mix them | English (Latin script); other text is matched by words only |
119
+ | Download | 587 MB | 23 MB |
120
+ | Memory while embedding | about 2.8 GB | about 0.6 GB |
121
+ | Time per session, 1 / 4 threads | about 2.9 s / 0.8 s | about 0.09 s / 0.03 s |
122
+
123
+ Measured on Apple silicon with real-length requests; older CPUs can be up to about 3x slower. The
124
+ `Embedding benchmark` workflow (`.github/workflows/embedding-bench.yml`; on pull requests that change embedding or matching code, by hand, and weekly)
125
+ measures load time, time per request and peak memory for both models on Linux (x64 and ARM),
126
+ Windows and macOS (Intel and Apple silicon), and checks matching quality is the same everywhere;
127
+ locally: `REFLEX_PERF=bge-m3 REFLEX_TEST_MODELS=~/.reflex/models pnpm vitest run packages/analysis/test/eval/perf.test.ts`. On
128
+ English requests MiniLM matches at least as well as bge-m3, so English-only users lose nothing with
129
+ `--light`. Embedding uses up to 4 cores (`REFLEX_EMBED_THREADS` to change). Before downloading,
130
+ `model fetch` estimates the first scan's time from your stored sessions and recommends `--light`
131
+ on machines with under 8 GB of memory or fewer than 4 cores. Each scan spends at most
132
+ `--embed-minutes` (default 5) embedding, newest sessions first, and the next scan continues; a
133
+ machine without memory for the model skips it with a warning. Vectors are cached per model, so
134
+ `reflex model use <name>` switches without re-embedding what either model already did.
135
+
136
+ ## Skills you already have
137
+
138
+ If most sessions of a repeated workflow already loaded skills you wrote, Reflex does not suggest a
139
+ new skill for it; `reflex scan` says which of your skills handle it instead. Only skills specific to
140
+ that workflow count (loaded at least twice as often there as in your other sessions), so general
141
+ guidance you load everywhere never hides a suggestion. Skill folders that are symlinks into a
142
+ skills repo are followed: Reflex reads and edits the real `SKILL.md`, so changes show up in that
143
+ repo's `git status`. `--dry-run` shows the review, the proposal and the check without writing.
144
+
145
+ `reflex improve <skill>` compares one of your skills with the sessions that loaded it (at least 2).
146
+ The rule is that a skill keeps producing the same thing; improving it means getting there faster
147
+ or cheaper.
148
+
149
+ - **What it never touches.** Your text is never edited: Reflex only appends a marked "Learned from
150
+ your sessions" section (replaced on the next run, never duplicated). Sections whose heading names
151
+ the output (`Output format`, `Response`, `Template`, `Report`, …) and anything between
152
+ `<!-- reflex:fixed:start -->` and `<!-- reflex:fixed:end -->` are treated as the output contract:
153
+ the appended section says to keep them exactly, and nothing proposed may write a summary or
154
+ correct the format.
155
+ - **Proposed by default: faster.** Commands that worked in those sessions for steps your skill
156
+ already names, so the agent doesn't work them out again.
157
+ - **Shown, not written: cheaper.** If a cheaper model was about as reliable on those sessions,
158
+ `reflex improve` says so; `reflex run` uses it. The skill file isn't changed for that.
159
+ - **Opt-in with `--behavior`: changes what the agent does.** Steps most sessions took that the
160
+ skill doesn't mention, and corrections you repeated. Steps the skill names that rarely happened
161
+ are reported; Reflex never removes a step.
162
+ - **Checked before it's applied.** `--verify "<a task this skill handles>"` runs that task with the
163
+ current and the proposed skill, each in a fresh copy of the current repository (non-persistent
164
+ Claude Code sessions on your account), and compares the shape of the two answers: headings,
165
+ tables, lists, labels, JSON keys. Values such as times and names may differ; the format may not.
166
+ If it changed, the edit is not applied (`--force` overrides). Answers are compared in memory and
167
+ never saved.
168
+ - **Recorded.** Every proposal is attached to the skill in Reflex's database: fingerprints before
169
+ and after, what was proposed, the check result, whether you applied it and where the backup is.
170
+ `reflex improve <skill> --history` lists them. Your file changes only if you confirm; the previous
171
+ version goes to `~/.reflex/backups`.
172
+
173
+ A session counts as using a skill when the agent called it (Claude Code's `Skill` tool) or read
174
+ its `SKILL.md`.
175
+
104
176
  ## Measuring a skill
105
177
 
106
178
  Each suggestion shows what the workflow costs today: median tokens and tool calls per run. When you
@@ -156,8 +228,9 @@ Cursor isn't routed: it records no tokens to compare, and its editor takes no mo
156
228
 
157
229
  - Transcripts are read locally and treated as data, never as instructions.
158
230
  - Reflex makes no network connections; outgoing sockets are blocked in-process. The one exception is
159
- `reflex model fetch`, which you run explicitly to download the optional embedding model (pinned
160
- files, verified by SHA-256). It reads no transcripts and uploads nothing; scans stay offline.
231
+ `reflex model fetch`, which you run explicitly to download an optional embedding model (pinned
232
+ files, streamed to disk and verified by SHA-256). It reads no transcripts and uploads nothing;
233
+ scans stay offline.
161
234
  - Secrets, emails, home paths and your user name are redacted before anything is stored or shown.
162
235
  - Scans are incremental: a transcript that has not changed since the last scan is not opened again.
163
236
  Redacted traces are kept after their transcript is deleted (by you, or by the agent's own cleanup),
@@ -176,8 +249,21 @@ Threat model and mitigations: [docs/security.md](docs/security.md).
176
249
  | Codex | `$CODEX_HOME/sessions/YYYY/MM/DD/rollout-*.jsonl` | `~/.codex/skills/<name>/SKILL.md` | Parser follows the Codex protocol types and is tested on fixtures; not yet run against real rollouts or a live Codex session |
177
250
  | Cursor | `~/.cursor/projects/*/agent-transcripts/*/*.jsonl` | `~/.cursor/skills/<name>/SKILL.md` | Parser tested on fixtures and on real agent transcripts. Cursor doesn't record tool results, so pass/fail outcomes aren't available for its sessions |
178
251
 
179
- Override locations with `REFLEX_CLAUDE_DIR`, `REFLEX_CODEX_DIR`, `REFLEX_CURSOR_DIR`,
180
- `REFLEX_CLAUDE_SKILLS_DIR`, `REFLEX_CODEX_SKILLS_DIR`, `REFLEX_CURSOR_SKILLS_DIR` and `REFLEX_HOME`. `REFLEX_DEBUG=1` prints local counters (counts only).
252
+ **Agents a session launched.** When a Cursor chat launches agents (its `Task` / `Subagent` tool),
253
+ Reflex records each one (kind, model, background or not, its short description) and reads the
254
+ agents' transcripts (`<chat>/subagents/*.jsonl`). Their commands, files and tool calls count toward
255
+ the chat's workflow; the message each agent was given is written by the parent agent, so it is
256
+ never treated as your request. `reflex agents` lists the chats that launched the most, and
257
+ `reflex sessions` notes the count. Claude Code's agents are not read yet.
258
+
259
+ **Conductor.** Conductor runs its own Claude Code and Codex, which save sessions to `~/.claude` and
260
+ `~/.codex` like any other session, so Reflex reads them with those sources. A session whose folder is
261
+ a Conductor workspace (`~/conductor/workspaces/<repo>/<workspace>`) counts toward `<repo>`, not
262
+ toward each workspace, and `reflex sessions` marks it "via Conductor". `reflex doctor` shows whether
263
+ the workspace folder exists. Cursor and OpenCode sessions run through Conductor are not read yet.
264
+
265
+ Override locations with `REFLEX_CLAUDE_DIR`, `REFLEX_CODEX_DIR`, `REFLEX_CURSOR_DIR`, `REFLEX_CONDUCTOR_DIR`,
266
+ `REFLEX_CLAUDE_SKILLS_DIR`, `REFLEX_CODEX_SKILLS_DIR`, `REFLEX_CURSOR_SKILLS_DIR` and `REFLEX_HOME`. `REFLEX_EMBED_THREADS` sets the embedding threads. `REFLEX_DEBUG=1` prints local counters (counts only).
181
267
 
182
268
  ## Walkthrough
183
269
 
@@ -201,11 +287,13 @@ by the tests; it is not part of the published CLI.
201
287
  ## Limitations
202
288
 
203
289
  - Confidence is a ranking heuristic, not a probability.
204
- - Without the model, intent matching uses stemmed TF-IDF plus a small built-in lexicon. Requests worded
205
- with no words in common need `reflex model fetch` to match.
206
- - The embedding model (all-MiniLM-L6-v2) is English-only and does not know developer jargon as well as
207
- the lexicon ("GitHub Actions is red" vs. "CI is failing"), so it is combined with word matching,
208
- never used alone. Clusters found only by meaning may get a generic name.
290
+ - Without the model, intent matching uses stemmed TF-IDF plus a small built-in lexicon (English).
291
+ Requests worded with no words in common, or asked in different languages, need
292
+ `reflex model fetch` to match.
293
+ - Embedding models do not know developer jargon as well as the lexicon ("GitHub Actions is red" vs.
294
+ "CI is failing"), so they are combined with word matching, never used alone. With the light
295
+ model, requests in other scripts (Korean, Japanese, ...) are matched by words only. Clusters
296
+ found only by meaning may get a generic name.
209
297
  - Each source reads at most its 2,000 most recent files per scan.
210
298
  - Sponsor integrations (Alike, Darwin) are not included: no public API documentation was available
211
299
  to build against, and the product works without them.