@backendkit-labs/agent-coding

中文文档
0.28.4发布于 2026/10/28TypeScriptCommonJS近 30 天下载 2856

Coding agent profiles and tools for @backendkit-labs/agent-core

原始使用文档
文档目录33 节
  1. Table of contents
  2. Installation
  3. Quick start
  4. createCodingEngine
  5. Options reference
  6. Minimal setup
  7. Multiple providers
  8. With full orchestration
  9. With MCP servers
  10. With manual tool approval
  11. createCodingEngineFromConfig
  12. Providers
  13. DeepSeek
  14. OpenAI
  15. Anthropic (Claude)
  16. Ollama (local — no API key)
  17. OpenAI-compatible (Kimi, Grok, any endpoint)
  18. Built-in agents
  19. Selecting an agent
  20. Adding custom agents
  21. Project agents and skills need a trusted project
  22. Built-in tools
  23. Skill packs
  24. Orchestration pipeline
  25. Custom orchestration
  26. Reflection engine
  27. MCP server integration
  28. Multi-agent examples
  29. Feature implementation
  30. Security audit
  31. Database migration
  32. Full stack refactor
  33. Config file

@backendkit-labs/agent-coding

A production-ready coding agent engine built on @backendkit-labs/agent-core. Bundles 10 specialized agents, filesystem tools, multi-provider support (DeepSeek, OpenAI, Anthropic, Ollama, Kimi, Grok), automatic stack detection, persistent memory, QA review, reflection, and an orchestration pipeline — all in a single createCodingEngine() call.

npm

Status: stable — Maintained and production-ready. No new features during the pilot phase.

Table of contents


Installation

npm install @backendkit-labs/agent-coding

All provider adapters are bundled — no separate packages needed.


Quick start

import { createCodingEngine } from '@backendkit-labs/agent-coding';

const engine = createCodingEngine({
  providers:       { deepseek: { apiKey: process.env.DEEPSEEK_API_KEY! } },
  defaultProvider: 'deepseek',
});

await engine.run('List all TypeScript files in src/ and tell me which ones have no tests');

That single call gives you: 10 specialized agents, filesystem tools (read/write/edit/search), persistent project memory, skill loading, and stack auto-detection.


createCodingEngine

The primary factory. Returns a fully configured AgentEngine.

Options reference

interface CodingEngineOptions {
  // Required
  providers:       ProvidersConfig;
  defaultProvider: string;

  // Agents and engine
  defaultAgent?:          string;       // default: 'general'
  workingDir?:            string;       // default: process.cwd()
  maxIterations?:         number;       // default: 100
  maxParallelAgents?:     number;       // default: 6

  // I/O
  transport?:             Transport;    // default: StdoutTransport

  // App identity
  appName?:               string;       // default: 'bk-agent' — used for ~/.{appName}/

  // Persistence
  disablePersistence?:    boolean;      // skip ProjectStore (useful for testing)

  // MCP servers
  mcpServers?:            MCPServerConfig[];

  // Context sharing
  subAgentContextMessages?: number;    // messages visible to sub-agents (recommend 10-20)

  // Iteration control
  onToolApproval?:   (toolName, agentId, argsPreview) => Promise<ToolApprovalDecision>;
  onIterationLimit?: (stats: IterationStats) => Promise<boolean>;
  onStep?:           (stats: IterationStats) => Promise<boolean>;

  // Orchestration
  orchestration?:    boolean | OrchestrationOptions;
}

Minimal setup

const engine = createCodingEngine({
  providers:       { deepseek: { apiKey: 'sk-...' } },
  defaultProvider: 'deepseek',
});

Multiple providers

