Skip to content

refactor(utils): move Ink-bound helpers out of utils/ (utils split 1/6) - #2155

Merged
will-lamerton merged 1 commit into
mainfrom
refactor/utils-layout
Nov 12, 2026
Merged

will-lamerton merged 1 commit into
mainfrom
refactor/utils-layout

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

First of a short series that splits source/utils/ (≈100 modules) by domain and then enforces layering. This PR moves the Ink/React modules out of utils/. It only moves files and updates imports; no logic changes.

Target layout (whole series)

Names follow directories that already exist. The only new top-level ones are conversation/, input/ and terminal/.

Destination What goes there PR
components/ Ink-bound helpers other layers render through: message-factory.ts, message-queue.tsx, tool-result-display.tsx this PR
hooks/chat-handler/conversation/ streaming-bash-tool.tsx, whose only caller is tool-executor.tsx this PR
tools/file-ops/ Helpers used only by the file editors: inline-diff.tsx (this PR), then edit-recovery, literal-replace, line-endings, path-validators, programming-language-helper 1, 3
conversation/ (+ conversation/compaction/) Framework-free conversation primitives shared by the TUI, --plain, ACP and subagents: prompt-builder, message-builder, message-capping, message-visibility, run-outcome, completion-note; compaction: auto-compact*, compression-backup, message-compression, llm-summariser, inline-overrides 2
tools/runtime/ Tool-call runtime: tool-approval*, tool-confirm-queue, tool-args-parser, tool-call-id, tool-cancellation, tool-validation, schema-validate, truncate-tool-result, read-tracker, question-queue 3
utils/fs/ Filesystem: atomic-write, exclusive-file-lock, write-unique-file, file-cache, derived-content, gitignore-loader, file-search, ripgrep-path, file-tree, file-type-detector, path-validation, path, load-md-dir, ensure-nanocoder-gitignore, glob-match 4
input/ Ink-free prompt-input model behind components/composer/: placeholders, paste-*, atomic-deletion, prompt-processor, file-mention-handler, file-content-loader, resource-mention-handler, file-autocomplete, clipboard-image 5
terminal/ Terminal protocol and text rendering: terminal-*, newline-key, highlighter, text-wrapping, ansi-truncate, indentation-normalizer, shell-command-display 5
services/ checkpoint-utils, update-checker + installation-detector, notifications 5
utils/ (what stays) Generic leaf helpers: logging/, shutdown/, error-formatter, message-queue-core, global-handler-slot, type-helpers, backoff, bounded-map, truncate-text, frontmatter, fuzzy-matching, shell-args, url-utils, package-version, process-tree, stream-collector, template-sections, token-calculator, ... —
lint rule utils/, types/ and config/ may not import components/, hooks/, tools/, mcp/ or session/. Remaining violations are fixed, or allowlisted with a comment. 6

Modules that find their own location at runtime (prompt-builder reads ../../source/app/prompts/sections, package-version, notifications, installation-detector) only move to directories at the same depth.

This PR

  • utils/tool-result-display.tsx, utils/message-factory.ts, utils/message-queue.tsx → components/
  • utils/streaming-bash-tool.tsx → hooks/chat-handler/conversation/
  • utils/inline-diff.tsx → tools/file-ops/
  • Their specs move with them (git mv, so history follows).
  • message-queue.tsx only re-exports message-queue-core and adds setGlobalMessageQueue, the Ink renderer. Every caller that used just the re-exported names (notify*, addToMessageQueue, setMessageQueueSink) now imports @/utils/message-queue-core directly. The functions are the same objects, so behaviour does not change, but services, lsp/, firewall/, plugins/, stats/, tools/tool-manager.ts and others no longer load components/message-box (Ink) just to log. Only App.tsx and four specs still import components/message-queue.
  • CLAUDE.md: the state-management paragraph now cites the new paths, and Key Directories gains a utils/ line.

Testing

  • tsc --noEmit, biome check on the changed files (import order re-sorted by biome only)
  • knip and knip --production --include files: clean
  • Full AVA suite, including config/no-ink-fast-paths.spec.ts

🤖 Generated with Claude Code

Move tool-result-display, message-factory and message-queue.tsx to
components/, streaming-bash-tool to hooks/chat-handler/conversation/ and
inline-diff to tools/file-ops/. Callers that only use names
message-queue.tsx re-exports from message-queue-core now import the core
module directly, so they stop loading Ink to log. No logic changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

No changeset found

This PR does not add a changeset, so it will not appear in the changelog or trigger a release.

If the change is user-facing, add one:

pnpm changeset

Pick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated .changeset/*.md file.

If this PR is docs-only or a chore that needs no release note, you can ignore this — or run pnpm changeset --empty to record that intentionally.

@github-actions github-actions Bot added area:tools Tool implementations and tool-calling area:tui Terminal UI labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit unknown). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit unknown). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

@will-lamerton
will-lamerton merged commit 6d6dc94 into main Nov 12, 2026
18 of 20 checks passed
@will-lamerton
will-lamerton deleted the refactor/utils-layout branch November 12, 2026 01:05
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
…e#2155)

Move tool-result-display, message-factory and message-queue.tsx to
components/, streaming-bash-tool to hooks/chat-handler/conversation/ and
inline-diff to tools/file-ops/. Callers that only use names
message-queue.tsx re-exports from message-queue-core now import the core
module directly, so they stop loading Ink to log. No logic changes.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
diyaavirmani added a commit to diyaavirmani/nanocoder that referenced this pull request Nov 16, 2026
Conflicts with on-demand MCP discovery (Nano-Collective#1651, Nano-Collective#2052, Nano-Collective#2057):
- tool-manager.ts: kept discovery, the catalog and outage recovery, with
  this branch's registration rule on every path. A name a built-in,
  custom or skill tool has is skipped from the catalog too, so
  load_tool_schema can't offer the MCP schema for it, and loadMcpTool
  won't claim it. Tools loaded on demand are tracked, so an outage or a
  disconnect removes them and never the built-in.
- daemon/entry.ts, plain/initialize.ts: pass upstream's tune config and
  keep the skipped-tools warning.
- Specs: kept both sides; setGlobalMessageQueue moved to
  @/components/message-queue (Nano-Collective#2155), and the custom-tools stand-in
  client now maps its tool, which initializeMCP reads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tools Tool implementations and tool-calling area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant