@bookedsolid/rea 0.1.0 → 0.2.1
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/.husky/commit-msg +130 -0
- package/.husky/pre-push +128 -0
- package/README.md +5 -5
- package/agents/codex-adversarial.md +23 -8
- package/commands/codex-review.md +2 -2
- package/dist/audit/append.d.ts +62 -0
- package/dist/audit/append.js +189 -0
- package/dist/audit/codex-event.d.ts +28 -0
- package/dist/audit/codex-event.js +15 -0
- package/dist/cli/doctor.d.ts +60 -1
- package/dist/cli/doctor.js +459 -20
- package/dist/cli/index.js +35 -5
- package/dist/cli/init.d.ts +13 -0
- package/dist/cli/init.js +278 -67
- package/dist/cli/install/canonical.d.ts +43 -0
- package/dist/cli/install/canonical.js +101 -0
- package/dist/cli/install/claude-md.d.ts +48 -0
- package/dist/cli/install/claude-md.js +93 -0
- package/dist/cli/install/commit-msg.d.ts +30 -0
- package/dist/cli/install/commit-msg.js +102 -0
- package/dist/cli/install/copy.d.ts +169 -0
- package/dist/cli/install/copy.js +455 -0
- package/dist/cli/install/fs-safe.d.ts +91 -0
- package/dist/cli/install/fs-safe.js +347 -0
- package/dist/cli/install/manifest-io.d.ts +12 -0
- package/dist/cli/install/manifest-io.js +44 -0
- package/dist/cli/install/manifest-schema.d.ts +83 -0
- package/dist/cli/install/manifest-schema.js +80 -0
- package/dist/cli/install/reagent.d.ts +59 -0
- package/dist/cli/install/reagent.js +160 -0
- package/dist/cli/install/settings-merge.d.ts +91 -0
- package/dist/cli/install/settings-merge.js +239 -0
- package/dist/cli/install/sha.d.ts +9 -0
- package/dist/cli/install/sha.js +21 -0
- package/dist/cli/serve.d.ts +11 -0
- package/dist/cli/serve.js +72 -6
- package/dist/cli/upgrade.d.ts +67 -0
- package/dist/cli/upgrade.js +509 -0
- package/dist/gateway/downstream-pool.d.ts +39 -0
- package/dist/gateway/downstream-pool.js +93 -0
- package/dist/gateway/downstream.d.ts +80 -0
- package/dist/gateway/downstream.js +196 -0
- package/dist/gateway/middleware/audit-types.d.ts +10 -0
- package/dist/gateway/middleware/audit.js +14 -0
- package/dist/gateway/middleware/injection.d.ts +59 -2
- package/dist/gateway/middleware/injection.js +91 -14
- package/dist/gateway/middleware/kill-switch.d.ts +20 -5
- package/dist/gateway/middleware/kill-switch.js +57 -35
- package/dist/gateway/middleware/redact.d.ts +83 -6
- package/dist/gateway/middleware/redact.js +133 -46
- package/dist/gateway/observability/codex-probe.d.ts +110 -0
- package/dist/gateway/observability/codex-probe.js +234 -0
- package/dist/gateway/observability/codex-telemetry.d.ts +93 -0
- package/dist/gateway/observability/codex-telemetry.js +221 -0
- package/dist/gateway/redact-safe/match-timeout.d.ts +83 -0
- package/dist/gateway/redact-safe/match-timeout.js +179 -0
- package/dist/gateway/reviewers/claude-self.d.ts +99 -0
- package/dist/gateway/reviewers/claude-self.js +316 -0
- package/dist/gateway/reviewers/codex.d.ts +64 -0
- package/dist/gateway/reviewers/codex.js +80 -0
- package/dist/gateway/reviewers/select.d.ts +64 -0
- package/dist/gateway/reviewers/select.js +102 -0
- package/dist/gateway/reviewers/types.d.ts +85 -0
- package/dist/gateway/reviewers/types.js +14 -0
- package/dist/gateway/server.d.ts +51 -0
- package/dist/gateway/server.js +258 -0
- package/dist/gateway/session.d.ts +9 -0
- package/dist/gateway/session.js +17 -0
- package/dist/policy/loader.d.ts +59 -0
- package/dist/policy/loader.js +65 -0
- package/dist/policy/profiles.d.ts +80 -0
- package/dist/policy/profiles.js +94 -0
- package/dist/policy/types.d.ts +38 -0
- package/dist/registry/loader.d.ts +98 -0
- package/dist/registry/loader.js +153 -0
- package/dist/registry/types.d.ts +44 -0
- package/dist/registry/types.js +6 -0
- package/dist/scripts/read-policy-field.d.ts +36 -0
- package/dist/scripts/read-policy-field.js +96 -0
- package/hooks/push-review-gate.sh +627 -17
- package/package.json +13 -2
- package/profiles/bst-internal-no-codex.yaml +40 -0
- package/profiles/bst-internal.yaml +23 -0
- package/profiles/client-engagement.yaml +23 -0
- package/profiles/lit-wc.yaml +17 -0
- package/profiles/minimal.yaml +11 -0
- package/profiles/open-source-no-codex.yaml +33 -0
- package/profiles/open-source.yaml +18 -0
- package/scripts/lint-safe-regex.mjs +78 -0
- package/scripts/postinstall.mjs +131 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type shapes for `.rea/registry.yaml`. The schema itself lives in
|
|
3
|
+
* `./loader.ts` — this file carries only the static TS surface so call sites
|
|
4
|
+
* can import types without dragging in zod.
|
|
5
|
+
*/
|
|
6
|
+
import type { Tier } from '../policy/types.js';
|
|
7
|
+
export interface RegistryServer {
|
|
8
|
+
/** Lowercase-kebab identifier used as the tool-name prefix (`<name>__<tool>`). */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Executable to spawn via stdio. Resolved through `PATH`. */
|
|
11
|
+
command: string;
|
|
12
|
+
/** Arguments passed to the spawned child process. */
|
|
13
|
+
args: string[];
|
|
14
|
+
/** Environment variables merged onto the child process env. */
|
|
15
|
+
env: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Optional opt-in list of operator-env var names to forward into the child.
|
|
18
|
+
* Names matching the secret-name heuristic (TOKEN/KEY/SECRET/PASSWORD/CREDENTIAL)
|
|
19
|
+
* are REFUSED at schema-parse time — use explicit `env:` mapping for those so
|
|
20
|
+
* the operator is making the decision consciously.
|
|
21
|
+
*/
|
|
22
|
+
env_passthrough?: string[];
|
|
23
|
+
/** Optional per-tool tier pins. Supplied verbatim to the tier middleware. */
|
|
24
|
+
tier_overrides?: Record<string, Tier>;
|
|
25
|
+
/** Set to `false` to keep the entry in the file but skip spawning. */
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Allowed values for `Registry.reviewer`. Extensions land here — don't
|
|
30
|
+
* accept unknown strings at parse time. The selector matches on these
|
|
31
|
+
* exact tokens.
|
|
32
|
+
*/
|
|
33
|
+
export type RegistryReviewer = 'codex' | 'claude-self';
|
|
34
|
+
export interface Registry {
|
|
35
|
+
version: '1';
|
|
36
|
+
servers: RegistryServer[];
|
|
37
|
+
/**
|
|
38
|
+
* Optional operator pin for the adversarial reviewer. When set, takes
|
|
39
|
+
* precedence over the default Codex-first selection but yields to the
|
|
40
|
+
* `REA_REVIEWER` env var. Unknown values are rejected at schema-parse
|
|
41
|
+
* time. Unset → default selector logic applies.
|
|
42
|
+
*/
|
|
43
|
+
reviewer?: RegistryReviewer;
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Tiny standalone helper used by shell hooks that need to consult a single
|
|
4
|
+
* scalar policy field without pulling in a full CLI subcommand.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node dist/scripts/read-policy-field.js <dotted.path>
|
|
8
|
+
*
|
|
9
|
+
* Exit codes:
|
|
10
|
+
* 0 — field resolved; value printed to stdout (single line, no trailing
|
|
11
|
+
* metadata).
|
|
12
|
+
* 1 — field is not present in the policy (also no policy file). stdout is
|
|
13
|
+
* empty; the caller should decide whether missing means "default" or
|
|
14
|
+
* "fail".
|
|
15
|
+
* 2 — the policy file exists but is malformed (YAML error, schema error,
|
|
16
|
+
* any exception). stderr carries a short diagnostic; stdout is empty.
|
|
17
|
+
*
|
|
18
|
+
* The split between 1 and 2 matters because the push gate fail-closes on
|
|
19
|
+
* malformed policy (treat codex_required=true) but is permitted to accept the
|
|
20
|
+
* documented default when the field is simply absent.
|
|
21
|
+
*
|
|
22
|
+
* ## Why a standalone script instead of a CLI subcommand?
|
|
23
|
+
*
|
|
24
|
+
* Shell hooks fire thousands of times a day. A full `rea policy get ...`
|
|
25
|
+
* subcommand would drag in commander, the prompts library, and the whole CLI
|
|
26
|
+
* surface for what is a one-line lookup. A dedicated script keeps the import
|
|
27
|
+
* graph tiny (loader + yaml + zod) and the startup cost minimal.
|
|
28
|
+
*
|
|
29
|
+
* ## Supported paths
|
|
30
|
+
*
|
|
31
|
+
* Only top-level and one-level-nested fields are supported; this matches the
|
|
32
|
+
* shape of the Policy schema. Anything deeper is an over-fetch that the
|
|
33
|
+
* caller should refactor to a schema method instead.
|
|
34
|
+
*/
|
|
35
|
+
declare function main(): number;
|
|
36
|
+
export { main as runReadPolicyField };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Tiny standalone helper used by shell hooks that need to consult a single
|
|
4
|
+
* scalar policy field without pulling in a full CLI subcommand.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node dist/scripts/read-policy-field.js <dotted.path>
|
|
8
|
+
*
|
|
9
|
+
* Exit codes:
|
|
10
|
+
* 0 — field resolved; value printed to stdout (single line, no trailing
|
|
11
|
+
* metadata).
|
|
12
|
+
* 1 — field is not present in the policy (also no policy file). stdout is
|
|
13
|
+
* empty; the caller should decide whether missing means "default" or
|
|
14
|
+
* "fail".
|
|
15
|
+
* 2 — the policy file exists but is malformed (YAML error, schema error,
|
|
16
|
+
* any exception). stderr carries a short diagnostic; stdout is empty.
|
|
17
|
+
*
|
|
18
|
+
* The split between 1 and 2 matters because the push gate fail-closes on
|
|
19
|
+
* malformed policy (treat codex_required=true) but is permitted to accept the
|
|
20
|
+
* documented default when the field is simply absent.
|
|
21
|
+
*
|
|
22
|
+
* ## Why a standalone script instead of a CLI subcommand?
|
|
23
|
+
*
|
|
24
|
+
* Shell hooks fire thousands of times a day. A full `rea policy get ...`
|
|
25
|
+
* subcommand would drag in commander, the prompts library, and the whole CLI
|
|
26
|
+
* surface for what is a one-line lookup. A dedicated script keeps the import
|
|
27
|
+
* graph tiny (loader + yaml + zod) and the startup cost minimal.
|
|
28
|
+
*
|
|
29
|
+
* ## Supported paths
|
|
30
|
+
*
|
|
31
|
+
* Only top-level and one-level-nested fields are supported; this matches the
|
|
32
|
+
* shape of the Policy schema. Anything deeper is an over-fetch that the
|
|
33
|
+
* caller should refactor to a schema method instead.
|
|
34
|
+
*/
|
|
35
|
+
import path from 'node:path';
|
|
36
|
+
import { loadPolicy } from '../policy/loader.js';
|
|
37
|
+
const EXIT_OK = 0;
|
|
38
|
+
const EXIT_MISSING = 1;
|
|
39
|
+
const EXIT_MALFORMED = 2;
|
|
40
|
+
function resolveDotted(obj, dottedPath) {
|
|
41
|
+
const parts = dottedPath.split('.');
|
|
42
|
+
let cursor = obj;
|
|
43
|
+
for (const key of parts) {
|
|
44
|
+
if (cursor === null || cursor === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (typeof cursor !== 'object')
|
|
47
|
+
return undefined;
|
|
48
|
+
cursor = cursor[key];
|
|
49
|
+
}
|
|
50
|
+
return cursor;
|
|
51
|
+
}
|
|
52
|
+
function main() {
|
|
53
|
+
const [, , dottedPath] = process.argv;
|
|
54
|
+
if (dottedPath === undefined || dottedPath.length === 0) {
|
|
55
|
+
process.stderr.write('usage: read-policy-field <dotted.path> (e.g. review.codex_required)\n');
|
|
56
|
+
return EXIT_MALFORMED;
|
|
57
|
+
}
|
|
58
|
+
const baseDir = process.env['REA_ROOT'] ?? process.cwd();
|
|
59
|
+
let policy;
|
|
60
|
+
try {
|
|
61
|
+
policy = loadPolicy(baseDir);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
65
|
+
// Distinguish "file missing" (exit 1) from "file present but malformed"
|
|
66
|
+
// (exit 2). loadPolicy throws a message starting with "Policy file not
|
|
67
|
+
// found" in the missing case.
|
|
68
|
+
if (/Policy file not found/.test(msg)) {
|
|
69
|
+
return EXIT_MISSING;
|
|
70
|
+
}
|
|
71
|
+
process.stderr.write(`read-policy-field: ${msg}\n`);
|
|
72
|
+
return EXIT_MALFORMED;
|
|
73
|
+
}
|
|
74
|
+
const value = resolveDotted(policy, dottedPath);
|
|
75
|
+
if (value === undefined) {
|
|
76
|
+
return EXIT_MISSING;
|
|
77
|
+
}
|
|
78
|
+
// Only emit scalars. Arrays and objects are refused so a caller can't
|
|
79
|
+
// accidentally get a JSON blob back and misparse it.
|
|
80
|
+
if (value === null || typeof value === 'object') {
|
|
81
|
+
process.stderr.write(`read-policy-field: ${dottedPath} is not a scalar (got ${value === null ? 'null' : typeof value})\n`);
|
|
82
|
+
return EXIT_MALFORMED;
|
|
83
|
+
}
|
|
84
|
+
process.stdout.write(String(value) + '\n');
|
|
85
|
+
return EXIT_OK;
|
|
86
|
+
}
|
|
87
|
+
// Only run when invoked as a script (not when imported in tests).
|
|
88
|
+
// path.basename strips the file extension differences between .js and .ts so
|
|
89
|
+
// this works in both the compiled and the ts-node paths.
|
|
90
|
+
const invokedAs = process.argv[1] ?? '';
|
|
91
|
+
if (path.basename(invokedAs).startsWith('read-policy-field')) {
|
|
92
|
+
process.exit(main());
|
|
93
|
+
}
|
|
94
|
+
// Exported for tests. Keeping the internal name distinct makes it obvious
|
|
95
|
+
// that this module has a CLI entry point.
|
|
96
|
+
export { main as runReadPolicyField };
|