Skip to content

Refactor: Split cmd/agentop/cmd_bob.go to move out its JSON settings editor - #1695

Merged
huang195 merged 1 commit into
rossoctl:mainfrom
huang195:refactor/split-cmd-bob-1584
Nov 7, 2026
Merged

huang195 merged 1 commit into
rossoctl:mainfrom
huang195:refactor/split-cmd-bob-1584

Conversation

@huang195

@huang195 huang195 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #1584. This PR moves code only. It changes no signature and no statement.

cmd/agentop/cmd_bob.go had 2100 lines. About 400 of them are a byte-level JSON editor. The editor changes one top-level key in a settings file and keeps all other bytes. It has no relation to Bob itself.

The editor moves, with its doc comments, to cmd/agentop/bob_settings_json.go in the same package:

  • bobSetKey, bobFindMember, bobSpliceOut, bobInsertMember and their helpers
  • errBobDuplicateKey
  • bobEdit, bobWriteKey and bobWriteKeys, which write the edited file

cmd_bob.go has 1700 lines now. bobDuplicateKey and bobBackupNote stay in cmd_bob.go, because they know Bob's keys and Bob's messages.

The tests stay in cmd_bob_test.go. The issue suggests a separate test surface for the editor. To move the tests is a different change, so this PR does not do it.

How to review

git show --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change HEAD

The only lines that are not dimmed are the new file header (package clause and imports) and the import block of cmd_bob.go.

Checks

  • A script parsed the package before and after the move. It compared every top-level declaration (with its doc comment) and every free comment, as text. The two sets are equal.
  • GOWORK=off go build ./..., go vet ./... and go test ./... pass in cmd/agentop.
  • golangci-lint gives the same findings before and after the move.

CodeQL

CodeQL reports go/allocation-size-overflow at bob_settings_json.go:54 and :300. The two lines move byte for byte from cmd_bob.go. Each line is make([]byte, 0, len(src)+len(x)), where src is the contents of a Bob settings file. The sum overflows only above 2^63 bytes, so the alert is a false positive. main has no alert for these lines.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

cmd_bob.go had 2100 lines. About 400 of them are a byte-level JSON
editor. The editor changes one top-level key in a settings file and
keeps all other bytes. It has no relation to Bob itself.

This change moves code only. It changes no signature and no statement.
The editor moves with its doc comments to bob_settings_json.go in the
same package:

- bobSetKey, bobFindMember, bobSpliceOut, bobInsertMember and their
  helpers
- errBobDuplicateKey
- bobEdit, bobWriteKey and bobWriteKeys, which write the edited file

cmd_bob.go has 1700 lines now. The tests stay in cmd_bob_test.go.

Check: a script parsed the package before and after the move. It
compared every top-level declaration (with its doc comment) and every
free comment, as text. The two sets are equal. golangci-lint gives the
same findings before and after the move.

Part of rossoctl#1584.

Signed-off-by: Hai Huang <huang195@gmail.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
@huang195
huang195 requested a review from a team as a code owner November 7, 2026 00:24
@huang195 huang195 changed the title Refactor: Move bob's JSON settings editor out of cmd_bob.go Refactor: Split cmd/agentop/cmd_bob.go to move out its JSON settings editor Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 82c4a778-de75-48a7-b45f-4e9f234641f0
Commits

Reviewing files that changed from the base of the PR and between dc15da6 and a20a295.

Files selected for processing: 2

  • cmd/agentop/bob_settings_json.go
  • cmd/agentop/cmd_bob.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Comment thread cmd/agentop/bob_settings_json.go Dismissed
Comment thread cmd/agentop/bob_settings_json.go Dismissed
Comment thread cmd/agentop/bob_settings_json.go Dismissed
Comment thread cmd/agentop/bob_settings_json.go Dismissed

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This is a clean move-only refactor. I checked the claim directly: the 400 lines removed from cmd_bob.go and the 408 lines added in bob_settings_json.go are identical and in the same order. The only extra lines are the new file's package clause and import block, minus one blank separator line. Nothing was dropped. There are 40 top-level funcs before the move and 30 + 10 after it. bobDuplicateKey and bobBackupNote stay in cmd_bob.go, as stated. encoding/json and strconv correctly leave cmd_bob.go's imports. The 2100 → 1700 line counts match.

Verified locally at a20a295 in cmd/agentop: GOWORK=off go build ./..., go vet ./... and gofmt -l are clean, and the bob tests (go test -run 'Bob|bob' .) pass.

CodeQL failure (non-blocking): the 4 go/allocation-size-overflow alerts (#352–#355, lines 54 and 300 of bob_settings_json.go) are on code that this PR only moves. It is the same make([]byte, 0, len(src)+len(member)) / len(src)+len(ins) that sits at cmd_bob.go lines 591 and 837 on main. CodeQL reports them as new only because the file path is new. Two lengths of in-memory byte slices cannot add up past int, so I suggest dismissing them as false positives so the check goes green. That decision is outside the scope of this PR.

Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (cmd/agentop)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: all passing except CodeQL (4 alerts on relocated pre-existing code, see above)

@huang195
huang195 merged commit 6303e0e into rossoctl:main Nov 7, 2026
43 checks passed
@huang195
huang195 deleted the refactor/split-cmd-bob-1584 branch November 7, 2026 01:17
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants