@codyswann/lisa 5.8.0 → 5.8.2

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 (78) hide show
  1. package/all/copy-overwrite/scripts/lisa-gates.mjs +5 -5
  2. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +1 -1
  3. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  4. package/dist/core/lisa-owned-hash-ledger.js +4 -0
  5. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  6. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  7. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  8. package/dist/core/upstream-evidence-manifest.js +4 -3
  9. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  10. package/package.json +4 -4
  11. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  13. package/plugins/lisa/hooks/auto-update.mjs +128 -25
  14. package/plugins/lisa-agy/plugin.json +1 -1
  15. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  17. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  18. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  22. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-copilot/hooks/auto-update.mjs +128 -25
  24. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cursor/hooks/auto-update.mjs +128 -25
  26. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  28. package/plugins/lisa-devin/hooks/auto-update.mjs +128 -25
  29. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo-agy/plugin.json +1 -1
  32. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  43. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  45. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  46. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  50. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  53. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  57. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  59. package/plugins/lisa-rails-agy/plugin.json +1 -1
  60. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  64. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  66. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  67. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  71. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  74. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  78. package/plugins/src/base/hooks/auto-update.mjs +128 -25
@@ -36,6 +36,19 @@
36
36
  *
37
37
  * FAIL SOFT, ALWAYS. Any failure is reported in the context and the session
38
38
  * starts; a half-finished update is reported, never hidden.
39
+ *
40
+ * ## The developer is told, not only the agent (CodySwannGT/lisa#4903)
41
+ *
42
+ * Hook context reaches the agent, never the person. So every outcome where a
43
+ * newer Lisa is known and is NOT in place — uncommitted changes, an update an
44
+ * earlier session left uncommitted, an update applied but not committable, a
45
+ * linked `node_modules`, unreadable release tags, a failure — also carries a
46
+ * plain-language notice. The hook emits it as `systemMessage`, which Claude
47
+ * Code, Codex and Devin (Claude-shaped hook output) show to the developer,
48
+ * and the context asks the agent to raise it in its first reply and offer to
49
+ * finish the update, with the command that does. A runtime that does not
50
+ * render `systemMessage` (Cursor) still reaches the developer through that
51
+ * relay. It warns rather than blocks: a session must always start.
39
52
  * @module plugins/src/base/hooks/auto-update
40
53
  */
41
54
  import { execFile } from "child_process";
@@ -461,7 +474,7 @@ async function npmLatest(projectDir, deps) {
461
474
  /**
462
475
  * Everything decided before anything is changed.
463
476
  * @param {object} ctx Context.
464
- * @returns {Promise<{skip: string} | {from: string, to: string, selfMode: boolean, manager: string}>} Plan.
477
+ * @returns {Promise<{skip: string, notice?: string, rerun?: boolean} | {from: string, to: string, selfMode: boolean, manager: string}>} Plan.
465
478
  */
466
479
  async function plan(ctx) {
467
480
  const { projectDir, run } = ctx;
@@ -476,11 +489,6 @@ async function plan(ctx) {
476
489
  if (!declares) return { skip: "" };
477
490
  const modules = path.join(projectDir, "node_modules");
478
491
  if (!existsSync(modules)) return { skip: "" };
479
- if (lstatSync(modules).isSymbolicLink()) {
480
- return {
481
- skip: "node_modules is a link to another checkout's install, so updating here would change that checkout too. Update Lisa from that checkout instead.",
482
- };
483
- }
484
492
  const from = installedVersion(projectDir);
485
493
  const to = await npmLatest(projectDir, ctx);
486
494
  if (!from) return { skip: "" };
@@ -489,12 +497,22 @@ async function plan(ctx) {
489
497
  skip: "npm could not be reached to check for a newer Lisa; nothing was changed.",
490
498
  };
491
499
  if (!precedes(from, to)) return { skip: "" };
500
+ // Checked only once Lisa is known to be behind, so a current project that
501
+ // shares an install is never warned about every session.
502
+ if (lstatSync(modules).isSymbolicLink()) {
503
+ return {
504
+ skip: "node_modules is a link to another checkout's install, so updating here would change that checkout too. Update Lisa from that checkout instead.",
505
+ notice: `Lisa is out of date: this project has ${from} and ${to} is available. This checkout shares its installed packages with another checkout, so it was not updated here. Update Lisa from that other checkout.`,
506
+ };
507
+ }
492
508
  const dirty = await run(["git", "status", "--porcelain"], {
493
509
  cwd: projectDir,
494
510
  });
495
511
  if (dirty) {
496
512
  return {
497
- skip: `Lisa ${to} is available (this project has ${from}), but the working tree has uncommitted changes, so nothing was changed. It updates at the start of a session that begins on a clean tree.`,
513
+ skip: `Lisa ${to} is available (this project has ${from}), but the working tree has uncommitted changes, so nothing was changed.`,
514
+ notice: `Lisa is out of date: this project has ${from} and ${to} is available. It was not updated automatically because there are uncommitted changes. Commit or stash them and start a new session, or ask your agent to update Lisa now.`,
515
+ rerun: true,
498
516
  };
499
517
  }
500
518
  if (selfMode) {
@@ -504,6 +522,7 @@ async function plan(ctx) {
504
522
  if (current === null) {
505
523
  return {
506
524
  skip: `Lisa ${to} is available, but the release tags needed to check it could not be read (offline?), so nothing was changed.`,
525
+ notice: `Lisa ${to} is available (this checkout has ${from}), but its release history could not be read, so it was not updated. Check the network and start a new session.`,
507
526
  };
508
527
  }
509
528
  if (current) return { skip: "" };
@@ -649,7 +668,8 @@ export async function workingTreeDigests(run, cwd, files) {
649
668
  * Commit the update now, or leave it pending for the first work-item binding.
650
669
  * @param {object} ctx Context.
651
670
  * @param {{from: string, to: string}} update The update.
652
- * @returns {Promise<string>} One sentence describing where the update is.
671
+ * @returns {Promise<{where: string, notice: string | null}>} Where the update
672
+ * is, and the developer notice when it is not committed.
653
673
  */
654
674
  async function settle(ctx, update) {
655
675
  const { projectDir, run } = ctx;
@@ -688,7 +708,10 @@ async function settle(ctx, update) {
688
708
  const sha = await run(["git", "rev-parse", "--short", "HEAD"], {
689
709
  cwd: projectDir,
690
710
  });
691
- return `It is committed on ${branch} as its own commit ${sha}, so it ships with this branch's pull request.`;
711
+ return {
712
+ where: `It is committed on ${branch} as its own commit ${sha}, so it ships with this branch's pull request.`,
713
+ notice: null,
714
+ };
692
715
  } catch (error) {
693
716
  await run(["git", "reset", "--quiet"], { cwd: projectDir }).catch(
694
717
  () => ""
@@ -708,13 +731,17 @@ async function settle(ctx, update) {
708
731
  marker,
709
732
  `${JSON.stringify({ from: update.from, to: update.to, files: changed, ...(digests ? { digests } : {}) }, null, 2)}\n`
710
733
  );
711
- return `It is NOT committed yet (${decision.reason}). The ${changed.length} changed file(s) are left in the working tree and recorded as a pending update; binding a work item on a feature branch (\`lisa-work-item.mjs link\` / \`attach-branch\`, which /lisa:track runs) commits them first, as their own commit. Do not fold these files into a feature commit.`;
734
+ return {
735
+ where: `It is NOT committed yet (${decision.reason}). The ${changed.length} changed file(s) are left in the working tree and recorded as a pending update; binding a work item on a feature branch (\`lisa-work-item.mjs link\` / \`attach-branch\`, which /lisa:track runs) commits them first, as their own commit. Do not fold these files into a feature commit.`,
736
+ notice: `Lisa was updated from ${update.from} to ${update.to}, but the change is not committed yet (${decision.reason}). Ask your agent to commit it on its own branch so it is not lost or mixed into other work.`,
737
+ };
712
738
  }
713
739
 
714
740
  /**
715
741
  * Remind about a pending update, or clear a marker whose files were committed.
716
742
  * @param {object} ctx Context.
717
- * @returns {Promise<string | null>} A reminder, or null when nothing is pending.
743
+ * @returns {Promise<{text: string, notice: string} | null>} A reminder, or
744
+ * null when nothing is pending.
718
745
  */
719
746
  async function pendingReminder(ctx) {
720
747
  const markerPath = path.resolve(
@@ -726,22 +753,84 @@ async function pendingReminder(ctx) {
726
753
  );
727
754
  const marker = readJson(markerPath);
728
755
  if (!marker) return null;
729
- const dirty = await ctx.run(["git", "status", "--porcelain"], {
730
- cwd: ctx.projectDir,
731
- });
756
+ // Only the marker's own files decide it: an unrelated edit must not keep a
757
+ // committed update looking pending, and no recorded files means none is.
758
+ const files = marker.files ?? [];
759
+ const dirty = files.length
760
+ ? await ctx.run(["git", "status", "--porcelain", "--", ...files], {
761
+ cwd: ctx.projectDir,
762
+ })
763
+ : "";
732
764
  if (!dirty) {
733
765
  rmSync(markerPath, { force: true });
734
766
  return null;
735
767
  }
736
- return `A Lisa update to ${marker.to} was applied in an earlier session and is still uncommitted (${(marker.files ?? []).length} file(s)). Binding a work item on a feature branch commits it first, as its own commit. Do not fold these files into a feature commit.`;
768
+ // An uncommitted update must not hide a release that came out since, or a
769
+ // project left on main with its bump uncommitted never hears of another.
770
+ // probe-direction: neutral — an unreachable registry only drops the clause.
771
+ const latest = await npmLatest(ctx.projectDir, ctx).catch(() => null);
772
+ const since =
773
+ latest && marker.to && precedes(marker.to, latest)
774
+ ? ` Lisa ${latest} has been released since.`
775
+ : "";
776
+ return {
777
+ text: `A Lisa update to ${marker.to} was applied in an earlier session and is still uncommitted (${files.length} file(s)).${since} Binding a work item on a feature branch commits it first, as its own commit. Do not fold these files into a feature commit.`,
778
+ notice: `A Lisa update to ${marker.to} is sitting in this project but is not committed.${since} Ask your agent to commit it on its own branch so it is not lost or mixed into other work.`,
779
+ };
780
+ }
781
+
782
+ /** This hook's own path, so the agent can rerun it once the tree is clean. */
783
+ const RUNNER_PATH = fileURLToPath(import.meta.url);
784
+
785
+ /**
786
+ * Agent context with the developer notice attached: what to tell them, and
787
+ * how to finish the update when they say yes.
788
+ * @param {string} text Context sentence(s).
789
+ * @param {string} notice What the developer is told.
790
+ * @param {string} projectDir Project root.
791
+ * @param {boolean} rerun Whether rerunning the hook would finish the update.
792
+ * @returns {string} Context for the agent.
793
+ */
794
+ function withNotice(text, notice, projectDir, rerun) {
795
+ const how = rerun
796
+ ? ` If they want it now, help them commit or stash their changes first, then run \`node "${RUNNER_PATH}" --project-dir "${projectDir}"\` and report what it says.`
797
+ : "";
798
+ return `${text}\n\nThe developer may not see hook output. In your first reply, tell them this in plain words and offer to sort it out: "${notice}"${how}`;
737
799
  }
738
800
 
739
801
  /**
740
802
  * Run the whole session-start update.
741
803
  * @param {{projectDir: string, env?: NodeJS.ProcessEnv, nowMs?: number, run?: typeof runCommand, refresh?: typeof refreshNpmLatest}} input Inputs.
804
+ * @returns {Promise<{text: string, notice: string | null}>} The agent context
805
+ * ("" when there is nothing to say) and the developer notice (null when the
806
+ * developer need not be told anything).
807
+ */
808
+ export async function autoUpdateResult(input) {
809
+ const result = await runUpdate(input);
810
+ const notice = result.notice ?? null;
811
+ return {
812
+ text: notice
813
+ ? withNotice(result.text, notice, input.projectDir, Boolean(result.rerun))
814
+ : result.text,
815
+ notice,
816
+ };
817
+ }
818
+
819
+ /**
820
+ * Run the whole session-start update, returning only the agent context.
821
+ * @param {Parameters<typeof autoUpdateResult>[0]} input Inputs.
742
822
  * @returns {Promise<string>} The context sentence(s), or "" when there is nothing to say.
743
823
  */
744
824
  export async function autoUpdate(input) {
825
+ return (await autoUpdateResult(input)).text;
826
+ }
827
+
828
+ /**
829
+ * The update itself.
830
+ * @param {Parameters<typeof autoUpdateResult>[0]} input Inputs.
831
+ * @returns {Promise<{text: string, notice?: string | null, rerun?: boolean}>} Outcome.
832
+ */
833
+ async function runUpdate(input) {
745
834
  const ctx = {
746
835
  env: process.env,
747
836
  nowMs: Date.now(),
@@ -750,11 +839,13 @@ export async function autoUpdate(input) {
750
839
  };
751
840
  ctx.config = readLisaConfig(ctx.projectDir);
752
841
  const setting = autoUpdateSetting(ctx.config, ctx.env);
753
- if (!setting.on) return "";
842
+ if (!setting.on) return { text: "" };
754
843
  const pending = await pendingReminder(ctx);
755
844
  if (pending) return pending;
756
845
  const update = await plan(ctx);
757
- if ("skip" in update) return update.skip;
846
+ if ("skip" in update) {
847
+ return { text: update.skip, notice: update.notice, rerun: update.rerun };
848
+ }
758
849
  const lock = path.resolve(
759
850
  ctx.projectDir,
760
851
  await ctx.run(["git", "rev-parse", "--git-path", "lisa/auto-update.lock"], {
@@ -762,17 +853,26 @@ export async function autoUpdate(input) {
762
853
  })
763
854
  );
764
855
  if (!takeLock(lock, ctx.nowMs)) {
765
- return `Lisa ${update.to} is available; another session is updating this worktree right now.`;
856
+ return {
857
+ text: `Lisa ${update.to} is available; another session is updating this worktree right now.`,
858
+ };
766
859
  }
767
860
  try {
768
861
  await applyUpdate(ctx, update);
769
- const where = await settle(ctx, update);
862
+ const { where, notice } = await settle(ctx, update);
770
863
  const what = update.selfMode
771
864
  ? `Updated Lisa's own self-dependency from ${update.from} to ${update.to}.`
772
865
  : `Updated Lisa from ${update.from} to ${update.to}, including the template changes \`lisa apply\` makes for it.`;
773
- return `${what} ${where} Guard and skill behaviour you observe in THIS session is still the plugin copy it started with.`;
866
+ return {
867
+ text: `${what} ${where} Guard and skill behaviour you observe in THIS session is still the plugin copy it started with.`,
868
+ notice,
869
+ };
774
870
  } catch (error) {
775
- return `Lisa ${update.to} is available but the automatic update failed: ${String(error.message).split("\n")[0]}. The working tree may hold a partial update; review it with \`git status\` before other work, or set "autoUpdate": false to stop these attempts.`;
871
+ const reason = String(error.message).split("\n")[0];
872
+ return {
873
+ text: `Lisa ${update.to} is available but the automatic update failed: ${reason}. The working tree may hold a partial update; review it with \`git status\` before other work, or set "autoUpdate": false to stop these attempts.`,
874
+ notice: `Lisa could not update itself from ${update.from} to ${update.to}, and the project may hold a half-finished update. Ask your agent to check \`git status\` and finish or undo it. The error was: ${reason}`,
875
+ };
776
876
  } finally {
777
877
  releaseLock(lock);
778
878
  }
@@ -782,11 +882,14 @@ export async function autoUpdate(input) {
782
882
  * Wrap the context in the hook envelope.
783
883
  * @param {string} text Context sentence(s).
784
884
  * @param {string} event Hook event name.
885
+ * @param {string | null} [notice] What the developer must see, shown as
886
+ * `systemMessage`; omitted when there is none.
785
887
  * @returns {string} JSON envelope, or "" when there is nothing to say.
786
888
  */
787
- export function envelope(text, event) {
889
+ export function envelope(text, event, notice = null) {
788
890
  if (!text) return "";
789
891
  return JSON.stringify({
892
+ ...(notice ? { systemMessage: `⚠️ ${notice}` } : {}),
790
893
  hookSpecificOutput: {
791
894
  hookEventName: event,
792
895
  additionalContext: `<${BLOCK_TAG}>\n${text}\n</${BLOCK_TAG}>`,
@@ -813,9 +916,9 @@ function invokedDirectly(moduleUrl, argv1 = process.argv[1]) {
813
916
  if (invokedDirectly(import.meta.url)) {
814
917
  const index = process.argv.indexOf("--project-dir");
815
918
  const projectDir = index >= 0 ? process.argv[index + 1] : process.cwd();
816
- autoUpdate({ projectDir })
817
- .then(text => {
818
- const out = envelope(text, "SessionStart");
919
+ autoUpdateResult({ projectDir })
920
+ .then(({ text, notice }) => {
921
+ const out = envelope(text, "SessionStart", notice);
819
922
  if (out) process.stdout.write(`${out}\n`);
820
923
  })
821
924
  .catch(() => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "5.8.0",
3
+ "version": "5.8.2",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -36,6 +36,19 @@
36
36
  *
37
37
  * FAIL SOFT, ALWAYS. Any failure is reported in the context and the session
38
38
  * starts; a half-finished update is reported, never hidden.
39
+ *
40
+ * ## The developer is told, not only the agent (CodySwannGT/lisa#4903)
41
+ *
42
+ * Hook context reaches the agent, never the person. So every outcome where a
43
+ * newer Lisa is known and is NOT in place — uncommitted changes, an update an
44
+ * earlier session left uncommitted, an update applied but not committable, a
45
+ * linked `node_modules`, unreadable release tags, a failure — also carries a
46
+ * plain-language notice. The hook emits it as `systemMessage`, which Claude
47
+ * Code, Codex and Devin (Claude-shaped hook output) show to the developer,
48
+ * and the context asks the agent to raise it in its first reply and offer to
49
+ * finish the update, with the command that does. A runtime that does not
50
+ * render `systemMessage` (Cursor) still reaches the developer through that
51
+ * relay. It warns rather than blocks: a session must always start.
39
52
  * @module plugins/src/base/hooks/auto-update
40
53
  */
41
54
  import { execFile } from "child_process";
@@ -461,7 +474,7 @@ async function npmLatest(projectDir, deps) {
461
474
  /**
462
475
  * Everything decided before anything is changed.
463
476
  * @param {object} ctx Context.
464
- * @returns {Promise<{skip: string} | {from: string, to: string, selfMode: boolean, manager: string}>} Plan.
477
+ * @returns {Promise<{skip: string, notice?: string, rerun?: boolean} | {from: string, to: string, selfMode: boolean, manager: string}>} Plan.
465
478
  */
466
479
  async function plan(ctx) {
467
480
  const { projectDir, run } = ctx;
@@ -476,11 +489,6 @@ async function plan(ctx) {
476
489
  if (!declares) return { skip: "" };
477
490
  const modules = path.join(projectDir, "node_modules");
478
491
  if (!existsSync(modules)) return { skip: "" };
479
- if (lstatSync(modules).isSymbolicLink()) {
480
- return {
481
- skip: "node_modules is a link to another checkout's install, so updating here would change that checkout too. Update Lisa from that checkout instead.",
482
- };
483
- }
484
492
  const from = installedVersion(projectDir);
485
493
  const to = await npmLatest(projectDir, ctx);
486
494
  if (!from) return { skip: "" };
@@ -489,12 +497,22 @@ async function plan(ctx) {
489
497
  skip: "npm could not be reached to check for a newer Lisa; nothing was changed.",
490
498
  };
491
499
  if (!precedes(from, to)) return { skip: "" };
500
+ // Checked only once Lisa is known to be behind, so a current project that
501
+ // shares an install is never warned about every session.
502
+ if (lstatSync(modules).isSymbolicLink()) {
503
+ return {
504
+ skip: "node_modules is a link to another checkout's install, so updating here would change that checkout too. Update Lisa from that checkout instead.",
505
+ notice: `Lisa is out of date: this project has ${from} and ${to} is available. This checkout shares its installed packages with another checkout, so it was not updated here. Update Lisa from that other checkout.`,
506
+ };
507
+ }
492
508
  const dirty = await run(["git", "status", "--porcelain"], {
493
509
  cwd: projectDir,
494
510
  });
495
511
  if (dirty) {
496
512
  return {
497
- skip: `Lisa ${to} is available (this project has ${from}), but the working tree has uncommitted changes, so nothing was changed. It updates at the start of a session that begins on a clean tree.`,
513
+ skip: `Lisa ${to} is available (this project has ${from}), but the working tree has uncommitted changes, so nothing was changed.`,
514
+ notice: `Lisa is out of date: this project has ${from} and ${to} is available. It was not updated automatically because there are uncommitted changes. Commit or stash them and start a new session, or ask your agent to update Lisa now.`,
515
+ rerun: true,
498
516
  };
499
517
  }
500
518
  if (selfMode) {
@@ -504,6 +522,7 @@ async function plan(ctx) {
504
522
  if (current === null) {
505
523
  return {
506
524
  skip: `Lisa ${to} is available, but the release tags needed to check it could not be read (offline?), so nothing was changed.`,
525
+ notice: `Lisa ${to} is available (this checkout has ${from}), but its release history could not be read, so it was not updated. Check the network and start a new session.`,
507
526
  };
508
527
  }
509
528
  if (current) return { skip: "" };
@@ -649,7 +668,8 @@ export async function workingTreeDigests(run, cwd, files) {
649
668
  * Commit the update now, or leave it pending for the first work-item binding.
650
669
  * @param {object} ctx Context.
651
670
  * @param {{from: string, to: string}} update The update.
652
- * @returns {Promise<string>} One sentence describing where the update is.
671
+ * @returns {Promise<{where: string, notice: string | null}>} Where the update
672
+ * is, and the developer notice when it is not committed.
653
673
  */
654
674
  async function settle(ctx, update) {
655
675
  const { projectDir, run } = ctx;
@@ -688,7 +708,10 @@ async function settle(ctx, update) {
688
708
  const sha = await run(["git", "rev-parse", "--short", "HEAD"], {
689
709
  cwd: projectDir,
690
710
  });
691
- return `It is committed on ${branch} as its own commit ${sha}, so it ships with this branch's pull request.`;
711
+ return {
712
+ where: `It is committed on ${branch} as its own commit ${sha}, so it ships with this branch's pull request.`,
713
+ notice: null,
714
+ };
692
715
  } catch (error) {
693
716
  await run(["git", "reset", "--quiet"], { cwd: projectDir }).catch(
694
717
  () => ""
@@ -708,13 +731,17 @@ async function settle(ctx, update) {
708
731
  marker,
709
732
  `${JSON.stringify({ from: update.from, to: update.to, files: changed, ...(digests ? { digests } : {}) }, null, 2)}\n`
710
733
  );
711
- return `It is NOT committed yet (${decision.reason}). The ${changed.length} changed file(s) are left in the working tree and recorded as a pending update; binding a work item on a feature branch (\`lisa-work-item.mjs link\` / \`attach-branch\`, which /lisa:track runs) commits them first, as their own commit. Do not fold these files into a feature commit.`;
734
+ return {
735
+ where: `It is NOT committed yet (${decision.reason}). The ${changed.length} changed file(s) are left in the working tree and recorded as a pending update; binding a work item on a feature branch (\`lisa-work-item.mjs link\` / \`attach-branch\`, which /lisa:track runs) commits them first, as their own commit. Do not fold these files into a feature commit.`,
736
+ notice: `Lisa was updated from ${update.from} to ${update.to}, but the change is not committed yet (${decision.reason}). Ask your agent to commit it on its own branch so it is not lost or mixed into other work.`,
737
+ };
712
738
  }
713
739
 
714
740
  /**
715
741
  * Remind about a pending update, or clear a marker whose files were committed.
716
742
  * @param {object} ctx Context.
717
- * @returns {Promise<string | null>} A reminder, or null when nothing is pending.
743
+ * @returns {Promise<{text: string, notice: string} | null>} A reminder, or
744
+ * null when nothing is pending.
718
745
  */
719
746
  async function pendingReminder(ctx) {
720
747
  const markerPath = path.resolve(
@@ -726,22 +753,84 @@ async function pendingReminder(ctx) {
726
753
  );
727
754
  const marker = readJson(markerPath);
728
755
  if (!marker) return null;
729
- const dirty = await ctx.run(["git", "status", "--porcelain"], {
730
- cwd: ctx.projectDir,
731
- });
756
+ // Only the marker's own files decide it: an unrelated edit must not keep a
757
+ // committed update looking pending, and no recorded files means none is.
758
+ const files = marker.files ?? [];
759
+ const dirty = files.length
760
+ ? await ctx.run(["git", "status", "--porcelain", "--", ...files], {
761
+ cwd: ctx.projectDir,
762
+ })
763
+ : "";
732
764
  if (!dirty) {
733
765
  rmSync(markerPath, { force: true });
734
766
  return null;
735
767
  }
736
- return `A Lisa update to ${marker.to} was applied in an earlier session and is still uncommitted (${(marker.files ?? []).length} file(s)). Binding a work item on a feature branch commits it first, as its own commit. Do not fold these files into a feature commit.`;
768
+ // An uncommitted update must not hide a release that came out since, or a
769
+ // project left on main with its bump uncommitted never hears of another.
770
+ // probe-direction: neutral — an unreachable registry only drops the clause.
771
+ const latest = await npmLatest(ctx.projectDir, ctx).catch(() => null);
772
+ const since =
773
+ latest && marker.to && precedes(marker.to, latest)
774
+ ? ` Lisa ${latest} has been released since.`
775
+ : "";
776
+ return {
777
+ text: `A Lisa update to ${marker.to} was applied in an earlier session and is still uncommitted (${files.length} file(s)).${since} Binding a work item on a feature branch commits it first, as its own commit. Do not fold these files into a feature commit.`,
778
+ notice: `A Lisa update to ${marker.to} is sitting in this project but is not committed.${since} Ask your agent to commit it on its own branch so it is not lost or mixed into other work.`,
779
+ };
780
+ }
781
+
782
+ /** This hook's own path, so the agent can rerun it once the tree is clean. */
783
+ const RUNNER_PATH = fileURLToPath(import.meta.url);
784
+
785
+ /**
786
+ * Agent context with the developer notice attached: what to tell them, and
787
+ * how to finish the update when they say yes.
788
+ * @param {string} text Context sentence(s).
789
+ * @param {string} notice What the developer is told.
790
+ * @param {string} projectDir Project root.
791
+ * @param {boolean} rerun Whether rerunning the hook would finish the update.
792
+ * @returns {string} Context for the agent.
793
+ */
794
+ function withNotice(text, notice, projectDir, rerun) {
795
+ const how = rerun
796
+ ? ` If they want it now, help them commit or stash their changes first, then run \`node "${RUNNER_PATH}" --project-dir "${projectDir}"\` and report what it says.`
797
+ : "";
798
+ return `${text}\n\nThe developer may not see hook output. In your first reply, tell them this in plain words and offer to sort it out: "${notice}"${how}`;
737
799
  }
738
800
 
739
801
  /**
740
802
  * Run the whole session-start update.
741
803
  * @param {{projectDir: string, env?: NodeJS.ProcessEnv, nowMs?: number, run?: typeof runCommand, refresh?: typeof refreshNpmLatest}} input Inputs.
804
+ * @returns {Promise<{text: string, notice: string | null}>} The agent context
805
+ * ("" when there is nothing to say) and the developer notice (null when the
806
+ * developer need not be told anything).
807
+ */
808
+ export async function autoUpdateResult(input) {
809
+ const result = await runUpdate(input);
810
+ const notice = result.notice ?? null;
811
+ return {
812
+ text: notice
813
+ ? withNotice(result.text, notice, input.projectDir, Boolean(result.rerun))
814
+ : result.text,
815
+ notice,
816
+ };
817
+ }
818
+
819
+ /**
820
+ * Run the whole session-start update, returning only the agent context.
821
+ * @param {Parameters<typeof autoUpdateResult>[0]} input Inputs.
742
822
  * @returns {Promise<string>} The context sentence(s), or "" when there is nothing to say.
743
823
  */
744
824
  export async function autoUpdate(input) {
825
+ return (await autoUpdateResult(input)).text;
826
+ }
827
+
828
+ /**
829
+ * The update itself.
830
+ * @param {Parameters<typeof autoUpdateResult>[0]} input Inputs.
831
+ * @returns {Promise<{text: string, notice?: string | null, rerun?: boolean}>} Outcome.
832
+ */
833
+ async function runUpdate(input) {
745
834
  const ctx = {
746
835
  env: process.env,
747
836
  nowMs: Date.now(),
@@ -750,11 +839,13 @@ export async function autoUpdate(input) {
750
839
  };
751
840
  ctx.config = readLisaConfig(ctx.projectDir);
752
841
  const setting = autoUpdateSetting(ctx.config, ctx.env);
753
- if (!setting.on) return "";
842
+ if (!setting.on) return { text: "" };
754
843
  const pending = await pendingReminder(ctx);
755
844
  if (pending) return pending;
756
845
  const update = await plan(ctx);
757
- if ("skip" in update) return update.skip;
846
+ if ("skip" in update) {
847
+ return { text: update.skip, notice: update.notice, rerun: update.rerun };
848
+ }
758
849
  const lock = path.resolve(
759
850
  ctx.projectDir,
760
851
  await ctx.run(["git", "rev-parse", "--git-path", "lisa/auto-update.lock"], {
@@ -762,17 +853,26 @@ export async function autoUpdate(input) {
762
853
  })
763
854
  );
764
855
  if (!takeLock(lock, ctx.nowMs)) {
765
- return `Lisa ${update.to} is available; another session is updating this worktree right now.`;
856
+ return {
857
+ text: `Lisa ${update.to} is available; another session is updating this worktree right now.`,
858
+ };
766
859
  }
767
860
  try {
768
861
  await applyUpdate(ctx, update);
769
- const where = await settle(ctx, update);
862
+ const { where, notice } = await settle(ctx, update);
770
863
  const what = update.selfMode
771
864
  ? `Updated Lisa's own self-dependency from ${update.from} to ${update.to}.`
772
865
  : `Updated Lisa from ${update.from} to ${update.to}, including the template changes \`lisa apply\` makes for it.`;
773
- return `${what} ${where} Guard and skill behaviour you observe in THIS session is still the plugin copy it started with.`;
866
+ return {
867
+ text: `${what} ${where} Guard and skill behaviour you observe in THIS session is still the plugin copy it started with.`,
868
+ notice,
869
+ };
774
870
  } catch (error) {
775
- return `Lisa ${update.to} is available but the automatic update failed: ${String(error.message).split("\n")[0]}. The working tree may hold a partial update; review it with \`git status\` before other work, or set "autoUpdate": false to stop these attempts.`;
871
+ const reason = String(error.message).split("\n")[0];
872
+ return {
873
+ text: `Lisa ${update.to} is available but the automatic update failed: ${reason}. The working tree may hold a partial update; review it with \`git status\` before other work, or set "autoUpdate": false to stop these attempts.`,
874
+ notice: `Lisa could not update itself from ${update.from} to ${update.to}, and the project may hold a half-finished update. Ask your agent to check \`git status\` and finish or undo it. The error was: ${reason}`,
875
+ };
776
876
  } finally {
777
877
  releaseLock(lock);
778
878
  }
@@ -782,11 +882,14 @@ export async function autoUpdate(input) {
782
882
  * Wrap the context in the hook envelope.
783
883
  * @param {string} text Context sentence(s).
784
884
  * @param {string} event Hook event name.
885
+ * @param {string | null} [notice] What the developer must see, shown as
886
+ * `systemMessage`; omitted when there is none.
785
887
  * @returns {string} JSON envelope, or "" when there is nothing to say.
786
888
  */
787
- export function envelope(text, event) {
889
+ export function envelope(text, event, notice = null) {
788
890
  if (!text) return "";
789
891
  return JSON.stringify({
892
+ ...(notice ? { systemMessage: `⚠️ ${notice}` } : {}),
790
893
  hookSpecificOutput: {
791
894
  hookEventName: event,
792
895
  additionalContext: `<${BLOCK_TAG}>\n${text}\n</${BLOCK_TAG}>`,
@@ -813,9 +916,9 @@ function invokedDirectly(moduleUrl, argv1 = process.argv[1]) {
813
916
  if (invokedDirectly(import.meta.url)) {
814
917
  const index = process.argv.indexOf("--project-dir");
815
918
  const projectDir = index >= 0 ? process.argv[index + 1] : process.cwd();
816
- autoUpdate({ projectDir })
817
- .then(text => {
818
- const out = envelope(text, "SessionStart");
919
+ autoUpdateResult({ projectDir })
920
+ .then(({ text, notice }) => {
921
+ const out = envelope(text, "SessionStart", notice);
819
922
  if (out) process.stdout.write(`${out}\n`);
820
923
  })
821
924
  .catch(() => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "5.8.0",
3
+ "version": "5.8.2",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "5.8.0",
3
+ "version": "5.8.2",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"