feat: add proto rm/remove command to uninstall protocol#3
Merged
Conversation
Implement cueme proto rm/remove command as the reverse operation of cueme proto apply. This allows users to cleanly remove the HAP protocol from agent configuration files. Features: - Add protoRemove() function to remove managed blocks - Support both 'rm' and 'remove' aliases - Automatically delete file if it becomes empty after removal - Preserve file content outside managed blocks - Handle cases where file or managed block doesn't exist Usage: cueme proto rm <agent> cueme proto remove <agent> Examples: cueme proto rm windsurf cueme proto remove kiro The command removes content between BEGIN_MARKER and END_MARKER, preserving any other content in the file. If the file only contains the managed block, it will be deleted entirely.
nmhjklnm
reviewed
Jan 17, 2026
Collaborator
nmhjklnm
left a comment
There was a problem hiding this comment.
Thanks — this feature makes a lot of sense as the reverse operation of cueme proto apply, and CI is green.
A couple of things I’d suggest before merging:
Must-fix
-
protoRemove()has an unused local (exists).- You set it but never read it; please remove it.
-
When deleting the file fails (
fs.unlinkSyncthrows), the command still returnsok:and exits 0.- I’d treat this as an error (e.g. return
error:and set a non-zero exit), otherwise users may think everything is clean but the file is still there.
- I’d treat this as an error (e.g. return
Nice-to-have / confirm behavior
-
Marker pairing robustness: current logic removes from the first BEGIN match to the first END match.
- If someone accidentally duplicates markers, this might delete an unexpected range. Consider pairing BEGIN with the next END after it (more explicit index search), or at least document the “first block only” behavior.
-
trimEnd()changes trailing whitespace/newlines of the remaining content.- Probably fine, but please confirm this is intended; otherwise keep the existing tail formatting and only remove the managed block.
Once you address (1)-(2), I think this is good to go.
Address all feedback from code review: Must-fix items: 1. Remove unused 'exists' variable in protoRemove() 2. Throw error when file deletion fails instead of returning ok - Changed from 'ok: ... but failed to delete' to throwing Error - This ensures non-zero exit code and proper error handling Improvements: 3. Removed trimEnd() to preserve original file formatting - Keep trailing whitespace/newlines as they were - Only remove the managed block itself The function now: - Cleanly removes managed blocks - Preserves original file formatting - Properly reports errors when file deletion fails - Has no unused variables
nmhjklnm
approved these changes
Jan 17, 2026
Collaborator
nmhjklnm
left a comment
There was a problem hiding this comment.
Re-review: looks good.
- Removed the unused
existsvariable. - Deletion failure now throws an error (non-zero exit), which is safer.
- Preserves existing file formatting (no
trimEnd()), while still removing the managed block.
CI is green. Approving.
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.
概述
添加
cueme proto rm/remove命令,作为cueme proto apply的反向操作,允许用户干净地移除已应用的 HAP 协议。功能特性
使用方法
使用场景
实现细节
修改内容
protoRemove()函数用于移除已应用的协议块rm和remove两个命令别名protoRemove函数到 module.exports代码逻辑
测试
相关文档
cueme proto apply命令对应的反向操作