BT AI development guide

BT AI development guide

BT AI development guide

Function

The BT website provides public knowledge endpoints for coding assistants, IDEs, and documentation tools. They cover language semantics, syntax, the standard library, Web and desktop development, networking, devices, extensions, and FFI. Clients can retrieve only the material needed for a task.

When providing a separate URL to the AI, use the following:

The guide instructs clients to search first, then read the relevant function contract, document, stable knowledge block, or module. These endpoints return public documentation only; they do not accept user questions, project source, model configuration, accounts, API keys, or private data.

Language and canonical URLs

The AI guide, reference modules, function contracts, search results, and current offline bundle use English as their authoritative language. Chinese category keywords remain available as search aliases. Assistants should respond in the user's requested language and follow the target project's code conventions.

Human documentation remains available in English and Simplified Chinese. All localized website URLs put the language first: /en/docs/{path}, /zh-hans/docs/{path}, /en/md/docs/{path}, and /zh-hans/md/docs/{path}. AI search links always select English explicitly, independently of browser language or cookies. /ai and /llms.txt remain global English machine entry points.

Legacy /md/docs/en/{path} redirects permanently to /en/md/docs/{path}. /md/docs/zh-hans/{path} and the historically Chinese /md/docs/{path} redirect to /zh-hans/md/docs/{path}. The zh-cn alias and language-tag casing normalize to lowercase zh-hans or en. Missing document paths default to index; missing documents and unsafe paths return 404.

Syntax

Recommended reading order:

1. Read only /ai for the first time;

2. Use /ai/search to query the API name, module name or runtime name;

3. Use a symbol contract directly. For a doc result, read markdown_url; for a block result, read content_url.

4. Read the entire module only when the system design or semantics are uncertain;

5. The complete index and offline package are only for client caching, offline development or knowledge tool integration.

Parameters

Path Parameters

FieldTypeRequiredDefault valueValid range or optional valueMeaning
module_idStringFor modules and blocksNoneA stable ID in modules[].idKnowledge module to read.
block_nameStringFor blocksNoneSearch results Stable block name in content_urlSingle knowledge block to read.
pathStringFor documentsNoneSearch results Documentation path in markdown_urlFunction or topic to read Markdown.
knowledge_versionStringFor bundlesNoneknowledge_versionThe immutable offline package version of the manifest to download.

Query Parameters

FieldTypeRequiredDefault valueValid range or optional valueMeaning
qStringFor searchNone1 to 100 characters; space-separated API, module, or runtime keywordsEvery non-empty term must match the same indexed entry.
limitIntNo81..20; invalid or non-positive values use 8; values above 20 are capped at 20The maximum number of search results returned.

Conditional request header

FieldTypeRequiredDefault valueValid range or optional valueMeaning
If-None-MatchStringNoNoneA previous ETag; weak tags and comma-separated lists are supportedReturns 304 Not Modified when the manifest, index, block, module, or bundle is unchanged.
If-Modified-SinceStringNoNoneLast responded Last-Modified304 Not Modified is returned when If-None-Match is not sent at the same time and the release time is consistent.

Return Value

AI guide

GET /ai returns a condensed plain text with Markdown structure as text/plain; charset=utf-8 to avoid rejection of response by AI crawling components that only accept common web page text types. The main text includes:

  • the most token-saving forced reading strategy;
  • search, precise documentation, knowledge blocks, modules and offline package addresses;
  • module routing, dependency and token estimation;
  • shorthand for running, building and accepting BT and bt-app.

It is not a full document, and AI should not guess specific function signatures based only on the entry summary.

Knowledge Manifest

GET /ai/manifest Returns UTF-8 JSON:

FieldTypeRequiredDefault valueValid range or optional valueMeaning
schema_versionIntYesNoneCurrently 1Manifest structure version.
bt_versionStringYesNoneThree-component versionBT version corresponding to knowledge.
knowledge_versionStringYesNoneYYYY.MM.DD.revisionThe only version released by this official knowledge.
updated_atStringYesNoneISO 8601Knowledge release time.
last_modifiedStringYesNoneRFC 7231 HTTP DateThe last modified time used by the conditional request.
min_client_versionStringYesNoneThree-component versionThe minimum tool version that can read the current schema.
guide_urlStringYes/aiAbsolute path within the siteThe only standardized entrance for universal AI.
text_content_typeStringYestext/plain; charset=utf-8Fixed valueCompatible response type used by AI portals, precise documentation, knowledge blocks, and modules; the body still uses Markdown structure.
search_url_templateStringYesNoneWith {query} and {limit} placeholdersSmall results search interface template.
search_index_urlStringYes/ai/indexAbsolute path within the siteComplete search index address.
search_index_sha256StringYesNone64-character lowercase hexFull search index raw UTF-8 byte digest.
block_url_templateStringYesNoneWith {module_id} and {block_name} placeholdersA single knowledge block interface template.
docs_url_templateStringYes/en/md/docs/{path}With {path} placeholderCanonical English Markdown documentation URL template.
source_sha256StringYesNone64-character lowercase hexadecimalSHA-256 of the normalized English reference source.
bundle_formatStringYesbt-ai-bundle-json-v1Fixed valueComplete offline package format.
bundle_urlStringYesNone/ai/bundle/{knowledge_version}The current complete offline package address.
bundle_sha256StringYesNone64-character lowercase hexadecimalSHA-256 of the exact UTF-8 bytes of the offline bundle.
modulesArray[Object]YesNoneFixed module listKnowledge module metadata that can be read on demand.

modules[] Field:

FieldTypeRequiredDefault valueValid range or optional valueMeaning
idStringYesNoneStable module IDUnique identification of the module.
revisionIntYesNoneGreater than or equal to 1Module text revision number.
content_urlStringYesNone/ai/knowledge/{id}Markdown address of the entire module.
sha256StringYesNone64-character lowercase hexadecimalThe raw UTF-8 byte digest of the module.
approx_tokensIntYesNoneGreater than 0The approximate number of Tokens of the module.
runtimesArray[String]YesNonecli/web/desktop/extension/ffiModule applicable runtime.
tagsArray[String]YesNoneStable search tagModule topic tag.
depends_onArray[String]Yes[]Other module IDDependencies that should be considered before reading the entire module.
block_countIntYesNoneGreater than 0The number of stable knowledge blocks contained in the module.

Search for

GET /ai/search by keyword Return small UTF-8 JSON:

FieldTypeRequiredDefault valueValid range or optional valueMeaning
queryStringYesNoneQuery text normalized to lowercaseThis actual query.
limitIntYes81..20The upper limit of this result.
countIntYesNone0..limitActual returned quantity.
resultsArray[Object]Yes[]Function contract, document, or knowledge block resultExact symbols and exact paths take precedence, followed by related candidates.

results[] Common fields and branch fields:

FieldTypeRequiredDefault valueValid range or optional valueMeaning
kindStringYesNone
idStringYesNoneStable IDResult identification.
titleStringYesNoneNon-empty textResult title.
approx_tokensIntYesNoneGreater than 0Read the approximate number of Tokens for this result.
signatureStringsymbol YesNoneMarkdown inline codeFunction calling method.
parametersStringsymbol YesNoneTextParameter name, type and required rules.
defaultsStringsymbol YesNoneTextParameter default value.
returnsStringsymbol YesNoneTextReturn type and semantics.
exampleStringsymbol YesNoneMarkdown inline codeMinimal call example.
notesStringsymbol YesNoneTextBehavior boundaries and precautions.
limitsStringsymbol YesNoneTextContext, permissions, or resource restrictions.
categoryStringdoc YesNoneDocument CategoryThe exact category to which the document belongs.
markdown_urlStringdoc YesNone/en/md/docs/...The exact Markdown address that the AI should read.
html_urlStringdoc YesNone/en/docs/...Human readable page.
module_idStringFor symbol and blockNoneStable module IDThe module to which the knowledge block belongs.
runtimesArray[String]For symbol and blockNoneRuntime listKnowledge block applicable runtime.
tagsArray[String]block YesNoneTag listKnowledge block topic tags.
content_urlStringblock YesNone/ai/block/...The address of the single block of Markdown that the AI should read.
sha256Stringblock YesNone64-character lowercase hexadecimalSingle block text summary.

Full Search Index

GET /ai/index Returns a JSON index of all accurate documents and stable knowledge chunks. It is suitable for IDE or local tools to build caches, but is not suitable for direct use as a model context for ordinary coding tasks.

