feat(cli): add agent bridge diagnostics and lifecycle logging#12682
Merged
Conversation
56435f7 to
ec8dc54
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an “AgentBridge” workflow to the Logseq CLI for routing assigned tasks/comments to an external agent (Codex), while also improving db-worker-node diagnostics by centralizing lifecycle + stdio logging and adding richer server restart mismatch logs. It also extends the frontend DB schema/migrations and e2e coverage to support the new persisted :logseq.property.agent/session-id field.
Changes:
- Add
logseq agent bridge/logseq agent bridge listcommands, prompt-template initialization, session recording, and event-driven routing. - Add unified db-worker-node logging (
logseq.db-worker.log) and wire it into daemon spawning and db-worker-node startup logging. - Extend DB schema/migrations and tests to add
AssigneeandAgent Session IDbuilt-in properties, plus CLI docs + e2e workflows.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/logseq/db_worker/daemon_test.cljs | Extends spawn tests to assert detached stdio redirection env + fd-based stdio config. |
| src/test/logseq/cli/server_test.cljs | Asserts restart-version-mismatch info logging via glogi handler capture. |
| src/test/logseq/cli/command/agent_test.cljs | Adds comprehensive unit tests for agent bridge parsing, routing, prompts, sessions, and event handling. |
| src/test/frontend/worker/migrate_test.cljs | Adds migration test for schema 65.31 creating agent/session-id property and migrate-updates. |
| src/test/frontend/worker/db_worker_node_test.cljs | Updates tests to use unified log module; adds tests for version/stdio logging and retention. |
| src/resources/dicts/zh-cn.edn | Adds :property.built-in/assignee translation. |
| src/resources/dicts/en.edn | Adds :property.built-in/assignee translation. |
| src/main/logseq/db_worker/log.cljs | New unified db-worker-node logging module (file log output + stdio/console wrapping + retention + child stdio helper). |
| src/main/logseq/db_worker/daemon.cljs | Uses unified child stdio redirection for detached db-worker-node spawn; sets env marker. |
| src/main/logseq/cli/server.cljs | Adds structured info log for restart version mismatch before stopping mismatched servers. |
| src/main/logseq/cli/format.cljs | Adds error hints + human formatting for agent bridge logs and session listing. |
| src/main/logseq/cli/commands.cljs | Registers agent command entries; wires agent actions to execution. |
| src/main/logseq/cli/command/core.cljs | Adds agent to top-level utilities group and help description overrides. |
| src/main/logseq/cli/command/agent.cljs | New agent bridge implementation (task/comment routing, prompt templates, Codex invocation, session store, event listener). |
| src/main/frontend/worker/db/migrate.cljs | Adds schema updates 65.30/65.31 for new built-in properties. |
| src/main/frontend/worker/db_worker_node.cljs | Installs unified logging at startup; logs build version; uninstalls on stop. |
| docs/agent-guide/logseq-cli/001-logseq-cli.md | Documents agent bridge command surface and behavior. |
| deps/db/test/logseq/db/frontend/property_test.cljs | Adds property definition tests for Assignee and Agent Session ID. |
| deps/db/src/logseq/db/frontend/schema.cljs | Bumps DB schema version to 65.31. |
| deps/db/src/logseq/db/frontend/property.cljs | Adds built-in Assignee and Agent Session ID property definitions; includes logseq.property.agent namespace. |
| cli-e2e/spec/non_sync_inventory.edn | Registers agent commands/options in CLI non-sync inventory. |
| cli-e2e/spec/non_sync_cases.edn | Adds non-sync e2e cases covering agent bridge workflows and prompt-template graph isolation. |
| cli-e2e/scripts/agent_bridge_e2e.py | New Python harness for fake Codex + agent bridge end-to-end checks. |
| cli-e2e/scripts/agent_bridge_demo.sh | New shell demo script validating live bridge routing and writeback with a fake Codex. |
| .agents/skills/logseq-review-workflow/SKILL.md | Updates the review workflow skill to subagent-based pass orchestration and migration contract emphasis. |
| .agents/skills/logseq-review-workflow/rules/README.md | Notes pass rule files under passes/. |
| .agents/skills/logseq-review-workflow/rules/passes/test-coverage.md | New subagent pass guidance for test coverage review. |
| .agents/skills/logseq-review-workflow/rules/passes/subagent-output.md | New output contract for pass subagents. |
| .agents/skills/logseq-review-workflow/rules/passes/repository-convention.md | New repository convention pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/regression.md | New regression pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/performance.md | New performance pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/migration-validation.md | New migration-validation pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/failure-mode.md | New failure-mode pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/data-contract.md | New data-contract pass definition. |
| .agents/skills/logseq-review-workflow/rules/passes/correctness.md | New correctness pass definition. |
| .agents/skills/logseq-cli/SKILL.md | Updates CLI skill docs to include agent bridge tips and command list. |
Comments suppressed due to low confidence (1)
src/main/frontend/worker/db_worker_node.cljs:578
start-daemon!installs the db-worker log wrappers early, but in thep/catcherror path it only removes the lock and rethrows. If startup fails afterdb-worker-log/install!(e.g. lock acquisition / DB init error), the wrappedconsole/*print-fn*/process streams can remain installed for the rest of the process lifetime (including subsequent retries/tests). Consider ensuringdb-worker-log/uninstall!runs on startup failure (e.g. in thep/catchor viap/finally).
(db-worker-log/install! {:root-dir root-dir
:repo repo
:log-level (keyword (or log-level "info"))})
(log/info :db-worker-node-version {:build-time (build-version/build-time)
:revision (build-version/revision)})
(reset! *ready? false)
(reset! *lock-info nil)
(reset! *server-list-file server-list-file)
(set-main-thread-stub!)
(-> (p/let [platform (platform-node/node-platform {:root-dir root-dir
:event-fn handle-event!
:write-guard-fn assert-lock-owner!
:owner-source owner-source
:recreate-lock-fn recreate-lock!})
proxy (db-core/init-core! platform)
_ (<init-worker! proxy)
{:keys [path lock]} (db-lock/ensure-lock! {:root-dir root-dir
:repo repo
:owner-source owner-source})
_ (reset! *lock-info {:path path :lock lock})
_ (let [method-kw :thread-api/create-or-open-db
method-str (normalize-method-str method-kw)]
(<invoke! proxy method-str method-kw [repo (startup-db-opts opts)]))]
(start-http-server! {:proxy proxy
:repo repo
:host host
:port port
:owner-source owner-source
:root-dir root-dir
:on-stopped! on-stopped!}))
(p/catch (fn [e]
(when-let [lock-path (:path @*lock-info)]
(db-lock/remove-lock! lock-path))
(throw e)))))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (or (.-stack value) (.-message value) (str value)) | ||
|
|
||
| (and value (fn? (.-toString value))) | ||
| (.toString value (or encoding "utf8")) |
Comment on lines
+1055
to
+1077
| (defn- show-task-tree | ||
| [cfg repo block] | ||
| (p/let [show-result (show-command/execute-show {:type :show | ||
| :repo repo | ||
| :uuid (block-uuid-str block) | ||
| :level 100 | ||
| :linked-references? false | ||
| :ref-id-footer? false} | ||
| cfg)] | ||
| (or (get-in show-result [:data :message]) | ||
| (:block/title block)))) | ||
|
|
||
| (defn- show-block-tree | ||
| [cfg repo block] | ||
| (p/let [show-result (show-command/execute-show {:type :show | ||
| :repo repo | ||
| :uuid (block-uuid-str block) | ||
| :level 100 | ||
| :linked-references? false | ||
| :ref-id-footer? false} | ||
| cfg)] | ||
| (or (get-in show-result [:data :message]) | ||
| (:block/title block)))) |
Comment on lines
+1027
to
+1037
| (defn- pull-assignee-property | ||
| [cfg repo] | ||
| (transport/invoke cfg :thread-api/pull [repo assignee-property-selector assignee-property-ident])) | ||
|
|
||
| (defn- resolve-assignee-datoms | ||
| [cfg repo tx-data] | ||
| (let [direct-datoms (filter direct-assignee-datom? tx-data) | ||
| unknown-attr-datoms (filter unknown-attr-datom? tx-data)] | ||
| (if (seq unknown-attr-datoms) | ||
| (p/let [property (pull-assignee-property cfg repo) | ||
| property-id (:db/id property)] |
26e9818 to
b960190
Compare
b960190 to
b6b182f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db-worker-nodeand CLI server lifecycle logging for startup version, restart mismatch details, and exit reasons.Testing
bb dev:test -v logseq.cli.command.agent-test/test-agent-bridge-built-in-propertiesbb dev:test -v frontend.worker.migrate-test/migrate-65-31-adds-agent-session-id-propertybb dev:test -v frontend.worker.migrate-testbb dev:test -v logseq.cli.command.agent-testgit diff --checklogseq-clicompiled successfully.