const engine = createCodingEngine({
  providers: {
    deepseek:  { apiKey: process.env.DEEPSEEK_API_KEY! },
    anthropic: { apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-opus-4-8' },
    ollama:    { host: 'http://localhost:11434', model: 'llama3.2' },
  },
  defaultProvider: 'deepseek',
  // Each agent profile can specify a provider override
});

With full orchestration

const engine = createCodingEngine({
  providers:       { deepseek: { apiKey: '...' } },
  defaultProvider: 'deepseek',
  orchestration:   true,
  // Enables:
  //   intent detection → domain detection → risk scoring
  //   policy engine → agent routing → QA auto-review → reflection
});

With MCP servers

const engine = createCodingEngine({
  providers:       { openai: { apiKey: '...' } },
  defaultProvider: 'openai',
  mcpServers: [
    { name: 'github',   command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'],  env: { GITHUB_TOKEN: '...' } },
    { name: 'postgres', command: 'npx', args: ['-y', '@modelcontextprotocol/server-postgres'], env: { DATABASE_URL: '...' } },
  ],
  subAgentContextMessages: 15,
});

With manual tool approval

const engine = createCodingEngine({
  providers:       { deepseek: { apiKey: '...' } },
  defaultProvider: 'deepseek',
  onToolApproval:  async (toolName, agentId, argsPreview) => {
    const write = ['write_file', 'edit_file', 'run_command'];
    if (!write.includes(toolName)) return 'approve';
    console.log(`\n⚠  [${agentId}] ${toolName}:\n${argsPreview}\n`);
    const a = await prompt('Approve? (y/n/all): ');
    if (a === 'y')   return 'approve';
    if (a === 'all') return 'approve_all';
    return 'reject';
  },
});

createCodingEngineFromConfig

Reads credentials from ~/.{appName}/config.json. No code changes needed to switch providers:

import { createCodingEngineFromConfig } from '@backendkit-labs/agent-coding';

const engine = createCodingEngineFromConfig();

// With overrides
const engine = createCodingEngineFromConfig({
  workingDir:    '/my-project',
  orchestration: true,
});

Providers

DeepSeek

providers: {
  deepseek: {
    apiKey:       process.env.DEEPSEEK_API_KEY!,
    model?:       'deepseek-chat',    // default
    maxTokens?:   8192,
    temperature?: 0.7,
  }
}

OpenAI

providers: {
  openai: {
    apiKey:   process.env.OPENAI_API_KEY!,
    model?:   'gpt-4o',
    baseUrl?: 'https://api.openai.com/v1',
  }
}

Anthropic (Claude)

providers: {
  anthropic: {
    apiKey: process.env.ANTHROPIC_API_KEY!,
    model?: 'claude-sonnet-4-6',    // default
  }
}

Ollama (local — no API key)

# Prerequisites
ollama serve
ollama pull llama3.2
providers: {
  ollama: {
    host?:  'http://localhost:11434',
    model?: 'llama3.2',
  }
}

OpenAI-compatible (Kimi, Grok, any endpoint)

providers: {
  kimi: { apiKey: process.env.KIMI_API_KEY!, model: 'moonshot-v1-8k' },
  grok: { apiKey: process.env.GROK_API_KEY!, model: 'grok-3' },
  // Any OpenAI-compatible endpoint
  vllm: { apiKey: 'local', baseUrl: 'http://localhost:8080/v1', model: 'my-model' },
}

Built-in agents

Ten specialist agents are bundled. Orchestration routes tasks automatically; you can also select explicitly.

Agent IDSpecialty
generalGeneral-purpose — default starting point
architectSystem design, ADRs, architecture decisions
backend-agentAPIs, server logic, databases
frontend-agentReact, CSS, accessibility, UX
devops-agentCI/CD, Docker, Kubernetes, infra
database-agentSQL, indexes, migrations, query tuning
security-reviewerSecurity audits, OWASP, threat modeling
qa-engineerTest strategy, edge cases, QA reviews
documentation-agentDocs, READMEs, API docs, changelogs
refactoring-agentCode cleanup, technical debt, design patterns

Selecting an agent

await engine.run('Audit src/ for SQL injection risks', { agentId: 'security-reviewer' });

Adding custom agents

Create ~/.bk-agent/agents/my-agent.json:

{
  "id":           "my-agent",
  "name":         "My Custom Agent",
  "systemPrompt": "You are specialized in ...",
  "tools":        ["read_file", "run_command"],
  "provider":     "anthropic"
}

Loaded automatically — no code changes needed.

Project agents and skills need a trusted project

Agents in {project}/.bk-agent/agents/ and skills in {project}/.bk-agent/skills/ are the repository's content, not yours: a cloned repo could ship an agent that replaces the built-in orchestrator with its own prompt and tools. So they load only for a project you trusted. Your own agents and skills under ~/.bk-agent/ always load.

/trust              # is this project trusted, and what would its project layer load
/trust add          # trust it (records the real path in ~/.bk-agent/trusted-projects.json)
/trust remove       # stop trusting it
/trust list
  • Trust is by exact path: trusting ~/code does not trust a repository cloned inside it.
  • For a project that is not trusted, the engine emits a warning naming what was left out. Skills load right after /trust add; agents the next time the agent starts.
  • BK_TRUST_PROJECT=1 trusts every path (CI, containers). A host that decides by itself can pass trustedProject: true | false to createCodingEngine.
  • A missing or damaged trust file means nobody is trusted.

Built-in tools

All agents have access to these tools via CODING_TOOLS:

ToolDescription
read_fileRead a file by path
write_fileCreate or overwrite a file
edit_fileApply a targeted patch to a file
list_directoryList files in a directory
run_commandExecute a shell command
search_filesRecursive content search
save_contextWrite to session.md (persisted notes)
save_learningAppend to lecciones-aprendidas.md
save_auditWrite a structured audit entry
get_latest_auditRead the latest audit
list_auditsList audit entries
save_user_preferencePersist user preferences
update_sessionUpdate the in-progress session note

Skill packs

Built-in packs activate based on detected project stack:

PackActivates for
GLOBAL_BUILTIN_SKILLSAll projects
NODE_PACK_SKILLSNode.js / TypeScript (package.json)
GO_PACK_SKILLSGo (go.mod)
JAVA_PACK_SKILLSJava (pom.xml, build.gradle)
KOTLIN_PACK_SKILLSKotlin / Android
PYTHON_PACK_SKILLSPython (requirements.txt, pyproject.toml)

Orchestration pipeline

When orchestration: true, an intelligent routing layer runs before each LLM call:

Input
  → Intent Detection (feature? bug? refactor? question?)
  → Domain Detection (backend? frontend? security? ops?)
  → Risk Scoring (reads only? writes files? runs commands?)
  → Policy Engine (enforce domain-level rules)
  → Agent Selection (best agent for detected domain + risk)
  → LLM Call
  → QA Review (auto-review code-heavy responses)

Custom orchestration

orchestration: {
  capabilityMatrix: {
    'my-specialist': {
      owns:       ['payments', 'billing'],
      skills:     ['typescript', 'stripe'],
      baseWeight: 0.95,
    },
  },
  customRules: [
    {
      if:   { domain: 'security' },
      then: { mustInclude: ['security-reviewer'] },
    },
  ],
  enableQA:   true,
  noQA:       false,
  onQAReview: (review) => logger.info('[QA]', review),
}

Reflection engine

Observes failures across runs, promotes recurring patterns into policy rules:

orchestration: {
  reflection: true,
  // After each sprint:
  // 1. Failures logged to FailureCatalog
  // 2. Patterns with ≥3 occurrences promoted to PolicyRules
  // 3. lecciones-aprendidas.md updated
}

MCP server integration

mcpServers: [
  {
    name:    'code-intelligence',
    command: 'bk-mcp',               // @backendkit-labs/mcp-server
    args:    [],
    env:     { BK_APP_NAME: 'bk-agent', BK_CWD: process.cwd() },
  },
  {
    name:    'github',
    command: 'npx',
    args:    ['-y', '@modelcontextprotocol/server-github'],
    env:     { GITHUB_TOKEN: process.env.GITHUB_TOKEN! },
  },
],
subAgentContextMessages: 20,

Multi-agent examples

Feature implementation

await engine.run(`
  Implement JWT authentication middleware for Express:
  - Validate Bearer token in Authorization header
  - Attach decoded user to req.user
  - Return 401 with clear error messages
  - Include unit tests with valid/expired/malformed token cases
`);
// architect plans → backend-agent implements → qa-engineer writes tests

Security audit

await engine.run(`
  Audit all routes in src/routes/ for:
  1. Missing auth middleware
  2. SQL injection vulnerabilities
  3. Exposed sensitive data
  Output a prioritized fix list.
`, { agentId: 'security-reviewer' });

Database migration

await engine.run(`
  Write a zero-downtime migration: add NOT NULL column 
  'last_login_at TIMESTAMP DEFAULT NOW()' to the users table (50M rows).
  Include rollback script and backfill strategy.
`, { agentId: 'database-agent' });

Full stack refactor

await engine.run(`
  Refactor auth from session cookies to JWT.
  Update both Express middleware and React login flow.
  Keep backward compatibility for 2 more sprints.
`);
// backend-agent + frontend-agent + security-reviewer

Config file

~/.bk-agent/config.json:

{
  "defaultProvider": "deepseek",
  "providers": {
    "deepseek": { "apiKey": "sk-xxxx", "model": "deepseek-chat" },
    "anthropic": { "apiKey": "sk-ant-xxxx", "model": "claude-sonnet-4-6" },
    "ollama":    { "host": "http://localhost:11434", "model": "llama3.2" }
  },
  "mcpServers": [
    {
      "name": "github",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "ghp_xxxx" }
    }
  ]
}

版本与发布记录

@backendkit-labs/agent-coding 共发布 27 个版本,首次发布于 2026/06/05;过去 12 个月发布了 27 个版本。

版本发布日期距今
0.28.4latest2026/10/2810 天前
0.28.32026/10/2711 天前
0.28.22026/10/2712 天前
0.28.12026/10/2612 天前
0.28.02026/10/2612 天前
0.27.32026/10/2514 天前

关于 @backendkit-labs/agent-coding 的常见问题

@backendkit-labs/agent-coding 是什么?

Coding agent profiles and tools for @backendkit-labs/agent-core

如何安装 @backendkit-labs/agent-coding?

在项目目录运行 npm install @backendkit-labs/agent-coding,或使用 pnpm add / yarn add / bun add。

@backendkit-labs/agent-coding 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@backendkit-labs/agent-coding 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@backendkit-labs/agent-coding 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@backendkit-labs/agent-coding 可以商用吗?

@backendkit-labs/agent-coding 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@backendkit-labs/agent-coding 的下载量有多少?

根据 npm 官方下载统计,@backendkit-labs/agent-coding 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,856 次,日均约 95 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@backendkit-labs/agent-coding 还在维护吗?

最新版本 0.28.4 发布于 2026/10/28(10 天前);至今共发布 27 个版本,其中过去 12 个月发布了 27 个;首次发布于 2026/06/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。