加载中…
✦
✧
✦
✦
✧
✦

jirab — 面向人和 AI agent 的只读 Jira CLI

一个轻量、低依赖的 Jira Server / Data Center 命令行客户端。设计上只读:没有创建、更新、流转或删除命令。既能在终端被人直接使用,也能被流水线里的 AI agent 调用。

安装

npm install -g .

需要 Node.js >= 20.12(使用原生 fetch 和 node:util.parseArgs)。

命令

命令说明
search <jql|->执行 JQL 搜索(直接传 JQL、- 从 stdin 读,或 --file)
issue <KEY>查看单个 issue(别名:get)
comments <KEY>列出 issue 评论
worklog <KEY>列出 issue 工作日志(时间跟踪)
transitions <KEY>列出可用的工作流流转
attachments <KEY>列出 issue 附件
attachment <ID>按 id 下载单个附件
me显示当前 Jira 账号
doctor检查配置、连通性和认证
config path打印生效的配置文件路径
completion <shell>输出 shell 补全脚本(bash、zsh、fish)

配置

jirab 按四个来源解析凭据,优先级从高到低:

  1. 环境变量 — JIRAB_BASE_URL、JIRAB_TOKEN(或 JIRAB_USERNAME + JIRAB_PASSWORD)。
    旧版 JIRA_* 变量作为回退仍可使用。
  2. 本地配置文件 — 当前目录的 ./jirab.config.json。
  3. ~/.zcode/cli/config.json — 回退读取 mcp.servers.jira.env。
  4. %APPDATA%\dock\config.json — 最后读取名为 “Jira” 的 MCP 应用。

当前目录的 .env 会自动加载。

配置文件格式

参见 jirab.config.example.json。文件是扁平 JSON 对象:

{
"baseUrl": "http://jira.example.com:8080",
"tokenEnv": "JIRAB_TOKEN",
"defaultFields": ["summary", "status", "issuetype", "priority", "assignee", "updated"],
"guard": {
"defaultLimit": 20,
"maxLimit": 100,
"maxAttachmentBytes": 52428800,
"requestTimeoutMs": 30000
},
"output": { "format": "auto", "maxColWidth": 60 },
"audit": { "enabled": false, "path": "" }
}

tokenEnv / usernameEnv / passwordEnv 引用环境变量名,而不是把密钥写进文件。

不支持 profiles

jirab 刻意不支持配置文件里的 profiles 键。需要多环境时,用 --config <path> 或设置 JIRAB_CONFIG 指向各环境自己的配置文件。

配置发现顺序

--config <path>  >  $JIRAB_CONFIG  >  ./jirab.config.json  >  用户级配置

用户级配置位置:

  • Windows:%APPDATA%\jirab\config.json
  • Linux/macOS:$XDG_CONFIG_HOME/jirab/config.json 或 ~/.config/jirab/config.json

输出格式

--format auto|table|json|csv|tsv(默认 auto)

  • auto — stdout 是 TTY 时输出表格,否则输出 JSON。
  • table — 列表命令输出对齐列,单个 issue 输出带标签的详情。
  • json — 结构化信封,含 ok、command、baseUrl、data、warnings、durationMs。
  • csv / tsv — 分隔符输出,仅列表命令可用。

--json-compact — 以单行无缩进输出 JSON。AI agent 在流水线里消费输出时可节省 token。仅对 --format json 生效。

推荐 AI agent 使用 JSON 格式。

搜索展开

--expand <fields> — 给搜索接口传 Jira expand 参数。示例:jirab search "key = DEMO-1" --expand changelog 返回 issue 变更历史。

审计日志轮转

audit.maxBytes(默认 10 MB,0 = 永不轮转)——审计日志超过该大小时,在写下一条记录前轮转为 <path>.1,只保留一代历史。

退出码

码含义
0成功
1Jira 请求失败
2用法 / 配置错误
3连接错误
4超时
130中断(SIGINT)

示例

jirab me
jirab search "assignee = currentUser() AND statusCategory != done ORDER BY updated DESC" --limit 10
echo "project = DEMO AND status = Open" | jirab search -
jirab issue DEMO-28645
jirab issue DEMO-28645 --comments --comments-limit 20
jirab comments DEMO-28645 --limit 20 --format csv
jirab worklog DEMO-28645 --limit 20 --format json
jirab transitions DEMO-28645
jirab attachments DEMO-28645
jirab attachment 42301 --out ./downloads/
jirab doctor --format json

开发

npm test              # 运行测试套件(65 个测试)
npm run typecheck # tsc --noEmit
npm run build # 编译到 dist/

许可证

ISC