@tayomi/deterministic-gates 0.4.2 → 0.5.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/catalog/angular.json +85 -0
- package/catalog/index.html +115 -1
- package/catalog/typescript.json +26 -0
- package/dist/src/cli.js +3 -3
- package/dist/src/core/check.js +30 -10
- package/dist/src/core/config.js +28 -2
- package/dist/src/core/run.js +26 -11
- package/dist/src/core/watch.js +280 -0
- package/dist/src/helpers/angular-watch.js +47 -0
- package/dist/src/helpers/type-errors.js +72 -0
- package/dist/src/helpers/vitest-state-reporter.js +26 -0
- package/dist/src/hook/hook.js +25 -1
- package/hooks/hooks.json +11 -0
- package/package.json +1 -1
- package/src/cli.ts +3 -3
- package/src/core/check.ts +29 -10
- package/src/core/config.ts +43 -2
- package/src/core/run.ts +29 -11
- package/src/core/watch.ts +310 -0
- package/src/helpers/angular-watch.ts +50 -0
- package/src/helpers/type-errors.ts +70 -0
- package/src/helpers/vitest-state-reporter.ts +48 -0
- package/src/hook/hook.ts +27 -2
package/src/hook/hook.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type CheckedTurn, checkTurn, startTurn } from "../core/check.ts";
|
|
1
|
+
import { type CheckedTurn, checkTurn, startSession, startTurn } from "../core/check.ts";
|
|
2
2
|
import { configuredRoot, gatesOf } from "../core/config.ts";
|
|
3
3
|
import { isRecord, messageOf, parseJson } from "../core/json.ts";
|
|
4
4
|
import { broken, failures, summary, toolsMissing, toolsToInstall } from "../core/report.ts";
|
|
5
5
|
import { type Judged, judge, waivesOf } from "../core/send-back.ts";
|
|
6
|
+
import { endSession } from "../core/watch.ts";
|
|
6
7
|
import { forgetTold, forgetTurn, readTurn, tellOnce, turnRoot, writeTurn } from "../core/turn-state.ts";
|
|
7
8
|
|
|
8
9
|
export interface HookInput {
|
|
@@ -20,7 +21,14 @@ export interface HookOutput {
|
|
|
20
21
|
hookSpecificOutput?: { hookEventName: "UserPromptSubmit"; additionalContext: string };
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
/** The events the plugin hooks, each named as the CLI takes it. */
|
|
25
|
+
export const HOOK_EVENTS = ["session-start", "turn-start", "check", "session-end"] as const;
|
|
26
|
+
|
|
27
|
+
export type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
28
|
+
|
|
29
|
+
export function isHookEvent(word: string | undefined): word is HookEvent {
|
|
30
|
+
return HOOK_EVENTS.some((event) => event === word);
|
|
31
|
+
}
|
|
24
32
|
|
|
25
33
|
export function parseHookInput(text: string): HookInput {
|
|
26
34
|
const input = parseJson(text);
|
|
@@ -76,6 +84,17 @@ function cannotRun(error: unknown): HookOutput {
|
|
|
76
84
|
return { systemMessage: broken(messageOf(error)) };
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
/**
|
|
88
|
+
* A session that starts starts the watches of its repo. Whatever stops them is told at the prompt, which reads the
|
|
89
|
+
* same gates.
|
|
90
|
+
*/
|
|
91
|
+
function sessionHook(session: string, cwd: string): void {
|
|
92
|
+
try {
|
|
93
|
+
const root = configuredRoot(cwd);
|
|
94
|
+
if (root !== undefined) startSession(session, root);
|
|
95
|
+
} catch {}
|
|
96
|
+
}
|
|
97
|
+
|
|
79
98
|
/**
|
|
80
99
|
* A prompt ends the turn in progress; from a folder with no gates, or when the turn cannot start, no check will look
|
|
81
100
|
* for a new one. When the gates of the repo miss tools, the agent is asked once to install them.
|
|
@@ -138,6 +157,12 @@ export async function handleHook(event: HookEvent, text: string): Promise<HookOu
|
|
|
138
157
|
// A session that starts, resumes or is cleared asks again for the missing tools; a compaction goes on as it was.
|
|
139
158
|
if (event === "session-start") {
|
|
140
159
|
if (source !== "compact") forgetTold(session);
|
|
160
|
+
sessionHook(session, cwd);
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
// Codex gives a session that ends 3 s at most: the hook only stops the watches no other session uses.
|
|
164
|
+
if (event === "session-end") {
|
|
165
|
+
endSession(session);
|
|
141
166
|
return undefined;
|
|
142
167
|
}
|
|
143
168
|
return event === "turn-start" ? promptHook(session, cwd) : stopHook(session, cwd, retry, message);
|