psyclaw 0.31.1 → 0.31.3

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 (38) hide show
  1. package/dist/src/adapters/pi/extension.js +36 -12
  2. package/dist/src/adapters/pi/extension.js.map +1 -1
  3. package/dist/src/analysis/decision-points.d.ts +10 -0
  4. package/dist/src/analysis/decision-points.js +88 -0
  5. package/dist/src/analysis/decision-points.js.map +1 -0
  6. package/dist/src/analysis/method-rules.d.ts +1 -0
  7. package/dist/src/analysis/method-rules.js +29 -8
  8. package/dist/src/analysis/method-rules.js.map +1 -1
  9. package/dist/src/analysis/runtime-tools.js +3 -1
  10. package/dist/src/analysis/runtime-tools.js.map +1 -1
  11. package/dist/src/analysis/shell-timeout.d.ts +18 -0
  12. package/dist/src/analysis/shell-timeout.js +58 -0
  13. package/dist/src/analysis/shell-timeout.js.map +1 -1
  14. package/dist/src/analysis/skill-resolution.d.ts +9 -0
  15. package/dist/src/analysis/skill-resolution.js +47 -8
  16. package/dist/src/analysis/skill-resolution.js.map +1 -1
  17. package/dist/src/observability/config.d.ts +1 -0
  18. package/dist/src/observability/config.js +3 -1
  19. package/dist/src/observability/config.js.map +1 -1
  20. package/dist/src/observability/langfuse.d.ts +15 -4
  21. package/dist/src/observability/langfuse.js +38 -10
  22. package/dist/src/observability/langfuse.js.map +1 -1
  23. package/dist/src/observability/node-sdks.js +16 -4
  24. package/dist/src/observability/node-sdks.js.map +1 -1
  25. package/dist/src/observability/public-keys.d.ts +10 -0
  26. package/dist/src/observability/public-keys.js +10 -0
  27. package/dist/src/observability/public-keys.js.map +1 -1
  28. package/dist/src/project/workspace.js +16 -0
  29. package/dist/src/project/workspace.js.map +1 -1
  30. package/dist/src/session/modes.js +13 -2
  31. package/dist/src/session/modes.js.map +1 -1
  32. package/dist/src/updates/whats-new.d.ts +8 -0
  33. package/dist/src/updates/whats-new.js +40 -0
  34. package/dist/src/updates/whats-new.js.map +1 -0
  35. package/package.json +2 -2
  36. package/skills/core/analysis-plan/SKILL.md +6 -1
  37. package/skills/core/method-interactions/SKILL.md +2 -1
  38. package/skills/core/method-multilevel/SKILL.md +4 -2
@@ -1,8 +1,10 @@
1
1
  import { DefaultPackageManager, getAgentDir, SettingsManager } from "@earendil-works/pi-coding-agent";
2
2
  import { isInstructionResult, isObservationEvidence, maskToolObservationsStable, observationSettledLimit } from "./observation-mask.js";
3
3
  import { outputLogFooter, persistToolOutput } from "../../analysis/output-log.js";
4
- import { applyShellTimeout, isShellTimeout, SHELL_TIMEOUT_HINT } from "../../analysis/shell-timeout.js";
4
+ import { applyShellTimeout, isShellTimeout, SHELL_TIMEOUT_HINT, ShellClock } from "../../analysis/shell-timeout.js";
5
5
  import { registerAnalysisRuntimeTools } from "../../analysis/runtime-tools.js";
6
+ import { PSYCLAW_VERSION } from "../../branding.js";
7
+ import { takeWhatsNew } from "../../updates/whats-new.js";
6
8
  import { formatDataAccess, loadDataAccess, redactScriptOnlyOutput, scriptOnlyBlock, setDataAccess } from "../../safety/data-access.js";
7
9
  import { Type } from "typebox";
