feat(commands): add Deps struct and secondToken helper, remove dead contains()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9f61d50470
commit
c940133d0f
2 changed files with 22 additions and 9 deletions
14
pkg/commands/deps.go
Normal file
14
pkg/commands/deps.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package commands
|
||||
|
||||
import "github.com/sipeed/picoclaw/pkg/config"
|
||||
|
||||
// Deps provides runtime data to command handlers without importing
|
||||
// agent or channel packages. Function fields are called at handler
|
||||
// invocation time, not at construction time, so late-bound values
|
||||
// (e.g. channelManager set after NewAgentLoop) are visible.
|
||||
type Deps struct {
|
||||
Config *config.Config
|
||||
GetModelInfo func() (name, provider string)
|
||||
ListAgentIDs func() []string
|
||||
GetEnabledChannels func() []string
|
||||
}
|
||||
|
|
@ -57,15 +57,14 @@ func trimCommandPrefix(token string) (string, bool) {
|
|||
return "", false
|
||||
}
|
||||
|
||||
func secondToken(input string) string {
|
||||
parts := strings.Fields(strings.TrimSpace(input))
|
||||
if len(parts) < 2 {
|
||||
return ""
|
||||
}
|
||||
return parts[1]
|
||||
}
|
||||
|
||||
func normalizeCommandName(name string) string {
|
||||
return strings.ToLower(strings.TrimSpace(name))
|
||||
}
|
||||
|
||||
func contains(items []string, target string) bool {
|
||||
for _, item := range items {
|
||||
if item == target {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue