Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

docs: Linux in the release steps; Prompt+ in the engineering notes

Gabriele Lozuponeb98006abaf4c
diff --git a/crates/qls-core/src/enhancer.rs b/crates/qls-core/src/enhancer.rs
index 47f4f90..b947bc1 100644
--- a/crates/qls-core/src/enhancer.rs
+++ b/crates/qls-core/src/enhancer.rs
@@ -3,13 +3,13 @@
//! images for edits) before the image is generated. Runs on Kokon's engine builds only
//! (`Capabilities::text_generation`, `POST /sdcpp/v1/text_gen`); the server has no built-in
//! system prompt, so Kokon always sends one: the user's from Settings or the defaults below.
-//! Design and the A/B behind these texts: docs/prompt-enhancer.md.
+//! Design and the A/B behind these texts: docs/engineering-notes.md, "Prompt+".
use crate::config::AppConfig;
use crate::planner::ResolvedMode;
use crate::sdcpp::{TextGenRequest, TextSampling};
-/// Built-in system prompt for text-to-image (docs/prompt-enhancer.md, decided 2026-10-18, revised
+/// Built-in system prompt for text-to-image (engineering notes, "Prompt+"; decided 2026-10-18, revised
/// 2026-10-20). No example colours or objects: the model copies them into every prompt.
pub const T2I_SYSTEM_PROMPT: &str = r#"You write prompts for an image generation model. Expand the user's request into one detailed English paragraph that describes the finished image: subject, setting, composition, lighting and style.
- Keep everything the user specified about the image (objects, counts, colours, positions, style) and never contradict it. If the request is already detailed, keep all of it and only add what is missing. Leave out size and quality words (4K, HD, 16:9, resolution): the app sets the size.
diff --git a/docs/engineering-notes.md b/docs/engineering-notes.md
index 10f9a63..f98419e 100644
--- a/docs/engineering-notes.md
+++ b/docs/engineering-notes.md
@@ -143,7 +143,7 @@ merged upstream as PR #2128 on 2026-10-12; since 0.9.2 the engine is the officia
`engine.json` at the repository root names the newest engine release tested with Kokon. Since
0.10 every engine is Kokon's own build (fork branch `kokon`, workflow `kokon.yml`, release
-`kokon-<n>-<commit>`; see docs/prompt-enhancer.md), listed under the `kokon` key: tag, `min_app`,
+`kokon-<n>-<commit>`; see "Prompt+" below), listed under the `kokon` key: tag, `min_app`,
URL + size + SHA-256 of `win_cuda`, `win_vulkan`, `linux_cuda`, `linux_vulkan`, `macos`. The
file's other keys are an upstream release for apps up to 0.9.4, which ignore `kokon`. The service
reads its cached copy at start and fetches it again when older than 2.5 days
@@ -236,6 +236,40 @@ method (a low-denoise img2img pass at about 2K first) was removed on 2026-10-09:
schedule leaves only 1–2 steps at strength 0.3. Requests with `"method": "detailed"` run as
the upscaler model only.
+### Prompt+ (the prompt enhancer, 0.10.0)
+
+Optional, off by default. The Qwen3-VL 8B that Qwen-Image 2.1 already loads as its text encoder
+rewrites the user's short instruction into a full English prompt (looking at the input image for
+edits) before the image is made, so there is no second model in memory.
+
+- **Inside the engine, not a second llama.cpp process.** Kokon's engine build adds a generation loop
+ (KV cache, sampling, streaming detokenizer) on the loaded encoder and `POST /sdcpp/v1/text_gen`
+ (SSE `delta` / `done` / `error`; `stream: false` returns one JSON). `/sdcpp/v1/capabilities` reports
+ `text_generation`; the app hides the Prompt+ pill on engines without it. A second llama.cpp would
+ double the 8B in RAM (+6.6 GB on Windows without mmap). Upstream prefers to leave text generation to
+ llama.cpp ([leejet/stable-diffusion.cpp#2155](https://github.com/leejet/stable-diffusion.cpp/issues/2155)),
+ so it lives in the fork.
+- **Checked against llama.cpp** on the same GGUF: tokenizer round-trips, first-step logits (text
+ KL ≤ 0.02 on CUDA, ≤ 0.03 on CPU, images ≤ 0.15) and greedy tokens identical up to the first near-tie.
+- **Memory:** the encoder weights live in RAM (`--params-backend te=cpu`). For generation the engine
+ moves the DiT/VAE to pinned RAM when the encoder doesn't fit next to them (restore ~0.5 s on the next
+ image job), releases the vision tower before decoding, and reuses the decode graph with CUDA graphs
+ (ggml patch: only graphs with an id are captured). Below the budget, layers run split CPU/GPU.
+ Measured: ~127 tok/s on 16, 12 and 8 GB (RTX 5070 Ti, real and emulated; llama.cpp 133–145).
+- **Cost per image** (Fast 1024², same seed on/off): Windows +2.0 s t2i / +1.1 s edit, +2.4 GB peak
+ VRAM; Linux (WSL) +1.6 / +0.1 s; 8 GB emulated +3.6 / +1.8 s; M2 Pro 16 GB ~+13 s on ~290 s.
+- **System prompts live only in Kokon** (`crates/qls-core/src/enhancer.rs`; Settings can replace
+ them). They are our own texts, chosen in blind A/Bs over 20 and then 39 cases × 2 seeds against
+ Qwen's official PE prompts (those are under the Qwen Research License, ~2,400 / ~4,900 tokens, and
+ on the 8B the edit one wrote edits in Chinese). Rules kept: copy the user's fixed content exactly
+ (quoted text, counts, colours), name the medium early, always state the light, no quality tags; for
+ edits lead with the operation, describe only what changes and end with one "keep everything else
+ unchanged" clause (describing what stays makes the model redraw it). Output is always English.
+ Lesson: **any example colour or object in a system prompt leaks** into the outputs.
+- **Sampling:** Qwen3-VL's values (temperature 0.7, top-p 0.8, top-k 20, presence penalty 1.5 counted
+ on generated tokens only), seeded with a portable RNG, so the same seed gives the same text on every
+ platform. Regenerate makes a new prompt and a new seed; greedy is the engine default and test mode.
+
## HDR
The source's ISO 21496-1 gain map is reused and faded out where the edit changed brightness by
diff --git a/docs/releasing.md b/docs/releasing.md
index e77a7aa..6cb902c 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -1,6 +1,7 @@
# Releasing Kokon
-How to publish a version that installed copies update to, on Windows and macOS.
+How to publish a version that installed copies update to, on Windows, macOS and Linux. Every release ships
+all three from the same code.
## How updates work
@@ -33,10 +34,14 @@ How to publish a version that installed copies update to, on Windows and macOS.
then both `"version"` fields in `mcp/server.json` (`npm test` in `mcp/` fails until all match;
`kokon-mcp --version` reads `mcp/package.json`).
2. **Windows:** `powershell -ExecutionPolicy Bypass -File scripts\build-release.ps1`
-3. **Mac:** `bash scripts/build-release-mac.sh`. Then copy `dist-release/` from the Mac to the
- PC (or the other way around) so that one folder holds both platforms' files.
+3. **Mac:** `bash scripts/build-release-mac.sh`.
+ **Linux:** in WSL Ubuntu 22.04 (clone in `~/kokon`, see [linux.md](linux.md)),
+ `bash scripts/build-release-linux.sh` → `.deb`, `.rpm` and `updater-linux-x86_64-{deb,rpm}.json`.
+ Then copy each machine's `dist-release/` files to the PC so that one folder holds every platform's files.
4. **Write the manifest:**
`node scripts/release/updater.mjs manifest --notes "What changed, in one or two lines"`
+ (`latest.json` must list Windows, macOS and both Linux packages).
+ Release notes go in `marketing/release-notes-<version>.md`, with each installer's SHA-256.
5. **Publish** (the tag must be `v` + the version):
```bash
gh release create v0.9.1 --draft --target master --title "Kokon 0.9.1" --notes-file notes.md \