@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.
Files changed (107) hide show
  1. package/README.md +729 -0
  2. package/dist/cli.js +7635 -516
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/arch/edit.d.ts.map +1 -1
  5. package/dist/commands/contract/evaluate.d.ts +99 -0
  6. package/dist/commands/contract/evaluate.d.ts.map +1 -0
  7. package/dist/commands/contract/growth.d.ts +22 -0
  8. package/dist/commands/contract/growth.d.ts.map +1 -0
  9. package/dist/commands/contract/index.d.ts +32 -0
  10. package/dist/commands/contract/index.d.ts.map +1 -0
  11. package/dist/commands/evidence/check.d.ts +33 -0
  12. package/dist/commands/evidence/check.d.ts.map +1 -0
  13. package/dist/commands/evidence/index.d.ts +3 -0
  14. package/dist/commands/evidence/index.d.ts.map +1 -0
  15. package/dist/commands/evidence/pack.d.ts +41 -0
  16. package/dist/commands/evidence/pack.d.ts.map +1 -0
  17. package/dist/commands/evidence/verify.d.ts +83 -0
  18. package/dist/commands/evidence/verify.d.ts.map +1 -0
  19. package/dist/commands/grant/build.d.ts +53 -0
  20. package/dist/commands/grant/build.d.ts.map +1 -0
  21. package/dist/commands/grant/canonical.d.ts +27 -0
  22. package/dist/commands/grant/canonical.d.ts.map +1 -0
  23. package/dist/commands/grant/check.d.ts +26 -0
  24. package/dist/commands/grant/check.d.ts.map +1 -0
  25. package/dist/commands/grant/duration.d.ts +8 -0
  26. package/dist/commands/grant/duration.d.ts.map +1 -0
  27. package/dist/commands/grant/index.d.ts +2 -0
  28. package/dist/commands/grant/index.d.ts.map +1 -0
  29. package/dist/commands/grant/issue.d.ts +23 -0
  30. package/dist/commands/grant/issue.d.ts.map +1 -0
  31. package/dist/commands/grant/key-init.d.ts +16 -0
  32. package/dist/commands/grant/key-init.d.ts.map +1 -0
  33. package/dist/commands/grant/list.d.ts +72 -0
  34. package/dist/commands/grant/list.d.ts.map +1 -0
  35. package/dist/commands/grant/revoke.d.ts +35 -0
  36. package/dist/commands/grant/revoke.d.ts.map +1 -0
  37. package/dist/commands/grant/show.d.ts +18 -0
  38. package/dist/commands/grant/show.d.ts.map +1 -0
  39. package/dist/commands/grant/sign.d.ts +3 -0
  40. package/dist/commands/grant/sign.d.ts.map +1 -0
  41. package/dist/commands/grant/signing-key.d.ts +22 -0
  42. package/dist/commands/grant/signing-key.d.ts.map +1 -0
  43. package/dist/commands/grant/verify.d.ts +51 -0
  44. package/dist/commands/grant/verify.d.ts.map +1 -0
  45. package/dist/commands/grant/workspace.d.ts +11 -0
  46. package/dist/commands/grant/workspace.d.ts.map +1 -0
  47. package/dist/commands/observe/imports/jsonc.d.ts +6 -0
  48. package/dist/commands/observe/imports/jsonc.d.ts.map +1 -0
  49. package/dist/commands/observe/imports/pass.d.ts +45 -0
  50. package/dist/commands/observe/imports/pass.d.ts.map +1 -0
  51. package/dist/commands/observe/imports/resolve.d.ts +44 -0
  52. package/dist/commands/observe/imports/resolve.d.ts.map +1 -0
  53. package/dist/commands/observe/imports/safe-read.d.ts +30 -0
  54. package/dist/commands/observe/imports/safe-read.d.ts.map +1 -0
  55. package/dist/commands/observe/imports/scan.d.ts +59 -0
  56. package/dist/commands/observe/imports/scan.d.ts.map +1 -0
  57. package/dist/commands/observe/index.d.ts +59 -0
  58. package/dist/commands/observe/index.d.ts.map +1 -0
  59. package/dist/commands/observe/same-path.d.ts +9 -0
  60. package/dist/commands/observe/same-path.d.ts.map +1 -0
  61. package/dist/commands/observe/walk.d.ts +29 -0
  62. package/dist/commands/observe/walk.d.ts.map +1 -0
  63. package/dist/commands/report/exec-git.d.ts.map +1 -1
  64. package/dist/commands/shared/brownfield-sidecar.d.ts +98 -0
  65. package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -0
  66. package/dist/commands/shared/git-exclude.d.ts +36 -0
  67. package/dist/commands/shared/git-exclude.d.ts.map +1 -0
  68. package/dist/commands/shared/glob.d.ts +29 -0
  69. package/dist/commands/shared/glob.d.ts.map +1 -0
  70. package/dist/commands/shared/grant-enumerator.d.ts +32 -0
  71. package/dist/commands/shared/grant-enumerator.d.ts.map +1 -0
  72. package/dist/commands/shared/ignore.d.ts +32 -0
  73. package/dist/commands/shared/ignore.d.ts.map +1 -0
  74. package/dist/commands/shared/sidecar-out.d.ts +6 -0
  75. package/dist/commands/shared/sidecar-out.d.ts.map +1 -0
  76. package/dist/commands/shared/sidecar-write.d.ts +2 -0
  77. package/dist/commands/shared/sidecar-write.d.ts.map +1 -0
  78. package/dist/commands/slice/index.d.ts +23 -0
  79. package/dist/commands/slice/index.d.ts.map +1 -0
  80. package/dist/commands/workbook/allow-list.d.ts +27 -0
  81. package/dist/commands/workbook/allow-list.d.ts.map +1 -0
  82. package/dist/commands/workbook/export.d.ts +41 -0
  83. package/dist/commands/workbook/export.d.ts.map +1 -0
  84. package/dist/commands/workbook/index.d.ts +3 -0
  85. package/dist/commands/workbook/index.d.ts.map +1 -0
  86. package/dist/commands/workbook/zip-read.d.ts +7 -0
  87. package/dist/commands/workbook/zip-read.d.ts.map +1 -0
  88. package/dist/fs-utils.d.ts.map +1 -1
  89. package/dist/generators/root-file-templates.d.ts +5 -4
  90. package/dist/generators/root-file-templates.d.ts.map +1 -1
  91. package/dist/generators/root-files.d.ts.map +1 -1
  92. package/dist/index.js +367 -37
  93. package/dist/index.js.map +1 -1
  94. package/dist/templates/agents-md/findings/0001-session-log-grows-unbounded.md +35 -0
  95. package/dist/templates/ci-github-actions/findings/0001-ci-runners-have-no-zsh.md +34 -0
  96. package/dist/templates/orchestration/README.md +88 -0
  97. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/SKILL.md +511 -0
  98. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/briefs.md +178 -0
  99. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/rationale.md +520 -0
  100. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/scripts/wave-event.sh +17 -0
  101. package/dist/templates/orchestration/files/.github/workflows/gate.yml +66 -0
  102. package/dist/templates/orchestration/findings/0001-relative-runbook-links-escape-the-skill.md +48 -0
  103. package/dist/templates/orchestration/findings/0002-interpolation-hazard-in-graphql-line.md +46 -0
  104. package/dist/templates/orchestration/manifest.json +41 -0
  105. package/dist/types/manifest/monorepo.d.ts +5 -0
  106. package/dist/types/manifest/monorepo.d.ts.map +1 -1
  107. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/commands/arch/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAwED,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsK1E;AAED,eAAO,MAAM,aAAa,SAOtB,CAAC"}
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/commands/arch/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAuED,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsK1E;AAED,eAAO,MAAM,aAAa,SAOtB,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { type Contract, type ObservedReport, type Slice } from "@hexagen/shared";
2
+ export interface Violation {
3
+ rule: string;
4
+ file: string;
5
+ specifier: string;
6
+ severity: "error" | "warn";
7
+ }
8
+ export interface Evaluation {
9
+ violations: Violation[];
10
+ /**
11
+ * Set when the edge or unresolved sections were not collected: nothing can be
12
+ * said about the slice's imports, so the check is never clean and no baseline
13
+ * can cover it.
14
+ */
15
+ incomplete: string | null;
16
+ }
17
+ /** Specifier recorded for a file the import pass cannot read. */
18
+ export declare function unreadLanguageSpecifier(ext: string): string;
19
+ /**
20
+ * Rules against the observed edges whose `from` is in the slice, plus the
21
+ * built-in `unresolved-import` rule (plan BW-D3):
22
+ * - every `unresolved` row whose `from` is in the slice, whatever its reason;
23
+ * - every in-slice file whose extension is in `edges.unreadLanguages`.
24
+ *
25
+ * `forbid`: an edge from the rule's `from` prefix to its `to` prefix.
26
+ * `allow-only`: an edge from the `from` prefix to anywhere that is neither
27
+ * the `to` prefix nor the `from` prefix itself (same-prefix imports are
28
+ * allowed).
29
+ * `closed`: the slice is the rule's `from` side, so an edge from anywhere in
30
+ * the slice to a target that is neither inside the slice nor under one of the
31
+ * rule's `except` prefixes (an exclude still wins over an except).
32
+ */
33
+ export declare function evaluateContract(input: {
34
+ slice: Slice;
35
+ contract: Contract | undefined;
36
+ observed: ObservedReport;
37
+ /** Work-tree files (tracked and untracked, not ignored). */
38
+ files: readonly string[];
39
+ }): Evaluation;
40
+ export { isSuppressionExpired, isKnown } from "@hexagen/shared";
41
+ /** Cross-prefix edges inside the slice, deduplicated by prefix pair. */
42
+ export declare function proposeCrossPrefixEdges(slice: Slice, observed: ObservedReport): {
43
+ from: string;
44
+ to: string;
45
+ count: number;
46
+ example: string;
47
+ }[];
48
+ export interface ClosedProposal {
49
+ /** Except entries, in the order `observed.json` lists them. */
50
+ excepts: string[];
51
+ /** Crossings that get no entry, each with the advice that would accept it. */
52
+ notProposed: {
53
+ to: string;
54
+ advice: string;
55
+ }[];
56
+ }
57
+ /**
58
+ * The `except` list a `closed` rule would need to accept the crossings the
59
+ * observed edges already make: every edge target that leaves the slice, emitted
60
+ * exactly as `slice check` prints it, deduplicated.
61
+ *
62
+ * A target is never turned into a directory. `observed.json` types `to` as a
63
+ * slice path, so a hand-edited report may spell a package root as a directory
64
+ * (`outside/pkg/`); emitting that verbatim gives an except entry which accepts
65
+ * every edge under it, and dropping the slash gives an exact entry which does
66
+ * not match the target at all (`underPrefix` compares equality without a
67
+ * trailing `/`). Neither names the one crossing that was observed, so such a
68
+ * target is reported with the flag that would accept it instead.
69
+ *
70
+ * A crossing no `except` can accept is reported the same way, because a rule
71
+ * naming one would still fail: `.` is never inside a prefix, and an `excludes`
72
+ * entry beats any except.
73
+ */
74
+ export declare function proposeClosedExcepts(slice: Slice, observed: ObservedReport): ClosedProposal;
75
+ /**
76
+ * The warning a `closed` rule earns when ITS OWN `except` list covers every
77
+ * observed package outside the slice: that rule then accepts every crossing it
78
+ * could have refused, so the slice is not closed.
79
+ *
80
+ * One rule, never a pool. Rules are ANDed (`edgeViolatesRule` answers one
81
+ * boolean per rule, and `evaluateContract` raises a violation for each rule an
82
+ * edge breaks), so an edge has to pass every one of them. Two rules that between
83
+ * them cover the whole repo leave each edge with one rule still to fail, which
84
+ * is exactly what a closed slice wants; pooling their lists would warn about a
85
+ * slice that is still shut.
86
+ *
87
+ * Coverage is asked per package root, and it means the root lies UNDER an entry:
88
+ * `--except apps/` covers `apps/web` and `apps/admin`, while `--except apps/web/ui/`
89
+ * covers neither the rest of its own package nor any sibling. An entry without a
90
+ * trailing `/` is an exact file (`underPrefix`), so a bare name covers nothing
91
+ * below it.
92
+ *
93
+ * A package the slice occupies, and one an `excludes` entry denies, are not
94
+ * units to cover: an except opens neither, so no crossing through them could be
95
+ * accepted either. The root package (`.`) is the repo, not a package an except
96
+ * can name.
97
+ */
98
+ export declare function closedRuleCoverageWarning(slice: Slice, observed: ObservedReport, rules: readonly Contract["rules"][number][]): string | null;
99
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../src/commands/contract/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,QAAQ,EACb,KAAK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AE,KAAK,EACZ,QAAQ,EAAE,cAAc,GACvB,cAAc,CA8BhB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,SAAS,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,GAC1C,MAAM,GAAG,IAAI,CAef"}
@@ -0,0 +1,22 @@
1
+ import { Contract, Slice } from "@hexagen/shared";
2
+ export interface ContractBase {
3
+ /** The commit `<ref>` resolved to — the hash the files were read at. */
4
+ hash: string;
5
+ contract: Contract;
6
+ slice: Slice;
7
+ }
8
+ /** The part of `GitReader` the guard needs, so a caller can supply its own. */
9
+ export interface BaseFileReader {
10
+ show(hash: string, relativePath: string): string | null;
11
+ }
12
+ /**
13
+ * The contract and the slice as committed at `ref`.
14
+ *
15
+ * Bad input throws `UsageError` (exit 2), never a pass: an unresolvable ref
16
+ * (a shallow CI clone that never fetched the base) and a sidecar file that was
17
+ * never staged are both "the guard cannot tell", and a guard that cannot tell
18
+ * must fail closed. `GitReader.show` returns `null` for both causes, so the ref
19
+ * is resolved FIRST and the two cannot be confused.
20
+ */
21
+ export declare function readContractBase(root: string, ref: string, reader?: BaseFileReader): ContractBase;
22
+ //# sourceMappingURL=growth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growth.d.ts","sourceRoot":"","sources":["../../../src/commands/contract/growth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAgBlD,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,cAAsC,GAC7C,YAAY,CAmBd"}
@@ -0,0 +1,32 @@
1
+ import { Command } from "commander";
2
+ import { type CommandResult } from "../shared/brownfield-sidecar.js";
3
+ import { type SliceRootOptions } from "../slice/index.js";
4
+ export declare function runContractPropose(options: SliceRootOptions & {
5
+ strict?: boolean;
6
+ closed?: boolean;
7
+ }): Promise<CommandResult>;
8
+ export interface AddRuleOptions extends SliceRootOptions {
9
+ /** `closed` takes `except` and no `from`/`to`; the prefix kinds the reverse. */
10
+ kind: "forbid" | "allow-only" | "closed";
11
+ from?: string;
12
+ to?: string;
13
+ /** The accepted crossings of a `closed` rule. `undefined` when the flag was not given, `[]` when it was given with no prefixes. */
14
+ except?: string[];
15
+ severity?: "error" | "warn";
16
+ id?: string;
17
+ yes?: boolean;
18
+ }
19
+ export declare function runContractAddRule(options: AddRuleOptions): Promise<CommandResult>;
20
+ export declare function runContractShow(options: SliceRootOptions): Promise<CommandResult>;
21
+ export interface ContractCheckOptions extends SliceRootOptions {
22
+ baseline?: boolean;
23
+ /** Git ref holding the contract and slice this check is compared against. */
24
+ base?: string;
25
+ allowGrowth?: boolean;
26
+ reason?: string;
27
+ yes?: boolean;
28
+ strict?: boolean;
29
+ }
30
+ export declare function runContractCheck(options: ContractCheckOptions): Promise<CommandResult>;
31
+ export declare const contractCommander: Command;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/contract/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,OAAO,EAUL,KAAK,aAAa,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,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**
4
+ * Reader-side checks for `hexagen evidence pack`: chain, line shape and the
5
+ * Rules of docs/kernel/TRACE.md. Pure; no fs.
6
+ *
7
+ * The Rule 1-3 logic itself is `traceRuleReasons` in `@hexagen/shared`, the same
8
+ * function the MCP server's `checkTrace` calls: a denial skips the allowlist and
9
+ * window checks, but still has to cite a known grant.
10
+ */
11
+ export type LineKind = "evidence" | "denial" | "invalid";
12
+ export interface LineVerdict {
13
+ /** 0-based position in the file (equals `seq` on a sound chain). */
14
+ readonly index: number;
15
+ readonly seq?: number;
16
+ readonly kind: LineKind;
17
+ readonly valid: boolean;
18
+ readonly reasons: readonly string[];
19
+ /** The grant a line cites, when it cites one. */
20
+ readonly grantId?: string;
21
+ readonly haltReason?: string;
22
+ readonly tool?: string;
23
+ readonly time?: string;
24
+ readonly reason?: string;
25
+ }
26
+ /** One verdict as a reader reports it: its position and every reason. */
27
+ export declare function describeVerdict(v: LineVerdict): string;
28
+ /**
29
+ * One verdict per line, in file order. `grants` holds only grants whose
30
+ * signature verified, so a line citing a forged grant fails Rule 3.
31
+ */
32
+ export declare function checkLines(lines: readonly SplitLine[], grants: ReadonlyMap<string, Grant>): LineVerdict[];
33
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/evidence/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,KAAK,EAEX,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAqDD,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAGtD;AAiDD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GACjC,WAAW,EAAE,CAoEf"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare const evidenceCommander: Command;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/evidence/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,iBAAiB,SAE7B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type LineVerdict } from "./check.js";
2
+ export interface EvidencePackOptions {
3
+ /** Repo root; `.hexagen/` lives here. Never searched upward. */
4
+ readonly root: string;
5
+ readonly trace: string;
6
+ readonly grantFiles: readonly string[];
7
+ readonly out: string;
8
+ readonly keyFile?: string;
9
+ readonly engagement?: string;
10
+ readonly env?: Readonly<Record<string, string | undefined>>;
11
+ /** Test seam; defaults to `os.homedir()`. */
12
+ readonly homeDir?: string;
13
+ readonly now?: () => Date;
14
+ /** Milliseconds to wait for the trace lock (default 15 s). */
15
+ readonly lockTimeoutMs?: number;
16
+ /** Test seam: replaces the atomic write of `tip.json`. */
17
+ /** Test seam: runs after the trace and tip were validated, before anything is written, with the trace lock held. */
18
+ readonly beforeTipWrite?: () => Promise<void>;
19
+ /** Test seam: runs after the output directory is validated, before the temp file is created. */
20
+ readonly beforeWrite?: () => Promise<void>;
21
+ /** Test seam: runs after the temp bundle is written, before it is linked. */
22
+ readonly beforeLink?: () => Promise<void>;
23
+ readonly writeTip?: (target: string, data: string) => Promise<void>;
24
+ }
25
+ export interface EvidencePackResult {
26
+ /** 0 packed; 1 the evidence is invalid (nothing written); 2 usage or precondition. */
27
+ readonly exitCode: 0 | 1 | 2;
28
+ readonly messages: readonly string[];
29
+ readonly verdicts?: readonly LineVerdict[];
30
+ /** Absolute path of the bundle, when one was written. */
31
+ readonly bundle?: string;
32
+ }
33
+ /**
34
+ * `hexagen evidence pack`: verifies a brownfield trace (chain, line shape,
35
+ * docs/kernel/TRACE.md Rules, the anchored tip) and, only if every line is
36
+ * sound, writes an HMAC'd bundle zip under `.hexagen/` and advances
37
+ * `.hexagen/evidence/tip.json`. On any invalid line it writes nothing at all,
38
+ * so a bundle that exists is a bundle that passed.
39
+ */
40
+ export declare function runEvidencePack(options: EvidencePackOptions): Promise<EvidencePackResult>;
41
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../../src/commands/evidence/pack.ts"],"names":[],"mappings":"AA4BA,OAAO,EAA+B,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAA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ared";
2
+ export interface EvidenceVerifyOptions {
3
+ /** Repo root; `.hexagen/` lives here. Never searched upward. */
4
+ readonly root: string;
5
+ /** Any git ref; only lines appended after it can cover anything. */
6
+ readonly since: string;
7
+ /** Upper end of the range. Defaults to `HEAD`. */
8
+ readonly until?: string;
9
+ /** Grant file(s) the trace's lines may cite, and whose paths widen scope. */
10
+ readonly grantFiles: readonly string[];
11
+ readonly keyFile?: string;
12
+ readonly engagement?: string;
13
+ /** Treat an empty diff as a pass instead of a precondition failure. */
14
+ readonly allowEmpty?: boolean;
15
+ readonly env?: Readonly<Record<string, string | undefined>>;
16
+ /** Test seam; defaults to `os.homedir()`. */
17
+ readonly homeDir?: string;
18
+ }
19
+ /** One changed file no anchored line covers, with the nearest line that does. */
20
+ export interface UnaccountedFile {
21
+ readonly path: string;
22
+ /**
23
+ * Lines that would cover `path` but that no `evidence pack` has anchored.
24
+ * Always present, and empty when no such line exists — an empty list means
25
+ * nothing was written at all, a non-empty one means the cover exists on paper
26
+ * only.
27
+ */
28
+ readonly unanchoredCover: readonly number[];
29
+ readonly nearestSeq?: number;
30
+ readonly nearestGrantId?: string;
31
+ readonly nearestPaths?: readonly string[];
32
+ }
33
+ export interface EvidenceVerifyResult {
34
+ /** 0 nothing unaccounted; 1 a change has no line; 2 bad input or bad state. */
35
+ readonly exitCode: 0 | 1 | 2;
36
+ /** Status lines, printed to stderr. */
37
+ readonly messages: readonly string[];
38
+ /** The unaccounted paths, one per line, printed to stdout. */
39
+ readonly stdout?: string;
40
+ readonly unaccounted?: readonly UnaccountedFile[];
41
+ /** The kept paths that a candidate line does cover. */
42
+ readonly covered?: readonly string[];
43
+ /** Raw changed paths outside the slice and every supplied grant. */
44
+ readonly skipped?: number;
45
+ /** Lines appended after `--since` that are valid completed evidence. */
46
+ readonly candidateLines?: number;
47
+ }
48
+ /** A joined line: the valid evidence line and the proposal that claims it. */
49
+ export interface CandidateLine {
50
+ readonly seq: number;
51
+ readonly grantId: string;
52
+ /** The proposal's paths, in the order the writer recorded them. */
53
+ readonly paths: readonly string[];
54
+ /** `result_digest` recomputed from the joined proposal. */
55
+ readonly digest: string;
56
+ /** The line's calls as written; the covering one names the paths. */
57
+ readonly calls: readonly {
58
+ readonly result_digest: string;
59
+ readonly time: string;
60
+ }[];
61
+ /**
62
+ * A key-holder's `evidence pack` anchored this line (`seq <= tip.seq` with the
63
+ * tip's HMAC verified). An unanchored line covers nothing.
64
+ */
65
+ readonly anchored: boolean;
66
+ }
67
+ /**
68
+ * Whether `candidate` covers `file`. Three things must hold, and the path and
69
+ * the time always come from the same record:
70
+ *
71
+ * 1. the joined proposal names `file`, exactly as the writer recorded it (both
72
+ * sides NFC-normalised, so a tree that spells a name in NFD and a proposal
73
+ * that spells it in NFC still name one file);
74
+ * 2. `file` sits inside *that* line's grant's paths — coverage is scoped to one
75
+ * grant, so a file another supplied grant allows is not covered here;
76
+ * 3. one of the line's calls carries the proposal's recomputed digest and sits
77
+ * inside that grant's window at its own time (`checkGrantWindow`, the same
78
+ * function the accept path and `grant check` call). A call that names the
79
+ * paths out of window does not cover them.
80
+ */
81
+ export declare function coveringLine(candidate: CandidateLine, grant: Grant, file: string): boolean;
82
+ export declare function runEvidenceVerify(options: EvidenceVerifyOptions): Promise<EvidenceVerifyResult>;
83
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/commands/evidence/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AAwEzB,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,SAAS,MA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,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,SAAS;QACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,EAAE,CAAC;IACJ;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAqGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAaT;AA6ID,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAqT/B"}
@@ -0,0 +1,53 @@
1
+ import { type GrantFields } from "./canonical.js";
2
+ export interface IssueGrantInput {
3
+ readonly principal: string;
4
+ readonly agent: string;
5
+ readonly paths: readonly string[];
6
+ readonly tools: readonly string[];
7
+ readonly mode: "write" | "propose";
8
+ readonly expiresIn: string;
9
+ readonly contexts?: readonly string[];
10
+ readonly maxFiles?: number;
11
+ /**
12
+ * Brownfield (no manifest): leave `contexts` off the grant entirely. Absent
13
+ * and `[]` sign differently, and a client-repo grant never writes `[]`.
14
+ */
15
+ readonly omitContexts?: boolean;
16
+ readonly now?: Date;
17
+ }
18
+ export interface IssuedGrant extends GrantFields {
19
+ readonly signature: string;
20
+ }
21
+ /**
22
+ * Looks up each `--contexts` name in `manifest.yaml`'s `bounded_contexts`
23
+ * and expands it to `packages/<context>/`, per docs/kernel/GRANT.md
24
+ * "Compiling a grant". A name that isn't a real context is a hard error
25
+ * (fail closed) — never a silently-dropped entry.
26
+ */
27
+ export declare function expandContexts(workspaceRoot: string, contexts: readonly string[]): Promise<string[]>;
28
+ /**
29
+ * `checkMutationAgainstGrant` requires `grant.contexts` to independently
30
+ * name every context a mutation targets — `grant.paths` covering
31
+ * `packages/<context>/` is not enough on its own (see
32
+ * packages/mcp-server/src/application/kernel/grant.ts
33
+ * `checkMutationAgainstGrant`, "An empty `grant.contexts` ... denies
34
+ * everything by construction"). So a grant issued on `--paths` alone,
35
+ * naming `packages/<context>/` prefixes but no `--contexts`, would
36
+ * otherwise sign with `contexts: []` and be denied for every mutation —
37
+ * contradicting the documented paths-only flow. This reverse-matches each
38
+ * `packages/<name>/` path prefix against the manifest's known contexts so
39
+ * those names land in `grant.contexts` too, without requiring the caller
40
+ * to repeat them via `--contexts`. Returns `[]` (never throws) when no
41
+ * manifest exists or no path matches a known context — that's the one
42
+ * case a true paths-only grant (no manifest at all) is deliberately
43
+ * useless against this manifest-only enforcement adapter, not a bug to
44
+ * paper over here.
45
+ */
46
+ export declare function deriveContextsFromPaths(workspaceRoot: string, paths: readonly string[]): Promise<string[]>;
47
+ /**
48
+ * Assembles and signs a Grant. Pure apart from the signature HMAC itself —
49
+ * `id` and `expires_at` are the only non-deterministic-by-design fields
50
+ * (fresh id, now + expiresIn), both overridable via `now` for tests.
51
+ */
52
+ export declare function buildGrant(input: IssueGrantInput, keyHex: string, signFn: (payload: string, keyHex: string) => string, contextPaths?: readonly string[]): Promise<IssuedGrant>;
53
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAkCD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,EACnD,YAAY,GAAE,SAAS,MAAM,EAAO,GACnC,OAAO,CAAC,WAAW,CAAC,CAoCtB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The exact bytes a Grant's signature is computed over.
3
+ *
4
+ * This MUST byte-for-byte match `canonicalGrantPayload` in
5
+ * `packages/mcp-server/src/application/kernel/grant.ts` — that is the
6
+ * function `GrantSignatureAdapter.verify` runs at the accept choke point.
7
+ * The two packages cannot share one implementation without `@hexagen/sync`
8
+ * depending on `@hexagen/mcp-server` (the wrong direction: `mcp-server`
9
+ * already depends on `sync`), so this is a deliberate, pinned duplicate —
10
+ * see `__tests__/commands/grant/canonical.test.ts`, which locks the output
11
+ * for a fixed sample grant so the two can't silently drift.
12
+ */
13
+ export interface GrantFields {
14
+ readonly id: string;
15
+ readonly principal: string;
16
+ readonly agent: string;
17
+ /** Absent on a client-repo grant (it never writes `[]`); absent and `[]` sign differently. */
18
+ readonly contexts?: readonly string[];
19
+ readonly paths: readonly string[];
20
+ readonly tools: readonly string[];
21
+ readonly mode: "write" | "propose";
22
+ readonly max_files?: number;
23
+ readonly expires_at: string;
24
+ readonly revoked_at?: string;
25
+ }
26
+ export declare function canonicalGrantPayload(grant: GrantFields): string;
27
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAchE"}
@@ -0,0 +1,26 @@
1
+ export interface CheckOptions {
2
+ grantFile: string;
3
+ /** Field Kit form. */
4
+ tool?: string | string[];
5
+ path?: string[];
6
+ /** Monaco form (`grant check <grant-file> <transaction-id>`); not built. */
7
+ transactionId?: string;
8
+ workspaceRoot?: string;
9
+ keyFile?: string;
10
+ engagement?: string;
11
+ /** Test seams. */
12
+ homeDir?: string;
13
+ env?: Readonly<Record<string, string | undefined>>;
14
+ now?: Date;
15
+ }
16
+ /**
17
+ * `hexagen grant check <grant-file> --tool <t> --path <p>...`: would this write
18
+ * be allowed? Signature, then window, then `checkWriteAgainstGrant`; never
19
+ * `checkGrantMode` (a client grant is propose-only, so the mode check would
20
+ * deny every patch). In a client repo (no manifest at the workspace root) a
21
+ * path outside `slice.paths`, or inside its excludes, is denied even when the
22
+ * grant allows it. Exit 0 allow, 1 deny, 2 bad input. Prints the reason, the
23
+ * workspace root and the key's path and fingerprint, never the key.
24
+ */
25
+ export declare function grantCheckCommand(options: CheckOptions): Promise<void>;
26
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/check.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,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;AAOD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0G5E"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Parses a `--expires-in` value like `4h`, `30m`, `900s`, `1d` into
3
+ * milliseconds. Whole positive integers only — no fractional or compound
4
+ * durations (`1h30m`), since a grant's expiry only needs to be "roughly
5
+ * this long," not scheduled to the second.
6
+ */
7
+ export declare function parseDurationMs(input: string): number;
8
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/duration.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAerD"}
@@ -0,0 +1,2 @@
1
+ export { grantCommander, issueGrantCommand } from "./issue.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Command } from "commander";
2
+ interface IssueOptions {
3
+ principal: string;
4
+ agent: string;
5
+ paths?: string;
6
+ tools: string;
7
+ mode: "write" | "propose";
8
+ expiresIn: string;
9
+ contexts?: string;
10
+ maxFiles?: string;
11
+ workspaceRoot?: string;
12
+ out?: string;
13
+ keyFile?: string;
14
+ engagement?: string;
15
+ /** Test seam; defaults to `os.homedir()`. */
16
+ homeDir?: string;
17
+ /** Brownfield: consent to the writes listed in the preflight. */
18
+ yes?: boolean;
19
+ }
20
+ export declare function issueGrantCommand(options: IssueOptions): Promise<void>;
21
+ export declare const grantCommander: Command;
22
+ export {};
23
+ //# sourceMappingURL=issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/issue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkDpC,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAQD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsV5E;AAED,eAAO,MAAM,cAAc,SAE1B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Command } from "commander";
2
+ export interface KeyInitOptions {
3
+ engagement: string;
4
+ keyFile?: string;
5
+ /** Test seam; defaults to `os.homedir()`. */
6
+ homeDir?: string;
7
+ }
8
+ /**
9
+ * The only place outside repo mode that mints a grant-signing key. Writes 32
10
+ * random bytes as hex at mode 0600 (directory 0700) and refuses to overwrite:
11
+ * replacing a key silently invalidates every grant already issued under it.
12
+ * Prints the path and fingerprint, never the key.
13
+ */
14
+ export declare function grantKeyInitCommand(options: KeyInitOptions): Promise<void>;
15
+ export declare const grantKeyCommander: Command;
16
+ //# sourceMappingURL=key-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-init.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/key-init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAsBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,eAAO,MAAM,iBAAiB,SAE7B,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * `hexagen grant list`: a read-only listing of `.hexagen/grants/`, so an FDE can
4
+ * see every grant, whether each is live, expired or revoked, and which one
5
+ * verifies, without opening JSON by hand (plan 4, lane 4B).
6
+ *
7
+ * Three rules the listing is built on:
8
+ *
9
+ * - The window is never recomputed here. A row's status comes from
10
+ * `checkGrantWindow` (the same call `grant show` and `grant check` make), and
11
+ * its signature verdict from `verifyGrantSignature` (the same two the
12
+ * workbook export uses), so a listing cannot disagree with enforcement.
13
+ * - Every entry in the directory becomes a row, including every refusal the
14
+ * shared enumerator returns and every error one raises. That is the one
15
+ * deliberate difference from `workbook export`, which fails the whole call
16
+ * instead: a listing is diagnostic, and one unreadable grant must not hide
17
+ * the others.
18
+ * - A symlink is classified from its own `lstat` and never read, so it prints
19
+ * as `invalid: symlink` rather than as the enumerator's refusal wording.
20
+ * `readAllowed` still runs its own lstat and its `O_NOFOLLOW` read below that
21
+ * point; this is a reason, not a second read guard.
22
+ *
23
+ * It reads only. It prints the key's path and fingerprint, never the key.
24
+ */
25
+ /** The statuses a row can carry, and the filters `--status` accepts. */
26
+ export declare const GRANT_LIST_STATUSES: readonly ["live", "expired", "revoked", "invalid", "all"];
27
+ export type GrantListFilter = (typeof GRANT_LIST_STATUSES)[number];
28
+ /** What a row's status column says: `--status all` matches every one of them. */
29
+ export type GrantRowStatus = Exclude<GrantListFilter, "all">;
30
+ export interface GrantListRow {
31
+ /** Path relative to `.hexagen/` (forward slashes). */
32
+ readonly file: string;
33
+ readonly id?: string;
34
+ readonly principal?: string;
35
+ readonly agent?: string;
36
+ readonly mode?: string;
37
+ readonly expires_at?: string;
38
+ readonly revoked_at?: string;
39
+ readonly status: GrantRowStatus;
40
+ readonly signature: "verified" | "not verified" | "invalid";
41
+ /** Why the signature failed, or why the row is invalid. Never key material. */
42
+ readonly reason?: string;
43
+ }
44
+ export interface GrantListOptions {
45
+ /** A `GRANT_LIST_STATUSES` member; anything else is bad input. */
46
+ status?: string;
47
+ json?: boolean;
48
+ workspaceRoot?: string;
49
+ keyFile?: string;
50
+ engagement?: string;
51
+ /** Test seams. */
52
+ homeDir?: string;
53
+ env?: Readonly<Record<string, string | undefined>>;
54
+ now?: Date;
55
+ /**
56
+ * Test seam: runs inside every guarded read, after the enumerator's checks
57
+ * and before the bytes are read (the hook `openSidecar` already takes).
58
+ */
59
+ afterValidate?: (file: string) => Promise<void>;
60
+ }
61
+ /**
62
+ * The row an entry that raised instead of returning gets. `readAllowed` refuses
63
+ * the cases it knows about and its wording is kept verbatim. Anything else it
64
+ * raises is an fs error (ENOENT when an entry vanishes between its lstat and its
65
+ * realpath, EACCES, ELOOP, ENOTDIR) or a parse verdict that escaped: all of them
66
+ * are the same kind of finding about the same file, so they become the same kind
67
+ * of row rather than stopping the listing and hiding every other grant.
68
+ */
69
+ export declare function unreadableRow(file: string, error: unknown): GrantListRow;
70
+ export declare function grantListCommand(options: GrantListOptions): Promise<void>;
71
+ export declare const grantListCommander: Command;
72
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/grant/list.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE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