@bevel-software/platform-shared 0.1.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/LICENSE +202 -0
- package/dist/auth/types.d.ts +15 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/chat/types.d.ts +39 -0
- package/dist/chat/types.d.ts.map +1 -0
- package/dist/chat/types.js +13 -0
- package/dist/chat/types.js.map +1 -0
- package/dist/git/branchAuthor.d.ts +28 -0
- package/dist/git/branchAuthor.d.ts.map +1 -0
- package/dist/git/branchAuthor.js +45 -0
- package/dist/git/branchAuthor.js.map +1 -0
- package/dist/git/pr.types.d.ts +264 -0
- package/dist/git/pr.types.d.ts.map +1 -0
- package/dist/git/pr.types.js +2 -0
- package/dist/git/pr.types.js.map +1 -0
- package/dist/git/protected.d.ts +52 -0
- package/dist/git/protected.d.ts.map +1 -0
- package/dist/git/protected.js +92 -0
- package/dist/git/protected.js.map +1 -0
- package/dist/git/review.types.d.ts +49 -0
- package/dist/git/review.types.d.ts.map +1 -0
- package/dist/git/review.types.js +2 -0
- package/dist/git/review.types.js.map +1 -0
- package/dist/git/types.d.ts +107 -0
- package/dist/git/types.d.ts.map +1 -0
- package/dist/git/types.js +2 -0
- package/dist/git/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/workflow/events.d.ts +218 -0
- package/dist/workflow/events.d.ts.map +1 -0
- package/dist/workflow/events.js +48 -0
- package/dist/workflow/events.js.map +1 -0
- package/dist/workflow/interface.d.ts +233 -0
- package/dist/workflow/interface.d.ts.map +1 -0
- package/dist/workflow/interface.js +20 -0
- package/dist/workflow/interface.js.map +1 -0
- package/dist/workflow/types.d.ts +131 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/types.js +17 -0
- package/dist/workflow/types.js.map +1 -0
- package/dist/workspace/filename.d.ts +33 -0
- package/dist/workspace/filename.d.ts.map +1 -0
- package/dist/workspace/filename.js +98 -0
- package/dist/workspace/filename.js.map +1 -0
- package/dist/workspace/frontmatter.d.ts +23 -0
- package/dist/workspace/frontmatter.d.ts.map +1 -0
- package/dist/workspace/frontmatter.js +48 -0
- package/dist/workspace/frontmatter.js.map +1 -0
- package/dist/workspace/kb-layout.d.ts +66 -0
- package/dist/workspace/kb-layout.d.ts.map +1 -0
- package/dist/workspace/kb-layout.js +63 -0
- package/dist/workspace/kb-layout.js.map +1 -0
- package/dist/workspace/types.d.ts +57 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/dist/workspace/types.js +2 -0
- package/dist/workspace/types.js.map +1 -0
- package/package.json +41 -0
- package/src/auth/types.ts +16 -0
- package/src/chat/types.ts +53 -0
- package/src/git/branchAuthor.ts +46 -0
- package/src/git/pr.types.ts +274 -0
- package/src/git/protected.ts +121 -0
- package/src/git/review.types.ts +51 -0
- package/src/git/types.ts +170 -0
- package/src/index.ts +23 -0
- package/src/workflow/events.ts +271 -0
- package/src/workflow/interface.ts +357 -0
- package/src/workflow/types.ts +156 -0
- package/src/workspace/filename.ts +102 -0
- package/src/workspace/frontmatter.ts +45 -0
- package/src/workspace/kb-layout.ts +81 -0
- package/src/workspace/types.ts +59 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative, env-overridable registry of the default branch + the set of
|
|
3
|
+
* protected branch slugs in the KB repo, plus their user-visible display names.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for BOTH sides of the app:
|
|
6
|
+
* - Backend (Node) reads `process.env.*` at runtime — the values are populated
|
|
7
|
+
* from the environment / the `.env` loaded by `config.ts`, which runs before
|
|
8
|
+
* this module is first evaluated (see `backend/src/index.ts` import order).
|
|
9
|
+
* - Frontend (browser) can't read `process.env` at runtime, so Vite statically
|
|
10
|
+
* replaces the `process.env.DEFAULT_BRANCH` / `process.env.PROTECTED_BRANCHES`
|
|
11
|
+
* references at build time via `define` in `frontend/vite.config.ts`. Keep
|
|
12
|
+
* those references written as the literal `process.env.<NAME>` member access
|
|
13
|
+
* so the static replacement keeps matching.
|
|
14
|
+
*
|
|
15
|
+
* Both the backend (server-side enforcement — refusing commit/push/revert and
|
|
16
|
+
* rejecting `createBranch` on protected names) and the frontend (disabling UI
|
|
17
|
+
* actions, showing the protected-branch banner, branch sort order) consume this
|
|
18
|
+
* single table so the two can never drift. Don't re-declare or hard-code the
|
|
19
|
+
* names elsewhere.
|
|
20
|
+
*
|
|
21
|
+
* Env vars (both REQUIRED — no fallback; the module throws at load if either is
|
|
22
|
+
* missing/empty, so a misconfigured deploy fails fast instead of silently
|
|
23
|
+
* defaulting to the wrong branches). Note the frontend needs them present at
|
|
24
|
+
* BUILD time (Vite `define`), the backend at runtime:
|
|
25
|
+
* - `DEFAULT_BRANCH` — the branch a user lands on / the default propose
|
|
26
|
+
* target.
|
|
27
|
+
* - `PROTECTED_BRANCHES` — comma/space-separated list of protected slugs.
|
|
28
|
+
* Display names are auto-derived from each slug
|
|
29
|
+
* (`target-company-state` → "Target company state").
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* The branch a logged-in user lands on when they don't explicitly pick one, and
|
|
33
|
+
* the default destination for shared drafts. Env-overridable via `DEFAULT_BRANCH`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_BRANCH: string;
|
|
36
|
+
export declare const PROTECTED_BRANCH_DISPLAY_NAMES: Readonly<Record<string, string>>;
|
|
37
|
+
export declare const PROTECTED_BRANCHES: ReadonlySet<string>;
|
|
38
|
+
export declare function isProtectedBranch(name: string | null | undefined): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Capitalised, human-readable name for a protected branch — e.g.
|
|
41
|
+
* `current-company-state` → "Current company state".
|
|
42
|
+
*
|
|
43
|
+
* Use this everywhere the branch name appears in user-visible body copy
|
|
44
|
+
* (banners, tooltips, button labels). The raw kebab slug is fine in small
|
|
45
|
+
* monospace badges for power users / debug surfaces, but body copy should
|
|
46
|
+
* never read "merge into current-company-state" to a non-developer.
|
|
47
|
+
*
|
|
48
|
+
* Returns `null` for unknown / non-protected names so the caller can decide
|
|
49
|
+
* whether to fall back to the raw string or hide the affordance.
|
|
50
|
+
*/
|
|
51
|
+
export declare function protectedBranchDisplayName(name: string | null | undefined): string | null;
|
|
52
|
+
//# sourceMappingURL=protected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected.d.ts","sourceRoot":"","sources":["../../src/git/protected.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA4BH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAkD,CAAC;AA0BhF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKzE,CAAC;AAEJ,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAkC,CAAC;AAEtF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAK1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC9B,MAAM,GAAG,IAAI,CAGf"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative, env-overridable registry of the default branch + the set of
|
|
3
|
+
* protected branch slugs in the KB repo, plus their user-visible display names.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for BOTH sides of the app:
|
|
6
|
+
* - Backend (Node) reads `process.env.*` at runtime — the values are populated
|
|
7
|
+
* from the environment / the `.env` loaded by `config.ts`, which runs before
|
|
8
|
+
* this module is first evaluated (see `backend/src/index.ts` import order).
|
|
9
|
+
* - Frontend (browser) can't read `process.env` at runtime, so Vite statically
|
|
10
|
+
* replaces the `process.env.DEFAULT_BRANCH` / `process.env.PROTECTED_BRANCHES`
|
|
11
|
+
* references at build time via `define` in `frontend/vite.config.ts`. Keep
|
|
12
|
+
* those references written as the literal `process.env.<NAME>` member access
|
|
13
|
+
* so the static replacement keeps matching.
|
|
14
|
+
*
|
|
15
|
+
* Both the backend (server-side enforcement — refusing commit/push/revert and
|
|
16
|
+
* rejecting `createBranch` on protected names) and the frontend (disabling UI
|
|
17
|
+
* actions, showing the protected-branch banner, branch sort order) consume this
|
|
18
|
+
* single table so the two can never drift. Don't re-declare or hard-code the
|
|
19
|
+
* names elsewhere.
|
|
20
|
+
*
|
|
21
|
+
* Env vars (both REQUIRED — no fallback; the module throws at load if either is
|
|
22
|
+
* missing/empty, so a misconfigured deploy fails fast instead of silently
|
|
23
|
+
* defaulting to the wrong branches). Note the frontend needs them present at
|
|
24
|
+
* BUILD time (Vite `define`), the backend at runtime:
|
|
25
|
+
* - `DEFAULT_BRANCH` — the branch a user lands on / the default propose
|
|
26
|
+
* target.
|
|
27
|
+
* - `PROTECTED_BRANCHES` — comma/space-separated list of protected slugs.
|
|
28
|
+
* Display names are auto-derived from each slug
|
|
29
|
+
* (`target-company-state` → "Target company state").
|
|
30
|
+
*/
|
|
31
|
+
function parseBranchList(raw) {
|
|
32
|
+
return (raw ?? '')
|
|
33
|
+
.split(/[\s,]+/)
|
|
34
|
+
.map((s) => s.trim())
|
|
35
|
+
.filter((s) => s.length > 0);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Human-readable name derived from a kebab/snake slug: lowercase words joined by
|
|
39
|
+
* spaces with only the first letter capitalised — e.g. `target-company-state` →
|
|
40
|
+
* "Target company state". Matches the historical hand-written display names.
|
|
41
|
+
*/
|
|
42
|
+
function deriveDisplayName(slug) {
|
|
43
|
+
const spaced = slug.replace(/[-_]+/g, ' ').trim();
|
|
44
|
+
if (!spaced)
|
|
45
|
+
return slug;
|
|
46
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The branch a logged-in user lands on when they don't explicitly pick one, and
|
|
50
|
+
* the default destination for shared drafts. Env-overridable via `DEFAULT_BRANCH`.
|
|
51
|
+
*/
|
|
52
|
+
export const DEFAULT_BRANCH = (process.env.DEFAULT_BRANCH ?? '').trim();
|
|
53
|
+
if (!DEFAULT_BRANCH) {
|
|
54
|
+
throw new Error('DEFAULT_BRANCH env var is required (no fallback). Set it on the backend ' +
|
|
55
|
+
'runtime and at the frontend build (Vite reads it via define).');
|
|
56
|
+
}
|
|
57
|
+
const PROTECTED_BRANCH_LIST = parseBranchList(process.env.PROTECTED_BRANCHES);
|
|
58
|
+
if (PROTECTED_BRANCH_LIST.length === 0) {
|
|
59
|
+
throw new Error('PROTECTED_BRANCHES env var is required (no fallback). Provide a ' +
|
|
60
|
+
'comma/space-separated list of protected branch slugs.');
|
|
61
|
+
}
|
|
62
|
+
// The default branch is where users land and the default propose target — it
|
|
63
|
+
// must itself be protected, or `isProtectedBranch(DEFAULT_BRANCH)` is false and
|
|
64
|
+
// the protected-branch guards silently don't apply to it. Fail fast on a
|
|
65
|
+
// misconfigured pair rather than shipping that inconsistency.
|
|
66
|
+
if (!PROTECTED_BRANCH_LIST.includes(DEFAULT_BRANCH)) {
|
|
67
|
+
throw new Error(`DEFAULT_BRANCH ("${DEFAULT_BRANCH}") must be one of PROTECTED_BRANCHES ` +
|
|
68
|
+
`(${PROTECTED_BRANCH_LIST.join(', ')}).`);
|
|
69
|
+
}
|
|
70
|
+
export const PROTECTED_BRANCH_DISPLAY_NAMES = Object.freeze(Object.fromEntries(PROTECTED_BRANCH_LIST.map((slug) => [slug, deriveDisplayName(slug)])));
|
|
71
|
+
export const PROTECTED_BRANCHES = new Set(PROTECTED_BRANCH_LIST);
|
|
72
|
+
export function isProtectedBranch(name) {
|
|
73
|
+
return !!name && Object.prototype.hasOwnProperty.call(PROTECTED_BRANCH_DISPLAY_NAMES, name);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Capitalised, human-readable name for a protected branch — e.g.
|
|
77
|
+
* `current-company-state` → "Current company state".
|
|
78
|
+
*
|
|
79
|
+
* Use this everywhere the branch name appears in user-visible body copy
|
|
80
|
+
* (banners, tooltips, button labels). The raw kebab slug is fine in small
|
|
81
|
+
* monospace badges for power users / debug surfaces, but body copy should
|
|
82
|
+
* never read "merge into current-company-state" to a non-developer.
|
|
83
|
+
*
|
|
84
|
+
* Returns `null` for unknown / non-protected names so the caller can decide
|
|
85
|
+
* whether to fall back to the raw string or hide the affordance.
|
|
86
|
+
*/
|
|
87
|
+
export function protectedBranchDisplayName(name) {
|
|
88
|
+
if (!name)
|
|
89
|
+
return null;
|
|
90
|
+
return PROTECTED_BRANCH_DISPLAY_NAMES[name] ?? null;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=protected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected.js","sourceRoot":"","sources":["../../src/git/protected.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAUH,SAAS,eAAe,CAAC,GAAuB;IAC9C,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;SACf,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC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CACL,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAA+B;IAE/B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,8BAA8B,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type ChangeKind = 'added' | 'modified' | 'deleted' | 'renamed';
|
|
2
|
+
/**
|
|
3
|
+
* A single pending change — the diff between the on-disk backup ledger
|
|
4
|
+
* (the user's last-confirmed state) and the current working tree for one path.
|
|
5
|
+
*/
|
|
6
|
+
export interface PendingChange {
|
|
7
|
+
/** Current path (for added/modified/renamed) or original path (for deleted). */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Populated only when kind === 'renamed' — the pre-rename path. */
|
|
10
|
+
oldPath?: string;
|
|
11
|
+
kind: ChangeKind;
|
|
12
|
+
isBinary: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Line counts from an LCS diff. Null in two cases:
|
|
15
|
+
* - the file is binary (no line concept), or
|
|
16
|
+
* - the text diff exceeds the backend's LCS cap and exact counts were
|
|
17
|
+
* skipped to avoid OOM. Consumers should treat null as "not computed".
|
|
18
|
+
*/
|
|
19
|
+
linesAdded: number | null;
|
|
20
|
+
linesRemoved: number | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Pending-changes envelope returned by the review API. Backed by the
|
|
24
|
+
* on-disk backup ledger (a sibling-to-workspaces folder containing each
|
|
25
|
+
* diffable file's last-confirmed contents). `baselineRef` is retained for
|
|
26
|
+
* wire-shape compatibility but is empty under the backup-folder model;
|
|
27
|
+
* the frontend reads `changes` and `branchName` only.
|
|
28
|
+
*/
|
|
29
|
+
export interface ReviewSession {
|
|
30
|
+
branchName: string;
|
|
31
|
+
/** Always empty in the backup-folder model — kept for wire compatibility. */
|
|
32
|
+
baselineRef: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
changes: PendingChange[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Full before/after content for one path in an active session. The UI renders
|
|
38
|
+
* this through a line-level LCS diff.
|
|
39
|
+
*/
|
|
40
|
+
export interface FileDiffPayload {
|
|
41
|
+
path: string;
|
|
42
|
+
kind: ChangeKind;
|
|
43
|
+
/** Content at the baseline. Null for `added` or binary files. */
|
|
44
|
+
baseline: string | null;
|
|
45
|
+
/** Current working-tree content. Null for `deleted` or binary files. */
|
|
46
|
+
current: string | null;
|
|
47
|
+
isBinary: boolean;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=review.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.types.d.ts","sourceRoot":"","sources":["../../src/git/review.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wEAAwE;IACxE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.types.js","sourceRoot":"","sources":["../../src/git/review.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { AuthUser } from '../auth/types.js';
|
|
2
|
+
export interface BranchInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
isProtected: boolean;
|
|
5
|
+
ahead: number | null;
|
|
6
|
+
behind: number | null;
|
|
7
|
+
/**
|
|
8
|
+
* True iff `refs/remotes/origin/<name>` exists after the last `fetch --prune`.
|
|
9
|
+
* False means the branch is local-only — either never pushed, or its remote
|
|
10
|
+
* counterpart was deleted (typically after a PR merged + branch cleanup on
|
|
11
|
+
* GitHub). The UI uses this to offer a "delete local branch" affordance.
|
|
12
|
+
*/
|
|
13
|
+
hasRemote: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-workspace branch sync state. Slimmed down from the legacy
|
|
17
|
+
* "one workspace, many branches via checkout" model: fields like `isDirty`,
|
|
18
|
+
* `unpushedCommits`, and `conflicted` are gone because save=share guarantees
|
|
19
|
+
* the working tree is never dirty, there are no committed-but-unpushed
|
|
20
|
+
* commits, and conflicts are resolved before lock release. What's left is
|
|
21
|
+
* the upstream-sync signal that drives the auto-update flow + the branch
|
|
22
|
+
* name (kept as a server-side cross-check against the URL-derived branch).
|
|
23
|
+
*/
|
|
24
|
+
export interface WorkingTreeStatus {
|
|
25
|
+
branch: string;
|
|
26
|
+
hasUpstream: boolean;
|
|
27
|
+
unmergedFromUpstream: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface CommitAttribution {
|
|
30
|
+
authorName: string;
|
|
31
|
+
authorEmail: string;
|
|
32
|
+
sha: string;
|
|
33
|
+
subject: string;
|
|
34
|
+
committedAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ShareChangesRequest {
|
|
37
|
+
summary: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ValidationReport {
|
|
41
|
+
ok: boolean;
|
|
42
|
+
mustFix: string[];
|
|
43
|
+
warnings: string[];
|
|
44
|
+
rawOutput: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IGitService {
|
|
47
|
+
status(workspaceId: string): Promise<WorkingTreeStatus>;
|
|
48
|
+
listBranches(workspaceId: string, opts?: {
|
|
49
|
+
freshFetch?: boolean;
|
|
50
|
+
}): Promise<BranchInfo[]>;
|
|
51
|
+
createBranch(workspaceId: string, name: string, fromBase?: string): Promise<BranchInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* Delete a branch. Removes the local ref (if present) AND the origin ref
|
|
54
|
+
* (if present); both sides go in one call so the picker's "discard draft"
|
|
55
|
+
* affordance leaves no orphan behind.
|
|
56
|
+
*
|
|
57
|
+
* Authorisation: the branch's author OR an admin can delete it. Authorship
|
|
58
|
+
* is inferred from the `<email-localpart>/...` naming convention — see
|
|
59
|
+
* `isBranchAuthoredBy`. Admins (per the workspace's `roles.yaml`) can
|
|
60
|
+
* additionally remove unprefixed CLI-created branches that have no
|
|
61
|
+
* recognisable author.
|
|
62
|
+
*
|
|
63
|
+
* `onlyIfNoRemote: true` is the legacy orphan-cleanup path used after a
|
|
64
|
+
* PR merge prunes the remote head: it BYPASSES the author/admin check
|
|
65
|
+
* (callers prune any orphan they encounter) and REFUSES if origin still
|
|
66
|
+
* has the ref (the safety property the flag has always provided).
|
|
67
|
+
* Protected branches and the currently-checked-out branch are always
|
|
68
|
+
* rejected.
|
|
69
|
+
*/
|
|
70
|
+
deleteBranch(workspaceId: string, name: string, user: AuthUser, opts?: {
|
|
71
|
+
onlyIfNoRemote?: boolean;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
commit(workspaceId: string, user: AuthUser, req: ShareChangesRequest): Promise<CommitAttribution>;
|
|
74
|
+
push(workspaceId: string, user: AuthUser): Promise<void>;
|
|
75
|
+
fetch(workspaceId: string): Promise<void>;
|
|
76
|
+
pull(workspaceId: string): Promise<void>;
|
|
77
|
+
diffStat(workspaceId: string, base?: string): Promise<string[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Paths in the working tree that the next commit would include — the set
|
|
80
|
+
* `git add -A` would stage: modified + deleted + renamed + untracked files
|
|
81
|
+
* (honouring `.gitignore`). Use this for share-dialog previews; for the
|
|
82
|
+
* committed delta vs a base ref (e.g. PR owner lookup), use `diffStat`.
|
|
83
|
+
*/
|
|
84
|
+
pendingChanges(workspaceId: string): Promise<string[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Best-fit protected branch a feature branch was forked from, resolved by
|
|
87
|
+
* picking whichever protected branch on origin yields the smallest "ahead"
|
|
88
|
+
* count. Returns null if no protected branch can be reached.
|
|
89
|
+
*/
|
|
90
|
+
resolveForkBase(workspaceId: string, branch: string): Promise<string | null>;
|
|
91
|
+
revertCommit(workspaceId: string, user: AuthUser, sha: string): Promise<CommitAttribution>;
|
|
92
|
+
logForFile(workspaceId: string, relativePath: string, limit?: number): Promise<CommitAttribution[]>;
|
|
93
|
+
diffFileAtCommit(workspaceId: string, relativePath: string, sha: string): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Unified diff of a single file between two branches. Both names must
|
|
96
|
+
* resolve to a known branch on this workspace (local head or
|
|
97
|
+
* `refs/remotes/origin/<name>`); arbitrary refspecs and SHAs are
|
|
98
|
+
* rejected upstream. Returns the raw `git diff` output — empty string
|
|
99
|
+
* when the file is identical on both sides, a unified-diff body
|
|
100
|
+
* otherwise (including the "new file mode" / "deleted file mode"
|
|
101
|
+
* headers when the file only exists on one side).
|
|
102
|
+
*
|
|
103
|
+
* Read-only: nothing is checked out, fetched, or written.
|
|
104
|
+
*/
|
|
105
|
+
diffFileBetweenBranches(workspaceId: string, relativePath: string, fromBranch: string, toBranch: string): Promise<string>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=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AC,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAChC,gBAAgB,CACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB;;;;;;;;;;OAUG;IACH,uBAAuB,CACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAAC;CAMpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/git/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './auth/types.js';
|
|
2
|
+
export * from './chat/types.js';
|
|
3
|
+
export * from './workspace/types.js';
|
|
4
|
+
export * from './workspace/filename.js';
|
|
5
|
+
export * from './workspace/kb-layout.js';
|
|
6
|
+
export * from './workspace/frontmatter.js';
|
|
7
|
+
export * from './git/types.js';
|
|
8
|
+
export * from './git/pr.types.js';
|
|
9
|
+
export * from './git/protected.js';
|
|
10
|
+
export * from './git/branchAuthor.js';
|
|
11
|
+
export * from './git/review.types.js';
|
|
12
|
+
export * from './workflow/types.js';
|
|
13
|
+
export * from './workflow/interface.js';
|
|
14
|
+
export * from './workflow/events.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAGhC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Auth
|
|
2
|
+
export * from './auth/types.js';
|
|
3
|
+
// Chat
|
|
4
|
+
export * from './chat/types.js';
|
|
5
|
+
// Workspace
|
|
6
|
+
export * from './workspace/types.js';
|
|
7
|
+
export * from './workspace/filename.js';
|
|
8
|
+
export * from './workspace/kb-layout.js';
|
|
9
|
+
export * from './workspace/frontmatter.js';
|
|
10
|
+
// Git
|
|
11
|
+
export * from './git/types.js';
|
|
12
|
+
export * from './git/pr.types.js';
|
|
13
|
+
export * from './git/protected.js';
|
|
14
|
+
export * from './git/branchAuthor.js';
|
|
15
|
+
export * from './git/review.types.js';
|
|
16
|
+
// Workflow — abstraction layer over git/PR/review-workflow. See PLAN.md.
|
|
17
|
+
export * from './workflow/types.js';
|
|
18
|
+
export * from './workflow/interface.js';
|
|
19
|
+
export * from './workflow/events.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,cAAc,iBAAiB,CAAC;AAEhC,OAAO;AACP,cAAc,iBAAiB,CAAC;AAEhC,YAAY;AACZ,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAE3C,MAAM;AACN,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,yEAAyE;AACzE,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow event bus types — what the backend pushes over SSE to keep the
|
|
3
|
+
* frontend in sync with state changes, including those triggered by other
|
|
4
|
+
* users on the same branch or by the agent acting server-side.
|
|
5
|
+
*
|
|
6
|
+
* **Scope model** — events have one of three scopes, set by the variant:
|
|
7
|
+
*
|
|
8
|
+
* - **Workspace-scoped** (`workspaceId` field). Pushed to every connected
|
|
9
|
+
* session whose current focus is `workspaceId`. Examples: a file changed
|
|
10
|
+
* on this branch, someone took the lock on a file. Anyone editing this
|
|
11
|
+
* branch cares.
|
|
12
|
+
*
|
|
13
|
+
* - **User-scoped** (`forUserId` field, no `workspaceId`). Pushed only to
|
|
14
|
+
* sessions opened by `forUserId`, regardless of their current focus.
|
|
15
|
+
* Examples: an agent turn called a tool on your behalf, your view should
|
|
16
|
+
* navigate to a different branch. Other users on the same branch don't
|
|
17
|
+
* care.
|
|
18
|
+
*
|
|
19
|
+
* - **Global** (no `workspaceId`, no `forUserId`). Pushed to every
|
|
20
|
+
* authenticated session. Examples: change requests opening / merging /
|
|
21
|
+
* being rejected — any user with access to the repo might care.
|
|
22
|
+
*
|
|
23
|
+
* **Identity + replay** — every event carries an `id` (monotonic int) and an
|
|
24
|
+
* ISO `ts`. Clients reconnecting with `Last-Event-ID: <id>` get the buffered
|
|
25
|
+
* tail replayed (server's ring buffer is finite — see `WorkflowEventBus`).
|
|
26
|
+
* If `id` is older than what the buffer still has, the server sends a
|
|
27
|
+
* `{ kind: 'resync' }` instead so the client refetches the world cleanly.
|
|
28
|
+
*
|
|
29
|
+
* **Idempotency over exactly-once** — clients tolerate duplicates and
|
|
30
|
+
* out-of-order delivery: every payload carries enough state for the UI to
|
|
31
|
+
* reach the right end state regardless of how many times it sees the event
|
|
32
|
+
* (e.g. `file-changed` includes the new SHA — UI only refreshes if the open
|
|
33
|
+
* tab's SHA differs).
|
|
34
|
+
*/
|
|
35
|
+
export interface WorkflowEventEnvelope {
|
|
36
|
+
/** Monotonic, process-local. Used for `Last-Event-ID` replay. */
|
|
37
|
+
id: number;
|
|
38
|
+
/** ISO timestamp the event was emitted on the backend. */
|
|
39
|
+
ts: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A file's content changed on disk — fires for ANY write that lands bytes
|
|
43
|
+
* for `(workspaceId, branch, path)`, whether or not a commit followed.
|
|
44
|
+
*
|
|
45
|
+
* - **`newSha` set** → a commit landed. The disk write came through the
|
|
46
|
+
* full lock-release pipeline (acquire → write → commitFile → push).
|
|
47
|
+
* History views should refetch.
|
|
48
|
+
*
|
|
49
|
+
* - **`newSha === null`** → disk bytes changed but no commit yet, i.e.
|
|
50
|
+
* the writer is mid-edit (lock still held — e.g. the editor's Ctrl+S
|
|
51
|
+
* autosave-to-disk before the final Save click). Watchers should
|
|
52
|
+
* refetch content but NOT history (nothing new in git log).
|
|
53
|
+
*
|
|
54
|
+
* Emitted from both the human PUT/PATCH/DELETE routes and the agent's
|
|
55
|
+
* LockingFilesystem so anyone tailing the file sees changes immediately.
|
|
56
|
+
*/
|
|
57
|
+
export interface FileChangedEvent {
|
|
58
|
+
kind: 'file-changed';
|
|
59
|
+
workspaceId: string;
|
|
60
|
+
branch: string;
|
|
61
|
+
path: string;
|
|
62
|
+
/** Commit sha if a commit landed; null if this was a disk-only write. */
|
|
63
|
+
newSha: string | null;
|
|
64
|
+
/** The user whose write caused the change. */
|
|
65
|
+
byUserId: string;
|
|
66
|
+
byUserName: string;
|
|
67
|
+
}
|
|
68
|
+
/** Someone (`holderUserId`) just acquired the lock on `(branch, path)`. */
|
|
69
|
+
export interface LockAcquiredEvent {
|
|
70
|
+
kind: 'lock-acquired';
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
branch: string;
|
|
73
|
+
path: string;
|
|
74
|
+
holderUserId: string;
|
|
75
|
+
holderName: string;
|
|
76
|
+
}
|
|
77
|
+
/** The lock on `(branch, path)` was released — file is free for the next caller. */
|
|
78
|
+
export interface LockReleasedEvent {
|
|
79
|
+
kind: 'lock-released';
|
|
80
|
+
workspaceId: string;
|
|
81
|
+
branch: string;
|
|
82
|
+
path: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The file tree for `(workspaceId, branch)` changed in a way that's not
|
|
86
|
+
* captured by a single `file-changed` event — typically a recursive delete,
|
|
87
|
+
* a move, or an unzip extracting many files. Emitted alongside per-file
|
|
88
|
+
* `file-changed` events, but lets the file explorer refresh once instead of
|
|
89
|
+
* N times.
|
|
90
|
+
*/
|
|
91
|
+
export interface FsTreeChangedEvent {
|
|
92
|
+
kind: 'fs-tree-changed';
|
|
93
|
+
workspaceId: string;
|
|
94
|
+
branch: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Agent called `switch_branch` mid-turn and the target validated +
|
|
98
|
+
* pre-warmed successfully. Tells the frontend to navigate to the new draft
|
|
99
|
+
* once the in-flight chat turn completes — navigation mid-stream would tear
|
|
100
|
+
* down the chat connection. The chat hook stashes the latest pending
|
|
101
|
+
* destination and consumes it in `onFinish`. The native chat path stamps the
|
|
102
|
+
* `threadId`; the registry `switch_branch` tool (called over the internal
|
|
103
|
+
* loopback, which carries no threadId) omits it, so the frontend keys the
|
|
104
|
+
* pending destination on `forUserId` — a user has one active chat stream.
|
|
105
|
+
*
|
|
106
|
+
* User-scoped (no `workspaceId`) — only the user whose agent ran the tool
|
|
107
|
+
* should follow; other users on the same branch don't care.
|
|
108
|
+
*/
|
|
109
|
+
export interface BranchSwitchedEvent {
|
|
110
|
+
kind: 'branch-switched';
|
|
111
|
+
forUserId: string;
|
|
112
|
+
threadId?: string;
|
|
113
|
+
branch: string;
|
|
114
|
+
workspaceId: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Agent (running on `forUserId`'s behalf) is about to call a tool — used by
|
|
118
|
+
* the file explorer to highlight files the agent is touching and by the
|
|
119
|
+
* chat sidebar to show a live activity feed without parsing the chat
|
|
120
|
+
* stream's data parts.
|
|
121
|
+
*
|
|
122
|
+
* Fired BEFORE the tool runs; the resulting `file-changed` /
|
|
123
|
+
* `change-request-opened` / etc. events arrive after.
|
|
124
|
+
*/
|
|
125
|
+
export interface AgentToolCallEvent {
|
|
126
|
+
kind: 'agent-tool-call';
|
|
127
|
+
forUserId: string;
|
|
128
|
+
threadId: string;
|
|
129
|
+
tool: string;
|
|
130
|
+
/**
|
|
131
|
+
* Free-form summary of what the tool is about to do (e.g. `"writing
|
|
132
|
+
* Knowledge/Foo.md"`, `"opening change request Foo → target-company-state"`).
|
|
133
|
+
* Optional — purely informational, never load-bearing.
|
|
134
|
+
*/
|
|
135
|
+
summary?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface ChangeRequestOpenedEvent {
|
|
138
|
+
kind: 'change-request-opened';
|
|
139
|
+
number: number;
|
|
140
|
+
source: string;
|
|
141
|
+
target: string;
|
|
142
|
+
/** Hash of the author's email (matches the marker in the CR body); null when unattributable. */
|
|
143
|
+
authorIdHash: string | null;
|
|
144
|
+
title: string;
|
|
145
|
+
}
|
|
146
|
+
export interface ChangeRequestMergedEvent {
|
|
147
|
+
kind: 'change-request-merged';
|
|
148
|
+
number: number;
|
|
149
|
+
}
|
|
150
|
+
export interface ChangeRequestRejectedEvent {
|
|
151
|
+
kind: 'change-request-rejected';
|
|
152
|
+
number: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A merge the caller triggered did NOT land — either the gate refused it, the
|
|
156
|
+
* branch needs conflict resolution, or `gh pr merge` failed. The merge route
|
|
157
|
+
* is async (returns 202 immediately so a large PR's merge can't outlive the
|
|
158
|
+
* gateway timeout), so this is how the failure reaches the UI that kicked it
|
|
159
|
+
* off. Success travels on `change-request-merged` instead.
|
|
160
|
+
*
|
|
161
|
+
* User-scoped (`forUserId`, no `workspaceId`) — a failed merge changes no
|
|
162
|
+
* shared state; only the user who clicked needs the reason, so we don't
|
|
163
|
+
* broadcast the error string to every session.
|
|
164
|
+
*/
|
|
165
|
+
export interface ChangeRequestMergeFailedEvent {
|
|
166
|
+
kind: 'change-request-merge-failed';
|
|
167
|
+
forUserId: string;
|
|
168
|
+
number: number;
|
|
169
|
+
/** Human-readable reason for the error banner (tokens already redacted). */
|
|
170
|
+
reason: string;
|
|
171
|
+
/**
|
|
172
|
+
* True when the merge failed because the branch needs conflict resolution.
|
|
173
|
+
* The UI routes to the agent resolution flow instead of showing an error.
|
|
174
|
+
*/
|
|
175
|
+
conflicts: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Per-file approval on a change request was added or removed (e.g. via the
|
|
179
|
+
* Approve / Withdraw confirmation buttons, or auto-invalidated by a new
|
|
180
|
+
* commit). The UI re-fetches the CR detail to get the updated approval set.
|
|
181
|
+
*/
|
|
182
|
+
export interface ApprovalChangedEvent {
|
|
183
|
+
kind: 'approval-changed';
|
|
184
|
+
number: number;
|
|
185
|
+
path: string;
|
|
186
|
+
approverUserId: string;
|
|
187
|
+
change: 'added' | 'removed';
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sent every ~25 s on the SSE stream to keep proxies / load balancers from
|
|
191
|
+
* killing idle connections. Carries no payload state — the client ignores it
|
|
192
|
+
* apart from the keepalive effect.
|
|
193
|
+
*/
|
|
194
|
+
export interface HeartbeatEvent {
|
|
195
|
+
kind: 'heartbeat';
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Server told the client to discard its cached state and refetch from
|
|
199
|
+
* scratch — sent when a reconnecting client's `Last-Event-ID` is older than
|
|
200
|
+
* the server's ring buffer still has, so we can't trust an event replay to
|
|
201
|
+
* catch them up.
|
|
202
|
+
*/
|
|
203
|
+
export interface ResyncEvent {
|
|
204
|
+
kind: 'resync';
|
|
205
|
+
/** Human-readable reason for logs / debugging. */
|
|
206
|
+
reason: string;
|
|
207
|
+
}
|
|
208
|
+
export type WorkflowEventPayload = FileChangedEvent | LockAcquiredEvent | LockReleasedEvent | FsTreeChangedEvent | BranchSwitchedEvent | AgentToolCallEvent | ChangeRequestOpenedEvent | ChangeRequestMergedEvent | ChangeRequestRejectedEvent | ChangeRequestMergeFailedEvent | ApprovalChangedEvent | HeartbeatEvent | ResyncEvent;
|
|
209
|
+
export type WorkflowEvent = WorkflowEventEnvelope & WorkflowEventPayload;
|
|
210
|
+
/** True for events scoped to a workspace — the focus filter applies. */
|
|
211
|
+
export declare function isWorkspaceScoped(e: WorkflowEventPayload): e is WorkflowEventPayload & {
|
|
212
|
+
workspaceId: string;
|
|
213
|
+
};
|
|
214
|
+
/** True for events scoped to a specific user — the user filter applies. */
|
|
215
|
+
export declare function isUserScoped(e: WorkflowEventPayload): e is WorkflowEventPayload & {
|
|
216
|
+
forUserId: string;
|
|
217
|
+
};
|
|
218
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/workflow/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,qBAAqB;IACpC,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;CACZ;AAID;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC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