@brainervirus/workit-core 2.4.0 → 2.6.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.
@@ -12,6 +12,20 @@ const NONE: HookDecision = { kind: "none" };
12
12
  /** Sessions already offered unfinished tasks in this process. */
13
13
  const offered = new Set<string>();
14
14
 
15
+ /** The Workit plugin's worktree-isolated implementer is the one Claude Code
16
+ * subagent that writes. Claude namespaces plugin agents, so only the exact
17
+ * `workit:implementer` is ours: a bare or other-plugin `implementer` is not. */
18
+ const CLAUDE_WORKTREE_IMPLEMENTER = "workit:implementer";
19
+
20
+ const subagentStartText = (
21
+ host: HookInput["host"],
22
+ descriptor: HostDescriptor,
23
+ event: Extract<HookInput["event"], { kind: "subagent.start" }>,
24
+ ): string =>
25
+ host === "claude_code" && event.agentType === CLAUDE_WORKTREE_IMPLEMENTER
26
+ ? `Workit observed ${descriptor.label} subagent ${event.agentId} (${event.agentType}) working in its own git worktree: it may edit and commit there, within its brief's scope. Before the first commit, switch to a policy-compliant branch (\`git switch -c <type>/<slug>\`, e.g. feature/<slug>); branch policy hooks still deny protected or non-compliant branches. Never push, open a PR, or merge unless the brief asks for it.`
27
+ : `Workit observed ${descriptor.label} subagent ${event.agentId} (${event.agentType}) as read-only/agent-guided; writer delegation is unavailable.`;
28
+
15
29
  export function handleHook(input: HookInput, deps: HookDeps): HookDecision {
16
30
  const { descriptor } = deps;
17
31
  const event = input.event;
@@ -36,10 +50,7 @@ export function handleHook(input: HookInput, deps: HookDeps): HookDecision {
36
50
  case "shell.pre":
37
51
  return usable(descriptor.shellPolicy.deny) ? shellPolicy(input.cwd, event.command) : NONE;
38
52
  case "subagent.start":
39
- return {
40
- kind: "context",
41
- text: `Workit observed ${descriptor.label} subagent ${event.agentId} (${event.agentType}) as read-only/agent-guided; writer delegation is unavailable.`,
42
- };
53
+ return { kind: "context", text: subagentStartText(input.host, descriptor, event) };
43
54
  case "compact.pre":
44
55
  return {
45
56
  kind: "notice",
package/src/ledger.ts CHANGED
@@ -62,7 +62,7 @@ export type VerdictSurface = (typeof VERDICT_SURFACES)[number];
62
62
  export type Observer = "agent_asserted" | "workit_cli";
63
63
 
64
64
  /** Row types written by the CLI's own PR verbs (S10/S11); the only PR→branch source. */
65
- export const PR_ROW_TYPES: ReadonlySet<string> = new Set(["pr.created", "pr.status"]);
65
+ export const PR_ROW_TYPES: ReadonlySet<string> = new Set(["pr.created", "pr.status", "pr.merged"]);
66
66
 
67
67
  /** Who wrote a row. Unverified: the environment says so (D18). */
68
68
  export type LedgerActor = { host: string; session: string | null; agentId: string | null };
@@ -1156,6 +1156,22 @@ export function summarizeRow(row: ReadRow): RowSummary {
1156
1156
  case "handoff":
1157
1157
  summary = `next: ${text("next")}${text("note") ? ` (note: ${text("note")})` : ""}`;
1158
1158
  break;
1159
+ case "commit.recorded":
1160
+ summary = `${(row.head ?? "?").slice(0, 12)} ${text("subject")}${row.actor.session ? "" : " (no session)"}`;
1161
+ break;
1162
+ case "push.verified":
1163
+ case "push.noop":
1164
+ summary = `${text("remote")} ${(str(row.previous) ?? "(new)").slice(0, 12)} -> ${(row.head ?? "?").slice(0, 12)}${row.forced === true ? " (force-with-lease)" : ""}`;
1165
+ break;
1166
+ case "pr.created":
1167
+ summary = `#${row.pr ?? "?"} -> ${text("base")} at ${(row.head ?? "?").slice(0, 12)}${row.created === false ? " (existing)" : ""}`;
1168
+ break;
1169
+ case "pr.merged":
1170
+ summary = `#${row.pr ?? "?"} ${text("method")} at ${(row.head ?? "?").slice(0, 12)}${text("mergeSha") ? ` -> ${text("mergeSha").slice(0, 12)}` : ""}`;
1171
+ break;
1172
+ case "delivery.verified":
1173
+ summary = `${text("expect")} delivered at ${(row.head ?? "?").slice(0, 12)}`;
1174
+ break;
1159
1175
  default:
1160
1176
  summary = text("what") || text("name") || row.type;
1161
1177
  }