41 Commits

Author SHA1 Message Date
Mohammad Hijjawi
7bd5b99f9a fix(book): match language cues as whole words (#2477)
Automatic book language detection matched its English-word cues as bare
substrings, so a topic that only mentioned a place or a subject forced
the book into another language: "energy policy in Germany" and "Berlin
German dialects" became German, "the main English clubs" became English
over the interface language, and any mention of "Traditional Chinese
Medicine" became Traditional Chinese.

Bound the Latin and Cyrillic cues with word boundaries and require the
phrased "in Traditional Chinese" form, matching how every other English
cue is written. CJK cues are unchanged.
2026-12-01 14:57:45 +08:00
Qiu
ff0b7be3f8 fix(book): use the active clock for standalone chapter retries (#3098) 2026-11-30 06:33:07 -03:00
Yuchuan He
5a1722b80f fix: preserve embedded fences in book Markdown export (#2957) 2026-11-28 19:41:41 +08:00
wojiecihuo
651a616b02 fix(visualize): raise the budget to 32k, cap it to the model, and retry without thinking (#3019)
* fix(book): retry an interactive page with thinking off when it runs out of room

deepseek-flash thinks by default and can spend the whole 16000-token
visualize budget on reasoning, so a book interactive block came back with
no code. When the page is empty or cut off before </html>, ask once more
with thinking turned off (thinking_off_effort_for) before failing. If that
still runs out of room, the error names the budget sent to the model and
the settings that change it.

The shipped default stays at 16000: the budget is shared by every visualize
caller, and 32768 breaks models with a lower output cap (#3018).

Refs #3011

* fix(llm): raise the visualize budget to 32k and cap each request to the model

A thinking model can spend 16k tokens before it writes any code, so the
visualize default is now 32768. Sent unchanged that would be rejected by
models whose output stops lower (gpt-4o and gpt-4o-mini at 16384) and could
overflow a small local context window, so every request now carries
min(budget, the model's known output limit, half the configured context
window). The cap lives in get_token_limit_kwargs, so it applies to every
caller; BaseAgent and the agentic loop pass the configured window.
2026-11-27 22:26:59 +08:00
OrdoAbChao
22399efcc2 Revert "fix(visualize): give reasoning models room and say how to fix an empty page (#3012)" (#3018)
This reverts commit 0f76dc080e.
2026-11-27 17:58:43 +08:00
wojiecihuo
0f76dc080e fix(visualize): give reasoning models room and say how to fix an empty page (#3012)
deepseek-flash thinks by default and spent the whole 16000-token visualize
budget on reasoning, so book interactive blocks came back with no code.
Raise the default to 32768 and make the book's interactive errors name the
two settings that fix it: Max tokens under Settings -> Capabilities ->
Visualize, or turning off thinking for the model.
2026-11-27 17:51:31 +08:00
游标卡尺
097f7c1125 fix(book): reject incomplete interactive HTML (#2919)
* fix(book): reject incomplete interactive HTML

Normalize wrapped HTML and require complete document and script boundaries so truncated output follows the existing retry/error path instead of being persisted as READY.

* fix(book): end interactive html at its real </html> and name truncation

Find the document end with the HTML parser instead of the last </html> or
the first code fence: script bodies stay raw text, so a fence in <pre>, an
end tag in a script string or prose after the page no longer moves the end.
A reply whose fence never closes is accepted when the document is complete,
and a cut-off document now says it was probably cut off.

---------

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-27 13:55:52 +08:00
Bingxi Zhao (Frank)
4c1e000d85 release: v1.7.3
Prepare v1.7.3 notes for reading and book editing, expanded provider and
agent connections, learning records, model streams, and desktop upgrades.

Sync README prose and 11 translations, archive older release notes, and
update the package version. Resolve release lint/type blockers with explicit
parser and capability contracts, compatible Book call forwarding, accurate
auth task types, and quoted SQLite schema identifiers. Cover positional Book
calls and quoted legacy columns; align KB seed tests with visible retrieval
failure reporting. Keep HTTP fixtures independent of host proxies and translate
new Portuguese UI copy.

Release notes: assets/releases/ver1-7-3.md
2026-11-16 02:17:36 +08:00
Bingxi Zhao (Frank)
8ab4ecfee9 feat(books): review and undo scoped chapter and section edits
Fixes #2571
2026-11-15 01:42:47 +08:00
Bingxi Zhao (Frank)
f583255ff0 fix(book): snapshot workspace instructions for generation
Fixes #2601
2026-11-15 01:20:52 +08:00
ZQR1101
71a05602d5 feat(book): post-generation chapter CRUD without recompiling
Add / rename / reorder / delete chapters after generation through REST
endpoints mirroring the block-CRUD handlers. New chapters are pending
shells; already-compiled pages are never recompiled or discarded. Each
edit carries the chapter's order/title onto its pages so the reader-visible
sequence follows, and delete prunes only its own pages plus the concept
graph, prerequisites, and progress refs.

Part of #2571
2026-11-11 17:45:37 +08:00
Rudy Celekli
83a0c7aceb fix(book): keep flash-card newlines inside the Markdown table row
_render_flash_cards escaped pipes but not newlines, so a card whose
front/back contained a line break split the GFM table row and corrupted
the rest of the table on "export book as Markdown". Replace interior
newlines with <br>, matching the pipe escaping and the notebook table
renderer's convention.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 23:54:51 -05:00
d41sys
9ddbb92c36 feat: add Vietnamese localization 2026-10-30 02:28:18 +01:00
dajiaohuang
93a6903be6 Merge commit '6cf793bd868ba5ecbe64722936d4be8fab5a01df' into fix/book-empty-source-drift 2026-10-08 12:35:42 +08:00
dajiaohuang
e6a3a8807b fix(book): detect deletion of the final knowledge source 2026-10-08 12:35:42 +08:00
evan188199-tech
7595f6ce31 style: apply ruff format to spine_synthesizer tests (#1750)
* test(book): cover SpineSynthesizer materialise, revise loop and fallback paths

20 offline cases over the spine_synthesizer seams the LLM-call test does
not reach: payload-to-chapter/graph materialisation, the draft-critique-
revise loop with on_round events, unusable-output fallbacks, and the
deterministic invariants (count, order, clamping). Module coverage
14.0% -> 94%. All LLM traffic is replayed via BaseAgent.stream_llm; each
test seeds its own agents.yaml home so no runtime install is required.

* style: apply ruff format to spine_synthesizer tests

* docs: add PR evidence for spine_synthesizer coverage

---------

Co-authored-by: XZH <cto@xzh.ai>
2026-10-07 20:14:56 +08:00
evan188199-tech
7e7b135709 test(book): cover engine stage transitions (#1718)
* test(book): cover engine stage transitions

Pin the three guarantees a long book generation depends on:
stage order with per-stage artefact persistence, single-stage failure
retry without duplicating output (exploration degrade + page-level
compile retry), and pause/resume recovery that never re-pays finished
pages. All agents and the compiler are faked — no LLM, no long tasks.

* docs: add PR evidence for book engine stage transition tests

---------

Co-authored-by: XZH <cto@xzh.ai>
2026-10-07 20:13:36 +08:00
Bingxi Zhao (Frank)
7f6c16ef09 fix(book): retry output-capped structured responses 2026-09-23 12:25:41 +08:00
Bingxi Zhao (Frank)
da856ad670 release: v1.6.9
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.

Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
2026-09-21 02:30:40 +08:00
Bingxi Zhao (Frank)
4e2f088548 merge: bring 19 reviewed PRs from origin/dev into dev
Resolves two collisions with the fixes committed locally tonight:

* book/blocks/_llm_writer.py — #1366 threaded a reasoning_effort
  through llm_json while 5ac8e2c9 replaced this file's private
  _json_has_expected with the shared json_payload_is_usable.
  Taking either side alone breaks: origin/dev's calls a helper that no
  longer exists, ours drops the caller's explicit effort. Kept the shared
  helper and the threading, and the retry now reuses an explicitly given
  effort so a round deliberately run without thinking cannot re-enable it.

* runtime/agentic/tool_dispatch.py — #1357 added tool_timeout /
  tool_max_retries to execute_tool_call in the same parameter list where
  4e816d79 renamed unknown_error_message_factory (tool) to
  tool_error_message_factory (tool, error). Both are needed: the
  dispatcher already passes the timeout pair through, and every call site
  in the tree now uses the renamed factory.
2026-09-10 23:52:04 +08:00
Gao Chenkai
fbdf975060 fix(book): isolate scratchpad from generated content (#1366) 2026-09-10 23:45:09 +08:00
Bingxi Zhao (Frank)
5ac8e2c9d3 fix(book): give Book a reachable token budget, and retry a starved plan
A book built with a reasoning model arrives as a single "Overview"
chapter, or with the right chapter count and every learning objective
and summary empty (#1316). Two independent faults compose into that.

`get_agent_params` maps a module name to a section of agents.yaml, and
`book` was not in the map — so the function returned the source-level
`global_defaults` of 4096 *before* ever opening the file. That budget
was therefore not the shipped default and not overridable: adding a
`capabilities.book` block did nothing, and only editing the source could
change it. It is now mapped, seeded at 12000 in DEFAULT_AGENTS_SETTINGS
(so a stale agents.yaml still gets it), and honoured from the yaml.
12000 rather than a larger figure matches `research`, the closest
analogue, and keeps the request under the output cap of providers that
enforce one.

The budget is the trigger, not the fault. A reasoning model pays for its
hidden tokens out of the same `max_tokens` as its answer, so on a large
prompt asking for a whole JSON object it can spend the lot and emit
nothing. The provider does not raise — it returns a truncated body, or
none — and `parse_json_response` hands back the caller's fallback, which
in `SpineSynthesizer._materialise` is one placeholder chapter. Where the
budget ran out *mid*-object, json-repair closes the fragment and the
caller gets chapters whose objectives never arrived: the same failure
wearing a different face.

`blocks/_llm_writer.llm_json` already knew the escape hatch — ask again
with thinking turned down — but only block generators went through it.
The four pipeline agents each parsed their own response and had no retry
at all. `book/json_retry.py` is now the one place that rule lives, and
ideation, both source-explorer calls, all three spine rounds and the
page planner go through it; `llm_json` shares its predicate so the two
cannot drift. Each caller names the key that proves the payload arrived,
which is what lets a repaired-but-gutted object trigger the retry rather
than settle the stage.

`BaseAgent.call_llm` / `stream_llm` gained the `reasoning_effort`
parameter this needs; it was already the shape `llm_text` used.
2026-09-10 22:50:45 +08:00
Bingxi Zhao (Frank)
93df3d48b7 release: v1.6.4
Ship lighter isolated runtimes, richer Books and Mastery flows,
Reading/session polish, and explicit model API capabilities.

Release notes: assets/releases/ver1-6-4.md
2026-09-03 01:38:54 +08:00
Bingxi Zhao (Frank)
6e6e56aedb release: v1.6.3
Ship the breaking front- and back-end runtime and route refactor,
learner and guardian flows, grounded reading, knowledge and parser
updates, and recoverable long-running streams.

Release notes: assets/releases/ver1-6-3.md
2026-09-02 04:09:11 +08:00
XZH
c9920a237c feat(book): infer requested language 2026-08-27 20:27:37 -07:00
Bingxi Zhao (Frank)
bd9f6a7625 release: v1.6.0 — connected learning workspaces
Release notes: assets/releases/ver1-6-0.md

Ship source-faithful reading, Courses and Little Tutor, Ask Questions,
bounded web-source sync, and shared Books with private reader state.
2026-08-27 22:03:09 +08:00
Bukely_
07abbd7326 feat(pageindex): add OSS knowledge bases and reasoning-based retrieval (#907)
Adds PageIndex OSS as a knowledge-base type and moves PageIndex retrieval from traditional RAG to reasoning-based retrieval: a small workflow-owned agent loop reads the document tree instead of going through the built-in MCP server, which this removes.
2026-08-20 00:35:15 +08:00
evan188199-tech
f46e188cdd fix(book): gate KB fingerprint refresh on stale recompilation (#927)
Scope stale-page detection to the KB documents that actually changed, and refuse to clear a drift warning while flagged pages are still awaiting recompilation (force=true overrides, since detection over-marks by design). One walk over raw/ per check, and a fingerprint-scheme tag so changing the formula re-baselines instead of marking every existing book stale.
2026-08-20 00:29:57 +08:00
evan188199-tech
15527bbdab feat(book): add a learning-capture inbox (#926)
Persist captured reading segments per book under learning_captures.json with an explicit status lifecycle, so selections can be reviewed before any downstream export. Follows the existing book storage conventions: a path_service seam, atomic writes, and per-row validation that skips bad entries instead of failing the read.
2026-08-20 00:16:44 +08:00
Bingxi Zhao (Frank)
7c6bcfaef7 release: v1.5.14
Immersive Reading, self-configuration, and a two-way IMA library.

- Immersive Reading: a new capability that opens a document beside the
  thread. New reading engine (PDF pages / slides / page-sized sections),
  five reading tools, a deterministic locate pre-pass that grounds the
  turn without a second LLM call, /api/v1/reading, and a reader pane with
  selection, highlights, notes, and export to an annotated PDF or Markdown.
- Setup capability: inspect the install, apply a setting, install a
  parsing engine, or request a credential from a chat turn. New settings
  spec table; a candidate value is probed before it is committed, and API
  keys never enter the model's context.
- Tencent IMA: pipeline split into transport/envelope/models/sources/
  notes/media/inventory, an additive capability with five tools, and
  connected libraries that can finally be enumerated (bounded listings
  are reported as a lower bound).
- Retrieval: supports_rag_retrieval() replaces is_connected_kb() for the
  "can I sweep this?" question, so linked / lightrag_server / ima sources
  stop being silently dropped from every book.
- Notebooks: their own console at /notebook, per-notebook locks and atomic
  writes, copy / move / export routes, damaged files surfaced instead of
  dropped, and renaming a record no longer clears its knowledge-base link.
- Settings persistence: one lock and one atomic replace shared by every
  writer of interface.json; the PUT endpoints stop writing the
  defaults-merged view back to disk.

Release notes: assets/releases/ver1-5-14.md
2026-08-19 17:34:52 +08:00
Bingxi Zhao (Frank)
96d6df9eb1 release: v1.5.13
Book is the bulk of this one. Compilation outlives the request that
started it, so a bus owned by that request dropped every background event
and "watch your book being written" degraded into a frozen page; the
stream is now owned per book by the process and survives a refresh or a
reconnect. Reading progress is finally recorded — `visited_page_ids` and
`bookmarked_page_ids` had been declared but never written for the life of
the feature — and rolls up into a completion score and weak chapters. A
book can also leave the app now, as one self-contained Markdown document,
with non-ASCII titles surviving the download.

Two scheduling defects that were invisible in production are fixed: the
same page compiled twice concurrently (billed twice, one result
discarded), and a book grinding on through a provider outage until every
chapter was half-generated. The source sweep is bounded and allocated
round-robin rather than spent on the first few knowledge bases, and
retrieval now tells indexed bases from connected pointers, so an Obsidian
vault or a remote IMA library no longer contributes zero while looking
like a source with nothing relevant. Confirming a spine shows a live
per-chapter estimate derived from the Section Architect's own templates.

Also here: three home starter suggestions built from memory recall,
mastery-path handoff moved into one module that changes lease, session
preference, and live turn together, and account-level Tencent IMA
credentials with the per-KB pair still winning.

Notes: assets/releases/ver1-5-13.md

This commit also carries the README prose sync, the eleven translated
READMEs, the release-notes archive sweep, and the version bump. Two gate
fixes ride along: the `Stamped` protocol is declared read-only so the
frozen `EntityStamp` satisfies it, and six GraphRAG adapter tests that
reached a deep `graphrag` import without guarding it now skip like their
four neighbours instead of failing where the extra is not installed.
2026-08-17 11:22:26 +08:00
Bingxi Zhao
0e17712888 fix(book): keep chapter map titles visible (#889) 2026-08-17 02:04:52 +08:00
Bingxi Zhao (Frank)
ef5ce9f952 fix: RAM issues 2026-08-02 13:07:32 +08:00
Bingxi Zhao (Frank)
97632b71fe refactor: land #713/#710/#707 on their proper seams
Follow-up to the three PRs merged for #711, #709 and #707 — same fixes,
moved onto the seam each one belongs to, plus the regression tests they
shipped without.

#711 — partner Codex login. The prefix sniffing lived inside the
credential store, so codex_auth had to know what a partner is. Add
`get_owner_path_service()` next to `get_current_path_service()`, where
scope resolution already lives, and `is_partner_user_id()` next to the
prefix that defines it. codex_auth now just asks for the owner's root.

#709 — missing web/node_modules. Split the side-effecting install out of
`_resolve_frontend()` into `_ensure_web_dependencies()`; the resolver
goes back to resolving, and the launcher's second resolve pass is a
single `Path.exists()`.

#707 — book spine and visualize. The blocking calls bypassed
`BaseAgent.call_llm` for the factory directly, which silently dropped the
image attachments the analysis stage is handed, the trace metadata the
Activity panel renders, and the per-agent api_key/base_url/binding
routing. Route all three through the agent seam; blocking behaviour and
its rationale are unchanged.
2026-07-27 21:23:33 +08:00
Bingxi Zhao (Frank)
294849d1e5 fix(book): rescue PLANNING pages too; contain storage I/O in the worker loop
Follow-up to #636: _mark_page_error now also resets pages stranded at
PLANNING (plan_blocks_async can throw after the status is persisted),
and the background worker's log-append and finalize check are wrapped
so a storage hiccup can neither skip the page reset nor kill the
worker task.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 01:37:47 +08:00
Bingxi Zhao (Frank)
68aa57cff9 fix(book): harden worker-loop error reset — per-iteration page binding + shared best-effort helper
The except handler referenced `page`, which is bound only after the
loaders succeed: a loader failure on the first queue item raised
UnboundLocalError inside the handler and killed the worker task, and on
later iterations the handler could flip the previous iteration's stale
page to ERROR. `page` is now re-bound to None every iteration, both
reset paths share one _mark_page_error helper, and the save is
best-effort so a failing save cannot mask the original error or kill
the worker either. Adds regression tests for the helper's contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 00:56:01 +08:00
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00
Bingxi Zhao (Frank)
b2ce70db69 Merge pull request #500: Guided Learning (mastery-based tutoring subsystem)
New self-contained deeptutor/learning/ subsystem (models, storage, service,
scheduler, grading) + 12-stage guided_learning capability, REST router, and
web learning pages, with 164 tests.

Conflict resolutions:
- services/llm/factory.py: kept dev's stream runner (allow_image_fallback
  multimodal path); dropped the PR's incidental 300s asyncio.wait_for wrapper
  and its now-orphaned TimeoutError handler / unused logger — the blanket
  timeout is unrelated to guided learning, dev already has consumer-side
  timeouts, and 300s would truncate long legitimate streams (book/research).
- web/components/sidebar/WorkspaceSidebar.tsx: kept dev's structure, added a
  useCallback handleNewChat that cancels any in-flight streaming turn before
  newSession() (mirrors handleDeleteSession) and wired it to onNewChat.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:44:05 +08:00
Bingxi Zhao (Frank)
56a87d3f72 Merge pull request #529: Qwen JSON preamble, force-recompile overview pages, health false positives
Book Engine fixes for local/Qwen models: robust JSON parsing, force-recompile
now resets overview pages, regenerate_block finalizes the book, and
scan_log_health no longer flags repeated successes as failures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:36:32 +08:00
unknown
80ccbe9dfb Block 7.5: Practice quiz phase, auto-advance fix, cancel streaming safety
- Add PRACTICE_QUIZ stage between Feynman Check and Error Diagnosis
- Generate 5-10 practice questions per module, record attempts but don't gate mastery
- Fix auto-advance race: move stagesRef updates outside React setState callbacks
- Fix stale handleStreamEvent closure via ref pattern
- Fix PLAN stage permanent deadlock when modules not initialized
- Clear error state unconditionally on new stage_start
- Add cancelStreamingTurn to sidebar and chat page for proper cleanup
- Fix cancelStreamingTurn to handle missing turnId gracefully
- Keep empty page_ids refs for whole-book resolution in guided learning
2026-05-16 11:33:45 +08:00
Bingxi Zhao (Frank)
144c90f3f7 prepare v1.3.4 release
Made-with: Cursor
2026-05-01 13:51:45 +08:00