@mingxy/opencode-mascot 0.3.7 → 0.3.9

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": "@mingxy/opencode-mascot",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "OpenCode TUI mascot plugin framework - customizable ASCII mascots for your terminal",
5
5
  "author": "mingxy",
6
6
  "license": "MIT",
@@ -49,8 +49,6 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
49
49
 
50
50
  return (
51
51
  <box
52
- height={6}
53
- width={16}
54
52
  alignItems="center"
55
53
  zIndex={9999}
56
54
  flexDirection="column"
@@ -315,10 +315,10 @@ export function createAnimatedRenderer(pack: MascotPack): {
315
315
  const dm = dragMsg();
316
316
 
317
317
  return (
318
- <box flexDirection="column" left={left} top={top}>
319
- {cel ? <text fg={flashColor() ?? fg}>{cel.text}</text> : null}
320
- {dm ? <text fg="#FF4081">{dm}</text> : null}
321
- <box flexDirection="column" alignItems="flex-start">
318
+ <box flexDirection="column" width={10} overflow="visible" left={left} top={top}>
319
+ {cel ? <text fg={flashColor() ?? fg} selectable={false}>{cel.text}</text> : null}
320
+ {dm ? <text fg="#FF4081" selectable={false}>{dm}</text> : null}
321
+ <box flexDirection="column" width={10} alignItems="flex-start">
322
322
  {lines.map((line: string) => (
323
323
  <text fg={flashColor() ?? fg} selectable={false}>{line}</text>
324
324
  ))}
@@ -0,0 +1,22 @@
1
+ import { appendFileSync, mkdirSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+
5
+ const LOG_DIR = join(homedir(), ".cache", "opencode", "logs");
6
+ const LOG_FILE = join(LOG_DIR, "mascot.log");
7
+
8
+ function ensureDir(): void {
9
+ if (!existsSync(LOG_DIR)) {
10
+ try { mkdirSync(LOG_DIR, { recursive: true }); } catch {}
11
+ }
12
+ }
13
+
14
+ export function log(level: string, message: string): void {
15
+ ensureDir();
16
+ const now = new Date();
17
+ const pad = (n: number) => String(n).padStart(2, "0");
18
+ const ts = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
19
+ try {
20
+ appendFileSync(LOG_FILE, `${ts} [${level}] ${message}\n`);
21
+ } catch {}
22
+ }
@@ -4,6 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { join, dirname } from "node:path";
5
5
  import { homedir, tmpdir } from "node:os";
6
6
  import { openSync, closeSync, unlinkSync, statSync, writeSync, mkdtempSync, readdirSync, rmSync, readFileSync, writeFileSync } from "node:fs";
7
+ import { log } from "./logger.js";
7
8
 
8
9
  const execFileAsync = promisify(execFile);
9
10
  const require = createRequire(import.meta.url);
@@ -106,19 +107,36 @@ export async function checkAndUpdate(
106
107
  currentVersion: string,
107
108
  onSuccess: (newVersion: string) => void,
108
109
  ): Promise<void> {
110
+ log("INFO", `checking: current=${currentVersion}`);
109
111
  const latest = await getLatestVersion();
110
- if (!latest) return;
112
+ if (!latest) {
113
+ log("ERROR", "failed to fetch latest version");
114
+ return;
115
+ }
116
+ log("INFO", `latest=${latest}`);
111
117
 
112
- if (compareVersions(latest, currentVersion) <= 0) return;
118
+ if (compareVersions(latest, currentVersion) <= 0) {
119
+ log("DEBUG", "already up to date");
120
+ return;
121
+ }
113
122
 
114
- if (!acquireLock()) return;
123
+ if (!acquireLock()) {
124
+ log("WARN", "lock acquisition failed");
125
+ return;
126
+ }
115
127
 
116
128
  try {
117
129
  const targetDir = getInstallDir();
130
+ log("INFO", `installing to ${targetDir}`);
118
131
  const success = await installUpdate(targetDir, latest);
119
132
  if (success) {
133
+ log("INFO", `SUCCESS: ${currentVersion} -> ${latest}`);
120
134
  onSuccess(latest);
135
+ } else {
136
+ log("ERROR", "install FAILED");
121
137
  }
138
+ } catch (err) {
139
+ log("ERROR", `exception: ${err}`);
122
140
  } finally {
123
141
  releaseLock();
124
142
  }