flavor-code 1.3.12 → 1.3.15

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
@@ -1,425 +1,426 @@
1
- <p align="center"><b><a href="./README.md">English</a></b> | <a href="./README.zh-CN.md">简体中文</a></p>
2
-
3
- <div align="center">
4
- <img src="./assets/icon-transparent-512.png" alt="Flavor Code Logo" width="168" />
5
- <h1>Flavor Code</h1>
6
- <p><strong>Local-first, auditable, resumable AI coding assistant</strong></p>
7
- <p>Read code, edit files, run commands, and complete complex tasks in the terminal, Electron desktop, and VS Code.</p>
8
-
9
- <p>
10
- <a href="https://www.npmjs.com/package/flavor-code"><img alt="npm version" src="https://img.shields.io/npm/v/flavor-code?color=cb3837&logo=npm" /></a>
11
- <a href="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
12
- <img alt="Node.js 20+" src="https://img.shields.io/badge/Node.js-20%2B-339933?logo=nodedotjs&logoColor=white" />
13
- <a href="./LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
14
- </p>
15
-
16
- <p>
17
- <a href="#quick-start">Quick Start</a> ·
18
- <a href="#features">Features</a> ·
19
- <a href="#entry-points">Entry Points</a> ·
20
- <a href="#permissions--sandbox">Security</a> ·
21
- <a href="#development">Development</a> ·
22
- <a href="./CHANGELOG.md">Changelog</a>
23
- </p>
24
- </div>
25
-
26
- ---
27
-
28
- Flavor Code connects to OpenAI, Anthropic, or compatible services and works with file, search, Shell, MCP, and custom tools inside a controlled workspace. Complex tasks can be broken into plans and parallel sub-tasks; sessions, diffs, tool calls, checkpoints, and audit records are all stored locally so you can resume, review, and continue at any time.
29
-
30
- ## Features
31
-
32
- | | Capability | What you get |
33
- | --- | --- | --- |
34
- | 🖥️ | **One runtime, three entry points** | CLI, Electron, and VS Code share model configuration, sessions, and tooling |
35
- | 🧭 | **Controlled progress on complex tasks** | Task plans, sub-agents, steering, follow-ups, `/loop`, `/goal`, and conflict-safe parallel execution (tasks owning overlapping files run serially) |
36
- | 🏝️ | **Flavor Island local control** | Host apps steer a running session over a token-authenticated local IPC channel (Windows named pipes / Unix sockets): abort, steering, follow-ups, and window focus; model duration, token usage, task summaries, and deliverables are reported via hook events |
37
- | ⏪ | **Traceable, resumable results** | Full timeline, checkpoints, rewind, traces, diffs, and failure audits |
38
- | 🧱 | **Crash-consistent execution** | Fsync-backed event journal, durable steering queue, savepoints, and no automatic replay of non-idempotent tools |
39
- | 🧠 | **Local long-term context** | Memory, Skills, plugins, and project guides stored on your machine |
40
- | 🔎 | **Code graph navigation** | A local AST code-graph index (`.flavor/astgraph/`) powers `ast_search`/`ast_callers`/`ast_impact` queries for precise symbol lookup and reachability tracing |
41
- | 🌿 | **Git-native workflows** | `/commit` drafts a Conventional-Commits message for staged changes and commits after confirmation; `/review` audits uncommitted changes; the read-only `GitHistory` tool explains when and why code changed |
42
- | 🎨 | **E2E requirement-to-delivery** | From a rough requirement or a design export to a delivered product: PRD, interactive prototype, visual implementation, API integration, autonomous acceptance, and scored delivery (Electron only) |
43
- | 🔁 | **Bounded self-improvement** | Repeated tool failures are captured, deduped, and proposed as suggestions; fixes ship as sandbox-verified plugins or as learned guardrail rules injected into future prompts, with run trends and rule management (`/evolve`) |
44
- | 🛡️ | **Clear permission boundaries** | Independent control over read, write, Shell, network, and destructive actions; Docker supported |
45
-
46
- ## Quick Start
47
-
48
- > [!IMPORTANT]
49
- > The CLI requires Node.js 20 or later. Windows desktop builds can also be downloaded directly from [Releases](https://github.com/YachuanWzh/flavor-code/releases).
50
-
51
- **1. Install**
52
-
53
- ```bash
54
- npm install -g flavor-code
55
- ```
56
-
57
- **2. Start in your project**
58
-
59
- ```bash
60
- cd your-project
61
- flavor
62
- ```
63
-
64
- **3. Initialize project context**
65
-
66
- Run `/init` the first time you enter a project. Flavor analyzes the language, package manager, source directories, and verification commands, then generates a `FLAVOR.md` project guide.
67
-
68
- You can also run one-off tasks directly:
69
-
70
- ```bash
71
- flavor --print "Analyze this project and list the top three issues worth fixing"
72
- flavor --resume
73
- flavor --resume -p "Continue the remaining work"
74
- ```
75
-
76
- Non-interactive mode refuses actions that require human approval and never hangs waiting for input.
77
-
78
- ## Configuring Models
79
-
80
- The fastest way is to set environment variables:
81
-
82
- ```bash
83
- # macOS / Linux
84
- export OPENAI_API_KEY="sk-..."
85
-
86
- # Windows PowerShell
87
- $env:OPENAI_API_KEY = "sk-..."
88
- ```
89
-
90
- You can also put the key in a `.env` file at the project root.
91
-
92
- <details>
93
- <summary><strong>Configure multiple providers with <code>.flavor/flavor.json</code></strong></summary>
94
-
95
- Example project configuration:
96
-
97
- ```json
98
- {
99
- "providers": {
100
- "openai": {
101
- "type": "openai",
102
- "apiKey": "${OPENAI_API_KEY}",
103
- "defaultModel": "gpt-5",
104
- "cheapModel": "gpt-5-mini"
105
- }
106
- },
107
- "agents": {
108
- "main": { "model": "openai:gpt-5" },
109
- "subagent": { "model": "openai:gpt-5-mini" }
110
- },
111
- "permissionMode": "default",
112
- "maxSubagents": 3,
113
- "language": "zh-CN"
114
- }
115
- ```
116
-
117
- Configuration is merged in the following order, with later sources taking precedence:
118
-
119
- 1. Global `~/.flavor-code/flavor.json`
120
- 2. Project `.flavor/flavor.json`
121
- 3. `.env`
122
- 4. Process environment variables
123
-
124
- Commonly supported provider types:
125
-
126
- - `openai`: OpenAI's official API
127
- - `anthropic`: Anthropic's official API
128
- - `openai-compatible`: Services compatible with the OpenAI protocol
129
-
130
- </details>
131
-
132
- Runtime behavior and configuration conventions for OAuth PKCE are described in the [PKCE spec](./docs/specs/pkce-runtime-config.md). The [config schema](./src/config/schema.ts) is the source of truth for all fields.
133
-
134
- ## Entry Points
135
-
136
- | Entry point | Best for | How to start |
137
- | --- | --- | --- |
138
- | **CLI** | Daily development, remote environments, scripting, and CI | `flavor` |
139
- | **Electron** | Visual sessions, diffs, permissions, and resource management | `npm run desktop:start` |
140
- | **VS Code / Qoder** | Editor context, diagnostic fixes, and a task control plane | `npm run ide:install` |
141
-
142
- ### CLI
143
-
144
- Run `flavor` and type natural language. Typing `/` shows built-in commands, plugin commands, and Skills.
145
-
146
- Common commands:
147
-
148
- | Command | Purpose |
149
- | --- | --- |
150
- | `/init` | Generate or update `FLAVOR.md` |
151
- | `/model` | View or switch main/sub-agent models |
152
- | `/permissions` | Switch permission modes |
153
- | `/tasks` | View task plans and sub-agent status |
154
- | `/compact` | Manually compact long session context |
155
- | `/checkpoint`, `/tree` | Save state, view the session tree |
156
- | `/rewind`, `/unrevert`, `/fork` | Resume or fork sessions |
157
- | `/memory`, `/remember`, `/forget`, `/forget-cold` | Manage long-term memory; `/forget-cold` purges cold entries and their files |
158
- | `/mcp` | View and manage MCP servers |
159
- | `/loop <goal>` | Run an autonomous loop with verification |
160
- | `/goal <objective>` | Run the plan, execute, adversarial-review workflow |
161
- | `/commit [hint]` | Draft a Conventional-Commits message for staged changes and commit after confirmation |
162
- | `/review [focus]` | Review uncommitted changes for bugs and risks before committing |
163
- | `/evolve <signals\|suggest\|improve ...>` | Self-improvement loop: review repeated tool failures, scaffold fix plugins, manage run trends and learned guardrail rules, verify and hot-reload |
164
- | `/pals`, `/chat`, `/co-work` | Discover and collaborate with other local CLI instances |
165
- | `/audit` | View tool failure audits |
166
-
167
- You can submit steering or queue follow-ups while a run is in progress; once the current model response finishes, the task picks up new instructions at safe boundaries.
168
-
169
- `/commit` and `/review` use the cheap sub-agent model and degrade gracefully when it is unavailable. Session checkpoints are tagged with the current git state (`branch@sha`), so `/tree` shows what the workspace looked like at each node.
170
-
171
- #### CLI pals and cross-project work
172
-
173
- Interactive CLI instances on the same Windows or macOS user account can collaborate over local-only IPC (Windows named pipes or Unix sockets; no TCP fallback). Give each window a memorable alias:
174
-
175
- ```bash
176
- # terminal A, in project A
177
- flavor --pal-name A
178
-
179
- # terminal B, in project B
180
- flavor --pal-name B
181
- ```
182
-
183
- Useful commands:
184
-
185
- ```text
186
- /pals # aliases and per-process UUIDs
187
- /pals --verbose # also show project paths and timestamps
188
- /pals rename api # rename this active instance
189
- /chat B Update the API and tests # deliver to B and start its agent safely
190
- /co-work B Upgrade B, then adapt A # negotiate one plan before parallel work
191
- /co-work status [co-work-uuid]
192
- /co-work cancel <co-work-uuid> [reason]
193
- ```
194
-
195
- `/chat` is bidirectional and task-oriented. If B is idle, the attributed message starts a normal model turn; if B is already running, it becomes steering, or a follow-up when another local submission is pending. Remote text is converted to a safe non-slash prompt, so `/exit`-like text is not dispatched as a local command. B can answer with `/chat A ...`.
196
-
197
- `/co-work` first places both agents in planning and waits for both to accept the same hashed plan and declare READY. Early READY intents are retained, and only the broker's exactly-once START event opens parallel execution. Each agent works only in its own project, receives only its assigned tasks, and reports bounded completion evidence. The broker-selected integration owner verifies all assertions and emits END or FAIL through `CoWorkIntegrate`. Communication uses authenticated, bounded local IPC with no TCP listener; peer input cannot approve tools or access the other workspace. UUID/alias routing and the protocol already support a third active client; durable artifact exchange, broker-restart journaling/recovery, and large-group coordination are later hardening work. See the [CLI pals specification](./docs/specs/2026-08-14-cli-pals-cowork.md).
198
-
199
- ### Electron Desktop
200
-
201
- ```bash
202
- npm run desktop:dev # dev mode
203
- npm run desktop:start # build and start
204
- npm run desktop:pack # Windows portable directory
205
- npm run desktop:dist # Windows NSIS installer
206
- ```
207
-
208
- The desktop app keeps multiple projects open and can run up to four independent tasks concurrently inside one project; switching projects or tasks does not stop background work. Completion, failure, attention, and interruption events enter a persistent activity inbox and trigger native notifications, while unread completions retain a blue dot. Projects can be pinned, renamed, closed, revealed, or copied; tasks can be searched, renamed, pinned, and archived.
209
-
210
- Use `Ctrl+P` to switch projects, `Ctrl+K` for the command palette, and `Ctrl+N` for a new task; the title bar also supports back/forward navigation. Interrupted work gets a recovery banner after an abnormal exit. The **Git Changes** view provides per-file diffs, stage/unstage/discard, commits, and `/review` handoff. Streaming Markdown, permission confirmations, and Skills, MCP, memory, and model management remain available.
211
-
212
- The **E2E** module in the sidebar drives a rough requirement or an existing design export through the full delivery pipeline: it generates a PRD and an interactive prototype for review, then moves into D2C visual implementation (Vue 3 / React) under `src/d2c-output/<task>/`. A Vite dev server starts automatically for pixel-level comparison, producing a visual-fidelity score and a structured diff report (region offsets, color deviations, font differences); the results workbench offers overlay, curtain, flicker, and heatmap modes, an SVG annotation layer, and a severity-sorted issue list. After visual review, a Swagger/OpenAPI contract is generated or imported to auto-create Axios wrappers and an Express mock server, followed by autonomous interactive acceptance and scored delivery.
213
-
214
- ### VS Code / Qoder
215
-
216
- ```bash
217
- npm run vscode:install # install into VS Code
218
- npm run qoder:install # install into Qoder
219
- npm run ide:install # auto-select the installed IDE
220
- ```
221
-
222
- The extension includes the `@flavor` Chat Participant, Mission Control, Changes & Health, Time Machine, diagnostic fixes, CodeLens, checkpoints, and rewind. If `flavor` is not on your `PATH`, set `flavorCode.executable`.
223
-
224
- ## MCP, Skills & Plugins
225
-
226
- Flavor can connect to stdio or Streamable HTTP MCP servers. Example project configuration:
227
-
228
- <details>
229
- <summary><strong>MCP configuration and CLI examples</strong></summary>
230
-
231
- ```json
232
- {
233
- "mcpServers": {
234
- "docs": {
235
- "url": "https://example.com/mcp",
236
- "headers": {
237
- "Authorization": "Bearer ${MCP_TOKEN}"
238
- }
239
- }
240
- }
241
- }
242
- ```
243
-
244
- MCP configuration can also be managed from the CLI:
245
-
246
- ```bash
247
- flavor mcp list
248
- flavor mcp add docs --url https://example.com/mcp
249
- flavor mcp disable docs
250
- ```
251
-
252
- </details>
253
-
254
- A Skill is a `SKILL.md` with YAML frontmatter, placed in `.flavor/skills/<name>/` or `~/.flavor-code/skills/<name>/`. Flavor loads skills progressively based on the task, and you can invoke one explicitly with `/<skill-name>`. Skill bodies support `$ARGUMENTS`, `$ARGUMENTS[N]`, and `$N` substitutions. A running composite Skill can load a dependency through the read-only `Skill` tool; plugin-qualified names such as `superharness:test-driven-development` resolve to discovered skills.
255
-
256
- Plugins live in `.flavor/plugins/` and can register commands, tools, hooks, Skill roots, and model adapters. `additionalContext` returned by `SessionStart` and `UserPromptSubmit` hooks is added to the current task context, enabling reliable project-level engineering policy injection. Plugin loads record a content fingerprint plus declared capabilities. Worker/vm isolation is available through the embedding API's `pluginSandbox: true` option; the compatibility default remains in-process because bundled and existing plugins use Node.js APIs that the isolated runtime does not yet mediate.
257
-
258
- When the `flavor-island` plugin is loaded, Flavor also starts a Flavor Island local control channel: a loopback-only IPC service (Windows named pipe, or Unix socket on macOS/Linux) secured by a random token. A host app (such as the Flavor Island desktop) can use it to abort, steer, or send follow-ups to a running session, and desktop hosts can also bring their window into focus. The channel's endpoint, token, and capability list are exposed to the host plugin via hook event context (`islandControlEndpoint`/`islandControlToken`/`islandControlCapabilities`); model-call duration and token usage, plus the final task summary and deliverables, are reported through hook events so the host can show live status and a result overview.
259
-
260
- > [!WARNING]
261
- > The default in-process plugin runtime grants full Node.js access. Only install and enable plugins you trust. Sandboxing reduces ambient access but does not make untrusted instructions safe, and plugins that import Node.js built-ins will not load with `pluginSandbox: true` yet.
262
-
263
- ## Sessions, Memory & Execution Records
264
-
265
- Project runtime data lives under `.flavor/`:
266
-
267
- ```text
268
- .flavor/
269
- ├── flavor.json # Project config
270
- ├── sessions/ # Session timelines
271
- │ └── *.events.jsonl # Crash-consistent execution journals
272
- ├── session-assets/ # Image attachments
273
- ├── session-trees/ # Session branches
274
- ├── checkpoints/ # Workspace snapshots
275
- ├── memory/ # Long-term memory
276
- ├── traces/ # Optional execution traces
277
- ├── audit.jsonl # Tool failure audits
278
- ├── evolve/ # Self-improvement signals and run reflections
279
- ├── skills/ # Project skills
280
- └── plugins/ # Project plugins
281
- ```
282
-
283
- Long-term memory distinguishes user preferences, behavioral feedback, project conventions, and external references. Automatic extraction only keeps high-confidence candidates and provides confirm, ignore, and delete actions; secrets, tokens, raw tool output, and model guesses are rejected.
284
-
285
- Image prompts support PNG, JPEG, and WebP, with a 5 MiB per-image maximum and up to 5 images per prompt. The desktop app supports picking or drag-and-drop; CLI clipboard images currently work on Windows and macOS.
286
-
287
- ## Permissions & Sandbox
288
-
289
- | Mode | Behavior |
290
- | --- | --- |
291
- | `default` | Reads are auto-approved; writes, Shell, network, and destructive actions are confirmed on demand |
292
- | `acceptEdits` | Workspace writes and routine verification are auto-approved |
293
- | `plan` | Read-only planning; no modifications or execution |
294
- | `bypassPermissions` | The main agent executes as much as possible after hard safety checks |
295
- | `auto` | A classifier decides, falling back to human approval when uncertain |
296
- | `bubble` | Uncertain operations bubble up to the main session for approval |
297
-
298
- Layered permission policies can be defined in the managed, user, project, local-project, and session tiers. Matching rules use token arrays and the strictest result always wins (`deny > ask > allow`); built-in hard denials cannot be weakened.
299
-
300
- > [!CAUTION]
301
- > Local Shell still runs as your current user. Consider enabling Docker when working with untrusted projects.
302
-
303
- <details>
304
- <summary><strong>Docker execution environment example</strong></summary>
305
-
306
- ```json
307
- {
308
- "execution": {
309
- "mode": "docker",
310
- "image": "node:24-bookworm-slim",
311
- "network": false,
312
- "memory": "2g",
313
- "cpus": 2
314
- }
315
- }
316
- ```
317
-
318
- If Docker is unavailable, tasks fail rather than silently falling back to the host. Sensitive fields in config files and OAuth tokens are encrypted at rest with AES-256-GCM using a local configuration key.
319
-
320
- </details>
321
-
322
- ## SDK, RPC & Evaluation
323
-
324
- <details>
325
- <summary><strong>Node.js SDK example</strong></summary>
326
-
327
- ```ts
328
- import { createFlavorRuntime } from "flavor-code/sdk";
329
-
330
- const runtime = await createFlavorRuntime({
331
- workspace: process.cwd(),
332
- approvalPolicy: "deny",
333
- output: console.log,
334
- });
335
-
336
- await runtime.session.start();
337
- await runtime.session.submit("fix the failing tests");
338
- await runtime.dispose();
339
- ```
340
-
341
- </details>
342
-
343
- Other IDEs or languages can integrate over JSONL RPC:
344
-
345
- ```bash
346
- flavor --mode rpc --workspace . --trace .flavor/traces/run.jsonl
347
- ```
348
-
349
- Run evaluations:
350
-
351
- ```bash
352
- flavor eval eval.json --output report.json
353
- ```
354
-
355
- Design constraints for RPC, traces, replay, eval, session trees, and Docker are in the [control-plane spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md).
356
-
357
- ## Development
358
-
359
- ```bash
360
- npm ci
361
- npm test
362
- npm run typecheck
363
- npm run vscode:typecheck
364
- npm run build
365
- npm run smoke:install
366
- ```
367
-
368
- - TypeScript strict, targeting ES2022, Node.js 20+
369
- - Vitest for unit and integration tests
370
- - tsup builds the CLI, SDK, Electron main process, and VS Code extension
371
- - Vite builds the Electron renderer
372
- - CI covers Windows/macOS with Node 20/24
373
-
374
- Release builds do not generate or package source maps by default. For a local debugging build, enable them explicitly:
375
-
376
- ```bash
377
- # macOS / Linux
378
- FLAVOR_SOURCEMAP=1 npm run build
379
-
380
- # Windows PowerShell
381
- $env:FLAVOR_SOURCEMAP = "1"
382
- npm run build
383
- ```
384
-
385
- ## Documentation
386
-
387
- - [Technical Design Report](./技术方案报告.md): overall architecture, agent loop, context, permissions, plugins, and security model
388
- - [Runtime reliability spec](./docs/specs/2026-07-26-runtime-reliability.md)
389
- - [1.3 reliability, prompt-cache & verification contract](./docs/specs/2026-08-24-v1.3-reliability-contract.md)
390
- - [Control plane, sandbox & VS Code spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md)
391
- - [Multimodal image attachments spec](./docs/specs/2026-07-30-multimodal-image-attachments.md)
392
- - [D2C design-to-code spec](./docs/specs/2026-08-09-d2c-design-to-code.md)
393
- - [D2C review & integration spec](./docs/specs/2026-08-10-d2c-review-and-integration.md)
394
- - [E2E requirement-to-delivery spec](./docs/specs/2026-08-12-e2e-requirement-to-delivery.md)
395
- - [1.2.9 runtime productivity spec](./docs/specs/2026-08-13-runtime-productivity-waves.md)
396
- - [VS Code next steps](./docs/specs/2026-08-01-flavor-code-vscode-next.md)
397
-
398
- ## Security Notes
399
-
400
- - Review model-generated code and commands, especially dependency installs, scripts, and deletions.
401
- - Do not treat `.flavor/sessions/`, traces, or long-term memory as secret stores.
402
- - Use least-privilege API keys and never commit `.env`.
403
- - Skill content can influence model behavior; sandboxed plugins still require review, while explicitly enabled legacy in-process plugins have full Node.js permissions.
404
- - Work under version control and create checkpoints before high-risk tasks.
405
-
406
- ## Contributing
407
-
408
- Issues and Pull Requests are welcome. Please at least run the following before submitting:
409
-
410
- ```bash
411
- npm test
412
- npm run typecheck
413
- npm run vscode:typecheck
414
- npm run build
415
- ```
416
-
417
- For architecture changes, read the [Technical Design Report](./技术方案报告.md) and the relevant [design specs](./docs/specs/) first.
418
-
419
- ## License
420
-
421
- [MIT](./LICENSE)
422
-
423
- <p align="center">
424
- Made with 🌶️ by Flavor Code contributors.
425
- </p>
1
+ <p align="center"><b><a href="./README.md">English</a></b> | <a href="./README.zh-CN.md">简体中文</a></p>
2
+
3
+ <div align="center">
4
+ <img src="./assets/icon-transparent-512.png" alt="Flavor Code Logo" width="168" />
5
+ <h1>Flavor Code</h1>
6
+ <p><strong>Local-first, auditable, resumable AI coding assistant</strong></p>
7
+ <p>Read code, edit files, run commands, and complete complex tasks in the terminal, Electron desktop, and VS Code.</p>
8
+
9
+ <p>
10
+ <a href="https://www.npmjs.com/package/flavor-code"><img alt="npm version" src="https://img.shields.io/npm/v/flavor-code?color=cb3837&logo=npm" /></a>
11
+ <a href="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
12
+ <img alt="Node.js 20+" src="https://img.shields.io/badge/Node.js-20%2B-339933?logo=nodedotjs&logoColor=white" />
13
+ <a href="./LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
14
+ </p>
15
+
16
+ <p>
17
+ <a href="#quick-start">Quick Start</a> ·
18
+ <a href="#features">Features</a> ·
19
+ <a href="#entry-points">Entry Points</a> ·
20
+ <a href="#permissions--sandbox">Security</a> ·
21
+ <a href="#development">Development</a> ·
22
+ <a href="./CHANGELOG.md">Changelog</a>
23
+ </p>
24
+ </div>
25
+
26
+ ---
27
+
28
+ Flavor Code connects to OpenAI, Anthropic, or compatible services and works with file, search, Shell, MCP, and custom tools inside a controlled workspace. Complex tasks can be broken into plans and parallel sub-tasks; sessions, diffs, tool calls, checkpoints, and audit records are all stored locally so you can resume, review, and continue at any time.
29
+
30
+ ## Features
31
+
32
+ | | Capability | What you get |
33
+ | --- | --- | --- |
34
+ | 🖥️ | **One runtime, three entry points** | CLI, Electron, and VS Code share model configuration, sessions, and tooling |
35
+ | 🧭 | **Controlled progress on complex tasks** | Task plans, sub-agents, steering, follow-ups, `/loop`, `/goal`, and conflict-safe parallel execution (tasks owning overlapping files run serially) |
36
+ | 🏝️ | **Flavor Island local control** | Host apps steer a running session over a token-authenticated local IPC channel (Windows named pipes / Unix sockets): abort, steering, follow-ups, and window focus; model duration, token usage, task summaries, and deliverables are reported via hook events |
37
+ | ⏪ | **Traceable, resumable results** | Full timeline, checkpoints, rewind, traces, diffs, and failure audits |
38
+ | 🧱 | **Crash-consistent execution** | Fsync-backed event journal, durable steering queue, savepoints, and no automatic replay of non-idempotent tools |
39
+ | 🧠 | **Local long-term context** | Memory, Skills, plugins, and project guides stored on your machine |
40
+ | 🔎 | **Code graph navigation** | A local AST code-graph index (`.flavor/astgraph/`) powers `ast_search`/`ast_callers`/`ast_impact` queries for precise symbol lookup and reachability tracing; `/explain` turns that graph plus git history into newcomer-oriented walkthroughs |
41
+ | 🌿 | **Git-native workflows** | `/commit` drafts a Conventional-Commits message for staged changes and commits after confirmation; `/review` audits uncommitted changes; the read-only `GitHistory` tool explains when and why code changed |
42
+ | 🎨 | **E2E requirement-to-delivery** | From a rough requirement or a design export to a delivered product: PRD, interactive prototype, visual implementation, API integration, autonomous acceptance, and scored delivery (Electron only) |
43
+ | 🔁 | **Bounded self-improvement** | Repeated tool failures are captured, deduped, and proposed as suggestions; fixes ship as sandbox-verified plugins or as learned guardrail rules injected into future prompts, with run trends and rule management (`/evolve`) |
44
+ | 🛡️ | **Clear permission boundaries** | Independent control over read, write, Shell, network, and destructive actions; Docker supported |
45
+
46
+ ## Quick Start
47
+
48
+ > [!IMPORTANT]
49
+ > The CLI requires Node.js 20 or later. Windows desktop builds can also be downloaded directly from [Releases](https://github.com/YachuanWzh/flavor-code/releases).
50
+
51
+ **1. Install**
52
+
53
+ ```bash
54
+ npm install -g flavor-code
55
+ ```
56
+
57
+ **2. Start in your project**
58
+
59
+ ```bash
60
+ cd your-project
61
+ flavor
62
+ ```
63
+
64
+ **3. Initialize project context**
65
+
66
+ Run `/init` the first time you enter a project. Flavor analyzes the language, package manager, source directories, and verification commands, then generates a `FLAVOR.md` project guide.
67
+
68
+ You can also run one-off tasks directly:
69
+
70
+ ```bash
71
+ flavor --print "Analyze this project and list the top three issues worth fixing"
72
+ flavor --resume
73
+ flavor --resume -p "Continue the remaining work"
74
+ ```
75
+
76
+ Non-interactive mode refuses actions that require human approval and never hangs waiting for input.
77
+
78
+ ## Configuring Models
79
+
80
+ The fastest way is to set environment variables:
81
+
82
+ ```bash
83
+ # macOS / Linux
84
+ export OPENAI_API_KEY="sk-..."
85
+
86
+ # Windows PowerShell
87
+ $env:OPENAI_API_KEY = "sk-..."
88
+ ```
89
+
90
+ You can also put the key in a `.env` file at the project root.
91
+
92
+ <details>
93
+ <summary><strong>Configure multiple providers with <code>.flavor/flavor.json</code></strong></summary>
94
+
95
+ Example project configuration:
96
+
97
+ ```json
98
+ {
99
+ "providers": {
100
+ "openai": {
101
+ "type": "openai",
102
+ "apiKey": "${OPENAI_API_KEY}",
103
+ "defaultModel": "gpt-5",
104
+ "cheapModel": "gpt-5-mini"
105
+ }
106
+ },
107
+ "agents": {
108
+ "main": { "model": "openai:gpt-5" },
109
+ "subagent": { "model": "openai:gpt-5-mini" }
110
+ },
111
+ "permissionMode": "default",
112
+ "maxSubagents": 3,
113
+ "language": "zh-CN"
114
+ }
115
+ ```
116
+
117
+ Configuration is merged in the following order, with later sources taking precedence:
118
+
119
+ 1. Global `~/.flavor-code/flavor.json`
120
+ 2. Project `.flavor/flavor.json`
121
+ 3. `.env`
122
+ 4. Process environment variables
123
+
124
+ Commonly supported provider types:
125
+
126
+ - `openai`: OpenAI's official API
127
+ - `anthropic`: Anthropic's official API
128
+ - `openai-compatible`: Services compatible with the OpenAI protocol
129
+
130
+ </details>
131
+
132
+ Runtime behavior and configuration conventions for OAuth PKCE are described in the [PKCE spec](./docs/specs/pkce-runtime-config.md). The [config schema](./src/config/schema.ts) is the source of truth for all fields.
133
+
134
+ ## Entry Points
135
+
136
+ | Entry point | Best for | How to start |
137
+ | --- | --- | --- |
138
+ | **CLI** | Daily development, remote environments, scripting, and CI | `flavor` |
139
+ | **Electron** | Visual sessions, diffs, permissions, and resource management | `npm run desktop:start` |
140
+ | **VS Code / Qoder** | Editor context, diagnostic fixes, and a task control plane | `npm run ide:install` |
141
+
142
+ ### CLI
143
+
144
+ Run `flavor` and type natural language. Typing `/` shows built-in commands, plugin commands, and Skills.
145
+
146
+ Common commands:
147
+
148
+ | Command | Purpose |
149
+ | --- | --- |
150
+ | `/init` | Generate or update `FLAVOR.md` |
151
+ | `/model` | View or switch main/sub-agent models |
152
+ | `/permissions` | Switch permission modes |
153
+ | `/tasks` | View task plans and sub-agent status |
154
+ | `/compact` | Manually compact long session context |
155
+ | `/checkpoint`, `/tree` | Save state, view the session tree |
156
+ | `/rewind`, `/unrevert`, `/fork` | Resume or fork sessions |
157
+ | `/memory`, `/remember`, `/forget`, `/forget-cold` | Manage long-term memory; `/forget-cold` purges cold entries and their files |
158
+ | `/mcp` | View and manage MCP servers |
159
+ | `/loop <goal>` | Run an autonomous loop with verification |
160
+ | `/goal <objective>` | Run the plan, execute, adversarial-review workflow |
161
+ | `/commit [hint]` | Draft a Conventional-Commits message for staged changes and commit after confirmation |
162
+ | `/review [focus]` | Review uncommitted changes for bugs and risks before committing |
163
+ | `/explain <symbol \| file.ts#symbol> [focus]` | Explain a symbol for newcomers using the code graph, real source and git history (interactive picker on ambiguity) |
164
+ | `/evolve <signals\|suggest\|improve ...>` | Self-improvement loop: review repeated tool failures, scaffold fix plugins, manage run trends and learned guardrail rules, verify and hot-reload |
165
+ | `/pals`, `/chat`, `/co-work` | Discover and collaborate with other local CLI instances |
166
+ | `/audit` | View tool failure audits |
167
+
168
+ You can submit steering or queue follow-ups while a run is in progress; once the current model response finishes, the task picks up new instructions at safe boundaries.
169
+
170
+ `/commit` and `/review` use the cheap sub-agent model and degrade gracefully when it is unavailable. Session checkpoints are tagged with the current git state (`branch@sha`), so `/tree` shows what the workspace looked like at each node. `/explain <symbol>` runs on the same cheap model: it assembles call relations from the code graph, the symbol's real source slice, and recent commits touching the file, then generates a five-part newcomer walkthrough (what it does / key implementation points / call flow / why it is written this way / gotchas); an interactive picker disambiguates multiple matches, and a missing graph degrades to a `/ast init` hint instead of an error.
171
+
172
+ #### CLI pals and cross-project work
173
+
174
+ Interactive CLI instances on the same Windows or macOS user account can collaborate over local-only IPC (Windows named pipes or Unix sockets; no TCP fallback). Give each window a memorable alias:
175
+
176
+ ```bash
177
+ # terminal A, in project A
178
+ flavor --pal-name A
179
+
180
+ # terminal B, in project B
181
+ flavor --pal-name B
182
+ ```
183
+
184
+ Useful commands:
185
+
186
+ ```text
187
+ /pals # aliases and per-process UUIDs
188
+ /pals --verbose # also show project paths and timestamps
189
+ /pals rename api # rename this active instance
190
+ /chat B Update the API and tests # deliver to B and start its agent safely
191
+ /co-work B Upgrade B, then adapt A # negotiate one plan before parallel work
192
+ /co-work status [co-work-uuid]
193
+ /co-work cancel <co-work-uuid> [reason]
194
+ ```
195
+
196
+ `/chat` is bidirectional and task-oriented. If B is idle, the attributed message starts a normal model turn; if B is already running, it becomes steering, or a follow-up when another local submission is pending. Remote text is converted to a safe non-slash prompt, so `/exit`-like text is not dispatched as a local command. B can answer with `/chat A ...`.
197
+
198
+ `/co-work` first places both agents in planning and waits for both to accept the same hashed plan and declare READY. Early READY intents are retained, and only the broker's exactly-once START event opens parallel execution. Each agent works only in its own project, receives only its assigned tasks, and reports bounded completion evidence. The broker-selected integration owner verifies all assertions and emits END or FAIL through `CoWorkIntegrate`. Communication uses authenticated, bounded local IPC with no TCP listener; peer input cannot approve tools or access the other workspace. UUID/alias routing and the protocol already support a third active client; durable artifact exchange, broker-restart journaling/recovery, and large-group coordination are later hardening work. See the [CLI pals specification](./docs/specs/2026-08-14-cli-pals-cowork.md).
199
+
200
+ ### Electron Desktop
201
+
202
+ ```bash
203
+ npm run desktop:dev # dev mode
204
+ npm run desktop:start # build and start
205
+ npm run desktop:pack # Windows portable directory
206
+ npm run desktop:dist # Windows NSIS installer
207
+ ```
208
+
209
+ The desktop app keeps multiple projects open and can run up to four independent tasks concurrently inside one project; switching projects or tasks does not stop background work. Completion, failure, attention, and interruption events enter a persistent activity inbox and trigger native notifications, while unread completions retain a blue dot. Projects can be pinned, renamed, closed, revealed, or copied; tasks can be searched, renamed, pinned, and archived.
210
+
211
+ Use `Ctrl+P` to switch projects, `Ctrl+K` for the command palette, and `Ctrl+N` for a new task; the title bar also supports back/forward navigation. Interrupted work gets a recovery banner after an abnormal exit. The **Git Changes** view provides per-file diffs, stage/unstage/discard, commits, and `/review` handoff. Streaming Markdown, permission confirmations, and Skills, MCP, memory, and model management remain available.
212
+
213
+ The **E2E** module in the sidebar drives a rough requirement or an existing design export through the full delivery pipeline: it generates a PRD and an interactive prototype for review, then moves into D2C visual implementation (Vue 3 / React) under `src/d2c-output/<task>/`. A Vite dev server starts automatically for pixel-level comparison, producing a visual-fidelity score and a structured diff report (region offsets, color deviations, font differences); the results workbench offers overlay, curtain, flicker, and heatmap modes, an SVG annotation layer, and a severity-sorted issue list. After visual review, a Swagger/OpenAPI contract is generated or imported to auto-create Axios wrappers and an Express mock server, followed by autonomous interactive acceptance and scored delivery.
214
+
215
+ ### VS Code / Qoder
216
+
217
+ ```bash
218
+ npm run vscode:install # install into VS Code
219
+ npm run qoder:install # install into Qoder
220
+ npm run ide:install # auto-select the installed IDE
221
+ ```
222
+
223
+ The extension includes the `@flavor` Chat Participant, Mission Control, Changes & Health, Time Machine, diagnostic fixes, CodeLens, checkpoints, and rewind. If `flavor` is not on your `PATH`, set `flavorCode.executable`.
224
+
225
+ ## MCP, Skills & Plugins
226
+
227
+ Flavor can connect to stdio or Streamable HTTP MCP servers. Example project configuration:
228
+
229
+ <details>
230
+ <summary><strong>MCP configuration and CLI examples</strong></summary>
231
+
232
+ ```json
233
+ {
234
+ "mcpServers": {
235
+ "docs": {
236
+ "url": "https://example.com/mcp",
237
+ "headers": {
238
+ "Authorization": "Bearer ${MCP_TOKEN}"
239
+ }
240
+ }
241
+ }
242
+ }
243
+ ```
244
+
245
+ MCP configuration can also be managed from the CLI:
246
+
247
+ ```bash
248
+ flavor mcp list
249
+ flavor mcp add docs --url https://example.com/mcp
250
+ flavor mcp disable docs
251
+ ```
252
+
253
+ </details>
254
+
255
+ A Skill is a `SKILL.md` with YAML frontmatter, placed in `.flavor/skills/<name>/` or `~/.flavor-code/skills/<name>/`. Flavor loads skills progressively based on the task, and you can invoke one explicitly with `/<skill-name>`. Skill bodies support `$ARGUMENTS`, `$ARGUMENTS[N]`, and `$N` substitutions. A running composite Skill can load a dependency through the read-only `Skill` tool; plugin-qualified names such as `superharness:test-driven-development` resolve to discovered skills.
256
+
257
+ Plugins live in `.flavor/plugins/` and can register commands, tools, hooks, Skill roots, and model adapters. Official plugins can be installed with the plugin manager: `npx --yes @flavor-code/plugin-manager`. `additionalContext` returned by `SessionStart` and `UserPromptSubmit` hooks is added to the current task context, enabling reliable project-level engineering policy injection. Plugin loads record a content fingerprint plus declared capabilities. Worker/vm isolation is available through the embedding API's `pluginSandbox: true` option; the compatibility default remains in-process because bundled and existing plugins use Node.js APIs that the isolated runtime does not yet mediate.
258
+
259
+ When the `flavor-island` plugin is loaded, Flavor also starts a Flavor Island local control channel: a loopback-only IPC service (Windows named pipe, or Unix socket on macOS/Linux) secured by a random token. A host app (such as the Flavor Island desktop) can use it to abort, steer, or send follow-ups to a running session, and desktop hosts can also bring their window into focus. The channel's endpoint, token, and capability list are exposed to the host plugin via hook event context (`islandControlEndpoint`/`islandControlToken`/`islandControlCapabilities`); model-call duration and token usage, plus the final task summary and deliverables, are reported through hook events so the host can show live status and a result overview.
260
+
261
+ > [!WARNING]
262
+ > The default in-process plugin runtime grants full Node.js access. Only install and enable plugins you trust. Sandboxing reduces ambient access but does not make untrusted instructions safe, and plugins that import Node.js built-ins will not load with `pluginSandbox: true` yet.
263
+
264
+ ## Sessions, Memory & Execution Records
265
+
266
+ Project runtime data lives under `.flavor/`:
267
+
268
+ ```text
269
+ .flavor/
270
+ ├── flavor.json # Project config
271
+ ├── sessions/ # Session timelines
272
+ │ └── *.events.jsonl # Crash-consistent execution journals
273
+ ├── session-assets/ # Image attachments
274
+ ├── session-trees/ # Session branches
275
+ ├── checkpoints/ # Workspace snapshots
276
+ ├── memory/ # Long-term memory
277
+ ├── traces/ # Optional execution traces
278
+ ├── audit.jsonl # Tool failure audits
279
+ ├── evolve/ # Self-improvement signals and run reflections
280
+ ├── skills/ # Project skills
281
+ └── plugins/ # Project plugins
282
+ ```
283
+
284
+ Long-term memory distinguishes user preferences, behavioral feedback, project conventions, and external references. Automatic extraction only keeps high-confidence candidates and provides confirm, ignore, and delete actions; secrets, tokens, raw tool output, and model guesses are rejected.
285
+
286
+ Image prompts support PNG, JPEG, and WebP, with a 5 MiB per-image maximum and up to 5 images per prompt. The desktop app supports picking or drag-and-drop; CLI clipboard images currently work on Windows and macOS.
287
+
288
+ ## Permissions & Sandbox
289
+
290
+ | Mode | Behavior |
291
+ | --- | --- |
292
+ | `default` | Reads are auto-approved; writes, Shell, network, and destructive actions are confirmed on demand |
293
+ | `acceptEdits` | Workspace writes and routine verification are auto-approved |
294
+ | `plan` | Read-only planning; no modifications or execution |
295
+ | `bypassPermissions` | The main agent executes as much as possible after hard safety checks |
296
+ | `auto` | A classifier decides, falling back to human approval when uncertain |
297
+ | `bubble` | Uncertain operations bubble up to the main session for approval |
298
+
299
+ Layered permission policies can be defined in the managed, user, project, local-project, and session tiers. Matching rules use token arrays and the strictest result always wins (`deny > ask > allow`); built-in hard denials cannot be weakened.
300
+
301
+ > [!CAUTION]
302
+ > Local Shell still runs as your current user. Consider enabling Docker when working with untrusted projects.
303
+
304
+ <details>
305
+ <summary><strong>Docker execution environment example</strong></summary>
306
+
307
+ ```json
308
+ {
309
+ "execution": {
310
+ "mode": "docker",
311
+ "image": "node:24-bookworm-slim",
312
+ "network": false,
313
+ "memory": "2g",
314
+ "cpus": 2
315
+ }
316
+ }
317
+ ```
318
+
319
+ If Docker is unavailable, tasks fail rather than silently falling back to the host. Sensitive fields in config files and OAuth tokens are encrypted at rest with AES-256-GCM using a local configuration key.
320
+
321
+ </details>
322
+
323
+ ## SDK, RPC & Evaluation
324
+
325
+ <details>
326
+ <summary><strong>Node.js SDK example</strong></summary>
327
+
328
+ ```ts
329
+ import { createFlavorRuntime } from "flavor-code/sdk";
330
+
331
+ const runtime = await createFlavorRuntime({
332
+ workspace: process.cwd(),
333
+ approvalPolicy: "deny",
334
+ output: console.log,
335
+ });
336
+
337
+ await runtime.session.start();
338
+ await runtime.session.submit("fix the failing tests");
339
+ await runtime.dispose();
340
+ ```
341
+
342
+ </details>
343
+
344
+ Other IDEs or languages can integrate over JSONL RPC:
345
+
346
+ ```bash
347
+ flavor --mode rpc --workspace . --trace .flavor/traces/run.jsonl
348
+ ```
349
+
350
+ Run evaluations:
351
+
352
+ ```bash
353
+ flavor eval eval.json --output report.json
354
+ ```
355
+
356
+ Design constraints for RPC, traces, replay, eval, session trees, and Docker are in the [control-plane spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md).
357
+
358
+ ## Development
359
+
360
+ ```bash
361
+ npm ci
362
+ npm test
363
+ npm run typecheck
364
+ npm run vscode:typecheck
365
+ npm run build
366
+ npm run smoke:install
367
+ ```
368
+
369
+ - TypeScript strict, targeting ES2022, Node.js 20+
370
+ - Vitest for unit and integration tests
371
+ - tsup builds the CLI, SDK, Electron main process, and VS Code extension
372
+ - Vite builds the Electron renderer
373
+ - CI covers Windows/macOS with Node 20/24
374
+
375
+ Release builds do not generate or package source maps by default. For a local debugging build, enable them explicitly:
376
+
377
+ ```bash
378
+ # macOS / Linux
379
+ FLAVOR_SOURCEMAP=1 npm run build
380
+
381
+ # Windows PowerShell
382
+ $env:FLAVOR_SOURCEMAP = "1"
383
+ npm run build
384
+ ```
385
+
386
+ ## Documentation
387
+
388
+ - [Technical Design Report](./技术方案报告.md): overall architecture, agent loop, context, permissions, plugins, and security model
389
+ - [Runtime reliability spec](./docs/specs/2026-07-26-runtime-reliability.md)
390
+ - [1.3 reliability, prompt-cache & verification contract](./docs/specs/2026-08-24-v1.3-reliability-contract.md)
391
+ - [Control plane, sandbox & VS Code spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md)
392
+ - [Multimodal image attachments spec](./docs/specs/2026-07-30-multimodal-image-attachments.md)
393
+ - [D2C design-to-code spec](./docs/specs/2026-08-09-d2c-design-to-code.md)
394
+ - [D2C review & integration spec](./docs/specs/2026-08-10-d2c-review-and-integration.md)
395
+ - [E2E requirement-to-delivery spec](./docs/specs/2026-08-12-e2e-requirement-to-delivery.md)
396
+ - [1.2.9 runtime productivity spec](./docs/specs/2026-08-13-runtime-productivity-waves.md)
397
+ - [VS Code next steps](./docs/specs/2026-08-01-flavor-code-vscode-next.md)
398
+
399
+ ## Security Notes
400
+
401
+ - Review model-generated code and commands, especially dependency installs, scripts, and deletions.
402
+ - Do not treat `.flavor/sessions/`, traces, or long-term memory as secret stores.
403
+ - Use least-privilege API keys and never commit `.env`.
404
+ - Skill content can influence model behavior; sandboxed plugins still require review, while explicitly enabled legacy in-process plugins have full Node.js permissions.
405
+ - Work under version control and create checkpoints before high-risk tasks.
406
+
407
+ ## Contributing
408
+
409
+ Issues and Pull Requests are welcome. Please at least run the following before submitting:
410
+
411
+ ```bash
412
+ npm test
413
+ npm run typecheck
414
+ npm run vscode:typecheck
415
+ npm run build
416
+ ```
417
+
418
+ For architecture changes, read the [Technical Design Report](./技术方案报告.md) and the relevant [design specs](./docs/specs/) first.
419
+
420
+ ## License
421
+
422
+ [MIT](./LICENSE)
423
+
424
+ <p align="center">
425
+ Made with 🌶️ by Flavor Code contributors.
426
+ </p>