8
10
  import { appendApproval, approvalInputDigest, assertResearchDecision, bootstrapProject, ensureProjectBinding, hasCanonicalWorkspace, resolveResearchDecision, runInstitutionalFulltext, runLiteratureReview, runExpertReview, runAnalysisDelegation, runWritingReview, runMetaAnalysis, createStageRunner, exportAcademicDocument, recordCitationUse, runParallelPeerReview } from "../../index.js";
@@ -37,8 +39,8 @@ import { isArsPiActive, isArsPiTurn, psyclawArsPatch, setArsPiSessionActive, } f
37
39
  import { buildArsDoctorReport, ensurePdfEngineForExport } from "../../ars/doctor.js";
38
40
  import { formatAcademicSoftRouteInvocation, rankAcademicSoftRoutes, resolveAcademicSoftRoute, } from "../../ars/academic-router.js";
39
41
  import { advanceAnalysisPlan, createAnalysisPlan, formatAnalysisPlanStatus, readActiveAnalysisPlan, syncHandoffFromAnalysisPlan, writeAnalysisPlan, } from "../../analysis/plan.js";
40
- import { mentionsLoadedSkill, methodTopicsIn } from "../../analysis/method-rules.js";
41
- import { composeMethodInjection, injectedTopicsFor, readSkillPreferences, refreshSkillResolution, SKILL_RESOLUTION_ENTRY, userSkillsOutsideScriptOnly, writeSkillPreferences, } from "../../analysis/skill-resolution.js";
42
+ import { METHOD_TOPICS, mentionsLoadedSkill, methodTopicsIn } from "../../analysis/method-rules.js";
43
+ import { composeMethodInjection, injectedTopicsFor, readSkillPreferences, referencedDocumentTopics, refreshSkillResolution, SKILL_RESOLUTION_ENTRY, userSkillsOutsideScriptOnly, writeSkillPreferences, } from "../../analysis/skill-resolution.js";
42
44
  import { formatAnalysisPlanTakeover, resolveStatsIntent, } from "../../analysis/stats-router.js";
43
45
  import { arsRoot } from "../../ars/pi-panel-executor.js";
44
46
  import { ArsModeEditor, isArsModeEditorText } from "../../ars/mode-editor.js";
