@mbe24/99problems 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/.githooks/pre-commit +22 -0
- package/.github/logo.svg +12 -0
- package/.github/scripts/publish.js +93 -0
- package/.github/social-preview.svg +82 -0
- package/.github/workflows/ci.yml +47 -0
- package/.github/workflows/release.yml +115 -0
- package/CONTRIBUTING.md +74 -0
- package/Cargo.lock +1758 -0
- package/Cargo.toml +27 -0
- package/LICENSE +201 -0
- package/README.md +124 -0
- package/artifacts/binary-aarch64-apple-darwin/99problems +0 -0
- package/artifacts/binary-aarch64-unknown-linux-gnu/99problems +0 -0
- package/artifacts/binary-x86_64-apple-darwin/99problems +0 -0
- package/artifacts/binary-x86_64-pc-windows-msvc/99problems.exe +0 -0
- package/artifacts/binary-x86_64-unknown-linux-gnu/99problems +0 -0
- package/npm/bin/99problems.js +42 -0
- package/npm/install.js +26 -0
- package/package.json +23 -0
- package/src/config.rs +101 -0
- package/src/format/json.rs +46 -0
- package/src/format/mod.rs +10 -0
- package/src/format/yaml.rs +44 -0
- package/src/lib.rs +4 -0
- package/src/main.rs +127 -0
- package/src/model.rs +17 -0
- package/src/source/github_issues.rs +232 -0
- package/src/source/mod.rs +110 -0
- package/tests/integration.rs +58 -0
package/Cargo.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "problems99"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
description = "GitHub issue conversation fetcher CLI"
|
|
6
|
+
license = "Apache License 2.0"
|
|
7
|
+
|
|
8
|
+
[[bin]]
|
|
9
|
+
name = "99problems"
|
|
10
|
+
path = "src/main.rs"
|
|
11
|
+
|
|
12
|
+
[lib]
|
|
13
|
+
name = "problems99"
|
|
14
|
+
path = "src/lib.rs"
|
|
15
|
+
|
|
16
|
+
[dependencies]
|
|
17
|
+
anyhow = "1"
|
|
18
|
+
clap = { version = "4", features = ["derive"] }
|
|
19
|
+
dirs = "5"
|
|
20
|
+
reqwest = { version = "0.12", features = ["blocking", "json", "rustls-tls"], default-features = false }
|
|
21
|
+
serde = { version = "1", features = ["derive"] }
|
|
22
|
+
serde_json = "1"
|
|
23
|
+
serde_yaml = "0.9"
|
|
24
|
+
toml = "0.8"
|
|
25
|
+
|
|
26
|
+
[dev-dependencies]
|
|
27
|
+
serde_json = "1"
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# 99problems
|
|
2
|
+
|
|
3
|
+
[](https://github.com/mbe24/99problems/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@mbe24/99problems)
|
|
5
|
+
[](https://crates.io/crates/problems99)
|
|
6
|
+

|
|
7
|
+
[](https://raw.githubusercontent.com/mbe24/99problems/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
> AI-friendly access to GitHub issues.
|
|
10
|
+
|
|
11
|
+
Fetch GitHub issue conversations as structured JSON or YAML — ready for LLM pipelines, RAG, and bulk analysis. Uses the same search syntax as the GitHub web UI.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @mbe24/99problems
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or via cargo:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cargo install problems99
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Pre-built binaries are available for Windows x64, Linux x64, Linux ARM64, macOS Intel, and macOS Apple Silicon. No runtime dependencies.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Fetch all closed issues mentioning "Event" from a repo
|
|
33
|
+
99problems -q "is:issue state:closed Event repo:schemaorg/schemaorg" -o output.json
|
|
34
|
+
|
|
35
|
+
# Fetch a single issue
|
|
36
|
+
99problems --repo schemaorg/schemaorg --issue 1842
|
|
37
|
+
|
|
38
|
+
# YAML output
|
|
39
|
+
99problems -q "state:open label:bug repo:owner/repo" --format yaml
|
|
40
|
+
|
|
41
|
+
# Pipe into jq
|
|
42
|
+
99problems -q "state:closed repo:owner/repo" | jq '.[].title'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Output
|
|
46
|
+
|
|
47
|
+
Each result is a conversation object with the issue body and all comments:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
"id": 1842,
|
|
53
|
+
"title": "Event schema improvements",
|
|
54
|
+
"body": "Issue body text...",
|
|
55
|
+
"url": "https://github.com/schemaorg/schemaorg/issues/1842",
|
|
56
|
+
"state": "closed",
|
|
57
|
+
"created_at": "2019-04-01T12:00:00Z",
|
|
58
|
+
"comments": [
|
|
59
|
+
{
|
|
60
|
+
"author": "octocat",
|
|
61
|
+
"body": "Comment text...",
|
|
62
|
+
"created_at": "2019-04-02T08:00:00Z"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
`99problems` reads TOML dotfiles so you don't have to repeat flags on every run.
|
|
72
|
+
|
|
73
|
+
| File | Purpose |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `~/.99problems` | Global defaults (token, preferred repo, etc.) |
|
|
76
|
+
| `./.99problems` | Per-project overrides |
|
|
77
|
+
|
|
78
|
+
Example `~/.99problems`:
|
|
79
|
+
|
|
80
|
+
```toml
|
|
81
|
+
token = "ghp_your_personal_access_token"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Example `./.99problems` in a project directory:
|
|
85
|
+
|
|
86
|
+
```toml
|
|
87
|
+
repo = "owner/my-repo"
|
|
88
|
+
state = "closed"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Token is resolved in this order: `--token` flag → `GITHUB_TOKEN` env var → `./.99problems` → `~/.99problems`. Without a token the GitHub API rate limit is 60 requests/hour; with one it's 5,000/hour.
|
|
92
|
+
|
|
93
|
+
## Options
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
Options:
|
|
97
|
+
-q, --query <QUERY> Full GitHub search query (web UI syntax)
|
|
98
|
+
--repo <REPO> Shorthand for "repo:owner/name"
|
|
99
|
+
--state <STATE> Shorthand for "state:open|closed"
|
|
100
|
+
--labels <LABELS> Comma-separated labels, e.g. "bug,help wanted"
|
|
101
|
+
--issue <ISSUE> Fetch a single issue by number (requires --repo)
|
|
102
|
+
--source <SOURCE> Data source [default: github-issues]
|
|
103
|
+
--format <FORMAT> Output format: json | yaml [default: json]
|
|
104
|
+
-o, --output <FILE> Write to file instead of stdout
|
|
105
|
+
--token <TOKEN> GitHub personal access token
|
|
106
|
+
-h, --help Print help
|
|
107
|
+
-V, --version Print version
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Use cases
|
|
111
|
+
|
|
112
|
+
- **LLM context / RAG** — load issue history into a vector store or prompt
|
|
113
|
+
- **Issue triage** — process closed issues in bulk with Python or JavaScript
|
|
114
|
+
- **Dataset generation** — build labelled datasets from GitHub discussions
|
|
115
|
+
- **Changelog automation** — extract closed issues for release notes
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
See [LICENSE](LICENSE).
|
|
124
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin shim: finds the platform-specific binary and executes it.
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
const PLATFORMS = {
|
|
8
|
+
"win32-x64": "@mbe24/99problems-win32-x64",
|
|
9
|
+
"linux-x64": "@mbe24/99problems-linux-x64",
|
|
10
|
+
"linux-arm64": "@mbe24/99problems-linux-arm64",
|
|
11
|
+
"darwin-x64": "@mbe24/99problems-darwin-x64",
|
|
12
|
+
"darwin-arm64": "@mbe24/99problems-darwin-arm64",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const key = `${process.platform}-${process.arch}`;
|
|
16
|
+
const pkg = PLATFORMS[key];
|
|
17
|
+
|
|
18
|
+
if (!pkg) {
|
|
19
|
+
console.error(`99problems: unsupported platform ${key}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const binaryName = process.platform === "win32" ? "99problems.exe" : "99problems";
|
|
24
|
+
|
|
25
|
+
let binaryPath;
|
|
26
|
+
try {
|
|
27
|
+
binaryPath = require.resolve(`${pkg}/${binaryName}`);
|
|
28
|
+
} catch {
|
|
29
|
+
// Fallback: look for binary placed by install.js next to this shim
|
|
30
|
+
binaryPath = path.join(__dirname, binaryName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!fs.existsSync(binaryPath)) {
|
|
34
|
+
console.error(`99problems: binary not found at ${binaryPath}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
40
|
+
} catch (err) {
|
|
41
|
+
process.exit(err.status ?? 1);
|
|
42
|
+
}
|
package/npm/install.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// postinstall: verify the platform binary is available.
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const PLATFORMS = {
|
|
6
|
+
"win32-x64": "@mbe24/99problems-win32-x64",
|
|
7
|
+
"linux-x64": "@mbe24/99problems-linux-x64",
|
|
8
|
+
"linux-arm64": "@mbe24/99problems-linux-arm64",
|
|
9
|
+
"darwin-x64": "@mbe24/99problems-darwin-x64",
|
|
10
|
+
"darwin-arm64": "@mbe24/99problems-darwin-arm64",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key = `${process.platform}-${process.arch}`;
|
|
14
|
+
const pkg = PLATFORMS[key];
|
|
15
|
+
|
|
16
|
+
if (!pkg) {
|
|
17
|
+
console.warn(`[99problems] No prebuilt binary for platform ${key}. You may need to build from source.`);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
require.resolve(`${pkg}/99problems${process.platform === "win32" ? ".exe" : ""}`);
|
|
23
|
+
console.log(`[99problems] Binary found for ${key}.`);
|
|
24
|
+
} catch {
|
|
25
|
+
console.warn(`[99problems] Optional dependency ${pkg} not installed (this is OK if you're building from source).`);
|
|
26
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mbe24/99problems",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "GitHub issue conversation fetcher CLI",
|
|
5
|
+
"bin": {
|
|
6
|
+
"99problems": "./npm/bin/99problems.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node npm/install.js"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@mbe24/99problems-win32-x64": "0.1.0",
|
|
13
|
+
"@mbe24/99problems-linux-x64": "0.1.0",
|
|
14
|
+
"@mbe24/99problems-darwin-x64": "0.1.0",
|
|
15
|
+
"@mbe24/99problems-darwin-arm64": "0.1.0",
|
|
16
|
+
"@mbe24/99problems-linux-arm64": "0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/mbe24/99problems"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/config.rs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
use anyhow::Result;
|
|
2
|
+
use serde::Deserialize;
|
|
3
|
+
use std::path::PathBuf;
|
|
4
|
+
|
|
5
|
+
/// Represents values that can be set in a .99problems TOML dotfile.
|
|
6
|
+
#[derive(Debug, Default, Deserialize)]
|
|
7
|
+
pub struct DotfileConfig {
|
|
8
|
+
pub token: Option<String>,
|
|
9
|
+
pub repo: Option<String>,
|
|
10
|
+
pub state: Option<String>,
|
|
11
|
+
pub per_page: Option<u32>,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// Fully resolved config after merging home + local dotfiles + env var.
|
|
15
|
+
#[derive(Debug, Default)]
|
|
16
|
+
pub struct Config {
|
|
17
|
+
pub token: Option<String>,
|
|
18
|
+
pub repo: Option<String>,
|
|
19
|
+
pub state: Option<String>,
|
|
20
|
+
pub per_page: u32,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
impl Config {
|
|
24
|
+
/// Load and merge: home dotfile (base) → local dotfile (override) → env var.
|
|
25
|
+
/// CLI flags are merged later in main.rs on top of this.
|
|
26
|
+
pub fn load() -> Result<Self> {
|
|
27
|
+
let home = load_dotfile(home_dotfile_path())?;
|
|
28
|
+
let local = load_dotfile(local_dotfile_path())?;
|
|
29
|
+
|
|
30
|
+
// Merge: local wins over home
|
|
31
|
+
let token = std::env::var("GITHUB_TOKEN")
|
|
32
|
+
.ok()
|
|
33
|
+
.or_else(|| local.token.clone())
|
|
34
|
+
.or_else(|| home.token.clone());
|
|
35
|
+
|
|
36
|
+
let repo = local.repo.or(home.repo);
|
|
37
|
+
let state = local.state.or(home.state);
|
|
38
|
+
let per_page = local.per_page.or(home.per_page).unwrap_or(100);
|
|
39
|
+
|
|
40
|
+
Ok(Self {
|
|
41
|
+
token,
|
|
42
|
+
repo,
|
|
43
|
+
state,
|
|
44
|
+
per_page,
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fn home_dotfile_path() -> Option<PathBuf> {
|
|
50
|
+
dirs::home_dir().map(|h| h.join(".99problems"))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn local_dotfile_path() -> Option<PathBuf> {
|
|
54
|
+
std::env::current_dir().ok().map(|d| d.join(".99problems"))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fn load_dotfile(path: Option<PathBuf>) -> Result<DotfileConfig> {
|
|
58
|
+
let path = match path {
|
|
59
|
+
Some(p) if p.exists() => p,
|
|
60
|
+
_ => return Ok(DotfileConfig::default()),
|
|
61
|
+
};
|
|
62
|
+
let content = std::fs::read_to_string(&path)?;
|
|
63
|
+
let cfg: DotfileConfig = toml::from_str(&content)?;
|
|
64
|
+
Ok(cfg)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#[cfg(test)]
|
|
68
|
+
mod tests {
|
|
69
|
+
use super::*;
|
|
70
|
+
|
|
71
|
+
#[test]
|
|
72
|
+
fn dotfile_config_defaults_when_missing() {
|
|
73
|
+
let cfg = load_dotfile(None).unwrap();
|
|
74
|
+
assert!(cfg.token.is_none());
|
|
75
|
+
assert!(cfg.repo.is_none());
|
|
76
|
+
assert!(cfg.per_page.is_none());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#[test]
|
|
80
|
+
fn dotfile_config_parses_toml() {
|
|
81
|
+
let toml = r#"
|
|
82
|
+
token = "ghp_test"
|
|
83
|
+
repo = "owner/repo"
|
|
84
|
+
state = "closed"
|
|
85
|
+
per_page = 50
|
|
86
|
+
"#;
|
|
87
|
+
let cfg: DotfileConfig = toml::from_str(toml).unwrap();
|
|
88
|
+
assert_eq!(cfg.token.as_deref(), Some("ghp_test"));
|
|
89
|
+
assert_eq!(cfg.repo.as_deref(), Some("owner/repo"));
|
|
90
|
+
assert_eq!(cfg.per_page, Some(50));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#[test]
|
|
94
|
+
fn config_per_page_defaults_to_100() {
|
|
95
|
+
// Simulate both dotfiles missing, no env var
|
|
96
|
+
let home = DotfileConfig::default();
|
|
97
|
+
let local = DotfileConfig::default();
|
|
98
|
+
let per_page = local.per_page.or(home.per_page).unwrap_or(100);
|
|
99
|
+
assert_eq!(per_page, 100);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
use super::Formatter;
|
|
2
|
+
use crate::model::Conversation;
|
|
3
|
+
use anyhow::Result;
|
|
4
|
+
|
|
5
|
+
pub struct JsonFormatter;
|
|
6
|
+
|
|
7
|
+
impl Formatter for JsonFormatter {
|
|
8
|
+
fn format(&self, conversations: &[Conversation]) -> Result<String> {
|
|
9
|
+
Ok(serde_json::to_string_pretty(conversations)?)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[cfg(test)]
|
|
14
|
+
mod tests {
|
|
15
|
+
use super::*;
|
|
16
|
+
use crate::model::Comment;
|
|
17
|
+
|
|
18
|
+
fn sample() -> Vec<Conversation> {
|
|
19
|
+
vec![Conversation {
|
|
20
|
+
id: 42,
|
|
21
|
+
title: "Test issue".into(),
|
|
22
|
+
state: "closed".into(),
|
|
23
|
+
body: Some("Body text".into()),
|
|
24
|
+
comments: vec![Comment {
|
|
25
|
+
author: Some("user1".into()),
|
|
26
|
+
created_at: "2024-01-01T00:00:00Z".into(),
|
|
27
|
+
body: Some("A comment".into()),
|
|
28
|
+
}],
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[test]
|
|
33
|
+
fn formats_valid_json() {
|
|
34
|
+
let out = JsonFormatter.format(&sample()).unwrap();
|
|
35
|
+
let parsed: serde_json::Value = serde_json::from_str(&out).unwrap();
|
|
36
|
+
assert_eq!(parsed[0]["id"], 42);
|
|
37
|
+
assert_eq!(parsed[0]["title"], "Test issue");
|
|
38
|
+
assert_eq!(parsed[0]["comments"][0]["author"], "user1");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[test]
|
|
42
|
+
fn empty_slice_produces_empty_array() {
|
|
43
|
+
let out = JsonFormatter.format(&[]).unwrap();
|
|
44
|
+
assert_eq!(out.trim(), "[]");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
use super::Formatter;
|
|
2
|
+
use crate::model::Conversation;
|
|
3
|
+
use anyhow::Result;
|
|
4
|
+
|
|
5
|
+
pub struct YamlFormatter;
|
|
6
|
+
|
|
7
|
+
impl Formatter for YamlFormatter {
|
|
8
|
+
fn format(&self, conversations: &[Conversation]) -> Result<String> {
|
|
9
|
+
Ok(serde_yaml::to_string(conversations)?)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[cfg(test)]
|
|
14
|
+
mod tests {
|
|
15
|
+
use super::*;
|
|
16
|
+
use crate::model::Comment;
|
|
17
|
+
|
|
18
|
+
fn sample() -> Vec<Conversation> {
|
|
19
|
+
vec![Conversation {
|
|
20
|
+
id: 7,
|
|
21
|
+
title: "YAML issue".into(),
|
|
22
|
+
state: "open".into(),
|
|
23
|
+
body: None,
|
|
24
|
+
comments: vec![Comment {
|
|
25
|
+
author: None,
|
|
26
|
+
created_at: "2024-06-01T12:00:00Z".into(),
|
|
27
|
+
body: Some("comment".into()),
|
|
28
|
+
}],
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[test]
|
|
33
|
+
fn formats_valid_yaml() {
|
|
34
|
+
let out = YamlFormatter.format(&sample()).unwrap();
|
|
35
|
+
assert!(out.contains("title: YAML issue"));
|
|
36
|
+
assert!(out.contains("id: 7"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[test]
|
|
40
|
+
fn empty_slice_produces_empty_yaml_list() {
|
|
41
|
+
let out = YamlFormatter.format(&[]).unwrap();
|
|
42
|
+
assert_eq!(out.trim(), "[]");
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/lib.rs
ADDED