@brainervirus/workit-claude-code 8.20.0 → 8.21.1

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "workit",
3
3
  "displayName": "Workit",
4
- "version": "8.20.0",
4
+ "version": "8.21.1",
5
5
  "description": "Workflow rails for agentic coding: task context on every session, branch policy on shell commands, and the workit method skills",
6
6
  "author": {
7
7
  "name": "BrainerVirus"
@@ -12,6 +12,7 @@
12
12
  // proceeds as if no Workit hook were installed (no context, no branch
13
13
  // policy): a broken hook must never brick the host.
14
14
  import { spawnSync } from "node:child_process";
15
+ import { createHash } from "node:crypto";
15
16
  import { existsSync, readFileSync, statSync } from "node:fs";
16
17
  import os from "node:os";
17
18
  import path from "node:path";
@@ -155,6 +156,49 @@ const mentionsIssued = (text) => {
155
156
  return /issued/i.test(text) || flat(text).includes(flat(stateDir()));
156
157
  };
157
158
 
159
+ // A standing order the lead added or cleared since this agent last looked
160
+ // (`<store>/standing/rev` against its `standing/seen/<key>.json`) rides the
161
+ // next tool call, so that call loads the runtime. A copy of
162
+ // workit-core/src/hooks/standing-signal.ts (a test holds them equal).
163
+ const gitStoreDir = (cwd) => {
164
+ try {
165
+ for (let dir = path.resolve(cwd); ; dir = path.dirname(dir)) {
166
+ const dotGit = path.join(dir, ".git");
167
+ if (existsSync(dotGit)) {
168
+ let gitDir = dotGit;
169
+ if (statSync(dotGit).isFile()) {
170
+ const target = /^gitdir:\s*(.+)$/mu.exec(readFileSync(dotGit, "utf8"))?.[1]?.trim();
171
+ if (!target) return null;
172
+ gitDir = path.resolve(dir, target);
173
+ const common = path.join(gitDir, "commondir");
174
+ if (existsSync(common))
175
+ gitDir = path.resolve(gitDir, readFileSync(common, "utf8").trim());
176
+ }
177
+ return path.join(gitDir, "workit");
178
+ }
179
+ if (path.dirname(dir) === dir) return null;
180
+ }
181
+ } catch {
182
+ return null;
183
+ }
184
+ };
185
+ const standingPending = (cwd, session, agentId) => {
186
+ const store = gitStoreDir(cwd);
187
+ if (!store || typeof session !== "string" || !session) return false;
188
+ let rev;
189
+ try {
190
+ rev = readFileSync(path.join(store, "standing", "rev"), "utf8").trim();
191
+ } catch {
192
+ return false;
193
+ }
194
+ if (!rev) return false;
195
+ const key = createHash("sha256")
196
+ .update(`${session}\0${typeof agentId === "string" ? agentId : ""}`)
197
+ .digest("hex")
198
+ .slice(0, 32);
199
+ return readJson(path.join(store, "standing", "seen", `${key}.json`))?.rev !== rev;
200
+ };
201
+
158
202
  const fastAllow = (() => {
159
203
  try {
160
204
  const value = JSON.parse(payload);
@@ -163,6 +207,7 @@ const fastAllow = (() => {
163
207
  return typeof command === "string" && !/\bcommit\b/.test(command);
164
208
  if (value?.hook_event_name !== "PreToolUse") return false;
165
209
  if (mentionsIssued(JSON.stringify(value.tool_input ?? {}))) return false;
210
+ if (standingPending(String(value.cwd ?? "."), value.session_id, value.agent_id)) return false;
166
211
  if (SHELLS.has(value.tool_name) && typeof command === "string") {
167
212
  if (WORKIT_DELIVERY.test(command)) return false;
168
213
  if (maybeHeavy(command, String(value.cwd ?? "."))) return false;