feat: add note_manager — create/get/list notes via API#8
feat: add note_manager — create/get/list notes via API#8
Conversation
Add note_manager.py to manage YouMind notes (thoughts) via API: - create: POST /api/v1/createThoughtWithPlain — plain text, optional title/board - get: POST /api/v1/getThought — fetch note by ID - list: POST /api/v1/listThoughts — list all notes in the space Also add Note API methods to api_client.py and update SKILL.md docs.
…napi Adds support for creating craft documents (type: page, the rich-text Document type in YouMind's board UI), distinct from plain notes (type: note). ## Changes ### scripts/api_client.py - Added create_craft(board_id, content_plain, title) method - Uses POST /openapi/v1/createDocument which accepts plain text content and converts to Yjs format server-side (same pattern as createThoughtWithPlain) - Returns PageDto with type='page' ### scripts/note_manager.py - Added create-craft subcommand - --content, --title, --board-id (required) flags ### SKILL.md - Added Note vs Craft explanation (type: note vs type: page) - Added Craft Document Commands section with usage examples ## Background createThoughtWithPlain (POST /api/v1/createThoughtWithPlain) always creates type='note'. To create a craft document (type='page'), use POST /openapi/v1/createDocument with content as a plain text string — the OpenApiContentInterceptor handles Yjs conversion server-side. Verified locally against production API — returns PageDto with type='page'.
新增:
|
…64.mjs)
Previously create_craft() sent plain text to /openapi/v1/createDocument without
proper Yjs conversion, causing markdown to render as raw text (## not a heading,
| table | not a table).
## Root Cause
- POST /api/v1/createPage expects content: { raw: <yjs-base64>, plain: string }
- The Yjs binary requires running the full tiptap + y-prosemirror pipeline
- /openapi/v1/createDocument has no @OpenApiContentFields decorator on createPage,
so the OpenApiContentInterceptor does NOT convert plain text to Yjs
## Fix: client-side markdown → Yjs conversion
Added scripts/md_to_base64.mjs — a Node.js script that runs locally:
Markdown → HTML (markdown-it) → Tiptap JSON (@tiptap/html) → Yjs binary (y-prosemirror) → base64
create_craft() now:
1. Calls md_to_base64.mjs via subprocess with the markdown content
2. Uses the resulting Yjs base64 as content.raw
3. Calls POST /api/v1/createPage directly with { raw, plain }
## Supported markdown elements
- Headings (h1-h6)
- Bold, italic, strikethrough
- Bullet/ordered lists
- Tables
- Code blocks and inline code
- Blockquotes
- Horizontal rules
Verified locally — renders correctly in YouMind board editor.
路径 B 实现:客户端 Markdown → Yjs 转换上一个 commit 修复了 markdown 不渲染的问题。 根本原因
解决方案新增
渲染效果(截图验证)标题、加粗/斜体、列表、表格、引用块、代码块全部正常渲染。 备选方案(如果 p697 愿意改后端):在 |
Summary
Add
note_manager.pyto support creating and reading YouMind notes (thoughts) via API.Changes
scripts/note_manager.py(new)create— create a note with plain text content, optional title and board association (POST /api/v1/createThoughtWithPlain)get— fetch a note by ID (POST /api/v1/getThought)list— list all notes in the space (POST /api/v1/listThoughts)scripts/api_client.pycreate_note(),get_note(),list_notes()methodsSKILL.mdUsage
Verified
Tested locally against production API — returns
NoteDtowithtype: "note"as expected.