@tekmidian/pai 0.46.0 → 0.48.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 (34) hide show
  1. package/dist/{chain-DAEC9AU7.mjs → chain-CNSa0A3G.mjs} +2 -2
  2. package/dist/{chain-DAEC9AU7.mjs.map → chain-CNSa0A3G.mjs.map} +1 -1
  3. package/dist/cli/index.mjs +4 -4
  4. package/dist/cli/program.mjs +4 -4
  5. package/dist/daemon/index.mjs +2 -2
  6. package/dist/{daemon-Dq2ZSdex.mjs → daemon-CYpVy_Dw.mjs} +2 -2
  7. package/dist/{daemon-DNBEFHaj.mjs → daemon-DZ4Q0jrs.mjs} +2 -2
  8. package/dist/{daemon-DNBEFHaj.mjs.map → daemon-DZ4Q0jrs.mjs.map} +1 -1
  9. package/dist/daemon-mcp/index.mjs +3 -3
  10. package/dist/{fallback-CxGDTXWt.mjs → fallback-IeR2FrFn.mjs} +6 -6
  11. package/dist/fallback-IeR2FrFn.mjs.map +1 -0
  12. package/dist/hooks/load-core-context.mjs +9 -11
  13. package/dist/hooks/load-core-context.mjs.map +3 -3
  14. package/dist/hooks/load-project-context.mjs +59 -6
  15. package/dist/hooks/load-project-context.mjs.map +3 -3
  16. package/dist/hooks/worker-status-line.mjs +23 -4
  17. package/dist/hooks/worker-status-line.mjs.map +3 -3
  18. package/dist/{planner-B4DvNpXd.mjs → planner-Cn8HmT7l.mjs} +3 -3
  19. package/dist/{planner-B4DvNpXd.mjs.map → planner-Cn8HmT7l.mjs.map} +1 -1
  20. package/dist/{program-Dk_EIMqC.mjs → program-Bgv1lFFA.mjs} +155 -16
  21. package/dist/program-Bgv1lFFA.mjs.map +1 -0
  22. package/dist/{run-BgExF8Xg.mjs → run-Cls0YGgV.mjs} +43 -6
  23. package/dist/run-Cls0YGgV.mjs.map +1 -0
  24. package/docs/commands/audit.md +1 -0
  25. package/package.json +1 -1
  26. package/src/hooks/ts/lib/frontmatter.test.ts +19 -0
  27. package/src/hooks/ts/lib/frontmatter.ts +10 -0
  28. package/src/hooks/ts/lib/handover-budget.test.ts +124 -0
  29. package/src/hooks/ts/lib/handover-budget.ts +94 -0
  30. package/src/hooks/ts/session-start/load-core-context.ts +6 -15
  31. package/src/hooks/ts/session-start/load-project-context.ts +9 -6
  32. package/dist/fallback-CxGDTXWt.mjs.map +0 -1
  33. package/dist/program-Dk_EIMqC.mjs.map +0 -1
  34. package/dist/run-BgExF8Xg.mjs.map +0 -1
@@ -8183,6 +8183,7 @@ import { homedir as homedir5 } from "node:os";
8183
8183
  import { join as join6 } from "node:path";
8184
8184
 
8185
8185
  // src/workers/status.ts
8186
+ import { execFileSync } from "node:child_process";
8186
8187
  import {
8187
8188
  existsSync as existsSync4,
8188
8189
  mkdirSync as mkdirSync4,
@@ -8226,6 +8227,24 @@ function alive(pid) {
8226
8227
  return false;
8227
8228
  }
8228
8229
  }
8230
+ function ownsPid(status) {
8231
+ if (status.pid <= 0 || !alive(status.pid)) return false;
8232
+ try {
8233
+ const out = execFileSync("ps", ["-o", "lstart=", "-p", String(status.pid)], {
8234
+ encoding: "utf8",
8235
+ env: { ...process.env, LC_ALL: "C" }
8236
+ }).trim();
8237
+ const psStart = Date.parse(out);
8238
+ const started = Date.parse(status.started.replace(" ", "T"));
8239
+ if (Number.isNaN(psStart) || Number.isNaN(started)) return alive(status.pid);
8240
+ return Math.abs(psStart - started) <= 12e4;
8241
+ } catch {
8242
+ return alive(status.pid);
8243
+ }
8244
+ }
8245
+ function isLive(status) {
8246
+ return status.state === "running" && ownsPid(status);
8247
+ }
8229
8248
  function ageOf(ts, now = /* @__PURE__ */ new Date()) {
8230
8249
  const t = Date.parse(ts.replace(" ", "T"));
8231
8250
  if (Number.isNaN(t)) return "?";
@@ -8289,14 +8308,14 @@ function recordSessionMapEntry(logDir, cwd2, session, term2, now = Date.now()) {
8289
8308
  }
8290
8309
 
8291
8310
  // src/workers/agentish.ts
8292
- import { execFileSync } from "node:child_process";
8311
+ import { execFileSync as execFileSync2 } from "node:child_process";
8293
8312
  var AG2_SPEC_FALLBACK = "AG2. msg=kind line+k=v lines. kinds T R S Q A X. keys i id g goal o own n forbid d steps p proof u out l limits r res c changes t tests G gate I inst m images # nums w worst x next z note(<200ch). sep |. outcomes + - ~ ? !. @n=path declared once then reused; @n:12=file:line. tests as Name+ Name-. no prose, no articles, never restate, unknown=?. r=+ only if all t +.";
8294
8313
  var AG2_EXTENSIONS_FALLBACK = "y why(\u2264600ch)";
8295
8314
  var cachedSpec = null;
8296
8315
  function ag2Spec() {
8297
8316
  if (cachedSpec) return cachedSpec;
8298
8317
  try {
8299
- const out = execFileSync("aibroker", ["agentish", "spec"], {
8318
+ const out = execFileSync2("aibroker", ["agentish", "spec"], {
8300
8319
  timeout: 3e3,
8301
8320
  stdio: ["ignore", "pipe", "ignore"],
8302
8321
  encoding: "utf8"
@@ -8419,8 +8438,8 @@ function renderStatusLine(mine, now = /* @__PURE__ */ new Date(), active = null,
8419
8438
  const live = active && active !== "auto" ? active : null;
8420
8439
  if (!mine.length) return live ?? "";
8421
8440
  const isChat = isChatPane;
8422
- const chat = mine.find((s) => isChat(s) && s.state === "running" && alive(s.pid));
8423
- const running = mine.filter((s) => !isChat(s) && s.state === "running" && alive(s.pid));
8441
+ const chat = mine.find((s) => isChat(s) && isLive(s));
8442
+ const running = mine.filter((s) => !isChat(s) && isLive(s));
8424
8443
  const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
8425
8444
  const doneToday = mine.filter((s) => s.state !== "running" && s.started.startsWith(today));
8426
8445
  const ok = doneToday.filter((s) => s.state === "done").length;