@osdlc/repo-cleaner 0.17.2 → 0.19.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 (54) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +691 -305
  3. package/dist/branches.d.ts +37 -36
  4. package/dist/branches.js +199 -196
  5. package/dist/clean.d.ts +179 -0
  6. package/dist/clean.js +824 -0
  7. package/dist/cli.d.ts +12 -16
  8. package/dist/cli.js +367 -478
  9. package/dist/hooks.d.ts +8 -12
  10. package/dist/hooks.js +2 -2
  11. package/dist/index.d.ts +18 -25
  12. package/dist/index.js +16 -23
  13. package/dist/landing.d.ts +3 -3
  14. package/dist/landing.js +7 -7
  15. package/dist/plan.d.ts +76 -70
  16. package/dist/plan.js +82 -77
  17. package/dist/providers/github.d.ts +2 -1
  18. package/dist/providers/github.js +2 -1
  19. package/dist/providers/gitlab.d.ts +3 -2
  20. package/dist/providers/gitlab.js +14 -8
  21. package/dist/providers/index.d.ts +5 -4
  22. package/dist/providers/index.js +8 -5
  23. package/dist/providers/types.d.ts +8 -2
  24. package/dist/prs.d.ts +35 -7
  25. package/dist/prs.js +45 -12
  26. package/dist/receipt.d.ts +46 -57
  27. package/dist/receipt.js +52 -28
  28. package/dist/reference.d.ts +12 -0
  29. package/dist/reference.js +152 -0
  30. package/dist/remote-mirror.d.ts +9 -1
  31. package/dist/remote-mirror.js +19 -1
  32. package/dist/render.d.ts +66 -61
  33. package/dist/render.js +206 -255
  34. package/dist/resolve.d.ts +3 -3
  35. package/dist/resolve.js +4 -12
  36. package/dist/status-line.d.ts +1 -1
  37. package/dist/status-line.js +5 -5
  38. package/dist/step-board.d.ts +1 -1
  39. package/dist/step-board.js +2 -5
  40. package/dist/submodules.d.ts +120 -0
  41. package/dist/submodules.js +292 -0
  42. package/dist/sweep.d.ts +107 -64
  43. package/dist/sweep.js +333 -119
  44. package/dist/types.d.ts +294 -105
  45. package/dist/types.js +106 -54
  46. package/dist/util.d.ts +13 -0
  47. package/dist/util.js +36 -0
  48. package/dist/version.generated.d.ts +1 -1
  49. package/dist/version.generated.js +1 -1
  50. package/dist/worktrees.d.ts +21 -37
  51. package/dist/worktrees.js +198 -165
  52. package/package.json +5 -5
  53. package/dist/apply.d.ts +0 -131
  54. package/dist/apply.js +0 -541
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdlc/repo-cleaner",
3
- "version": "0.17.2",
3
+ "version": "0.19.0",
4
4
  "description": "What has been merged into the default branch, and what can go away. Inventories local branches, worktrees and remote branches across one repository or many, classifying each with the evidence behind the verdict and the command that would act on it. Plans and applies approved deletes, compare-and-swap.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "sksizer",