@@ -1235,11 +1237,8 @@ export default function psyclawExtension(pi) {
1235
1237
  if (!legacyTestApi && typeof pi.on === "function")
1236
1238
  pi.on("resources_discover", async (event) => {
1237
1239
  try {
1240
+ // session_start appends the session record; here only the file is refreshed.
1238
1241
  const discovered = await refreshSkillResolution(event.cwd);
1239
- try {
1240
- pi.appendEntry(SKILL_RESOLUTION_ENTRY, discovered.resolution);
1241
- }
1242
- catch { /* session may not be open */ }
1243
1242
  return { skillPaths: [...discovered.recommendedPaths, ...discovered.localPaths], promptPaths: discovered.promptPaths };
1244
1243
  }
1245
1244
  catch {
@@ -1347,6 +1346,14 @@ export default function psyclawExtension(pi) {
1347
1346
  }
1348
1347
  catch { /* discovery must not block the session */ }
1349
1348
  }
1349
+ if (ctx.hasUI) {
1350
+ try {
1351
+ const notice = await takeWhatsNew(PSYCLAW_VERSION, join(getAgentDir(), "psyclaw-whats-new.json"));
1352
+ if (notice)
1353
+ ctx.ui.notify(notice, "info");
1354
+ }
1355
+ catch { /* the notice must not block the session */ }
1356
+ }
1350
1357
  if (isContinuouslyWorkEnabled() && ctx.hasUI) {
1351
1358
  ctx.ui.setStatus("cw", "continuously-work");
1352
1359
  ctx.ui.notify(continuouslyWorkWarningText(), "error");
@@ -1541,10 +1548,18 @@ export default function psyclawExtension(pi) {
1541
1548
  const userSkills = await userSkillsOutsideScriptOnly(ctx.cwd).catch(() => []);
1542
1549
  const userSkillNames = userSkills.map((skill) => skill.name);
1543
1550
  const match = resolveStatsIntent(event.text, { userSkillNames });
1544
- const reportOnly = !match
1545
- && methodTopicsIn(event.text).includes("report")
1546
- && !mentionsLoadedSkill(event.text, userSkillNames);
1547
- if (!match && !reportOnly)
1551
+ const namesUserSkill = mentionsLoadedSkill(event.text, userSkillNames);
1552
+ // The task often lives in a document the message names ("Read BRIEF.md"), not in the message itself.
1553
+ const documents = namesUserSkill
1554
+ ? { documents: [], topics: [] }
1555
+ : await referencedDocumentTopics(ctx.cwd, event.text).catch(() => ({ documents: [], topics: [] }));
1556
+ const messageTopics = match?.topics
1557
+ ?? (!namesUserSkill && methodTopicsIn(event.text).includes("report") ? ["report"] : []);
1558
+ // An unattended run writes its report with no reviewer: add the reporting checklist when it works from a task document.
1559
+ const unattendedReport = ctx.hasUI !== true && documents.documents.length > 0 ? ["report"] : [];
1560
+ const wanted = new Set([...messageTopics, ...documents.topics, ...unattendedReport]);
1561
+ const topics = METHOD_TOPICS.filter((topic) => wanted.has(topic));
1562
+ if (!match && topics.length === 0)
1548
1563
  return;
1549
1564
  let block = "";
1550
1565
  try {
@@ -1554,7 +1569,7 @@ export default function psyclawExtension(pi) {
1554
1569
  : undefined;
1555
1570
  const composed = await composeMethodInjection({
1556
1571
  cwd: ctx.cwd,
1557
- topics: match?.topics ?? ["report"],
1572
+ topics,
1558
1573
  seen: injectedTopicsFor(ctx.cwd, branch),
1559
1574
  hasUI: ctx.hasUI === true,
1560
1575
  userSkills,
@@ -1585,6 +1600,7 @@ export default function psyclawExtension(pi) {
1585
1600
  return { messages };
1586
1601
  });
1587
1602
  let dataAccessWarningShown = false;
1603
+ const shellClock = new ShellClock();
1588
1604
  if (!legacyTestApi && typeof pi.on === "function")
1589
1605
  pi.on("tool_call", async (event, ctx) => {
1590
1606
  // Host-teardown hard block runs even without /init — project approvals do not cover this.
@@ -1598,6 +1614,7 @@ export default function psyclawExtension(pi) {
1598
1614
  }
1599
1615
  }
1600
1616
  applyShellTimeout(event.toolName, event.input);
1617
+ shellClock.start(event.toolName, event.toolCallId, commandText);
1601
1618
  try {
1602
1619
  const access = await loadDataAccess(ctx.cwd);
1603
1620
  if (access.warning && !dataAccessWarningShown) {
@@ -1665,6 +1682,13 @@ export default function psyclawExtension(pi) {
1665
1682
  content[timedOutIndex] = { ...timedOut, text: `${timedOut.text}\n${SHELL_TIMEOUT_HINT}` };
1666
1683
  changed = true;
1667
1684
  }
1685
+ const timing = shellClock.finish(event.toolCallId);
1686
+ const lastText = content.map((part) => part.type).lastIndexOf("text");
1687
+ const last = content[lastText];
1688
+ if (timing && last?.type === "text") {
1689
+ content[lastText] = { ...last, text: `${last.text}\n${timing}` };
1690
+ changed = true;
1691
+ }
1668
1692
  if (!isObservationEvidence(event.toolName) && !isInstructionResult(event.toolName)) {
1669
1693
  const body = content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
1670
1694
  const saved = await persistToolOutput(ctx.cwd, event.toolCallId, body, observationSettledLimit());