@geminilight/mindos 0.5.43 → 0.5.45

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.
@@ -0,0 +1,115 @@
1
+ import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { MINDOS_DIR } from './constants.js';
4
+
5
+ const STATUS_PATH = resolve(MINDOS_DIR, 'update-status.json');
6
+
7
+ const STAGE_ORDER = ['downloading', 'skills', 'rebuilding', 'restarting'];
8
+
9
+ /**
10
+ * Write update progress to ~/.mindos/update-status.json.
11
+ *
12
+ * @param {'downloading'|'skills'|'rebuilding'|'restarting'|'done'|'failed'} stage
13
+ * @param {{ error?: string, fromVersion?: string, toVersion?: string }} [opts]
14
+ */
15
+ export function writeUpdateStatus(stage, opts = {}) {
16
+ const stages = STAGE_ORDER.map((id) => {
17
+ const idx = STAGE_ORDER.indexOf(id);
18
+ const currentIdx = STAGE_ORDER.indexOf(stage);
19
+ let status = 'pending';
20
+ if (stage === 'done' || stage === 'failed') {
21
+ // done: all stages done; failed: stages up to current are done, current is failed
22
+ if (stage === 'done') {
23
+ status = 'done';
24
+ } else {
25
+ // For 'failed', we don't know which stage failed from just 'failed'
26
+ // So we keep whatever was last written — this function is called per-stage
27
+ status = 'pending';
28
+ }
29
+ } else if (idx < currentIdx) {
30
+ status = 'done';
31
+ } else if (idx === currentIdx) {
32
+ status = 'running';
33
+ }
34
+ return { id, status };
35
+ });
36
+
37
+ // For 'done', mark all as done
38
+ if (stage === 'done') {
39
+ stages.forEach((s) => { s.status = 'done'; });
40
+ }
41
+
42
+ const data = {
43
+ stage,
44
+ stages,
45
+ error: opts.error || null,
46
+ version: {
47
+ from: opts.fromVersion || null,
48
+ to: opts.toVersion || null,
49
+ },
50
+ startedAt: stage === 'downloading'
51
+ ? new Date().toISOString()
52
+ : readCurrentStartedAt(),
53
+ };
54
+
55
+ try {
56
+ writeFileSync(STATUS_PATH, JSON.stringify(data, null, 2), 'utf-8');
57
+ } catch { /* best-effort — directory may not exist yet */ }
58
+ }
59
+
60
+ /**
61
+ * Mark a specific stage as failed. Preserves progress of prior stages.
62
+ */
63
+ export function writeUpdateFailed(failedStage, errorMessage, opts = {}) {
64
+ const stages = STAGE_ORDER.map((id) => {
65
+ const idx = STAGE_ORDER.indexOf(id);
66
+ const failedIdx = STAGE_ORDER.indexOf(failedStage);
67
+ if (idx < failedIdx) return { id, status: 'done' };
68
+ if (idx === failedIdx) return { id, status: 'failed' };
69
+ return { id, status: 'pending' };
70
+ });
71
+
72
+ const data = {
73
+ stage: 'failed',
74
+ stages,
75
+ error: errorMessage,
76
+ version: {
77
+ from: opts.fromVersion || null,
78
+ to: opts.toVersion || null,
79
+ },
80
+ startedAt: readCurrentStartedAt(),
81
+ };
82
+
83
+ try {
84
+ writeFileSync(STATUS_PATH, JSON.stringify(data, null, 2), 'utf-8');
85
+ } catch { /* best-effort */ }
86
+ }
87
+
88
+ /**
89
+ * Read the current update status. Returns null if no status file.
90
+ */
91
+ export function readUpdateStatus() {
92
+ try {
93
+ return JSON.parse(readFileSync(STATUS_PATH, 'utf-8'));
94
+ } catch {
95
+ return null;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Remove the status file (called on startup to clear stale state).
101
+ */
102
+ export function clearUpdateStatus() {
103
+ try {
104
+ if (existsSync(STATUS_PATH)) unlinkSync(STATUS_PATH);
105
+ } catch { /* best-effort */ }
106
+ }
107
+
108
+ function readCurrentStartedAt() {
109
+ try {
110
+ const existing = JSON.parse(readFileSync(STATUS_PATH, 'utf-8'));
111
+ return existing.startedAt || new Date().toISOString();
112
+ } catch {
113
+ return new Date().toISOString();
114
+ }
115
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geminilight/mindos",
3
- "version": "0.5.43",
3
+ "version": "0.5.45",
4
4
  "description": "MindOS — Human-Agent Collaborative Mind System. Local-first knowledge base that syncs your mind to all AI Agents via MCP.",
5
5
  "keywords": [
6
6
  "mindos",
@@ -16,9 +16,11 @@ const { join } = require('path');
16
16
  const { execSync } = require('child_process');
17
17
 
18
18
  const postcssDir = join('node_modules', 'next', 'node_modules', 'postcss');
19
- const depsDir = join(postcssDir, 'node_modules');
19
+ // Check for an actual dependency, not just the node_modules directory
20
+ // (npm sometimes leaves an empty node_modules with only .bin and .package-lock.json)
21
+ const marker = join(postcssDir, 'node_modules', 'source-map-js');
20
22
 
21
- if (existsSync(postcssDir) && !existsSync(depsDir)) {
23
+ if (existsSync(postcssDir) && !existsSync(marker)) {
22
24
  try {
23
25
  execSync('npm install --no-save --install-strategy=nested', {
24
26
  cwd: postcssDir,