Skip to content

cleanup: remove dead code, invalid test references, and aliases#7

Merged
eddieran merged 2 commits intomainfrom
cleanup/remove-dead-code-and-aliases
Feb 26, 2026
Merged

cleanup: remove dead code, invalid test references, and aliases#7
eddieran merged 2 commits intomainfrom
cleanup/remove-dead-code-and-aliases

Conversation

@eddieran
Copy link
Copy Markdown
Owner

@eddieran eddieran commented Feb 25, 2026

  • Remove newRemoveCmd() dead code (superseded by uninstall)
  • Remove harvest/validate/remove references from E2E tests
  • Remove sync --json and leaderboard --json/top alias tests (unimplemented features)
  • Remove source update alias "up"
  • Remove unused newSvc param from newVersionCmd
  • Remove unused injectedCount variable from inject command
  • Remove non-existent harvest package from coverage-gate.sh
  • Add inject --all flag for multi-agent injection

Summary

Describe what changed and why.

Type of change

  • feat
  • fix
  • refactor
  • test
  • docs
  • ci

Validation

  • go test ./...
  • go vet ./...
  • ./tools/coverage-gate.sh (when applicable)

Risk / Compatibility

  • Breaking change? If yes, explain migration path.
  • Security impact? If yes, explain controls/tests.

Notes

Anything reviewers should focus on.

Summary by CodeRabbit

  • New Features

    • Added --all flag to inject to target all enabled adapters.
  • Changed

    • Inject requires either --agent or --all (mutually exclusive); clearer error messaging.
    • Root CLI completion command disabled.
    • Help and usage texts standardized across several commands.
  • Removed

    • Legacy commands and aliases cleaned up (harvest, validate and numerous legacy aliases).
  • Chores

    • Coverage gate for the harvest package removed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Removed several CLI commands and aliases, simplified command headers, decoupled the version command from app.Service, refactored inject to support mutually exclusive --agent/--all multi-target execution with per-target JSON results, pruned related tests and e2e harvest/validate/remove flows, and removed the coverage gate for internal/harvest.

Changes

Cohort / File(s) Summary
Root CLI wiring & version
cmd/skillpm/main.go, cmd/skillpm/version.go
Root now wires newVersionCmd() without an app.Service constructor; removed newRemoveCmd; disabled root completion and trimmed command headers/aliases.
Inject command & multi-target
cmd/skillpm/.../inject.go, cmd/skillpm/.../inject_*
Added --all flag, enforced mutual exclusivity with --agent, changed single-target execution to iterate targets (including enabled adapters) and accumulate per-target JSON-friendly results.
Command header/alias cleanup
cmd/skillpm/... (source, install/uninstall/upgrade, schedule, leaderboard, sync, doctor, etc.)
Removed many Aliases and shortened Use/Short/Long texts across source, install/uninstall/upgrade, schedule, leaderboard, sync, doctor and related command files.
Command tests
cmd/skillpm/main_test.go
Removed many alias-resolution and command-specific tests; simplified assertions to subcommand registration and no-alias expectations; updated error expectation to require "either --agent or --all is required".
Version signature update
cmd/skillpm/version.go
Changed newVersionCmd signature to remove newSvc param and rely on config/flags for JSON output; removed import of internal/app.
End-to-end tests
test/e2e/critical_flows_test.go, test/e2e/leaderboard_test.go
Removed candidateDir setup, SKILL.md creation, harvest/validate CLI invocations, a removal step, and the TestLeaderboardTopAlias test.
Coverage gating script
tools/coverage-gate.sh
Dropped enforcement of the 80% coverage gate for internal/harvest; other gates unchanged.
go.mod / dependencies
go.mod
Dependency adjustments (lines changed significantly) to reflect removed imports and refactors.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant CLI as "CLI (skillpm)"
participant Svc as "Service / app"
participant Adapter as "Agent Adapter(s)"
CLI->>Svc: parse inject command (--agent or --all)
alt --agent provided
CLI->>Adapter: target specific agent execute inject
Adapter-->>CLI: per-target result
else --all provided
CLI->>Svc: request enabled adapters list
Svc-->>CLI: list of targets
loop for each target
CLI->>Adapter: execute inject on target
Adapter-->>CLI: per-target result
end
end
CLI-->>CLI: accumulate per-target results into JSON-friendly structure
CLI-->>User: output aggregated results

