kaizen-agent 1.66.0 → 1.67.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.66.0",
3
+ "version": "1.67.0",
4
4
  "description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,41 +9,66 @@ import { view } from "./views.ts";
9
9
  // is a quiet row whose Check for updates asks npm now instead of the server's 6 h cache.
10
10
  let upd = null,
11
11
  ver = null;
12
+ // Inside the desktop app (desktop/src/preload.ts) the version and the update are the
13
+ // app's own, from GitHub Releases; anywhere else, kaizen's npm package.
14
+ const desk = globalThis.kaizenDesktop;
15
+ const name = desk ? "Kaizen" : "kaizen";
16
+ const getVer = (fresh) => (desk ? desk.check() : fetch(fresh ? "/version?fresh=1" : "/version").then((r) => r.json()));
12
17
  export function gotVer(v) {
13
18
  ver = v;
14
19
  upd = v.update ? v : null;
15
20
  const a = document.querySelector('.rail a[data-view="settings"]');
16
21
  a.classList.toggle("upd", !!upd);
17
- a.title = upd ? `Settings: kaizen ${v.latest} is available` : "Settings";
22
+ a.title = upd ? `Settings: ${name} ${v.latest} is available` : "Settings";
18
23
  return !!upd;
19
24
  }
20
25
  export function updBar() {
21
26
  const d = document.createElement("div");
22
27
  d.className = `updbar${upd ? "" : " quiet"}`;
23
28
  if (!upd) {
24
- d.innerHTML = html`<span id="upd-msg" aria-live="polite">${ver ? `kaizen ${ver.version}` : "kaizen"}</span><button class="btn" id="upd-chk">Check for updates</button>`;
29
+ d.innerHTML = html`<span id="upd-msg" aria-live="polite">${ver ? `${name} ${ver.version}` : name}</span
30
+ ><button class="btn" id="upd-chk">Check for updates</button>`;
25
31
  } else {
26
32
  // What's new: each newer release's one-line title, shown on hover, focus or click.
27
33
  const notes = (upd.notes || []).map((n) => html`<li><b>${n.v}</b> ${n.text}</li>`);
28
34
  const news = notes.length
29
- ? html`<span class="updnew"><button class="btn" aria-describedby="upd-notes">What's new</button><span class="updpop" id="upd-notes" role="tooltip"><ul>${notes}</ul><a href="https://github.com/hfadhlullah/kaizen/releases" target="_blank" rel="noopener">All release notes</a></span></span>`
35
+ ? html`<span class="updnew"
36
+ ><button class="btn" aria-describedby="upd-notes">What's new</button
37
+ ><span class="updpop" id="upd-notes" role="tooltip"
38
+ ><ul>
39
+ ${notes}
40
+ </ul>
41
+ <a href="https://github.com/hfadhlullah/kaizen/releases" target="_blank" rel="noopener"
42
+ >All release notes</a
43
+ ></span
44
+ ></span
45
+ >`
30
46
  : "";
31
- d.innerHTML = html`<span>kaizen <b>${upd.latest}</b> is available. You are running ${upd.version}.</span><span class="updact">${news}<button class="btn" id="upd-chk">Check for updates</button><button class="btn pri" id="upd-go">Update kaizen</button></span>`;
47
+ d.innerHTML = html`<span>${name} <b>${upd.latest}</b> is available. You are running ${upd.version}.</span
48
+ ><span class="updact"
49
+ >${news}<button class="btn" id="upd-chk">Check for updates</button
50
+ ><button class="btn pri" id="upd-go">Update ${name}</button></span
51
+ >`;
32
52
  }
33
- if (ver && ver.failed) d.insertAdjacentHTML("afterbegin", html`<span class="updfail" role="alert">Last update failed: ${ver.failed}</span>`);
53
+ if (ver && ver.failed)
54
+ d.insertAdjacentHTML(
55
+ "afterbegin",
56
+ html`<span class="updfail" role="alert">Last update failed: ${ver.failed}</span>`,
57
+ );
34
58
  ($("supd") || $("pbody")).prepend(d);
35
59
  const check = $("upd-chk");
36
60
  check.onclick = async () => {
37
61
  check.disabled = true;
38
62
  check.textContent = "Checking…";
39
- const v = await fetch("/version?fresh=1")
40
- .then((r) => r.json())
41
- .catch(() => null);
63
+ const v = await getVer(true).catch(() => null);
42
64
  if (!d.isConnected) return;
43
65
  check.disabled = false;
44
66
  if (!v || !v.latest) {
45
67
  if (upd) check.textContent = "Could not check. Try again";
46
- else $("upd-msg").textContent = "Could not reach npm. Try again later.";
68
+ else
69
+ $("upd-msg").textContent = desk
70
+ ? "Could not reach GitHub Releases. Try again later."
71
+ : "Could not reach npm. Try again later.";
47
72
  return;
48
73
  }
49
74
  gotVer(v);
@@ -52,7 +77,7 @@ export function updBar() {
52
77
  updBar();
53
78
  if (upd) $("upd-go").focus();
54
79
  else {
55
- $("upd-msg").textContent = `kaizen ${v.version} is up to date.`;
80
+ $("upd-msg").textContent = `${name} ${v.version} is up to date.`;
56
81
  $("upd-chk").focus();
57
82
  }
58
83
  };
@@ -62,6 +87,7 @@ export function updBar() {
62
87
  }
63
88
 
64
89
  async function upgrade(b) {
90
+ if (desk) return installApp(b);
65
91
  if (!confirm(`Update kaizen to ${upd.latest}? kaizen restarts, and agents it runs stop.`)) return;
66
92
  const label = b.textContent;
67
93
  b.disabled = true;
@@ -76,6 +102,23 @@ async function upgrade(b) {
76
102
  setTimeout(() => location.reload(), 20000);
77
103
  }
78
104
 
105
+ // The desktop app installs its newest build and restarts into it; an unsigned macOS
106
+ // build cannot replace itself, so there the app opens the download page instead.
107
+ async function installApp(b) {
108
+ if (!confirm(`Install Kaizen ${upd.latest}? The app restarts, and agents it runs stop.`)) return;
109
+ const label = b.textContent;
110
+ b.disabled = true;
111
+ b.textContent = "Downloading…";
112
+ const r = await desk.install().catch((e) => ({ ok: false, error: String(e) }));
113
+ if (r && r.ok && !r.opened) {
114
+ b.textContent = "Restarting…";
115
+ return;
116
+ }
117
+ b.disabled = false;
118
+ b.textContent = r && r.opened ? "Opened the download page" : label;
119
+ if (r && !r.ok) alert(`Could not install the update: ${r.error}`);
120
+ }
121
+
79
122
  // The bottom-right popup for a new release. Later silences that version in this browser;
80
123
  // the next release asks again.
81
124
  function updPop() {
@@ -85,7 +128,7 @@ function updPop() {
85
128
  } catch {}
86
129
  const open = $("updcard");
87
130
  if (!upd || later === upd.latest) return open?.remove();
88
- const msg = html`kaizen <b>${upd.latest}</b> is available. You are running ${upd.version}.`;
131
+ const msg = html`${name} <b>${upd.latest}</b> is available. You are running ${upd.version}.`;
89
132
  if (open) {
90
133
  open.firstElementChild.innerHTML = msg;
91
134
  return;
@@ -93,7 +136,11 @@ function updPop() {
93
136
  const d = document.createElement("div");
94
137
  d.id = "updcard";
95
138
  d.setAttribute("role", "status");
96
- d.innerHTML = html`<span>${msg}</span><span class="updact"><button class="btn" id="updcard-later">Later</button><button class="btn pri" id="updcard-go">Update now</button></span>`;
139
+ d.innerHTML = html`<span>${msg}</span
140
+ ><span class="updact"
141
+ ><button class="btn" id="updcard-later">Later</button
142
+ ><button class="btn pri" id="updcard-go">Update now</button></span
143
+ >`;
97
144
  document.body.append(d);
98
145
  $("updcard-later").onclick = () => {
99
146
  try {
@@ -107,8 +154,7 @@ function updPop() {
107
154
 
108
155
  function checkUpdate() {
109
156
  const had = !!upd;
110
- fetch("/version")
111
- .then((r) => r.json())
157
+ getVer(false)
112
158
  .then((v) => {
113
159
  if (gotVer(v) && !had && view === "settings") openSettings();
114
160
  updPop();