@tekmidian/pai 0.61.0 → 0.62.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.
Files changed (67) hide show
  1. package/dist/{async-CLvuY7b-.mjs → async-DNVWtQl2.mjs} +2 -2
  2. package/dist/{async-CLvuY7b-.mjs.map → async-DNVWtQl2.mjs.map} +1 -1
  3. package/dist/{chain-C5oeyUg4.mjs → chain-CuaDawK9.mjs} +2 -2
  4. package/dist/{chain-C5oeyUg4.mjs.map → chain-CuaDawK9.mjs.map} +1 -1
  5. package/dist/cli/index.mjs +11 -11
  6. package/dist/cli/program.mjs +11 -11
  7. package/dist/{context-handover-cache-BdtJZpgv.mjs → context-handover-cache-DFNnlWv2.mjs} +2 -2
  8. package/dist/{context-handover-cache-BdtJZpgv.mjs.map → context-handover-cache-DFNnlWv2.mjs.map} +1 -1
  9. package/dist/daemon/index.mjs +8 -8
  10. package/dist/{daemon-DSsIEqzW.mjs → daemon-Bf7Eock4.mjs} +32 -18
  11. package/dist/{daemon-DSsIEqzW.mjs.map → daemon-Bf7Eock4.mjs.map} +1 -1
  12. package/dist/daemon-bJi1gDkG.mjs +19 -0
  13. package/dist/daemon-mcp/index.mjs +4 -4
  14. package/dist/{factory-EUUhSSoq.mjs → factory-BozZa81q.mjs} +3 -3
  15. package/dist/{factory-EUUhSSoq.mjs.map → factory-BozZa81q.mjs.map} +1 -1
  16. package/dist/{factory-DW7BCJJT.mjs → factory-UO9_DFMN.mjs} +1 -1
  17. package/dist/{fallback-DDbJVaR8.mjs → fallback-F0TWGVM2.mjs} +2 -2
  18. package/dist/{fallback-DDbJVaR8.mjs.map → fallback-F0TWGVM2.mjs.map} +1 -1
  19. package/dist/{helpers-D9WkIf9R.mjs → helpers-Dj-B314s.mjs} +3 -2
  20. package/dist/{helpers-D9WkIf9R.mjs.map → helpers-Dj-B314s.mjs.map} +1 -1
  21. package/dist/hooks/block-sleep-poll.mjs.map +2 -2
  22. package/dist/hooks/load-project-context.mjs +8513 -133
  23. package/dist/hooks/load-project-context.mjs.map +4 -4
  24. package/dist/hooks/security-validator.mjs.map +1 -1
  25. package/dist/hooks/worker-guard.mjs +7859 -0
  26. package/dist/hooks/worker-guard.mjs.map +7 -0
  27. package/dist/hooks/worker-status-line.mjs +101 -8
  28. package/dist/hooks/worker-status-line.mjs.map +4 -4
  29. package/dist/index.mjs +1 -1
  30. package/dist/{indexer-backend-DcDtin1O.mjs → indexer-backend-BN9rpp9O.mjs} +2 -2
  31. package/dist/{main-resolver-DIQ6m_RA.mjs → main-resolver-BIft_FVF.mjs} +3 -3
  32. package/dist/{main-resolver-DIQ6m_RA.mjs.map → main-resolver-BIft_FVF.mjs.map} +1 -1
  33. package/dist/{main-resolver-CxOsxtOr.mjs → main-resolver-C9-poMdi.mjs} +1 -1
  34. package/dist/{planner-D8jAr_sx.mjs → planner-BG9ivPj0.mjs} +4 -4
  35. package/dist/{planner-D8jAr_sx.mjs.map → planner-BG9ivPj0.mjs.map} +1 -1
  36. package/dist/{postgres-nvU5pShF.mjs → postgres-CxD6_Dca.mjs} +3 -3
  37. package/dist/{postgres-nvU5pShF.mjs.map → postgres-CxD6_Dca.mjs.map} +1 -1
  38. package/dist/{program-BTdspOOa.mjs → program-BRvCzhjx.mjs} +157 -40
  39. package/dist/program-BRvCzhjx.mjs.map +1 -0
  40. package/dist/{run-CxxZKEZw.mjs → run-BVQZI79D.mjs} +281 -85
  41. package/dist/run-BVQZI79D.mjs.map +1 -0
  42. package/dist/{session-keepalive-urk--pfa.mjs → session-keepalive-DJA97K2X.mjs} +2 -2
  43. package/dist/{session-keepalive-urk--pfa.mjs.map → session-keepalive-DJA97K2X.mjs.map} +1 -1
  44. package/dist/{sqlite-D9p5a4qe.mjs → sqlite-CfKfuggn.mjs} +2 -2
  45. package/dist/{sqlite-D9p5a4qe.mjs.map → sqlite-CfKfuggn.mjs.map} +1 -1
  46. package/dist/{tools-r-7ZG8B5.mjs → tools-B52IvaU6.mjs} +3 -3
  47. package/dist/{tools-qXyHFwNj.mjs → tools-DFdPbX-X.mjs} +2 -2
  48. package/dist/{tools-qXyHFwNj.mjs.map → tools-DFdPbX-X.mjs.map} +1 -1
  49. package/dist/{vault-indexer-DHYBpRZ5.mjs → vault-indexer-mCFus_AM.mjs} +2 -2
  50. package/dist/{vault-indexer-DHYBpRZ5.mjs.map → vault-indexer-mCFus_AM.mjs.map} +1 -1
  51. package/dist/{wakeup-C48hcN6O.mjs → wakeup-DO1O4udw.mjs} +2 -2
  52. package/dist/{wakeup-C48hcN6O.mjs.map → wakeup-DO1O4udw.mjs.map} +1 -1
  53. package/dist/{work-queue-worker-DUvPiwGO.mjs → work-queue-worker-BbrC3I_R.mjs} +2 -2
  54. package/dist/{work-queue-worker-DUvPiwGO.mjs.map → work-queue-worker-BbrC3I_R.mjs.map} +1 -1
  55. package/dist/{work-queue-worker-1_VBfI_k.mjs → work-queue-worker-z-AATZ2t.mjs} +3 -3
  56. package/docs/commands/README.md +2 -0
  57. package/docs/commands/worker.md +27 -0
  58. package/package.json +2 -2
  59. package/scripts/build-hooks.mjs +6 -5
  60. package/scripts/build-skill-stubs.mjs +6 -5
  61. package/src/hooks/ts/lib/worker-guard.test.ts +188 -0
  62. package/src/hooks/ts/lib/worker-guard.ts +315 -0
  63. package/src/hooks/ts/pre-tool-use/worker-guard.ts +75 -0
  64. package/src/hooks/ts/session-start/load-project-context.ts +14 -0
  65. package/dist/daemon-MoFF4oeg.mjs +0 -19
  66. package/dist/program-BTdspOOa.mjs.map +0 -1
  67. package/dist/run-CxxZKEZw.mjs.map +0 -1
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * worker-guard.ts — PreToolUse (Bash|Edit|Write|MultiEdit|NotebookEdit)
5
+ *
6
+ * Worker-only (PAI_WORKER=1) enforcement of the git/worktree rules every
7
+ * worker spec used to repeat in prose and workers still broke: no symlinks
8
+ * out of the worktree, no repo copies, no push/publish/tag/version, no
9
+ * tree-rewriting git in a shared checkout, no cd into the main checkout,
10
+ * no Notes/TODO.md or live config writes, no `bun test` on a vitest repo.
11
+ * A no-op in interactive sessions.
12
+ *
13
+ * This file is only I/O: read stdin, gather the git context, print the
14
+ * decision. The decision lives in lib/worker-guard.ts and is tested there
15
+ * and through this entry.
16
+ */
17
+
18
+ import { execFileSync } from "node:child_process";
19
+ import { readFileSync } from "node:fs";
20
+ import { homedir } from "node:os";
21
+ import { dirname, join } from "node:path";
22
+ import { renderDecision } from "../lib/sleep-poll-gate.js";
23
+ import { decideWorkerGuard, type WorkerGuardContext, type WorkerGuardInput } from "../lib/worker-guard.js";
24
+
25
+ function git(cwd: string, args: string[]): string | null {
26
+ try {
27
+ return execFileSync("git", ["-C", cwd, ...args], { encoding: "utf8", timeout: 5_000, stdio: ["ignore", "pipe", "ignore"] }).trim();
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ function buildContext(cwd: string): WorkerGuardContext {
34
+ const worktreeRoot = git(cwd, ["rev-parse", "--show-toplevel"]);
35
+ const gitDir = git(cwd, ["rev-parse", "--absolute-git-dir"]);
36
+ const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
37
+ const inWorktree = !!gitDir && !!common && gitDir !== common;
38
+ return {
39
+ cwd,
40
+ home: homedir(),
41
+ worktreeRoot,
42
+ inWorktree,
43
+ mainCheckout: inWorktree && common ? dirname(common) : null,
44
+ testScript: () => {
45
+ try {
46
+ const pkg = JSON.parse(readFileSync(join(worktreeRoot ?? cwd, "package.json"), "utf8"));
47
+ return typeof pkg?.scripts?.test === "string" ? pkg.scripts.test : null;
48
+ } catch {
49
+ return null;
50
+ }
51
+ },
52
+ };
53
+ }
54
+
55
+ async function main(): Promise<void> {
56
+ let text = "";
57
+ try {
58
+ for await (const chunk of process.stdin) text += chunk;
59
+ } catch {
60
+ return;
61
+ }
62
+ if (!text.trim()) return;
63
+
64
+ let input: WorkerGuardInput;
65
+ try {
66
+ input = JSON.parse(text) as WorkerGuardInput;
67
+ } catch {
68
+ return;
69
+ }
70
+
71
+ const decision = decideWorkerGuard(input, process.env, () => buildContext(input.cwd || process.cwd()));
72
+ if (decision.decision === "deny") process.stdout.write(renderDecision(decision) + "\n");
73
+ }
74
+
75
+ main().catch(() => process.exit(0));
@@ -16,6 +16,9 @@
16
16
  * - Sending ntfy.sh notifications
17
17
  */
18
18
 
19
+ import { readWorkersSection } from '../../../workers/config.js';
20
+ import { workersLogDir } from '../../../workers/paths.js';
21
+ import { pendingResults } from '../../../workers/pending.js';
19
22
  import { isWorkerSession } from "../lib/worker-session.js";
20
23
  import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
21
24
  import { join, basename, dirname, resolve } from 'path';
@@ -492,6 +495,17 @@ ${paiProjectBlock ? `\n${paiProjectBlock}` : ''}
492
495
  // Output to stdout for Claude to receive
493
496
  console.log(reminder);
494
497
 
498
+ // Unmerged finished worker results in this repo: one line, none when zero
499
+ try {
500
+ const { workers } = readWorkersSection();
501
+ const pending = pendingResults(workersLogDir(workers), cwd);
502
+ if (pending.length) {
503
+ console.log(`${pending.length} finished worker result(s) not merged in this repo: ${pending.map((r) => r.id).join(', ')} — run \`pai worker pending\``);
504
+ }
505
+ } catch {
506
+ // no workers config or not a git repo: stay silent
507
+ }
508
+
495
509
  // 8.5. INJECT THE PAUSE CHECKPOINT
496
510
  //
497
511
  // `pai pause` writes the handover to TODO.md under `## Continue`. Until now
@@ -1,19 +0,0 @@
1
- import "./utils-C9HsYDpO.mjs";
2
- import "./migrate-BD7D8EEh.mjs";
3
- import "./factory-EUUhSSoq.mjs";
4
- import "./wakeup-C48hcN6O.mjs";
5
- import "./context-handover-cache-BdtJZpgv.mjs";
6
- import "./config-CQCmH_gV.mjs";
7
- import "./run-env-BE5xyCwy.mjs";
8
- import "./run-CxxZKEZw.mjs";
9
- import "./server-BY6AedmC.mjs";
10
- import "./state-n13uPK5B.mjs";
11
- import "./aibroker-client-BK1h--W_.mjs";
12
- import "./session-keepalive-urk--pfa.mjs";
13
- import "./embeddings-DfrYNIng.mjs";
14
- import { t as serve } from "./daemon-DSsIEqzW.mjs";
15
- import "./router-DjFZIoDl.mjs";
16
- import "./tools-qXyHFwNj.mjs";
17
- import "./work-queue-worker-DUvPiwGO.mjs";
18
-
19
- export { serve };