uxos 0.0.28 → 0.0.29

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 (3) hide show
  1. package/README.md +77 -47
  2. package/cli.js +61 -70
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -2,38 +2,9 @@
2
2
 
3
3
  UXOS - 设计效率助手:一个由 AI 驱动的、具有引导式工作流的设计协作系统。
4
4
 
5
- ## ⚠️ 重要提示
6
-
7
- **必须使用 `@latest` 标签,否则可能使用缓存的旧版本导致安装失败!**
8
-
9
5
  ## 安装方法
10
6
 
11
- **唯一正确的安装命令**:
12
-
13
- ```bash
14
- npx uxos@latest
15
- ```
16
-
17
- > ❌ **错误**:`npx uxos`(会使用缓存)
18
- > ❌ **错误**:`npx uxos install`(会使用缓存)
19
- > ✅ **正确**:`npx uxos@latest`(始终最新)
20
- > ✅ **正确**:`npx uxos@0.0.27`(指定版本)
21
-
22
- ### 为什么必须使用 @latest?
23
-
24
- npx 会优先使用缓存的旧版本(0.0.21 或更早),导致:
25
- - ❌ 创建错误的文件夹(`config/`、`workflows/`)
26
- - ❌ 缺少必要的文件(`_uxos/`)
27
- - ❌ 安装失败并报错
28
- - ❌ 与新版本冲突(同时出现旧文件夹和 `_uxos/`)
29
-
30
- 使用 `@latest` 可以:
31
- - ✅ 强制从 npm 下载最新版本
32
- - ✅ 跳过缓存
33
- - ✅ 确保正确安装
34
- - ✅ 避免版本冲突
35
-
36
- **方法一:通过 AI 助手安装**
7
+ ### 方法一:通过 AI 助手安装(推荐)
37
8
 
38
9
  在 CodeBuddy 的 AI 助手中输入:
39
10
 
@@ -41,38 +12,47 @@ npx 会优先使用缓存的旧版本(0.0.21 或更早),导致:
41
12
  帮我安装 npx uxos
42
13
  ```
43
14
 
44
- **方法二:命令行安装(推荐)**
15
+ AI 助手会自动处理安装过程。
16
+
17
+ > ⚠️ **AI 助手注意**:请务必使用以下命令,不要使用全局安装或其他方式:
18
+ > ```bash
19
+ > npx uxos@latest
20
+ > ```
21
+ > **禁止使用**:
22
+ > - ❌ `npm install -g uxos`(全局安装)
23
+ > - ❌ `npm install uxos`(本地安装)
24
+ > - ❌ `uxos`(直接调用全局命令)
25
+ > - ❌ `npx uxos`(没有 @latest)
26
+
27
+ ### 方法二:命令行安装
45
28
 
46
29
  ```bash
47
- # 推荐:明确指定 @latest 确保使用最新版本
48
30
  npx uxos@latest
49
-
50
- # 或指定具体版本号
51
- npx uxos@0.0.24
52
31
  ```
53
32
 
54
- ### ⚠️ 如果遇到旧版本问题
33
+ > 💡 **提示**:执行时会提示 "Ok to proceed? (y)",输入 `y` 回车即可。
55
34
 
56
- 如果之前安装过 uxos 并遇到错误,请运行:
35
+ ---
57
36
 
58
- ```bash
59
- # 1. 卸载全局安装(如果有)
60
- npm uninstall -g uxos
37
+ ## ⚠️ 重要提示
61
38
 
62
- # 2. 清除缓存
63
- npm cache clean --force
64
- rm -rf ~/.npm/_npx
39
+ **必须使用 `@latest` 标签,否则可能使用缓存的旧版本导致安装失败!**
65
40
 
