mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-01 14:53:07 +08:00
a2e368b1e8
Three command renames consolidate the v0.7 verb table:
- `weknora agent invoke` → `weknora session ask --agent <id>`.
Server route POST /sessions/{session_id}/agent-qa is session-
anchored, so the verb moves with it. `weknora agent` subtree keeps
CRUD only (list / view / create / edit / delete / status / check).
SDK call (AgentQAStreamWithRequest) preserved verbatim; only the
command surface + flag layout move.
- `weknora doc upload` split into three commands:
- `weknora doc upload <file>` — local file (only).
- `weknora doc fetch <url>` — server-side remote fetch (was
`upload --from-url`). URL-only flags (--title / --file-type /
--tag-id) move with the verb.
- `weknora doc create --text` — direct text knowledge entry via
server CreateManualKnowledge.
- `weknora kb empty <id>` → `weknora doc delete --all --kb=<id>`.
Atomic server ClearKnowledgeBaseContents (no list-then-delete
race). Same exit-10 -y/--yes guard as other destructive verbs;
unified through the extended ConfirmDestructive helper.
Parent commands (agent, kb, doc, chunk, session, auth, profile,
search) lose their explicit Args:NoArgs + Run:cmd.Help so the
unknown-subcommand guard fires correctly — `weknora agent invoke
ag_x q` now emits the typed input.unknown_subcommand envelope with
detail.available[] instead of cobra's free-form exit-2 prose.
Spec: docs/superpowers/specs/2026-05-20-weknora-cli-v0.7-design.md §3.4 / §10.7
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
// Package agentcmd holds the `weknora agent` command tree:
|
|
// list / view / create / edit / delete / status / check. The directory is
|
|
// named `agent/` to match the cobra subcommand; the Go package is `agentcmd`
|
|
// to avoid colliding with cobra's *cobra.Command identifier.
|
|
//
|
|
// "agent" in this subtree refers to WeKnora's user-defined Custom
|
|
// Agents (server resource: GET/POST /agents/...) and handles CRUD
|
|
// operations only. Agent invocation has moved to `weknora session ask
|
|
// --agent <id>` (see cli/cmd/session/ask.go).
|
|
package agentcmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
|
)
|
|
|
|
// NewCmd builds the `weknora agent` parent and registers leaves. Called
|
|
// from cli/cmd/root.go.
|
|
func NewCmd(f *cmdutil.Factory) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "agent",
|
|
Short: "Manage custom agents (CRUD + status/check)",
|
|
Long: `Custom Agents bundle a system prompt, model, tool allow-list, and KB
|
|
scope into an addressable resource. Create, edit, list, view, check,
|
|
or delete agents. To invoke an agent, use: weknora session ask --agent <id>`,
|
|
}
|
|
cmd.AddCommand(NewCmdList(f))
|
|
cmd.AddCommand(NewCmdView(f))
|
|
cmd.AddCommand(NewCmdCreate(f))
|
|
cmd.AddCommand(NewCmdEdit(f))
|
|
cmd.AddCommand(NewCmdDelete(f))
|
|
cmd.AddCommand(NewCmdStatus(f))
|
|
cmd.AddCommand(NewCmdCheck(f))
|
|
return cmd
|
|
}
|