gh-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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/dist/bin/gh-axg.d.ts +2 -0
  4. package/dist/bin/gh-axg.js +4 -0
  5. package/dist/bin/gh-axg.js.map +1 -0
  6. package/dist/bin/gh-axi.d.ts +2 -0
  7. package/dist/bin/gh-axi.js +4 -0
  8. package/dist/bin/gh-axi.js.map +1 -0
  9. package/dist/src/args.d.ts +16 -0
  10. package/dist/src/args.js +66 -0
  11. package/dist/src/args.js.map +1 -0
  12. package/dist/src/body.d.ts +14 -0
  13. package/dist/src/body.js +44 -0
  14. package/dist/src/body.js.map +1 -0
  15. package/dist/src/cli.d.ts +1 -0
  16. package/dist/src/cli.js +112 -0
  17. package/dist/src/cli.js.map +1 -0
  18. package/dist/src/commands/api.d.ts +3 -0
  19. package/dist/src/commands/api.js +144 -0
  20. package/dist/src/commands/api.js.map +1 -0
  21. package/dist/src/commands/home.d.ts +3 -0
  22. package/dist/src/commands/home.js +42 -0
  23. package/dist/src/commands/home.js.map +1 -0
  24. package/dist/src/commands/issue.d.ts +3 -0
  25. package/dist/src/commands/issue.js +432 -0
  26. package/dist/src/commands/issue.js.map +1 -0
  27. package/dist/src/commands/label.d.ts +3 -0
  28. package/dist/src/commands/label.js +121 -0
  29. package/dist/src/commands/label.js.map +1 -0
  30. package/dist/src/commands/pr.d.ts +3 -0
  31. package/dist/src/commands/pr.js +544 -0
  32. package/dist/src/commands/pr.js.map +1 -0
  33. package/dist/src/commands/release.d.ts +3 -0
  34. package/dist/src/commands/release.js +209 -0
  35. package/dist/src/commands/release.js.map +1 -0
  36. package/dist/src/commands/repo.d.ts +3 -0
  37. package/dist/src/commands/repo.js +182 -0
  38. package/dist/src/commands/repo.js.map +1 -0
  39. package/dist/src/commands/run.d.ts +3 -0
  40. package/dist/src/commands/run.js +218 -0
  41. package/dist/src/commands/run.js.map +1 -0
  42. package/dist/src/commands/search.d.ts +3 -0
  43. package/dist/src/commands/search.js +295 -0
  44. package/dist/src/commands/search.js.map +1 -0
  45. package/dist/src/commands/workflow.d.ts +3 -0
  46. package/dist/src/commands/workflow.js +126 -0
  47. package/dist/src/commands/workflow.js.map +1 -0
  48. package/dist/src/context.d.ts +13 -0
  49. package/dist/src/context.js +48 -0
  50. package/dist/src/context.js.map +1 -0
  51. package/dist/src/errors.d.ts +8 -0
  52. package/dist/src/errors.js +84 -0
  53. package/dist/src/errors.js.map +1 -0
  54. package/dist/src/gh.d.ts +12 -0
  55. package/dist/src/gh.js +54 -0
  56. package/dist/src/gh.js.map +1 -0
  57. package/dist/src/suggestions.d.ts +12 -0
  58. package/dist/src/suggestions.js +431 -0
  59. package/dist/src/suggestions.js.map +1 -0
  60. package/dist/src/toon.d.ts +65 -0
  61. package/dist/src/toon.js +151 -0
  62. package/dist/src/toon.js.map +1 -0
  63. package/package.json +50 -0
