@gonzih/cc-tg 0.3.2 → 0.3.4

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/bot.js CHANGED
@@ -990,24 +990,46 @@ export class CcTgBot {
990
990
  await this.bot.sendMessage(chatId, `cc-agent npm version: ${npmVersion}\n\nnpx cache (~/.npm/_npx/):\n${cacheEntries}`);
991
991
  }
992
992
  async handleClearNpxCache(chatId) {
993
- try {
994
- const home = process.env.HOME ?? "~";
995
- execSync(`rm -rf "${home}/.npm/_npx/"`, { encoding: "utf8", shell: "/bin/sh" });
996
- console.log("[mcp] cleared ~/.npm/_npx/");
997
- }
998
- catch (err) {
999
- await this.bot.sendMessage(chatId, `Failed to clear npx cache: ${err.message}`);
1000
- return;
993
+ const home = process.env.HOME ?? "/tmp";
994
+ const cleared = [];
995
+ const failed = [];
996
+ // Clear both npx execution cache and full npm package cache
997
+ for (const dir of [`${home}/.npm/_npx`, `${home}/.npm/cache`]) {
998
+ try {
999
+ execSync(`rm -rf "${dir}"`, { encoding: "utf8", shell: "/bin/sh" });
1000
+ cleared.push(dir.replace(home, "~"));
1001
+ console.log(`[cache] cleared ${dir}`);
1002
+ }
1003
+ catch (err) {
1004
+ failed.push(dir.replace(home, "~"));
1005
+ console.warn(`[cache] failed to clear ${dir}:`, err.message);
1006
+ }
1001
1007
  }
1002
1008
  const pids = this.killCcAgent();
1003
1009
  const pidNote = pids.length > 0
1004
- ? ` Sent SIGTERM to pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}.`
1005
- : " No cc-agent process found (will start fresh on next call).";
1006
- await this.bot.sendMessage(chatId, `NPX cache cleared and MCP restarted.${pidNote} Will pick up latest npm version on next call.`);
1010
+ ? ` Sent SIGTERM to cc-agent pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}.`
1011
+ : " No cc-agent running.";
1012
+ const clearNote = failed.length
1013
+ ? `Cleared: ${cleared.join(", ")}. Failed: ${failed.join(", ")}.`
1014
+ : `Cleared: ${cleared.join(", ")}.`;
1015
+ await this.bot.sendMessage(chatId, `${clearNote}${pidNote} Next call picks up latest npm version.`);
1007
1016
  }
1008
1017
  async handleRestart(chatId) {
1009
- await this.bot.sendMessage(chatId, "Restarting... brb.");
1010
- await new Promise(resolve => setTimeout(resolve, 500));
1018
+ await this.bot.sendMessage(chatId, "Clearing cache and restarting... brb.");
1019
+ await new Promise(resolve => setTimeout(resolve, 300));
1020
+ // Clear npm caches before restart so launchd brings up fresh version
1021
+ const home = process.env.HOME ?? "/tmp";
1022
+ for (const dir of [`${home}/.npm/_npx`, `${home}/.npm/cache`]) {
1023
+ try {
1024
+ execSync(`rm -rf "${dir}"`, { shell: "/bin/sh" });
1025
+ }
1026
+ catch { }
1027
+ }
1028
+ // Kill all active Claude sessions cleanly
1029
+ for (const [cid] of this.sessions) {
1030
+ this.killSession(cid);
1031
+ }
1032
+ await new Promise(resolve => setTimeout(resolve, 200));
1011
1033
  process.exit(0);
1012
1034
  }
1013
1035
  async handleGetFile(chatId, text) {
package/dist/claude.js CHANGED
@@ -13,7 +13,7 @@ export class ClaudeProcess extends EventEmitter {
13
13
  constructor(opts = {}) {
14
14
  super();
15
15
  const args = [
16
- "--no-session-persistence",
16
+ "--continue",
17
17
  "--output-format", "stream-json",
18
18
  "--input-format", "stream-json",
19
19
  "--print",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {