blade-code
AGENTS.md181 starsChanged 11 months agoMITView on GitHub
Always respond in Chinese. Blade Code is a modern AI-powered coding assistant with CLI + Web UI, built with React + Ink (CLI) and React + Vite (Web), using TypeScript. - packages/cli/package.json is the only authoritative npm version. The root package.json version is private monorepo metadata. - Release each independent feature or fix as its own npm patch version. - Keep implementation, release metadata, and any qualification fix in separate commits so the exact candidate is auditable. - Serialize releases.…
- Deletes or force-pushes
- Installs packages
- Commits and pushes
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 35,337 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.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
17 rules. About 0 are common, 7 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 3
Always respond in Chinese.
- Distinctive: line 72
Use TypeBox schemas for tool parameters (not Zod)
- Distinctive: line 88
Keep implementation, release metadata, and any qualification fix in separate commits so the exact candidate is auditable.
- Very specific: line 96
Start from a clean main synchronized with origin/main.
- Distinctive: line 97
Commit the implementation or fix before preparing release metadata.
- Distinctive: line 99
Update both changelogs with the same version heading and equivalent content:
- Very specific: line 103
Update related bilingual user documentation when behavior is user-facing.
- Very specific: line 104
Do not edit generated docs/changelog.md or docs/en/changelog.md.
- Very specific: line 105
Commit release metadata as chore: release v<version>.
- Very specific: line 146
Do not add a separate npm dist-tag add step unless the npm Trusted Publisher is explicitly configured with Allow npm dist-tag.
- Distinctive: line 150
Do not use legacy long-lived npm tokens or the old token helper scripts.
- Very specific: line 164
If npm publish succeeds but a later step fails:
- Distinctive: line 166
Do not rewrite the public tag or attempt to republish the immutable npm version.
- Very specific: line 168
Verify npm view blade-code@<version> version and the latest dist-tag.
- Very specific: line 169
Create only the missing GitHub Release from the matching CHANGELOG.md section with gh release create ...
- Very specific: line 173
If CI exposes a newly disclosed transitive vulnerability, update the smallest compatible dependency or lockfile entry, run bun audit …
- Very specific: line 179
Verify the immutable version, latest, GitHub Release, remote tag, and clean worktree:
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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
Always respond in Chinese.
Project Overview
Blade Code is a modern AI-powered coding assistant with CLI + Web UI, built with React + Ink (CLI) and React + Vite (Web), using TypeScript.
Quick Commands
# Development
bun run dev # Start CLI dev mode (watch)
bun run dev:web # Start CLI + Web server
bun run build # Build CLI
# Running
blade # Start interactive CLI
blade web # Start Web UI (opens browser)
blade serve # Start headless server
# Testing & Quality
bun run test:all # Run all tests
bun run lint # Run linter
bun run type-check # TypeScript type checkingArchitecture
Monorepo Structure
Blade/
├── packages/
│ ├── cli/ # blade-code - CLI core (npm package)
│ │ └── src/
│ │ ├── agent/ # Stateless Agent core
│ │ ├── tools/ # Tool system (builtin, execution, registry)
│ │ ├── server/ # Web server (Hono)
│ │ ├── mcp/ # MCP protocol support
│ │ ├── context/ # Context management
│ │ ├── config/ # Configuration management
│ │ ├── ui/ # Terminal UI (React + Ink)
│ │ ├── store/ # State management (Zustand)
│ │ ├── services/ # Service layer (Chat, Session, etc.)
│ │ ├── services/pi/ # pi-ai runtime adapter
│ │ ├── schema/ # TypeBox runtime wrapper
│ │ ├── commands/ # CLI subcommands (serve, web, mcp, etc.)
│ │ ├── prompts/ # Prompt templates
│ │ ├── slash-commands/ # Slash commands
│ │ ├── skills/ # Skills system
│ │ ├── hooks/ # Hooks system
│ │ └── blade.tsx # Entry point
│ └── vscode/ # blade-vscode - VSCode extension
├── docs/ # User documentation (Docsify)
└── .blade/ # Project-level configKey Design Principles
- Stateless Agent: Agent doesn't store session state; all state passed via context
- Tool System: Unified tool registration, execution, and validation with TypeBox schemas
- Permission Control: Three-level permission system (allow/ask/deny)
- Session Management: Multi-session support with resume and fork capabilities
- pi-ai Runtime: Single LLM abstraction layer; model metadata from catalog, not hardcoded
Code Style
- TypeScript strict mode
- Biome for linting and formatting (single quotes, semicolons, 88 char line width)
- Avoid
anytype - Use TypeBox schemas for tool parameters (not Zod)
Testing
- Test framework: Vitest
- Tests location:
packages/cli/tests/ - Run tests:
bun run test:all - Integration tests must use real API calls, no mocks
Release Process
Release Boundaries
packages/cli/package.jsonis the only authoritative npm version. The rootpackage.jsonversion is private monorepo metadata.- Release each independent feature or fix as its own npm patch version.
- Keep implementation, release metadata, and any qualification fix in separate commits so the exact candidate is auditable.
- Serialize releases. Do not push multiple new release tags in one batch:
npm assigns
latestwhen each publish completes, so concurrent releases can leavelatestpointing at an older version.
Prepare and Qualify the Exact Candidate
- Start from a clean
mainsynchronized withorigin/main. - Commit the implementation or fix before preparing release metadata.
- Bump
packages/cli/package.json. - Update both changelogs with the same version heading and equivalent content:
CHANGELOG.mdis the English authoritative source consumed by npm andVersionChecker.CHANGELOG.zh.mdis the manually synchronized Chinese source.
- Update related bilingual user documentation when behavior is user-facing.
Do not edit generated
docs/changelog.mdordocs/en/changelog.md. - Commit release metadata as
chore: release v<version>. On that exact commit, run the pre-tag gate:
scripts/verify-release-candidate.sh <version>The script codifies steps 7-8 of this checklist: it refuses a dirty worktree, requires matching headings in both changelogs, blocks reuse of a local or remote tag and of an existing npm version, and then runs
bun install --frozen-lockfile,bun run build,bun run test:all,bun run lint, andbun run type-check.bun run lintincludes the repository-wide Biome format check, so package-only lint commands are not an equivalent gate. Paid real-API qualification remains separate and must be run when the affected release matrix requires it.- The script also re-checks that the worktree is clean after the gate; abort if any step fails before continuing to tag creation.
Extract the exact English changelog section into a temporary notes file and create an annotated tag:
git tag -a v<version> -F <release-notes-file> git cat-file -t v<version> # must print: tag git rev-list -n 1 v<version> # must equal the qualified candidate SHAPush the branch and one release tag:
git push origin main git push origin v<version>
Automated Publication
.github/workflows/publish.ymlruns the full reusable CI workflow before publishing.- The workflow validates that
v<version>matchespackages/cli/package.json, builds again, upgrades npm, publishes with Trusted Publishing (OIDC), and ensures a GitHub Release exists. - npm publishing must use
npm publish --access public --tag latest. - Do not add a separate
npm dist-tag addstep unless the npm Trusted Publisher is explicitly configured with Allow npm dist-tag. Without that permission npm returnsE403after a successful publish and prevents later workflow steps, including GitHub Release creation. - Do not use legacy long-lived npm tokens or the old token helper scripts.
- Publication is idempotent: an existing npm version is skipped and an existing GitHub Release is retained.
Monitor and Recover
Monitor the tag workflow until the publish job completes:
gh run list --workflow=publish.yml --limit=5
gh run view <run-id> --json status,conclusion,jobs
gh run view <run-id> --log-failedIf npm publish succeeds but a later step fails:
- Do not rewrite the public tag or attempt to republish the immutable npm version.
- Verify
npm view blade-code@<version> versionand thelatestdist-tag. - Create only the missing GitHub Release from the matching
CHANGELOG.mdsection withgh release create ... --verify-tag. - Fix the workflow in a separate patch release.
If CI exposes a newly disclosed transitive vulnerability, update the smallest
compatible dependency or lockfile entry, run bun audit --audit-level=critical,
and qualify that fix as its own patch release.
Post-Release Verification
Verify the immutable version,
latest, GitHub Release, remote tag, and clean worktree:npm view blade-code@<version> version npm view blade-code dist-tags.latest gh release view v<version> git ls-remote --tags origin refs/tags/v<version> git status --short --branch- npm metadata can appear before the tarball CDN is ready. If installation
returns tarball
404, wait and retry; do not publish the version again. Finish with a clean-directory installation smoke test:
tmpdir="$(mktemp -d)" trap 'rm -rf "$tmpdir"' EXIT cd "$tmpdir" npm init -y >/dev/null 2>&1 npm install --ignore-scripts blade-code@latest node -p "require('./node_modules/blade-code/package.json').version" ./node_modules/.bin/blade --versionThe installed package version, CLI-reported version, and npm
latestdist-tag must all equal the released version.
The docs site (docs/) is bilingual: Chinese is the default under the docs root
and English lives under docs/en/. docs/changelog.md (zh) and
docs/en/changelog.md (en) are build artifacts synced from CHANGELOG.zh.md
and CHANGELOG.md by the Deploy Docs workflow — do not edit them directly.
Documentation
- User docs:
docs/ - README.md - Project overview
- CONTRIBUTING.md - Contribution guide
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.

