Sign In

dakin

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dakin

企业统一 CLI 工具 — 连接 AI Agent 与企业内部 API 的标准化桥梁

latest
npmnpm
Version
0.3.0
Version published
Maintainers
2
Created
Source

dakin — 企业统一 CLI 工具

连接 AI Agent 与企业内部 API 的标准化桥梁。

环境要求

  • Node.js >= 18

使用方式

所有命令统一通过 npx dakin 免安装执行,无需全局安装:

npx dakin <命令> [参数...]

npx 会自动下载并执行最新版本的 dakin,始终使用最新功能,无需手动升级。

快速开始

# 1. 配置认证 Key
npx dakin config set-key

# 2. 列出可用系统
npx dakin list

# 3. 浏览接口
npx dakin guard                      # 查看 guard 系统下的子系统
npx dakin guard open                 # 查看 open 子系统下的操作
npx dakin guard open getApp --help   # 查看 getApp 操作的参数详情

# 4. 调用接口
npx dakin guard open getApp --client-id 123 --env local

# 5. 搜索接口
npx dakin find "员工"

命令参考

动态命令

npx dakin <系统> <子系统> <操作> [参数...]

根据 manifest 命令树解析并执行业务接口调用。

示例说明
npx dakin list列出所有可用系统(名称 + 描述)
npx dakin guard查看 guard 系统下的子系统列表
npx dakin guard open查看 open 子系统下的操作列表
npx dakin guard open getApp --help查看 getApp 操作的参数详情
npx dakin guard open getApp --client-id 123调用接口

内置命令

config — 认证与配置管理

子命令说明
config set-key [key]设置全局 API Key(不传参数则交互式输入)
config show查看当前配置(Key 脱敏显示)
config clean清除所有配置
npx dakin config set-key
npx dakin config show

config env — 多环境管理

支持 dev / test / pre / prod 四套环境,默认 prod

子命令说明
env list列出所有环境(🔑 表示已配 Key,* 表示当前默认)
env set <name> [url] [--key <key>]添加/更新环境
env remove <name>删除环境
env use <name>切换默认环境
npx dakin config env set dev https://api-dev.giikin.cn --key sk-dev-xxx
npx dakin config env use local
npx dakin config env list

find — 搜索接口

npx dakin find "用户"              # 关键词搜索
npx dakin find "订单" --limit 5    # 限制返回数量
npx dakin find "员工" --env dev    # 指定环境

command — 查看命令详情

npx dakin command 1046             # 查看 apiId=1046 的完整命令详情
npx dakin command 1046 --plain     # 纯文本格式

update — 检查版本更新

npx dakin update --check

mcp-server — MCP 模式

启动 MCP Server 供 AI IDE(Cursor、Claude Code、Kiro)集成:

npx dakin mcp-server

IDE 配置示例(Claude Code):

{
  "mcpServers": {
    "dakin": {
      "command": "npx",
      "args": ["dakin", "mcp-server"],
      "autoApprove": [
        "find_api",
        "get_command",
        "list_systems",
        "get_system_info",
        "debug_manifest",
        "check_update"
      ]
    }
  }
}

说明call_api 不在 autoApprove 列表中,调用业务接口需用户手动确认,避免误操作。 可通过 --env 切换环境(如 --env dev),不指定则使用 currentEnv(默认 prod)。

MCP 工具列表:

工具名说明
find_api关键词搜索接口(返回摘要,需配合 get_command 获取参数)
get_command获取接口完整参数列表和调用示例(find_apicall_api 的必要桥梁)
call_api调用业务接口(需用户确认,自动处理域名路由、认证、参数转换)
list_systems列出可用系统及网关域名
get_system_info查看系统详情(子系统、API 数量)
debug_manifest诊断工具:查看 manifest 概要(版本、系统、API 分布)
check_update检查 CLI 工具是否有新版本(查 npm registry),引导用户升级

全局选项

选项说明
-e, --env <env>指定环境(local/dev/test/pre/prod),本次生效不修改配置
-v, --verbose输出完整请求/响应详情到 stderr
-o, --output <mode>输出格式(json | plain),默认 json
--raw仅输出 data 字段
-h, --help显示帮助

环境变量

变量说明
DAKIN_API_KEY临时覆盖 API Key,优先级高于配置文件

配置文件

位置:~/.dakin/config.json

{
  "apiKey": "dk-xxx",
  "currentEnv": "prod",
  "environments": {
    "local": { "url": "http://localhost:8009" },
    "dev":   { "url": "https://api-dev.giikin.cn", "apiKey": "sk-dev-xxx" },
    "test":  { "url": "https://api-test.giikin.cn" },
    "pre":   { "url": "https://api-pre.giikin.com" },
    "prod":  { "url": "https://api.giikin.com" }
  }
}
  • url — 元数据 API 地址(manifest、routes、find 等端点)
  • apiKey — 该环境的 API Key(可选,未配则回退到全局 apiKey
  • 业务接口的网关地址由 /apim/cli/v1/routes 端点自动下发,无需手动配置

缓存机制

缓存文件内容策略
~/.dakin/manifest.json命令树(系统/子系统/操作)版本号对比,304 零传输
~/.dakin/routes.json系统 → 网关地址映射随 manifest 版本变化自动刷新
~/.dakin/params.jsonapiId → 参数定义随 manifest 版本变化自动清理

调用流程

首次调用(4 次 HTTP):
  manifest → routes → getCommand → 业务调用

后续调用(2 次 HTTP):
  manifest (304) → 业务调用
  (routes + params 命中本地缓存)

调试

npx dakin guard open getApp --client-id 123 --verbose

输出示例:

============================================================
[VERBOSE] >>> GET http://localhost:8009/apim/cli/v1/manifest?version=202606241624
[VERBOSE] 请求头:
    Content-Type: application/json
    Authorization: Bearer dk-ai-p-****
[VERBOSE] <<< 304
============================================================

============================================================
[VERBOSE] >>> POST http://localhost:8009/guard/open/rpc/v1/open/getApp
[VERBOSE] 请求头:
    Content-Type: application/json
    Authorization: Bearer dk-ai-p-****
[VERBOSE] 请求体:
{"clientId":"123"}
[VERBOSE] <<< 200 OK
[VERBOSE] 响应体:
{"code":200,"data":{...}}
============================================================

POST JSON Body

# Linux/Mac — 单引号
npx dakin guard basic somePostApi --body '{"fieldCodes":["val1","val2"]}'

# Windows Git Bash — 双引号 + 转义
npx dakin guard basic somePostApi --body "{\"fieldCodes\":[\"val1\",\"val2\"]}"

本地开发

cd cli
pnpm install
pnpm build
pnpm test

开发模式(文件变更自动编译):

pnpm dev

发布 snapshot 版本:

pnpm publish:snapshot

FAQs

Package last updated on 01 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts