feat: persistent file-access allow list via clet.config.json + interactive access dialog for clet edit#134
Conversation
- Add FileAccessSettings class with AllowedPaths property and LoadFromConfig() method that reads "FileAccessSettings.AllowedPaths" JSON array directly from ~/.tui/clet.config.json (CM doesn't support string[] via [ConfigurationProperty]) - Add FileAccessPolicy.MergeWithConfigPaths() static helper that combines --allow-file CLI paths with config-based AllowedPaths - Update MarkdownContentResolver.Resolve() and EditorClet.RunAsync() to use MergeWithConfigPaths() so both clets respect config-based allowed paths - Call FileAccessSettings.LoadFromConfig() in AliasDispatcher after CM.Enable(All) and also in --cat mode before file resolution - Update FileAccessPolicy error messages to mention clet.config.json as alternative - Update ConfigClet.DefaultConfigContent with AllowedPaths documentation section - Update md.md and edit.md help to document the persistent allow list - Add 14 unit tests covering LoadFromConfig, MergeWithConfigPaths, and policy integration Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/6ec0cea4-f7d5-4a80-9a07-d54d32fd66f1 Co-authored-by: tig <585482+tig@users.noreply.github.com>
… error message Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/6ec0cea4-f7d5-4a80-9a07-d54d32fd66f1 Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
@copilot you need to use ConfigurationManager for read of config. I do not want two code paths that read it. The allowed list should be a configuration property. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0ccbb8fce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rter] for AllowedPaths - Replace the hand-rolled JSON file reader with a proper CM [ConfigurationProperty] - Add StringArrayJsonConverter so CM can deserialize string[] from a JSON array - AllowedPaths is now a non-nullable string[] with empty default (CM Apply() requires a non-null current value to set the property) - Remove LoadFromConfig() method and all callers (AliasDispatcher no longer has a separate file-read step; CM.Enable(All) is the sole config reader) - Update tests: remove LoadFromConfig-based tests, add CM RuntimeConfig-based tests in FileAccessSettingsCmTests collection Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/23c0409a-c113-4eb4-a046-c8be9f944985 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/23c0409a-c113-4eb4-a046-c8be9f944985 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Done in commit The key was adding |
|
@copilot ci/cd is failing. Also, instead of The user hsould be presented with a messagbox asking:
|
Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/94d1e029-cffa-464a-9b6b-2b6c11cac138 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/94d1e029-cffa-464a-9b6b-2b6c11cac138 Co-authored-by: tig <585482+tig@users.noreply.github.com>
…tFocus, extract dirPathNode Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/94d1e029-cffa-464a-9b6b-2b6c11cac138 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Fixed in CI failures
File access dialog
The dialog is shown from inside |
|
@copilot ci/cd is failing. Are you not runiing the tests yourself?? |
…itespace Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/139a95e7-ec01-4fc4-a80f-a58ad23d4a07 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Fixed in Ubuntu (dotnet format): Switch case indentation in the dialog code and indexer/cast spacing in Windows (test failure): All 474 unit tests and 56 integration tests pass locally; |
|
@copilot ci/cd is failing. user testing shows that the config file is being updated, but those settings are not honored. I get prompted for these folder even after they were added: "FileAccessSettings.AllowedPaths": [ |
Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/479e2811-3a2e-414a-bb57-514a46e45570 Co-authored-by: tig <585482+tig@users.noreply.github.com>
…ely; defensive Disable() in CM tests Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/479e2811-3a2e-414a-bb57-514a46e45570 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Fixed in Root cause of both issues: TG's Fix:
CI test fix:
|
|
@copilot any tests that use cm can not run in parallel with other tests. |
…gerCollection Agent-Logs-Url: https://github.com/gui-cs/clet/sessions/7178d2e6-ab9c-492a-9130-04c0473803f7 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Done in
Also fixed |
The wildcard 2.1.1-develop.* was resolving to .163 which is a bad build without the VisualRole.Code* tokens that Editor PR #134 relies on. Pin to .98 to match Editor's Directory.Build.props. Also remove obsolete GetThemeForBackground calls (now errors with TreatWarningsAsErrors) — syntax colors are resolved via VisualRoles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
clet editandclet mdpreviously required--allow-fileon every invocation to access files outside the working directory. This adds a persistent trusted-directories list stored in~/.tui/clet.config.json, analogous to VS Code's workspace trust model. Whenclet editis denied access to a file, it now presents an interactive TUI dialog instead of printing an error.Changes
New
FileAccessSettingsclassAllowedPaths(List<string>) — persistent allow list, populated byConfigurationManagerfrom"FileAccessSettings.AllowedPaths"inclet.config.json[ConfigurationProperty(Scope = typeof(SettingsScope))]— CM discovers and owns this setting like all other clet settingsList<string>(notstring[]) so CM can deserialize it natively via Terminal.Gui'sSourceGenerationContext, which registersList<string>but notstring[]— no customJsonConverterneededAddToConfig(dirPath)— persists a new directory to~/.tui/clet.config.jsonusingJsonNode(preserves all active keys; JSONC comments are stripped on write), then ensures in-memoryAllowedPathsis updated immediatelyInteractive file-access dialog for
clet editWhen
clet editis invoked with a file outside the allowed directories, instead of printing an error, the editor window opens and a TUI messagebox appears offering:FileAccessSettings.AddToConfig(dir)to persist the directory in~/.tui/clet.config.json; the file loads immediatelyPolicy integration
FileAccessPolicy.MergeWithConfigPaths(cliPaths)— merges ephemeral--allow-fileCLI paths with CM-loadedAllowedPathsbefore constructing a policyMarkdownContentResolverandEditorCletboth pass merged paths;--allow-fileremains fully functional as an ephemeral overrideConfigurationManager.Enable(All)is the sole config read path — no secondary file-read stepConfig template & help
ConfigClet.DefaultConfigContentgains a "File-Access Allow List" section with docs and exampleedit.mdgains a "File access" section describing the dialog workflow and the persistent config optionmd.mdgains a "File access" section explaining both the ephemeral and persistent optionsUsage
Files under listed directories are allowed by both
clet editandclet mdwithout--allow-file. Forclet edit, the directory can also be added interactively via the "Add to config" option in the access dialog.