pgroast 0.0.0-stage → 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 (67) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +173 -2
  3. package/bin/pgroast.mjs +19 -0
  4. package/data/precedents.sql.gz +0 -0
  5. package/docs/corpus.md +352 -0
  6. package/docs/design.md +540 -0
  7. package/docs/eval.md +245 -0
  8. package/docs/haas-paranoia-notes.md +223 -0
  9. package/invariants/README.md +15 -0
  10. package/invariants/nbtree.md +14 -0
  11. package/package.json +51 -4
  12. package/prompts/brief.md +32 -0
  13. package/prompts/committer-paranoia.md +149 -0
  14. package/prompts/critic.md +56 -0
  15. package/prompts/enrich.md +35 -0
  16. package/prompts/pushback-map.md +58 -0
  17. package/prompts/pushback-reduce.md +72 -0
  18. package/prompts/reflect.md +20 -0
  19. package/prompts/relevance.md +20 -0
  20. package/prompts/roaster-already-exists.md +23 -0
  21. package/prompts/roaster-common.md +88 -0
  22. package/prompts/roaster-demand.md +28 -0
  23. package/prompts/roaster-maintenance-fit.md +22 -0
  24. package/prompts/roaster-prior-attempts.md +29 -0
  25. package/prompts/roaster-replication-ondisk.md +24 -0
  26. package/prompts/roaster-security.md +21 -0
  27. package/prompts/roaster-standards-compat.md +21 -0
  28. package/prompts/supervisor.md +31 -0
  29. package/prompts/synth-self.md +19 -0
  30. package/prompts/synth.md +140 -0
  31. package/prompts/tone.md +21 -0
  32. package/prompts/writing.md +98 -0
  33. package/sql/schema.sql +45 -0
  34. package/src/cli.ts +391 -0
  35. package/src/corpus/cf.ts +220 -0
  36. package/src/corpus/cli.ts +189 -0
  37. package/src/corpus/db.ts +119 -0
  38. package/src/corpus/fetch.ts +104 -0
  39. package/src/corpus/reverts.ts +133 -0
  40. package/src/corpus/search.ts +201 -0
  41. package/src/corpus/util.ts +133 -0
  42. package/src/corpus/wiki.ts +80 -0
  43. package/src/eval/cases.ts +118 -0
  44. package/src/eval/cli.ts +105 -0
  45. package/src/eval/judge.ts +136 -0
  46. package/src/eval/report.ts +268 -0
  47. package/src/eval/run.ts +153 -0
  48. package/src/eval/score.ts +275 -0
  49. package/src/roast/doctor.ts +109 -0
  50. package/src/roast/enrich.ts +335 -0
  51. package/src/roast/invariants.ts +65 -0
  52. package/src/roast/llm.ts +601 -0
  53. package/src/roast/material.ts +133 -0
  54. package/src/roast/page.ts +266 -0
  55. package/src/roast/pipeline.ts +981 -0
  56. package/src/roast/precedents.ts +308 -0
  57. package/src/roast/pushback.ts +664 -0
  58. package/src/roast/render.ts +386 -0
  59. package/src/roast/sanitize.ts +140 -0
  60. package/src/roast/schema.ts +714 -0
  61. package/src/roast/tone.ts +216 -0
  62. package/src/thread/fetch.ts +172 -0
  63. package/src/thread/load.ts +227 -0
  64. package/src/thread/local.ts +73 -0
  65. package/src/thread/parse.ts +243 -0
  66. package/src/thread/patchprose.ts +143 -0
  67. package/src/thread/types.ts +120 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
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.
202
+
package/README.md CHANGED
@@ -1,3 +1,174 @@
1
- # Temporary Holding Version
1
+ # pgroast
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ PG Roast is an adversarial reviewer for Postgres proposals. It judges the idea and the design, not the code.
4
+
5
+ Given a pgsql-hackers thread or a CommitFest entry, it argues why the proposal might not be accepted, the way experienced committers do: earlier attempts that were not accepted, the strongest objections with concrete failure scenarios, and the touch points that raise the risk. A critic then tries to refute every objection, and only the survivors are reported.
6
+
7
+ > Prepared by an AI harness; treat as a devil's advocate, not a verdict.
8
+
9
+ Status: prototype. Output is local files only. Nothing is posted to mailing lists or to CommitFest, and there is no code that could do so.
10
+
11
+ ## What you get
12
+
13
+ `roast.md` (the short report), `roast-full.md`, `roast.json` and `roast-summary.txt` in a local directory. The short report has the verdict, prior attempts, the listed objections, the questions and the touch points that are hit. The full report and the JSON also have:
14
+
15
+ - a neutral restatement of the proposal;
16
+ - prior attempts from the precedent index, with links, status and who objected;
17
+ - the ranked objections that survived the critic, each with a failure scenario and what the author would need to show;
18
+ - the 15 touch points, each marked hit or not hit;
19
+ - up to 5 questions for the author;
20
+ - a verdict with a confidence, and three fields kept apart from it: `committability`, `not_now` ("not now, show demand") and `priority`.
21
+
22
+ Refuted objections stay in the JSON and are listed at the end of the full report with the critic's reason.
23
+
24
+ All prose follows one set of writing rules, [prompts/writing.md](prompts/writing.md): the point first, hard length limits per field, plain words.
25
+
26
+ ### Verdict scale
27
+
28
+ | Verdict | Meaning |
29
+ |---|---|
30
+ | `LIKELY-REJECT` | A fatal objection at the idea or design level survived the critic and cannot be overcome without making a different proposal, or the same idea was not accepted before and nothing has changed. |
31
+ | `NEEDS-DESIGN-DISCUSSION` | The goal may be fine, but the design or the demand is in question; the list needs to agree on something before code review makes sense. "Not now, show demand" goes here. |
32
+ | `NEEDS-COMMITTER-EYES` | No fundamental objection to the idea, but it touches things that only a committer who knows the area can sign off, or the remaining concerns are fixable design points. |
33
+ | `NO-FUNDAMENTAL-OBJECTION` | Nothing that survived would stop it at the idea or design level. This says nothing about the code. |
34
+
35
+ The verdict covers the review pyramid from the base up: 1a understandability, 1b desirability, 2 architecture and design. When a level fails, the levels above it are not argued. Implementation (levels 3 to 5) is out of scope. The rubric is in [prompts/committer-paranoia.md](prompts/committer-paranoia.md); its sources are in [docs/haas-paranoia-notes.md](docs/haas-paranoia-notes.md).
36
+
37
+ ### Touch points
38
+
39
+ 1. on-disk format / pg_upgrade
40
+ 2. WAL / replication / standby
41
+ 3. wire protocol
42
+ 4. catalog changes
43
+ 5. ABI / extension API
44
+ 6. SQL-standard conflict or non-standard syntax
45
+ 7. new GUC
46
+ 8. planner behaviour change
47
+ 9. pg_dump / restore round-trip
48
+ 10. psql UX conventions
49
+ 11. security / privileges
50
+ 12. backpatchability
51
+ 13. maintenance burden ("who maintains this in 10 years")
52
+ 14. performance on the hot path
53
+ 15. doesn't fit what Postgres is about (extension / external tool / already solved)
54
+
55
+ ## How it works
56
+
57
+ 1. **Brief**: a neutral restatement and the search queries for precedents.
58
+ 2. **Retrieval**, in code: full-text search over the precedent index, with a date cutoff. The proposal's own thread and CommitFest entry are excluded.
59
+ 3. **Enrichment**: precedent threads without a recorded reason are summarised once and cached. A relevance call decides which candidates the roasters see.
60
+ 4. **Seven roasters** in parallel, one angle each: prior attempts, standards and compatibility, replication and on-disk, security, maintenance and fit, already exists, demand.
61
+ 5. **Critic**: tries to refute every objection.
62
+ 6. **Synthesis**: applies the stop rule, picks the verdict, fills the touch points and the questions.
63
+ 7. **Checks in code**: links, precedent ids, message numbers and quotes are verified; a tone lint runs; then the files are written.
64
+
65
+ The models have no tools. They never see a URL: they cite ids such as `P3`, and code fills in the links from the database. Quotes are accepted only as verbatim substrings of the author's own text. Free prose is not fact-checked by code.
66
+
67
+ The precedent index holds 2,547 rows: CommitFest entries that ended Rejected, Returned with feedback or Withdrawn, revert commits from the Postgres git history, and the wiki page "Not Worth Doing". See [docs/corpus.md](docs/corpus.md).
68
+
69
+ Full design: [docs/design.md](docs/design.md).
70
+
71
+ ## Requirements
72
+
73
+ 1. **An AI coding CLI, installed and signed in with your subscription.** One of:
74
+ - [Claude Code](https://claude.com/claude-code): install it, run `claude` once and sign in (`/login`). The account needs access to Opus, and to Mythos 5.2 or Fable 5.2.
75
+ - Codex CLI: install it and run `codex login`.
76
+
77
+ PG Roast starts that CLI for every model call, so the calls count toward the limits of the account the CLI is signed in to. A roast is 12 to 20 calls. No API key is needed or used: `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `OPENAI_API_KEY` and `CODEX_API_KEY` are removed from the CLI's environment, and a call fails if the CLI reports that it is using a key.
78
+ 2. **[Bun](https://bun.sh) 1.3.5 or later.** There are no npm dependencies.
79
+ 3. **Postgres 18**, for the precedent index (database `pgroast`; `PGROAST_DSN` if it is not on the local socket). `createdb` and `psql` are used once, to load the index.
80
+ 4. A clone of the Postgres repository, only if you rebuild the index (`PGROAST_PG_REPO`).
81
+
82
+ ## Quick start
83
+
84
+ With npm (the package starts Bun for you; `bunx pgroast` works the same way):
85
+
86
+ ```
87
+ npx pgroast init-db # once: creates the database "pgroast" and loads the index
88
+ npx pgroast doctor # checks both CLIs and their login
89
+ npx pgroast <cf-id|thread-url> # results go to ./pgroast-out/<name>/
90
+ ```
91
+
92
+ From a clone:
93
+
94
+ ```
95
+ git clone https://github.com/NikolayS/pgroast && cd pgroast
96
+ bun run src/cli.ts init-db
97
+ bun run src/cli.ts doctor
98
+ bun run src/cli.ts <cf-id|thread-url> # results go to out/<name>/
99
+ ```
100
+
101
+ `doctor` makes one small call on each installed CLI and says which backends are usable. If it reports a sign-in problem, run `claude` (then `/login`) or `codex login` and try again.
102
+
103
+ Claude Code keeps one login per config directory. If you start `claude` through an alias that sets `CLAUDE_CONFIG_DIR`, a plain `pgroast` run uses a different login, which may be expired even though `claude` works for you. Set the same variable for PG Roast:
104
+
105
+ ```
106
+ CLAUDE_CONFIG_DIR=~/.claude npx pgroast doctor
107
+ ```
108
+
109
+ Fetched pages are cached in `~/.cache/pgroast` when installed from npm and in `data/cache/` in a clone (`PGROAST_CACHE_DIR` overrides both).
110
+
111
+ Models on the claude backend: roasters run on `opus` (`PGROAST_ROASTER_MODEL`), critic and synthesis on `claude-mythos-5-2` (`PGROAST_CRITIC_MODEL`). If your account does not have Mythos 5.2, use Fable 5.2, which is the same underlying model:
112
+
113
+ ```
114
+ export PGROAST_CRITIC_MODEL=claude-fable-5-2
115
+ ```
116
+
117
+ Only Opus, Mythos and Fable models are accepted on the claude backend. To use Codex instead, pass `--backend codex`.
118
+
119
+ ## Run
120
+
121
+ ```
122
+ pgroast <cf-id|cf-url|message-id|thread-url> [options]
123
+ pgroast --self --proposal FILE [--patch FILE ...]
124
+ pgroast page <roast.json> [--out FILE] [--site DIR [--base-url URL]]
125
+ pgroast doctor
126
+ pgroast init-db
127
+ ```
128
+
129
+ `pgroast` here is `npx pgroast`, or `bun run src/cli.ts` in a clone.
130
+
131
+ | Option | Meaning |
132
+ |---|---|
133
+ | `--blind N` | read only the first N messages of the thread |
134
+ | `--before YYYY-MM-DD` | read only messages before the date (UTC); also the precedent cutoff |
135
+ | `--hint TEXT` | directed precedent lookup |
136
+ | `--out DIR` | output directory; default `./pgroast-out/<slug>` (npm) or `out/<slug>` (clone) |
137
+ | `--backend claude\|codex` | which installed CLI runs the model |
138
+ | `--self` | your own proposal before you send it; with `--proposal FILE` for a draft that has no thread yet |
139
+ | `--rounds N` | extra reflection rounds after the first pass, default 0 |
140
+ | `--no-enrich` | skip the reading of precedent threads and the relevance pass |
141
+ | `--dry-run` | build every prompt, call no model |
142
+ | `--offline` | use only cached pages |
143
+
144
+ A roast at `--rounds 0` makes 11 model calls, plus up to 8 for enrichment, and takes a few minutes.
145
+
146
+ Fetching is polite: a generic User-Agent, at least 1 s between requests per host, read-only, no sign-in, and every page is cached under `data/cache/`.
147
+
148
+ ## Evaluation
149
+
150
+ `eval/cases.json` holds 18 historical proposals with a known outcome (rejected, accepted, reverted). The roaster reads only the first messages of each thread, and precedents are cut off at that date. The scoring rules were fixed before any result existed: [docs/eval.md](docs/eval.md).
151
+
152
+ ```
153
+ bun run src/eval/cli.ts run --run-id ID [--case a,b] [--concurrency 2]
154
+ bun run src/eval/cli.ts score ID
155
+ ```
156
+
157
+ ## Limits
158
+
159
+ - Models may remember how a well-known old thread ended. Blind mode cannot remove that. Only 2 of the 18 eval cases started after the models' training cutoff.
160
+ - Only idea and design are judged. A problem that shows up in the implementation is out of reach.
161
+ - The index does not hold list-only threads that never had a CommitFest entry, and search is keyword-based.
162
+ - The tone lint is a word list.
163
+ - Only the earliest thread of a multi-thread CommitFest entry is read.
164
+
165
+ ## Tests
166
+
167
+ ```
168
+ bun test
169
+ bunx tsc --noEmit
170
+ ```
171
+
172
+ ## License
173
+
174
+ Apache 2.0, see [LICENSE](LICENSE).
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ // Launcher for `npx pgroast`. PG Roast is written for Bun (TypeScript sources, Bun.sql), so this
3
+ // small Node script only finds `bun` and hands over to it.
4
+ import { spawnSync } from "node:child_process";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
9
+ const bun = process.env.PGROAST_BUN_BIN || "bun";
10
+ const r = spawnSync(bun, ["run", join(root, "src", "cli.ts"), ...process.argv.slice(2)], { stdio: "inherit" });
11
+ if (r.error) {
12
+ if (r.error.code === "ENOENT") {
13
+ console.error("pgroast needs Bun 1.3.5 or later (https://bun.sh), and `bun` was not found on PATH.\nInstall it, for example: curl -fsSL https://bun.sh/install | bash\nOr run it directly with: bunx pgroast ...");
14
+ process.exit(127);
15
+ }
16
+ console.error(`pgroast: could not start bun: ${r.error.message}`);
17
+ process.exit(1);
18
+ }
19
+ process.exit(r.status ?? 1);
Binary file