ya-git-jira 1.6.0 → 2.0.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 (86) hide show
  1. package/.opencode/skills/architecture/SKILL.md +45 -0
  2. package/.opencode/skills/code-style/SKILL.md +76 -0
  3. package/.opencode/skills/git-confluence/SKILL.md +82 -0
  4. package/.opencode/skills/git-jira/SKILL.md +63 -0
  5. package/.opencode/skills/git-lab/SKILL.md +102 -0
  6. package/AGENTS.md +50 -0
  7. package/README.md +106 -106
  8. package/bin/git-api.ts +70 -0
  9. package/bin/git-confluence-page-search.ts +58 -0
  10. package/bin/git-confluence-page-show.ts +61 -0
  11. package/bin/git-confluence-page-update.ts +77 -0
  12. package/bin/git-confluence-page.ts +28 -0
  13. package/bin/git-confluence-space-list.ts +34 -0
  14. package/bin/git-confluence-space.ts +24 -0
  15. package/bin/git-confluence-whoami.ts +33 -0
  16. package/bin/git-confluence.ts +27 -0
  17. package/bin/git-jira-start.ts +1 -1
  18. package/bin/git-jira-whoami.ts +32 -0
  19. package/bin/git-jira.ts +2 -0
  20. package/bin/git-lab-project-mr-list.ts +57 -0
  21. package/bin/git-lab-project-mr.ts +24 -0
  22. package/bin/git-lab-project-pipeline-jobs.ts +46 -0
  23. package/bin/git-lab-project-pipeline-latest.ts +47 -0
  24. package/bin/git-lab-project-pipeline-log.ts +49 -0
  25. package/bin/git-lab-project-pipeline.ts +6 -0
  26. package/bin/git-lab-project.ts +5 -1
  27. package/bin/gitj-install-skills.ts +126 -0
  28. package/bin/gitj.ts +12 -0
  29. package/dist/bin/git-api.js +2156 -0
  30. package/dist/bin/git-bump.js +132 -121
  31. package/dist/bin/git-confluence-page-search.js +2079 -0
  32. package/dist/bin/git-confluence-page-show.js +2082 -0
  33. package/dist/bin/git-confluence-page-update.js +2093 -0
  34. package/dist/bin/git-confluence-page.js +2186 -0
  35. package/dist/bin/git-confluence-space-list.js +2061 -0
  36. package/dist/bin/git-confluence-space.js +2073 -0
  37. package/dist/bin/git-confluence-whoami.js +2060 -0
  38. package/dist/bin/git-confluence.js +2251 -0
  39. package/dist/bin/git-jira-issue-list.js +136 -125
  40. package/dist/bin/git-jira-issue-show.js +136 -125
  41. package/dist/bin/git-jira-issue.js +140 -129
  42. package/dist/bin/git-jira-start.js +138 -127
  43. package/dist/bin/git-jira-whoami.js +1972 -0
  44. package/dist/bin/git-jira.js +170 -139
  45. package/dist/bin/git-lab-group-list.js +321 -279
  46. package/dist/bin/git-lab-group.js +323 -281
  47. package/dist/bin/git-lab-merge-active.js +321 -279
  48. package/dist/bin/git-lab-merge-todo.js +321 -279
  49. package/dist/bin/git-lab-merge-train-list.js +289 -273
  50. package/dist/bin/git-lab-merge-train.js +291 -275
  51. package/dist/bin/git-lab-merge.js +330 -288
  52. package/dist/bin/git-lab-namespace-list.js +138 -127
  53. package/dist/bin/git-lab-namespace.js +140 -129
  54. package/dist/bin/git-lab-project-list.js +288 -272
  55. package/dist/bin/git-lab-project-mr-list.js +2740 -0
  56. package/dist/bin/git-lab-project-mr.js +2752 -0
  57. package/dist/bin/git-lab-project-pipeline-jobs.js +2734 -0
  58. package/dist/bin/git-lab-project-pipeline-latest.js +2736 -0
  59. package/dist/bin/git-lab-project-pipeline-list.js +323 -281
  60. package/dist/bin/git-lab-project-pipeline-log.js +2739 -0
  61. package/dist/bin/git-lab-project-pipeline.js +437 -292
  62. package/dist/bin/git-lab-project-whereami.js +292 -276
  63. package/dist/bin/git-lab-project.js +563 -288
  64. package/dist/bin/git-lab-whoami.js +142 -131
  65. package/dist/bin/git-lab.js +575 -338
  66. package/dist/bin/gitj-install-skills.js +1954 -0
  67. package/dist/bin/gitj.js +1385 -473
  68. package/dist/index.js +371 -187
  69. package/index.ts +1 -0
  70. package/lib/api.ts +177 -0
  71. package/lib/confluence/api.ts +132 -0
  72. package/lib/confluence/config.ts +25 -0
  73. package/lib/confluence/index.ts +3 -0
  74. package/lib/confluence/types.ts +59 -0
  75. package/lib/gitlab/index.ts +1 -0
  76. package/lib/gitlab/job.ts +31 -0
  77. package/lib/gitlab/merge-request.ts +20 -0
  78. package/lib/gitlab/pipeline.ts +28 -1
  79. package/lib/gitlab/project.ts +14 -5
  80. package/lib/help.ts +40 -0
  81. package/lib/jira.ts +2 -2
  82. package/package.json +18 -2
  83. package/tests/all-help.test.ts +6 -1
  84. package/tests/gitj.test.ts +1 -1
  85. package/tests/help-all.test.ts +29 -0
  86. package/bun.lockb +0 -0
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: architecture
3
+ description: Project architecture, CLI design patterns, and test conventions
4
+ ---
5
+
6
+ ## Dual-Mode Files
7
+
8
+ Every `bin/` file works both as an importable module (exporting `create()`) and as a
9
+ directly-executable script (via the `isMain()` guard). This enables hierarchical command
10
+ composition while allowing each command to be invoked standalone.
11
+
12
+ ## Hierarchical CLI
13
+
14
+ Commands form a tree: `gitj` -> `lab` -> `merge` -> `active`. Each level is its own
15
+ file. Parent commands add children via `.addCommand(child.create())`.
16
+
17
+ ## Eager Config Loading
18
+
19
+ Config values (git config reads) are initiated at module scope as top-level promises:
20
+ ```ts
21
+ const hostP = getConfig("jira.host")
22
+ ```
23
+ Then awaited when actually needed. This is a performance optimization.
24
+
25
+ ## GitLab API Client
26
+
27
+ - `lib/gitlab/api.ts` handles pagination by following `Link` headers with `rel="next"`
28
+ - `projectScopedGet()` auto-determines the current GitLab project from the git remote URL
29
+
30
+ ## TypeScript Configuration
31
+
32
+ - `strict: true`, target/module: `esnext`, `moduleResolution: "bundler"`
33
+ - `allowImportingTsExtensions: true` -- imports use `.ts` extensions
34
+ - `noEmit: true` -- Bun's bundler handles output, not tsc
35
+ - `types: ["bun-types"]` -- Bun global APIs (Bun.spawn, Bun.argv, etc.)
36
+
37
+ ## Test Conventions
38
+
39
+ - Test runner: Bun's built-in (`bun:test`)
40
+ - Test files: `tests/*.test.ts`
41
+ - Imports: `import { describe, expect, test, beforeEach, afterEach } from 'bun:test'`
42
+ - Tests are async with explicit `Promise<void>` return types
43
+ - Integration tests spawn real subprocesses via the project's `spawn`/`doCommand` utilities
44
+ - Some tests set custom timeouts as a second argument: `test('name', async () => { ... }, 15000)`
45
+ - `all-help.test.ts` dynamically generates tests for every `bin/*.ts` script
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: code-style
3
+ description: Code style rules for writing and editing TypeScript in this project
4
+ ---
5
+
6
+ ## File Structure
7
+
8
+ Every `bin/*.ts` file follows this exact pattern:
9
+ 1. Shebang: `#!/usr/bin/env bun`
10
+ 2. Imports
11
+ 3. Top-level `const version = await getPackageVersion()`
12
+ 4. `export function create(): Command { ... }` -- factory returning a Commander command
13
+ 5. `export default create` -- default export of the factory (not the command instance)
14
+ 6. `if (isMain('filename')) { await create().parseAsync(Bun.argv) }` -- dual-mode guard
15
+
16
+ Parent commands (routing nodes) compose children via `.addCommand()`.
17
+ Leaf commands define `.action(async () => { ... })` with inline logic.
18
+
19
+ ## Imports
20
+
21
+ - Use `import type { Foo }` for type-only imports
22
+ - Relative paths use `.ts` extensions for files: `import { foo } from "../lib/git.ts"`
23
+ - Relative paths omit extensions for directories with `index.ts`: `import { bar } from "../lib/gitlab"`
24
+ - General ordering (not strictly enforced):
25
+ 1. Third-party / built-in (`commander`, `debug`, `node:path`)
26
+ 2. Local lib modules (`../lib/git`, `../lib/gitlab`)
27
+ 3. Sibling imports (other `bin/` files for subcommand composition)
28
+
29
+ ## Naming Conventions
30
+
31
+ | Element | Convention | Examples |
32
+ |---------|-----------|----------|
33
+ | Functions | camelCase | `getConfig`, `createBranch`, `getCurrentBranch` |
34
+ | Types/Interfaces | PascalCase | `SpawnResult`, `MergeRequest`, `JiraConfig` |
35
+ | Variables/Constants | camelCase | `defaultOptions`, `dlog` |
36
+ | Files | kebab-case | `merge-request.ts`, `merge-trains.ts` |
37
+ | API response fields | snake_case (matching external APIs) | `path_with_namespace`, `source_branch` |
38
+
39
+ ## Types
40
+
41
+ - API response types use intersection with `JSONValue`:
42
+ `export type Project = JSONValue & { id: number; name: string; ... }`
43
+ - `JSONValue` is defined in `lib/json.ts` as a recursive union type
44
+ - API responses are cast with `as Type`: `await response.json() as Issue`
45
+ - Function return types are explicitly annotated: `Promise<string>`, `Promise<Array<Project>>`
46
+ - Both `Array<T>` and `T[]` appear; either is acceptable
47
+ - Use `export type` for API response shapes, `export interface` for configs/options
48
+
49
+ ## Formatting
50
+
51
+ - **4-space indentation**
52
+ - **Single quotes** for strings (not double quotes)
53
+ - Semicolons are used inconsistently; both with and without are acceptable
54
+ - Opening braces on same line: `function foo(): Type {`
55
+ - Commander method chains use 4-space indentation with dot-chaining on new lines
56
+
57
+ ## Error Handling
58
+
59
+ - **No try/catch blocks** -- errors propagate naturally
60
+ - Throw on missing config: `if (!host) throw new Error("jira.host not in git config")`
61
+ - CLI-facing errors use `console.error()` + `process.exit(1)`
62
+ - Non-fatal warnings use `console.warn()`
63
+ - The `spawn` utility warns on no-output commands unless `expectQuiet` is set
64
+
65
+ ## Debug Logging
66
+
67
+ - Uses the `debug` npm package
68
+ - Create logger: `const dlog = debug('gitlab')` or `const dlog = debug('git-lab-project-pipeline-list')`
69
+ - Centralized for gitlab module in `lib/gitlab/dlog.ts`
70
+ - Enable at runtime: `DEBUG=gitlab bun run bin/git-lab-project.ts`
71
+
72
+ ## Comments
73
+
74
+ - Minimal comments; code is self-documenting
75
+ - Use `//` single-line style when needed
76
+ - No JSDoc conventions
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: git-confluence
3
+ description: Using git-confluence commands to search, read, and update Confluence pages
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ `git-confluence` interacts with Confluence Cloud via its REST API v2.
9
+ Authentication uses git config values with fallback to `jira.*` equivalents:
10
+
11
+ ```sh
12
+ git config --global confluence.host yourcompany.atlassian.net # falls back to jira.host
13
+ git config --global confluence.user you@company.com # falls back to jira.user, then user.email
14
+ git config --global confluence.token your-api-token # falls back to jira.token
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ```
20
+ git-confluence whoami Show current authenticated user
21
+ git-confluence space list List all spaces
22
+ git-confluence page search <q> Search pages (fuzzy title, --exact, or --full-text)
23
+ git-confluence page show <id> Show page metadata (add --body-format for content)
24
+ git-confluence page update <id> Update page content (from stdin or --file)
25
+ ```
26
+
27
+ Use `--help` on any command for options.
28
+
29
+ ## Key Behaviors
30
+
31
+ - **`--body-format`** accepts `storage` (XHTML) or `atlas_doc_format` (ADF JSON).
32
+ `--body-only` requires `--body-format` to be set.
33
+ - **`page update`** always writes in `storage` representation, regardless of how
34
+ the content was read. It auto-fetches the current version and increments it.
35
+ - **Page IDs are numeric strings** (e.g., `"36306946"`).
36
+ - Page content uses Confluence storage format (XHTML with `ac:*`/`ri:*` namespaced
37
+ elements for macros, links, and images). Reference:
38
+ https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html
39
+
40
+ ## Workflow: Read, Revise, and Update a Page
41
+
42
+ ```sh
43
+ # 1. Find the page
44
+ git-confluence page search "My Page Title"
45
+
46
+ # 2. Read content (outputs raw storage-format XHTML)
47
+ git-confluence page show <id> --body-format storage --body-only > page.html
48
+
49
+ # 3. Edit page.html as needed (must remain valid storage format)
50
+
51
+ # 4. Push the update
52
+ git-confluence page update <id> --file page.html --message "Updated content"
53
+ ```
54
+
55
+ Content can also be piped via stdin:
56
+
57
+ ```sh
58
+ cat page.html | git-confluence page update <id>
59
+ ```
60
+
61
+ ## Arbitrary Confluence API Access
62
+
63
+ For operations not covered by the dedicated commands, use `git-api confluence`:
64
+
65
+ ```sh
66
+ # GET (default) -- path is relative to /wiki/api/v2
67
+ git-api confluence /spaces
68
+ git-api confluence /pages/12345
69
+
70
+ # POST (auto-promoted when --data is provided)
71
+ git-api confluence /pages -d '{"spaceId":"123","title":"New Page","body":{"representation":"storage","value":"<p>content</p>"},"status":"current"}'
72
+
73
+ # Paginated listing
74
+ git-api confluence /spaces --paginate
75
+
76
+ # Skip /wiki/api/v2 prefix for v1 API access
77
+ git-api confluence /wiki/rest/api/content/12345 --raw
78
+ ```
79
+
80
+ `git-api` handles authentication and base URL automatically. It also supports
81
+ `-v` (status/headers to stderr), and exits with code 1 on HTTP 4xx/5xx.
82
+ Run `git-api -h` for all options.
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: git-jira
3
+ description: Using git-jira commands to work with Jira issues and branches
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ `git-jira` interacts with Jira Cloud via its REST API v3. Authentication uses
9
+ git config values:
10
+
11
+ ```sh
12
+ git config --global jira.host yourcompany.atlassian.net
13
+ git config --global jira.user you@company.com # falls back to user.email
14
+ git config --global jira.token your-api-token
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ```
20
+ git-jira whoami Show current Jira user
21
+ git-jira issue list List your unresolved issues (shortcut: git-jira list)
22
+ git-jira issue show <key> Show a single issue
23
+ git-jira start <key> Create a branch from an issue key + summary
24
+ git-bump Increment the branch version suffix
25
+ ```
26
+
27
+ All dedicated commands are **read-only**. Use `--help` on any command for options.
28
+
29
+ ## Workflow: Start Working on a Jira Issue
30
+
31
+ ```sh
32
+ git-jira issue list # find your unresolved issues
33
+ git-jira start PROJ-123 # creates and checks out a descriptive branch
34
+ git-bump # re-branch with incremented suffix if needed
35
+ ```
36
+
37
+ The `start` command only creates a local branch -- it does not push or
38
+ transition the Jira issue.
39
+
40
+ ## Arbitrary Jira API Access
41
+
42
+ The dedicated commands are read-only. For write operations (creating issues,
43
+ transitions, comments, etc.), use `git-api jira`:
44
+
45
+ ```sh
46
+ # GET (default) -- path is relative to /rest/api/3
47
+ git-api jira /myself
48
+ git-api jira /issue/PROJ-123
49
+
50
+ # POST (auto-promoted when --data is provided)
51
+ git-api jira /issue -d '{"fields":{"project":{"key":"PROJ"},"summary":"New issue","issuetype":{"name":"Task"}}}'
52
+
53
+ # Explicit method
54
+ git-api jira /issue/PROJ-123 -X PUT -d '{"fields":{"summary":"Updated title"}}'
55
+ git-api jira /issue/PROJ-123/transitions -d '{"transition":{"id":"31"}}'
56
+
57
+ # Skip /rest/api/3 prefix for full URL control
58
+ git-api jira /rest/api/2/myself --raw
59
+ ```
60
+
61
+ `git-api` handles authentication and base URL automatically. It also supports
62
+ `--paginate`, `-v` (status/headers to stderr), and exits with code 1 on HTTP
63
+ 4xx/5xx. Run `git-api -h` for all options.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: git-lab
3
+ description: Using git-lab commands to work with GitLab projects, merge requests, and pipelines
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ `git-lab` interacts with GitLab via its REST API v4. Authentication uses git
9
+ config values:
10
+
11
+ ```sh
12
+ git config --global gitlab.host gitlab.example.com # defaults to gitlab.com
13
+ git config --global gitlab.token glpat-xxxxxxxxxxxx # required
14
+ ```
15
+
16
+ The token is sent as a `Private-Token` header. User identity is resolved from
17
+ `user.email` (falls back to `gitlab.user`).
18
+
19
+ ## Commands
20
+
21
+ ```
22
+ git-lab whoami Show current GitLab user
23
+ git-lab group list List groups
24
+ git-lab namespace list List namespaces
25
+ git-lab project list [--match] List projects (server + client-side filter)
26
+ git-lab project whereami Identify project from current git remote
27
+ git-lab project mr list List MRs for a project/branch (defaults to current)
28
+ git-lab merge active My open merge requests (across all projects)
29
+ git-lab merge todo MRs where I'm assigned as reviewer
30
+ git-lab merge train list Merge trains for the current project
31
+ git-lab project pipeline list Recent pipelines (scoped to current user)
32
+ git-lab project pipeline latest Jobs for latest pipeline on current branch
33
+ git-lab project pipeline jobs Jobs for a specific pipeline
34
+ git-lab project pipeline log Download a job's log output (plain text)
35
+ git-bump Increment branch version suffix
36
+ ```
37
+
38
+ All dedicated commands are **read-only**. Use `--help` on any command for
39
+ options and defaults.
40
+
41
+ ## Key Behaviors
42
+
43
+ - **Project-scoped commands** (`project whereami`, `project mr list`,
44
+ `merge train list`, all `pipeline` commands) require being in a git repo
45
+ with an `origin` remote pointing to GitLab.
46
+ - **`pipeline list`** filters to the current user's pipelines, not all project
47
+ pipelines.
48
+ - **`pipeline log`** outputs raw text to stdout, suitable for piping or agent
49
+ consumption when diagnosing CI failures.
50
+
51
+ ## Workflows
52
+
53
+ ### Find the MR for the current branch
54
+
55
+ ```sh
56
+ git-lab project mr list
57
+ ```
58
+
59
+ Defaults to the current directory's project and current branch. Use
60
+ `-p <path>` and `-b <branch>` to override.
61
+
62
+ ### Debug a CI failure
63
+
64
+ ```sh
65
+ git-lab project pipeline latest # see jobs for current branch
66
+ git-lab project pipeline log --job <id> # download the log
67
+ git-lab project pipeline log --job <id> --tail 200 # last 200 lines
68
+ ```
69
+
70
+ ### Review merge requests
71
+
72
+ ```sh
73
+ git-lab merge todo # MRs needing my review
74
+ git-lab merge active # my own open MRs
75
+ ```
76
+
77
+ ## Arbitrary GitLab API Access
78
+
79
+ The dedicated commands are read-only. For write operations (approving MRs,
80
+ posting comments, triggering pipelines, etc.), use `git-api gitlab`:
81
+
82
+ ```sh
83
+ # GET (default) -- path is relative to /api/v4
84
+ git-api gitlab /user
85
+ git-api gitlab /projects/123/merge_requests
86
+
87
+ # POST (auto-promoted when --data is provided)
88
+ git-api gitlab /projects/123/merge_requests/456/notes -d '{"body":"LGTM"}'
89
+
90
+ # Explicit method
91
+ git-api gitlab /projects/123/merge_requests/456/approve -X POST
92
+
93
+ # Paginated listing
94
+ git-api gitlab /projects --paginate
95
+
96
+ # Skip /api/v4 prefix for full URL control
97
+ git-api gitlab /api/v4/version --raw
98
+ ```
99
+
100
+ `git-api` handles authentication and base URL automatically. It also supports
101
+ `-v` (status/headers to stderr), and exits with code 1 on HTTP 4xx/5xx.
102
+ Run `git-api -h` for all options.
package/AGENTS.md ADDED
@@ -0,0 +1,50 @@
1
+ # ya-git-jira
2
+
3
+ CLI tool providing git subcommands for Jira and GitLab integration
4
+ (e.g., `git-jira start`, `git-lab merge active`, `git-bump`). Built with TypeScript
5
+ on the Bun runtime (NOT Node.js). Uses Commander.js for CLI argument parsing.
6
+
7
+ ## Commands
8
+
9
+ | Task | Command |
10
+ |------|---------|
11
+ | Install dependencies | `bun install` |
12
+ | Build | `bun run build` or `bun run build.ts` |
13
+ | Run all tests | `bun test` |
14
+ | Run a single test file | `bun test tests/git.test.ts` |
15
+ | Run a single test by name | `bun test --test-name-pattern "pattern"` |
16
+ | Type check (no emit) | `bunx tsc --noEmit` |
17
+
18
+ No linters or formatters are configured. Build output goes to `dist/` (gitignored).
19
+
20
+ ## Commit Messages
21
+
22
+ Short, lowercase, descriptive phrases without conventional-commit prefixes:
23
+ - `improved config`
24
+ - `split lib/gitlab.ts into lib/gitlab/*.ts`
25
+ - `fix/update git-lab-merge-*`
26
+ - Version bumps: `v1.6.0`
27
+
28
+ ## Key Files
29
+
30
+ | Path | Purpose |
31
+ |------|---------|
32
+ | `build.ts` | Bun build script (discovers entry points via glob) |
33
+ | `index.ts` | Barrel export of all lib modules |
34
+ | `lib/spawn.ts` | Process spawning wrapper around Bun.spawn |
35
+ | `lib/git.ts` | Git operations (config, branch, remote) |
36
+ | `lib/jira.ts` | Jira API client |
37
+ | `lib/json.ts` | JSONValue type definition |
38
+ | `lib/is_main.ts` | isMain() helper for dual import/run files |
39
+ | `lib/package.ts` | package.json reading and version extraction |
40
+ | `lib/gitlab/` | GitLab API client (api, config, groups, MRs, pipelines, etc.) |
41
+ | `lib/confluence/` | Confluence API client (api, config, types) |
42
+ | `bin/gitj.ts` | Root CLI entry point aggregating all subcommands |
43
+
44
+ ## Skills
45
+
46
+ Load the `code-style` skill before writing or editing TypeScript code.
47
+ Load the `architecture` skill when you need to understand CLI design patterns, project structure, or test conventions.
48
+ Load the `git-confluence` skill when working with Confluence pages (searching, reading, or updating content).
49
+ Load the `git-jira` skill when working with Jira issues or the `git-jira` commands.
50
+ Load the `git-lab` skill when working with GitLab projects, merge requests, or the `git-lab` commands.