Skip to content

Docs command - #71

Merged
IvanKiral merged 6 commits into
masterfrom
docs_command
Sep 21, 2026
Merged

IvanKiral merged 6 commits into
masterfrom
docs_command

Conversation

@IvanKiral

@IvanKiral IvanKiral commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

kontent docs search|endpoint|object <query> looks up Kontent.ai Learn docs and API reference from the terminal, so an agent (or a human) driving kontent mapi can find the right endpoint and payload shape without leaving the CLI. It talks to the Learn-MCP service (https://learn-mcp.kontent.ai, no auth, GET only) through a new src/lib/learn client on core-sdk's createFetchQuery. Each subcommand prints a JSON array of service-ranked candidates; --limit (1-10) and --compact on all three, --api filter on search. The zod/mini schemas declare only the fields the CLI reads, so unknown keys pass through to stdout. Empty query, no match and request failure are distinct error kinds, and no-match hints point at docs search or at dropping --api.

Agent evals harness (evals/, opt-in) runs the Agent SDK against the built CLI on one cloned environment, then grades the resulting state through the Management SDK with deterministic checks. The agent gets Bash (confined to a workspace dir) and WebFetch (kontent.ai only, key-in-URL denied); the policy is a pure reducer wired into the PreToolUse hook. Seven tasks run sequentially in dependency order; a task whose parent did not PASS is recorded BLOCKED. Each run writes run.json, a markdown report, per-task traces, raw SDK messages and a shim log of every kontent invocation to evals/results/ (git-ignored). The paid run is gated on EVALS_MAPI_KEY/EVALS_SOURCE_ENV_ID and never part of pnpm test or CI; the harness's own unit tests do run in pnpm test. Adds @anthropic-ai/claude-agent-sdk as a dev dependency. Playbook in evals/README.md.

kontent mapi fixes from the eval runs:

  • An empty 2xx body (e.g. 204 on publish) now logs HTTP <status> <text> on stderr instead of leaving both streams silent.
  • The not-logged-in error lists every credential source: kontent login, --mapiKey, Authorization header, KONTENT_MAPI_KEY.
  • A blank --envId is rejected before any request goes out.
  • Help clarifies that --envId is prepended to the path and points at kontent docs for endpoint lookup.

Docs and infra: each command's README now lives next to its module (project/sample/bootstrap/), and generateCommandDocs.ts resolves the page folder from the filesystem. test/helpers/environment.ts and requiredEnv.ts are extracted from the e2e helpers and shared with evals. CLAUDE.md, the root README table and .env.template are updated.

Checklist

  • Code follows coding conventions held in this repo
  • Automated tests have been added
  • Tests are passing
  • Docs have been updated (if applicable)
  • Temporary settings (e.g. variables used during development and testing) have been reverted to defaults

How to test

pnpm build
node dist/index.js docs search "publish a variant" --limit 3
node dist/index.js docs endpoint "upsert language variant"
node dist/index.js docs object "rich text element" --compact
node dist/index.js docs search "webhook" --api delivery_api
node dist/index.js docs search ""            # exits 1, empty-query message on stderr

For mapi: run kontent mapi types --envId "" (rejected before any request) and, while logged out with no key set, kontent mapi types --envId <id> (credential hint on stderr). Publishing a variant with -X PUT now prints HTTP 204 No Content on stderr.

For the evals run, set EVALS_MAPI_KEY and EVALS_SOURCE_ENV_ID in .env, make sure ANTHROPIC_API_KEY is unset, and run pnpm evals:run. Results land in evals/results/<date>-<time>-<model>/.

Generator places a leaf's page in its own folder when it has one.
Drop the generated edit hint comment; bootstrap moves to its folder.
Semantic lookup over Kontent.ai Learn for agents, JSON on stdout.
mapi --help points at it.
@IvanKiral
IvanKiral requested a review from a team as a code owner September 17, 2026 12:56
@IvanKiral
IvanKiral merged commit a3efea2 into master Sep 21, 2026
2 checks passed
@IvanKiral
IvanKiral deleted the docs_command branch September 21, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant