@jeffober/thatch 0.2.2 → 0.2.4
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/bin/thatch +77 -46
- package/docs/dev/README.md +21 -25
- package/docs/dev/features/cli.md +1 -0
- package/docs/dev/features/extraction.md +120 -81
- package/docs/dev/features/nudge-pipeline.md +44 -39
- package/docs/dev/features/session-lifecycle.md +34 -20
- package/docs/dev/features/setup.md +7 -0
- package/docs/dev/features/watchers.md +9 -0
- package/docs/dev/gotchas.md +20 -26
- package/docs/dev/mcp-parity.md +16 -17
- package/docs/dev/setup-and-hooks.md +1 -1
- package/docs/user/cli.md +2 -1
- package/docs/user/setup.md +13 -0
- package/docs/user/watchers.md +6 -0
- package/package.json +1 -1
- package/src/chat.ts +1 -1
- package/src/extract-queue.ts +16 -1
- package/src/extraction.ts +4 -3
- package/src/opencode/v2.ts +4 -3
- package/src/prompts.ts +12 -33
- package/src/runtime.ts +110 -107
- package/src/setup.ts +50 -0
- package/src/tool-defs.ts +39 -31
- package/src/watchers.ts +31 -0
package/src/watchers.ts
CHANGED
|
@@ -703,6 +703,37 @@ export async function fetchBranchState(gh: GhRunner, repo: string, branch: strin
|
|
|
703
703
|
/** At most this many events per watcher per cycle; comment floods collapse. */
|
|
704
704
|
const MAX_EVENTS_PER_DIFF = 10;
|
|
705
705
|
|
|
706
|
+
/**
|
|
707
|
+
* Describes the check runs already present on a head at watcher creation,
|
|
708
|
+
* for the registration response. The diff only fires on a not-completed ->
|
|
709
|
+
* completed transition, so runs that are ALREADY completed in the baseline
|
|
710
|
+
* can never produce a CI event for this head - a watcher registered after a
|
|
711
|
+
* fast CI (one that finishes in under a minute) is silently dead for the
|
|
712
|
+
* head it was meant to cover. Saying so at creation lets the caller just
|
|
713
|
+
* read the result instead of waiting on a notification that cannot come.
|
|
714
|
+
* Returns null when there is nothing to say: no runs yet, or some still
|
|
715
|
+
* running (those WILL transition and notify).
|
|
716
|
+
*/
|
|
717
|
+
export function describeBaselineCheckRuns(checkRuns: Record<string, CheckRunRef>, headSha: string): string | null {
|
|
718
|
+
const runs = Object.values(checkRuns);
|
|
719
|
+
if (runs.length === 0) return null;
|
|
720
|
+
const completed = runs.filter((r) => r.status === "completed");
|
|
721
|
+
if (completed.length < runs.length) return null;
|
|
722
|
+
const counts = new Map<string, number>();
|
|
723
|
+
for (const r of completed) {
|
|
724
|
+
const key = r.conclusion ?? "no conclusion";
|
|
725
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
726
|
+
}
|
|
727
|
+
const breakdown = [...counts.entries()].map(([k, n]) => `${n} ${k}`).join(", ");
|
|
728
|
+
return (
|
|
729
|
+
`NOTE: all ${completed.length} check run${completed.length === 1 ? "" : "s"} on ${headSha.slice(0, 7)} ` +
|
|
730
|
+
`${completed.length === 1 ? "has" : "have"} already completed (${breakdown}). ` +
|
|
731
|
+
`CI events fire only on a running -> completed transition, so this watcher will NOT notify for this head's CI - ` +
|
|
732
|
+
`read the result now (gh api repos/<owner>/<repo>/commits/${headSha.slice(0, 7)}/check-runs) ` +
|
|
733
|
+
`rather than waiting. To catch a push's CI, register the watcher BEFORE pushing.`
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
|
|
706
737
|
/**
|
|
707
738
|
* Shared check-run diff: emits one event per run that reaches a completed
|
|
708
739
|
* status. A run that was already completed before produces nothing; a run
|