(Note: colored rectangles are not required in this simple sequence.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I nibble code and hop the stack,
Pruned commands left tidy track,
Injectors scatter—agents all,
Tests trimmed small, harvest gates fall,
A rabbit cheers this lean new pack 🐇✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description lists specific changes but leaves the template sections (Summary, Type of change, Validation, Risk/Compatibility, Notes) incomplete or unchecked. Complete the template by filling in the Summary section with context, checking the appropriate Type of change boxes, confirming validation steps, and noting any breaking changes or risks for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary changes: removing dead code, invalid test references, and aliases, which aligns with the substantial file modifications and removals across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cleanup/remove-dead-code-and-aliases

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 @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
cmd/skillpm/main.go (1)

311-315: Add target context to inject errors in multi-agent mode.

At Line 313, returning err directly obscures which adapter failed when --all is used. Wrap with target info for actionable failures.

Proposed patch
 			for _, target := range targets {
 				res, err := svc.Inject(context.Background(), target, args)
 				if err != nil {
-					return err
+					return fmt.Errorf("ADP_INJECT: inject failed for agent %q: %w", target, err)
 				}
 				fmt.Printf("injected %d skill(s) into %s\n", len(res.Injected), target)
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/skillpm/main.go` around lines 311 - 315, When calling svc.Inject in the
loop over targets, don't return err directly; wrap it with the target context so
failures show which adapter failed in multi-agent (--all) mode. Locate the loop
that iterates over targets and the call to svc.Inject(context.Background(),
target, args) and replace the direct return of err with a wrapped error that
includes the target identifier (e.g., target.Name or target.ID or the target
variable) and the original error message (use fmt.Errorf or errors.Wrap/Wrapf
consistent with the repo) so logs and returned errors indicate which specific
target caused the failure.
cmd/skillpm/main_test.go (1)

192-206: Add a test for the new --agent + --all conflict guard.

This test now covers the “neither provided” branch; add a companion case for the new mutual-exclusion path to lock behavior.

Suggested test addition
 func TestInjectRequiresAgentBeforeService(t *testing.T) {
@@
 }
+
+func TestInjectRejectsAgentAndAllBeforeService(t *testing.T) {
+	called := false
+	cmd := newInjectCmd(func() (*app.Service, error) {
+		called = true
+		return nil, errors.New("should not be called")
+	})
+	cmd.SetArgs([]string{"demo/skill", "--agent", "ghost", "--all"})
+	err := cmd.Execute()
+	if err == nil || !strings.Contains(err.Error(), "cannot specify both --agent and --all") {
+		t.Fatalf("expected mutual exclusion error, got %v", err)
+	}
+	if called {
+		t.Fatalf("newSvc should not be called when both --agent and --all are set")
+	}
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/skillpm/main_test.go` around lines 192 - 206, Add a companion test (e.g.,
TestInjectAgentAndAllConflict) that mirrors TestInjectRequiresAgentBeforeService
but sets cmd arguments to include both --agent (with a name) and --all; use
newInjectCmd to pass a stub that flips a called flag and returns an error; call
cmd.Execute() and assert it returns a non-nil error, that the error message
mentions both "--agent" and "--all" (to detect the mutual-exclusion guard), and
that the stub (called) remains false so newInjectCmd's service factory is not
invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmd/skillpm/main_test.go`:
- Around line 192-206: Add a companion test (e.g.,
TestInjectAgentAndAllConflict) that mirrors TestInjectRequiresAgentBeforeService
but sets cmd arguments to include both --agent (with a name) and --all; use
newInjectCmd to pass a stub that flips a called flag and returns an error; call
cmd.Execute() and assert it returns a non-nil error, that the error message
mentions both "--agent" and "--all" (to detect the mutual-exclusion guard), and
that the stub (called) remains false so newInjectCmd's service factory is not
invoked.

In `@cmd/skillpm/main.go`:
- Around line 311-315: When calling svc.Inject in the loop over targets, don't
return err directly; wrap it with the target context so failures show which
adapter failed in multi-agent (--all) mode. Locate the loop that iterates over
targets and the call to svc.Inject(context.Background(), target, args) and
replace the direct return of err with a wrapped error that includes the target
identifier (e.g., target.Name or target.ID or the target variable) and the
original error message (use fmt.Errorf or errors.Wrap/Wrapf consistent with the
repo) so logs and returned errors indicate which specific target caused the
failure.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6991cd and 305cfa32bbfb8d26c022a69fa75ea069bd20fd71.

📒 Files selected for processing (6)
  • cmd/skillpm/main.go
  • cmd/skillpm/main_test.go
  • cmd/skillpm/version.go
  • test/e2e/critical_flows_test.go
  • test/e2e/leaderboard_test.go
  • tools/coverage-gate.sh
💤 Files with no reviewable changes (3)
  • test/e2e/leaderboard_test.go
  • tools/coverage-gate.sh
  • test/e2e/critical_flows_test.go

- Remove newRemoveCmd (superseded by uninstall)
- Remove newHarvestCmd (references non-existent svc.HarvestRun)
- Remove newValidateCmd (references non-existent svc.Validate)
- Remove ALL command aliases across the CLI
- Remove harvest package from coverage-gate.sh
- Remove E2E tests referencing harvest/validate/remove/top-alias
- Add inject --all flag for multi-agent injection
- Clean newVersionCmd unused newSvc parameter
- Re-enable DisableDefaultCmd for completion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eddieran eddieran force-pushed the cleanup/remove-dead-code-and-aliases branch from 305cfa3 to f9540bb Compare February 26, 2026 01:18
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/skillpm/main.go (1)

337-346: Fail-fast behavior may discard partial progress with --all.

When --all is used and one agent fails, the loop exits immediately without reporting which agents succeeded. Consider whether accumulating errors and continuing would provide better UX, or at minimum logging which agents completed before the failure.

Current behavior is acceptable for an initial implementation but worth noting.

🔧 Optional: Continue-on-error approach
+			var errs []error
 			for _, target := range targets {
 				res, err := svc.Inject(context.Background(), target, args)
 				if err != nil {
-					return err
+					errs = append(errs, fmt.Errorf("agent %s: %w", target, err))
+					continue
 				}
 				results = append(results, agentResult{Agent: target, Injected: len(res.Injected)})
 				if !*jsonOutput {
 					fmt.Printf("injected %d skill(s) into %s\n", len(res.Injected), target)
 				}
 			}
+			if len(errs) > 0 {
+				// Still output successful results before returning error
+				if *jsonOutput {
+					_ = print(true, results, "")
+				}
+				return fmt.Errorf("injection failed for %d agent(s): %v", len(errs), errs)
+			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/skillpm/main.go` around lines 337 - 346, The loop over targets currently
returns on the first svc.Inject error and discards prior successes; update the
behavior so failures don't hide completed agents: inside the for loop that calls
svc.Inject(target, args) (symbols: svc.Inject, targets, results, agentResult,
jsonOutput) capture errors per-agent rather than returning immediately — e.g.,
append a structured error record (agent name + err) to an errors slice and
continue the loop, still appending successful agentResult entries and printing
when !*jsonOutput; after the loop, if the errors slice is non-empty, print/log a
concise summary of which agents failed and return an aggregated error (or
non-zero exit) so callers see both successes and failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmd/skillpm/main.go`:
- Around line 337-346: The loop over targets currently returns on the first
svc.Inject error and discards prior successes; update the behavior so failures
don't hide completed agents: inside the for loop that calls svc.Inject(target,
args) (symbols: svc.Inject, targets, results, agentResult, jsonOutput) capture
errors per-agent rather than returning immediately — e.g., append a structured
error record (agent name + err) to an errors slice and continue the loop, still
appending successful agentResult entries and printing when !*jsonOutput; after
the loop, if the errors slice is non-empty, print/log a concise summary of which
agents failed and return an aggregated error (or non-zero exit) so callers see
both successes and failures.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 305cfa32bbfb8d26c022a69fa75ea069bd20fd71 and f9540bb.

📒 Files selected for processing (6)
  • cmd/skillpm/main.go
  • cmd/skillpm/main_test.go
  • cmd/skillpm/version.go
  • test/e2e/critical_flows_test.go
  • test/e2e/leaderboard_test.go
  • tools/coverage-gate.sh
💤 Files with no reviewable changes (3)
  • test/e2e/critical_flows_test.go
  • test/e2e/leaderboard_test.go
  • tools/coverage-gate.sh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/skillpm/main.go`:
- Around line 323-331: When handling the --all flag, ensure we fail when no
enabled adapters are discovered instead of silently doing nothing: after the
allAgents branch that iterates svc.Config.Adapters and appends to targets, check
if len(targets) == 0 and return/exit with a clear error (e.g. "no enabled
adapters found" or "no targets for injection") so callers can distinguish a real
no-op from success; update the function that builds targets (referencing
allAgents, svc.Config.Adapters, targets, agentName) to perform this explicit
error return when targets is empty.
- Around line 337-349: The loop over targets aborts on the first svc.Inject
error and drops previously collected results; change the logic in the for loop
that calls svc.Inject so it continues processing all targets even when
svc.Inject returns an error, capture per-target error details (e.g., extend
agentResult to include an Error string or status) for each target, append either
the successful injected count or the error info to results, and after the loop
use *jsonOutput with print(true, results, "") to emit the full result list and
return a non-zero error/exit code if any target failed; update references to
svc.Inject, agentResult, jsonOutput, and print accordingly so callers get
per-target outcomes instead of an early return.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9540bb and 786b397.

📒 Files selected for processing (1)
  • cmd/skillpm/main.go

Comment thread cmd/skillpm/main.go
Comment on lines +323 to 331
if allAgents {
for _, a := range svc.Config.Adapters {
if a.Enabled {
targets = append(targets, a.Name)
}
}
} else {
targets = []string{agentName}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Handle --all with zero enabled adapters explicitly.

If no enabled adapters are found, the command currently succeeds as a silent no-op (non-JSON mode). Return a clear error so callers can distinguish “nothing targeted” from successful injection.

💡 Proposed fix
 			if allAgents {
 				for _, a := range svc.Config.Adapters {
 					if a.Enabled {
 						targets = append(targets, a.Name)
 					}
 				}
+				if len(targets) == 0 {
+					return &exitError{code: 2, msg: "INJECT_NO_TARGETS: no enabled adapters found"}
+				}
 			} else {
 				targets = []string{agentName}
 			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if allAgents {
for _, a := range svc.Config.Adapters {
if a.Enabled {
targets = append(targets, a.Name)
}
}
} else {
targets = []string{agentName}
}
if allAgents {
for _, a := range svc.Config.Adapters {
if a.Enabled {
targets = append(targets, a.Name)
}
}
if len(targets) == 0 {
return &exitError{code: 2, msg: "INJECT_NO_TARGETS: no enabled adapters found"}
}
} else {
targets = []string{agentName}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/skillpm/main.go` around lines 323 - 331, When handling the --all flag,
ensure we fail when no enabled adapters are discovered instead of silently doing
nothing: after the allAgents branch that iterates svc.Config.Adapters and
appends to targets, check if len(targets) == 0 and return/exit with a clear
error (e.g. "no enabled adapters found" or "no targets for injection") so
callers can distinguish a real no-op from success; update the function that
builds targets (referencing allAgents, svc.Config.Adapters, targets, agentName)
to perform this explicit error return when targets is empty.

Comment thread cmd/skillpm/main.go
Comment on lines +337 to 349
for _, target := range targets {
res, err := svc.Inject(context.Background(), target, args)
if err != nil {
return err
}
results = append(results, agentResult{Agent: target, Injected: len(res.Injected)})
if !*jsonOutput {
fmt.Printf("injected %d skill(s) into %s\n", len(res.Injected), target)
}
}
if *jsonOutput {
return print(true, res, "")
return print(true, results, "")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve per-target results instead of aborting on first inject failure.

The loop returns on the first failed target, so multi-target runs can partially mutate state while dropping accumulated results (especially for JSON callers). Continue processing targets, record per-target errors, then return a non-zero exit at the end if any failed.

💡 Proposed fix
 			type agentResult struct {
 				Agent    string `json:"agent"`
 				Injected int    `json:"injected"`
+				Error    string `json:"error,omitempty"`
 			}
-			var results []agentResult
+			var (
+				results  []agentResult
+				hadError bool
+			)
 			for _, target := range targets {
 				res, err := svc.Inject(context.Background(), target, args)
 				if err != nil {
-					return err
+					hadError = true
+					results = append(results, agentResult{Agent: target, Error: err.Error()})
+					if !*jsonOutput {
+						fmt.Fprintf(os.Stderr, "inject failed for %s: %v\n", target, err)
+					}
+					continue
 				}
 				results = append(results, agentResult{Agent: target, Injected: len(res.Injected)})
 				if !*jsonOutput {
 					fmt.Printf("injected %d skill(s) into %s\n", len(res.Injected), target)
 				}
 			}
 			if *jsonOutput {
-				return print(true, results, "")
+				if err := print(true, results, ""); err != nil {
+					return err
+				}
+				if hadError {
+					return &exitError{code: 2, msg: "INJECT_PARTIAL_FAILURE: one or more agent injections failed"}
+				}
+				return nil
 			}
+			if hadError {
+				return &exitError{code: 2, msg: "INJECT_PARTIAL_FAILURE: one or more agent injections failed"}
+			}
 			return nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/skillpm/main.go` around lines 337 - 349, The loop over targets aborts on
the first svc.Inject error and drops previously collected results; change the
logic in the for loop that calls svc.Inject so it continues processing all
targets even when svc.Inject returns an error, capture per-target error details
(e.g., extend agentResult to include an Error string or status) for each target,
append either the successful injected count or the error info to results, and
after the loop use *jsonOutput with print(true, results, "") to emit the full
result list and return a non-zero error/exit code if any target failed; update
references to svc.Inject, agentResult, jsonOutput, and print accordingly so
callers get per-target outcomes instead of an early return.

@eddieran eddieran merged commit 9efdc5c into main Feb 26, 2026
4 checks passed
eddieran added a commit that referenced this pull request Mar 2, 2026
cleanup: remove dead code, invalid test references, and aliases
eddieran added a commit that referenced this pull request Mar 2, 2026
cleanup: remove dead code, invalid test references, and aliases
@eddieran eddieran deleted the cleanup/remove-dead-code-and-aliases branch March 15, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant