mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 15:04:52 +00:00
Move exec to HookAPI, sessionManager/modelRegistry to HookEventContext
Breaking changes: - HookEventContext now has sessionManager and modelRegistry (moved from SessionEventBase) - HookAPI now has exec() method (moved from HookEventContext/HookCommandContext) - HookRunner constructor takes sessionManager and modelRegistry as required params - Session events no longer include sessionManager/modelRegistry fields Hook code migration: - event.sessionManager -> ctx.sessionManager - event.modelRegistry -> ctx.modelRegistry - ctx.exec() -> pi.exec() Updated: - src/core/hooks/types.ts - type changes - src/core/hooks/runner.ts - constructor, createContext - src/core/hooks/loader.ts - add exec to HookAPI - src/core/sdk.ts - pass sessionManager/modelRegistry to HookRunner - src/core/agent-session.ts - remove sessionManager/modelRegistry from events - src/modes/* - remove setSessionFile calls, update events - examples/hooks/* - update to new API
This commit is contained in:
parent
7ed8e2e9fc
commit
29fec7848e
14 changed files with 78 additions and 90 deletions
|
|
@ -12,7 +12,7 @@ export default function (pi: HookAPI) {
|
|||
if (event.reason !== "shutdown") return;
|
||||
|
||||
// Check for uncommitted changes
|
||||
const { stdout: status, code } = await ctx.exec("git", ["status", "--porcelain"]);
|
||||
const { stdout: status, code } = await pi.exec("git", ["status", "--porcelain"]);
|
||||
|
||||
if (code !== 0 || status.trim().length === 0) {
|
||||
// Not a git repo or no changes
|
||||
|
|
@ -20,7 +20,7 @@ export default function (pi: HookAPI) {
|
|||
}
|
||||
|
||||
// Find the last assistant message for commit context
|
||||
const entries = event.sessionManager.getEntries();
|
||||
const entries = ctx.sessionManager.getEntries();
|
||||
let lastAssistantText = "";
|
||||
for (let i = entries.length - 1; i >= 0; i--) {
|
||||
const entry = entries[i];
|
||||
|
|
@ -41,8 +41,8 @@ export default function (pi: HookAPI) {
|
|||
const commitMessage = `[pi] ${firstLine.slice(0, 50)}${firstLine.length > 50 ? "..." : ""}`;
|
||||
|
||||
// Stage and commit
|
||||
await ctx.exec("git", ["add", "-A"]);
|
||||
const { code: commitCode } = await ctx.exec("git", ["commit", "-m", commitMessage]);
|
||||
await pi.exec("git", ["add", "-A"]);
|
||||
const { code: commitCode } = await pi.exec("git", ["commit", "-m", commitMessage]);
|
||||
|
||||
if (commitCode === 0 && ctx.hasUI) {
|
||||
ctx.ui.notify(`Auto-committed: ${commitMessage}`, "info");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue