jira-ticket-prioritizer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

JIRA Ticket Prioritizer

JIRA工单优先级排序器

Analyze a set of JIRA tickets to determine optimal execution order based on dependencies and priority. Produces an ordered list usable standalone or as a pre-step before
implement
/
forge
.
分析一组JIRA工单,基于依赖关系和优先级确定最优执行顺序。生成的有序列表可独立使用,也可作为
implement
/
forge
执行前的前置步骤。

Arguments

参数

  • $ARGUMENTS[0]
    — Comma-separated ticket keys (e.g.
    EC-100,EC-101,EC-102
    ) OR a JQL query (detected by presence of
    =
    ,
    AND
    ,
    OR
    )
  • $ARGUMENTS[1]
    — (optional) Additional context for prioritization (e.g. "focus on backend", "frontend first")
  • $ARGUMENTS[0]
    — 逗号分隔的工单key(例如
    EC-100,EC-101,EC-102
    ),或是一个JQL查询(通过是否包含
    =
    AND
    OR
    来检测)
  • $ARGUMENTS[1]
    — (可选)优先级排序的额外上下文(例如「优先关注后端」、「前端优先」)

System Requirements

系统要求

  • jira
    CLI installed and configured (https://github.com/ankitpokhrel/jira-cli)
  • Environment variable
    JIRA_API_TOKEN
    set with a valid Jira API token. Important: When checking this variable, verify at least 2 times before concluding it is not set. Never expose the value — use existence checks only.
  • 已安装并配置
    jira
    CLI(https://github.com/ankitpokhrel/jira-cli)
  • 已设置环境变量
    JIRA_API_TOKEN
    ,值为有效的Jira API token。重要提示: 检查该变量时,至少验证2次再判定其未设置。绝对不要暴露变量值 — 仅做存在性检查即可。

Execution

执行

Step 1 — Parse Input

步骤1 — 解析输入

  • Check if
    $ARGUMENTS[0]
    contains
    =
    ,
    AND
    , or
    OR
    (case-insensitive) to detect JQL
  • If JQL detected: run
    jira issue list --jql "$ARGUMENTS[0]" --plain --columns key --no-headers
    to resolve to ticket keys
  • If comma-separated: split on
    ,
    and trim whitespace
  • Validate each key matches
    [A-Z]+-\d+
  • If fewer than 2 valid tickets, report the single ticket and exit
  • 检查
    $ARGUMENTS[0]
    是否包含
    =
    AND
    OR
    (不区分大小写),以此检测是否为JQL
  • 如果检测到JQL:运行
    jira issue list --jql "$ARGUMENTS[0]" --plain --columns key --no-headers
    解析出工单key
  • 如果为逗号分隔格式:按
    ,
    拆分并去除空格
  • 验证每个key匹配
    [A-Z]+-\d+
    格式
  • 如果有效工单数量少于2个,返回单个工单信息后退出

Step 2 — Fetch All Tickets

步骤2 — 拉取所有工单

  • Create temp directory:
    mkdir -p .jira-ticket-prioritizer-tmp/tickets
  • For each ticket key, fetch via jira CLI:
    jira issue view {KEY} --raw > .jira-ticket-prioritizer-tmp/tickets/{KEY}.json
  • Parse each ticket using the jira-ticket-viewer parse script:
    node ../jira-ticket-viewer/scripts/parse-ticket.js < .jira-ticket-prioritizer-tmp/tickets/{KEY}.json > .jira-ticket-prioritizer-tmp/tickets/{KEY}-parsed.json
  • Collect all parsed outputs into a single JSON array and write to
    .jira-ticket-prioritizer-tmp/all-tickets.json
  • 创建临时目录:
    mkdir -p .jira-ticket-prioritizer-tmp/tickets
  • 对每个工单key,通过jira CLI拉取信息:
    jira issue view {KEY} --raw > .jira-ticket-prioritizer-tmp/tickets/{KEY}.json
  • 使用jira-ticket-viewer解析脚本解析每个工单:
    node ../jira-ticket-viewer/scripts/parse-ticket.js < .jira-ticket-prioritizer-tmp/tickets/{KEY}.json > .jira-ticket-prioritizer-tmp/tickets/{KEY}-parsed.json
  • 将所有解析后的输出汇总为单个JSON数组,写入
    .jira-ticket-prioritizer-tmp/all-tickets.json

Step 3 — Build Dependency Graph

步骤3 — 构建依赖图

  • Run:
    node ./scripts/build-dependency-graph.js < .jira-ticket-prioritizer-tmp/all-tickets.json > .jira-ticket-prioritizer-tmp/graph.json
  • Review graph output for cycles or warnings
  • See references/dependency-analysis.md for relationship mapping rules
  • 运行:
    node ./scripts/build-dependency-graph.js < .jira-ticket-prioritizer-tmp/all-tickets.json > .jira-ticket-prioritizer-tmp/graph.json
  • 检查图输出中是否存在循环或警告
  • 关联映射规则可查看references/dependency-analysis.md

Step 4 — Semantic Dependency Analysis

步骤4 — 语义依赖分析

  • For tickets flagged with
    "relates to"
    links or no explicit links in the graph output, analyze their
    description
    ,
    summary
    , and
    commentSummary
    for implicit dependencies
  • Look for:
    • References to other ticket keys in the input set
    • Shared component or module mentions
    • Functional ordering hints ("builds on", "requires", "after", "depends on")
  • Add soft edges with confidence levels (high/medium/low) to the graph
  • Re-run topological sort if new edges were added:
    • Update
      all-tickets.json
      with additional
      softEdges
      and re-run
      build-dependency-graph.js
  • 对于图输出中标记有
    "relates to"
    链接、或没有显式链接的工单,分析其
    description
    summary
    commentSummary
    以识别隐式依赖
  • 查找以下内容:
    • 输入集合中其他工单key的引用
    • 共享组件或模块的提及
    • 功能顺序提示("builds on"、"requires"、"after"、"depends on")
  • 为图添加带置信度等级(高/中/低)的软边
  • 如果添加了新边,重新运行拓扑排序:
    • 用新增的
      softEdges
      更新
      all-tickets.json
      ,重新运行
      build-dependency-graph.js

Step 5 — Priority Scoring

步骤5 — 优先级评分

  • For tickets at the same dependency layer, score using weights from references/priority-weights.md
  • Skip tickets with status "Done" — list them as excluded in the report
  • Sort within each layer by descending score
  • Apply
    $ARGUMENTS[1]
    context as a tiebreaker or boost (e.g. "focus on backend" boosts tickets with backend labels/components)
  • 对处于同一依赖层的工单,使用references/priority-weights.md中的权重进行评分
  • 跳过状态为"Done"的工单 — 在报告中将其列为已排除
  • 每个层级内按分数降序排序
  • 应用
    $ARGUMENTS[1]
    的上下文作为平局决胜项或权重加成(例如「优先关注后端」会给带有后端标签/组件的工单加分)

Step 6 — Generate Output

步骤6 — 生成输出

  • Write
    .jira-ticket-prioritizer-tmp/detailed-report.json
    — full details including scores, justifications, dependency graph, excluded tickets, and warnings (see references/output-format.md for schema)
  • Write
    .jira-ticket-prioritizer-tmp/output.json
    — ticket keys grouped by dependency layer (array of arrays), sorted by priority score within each layer
  • Present only
    output.json
    (the simple sorted array) to the user. The detailed report is saved for reference but not displayed.
  • 写入
    .jira-ticket-prioritizer-tmp/detailed-report.json
    — 包含分数、判定依据、依赖图、已排除工单和警告在内的完整详情(schema可查看references/output-format.md
  • 写入
    .jira-ticket-prioritizer-tmp/output.json
    — 按依赖层分组的工单key(二维数组),每层内按优先级分数排序
  • 仅向用户展示
    output.json
    (简单排序数组)。详细报告仅保存用于参考,不对外展示。

Reference Files

参考文件

NameWhen to Read
references/priority-weights.mdStep 5 — scoring rules and factor weights
references/output-format.mdStep 6 — report template and JSON schema
references/dependency-analysis.mdSteps 3-4 — dependency detection rules
<tags> <mode>think</mode> <custom>yes</custom> </tags>
名称阅读时机
references/priority-weights.md步骤5 — 评分规则和因子权重
references/output-format.md步骤6 — 报告模板和JSON schema
references/dependency-analysis.md步骤3-4 — 依赖检测规则
<tags> <mode>think</mode> <custom>yes</custom> </tags>