@webappwiz/arbor 0.0.30 → 0.0.31

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 (118) hide show
  1. package/add.d.ts +23 -0
  2. package/age.d.ts +2 -0
  3. package/arbor.d.ts +11 -0
  4. package/attachments.d.ts +36 -0
  5. package/claim.d.ts +11 -0
  6. package/config.d.ts +55 -0
  7. package/config.js +7 -0
  8. package/dev/assets.d.ts +11 -0
  9. package/dev.d.ts +48 -0
  10. package/escalate.d.ts +28 -0
  11. package/exit.d.ts +42 -0
  12. package/git.d.ts +77 -0
  13. package/index.d.ts +2 -0
  14. package/index.js +4712 -0
  15. package/journal.d.ts +29 -0
  16. package/list.d.ts +18 -0
  17. package/load-config.d.ts +15 -0
  18. package/log.d.ts +14 -0
  19. package/merge.d.ts +24 -0
  20. package/package.json +15 -32
  21. package/path.d.ts +13 -0
  22. package/plan.d.ts +83 -0
  23. package/remove.d.ts +19 -0
  24. package/repository.d.ts +25 -0
  25. package/retry.d.ts +17 -0
  26. package/shell.d.ts +17 -0
  27. package/show.d.ts +53 -0
  28. package/snapshot.d.ts +35 -0
  29. package/table.d.ts +5 -0
  30. package/todo.d.ts +264 -0
  31. package/wait.d.ts +22 -0
  32. package/worktree-service.d.ts +51 -0
  33. package/worktree.d.ts +95 -0
  34. package/AGENTS.md +0 -7
  35. package/add.test.ts +0 -125
  36. package/add.ts +0 -192
  37. package/age.ts +0 -11
  38. package/arbor.test.ts +0 -145
  39. package/arbor.ts +0 -429
  40. package/assets.d.ts +0 -9
  41. package/attachments.ts +0 -87
  42. package/build.ts +0 -98
  43. package/claim.test.ts +0 -89
  44. package/claim.ts +0 -73
  45. package/components.json +0 -21
  46. package/config.ts +0 -58
  47. package/dev/api.ts +0 -120
  48. package/dev/app.test.tsx +0 -645
  49. package/dev/app.tsx +0 -80
  50. package/dev/assets.ts +0 -16
  51. package/dev/build/main.txt +0 -68
  52. package/dev/build/shell.txt +0 -21
  53. package/dev/build/styles.txt +0 -2263
  54. package/dev/components/ui/badge.tsx +0 -51
  55. package/dev/components/ui/button.tsx +0 -57
  56. package/dev/components/ui/dialog.tsx +0 -154
  57. package/dev/components/ui/empty.tsx +0 -100
  58. package/dev/components/ui/input-group.tsx +0 -155
  59. package/dev/components/ui/input.tsx +0 -19
  60. package/dev/components/ui/progress.tsx +0 -80
  61. package/dev/components/ui/textarea.tsx +0 -17
  62. package/dev/components/ui/toast.tsx +0 -227
  63. package/dev/feed.ts +0 -69
  64. package/dev/files.tsx +0 -191
  65. package/dev/index.html +0 -21
  66. package/dev/lib/utils.ts +0 -7
  67. package/dev/main.tsx +0 -22
  68. package/dev/markdown.test.tsx +0 -133
  69. package/dev/markdown.tsx +0 -124
  70. package/dev/mentions.tsx +0 -319
  71. package/dev/shadcn.css +0 -649
  72. package/dev/styles.css +0 -107
  73. package/dev/tags.tsx +0 -44
  74. package/dev/tasks.tsx +0 -151
  75. package/dev/todos.tsx +0 -759
  76. package/dev.test.ts +0 -439
  77. package/dev.ts +0 -386
  78. package/e2e.test.ts +0 -256
  79. package/escalate.test.ts +0 -76
  80. package/escalate.ts +0 -112
  81. package/exit.test.ts +0 -71
  82. package/exit.ts +0 -74
  83. package/git.ts +0 -294
  84. package/index.ts +0 -9
  85. package/journal.ts +0 -89
  86. package/list.test.ts +0 -82
  87. package/list.ts +0 -137
  88. package/load-config.test.ts +0 -121
  89. package/load-config.ts +0 -62
  90. package/log.test.ts +0 -65
  91. package/log.ts +0 -40
  92. package/merge.test.ts +0 -332
  93. package/merge.ts +0 -283
  94. package/path.test.ts +0 -35
  95. package/path.ts +0 -38
  96. package/plan.test.ts +0 -318
  97. package/plan.ts +0 -302
  98. package/progress.test.ts +0 -54
  99. package/progress.ts +0 -31
  100. package/remove.test.ts +0 -68
  101. package/remove.ts +0 -88
  102. package/repository.ts +0 -83
  103. package/retry.test.ts +0 -43
  104. package/retry.ts +0 -48
  105. package/shell.ts +0 -44
  106. package/show.test.ts +0 -91
  107. package/show.ts +0 -151
  108. package/snapshot.test.ts +0 -33
  109. package/snapshot.ts +0 -84
  110. package/table.ts +0 -20
  111. package/testing.ts +0 -229
  112. package/todo.test.ts +0 -490
  113. package/todo.ts +0 -834
  114. package/wait.test.ts +0 -61
  115. package/wait.ts +0 -77
  116. package/worktree-service.test.ts +0 -158
  117. package/worktree-service.ts +0 -193
  118. package/worktree.ts +0 -239