@@ -50,11 +50,11 @@
50
50
  "dependencies": {
51
51
  "zod": "^4.6.6",
52
52
  "@osdlc/cli-tool": "^0.17.0",
53
- "@osdlc/command-seam": "^0.14.0",
54
53
  "@osdlc/path-guard": "^0.3.1",
55
- "@osdlc/typed-gh": "^0.16.0",
56
- "@osdlc/typed-git": "^0.12.0",
57
- "@osdlc/ux": "^0.1.1"
54
+ "@osdlc/typed-gh": "^0.16.1",
55
+ "@osdlc/command-seam": "^0.14.0",
56
+ "@osdlc/ux": "^0.1.1",
57
+ "@osdlc/typed-git": "^0.13.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^26.1.0",
package/dist/apply.d.ts DELETED
@@ -1,131 +0,0 @@
1
- /**
2
- * Apply an approved cleanup plan.
3
- *
4
- * Re-sweeps each repository and drops selected rows that are gone, no longer
5
- * deletable, changed, or lack a grant. Deletes the rest in a fixed order and
6
- * stops at the first failure:
7
- *
8
- * 1. worktrees, each unlocked first when its lock's owner is dead, and each
9
- * checked again for live processes just before it is unlocked or removed;
10
- * 2. local branches;
11
- * 3. remote branches;
12
- * 4. one prune per repository.
13
- *
14
- * Branch deletes are compare-and-swap on the planned sha. Every step is
15
- * verified, and the receipt is rewritten after each.
16
- */
17
- import { type CommandRunner } from '@osdlc/command-seam';
18
- import type { HostHooks } from './hooks.ts';
19
- import { type ProcessProbe } from './processes.ts';
20
- import { type Plan } from './plan.ts';
21
- import { type Dropped, type Receipt, type RowRef, type Step } from './receipt.ts';
22
- import { type Authorization, type SweepItem, type SweepProgress } from './types.ts';
23
- /** An authorization the caller gave, for one row or (`row: null`) for all. */
24
- export interface Grant {
25
- name: Authorization;
26
- row: RowRef | null;
27
- }
28
- export interface ApplyOptions extends HostHooks {
29
- /** Injected runners. Defaults spawn the real `git`, `gh` and `glab`. */
30
- git?: CommandRunner | undefined;
31
- gh?: CommandRunner | undefined;
32
- glab?: CommandRunner | undefined;
33
- /**
34
- * Answers lock-owner and working-directory questions, for the re-sweep and
35
- * for the checks just before an unlock and a remove. Defaults to `ps` and
36
- * `lsof`.
37
- */
38
- probe?: ProcessProbe | undefined;
39
- /** The caller's directory; the sweep never offers the worktree holding it. */
40
- callerCwd: string;
41
- dryRun: boolean;
42
- /** Where the receipt is written after each step; null writes none. Unused under `dryRun`. */
43
- receiptPath: string | null;
44
- /** Where the plan came from, shown in the receipt. */
45
- planPath: string;
46
- /** Limit the run to the plan repository rooted here. */
47
- repoRoot?: string | undefined;
48
- now?: () => Date;
49
- /**
50
- * Drop each selected row the re-check does not judge `safe-to-delete`.
51
- * Defaults to true when no rows are requested, so a row to review runs only
52
- * when it is named. Pass it to keep that guard on a run whose rows came
53
- * from such a selection, such as the run a preview confirmed.
54
- */
55
- safeOnly?: boolean | undefined;
56
- /**
57
- * Items to re-check against instead of sweeping again, keyed by repository
58
- * root, already annotated: the hook is not applied to them again, though
59
- * `holdFreedBranches` is, so a freed branch matches its worktree. For a
60
- * preview straight after a sweep; the run that deletes should always sweep
61
- * again.
62
- */
63
- swept?: ReadonlyMap<string, readonly SweepItem[]> | undefined;
64
- /** Rows dropped before this run, such as by a preview; recorded first in the receipt. */
65
- dropped?: readonly Dropped[] | undefined;
66
- /**
67
- * Remote branch rows to keep: not deleted, but checked. Each must be a
68
- * `remote_branch` row of the plan; its id is `<remote>/<branch>`, as in the
69
- * plan, e.g. `origin/topic`. The re-check refuses the run with
70
- * {@link ApplyRefused} when a kept branch is gone or its tip is not the
71
- * planned one, and the run's first steps check each tip again with
72
- * `ls-remote`, so a branch that moves after the re-check stops the run
73
- * before anything is deleted. A kept row cannot also be selected.
74
- */
75
- keep?: readonly RowSelection[] | undefined;
76
- /**
77
- * Fetch each repository's remote before the re-sweep. Defaults to what the
78
- * plan repository records in `fetch`: a plan swept after a fetch is
79
- * re-checked after one. Remote branch tips are read live either way; the
80
- * fetch moves the default branch those tips and the local refs are judged
81
- * against. A failed fetch fails the run before any step.
82
- */
83
- fetch?: boolean | undefined;
84
- /** Passed to the re-sweep's `onProgress`, for a status line. */
85
- onSweepProgress?: ((progress: SweepProgress) => void) | undefined;
86
- /**
87
- * Told once the steps are planned, before the first runs, with the list
88
- * itself: each step's `result` is updated in place as the run goes. Not
89
- * called under `dryRun`.
90
- */
91
- onStart?: ((steps: readonly Step[]) => void) | undefined;
92
- /** Told before each step runs: its 0-based index, the step count and the step. Not called under `dryRun`. */
93
- onStep?: ((index: number, total: number, step: Step) => void) | undefined;
94
- /** Told after each step, with its `result` set (`ok`, or `failed` and the run stops), before the receipt is saved. Not called under `dryRun`. */
95
- onStepDone?: ((index: number, total: number, step: Step) => void) | undefined;
96
- }
97
- /** A selection or grant the plan cannot satisfy. Nothing has been touched. */
98
- export declare class ApplyArgumentError extends Error {
99
- }
100
- /** A kept row is gone or moved since the plan, so the run refuses. Nothing has been touched. */
101
- export declare class ApplyRefused extends Error {
102
- }
103
- /** `<category>:<id>`, split at the first colon. */
104
- export declare function parseRowRef(text: string): RowRef;
105
- /** `<name>` for every row, or `<name>=<category>:<id>` for one. */
106
- export declare function parseGrant(text: string): Grant;
107
- /**
108
- * A row to apply, optionally pinned to the plan repository rooted at `repo`.
109
- * Without `repo`, a row id that two plan repositories share is ambiguous.
110
- */
111
- export type RowSelection = RowRef & {
112
- repo?: string;
113
- };
114
- /**
115
- * A network URL as `host[:port]/path`, the same for `git@host:o/r.git`,
116
- * `ssh://git@host/o/r` and `https://host/o/r/`; the whole path is kept, so
117
- * nested groups stay apart. Null for a path on this machine, including
118
- * `file://` and a Windows drive path.
119
- */
120
- export declare function networkRemoteKey(url: string): string | null;
121
- /**
122
- * Apply the `requested` rows of `plan` under `grants`. An empty `requested`
123
- * selects every row of the plan (of `repoRoot`'s repository, when given) and
124
- * then drops each one the re-sweep does not judge `safe-to-delete`: a row to
125
- * review runs only when it is named. A row named twice runs once. A row whose
126
- * `requires` was not granted is dropped, never run.
127
- *
128
- * @throws ApplyArgumentError before touching anything, when a row or grant does
129
- * not fit the plan.
130
- */
131
- export declare function applyPlan(plan: Plan, requested: readonly RowSelection[], grants: readonly Grant[], opts: ApplyOptions): Receipt;