Conversation
- Add go.mod and go.sum for dependency management. - Implement main entry point for the CLI with command options for Logseq API. - Create logseq package with client and API methods for interacting with Logseq. - Implement page and block operations including create, delete, update, and query functionalities. - Add types for pages, blocks, and search results to facilitate API responses.
- Introduced `webui` command to start a simple web UI for Logseq data operations. - Updated README.md to include `webui` command details. - Implemented web UI server with endpoints for health check, connection info, page management, block operations, and querying. - Added HTML interface for user interactions with Logseq data. - Integrated automatic browser opening option when starting the web UI.
- Implemented `page current` command to retrieve the currently focused page. - Added `page current-tree` command to get the block tree of the currently focused page. - Introduced `page journal` command for creating journal pages with optional date input. - Enhanced `tag` commands with `get`, `search`, `create`, `objects`, and property management operations. - Added support for tag relations and block-tag operations. - Created property management commands for listing, getting, upserting, and removing property schemas. - Updated documentation to reflect new commands and their usage. - Added CI workflows for quick checks and end-to-end smoke tests.
- Implemented journal page creation with optional date input. - Added block utility operations including fetching current and selected blocks, clearing selections, generating UUIDs, and navigating sibling blocks. - Enhanced tag and property management with new operations for creating, querying, and managing relationships. - Introduced graph state management capabilities for reading and writing state values.
…nd idempotency support - Implemented `page append-safe <name> <content>` command to safely append blocks to pages. - Added options for dry-run, confirmation, and idempotency key to prevent duplicate writes. - Introduced capability probing command `capabilities get` to check runtime capabilities for LLM/MCP orchestration. - Enhanced documentation for new commands and capabilities. - Created unified response envelope structure for all commands. - Implemented safety checks for write operations to ensure controlled writing risks. - Added search-notes command for structured search with pagination and filtering options.
- Implemented property management endpoints: list, get, upsert, and remove. - Added query handling for Datalog and DSL. - Developed search functionality with keyword filtering and tag support. - Created tag management endpoints: list, get, create, and manage relations. - Added unit tests for limit and order-by regex handling, as well as JSON unmarshalling for search blocks and results.
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Go CLI and SDK for the Logseq HTTP API, featuring MCP integration, a WebUI, and safety mechanisms like dry-runs and confirmation prompts for LLM-driven operations. While the implementation is robust, several improvements are recommended: the regex-based query stripping in db.go should be more context-aware to avoid breaking queries with keyword literals, and the E2E build process requires timeout controls. Additionally, the global idempotency store in llm_safety.go needs a capacity limit to prevent memory leaks, the WebUI startup should use a more reliable synchronization method than hardcoded sleeps, and the journal detection logic should be flexible enough to handle custom Logseq date formats.
| clientLimit, _ = strconv.Atoi(m[1]) | ||
| } |
| cmd := exec.Command("go", "build", "-o", binPath, ".") | ||
| cmd.Dir = workDir | ||
| cmd.Env = os.Environ() | ||
|
|
||
| var stderr bytes.Buffer | ||
| cmd.Stderr = &stderr | ||
|
|
||
| if err := cmd.Run(); err != nil { |
| func setAppendSafeRecord(key string, rec appendSafeRecord) { | ||
| k := strings.TrimSpace(key) | ||
| if k == "" { | ||
| return | ||
| } | ||
| appendSafeStoreMu.Lock() | ||
| defer appendSafeStoreMu.Unlock() | ||
| appendSafeStore[k] = rec | ||
| } |
There was a problem hiding this comment.
appendSafeStore 是一个全局内存 Map,在长运行的 MCP Server 模式下会无限制增长,存在内存溢出风险。建议增加简单的容量限制以保证稳定性。
| func setAppendSafeRecord(key string, rec appendSafeRecord) { | |
| k := strings.TrimSpace(key) | |
| if k == "" { | |
| return | |
| } | |
| appendSafeStoreMu.Lock() | |
| defer appendSafeStoreMu.Unlock() | |
| appendSafeStore[k] = rec | |
| } | |
| func setAppendSafeRecord(key string, rec appendSafeRecord) { | |
| k := strings.TrimSpace(key) | |
| if k == "" { | |
| return | |
| } | |
| appendSafeStoreMu.Lock() | |
| defer appendSafeStoreMu.Unlock() | |
| if len(appendSafeStore) > 1000 { | |
| for k := range appendSafeStore { | |
| delete(appendSafeStore, k) | |
| break | |
| } | |
| } | |
| appendSafeStore[k] = rec | |
| } |
|
|
||
| if open { | ||
| go func() { | ||
| time.Sleep(250 * time.Millisecond) |
| return true | ||
| } | ||
|
|
||
| func isJournalName(v string) bool { |
No description provided.