Skip to content

feat(agent): arrange_notes tool for on-demand layout - #257

Merged
winlp4ever merged 2 commits into
mainfrom
feat/agent-arrange-tool
Aug 26, 2026
Merged

feat(agent): arrange_notes tool for on-demand layout#257
winlp4ever merged 2 commits into
mainfrom
feat/agent-arrange-tool

Conversation

@winlp4ever

Copy link
Copy Markdown
Contributor

PR of the board-authoring plan (docs/plans/agent-board-authoring-tools.md §4, S6). Stacked on #256 (→ #255#253#250) — merge those first.

What

A new arrange_notes(note_ids?) tool: tidy notes into a clean auto-layout on demand. Pass ids to arrange just those; omit to tidy the whole current board/folder. Renders as a visible "Arranged N notes" step.

Key behavior: in place, not relocated

The post-turn create-arrange drops a new cluster beneath existing content. Re-tidying existing notes shouldn't move the whole cluster elsewhere — so arrangeNodesInPlace lays them out and keeps the cluster centered where it already sits. (Same mindmap→dagre engine, different translate.)

How

  • Factored the shared layout step (layoutNodes) out of arrangeCreatedNodes; added arrangeNodesInPlace (returns the count moved; no-op for < 2).
  • New arrange_notes tool → agentBuildTools; writes go through the current-layer store (sync-correct, same as create-arrange).
  • Wired the stream ToolName/label/icon maps, a readable agent-event-to-step output ("Arranged N notes"), and the system-prompt tool list so the agent discovers it.

Scope

v1 uses the existing single layout (mindmap-first, dagre fallback); the tree/grid/flow strategy variants from §4 are deferred. Current-layer only (cross-layer arrange is the S7 headless-emit concern).

Tests

arrangeNodesInPlace: tidies while keeping the cluster centered (not shoved beneath); no-op for < 2. arrange_notes tool: arranges given ids / whole view, reports count. agent-event-to-step: readable "Arranged N notes" output. check-all clean; agent + arrange suites green (567).

@winlp4ever
winlp4ever force-pushed the feat/agent-relational-placement branch from ad125e8 to 7c4e1d3 Compare August 26, 2026 07:56
@winlp4ever
winlp4ever force-pushed the feat/agent-arrange-tool branch from a20d486 to 47f14c1 Compare August 26, 2026 07:56
@winlp4ever
winlp4ever force-pushed the feat/agent-relational-placement branch from 7c4e1d3 to 4f04cfb Compare August 26, 2026 12:04
@winlp4ever
winlp4ever force-pushed the feat/agent-arrange-tool branch from 47f14c1 to 696aac6 Compare August 26, 2026 12:04
@winlp4ever
winlp4ever force-pushed the feat/agent-relational-placement branch from 4f04cfb to 9bf4ecb Compare August 26, 2026 12:06
@winlp4ever
winlp4ever force-pushed the feat/agent-arrange-tool branch from 696aac6 to b01a946 Compare August 26, 2026 12:06
Expose the layout engine as a tool: arrange_notes(note_ids?) tidies the given
notes — or the whole current layer when omitted — into a clean mindmap/dagre
layout. Unlike the post-turn create-arrange (which drops a new cluster beneath
existing content), it reorganizes IN PLACE, keeping the cluster centered where
it already sits, so re-tidying doesn't relocate the board.

Factors the shared layout step (layoutNodes) out of arrangeCreatedNodes and
adds arrangeNodesInPlace. Wires the tool into agentBuildTools, the stream
ToolName/label/icon maps, a readable 'Arranged N notes' step output, and the
system prompt's tool list. S6 of the board-authoring plan.
- Revert the near-anchor arrange-exclusion: pinning a same-turn auto anchor
  fragmented a mindmap rooted at it (root dropped from the layout, edges
  stranded). Arrange now runs on all auto nodes; `near` is for stable/existing
  anchors (anchoring to a same-turn auto node is the deferred pinned-aware case).
- arrangeNodesInPlace re-reads nodes after the async layout and drops any
  removed concurrently, so the write-back can't throw on a missing node.
- link_notes errors (no dangling edge at 0,0) when an endpoint doesn't exist
  in the current layer.
- arrange_notes caps a whole-view arrange (MAX_ARRANGE) so a huge board isn't
  mass-relocated / re-laid-out in one shot; steer toward passing note_ids.
- offsetToOrigin uses a reduce, not Math.min spread, over a possibly large
  cluster (call-argument-limit safety).
@winlp4ever
winlp4ever force-pushed the feat/agent-arrange-tool branch from b01a946 to 2eee322 Compare August 26, 2026 12:08
@winlp4ever
winlp4ever changed the base branch from feat/agent-relational-placement to main August 26, 2026 12:08
@winlp4ever
winlp4ever merged commit 97de452 into main Aug 26, 2026
5 checks passed
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