refactor(cli): resource-command refactors — --kb resolver, MCP session_ask, session stop (BREAKING)
Unify the --kb resolver (accepts name or UUID) across kb/doc/chunk/session/ search/chat/link; `agent create` attaches knowledge bases via --attach-kb (no longer --kb). Rename the MCP tool agent_invoke → session_ask and drop dead MCP error codes. Add `session stop` (StopSession), completing the start / continue-stream / stop triad. Across these commands, bring the agent contract up to par: --dry-run previews on mutations (incl. kb pin/unpin, session stop), agent-help blobs on the read/health surface, accurate destructive-confirmation verbs, and search has_more truncation signalling so an agent can tell its results were capped.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package doc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -138,3 +139,21 @@ func TestCreate_EmptyText_RejectsBeforeSDK(t *testing.T) {
|
||||
// Verify the SDK was NOT called.
|
||||
assert.Nil(t, svc.got.req, "SDK must not be called when --text is empty")
|
||||
}
|
||||
|
||||
// TestCreate_AgentHelp_EmitsUsedFor verifies that when WEKNORA_AGENT_HELP=1
|
||||
// the `doc create --help` path emits a JSON blob containing "used_for".
|
||||
// This is the representative test for 3.2; the mechanism is covered by
|
||||
// internal/cmdutil/agenthelp_test.go — we test the wiring here.
|
||||
func TestCreate_AgentHelp_EmitsUsedFor(t *testing.T) {
|
||||
t.Setenv("WEKNORA_AGENT_HELP", "1")
|
||||
_, _ = iostreams.SetForTest(t)
|
||||
|
||||
f := &cmdutil.Factory{}
|
||||
cmd := NewCmdCreate(f)
|
||||
|
||||
var buf bytes.Buffer
|
||||
cmd.SetOut(&buf)
|
||||
cmd.HelpFunc()(cmd, nil)
|
||||
|
||||
assert.Contains(t, buf.String(), `"used_for"`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user