taktiko 0.3.0 → 0.3.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.
package/dist/cli.js CHANGED
@@ -7405,6 +7405,11 @@ function appendAttachmentPaths(text, attachments) {
7405
7405
  [Attached files \u2014 read them from these local paths:]
7406
7406
  ${lines.join("\n")}`;
7407
7407
  }
7408
+ function foldSystemPrompt(query, systemPrompt, isResume) {
7409
+ return systemPrompt && !isResume ? `${systemPrompt}
7410
+
7411
+ ${query}` : query;
7412
+ }
7408
7413
  var hasFlag = (args, ...flags) => flags.some((f) => args.includes(f));
7409
7414
  async function spawnLines(ctx, command, args, opts) {
7410
7415
  const child = ctx.spawn(command, args, {
@@ -7461,7 +7466,6 @@ function parseJsonLine(line) {
7461
7466
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
7462
7467
  import { dirname, join, resolve } from "path";
7463
7468
  var MCP_SERVER_NAME = "taktiko";
7464
- var ASK_TOOL_FQN = `mcp__${MCP_SERVER_NAME}__AskUserQuestion`;
7465
7469
  var ASK_TOOL_TIMEOUT_MS = Number(process.env.TAKTIKO_ASK_TOOL_TIMEOUT_MS) || 60 * 6e4;
7466
7470
  function isAskUserTool(name) {
7467
7471
  return /(?:^|__|\.)(AskUserQuestion|ask_user)$/.test(name);
@@ -7645,9 +7649,7 @@ var codexAdapter = async (ctx) => {
7645
7649
  }
7646
7650
  const ask = buildAskUserMcp(a.env);
7647
7651
  if (ask) args.push(...codexMcpFlags(ask));
7648
- const base = a.systemPrompt && !resume ? `${a.systemPrompt}
7649
-
7650
- ${job.query}` : job.query;
7652
+ const base = foldSystemPrompt(job.query, a.systemPrompt, !!resume);
7651
7653
  args.push(appendAttachmentPaths(base, job.attachments));
7652
7654
  let sessionId = resume;
7653
7655
  const messages = [];
@@ -7695,9 +7697,7 @@ var genericAdapter = async (ctx) => {
7695
7697
  const a = job.agent;
7696
7698
  const args = [...a.args];
7697
7699
  if (job.resumeSessionId) args.push("--resume", job.resumeSessionId);
7698
- const base = a.systemPrompt && !job.resumeSessionId ? `${a.systemPrompt}
7699
-
7700
- ${job.query}` : job.query;
7700
+ const base = foldSystemPrompt(job.query, a.systemPrompt, !!job.resumeSessionId);
7701
7701
  args.push(appendAttachmentPaths(base, job.attachments));
7702
7702
  let out = "";
7703
7703
  const { code, stderr } = await spawnLines(ctx, a.command, args, {
@@ -7730,9 +7730,7 @@ var kimiAdapter = async (ctx) => {
7730
7730
  env.TAKTIKO_ASK_TOOL_NAME = "ask_user";
7731
7731
  if (!env.MCP_TOOL_TIMEOUT) env.MCP_TOOL_TIMEOUT = String(ASK_TOOL_TIMEOUT_MS);
7732
7732
  }
7733
- const base = a.systemPrompt && !resume ? `${a.systemPrompt}
7734
-
7735
- ${job.query}` : job.query;
7733
+ const base = foldSystemPrompt(job.query, a.systemPrompt, !!resume);
7736
7734
  const prompt = appendAttachmentPaths(base, job.attachments);
7737
7735
  if (!hasFlag(args, "-p", "--prompt")) args.push("-p", prompt);
7738
7736
  let sessionId = resume;
@@ -8349,7 +8347,7 @@ var TerminalSession = class {
8349
8347
  for (const l of this.outputListeners) l(payload);
8350
8348
  });
8351
8349
  this.pty = spawn2(opts.shell, opts.args ?? [], {
8352
- name: opts.name ?? "xterm-256color",
8350
+ name: "xterm-256color",
8353
8351
  cols: this.cols,
8354
8352
  rows: this.rows,
8355
8353
  cwd: this.cwd,
@@ -8417,7 +8415,7 @@ var TerminalRegistry = class {
8417
8415
  const session = new TerminalSession({
8418
8416
  ...opts,
8419
8417
  shell: opts.shell?.trim() || defaultShell(),
8420
- args: opts.args ?? (platform() === "win32" ? [] : ["-l"]),
8418
+ args: platform() === "win32" ? [] : ["-l"],
8421
8419
  // login shell on POSIX
8422
8420
  cwd
8423
8421
  });
@@ -8926,7 +8924,7 @@ function runMcpTools() {
8926
8924
  reply(id, {
8927
8925
  protocolVersion: params?.protocolVersion || "2025-06-18",
8928
8926
  capabilities: { tools: {} },
8929
- serverInfo: { name: "taktiko", version: "0.3.0" }
8927
+ serverInfo: { name: "taktiko", version: "0.3.2" }
8930
8928
  });
8931
8929
  return;
8932
8930
  }
@@ -9021,9 +9019,9 @@ function processInfo() {
9021
9019
  }
9022
9020
  try {
9023
9021
  const st = statSync(PID_FILE);
9024
- return { pid, startedAt: st.mtime, uptimeMs: Date.now() - st.mtimeMs };
9022
+ return { pid, uptimeMs: Date.now() - st.mtimeMs };
9025
9023
  } catch {
9026
- return { pid, startedAt: null, uptimeMs: null };
9024
+ return { pid, uptimeMs: null };
9027
9025
  }
9028
9026
  }
9029
9027
  function rotateLogIfLarge() {
@@ -9385,8 +9383,7 @@ async function handleRpc(ws, frame) {
9385
9383
  shell: p2.shell ? String(p2.shell) : void 0,
9386
9384
  env: {
9387
9385
  ...passedEnv,
9388
- TAKTIKO_ACTIVITY_URL: `${daemonServerUrl}/api/terminal-activity`,
9389
- TAKTIKO_HOOK_CLI: process.argv[1] ?? "taktiko"
9386
+ TAKTIKO_ACTIVITY_URL: `${daemonServerUrl}/api/terminal-activity`
9390
9387
  },
9391
9388
  cols: typeof p2.cols === "number" ? p2.cols : void 0,
9392
9389
  rows: typeof p2.rows === "number" ? p2.rows : void 0
@@ -10040,7 +10037,7 @@ function runDaemon(cfg) {
10040
10037
  connect();
10041
10038
  }
10042
10039
  var program = new Command();
10043
- program.name("taktiko").description("Taktiko daemon \u2014 runs your local agent CLIs").version("0.3.0", "-v, --version", "output the version number");
10040
+ program.name("taktiko").description("Taktiko daemon \u2014 runs your local agent CLIs").version("0.3.2", "-v, --version", "output the version number");
10044
10041
  program.command("hooks <provider> <event>").description("internal: report agent activity for the current Taktiko terminal (called by agent hooks)").action(async (provider, event) => {
10045
10042
  await reportHookActivity(provider, event);
10046
10043
  process.exit(0);
@@ -10123,6 +10120,50 @@ program.command("restart").description("restart the daemon (cycles the installed
10123
10120
  process.exit(1);
10124
10121
  }
10125
10122
  });
10123
+ program.command("update").description("update taktiko to the latest published version (npm i -g), then restart the daemon").option("--check", "only report whether a newer version exists; don't install").option("--force", "reinstall the latest even if already up to date").action(async (opts) => {
10124
+ const npm = process.platform === "win32" ? "npm.cmd" : "npm";
10125
+ const current = "0.3.2";
10126
+ let latest;
10127
+ try {
10128
+ latest = execFileSync2(npm, ["view", "taktiko", "version"], { encoding: "utf8" }).trim();
10129
+ } catch (e) {
10130
+ console.error(`could not reach npm to check the latest version: ${e instanceof Error ? e.message : String(e)}`);
10131
+ process.exit(1);
10132
+ }
10133
+ console.log(`current: ${current}`);
10134
+ console.log(`latest: ${latest}`);
10135
+ const outdated = isNewerVersion(latest, current);
10136
+ if (opts.check) {
10137
+ console.log(outdated ? "a newer version is available \u2014 run `taktiko update` to install it." : "up to date.");
10138
+ return;
10139
+ }
10140
+ if (!outdated && !opts.force) {
10141
+ console.log("already on the latest version (use --force to reinstall).");
10142
+ return;
10143
+ }
10144
+ console.log(`installing taktiko@${latest} ...`);
10145
+ try {
10146
+ execFileSync2(npm, ["install", "-g", `taktiko@${latest}`], { stdio: "inherit" });
10147
+ } catch (e) {
10148
+ console.error(`update failed: ${e instanceof Error ? e.message : String(e)}`);
10149
+ process.exit(1);
10150
+ }
10151
+ console.log(`updated to ${latest}.`);
10152
+ try {
10153
+ if (restartService()) {
10154
+ console.log("restarted the installed taktiko service \u2014 now running the new version.");
10155
+ } else if (isRunning()) {
10156
+ stopRunning();
10157
+ await new Promise((r) => setTimeout(r, 500));
10158
+ const pid = spawnDetached();
10159
+ console.log(`restarted the running daemon (pid ${pid}) \u2014 now running the new version.`);
10160
+ } else {
10161
+ console.log("run `taktiko start` to connect this machine with the new version.");
10162
+ }
10163
+ } catch (e) {
10164
+ console.log(`updated, but the restart failed \u2014 run \`taktiko restart\` manually (${e instanceof Error ? e.message : String(e)}).`);
10165
+ }
10166
+ });
10126
10167
  program.command("status").description("show the local daemon process + server reachability").option("--json", "machine-readable output").action(async (opts) => {
10127
10168
  const info = processInfo();
10128
10169
  const svc = getServiceStatus();
@@ -10216,6 +10257,16 @@ function printTail(n) {
10216
10257
  console.error(`could not read ${LOG_FILE}: ${e instanceof Error ? e.message : String(e)}`);
10217
10258
  }
10218
10259
  }
10260
+ function isNewerVersion(latest, current) {
10261
+ const seg = (v2) => v2.split(".").map((p2) => Number.parseInt(p2, 10) || 0);
10262
+ const a = seg(latest);
10263
+ const b2 = seg(current);
10264
+ for (let i = 0; i < Math.max(a.length, b2.length); i++) {
10265
+ const d = (a[i] ?? 0) - (b2[i] ?? 0);
10266
+ if (d !== 0) return d > 0;
10267
+ }
10268
+ return false;
10269
+ }
10219
10270
  function formatDuration(ms) {
10220
10271
  const s = Math.floor(ms / 1e3);
10221
10272
  if (s < 60) return `${s}s`;