fix: missing sawMessage init in accumulator literal; add pre-commit port typecheck hook
All checks were successful
port-to-omp / port (push) Successful in 5s
All checks were successful
port-to-omp / port (push) Successful in 5s
The CI port job's tsc --noEmit caught SessionEventAccumulator literals not initializing the new sawMessage field (tests don't typecheck, so bun test was green). Add a committed .githooks/pre-commit that mirrors the CI port job — regenerate the port into a temp dir and tsc --noEmit it — so this class of error fails at commit time, not in CI.
This commit is contained in:
37
.githooks/pre-commit
Executable file
37
.githooks/pre-commit
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# pre-commit — typecheck the generated omp port before committing.
|
||||||
|
#
|
||||||
|
# Mirrors the CI port job (.gitea/workflows/port-to-omp.yml). The source
|
||||||
|
# repo's own tsconfig extends the host harness tsconfig and is not
|
||||||
|
# self-contained, so the reliable typecheck target is the regenerated port:
|
||||||
|
# it ships a self-contained tsconfig and the pinned @oh-my-pi SDK as a real
|
||||||
|
# devDependency. Regenerating into a temp dir and running `tsc --noEmit`
|
||||||
|
# there catches exactly what CI will fail on (e.g. an interface field added
|
||||||
|
# without updating its object literals).
|
||||||
|
#
|
||||||
|
# Enable (per clone): git config core.hooksPath .githooks
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
# Fast path: no TypeScript-adjacent change staged -> nothing to typecheck.
|
||||||
|
if git diff --cached --quiet -- src/ agents/ package.json tsconfig.json port-to-omp.mjs; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TMP="$(mktemp -d)"
|
||||||
|
LOG="$(mktemp)"
|
||||||
|
trap 'rm -rf "$TMP" "$LOG"' EXIT
|
||||||
|
|
||||||
|
if ! bun port-to-omp.mjs --out "$TMP" >"$LOG" 2>&1; then
|
||||||
|
echo "pre-commit: port regeneration failed (CI would fail too) — output:" >&2
|
||||||
|
tail -20 "$LOG" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! (cd "$TMP" && bun run typecheck) >"$LOG" 2>&1; then
|
||||||
|
echo "pre-commit: port typecheck failed (this is what CI runs) — output:" >&2
|
||||||
|
tail -30 "$LOG" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
15
README.md
15
README.md
@@ -202,6 +202,21 @@ pygienium/
|
|||||||
└─ agents/ ← scanner.md fixer.md deep-modules.md defensive-guards.md
|
└─ agents/ ← scanner.md fixer.md deep-modules.md defensive-guards.md
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
The omp port at `~/.omp/agent/extensions/pygienium` is regenerated **only by CI
|
||||||
|
on push** (`.gitea/workflows/port-to-omp.yml`) — never by hand.
|
||||||
|
|
||||||
|
The source repo's own `tsconfig.json` extends the host harness tsconfig, so the
|
||||||
|
reliable typecheck target is the regenerated port (self-contained tsconfig +
|
||||||
|
pinned `@oh-my-pi` SDK devDependency). A committed pre-commit hook runs exactly
|
||||||
|
what CI runs — regenerate the port into a temp dir and `tsc --noEmit` it — and
|
||||||
|
fails the commit on any error:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ async function runSessionToCompletion(
|
|||||||
session: AgentSession,
|
session: AgentSession,
|
||||||
opts: AgentTaskOptions,
|
opts: AgentTaskOptions,
|
||||||
): Promise<AgentRunResult> {
|
): Promise<AgentRunResult> {
|
||||||
const acc: SessionEventAccumulator = { text: "" };
|
const acc: SessionEventAccumulator = { text: "", sawMessage: false };
|
||||||
try {
|
try {
|
||||||
const unsubscribe = session.subscribe((event: AgentSessionEvent) => {
|
const unsubscribe = session.subscribe((event: AgentSessionEvent) => {
|
||||||
applySessionEvent(acc, event, opts.onEvent);
|
applySessionEvent(acc, event, opts.onEvent);
|
||||||
|
|||||||
Reference in New Issue
Block a user