@@ -0,0 +1,209 @@
1
+ import { encode } from '@toon-format/toon';
2
+ import { ghJson, ghExec } from '../gh.js';
3
+ import { AxiError } from '../errors.js';
4
+ import { getFlag, hasFlag } from '../args.js';
5
+ import { truncateBody } from '../body.js';
6
+ import { field, boolYesNo, relativeTime, pluck, custom, renderList, renderDetail, renderHelp, renderOutput, renderError, } from '../toon.js';
7
+ import { getSuggestions } from '../suggestions.js';
8
+ export const RELEASE_HELP = `usage: gh-axi release <subcommand> [flags]
9
+ subcommands[7]:
10
+ list, view <tag>, create <tag>, edit <tag>, delete <tag>, download <tag>, upload <tag>
11
+ flags{list}:
12
+ --exclude-drafts, --exclude-pre-releases, --limit (default 10)
13
+ flags{view}:
14
+ --full (show complete release notes without truncation)
15
+ flags{create}:
16
+ --title, --notes, --notes-file, --draft, --prerelease, --target, --generate-notes
17
+ flags{edit}:
18
+ --title, --notes, --draft, --prerelease
19
+ flags{download}:
20
+ --pattern, --dir`;
21
+ const listSchema = [
22
+ field('tagName', 'tag'),
23
+ field('name'),
24
+ boolYesNo('isDraft', 'draft'),
25
+ boolYesNo('isPrerelease', 'prerelease'),
26
+ relativeTime('publishedAt', 'published'),
27
+ ];
28
+ const viewSchema = [
29
+ field('tagName', 'tag'),
30
+ field('name'),
31
+ relativeTime('publishedAt', 'published'),
32
+ pluck('author', 'login', 'author'),
33
+ custom('body', (item) => truncateBody(item.body, 1000)),
34
+ ];
35
+ const viewSchemaFull = [
36
+ field('tagName', 'tag'),
37
+ field('name'),
38
+ relativeTime('publishedAt', 'published'),
39
+ pluck('author', 'login', 'author'),
40
+ custom('body', (item) => typeof item.body === 'string' ? item.body : ''),
41
+ ];
42
+ async function listReleases(args, ctx) {
43
+ const limit = getFlag(args, '--limit') ?? '10';
44
+ const ghArgs = [
45
+ 'release', 'list',
46
+ '--json', 'tagName,name,isDraft,isPrerelease,publishedAt',
47
+ '--limit', limit,
48
+ ];
49
+ if (hasFlag(args, '--exclude-drafts'))
50
+ ghArgs.push('--exclude-drafts');
51
+ if (hasFlag(args, '--exclude-pre-releases'))
52
+ ghArgs.push('--exclude-pre-releases');
53
+ const releases = await ghJson(ghArgs, ctx);
54
+ const isEmpty = releases.length === 0;
55
+ const limitNum = Number(limit);
56
+ const countLine = releases.length === limitNum
57
+ ? `count: ${releases.length} (showing first ${releases.length}; run \`gh-axi repo view\` for total count)`
58
+ : `count: ${releases.length}`;
59
+ const suggestions = getSuggestions({ domain: 'release', action: 'list', isEmpty, repo: ctx });
60
+ return renderOutput([
61
+ countLine,
62
+ renderList('releases', releases, listSchema),
63
+ renderHelp(suggestions),
64
+ ]);
65
+ }
66
+ async function viewRelease(args, ctx) {
67
+ const full = hasFlag(args, '--full');
68
+ const positionals = args.filter((a) => !a.startsWith('--'));
69
+ const tag = positionals[1];
70
+ if (!tag)
71
+ throw new AxiError('Tag is required: gh-axi release view <tag>', 'VALIDATION_ERROR');
72
+ const release = await ghJson(['release', 'view', tag, '--json', 'tagName,name,publishedAt,author,body'], ctx);
73
+ const suggestions = getSuggestions({ domain: 'release', action: 'view', id: tag, repo: ctx });
74
+ const blocks = [renderDetail('release', release, full ? viewSchemaFull : viewSchema)];
75
+ blocks.push(renderHelp(suggestions));
76
+ return renderOutput(blocks);
77
+ }
78
+ async function createRelease(args, ctx) {
79
+ const positionals = args.filter((a) => !a.startsWith('--'));
80
+ const tag = positionals[1];
81
+ if (!tag)
82
+ throw new AxiError('Tag is required: gh-axi release create <tag>', 'VALIDATION_ERROR');
83
+ const ghArgs = ['release', 'create', tag];
84
+ const title = getFlag(args, '--title');
85
+ if (title)
86
+ ghArgs.push('--title', title);
87
+ const notes = getFlag(args, '--notes');
88
+ if (notes)
89
+ ghArgs.push('--notes', notes);
90
+ const notesFile = getFlag(args, '--notes-file');
91
+ if (notesFile)
92
+ ghArgs.push('--notes-file', notesFile);
93
+ if (hasFlag(args, '--draft'))
94
+ ghArgs.push('--draft');
95
+ if (hasFlag(args, '--prerelease'))
96
+ ghArgs.push('--prerelease');
97
+ const target = getFlag(args, '--target');
98
+ if (target)
99
+ ghArgs.push('--target', target);
100
+ if (hasFlag(args, '--generate-notes'))
101
+ ghArgs.push('--generate-notes');
102
+ // Positional files (after tag, excluding flags and their values)
103
+ const files = [];
104
+ for (let i = 2; i < positionals.length; i++) {
105
+ files.push(positionals[i]);
106
+ }
107
+ ghArgs.push(...files);
108
+ await ghExec(ghArgs, ctx);
109
+ const suggestions = getSuggestions({ domain: 'release', action: 'create', id: tag, repo: ctx });
110
+ return renderOutput([
111
+ encode({ created: 'ok', tag }),
112
+ renderHelp(suggestions),
113
+ ]);
114
+ }
115
+ async function editRelease(args, ctx) {
116
+ const positionals = args.filter((a) => !a.startsWith('--'));
117
+ const tag = positionals[1];
118
+ if (!tag)
119
+ throw new AxiError('Tag is required: gh-axi release edit <tag>', 'VALIDATION_ERROR');
120
+ const ghArgs = ['release', 'edit', tag];
121
+ const title = getFlag(args, '--title');
122
+ if (title)
123
+ ghArgs.push('--title', title);
124
+ const notes = getFlag(args, '--notes');
125
+ if (notes)
126
+ ghArgs.push('--notes', notes);
127
+ if (hasFlag(args, '--draft'))
128
+ ghArgs.push('--draft');
129
+ if (hasFlag(args, '--prerelease'))
130
+ ghArgs.push('--prerelease');
131
+ await ghExec(ghArgs, ctx);
132
+ const suggestions = getSuggestions({ domain: 'release', action: 'edit', id: tag, repo: ctx });
133
+ return renderOutput([
134
+ encode({ edit: 'ok', tag }),
135
+ renderHelp(suggestions),
136
+ ]);
137
+ }
138
+ async function deleteRelease(args, ctx) {
139
+ const positionals = args.filter((a) => !a.startsWith('--'));
140
+ const tag = positionals[1];
141
+ if (!tag)
142
+ throw new AxiError('Tag is required: gh-axi release delete <tag>', 'VALIDATION_ERROR');
143
+ await ghExec(['release', 'delete', tag, '--yes'], ctx);
144
+ const suggestions = getSuggestions({ domain: 'release', action: 'delete', id: tag, repo: ctx });
145
+ return renderOutput([
146
+ encode({ delete: 'ok', tag }),
147
+ renderHelp(suggestions),
148
+ ]);
149
+ }
150
+ async function downloadRelease(args, ctx) {
151
+ const positionals = args.filter((a) => !a.startsWith('--'));
152
+ const tag = positionals[1];
153
+ if (!tag)
154
+ throw new AxiError('Tag is required: gh-axi release download <tag>', 'VALIDATION_ERROR');
155
+ const ghArgs = ['release', 'download', tag];
156
+ const pattern = getFlag(args, '--pattern');
157
+ if (pattern)
158
+ ghArgs.push('--pattern', pattern);
159
+ const dir = getFlag(args, '--dir');
160
+ if (dir)
161
+ ghArgs.push('--dir', dir);
162
+ await ghExec(ghArgs, ctx);
163
+ const suggestions = getSuggestions({ domain: 'release', action: 'download', id: tag, repo: ctx });
164
+ return renderOutput([
165
+ encode({ download: 'ok', tag }),
166
+ renderHelp(suggestions),
167
+ ]);
168
+ }
169
+ async function uploadRelease(args, ctx) {
170
+ const positionals = args.filter((a) => !a.startsWith('--'));
171
+ const tag = positionals[1];
172
+ if (!tag)
173
+ throw new AxiError('Tag is required: gh-axi release upload <tag> <files...>', 'VALIDATION_ERROR');
174
+ const files = positionals.slice(2);
175
+ if (files.length === 0)
176
+ throw new AxiError('At least one file is required: gh-axi release upload <tag> <files...>', 'VALIDATION_ERROR');
177
+ await ghExec(['release', 'upload', tag, ...files], ctx);
178
+ const suggestions = getSuggestions({ domain: 'release', action: 'upload', id: tag, repo: ctx });
179
+ return renderOutput([
180
+ encode({ upload: 'ok', tag, files: files.length }),
181
+ renderHelp(suggestions),
182
+ ]);
183
+ }
184
+ export async function releaseCommand(args, ctx) {
185
+ const sub = args[0];
186
+ if (sub === '--help' || sub === undefined)
187
+ return RELEASE_HELP;
188
+ switch (sub) {
189
+ case 'list':
190
+ return listReleases(args, ctx);
191
+ case 'view':
192
+ return viewRelease(args, ctx);
193
+ case 'create':
194
+ return createRelease(args, ctx);
195
+ case 'edit':
196
+ return editRelease(args, ctx);
197
+ case 'delete':
198
+ return deleteRelease(args, ctx);
199
+ case 'download':
200
+ return downloadRelease(args, ctx);
201
+ case 'upload':
202
+ return uploadRelease(args, ctx);
203
+ default:
204
+ return renderError(`Unknown subcommand: ${sub}`, 'VALIDATION_ERROR', [
205
+ 'Available subcommands: list, view, create, edit, delete, download, upload',
206
+ ]);
207
+ }
208
+ }
209
+ //# sourceMappingURL=release.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release.js","sourceRoot":"","sources":["../../../src/commands/release.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,KAAK,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EACL,MAAM,EACN,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,GAEZ,MAAM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AC;IACP,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RepoContext } from '../context.js';
2
+ export declare const REPO_HELP = "usage: gh-axi repo <subcommand> [flags]\nsubcommands[6]:\n view, create <name>, edit, clone <repo>, fork [repo], list [owner]\nflags{create}:\n --public, --private, --internal, --description, --clone, --template\nflags{edit}:\n --description, --visibility, --default-branch, --enable-issues, --enable-wiki\nflags{fork}:\n --clone, --remote\nflags{list}:\n --limit <n> (default 30), --visibility, --language, --archived";
3
+ export declare function repoCommand(args: string[], ctx?: RepoContext): Promise<string>;
@@ -0,0 +1,182 @@
1
+ import { encode } from '@toon-format/toon';
2
+ import { ghJson, ghExec } from '../gh.js';
3
+ import { AxiError } from '../errors.js';
4
+ import { getFlag, hasFlag } from '../args.js';
5
+ import { field, lower, pluck, relativeTime, custom, renderList, renderDetail, renderHelp, renderOutput, renderError, } from '../toon.js';
6
+ import { getSuggestions } from '../suggestions.js';
7
+ export const REPO_HELP = `usage: gh-axi repo <subcommand> [flags]
8
+ subcommands[6]:
9
+ view, create <name>, edit, clone <repo>, fork [repo], list [owner]
10
+ flags{create}:
11
+ --public, --private, --internal, --description, --clone, --template
12
+ flags{edit}:
13
+ --description, --visibility, --default-branch, --enable-issues, --enable-wiki
14
+ flags{fork}:
15
+ --clone, --remote
16
+ flags{list}:
17
+ --limit <n> (default 30), --visibility, --language, --archived`;
18
+ const viewSchema = [
19
+ field('name'),
20
+ field('description'),
21
+ pluck('defaultBranchRef', 'name', 'branch'),
22
+ field('stargazerCount', 'stars'),
23
+ field('forkCount', 'forks'),
24
+ custom('issues', (item) => item.issues?.totalCount ?? 0),
25
+ custom('prs', (item) => item.pullRequests?.totalCount ?? 0),
26
+ lower('visibility'),
27
+ pluck('primaryLanguage', 'name', 'language'),
28
+ ];
29
+ const listSchema = [
30
+ field('name'),
31
+ field('description'),
32
+ lower('visibility'),
33
+ pluck('primaryLanguage', 'name', 'language'),
34
+ field('stargazerCount', 'stars'),
35
+ relativeTime('updatedAt', 'updated'),
36
+ ];
37
+ async function viewRepo(args, ctx) {
38
+ const ghArgs = ['repo', 'view'];
39
+ // repo view takes the repo as a positional arg — always pass it if available
40
+ if (ctx)
41
+ ghArgs.push(ctx.nwo);
42
+ ghArgs.push('--json', 'name,description,defaultBranchRef,stargazerCount,forkCount,issues,pullRequests,visibility,primaryLanguage');
43
+ const repo = await ghJson(ghArgs); // Don't pass ctx — we handle repo arg ourselves
44
+ const suggestions = getSuggestions({ domain: 'repo', action: 'view', repo: ctx });
45
+ return renderOutput([
46
+ renderDetail('repo', repo, viewSchema),
47
+ renderHelp(suggestions),
48
+ ]);
49
+ }
50
+ async function createRepo(args, ctx) {
51
+ const positionals = args.filter((a) => !a.startsWith('--'));
52
+ const name = positionals[1];
53
+ if (!name)
54
+ throw new AxiError('Repository name is required: gh-axi repo create <name>', 'VALIDATION_ERROR');
55
+ const ghArgs = ['repo', 'create', name];
56
+ if (hasFlag(args, '--public'))
57
+ ghArgs.push('--public');
58
+ else if (hasFlag(args, '--private'))
59
+ ghArgs.push('--private');
60
+ else if (hasFlag(args, '--internal'))
61
+ ghArgs.push('--internal');
62
+ const description = getFlag(args, '--description');
63
+ if (description)
64
+ ghArgs.push('--description', description);
65
+ if (hasFlag(args, '--clone'))
66
+ ghArgs.push('--clone');
67
+ const template = getFlag(args, '--template');
68
+ if (template)
69
+ ghArgs.push('--template', template);
70
+ await ghExec(ghArgs);
71
+ const suggestions = getSuggestions({ domain: 'repo', action: 'create', repo: ctx });
72
+ return renderOutput([
73
+ encode({ created: 'ok', repo: name }),
74
+ renderHelp(suggestions),
75
+ ]);
76
+ }
77
+ async function editRepo(args, ctx) {
78
+ const ghArgs = ['repo', 'edit'];
79
+ if (ctx && ctx.source !== 'git')
80
+ ghArgs.push(ctx.nwo);
81
+ const description = getFlag(args, '--description');
82
+ if (description)
83
+ ghArgs.push('--description', description);
84
+ const visibility = getFlag(args, '--visibility');
85
+ if (visibility)
86
+ ghArgs.push('--visibility', visibility);
87
+ const defaultBranch = getFlag(args, '--default-branch');
88
+ if (defaultBranch)
89
+ ghArgs.push('--default-branch', defaultBranch);
90
+ const enableIssues = getFlag(args, '--enable-issues');
91
+ if (enableIssues)
92
+ ghArgs.push('--enable-issues=' + enableIssues);
93
+ const enableWiki = getFlag(args, '--enable-wiki');
94
+ if (enableWiki)
95
+ ghArgs.push('--enable-wiki=' + enableWiki);
96
+ await ghExec(ghArgs); // Don't pass ctx — we handle repo arg ourselves
97
+ const suggestions = getSuggestions({ domain: 'repo', action: 'edit', repo: ctx });
98
+ return renderOutput([
99
+ encode({ edit: 'ok' }),
100
+ renderHelp(suggestions),
101
+ ]);
102
+ }
103
+ async function cloneRepo(args) {
104
+ const positionals = args.filter((a) => !a.startsWith('--'));
105
+ const repo = positionals[1];
106
+ if (!repo)
107
+ throw new AxiError('Repository is required: gh-axi repo clone <repo>', 'VALIDATION_ERROR');
108
+ await ghExec(['repo', 'clone', repo]);
109
+ const suggestions = getSuggestions({ domain: 'repo', action: 'clone' });
110
+ return renderOutput([
111
+ encode({ clone: 'ok', repo }),
112
+ renderHelp(suggestions),
113
+ ]);
114
+ }
115
+ async function forkRepo(args, ctx) {
116
+ const positionals = args.filter((a) => !a.startsWith('--'));
117
+ const repo = positionals[1]; // optional
118
+ const ghArgs = ['repo', 'fork'];
119
+ if (repo)
120
+ ghArgs.push(repo);
121
+ if (hasFlag(args, '--clone'))
122
+ ghArgs.push('--clone');
123
+ if (hasFlag(args, '--remote'))
124
+ ghArgs.push('--remote');
125
+ await ghExec(ghArgs, ctx);
126
+ const suggestions = getSuggestions({ domain: 'repo', action: 'fork', repo: ctx });
127
+ return renderOutput([
128
+ encode({ fork: 'ok', repo: repo ?? ctx?.nwo ?? 'current' }),
129
+ renderHelp(suggestions),
130
+ ]);
131
+ }
132
+ async function listRepos(args, ctx) {
133
+ const positionals = args.filter((a) => !a.startsWith('--'));
134
+ const owner = positionals[1]; // optional
135
+ const limit = getFlag(args, '--limit') ?? '30';
136
+ const ghArgs = [
137
+ 'repo', 'list',
138
+ '--json', 'name,description,visibility,primaryLanguage,stargazerCount,updatedAt',
139
+ '--limit', limit,
140
+ ];
141
+ if (owner)
142
+ ghArgs.splice(2, 0, owner); // insert owner after 'list'
143
+ const visibility = getFlag(args, '--visibility');
144
+ if (visibility)
145
+ ghArgs.push('--visibility', visibility);
146
+ const language = getFlag(args, '--language');
147
+ if (language)
148
+ ghArgs.push('--language', language);
149
+ if (hasFlag(args, '--archived'))
150
+ ghArgs.push('--archived');
151
+ const repos = await ghJson(ghArgs);
152
+ const isEmpty = repos.length === 0;
153
+ const suggestions = getSuggestions({ domain: 'repo', action: 'list', isEmpty, repo: ctx });
154
+ return renderOutput([
155
+ renderList('repos', repos, listSchema),
156
+ renderHelp(suggestions),
157
+ ]);
158
+ }
159
+ export async function repoCommand(args, ctx) {
160
+ const sub = args[0];
161
+ if (sub === '--help' || sub === undefined)
162
+ return REPO_HELP;
163
+ switch (sub) {
164
+ case 'view':
165
+ return viewRepo(args, ctx);
166
+ case 'create':
167
+ return createRepo(args, ctx);
168
+ case 'edit':
169
+ return editRepo(args, ctx);
170
+ case 'clone':
171
+ return cloneRepo(args);
172
+ case 'fork':
173
+ return forkRepo(args, ctx);
174
+ case 'list':
175
+ return listRepos(args, ctx);
176
+ default:
177
+ return renderError(`Unknown subcommand: ${sub}`, 'VALIDATION_ERROR', [
178
+ 'Available subcommands: view, create, edit, clone, fork, list',
179
+ ]);
180
+ }
181
+ }
182
+ //# sourceMappingURL=repo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo.js","sourceRoot":"","sources":["../../../src/commands/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAA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ACjE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpB,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE5D,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/B,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,KAAK,OAAO;YACV,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,KAAK,MAAM;YACT,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9B;YACE,OAAO,WAAW,CAAC,uBAAuB,GAAG,EAAE,EAAE,kBAAkB,EAAE;gBACnE,8DAA8D;aAC/D,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RepoContext } from '../context.js';
2
+ export declare const RUN_HELP = "usage: gh-axi run <subcommand> [flags]\nsubcommands[7]:\n list, view <id>, watch <id>, rerun <id>, cancel <id>, delete <id>, download <id>\nflags{list}:\n --workflow, --branch, --status, --event, --user, --commit, --limit (default 10)\nflags{view}:\n --log, --log-failed, --conclusion <success|failure|cancelled|skipped> (filter jobs by conclusion)\nflags{rerun}:\n --failed, --debug, --job\nflags{download}:\n --name, --dir";
3
+ export declare function runCommand(args: string[], ctx?: RepoContext): Promise<string>;
@@ -0,0 +1,218 @@
1
+ import { encode } from '@toon-format/toon';
2
+ import { ghJson, ghExec } from '../gh.js';
3
+ import { AxiError } from '../errors.js';
4
+ import { getFlag, hasFlag } from '../args.js';
5
+ import { field, lower, relativeTime, renderList, renderDetail, renderHelp, renderOutput, renderError, } from '../toon.js';
6
+ import { getSuggestions } from '../suggestions.js';
7
+ export const RUN_HELP = `usage: gh-axi run <subcommand> [flags]
8
+ subcommands[7]:
9
+ list, view <id>, watch <id>, rerun <id>, cancel <id>, delete <id>, download <id>
10
+ flags{list}:
11
+ --workflow, --branch, --status, --event, --user, --commit, --limit (default 10)
12
+ flags{view}:
13
+ --log, --log-failed, --conclusion <success|failure|cancelled|skipped> (filter jobs by conclusion)
14
+ flags{rerun}:
15
+ --failed, --debug, --job
16
+ flags{download}:
17
+ --name, --dir`;
18
+ const listSchema = [
19
+ field('databaseId', 'id'),
20
+ field('displayTitle', 'title'),
21
+ lower('status'),
22
+ lower('conclusion'),
23
+ field('workflowName', 'workflow'),
24
+ field('headBranch', 'branch'),
25
+ field('event'),
26
+ relativeTime('createdAt', 'created'),
27
+ ];
28
+ const viewSchema = [
29
+ field('databaseId', 'id'),
30
+ field('displayTitle', 'title'),
31
+ lower('status'),
32
+ lower('conclusion'),
33
+ field('workflowName', 'workflow'),
34
+ field('headBranch', 'branch'),
35
+ relativeTime('createdAt', 'created'),
36
+ ];
37
+ const jobSchema = [
38
+ field('name'),
39
+ lower('status'),
40
+ lower('conclusion'),
41
+ ];
42
+ async function listRuns(args, ctx) {
43
+ const limit = getFlag(args, '--limit') ?? '10';
44
+ const ghArgs = [
45
+ 'run', 'list',
46
+ '--json', 'databaseId,displayTitle,status,conclusion,workflowName,headBranch,event,createdAt',
47
+ '--limit', limit,
48
+ ];
49
+ const workflow = getFlag(args, '--workflow');
50
+ if (workflow)
51
+ ghArgs.push('--workflow', workflow);
52
+ const branch = getFlag(args, '--branch');
53
+ if (branch)
54
+ ghArgs.push('--branch', branch);
55
+ const status = getFlag(args, '--status');
56
+ if (status)
57
+ ghArgs.push('--status', status);
58
+ const event = getFlag(args, '--event');
59
+ if (event)
60
+ ghArgs.push('--event', event);
61
+ const user = getFlag(args, '--user');
62
+ if (user)
63
+ ghArgs.push('--user', user);
64
+ const commit = getFlag(args, '--commit');
65
+ if (commit)
66
+ ghArgs.push('--commit', commit);
67
+ const runs = await ghJson(ghArgs, ctx);
68
+ const isEmpty = runs.length === 0;
69
+ const limitNum = Number(limit);
70
+ const countLine = runs.length === limitNum
71
+ ? `count: ${runs.length} (showing first ${runs.length}; run \`gh-axi repo view\` for total count)`
72
+ : `count: ${runs.length}`;
73
+ const suggestions = getSuggestions({ domain: 'run', action: 'list', isEmpty, repo: ctx });
74
+ return renderOutput([
75
+ countLine,
76
+ renderList('runs', runs, listSchema),
77
+ renderHelp(suggestions),
78
+ ]);
79
+ }
80
+ async function viewRun(args, ctx) {
81
+ const positionals = args.filter((a) => !a.startsWith('--'));
82
+ const id = positionals[1]; // positionals[0] is "view"
83
+ if (!id)
84
+ throw new AxiError('Run ID is required: gh-axi run view <id>', 'VALIDATION_ERROR');
85
+ // Handle log modes
86
+ if (hasFlag(args, '--log') || hasFlag(args, '--verbose')) {
87
+ return ghExec(['run', 'view', id, '--log'], ctx);
88
+ }
89
+ if (hasFlag(args, '--log-failed')) {
90
+ return ghExec(['run', 'view', id, '--log-failed'], ctx);
91
+ }
92
+ const run = await ghJson(['run', 'view', id, '--json', 'databaseId,displayTitle,status,conclusion,workflowName,headBranch,createdAt,jobs'], ctx);
93
+ const state = run.status === 'completed' ? 'completed' : 'in_progress';
94
+ const suggestions = getSuggestions({ domain: 'run', action: 'view', state, id, repo: ctx });
95
+ const blocks = [renderDetail('run', run, viewSchema)];
96
+ const jobsArr = run.jobs;
97
+ if (Array.isArray(jobsArr) && jobsArr.length > 0) {
98
+ const typedJobs = jobsArr;
99
+ const conclusionFilter = getFlag(args, '--conclusion');
100
+ const jobs = conclusionFilter
101
+ ? typedJobs.filter((j) => (typeof j.conclusion === 'string' ? j.conclusion : '').toLowerCase() === conclusionFilter.toLowerCase())
102
+ : typedJobs;
103
+ if (conclusionFilter) {
104
+ blocks.push(`jobs: ${jobs.length} of ${typedJobs.length} with conclusion=${conclusionFilter}`);
105
+ }
106
+ blocks.push(renderList('jobs', jobs, jobSchema));
107
+ }
108
+ blocks.push(renderHelp(suggestions));
109
+ return renderOutput(blocks);
110
+ }
111
+ async function watchRun(args, ctx) {
112
+ const positionals = args.filter((a) => !a.startsWith('--'));
113
+ const id = positionals[1];
114
+ if (!id)
115
+ throw new AxiError('Run ID is required: gh-axi run watch <id>', 'VALIDATION_ERROR');
116
+ const ghArgs = ['run', 'watch', id, '--exit-status'];
117
+ const output = await ghExec(ghArgs, ctx);
118
+ const suggestions = getSuggestions({ domain: 'run', action: 'watch', id, repo: ctx });
119
+ return renderOutput([output.trim(), renderHelp(suggestions)]);
120
+ }
121
+ async function rerunRun(args, ctx) {
122
+ const positionals = args.filter((a) => !a.startsWith('--'));
123
+ const id = positionals[1];
124
+ if (!id)
125
+ throw new AxiError('Run ID is required: gh-axi run rerun <id>', 'VALIDATION_ERROR');
126
+ const ghArgs = ['run', 'rerun', id];
127
+ if (hasFlag(args, '--failed'))
128
+ ghArgs.push('--failed');
129
+ if (hasFlag(args, '--debug'))
130
+ ghArgs.push('--debug');
131
+ const job = getFlag(args, '--job');
132
+ if (job)
133
+ ghArgs.push('--job', job);
134
+ await ghExec(ghArgs, ctx);
135
+ const suggestions = getSuggestions({ domain: 'run', action: 'rerun', id, repo: ctx });
136
+ return renderOutput([
137
+ encode({ rerun: 'ok', run: id }),
138
+ renderHelp(suggestions),
139
+ ]);
140
+ }
141
+ async function cancelRun(args, ctx) {
142
+ const positionals = args.filter((a) => !a.startsWith('--'));
143
+ const id = positionals[1];
144
+ if (!id)
145
+ throw new AxiError('Run ID is required: gh-axi run cancel <id>', 'VALIDATION_ERROR');
146
+ // Idempotent: check status first
147
+ const run = await ghJson(['run', 'view', id, '--json', 'status,conclusion'], ctx);
148
+ if (run.status === 'completed') {
149
+ const suggestions = getSuggestions({ domain: 'run', action: 'cancel', id, repo: ctx });
150
+ return renderOutput([
151
+ encode({ cancel: 'already_completed', run: id, conclusion: typeof run.conclusion === 'string' ? run.conclusion.toLowerCase() : 'unknown' }),
152
+ renderHelp(suggestions),
153
+ ]);
154
+ }
155
+ await ghExec(['run', 'cancel', id], ctx);
156
+ const suggestions = getSuggestions({ domain: 'run', action: 'cancel', id, repo: ctx });
157
+ return renderOutput([
158
+ encode({ cancel: 'ok', run: id }),
159
+ renderHelp(suggestions),
160
+ ]);
161
+ }
162
+ async function deleteRun(args, ctx) {
163
+ const positionals = args.filter((a) => !a.startsWith('--'));
164
+ const id = positionals[1];
165
+ if (!id)
166
+ throw new AxiError('Run ID is required: gh-axi run delete <id>', 'VALIDATION_ERROR');
167
+ await ghExec(['run', 'delete', id], ctx);
168
+ const suggestions = getSuggestions({ domain: 'run', action: 'delete', id, repo: ctx });
169
+ return renderOutput([
170
+ encode({ delete: 'ok', run: id }),
171
+ renderHelp(suggestions),
172
+ ]);
173
+ }
174
+ async function downloadRun(args, ctx) {
175
+ const positionals = args.filter((a) => !a.startsWith('--'));
176
+ const id = positionals[1];
177
+ if (!id)
178
+ throw new AxiError('Run ID is required: gh-axi run download <id>', 'VALIDATION_ERROR');
179
+ const ghArgs = ['run', 'download', id];
180
+ const name = getFlag(args, '--name');
181
+ if (name)
182
+ ghArgs.push('--name', name);
183
+ const dir = getFlag(args, '--dir');
184
+ if (dir)
185
+ ghArgs.push('--dir', dir);
186
+ await ghExec(ghArgs, ctx);
187
+ const suggestions = getSuggestions({ domain: 'run', action: 'download', id, repo: ctx });
188
+ return renderOutput([
189
+ encode({ download: 'ok', run: id }),
190
+ renderHelp(suggestions),
191
+ ]);
192
+ }
193
+ export async function runCommand(args, ctx) {
194
+ const sub = args[0];
195
+ if (sub === '--help' || sub === undefined)
196
+ return RUN_HELP;
197
+ switch (sub) {
198
+ case 'list':
199
+ return listRuns(args, ctx);
200
+ case 'view':
201
+ return viewRun(args, ctx);
202
+ case 'watch':
203
+ return watchRun(args, ctx);
204
+ case 'rerun':
205
+ return rerunRun(args, ctx);
206
+ case 'cancel':
207
+ return cancelRun(args, ctx);
208
+ case 'delete':
209
+ return deleteRun(args, ctx);
210
+ case 'download':
211
+ return downloadRun(args, ctx);
212
+ default:
213
+ return renderError(`Unknown subcommand: ${sub}`, 'VALIDATION_ERROR', [
214
+ 'Available subcommands: list, view, watch, rerun, cancel, delete, download',
215
+ ]);
216
+ }
217
+ }
218
+ //# sourceMappingURL=run.js.map