feat: add read-only mode for safe AI agent usage#74
Merged
Conversation
Add profile-level readOnly flag that blocks all write operations at the CLI level. Supports CONFLUENCE_READ_ONLY env var override and --read-only flag on init/profile add commands. - Add readOnly field to config profiles and getConfig() - Add assertWritable() guard to 13 write commands - Show [read-only] badge in profile list - Add CONFLUENCE_READ_ONLY env var (overrides profile setting) - Add --read-only flag to init and profile add commands - Add tests for read-only mode behavior - Update README.md and SKILL.md documentation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a profile-level read-only mode to prevent accidental Confluence writes (particularly for AI agent usage), enforced at the CLI command layer and configurable via profile config or CONFLUENCE_READ_ONLY.
Changes:
- Add
readOnlysupport to config loading/saving and profile listing. - Add an
assertWritable()guard and apply it to all write commands; add--read-onlytoinitandprofile add. - Add read-only mode documentation and a new Jest test suite covering the behavior.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/config.js |
Reads CONFLUENCE_READ_ONLY, persists readOnly in profiles, and exposes it via getConfig() / listProfiles(). |
bin/confluence.js |
Introduces assertWritable(config) and applies it to write commands; adds --read-only to profile creation flows and shows a [read-only] badge. |
tests/read-only.test.js |
Adds tests for env/config precedence, assertWritable(), and listProfiles() readOnly field. |
README.md |
Documents read-only mode, env var, flags, and command table updates. |
.claude/skills/confluence/SKILL.md |
Updates the skill doc to include read-only mode guidance and error pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…y=true When CONFLUENCE_READ_ONLY is set, its value takes full precedence over the profile's readOnly field. Previously the || logic prevented false from overriding a true profile setting. Also adds missing create-child to the blocked commands list in README.
|
🎉 This PR is included in version 1.27.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Pull Request Template
Description
Add profile-level read-only mode that blocks all write operations at the CLI level, designed for safe AI agent usage. Resolves #73.
When
readOnlyis enabled (via profile config orCONFLUENCE_READ_ONLY=trueenv var), the following 13 write commands are blocked:create,create-child,update,move,delete,edit,attachment-upload,attachment-delete,property-set,property-delete,comment,comment-delete,copy-tree.Type of Change
Testing
Checklist
Changes
lib/config.jsgetConfig()returnsreadOnlyfield from profile orCONFLUENCE_READ_ONLYenv varsaveConfig()persistsreadOnlyflaglistProfiles()includesreadOnlystatusinitConfig()acceptsreadOnlyoptionbin/confluence.jsassertWritable(config)guard function — exits with code 1 when readOnly is true--read-onlyoption oninitandprofile addcommands[read-only]badge inprofile listoutputtests/read-only.test.js(new)assertWritable()function behaviorlistProfiles()includes readOnly flagREADME.md/SKILL.md--read-onlyflag documented for init and profile addCONFLUENCE_READ_ONLYenv var documented