Repository navigation
Let AI chats search and read notes - #45
Merged
Merged
Conversation
WorkspaceEngine::is_visible_file checks a workspace path the way the index and the file tree do. It fails for a path that leaves the workspace or names a reserved folder. It returns false for dot files and dot folders, node_modules and target at the top, and anything the Ignored files list matches, including through a parent folder. The AI note tools use it to keep ignored files away from the model.
A plain chat offered only the plugins' tools, Tasks and Projects, so the AI couldn't answer from your notes. Noura's own tools reached only Orb runs. workspace-tools listed plugin tools alone, and run-tools refused a noura__ call in any run without an Orb. Every chat now offers three note tools beside the plugins' tools: - noura__search_notes searches titles and text through the search index. It returns 10 hits by default and 20 at most, with more: true when it left some out. - noura__list_notes lists the folders and Markdown files directly in one folder, up to 200 entries. - noura__read reads a Markdown file by title, link or path. A body over 40,000 characters ends with "[Noura cut the rest.]" and truncated: true. They only read. Their targets set the read_only flag that #43 added for a plugin's read-only tools, so their calls run without the prompt whether or not Ask before the AI changes your workspace is on. The tools write nothing, so there are no note-writing tools for chats. app-core's ai/notes.rs holds the tools, and Orbs now get them from the same place. noura__read keeps its link argument for Orb files that list it, and search and list respect an Orb's reads. local-core checks every path, so traversal, absolute paths, reserved folders and symlinks fail. The tools leave out dot files and ignored files, and search and listings leave out chats, so a chat doesn't find its own question. Noura's chat instructions now call tool results untrusted data. The AI page names the rows Searched notes, Listed notes and Read a note. The WIT comments on workspace-tools and run-tools, the frozen copy, the reference, the ai interface page, the runtime notes and the Orb format list the tools. The ai interface page and the runtime notes also now say that read-only calls skip the prompt, as #43 made them. Tests: an app-core chat offers the tools, finds a note by its text, leaves out ignored files and its own chat, caps hits at 20, reads by link or path, refuses traversal, absolute and reserved paths, ignored files and symlink escapes, and cuts a long note. An Orb's search stays inside its reads. An egui_kittest test has a fake model search, read and answer from the note, with no prompt and both rows Done.
The real host's workspaceTools now ends with noura__search_notes, noura__list_notes and noura__read, so the kit's same-results test failed on the mock host, which offered only the plugin's own tools. The mock host now offers the same three after the plugin's tools. The probe plugin's ai-note-tools call returns the note tools' full definitions. The same-results test checks that the real host returns the same names, descriptions and schemas as the mock host, so the mock's copy can't drift from app-core's. The ai interface page says what the mock host's workspaceTools returns.
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.
A plain chat could call only the plugins' tools, Tasks and Projects. Reading notes was a kernel tool,
noura__read, that only Orb runs got:workspace-toolsreturned plugin tools alone, andpending_callsrefused anoura__call in any run without an Orb. You couldn't ask a chat "what did we decide in Thursday's review?"What changed
Every chat now offers three note tools beside the plugins' tools:
noura__search_notessearches titles and text through the existing search index.noura__list_noteslists the folders and Markdown files directly in one folder.noura__readreads a Markdown file by title, link or path and returns its title, path, properties and body.They live in
crates/app-core/src/ai/notes.rs. Orbs now get the same three from there, so Orbs gain search and list, and an Orb'sreadslimit what all three show it.noura__readkeeps itslinkargument for Orb files that already list it.The tools only read. Each one's target sets the
read_onlyflag that #43 added, so a call runs without the prompt, with Ask before the AI changes your workspace on or off. I added no note-writing tools to chats: the MCP server hasnotes.createandnotes.update, but Orbs have no note-writing kernel tool, so nothing existing fit.The AI page shows the calls as Searched notes, Listed notes and Read a note. The chat instructions now call tool results, such as notes, untrusted data.
Limits
more: truewhen it left some out.more.[Noura cut the rest.], andtruncatedis true..., absolute paths, reserved folders such as.nouraand symlinks fail.WorkspaceEngine::is_visible_filekeeps out dot files,node_modulesandtarget, and anything the Ignored files list matches. Search and read both apply it.The TypeScript kit's mock host offers the same three tools after a plugin's own, as the real host does.
Docs
The WIT comments on
workspace-toolsandrun-tools, the frozen 0.1.0 copy, the generated reference,docs/plugins/interfaces/ai.md,docs/architecture/ai-runtime.md(a new Note tools section) and the Orb tool list indocs/workspace-format/v1.mdcover the tools. The ai interface page and the runtime notes also still said every call asks, so they now describe #43's read-only rule.Tests
is_visible_filefor ignored, reserved, dotted and unsafe paths.ai_notes: a chat offers the tools, searches and then reads a note with no prompt, and the answer shows on the page. Search finds a note by its text and leaves out ignored files and the chat itself. It caps hits at 20. Read works by link or path and refuses traversal, absolute and reserved paths, ignored files, PDFs and symlink escapes. A long note comes back cut. The listing leaves out ignored folders and chats.orb_runs: an Orb's search and listing stay inside itsreads.same-resultschecks that both hosts list the note tools and that the mock host's names, descriptions and schemas match the real host's.npm run checkand the kit's tests pass against the real host.cargo fmt,cargo clippy --workspace --all-targets --all-features -- -D warnings, and the full local-core, app-core, app-ui, plugin-host, plugin-sdk, ai-plugin and noura-mcp suites pass withNOURA_REQUIRE_PLUGINS=1. I rebased onto main after #43 merged and reran clippy and the local-core, app-core AI and Orb, app-ui and plugin-host tests.