Skip to content

Feat/v1#1

Merged
kooksee merged 37 commits intomainfrom
feat/v1
May 10, 2026
Merged

Feat/v1#1
kooksee merged 37 commits intomainfrom
feat/v1

Conversation

@kooksee
Copy link
Copy Markdown
Contributor

@kooksee kooksee commented May 10, 2026

No description provided.

kooksee and others added 30 commits May 7, 2026 20:42
- 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.
@kooksee kooksee merged commit 5756de9 into main May 10, 2026
1 check failed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/logseq/db.go
Comment on lines +22 to +23
clientLimit, _ = strconv.Atoi(m[1])
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

使用正则表达式直接从 Datalog 查询字符串中移除 :limit:order-by 存在风险。如果查询的字符串字面量中包含这些关键词(例如 [:find ?b :where [?b :block/content ":limit 5"]]),它们会被错误地替换,导致查询逻辑失效。

Comment thread cmd/e2e/main.go
Comment on lines +296 to +303
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 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

构建 CLI 二进制文件时未使用超时控制。如果 go build 过程因环境问题挂起,将导致整个测试流程无限期阻塞。建议使用 exec.CommandContext 并设置合理的超时时间。

Comment thread cmds/llm_safety.go
Comment on lines +86 to +94
func setAppendSafeRecord(key string, rec appendSafeRecord) {
k := strings.TrimSpace(key)
if k == "" {
return
}
appendSafeStoreMu.Lock()
defer appendSafeStoreMu.Unlock()
appendSafeStore[k] = rec
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

appendSafeStore 是一个全局内存 Map,在长运行的 MCP Server 模式下会无限制增长,存在内存溢出风险。建议增加简单的容量限制以保证稳定性。

Suggested change
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
}

Comment thread internal/webui/server.go

if open {
go func() {
time.Sleep(250 * time.Millisecond)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

硬编码的 time.Sleep 无法保证服务器已完全启动并开始监听端口,存在竞态条件。在系统负载较高时,250ms 可能不足以让服务器 Ready。

Comment thread pkg/logseq/tags.go
return true
}

func isJournalName(v string) bool {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

isJournalName 仅支持 YYYY-MM-DD 等固定格式。由于 Logseq 允许用户自定义日记页面的日期格式(如 MMM do, yyyy),这种硬编码检查会导致 GetAllTags 在非标准配置下将日记页面误判为普通标签。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant