nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Trust prompt should list what the project will run, and ask again when that changes

Open addyCooks opened this issue 1 month ago • 2 comments

Description

The directory trust prompt only says "Nanocoder may read, write, or execute files contained in this folder" (source/components/security-disclaimer.tsx). It does not say that, once trusted, the project can run in-process plugins (.nanocoder/plugins/*.mjs), session-start hooks, formatters and MCP servers. Trust is saved as just the directory path (trustedDirectories, see ensureDirectoryTrust in source/config/preferences.ts), so if a later git pull adds a plugin or hook, it runs on the next start without any prompt.

Use Case

A user trusts a repo while it is harmless. Later the repo changes (a bad commit, a compromised dependency, or a teammate's mistake) and adds a plugin or a hook. Nanocoder runs it immediately. Plugins run with the same privileges as Nanocoder itself (docs/features/hooks.md).

Proposed Solution

  • Make the prompt list what will run, for example: This folder contains: 2 plugins, 1 session-start hook, 3 MCP servers, 1 formatter.
  • Store a hash of those files with the trust entry, and show the prompt again when it changes.
  • A smaller first step is only the first point: the prompt text. That could be done on its own.

Alternatives Considered

  • Leave it as is, like editors that trust a workspace once. The difference here is that the files are executable code that the agent loads on its own at startup.
  • Ask for confirmation only for newly added plugins.

Additional Context

Tested on Windows 11, Node 22.22.3, Nanocoder 1.31.0 (main at 5c2e693):

  1. Trusted a harmless folder once with NANOCODER_TRUST_DIRECTORY=1 nanocoder run ... (it was saved to trustedDirectories).
  2. Added .nanocoder/plugins/pulled.mjs (writes a file when imported) and a session-start hook in agents.config.json.
  3. Ran nanocoder run "Reply with the single word OK" again, without the env var.

Result: no prompt, and both ran. PLUGIN-RAN.txt and HOOK-RAN.txt were created.

A copy of the same project that was never trusted refused to run: Directory ... is not trusted. So the gate works the first time, but is never checked again.

A test that renders SecurityDisclaimer in a folder with a plugin and a hook and checks that the text mentions them fails today.

Related: #1244, #1245, #1258 and #1259 made sure the prompt runs before anything starts. #1568 added plugins.

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] This feature aligns with the project's goals (local-first AI assistance)

addyCooks avatar Oct 08 '26 17:10 addyCooks

@addyCooks I go for this one

Dhirenderchoudhary avatar Oct 08 '26 22:10 Dhirenderchoudhary

Go for it @Dhirenderchoudhary !

addyCooks avatar Oct 09 '26 06:10 addyCooks