@tenonai/yew 1.3.0 → 1.5.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 (75) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/README.md +9 -18
  3. package/dist/cli/app.js +23 -26
  4. package/dist/cli/export.js +5 -5
  5. package/dist/cli/main.js +0 -14
  6. package/dist/cli/mcp.js +7 -7
  7. package/dist/cli/remote.js +6 -6
  8. package/dist/cli/run.js +3 -3
  9. package/dist/cli/schedule.js +3 -3
  10. package/dist/cli/send.js +5 -6
  11. package/dist/cli/serve.js +13 -11
  12. package/dist/cli/service.js +14 -41
  13. package/dist/server/agent/context.js +2 -3
  14. package/dist/server/agent/runner.js +1 -1
  15. package/dist/server/data-usage.js +2 -3
  16. package/dist/server/db/database.js +1 -1
  17. package/dist/server/db/migrations.js +4 -0
  18. package/dist/server/export.js +2 -2
  19. package/dist/server/folder-picker.js +1 -1
  20. package/dist/server/http/api.js +3 -0
  21. package/dist/server/http/app.js +3 -3
  22. package/dist/server/http/data.js +1 -1
  23. package/dist/server/http/mcp.js +2 -2
  24. package/dist/server/http/problem.js +1 -1
  25. package/dist/server/http/security.js +5 -5
  26. package/dist/server/keys.js +5 -24
  27. package/dist/server/mail/post.js +2 -2
  28. package/dist/server/mcp-builtin.js +2 -3
  29. package/dist/server/mcp-config.js +4 -4
  30. package/dist/server/mcp-oauth.js +6 -6
  31. package/dist/server/paths.js +6 -15
  32. package/dist/server/settings.js +3 -0
  33. package/dist/server/skills.js +1 -2
  34. package/dist/server/store.js +2 -2
  35. package/dist/server/tools/mail.js +1 -1
  36. package/dist/server/tools/registry.js +2 -2
  37. package/dist/shared/policy.js +3 -3
  38. package/dist/shared/version.js +2 -0
  39. package/package.json +2 -2
  40. package/web/dist/THIRD-PARTY-NOTICES.txt +1 -1
  41. package/web/dist/assets/index-B_NesKxw.js +68 -0
  42. package/web/dist/assets/index-BqTqnE18.css +1 -0
  43. package/web/dist/index.html +3 -3
  44. package/web/dist/mascot/alarm.webp +0 -0
  45. package/web/dist/mascot/books.webp +0 -0
  46. package/web/dist/mascot/bow.webp +0 -0
  47. package/web/dist/mascot/branch.webp +0 -0
  48. package/web/dist/mascot/clipboard.webp +0 -0
  49. package/web/dist/mascot/dozing.webp +0 -0
  50. package/web/dist/mascot/fired-up.webp +0 -0
  51. package/web/dist/mascot/giftbox.webp +0 -0
  52. package/web/dist/mascot/halt.webp +0 -0
  53. package/web/dist/mascot/jump.webp +0 -0
  54. package/web/dist/mascot/letter-run.webp +0 -0
  55. package/web/dist/mascot/magnifier.webp +0 -0
  56. package/web/dist/mascot/mini.webp +0 -0
  57. package/web/dist/mascot/nap.webp +0 -0
  58. package/web/dist/mascot/pajamas.webp +0 -0
  59. package/web/dist/mascot/paper-plane.webp +0 -0
  60. package/web/dist/mascot/peek.webp +0 -0
  61. package/web/dist/mascot/phone.webp +0 -0
  62. package/web/dist/mascot/pointing.webp +0 -0
  63. package/web/dist/mascot/portrait.webp +0 -0
  64. package/web/dist/mascot/pout.webp +0 -0
  65. package/web/dist/mascot/proud.webp +0 -0
  66. package/web/dist/mascot/reading.webp +0 -0
  67. package/web/dist/mascot/stamp.webp +0 -0
  68. package/web/dist/mascot/stretch.webp +0 -0
  69. package/web/dist/mascot/surprised.webp +0 -0
  70. package/web/dist/mascot/tea.webp +0 -0
  71. package/web/dist/mascot/teary.webp +0 -0
  72. package/web/dist/mascot/typing.webp +0 -0
  73. package/dist/server/from-jig.js +0 -98
  74. package/web/dist/assets/index-BtK_SzpF.css +0 -1
  75. package/web/dist/assets/index-C0rnUFI-.js +0 -68
@@ -4,20 +4,19 @@ import { homedir, userInfo } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { parseArgs } from "node:util";
7
- import { fromJigEnv, JIG_SERVICE_LABEL, JIG_SERVICE_UNIT } from "../server/from-jig.js";
8
7
  import { EXIT_ERROR, EXIT_OK, UsageError } from "./io.js";
9
8
  import { serviceRunning } from "./serve.js";
10
9
  const HELP = `Usage: yew service <install|uninstall|status> [options]
11
10
 
12
- Start Yew when you log in, so your phone and scheduled tasks can reach it
13
- without a terminal open. On macOS this is a LaunchAgent for your user, on
14
- Linux a systemd user unit. Yew is restarted if it exits with an error, and
15
- its log goes to the logs folder in Yew's data directory. Nothing is changed
16
- on your system until you run install.
11
+ Start Yew Harness when you log in, so your phone and scheduled tasks can reach
12
+ it without a terminal open. On macOS this is a LaunchAgent for your user, on
13
+ Linux a systemd user unit. Yew Harness is restarted if it exits with an error,
14
+ and its log goes to the logs folder in Yew Harness's data directory. Nothing
15
+ is changed on your system until you run install.
17
16
 
18
17
  Commands:
19
- install Start Yew at login, and start it now
20
- uninstall Stop starting Yew at login, and stop it now
18
+ install Start Yew Harness at login, and start it now
19
+ uninstall Stop starting Yew Harness at login, and stop it now
21
20
  status Show whether it is installed and running
22
21
 
23
22
  Options:
@@ -25,9 +24,6 @@ Options:
25
24
  -h, --help Show this help
26
25
  `;
27
26
  export const SERVICE_LABEL = "cn.tenonai.apps.yew";
28
- /** Jig's, Yew's earlier name (from-jig.ts): installing or removing Yew's takes it away. */
29
- const JIG_LABEL = JIG_SERVICE_LABEL;
30
- const JIG_UNIT = JIG_SERVICE_UNIT;
31
27
  const UNIT = "yew.service";
32
28
  export function realServiceHost() {
33
29
  return {
@@ -87,7 +83,7 @@ export function systemdUnit(host, env, log) {
87
83
  .map(([key, value]) => `Environment=${quoted(`${key}=${value}`)}`)
88
84
  .join("\n");
89
85
  return `[Unit]
90
- Description=Yew, an AI-native multi-agent workbench
86
+ Description=Yew Harness, an AI-native multi-agent workbench
91
87
 
92
88
  [Service]
93
89
  ExecStart=${quoted(host.node)} ${quoted(host.entry)} serve
@@ -112,27 +108,6 @@ export function serviceFile(host) {
112
108
  throw new Error("yew service works on macOS and Linux.");
113
109
  }
114
110
  const target = (host) => `gui/${host.uid}/${SERVICE_LABEL}`;
115
- /**
116
- * Jig's login service, from before Jig was renamed Yew: stopped and removed when Yew's is installed
117
- * or removed, so the two never both start.
118
- */
119
- function removeJigService(host) {
120
- if (host.platform === "darwin") {
121
- const file = join(host.homeDir, "Library", "LaunchAgents", `${JIG_LABEL}.plist`);
122
- if (!existsSync(file))
123
- return;
124
- host.run("launchctl", ["bootout", `gui/${host.uid}/${JIG_LABEL}`]);
125
- rmSync(file, { force: true });
126
- }
127
- else if (host.platform === "linux") {
128
- const file = join(host.homeDir, ".config", "systemd", "user", JIG_UNIT);
129
- if (!existsSync(file))
130
- return;
131
- host.run("systemctl", ["--user", "disable", "--now", JIG_UNIT]);
132
- rmSync(file, { force: true });
133
- host.run("systemctl", ["--user", "daemon-reload"]);
134
- }
135
- }
136
111
  /** The service file is there and the system has it loaded (macOS) or enabled (Linux). */
137
112
  export function serviceLoaded(host) {
138
113
  return (existsSync(serviceFile(host)) &&
@@ -159,11 +134,10 @@ export function installService(host, home, env, options) {
159
134
  const file = serviceFile(host);
160
135
  const mac = host.platform === "darwin";
161
136
  const log = join(home, "logs", "serve.log");
162
- removeJigService(host);
163
137
  mkdirSync(join(home, "logs"), { recursive: true, mode: 0o700 });
164
138
  // Shell commands the sessions run need your PATH; launchd and systemd start with a bare one.
165
139
  const vars = { PATH: env.PATH ?? "/usr/bin:/bin" };
166
- if (fromJigEnv(env, "HOME"))
140
+ if (env.YEW_HOME)
167
141
  vars.YEW_HOME = home;
168
142
  mkdirSync(dirname(file), { recursive: true });
169
143
  writeFileSync(file, mac ? launchAgent(host, vars, log) : systemdUnit(host, vars, log), {
@@ -192,7 +166,6 @@ export function uninstallService(host, options) {
192
166
  const file = serviceFile(host);
193
167
  const mac = host.platform === "darwin";
194
168
  const had = existsSync(file);
195
- removeJigService(host);
196
169
  if (mac) {
197
170
  if (options.stop)
198
171
  host.run("launchctl", ["bootout", target(host)]);
@@ -208,7 +181,7 @@ export function uninstallService(host, options) {
208
181
  export function serviceCommand(host = realServiceHost()) {
209
182
  return {
210
183
  name: "service",
211
- summary: "Start Yew when you log in",
184
+ summary: "Start Yew Harness when you log in",
212
185
  async run(args, io) {
213
186
  const { values, positionals } = parseArgs({
214
187
  args,
@@ -243,13 +216,13 @@ export function serviceCommand(host = realServiceHost()) {
243
216
  io.stdout.write(`${JSON.stringify({ installed: false, file })}\n`);
244
217
  else {
245
218
  io.stdout.write(had
246
- ? "Yew no longer starts at login, and was stopped.\n"
247
- : "Yew was not set to start at login.\n");
219
+ ? "Yew Harness no longer starts at login, and was stopped.\n"
220
+ : "Yew Harness was not set to start at login.\n");
248
221
  }
249
222
  return EXIT_OK;
250
223
  }
251
224
  if (!serviceLoaded(host) && serviceRunning(home)) {
252
- io.stderr.write("yew: Yew is already running, started by hand. Stop that 'yew serve' first, then run this again.\n");
225
+ io.stderr.write("yew: Yew Harness is already running, started by hand. Stop that 'yew serve' first, then run this again.\n");
253
226
  return EXIT_ERROR;
254
227
  }
255
228
  const { code, log } = installService(host, home, io.env, { start: true });
@@ -260,7 +233,7 @@ export function serviceCommand(host = realServiceHost()) {
260
233
  if (values.json)
261
234
  io.stdout.write(`${JSON.stringify({ installed: true, file, log })}\n`);
262
235
  else {
263
- io.stdout.write(`Yew now starts when you log in, and was started.\nLog: ${log}\nOpen the web interface with 'yew open'.\n`);
236
+ io.stdout.write(`Yew Harness now starts when you log in, and was started.\nLog: ${log}\nOpen the web interface with 'yew open'.\n`);
264
237
  }
265
238
  return EXIT_OK;
266
239
  },
@@ -1,11 +1,10 @@
1
1
  import { messageText } from "../../shared/messages.js";
2
- import { isJigNote } from "../from-jig.js";
3
2
  export const SUMMARY_HEADING = "[Summary of the earlier conversation, written by Yew when it shortened the context]";
4
3
  export const REQUEST_HEADING = "[The latest message to you before that summary, word for word; it is still what you are working on]";
5
4
  /** What Yew puts in front of its own messages to the model, which are stored like the person's. */
6
5
  export const YEW_NOTE = "[From Yew, not from the person]";
7
- /** Whether a stored message is one of Yew's own notes (or Jig's, from before the rename). */
8
- export const isOwnNote = (text) => text.startsWith(YEW_NOTE) || isJigNote(text);
6
+ /** Whether a stored message is one of Yew's own notes. */
7
+ export const isOwnNote = (text) => text.startsWith(YEW_NOTE);
9
8
  function placeholder(call, timestamp) {
10
9
  return {
11
10
  role: "toolResult",
@@ -539,7 +539,7 @@ export class Agents {
539
539
  detail =
540
540
  error instanceof YewError
541
541
  ? error.message
542
- : `Yew hit an internal error: ${error.message}`;
542
+ : `Yew Harness hit an internal error: ${error.message}`;
543
543
  if (!(error instanceof YewError))
544
544
  this.#log(`session ${sessionId}: ${error.stack ?? error}`);
545
545
  // The code lets the interface explain the problem in the person's language.
@@ -1,8 +1,7 @@
1
1
  import { lstatSync, readdirSync, realpathSync, rmdirSync, unlinkSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { conflict } from "./errors.js";
4
- import { JIG_DATABASE_FILES } from "./from-jig.js";
5
- const DATABASE_FILES = new Set(["yew.db", "yew.db-wal", "yew.db-shm", ...JIG_DATABASE_FILES]);
4
+ const DATABASE_FILES = new Set(["yew.db", "yew.db-wal", "yew.db-shm"]);
6
5
  const FOLDERS = { artifacts: "artifacts", logs: "logs", tmp: "temp" };
7
6
  function entries(dir) {
8
7
  try {
@@ -79,7 +78,7 @@ function scanTemp(home, inUse) {
79
78
  walk(real, false, true);
80
79
  return scan;
81
80
  }
82
- const outside = () => conflict("The tmp folder in Yew's data folder is a link to somewhere else. Yew does not delete through it.", undefined, "temp-outside");
81
+ const outside = () => conflict("The tmp folder in Yew Harness's data folder is a link to somewhere else. Yew Harness does not delete through it.", undefined, "temp-outside");
83
82
  export function dataUsage(home, inUse = () => false, now = Date.now()) {
84
83
  const bytes = {
85
84
  database: 0,
@@ -17,7 +17,7 @@ export function openDatabase(path) {
17
17
  export function migrate(db) {
18
18
  const row = db.prepare("PRAGMA user_version").get();
19
19
  if (row.user_version > migrations.length) {
20
- throw new Error(`The database was written by a newer version of Yew (schema ${row.user_version}); upgrade Yew.`);
20
+ throw new Error(`The database was written by a newer version of Yew Harness (schema ${row.user_version}); upgrade Yew Harness.`);
21
21
  }
22
22
  for (let version = row.user_version; version < migrations.length; version++) {
23
23
  transaction(db, () => {
@@ -340,4 +340,8 @@ UPDATE approvals SET request = replace(replace(request, '"tool":"manage_jig"', '
340
340
  UPDATE sessions SET rules = replace(rules, '"tool":"manage_jig"', '"tool":"manage_yew"')
341
341
  WHERE rules LIKE '%manage_jig%';
342
342
  DELETE FROM session_events;`,
343
+ // Yew no longer reads anything by Jig's names: Jig's notes in old conversations are rewritten once
344
+ // as Yew's, so they still count as Yew's own words and not the person's.
345
+ `UPDATE messages SET body = replace(body, '[From Jig, not from the person]', '[From Yew, not from the person]')
346
+ WHERE body LIKE '%[From Jig, not from the person]%';`,
343
347
  ];
@@ -29,7 +29,7 @@ const ZH = {
29
29
  image: "图片",
30
30
  stopped: "已停止",
31
31
  modelChanged: "换了模型",
32
- restarted: "Yew 重启时这个会话在干活,已标为待核对。检查过后点「继续」接着运行。",
32
+ restarted: "Yew Harness 重启时这个会话在干活,已标为待核对。检查过后点「继续」接着运行。",
33
33
  changed: "{by} 改了这个会话的设置",
34
34
  compacted: "较早的记录已压成摘要",
35
35
  modelError: "模型请求失败",
@@ -92,7 +92,7 @@ const EN = {
92
92
  image: "Image",
93
93
  stopped: "Stopped",
94
94
  modelChanged: "Model changed",
95
- restarted: "Yew restarted while this session was working, so it is marked for review. Check it, then choose Continue.",
95
+ restarted: "Yew Harness restarted while this session was working, so it is marked for review. Check it, then choose Continue.",
96
96
  changed: "{by} changed this session's settings",
97
97
  compacted: "Earlier messages were summarized",
98
98
  modelError: "The model request failed",
@@ -16,7 +16,7 @@ const runOsascript = (args) => new Promise((resolve, reject) => {
16
16
  */
17
17
  export async function pickFolder(platform = process.platform, run = runOsascript) {
18
18
  if (platform !== "darwin") {
19
- throw new YewError("not-supported", 501, "Yew cannot open a folder picker on this computer. Type the folder's path instead.");
19
+ throw new YewError("not-supported", 501, "Yew Harness cannot open a folder picker on this computer. Type the folder's path instead.");
20
20
  }
21
21
  try {
22
22
  const out = (await run(["-e", "activate", "-e", "POSIX path of (choose folder)"])).trim();
@@ -359,6 +359,9 @@ export function api(deps) {
359
359
  const language = optEnum(fields, "language", ["system", "zh", "en"]);
360
360
  if (language)
361
361
  store.setSetting("language", language);
362
+ const mascot = optBoolean(fields, "mascot");
363
+ if (mascot !== undefined)
364
+ store.setSetting("mascot", mascot);
362
365
  const workspaces = optArray(fields, "workspaces");
363
366
  if (workspaces) {
364
367
  store.setSetting("workspaces", parseWorkspaces(workspaces, readSettings(store).workspaces));
@@ -20,10 +20,10 @@ import { searchRoutes } from "./search.js";
20
20
  import { authRoutes, deviceLimits, localOnly, requireBrowser, securityHeaders, } from "./security.js";
21
21
  import { skillRoutes } from "./skills.js";
22
22
  import { systemRoutes } from "./system.js";
23
- const NOT_BUILT = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><title>Yew</title>
23
+ const NOT_BUILT = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><title>Yew Harness</title>
24
24
  <meta name="color-scheme" content="light dark"></head><body>
25
- <p>网页界面还没有构建。在 Yew 的目录运行 npm run build:web,然后刷新这个页面。</p>
26
- <p lang="en">The web interface has not been built yet. In the Yew folder, run npm run build:web, then reload this page.</p>
25
+ <p>网页界面还没有构建。在 Yew Harness 的目录运行 npm run build:web,然后刷新这个页面。</p>
26
+ <p lang="en">The web interface has not been built yet. In the Yew Harness folder, run npm run build:web, then reload this page.</p>
27
27
  </body></html>`;
28
28
  export function createApp(options) {
29
29
  const log = options.log ?? ((line) => process.stderr.write(`${line}\n`));
@@ -44,7 +44,7 @@ export function dataRoutes(store, options) {
44
44
  }
45
45
  const dir = target === "home" ? options.home : exported;
46
46
  if (dir === null) {
47
- throw conflict("Nothing was exported since Yew started.", { field: "target" }, "no-export");
47
+ throw conflict("Nothing was exported since Yew Harness started.", { field: "target" }, "no-export");
48
48
  }
49
49
  // The folder itself is opened, so its contents are what the person sees.
50
50
  await showInFileManager(dir, { platform, run: options.run, inside: true, field: "target" });
@@ -123,11 +123,11 @@ export function oauthCallbackRoute(hub, log) {
123
123
  c.header("Cache-Control", "no-store");
124
124
  try {
125
125
  const name = await hub.completeSignIn(state, c.req.query("code") ?? null, c.req.query("error") ?? null, c.req.query("iss") ?? null);
126
- return c.html(page("已登录 · Signed in", `已登录 ${html(name)},可以关掉这个页面回到 Yew。<br>Signed in to ${html(name)}. You can close this page and go back to Yew.`));
126
+ return c.html(page("已登录 · Signed in", `已登录 ${html(name)},可以关掉这个页面回到 Yew Harness。<br>Signed in to ${html(name)}. You can close this page and go back to Yew Harness.`));
127
127
  }
128
128
  catch (error) {
129
129
  log?.(`mcp: sign-in did not finish: ${error.message}`);
130
- return c.html(page("没有登录 · Not signed in", `${html(error.message)}<br>回到 Yew 的「MCP 服务」再试一次。Go back to MCP servers in Yew and try again.`), 400);
130
+ return c.html(page("没有登录 · Not signed in", `${html(error.message)}<br>回到 Yew Harness 的「MCP 服务」再试一次。Go back to MCP servers in Yew Harness and try again.`), 400);
131
131
  }
132
132
  });
133
133
  return app;
@@ -50,6 +50,6 @@ export function errorHandler(log) {
50
50
  return problemResponse(c, error.status, "http-error", titleFor(error.status), error.message);
51
51
  }
52
52
  log(`[${c.get("requestId")}] ${c.req.method} ${c.req.path}: ${error.stack ?? error.message}`);
53
- return problemResponse(c, 500, "internal-error", titleFor(500), "Something went wrong inside Yew. The request ID is in the log.");
53
+ return problemResponse(c, 500, "internal-error", titleFor(500), "Something went wrong inside Yew Harness. The request ID is in the log.");
54
54
  };
55
55
  }
@@ -33,7 +33,7 @@ export function localOnly(port) {
33
33
  return next();
34
34
  const host = c.req.header("Host") ?? "";
35
35
  if (!hosts.has(host)) {
36
- return problemResponse(c, 421, "wrong-host", titleFor(421), "Yew only answers on 127.0.0.1 and localhost.");
36
+ return problemResponse(c, 421, "wrong-host", titleFor(421), "Yew Harness only answers on 127.0.0.1 and localhost.");
37
37
  }
38
38
  for (const header of [
39
39
  "Forwarded",
@@ -52,12 +52,12 @@ export function localOnly(port) {
52
52
  }
53
53
  const dest = c.req.header("Sec-Fetch-Dest");
54
54
  if (dest === "iframe" || dest === "frame" || dest === "embed" || dest === "object") {
55
- return problemResponse(c, 403, "embedded", titleFor(403), "Yew cannot be embedded.");
55
+ return problemResponse(c, 403, "embedded", titleFor(403), "Yew Harness cannot be embedded.");
56
56
  }
57
57
  if (c.req.method !== "GET" && c.req.method !== "HEAD") {
58
58
  const origin = c.req.header("Origin");
59
59
  if (origin !== `http://${host}`) {
60
- return problemResponse(c, 403, "bad-origin", titleFor(403), "This request did not come from Yew's own page.");
60
+ return problemResponse(c, 403, "bad-origin", titleFor(403), "This request did not come from Yew Harness's own page.");
61
61
  }
62
62
  }
63
63
  }
@@ -96,7 +96,7 @@ export function requireBrowser(store, port) {
96
96
  return next();
97
97
  const token = getCookie(c, cookieName(port));
98
98
  if (!token || !store.touchBrowserToken(hashToken(token), Date.now() + BROWSER_TTL_MS)) {
99
- return problemResponse(c, 401, "sign-in-required", titleFor(401), "Open Yew with the link from `yew serve` or `yew open`.");
99
+ return problemResponse(c, 401, "sign-in-required", titleFor(401), "Open Yew Harness with the link from `yew serve` or `yew open`.");
100
100
  }
101
101
  await next();
102
102
  };
@@ -161,7 +161,7 @@ export function deviceLimits() {
161
161
  // Artifacts are looked at on the phone and managed on the Mac.
162
162
  (path.startsWith("/api/artifacts/") && write) ||
163
163
  path.startsWith("/api/auth/")) {
164
- return problemResponse(c, 403, "mac-only", titleFor(403), "Only Yew on the Mac can do this: API keys, devices and remote access stay there.");
164
+ return problemResponse(c, 403, "mac-only", titleFor(403), "Only Yew Harness on the Mac can do this: API keys, devices and remote access stay there.");
165
165
  }
166
166
  await next();
167
167
  };
@@ -1,8 +1,5 @@
1
1
  import { AsyncEntry } from "@napi-rs/keyring";
2
- import { fromJigEnv, JIG_KEYCHAIN_SERVICE } from "./from-jig.js";
3
2
  export const KEYCHAIN_SERVICE = "cn.tenonai.yew";
4
- /** Where Jig, Yew's earlier name, kept them; a key found there moves over when first read. */
5
- const JIG_SERVICE = JIG_KEYCHAIN_SERVICE;
6
3
  /** The operating system keychain (macOS Keychain, Windows Credential Manager, Secret Service). */
7
4
  export class KeychainStore {
8
5
  #prefix;
@@ -10,35 +7,19 @@ export class KeychainStore {
10
7
  constructor(prefix = "provider") {
11
8
  this.#prefix = prefix;
12
9
  }
13
- #entry(name, service = KEYCHAIN_SERVICE) {
14
- return new AsyncEntry(service, `${this.#prefix}:${name}`);
10
+ #entry(name) {
11
+ return new AsyncEntry(KEYCHAIN_SERVICE, `${this.#prefix}:${name}`);
15
12
  }
16
13
  async get(provider) {
17
- const key = await this.#entry(provider).getPassword();
18
- if (key !== null && key !== undefined)
19
- return key;
20
- const old = this.#entry(provider, JIG_SERVICE);
21
- const kept = await old.getPassword().catch(() => null);
22
- if (kept === null || kept === undefined)
23
- return null;
24
- await this.#entry(provider).setPassword(kept);
25
- await old.deleteCredential().catch(() => false);
26
- return kept;
14
+ return (await this.#entry(provider).getPassword()) ?? null;
27
15
  }
28
16
  async set(provider, key) {
29
17
  await this.#entry(provider).setPassword(key);
30
- await this.#entry(provider, JIG_SERVICE)
31
- .deleteCredential()
32
- .catch(() => false);
33
18
  }
34
19
  async delete(provider) {
35
- const had = await this.#entry(provider)
36
- .deleteCredential()
37
- .catch(() => false);
38
- const hadOld = await this.#entry(provider, JIG_SERVICE)
20
+ return await this.#entry(provider)
39
21
  .deleteCredential()
40
22
  .catch(() => false);
41
- return had || hadOld;
42
23
  }
43
24
  }
44
25
  /**
@@ -48,7 +29,7 @@ export class KeychainStore {
48
29
  * with them. With the switch off it starts with no keys and forgets what is saved when it stops.
49
30
  */
50
31
  export function systemKeys(prefix = "provider", env = process.env) {
51
- const off = fromJigEnv(env, "KEYCHAIN") === "off";
32
+ const off = env.YEW_KEYCHAIN === "off";
52
33
  return off ? new MemoryKeyStore() : new KeychainStore(prefix);
53
34
  }
54
35
  /** For tests: keeps keys in memory. */
@@ -473,7 +473,7 @@ export class PostOffice {
473
473
  `Chosen: ${chosen ?? "(note only)"}`,
474
474
  ...(card.note ? [`Note: ${oneLine(card.note)}`] : []),
475
475
  ...(requester ? [`Requested by: ${requester}`] : []),
476
- "Decided by the person in Yew",
476
+ "Decided by the person in Yew Harness",
477
477
  ]
478
478
  : [
479
479
  stamp,
@@ -482,7 +482,7 @@ export class PostOffice {
482
482
  `选择:${chosen ?? "(只写了备注)"}`,
483
483
  ...(card.note ? [`备注:${oneLine(card.note)}`] : []),
484
484
  ...(requester ? [`提出:${requester}`] : []),
485
- "本人在 Yew 里决定",
485
+ "本人在 Yew Harness 里决定",
486
486
  ];
487
487
  try {
488
488
  const header = existsSync(path) ? "" : english ? "# Approval log\n\n" : "# 审批记录\n\n";
@@ -3,7 +3,6 @@ import { createHash } from "node:crypto";
3
3
  import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { fromJigEnv } from "./from-jig.js";
7
6
  /**
8
7
  * The MCP servers Yew sets up by itself (blueprint 6.10, item 38): a browser and control of this
9
8
  * computer. Yew does not build these in; it runs two open-source servers.
@@ -54,7 +53,7 @@ export function presetMcp(yewHome, id) {
54
53
  };
55
54
  }
56
55
  export function builtinMcp(yewHome, env = process.env) {
57
- if (fromJigEnv(env, "MCP_BUILTIN") === "off")
56
+ if (env.YEW_MCP_BUILTIN === "off")
58
57
  return {};
59
58
  const modules = join(installDir(yewHome), "node_modules");
60
59
  return {
@@ -126,7 +125,7 @@ function lockedInstaller(options, source, folder, what) {
126
125
  }
127
126
  /** Makes sure Yew's own two servers are installed as the lock file that ships with this Yew says. */
128
127
  export function builtinInstaller(options) {
129
- return lockedInstaller(options, options.source ?? SOURCE, installDir(options.yewHome), "Yew's own servers (browser, computer control)");
128
+ return lockedInstaller(options, options.source ?? SOURCE, installDir(options.yewHome), "Yew Harness's own servers (browser, computer control)");
130
129
  }
131
130
  /**
132
131
  * What the hub calls before it starts a server Yew runs from its data folder: installs Yew's own
@@ -34,7 +34,7 @@ function readFile(yewHome) {
34
34
  }
35
35
  if (!isObject(doc)) {
36
36
  // Not overwritten: the person may have servers in it that a typo is hiding.
37
- throw conflict("mcp.json in Yew's data folder is not valid JSON. Correct it by hand first.", undefined, "mcp-unreadable");
37
+ throw conflict("mcp.json in Yew Harness's data folder is not valid JSON. Correct it by hand first.", undefined, "mcp-unreadable");
38
38
  }
39
39
  const key = doc.mcpServers === undefined && doc.servers !== undefined ? "servers" : "mcpServers";
40
40
  if (doc[key] !== undefined && !isObject(doc[key])) {
@@ -192,7 +192,7 @@ export function addMcpEntry(yewHome, input) {
192
192
  let entry;
193
193
  if (preset) {
194
194
  if (!presetPackage(preset))
195
- throw invalid(`Yew has no preset named ${preset}.`, "preset");
195
+ throw invalid(`Yew Harness has no preset named ${preset}.`, "preset");
196
196
  const env = input.env ?? {};
197
197
  checkValues(env, ENV_NAME, "env");
198
198
  entry = { preset, ...(Object.keys(env).length > 0 ? { env } : {}) };
@@ -248,7 +248,7 @@ export function patchMcpEntry(yewHome, name, patch, builtin = {}) {
248
248
  if (builtin[name] && (!Object.hasOwn(servers, name) || turnsOff(servers[name]))) {
249
249
  // One of Yew's own: the file only records that it is off.
250
250
  if (patch.env || patch.headers) {
251
- throw invalid("A server Yew sets up by itself has no variables to set.", "env");
251
+ throw invalid("A server Yew Harness sets up by itself has no variables to set.", "env");
252
252
  }
253
253
  if (patch.disabled === true)
254
254
  servers[name] = { disabled: true };
@@ -297,7 +297,7 @@ export function patchMcpEntry(yewHome, name, patch, builtin = {}) {
297
297
  export function removeMcpEntry(yewHome, name, builtin = {}) {
298
298
  const { doc, servers } = readFile(yewHome);
299
299
  if (builtin[name] && (!Object.hasOwn(servers, name) || turnsOff(servers[name]))) {
300
- throw conflict(`${name} is set up by Yew itself. It can be turned off, not removed.`, undefined, "mcp-builtin");
300
+ throw conflict(`${name} is set up by Yew Harness itself. It can be turned off, not removed.`, undefined, "mcp-builtin");
301
301
  }
302
302
  entryOf(servers, name);
303
303
  delete servers[name];
@@ -220,13 +220,13 @@ export class McpAuth {
220
220
  const pending = this.#pending.get(state);
221
221
  this.#pending.delete(state);
222
222
  if (!pending || this.#now() - pending.createdAt > PENDING_MS) {
223
- throw new Error("This sign-in is not valid any more. Start it again from Yew.");
223
+ throw new Error("This sign-in is not valid any more. Start it again from Yew Harness.");
224
224
  }
225
225
  const { saved } = pending;
226
226
  // RFC 9207: a return that names a sign-in server, or that should and does not, comes from the
227
227
  // one the browser was sent to, or it is not used.
228
228
  if (iss !== null ? !same(iss, saved.endpoints.issuer) : saved.endpoints.namesItself) {
229
- throw new Error("The sign-in came back from another server than the one Yew sent you to.");
229
+ throw new Error("The sign-in came back from another server than the one Yew Harness sent you to.");
230
230
  }
231
231
  if (error || !code)
232
232
  throw new Error(`The sign-in was not completed (${error ?? "no code"}).`);
@@ -242,7 +242,7 @@ export class McpAuth {
242
242
  body.set("client_secret", saved.client.secret);
243
243
  const answer = await this.#post(saved.endpoints.token, body);
244
244
  if (!answer || typeof answer.access_token !== "string") {
245
- throw new Error("The server did not give Yew a token.");
245
+ throw new Error("The server did not give Yew Harness a token.");
246
246
  }
247
247
  await this.#save(pending.server, { ...saved, tokens: tokensFrom(answer, this.#now()) });
248
248
  return pending.server;
@@ -337,7 +337,7 @@ export class McpAuth {
337
337
  const at = new URL(resource);
338
338
  const local = at.protocol === "http:" && LOOPBACK.has(at.hostname);
339
339
  if (!usable(resource, local)) {
340
- throw new Error("Yew signs in only to servers at https addresses.");
340
+ throw new Error("Yew Harness signs in only to servers at https addresses.");
341
341
  }
342
342
  const named = param(challenge, "resource_metadata");
343
343
  if (named !== null && !usable(named, local)) {
@@ -428,7 +428,7 @@ export class McpAuth {
428
428
  throw new Error("This server only accepts clients registered in advance. Add its client ID and secret to its entry in mcp.json.");
429
429
  }
430
430
  const answer = await this.#post(endpoints.registration, JSON.stringify({
431
- client_name: "Yew",
431
+ client_name: "Yew Harness",
432
432
  redirect_uris: [this.#redirect],
433
433
  grant_types: ["authorization_code", "refresh_token"],
434
434
  response_types: ["code"],
@@ -436,7 +436,7 @@ export class McpAuth {
436
436
  software_version: this.#version,
437
437
  }));
438
438
  if (!answer || typeof answer.client_id !== "string") {
439
- throw new Error("The server did not let Yew register to sign in.");
439
+ throw new Error("The server did not let Yew Harness register to sign in.");
440
440
  }
441
441
  return {
442
442
  id: answer.client_id,
@@ -1,29 +1,20 @@
1
- import { existsSync, mkdirSync, realpathSync, statSync } from "node:fs";
1
+ import { mkdirSync, realpathSync, statSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { isAbsolute, join, resolve } from "node:path";
4
4
  import { invalid } from "./errors.js";
5
- import { fromJigEnv, JIG_DATABASE, unmovedJigHome } from "./from-jig.js";
6
- /**
7
- * Yew's data directory: `YEW_HOME` when set, otherwise `~/.yew`. A folder from Jig, Yew's earlier
8
- * name, counts until it has moved (from-jig.ts).
9
- */
5
+ /** Yew's data directory: `YEW_HOME` when set, otherwise `~/.yew`. */
10
6
  export function yewHome(env = process.env, user = homedir()) {
11
- const custom = fromJigEnv(env, "HOME");
12
- if (custom)
13
- return resolve(custom);
14
- const home = join(user, ".yew");
15
- return unmovedJigHome(home, user) ?? home;
7
+ const custom = env.YEW_HOME;
8
+ return custom ? resolve(custom) : join(user, ".yew");
16
9
  }
17
10
  /** Creates the data directory readable only by the current user. */
18
11
  export function ensureDir(path) {
19
12
  mkdirSync(path, { recursive: true, mode: 0o700 });
20
13
  return path;
21
14
  }
22
- /** The database file, `yew.db`; Jig's `jig.db` until it is renamed (from-jig.ts). */
15
+ /** The database file. */
23
16
  export function dbPath(home) {
24
- const yew = join(home, "yew.db");
25
- const jig = join(home, JIG_DATABASE);
26
- return !existsSync(yew) && existsSync(jig) ? jig : yew;
17
+ return join(home, "yew.db");
27
18
  }
28
19
  /** Resolves `~`, requires an existing folder and stores its real path, so permission checks compare like with like. */
29
20
  export function resolveWorkingFolder(path) {
@@ -31,6 +31,8 @@ export const SETTING_DEFAULTS = {
31
31
  notify: { waiting: true, error: true, task: true, budget: true },
32
32
  /** Skills switched off in the settings, each by its folder's real path (blueprint 6.10, item 35). */
33
33
  disabledSkills: [],
34
+ /** The mascot at the foot of the sidebar and the opening animation (blueprint, section 12). */
35
+ mascot: true,
34
36
  };
35
37
  export function readSettings(store) {
36
38
  const workspaces = store.getSetting("workspaces", SETTING_DEFAULTS.workspaces);
@@ -52,6 +54,7 @@ export function readSettings(store) {
52
54
  : null,
53
55
  notify: { ...SETTING_DEFAULTS.notify, ...store.getSetting("notify", SETTING_DEFAULTS.notify) },
54
56
  disabledSkills: store.getSetting("disabledSkills", SETTING_DEFAULTS.disabledSkills),
57
+ mascot: store.getSetting("mascot", SETTING_DEFAULTS.mascot),
55
58
  };
56
59
  }
57
60
  /** The decision log must be a Markdown file in an existing folder; `~` is expanded. */
@@ -2,7 +2,6 @@ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "n
2
2
  import { homedir } from "node:os";
3
3
  import { basename, isAbsolute, join } from "node:path";
4
4
  import { invalid } from "./errors.js";
5
- import { JIG_PROJECT_FOLDER } from "./from-jig.js";
6
5
  import { errorResult, str, text } from "./tools/types.js";
7
6
  const MAX_SKILLS = 200;
8
7
  const MAX_SKILL_CHARS = 60_000;
@@ -102,7 +101,7 @@ export function skillFolders(cwd, yewHome, userHome = homedir()) {
102
101
  if (userHome)
103
102
  folders.push(join(userHome, ".claude", "skills"));
104
103
  if (cwd) {
105
- for (const local of [".agents", ".claude", ".yew", JIG_PROJECT_FOLDER])
104
+ for (const local of [".agents", ".claude", ".yew"])
106
105
  folders.push(join(cwd, local, "skills"));
107
106
  }
108
107
  return folders;
@@ -1052,12 +1052,12 @@ export class Store {
1052
1052
  for (const approval of pending)
1053
1053
  this.cancelApproval(approval.id);
1054
1054
  for (const session of affected) {
1055
- this.#q("UPDATE sessions SET status = 'needs_review', status_detail = ?, updated_at = ? WHERE id = ?").run("Yew restarted while this session was working.", now, session.id);
1055
+ this.#q("UPDATE sessions SET status = 'needs_review', status_detail = ?, updated_at = ? WHERE id = ?").run("Yew Harness restarted while this session was working.", now, session.id);
1056
1056
  this.appendEntry(session.id, {
1057
1057
  role: "notice",
1058
1058
  notice: {
1059
1059
  kind: "restarted",
1060
- text: "Yew restarted while this session was working.",
1060
+ text: "Yew Harness restarted while this session was working.",
1061
1061
  timestamp: now,
1062
1062
  },
1063
1063
  });
@@ -294,7 +294,7 @@ const TEXT = { type: "string" };
294
294
  * manage_yew: the model changes Yew itself (blueprint 6.2, item 10). One call, all changes; Yew plans it
295
295
  * to rank how far it reaches and to show the person every change, then applies all or none.
296
296
  */
297
- export const manageJigTool = {
297
+ export const manageYewTool = {
298
298
  name: "manage_yew",
299
299
  description: "Change Yew itself when the person asks or the work needs it: sessions (create a standing one, or change its name, team, role, model, working folder, permission mode, how it receives letters, letter quota, rights, pinned, archived), teams, scheduled tasks, and settings. Put every change in one call; Yew checks them, asks the person when a change needs it, and applies all or none. Sessions, teams and tasks are named by name or id. API keys, pairing and deleting data are the person's.",
300
300
  parameters: {
@@ -1,5 +1,5 @@
1
1
  import { editTool, readTool, writeTool } from "./files.js";
2
- import { checkDecisionTool, finishTaskTool, listCardsTool, listSessionsTool, manageJigTool, openSessionTool, postCardTool, sendLetterTool, updateCardTool, withdrawCardTool, } from "./mail.js";
2
+ import { checkDecisionTool, finishTaskTool, listCardsTool, listSessionsTool, manageYewTool, openSessionTool, postCardTool, sendLetterTool, updateCardTool, withdrawCardTool, } from "./mail.js";
3
3
  import { askUserTool, delegateTool, todoTool } from "./misc.js";
4
4
  import { globTool, grepTool } from "./search.js";
5
5
  import { shellJobTool, shellTool } from "./shell.js";
@@ -20,7 +20,7 @@ export const ALL_TOOLS = [
20
20
  checkDecisionTool,
21
21
  openSessionTool,
22
22
  finishTaskTool,
23
- manageJigTool,
23
+ manageYewTool,
24
24
  postCardTool,
25
25
  updateCardTool,
26
26
  withdrawCardTool,