moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/**
* Codex PreCompact hook — fired just before Codex truncates context.
* Triggers `cleanup_frames` so superseded P/B frames merge before the
* native compaction step. Thin entrypoint over the shared handler body.
* Codex carries the compaction `trigger` (`manual|auto`) on the payload.
*/
import {
makePreCompactHandler,
runHook,
type HookRunOptions,
} from '@waggle/hive-mind-hooks-core';
import { codexAdapter } from '../adapter.js';
export async function runPreCompact(opts: Partial<HookRunOptions> = {}): Promise<void> {
return runHook(makePreCompactHandler(codexAdapter), {
name: 'pre-compact',
loggerPrefix: 'codex-hooks',
...opts,
});
}
const isMain = (() => {
try {
if (typeof process.argv[1] !== 'string') return false;
const url = new URL(`file://${process.argv[1].replace(/\\/g, '/')}`);
return url.href === import.meta.url;
} catch {
return false;
}
})();
if (isMain) {
void runPreCompact();
}

View File

@@ -0,0 +1,37 @@
/**
* Codex SessionStart hook — recalls the top-N most relevant frames from
* personal memory and injects them as additional context for the new
* Codex session. Thin entrypoint over the shared handler body.
*
* If hive-mind-cli is unreachable, the hook logs and exits 0 with no
* output (fail-open) — the session starts as it would have without the
* shim.
*/
import {
makeSessionStartHandler,
runHook,
type HookRunOptions,
} from '@waggle/hive-mind-hooks-core';
import { codexAdapter } from '../adapter.js';
export async function runSessionStart(opts: Partial<HookRunOptions> = {}): Promise<void> {
return runHook(makeSessionStartHandler(codexAdapter), {
name: 'session-start',
loggerPrefix: 'codex-hooks',
...opts,
});
}
const isMain = (() => {
try {
if (typeof process.argv[1] !== 'string') return false;
const url = new URL(`file://${process.argv[1].replace(/\\/g, '/')}`);
return url.href === import.meta.url;
} catch {
return false;
}
})();
if (isMain) {
void runSessionStart();
}

View File

@@ -0,0 +1,35 @@
/**
* Codex Stop hook — fired when an assistant turn completes. Summarizes the
* turn deterministically (no LLM call) and writes it as an `important`
* frame parented to the originating prompt frame when known. Thin
* entrypoint over the shared handler body; the adapter reads codex's
* `last_assistant_message` in the response fallback list.
*/
import {
makeStopHandler,
runHook,
type HookRunOptions,
} from '@waggle/hive-mind-hooks-core';
import { codexAdapter } from '../adapter.js';
export async function runStop(opts: Partial<HookRunOptions> = {}): Promise<void> {
return runHook(makeStopHandler(codexAdapter), {
name: 'stop',
loggerPrefix: 'codex-hooks',
...opts,
});
}
const isMain = (() => {
try {
if (typeof process.argv[1] !== 'string') return false;
const url = new URL(`file://${process.argv[1].replace(/\\/g, '/')}`);
return url.href === import.meta.url;
} catch {
return false;
}
})();
if (isMain) {
void runStop();
}

View File

@@ -0,0 +1,33 @@
/**
* Codex UserPromptSubmit hook — captures the user prompt as a temporary
* frame scoped to the current Codex session. Thin entrypoint over the
* shared handler body. No stdout output: pure side-effect on the .mind file.
*/
import {
makeUserPromptSubmitHandler,
runHook,
type HookRunOptions,
} from '@waggle/hive-mind-hooks-core';
import { codexAdapter } from '../adapter.js';
export async function runUserPromptSubmit(opts: Partial<HookRunOptions> = {}): Promise<void> {
return runHook(makeUserPromptSubmitHandler(codexAdapter), {
name: 'user-prompt-submit',
loggerPrefix: 'codex-hooks',
...opts,
});
}
const isMain = (() => {
try {
if (typeof process.argv[1] !== 'string') return false;
const url = new URL(`file://${process.argv[1].replace(/\\/g, '/')}`);
return url.href === import.meta.url;
} catch {
return false;
}
})();
if (isMain) {
void runUserPromptSubmit();
}