bkn-sdk
AGENTS.md26 starsChanged 4 months agoApache-2.0View on GitHub
Entry point for AI agents (Claude Code / Codex / others) working in this repo. Read this first, then load the relevant repository documents below. Before working in any subdirectory, locate and read every AGENTS.md from the repository root through that target directory; rules in the more specific (deeper) file take precedence.
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- create-bknSkill
- create-skillSkill
- referencesSkill
- openbknSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 4
Read this first, then load the relevant repository documents below.
- Distinctive: line 22
Clarify material ambiguity: Before editing, ask for direction when an ambiguity would materially change scope, behavior, risk, or the …
- Distinctive: line 24
Verification handoff: After implementing a change, report relevant edge cases and any remaining test-coverage gaps along with the commands …
- Distinctive: line 94
Every command sits in one of four sections, and the vocabulary is the same at every level: GROUPS nests deeper, READ changes nothing, RUN …
- Distinctive: line 102
When you add a command, it is not done until:
- Very specific: line 116
if it is READ, scripts/capture-returns.mjs can reach it — rerun that against a live deploy to refresh src/help/returns.json.
- Distinctive: line 126
All code comments, docstrings, and log messages in English.
- Very specific: line 138
Default list limit = 30; query/preview limit = 50.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Entry point for AI agents (Claude Code / Codex / others) working in this repo.
Read this first, then load the relevant repository documents below. Before working in any subdirectory, locate and read every AGENTS.md from the repository root through that target directory; rules in the more specific (deeper) file take precedence.
Read before doing anything
| Topic | File |
| Architecture & module boundaries | ARCHITECTURE.md |
| Reliability conventions | docs/RELIABILITY.md |
| Security conventions | docs/SECURITY.md |
| Testing and quality expectations | docs/QUALITY_SCORE.md |
| Non-trivial development workflow | docs/superpowers/workflow.md |
| Issue templates (bug / feature / task) | .github/ISSUE_TEMPLATE/ |
| Pull request template | .github/pull_request_template.md |
Hard rules for Agents
- Review before external writes: Unless the requester explicitly directs otherwise, after making and verifying code changes, present the working-tree diff for review first. Do not commit, push, create or update a PR, or post Issue/PR comments before the requester approves.
- Language: Communicate with users in Chinese by default. Use another language only when the requester explicitly asks for it or the artifact itself requires it.
- Clarify material ambiguity: Before editing, ask for direction when an ambiguity would materially change scope, behavior, risk, or the intended solution; otherwise proceed with a stated, reasonable assumption.
- Bug regression coverage: For bug fixes, add or update a focused regression test that demonstrates the reported failure whenever it is practical.
- Verification handoff: After implementing a change, report relevant edge cases and any remaining test-coverage gaps along with the commands run.
- Issue / PR templates: Before creating an Issue, select the matching template under
.github/ISSUE_TEMPLATE/and preserve its structure when filling in all applicable sections. Before creating or updating a PR, read and fully complete.github/pull_request_template.md. Do not delete required sections; mark non-applicable items explicitly with a brief reason. - Only pick up Issues labeled
agent-ready(acceptance criteria complete + independently doable) that are unassigned. Self-assign to lock. - Acceptance criteria: a human approves them (label
ac-approved) before an Issue becomesagent-ready. You may draft them for human approval. - Do not change
engines.nodecasually — and never as a side change. Treat it like the risky operations below: propose it on its own, say what it excludes, and wait for an Owner. It rode into 0.1.4 inside an unrelated bigint fix, under a sub-commit titled "clarify node 24 support", and nothing in the pipeline objected. engines.nodedecides installability, not preference. npm does not error on a floor the caller cannot meet: resolving a range, it skips that version and installs the previous one with no warning at all, so raising the floor removes the release from everyone below it without telling any of them. (EBADENGINE appears only when a caller pins the exact version — which nobody does for a release they do not know exists.) 0.1.4 declared>=24.19.0on the reasoning that Node 22 had entered maintenance;npm i @openbkn/bkn-sdkthen quietly returned 0.1.3 on every Node below that, and the release looked from the outside like it had never happened. The floor is the highest version a dependency or language feature actually requires — todayundici's>=22.19.0and nativeJSON.rawJSON/JSON.parsesource-text access — and it must equal thenode-versiontheengines-floorCI job runs, whichtest/unit/engines-floor.test.tsenforces. Support policy goes in the README; it does not belong in the field that decides whether anyone can install the package.- Risky operations (deploy, delete/modify data, schema migration, prod config, secrets/permissions, major dependency bumps,
engines.nodechanges, cross-service breaking changes): do not execute. Post the three-part confirmation (what / blast radius / rollback), apply labelawaiting-confirmation, and wait for an Owner to applyowner-confirmed. - You may never: approve or merge a PR, bypass or skip CI, or act without the confirmation above. Code review and the merge gates are human-only.
- Open PRs with
Closes #<issue>and write back progress as Issue/PR comments. Label your PRsby-agent. - Stuck / off-track / tests won't pass → comment the blocker, return the Issue to triage, clear your assignee, label
needs-human.
Commits & branches
- Conventional Commits:
type(scope): subject(feat/fix/chore/refactor/docs/test; scope = service name). - Branch from the Issue's "Create a branch"; one PR per Issue, kept small.
- Branch names must use a valid type prefix and at most two path segments after it:
<type>/<description>,<type>/<issue-number>-<description>, or<type>/<module>/<description>; segments start with lowercase letters or digits and may contain-,., or_. - Release branches are the sole exception: use
release/X.Y.Zwith a stable version that exactly matches rootVERSION; RCs arevX.Y.Z-rc*tags, not release branch suffixes.
bkn-sdk-specific guidance
Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform. One toolkit, two audiences: end-users/agents (knowledge, agents, search, chat) and platform operators (org, user, role, model, audit). Backend-only; no web UI. Published to npm under @openbkn.
This file is a map, not a manual. Start here, then follow links into
docs/. Keep it under 120 lines.
Priority order
- Explicit user instructions (this chat).
- This harness —
AGENTS.md, thendocs/. - Model defaults.
Tech stack
| Concern | Choice |
| Language | TypeScript (ESM), Node ≥ 22.19.0 |
| CLI | commander + @clack/prompts (prompts) + chalk/cli-table3 (output); no TUI |
| Validation | zod at IO boundaries |
| HTTP | native fetch |
| Build | tsup (dual: library + openbkn bin) |
| Test | vitest (UT), separate E2E entry |
| Lint + format | biome (lint + format in one) |
| Package manager | npm (single package) |
Repo layout
| Path | Holds |
src/commands/ | CLI command handlers (parse argv → call resource → print) |
src/resources/ | Programmatic API surface (the exported SDK) |
src/api/ | Thin HTTP clients per backend service |
src/auth/ | OAuth, token resolution |
src/config/ | Config store, base-url/TLS resolution |
src/utils/ | Output formatting, errors, prompts |
src/help/ | Grouped-help formatter, section taxonomy, captured return shapes |
src/index.ts | Library entry (exports resources/) |
src/cli.ts | CLI entry (openbkn bin) |
docs/ | Harness: design, specs, plans, references |
Architecture (layered)
Dependency direction is one-way: commands → resources → api → auth/config. Commands never call fetch directly; resources never parse argv. See ARCHITECTURE.md.
Self-describing surface
An agent reaches this CLI with no docs and has to work out what exists, what each
thing costs, and where an id comes from — from the CLI itself. That is a contract,
not a nicety, and it is checked by test/unit/help-contract.test.ts.
Every command sits in one of four sections, and the vocabulary is the same at every
level: GROUPS nests deeper, READ changes nothing, RUN acts without
changing configuration, WRITE changes platform state. Sections are assigned by
structure and verb in src/help/grouped-help.ts; a name the verb table does not know
falls into COMMANDS, which is visible rather than silently wrong. Override with
groupChildren(cmd, {...}) in the command module — never by editing the verb table
for a one-off.
When you add a command, it is not done until:
- it has a one-line description that says what it answers, not what it calls;
- its section is right — if the verb table guessed, check that it guessed correctly;
- ids it takes are resolvable: add the minting command to
ID_SOURCES/GROUP_ID_SOURCESinsrc/commands/describe.ts, orARGUMENT_OVERRIDESwhen a command takes two different kinds of id; - anything a caller must know before running it (order of work, a gate, a field that
decides success) is in the group's
guide()— prose belongs there, not in 30 per-command descriptions; --dry-runstill sends nothing: the preview hook lives intlsFetch, the one choke point, and redacts credential-shaped headers and body fields;--probeknows which service answers it (COMMAND_SERVICEinsrc/commands/probe.ts);- if it is READ,
scripts/capture-returns.mjscan reach it — rerun that against a live deploy to refreshsrc/help/returns.json. READ means "changes nothing on the platform"; a command that writes to the local filesystem goes in its blacklist.
openbkn describe [path] [--json] [--depth n] [--probe] is the machine-readable view
of all of it. Check your work by reading it, not by reading the source.
Secrets & logging
- Tokens live in
~/.bkn/(config store) and env (BKN_BASE_URL,BKN_TOKEN). Never commit, never log. - All code comments, docstrings, and log messages in English.
- Redact tokens/PII before any output. See docs/SECURITY.md.
Testing bar
npm run lint(biome + tsc--noEmit) andnpm test(vitest UT, no external deps) must pass before "done".- UT fully mocked; E2E (real backend) is a separate entry, not part of
npm test. - New behavior ships with a minimal test or runnable example. See docs/QUALITY_SCORE.md.
- A release is not verified until it installs.
npm testpassing on the developer's Node says nothing about whether a user can obtain the package: runnpm i <pkg>on the declared floor and check the version that actually lands. 0.1.4 passed every check and was still unreachable for most callers.
Conventions
- Default list
limit= 30; query/previewlimit= 50;--limitalways overrides. - Global
--jsonfor machine-readable output where supported. - This is a rewrite, not a port: reference the legacy user/agent-SDK and operator-CLI predecessors, but slim and unify — do not copy verbatim. The legacy Python SDK stays dropped;
python/is a different thing — a generated, read-only OSDK, not a hand-written port of this surface.
Domains
Behavior per product area lives in docs/product-specs/: knowledge-networks · datasources · model-factory · skills-toolboxes · vega · bkn-trace · identity-access.
How to use this harness
| Scenario | Start here | Then |
| New feature | docs/product-specs/<domain>.md | Plan in docs/exec-plans/active/ → implement → move to completed/ |
| Bug fix | docs/RELIABILITY.md + docs/SECURITY.md | Fix → update docs/QUALITY_SCORE.md |
| Architecture change | ARCHITECTURE.md | Add docs/design-docs/<name>.md → link from index → implement |
Non-trivial work follows the Superpowers loop (design → plan → execute → verify): docs/superpowers/workflow.md.
For tech debt, doc maintenance, and other workflows see docs/PLANS.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

