@hexagen-monaco/sync 0.12.1 → 0.14.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 +729 -0
- package/dist/cli.js +7635 -516
- package/dist/cli.js.map +1 -1
- package/dist/commands/arch/edit.d.ts.map +1 -1
- package/dist/commands/contract/evaluate.d.ts +99 -0
- package/dist/commands/contract/evaluate.d.ts.map +1 -0
- package/dist/commands/contract/growth.d.ts +22 -0
- package/dist/commands/contract/growth.d.ts.map +1 -0
- package/dist/commands/contract/index.d.ts +32 -0
- package/dist/commands/contract/index.d.ts.map +1 -0
- package/dist/commands/evidence/check.d.ts +33 -0
- package/dist/commands/evidence/check.d.ts.map +1 -0
- package/dist/commands/evidence/index.d.ts +3 -0
- package/dist/commands/evidence/index.d.ts.map +1 -0
- package/dist/commands/evidence/pack.d.ts +41 -0
- package/dist/commands/evidence/pack.d.ts.map +1 -0
- package/dist/commands/evidence/verify.d.ts +83 -0
- package/dist/commands/evidence/verify.d.ts.map +1 -0
- package/dist/commands/grant/build.d.ts +53 -0
- package/dist/commands/grant/build.d.ts.map +1 -0
- package/dist/commands/grant/canonical.d.ts +27 -0
- package/dist/commands/grant/canonical.d.ts.map +1 -0
- package/dist/commands/grant/check.d.ts +26 -0
- package/dist/commands/grant/check.d.ts.map +1 -0
- package/dist/commands/grant/duration.d.ts +8 -0
- package/dist/commands/grant/duration.d.ts.map +1 -0
- package/dist/commands/grant/index.d.ts +2 -0
- package/dist/commands/grant/index.d.ts.map +1 -0
- package/dist/commands/grant/issue.d.ts +23 -0
- package/dist/commands/grant/issue.d.ts.map +1 -0
- package/dist/commands/grant/key-init.d.ts +16 -0
- package/dist/commands/grant/key-init.d.ts.map +1 -0
- package/dist/commands/grant/list.d.ts +72 -0
- package/dist/commands/grant/list.d.ts.map +1 -0
- package/dist/commands/grant/revoke.d.ts +35 -0
- package/dist/commands/grant/revoke.d.ts.map +1 -0
- package/dist/commands/grant/show.d.ts +18 -0
- package/dist/commands/grant/show.d.ts.map +1 -0
- package/dist/commands/grant/sign.d.ts +3 -0
- package/dist/commands/grant/sign.d.ts.map +1 -0
- package/dist/commands/grant/signing-key.d.ts +22 -0
- package/dist/commands/grant/signing-key.d.ts.map +1 -0
- package/dist/commands/grant/verify.d.ts +51 -0
- package/dist/commands/grant/verify.d.ts.map +1 -0
- package/dist/commands/grant/workspace.d.ts +11 -0
- package/dist/commands/grant/workspace.d.ts.map +1 -0
- package/dist/commands/observe/imports/jsonc.d.ts +6 -0
- package/dist/commands/observe/imports/jsonc.d.ts.map +1 -0
- package/dist/commands/observe/imports/pass.d.ts +45 -0
- package/dist/commands/observe/imports/pass.d.ts.map +1 -0
- package/dist/commands/observe/imports/resolve.d.ts +44 -0
- package/dist/commands/observe/imports/resolve.d.ts.map +1 -0
- package/dist/commands/observe/imports/safe-read.d.ts +30 -0
- package/dist/commands/observe/imports/safe-read.d.ts.map +1 -0
- package/dist/commands/observe/imports/scan.d.ts +59 -0
- package/dist/commands/observe/imports/scan.d.ts.map +1 -0
- package/dist/commands/observe/index.d.ts +59 -0
- package/dist/commands/observe/index.d.ts.map +1 -0
- package/dist/commands/observe/same-path.d.ts +9 -0
- package/dist/commands/observe/same-path.d.ts.map +1 -0
- package/dist/commands/observe/walk.d.ts +29 -0
- package/dist/commands/observe/walk.d.ts.map +1 -0
- package/dist/commands/report/exec-git.d.ts.map +1 -1
- package/dist/commands/shared/brownfield-sidecar.d.ts +98 -0
- package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -0
- package/dist/commands/shared/git-exclude.d.ts +36 -0
- package/dist/commands/shared/git-exclude.d.ts.map +1 -0
- package/dist/commands/shared/glob.d.ts +29 -0
- package/dist/commands/shared/glob.d.ts.map +1 -0
- package/dist/commands/shared/grant-enumerator.d.ts +32 -0
- package/dist/commands/shared/grant-enumerator.d.ts.map +1 -0
- package/dist/commands/shared/ignore.d.ts +32 -0
- package/dist/commands/shared/ignore.d.ts.map +1 -0
- package/dist/commands/shared/sidecar-out.d.ts +6 -0
- package/dist/commands/shared/sidecar-out.d.ts.map +1 -0
- package/dist/commands/shared/sidecar-write.d.ts +2 -0
- package/dist/commands/shared/sidecar-write.d.ts.map +1 -0
- package/dist/commands/slice/index.d.ts +23 -0
- package/dist/commands/slice/index.d.ts.map +1 -0
- package/dist/commands/workbook/allow-list.d.ts +27 -0
- package/dist/commands/workbook/allow-list.d.ts.map +1 -0
- package/dist/commands/workbook/export.d.ts +41 -0
- package/dist/commands/workbook/export.d.ts.map +1 -0
- package/dist/commands/workbook/index.d.ts +3 -0
- package/dist/commands/workbook/index.d.ts.map +1 -0
- package/dist/commands/workbook/zip-read.d.ts +7 -0
- package/dist/commands/workbook/zip-read.d.ts.map +1 -0
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/generators/root-file-templates.d.ts +5 -4
- package/dist/generators/root-file-templates.d.ts.map +1 -1
- package/dist/generators/root-files.d.ts.map +1 -1
- package/dist/index.js +367 -37
- package/dist/index.js.map +1 -1
- package/dist/templates/agents-md/findings/0001-session-log-grows-unbounded.md +35 -0
- package/dist/templates/ci-github-actions/findings/0001-ci-runners-have-no-zsh.md +34 -0
- package/dist/templates/orchestration/README.md +88 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/SKILL.md +511 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/briefs.md +178 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/rationale.md +520 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/scripts/wave-event.sh +17 -0
- package/dist/templates/orchestration/files/.github/workflows/gate.yml +66 -0
- package/dist/templates/orchestration/findings/0001-relative-runbook-links-escape-the-skill.md +48 -0
- package/dist/templates/orchestration/findings/0002-interpolation-hazard-in-graphql-line.md +46 -0
- package/dist/templates/orchestration/manifest.json +41 -0
- package/dist/types/manifest/monorepo.d.ts +5 -0
- package/dist/types/manifest/monorepo.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface RevokeOptions {
|
|
2
|
+
grantFile: string;
|
|
3
|
+
/** ISO date-time with an offset; default now. */
|
|
4
|
+
at?: string;
|
|
5
|
+
workspaceRoot?: string;
|
|
6
|
+
keyFile?: string;
|
|
7
|
+
engagement?: string;
|
|
8
|
+
yes?: boolean;
|
|
9
|
+
/** Test seams. */
|
|
10
|
+
homeDir?: string;
|
|
11
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
12
|
+
now?: Date;
|
|
13
|
+
/** Runs after the temp file is written, before the final containment re-check and the rename. */
|
|
14
|
+
beforeRename?: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `hexagen grant revoke <grant-file> [--at <iso>] [--yes]`: set `revoked_at`
|
|
18
|
+
* and re-sign with the key that verifies the grant. Refuses a grant whose
|
|
19
|
+
* signature does not verify under the resolved key (exit 1): it never signs
|
|
20
|
+
* what it cannot vouch for. Idempotent: an already-revoked grant is left
|
|
21
|
+
* untouched unless `--at` is earlier than the recorded time. Exit 0 done or
|
|
22
|
+
* already revoked, 1 not verified, 2 bad input, a held lock or no `--yes`.
|
|
23
|
+
* Never prints the key; prints its path and fingerprint.
|
|
24
|
+
*
|
|
25
|
+
* The grant path is resolved once. In a client repo it must be under the real
|
|
26
|
+
* `<root>/.hexagen/`, and that containment is re-checked on the directory
|
|
27
|
+
* right before the rename. Residual window: between that last check and the
|
|
28
|
+
* rename itself nothing is held, so an attacker who can already write inside
|
|
29
|
+
* `.hexagen/` and swap its ancestors in that instant can still redirect the
|
|
30
|
+
* rename; the guard narrows the window, it does not close it (the same
|
|
31
|
+
* trade-off the sidecar writers make). A `<grant>.lock` file (O_EXCL, holding
|
|
32
|
+
* the pid, never auto-broken) serialises concurrent revokes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function grantRevokeCommand(options: RevokeOptions): Promise<void>;
|
|
35
|
+
//# sourceMappingURL=revoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/revoke.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACnD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,iGAAiG;IACjG,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AA4CD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAgFf"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ShowOptions {
|
|
2
|
+
grantFile: string;
|
|
3
|
+
workspaceRoot?: string;
|
|
4
|
+
keyFile?: string;
|
|
5
|
+
engagement?: string;
|
|
6
|
+
/** Test seams. */
|
|
7
|
+
homeDir?: string;
|
|
8
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
9
|
+
now?: Date;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `hexagen grant show <grant-file>`: the grant as the runtime reads it, plus
|
|
13
|
+
* whether its signature verifies. Exit 0 verified, 1 not verified, 2 bad
|
|
14
|
+
* input. The window (expired/revoked) is informational here; `grant check`
|
|
15
|
+
* enforces it. Prints the key's path and fingerprint, never the key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function grantShowCommand(options: ShowOptions): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=show.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/show.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACnD,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiE1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/sign.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface LoadedSigningKey {
|
|
2
|
+
readonly keyHex: string;
|
|
3
|
+
readonly created: boolean;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the trust root `GrantSignatureAdapter.verify` checks against
|
|
8
|
+
* (`<workspaceRoot>/.hexagen/grant-signing.key`). If it doesn't exist yet,
|
|
9
|
+
* mints a fresh 32-byte random key and writes it — per
|
|
10
|
+
* `docs/kernel/GRANT.md` "No issuer exists yet": "create it ... if it
|
|
11
|
+
* doesn't exist; treat it like any other credential, never commit it." The
|
|
12
|
+
* caller is told whether a key was just created, so it can warn loudly
|
|
13
|
+
* (this is a secret landing on disk in a git working tree).
|
|
14
|
+
*
|
|
15
|
+
* Key creation uses exclusive (`wx`) file creation: if two `grant issue`
|
|
16
|
+
* invocations race on a fresh workspace, the loser's write fails with
|
|
17
|
+
* EEXIST and it re-reads the winner's key instead of overwriting it —
|
|
18
|
+
* otherwise both would sign with different keys while only one survives on
|
|
19
|
+
* disk, and the loser's grant would never verify.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadOrCreateSigningKey(workspaceRoot: string): Promise<LoadedSigningKey>;
|
|
22
|
+
//# sourceMappingURL=signing-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing-key.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/signing-key.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAmDD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAyB3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Grant } from "@hexagen/shared";
|
|
3
|
+
import { type ResolvedGrantKey } from "@hexagen/shared/node/grant-key";
|
|
4
|
+
/** RFC 3339 date-time with a mandatory offset, and a real calendar instant (the Field Kit schema's `date-time`). */
|
|
5
|
+
export declare const isoDateTime: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
export type LoadedGrant = {
|
|
7
|
+
readonly ok: true;
|
|
8
|
+
readonly grant: Grant;
|
|
9
|
+
} | {
|
|
10
|
+
readonly ok: false;
|
|
11
|
+
readonly problem: string;
|
|
12
|
+
};
|
|
13
|
+
/** Reads and shape-checks a grant file. A failure here is bad input (exit 2), not a denial. */
|
|
14
|
+
export declare function loadGrantFile(file: string): Promise<LoadedGrant>;
|
|
15
|
+
/**
|
|
16
|
+
* Shape-checks already-parsed JSON against the one strict grant schema (also
|
|
17
|
+
* used by `hexagen evidence pack`, so there is exactly one).
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseGrant(json: unknown, label: string): LoadedGrant;
|
|
20
|
+
export interface VerifyContext {
|
|
21
|
+
readonly workspaceRoot: string;
|
|
22
|
+
readonly keyFile?: string;
|
|
23
|
+
readonly engagement?: string;
|
|
24
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
25
|
+
/** Test seam; defaults to `os.homedir()`. */
|
|
26
|
+
readonly homeDir?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GrantVerification {
|
|
29
|
+
readonly verified: boolean;
|
|
30
|
+
/** Why not, when not. Never contains key material. */
|
|
31
|
+
readonly reason?: string;
|
|
32
|
+
readonly key: ResolvedGrantKey;
|
|
33
|
+
}
|
|
34
|
+
/** The same resolution `hexagen grant issue` and the MCP server use. */
|
|
35
|
+
export declare function resolveVerifyKey(ctx: VerifyContext): ResolvedGrantKey;
|
|
36
|
+
/**
|
|
37
|
+
* Verifies `grant.signature` (HMAC-SHA256 hex over the canonical payload)
|
|
38
|
+
* against the key the shared resolver finds. Fails closed on every way trust
|
|
39
|
+
* can fail to be established: no signature, a malformed one, no key location,
|
|
40
|
+
* a missing or weak key, or a mismatch. When the operator overrode the key
|
|
41
|
+
* (`--key-file` / `--engagement`) and it fails, the message also names the key
|
|
42
|
+
* the MCP server would use without the override, with both fingerprints.
|
|
43
|
+
*
|
|
44
|
+
* `resolved` is the key already resolved from this same `ctx` — `hexagen grant
|
|
45
|
+
* list` resolves once for the whole listing instead of once per row. Callers
|
|
46
|
+
* that omit it are unaffected. It changes nothing about what is trusted: the
|
|
47
|
+
* key is still read and checked on every call (verify never caches key
|
|
48
|
+
* material), and only the resolution is skipped.
|
|
49
|
+
*/
|
|
50
|
+
export declare function verifyGrantSignature(grant: Grant, ctx: VerifyContext, resolved?: ResolvedGrantKey): GrantVerification;
|
|
51
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAC;AAGxC,oHAAoH;AACpH,eAAO,MAAM,WAAW,2CASrB,CAAC;AAmBJ,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,+FAA+F;AAC/F,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAiBtE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAUpE;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;CAChC;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,gBAAgB,CAQrE;AAyBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,iBAAiB,CA2BnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Slice } from "@hexagen/shared";
|
|
2
|
+
export declare function loadSlice(workspaceRoot: string): Promise<Slice | undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* Which workspace root the grant commands (issue, show, check) work from. `findWorkspaceRoot` walks up to ANY parent manifest,
|
|
5
|
+
* so a client repo checked out beneath a monorepo would inherit its repo mode
|
|
6
|
+
* (and its key). The git toplevel is the repo boundary: when discovery lands
|
|
7
|
+
* outside it, the toplevel wins. A manifest at or below the toplevel (a HexaGen
|
|
8
|
+
* project inside a larger repo) stays the root. `--workspace-root` overrides.
|
|
9
|
+
*/
|
|
10
|
+
export declare function discoverWorkspaceRoot(workspaceRootOption?: string): string;
|
|
11
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/workspace.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAY5B;AAgBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonc.d.ts","sourceRoot":"","sources":["../../../../src/commands/observe/imports/jsonc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAwDhD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type UnresolvedReason, type WorkspacePackage } from "./resolve.js";
|
|
2
|
+
/** Extensions the pass reads. Every other counted language is unread. */
|
|
3
|
+
export declare const READ_EXTENSIONS: ReadonlySet<string>;
|
|
4
|
+
export declare const DEFAULT_MAX_IMPORT_FILES = 20000;
|
|
5
|
+
export declare const DEFAULT_MAX_IMPORT_BYTES: number;
|
|
6
|
+
export declare const DEFAULT_MAX_IMPORT_MS = 30000;
|
|
7
|
+
/** Only files up to this size are read; a larger one is noted and skipped. */
|
|
8
|
+
export declare const MAX_FILE_BYTES: number;
|
|
9
|
+
/** A tsconfig `extends` chain is followed this many levels past the nearest file. */
|
|
10
|
+
export declare const MAX_EXTENDS_DEPTH = 5;
|
|
11
|
+
export interface ImportPassOptions {
|
|
12
|
+
root: string;
|
|
13
|
+
/** Repo-relative walked files. */
|
|
14
|
+
files: readonly string[];
|
|
15
|
+
packages: readonly WorkspacePackage[];
|
|
16
|
+
maxFiles: number;
|
|
17
|
+
maxBytes: number;
|
|
18
|
+
maxMs: number;
|
|
19
|
+
now: () => number;
|
|
20
|
+
start: number;
|
|
21
|
+
notes: string[];
|
|
22
|
+
/** Per-file read limit; defaults to MAX_FILE_BYTES. A test seam, not a flag. */
|
|
23
|
+
maxFileBytes?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface EdgeRow {
|
|
26
|
+
from: string;
|
|
27
|
+
to: string;
|
|
28
|
+
specifier: string;
|
|
29
|
+
}
|
|
30
|
+
export interface UnresolvedRow {
|
|
31
|
+
from: string;
|
|
32
|
+
specifier: string;
|
|
33
|
+
reason: UnresolvedReason;
|
|
34
|
+
}
|
|
35
|
+
export type ImportPassResult = {
|
|
36
|
+
collected: true;
|
|
37
|
+
edges: EdgeRow[];
|
|
38
|
+
unresolved: UnresolvedRow[];
|
|
39
|
+
} | {
|
|
40
|
+
collected: false;
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function isReadable(file: string): boolean;
|
|
44
|
+
export declare function runImportPass(options: ImportPassOptions): Promise<ImportPassResult>;
|
|
45
|
+
//# sourceMappingURL=pass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pass.d.ts","sourceRoot":"","sources":["../../../../src/commands/observe/imports/pass.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAOtB,yEAAyE;AACzE,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAS9C,CAAC;AAEH,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,wBAAwB,QAAoB,CAAC;AAC1D,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,8EAA8E;AAC9E,eAAO,MAAM,cAAc,QAAc,CAAC;AAC1C,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,EAAE,CAAC;IAAC,UAAU,EAAE,aAAa,EAAE,CAAA;CAAE,GAClE;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhD;AASD,wBAAsB,aAAa,CACjC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAO3B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifier resolution for the import pass. Pure: it sees only the walked
|
|
3
|
+
* file set, the workspace packages and a tsconfig lookup.
|
|
4
|
+
*
|
|
5
|
+
* Order, per specifier: (1) relative, (2) workspace package name,
|
|
6
|
+
* (3) the nearest tsconfig `paths` / `baseUrl`, (4) `#` package imports.
|
|
7
|
+
* Anything no step claims is external (a node builtin or a dependency).
|
|
8
|
+
*/
|
|
9
|
+
export type UnresolvedReason = "not-found" | "exports-subpath" | "non-literal" | "outside-repo" | "package-imports" | "not-scanned";
|
|
10
|
+
export type Resolution = {
|
|
11
|
+
kind: "edge";
|
|
12
|
+
to: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "unresolved";
|
|
15
|
+
reason: UnresolvedReason;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "external";
|
|
18
|
+
};
|
|
19
|
+
export interface WorkspacePackage {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** "." for the repo root, else a repo-relative directory. */
|
|
22
|
+
readonly root: string;
|
|
23
|
+
}
|
|
24
|
+
/** A tsconfig reduced to what resolution needs. Paths are repo-relative, "" is the root. */
|
|
25
|
+
export interface EffectiveTsconfig {
|
|
26
|
+
/** Absolute-in-repo directory the `baseUrl` points at, or undefined. */
|
|
27
|
+
readonly baseUrl?: string;
|
|
28
|
+
/** Directory the `paths` targets are relative to. */
|
|
29
|
+
readonly pathsBase?: string;
|
|
30
|
+
readonly paths?: Readonly<Record<string, readonly string[]>>;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolveContext {
|
|
33
|
+
readonly files: ReadonlySet<string>;
|
|
34
|
+
readonly packages: readonly WorkspacePackage[];
|
|
35
|
+
/** The effective tsconfig for the directory of the importing file. */
|
|
36
|
+
readonly tsconfigFor: (fileDir: string) => EffectiveTsconfig | null;
|
|
37
|
+
}
|
|
38
|
+
export declare const RESOLVE_EXTENSIONS: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json"];
|
|
39
|
+
/** Join and normalize; null when the result leaves the repo root. "" is the root. */
|
|
40
|
+
export declare function joinInRepo(dir: string, rel: string): string | null;
|
|
41
|
+
/** Find the file a repo-relative path names, with extension and index rules. */
|
|
42
|
+
export declare function tryFile(files: ReadonlySet<string>, p: string, dirOnly?: boolean): string | null;
|
|
43
|
+
export declare function makeResolver(ctx: ResolveContext): (spec: string, fromFile: string) => Resolution;
|
|
44
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/commands/observe/imports/resolve.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,aAAa,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAA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E,QAAQ,EAAE,MAAM,KAAK,UAAU,CAiBhD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type SafeRead = {
|
|
2
|
+
ok: true;
|
|
3
|
+
text: string;
|
|
4
|
+
size: number;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
why: "unreadable" | "too-large";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Read a regular file without following a symlink in its last component, so a
|
|
11
|
+
* file swapped for a link after the walk is refused rather than read.
|
|
12
|
+
*
|
|
13
|
+
* Where `O_NOFOLLOW` exists the file is opened with it; elsewhere (Windows) the
|
|
14
|
+
* path is `lstat`ed first and a symlink refused. The size limit is decided on
|
|
15
|
+
* the opened handle (`fstat`), and the bytes are read through that handle, so
|
|
16
|
+
* the size checked is the size read. Parent directories are not re-checked: the
|
|
17
|
+
* walk never follows a symlinked directory, and a swap of one is outside this
|
|
18
|
+
* tool's threat model.
|
|
19
|
+
*/
|
|
20
|
+
export declare function safeReadText(abs: string, maxBytes: number): Promise<SafeRead>;
|
|
21
|
+
export type SafeReadBytes = {
|
|
22
|
+
ok: true;
|
|
23
|
+
bytes: Buffer;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
why: "unreadable" | "too-large";
|
|
27
|
+
};
|
|
28
|
+
/** `safeReadText`'s twin that returns the exact bytes (for files that are hashed or signed). */
|
|
29
|
+
export declare function safeReadBytes(abs: string, maxBytes: number): Promise<SafeReadBytes>;
|
|
30
|
+
//# sourceMappingURL=safe-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-read.d.ts","sourceRoot":"","sources":["../../../../src/commands/observe/imports/safe-read.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAChB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,YAAY,GAAG,WAAW,CAAA;CAAE,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,CAAC,CAqCnB;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,YAAY,GAAG,WAAW,CAAA;CAAE,CAAC;AAEnD,gGAAgG;AAChG,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,CAAC,CAiCxB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small lexical scanner for JS/TS module specifiers. It is a tokenizer, not
|
|
3
|
+
* a parser: it knows comments, strings, template literals (with nested
|
|
4
|
+
* `${...}`), regex literals and a few keywords, and nothing else. It never
|
|
5
|
+
* builds a syntax tree and never touches the TypeScript compiler API.
|
|
6
|
+
*
|
|
7
|
+
* Cost is linear in the input: a regex attempt that fails to close remembers
|
|
8
|
+
* where its line ends, so no later attempt on that line rescans it.
|
|
9
|
+
*
|
|
10
|
+
* Known limits, accepted for a bounded pass:
|
|
11
|
+
* - JSX text containing an apostrophe opens a string that is closed at the end
|
|
12
|
+
* of the line.
|
|
13
|
+
* - A regex literal right after `)` (for example `if (x) /re/.test(y)`) is read
|
|
14
|
+
* as division, so its contents are tokenized as code and can yield a phantom
|
|
15
|
+
* specifier.
|
|
16
|
+
* - A wrong regex or string guess can swallow a backtick and flip template
|
|
17
|
+
* state until the next backtick, so a mistake can reach past its own line.
|
|
18
|
+
* - After `>` a `/` starts a regex, because `=>` tokenizes as `=` then `>` and
|
|
19
|
+
* `x => /re/.test(x)` must work. After `<` it never does, since `</tag>` is
|
|
20
|
+
* the usual case.
|
|
21
|
+
* - A postfix `++`/`--` is read as two operators, so the `/` after it starts a
|
|
22
|
+
* regex attempt. If that attempt reads an unbalanced `[` from a divisor
|
|
23
|
+
* string, the line guard can then hide a later quote-bearing regex on the
|
|
24
|
+
* same line: `x = i++ / "["; y = /it's/.test(s); import a from './a.js';`.
|
|
25
|
+
* - A block statement after a semicolon-less non-literal `require(x)` (ASI
|
|
26
|
+
* only, `const m = require(name)\n{ … }`) is read as a method definition
|
|
27
|
+
* and the call is dropped.
|
|
28
|
+
*/
|
|
29
|
+
export interface ScannedSpecifier {
|
|
30
|
+
/** The literal specifier, or null when the specifier is not a plain string. */
|
|
31
|
+
readonly specifier: string | null;
|
|
32
|
+
readonly kind: "import" | "export-from" | "dynamic-import" | "require";
|
|
33
|
+
}
|
|
34
|
+
type Tok = {
|
|
35
|
+
k: "id";
|
|
36
|
+
v: string;
|
|
37
|
+
inTpl: boolean;
|
|
38
|
+
} | {
|
|
39
|
+
k: "str";
|
|
40
|
+
v: string;
|
|
41
|
+
escaped: boolean;
|
|
42
|
+
inTpl: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
k: "opaque";
|
|
45
|
+
inTpl: boolean;
|
|
46
|
+
} | {
|
|
47
|
+
k: "p";
|
|
48
|
+
v: string;
|
|
49
|
+
inTpl: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** Pass 1: text to tokens. Comments are dropped; template contents are opaque. */
|
|
52
|
+
export declare function tokenize(text: string): Tok[];
|
|
53
|
+
/**
|
|
54
|
+
* Scan `text` and return every module specifier found outside comments and
|
|
55
|
+
* template literals, in source order.
|
|
56
|
+
*/
|
|
57
|
+
export declare function scanSpecifiers(text: string): ScannedSpecifier[];
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../src/commands/observe/imports/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,GAAG,gBAAgB,GAAG,SAAS,CAAC;CACxE;AAED,KAAK,GAAG,GACJ;IAAE,CAAC,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACtC;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACzD;IAAE,CAAC,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC/B;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AA+B1C,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,CAwH5C;AAsBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAyE/D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { ObservedReport } from "@hexagen/shared";
|
|
3
|
+
import { DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_FILES, DEFAULT_MAX_IMPORT_MS } from "./imports/pass.js";
|
|
4
|
+
/**
|
|
5
|
+
* `hexagen observe`: a read-only scan that reports what a repo already
|
|
6
|
+
* contains, in the repo's own names. It never calls adopt, bootstrap, sync or
|
|
7
|
+
* hexagen-lint, and the only thing it can write is `--out`, which must
|
|
8
|
+
* resolve under `<root>/.hexagen/`.
|
|
9
|
+
*
|
|
10
|
+
* The import pass (`edges`, `unresolved`) is a bounded lexical scan of
|
|
11
|
+
* JS/TS files; see `./imports/`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_MAX_FILES = 50000;
|
|
14
|
+
export declare const DEFAULT_MAX_MS = 30000;
|
|
15
|
+
export { DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_FILES, DEFAULT_MAX_IMPORT_MS, };
|
|
16
|
+
export declare function extOf(file: string): string;
|
|
17
|
+
export interface ObserveOptions {
|
|
18
|
+
root: string;
|
|
19
|
+
/** `--dont-touch` prefixes, reported as given. */
|
|
20
|
+
dontTouch?: string[];
|
|
21
|
+
maxFiles?: number;
|
|
22
|
+
maxMs?: number;
|
|
23
|
+
/** Import pass caps; the pass has its own clock, started when it begins. */
|
|
24
|
+
maxImportFiles?: number;
|
|
25
|
+
maxImportBytes?: number;
|
|
26
|
+
maxImportMs?: number;
|
|
27
|
+
/** Per-file read limit for the import pass (default 1 MiB); a test seam. */
|
|
28
|
+
maxImportFileBytes?: number;
|
|
29
|
+
/** Clock seam for the time cap. */
|
|
30
|
+
now?: () => number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Remove credentials, query and fragment from a URL remote. scp-like remotes
|
|
34
|
+
* (`git@host:o/r`) are not URLs and go through the regex fallback.
|
|
35
|
+
*/
|
|
36
|
+
export declare function stripCredentials(remote: string): string;
|
|
37
|
+
export declare class ObserveError extends Error {
|
|
38
|
+
}
|
|
39
|
+
export declare function readRepo(root: string): {
|
|
40
|
+
remote?: string;
|
|
41
|
+
commit: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function observe(options: ObserveOptions): Promise<ObservedReport>;
|
|
44
|
+
export interface RunObserveOptions extends ObserveOptions {
|
|
45
|
+
out?: string;
|
|
46
|
+
yes?: boolean;
|
|
47
|
+
/** Test seam: the temp file path for a given target. */
|
|
48
|
+
tmpPath?: (target: string) => string;
|
|
49
|
+
}
|
|
50
|
+
export interface RunObserveResult {
|
|
51
|
+
exitCode: number;
|
|
52
|
+
/** The report JSON, when it is meant for stdout. */
|
|
53
|
+
stdout?: string;
|
|
54
|
+
/** Preflight and error lines, in order, for stderr. */
|
|
55
|
+
messages: string[];
|
|
56
|
+
}
|
|
57
|
+
export declare function runObserve(options: RunObserveOptions): Promise<RunObserveResult>;
|
|
58
|
+
export declare const observeCommander: Command;
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/observe/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAwB,MAAM,WAAW,CAAC;AAM1D,OAAO,EAEL,cAAc,EAEf,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EAGtB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,GACtB,CAAC;AAiEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1C;AAMD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgBvD;AAeD,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAU1C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAgB1E;AAwVD,wBAAsB,OAAO,CAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CA8HzB;AAED,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAcD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAgF3B;AAYD,eAAO,MAAM,gBAAgB,SAkE1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function samePath(a: string, b: string, platform?: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* True when `child` is `parent` itself or lies beneath it, judged on the same
|
|
4
|
+
* canonical text as `samePath` (separators, case on win32, trailing slashes).
|
|
5
|
+
* Both inputs must already be resolved with `fs.realpath.native`. Pure, so a
|
|
6
|
+
* Windows decision can be tested on any OS.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSameOrInside(parent: string, child: string, platform?: string): boolean;
|
|
9
|
+
//# sourceMappingURL=same-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-path.d.ts","sourceRoot":"","sources":["../../../src/commands/observe/same-path.ts"],"names":[],"mappings":"AAaA,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAIT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Never descended into. `.hexagen` is observe's own output directory. */
|
|
2
|
+
export declare const SKIP_DIRS: ReadonlySet<string>;
|
|
3
|
+
export interface WalkLimits {
|
|
4
|
+
readonly maxFiles: number;
|
|
5
|
+
readonly maxMs: number;
|
|
6
|
+
readonly now: () => number;
|
|
7
|
+
/** When the deadline started; defaults to the start of the walk. */
|
|
8
|
+
readonly start?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WalkResult {
|
|
11
|
+
/** Repo-relative POSIX paths of non-ignored regular files, sorted. */
|
|
12
|
+
readonly files: string[];
|
|
13
|
+
/** Repo-relative POSIX paths of walked directories (not the root), sorted. */
|
|
14
|
+
readonly dirs: string[];
|
|
15
|
+
/** Gitignored directories named `dist` or `build`, with a trailing `/`. */
|
|
16
|
+
readonly ignoredBuildDirs: string[];
|
|
17
|
+
/** Non-fatal observations (unreadable directories, skipped entries). */
|
|
18
|
+
readonly notes: string[];
|
|
19
|
+
/** The reason the walk stopped early, or null when it finished. */
|
|
20
|
+
readonly truncated: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function timeCapReason(maxMs: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Walk `root` without following symlinks. Skips VCS, vendored and dependency
|
|
25
|
+
* directories, and honours the root `.gitignore` and any nested `.gitignore`.
|
|
26
|
+
* Ignored directories are not descended into.
|
|
27
|
+
*/
|
|
28
|
+
export declare function walk(root: string, limits: WalkLimits): Promise<WalkResult>;
|
|
29
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/commands/observe/walk.ts"],"names":[],"mappings":"AASA,0EAA0E;AAC1E,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,MAAM,CAUxC,CAAC;AAEH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAkGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-git.d.ts","sourceRoot":"","sources":["../../../src/commands/report/exec-git.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"exec-git.d.ts","sourceRoot":"","sources":["../../../src/commands/report/exec-git.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmB5C,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CA6BhE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Contract, ObservedReport, Slice } from "@hexagen/shared";
|
|
2
|
+
/** Result shape shared by the slice and contract commands. */
|
|
3
|
+
export interface CommandResult {
|
|
4
|
+
/** 0 clean/ok, 1 drift or violation, 2 bad input or refused. */
|
|
5
|
+
exitCode: 0 | 1 | 2;
|
|
6
|
+
/** Status lines, printed to stderr. */
|
|
7
|
+
messages: string[];
|
|
8
|
+
/** The command's own output, printed to stdout. */
|
|
9
|
+
stdout?: string;
|
|
10
|
+
}
|
|
11
|
+
/** A refusal, bad input or failed precondition: exit 2. */
|
|
12
|
+
export declare class UsageError extends Error {
|
|
13
|
+
}
|
|
14
|
+
/** A sidecar file that does not exist (a missing slice, observed report or contract). */
|
|
15
|
+
export declare class NotFoundError extends UsageError {
|
|
16
|
+
}
|
|
17
|
+
/** Turn a thrown precondition failure into an exit-2 result. */
|
|
18
|
+
export declare function asResult(e: unknown, messages: string[]): CommandResult;
|
|
19
|
+
export declare const SIDECAR_ENTRY = ".hexagen/";
|
|
20
|
+
export { prefixHasTarget, sliceEntryOf, targetInSlice, underPrefix, } from "@hexagen/shared";
|
|
21
|
+
export declare function git(root: string, args: string[]): string | null;
|
|
22
|
+
/** Tracked and untracked-but-not-ignored files, repo-relative. */
|
|
23
|
+
export declare function listWorkTreeFiles(root: string): string[];
|
|
24
|
+
/** True when `commit` names a commit object in the repo. */
|
|
25
|
+
export declare function commitExists(root: string, commit: string): boolean;
|
|
26
|
+
/** True when `ancestor` is `descendant` or one of its ancestors. */
|
|
27
|
+
export declare function isAncestor(root: string, ancestor: string, descendant: string): boolean;
|
|
28
|
+
export declare function headCommit(root: string): string | null;
|
|
29
|
+
/** Files changed between `commit` and HEAD, restricted to the pathspecs. */
|
|
30
|
+
export declare function changedSince(root: string, commit: string, pathspecs: readonly string[]): string[] | null;
|
|
31
|
+
/** One `git diff --name-status -M -z` record. */
|
|
32
|
+
export interface ChangedPath {
|
|
33
|
+
/** The record's status field: `A`, `M`, `D`, `R100`, `C075`, ... */
|
|
34
|
+
readonly status: string;
|
|
35
|
+
/** The new side: the only path for every status but a rename or copy. */
|
|
36
|
+
readonly path: string;
|
|
37
|
+
/** The old side of a rename or copy, which is a path that moved too. */
|
|
38
|
+
readonly oldPath?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Files changed in `from..to`, renames and copies expanded into both of their
|
|
42
|
+
* paths. The sibling of `changedSince`, not a replacement: that one answers
|
|
43
|
+
* "which files under these pathspecs changed" for `slice check` and keeps
|
|
44
|
+
* `--name-only`, while this one has to know which side of a rename moved —
|
|
45
|
+
* `--name-only` prints one name per side and loses the pairing. Both go through
|
|
46
|
+
* the module-private `gitZ`, so NUL splitting is written once.
|
|
47
|
+
*
|
|
48
|
+
* Both refs may be any rev; the caller resolves them. Null means git failed,
|
|
49
|
+
* which for a range ref is how a shallow clone that cannot reach `from` answers:
|
|
50
|
+
* never treat that as "nothing changed".
|
|
51
|
+
*/
|
|
52
|
+
export declare function changedPaths(root: string, from: string, to: string): ChangedPath[] | null;
|
|
53
|
+
/**
|
|
54
|
+
* The NUL-split fields of one `git diff --name-status -M -z` run, read as
|
|
55
|
+
* records. A truncated record — a status with no path, or a rename missing its
|
|
56
|
+
* second path — cannot be read honestly, and returning the records before the
|
|
57
|
+
* cut would judge a partial range as if it were the whole one. Null refuses the
|
|
58
|
+
* whole diff instead, so the caller cannot pass a range it only half read.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseChangedPaths(fields: readonly string[]): ChangedPath[] | null;
|
|
61
|
+
export declare const slicePath: (root: string) => string;
|
|
62
|
+
export declare const observedPath: (root: string) => string;
|
|
63
|
+
export declare const contractPath: (root: string) => string;
|
|
64
|
+
/** Every command works from the repo top level, never a subdirectory. */
|
|
65
|
+
export declare function assertTopLevel(root: string): void;
|
|
66
|
+
export declare function loadSlice(root: string): Promise<Slice>;
|
|
67
|
+
export declare function loadObserved(root: string): Promise<ObservedReport>;
|
|
68
|
+
export { isSuppressionExpired } from "@hexagen/shared";
|
|
69
|
+
/** The contract, or undefined when none exists yet. */
|
|
70
|
+
export declare function loadContract(root: string): Promise<Contract | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Stale-input checks on `observed.json` against the slice (plan BW5 task 3).
|
|
73
|
+
* Returns hard problems (exit 2) and warnings. `observed.repo.commit` must be
|
|
74
|
+
* the slice's `repo.commit` or a descendant of it (the report is "newer" than
|
|
75
|
+
* the slice's commit); a different HEAD is a warning, and a problem with
|
|
76
|
+
* `strict`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function staleInputs(root: string, slice: Slice, observed: ObservedReport, strict: boolean): {
|
|
79
|
+
problems: string[];
|
|
80
|
+
warnings: string[];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Preflight for writes into the sidecar: names every file that will be
|
|
84
|
+
* written, adds the exclude file when it would change, and requires `--yes`.
|
|
85
|
+
* Throws `UsageError` (exit 2) without `--yes`. Returns whether the exclude
|
|
86
|
+
* must be applied.
|
|
87
|
+
*/
|
|
88
|
+
export declare function preflight(root: string, writes: readonly string[], yes: boolean | undefined, messages: string[]): Promise<{
|
|
89
|
+
applyExclude: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Run `fn` holding `.hexagen/contract.json.lock`, created with O_EXCL and
|
|
93
|
+
* holding this pid. A lock that is already there exits 2; it is never broken
|
|
94
|
+
* automatically. The lock is removed in a `finally`. When `.hexagen` does not
|
|
95
|
+
* exist yet nothing can be locked and `fn` runs (it fails on the missing slice).
|
|
96
|
+
*/
|
|
97
|
+
export declare function withContractLock<T>(root: string, fn: () => Promise<T>): Promise<T>;
|
|
98
|
+
//# sourceMappingURL=brownfield-sidecar.d.ts.map
|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