@jawache/flow 0.2.1 → 0.3.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.
@@ -1,5 +1,6 @@
1
1
  import { type ExecResult, type FlowConfig, type LoadResult, type Grammar, type Settings, type World } from "../language/domain.ts";
2
- import { type CallRecord, type Change, type Delta, type HookEvent, type HookPayload, type HookResult } from "./domain.ts";
2
+ import { type AgentOf } from "../engine/domain.ts";
3
+ import { type CommitScope, type CallRecord, type Change, type Delta, type HookEvent, type HookPayload, type HookResult } from "./domain.ts";
3
4
  /**
4
5
  * Run one command the way a check means it — through a shell, in the repo, hermetically.
5
6
  *
@@ -13,7 +14,7 @@ import { type CallRecord, type Change, type Delta, type HookEvent, type HookPayl
13
14
  * installed refuses the commit instead of passing it. bash answers 127 itself; the only case left
14
15
  * is bash being unspawnable, which is the same fact one level up and is answered the same way.
15
16
  */
16
- export declare function runCommand(command: string, root: string): ExecResult;
17
+ export declare function runCommand(command: string, root: string, env?: Record<string, string | undefined>): ExecResult;
17
18
  /** A file's text, or null when it is not there / not readable. */
18
19
  export declare function readText(root: string, path: string): string | null;
19
20
  /**
@@ -52,14 +53,14 @@ export declare function currentBranch(root: string): string | null;
52
53
  * who is here — and a rule that fires at the gate for a wearer status never showed is the exact
53
54
  * surprise the marker exists to prevent.
54
55
  *
55
- * `agent` is null when the marker is missing, stale or malformed, and then the wearer wears NOTHING
56
- * rather than a guess: there is no transcript and no sidecar out here, so the stored verdict is the
57
- * only truthful answer there can be.
56
+ * `who` is null when the marker is missing, stale or malformed, and then the wearer wears NOTHING
57
+ * rather than a guess: there is no transcript and no hook message out here, so the stored verdict is
58
+ * the only truthful answer there can be.
58
59
  */
59
60
  export declare function wearer(root: string): {
60
61
  readonly branch: string | null;
61
62
  readonly session: string;
62
- readonly agent: string | null;
63
+ readonly who: AgentOf | null;
63
64
  readonly wearing: readonly string[];
64
65
  };
65
66
  /**
@@ -76,7 +77,8 @@ export declare function takeSnapshot(root: string, key: string, include: readonl
76
77
  }): void;
77
78
  /**
78
79
  * WHAT THE CALL CHANGED: the tree now against the tree its snapshot recorded, path by path, with
79
- * the content either side. The before-snapshot is kept — a revert reads from it — until `forget`.
80
+ * the content either side, less each path git put there (see `authored`). The before-snapshot is
81
+ * kept — a revert reads from it — until `forget`.
80
82
  */
81
83
  export declare function observeDelta(root: string, key: string, include: readonly string[]): Delta & {
82
84
  readonly before?: string;
@@ -115,10 +117,10 @@ export declare function projectRoot(cwd: string): string;
115
117
  * once in the host's settings and fire in every repo the agent visits, so a missing config is the
116
118
  * ordinary case and blocking on it would make flow unusable the moment it was installed.
117
119
  *
118
- * `broken` is the opposite fact and gets the opposite answer: a config file that is THERE and will
119
- * not even import is a guard that cannot run, which is what fail-loud exists for. (A config that
120
- * imports and then will not load is the engine's own path — `load.ok === false` — and refuses with
121
- * the same shape from inside `guard`.)
120
+ * `broken` is the opposite fact and must never be silent: a config file that is THERE and will
121
+ * not even import is a guard that cannot run. The hook rail hands it to `whileBroken`, which lets
122
+ * every call through with the load error, and the commit gate refuses. (A config that imports and
123
+ * then will not load — `load.ok === false` — is the same fact and gets the same two answers.)
122
124
  */
123
125
  export type Regime = {
124
126
  readonly kind: "none";
@@ -165,10 +167,10 @@ export declare function runHook(hook: HookEvent, payload: HookPayload, root: str
165
167
  * WHO IT IS comes from the marker the PreToolUse rail left — session AND agent — so a commit's rows
166
168
  * land in the session that caused them and an actor-scoped rule fires at this moment as honestly as
167
169
  * at any other. The classification itself is never re-derived here: there is no transcript and no
168
- * sidecar outside a session, so the STORED verdict is the only truthful answer, and a fresh commit
170
+ * hook message outside a session, so the STORED verdict is the only truthful answer, and a fresh commit
169
171
  * on a stale or absent marker wears nothing rather than wearing a guess.
170
172
  */
171
- export declare function runCommit(root: string, files: readonly string[]): Promise<HookResult>;
173
+ export declare function runCommit(root: string, scope: CommitScope): Promise<HookResult>;
172
174
  /** What came in on stdin: a payload, or which of the two ways reading it failed. */
173
175
  export type PayloadRead = {
174
176
  readonly ok: true;
@@ -206,5 +208,11 @@ export declare function readPayload(): PayloadRead;
206
208
  * is silence rather than a usage message in front of the model.
207
209
  */
208
210
  export declare function hookEntry(event: string, cwd: string): Promise<HookResult>;
209
- /** The git gate, end to end. Paths arrive repo-relative from git; a stray absolute one is folded. */
210
- export declare function commitEntry(files: readonly string[], cwd: string): Promise<HookResult>;
211
+ /**
212
+ * The git gate, end to end — `flow hook commit`, or `flow hook commit --all` for the whole tree.
213
+ *
214
+ * It takes no file list: git is asked. `flow commit <files…>`, the name an older hook still calls,
215
+ * arrives here with `legacy` set and its list is dropped, because git's answer is the only list — a
216
+ * second source of the staged set is two answers that can disagree.
217
+ */
218
+ export declare function commitEntry(args: readonly string[], cwd: string, legacy?: boolean): Promise<HookResult>;