@praxisflux/gates 0.61.0 → 0.61.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.
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
//
|
|
19
19
|
// Contract (Claude Code Stop hook): stdin is JSON with { stop_hook_active, session_id, cwd, … };
|
|
20
20
|
// exit 0 = allow the model to stop; exit 2 = block, and stderr becomes the message it sees.
|
|
21
|
+
//
|
|
22
|
+
// Root resolution in evaluate() (spec 062), most specific first: explicit { cwd } option ->
|
|
23
|
+
// $CLAUDE_PROJECT_DIR -> input.cwd -> process.cwd(). An explicit argument is a caller naming a
|
|
24
|
+
// directory on purpose and must never be silently overridden by an ambient variable. The env
|
|
25
|
+
// var still outranks input.cwd: it's the harness's authoritative statement of the project root,
|
|
26
|
+
// while input.cwd is merely where the hook happened to fire (a worktree, a subdir, wherever the
|
|
27
|
+
// session sat). The only production caller, runStopHook below, passes no cwd, so this ordering
|
|
28
|
+
// is byte-identical to before for the real Stop-hook path.
|
|
21
29
|
|
|
22
30
|
/** Read all of stdin as a string (empty string on a TTY, so it's safe to run by hand). */
|
|
23
31
|
export function readStdin() {
|
|
@@ -34,9 +42,9 @@ export function readStdin() {
|
|
|
34
42
|
* Pure core: given the parsed hook input and the gates, return { block, message }.
|
|
35
43
|
* Separated from process I/O so it is unit-testable.
|
|
36
44
|
*/
|
|
37
|
-
export function evaluate(input, gates, { cwd =
|
|
45
|
+
export function evaluate(input, gates, { cwd = undefined } = {}) {
|
|
38
46
|
if (input && input.stop_hook_active === true) return { block: false, message: "", warnings: "" };
|
|
39
|
-
const start = process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || cwd;
|
|
47
|
+
const start = cwd || process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || process.cwd();
|
|
40
48
|
const ctx = {
|
|
41
49
|
sessionId: (input && input.session_id) || process.env.CLAUDE_CODE_SESSION_ID || null,
|
|
42
50
|
input: input || {},
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
//
|
|
19
19
|
// Contract (Claude Code Stop hook): stdin is JSON with { stop_hook_active, session_id, cwd, … };
|
|
20
20
|
// exit 0 = allow the model to stop; exit 2 = block, and stderr becomes the message it sees.
|
|
21
|
+
//
|
|
22
|
+
// Root resolution in evaluate() (spec 062), most specific first: explicit { cwd } option ->
|
|
23
|
+
// $CLAUDE_PROJECT_DIR -> input.cwd -> process.cwd(). An explicit argument is a caller naming a
|
|
24
|
+
// directory on purpose and must never be silently overridden by an ambient variable. The env
|
|
25
|
+
// var still outranks input.cwd: it's the harness's authoritative statement of the project root,
|
|
26
|
+
// while input.cwd is merely where the hook happened to fire (a worktree, a subdir, wherever the
|
|
27
|
+
// session sat). The only production caller, runStopHook below, passes no cwd, so this ordering
|
|
28
|
+
// is byte-identical to before for the real Stop-hook path.
|
|
21
29
|
|
|
22
30
|
/** Read all of stdin as a string (empty string on a TTY, so it's safe to run by hand). */
|
|
23
31
|
export function readStdin() {
|
|
@@ -34,9 +42,9 @@ export function readStdin() {
|
|
|
34
42
|
* Pure core: given the parsed hook input and the gates, return { block, message }.
|
|
35
43
|
* Separated from process I/O so it is unit-testable.
|
|
36
44
|
*/
|
|
37
|
-
export function evaluate(input, gates, { cwd =
|
|
45
|
+
export function evaluate(input, gates, { cwd = undefined } = {}) {
|
|
38
46
|
if (input && input.stop_hook_active === true) return { block: false, message: "", warnings: "" };
|
|
39
|
-
const start = process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || cwd;
|
|
47
|
+
const start = cwd || process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || process.cwd();
|
|
40
48
|
const ctx = {
|
|
41
49
|
sessionId: (input && input.session_id) || process.env.CLAUDE_CODE_SESSION_ID || null,
|
|
42
50
|
input: input || {},
|
package/lib/gate-runner.mjs
CHANGED
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
//
|
|
19
19
|
// Contract (Claude Code Stop hook): stdin is JSON with { stop_hook_active, session_id, cwd, … };
|
|
20
20
|
// exit 0 = allow the model to stop; exit 2 = block, and stderr becomes the message it sees.
|
|
21
|
+
//
|
|
22
|
+
// Root resolution in evaluate() (spec 062), most specific first: explicit { cwd } option ->
|
|
23
|
+
// $CLAUDE_PROJECT_DIR -> input.cwd -> process.cwd(). An explicit argument is a caller naming a
|
|
24
|
+
// directory on purpose and must never be silently overridden by an ambient variable. The env
|
|
25
|
+
// var still outranks input.cwd: it's the harness's authoritative statement of the project root,
|
|
26
|
+
// while input.cwd is merely where the hook happened to fire (a worktree, a subdir, wherever the
|
|
27
|
+
// session sat). The only production caller, runStopHook below, passes no cwd, so this ordering
|
|
28
|
+
// is byte-identical to before for the real Stop-hook path.
|
|
21
29
|
|
|
22
30
|
/** Read all of stdin as a string (empty string on a TTY, so it's safe to run by hand). */
|
|
23
31
|
export function readStdin() {
|
|
@@ -34,9 +42,9 @@ export function readStdin() {
|
|
|
34
42
|
* Pure core: given the parsed hook input and the gates, return { block, message }.
|
|
35
43
|
* Separated from process I/O so it is unit-testable.
|
|
36
44
|
*/
|
|
37
|
-
export function evaluate(input, gates, { cwd =
|
|
45
|
+
export function evaluate(input, gates, { cwd = undefined } = {}) {
|
|
38
46
|
if (input && input.stop_hook_active === true) return { block: false, message: "", warnings: "" };
|
|
39
|
-
const start = process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || cwd;
|
|
47
|
+
const start = cwd || process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || process.cwd();
|
|
40
48
|
const ctx = {
|
|
41
49
|
sessionId: (input && input.session_id) || process.env.CLAUDE_CODE_SESSION_ID || null,
|
|
42
50
|
input: input || {},
|
package/package.json
CHANGED
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
//
|
|
19
19
|
// Contract (Claude Code Stop hook): stdin is JSON with { stop_hook_active, session_id, cwd, … };
|
|
20
20
|
// exit 0 = allow the model to stop; exit 2 = block, and stderr becomes the message it sees.
|
|
21
|
+
//
|
|
22
|
+
// Root resolution in evaluate() (spec 062), most specific first: explicit { cwd } option ->
|
|
23
|
+
// $CLAUDE_PROJECT_DIR -> input.cwd -> process.cwd(). An explicit argument is a caller naming a
|
|
24
|
+
// directory on purpose and must never be silently overridden by an ambient variable. The env
|
|
25
|
+
// var still outranks input.cwd: it's the harness's authoritative statement of the project root,
|
|
26
|
+
// while input.cwd is merely where the hook happened to fire (a worktree, a subdir, wherever the
|
|
27
|
+
// session sat). The only production caller, runStopHook below, passes no cwd, so this ordering
|
|
28
|
+
// is byte-identical to before for the real Stop-hook path.
|
|
21
29
|
|
|
22
30
|
/** Read all of stdin as a string (empty string on a TTY, so it's safe to run by hand). */
|
|
23
31
|
export function readStdin() {
|
|
@@ -34,9 +42,9 @@ export function readStdin() {
|
|
|
34
42
|
* Pure core: given the parsed hook input and the gates, return { block, message }.
|
|
35
43
|
* Separated from process I/O so it is unit-testable.
|
|
36
44
|
*/
|
|
37
|
-
export function evaluate(input, gates, { cwd =
|
|
45
|
+
export function evaluate(input, gates, { cwd = undefined } = {}) {
|
|
38
46
|
if (input && input.stop_hook_active === true) return { block: false, message: "", warnings: "" };
|
|
39
|
-
const start = process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || cwd;
|
|
47
|
+
const start = cwd || process.env.CLAUDE_PROJECT_DIR || (input && input.cwd) || process.cwd();
|
|
40
48
|
const ctx = {
|
|
41
49
|
sessionId: (input && input.session_id) || process.env.CLAUDE_CODE_SESSION_ID || null,
|
|
42
50
|
input: input || {},
|