package/add.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { type Logger } from "webappwiz/log";
2
+ import type { Fs } from "webappwiz/system";
3
+ import type { Config } from "./config.js";
4
+ import type { Shell } from "./shell.js";
5
+ import type { Todos } from "./todo.js";
6
+ import type { WorktreeService } from "./worktree-service.js";
7
+ export interface AddOptions {
8
+ /** Branch the task starts from and merges onto. Defaults to the trunk. */
9
+ base?: string;
10
+ /**
11
+ * The todos this task takes up: their words seed the plan's Goal, and
12
+ * nobody else can take them while the task lives.
13
+ */
14
+ todos?: number[];
15
+ }
16
+ export declare function add({ service, shell, config, log, fs, todos, }: {
17
+ service: WorktreeService;
18
+ shell: Shell;
19
+ config: Config;
20
+ log: Logger;
21
+ fs: Fs;
22
+ todos: Todos;
23
+ }, task: string, { base, todos: ids }?: AddOptions): Promise<void>;
package/age.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** How long ago an ISO timestamp was, at the coarsest unit that still reads. */
2
+ export declare function age(since: string): string;
package/arbor.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { type Deps } from "webappwiz/cmd";
2
+ import type { Fs } from "webappwiz/system";
3
+ import type { Assets } from "./dev/assets.js";
4
+ import { type Repository } from "./repository.js";
5
+ /** Everything `arbor` is run with, before the repository middleware adds to it. */
6
+ export interface ArborDeps extends Deps {
7
+ fs: Fs;
8
+ /** The built page `dev` serves as its preview. */
9
+ assets: Assets;
10
+ }
11
+ export declare const arbor: import("webappwiz/cmd").Cli<ArborDeps, ArborDeps & Repository>;
@@ -0,0 +1,36 @@
1
+ import { type IdProvider } from "webappwiz/id";
2
+ import type { Fs, Ps } from "webappwiz/system";
3
+ /** A file handed over, as bytes so a pasted image needs no temp file. */
4
+ export interface Attachment {
5
+ /** What it was called, kept in the stored name so the files stay apart. */
6
+ name: string;
7
+ bytes: Uint8Array;
8
+ }
9
+ /**
10
+ * The folder of files that belong to a todo: todo 7's beside its record, in
11
+ * `todos/7/`.
12
+ * Under `.git/arbor`, so nothing here is ever committed and every tree can
13
+ * open what it holds.
14
+ */
15
+ export declare class Attachments {
16
+ readonly dir: string;
17
+ private readonly fs;
18
+ private readonly ids;
19
+ constructor(dir: string, fs: Fs, ids?: IdProvider);
20
+ /** Copies each file in, returning the absolute path each was stored at. */
21
+ store(files: Attachment[]): Promise<string[]>;
22
+ /** Whether `path` is one of this folder's files, and not a way out of it. */
23
+ owns(path: string): boolean;
24
+ /** Deletes the files given that are this folder's; others are left alone. */
25
+ remove(paths: string[]): Promise<void>;
26
+ /** Deletes the folder and everything in it. */
27
+ clear(): Promise<void>;
28
+ }
29
+ /**
30
+ * Reads files named on the command line, relative to the current directory or
31
+ * absolute, refusing the whole command over one that cannot be read.
32
+ */
33
+ export declare function readFiles({ fs, ps }: {
34
+ fs: Fs;
35
+ ps: Ps;
36
+ }, paths: string[]): Promise<Attachment[]>;
package/claim.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { type Logger } from "webappwiz/log";
2
+ import type { WorktreeService } from "./worktree-service.js";
3
+ /**
4
+ * The resume entry point: a fresh agent thread picking up existing work. An
5
+ * escalated task goes back to `working`, since someone is on it again; its
6
+ * merge budget stays as it was, which only `retry` refills.
7
+ */
8
+ export declare function claim({ service, log }: {
9
+ service: WorktreeService;
10
+ log: Logger;
11
+ }, task: string): Promise<void>;
package/config.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ export interface Config {
2
+ /**
3
+ * The integration branch name. `merge` rebases a task onto this branch and
4
+ * then fast-forwards it to the result; new worktrees start from it.
5
+ */
6
+ trunk: string;
7
+ /** Directory holding one worktree per task, a sibling of the repo. */
8
+ worktreeRoot: string;
9
+ /** Command run by `add` in the new worktree, via `sh -c`. */
10
+ postCheckout: string | null;
11
+ /**
12
+ * Command run by `merge` after the rebase, before `preMerge`, via `sh -c`.
13
+ * A rebase can bring in a dependency the worktree has never installed, and
14
+ * whatever `preMerge` runs needs it.
15
+ */
16
+ postRewrite: string | null;
17
+ /**
18
+ * Command run by `merge` after the rebase, via `sh -c`. The last gate before
19
+ * the branch lands: a nonzero exit rolls the branch back and leaves the base
20
+ * untouched. Tests are the obvious thing to put here, but arbor has no
21
+ * opinion; a repo with nothing to run leaves it null and merges on a green
22
+ * rebase alone.
23
+ */
24
+ preMerge: string | null;
25
+ /**
26
+ * Command run by `merge` in the main tree after the base fast-forwards, via
27
+ * `sh -c`. The branch has already landed and the worktree is gone: a nonzero
28
+ * exit reports the failure but rolls nothing back.
29
+ */
30
+ postMerge: string | null;
31
+ /** How long since its last heartbeat before a task's lease is up for grabs. */
32
+ leaseStalenessMs: number;
33
+ /** Failed `merge` attempts a task gets before it must escalate or be removed. */
34
+ mergeRetryCount: number;
35
+ /**
36
+ * How many removed task names to keep, so `remove` can say "already removed"
37
+ * rather than "never existed". A flat cap with no age policy: losing the
38
+ * oldest costs a nicer message and nothing else.
39
+ */
40
+ removedCapacity: number;
41
+ /** How many entries `arbor log` keeps before the oldest fall off. */
42
+ logCapacity: number;
43
+ /**
44
+ * How long a todo can wait before `merge` stops recommending it and offers
45
+ * it for removal instead: work deferred that long has usually been done
46
+ * some other way, or stopped mattering.
47
+ */
48
+ todoStalenessMs: number;
49
+ }
50
+ /**
51
+ * Identity, for the types. `export default defineConfig({ ... })` in
52
+ * `arbor.config.ts` gets the key names and their types checked, and completion
53
+ * while writing it; a bare object literal gets neither.
54
+ */
55
+ export declare function defineConfig(config: Partial<Config>): Partial<Config>;
package/config.js ADDED
@@ -0,0 +1,7 @@
1
+ // config.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+ export {
6
+ defineConfig
7
+ };
@@ -0,0 +1,11 @@
1
+ /** The three files the browser asks for, as the server hands them over. */
2
+ export interface Assets {
3
+ /** The page, which asks for the other two. */
4
+ shell: string;
5
+ /** The React app, bundled for the browser. */
6
+ script: string;
7
+ /** The stylesheet, with Tailwind already compiled. */
8
+ styles: string;
9
+ }
10
+ /** The page this package ships. Serve each field's contents as-is. */
11
+ export declare const assets: Assets;
package/dev.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { type AsyncResource } from "webappwiz/disposable";
2
+ import type { Logger } from "webappwiz/log";
3
+ import { type Fs, type PortProvider, type Ps } from "webappwiz/system";
4
+ import type { Assets } from "./dev/assets.js";
5
+ import type { Journal } from "./journal.js";
6
+ import type { Todos } from "./todo.js";
7
+ import type { WorktreeService } from "./worktree-service.js";
8
+ /** Preferred, not required: `dev` moves up from here when it is taken. */
9
+ export declare const DEFAULT_PORT = 4269;
10
+ /** How far above the port asked for `dev` will look before giving up. */
11
+ export declare const PORT_SPAN = 20;
12
+ /** What `dev` lets a caller choose. */
13
+ export interface DevOptions {
14
+ /** Where to listen; the port `--port` asked for, and the span above it. */
15
+ ports?: PortProvider;
16
+ /**
17
+ * Host names besides this machine's own that the page may be reached by,
18
+ * like the hostname of a tunnel. Anything else is refused, which is what
19
+ * stops another site from reading the repo through a browser pointed at
20
+ * localhost. Who may use those names is the tunnel's business, not arbor's.
21
+ */
22
+ hosts?: string[];
23
+ }
24
+ /** A running server, and the one thing a caller ever wants to do with it. */
25
+ export interface DevServer extends AsyncResource {
26
+ port: number;
27
+ }
28
+ /**
29
+ * Serves what `todo list`, `list` and `show` print as one page that refetches
30
+ * when the repo changes, where a person adds, edits, reorders and removes
31
+ * todos. Anything that moves a task (merge, remove, claim) stays in the CLI,
32
+ * so a page that should not have been reachable can at worst change a todo.
33
+ */
34
+ export declare function dev({ service, fs, ps, journal, todos, log, assets, }: {
35
+ service: WorktreeService;
36
+ fs: Fs;
37
+ ps: Ps;
38
+ journal: Journal;
39
+ todos: Todos;
40
+ log: Logger;
41
+ assets: Assets;
42
+ }, { ports, hosts }?: DevOptions): Promise<DevServer>;
43
+ /**
44
+ * Where `dev` will listen, given the port asked for. A flag is outside input,
45
+ * so a port that cannot exist is a refusal with an exit code rather than the
46
+ * assertion `OpenPortProvider` would raise for a bug in here.
47
+ */
48
+ export declare function devPorts(from: number): PortProvider;
package/escalate.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { type Logger } from "webappwiz/log";
2
+ import type { Fs, Lock } from "webappwiz/system";
3
+ import type { Git } from "./git.js";
4
+ import type { WorktreeService } from "./worktree-service.js";
5
+ export interface EscalateOptions {
6
+ /** Task to escalate. Defaults to the one `cwd` is a worktree for. */
7
+ task?: string;
8
+ /**
9
+ * Ask a person to approve merging, rather than to answer questions: adds
10
+ * the question that asks it to the plan, with the reason as its detail.
11
+ * Refused while another question is unchecked.
12
+ */
13
+ review?: boolean;
14
+ }
15
+ /** The question a review asks. */
16
+ export declare const REVIEW_SUBJECT = "Ready to merge?";
17
+ /**
18
+ * The way out that is not "resolve the conflict badly to finish the task".
19
+ * When both sides restructured the same logic there is no correct merge, only
20
+ * a decision, and that belongs to a human.
21
+ */
22
+ export declare function escalate({ service, git, lock, log, fs, }: {
23
+ service: WorktreeService;
24
+ git: Git;
25
+ lock: Lock;
26
+ log: Logger;
27
+ fs: Fs;
28
+ }, reason: string, cwd: string, { task, review }?: EscalateOptions): Promise<void>;
package/exit.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { Deps, Middleware } from "webappwiz/cmd";
2
+ /** Exit codes are the API: an agent branches on these, not on prose. */
3
+ export declare const EXIT: {
4
+ readonly usage: 1;
5
+ readonly conflict: 2;
6
+ readonly tests_failed: 3;
7
+ readonly lease_lost: 4;
8
+ readonly budget_exhausted: 5;
9
+ readonly lease_held: 6;
10
+ readonly dirty: 7;
11
+ readonly not_found: 8;
12
+ readonly hook_failed: 9;
13
+ readonly exists: 10;
14
+ readonly orphaned: 11;
15
+ readonly merge_failed: 12;
16
+ readonly already_removed: 13;
17
+ readonly timeout: 14;
18
+ readonly blocked: 16;
19
+ };
20
+ export type Reason = keyof typeof EXIT;
21
+ /**
22
+ * A refusal, carrying the reason to branch on, a message to show, and any
23
+ * data worth reporting with it. `exits` turns one into output and a status
24
+ * code.
25
+ */
26
+ export declare class Exit extends Error {
27
+ readonly reason: Reason;
28
+ readonly data: Record<string, unknown>;
29
+ constructor(reason: Reason, message: string, data?: Record<string, unknown>);
30
+ }
31
+ /**
32
+ * How a command refuses. Every call site means "and go no further", which is
33
+ * what the `never` return buys: the code below a `fail` is unreachable, and
34
+ * TypeScript narrows accordingly.
35
+ */
36
+ export declare function fail(reason: Reason, message: string, data?: Record<string, unknown>): never;
37
+ /**
38
+ * Decides what a refusal looks like (a machine-readable reason on stdout, a
39
+ * human explanation on stderr) and is the only place that ends the process.
40
+ * An agent branches on the first and reads the second.
41
+ */
42
+ export declare function exits<C extends Deps>(): Middleware<C>;
package/git.d.ts ADDED
@@ -0,0 +1,77 @@
1
+ import { type Fs, type Ps } from "webappwiz/system";
2
+ export interface GitResult {
3
+ code: number;
4
+ stdout: string;
5
+ stderr: string;
6
+ }
7
+ /**
8
+ * Every git call arbor makes, scoped to one repository. Agents are not allowed
9
+ * to run these themselves, since going through arbor is what makes concurrent
10
+ * work safe, so this is the only place git is spoken.
11
+ */
12
+ /** What a `Git` works through; the real ones by default. */
13
+ export interface GitOptions {
14
+ ps?: Ps;
15
+ fs?: Fs;
16
+ }
17
+ export declare class Git {
18
+ /** The main worktree, where trunk lives. */
19
+ readonly root: string;
20
+ private readonly ps;
21
+ private readonly fs;
22
+ constructor(
23
+ /** The main worktree, where trunk lives. */
24
+ root: string, opts?: GitOptions);
25
+ run(cwd: string, ...args: string[]): Promise<GitResult>;
26
+ out(cwd: string, ...args: string[]): Promise<string>;
27
+ branchExists(branch: string): Promise<boolean>;
28
+ /**
29
+ * The branch `origin/HEAD` points at, or null when the repo has no such ref:
30
+ * no remote, or a clone that never fetched it.
31
+ */
32
+ defaultBranch(): Promise<string | null>;
33
+ currentBranch(cwd: string): Promise<string>;
34
+ head(cwd: string): Promise<string>;
35
+ shortHead(cwd: string): Promise<string>;
36
+ porcelain(cwd: string): Promise<string[]>;
37
+ conflictedPaths(cwd: string): Promise<string[]>;
38
+ commitsAhead(trunk: string, branch: string): Promise<number | null>;
39
+ /** Lines added and removed on `branch` since it left `trunk`. */
40
+ diffStat(trunk: string, branch: string): Promise<{
41
+ added: number;
42
+ removed: number;
43
+ } | null>;
44
+ /**
45
+ * Every path `branch` touches since it left `trunk`, plus what is still
46
+ * uncommitted in `worktree` when there is one: an agent mid-task has usually
47
+ * committed nothing yet, and its edits are the overlap that matters most.
48
+ */
49
+ changedFiles(trunk: string, branch: string, worktree: string | null): Promise<string[] | null>;
50
+ /**
51
+ * Every path a person might point an agent at in the tree at `cwd`: the
52
+ * files git tracks, the new ones it does not ignore, and each directory
53
+ * above them, which ends in `/`. Sorted, relative to the tree's root.
54
+ */
55
+ paths(cwd: string): Promise<string[]>;
56
+ rebase(cwd: string, onto: string): Promise<GitResult>;
57
+ resetHard(cwd: string, commit: string): Promise<GitResult>;
58
+ checkout(branch: string): Promise<GitResult>;
59
+ mergeFfOnly(cwd: string, branch: string): Promise<GitResult>;
60
+ /**
61
+ * The worktree with `branch` checked out, or null when no worktree has it.
62
+ * Git allows one worktree per branch and that is the only place the branch
63
+ * can be advanced, so this is where a fast-forward has to happen.
64
+ */
65
+ worktreeFor(branch: string): Promise<string | null>;
66
+ addWorktree(branch: string, path: string, from: string): Promise<GitResult>;
67
+ removeWorktree(path: string): Promise<GitResult>;
68
+ /** Drops metadata for worktrees whose directories are gone. */
69
+ pruneWorktrees(): Promise<GitResult>;
70
+ deleteBranch(branch: string): Promise<GitResult>;
71
+ /** The one `.git` every worktree of this repo shares. */
72
+ commonDir(): Promise<string>;
73
+ /** The git directory belonging to a worktree, or null if it has none. */
74
+ worktreeGitDir(worktree: string): Promise<string | null>;
75
+ /** Half-finished merges and rebases a resuming agent is standing in. */
76
+ interruptedOps(worktree: string): Promise<string[]>;
77
+ }
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};