66
- # 3. 使用最新版本
67
- npx uxos@latest
68
- ```
41
+ > **错误**:`npx uxos`(会使用缓存)
42
+ > ✅ **正确**:`npx uxos@latest`(始终最新)
43
+
44
+ ### 为什么必须使用 @latest?
45
+
46
+ npx 会优先使用缓存的旧版本,导致创建错误的文件夹结构。使用 `@latest` 可以强制从 npm 下载最新版本。
69
47
 
70
- 然后跟随 AI 助手的指引即可完成安装。
48
+ ---
71
49
 
72
50
  ## 使用说明
73
51
 
74
52
  安装完成后,UXOS 会自动在工作目录创建 `_uxos/` 文件夹。AI 助手会引导你阅读初始化指南并开始使用。
75
53
 
54
+ ---
55
+
76
56
  ## 故障排除
77
57
 
78
58
  ### 问题:出现 config/ 或 workflows/ 文件夹
@@ -135,3 +115,53 @@ npx uxos -v
135
115
  ## 许可证
136
116
 
137
117
  MIT
118
+
119
+ ---
120
+
121
+ ## 🤖 AI 助手专用指令
122
+
123
+ > **本节专门针对 AI 助手,确保正确安装 uxos**
124
+
125
+ ### 当用户请求安装 uxos 时
126
+
127
+ **唯一正确的命令**:
128
+ ```bash
129
+ npx uxos@latest
130
+ ```
131
+
132
+ **禁止的操作**:
133
+ 1. ❌ 不要使用 `npm install -g uxos`(会安装到全局,导致版本混乱)
134
+ 2. ❌ 不要使用 `npm install uxos`(会安装到项目依赖)
135
+ 3. ❌ 不要使用 `uxos` 命令(会调用全局安装的旧版本)
136
+ 4. ❌ 不要使用 `npx uxos`(没有 @latest,会使用缓存)
137
+
138
+ **检查清单**:
139
+ - ✅ 命令必须包含 `@latest`
140
+ - ✅ 使用 `npx` 而不是 `npm install`
141
+ - ✅ 不要检查或使用全局安装的 uxos
142
+ - ✅ 执行前先 `cd` 到用户的目标目录
143
+
144
+ ### 安装前检查
145
+
146
+ 如果用户机器上有全局安装的 uxos,**不要使用它**,直接执行:
147
+ ```bash
148
+ npx uxos@latest
149
+ ```
150
+
151
+ ### 常见错误示例
152
+
153
+ ❌ **错误示例 1**:检测到全局安装后直接使用
154
+ ```bash
155
+ # AI 发现: npm list -g uxos 显示 0.0.25
156
+ uxos # 错误!会使用旧版本 0.0.25
157
+ ```
158
+
159
+ ❌ **错误示例 2**:尝试更新全局安装
160
+ ```bash
161
+ npm update -g uxos # 不要这样做!
162
+ ```
163
+
164
+ ✅ **正确做法**:始终使用 npx @latest
165
+ ```bash
166
+ npx uxos@latest # 永远使用这个命令
167
+ ```
package/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
+ const os = require('os');
5
6
  const { execSync } = require('child_process');
6
7
 
7
8
  // Read version from package.json
@@ -9,14 +10,62 @@ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.jso
9
10
  const VERSION = packageJson.version;
10
11
 
11
12
  const UXOS_SRC_DIR = path.join(__dirname, '_uxos');
13
+ const CHECK_INTERVAL = 1000 * 60 * 60 * 24; // 24 hours
12
14
 
13
15
  // CRITICAL: Check if running the latest version IMMEDIATELY
14
16
  function checkForLatestVersion() {
15
17
  try {
16
- const latestVersion = execSync('npm view uxos version', { encoding: 'utf8', timeout: 3000 }).trim();
18
+ // Use a cache file to avoid checking too frequently
19
+ const cacheDir = path.join(os.tmpdir(), '.uxos-version-check');
20
+ const cacheFile = path.join(cacheDir, 'last-check.json');
17
21
 
18
- if (latestVersion !== VERSION) {
19
- console.log(`
22
+ let shouldCheck = true;
23
+
24
+ // Check if we need to query npm registry
25
+ if (fs.existsSync(cacheFile)) {
26
+ const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
27
+ const timeSinceLastCheck = Date.now() - cache.timestamp;
28
+
29
+ if (timeSinceLastCheck < CHECK_INTERVAL) {
30
+ // Use cached result
31
+ shouldCheck = false;
32
+ if (cache.latestVersion !== VERSION) {
33
+ showVersionWarning(cache.latestVersion);
34
+ process.exit(1);
35
+ }
36
+ }
37
+ }
38
+
39
+ // Perform actual check if needed
40
+ if (shouldCheck) {
41
+ const latestVersion = execSync('npm view uxos version', {
42
+ encoding: 'utf8',
43
+ timeout: 3000,
44
+ stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr
45
+ }).trim();
46
+
47
+ // Save to cache
48
+ if (!fs.existsSync(cacheDir)) {
49
+ fs.mkdirSync(cacheDir, { recursive: true });
50
+ }
51
+ fs.writeFileSync(cacheFile, JSON.stringify({
52
+ timestamp: Date.now(),
53
+ latestVersion: latestVersion
54
+ }));
55
+
56
+ if (latestVersion !== VERSION) {
57
+ showVersionWarning(latestVersion);
58
+ process.exit(1);
59
+ }
60
+ }
61
+ } catch (error) {
62
+ // If we can't check (no internet, etc.), continue anyway
63
+ // Silent failure - don't spam users with warnings
64
+ }
65
+ }
66
+
67
+ function showVersionWarning(latestVersion) {
68
+ console.log(`
20
69
  ╔═══════════════════════════════════════════════════════════╗
21
70
  ║ ⚠️ VERSION WARNING ║
22
71
  ╚═══════════════════════════════════════════════════════════╝
@@ -32,7 +81,6 @@ SOLUTION: Always use @latest tag:
32
81
 
33
82
  Or clean cache first:
34
83
 
35
- npm uninstall -g uxos
36
84
  npm cache clean --force
37
85
  rm -rf ~/.npm/_npx
38
86
  npx uxos@latest
@@ -40,31 +88,11 @@ Or clean cache first:
40
88
  Visit: https://www.npmjs.com/package/uxos
41
89
 
42
90
  `);
43
- process.exit(1);
44
- }
45
- } catch (error) {
46
- // If we can't check (no internet, etc.), continue anyway
47
- console.log('⚠️ Unable to check for updates (network issue?)\n');
48
- }
49
91
  }