FieldTypeRequiredDefault valueValid range or optional valueMeaning
schema_versionIntYesNoneCurrently 1Index structure version.
knowledge_versionStringYesNoneCurrent knowledge versionRelease version to which the index belongs.
source_sha256StringYesNone64-character lowercase hexadecimalSummary of the knowledge source corresponding to the index.
entriesArray[Object]YesNonesymbol/doc/block Mixed ListAll searchable entries; internally search_text and exact_queries are search matches only.

Single knowledge block and the entire module

GET /ai/block/{module_id}/{block_name} returns only a stable Markdown knowledge block; GET /ai/knowledge/{module_id} returns the entire module. Both transfer Markdown body as text/plain; charset=utf-8 and provide SHA-256 and conditional caching response headers.

Knowledge chunks are usually much smaller than the entire module. For example, when you only need the String method summary, you should read the corresponding knowledge block; when you only need the precise signature of string.replace, you should directly use the symbol function contract in the search results.

Complete offline package

GET /ai/bundle/{knowledge_version} Returns bt-ai-bundle-json-v1 JSON:

FieldsTypeRequiredDefaultValid range or optionalMeaning
schema_versionIntYesNoneCurrently 1Full package structure version.
bundle_formatStringYesNonebt-ai-bundle-json-v1Complete package format.
knowledge_versionStringYesNoneConsistent with the requested versionKnowledge version in the package.
manifestObjectYesNoneManifest SnapshotTo avoid self-referential hashes, bundle_sha256 is fixed to null within the package.
block_indexObjectYesNoneschema 1Line number, label, token estimate and summary of all stable knowledge blocks.
modulesObject[String,String]YesNoneKey is module IDAll modules Markdown text.

Response headers

FieldTypeRequiredDefault valueValid range or optional valueMeaning
Content-LanguageStringAI guide, errors, search, versioned knowledge, and raw documentsNoneen for AI knowledge; en or zh-hans for raw documentsResponse language; explicit URLs are independent of browser preferences.
Content-LocationStringAI guide and raw documentsNoneAbsolute canonical HTTPS URLCanonical location of the returned text.
Content-TypeStringYesNoneJSON uses application/json; AI text uses text/plain; charset=utf-8Response body format; plain text body remains Markdown Titles, tables and code blocks.
Cache-ControlStringYesNoneFirst read entry 60 seconds; search/knowledge 5 minutes; version package one year and immutableClient cache strategy; first read entry shortens the cache, so that compatibility adjustments such as content types can take effect quickly.
ETagStringFor manifest, index, blocks, modules, and bundlesNoneHTTP entity tagConditional request value.
Last-ModifiedStringFor manifest, index, blocks, modules, and bundlesNoneRFC 7231 HTTP DateConditional request value.
X-BT-Knowledge-VersionStringFor manifest, index, search, blocks, modules, and bundlesNoneCurrent knowledge versionThe knowledge version to which the response belongs.
X-Content-SHA256StringIndexes, knowledge chunks, modules, and complete packages areNone64-character lowercase hexadecimalA summary of the current response body.
Access-Control-Allow-OriginStringThe AI interface is*Fixed to *Allow public knowledge clients to read across domains.

Code Examples

The following BT script searches for string.replace, reading the minimal function contract directly:

The following BT script verifies a single knowledge block by manifest:

Notes

  • Normal coding tasks do not read the full search index, the full module set, or the offline package; search first and read by minimal results.
  • /llms.txt is an automatically discovered alias agreed by AI tools, and the text format is still Markdown; only https://btlang.org/ai is used when developers actively provide links.
  • AI portals, precise documentation, knowledge blocks and modules intentionally use the more compatible text/plain and do not change back to text/markdown which may be rejected by some web page reading components.
  • When the API name is known, search for category api_name or the complete symbol first, such as string replace, mysql begin, window.bt.call.
  • The same development task should always use one knowledge_version, and do not mix two versions in the middle of the task.
  • Modules, knowledge blocks, indexes or offline packages should be SHA-256 verified against the original UTF-8 bytes after downloading before being written to the official cache.
  • The 304 response has no body, the client should continue to use the local verified content.
  • When the official website is inaccessible, the tool can fall back to its own built-in and verified complete package; ordinary projects must not assume the existence of fixed local directories such as E:\bt-lang.
  • The project's own AGENTS.md, README, runtime file locations and test commands take precedence over this site's general recommendations.
  • Unknown paths, modules or knowledge blocks return 404, missing search terms return 400, non-GET requests return 405.