Metadata-Version: 2.4
Name: jsm-compare
Version: 0.1.1
Summary: Compare JSM automation rules and workflows between Jira Cloud environments
Project-URL: Homepage, https://github.com/nyankotaro/jsm-compare
Author: Kotaro Takayama
License-Expression: MIT
License-File: LICENSE
Keywords: atlassian,automation,comparison,jira,jsm
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Requires-Dist: httpx>=0.27
Requires-Dist: rich>=13.0
Description-Content-Type: text/markdown

# jsm-compare

Jira Service Management (JSM) の自動化ルールをサンドボックスと本番環境で比較するCLIツール。

環境間のルール設定ドリフトを検出し、本番デプロイ前の差分チェックを自動化します。

## インストール

```bash
# インストール不要で即実行（uvx）
uvx jsm-compare rules --domain my-project --user me@example.com

# グローバルインストール
uv tool install jsm-compare

# pip
pip install jsm-compare
```

## 使い方

### 基本

```bash
# 環境変数で認証情報を設定
export JIRA_USER="me@example.com"
export JIRA_API_TOKEN="ATATT3x..."

# ドメイン指定（推奨）- sandbox/本番を自動展開
jsm-compare rules --domain my-project

# セクション指定
jsm-compare rules --domain my-project --section rules-overview
jsm-compare rules --domain my-project --section triggers
jsm-compare rules --domain my-project --section components

# フルホスト名指定（カスタムホスト名の場合）
jsm-compare rules --source my-project-sandbox.atlassian.net --target my-project.atlassian.net
```

`--domain my-project` は `--source my-project-sandbox.atlassian.net --target my-project.atlassian.net` に展開されます。

### オプション

```bash
# ルール名でフィルタ
jsm-compare rules --domain my-project --filter '[MyPrefix]'

# Webhook URL等のセンシティブ値をマスク
jsm-compare rules --domain my-project --mask

# デバッグ用: 正規化後のJSONを表示
jsm-compare rules --domain my-project --raw
```

### 認証

Jira Cloud APIトークンが必要です。
[Atlassian API トークンの管理](https://id.atlassian.com/manage-profile/security/api-tokens) から取得できます。

Automation REST APIにアクセスするには Jira管理者権限が必要です。

| パラメータ | 環境変数         | 説明                        |
| ---------- | ---------------- | --------------------------- |
| `--user`   | `JIRA_USER`      | Jira Cloud のメールアドレス |
| `--token`  | `JIRA_API_TOKEN` | Jira API トークン           |

## 比較セクション

| セクション       | 比較内容                                         |
| ---------------- | ------------------------------------------------ |
| `rules-overview` | ルール名、state (ENABLED/DISABLED)、description  |
| `triggers`       | トリガーtype、スケジュール設定、JQL条件          |
| `components`     | 条件・アクション設定（環境固有のID/ARI自動除外） |

## 正規化

環境固有で比較不要なフィールドは自動的に除外されます。

### 除外フィールド

**ルールレベル**: id, clientKey, authorAccountId, actor, created, updated, ruleScope, labels, tags

**コンポーネントレベル**: id, parentId, conditionParentId, connectionId, checksum, schemaVersion

**トリガー**: eventFilters (ARI形式のプロジェクト参照)

## 出力例

```
JSM Automation Rules Comparison
  Source: my-project-sandbox.atlassian.net
  Target: my-project.atlassian.net
  Filter: [MyPrefix]

────── Section 1: Rules Overview ──────

  [INFO]  Only in source:
    [MyPrefix]Incident Creation Rule 20260324 [DISABLED]

  [MATCH] Recovery Notification 20260401
  [DIFF]  Customer Comment Notification 20260401
    - "description": "... Webhook URL管理者 : Admin User"
    + "description": "... 管理先Slack API : https://api.slack.com/..."

────── Section 2: Triggers ──────

  [MATCH] Recovery Notification 20260401 [trigger]
  [MATCH] Customer Comment Notification 20260401 [trigger]

────── Section 3: Components ──────

  [DIFF]  Incident Creation Rule 20260330 [components]
    - "value": "{{issue.customfield_10557}}"
    + "value": "{{issue.customfield_10356}}"

Differences found. Review the output above.
```

## 終了コード

| コード | 意味                                  |
| ------ | ------------------------------------- |
| 0      | 全セクション一致                      |
| 1      | 差分あり                              |
| 2      | エラー（認証失敗、API接続エラーなど） |

## 動作要件

- Python 3.10+
- Jira Cloud 環境
- Jira管理者権限（Automation REST API アクセスに必要）

## ライセンス

MIT
