wachiman 1.15.0 → 1.17.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 +13 -0
- package/package.json +1 -1
- package/skills/wachiman-loop/SKILL.md +43 -0
- package/src/accounts/commands.ts +3 -2
- package/src/accounts/confirm.ts +1 -1
- package/src/accounts/profile-list.ts +24 -0
- package/src/cli.ts +91 -26
- package/src/config.ts +40 -8
- package/src/connectors/local-git.ts +128 -0
- package/src/connectors/working-tree.ts +23 -1
- package/src/doctor/checks.ts +106 -1
- package/src/doctor/run.ts +9 -1
- package/src/engine.ts +1126 -222
- package/src/formats.ts +44 -3
- package/src/help.ts +204 -7
- package/src/history/command.ts +5 -5
- package/src/history/match.ts +24 -4
- package/src/history/store.ts +1 -1
- package/src/history/types.ts +7 -2
- package/src/init/agents.ts +135 -0
- package/src/init/args.ts +7 -2
- package/src/init/github-login.ts +13 -0
- package/src/init/json.ts +82 -0
- package/src/init/options.ts +42 -4
- package/src/init/prompt.ts +46 -15
- package/src/init/render.ts +3 -1
- package/src/init/run.ts +362 -28
- package/src/init/settings.ts +137 -0
- package/src/init/write.ts +16 -102
- package/src/json-schema.ts +8 -0
- package/src/ledger.ts +2 -2
- package/src/local-ask.ts +5 -4
- package/src/local.ts +90 -17
- package/src/loop/command.ts +29 -7
- package/src/memory/candidates.ts +425 -0
- package/src/memory/capture.ts +298 -0
- package/src/memory/command.ts +195 -0
- package/src/memory/entries.ts +213 -0
- package/src/memory/hygiene.ts +291 -0
- package/src/memory/inspect.ts +74 -0
- package/src/memory/load.ts +283 -0
- package/src/memory/mute.ts +259 -0
- package/src/memory/personal.ts +253 -0
- package/src/memory/proposal.ts +92 -0
- package/src/memory/propose.ts +414 -0
- package/src/memory/remember.ts +187 -0
- package/src/memory/report.ts +250 -0
- package/src/memory/settings.ts +20 -0
- package/src/pr-template/adopt.ts +434 -0
- package/src/pr-template/catalog.ts +429 -0
- package/src/pr-template/check-run.ts +328 -0
- package/src/pr-template/check.ts +338 -0
- package/src/pr-template/describe.ts +368 -0
- package/src/pr-template/format.ts +399 -0
- package/src/pr-template/gh.ts +159 -0
- package/src/pr-template/install.ts +311 -0
- package/src/pr-template/legacy-guides.ts +50 -0
- package/src/pr-template/pr-risk.ts +426 -0
- package/src/pr-template/render.ts +302 -0
- package/src/pr-template/resolve.ts +65 -0
- package/src/pr-template/run.ts +88 -0
- package/src/pr-template/strip.ts +171 -0
- package/src/pr-template/write.ts +139 -0
- package/src/precision.ts +10 -2
- package/src/priority.ts +106 -0
- package/src/providers/claude-code.ts +7 -8
- package/src/providers/codex.ts +4 -4
- package/src/providers/spawn.ts +95 -0
- package/src/providers/types.ts +5 -2
- package/src/repo-settings.ts +322 -0
- package/src/risk.ts +38 -9
- package/src/setup/prompt.ts +49 -33
- package/src/setup/run.ts +31 -6
- package/src/sinks/common.ts +22 -9
- package/src/sinks/markdown.ts +6 -2
- package/src/sinks/terminal.ts +6 -2
- package/src/store/figures.ts +5 -4
- package/src/store/html.ts +1 -1
- package/src/upgrade/command.ts +286 -0
- package/src/upgrade/pin.ts +112 -0
- package/src/verify.ts +20 -2
- package/src/wizard/mascot.ts +56 -51
- package/src/wizard/prompt-fancy.ts +10 -2
- package/src/wizard/prompt.ts +17 -4
- package/src/wizard/ui.ts +2 -0
- package/templates/pr/sections.json +163 -0
- package/templates/wachiman-review-caller.yml +7 -7
|
@@ -17,6 +17,7 @@ import { UsageError } from "../config";
|
|
|
17
17
|
import {
|
|
18
18
|
instructionFileOf,
|
|
19
19
|
instructionsFrom,
|
|
20
|
+
MAX_INSTRUCTION_BYTES,
|
|
20
21
|
REVIEW_INPUT_FORMAT,
|
|
21
22
|
resolveScope,
|
|
22
23
|
type BaseInstructions,
|
|
@@ -24,6 +25,8 @@ import {
|
|
|
24
25
|
type ReviewInput,
|
|
25
26
|
} from "../engine";
|
|
26
27
|
import { GIT_BASE_ARGS, gitEnv, spawnGit, type GitRunner } from "../evidence";
|
|
28
|
+
import { ignoredSettingsNote, parseRepoSettings, pathsEdited, SETTINGS_PATH, touchesSettingsFile, withPolicyEditRule, type PathRule, type RepoSettings } from "../repo-settings";
|
|
29
|
+
import { MEMORY_DIR, cutMemoryNote, loadMemory, type MemoryLoad, type MemorySource } from "../memory/load";
|
|
27
30
|
|
|
28
31
|
const TIMEOUT_MS = 60_000;
|
|
29
32
|
/** The whole branch diff is one output; a large branch can be far over the evidence step's 8 MB. */
|
|
@@ -353,6 +356,124 @@ export function localInstructions(
|
|
|
353
356
|
);
|
|
354
357
|
}
|
|
355
358
|
|
|
359
|
+
/** What decides the commit whose `.wachiman.yml` a local run reads: the same scope flags the review itself takes. */
|
|
360
|
+
export interface SettingsScope {
|
|
361
|
+
/** `--working-tree`: the instruction files are read at `HEAD`, and so is the settings file. */
|
|
362
|
+
workingTree?: "staged" | "all";
|
|
363
|
+
base?: string;
|
|
364
|
+
commit?: string;
|
|
365
|
+
from?: string;
|
|
366
|
+
maxDepth?: number;
|
|
367
|
+
/** `--input`: the base commit the input file names. */
|
|
368
|
+
inputBase?: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* The commit whose `.wachiman.yml` a local run reads, the one the instruction files are read at:
|
|
373
|
+
* the merge-base (the start of the diff), `HEAD` for a working-tree review, or the input file's
|
|
374
|
+
* base. Never the head, so a branch cannot raise the model or the effort it is reviewed under.
|
|
375
|
+
* Undefined when the scope does not resolve; the review's own ref checks report that, with their
|
|
376
|
+
* message, a moment later.
|
|
377
|
+
*/
|
|
378
|
+
export function localSettingsCommit(repoDir: string, scope: SettingsScope, git: GitRunner = spawnGit): string | undefined {
|
|
379
|
+
if (scope.inputBase !== undefined) return scope.inputBase;
|
|
380
|
+
try {
|
|
381
|
+
if (scope.workingTree) return run(git, repoDir, ["rev-parse", "--verify", "HEAD^{commit}"]).trim();
|
|
382
|
+
return resolveRefs(repoDir, scope.base, git, scope.maxDepth, { commit: scope.commit, from: scope.from }).mergeBase;
|
|
383
|
+
} catch {
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* `.wachiman.yml` as it is at `sha`, parsed, or undefined when there is none there (or `sha` is
|
|
390
|
+
* not in this clone: an `--input` file can name one that is not). An invalid file is a usage error.
|
|
391
|
+
*/
|
|
392
|
+
export function localRepoSettings(repoDir: string, sha: string, git: GitRunner = spawnGit): RepoSettings | undefined {
|
|
393
|
+
let bytes: Buffer | null;
|
|
394
|
+
try {
|
|
395
|
+
bytes = blobAt(repoDir, sha, SETTINGS_PATH, git);
|
|
396
|
+
} catch {
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
if (!bytes) return undefined;
|
|
400
|
+
if (bytes.length > MAX_INSTRUCTION_BYTES) throw new UsageError(`${SETTINGS_PATH} at ${short(sha)} is over ${MAX_INSTRUCTION_BYTES / 1024} KB, too large for a settings file.`);
|
|
401
|
+
return parseRepoSettings(bytes.toString("utf8"));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* The `paths` rules of the `.wachiman.yml` at `sha` (ADR 0058), or undefined when it has none. Read
|
|
406
|
+
* at the commit the instruction files are read at, never at the head. A broken file is ignored with
|
|
407
|
+
* one warning naming `where`, like the model and effort read: the change that fixes it must be
|
|
408
|
+
* reviewable.
|
|
409
|
+
*/
|
|
410
|
+
export function localPathRules(repoDir: string, sha: string, where: string, warn: (line: string) => void, git: GitRunner = spawnGit): PathRule[] | undefined {
|
|
411
|
+
try {
|
|
412
|
+
return localRepoSettings(repoDir, sha, git)?.paths;
|
|
413
|
+
} catch (error) {
|
|
414
|
+
if (!(error instanceof UsageError)) throw error;
|
|
415
|
+
warn(ignoredSettingsNote(error.message, `${where} ${short(sha)}`));
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* The path rules a local review applies and whether the change edits them (ADR 0058 decision 5).
|
|
422
|
+
* `readHead` returns the head's `.wachiman.yml` bytes, or null when the head has none: the head
|
|
423
|
+
* commit's blob, or the snapshot's file for a working-tree review. They are compared with the
|
|
424
|
+
* base's (`baseRules`) only to tell the reader; the head's rules are never applied. When the change
|
|
425
|
+
* edits them, `.wachiman.yml` is added to the rules as a critical path for this review.
|
|
426
|
+
*/
|
|
427
|
+
export function localPathPolicy(
|
|
428
|
+
readHead: () => Buffer | null,
|
|
429
|
+
files: readonly ReviewFile[],
|
|
430
|
+
baseRules: PathRule[] | undefined,
|
|
431
|
+
): { pathRules: PathRule[] | undefined; pathPolicyChanged: boolean } {
|
|
432
|
+
if (!touchesSettingsFile(files)) return { pathRules: baseRules, pathPolicyChanged: false };
|
|
433
|
+
const bytes = readHead();
|
|
434
|
+
const edited = bytes ? bytes.length > MAX_INSTRUCTION_BYTES || pathsEdited(baseRules, bytes.toString("utf8")) : pathsEdited(baseRules, null);
|
|
435
|
+
return edited ? { pathRules: withPolicyEditRule(baseRules), pathPolicyChanged: true } : { pathRules: baseRules, pathPolicyChanged: false };
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* The memory folder and `.wachiman.yml` at `sha`, read from git's object store: the merge-base for a
|
|
440
|
+
* branch, never the head, so a branch cannot change the memory it is reviewed under (ADR 0056).
|
|
441
|
+
* A `sha` that is not in this clone (an `--input` file can name one) has no memory.
|
|
442
|
+
*/
|
|
443
|
+
export function localMemorySource(repoDir: string, sha: string, git: GitRunner = spawnGit, warn: (line: string) => void = () => {}): MemorySource {
|
|
444
|
+
return {
|
|
445
|
+
list: () => {
|
|
446
|
+
const out = git(["ls-tree", "-z", sha, "--", `${MEMORY_DIR}/`], { cwd: repoDir, timeoutMs: TIMEOUT_MS });
|
|
447
|
+
if (out.status !== 0) return [];
|
|
448
|
+
return out.stdout
|
|
449
|
+
.split("\0")
|
|
450
|
+
.filter(Boolean)
|
|
451
|
+
.flatMap((line) => {
|
|
452
|
+
const [meta, path] = line.split("\t");
|
|
453
|
+
const [mode, type] = meta.split(" ");
|
|
454
|
+
return type === "blob" && (mode === "100644" || mode === "100755") && path.startsWith(`${MEMORY_DIR}/`) ? [path.slice(MEMORY_DIR.length + 1)] : [];
|
|
455
|
+
});
|
|
456
|
+
},
|
|
457
|
+
read: (name) => {
|
|
458
|
+
const bytes = blobAt(repoDir, sha, `${MEMORY_DIR}/${name}`, git);
|
|
459
|
+
if (!bytes) return null;
|
|
460
|
+
const file = instructionFileOf(name, bytes);
|
|
461
|
+
if (file.truncated) warn(cutMemoryNote(name, MAX_INSTRUCTION_BYTES / 1024));
|
|
462
|
+
return file.content;
|
|
463
|
+
},
|
|
464
|
+
settings: () => localRepoSettings(repoDir, sha, git),
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The memory a local review of `changedPaths` loads at `sha`; undefined without a memory folder.
|
|
470
|
+
* `personal` is the developer's own folder for this repository (`personalSourceFor`): only a laptop
|
|
471
|
+
* review passes it, so a review in Actions never has it.
|
|
472
|
+
*/
|
|
473
|
+
export function localMemory(repoDir: string, sha: string, changedPaths: string[], warn: (line: string) => void, git: GitRunner = spawnGit, personal?: MemorySource): MemoryLoad | undefined {
|
|
474
|
+
return loadMemory(localMemorySource(repoDir, sha, git, warn), sha, changedPaths, warn, personal);
|
|
475
|
+
}
|
|
476
|
+
|
|
356
477
|
const names = (out: string) => out.split("\0").filter(Boolean);
|
|
357
478
|
|
|
358
479
|
/**
|
|
@@ -544,6 +665,11 @@ export function buildLocalInput(p: {
|
|
|
544
665
|
);
|
|
545
666
|
if (ignored.length > 0) p.log(`Not paths in this change, ignored: ${ignored.join(" ")}`);
|
|
546
667
|
const instructions = localInstructions(p.repoDir, refs.mergeBase, p.warn, git);
|
|
668
|
+
const { pathRules, pathPolicyChanged } = localPathPolicy(
|
|
669
|
+
() => blobAt(p.repoDir, refs.headSha, SETTINGS_PATH, git),
|
|
670
|
+
files,
|
|
671
|
+
localPathRules(p.repoDir, refs.mergeBase, "the merge-base", p.warn, git),
|
|
672
|
+
);
|
|
547
673
|
const top = run(git, p.repoDir, ["rev-parse", "--show-toplevel"]).trim();
|
|
548
674
|
const name = basename(top);
|
|
549
675
|
const subjects = run(git, p.repoDir, ["log", "--reverse", "--format=%s", ...subjectRange(refs)]).trim();
|
|
@@ -566,6 +692,8 @@ export function buildLocalInput(p: {
|
|
|
566
692
|
instructions,
|
|
567
693
|
headDir: snapshot.dir,
|
|
568
694
|
scope: paths,
|
|
695
|
+
...(pathRules?.length ? { pathRules } : {}),
|
|
696
|
+
...(pathPolicyChanged ? { pathPolicyChanged: true as const } : {}),
|
|
569
697
|
};
|
|
570
698
|
return { input, snapshotDir: snapshot.dir, refs };
|
|
571
699
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
readFileSync,
|
|
12
12
|
readlinkSync,
|
|
13
13
|
realpathSync,
|
|
14
|
+
statSync,
|
|
14
15
|
rmSync,
|
|
15
16
|
writeFileSync,
|
|
16
17
|
} from "node:fs";
|
|
@@ -21,10 +22,20 @@ import { UsageError } from "../config";
|
|
|
21
22
|
import { GIT_BASE_ARGS, gitEnv, spawnGit, type GitRunner } from "../evidence";
|
|
22
23
|
import { REVIEW_INPUT_V2, type ReviewInput } from "../formats";
|
|
23
24
|
import { resolveScope } from "../engine";
|
|
24
|
-
import {
|
|
25
|
+
import { SETTINGS_PATH } from "../repo-settings";
|
|
26
|
+
import { localFiles, localInstructions, localPathPolicy, localPathRules } from "./local-git";
|
|
25
27
|
|
|
26
28
|
type Spawn = typeof spawnSync;
|
|
27
29
|
const hash = (bytes: Buffer) => createHash("sha256").update(bytes).digest("hex");
|
|
30
|
+
/** A snapshot file's bytes, or null when the path is absent or not a regular file (a directory is absent, as in a commit). */
|
|
31
|
+
export function readSnapshotFile(file: string): Buffer | null {
|
|
32
|
+
try {
|
|
33
|
+
return statSync(file).isFile() ? readFileSync(file) : null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
const identity = (s: ReturnType<typeof lstatSync>) => [s.dev, s.ino, s.mode, s.size, s.mtimeMs, s.ctimeMs].join(":");
|
|
29
40
|
const failure = () => new UsageError("The index, HEAD or tracked files changed during capture; retry --working-tree.");
|
|
30
41
|
/** Index the materialized bytes directly; git add would apply repository attributes. */
|
|
@@ -264,6 +275,15 @@ export function workingTreeInput(p: {
|
|
|
264
275
|
// Evidence uses git grep in its own index; symlink entries remain textual blobs there too.
|
|
265
276
|
indexRawSnapshot(snapshot, treeEntries, (a, input) => exec(["-C", snapshot, ...a], input));
|
|
266
277
|
const name = basename(top);
|
|
278
|
+
const { pathRules, pathPolicyChanged } = localPathPolicy(
|
|
279
|
+
() => {
|
|
280
|
+
// The snapshot holds the working tree's blobs as plain files, so a link is its target text.
|
|
281
|
+
const file = join(snapshot, SETTINGS_PATH);
|
|
282
|
+
return readSnapshotFile(file);
|
|
283
|
+
},
|
|
284
|
+
files,
|
|
285
|
+
localPathRules(top, base, "HEAD", p.warn, git),
|
|
286
|
+
);
|
|
267
287
|
const input: ReviewInput = {
|
|
268
288
|
format: REVIEW_INPUT_V2,
|
|
269
289
|
change: {
|
|
@@ -278,6 +298,8 @@ export function workingTreeInput(p: {
|
|
|
278
298
|
instructions: localInstructions(top, base, p.warn, git),
|
|
279
299
|
headDir: snapshot,
|
|
280
300
|
scope: paths,
|
|
301
|
+
...(pathRules?.length ? { pathRules } : {}),
|
|
302
|
+
...(pathPolicyChanged ? { pathPolicyChanged: true as const } : {}),
|
|
281
303
|
};
|
|
282
304
|
return { input, release };
|
|
283
305
|
} catch (e) {
|
package/src/doctor/checks.ts
CHANGED
|
@@ -16,10 +16,13 @@ import type { HistoryRepository } from "../history/types";
|
|
|
16
16
|
import { detectInstall, type InstallKind } from "../install-kind";
|
|
17
17
|
import { inspectIsolatedProfile } from "../profiles";
|
|
18
18
|
import { buildChildEnv } from "../providers/claude-code";
|
|
19
|
+
import { effectiveSettings, OLD_SETTINGS_PATH, parseRepoSettings, SETTINGS_PATH } from "../repo-settings";
|
|
20
|
+
import { UsageError } from "../config";
|
|
21
|
+
import { classifyRef, compareVersions, parseTag, scanWorkflows } from "../upgrade/pin";
|
|
19
22
|
|
|
20
23
|
export type CheckLevel = "required" | "optional";
|
|
21
24
|
export type CheckStatus = "ok" | "fail" | "warn" | "skip";
|
|
22
|
-
export type CheckId = "wachiman" | "bun" | "git" | "tar" | "config" | "profile" | "auth" | "environment" | "project" | "history" | "skills" | "isolation";
|
|
25
|
+
export type CheckId = "wachiman" | "bun" | "git" | "tar" | "config" | "profile" | "auth" | "environment" | "project" | "settings" | "workflow-pin" | "history" | "skills" | "isolation";
|
|
23
26
|
|
|
24
27
|
export interface DoctorRow {
|
|
25
28
|
id: CheckId;
|
|
@@ -49,6 +52,8 @@ export interface DoctorFs {
|
|
|
49
52
|
isDirectory: (path: string) => boolean;
|
|
50
53
|
/** The names in a directory; empty when it cannot be listed. */
|
|
51
54
|
list: (path: string) => string[];
|
|
55
|
+
/** Like `list`, but throws when the directory cannot be read (used by the workflow-pin row). */
|
|
56
|
+
listStrict?: (path: string) => string[];
|
|
52
57
|
/** Permission bits, or undefined where the platform has none. */
|
|
53
58
|
mode: (path: string) => number | undefined;
|
|
54
59
|
/** Used only for a managed profile's `settings.json`. */
|
|
@@ -56,6 +61,7 @@ export interface DoctorFs {
|
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export const realDoctorFs: DoctorFs = {
|
|
64
|
+
listStrict: (p) => readdirSync(p),
|
|
59
65
|
exists: (p) => existsSync(p),
|
|
60
66
|
isDirectory: (p) => {
|
|
61
67
|
try {
|
|
@@ -102,6 +108,10 @@ export interface DoctorContext {
|
|
|
102
108
|
config: ConfigRead;
|
|
103
109
|
/** The repository of `--repo-dir`, or why there is none. */
|
|
104
110
|
repository: { ok: true; value: HistoryRepository } | { ok: false; reason: string };
|
|
111
|
+
/** The top of the working tree of `--repo-dir` (where `.wachiman.yml` is looked for); undefined when it is not one. */
|
|
112
|
+
root?: string;
|
|
113
|
+
/** `.wachiman.yml` differs from the last commit (new, edited or deleted): runs do not see the working copy yet. */
|
|
114
|
+
settingsUncommitted?: boolean;
|
|
105
115
|
/** The profile the full resolution picks (or the one `--profile` names); undefined when it resolves to nothing. */
|
|
106
116
|
primary: ResolvedProfile | undefined;
|
|
107
117
|
/** The profile this pass of `profile`, `auth` and `isolation` looks at. */
|
|
@@ -359,6 +369,101 @@ export const CHECKS: DoctorCheck[] = [
|
|
|
359
369
|
};
|
|
360
370
|
},
|
|
361
371
|
},
|
|
372
|
+
{
|
|
373
|
+
// Read-only: reports the repository's `.wachiman.yml` (the working tree is fine here; a run reads
|
|
374
|
+
// the base commit) and where the model and the effort of a run would come from. Never writes or moves anything.
|
|
375
|
+
id: "settings",
|
|
376
|
+
level: "optional",
|
|
377
|
+
run: ({ root, env, fs, settingsUncommitted }) => {
|
|
378
|
+
if (root === undefined) return { id: "settings", level: "optional", status: "skip", evidence: "not in a git working tree: no repository settings to read" };
|
|
379
|
+
const file = join(root, SETTINGS_PATH);
|
|
380
|
+
const old = join(root, OLD_SETTINGS_PATH);
|
|
381
|
+
const hasFile = fs.exists(file);
|
|
382
|
+
const hasOld = fs.exists(old);
|
|
383
|
+
let settings: ReturnType<typeof parseRepoSettings> | undefined;
|
|
384
|
+
if (hasFile) {
|
|
385
|
+
try {
|
|
386
|
+
settings = parseRepoSettings(fs.read(file));
|
|
387
|
+
} catch (error) {
|
|
388
|
+
const why = error instanceof UsageError ? error.message : `${SETTINGS_PATH} cannot be read (${error instanceof Error ? error.message : error})`;
|
|
389
|
+
return {
|
|
390
|
+
id: "settings",
|
|
391
|
+
level: "optional",
|
|
392
|
+
status: "warn",
|
|
393
|
+
evidence: `the working copy of ${SETTINGS_PATH} is invalid: ${why} Runs read it at the base commit (Actions) or the merge-base (local), so it takes effect once committed and merged; a run with a broken file at that commit ignores it with a warning and uses the defaults.`,
|
|
394
|
+
fix: `fix ${SETTINGS_PATH} (effort is low, medium, high, xhigh or max; model is a model name), or remove it to use the defaults`,
|
|
395
|
+
detail: { file, valid: false },
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const effective = effectiveSettings(env, settings);
|
|
400
|
+
const from = (s: { value: string; source: string; skipped?: string }) =>
|
|
401
|
+
`${s.value} (${s.source === "file" ? `from ${SETTINGS_PATH}` : s.source === "env" ? "from the environment" : s.skipped !== undefined ? `default; the model "${settings?.model}" in ${SETTINGS_PATH} is skipped: ${s.skipped}` : "default"})`;
|
|
402
|
+
const read = hasFile ? `${SETTINGS_PATH}: kind ${settings?.kind ?? "not set"}, model ${settings?.model ?? "not set"}, effort ${settings?.effort ?? "not set"}` : `no ${SETTINGS_PATH}`;
|
|
403
|
+
const detail = {
|
|
404
|
+
file: hasFile ? file : null,
|
|
405
|
+
valid: true,
|
|
406
|
+
kind: settings?.kind ?? null,
|
|
407
|
+
model: settings?.model ?? null,
|
|
408
|
+
effort: settings?.effort ?? null,
|
|
409
|
+
effectiveModel: effective.model.value,
|
|
410
|
+
modelFrom: effective.model.source,
|
|
411
|
+
modelSkipped: effective.model.skipped ?? null,
|
|
412
|
+
effectiveEffort: effective.effort.value,
|
|
413
|
+
effortFrom: effective.effort.source,
|
|
414
|
+
uncommitted: settingsUncommitted === true,
|
|
415
|
+
};
|
|
416
|
+
// A run reads the committed file, so with uncommitted changes the working copy says what will apply once committed, not now.
|
|
417
|
+
const runs = settingsUncommitted
|
|
418
|
+
? `${SETTINGS_PATH} has changes that are not committed, and runs read the committed file: once committed (and merged, for Actions) a run would use model ${from(effective.model)}, effort ${from(effective.effort)}`
|
|
419
|
+
: `a run here would use model ${from(effective.model)}, effort ${from(effective.effort)}`;
|
|
420
|
+
const evidence = `${read}; ${runs}. GitHub Actions reads the file from the base commit of the pull request, not from the head`;
|
|
421
|
+
if (hasOld) {
|
|
422
|
+
return {
|
|
423
|
+
id: "settings",
|
|
424
|
+
level: "optional",
|
|
425
|
+
status: "warn",
|
|
426
|
+
evidence: `${OLD_SETTINGS_PATH} exists and is never read (the settings file is ${SETTINGS_PATH} at the root); ${evidence}`,
|
|
427
|
+
fix: hasFile ? `merge ${OLD_SETTINGS_PATH} into ${SETTINGS_PATH}, then remove it` : `mv ${OLD_SETTINGS_PATH} ${SETTINGS_PATH}`,
|
|
428
|
+
detail: { ...detail, oldLocation: old },
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
return { id: "settings", level: "optional", status: "ok", evidence, detail };
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
id: "workflow-pin",
|
|
436
|
+
level: "optional",
|
|
437
|
+
run: ({ root, fs, version }) => {
|
|
438
|
+
const row = (status: CheckStatus, evidence: string, extra: Partial<DoctorRow> = {}): DoctorRow => ({ id: "workflow-pin", level: "optional", status, evidence, ...extra });
|
|
439
|
+
const installed = parseTag(version);
|
|
440
|
+
if (root === undefined) return row("skip", "not in a git repository, so no workflow was read");
|
|
441
|
+
const scan = scanWorkflows(root, fs);
|
|
442
|
+
const unreadable = [...(scan.unreadableDir ? [`${scan.unreadableDir} (directory)`] : []), ...scan.unreadable];
|
|
443
|
+
const unreadableNote = unreadable.length > 0 ? `; could not read ${unreadable.join(", ")}, so its pins are unknown` : "";
|
|
444
|
+
const pins = scan.files.flatMap(({ file, refs }) => refs.map((ref) => ({ file, ref })));
|
|
445
|
+
if (pins.length === 0) {
|
|
446
|
+
return unreadable.length > 0
|
|
447
|
+
? row("warn", `no readable workflow calls a Wachiman reusable workflow${unreadableNote}`, { detail: { unreadable: unreadable.length } })
|
|
448
|
+
: row("skip", "no workflow in .github/workflows calls a Wachiman reusable workflow");
|
|
449
|
+
}
|
|
450
|
+
if (installed === undefined) return row("skip", `the installed version "${version}" is not a release version, so pins cannot be compared`);
|
|
451
|
+
const older = pins.filter((p) => classifyRef(p.ref) === "tag" && compareVersions(parseTag(p.ref)!, installed) < 0);
|
|
452
|
+
const fixed = pins.filter((p) => classifyRef(p.ref) === "tag");
|
|
453
|
+
const other = pins.filter((p) => classifyRef(p.ref) !== "tag");
|
|
454
|
+
const list = (items: typeof pins) => items.map((p) => `${p.file} @${classifyRef(p.ref) === "sha" ? p.ref.slice(0, 12) : p.ref}`).join(", ");
|
|
455
|
+
const detail = { pins: pins.length, older: older.length, notReleaseTag: other.length, unreadable: unreadable.length };
|
|
456
|
+
if (older.length > 0) {
|
|
457
|
+
return row("warn", `${list(older)} older than the installed v${version}: reviews in Actions run that older release${unreadableNote}`, {
|
|
458
|
+
fix: "wachiman upgrade --repo-only",
|
|
459
|
+
detail,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
const note = (other.length > 0 ? `; ${list(other)} is a commit or branch, which is not compared` : "") + unreadableNote;
|
|
463
|
+
if (fixed.length === 0) return row(unreadable.length > 0 ? "warn" : "skip", `${list(other)} is a commit or branch, not a release tag, so it is not compared${unreadableNote}`, { detail });
|
|
464
|
+
return row(unreadable.length > 0 ? "warn" : "ok", `${list(fixed)} is not older than the installed v${version}${note}`, { detail });
|
|
465
|
+
},
|
|
466
|
+
},
|
|
362
467
|
{
|
|
363
468
|
id: "history",
|
|
364
469
|
level: "optional",
|
package/src/doctor/run.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { confirmProfile, type ConfirmIo, type SpawnFn } from "../accounts/confir
|
|
|
9
9
|
import { buildProfileList, managedDir } from "../accounts/profile-list";
|
|
10
10
|
import { parseProfileRef, resolveProfile } from "../accounts/resolve";
|
|
11
11
|
import { UsageError } from "../config";
|
|
12
|
-
import { type GitRunner } from "../evidence";
|
|
12
|
+
import { spawnGit, type GitRunner } from "../evidence";
|
|
13
13
|
import { parseFlags } from "../flags";
|
|
14
14
|
import { repositoryKey } from "../history/store";
|
|
15
15
|
import { CHECKS, detectInstall, PROFILE_SCOPED, realDoctorFs, tierOf, type DoctorContext, type DoctorFs, type DoctorReport, type InstallKind, type Target } from "./checks";
|
|
@@ -76,6 +76,12 @@ export function buildDoctorReport(opts: DoctorOptions, env: Record<string, strin
|
|
|
76
76
|
} catch {
|
|
77
77
|
repository = { ok: false, reason: `${opts.repoDir} is not a git repository` };
|
|
78
78
|
}
|
|
79
|
+
// Where `.wachiman.yml` is looked for: the top of the working tree (a linked worktree has its own copy).
|
|
80
|
+
const top = (deps.git ?? spawnGit)(["rev-parse", "--show-toplevel"], { cwd: opts.repoDir, timeoutMs: 15_000 });
|
|
81
|
+
const root = top.status === 0 && top.stdout.trim() !== "" ? top.stdout.trim() : undefined;
|
|
82
|
+
// Runs read the committed file, so an edit not committed yet does not apply to them.
|
|
83
|
+
const pending = root === undefined ? undefined : (deps.git ?? spawnGit)(["status", "--porcelain", "--", ".wachiman.yml"], { cwd: root, timeoutMs: 15_000 });
|
|
84
|
+
const settingsUncommitted = pending !== undefined && pending.status === 0 && pending.stdout.trim() !== "";
|
|
79
85
|
const binding =
|
|
80
86
|
repository.ok && accounts && Object.hasOwn(accounts.projects, repository.value.key) ? accounts.projects[repository.value.key] : undefined;
|
|
81
87
|
|
|
@@ -111,6 +117,8 @@ export function buildDoctorReport(opts: DoctorOptions, env: Record<string, strin
|
|
|
111
117
|
arch,
|
|
112
118
|
config,
|
|
113
119
|
repository,
|
|
120
|
+
root,
|
|
121
|
+
settingsUncommitted,
|
|
114
122
|
primary,
|
|
115
123
|
};
|
|
116
124
|
|