gh-axi 0.1.20 → 0.1.22
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/README.md +25 -2
- package/dist/src/args.d.ts +3 -3
- package/dist/src/args.js +45 -19
- package/dist/src/args.js.map +1 -1
- package/dist/src/body.d.ts +17 -3
- package/dist/src/body.js +118 -18
- package/dist/src/body.js.map +1 -1
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/cli.js +13 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/issue.d.ts +1 -1
- package/dist/src/commands/issue.js +11 -12
- package/dist/src/commands/issue.js.map +1 -1
- package/dist/src/commands/pr.d.ts +1 -1
- package/dist/src/commands/pr.js +32 -16
- package/dist/src/commands/pr.js.map +1 -1
- package/dist/src/commands/release.d.ts +2 -2
- package/dist/src/commands/release.js +221 -123
- package/dist/src/commands/release.js.map +1 -1
- package/dist/src/commands/search.js +15 -3
- package/dist/src/commands/search.js.map +1 -1
- package/dist/src/skill.d.ts +3 -0
- package/dist/src/skill.js +13 -1
- package/dist/src/skill.js.map +1 -1
- package/dist/src/suggestions.js +8 -8
- package/dist/src/suggestions.js.map +1 -1
- package/package.json +3 -2
- package/skills/gh-axi/SKILL.md +7 -1
package/README.md
CHANGED
|
@@ -14,6 +14,24 @@ GitHub CLI for agents — designed with [AXI](https://github.com/kunchenguid/axi
|
|
|
14
14
|
Wraps the official `gh` cli with token-efficient TOON output, contextual next-step suggestions, and structured error handling.
|
|
15
15
|
Built for autonomous agents that interact with GitHub via shell execution.
|
|
16
16
|
|
|
17
|
+
## Benchmarks
|
|
18
|
+
|
|
19
|
+
Agent ergonomics is measurable.
|
|
20
|
+
The [axi benchmark](https://axi.md) runs the same 17 real-world GitHub tasks (issue triage, PR review prep, CI failure investigation, and more) through 5 GitHub interface setups - 5 repeats each, with `claude-sonnet-4-6` as the agent and an LLM judge scoring task success.
|
|
21
|
+
|
|
22
|
+
gh-axi posts the lowest input tokens, cost, and duration of all 5 conditions, and is the only one to pass every run:
|
|
23
|
+
|
|
24
|
+
| Condition | Avg Input Tokens | Avg Cost/Task | Avg Duration | Avg Turns | Success |
|
|
25
|
+
| -------------------------- | ---------------- | ------------- | ------------ | --------- | -------- |
|
|
26
|
+
| **gh-axi** | **46,462** | **$0.050** | **15.7s** | **3** | **100%** |
|
|
27
|
+
| gh CLI (raw) | 47,076 | $0.054 | 17.4s | 3 | 86% |
|
|
28
|
+
| GitHub MCP code execution | 137,409 | $0.101 | 43.4s | 7 | 84% |
|
|
29
|
+
| GitHub MCP + ToolSearch | 153,621 | $0.147 | 41.1s | 8 | 82% |
|
|
30
|
+
| GitHub MCP (eager schemas) | 175,757 | $0.148 | 34.2s | 6 | 87% |
|
|
31
|
+
|
|
32
|
+
Against raw `gh` - the very CLI this tool wraps - that is 100% vs 86% task success at 7% lower cost.
|
|
33
|
+
Against the GitHub MCP server it is 66% cheaper, with 74% fewer input tokens and half the turns.
|
|
34
|
+
|
|
17
35
|
## Quick Start
|
|
18
36
|
|
|
19
37
|
Install the gh-axi skill in the [Agent Skills](https://agentskills.io) format with [`npx skills`](https://github.com/vercel-labs/skills):
|
|
@@ -27,6 +45,7 @@ The skill teaches your agent to run gh-axi through `npx -y gh-axi`, so the CLI c
|
|
|
27
45
|
You still need [`gh`](https://cli.github.com/) installed and authenticated via `gh auth login` (Node 20+ required).
|
|
28
46
|
|
|
29
47
|
The skill is not a user-facing slash command (`user-invocable: false`).
|
|
48
|
+
Its frontmatter also includes Hermes Agent metadata (`metadata.hermes`) so Hermes can categorize it as a `devops` skill for GitHub, git, CI, pull requests, and releases.
|
|
30
49
|
Just ask for anything that touches GitHub - filing issues, reviewing PRs, checking CI runs, cutting releases - and the agent loads the skill on its own when it recognizes the task.
|
|
31
50
|
|
|
32
51
|
`-g` installs the skill for all projects (`~/.claude/skills/`, for example); drop it to install for the current project only (`.claude/skills/`).
|
|
@@ -70,6 +89,9 @@ gh-axi run view --job 789012 --log-failed # show failed log lines for one job
|
|
|
70
89
|
gh-axi setup hooks # install optional agent session hooks
|
|
71
90
|
```
|
|
72
91
|
|
|
92
|
+
For multi-line issue, PR, review, or comment text, write Markdown to a UTF-8 file and pass `--body-file <path>` anywhere `--body` is accepted.
|
|
93
|
+
For releases, `--body` and `--body-file` are aliases for release notes, alongside `--notes` and `--notes-file`.
|
|
94
|
+
|
|
73
95
|
Long `run view --log` and `run view --log-failed` output shows the last 20,000 characters so CI failures stay visible.
|
|
74
96
|
When truncation happens, gh-axi best-effort saves the complete log to a temp file, includes it as `full_log`, and prints a `help:` hint telling agents to grep that file for earlier context.
|
|
75
97
|
|
|
@@ -97,6 +119,7 @@ Repository targeting is command-first too:
|
|
|
97
119
|
|
|
98
120
|
- `gh-axi issue list -R owner/name`
|
|
99
121
|
- `gh-axi issue list --repo owner/name`
|
|
122
|
+
- `gh-axi issue list --repo=owner/name`
|
|
100
123
|
- `gh-axi run list -R owner/name`
|
|
101
124
|
- `gh-axi search issues "login bug" --repo owner/name`
|
|
102
125
|
|
|
@@ -108,13 +131,13 @@ When a command also needs a destination repository, use a dedicated flag for it:
|
|
|
108
131
|
|
|
109
132
|
```sh
|
|
110
133
|
pnpm run build # Compile TypeScript to dist/
|
|
111
|
-
pnpm run build:skill # Regenerate skills/gh-axi/SKILL.md from shared
|
|
134
|
+
pnpm run build:skill # Regenerate skills/gh-axi/SKILL.md from shared skill source
|
|
112
135
|
pnpm run dev # Run CLI directly with tsx
|
|
113
136
|
pnpm test # Run tests with vitest
|
|
114
137
|
pnpm run test:watch # Run tests in watch mode
|
|
115
138
|
```
|
|
116
139
|
|
|
117
|
-
The committed `skills/gh-axi/SKILL.md` is generated by `pnpm run build:skill`; `pnpm test` fails if it drifts from the shared CLI guidance.
|
|
140
|
+
The committed `skills/gh-axi/SKILL.md` is generated by `pnpm run build:skill`; `pnpm test` fails if it drifts from the shared CLI guidance or generated skill frontmatter.
|
|
118
141
|
The npm package includes `skills/gh-axi/`, so published releases ship the same installable Agent Skill documented in Quick Start.
|
|
119
142
|
|
|
120
143
|
## License
|
package/dist/src/args.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/** Get a flag's value without modifying
|
|
1
|
+
/** Get a flag's value from --flag value or --flag=value without modifying args. */
|
|
2
2
|
export declare function getFlag(args: string[], name: string): string | undefined;
|
|
3
|
-
/** Get a flag's value
|
|
3
|
+
/** Get a flag's value from --flag value or --flag=value and remove it from args. */
|
|
4
4
|
export declare function takeFlag(args: string[], flag: string): string | undefined;
|
|
5
5
|
/** Check if a boolean flag is present. */
|
|
6
6
|
export declare function hasFlag(args: string[], flag: string): boolean;
|
|
7
7
|
/** Check if a boolean flag is present and remove it from args. */
|
|
8
8
|
export declare function takeBoolFlag(args: string[], flag: string): boolean;
|
|
9
|
-
/** Collect all values for a repeatable flag. */
|
|
9
|
+
/** Collect all values for a repeatable flag in --flag value or --flag=value form. */
|
|
10
10
|
export declare function getAllFlags(args: string[], flag: string): string[];
|
|
11
11
|
/** Get the first positional arg (non-flag) starting from startIndex. */
|
|
12
12
|
export declare function getPositional(args: string[], startIndex: number): string | undefined;
|
package/dist/src/args.js
CHANGED
|
@@ -1,19 +1,40 @@
|
|
|
1
|
-
import { AxiError } from
|
|
2
|
-
|
|
1
|
+
import { AxiError } from "./errors.js";
|
|
2
|
+
function flagEqualsPrefix(flag) {
|
|
3
|
+
return `${flag}=`;
|
|
4
|
+
}
|
|
5
|
+
/** Get a flag's value from --flag value or --flag=value without modifying args. */
|
|
3
6
|
export function getFlag(args, name) {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const equalsPrefix = flagEqualsPrefix(name);
|
|
8
|
+
for (let i = 0; i < args.length; i++) {
|
|
9
|
+
const arg = args[i];
|
|
10
|
+
if (arg === name) {
|
|
11
|
+
if (i + 1 >= args.length)
|
|
12
|
+
return undefined;
|
|
13
|
+
return args[i + 1];
|
|
14
|
+
}
|
|
15
|
+
if (arg.startsWith(equalsPrefix)) {
|
|
16
|
+
return arg.slice(equalsPrefix.length);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
8
20
|
}
|
|
9
|
-
/** Get a flag's value
|
|
21
|
+
/** Get a flag's value from --flag value or --flag=value and remove it from args. */
|
|
10
22
|
export function takeFlag(args, flag) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
const equalsPrefix = flagEqualsPrefix(flag);
|
|
24
|
+
for (let i = 0; i < args.length; i++) {
|
|
25
|
+
const arg = args[i];
|
|
26
|
+
if (arg === flag) {
|
|
27
|
+
const val = args[i + 1];
|
|
28
|
+
args.splice(i, 2);
|
|
29
|
+
return val;
|
|
30
|
+
}
|
|
31
|
+
if (arg.startsWith(equalsPrefix)) {
|
|
32
|
+
const val = arg.slice(equalsPrefix.length);
|
|
33
|
+
args.splice(i, 1);
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
17
38
|
}
|
|
18
39
|
/** Check if a boolean flag is present. */
|
|
19
40
|
export function hasFlag(args, flag) {
|
|
@@ -27,21 +48,26 @@ export function takeBoolFlag(args, flag) {
|
|
|
27
48
|
args.splice(idx, 1);
|
|
28
49
|
return true;
|
|
29
50
|
}
|
|
30
|
-
/** Collect all values for a repeatable flag. */
|
|
51
|
+
/** Collect all values for a repeatable flag in --flag value or --flag=value form. */
|
|
31
52
|
export function getAllFlags(args, flag) {
|
|
32
53
|
const result = [];
|
|
54
|
+
const equalsPrefix = flagEqualsPrefix(flag);
|
|
33
55
|
for (let i = 0; i < args.length; i++) {
|
|
34
|
-
|
|
56
|
+
const arg = args[i];
|
|
57
|
+
if (arg === flag && i + 1 < args.length) {
|
|
35
58
|
result.push(args[i + 1]);
|
|
36
59
|
i++;
|
|
37
60
|
}
|
|
61
|
+
else if (arg.startsWith(equalsPrefix)) {
|
|
62
|
+
result.push(arg.slice(equalsPrefix.length));
|
|
63
|
+
}
|
|
38
64
|
}
|
|
39
65
|
return result;
|
|
40
66
|
}
|
|
41
67
|
/** Get the first positional arg (non-flag) starting from startIndex. */
|
|
42
68
|
export function getPositional(args, startIndex) {
|
|
43
69
|
for (let i = startIndex; i < args.length; i++) {
|
|
44
|
-
if (!args[i].startsWith(
|
|
70
|
+
if (!args[i].startsWith("--"))
|
|
45
71
|
return args[i];
|
|
46
72
|
}
|
|
47
73
|
return undefined;
|
|
@@ -49,17 +75,17 @@ export function getPositional(args, startIndex) {
|
|
|
49
75
|
/** Parse and validate a required numeric argument. */
|
|
50
76
|
export function requireNumber(raw, label) {
|
|
51
77
|
if (!raw)
|
|
52
|
-
throw new AxiError(`Missing ${label} number`,
|
|
78
|
+
throw new AxiError(`Missing ${label} number`, "VALIDATION_ERROR");
|
|
53
79
|
const n = parseInt(raw, 10);
|
|
54
80
|
if (isNaN(n))
|
|
55
|
-
throw new AxiError(`Invalid ${label} number: ${raw}`,
|
|
81
|
+
throw new AxiError(`Invalid ${label} number: ${raw}`, "VALIDATION_ERROR");
|
|
56
82
|
return n;
|
|
57
83
|
}
|
|
58
84
|
/** Find the first numeric positional arg, remove it from args, and return it as a number. */
|
|
59
85
|
export function takeNumber(args, label) {
|
|
60
86
|
const raw = args.find((a) => /^\d+$/.test(a));
|
|
61
87
|
if (!raw)
|
|
62
|
-
throw new AxiError(`Missing ${label} number`,
|
|
88
|
+
throw new AxiError(`Missing ${label} number`, "VALIDATION_ERROR");
|
|
63
89
|
args.splice(args.indexOf(raw), 1);
|
|
64
90
|
return Number(raw);
|
|
65
91
|
}
|
package/dist/src/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/args.ts"],"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AC;IAC5E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}
|
package/dist/src/body.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
interface TakeBodyOptions {
|
|
2
|
+
required?: boolean;
|
|
3
|
+
inlineFlags?: string[];
|
|
4
|
+
fileFlags?: string[];
|
|
5
|
+
valueBoundaryFlags?: string[];
|
|
6
|
+
label?: string;
|
|
7
|
+
suggestions?: string[];
|
|
8
|
+
}
|
|
1
9
|
/**
|
|
2
|
-
*
|
|
10
|
+
* Resolve a command body from inline text or a UTF-8 file and remove the flags.
|
|
3
11
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
12
|
+
* Optional bodies accept at most one source. Required bodies enforce exactly
|
|
13
|
+
* one source and raise validation errors for missing, conflicting, or
|
|
14
|
+
* unreadable input.
|
|
6
15
|
*/
|
|
16
|
+
export declare function takeBody(args: string[], options: TakeBodyOptions & {
|
|
17
|
+
required: true;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function takeBody(args: string[], options?: TakeBodyOptions): string | undefined;
|
|
7
20
|
/** Clean up a body string to reduce token cost before truncation. */
|
|
8
21
|
export declare function cleanBody(text: string): string;
|
|
9
22
|
/**
|
|
@@ -12,3 +25,4 @@ export declare function cleanBody(text: string): string;
|
|
|
12
25
|
* Returns the raw body when it fits within maxLen.
|
|
13
26
|
*/
|
|
14
27
|
export declare function truncateBody(body: unknown, maxLen?: number): string;
|
|
28
|
+
export {};
|
package/dist/src/body.js
CHANGED
|
@@ -1,24 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { AxiError } from "./errors.js";
|
|
3
|
+
function defaultSuggestions(label) {
|
|
4
|
+
return [
|
|
5
|
+
`Use --body "..." for inline ${label}, or --body-file <path> for markdown from a file`,
|
|
6
|
+
];
|
|
7
|
+
}
|
|
8
|
+
function isMissingValue(value) {
|
|
9
|
+
return value === undefined || value.trim() === "";
|
|
10
|
+
}
|
|
11
|
+
function isValueBoundary(arg, flags) {
|
|
12
|
+
if (arg === undefined)
|
|
13
|
+
return false;
|
|
14
|
+
return flags.some((flag) => arg === flag || arg.startsWith(`${flag}=`));
|
|
15
|
+
}
|
|
16
|
+
function takeFlagMatches(args, flags, valueBoundaryFlags) {
|
|
17
|
+
const matches = [];
|
|
18
|
+
for (let index = 0; index < args.length; index++) {
|
|
19
|
+
const arg = args[index];
|
|
20
|
+
let matched = false;
|
|
21
|
+
for (const flag of flags) {
|
|
22
|
+
const equalsPrefix = `${flag}=`;
|
|
23
|
+
if (arg === flag) {
|
|
24
|
+
const next = args[index + 1];
|
|
25
|
+
const value = next !== undefined && !isValueBoundary(next, valueBoundaryFlags)
|
|
26
|
+
? next
|
|
27
|
+
: undefined;
|
|
28
|
+
const consumeCount = value === undefined ? 1 : 2;
|
|
29
|
+
args.splice(index, consumeCount);
|
|
30
|
+
index--;
|
|
31
|
+
matches.push({ flag, value });
|
|
32
|
+
matched = true;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (arg.startsWith(equalsPrefix)) {
|
|
36
|
+
args.splice(index, 1);
|
|
37
|
+
index--;
|
|
38
|
+
matches.push({ flag, value: arg.slice(equalsPrefix.length) });
|
|
39
|
+
matched = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (matched)
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
return matches;
|
|
47
|
+
}
|
|
48
|
+
function readBodyFile(flag, path, suggestions) {
|
|
49
|
+
try {
|
|
50
|
+
return readFileSync(path, "utf8");
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const code = error && typeof error === "object" && "code" in error
|
|
54
|
+
? String(error.code)
|
|
55
|
+
: "UNKNOWN";
|
|
56
|
+
if (code === "ENOENT") {
|
|
57
|
+
throw new AxiError(`${flag} path not found: ${path}`, "VALIDATION_ERROR", suggestions);
|
|
58
|
+
}
|
|
59
|
+
if (code === "EISDIR") {
|
|
60
|
+
throw new AxiError(`${flag} must point to a readable UTF-8 file, not a directory: ${path}`, "VALIDATION_ERROR", suggestions);
|
|
61
|
+
}
|
|
62
|
+
throw new AxiError(`Could not read ${flag} path: ${path} (${code})`, "VALIDATION_ERROR", suggestions);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function takeBody(args, options = {}) {
|
|
66
|
+
const inlineFlags = options.inlineFlags ?? ["--body"];
|
|
67
|
+
const fileFlags = options.fileFlags ?? ["--body-file"];
|
|
68
|
+
const valueBoundaryFlags = [
|
|
69
|
+
...new Set([
|
|
70
|
+
...inlineFlags,
|
|
71
|
+
...fileFlags,
|
|
72
|
+
...(options.valueBoundaryFlags ?? []),
|
|
73
|
+
]),
|
|
74
|
+
];
|
|
75
|
+
const label = options.label ?? "body";
|
|
76
|
+
const suggestions = options.suggestions ?? defaultSuggestions(label);
|
|
77
|
+
const inlineMatches = takeFlagMatches(args, inlineFlags, valueBoundaryFlags);
|
|
78
|
+
const fileMatches = takeFlagMatches(args, fileFlags, valueBoundaryFlags);
|
|
79
|
+
const matches = [...inlineMatches, ...fileMatches];
|
|
80
|
+
if (matches.length === 0) {
|
|
81
|
+
if (options.required) {
|
|
82
|
+
throw new AxiError(`${inlineFlags[0]} or ${fileFlags[0]} is required`, "VALIDATION_ERROR", suggestions);
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (matches.length > 1) {
|
|
87
|
+
throw new AxiError(`Use only one ${label} source: ${matches.map((m) => m.flag).join(", ")} were provided`, "VALIDATION_ERROR", suggestions);
|
|
88
|
+
}
|
|
89
|
+
const match = matches[0];
|
|
90
|
+
const value = match.value;
|
|
91
|
+
if (isMissingValue(value)) {
|
|
92
|
+
const noun = fileFlags.includes(match.flag) ? "path" : "text";
|
|
93
|
+
throw new AxiError(`${match.flag} requires ${noun}`, "VALIDATION_ERROR", suggestions);
|
|
94
|
+
}
|
|
95
|
+
const resolvedValue = value ?? "";
|
|
96
|
+
if (fileFlags.includes(match.flag)) {
|
|
97
|
+
return readBodyFile(match.flag, resolvedValue, suggestions);
|
|
98
|
+
}
|
|
99
|
+
return resolvedValue;
|
|
100
|
+
}
|
|
7
101
|
/** Clean up a body string to reduce token cost before truncation. */
|
|
8
102
|
export function cleanBody(text) {
|
|
9
103
|
// Normalize GitHub PR/issue URLs to short references
|
|
10
|
-
let s = text.replace(/\[([^\]]+)\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)\)/g,
|
|
11
|
-
s = s.replace(/\[([^\]]+)\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/(\d+)\)/g,
|
|
12
|
-
s = s.replace(/(?<!\()https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)/g,
|
|
13
|
-
s = s.replace(/(?<!\()https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/(\d+)/g,
|
|
104
|
+
let s = text.replace(/\[([^\]]+)\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)\)/g, "[$1](PR#$2)");
|
|
105
|
+
s = s.replace(/\[([^\]]+)\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/(\d+)\)/g, "[$1](Issue#$2)");
|
|
106
|
+
s = s.replace(/(?<!\()https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)/g, "PR#$1");
|
|
107
|
+
s = s.replace(/(?<!\()https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/(\d+)/g, "Issue#$1");
|
|
14
108
|
// Strip markdown image embeds:  → [image: alt]
|
|
15
|
-
s = s.replace(/!\[([^\]]*)\]\([^)]+\)/g, (_m, alt) => alt ? `[image: ${alt}]` :
|
|
109
|
+
s = s.replace(/!\[([^\]]*)\]\([^)]+\)/g, (_m, alt) => alt ? `[image: ${alt}]` : "[image]");
|
|
16
110
|
// Strip long URLs (>80 chars) in markdown links: [text](longurl) → [text]
|
|
17
|
-
s = s.replace(/\[([^\]]+)\]\(([^)]{80,})\)/g,
|
|
111
|
+
s = s.replace(/\[([^\]]+)\]\(([^)]{80,})\)/g, "[$1]");
|
|
18
112
|
// Strip standalone long URLs (>100 chars) not in markdown
|
|
19
|
-
s = s.replace(/(?<!\()https?:\/\/\S{100,}/g,
|
|
113
|
+
s = s.replace(/(?<!\()https?:\/\/\S{100,}/g, "[long URL removed]");
|
|
20
114
|
// Collapse email-style quoted blocks (lines starting with >) to a summary
|
|
21
|
-
s = s.replace(/(^|\n)(>\s?[^\n]*\n?){3,}/gm,
|
|
115
|
+
s = s.replace(/(^|\n)(>\s?[^\n]*\n?){3,}/gm, "$1[quoted text removed]\n");
|
|
22
116
|
return s;
|
|
23
117
|
}
|
|
24
118
|
/**
|
|
@@ -27,18 +121,24 @@ export function cleanBody(text) {
|
|
|
27
121
|
* Returns the raw body when it fits within maxLen.
|
|
28
122
|
*/
|
|
29
123
|
export function truncateBody(body, maxLen = 500) {
|
|
30
|
-
if (typeof body !==
|
|
31
|
-
return
|
|
124
|
+
if (typeof body !== "string" || !body)
|
|
125
|
+
return "";
|
|
32
126
|
if (body.length <= maxLen)
|
|
33
127
|
return body;
|
|
34
128
|
const cleaned = cleanBody(body);
|
|
35
129
|
if (cleaned.length <= maxLen) {
|
|
36
130
|
// Cleanup made it fit, but content was modified — offer --full for the original
|
|
37
131
|
if (cleaned !== body) {
|
|
38
|
-
return
|
|
132
|
+
return (cleaned +
|
|
133
|
+
"\n(cleaned, " +
|
|
134
|
+
body.length +
|
|
135
|
+
" chars original — use --full to see original)");
|
|
39
136
|
}
|
|
40
137
|
return cleaned;
|
|
41
138
|
}
|
|
42
|
-
return cleaned.slice(0, maxLen) +
|
|
139
|
+
return (cleaned.slice(0, maxLen) +
|
|
140
|
+
"\n... (truncated, " +
|
|
141
|
+
cleaned.length +
|
|
142
|
+
" chars total — use --full to see complete body)");
|
|
43
143
|
}
|
|
44
144
|
//# sourceMappingURL=body.js.map
|
package/dist/src/body.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../src/body.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../src/body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuBvC,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO;QACL,+BAA+B,KAAK,kDAAkD;KACvF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAyB;IAC/C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,eAAe,CAAC,GAAuB,EAAE,KAAe;IAC/D,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,eAAe,CACtB,IAAc,EACd,KAAe,EACf,kBAA4B;IAE5B,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MA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M,IAAI,MAAM,EAAE,CAAC;QAC7B,gFAAgF;QAChF,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,CACL,OAAO;gBACP,cAAc;gBACd,IAAI,CAAC,MAAM;gBACX,+CAA+C,CAChD,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,CACL,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC;QACxB,oBAAoB;QACpB,OAAO,CAAC,MAAM;QACd,iDAAiD,CAClD,CAAC;AACJ,CAAC"}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ type MainOptions = {
|
|
|
4
4
|
argv?: string[];
|
|
5
5
|
stdout?: CliStdout;
|
|
6
6
|
};
|
|
7
|
-
export declare const TOP_HELP = "usage: gh-axi [command] [args] [flags]\ncommands[11]:\n (none)=dashboard, issue, pr, run, workflow, release, repo, label, search, api, setup\nflags[3]:\n -R/--repo <OWNER/NAME> (after command), --help, -v/-V/--version\nexamples:\n gh-axi\n gh-axi issue list --state open\n gh-axi issue list -R owner/name\n gh-axi issue list --repo
|
|
7
|
+
export declare const TOP_HELP = "usage: gh-axi [command] [args] [flags]\ncommands[11]:\n (none)=dashboard, issue, pr, run, workflow, release, repo, label, search, api, setup\nflags[3]:\n -R/--repo <OWNER/NAME> (after command), accepts space or equals form, --help, -v/-V/--version\nexamples:\n gh-axi\n gh-axi issue list --state open\n gh-axi issue list -R owner/name\n gh-axi issue list --repo=owner/name\n gh-axi pr view 42\n gh-axi setup hooks\n";
|
|
8
8
|
export declare function main(options?: MainOptions): Promise<void>;
|
|
9
9
|
export {};
|
package/dist/src/cli.js
CHANGED
|
@@ -20,12 +20,12 @@ export const TOP_HELP = `usage: gh-axi [command] [args] [flags]
|
|
|
20
20
|
commands[11]:
|
|
21
21
|
(none)=dashboard, issue, pr, run, workflow, release, repo, label, search, api, setup
|
|
22
22
|
flags[3]:
|
|
23
|
-
-R/--repo <OWNER/NAME> (after command), --help, -v/-V/--version
|
|
23
|
+
-R/--repo <OWNER/NAME> (after command), accepts space or equals form, --help, -v/-V/--version
|
|
24
24
|
examples:
|
|
25
25
|
gh-axi
|
|
26
26
|
gh-axi issue list --state open
|
|
27
27
|
gh-axi issue list -R owner/name
|
|
28
|
-
gh-axi issue list --repo
|
|
28
|
+
gh-axi issue list --repo=owner/name
|
|
29
29
|
gh-axi pr view 42
|
|
30
30
|
gh-axi setup hooks
|
|
31
31
|
`;
|
|
@@ -95,6 +95,10 @@ function parseRepoContextArgs(command, args) {
|
|
|
95
95
|
index++;
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
|
+
if (arg.startsWith("-R=") && arg.length > 3) {
|
|
99
|
+
repoFlag = arg.slice(3);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
98
102
|
if (arg === "--repo" && index + 1 < args.length) {
|
|
99
103
|
const value = args[index + 1];
|
|
100
104
|
repoFlag = value;
|
|
@@ -104,6 +108,13 @@ function parseRepoContextArgs(command, args) {
|
|
|
104
108
|
index++;
|
|
105
109
|
continue;
|
|
106
110
|
}
|
|
111
|
+
if (arg.startsWith("--repo=") && arg.length > "--repo=".length) {
|
|
112
|
+
repoFlag = arg.slice("--repo=".length);
|
|
113
|
+
if (command === "search") {
|
|
114
|
+
stripped.push(arg);
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
107
118
|
stripped.push(arg);
|
|
108
119
|
}
|
|
109
120
|
return { repoFlag, strippedArgs: stripped };
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;A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;QACX,CAAC;QAED,IAAI,GAAG,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAE9B,QAAQ,GAAG,KAAK,CAAC;YAEjB,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC5B,CAAC;YAED,KAAK,EAAE,CAAC;YACR,SAAS;QACX,CAAC;QAED,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;YAC/D,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAEvC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;YAED,SAAS;QACX,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RepoContext } from "../context.js";
|
|
2
|
-
export declare const ISSUE_HELP = "usage: gh-axi issue <subcommand> [flags]\nsubcommands[14]:\n list, view <number>, create, edit <number>, close <number>, reopen <number>, comment <number>, delete <number>, lock <number>, unlock <number>, pin <number>, unpin <number>, transfer <number>, subissue <add|remove|list>\nflags{list}:\n --state <open|closed|all>, --label <name>, --assignee <login>, --author <login>, --milestone <name>, --sort <created|updated|comments>, --limit <n> (default 30), --fields <a,b,c>\nflags{view}:\n --comments, --full (show complete body without truncation)\nflags{create}:\n --title <text> (required), --body <text>, --assignee <login>, --label <name>, --milestone <name>, --type <name>\nflags{edit}:\n --title, --body
|
|
2
|
+
export declare const ISSUE_HELP = "usage: gh-axi issue <subcommand> [flags]\nsubcommands[14]:\n list, view <number>, create, edit <number>, close <number>, reopen <number>, comment <number>, delete <number>, lock <number>, unlock <number>, pin <number>, unpin <number>, transfer <number>, subissue <add|remove|list>\nflags{list}:\n --state <open|closed|all>, --label <name>, --assignee <login>, --author <login>, --milestone <name>, --sort <created|updated|comments>, --limit <n> (default 30), --fields <a,b,c>\nflags{view}:\n --comments, --full (show complete body without truncation)\nflags{create}:\n --title <text> (required), --body <text> or --body-file <path>, --assignee <login>, --label <name>, --milestone <name>, --type <name>\nflags{edit}:\n --title, --body <text> or --body-file <path>, --add-label, --remove-label, --add-assignee, --remove-assignee, --milestone, --type <name>, --no-type\nflags{close}:\n --reason <completed|not_planned>, --comment <text>\nflags{comment}:\n --body <text> or --body-file <path> (required)\nflags{transfer}:\n --to-repo <owner/name> (required)\nsubissue:\n add <parent> <child> [<child> ...], remove <parent> <child>, list <parent>\nexamples:\n gh-axi issue list --state closed --label bug\n gh-axi issue view 42 --comments\n gh-axi issue create --title \"Fix login\" --body \"Steps to reproduce...\"\n gh-axi issue comment 42 --body-file comment.md\n gh-axi issue close 42 --reason completed\n gh-axi issue transfer 42 -R source/repo --to-repo dest/repo\n gh-axi issue subissue add 16 20 101 125\n gh-axi issue subissue list 16";
|
|
3
3
|
export declare const SUBISSUE_HELP = "usage: gh-axi issue subissue <add|remove|list> <parent> [child...]\nsubcommands[3]:\n add <parent> <child> [<child> ...], remove <parent> <child>, list <parent>\nexamples:\n gh-axi issue subissue add 16 20 101 125\n gh-axi issue subissue remove 16 101\n gh-axi issue subissue list 16";
|
|
4
4
|
export declare function issueCommand(args: string[], ctx?: RepoContext): Promise<string>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ghJson, ghExec, ghRaw } from "../gh.js";
|
|
2
2
|
import { AxiError, mapGhError } from "../errors.js";
|
|
3
3
|
import { getSuggestions } from "../suggestions.js";
|
|
4
|
-
import {
|
|
5
|
-
import { truncateBody } from "../body.js";
|
|
4
|
+
import { hasFlag, getFlag, getPositional, requireNumber, takeFlag, takeBoolFlag, } from "../args.js";
|
|
5
|
+
import { takeBody, truncateBody } from "../body.js";
|
|
6
6
|
import { parseFields } from "../fields.js";
|
|
7
7
|
import { formatCountLine } from "../format.js";
|
|
8
8
|
import { field, pluck, joinArray, relativeTime, lower, custom, renderList, renderDetail, renderHelp, renderError, renderOutput, } from "../toon.js";
|
|
@@ -17,13 +17,13 @@ flags{list}:
|
|
|
17
17
|
flags{view}:
|
|
18
18
|
--comments, --full (show complete body without truncation)
|
|
19
19
|
flags{create}:
|
|
20
|
-
--title <text> (required), --body <text>, --assignee <login>, --label <name>, --milestone <name>, --type <name>
|
|
20
|
+
--title <text> (required), --body <text> or --body-file <path>, --assignee <login>, --label <name>, --milestone <name>, --type <name>
|
|
21
21
|
flags{edit}:
|
|
22
|
-
--title, --body
|
|
22
|
+
--title, --body <text> or --body-file <path>, --add-label, --remove-label, --add-assignee, --remove-assignee, --milestone, --type <name>, --no-type
|
|
23
23
|
flags{close}:
|
|
24
24
|
--reason <completed|not_planned>, --comment <text>
|
|
25
25
|
flags{comment}:
|
|
26
|
-
--body <text> (required)
|
|
26
|
+
--body <text> or --body-file <path> (required)
|
|
27
27
|
flags{transfer}:
|
|
28
28
|
--to-repo <owner/name> (required)
|
|
29
29
|
subissue:
|
|
@@ -32,6 +32,7 @@ examples:
|
|
|
32
32
|
gh-axi issue list --state closed --label bug
|
|
33
33
|
gh-axi issue view 42 --comments
|
|
34
34
|
gh-axi issue create --title "Fix login" --body "Steps to reproduce..."
|
|
35
|
+
gh-axi issue comment 42 --body-file comment.md
|
|
35
36
|
gh-axi issue close 42 --reason completed
|
|
36
37
|
gh-axi issue transfer 42 -R source/repo --to-repo dest/repo
|
|
37
38
|
gh-axi issue subissue add 16 20 101 125
|
|
@@ -334,7 +335,7 @@ async function createIssue(args, ctx) {
|
|
|
334
335
|
const title = getFlag(args, "--title");
|
|
335
336
|
if (!title)
|
|
336
337
|
throw new AxiError("--title is required", "VALIDATION_ERROR");
|
|
337
|
-
const body =
|
|
338
|
+
const body = takeBody(args);
|
|
338
339
|
const assignee = getFlag(args, "--assignee");
|
|
339
340
|
const label = getFlag(args, "--label");
|
|
340
341
|
const milestone = getFlag(args, "--milestone");
|
|
@@ -346,7 +347,7 @@ async function createIssue(args, ctx) {
|
|
|
346
347
|
resolvedType = await resolveIssueType(typeName, ctx);
|
|
347
348
|
}
|
|
348
349
|
const ghArgs = ["issue", "create", "--title", title];
|
|
349
|
-
if (body)
|
|
350
|
+
if (body !== undefined)
|
|
350
351
|
ghArgs.push("--body", body);
|
|
351
352
|
if (assignee)
|
|
352
353
|
ghArgs.push("--assignee", assignee);
|
|
@@ -388,7 +389,7 @@ async function createIssue(args, ctx) {
|
|
|
388
389
|
async function editIssue(args, ctx) {
|
|
389
390
|
const num = requireNumber(getPositional(args, 1), "issue");
|
|
390
391
|
const title = getFlag(args, "--title");
|
|
391
|
-
const body =
|
|
392
|
+
const body = takeBody(args);
|
|
392
393
|
const addLabel = getFlag(args, "--add-label");
|
|
393
394
|
const removeLabel = getFlag(args, "--remove-label");
|
|
394
395
|
const addAssignee = getFlag(args, "--add-assignee");
|
|
@@ -405,7 +406,7 @@ async function editIssue(args, ctx) {
|
|
|
405
406
|
const ghArgs = ["issue", "edit", String(num)];
|
|
406
407
|
if (title)
|
|
407
408
|
ghArgs.push("--title", title);
|
|
408
|
-
if (body)
|
|
409
|
+
if (body !== undefined)
|
|
409
410
|
ghArgs.push("--body", body);
|
|
410
411
|
if (addLabel)
|
|
411
412
|
ghArgs.push("--add-label", addLabel);
|
|
@@ -525,9 +526,7 @@ async function reopenIssue(args, ctx) {
|
|
|
525
526
|
}
|
|
526
527
|
async function commentOnIssue(args, ctx) {
|
|
527
528
|
const num = requireNumber(getPositional(args, 1), "issue");
|
|
528
|
-
const body =
|
|
529
|
-
if (!body)
|
|
530
|
-
throw new AxiError("--body is required", "VALIDATION_ERROR");
|
|
529
|
+
const body = takeBody(args, { required: true });
|
|
531
530
|
await ghExec(["issue", "comment", String(num), "--body", body], ctx);
|
|
532
531
|
// Fetch the latest comment
|
|
533
532
|
const issue = await ghJson(["issue", "view", String(num), "--json", "comments"], ctx);
|