@workit-dev/codex 2.10.0 → 2.11.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -30511,7 +30511,9 @@ var WORKIT_ALLOWED_VERBS = [
30511
30511
  "verify-delivery",
30512
30512
  "policy",
30513
30513
  "doctor",
30514
- "help"
30514
+ "help",
30515
+ "ps",
30516
+ "stop"
30515
30517
  ];
30516
30518
  var WORKIT_USER_ONLY = [
30517
30519
  ["release", "notes", "approve"],
@@ -30649,6 +30651,31 @@ var NPM_INSTALL = new Set([
30649
30651
  var NPM_RUN = new Set(["run", "run-script", "rum", "urn"]);
30650
30652
  var NPM_TEST = new Set(["test", "t", "tst"]);
30651
30653
  var EXEC = new Set(["exec", "x", "dlx"]);
30654
+ var NUXT = sub("dev", "preview", "start");
30655
+ var WEBPACK = sub("serve", "s", "server");
30656
+ var SERVER_TOOLS = {
30657
+ ng: sub("serve", "s"),
30658
+ next: sub("dev", "start"),
30659
+ nuxt: NUXT,
30660
+ nuxi: NUXT,
30661
+ astro: sub("dev", "preview"),
30662
+ "react-scripts": sub("start"),
30663
+ webpack: WEBPACK,
30664
+ "webpack-cli": WEBPACK,
30665
+ storybook: sub("dev", "start"),
30666
+ rails: sub("server", "s"),
30667
+ mix: sub("phx.server")
30668
+ };
30669
+ var COMPOSE_VALUES = new Set([
30670
+ "-f",
30671
+ "--file",
30672
+ "-p",
30673
+ "-H",
30674
+ "--host",
30675
+ "--context",
30676
+ "-c",
30677
+ "--config"
30678
+ ]);
30652
30679
 
30653
30680
  // packages/workit-core/src/core/heavy-words.ts
30654
30681
  var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ stateDir3
4
+ } from "./workit-hook-7jv519ep.js";
5
+
6
+ // packages/workit-core/src/hooks/server-gate.ts
7
+ import fs from "node:fs";
8
+ import path from "node:path";
9
+ var procNoticeFile2 = (env, session) => path.join(stateDir3(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
10
+ var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
11
+ function takeProcNotice2(session, env = process.env) {
12
+ if (!session)
13
+ return null;
14
+ const file = procNoticeFile2(env, session);
15
+ const taken = `${file}.${process.pid}.taken`;
16
+ try {
17
+ fs.renameSync(file, taken);
18
+ } catch {
19
+ return null;
20
+ }
21
+ try {
22
+ const { notices } = JSON.parse(fs.readFileSync(taken, "utf8"));
23
+ const lines = (Array.isArray(notices) ? notices : []).flatMap((notice) => {
24
+ if (!notice || typeof notice !== "object")
25
+ return [];
26
+ const { id, cmd, cwd, rssBytes, ceilingBytes } = notice;
27
+ if (typeof id !== "string")
28
+ return [];
29
+ return [
30
+ `- ${id} \`${String(cmd)}\` in ${String(cwd)}: ${mb(rssBytes)} (ceiling ${mb(ceilingBytes)}). Restart it: \`workit run --bg --restart ${id}\`, or \`workit stop ${id}\`.`
31
+ ];
32
+ });
33
+ return lines.length ? ["Workit: a background process you started is past the memory ceiling:", ...lines].join(`
34
+ `) : null;
35
+ } catch {
36
+ return null;
37
+ } finally {
38
+ try {
39
+ fs.rmSync(taken, { force: true });
40
+ } catch {}
41
+ }
42
+ }
43
+
44
+ export { procNoticeFile2, takeProcNotice2 };
@@ -24,6 +24,9 @@ import {
24
24
  readStandingSeen2,
25
25
  writeStandingSeen2
26
26
  } from "./workit-hook-jy7y0gdx.js";
27
+ import {
28
+ takeProcNotice2
29
+ } from "./workit-hook-btkg30rw.js";
27
30
  import {
28
31
  recordHookRun2
29
32
  } from "./workit-hook-w7w0fe4v.js";
@@ -17234,7 +17237,7 @@ function workitCheckTail(words) {
17234
17237
  } else if (!/^workit(?:\.exe|\.cmd)?$/.test(commandName(words[0])))
17235
17238
  return null;
17236
17239
  const { rest: args, cwd } = skipWorkitGlobals(words.slice(at + 1));
17237
- if (args[0] !== "check" && !(args[0] === "lock" && args[1] === "run"))
17240
+ if (args[0] !== "check" && args[0] !== "run" && !(args[0] === "lock" && args[1] === "run"))
17238
17241
  return null;
17239
17242
  const split = args.indexOf("--");
17240
17243
  const tail = split < 0 ? [] : args.slice(split + 1);
@@ -18616,7 +18619,9 @@ var WORKIT_ALLOWED_VERBS = [
18616
18619
  "verify-delivery",
18617
18620
  "policy",
18618
18621
  "doctor",
18619
- "help"
18622
+ "help",
18623
+ "ps",
18624
+ "stop"
18620
18625
  ];
18621
18626
  var WORKIT_BYPASS_FLAGS = ["--unverified", "--overwrite-unintegrated"];
18622
18627
  var WORKIT_USER_ONLY = [
@@ -19290,6 +19295,95 @@ function builtIn(words, depth = 0) {
19290
19295
  const command = words.slice(1).find((word) => !word.startsWith("-") && !word.startsWith("+") || rule.has(word));
19291
19296
  return command !== undefined && rule.has(command) ? label() : null;
19292
19297
  }
19298
+ var SERVER_SCRIPT = /(?:^|[:_.-])(?:dev|serve|start|storybook)(?:$|[:_.-])/iu;
19299
+ var serverScript = (script = "") => SERVER_SCRIPT.test(script) && !HEAVY_SCRIPT.test(script);
19300
+ var NUXT = sub("dev", "preview", "start");
19301
+ var WEBPACK = sub("serve", "s", "server");
19302
+ var SERVER_TOOLS = {
19303
+ ng: sub("serve", "s"),
19304
+ next: sub("dev", "start"),
19305
+ nuxt: NUXT,
19306
+ nuxi: NUXT,
19307
+ astro: sub("dev", "preview"),
19308
+ "react-scripts": sub("start"),
19309
+ webpack: WEBPACK,
19310
+ "webpack-cli": WEBPACK,
19311
+ storybook: sub("dev", "start"),
19312
+ rails: sub("server", "s"),
19313
+ mix: sub("phx.server")
19314
+ };
19315
+ var COMPOSE_VALUES = new Set([
19316
+ "-f",
19317
+ "--file",
19318
+ "-p",
19319
+ "-H",
19320
+ "--host",
19321
+ "--context",
19322
+ "-c",
19323
+ "--config"
19324
+ ]);
19325
+ function serverBuiltIn(words, depth = 0) {
19326
+ const name = baseName2(words[0]);
19327
+ if (depth > 6 || WORKIT.test(name) || words.some((word) => /^(?:-h|--help|--version)$/u.test(word)))
19328
+ return null;
19329
+ const compose = /^(?:docker|podman|nerdctl|docker-compose)$/u.test(name);
19330
+ const at = positional2(words, 1, compose ? COMPOSE_VALUES : PM_VALUES);
19331
+ const command = words[at];
19332
+ const yes = words.slice(0, 3).join(" ");
19333
+ const inner = (from) => serverBuiltIn(words.slice(from), depth + 1);
19334
+ const up = (from) => words[from] === "up" && !words.some((word) => /^(?:-d|--detach|--wait)$/u.test(word));
19335
+ if (name === "npx" || name === "bunx" || name === "pnpx")
19336
+ return inner(at);
19337
+ if (name === "corepack")
19338
+ return inner(1);
19339
+ if (command === undefined)
19340
+ return name === "vite" ? yes : null;
19341
+ if (name === "npm" || name === "pnpm" || name === "yarn" || name === "bun" || name === "deno") {
19342
+ if (EXEC.has(command))
19343
+ return inner(positional2(words, at + 1));
19344
+ if (command === "start")
19345
+ return yes;
19346
+ if (name === "yarn" && command === "workspace")
19347
+ return serverScript(words[at + 2]) ? yes : inner(at + 2);
19348
+ if (NPM_RUN.has(command) || name === "deno" && command === "task") {
19349
+ if (serverScript(words[positional2(words, at + 1)]))
19350
+ return yes;
19351
+ return name === "bun" && command !== "task" ? inner(positional2(words, at + 1)) : null;
19352
+ }
19353
+ if (name === "npm" || name === "deno")
19354
+ return null;
19355
+ return serverScript(command) ? yes : inner(at);
19356
+ }
19357
+ if (PYTHONS.test(name)) {
19358
+ const m = words.indexOf("-m");
19359
+ if (words[m + 1] === "http.server" || command.endsWith("manage.py")) {
19360
+ return m > 0 || words[at + 1] === "runserver" ? yes : null;
19361
+ }
19362
+ return m > 0 && words[m + 1] ? inner(m + 1) : null;
19363
+ }
19364
+ if (["uv", "poetry", "pdm", "pipenv", "hatch", "rye", "bundle"].includes(name))
19365
+ return command === "run" || command === "exec" ? inner(positional2(words, at + 1)) : null;
19366
+ if (name === "make" || name === "gmake")
19367
+ return words.slice(1).some((word) => !/^-|=/u.test(word) && serverScript(word)) ? yes : null;
19368
+ if (name === "nx")
19369
+ return serverScript(command === "run" ? words[at + 1]?.split(":")[1] : command) ? yes : null;
19370
+ if (name === "docker-compose")
19371
+ return up(at) ? yes : null;
19372
+ if (compose)
19373
+ return command === "compose" && up(positional2(words, at + 1, COMPOSE_VALUES)) ? yes : null;
19374
+ if (name === "vite")
19375
+ return command === "build" || command === "optimize" ? null : yes;
19376
+ const rule = SERVER_TOOLS[name];
19377
+ return rule && rule !== "any" && rule.has(command) ? yes : null;
19378
+ }
19379
+ function serverCommand(command, dialect = "posix") {
19380
+ for (const line of linesOf(command, dialect) ?? []) {
19381
+ const reason = serverBuiltIn(line);
19382
+ if (reason)
19383
+ return { line, reason };
19384
+ }
19385
+ return null;
19386
+ }
19293
19387
  var globWord = (word) => new RegExp(`^${word.replace(/[.+?^${}()|[\]\\]/gu, "\\$&").replaceAll("*", ".*")}$`, "u");
19294
19388
  function parsePattern(pattern) {
19295
19389
  const words = pattern.trim().split(/\s+/u).filter(Boolean);
@@ -19386,6 +19480,28 @@ function heavyPlan(command, options) {
19386
19480
  unblock: parts[0] ?? null
19387
19481
  };
19388
19482
  }
19483
+ function serverPlan(command, options) {
19484
+ const dialect = options.dialect ?? "posix";
19485
+ if (dialect !== "posix" || !gitTop(options.cwd))
19486
+ return { kind: "none" };
19487
+ const found = serverCommand(command, dialect);
19488
+ if (!found)
19489
+ return { kind: "none" };
19490
+ const simple = simpleCommand(command, dialect, 0, true);
19491
+ const single = simple && serverBuiltIn(simple);
19492
+ if (options.rules !== null && !wrapAllowed(options.rules, single ? (linesOf(command, dialect) ?? []).flat() : found.line, single ? command : found.line.join(" "), options).ok)
19493
+ return { kind: "passthrough", note: "" };
19494
+ if (single) {
19495
+ const rewrite = leaseRewrite(command)?.replace("workit check --heavy --", "workit run --bg --");
19496
+ return rewrite ? { kind: "rewrite", command: rewrite, reason: single, server: true } : { kind: "none" };
19497
+ }
19498
+ const start = `workit run --bg -- ${found.line.map(quoteWord).join(" ")}`;
19499
+ return {
19500
+ kind: "split",
19501
+ reason: `dev_server: \`${command.trim()}\` chains a dev server (${found.reason}) with other commands. Start it alone, now: \`${start}\`; then run the other parts as their own commands.`,
19502
+ unblock: start
19503
+ };
19504
+ }
19389
19505
  function workitOnPath(env = process.env) {
19390
19506
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
19391
19507
  for (const dir of (env.PATH ?? "").split(path27.delimiter))
@@ -19434,21 +19550,26 @@ function heavyGate(cwd, command, options) {
19434
19550
  const single = dialect === "posix" ? simpleCommand(command, dialect, 0, true) : null;
19435
19551
  if (single && lightCommand(single, cwd))
19436
19552
  return { kind: "none" };
19437
- return heavyPlan(command, {
19553
+ const plan = {
19438
19554
  cwd,
19439
19555
  env,
19440
19556
  dialect,
19441
19557
  rules: rulesFor(options.host, cwd, env),
19442
19558
  bypass: options.permissionMode === "bypassPermissions"
19443
- });
19559
+ };
19560
+ const server = serverPlan(command, plan);
19561
+ if (server.kind === "rewrite")
19562
+ return server;
19563
+ const heavy = heavyPlan(command, plan);
19564
+ return heavy.kind === "none" ? server : heavy;
19444
19565
  } catch {
19445
19566
  return { kind: "none" };
19446
19567
  }
19447
19568
  }
19448
- var rewriteNote = (plan) => `workit: this heavy command (${plan.reason}) runs under the machine-wide heavy-check lease as \`${plan.command}\`: it waits while another heavy check holds the lease (\`workit lock status\` shows who). Run heavy commands that way yourself; \`workit help lock\` explains the lease.`;
19569
+ var rewriteNote = (plan) => plan.server ? `workit: this dev server (${plan.reason}) runs in the background as \`${plan.command}\`, owned by this session; \`workit stop <id>\` stops it when your work is done.` : `workit: this heavy command (${plan.reason}) runs under the machine-wide heavy-check lease as \`${plan.command}\`: it waits while another heavy check holds the lease (\`workit lock status\` shows who). Run heavy commands that way yourself; \`workit help lock\` explains the lease.`;
19449
19570
  var heavyDenial = (original, plan) => ({
19450
19571
  kind: "deny",
19451
- reason: `heavy_command: \`${original.trim()}\` is heavy (${plan.reason}) and must run under the machine-wide heavy-check lease, so parallel agents cannot exhaust this machine's memory and CPU. Run exactly: ${plan.command}`,
19572
+ reason: plan.server ? `dev_server: \`${original.trim()}\` starts a dev server (${plan.reason}), which never returns. Start it in the background, owned by this session; run exactly: ${plan.command}` : `heavy_command: \`${original.trim()}\` is heavy (${plan.reason}) and must run under the machine-wide heavy-check lease, so parallel agents cannot exhaust this machine's memory and CPU. Run exactly: ${plan.command}`,
19452
19573
  unblock: plan.command
19453
19574
  });
19454
19575
  var splitDenial = (plan) => ({
@@ -24395,7 +24516,7 @@ function handleHook(input, deps) {
24395
24516
  const decision = decide(input, deps);
24396
24517
  if (deps.descriptor.transport !== "hook-process" || !PRE_TOOL.has(input.event.kind) || decision.kind === "deny" || decision.kind === "ask")
24397
24518
  return decision;
24398
- const delta = [standingDelta(input), deps.budget?.line(input) ?? null].filter(Boolean).join(`
24519
+ const delta = [standingDelta(input), takeProcNotice2(input.session.id), deps.budget?.line(input) ?? null].filter(Boolean).join(`
24399
24520
  `) || null;
24400
24521
  if (!delta)
24401
24522
  return decision;
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ procNoticeFile2,
4
+ takeProcNotice2
5
+ } from "./workit-hook-btkg30rw.js";
6
+ import"./workit-hook-7jv519ep.js";
7
+ export {
8
+ procNoticeFile2 as procNoticeFile,
9
+ takeProcNotice2 as takeProcNotice
10
+ };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // packages/workit-codex/hooks/launcher.ts
4
- import { readFileSync } from "node:fs";
4
+ import { existsSync, readFileSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  var foundNode = process.env.WORKIT_HOOK_NODE_VERSION || process.versions.node;
@@ -37,6 +37,7 @@ useOwnedWorkitCli();
37
37
  var { maybeHeavy, stateDir } = await import("./workit-hook-1xk8mx4h.js");
38
38
  var { configDir } = await import("./workit-hook-z09frbdk.js");
39
39
  var { standingPending } = await import("./workit-hook-mk64s4fk.js");
40
+ var { procNoticeFile } = await import("./workit-hook-vmvv43m0.js");
40
41
  var { recordHookRun } = await import("./workit-hook-zyj0kzc5.js");
41
42
  var { observeHookBudget } = await import("./workit-hook-3g6cv3hd.js");
42
43
  var { hasTaskStore, mayReach } = await import("./workit-hook-7dwf87hc.js");
@@ -70,6 +71,8 @@ var quietEvent = () => {
70
71
  return null;
71
72
  if (event === "PreToolUse" && typeof value.session_id === "string" && standingPending(value.cwd, value.session_id, typeof value.agent_id === "string" && value.agent_id.trim() ? value.agent_id : null))
72
73
  return null;
74
+ if (event === "PreToolUse" && typeof value.session_id === "string" && value.session_id && existsSync(procNoticeFile(process.env, value.session_id)))
75
+ return null;
73
76
  const tool = value.tool_name.toLowerCase();
74
77
  if (event === "PreToolUse" && WRITE_TOOLS.has(tool.replace(/[_-]/g, "")))
75
78
  return null;
@@ -98,7 +101,7 @@ if (quiet) {
98
101
  `);
99
102
  } else {
100
103
  try {
101
- const { runCodexHook } = await import("./workit-hook-a6kefgqh.js");
104
+ const { runCodexHook } = await import("./workit-hook-py08h373.js");
102
105
  await runCodexHook([payload]);
103
106
  } catch (error) {
104
107
  const { answerRuntimeFailure } = await import("./workit-hook-9k8dtngs.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^2.10.0",
45
- "@workit-dev/mcp": "^2.10.0"
44
+ "@workit-dev/core": "^2.11.0",
45
+ "@workit-dev/mcp": "^2.11.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"
@@ -22,7 +22,8 @@ way a user would.
22
22
  already has a project skills directory, use it:
23
23
  - **Launch:** one command, its ready signal (log line, port, exit 0), a timeout.
24
24
  Builds, installs and e2e suites run under the heavy-check lease
25
- (`workit check --heavy -- <cmd>`); a long-running server does not.
25
+ (`workit check --heavy -- <cmd>`). A dev server starts in the background
26
+ through `workit run --bg -- <cmd>`, which prints its id, port and log.
26
27
  - **Doctor:** each precondition and its fix (deps, env vars, ports, services).
27
28
  - **Drive:** how to exercise it: CLI invocations, `curl` against routes, a
28
29
  browser tool for UI, with fixture data.
@@ -31,7 +32,7 @@ way a user would.
31
32
  agent-browser, with a screenshot or console/network observation; an API
32
33
  with a real call, response quoted. The report carries the observation.
33
34
  App not runnable? Say so plainly, never claim success.
34
- - **Cleanup:** stop processes, remove temp data.
35
+ - **Cleanup:** `workit stop <id>` for each server it started, remove temp data.
35
36
  - **Feature map:** feature, how to drive it, expected observation.
36
37
  3. **Prove it end-to-end once:** launch, drive one feature, capture evidence,
37
38
  clean up. Fix the skill until that run is clean. A generated skill that was
@@ -56,10 +57,11 @@ report `clean`, `changed` (what) or `blocked` (why).
56
57
 
57
58
  Bad: "Verify by running the tests." (that is not the real surface)
58
59
 
59
- Good: "Launch `bun run dev` (ready: `listening on :5173`, 30 s). Drive:
60
- `curl -s localhost:5173/api/health` returned `{"ok":true}`; screenshot of
61
- /settings at .workit-scratch/settings.png. Evidence:
62
- `workit check --name verify-web -- bun scripts/smoke.ts` exit 0."
60
+ Good: "Launch `workit run --bg -- bun run dev` (ready: `listening on :5173`,
61
+ 30 s). Drive: `curl -s localhost:5173/api/health` returned `{"ok":true}`;
62
+ screenshot of /settings at .workit-scratch/settings.png. Evidence:
63
+ `workit check --name verify-web -- bun scripts/smoke.ts` exit 0. Cleanup:
64
+ `workit stop p1abc2def3`."
63
65
 
64
66
  ## Check
65
67
 
@@ -14,6 +14,7 @@ description: Launch, drive and observe <app> on its real surface (<cli|web|api>)
14
14
 
15
15
  ## Launch
16
16
  `<command>` - ready when `<log line | port open | exit 0>`, timeout <n> s.
17
+ A server: `workit run --bg -- <command>` (prints its id, port and log).
17
18
 
18
19
  ## Doctor
19
20
  | Precondition | Check | Fix |
@@ -34,7 +35,7 @@ UI: also report a console or network observation. API: quote the real response.
34
35
  If the app cannot be run, say so plainly instead of claiming success.
35
36
 
36
37
  ## Cleanup
37
- `<command>` (stop servers, remove `<tmp dir>`).
38
+ `workit stop <id>` for each server Launch started; remove `<tmp dir>`.
38
39
 
39
40
  ## Feature map
40
41
  | Feature | Drive | Expect |