docs(cli): README / AGENTS.md / CHANGELOG + CI parity test

Wire-contract documentation and the CI check that keeps it honest.

* cli/README.md gains a verbatim --help block (top-level + subtrees),
  an Exit codes table covering 0/1/2/3/4/5/6/7/10/124/130, a "Status
  vs check" verb-pair subtable, and a "doc wait" paragraph spelling out
  the four exit codes (0 / 1 / 124 / 130). The api passthrough note
  trims storage provider out of the deep-config list now that
  kb create --storage-provider is a polished flag.
* cli/AGENTS.md becomes the contributor guide: build/test, CRUD flag
  conventions, the status/check verb pattern, long-poll wait commands,
  the SetAgentHelp pattern, and a full Error code reference with 35
  typed codes mapped to namespaces, exit codes, retryable / hint
  guidance. Reference section is bracketed by HTML markers so a CI
  parity test can keep it in sync with AllCodes().
* cli/internal/cmdutil/errors_doc_test.go enforces parity: every code
  in AllCodes() must appear in AGENTS.md inside the markers, and
  AGENTS.md must not reference codes that no longer exist. Fails CI
  if a new typed code is added without documentation.
* CHANGELOG.md gets the v0.6 entry: BREAKING (--json / --no-stream /
  WEKNORA_SDK_DEBUG / kb create --name), Added (--format / --jq /
  doc wait / --log-level / kb-and-agent status & check / multi-id
  delete / api --paginate / MCP schema extension / SetAgentHelp /
  signal-aware ctx / kb create --storage-provider / new operation.*
  namespace), Changed (multi-id partial-failure exit code, doc upload
  FlagError, --log-level FlagError, multi-id stdout cleanup, README /
  AGENTS.md changes), with a Migration from v0.5 section walking
  every BREAKING through its v0.6 replacement.
This commit is contained in:
nullkey
2026-05-18 01:38:42 +08:00
committed by lyingbug
parent 34bb0b5096
commit 7611d59d71
9 changed files with 388 additions and 68 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
// Package agentcmd holds the `weknora agent` command tree:
// list / view / invoke / create / edit / delete. The directory is named
// `agent/` (matches cobra noun-verb convention) but the Go package is
// `agentcmd` to avoid colliding with cobra's *cobra.Command identifier.
// `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/...). The CLI's
+3 -3
View File
@@ -1,7 +1,7 @@
// Package chunkcmd implements the `chunk` verb subtree for managing
// Package chunkcmd implements the `chunk` command subtree for managing
// document chunks in a knowledge base. The directory is named `chunk/`
// (cobra noun-verb convention) but the Go package is `chunkcmd` to
// avoid colliding with cobra's *cobra.Command identifier.
// to match the cobra subcommand; the Go package is `chunkcmd` to avoid
// colliding with cobra's *cobra.Command identifier.
//
// "chunk" in this subtree refers to indexed pieces of a knowledge
// document (server resource: GET/DELETE /chunks/...). Each document
+2 -3
View File
@@ -1,6 +1,5 @@
// Package contextcmd holds `weknora context` command tree
// (list / add / remove / use). Uses the `<noun> <verb>` shape
// consistent with the rest of this CLI.
// Package contextcmd holds the `weknora context` command tree
// (list / add / remove / use).
//
// Package name `contextcmd` (not `context`) to avoid shadowing stdlib context.
// The cobra Use: string is "context" - this is what users type.
+8 -8
View File
@@ -88,14 +88,14 @@ func NewRootCmd(f *cmdutil.Factory) *cobra.Command {
v, commit, date := build.Info()
cmd := &cobra.Command{
Use: "weknora",
Short: "WeKnora CLI - RAG knowledge base from your terminal",
Long: `WeKnora CLI lets you authenticate, browse knowledge bases, and run
hybrid searches against a WeKnora server from your shell or an AI agent.`,
Example: ` weknora auth login --host=https://kb.example.com # one-time setup
weknora kb list # list knowledge bases
weknora kb view <id> # show one
weknora search chunks "your question" --kb=<id> # hybrid retrieval
weknora doctor --format json # health check (agent-readable)`,
Short: "WeKnora CLI",
Long: `Command-line client for the WeKnora RAG server. Manage knowledge bases
and documents, run hybrid search, chat with grounded answers, or expose
a curated read-only MCP tool surface for AI agents.`,
Example: ` weknora auth login --host=https://kb.example.com
weknora kb list
weknora chat "summarise the design doc"
weknora doctor --format json`,
SilenceUsage: true,
SilenceErrors: true,
// Version makes cobra auto-register a `--version` global flag that