50
92
 
51
93
  // Check IMMEDIATELY before doing anything
52
94
  checkForLatestVersion();
53
95
 
54
- function createDirectory(dir) {
55
- if (!fs.existsSync(dir)) {
56
- fs.mkdirSync(dir, { recursive: true });
57
- console.log(`✓ Created directory: ${dir}`);
58
- }
59
- }
60
-
61
- function copyFile(src, dest) {
62
- if (fs.existsSync(src)) {
63
- fs.copyFileSync(src, dest);
64
- console.log(`✓ Copied: ${path.basename(dest)}`);
65
- }
66
- }
67
-
68
96
  function copyDirectory(src, dest) {
69
97
  if (!fs.existsSync(src)) return;
70
98
 
@@ -94,65 +122,28 @@ function main() {
94
122
  return;
95
123
  }
96
124
 
97
- // Check for old version structure FIRST (before creating anything)
98
- const oldWorkflowsDir = path.join(__dirname, 'workflows');
99
- const oldTemplatesDir = path.join(__dirname, 'templates');
100
- const oldConfigDir = path.join(__dirname, 'config');
101
-
102
- if (fs.existsSync(oldWorkflowsDir) || fs.existsSync(oldTemplatesDir) || fs.existsSync(oldConfigDir)) {
103
- console.log(`
104
- ╔═══════════════════════════════════════════════════════════╗
105
- ║ ⚠️ OLD VERSION STRUCTURE DETECTED ║
106
- ╚═══════════════════════════════════════════════════════════╝
107
-
108
- This is an old version (0.0.21 or earlier).
109
-
110
- ⚠️ CRITICAL: You are using a CACHED old version!
111
-
112
- The old version may have created these folders:
113
- - config/
114
- - workflows/
115
- - templates/
116
-
117
- SOLUTION: Always use @latest to avoid cache:
118
-
119
- npx uxos@latest
120
-
121
- Or clean up:
122
-
123
- npm uninstall -g uxos
124
- npm cache clean --force
125
- rm -rf ~/.npm/_npx
126
-
127
- Then delete old folders in your project:
128
- rm -rf config/ workflows/ templates/
129
-
130
- Then run:
131
- npx uxos@latest
132
-
133
- `);
134
- process.exit(1);
135
- }
136
-
137
125
  const projectRoot = process.cwd();
138
126
 
139
- // Check if old folders exist in project directory
127
+ // Check if old UXOS folders exist in project directory (from cached old version)
140
128
  const projectOldWorkflows = path.join(projectRoot, 'workflows');
141
129
  const projectOldConfig = path.join(projectRoot, 'config');
130
+ const projectOldTemplates = path.join(projectRoot, 'templates');
142
131
 
143
- if (fs.existsSync(projectOldWorkflows) || fs.existsSync(projectOldConfig)) {
132
+ if (fs.existsSync(projectOldWorkflows) || fs.existsSync(projectOldConfig) || fs.existsSync(projectOldTemplates)) {
144
133
  console.log(`
145
134
  ╔═══════════════════════════════════════════════════════════╗
146
135
  ║ ⚠️ OLD UXOS FILES DETECTED IN PROJECT ║
147
136
  ╚═══════════════════════════════════════════════════════════╝
148
137
 
149
- Found old UXOS files from version 0.0.21 or earlier:
150
- ${fs.existsSync(projectOldWorkflows) ? ' ✗ workflows/\n' : ''}${fs.existsSync(projectOldConfig) ? ' ✗ config/\n' : ''}
151
- Please remove these folders before installing:
138
+ Found old UXOS files from a previous cached version (v0.0.21 or earlier):
139
+ ${fs.existsSync(projectOldWorkflows) ? ' ✗ workflows/\n' : ''}${fs.existsSync(projectOldConfig) ? ' ✗ config/\n' : ''}${fs.existsSync(projectOldTemplates) ? ' ✗ templates/\n' : ''}
140
+ These folders are incompatible with the new version structure (_uxos/).
141
+
142
+ SOLUTION: Clean up old files first:
152
143
 
153
144
  rm -rf workflows/ config/ templates/
154
145
 
155
- Then run:
146
+ Then run again with @latest:
156
147
 
157
148
  npx uxos@latest
158
149
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "uxos",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "UXOS - Design Efficiency Assistant: A guided workflow system for AI-powered design collaboration",
5
5
  "main": "cli.js",
6
6
  "bin": {
7
- "uxos": "./cli.js"
7
+ "uxos": "cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "test": "node cli.js"