wachiman 1.13.0 → 1.15.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/README.md +2 -2
- package/bin/wachiman.js +1 -1
- package/package.json +5 -4
- package/skills/wachiman-review/SKILL.md +2 -2
- package/src/accounts/confirm.ts +62 -3
- package/src/cli.ts +136 -132
- package/src/config.ts +83 -35
- package/src/connectors/local-git.ts +1 -1
- package/src/cost.ts +28 -1
- package/src/engine.ts +396 -38
- package/src/help.ts +555 -0
- package/src/history/store.ts +5 -5
- package/src/init/options.ts +1 -1
- package/src/init/run.ts +43 -17
- package/src/ledger-read/command.ts +106 -0
- package/src/ledger-read/credentials.ts +103 -0
- package/src/ledger-read/files.ts +141 -0
- package/src/ledger-read/pull.ts +69 -0
- package/src/ledger-read/rows.ts +60 -0
- package/src/ledger-read/types.ts +127 -0
- package/src/ledger.ts +322 -0
- package/src/local.ts +4 -4
- package/src/providers/claude-code.ts +1 -1
- package/src/providers/codex.ts +5 -5
- package/src/providers/index.ts +1 -1
- package/src/providers/types.ts +3 -3
- package/src/setup/run.ts +27 -10
- package/src/sinks/common.ts +3 -3
- package/src/spend/report.ts +349 -0
- package/src/status/command.ts +151 -37
- package/src/store/command.ts +20 -3
- package/src/store/html.ts +205 -8
- package/src/store/index.ts +64 -5
- package/src/store/rows.ts +103 -0
- package/src/wizard/interactive.ts +11 -0
- package/src/wizard/launcher.ts +340 -0
- package/src/wizard/load.ts +30 -0
- package/src/wizard/mascot.ts +223 -0
- package/src/wizard/prompt-fancy.ts +127 -0
- package/src/wizard/prompt.ts +95 -61
- package/src/wizard/style.ts +93 -13
- package/src/wizard/tone.ts +11 -0
- package/src/wizard/ui.ts +78 -0
- package/templates/caller-workflow.yml +44 -47
- package/templates/wachiman-review-caller.yml +5 -0
package/src/help.ts
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The help text of every command. `wachiman --help` is a short index; `wachiman <command> --help`
|
|
3
|
+
* and `wachiman help <command>` print one command's page, and `wachiman help ci` the commands that
|
|
4
|
+
* only a GitHub Actions run uses. Nothing here loads configuration, reads the repository or calls a
|
|
5
|
+
* model: `helpFor` is called by `main` before any of that. The full reference is docs/cli.md.
|
|
6
|
+
*/
|
|
7
|
+
import { plain, type Paint } from "./wizard/tone";
|
|
8
|
+
import { askUsage } from "./local-ask";
|
|
9
|
+
import { dashboardUsage } from "./store/command";
|
|
10
|
+
import { ledgerUsage } from "./ledger-read/command";
|
|
11
|
+
import { doctorUsage } from "./doctor/run";
|
|
12
|
+
import { historyUsage } from "./history/command";
|
|
13
|
+
import { initUsage } from "./init/args";
|
|
14
|
+
import { localUsage } from "./local";
|
|
15
|
+
import { loopUsage } from "./loop/command";
|
|
16
|
+
import { profileUsage, projectUsage, setupUsage } from "./accounts/commands";
|
|
17
|
+
import { skillsUsage } from "./skills/install";
|
|
18
|
+
import { statusUsage } from "./status/command";
|
|
19
|
+
|
|
20
|
+
export const DOCS = "https://github.com/niway-dev/wachiman/blob/main/docs";
|
|
21
|
+
|
|
22
|
+
// Colors the section headers only. The page takes a `Paint`; `terminalStyle` in `src/wizard/style.ts` makes the one that uses
|
|
23
|
+
// chalk (plain text when the output is not a terminal or `NO_COLOR` is set), so this module, which
|
|
24
|
+
// the review engine's entry point imports, never loads it.
|
|
25
|
+
export { plain, type Paint };
|
|
26
|
+
|
|
27
|
+
type Row = readonly [name: string, text: string];
|
|
28
|
+
|
|
29
|
+
interface Page {
|
|
30
|
+
/** The usage lines (a usage constant of the command, or several lines for a parent command). */
|
|
31
|
+
usage: string;
|
|
32
|
+
summary: string;
|
|
33
|
+
options?: readonly Row[];
|
|
34
|
+
env?: readonly Row[];
|
|
35
|
+
exit: readonly Row[];
|
|
36
|
+
examples: readonly string[];
|
|
37
|
+
docs: string;
|
|
38
|
+
/** Pages of the nested commands (`profile create`, `skills install`, …). */
|
|
39
|
+
subs?: Readonly<Record<string, Page>>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const REPO_DIR: Row = ["--repo-dir <dir>", "The clone to read. Default: the current directory"];
|
|
43
|
+
const PROFILE: Row = ["--profile <name>", "The account to run on: `default` (your own claude), a registered profile, or `isolated[:<name>]`. Default: the project binding, WACHIMAN_PROFILE, the configured default, then `default`"];
|
|
44
|
+
const HOME_ENV: Row = ["WACHIMAN_HOME", "The Wachiman home, an absolute path. Default: ~/.wachiman"];
|
|
45
|
+
const PROFILE_ENV: Row = ["WACHIMAN_PROFILE", "The profile used when there is no --profile and no project binding"];
|
|
46
|
+
const KEY_ENV: Row = ["ANTHROPIC_API_KEY", "Must be unset: the run refuses to start (exit 2) so the call goes to your subscription"];
|
|
47
|
+
const OTHER_ENV: Row = ["WACHIMAN_*", `Other engine settings: ${DOCS}/configuration.md`];
|
|
48
|
+
const SCOPE: readonly Row[] = [
|
|
49
|
+
["--base <ref>", "Compare with this branch (merge-base to HEAD). Default: origin/HEAD, else main. No fetch is made"],
|
|
50
|
+
["--from <commit>", "From that commit forward: <commit>^ to HEAD. Excludes --base and --commit"],
|
|
51
|
+
["--commit <commit>", "Exactly that commit: <commit>^ to <commit>. Excludes --base and --from"],
|
|
52
|
+
["--working-tree staged|all", "Tracked local changes against HEAD: the index, or the index plus unstaged edits. Excludes --base, --from, --commit"],
|
|
53
|
+
["--max-depth <n>", "The most commits between the start and HEAD; deeper exits 2 before any call. Default: 250"],
|
|
54
|
+
];
|
|
55
|
+
const GH_EXIT: readonly Row[] = [
|
|
56
|
+
["0", "Posted, or nothing to do (with limit_mode: notice a spend limit also exits 0)"],
|
|
57
|
+
["1", "Engine error: a failed gh call, no review returned, or a missing provider binary or credential"],
|
|
58
|
+
["2", "Usage error: unknown flag, missing or invalid pull request number, missing GH_TOKEN, GITHUB_REPOSITORY or REQUEST, an invalid setting"],
|
|
59
|
+
["3", "The spend ledger stopped the run before any model call"],
|
|
60
|
+
];
|
|
61
|
+
const GH_ENV: readonly Row[] = [
|
|
62
|
+
["GH_TOKEN", "Token for gh. Never given to the agent"],
|
|
63
|
+
["GITHUB_REPOSITORY", "owner/name of the repository"],
|
|
64
|
+
["ANTHROPIC_API_KEY", "The claude-code provider needs this or CLAUDE_CODE_OAUTH_TOKEN (not in a dry run)"],
|
|
65
|
+
["CLAUDE_CODE_OAUTH_TOKEN", "A Claude subscription token (`claude setup-token`); when set it wins and the API key never reaches the agent"],
|
|
66
|
+
OTHER_ENV,
|
|
67
|
+
];
|
|
68
|
+
const COMMENT_ENV: readonly Row[] = [
|
|
69
|
+
["WACHIMAN_COMMENT_AUTHOR", "The login of the comment's author"],
|
|
70
|
+
["WACHIMAN_COMMENT_ID", "The review comment's id; with it a question is answered in its thread"],
|
|
71
|
+
["WACHIMAN_COMMENT_IN_REPLY_TO", "The id of the comment this one replies to"],
|
|
72
|
+
["WACHIMAN_COMMENT_PATH, WACHIMAN_COMMENT_LINE", "The file and line the review comment is on"],
|
|
73
|
+
];
|
|
74
|
+
const CONFIRMATION_EXIT: readonly Row[] = [
|
|
75
|
+
["0", "Done (including a \"no\" answer)"],
|
|
76
|
+
["2", "Usage error"],
|
|
77
|
+
["130", "Cancelled (Escape, Ctrl-C, Ctrl-D); nothing pending is saved"],
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
const reviewPage: Page = {
|
|
81
|
+
usage: "wachiman review <pr> [paths…] [--repo-dir <dir>]",
|
|
82
|
+
summary: "Review a pull request (or only the given paths) and post one GitHub review. After the first review, only what changed since the last reviewed commit.",
|
|
83
|
+
options: [["<pr>", "The pull request number (digits, greater than 0)"], ["[paths…]", "Only these paths"], ["--repo-dir <dir>", "The checked-out pull request head: every file the engine reads and the agent's working directory. Default: the current directory"]],
|
|
84
|
+
env: GH_ENV,
|
|
85
|
+
exit: GH_EXIT,
|
|
86
|
+
examples: ["wachiman review 42 --repo-dir ./head", "wachiman review 42 src/engine.ts"],
|
|
87
|
+
docs: `${DOCS}/cli.md#incremental-reviews`,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const commentPage: Page = {
|
|
91
|
+
usage: "wachiman comment <pr> [--repo-dir <dir>]",
|
|
92
|
+
summary: "Handle the operator's comment in $REQUEST: route it to a review or an answer. Takes no paths.",
|
|
93
|
+
options: [["<pr>", "The pull request number"], ["--repo-dir <dir>", "The checked-out pull request head. Default: the current directory"]],
|
|
94
|
+
env: [["REQUEST", "The comment text. Pass it through the environment, never interpolated into a shell command"], ...GH_ENV.slice(0, 2), ...COMMENT_ENV, ...GH_ENV.slice(2)],
|
|
95
|
+
exit: GH_EXIT,
|
|
96
|
+
examples: ['REQUEST="@wachiman review" wachiman comment 42 --repo-dir ./head'],
|
|
97
|
+
docs: `${DOCS}/cli.md#what-comment-does`,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const threadsPage: Page = {
|
|
101
|
+
usage: "wachiman threads <pr> [--repo-dir <dir>]",
|
|
102
|
+
summary: "Answer the pending Wachiman threads, with no review; only when the pull request's head was already reviewed (an automatic run). Takes no paths.",
|
|
103
|
+
options: [["<pr>", "The pull request number"], ["--repo-dir <dir>", "The checked-out pull request head. Default: the current directory"]],
|
|
104
|
+
env: [...GH_ENV.slice(0, 2), ...COMMENT_ENV, ...GH_ENV.slice(2)],
|
|
105
|
+
exit: GH_EXIT,
|
|
106
|
+
examples: ["wachiman threads 42 --repo-dir ./head"],
|
|
107
|
+
docs: `${DOCS}/cli.md#what-threads-does`,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const resetConfidencePage: Page = {
|
|
111
|
+
usage: "wachiman reset-confidence <pr> [--commit <sha>]",
|
|
112
|
+
summary: 'Write "cannot say" into the PR Confidence block. No model call; the first step of a review run with WACHIMAN_CONFIDENCE=1.',
|
|
113
|
+
options: [["<pr>", "The pull request number"], ["--commit <sha>", "The commit under review"]],
|
|
114
|
+
env: [["GH_TOKEN, GITHUB_REPOSITORY", "Required (unless confidence is off)"], ["WACHIMAN_CONFIDENCE", "Set to 1 to enable the block"]],
|
|
115
|
+
exit: [["0", "Reset, or nothing to do; a failure inside the reset itself is a warning"], ["2", "Usage or configuration error: a bad pull request number or flag, an invalid WACHIMAN_* value, a missing GH_TOKEN or GITHUB_REPOSITORY"]],
|
|
116
|
+
examples: ["wachiman reset-confidence 42 --commit 1a2b3c4"],
|
|
117
|
+
docs: `${DOCS}/pr-confidence.md`,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const localPage: Page = {
|
|
121
|
+
usage: localUsage,
|
|
122
|
+
summary: "Review the committed branch of a clone on your signed-in claude and print it. Nothing is posted and no GitHub call is made.",
|
|
123
|
+
options: [
|
|
124
|
+
["[paths…]", "Only the changed files under these paths. Default: the whole change"],
|
|
125
|
+
...SCOPE,
|
|
126
|
+
["--input <file>", "A wachiman.review-input/1 or /2 file instead of the local diff. Takes no --base, --from, --commit or paths"],
|
|
127
|
+
["--format terminal|markdown|json", "Plain text, a Markdown report with the prompt for your agent, or the ReviewResult JSON. Default: terminal"],
|
|
128
|
+
["--output <file>", "Write the report to a file; its path is printed on stderr. Default: stdout"],
|
|
129
|
+
["--agent-prompt", "With terminal, also print the prompt for your agent. Default: off"],
|
|
130
|
+
PROFILE,
|
|
131
|
+
["--verify | --no-verify", "One more call tries to refute each finding above info. Default: follows WACHIMAN_VERIFY (off)"],
|
|
132
|
+
["--result-version 1|2", "With --format json only. Default: 1 for committed changes, 2 for --working-tree"],
|
|
133
|
+
["--history", "Save the run under ~/.wachiman/history and label each finding new or open. Default: off (or WACHIMAN_HISTORY=1)"],
|
|
134
|
+
REPO_DIR,
|
|
135
|
+
],
|
|
136
|
+
env: [
|
|
137
|
+
KEY_ENV,
|
|
138
|
+
HOME_ENV,
|
|
139
|
+
PROFILE_ENV,
|
|
140
|
+
["WACHIMAN_HISTORY", "1 saves the run, as --history"],
|
|
141
|
+
["WACHIMAN_VERIFY, WACHIMAN_VERIFIER_MODEL", "Turn verification on, and pick the verifier's model"],
|
|
142
|
+
["WACHIMAN_BUDGET_USD", "The most one run may spend. Default: 3"],
|
|
143
|
+
["WACHIMAN_BATCH_BUDGET_USD", "The cap on each call (soft)"],
|
|
144
|
+
["WACHIMAN_SIZE_GATE_USD", "An estimate above this (or the budget, if larger) prints one warning and continues"],
|
|
145
|
+
OTHER_ENV,
|
|
146
|
+
],
|
|
147
|
+
exit: [
|
|
148
|
+
["0", "A report was printed (complete, partial, or ended by the account's usage limit)"],
|
|
149
|
+
["1", "No call returned a review, or the claude binary did not run"],
|
|
150
|
+
["2", "Usage error: an unknown option, ANTHROPIC_API_KEY set, a profile that cannot be resolved, a detached HEAD, a range deeper than --max-depth, no merge-base"],
|
|
151
|
+
["130", "Interrupted (Ctrl-C); the snapshot was removed"],
|
|
152
|
+
],
|
|
153
|
+
examples: ["wachiman local --base main", "wachiman local --working-tree staged --format markdown --output review.md"],
|
|
154
|
+
docs: `${DOCS}/local-review.md`,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const loopPage: Page = {
|
|
158
|
+
usage: loopUsage,
|
|
159
|
+
summary: "Run one round of a review loop on your signed-in claude: `local` with history on and a stop rule. The CLI never edits code; fix, or judge a finding wrong with a reason, between calls.",
|
|
160
|
+
options: [
|
|
161
|
+
["--base <ref>", "Start a new loop; round 1 reviews the whole range. Without it, continue the open loop and review only the commits since the last round"],
|
|
162
|
+
["--max-rounds <n>", "The round cap. Default: 3"],
|
|
163
|
+
["--max-depth <n>", "The most commits from the start to HEAD. Default: 250"],
|
|
164
|
+
["--format terminal|json", "The round as text or wachiman.loop-round/1. Default: terminal"],
|
|
165
|
+
PROFILE,
|
|
166
|
+
["--verify | --no-verify", "Verification of each finding. Default: follows WACHIMAN_VERIFY"],
|
|
167
|
+
REPO_DIR,
|
|
168
|
+
],
|
|
169
|
+
env: [KEY_ENV, HOME_ENV, PROFILE_ENV, ["WACHIMAN_VERIFY, WACHIMAN_VERIFIER_MODEL", "Turn verification on, and pick the verifier's model"], OTHER_ENV],
|
|
170
|
+
exit: [
|
|
171
|
+
["0", "Converged: no Blocker or Fix is open"],
|
|
172
|
+
["10", "Findings are still open"],
|
|
173
|
+
["11", "Stopped without converging (round cap, or the review failed twice). A stop is never an approval"],
|
|
174
|
+
["2", "Usage error: no loop open, a detached HEAD, an unknown flag"],
|
|
175
|
+
["130", "Interrupted"],
|
|
176
|
+
],
|
|
177
|
+
examples: ["wachiman loop --base main", "wachiman loop --max-rounds 5 --format json"],
|
|
178
|
+
docs: `${DOCS}/cli.md#loop`,
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const askPage: Page = {
|
|
182
|
+
usage: askUsage,
|
|
183
|
+
summary: "Answer one question about the change `local` would review, or explain it when there is no question. One call on your signed-in claude; no GitHub request. Grounded in the stored review when `local --history` kept one; never runs a review.",
|
|
184
|
+
options: [
|
|
185
|
+
["[question…]", "The words are the question. None: a five-section walkthrough"],
|
|
186
|
+
...SCOPE,
|
|
187
|
+
PROFILE,
|
|
188
|
+
["--format terminal|markdown|json", "Plain text with the cost line, Markdown, or wachiman.ask-result/1. Default: terminal"],
|
|
189
|
+
["--output <file>", "Write the answer to a file; its path is printed on stderr. Default: stdout"],
|
|
190
|
+
REPO_DIR,
|
|
191
|
+
],
|
|
192
|
+
env: [KEY_ENV, HOME_ENV, PROFILE_ENV, OTHER_ENV],
|
|
193
|
+
exit: [
|
|
194
|
+
["0", "An answer was printed (it may say what it could not answer)"],
|
|
195
|
+
["1", "No answer: the call failed or returned nothing usable"],
|
|
196
|
+
["2", "Usage error: an unknown flag, a scope with no kept file, ANTHROPIC_API_KEY set"],
|
|
197
|
+
["130", "Interrupted"],
|
|
198
|
+
],
|
|
199
|
+
examples: ['wachiman ask "how does the retry budget work?" --commit 1a2b3c4', "wachiman ask --working-tree all"],
|
|
200
|
+
docs: `${DOCS}/cli.md#ask`,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const historyPage: Page = {
|
|
204
|
+
usage: historyUsage,
|
|
205
|
+
summary: "List, judge and forget the findings kept by `local --history`. Reads files and local git metadata only: no claude, no GitHub.",
|
|
206
|
+
options: [
|
|
207
|
+
["--since <n>d", "Only findings seen in the last n days"],
|
|
208
|
+
["--all-repos", "Every repository in the history, not just this clone's"],
|
|
209
|
+
["--json", "The replayed state as wachiman.history-state/1"],
|
|
210
|
+
["--verdict <id> correct|partial|wrong", "Record your judgement of a finding (the id is in the report and the listing)"],
|
|
211
|
+
["--reason <text>", "With --verdict: why"],
|
|
212
|
+
["--forget [--all]", "Delete this repository's history, or all of it with --all. Takes no --all-repos, --json or --since"],
|
|
213
|
+
REPO_DIR,
|
|
214
|
+
],
|
|
215
|
+
env: [HOME_ENV],
|
|
216
|
+
exit: [["0", "Listed, recorded or forgotten (no history prints one line)"], ["2", "Usage error, including a --verdict id that matches no finding"]],
|
|
217
|
+
examples: ["wachiman history --since 7d", 'wachiman history --verdict 3f9a1c wrong --reason "the guard is two lines above"'],
|
|
218
|
+
docs: `${DOCS}/cli.md#history`,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const REFRESH: Row = ["--refresh", "Run `ledger pull` first (the only request it can make). A failed download warns and keeps the entries already on disk. With no ledger connected it exits 2"];
|
|
222
|
+
const LEDGER_ENV: Row = ["WACHIMAN_LEDGER_URL, WACHIMAN_LEDGER_TOKEN", "Override the connected ledger (only read with --refresh)"];
|
|
223
|
+
|
|
224
|
+
const statusPage: Page = {
|
|
225
|
+
usage: statusUsage,
|
|
226
|
+
summary: "Show what this laptop kept of its local runs and their estimated cost; after `ledger pull`, GitHub Actions runs too. Reads local files only unless --refresh is given.",
|
|
227
|
+
options: [
|
|
228
|
+
["--since <n>d", "Only runs from the last n days"],
|
|
229
|
+
["--all-repos", "Every repository in the history"],
|
|
230
|
+
["--repo <name|key>", "One repository by name or key, from any directory"],
|
|
231
|
+
["--model <text>", "Only runs whose model id contains the text"],
|
|
232
|
+
["--profile <name>", "Only runs made with that account (leaves out Actions runs)"],
|
|
233
|
+
["--by day|week|repo|pr|model|profile|source", "How the table groups runs. Default: day"],
|
|
234
|
+
["--source laptop|actions|all", "Only laptop runs, only Actions runs from the pulled ledger, or both. Default: all"],
|
|
235
|
+
REFRESH,
|
|
236
|
+
["--json", "wachiman.status/1: the filters, totals, groups and every run"],
|
|
237
|
+
REPO_DIR,
|
|
238
|
+
],
|
|
239
|
+
env: [HOME_ENV, ["WACHIMAN_HISTORY_DAYS", "How long a --history run is kept. Default: 30; 0 keeps all"], LEDGER_ENV],
|
|
240
|
+
exit: [["0", "Printed (with no run kept it says how to start)"], ["2", "Usage error, or --refresh or --source actions with no ledger connected"]],
|
|
241
|
+
examples: ["wachiman status --since 7d --by model", "wachiman status --all-repos --source actions --json"],
|
|
242
|
+
docs: `${DOCS}/cli.md#status`,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const dashboardPage: Page = {
|
|
246
|
+
usage: dashboardUsage,
|
|
247
|
+
summary: "Export one static HTML page (or JSON) with the spend, findings and loop rounds of every repository in the local history, and Actions spend once a ledger is pulled. No claude, no GitHub, no server; a request only with --refresh.",
|
|
248
|
+
options: [
|
|
249
|
+
["--json", "Print wachiman.dashboard/1 on stdout instead of writing the page"],
|
|
250
|
+
["--out <file>", "Where to write the page. Default: ~/.wachiman/dashboard.html. Not allowed with --json"],
|
|
251
|
+
REFRESH,
|
|
252
|
+
["--repo-dir <dir>", "Accepted and unused"],
|
|
253
|
+
],
|
|
254
|
+
env: [HOME_ENV, LEDGER_ENV],
|
|
255
|
+
exit: [["0", "Written or printed (also with no run kept)"], ["1", "A loop file, the index or the page could not be written"], ["2", "Usage error, or --refresh with no ledger connected"]],
|
|
256
|
+
examples: ["wachiman dashboard", "wachiman dashboard --json"],
|
|
257
|
+
docs: `${DOCS}/local-dashboard.md`,
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const LEDGER_EXIT: readonly Row[] = [["0", "Done"], ["1", "The ledger could not be reached, refused the token or answered something unexpected"], ["2", "Usage error, or pull with no ledger connected"]];
|
|
261
|
+
const ledgerPage = (usage: string, summary: string, options: readonly Row[], examples: string[]): Page => ({
|
|
262
|
+
usage, summary, options, env: [HOME_ENV, ["WACHIMAN_LEDGER_URL, WACHIMAN_LEDGER_TOKEN", "Override the credentials file"]], exit: LEDGER_EXIT, examples, docs: `${DOCS}/cli.md#ledger`,
|
|
263
|
+
});
|
|
264
|
+
const ledgerRoot = ledgerPage(
|
|
265
|
+
ledgerUsage,
|
|
266
|
+
"Connect with a read token (not the workflow's `ledger_url`) and download the spend ledger's entries, so status and dashboard can show Actions runs next to laptop runs. Only pull and --refresh make a request, and no run data is ever sent from the laptop. Run `wachiman ledger <subcommand> --help` for one of them.",
|
|
267
|
+
[],
|
|
268
|
+
["wachiman ledger connect https://ledger.example.com", "wachiman ledger pull --since 14d"],
|
|
269
|
+
);
|
|
270
|
+
const ledgerSubs: Record<string, Page> = {
|
|
271
|
+
connect: ledgerPage("wachiman ledger connect <url>", "Ask for the read token on standard input (not echoed) and keep it in ~/.wachiman/ledger/credentials.json, mode 0600.", [["<url>", "https, or http only for localhost, 127.0.0.1 or [::1]"]], ["wachiman ledger connect https://ledger.example.com"]),
|
|
272
|
+
disconnect: ledgerPage("wachiman ledger disconnect", "Delete the stored credentials. Entries already downloaded stay on disk.", [], ["wachiman ledger disconnect"]),
|
|
273
|
+
pull: ledgerPage("wachiman ledger pull [--since <n>d]", "Download the ledger's entries into ~/.wachiman/ledger, one file per UTC day, replacing each day as a whole.", [["--since <n>d", "How many days back. Default: 35; at most 92"]], ["wachiman ledger pull", "wachiman ledger pull --since 7d"]),
|
|
274
|
+
};
|
|
275
|
+
const ledgerPageWithSubs: Page = { ...ledgerRoot, options: undefined, subs: ledgerSubs };
|
|
276
|
+
|
|
277
|
+
const setupPage: Page = {
|
|
278
|
+
usage: setupUsage,
|
|
279
|
+
summary: "Bind this repository to an account profile; written in the Wachiman home, never in the repository. On a terminal without --profile it asks, and can register or create a profile.",
|
|
280
|
+
options: [
|
|
281
|
+
["--profile <name>", "The profile to bind. Without a terminal it is required and must already exist"],
|
|
282
|
+
["--yes", "No prompts. Requires --profile"],
|
|
283
|
+
["--json", "Print the result as JSON"],
|
|
284
|
+
REPO_DIR,
|
|
285
|
+
],
|
|
286
|
+
env: [HOME_ENV, ["CI", "true or 1 turns the prompts off, as no terminal does"]],
|
|
287
|
+
exit: [["0", "Bound (including a \"no\" answer)"], ["1", "The closing doctor summary failed; the binding is already written"], ["2", "Usage error, such as no --profile when it cannot ask"], ["130", "Cancelled; nothing pending is saved"]],
|
|
288
|
+
examples: ["wachiman setup", "wachiman setup --profile work --yes"],
|
|
289
|
+
docs: `${DOCS}/cli.md#setup-doctor-profile-and-project`,
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const initPage: Page = {
|
|
293
|
+
usage: initUsage,
|
|
294
|
+
summary: "Write the GitHub Actions caller workflow (.github/workflows/wachiman-review.yml), or, with --mode local, write nothing and hand over to setup.",
|
|
295
|
+
options: [
|
|
296
|
+
["--mode github|local|both", "What to set up. Required without a terminal"],
|
|
297
|
+
["--operator <login>", "The GitHub login allowed to command the reviewer. Required for github and both without a terminal"],
|
|
298
|
+
["--version <tag>", "vX.Y.Z or a 40-character commit SHA written after review.yml@. Default: the release bundled in this build"],
|
|
299
|
+
["--path <file>", "Default: .github/workflows/wachiman-review.yml; a .yml or .yaml file directly in .github/workflows/"],
|
|
300
|
+
["--force", "Replace an existing file after copying it to <file>.bak-<timestamp>"],
|
|
301
|
+
["--dry-run", "Print the file to stdout and write nothing"],
|
|
302
|
+
["--yes", "No prompts"],
|
|
303
|
+
REPO_DIR,
|
|
304
|
+
],
|
|
305
|
+
env: [HOME_ENV, ["CI", "true or 1 turns the prompts off"], ["NO_COLOR", "Turns styling off"]],
|
|
306
|
+
exit: [["0", "Done (including a \"no\" answer)"], ["1", "Engine error"], ["2", "Usage error: an unknown flag, an existing file without --force, --mode local with a workflow flag"], ["130", "Cancelled; nothing is written"]],
|
|
307
|
+
examples: ["wachiman init --mode both", "wachiman init --mode github --operator octocat --dry-run"],
|
|
308
|
+
docs: `${DOCS}/cli.md#init`,
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const doctorPage: Page = {
|
|
312
|
+
usage: doctorUsage,
|
|
313
|
+
summary: "Explain what a local run would use and what would fail. Makes no model call and no request.",
|
|
314
|
+
options: [
|
|
315
|
+
["--json", "Print wachiman.doctor/1"],
|
|
316
|
+
["--profile <name>", "Check this profile instead of the resolved one"],
|
|
317
|
+
["--all-profiles", "Repeat the profile, auth and isolation rows for every profile. Excludes --profile"],
|
|
318
|
+
["--redact-paths", "Swap paths and URLs for placeholders so the output can be shared"],
|
|
319
|
+
REPO_DIR,
|
|
320
|
+
],
|
|
321
|
+
env: [HOME_ENV, PROFILE_ENV, ["ANTHROPIC_API_KEY", "When set, the environment row fails, because `local` would refuse to start"]],
|
|
322
|
+
exit: [["0", "Every required check passed"], ["1", "A required check failed"], ["2", "Usage error"]],
|
|
323
|
+
examples: ["wachiman doctor", "wachiman doctor --all-profiles --redact-paths"],
|
|
324
|
+
docs: `${DOCS}/cli.md#setup-doctor-profile-and-project`,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const ACCOUNT_ENV: readonly Row[] = [HOME_ENV, ["CI", "true or 1 means no terminal: confirmations need --yes"]];
|
|
328
|
+
const accountPage = (usage: string, summary: string, options: readonly Row[], examples: string[]): Page => ({
|
|
329
|
+
usage, summary, options, env: ACCOUNT_ENV, exit: CONFIRMATION_EXIT, examples, docs: `${DOCS}/cli.md#setup-doctor-profile-and-project`,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const profilePage: Page = {
|
|
333
|
+
usage: profileUsage,
|
|
334
|
+
summary: "Manage account profiles. A managed profile lives in ~/.wachiman/claude-<name>; an external one is your own Claude configuration directory, used in place. Run `wachiman profile <subcommand> --help` for one of them.",
|
|
335
|
+
exit: CONFIRMATION_EXIT,
|
|
336
|
+
env: ACCOUNT_ENV,
|
|
337
|
+
examples: ["wachiman profile list", "wachiman profile create work"],
|
|
338
|
+
docs: `${DOCS}/cli.md#setup-doctor-profile-and-project`,
|
|
339
|
+
subs: {
|
|
340
|
+
list: accountPage("wachiman profile list [--json]", "List registered profiles and the unregistered claude-* directories under the home, with the projects bound to each and the default.", [["--json", "Print wachiman.profiles/1"]], ["wachiman profile list --json"]),
|
|
341
|
+
create: accountPage("wachiman profile create [<name>]", "Create the managed profile <home>/claude-<name>, register it and start claude there so you can sign in (/login, then /exit).", [["<name>", "Default: isolated"]], ["wachiman profile create", "wachiman profile create work"]),
|
|
342
|
+
add: accountPage("wachiman profile add <name> --config-dir <abs> [--binary <abs>] [--note <text>]", "Register a Claude configuration directory you already use, in place (an external profile). Wachiman never writes into it.", [
|
|
343
|
+
["--config-dir <abs>", "An absolute, existing directory outside the Wachiman home"],
|
|
344
|
+
["--binary <abs>", "An absolute, executable claude binary (an npm shim is refused). Default: claude on PATH"],
|
|
345
|
+
["--note <text>", "A note kept with the profile"],
|
|
346
|
+
], ["wachiman profile add work --config-dir ~/.claude-work"]),
|
|
347
|
+
login: accountPage("wachiman profile login <name>", "Start claude for that profile (with `auth login` when this claude has it) so you can sign in again. It never reads the outcome.", [["<name>", "A registered profile"]], ["wachiman profile login work"]),
|
|
348
|
+
remove: accountPage("wachiman profile remove <name> [--delete-dir] [--yes]", "Remove the registration and every binding and default that named it. The directory stays unless you pass --delete-dir.", [
|
|
349
|
+
["--delete-dir", "Also delete the directory: asks twice for a managed profile, a usage error for an external one"],
|
|
350
|
+
["--yes", "Skip the question; required without a terminal"],
|
|
351
|
+
], ["wachiman profile remove work --yes"]),
|
|
352
|
+
default: accountPage("wachiman profile default <name> | --none", "Set or clear the configured default profile.", [["<name>", "A registered profile"], ["--none", "Clear the default"]], ["wachiman profile default work", "wachiman profile default --none"]),
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const projectPage: Page = {
|
|
357
|
+
usage: projectUsage,
|
|
358
|
+
summary: "Inspect or remove this repository's account binding. Run `wachiman project <subcommand> --help` for one of them.",
|
|
359
|
+
exit: CONFIRMATION_EXIT,
|
|
360
|
+
env: ACCOUNT_ENV,
|
|
361
|
+
examples: ["wachiman project show", "wachiman project unbind --yes"],
|
|
362
|
+
docs: `${DOCS}/cli.md#setup-doctor-profile-and-project`,
|
|
363
|
+
subs: {
|
|
364
|
+
show: accountPage("wachiman project show [--json] [--repo-dir <dir>]", "Show the repository's key, its binding, and what `local` would use here now, with the rule and any ignored values.", [["--json", "Print wachiman.project/1"], REPO_DIR], ["wachiman project show --json"]),
|
|
365
|
+
unbind: accountPage("wachiman project unbind [--repo-dir <dir>] [--yes]", "Remove this repository's binding. It asks first.", [["--yes", "Skip the question; required without a terminal"], REPO_DIR], ["wachiman project unbind --yes"]),
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const SKILLS_EXIT: readonly Row[] = [["0", "Done (copies left in place are warnings)"], ["1", "A copy could not be written or removed"], ["2", "Usage error or a refused target (anything under the Wachiman home)"]];
|
|
370
|
+
const SKILLS_ENV: readonly Row[] = [HOME_ENV, ["CLAUDE_CONFIG_DIR", "Its skills folder is a target too, when it exists"]];
|
|
371
|
+
const skillsPage: Page = {
|
|
372
|
+
usage: skillsUsage,
|
|
373
|
+
summary: "Copy the wachiman-review, wachiman-loop and wachiman-audit agent skills into ~/.agents/skills and each Claude Code config directory, or remove the copies it marked. Never touches ~/.wachiman.",
|
|
374
|
+
options: [["--dir <path>", "Add a skills directory of your own; may repeat"], ["--json", "install only: print wachiman.skills/1"]],
|
|
375
|
+
env: SKILLS_ENV,
|
|
376
|
+
exit: SKILLS_EXIT,
|
|
377
|
+
examples: ["wachiman skills install", "wachiman skills uninstall"],
|
|
378
|
+
docs: `${DOCS}/cli.md#skills`,
|
|
379
|
+
subs: {
|
|
380
|
+
install: {
|
|
381
|
+
usage: "wachiman skills install [--dir <path>]… [--json]",
|
|
382
|
+
summary: "Copy the agent skills into ~/.agents/skills and each Claude Code config directory. A copy you edited, or one that is not marked as Wachiman's, is left as it is and warned about.",
|
|
383
|
+
options: [["--dir <path>", "Add a skills directory of your own; may repeat"], ["--json", "Print wachiman.skills/1: one entry per copy"]],
|
|
384
|
+
env: SKILLS_ENV, exit: SKILLS_EXIT, examples: ["wachiman skills install", "wachiman skills install --dir ./my-skills --json"], docs: `${DOCS}/cli.md#skills`,
|
|
385
|
+
},
|
|
386
|
+
uninstall: {
|
|
387
|
+
usage: "wachiman skills uninstall [--dir <path>]…",
|
|
388
|
+
summary: "Remove only the files that a Wachiman marker lists and whose content still matches. Edited files and anything unmarked stay, with a warning.",
|
|
389
|
+
options: [["--dir <path>", "Also look in this skills directory; may repeat"]],
|
|
390
|
+
env: SKILLS_ENV, exit: SKILLS_EXIT, examples: ["wachiman skills uninstall"], docs: `${DOCS}/cli.md#skills`,
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/** The commands a GitHub Actions run uses; they are not in the root help. */
|
|
396
|
+
export const CI_COMMANDS = ["review", "comment", "threads", "reset-confidence"] as const;
|
|
397
|
+
|
|
398
|
+
const PAGES: Readonly<Record<string, Page>> = {
|
|
399
|
+
local: localPage, loop: loopPage, ask: askPage,
|
|
400
|
+
history: historyPage, status: statusPage, dashboard: dashboardPage, ledger: ledgerPageWithSubs,
|
|
401
|
+
setup: setupPage, init: initPage, doctor: doctorPage, profile: profilePage, project: projectPage, skills: skillsPage,
|
|
402
|
+
review: reviewPage, comment: commentPage, threads: threadsPage, "reset-confidence": resetConfidencePage,
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
export const COMMANDS = Object.keys(PAGES);
|
|
406
|
+
|
|
407
|
+
export function isCommand(word: string | undefined): word is string {
|
|
408
|
+
return word !== undefined && Object.hasOwn(PAGES, word);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** Breaks `text` into lines of at most `room` characters at word boundaries. */
|
|
412
|
+
function wrapText(text: string, room: number): string[] {
|
|
413
|
+
const lines: string[] = [];
|
|
414
|
+
let line = "";
|
|
415
|
+
for (const word of text.split(" ")) {
|
|
416
|
+
if (line !== "" && line.length + 1 + word.length > room) {
|
|
417
|
+
lines.push(line);
|
|
418
|
+
line = word;
|
|
419
|
+
} else {
|
|
420
|
+
line = line === "" ? word : `${line} ${word}`;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
lines.push(line);
|
|
424
|
+
return lines;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Rows as a two-column block: the name padded, the text wrapped under it. A long name takes its own line. */
|
|
428
|
+
function block(rows: readonly Row[], width = 100): string[] {
|
|
429
|
+
const pad = Math.min(Math.max(...rows.map(([name]) => name.length)) + 2, 34);
|
|
430
|
+
const room = Math.max(width - pad - 2, 30);
|
|
431
|
+
const lines: string[] = [];
|
|
432
|
+
for (const [name, text] of rows) {
|
|
433
|
+
const wrapped = wrapText(text, room);
|
|
434
|
+
if (name.length + 2 > pad) {
|
|
435
|
+
lines.push(` ${name}`, ...wrapped.map((w) => ` ${" ".repeat(pad)}${w}`));
|
|
436
|
+
} else {
|
|
437
|
+
lines.push(` ${name.padEnd(pad)}${wrapped[0]}`, ...wrapped.slice(1).map((w) => ` ${" ".repeat(pad)}${w}`));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return lines;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function renderPage(page: Page, paint: Paint): string {
|
|
444
|
+
const out: string[] = [];
|
|
445
|
+
const header = (title: string) => out.push("", paint(title, "strong"));
|
|
446
|
+
out.push(paint("Usage", "strong"));
|
|
447
|
+
for (const line of page.usage.split("\n")) out.push(` ${line}`);
|
|
448
|
+
out.push("", ...wrapText(page.summary, 78));
|
|
449
|
+
if (page.options && page.options.length > 0) { header("Options"); out.push(...block(page.options)); }
|
|
450
|
+
if (page.subs) { header("Subcommands"); out.push(...block(Object.entries(page.subs).map(([name, sub]) => [name, sub.summary.split(/(?<=\.)\s/)[0]] as Row))); }
|
|
451
|
+
if (page.env && page.env.length > 0) { header("Environment"); out.push(...block(page.env)); }
|
|
452
|
+
header("Exit codes");
|
|
453
|
+
out.push(...block(page.exit));
|
|
454
|
+
header("Examples");
|
|
455
|
+
for (const example of page.examples) out.push(` ${example}`);
|
|
456
|
+
out.push("", `Docs: ${page.docs}`);
|
|
457
|
+
return `${out.join("\n")}\n`;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export function rootHelp(paint: Paint = plain): string {
|
|
461
|
+
const rows = (items: readonly Row[]) => items.map(([name, text]) => ` ${name.padEnd(12)}${text}`);
|
|
462
|
+
return [
|
|
463
|
+
"Wachiman — review code on your Claude subscription.",
|
|
464
|
+
"",
|
|
465
|
+
"Usage: wachiman <command> [options]",
|
|
466
|
+
"",
|
|
467
|
+
paint("Review", "strong"),
|
|
468
|
+
...rows([["local", "Review a branch, commit, or working-tree changes"], ["loop", "Run one round of a tracked review loop"], ["ask", "Explain a change or ask a question"]]),
|
|
469
|
+
"",
|
|
470
|
+
paint("Results", "strong"),
|
|
471
|
+
...rows([["history", "Browse findings and record verdicts"], ["status", "Show local usage and estimated cost"], ["dashboard", "Export a local usage dashboard"], ["ledger", "Download GitHub Actions spend from the ledger"]]),
|
|
472
|
+
"",
|
|
473
|
+
paint("Configuration", "strong"),
|
|
474
|
+
...rows([
|
|
475
|
+
["setup", "Bind this repository to an account profile"],
|
|
476
|
+
["init", "Write the GitHub caller workflow, or hand over to setup"],
|
|
477
|
+
["doctor", "Explain what a local run would use and what would fail"],
|
|
478
|
+
["profile", "List, create, add, log in, remove and default profiles"],
|
|
479
|
+
["project", "Show or remove this repository's binding"],
|
|
480
|
+
["skills", "Install or remove the agent skills"],
|
|
481
|
+
]),
|
|
482
|
+
"",
|
|
483
|
+
`Help: wachiman <command> --help · wachiman help ci · docs: ${DOCS}/cli.md`,
|
|
484
|
+
"Options: -h, --help · -v, --version",
|
|
485
|
+
"",
|
|
486
|
+
].join("\n");
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export function ciHelp(paint: Paint = plain): string {
|
|
490
|
+
const out: string[] = [];
|
|
491
|
+
out.push(paint("Commands for GitHub Actions", "strong"), "");
|
|
492
|
+
out.push(...wrapText("These run inside the reusable workflow, not on a laptop. They post to GitHub and need GH_TOKEN. Run `wachiman <command> --help` for one of them.", 78));
|
|
493
|
+
out.push("", paint("Usage", "strong"));
|
|
494
|
+
for (const name of CI_COMMANDS) out.push(` ${PAGES[name].usage}`);
|
|
495
|
+
out.push("", paint("Commands", "strong"));
|
|
496
|
+
out.push(...block(CI_COMMANDS.map((name) => [name, PAGES[name].summary.split(/(?<=\.)\s/)[0]] as Row)));
|
|
497
|
+
out.push("", paint("Environment", "strong"));
|
|
498
|
+
out.push(...block([GH_ENV[0], GH_ENV[1], ["REQUEST", "comment: the comment text"], ...COMMENT_ENV, ...GH_ENV.slice(2), ["WACHIMAN_CONFIDENCE", "reset-confidence: 1 enables the PR Confidence block"]]));
|
|
499
|
+
out.push("", paint("Exit codes", "strong"));
|
|
500
|
+
out.push(...block(GH_EXIT));
|
|
501
|
+
out.push("", paint("Examples", "strong"));
|
|
502
|
+
out.push(" wachiman review 42 --repo-dir ./head", ' REQUEST="@wachiman review" wachiman comment 42');
|
|
503
|
+
out.push("", `Docs: ${DOCS}/cli.md#environment`);
|
|
504
|
+
return `${out.join("\n")}\n`;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* The page for `words` (the command, then maybe a subcommand), or undefined when no command has that
|
|
509
|
+
* name. A subcommand that does not exist falls back to the command's own page.
|
|
510
|
+
*/
|
|
511
|
+
export function commandHelp(words: readonly string[], paint: Paint = plain): string | undefined {
|
|
512
|
+
const [command, sub] = words;
|
|
513
|
+
if (!isCommand(command)) return undefined;
|
|
514
|
+
const page = PAGES[command];
|
|
515
|
+
const nested = sub !== undefined && page.subs && Object.hasOwn(page.subs, sub) ? page.subs[sub] : undefined;
|
|
516
|
+
return renderPage(nested ?? page, paint);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export type HelpRequest = { text: string } | { error: string };
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* What `wachiman help …`, `wachiman <command> --help` and `-h` print, or undefined when the arguments
|
|
523
|
+
* are not a help request. It looks at the arguments only: the caller returns before any configuration,
|
|
524
|
+
* authentication, git or model use.
|
|
525
|
+
*/
|
|
526
|
+
/**
|
|
527
|
+
* Whether `rest` (the arguments after a command) ask for help. Free text and option values are not flags:
|
|
528
|
+
* nothing after a `--` counts, `ask` takes it only as its first argument (the rest is the question), and
|
|
529
|
+
* the value of `--reason` is never a request.
|
|
530
|
+
*/
|
|
531
|
+
function asksForHelp(command: string, rest: readonly string[]): boolean {
|
|
532
|
+
const end = rest.indexOf("--");
|
|
533
|
+
const args = end === -1 ? rest : rest.slice(0, end);
|
|
534
|
+
const isHelp = (arg: string) => arg === "--help" || arg === "-h";
|
|
535
|
+
if (command === "ask") return args.length > 0 && isHelp(args[0]);
|
|
536
|
+
return args.some((arg, i) => isHelp(arg) && args[i - 1] !== "--reason");
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function helpFor(argv: readonly string[], paint: Paint = plain): HelpRequest | undefined {
|
|
540
|
+
const [first, ...rest] = argv;
|
|
541
|
+
if (first === "help") {
|
|
542
|
+
const words = rest.filter((word) => !word.startsWith("-"));
|
|
543
|
+
if (words.length === 0) return { text: rootHelp(paint) };
|
|
544
|
+
if (words[0] === "ci") return { text: ciHelp(paint) };
|
|
545
|
+
const text = commandHelp(words, paint);
|
|
546
|
+
return text === undefined ? { error: `Unknown help topic "${words[0]}".` } : { text };
|
|
547
|
+
}
|
|
548
|
+
if (first === "--setup-profile" && asksForHelp(first, rest)) {
|
|
549
|
+
return { text: commandHelp(["profile", "create"], paint)! };
|
|
550
|
+
}
|
|
551
|
+
if (isCommand(first) && asksForHelp(first, rest)) {
|
|
552
|
+
return { text: commandHelp([first, ...rest.filter((arg) => !arg.startsWith("-"))], paint)! };
|
|
553
|
+
}
|
|
554
|
+
return undefined;
|
|
555
|
+
}
|
package/src/history/store.ts
CHANGED
|
@@ -44,16 +44,16 @@ export interface HistorySettings {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Whether the history is on (`--history` or `
|
|
47
|
+
* Whether the history is on (`--history` or `WACHIMAN_HISTORY=1`) and how long it is kept.
|
|
48
48
|
* Read here, not in `loadConfig`: that one rejects `0`, and GitHub mode must not see the variable.
|
|
49
|
-
* A bad `
|
|
49
|
+
* A bad `WACHIMAN_HISTORY_DAYS` is checked only when the history is on.
|
|
50
50
|
*/
|
|
51
51
|
export function historySettings(env: Record<string, string | undefined>, flag: boolean): HistorySettings {
|
|
52
|
-
const enabled = flag || env.
|
|
53
|
-
const raw = env.
|
|
52
|
+
const enabled = flag || env.WACHIMAN_HISTORY === "1";
|
|
53
|
+
const raw = env.WACHIMAN_HISTORY_DAYS;
|
|
54
54
|
if (!enabled || raw === undefined || raw === "") return { enabled, days: DEFAULT_HISTORY_DAYS };
|
|
55
55
|
if (!/^\d+$/.test(raw)) {
|
|
56
|
-
throw new UsageError(`
|
|
56
|
+
throw new UsageError(`WACHIMAN_HISTORY_DAYS must be 0 (keep forever) or a whole number of days, got "${raw}".`);
|
|
57
57
|
}
|
|
58
58
|
return { enabled, days: Number(raw) };
|
|
59
59
|
}
|
package/src/init/options.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type ResolveResult<T> = { ok: true; options: T } | { ok: false; error: st
|
|
|
34
34
|
* docs/releasing.md); the CLI's own version is never a substitute,
|
|
35
35
|
* because an unreleased or unrelated version would pin a workflow that does not exist.
|
|
36
36
|
*/
|
|
37
|
-
export const DEFAULT_WORKFLOW_REF: string | undefined = "v1.
|
|
37
|
+
export const DEFAULT_WORKFLOW_REF: string | undefined = "v1.15.0"; // x-release-please-version
|
|
38
38
|
|
|
39
39
|
export const DEFAULT_WORKFLOW_PATH = ".github/workflows/wachiman-review.yml";
|
|
40
40
|
const WORKFLOWS_DIR = ".github/workflows/";
|