atlassian-axi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/adf.d.ts +13 -0
- package/dist/adf.js +188 -0
- package/dist/adf.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +124 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/conf/create.d.ts +14 -0
- package/dist/commands/conf/create.js +45 -0
- package/dist/commands/conf/create.js.map +1 -0
- package/dist/commands/conf/mine.d.ts +13 -0
- package/dist/commands/conf/mine.js +28 -0
- package/dist/commands/conf/mine.js.map +1 -0
- package/dist/commands/conf/update.d.ts +12 -0
- package/dist/commands/conf/update.js +53 -0
- package/dist/commands/conf/update.js.map +1 -0
- package/dist/commands/jira/assign.d.ts +9 -0
- package/dist/commands/jira/assign.js +20 -0
- package/dist/commands/jira/assign.js.map +1 -0
- package/dist/commands/jira/create.d.ts +16 -0
- package/dist/commands/jira/create.js +44 -0
- package/dist/commands/jira/create.js.map +1 -0
- package/dist/commands/jira/mine.d.ts +13 -0
- package/dist/commands/jira/mine.js +32 -0
- package/dist/commands/jira/mine.js.map +1 -0
- package/dist/commands/jira/move.d.ts +9 -0
- package/dist/commands/jira/move.js +17 -0
- package/dist/commands/jira/move.js.map +1 -0
- package/dist/commands/jira/search.d.ts +12 -0
- package/dist/commands/jira/search.js +30 -0
- package/dist/commands/jira/search.js.map +1 -0
- package/dist/commands/jira/sprint.d.ts +11 -0
- package/dist/commands/jira/sprint.js +38 -0
- package/dist/commands/jira/sprint.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -0
- package/dist/format.d.ts +3 -0
- package/dist/format.js +14 -0
- package/dist/format.js.map +1 -0
- package/dist/http.d.ts +19 -0
- package/dist/http.js +80 -0
- package/dist/http.js.map +1 -0
- package/dist/resolvers.d.ts +12 -0
- package/dist/resolvers.js +64 -0
- package/dist/resolvers.js.map +1 -0
- package/package.json +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Selwyn Yeow
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<h1 align="center">atlassian-axi</h1>
|
|
2
|
+
|
|
3
|
+
<h3 align="center">Token-efficient Jira + Confluence CLI for AI agents</h3>
|
|
4
|
+
|
|
5
|
+
<p align="center">An <a href="https://github.com/kunchenguid/axi">AXI</a>-style CLI that strips Atlassian API noise down to compact TSV — built for agents that pay per token.</p>
|
|
6
|
+
|
|
7
|
+
## Results
|
|
8
|
+
|
|
9
|
+
Measured against real Atlassian Cloud API responses (fields agents actually request):
|
|
10
|
+
|
|
11
|
+
| Command | Raw API JSON | atlassian-axi output | Savings |
|
|
12
|
+
|---------|-------------|-----------|---------|
|
|
13
|
+
| `jira sprint` (20 issues) | ~10,800 tokens | ~460 tokens | **96%** |
|
|
14
|
+
| `jira mine` (12 issues) | ~3,600 tokens | ~220 tokens | **94%** |
|
|
15
|
+
| `conf mine` (15 pages) | ~6,000 tokens | ~510 tokens | **91%** |
|
|
16
|
+
|
|
17
|
+
**Overall: ~94% token reduction** vs raw API responses.
|
|
18
|
+
|
|
19
|
+
What gets stripped: avatar URLs, self-links, expand metadata, status category objects, project/space objects, icon URLs, account IDs, pagination wrappers.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install -g atlassian-axi
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or from source:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
git clone https://github.com/selwynyeow/atlassian-axi.git
|
|
31
|
+
cd atlassian-axi
|
|
32
|
+
npm install && npm run build
|
|
33
|
+
npm link
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Add to your `CLAUDE.md` or `AGENTS.md`:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Use `atlassian-axi jira` for Jira operations and `atlassian-axi conf` for Confluence operations.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
Create `~/.config/atlassian-axi/config.json`:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"defaultSite": "a",
|
|
49
|
+
"sites": {
|
|
50
|
+
"a": { "baseUrl": "https://yoursite.atlassian.net", "email": "you@co.com", "tokenEnv": "AXI_A_TOKEN", "defaultBoard": 12 },
|
|
51
|
+
"b": { "baseUrl": "https://other.atlassian.net", "email": "you@co.com", "tokenEnv": "AXI_B_TOKEN" }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Export your API token:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
export AXI_A_TOKEN="..."
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Generate one at https://id.atlassian.com/manage-profile/security/api-tokens (classic unscoped token).
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
### Jira
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
atlassian-axi jira sprint --board 42 # active sprint summary + issue list
|
|
70
|
+
atlassian-axi jira mine --since 2w # my done issues, last 2 weeks
|
|
71
|
+
atlassian-axi jira search --jql "project=X" # raw JQL
|
|
72
|
+
atlassian-axi jira move PROJ-123 "In Progress" # transition issue (exit 3 if invalid)
|
|
73
|
+
atlassian-axi jira create -p PROJ --summary "Fix bug" -d - # stdin = markdown description
|
|
74
|
+
atlassian-axi jira assign PROJ-123 "Jane" # resolve name → accountId (exit 3 if ambiguous)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Confluence
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
atlassian-axi conf mine --pages # my recent pages
|
|
81
|
+
atlassian-axi conf mine --comments # my recent comments
|
|
82
|
+
atlassian-axi conf create --space DEV --title "Design doc" --body - # stdin markdown
|
|
83
|
+
atlassian-axi conf update 12345 --append --body - # append to existing page
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Global flags
|
|
87
|
+
|
|
88
|
+
| Flag | Effect |
|
|
89
|
+
|------|--------|
|
|
90
|
+
| `--site a\|b` | target site (default from config) |
|
|
91
|
+
| `--json` | raw API response (bypass formatting) |
|
|
92
|
+
|
|
93
|
+
## Exit codes
|
|
94
|
+
|
|
95
|
+
| Code | Meaning |
|
|
96
|
+
|------|---------|
|
|
97
|
+
| `0` | success |
|
|
98
|
+
| `1` | API/HTTP error |
|
|
99
|
+
| `2` | bad usage or missing config |
|
|
100
|
+
| `3` | resolvable ambiguity (retry with hint from stderr) |
|
|
101
|
+
|
|
102
|
+
## Output format
|
|
103
|
+
|
|
104
|
+
Default: compact TSV with a one-line header/aggregate. No avatar URLs, no null fields, no JSON noise unless `--json`.
|
|
105
|
+
|
|
106
|
+
Errors go to stderr: `error(<status>): <message>` with optional `hint:` line.
|
package/dist/adf.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface AdfNode {
|
|
2
|
+
type: string;
|
|
3
|
+
content?: AdfNode[];
|
|
4
|
+
text?: string;
|
|
5
|
+
attrs?: Record<string, unknown>;
|
|
6
|
+
marks?: {
|
|
7
|
+
type: string;
|
|
8
|
+
attrs?: Record<string, unknown>;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export declare function markdownToAdf(md: string): AdfNode;
|
|
12
|
+
export declare function markdownToStorage(md: string): string;
|
|
13
|
+
export {};
|
package/dist/adf.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Markdown → ADF (Atlassian Document Format) converter
|
|
2
|
+
// Supports: paragraphs, headings, bold, italic, code, links, lists, code blocks
|
|
3
|
+
export function markdownToAdf(md) {
|
|
4
|
+
const lines = md.split("\n");
|
|
5
|
+
const doc = { type: "doc", attrs: { version: 1 }, content: [] };
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (i < lines.length) {
|
|
8
|
+
const line = lines[i];
|
|
9
|
+
// Code block
|
|
10
|
+
if (line.startsWith("```")) {
|
|
11
|
+
const lang = line.slice(3).trim() || undefined;
|
|
12
|
+
const codeLines = [];
|
|
13
|
+
i++;
|
|
14
|
+
while (i < lines.length && !lines[i].startsWith("```")) {
|
|
15
|
+
codeLines.push(lines[i]);
|
|
16
|
+
i++;
|
|
17
|
+
}
|
|
18
|
+
i++; // skip closing ```
|
|
19
|
+
doc.content.push({
|
|
20
|
+
type: "codeBlock",
|
|
21
|
+
attrs: lang ? { language: lang } : {},
|
|
22
|
+
content: [{ type: "text", text: codeLines.join("\n") }],
|
|
23
|
+
});
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
// Heading
|
|
27
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
28
|
+
if (headingMatch) {
|
|
29
|
+
const level = headingMatch[1].length;
|
|
30
|
+
doc.content.push({
|
|
31
|
+
type: "heading",
|
|
32
|
+
attrs: { level },
|
|
33
|
+
content: parseInline(headingMatch[2]),
|
|
34
|
+
});
|
|
35
|
+
i++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// Unordered list
|
|
39
|
+
if (line.match(/^[\s]*[-*+]\s/)) {
|
|
40
|
+
const items = [];
|
|
41
|
+
while (i < lines.length && lines[i].match(/^[\s]*[-*+]\s/)) {
|
|
42
|
+
const text = lines[i].replace(/^[\s]*[-*+]\s/, "");
|
|
43
|
+
items.push({
|
|
44
|
+
type: "listItem",
|
|
45
|
+
content: [{ type: "paragraph", content: parseInline(text) }],
|
|
46
|
+
});
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
doc.content.push({ type: "bulletList", content: items });
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Ordered list
|
|
53
|
+
if (line.match(/^[\s]*\d+[.)]\s/)) {
|
|
54
|
+
const items = [];
|
|
55
|
+
while (i < lines.length && lines[i].match(/^[\s]*\d+[.)]\s/)) {
|
|
56
|
+
const text = lines[i].replace(/^[\s]*\d+[.)]\s/, "");
|
|
57
|
+
items.push({
|
|
58
|
+
type: "listItem",
|
|
59
|
+
content: [{ type: "paragraph", content: parseInline(text) }],
|
|
60
|
+
});
|
|
61
|
+
i++;
|
|
62
|
+
}
|
|
63
|
+
doc.content.push({ type: "orderedList", content: items });
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Empty line
|
|
67
|
+
if (!line.trim()) {
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Paragraph
|
|
72
|
+
doc.content.push({ type: "paragraph", content: parseInline(line) });
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
if (!doc.content.length) {
|
|
76
|
+
doc.content.push({ type: "paragraph", content: [{ type: "text", text: "" }] });
|
|
77
|
+
}
|
|
78
|
+
return doc;
|
|
79
|
+
}
|
|
80
|
+
function parseInline(text) {
|
|
81
|
+
const nodes = [];
|
|
82
|
+
// Regex matches: `code`, **bold**, *italic*, [link](url), plain text
|
|
83
|
+
const re = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\([^)]+\))/;
|
|
84
|
+
const parts = text.split(re);
|
|
85
|
+
for (const part of parts) {
|
|
86
|
+
if (!part)
|
|
87
|
+
continue;
|
|
88
|
+
if (part.startsWith("`") && part.endsWith("`")) {
|
|
89
|
+
nodes.push({
|
|
90
|
+
type: "text",
|
|
91
|
+
text: part.slice(1, -1),
|
|
92
|
+
marks: [{ type: "code" }],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else if (part.startsWith("**") && part.endsWith("**")) {
|
|
96
|
+
nodes.push({
|
|
97
|
+
type: "text",
|
|
98
|
+
text: part.slice(2, -2),
|
|
99
|
+
marks: [{ type: "strong" }],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (part.startsWith("*") && part.endsWith("*")) {
|
|
103
|
+
nodes.push({
|
|
104
|
+
type: "text",
|
|
105
|
+
text: part.slice(1, -1),
|
|
106
|
+
marks: [{ type: "em" }],
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else if (part.match(/^\[([^\]]+)\]\(([^)]+)\)$/)) {
|
|
110
|
+
const m = part.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
111
|
+
nodes.push({
|
|
112
|
+
type: "text",
|
|
113
|
+
text: m[1],
|
|
114
|
+
marks: [{ type: "link", attrs: { href: m[2] } }],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
nodes.push({ type: "text", text: part });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return nodes.length ? nodes : [{ type: "text", text: "" }];
|
|
122
|
+
}
|
|
123
|
+
// Markdown → Confluence Storage Format (XHTML subset)
|
|
124
|
+
export function markdownToStorage(md) {
|
|
125
|
+
const lines = md.split("\n");
|
|
126
|
+
const out = [];
|
|
127
|
+
let i = 0;
|
|
128
|
+
while (i < lines.length) {
|
|
129
|
+
const line = lines[i];
|
|
130
|
+
if (line.startsWith("```")) {
|
|
131
|
+
const lang = line.slice(3).trim() || "none";
|
|
132
|
+
const codeLines = [];
|
|
133
|
+
i++;
|
|
134
|
+
while (i < lines.length && !lines[i].startsWith("```")) {
|
|
135
|
+
codeLines.push(lines[i]);
|
|
136
|
+
i++;
|
|
137
|
+
}
|
|
138
|
+
i++;
|
|
139
|
+
out.push(`<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">${esc(lang)}</ac:parameter><ac:plain-text-body><![CDATA[${codeLines.join("\n")}]]></ac:plain-text-body></ac:structured-macro>`);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
143
|
+
if (headingMatch) {
|
|
144
|
+
const level = headingMatch[1].length;
|
|
145
|
+
out.push(`<h${level}>${inlineToHtml(headingMatch[2])}</h${level}>`);
|
|
146
|
+
i++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (line.match(/^[\s]*[-*+]\s/)) {
|
|
150
|
+
out.push("<ul>");
|
|
151
|
+
while (i < lines.length && lines[i].match(/^[\s]*[-*+]\s/)) {
|
|
152
|
+
const text = lines[i].replace(/^[\s]*[-*+]\s/, "");
|
|
153
|
+
out.push(`<li>${inlineToHtml(text)}</li>`);
|
|
154
|
+
i++;
|
|
155
|
+
}
|
|
156
|
+
out.push("</ul>");
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (line.match(/^[\s]*\d+[.)]\s/)) {
|
|
160
|
+
out.push("<ol>");
|
|
161
|
+
while (i < lines.length && lines[i].match(/^[\s]*\d+[.)]\s/)) {
|
|
162
|
+
const text = lines[i].replace(/^[\s]*\d+[.)]\s/, "");
|
|
163
|
+
out.push(`<li>${inlineToHtml(text)}</li>`);
|
|
164
|
+
i++;
|
|
165
|
+
}
|
|
166
|
+
out.push("</ol>");
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (!line.trim()) {
|
|
170
|
+
i++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
out.push(`<p>${inlineToHtml(line)}</p>`);
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
return out.join("\n");
|
|
177
|
+
}
|
|
178
|
+
function inlineToHtml(text) {
|
|
179
|
+
return text
|
|
180
|
+
.replace(/`([^`]+)`/g, "<code>$1</code>")
|
|
181
|
+
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
|
|
182
|
+
.replace(/\*([^*]+)\*/g, "<em>$1</em>")
|
|
183
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
184
|
+
}
|
|
185
|
+
function esc(s) {
|
|
186
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=adf.js.map
|
package/dist/adf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adf.js","sourceRoot":"","sources":["../src/adf.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,gFAAgF;AAUhF,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,GAAG,GAAY,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzE,IAAI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AAC,OAAO,CAAC,CAAC;YAClB,SAAS;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjB,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC,EAAE,CAAC;IACN,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI;SACR,OAAO,CAAC,YAAY,EAAE,iBAAiB,CAAC;SACxC,OAAO,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;SAClD,OAAO,CAAC,cAAc,EAAE,aAAa,CAAC;SACtC,OAAO,CAAC,0BAA0B,EAAE,qBAAqB,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { loadConfig, resolveSite } from "./config.js";
|
|
4
|
+
import { AxiHttpError } from "./http.js";
|
|
5
|
+
import { jiraSprint } from "./commands/jira/sprint.js";
|
|
6
|
+
import { jiraMine } from "./commands/jira/mine.js";
|
|
7
|
+
import { jiraSearch } from "./commands/jira/search.js";
|
|
8
|
+
import { jiraMove } from "./commands/jira/move.js";
|
|
9
|
+
import { jiraCreate } from "./commands/jira/create.js";
|
|
10
|
+
import { jiraAssign } from "./commands/jira/assign.js";
|
|
11
|
+
import { confMine } from "./commands/conf/mine.js";
|
|
12
|
+
import { confCreate } from "./commands/conf/create.js";
|
|
13
|
+
import { confUpdate } from "./commands/conf/update.js";
|
|
14
|
+
const program = new Command();
|
|
15
|
+
program.name("axi").description("Token-efficient Atlassian CLI for AI agents").version("0.1.0");
|
|
16
|
+
// Global --site option
|
|
17
|
+
program.option("-s, --site <name>", "site alias from config");
|
|
18
|
+
program.option("--json", "output raw JSON response");
|
|
19
|
+
// --- init ---
|
|
20
|
+
program
|
|
21
|
+
.command("init")
|
|
22
|
+
.description("Initialize config interactively")
|
|
23
|
+
.action(() => {
|
|
24
|
+
process.stderr.write("Create ~/.config/atlassian-axi/config.json manually. See README.\n");
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
// --- jira ---
|
|
28
|
+
const jira = program.command("jira").description("Jira commands");
|
|
29
|
+
jira
|
|
30
|
+
.command("sprint")
|
|
31
|
+
.description("Show active sprint issues")
|
|
32
|
+
.option("-b, --board <id|name>", "board id or name")
|
|
33
|
+
.action(wrap(jiraSprint));
|
|
34
|
+
jira
|
|
35
|
+
.command("mine")
|
|
36
|
+
.description("Issues assigned to me (done)")
|
|
37
|
+
.option("--done", "show completed issues", true)
|
|
38
|
+
.option("--since <period>", "lookback period (2w, 30d, 3m)", "4w")
|
|
39
|
+
.option("-p, --project <key>", "filter by project")
|
|
40
|
+
.action(wrap(jiraMine));
|
|
41
|
+
jira
|
|
42
|
+
.command("search")
|
|
43
|
+
.description("Search with JQL")
|
|
44
|
+
.requiredOption("--jql <query>", "JQL query")
|
|
45
|
+
.option("--fields <list>", "comma-separated fields", "key,summary,status")
|
|
46
|
+
.action(wrap(jiraSearch));
|
|
47
|
+
jira
|
|
48
|
+
.command("move")
|
|
49
|
+
.description("Transition an issue to a new status")
|
|
50
|
+
.argument("<key>", "issue key")
|
|
51
|
+
.argument("<status>", "target status name")
|
|
52
|
+
.action(wrap(jiraMove));
|
|
53
|
+
jira
|
|
54
|
+
.command("create")
|
|
55
|
+
.description("Create an issue")
|
|
56
|
+
.requiredOption("-p, --project <key>", "project key")
|
|
57
|
+
.option("-t, --type <name>", "issue type", "Task")
|
|
58
|
+
.requiredOption("--summary <text>", "issue summary")
|
|
59
|
+
.option("-l, --label <list>", "comma-separated labels")
|
|
60
|
+
.option("-a, --assignee <name>", "assignee name")
|
|
61
|
+
.option("-d, --description <source>", "'-' for stdin")
|
|
62
|
+
.action(wrap(jiraCreate));
|
|
63
|
+
jira
|
|
64
|
+
.command("assign")
|
|
65
|
+
.description("Assign an issue")
|
|
66
|
+
.argument("<key>", "issue key")
|
|
67
|
+
.argument("<name>", "assignee name or accountId")
|
|
68
|
+
.action(wrap(jiraAssign));
|
|
69
|
+
// --- conf ---
|
|
70
|
+
const conf = program.command("conf").description("Confluence commands");
|
|
71
|
+
conf
|
|
72
|
+
.command("mine")
|
|
73
|
+
.description("My recent pages or comments")
|
|
74
|
+
.option("--pages", "show pages (default)")
|
|
75
|
+
.option("--comments", "show comments instead")
|
|
76
|
+
.option("--since <period>", "lookback period", "4w")
|
|
77
|
+
.action(wrap(confMine));
|
|
78
|
+
conf
|
|
79
|
+
.command("create")
|
|
80
|
+
.description("Create a page")
|
|
81
|
+
.requiredOption("--space <key>", "space key")
|
|
82
|
+
.requiredOption("--title <text>", "page title")
|
|
83
|
+
.option("--parent <id>", "parent page id")
|
|
84
|
+
.option("--body <source>", "'-' for stdin")
|
|
85
|
+
.action(wrap(confCreate));
|
|
86
|
+
conf
|
|
87
|
+
.command("update")
|
|
88
|
+
.description("Update a page")
|
|
89
|
+
.argument("<pageId>", "page id")
|
|
90
|
+
.option("--append", "append instead of replace")
|
|
91
|
+
.option("--body <source>", "'-' for stdin")
|
|
92
|
+
.action(wrap(confUpdate));
|
|
93
|
+
program.parse();
|
|
94
|
+
function wrap(fn) {
|
|
95
|
+
return async (...args) => {
|
|
96
|
+
try {
|
|
97
|
+
const opts = program.opts();
|
|
98
|
+
const config = loadConfig();
|
|
99
|
+
const site = resolveSite(config, opts.site);
|
|
100
|
+
const json = opts.json || false;
|
|
101
|
+
const ctx = { site, config, json };
|
|
102
|
+
// Commander passes (...positionalArgs, commandOpts, Command) — strip Command, merge opts
|
|
103
|
+
const cmd = args.pop(); // Command instance
|
|
104
|
+
const cmdOpts = args.pop(); // command-level options
|
|
105
|
+
await fn(...args, { ...cmdOpts, ...opts }, ctx);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err instanceof AxiHttpError) {
|
|
109
|
+
process.stderr.write(`error(${err.status}): ${err.body}\n`);
|
|
110
|
+
if (err.hint)
|
|
111
|
+
process.stderr.write(`hint: ${err.hint}\n`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
if (err instanceof Error) {
|
|
115
|
+
if (err.message.includes("exit:3")) {
|
|
116
|
+
process.exit(3);
|
|
117
|
+
}
|
|
118
|
+
process.stderr.write(`error: ${err.message}\n`);
|
|
119
|
+
}
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2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
};
|
|
6
|
+
json: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function confCreate(opts: {
|
|
9
|
+
space: string;
|
|
10
|
+
title: string;
|
|
11
|
+
parent?: string;
|
|
12
|
+
body?: string;
|
|
13
|
+
}, ctx: CmdContext): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { api } from "../../http.js";
|
|
3
|
+
import { markdownToStorage } from "../../adf.js";
|
|
4
|
+
export async function confCreate(opts, ctx) {
|
|
5
|
+
// Resolve space key to space id
|
|
6
|
+
const spaces = await api(ctx.site, `/wiki/api/v2/spaces?keys=${encodeURIComponent(opts.space)}&limit=1`);
|
|
7
|
+
const space = spaces.results?.[0];
|
|
8
|
+
if (!space) {
|
|
9
|
+
process.stderr.write(`error(resolve): space "${opts.space}" not found\n`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
let storageBody = "";
|
|
13
|
+
if (opts.body === "-") {
|
|
14
|
+
const md = readFileSync(0, "utf-8");
|
|
15
|
+
storageBody = markdownToStorage(md);
|
|
16
|
+
}
|
|
17
|
+
else if (opts.body) {
|
|
18
|
+
storageBody = markdownToStorage(opts.body);
|
|
19
|
+
}
|
|
20
|
+
const payload = {
|
|
21
|
+
spaceId: space.id,
|
|
22
|
+
status: "current",
|
|
23
|
+
title: opts.title,
|
|
24
|
+
body: {
|
|
25
|
+
representation: "storage",
|
|
26
|
+
value: storageBody,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
if (opts.parent) {
|
|
30
|
+
payload.parentId = opts.parent;
|
|
31
|
+
}
|
|
32
|
+
const result = await api(ctx.site, "/wiki/api/v2/pages", {
|
|
33
|
+
method: "POST",
|
|
34
|
+
body: payload,
|
|
35
|
+
});
|
|
36
|
+
if (ctx.json) {
|
|
37
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const url = result._links?.webui
|
|
41
|
+
? `${ctx.site.baseUrl}/wiki${result._links.webui}`
|
|
42
|
+
: "";
|
|
43
|
+
process.stdout.write(`${result.id} ${url}\n`);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/conf/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAsE,EACtE,GAAe;IAEf,gCAAgC;IAChC,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,GAAG,CAAC,IAAI,EACR,4BAA4B,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CACrE,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAI,CAAC,KAAK,eAAe,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QACtB,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACpC,WAAW,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,OAAO,GAAwB;QACnC,OAAO,EAAE,KAAK,CAAC,EAAE;QACjB,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE;YACJ,cAAc,EAAE,SAAS;YACzB,KAAK,EAAE,WAAW;SACnB;KACF,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAM,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE;QAC5D,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IAEH,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7D,OAAO;IACT,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK;QAC9B,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,QAAQ,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;QAClD,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SiteConfig } from "../../config.js";
|
|
2
|
+
interface CmdContext {
|
|
3
|
+
site: SiteConfig & {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
json: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function confMine(opts: {
|
|
9
|
+
pages?: boolean;
|
|
10
|
+
comments?: boolean;
|
|
11
|
+
since?: string;
|
|
12
|
+
}, ctx: CmdContext): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { api } from "../../http.js";
|
|
2
|
+
import { tsv, header } from "../../format.js";
|
|
3
|
+
export async function confMine(opts, ctx) {
|
|
4
|
+
const type = opts.comments ? "comment" : "page";
|
|
5
|
+
const cql = `type = ${type} and creator = currentUser() ORDER BY lastmodified DESC`;
|
|
6
|
+
const encodedCql = encodeURIComponent(cql);
|
|
7
|
+
const path = `/wiki/rest/api/search?cql=${encodedCql}&limit=25`;
|
|
8
|
+
const body = await api(ctx.site, path);
|
|
9
|
+
if (ctx.json) {
|
|
10
|
+
process.stdout.write(JSON.stringify(body, null, 2) + "\n");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const results = body.results || [];
|
|
14
|
+
process.stdout.write(header(`${results.length} ${type}s`) + "\n");
|
|
15
|
+
const rows = results.map((r) => {
|
|
16
|
+
const content = r.content || r;
|
|
17
|
+
return [
|
|
18
|
+
content.title || "",
|
|
19
|
+
content.space?.key || r.resultGlobalContainer?.title || "",
|
|
20
|
+
(r.lastModified || content.version?.when || "").slice(0, 10),
|
|
21
|
+
content._links?.webui
|
|
22
|
+
? `${ctx.site.baseUrl}/wiki${content._links.webui}`
|
|
23
|
+
: "",
|
|
24
|
+
];
|
|
25
|
+
});
|
|
26
|
+
process.stdout.write(tsv(["title", "space", "modified", "url"], rows) + "\n");
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=mine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mine.js","sourceRoot":"","sources":["../../../src/commands/conf/mine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAO9C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAA6D,EAC7D,GAAe;IAEf,MAAM,IAAI,GAAG,IAAI,CAAC,QAA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AE;SACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SiteConfig } from "../../config.js";
|
|
2
|
+
interface CmdContext {
|
|
3
|
+
site: SiteConfig & {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
json: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function confUpdate(pageId: string, opts: {
|
|
9
|
+
append?: boolean;
|
|
10
|
+
body?: string;
|
|
11
|
+
}, ctx: CmdContext): Promise<void>;
|
|
12
|
+
export {};
|