18 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
f583255ff0 fix(book): snapshot workspace instructions for generation
Fixes #2601
2026-11-15 01:20:52 +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)
c31bed8aeb refactor(llm): one rule for a structured call a reasoning model starved
Four defects this month were the same failure: a step asks a model for a
whole payload in one shot, the model spends its whole max_tokens on
hidden thinking, and the provider returns a truncated body or none at
all — with no error. Book's spine collapsed to a single "Overview"
chapter (#1316), the quiz plan emitted zero templates (#1318), the
non-streaming path handed the scratchpad back as the answer (#1352).

Each fix grew its own retry. Book got `book/json_retry.py`; question got
`LabeledStepResult.reasoning_only`; research got nothing, so its
decompose step still degraded a topic to one sub-topic in silence, and
its report outline still lost the whole report structure.

Moves the rule out of `book/` — it was never Book's — into
`services/llm/structured_retry.py`, and points it at the streaming-side
detector so the two halves read as one rule: two ways to notice a budget
spent on hidden tokens, one remedy, which is to ask again with thinking
turned down.

Applies it to research's two one-shot payloads, which needed the step
wrapper to accept a per-call reasoning effort the way question's already
did.

The generic entry point takes the caller's own `is_usable` rather than
imposing the object shape. Research's decompose accepts a bare array of
sub-topics; judging that unusable would have retried a good answer and
then discarded it — a regression the object-shaped helper would have
caused as the only entry point. The object form still guarantees a dict,
because its callers index the result directly.

6902 passed, 24 skipped.
2026-09-11 12:43:41 +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)
02ba56793e chore: checkpoint backend stabilization workspace 2026-09-01 21:28:15 +08:00
Bingxi Zhao (Frank)
23ead9e6d6 docs(book): reflow the partition_knowledge_bases docstring 2026-08-21 16:13:21 +08:00
evan188199-tech
1413cd8ed0 feat(knowledge): add MarginNote 4 as a connected knowledge base (#931)
* feat(marginnote4): add connected KB type, read-only tools, and sync bridge

Add MarginNote 4 as a connected knowledge base type that syncs study data
(notes, excerpts, cards, mindmap nodes) from MN4 via the official Add-on API
into a dedicated SQLite store, then exposes it to the chat loop through seven
read-only tools.

New package: deeptutor/capabilities/marginnote4/
- models.py: MarginNoteObject, SyncBatch, PairedDevice, LearningEvent
- store.py: SQLite CRUD + search + device pairing with hashed tokens
- binding.py: per-turn resolution of the selected MN4 library
- tools.py: search, read, list, documents, links, tags, cards
- capability.py: KnowledgeCapability (exclusive turn ownership)
- prompts/{en,zh}/system.md

HTTP bridge: deeptutor/api/routers/marginnote4.py
- POST /pair (session auth) -- register a device, get one-time token
- POST /sync (device-token auth) -- incremental upsert + tombstones
- POST /heartbeat (device-token auth) -- liveness + object count
- GET /devices, DELETE /devices/{id}, GET /status (session auth)

Integration points:
- kb_types.py: MARGINNOTE4_KB_TYPE added to CONNECTED_KB_TYPES
- manager.py: db_path surfaced in get_metadata allowlist
- registry.py: MarginNoteCapability registered in LOOP_CAPABILITIES
- builtin/__init__.py: MARGINNOTE_TOOL_TYPES in BUILTIN_TOOL_TYPES
- api/main.py: router mounted at /api/v1/marginnote4

Phase 1 scope: device pairing, read-only sync, tool navigation.
Write-back (propose/apply/verify), learning events, and mastery bridge
are planned for Phase 2-3.

Refs: #756 (Obsidian external knowledge source pattern), #180

* fix(marginnote4): search scope, store caching, prompts, KB registration

Testing and experience improvements:

- Search now includes document_title in scope: searching for a textbook
  name returns results instead of zero hits
- Store instances cached by db_path so schema init runs once, not per
  tool call within a turn
- object_type parameters carry enum constraints so the LLM knows valid
  types without guessing
- System prompts (en/zh) rewritten with domain context: explains the
  five object types, link traversal strategy, and citation guidance
- KB registration: register_marginnote4_kb manager method +
  /connect-marginnote4 API endpoint, mirroring the Obsidian connect flow
- Fix indentation inconsistencies in manager.py and main.py
- New tests: document_title search scope, KB registration (create,
  default path, duplicate rejection)

65 tests pass, 0 regressions, ruff clean.

* style(marginnote4): apply repository formatter

* fix(marginnote4): keep MN4 libraries out of the rag_search sweep

``MARGINNOTE4_KB_TYPE`` joined ``CONNECTED_KB_TYPES`` but not
``NON_RETRIEVABLE_KB_TYPES``, so ``supports_rag_retrieval`` answered true
for a library that has no index and no retrieval API — its objects live
in ``mn4_objects`` and are reachable only through the seven
``marginnote_*`` tools. Book's source explorer would have swept it,
gotten nothing back, and reported it as a source with no relevant
content rather than one that needs its own tools.

MN4 belongs with ``obsidian`` and ``subagent``, not with ``linked`` /
``lightrag_server`` / ``ima``, which do resolve to an index or an HTTP
retrieval API. Tests pin both halves of that split, since collapsing it
the other way has cost Book its connected sources before.

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: evan <evan@dazongguandeMac-mini.local>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
2026-08-21 16:10:22 +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
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 (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
generalthunder15
233cc14eee fix: book creation timeout and spine single-chapter fallback (#707)
* fix(web): use WebSocket for book creation to avoid proxy timeout

* fix(book): stabilize spine synthesis with non-streaming LLM

* fix(web): use WebSocket for regenerate-block to avoid proxy timeout

* fix(visualize): use non-streaming LLM to avoid reasoning truncation in analysis/code generation

---------

Co-authored-by: raidenShogun <18191371014@163.com>
2026-07-27 20:54:53 +08:00
Bingxi Zhao (Frank)
824bf778df fix: lint & logging system 2026-05-01 01:39:08 +08:00
Bingxi Zhao (Frank)
77f29cbcc7 fix lint 2026-04-23 19:29:16 +08:00
Bingxi Zhao (Frank)
2745e8bde9 feat(book): introduce book capability and restructure guide/co_writer modules
- Add new `deeptutor/book/` module with multi-agent pipeline
  (ideation, spine, page planner, source explorer, synthesizer)
  and rich block system (text, code, figure, quiz, flash cards,
  callout, deep dive, timeline, animation, concept graph, etc.)
- Add `/api/routers/book.py` and `deeptutor_cli/book.py` entry points
- Add web UI under `web/app/(workspace)/book/` with sidebar,
  chat panel, page reader, spine editor, progress timeline, and
  block renderers
- Move `deeptutor/agents/co_writer` -> `deeptutor/co_writer` and
  `deeptutor/agents/guide` -> `deeptutor/guide` (then remove guide
  entirely now superseded by book)
- Remove legacy guide UI, hooks, types, and API router
- Update visualize agents/prompts, notebook service, prompt manager,
  session turn runtime, and shared services to support new flows
- Refresh chat composer, sidebar, notebook selector, and locales

Made-with: Cursor
2026-04-20 00:33:33 +08:00