feat(cli): agent-first WeKnora CLI
The `weknora` command-line client for the WeKnora RAG server. Full command surface: kb / doc / chunk / session / message / agent / model / search / chat / auth / profile / link / api / mcp / skills / config / doctor / schema / exit-codes. Agent-first wire contract: JSON envelope by default, typed error codes mapped to stable exit codes, error.retry_argv / retryable / partial-failure status, global --dry-run preview, the exit-10 confirmation protocol for writes, and control/ANSI/Bidi input hygiene. Stateless env-credential auth (WEKNORA_API_KEY / WEKNORA_TOKEN + WEKNORA_HOST) for headless/CI/agent use. A curated read-only MCP tool surface (`mcp serve`) and embedded Agent Skills (`skills install`). Extensive unit + contract-golden tests and CI.
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/output"
|
||||
)
|
||||
|
||||
func TestAddDryRunFlag_RegistersFlag(t *testing.T) {
|
||||
@@ -78,27 +77,6 @@ func TestEmitDryRun_ApiPlanShape(t *testing.T) {
|
||||
assert.Equal(t, "foo", body["name"])
|
||||
}
|
||||
|
||||
func TestEmitDryRun_InjectsNotice(t *testing.T) {
|
||||
// Regression: dry-run envelope must carry the same _notice channel as
|
||||
// every other success envelope. PendingNotice is the system-level hook
|
||||
// used for deprecation / version_skew / security signals.
|
||||
output.PendingNotice = func() map[string]any {
|
||||
return map[string]any{"deprecation": "use weknora kb create-v2"}
|
||||
}
|
||||
t.Cleanup(func() { output.PendingNotice = nil })
|
||||
|
||||
var buf bytes.Buffer
|
||||
err := EmitDryRun(&buf, &FormatOptions{Mode: FormatJSON},
|
||||
DryRunPlan{Action: "kb.create", Args: map[string]any{"name": "x"}})
|
||||
require.NoError(t, err)
|
||||
|
||||
var got map[string]any
|
||||
require.NoError(t, json.Unmarshal(buf.Bytes(), &got))
|
||||
notice, ok := got["_notice"].(map[string]any)
|
||||
require.True(t, ok, "expected _notice field on dry-run envelope; got %v", got)
|
||||
assert.Equal(t, "use weknora kb create-v2", notice["deprecation"])
|
||||
}
|
||||
|
||||
func TestEmitDryRun_HonorsTTYIndent(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
err := EmitDryRun(&buf, &FormatOptions{Mode: FormatJSON, TTY: true},
|
||||
|
||||
Reference in New Issue
Block a user