@quicktvui/ai 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/ai",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "QuickTVUI AI 开发规范与脚手架注入工具",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -11,7 +11,10 @@ if (!projectRoot || !fs.existsSync(projectRoot)) {
11
11
  }
12
12
 
13
13
  // 避免在包自身的开发环境中循环复制
14
- if (projectRoot === __dirname) {
14
+ if (
15
+ projectRoot === __dirname ||
16
+ projectRoot === path.join(__dirname, "..", "..")
17
+ ) {
15
18
  process.exit(0);
16
19
  }
17
20
 
@@ -19,6 +22,9 @@ console.log("\n🚀 [@quicktvui/ai] 开始为您注入 QuickTVUI 专属 AI 规
19
22
  console.log(`📂 目标目录: ${projectRoot}`);
20
23
 
21
24
  const rulesDir = path.join(__dirname, "rules");
25
+ const backupBaseDir = path.join(projectRoot, ".quicktvui-ai-backup");
26
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
27
+ const currentBackupDir = path.join(backupBaseDir, `backup_${timestamp}`);
22
28
 
23
29
  function copyDirectorySync(src, dest) {
24
30
  if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
@@ -35,27 +41,80 @@ function copyDirectorySync(src, dest) {
35
41
  }
36
42
 
37
43
  try {
38
- // 1. 拷贝规则
44
+ const rootItems = fs.readdirSync(rulesDir);
45
+ let backupNeeded = false;
46
+
47
+ // 1. 检查并备份现有配置
48
+ rootItems.forEach((item) => {
49
+ const targetPath = path.join(projectRoot, item);
50
+ if (fs.existsSync(targetPath)) {
51
+ if (!backupNeeded) {
52
+ if (!fs.existsSync(currentBackupDir))
53
+ fs.mkdirSync(currentBackupDir, { recursive: true });
54
+ backupNeeded = true;
55
+ }
56
+ const backupPath = path.join(currentBackupDir, item);
57
+ if (fs.lstatSync(targetPath).isDirectory()) {
58
+ copyDirectorySync(targetPath, backupPath);
59
+ } else {
60
+ fs.copyFileSync(targetPath, backupPath);
61
+ }
62
+ }
63
+ });
64
+
65
+ if (backupNeeded) {
66
+ console.log(
67
+ `📦 已检测到现有 AI 配置文件,已备份至: .quicktvui-ai-backup/backup_${timestamp}`,
68
+ );
69
+ }
70
+
71
+ // 2. 注入新规则
39
72
  copyDirectorySync(rulesDir, projectRoot);
40
73
  console.log("🎉 [@quicktvui/ai] AI 规范注入成功!");
41
74
 
42
- // 2. 尝试 Git Add
43
- const gitDir = path.join(projectRoot, ".git");
44
- if (fs.existsSync(gitDir)) {
45
- console.log("📦 正在将配置文件添加到 Git 暂存区...");
46
- const rootItems = fs.readdirSync(rulesDir);
47
- rootItems.forEach((item) => {
48
- try {
49
- execSync(`git add "${item}"`, { cwd: projectRoot, stdio: "ignore" });
50
- } catch (e) {}
51
- });
52
- console.log(" 自动 git add 完成。");
53
- } else {
54
- console.log("ℹ️ 未检测到 Git 仓库,跳过自动 git add。");
75
+ // 3. 更新 .gitignore
76
+ const gitignorePath = path.join(projectRoot, ".gitignore");
77
+ let gitignoreContent = "";
78
+ if (fs.existsSync(gitignorePath)) {
79
+ gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
80
+ }
81
+
82
+ const itemsToIgnore = [
83
+ ".quicktvui-ai-backup",
84
+ ...rootItems.map((item) =>
85
+ item === ".github" ? ".github/copilot-instructions.md" : item,
86
+ ),
87
+ ];
88
+
89
+ let updatedGitignore = gitignoreContent;
90
+ let hasChanges = false;
91
+
92
+ const sectionHeader = "# QuickTVUI AI Rules";
93
+ if (!updatedGitignore.includes(sectionHeader)) {
94
+ updatedGitignore +=
95
+ (updatedGitignore.length > 0 && !updatedGitignore.endsWith("\n")
96
+ ? "\n"
97
+ : "") + `\n${sectionHeader}\n`;
98
+ hasChanges = true;
99
+ }
100
+
101
+ itemsToIgnore.forEach((item) => {
102
+ const regex = new RegExp(`^${item.replace(/\./g, "\\.")}$`, "m");
103
+ if (!regex.test(updatedGitignore)) {
104
+ if (!updatedGitignore.endsWith("\n")) updatedGitignore += "\n";
105
+ updatedGitignore += `${item}\n`;
106
+ hasChanges = true;
107
+ }
108
+ });
109
+
110
+ if (hasChanges) {
111
+ fs.writeFileSync(gitignorePath, updatedGitignore);
112
+ console.log("✅ 已更新 .gitignore,排除 AI 配置文件。");
55
113
  }
56
114
  } catch (err) {
57
115
  console.error(`❌ 注入失败: ${err.message}`);
58
116
  }
117
+
59
118
  console.log(
60
119
  "\n🤖 您的项目现已全面兼容 Cursor, Windsurf, Cline 等 AI 助手!开发愉快!\n",
61
120
  );
package/rules/.clinerules CHANGED
@@ -143,6 +143,26 @@ Other CSS rules:
143
143
  <qt-list-view :clipChildren="false" :clipPadding="false" />
144
144
  ```
145
145
 
146
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
147
+
148
+ 当用户通过以下方式表达困惑时:
149
+ - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
150
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
151
+
152
+ **AI 执行协议:**
153
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
154
+ - 提取报错日志(去除绝对路径和私密 Token)。
155
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
156
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
157
+ 2. **寻求授权 (Request Consent)**:
158
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
159
+ 3. **提交方式 (Submission)**:
160
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
161
+ - macOS: `open "URL"`
162
+ - Linux: `xdg-open "URL"`
163
+ - Windows: `start "URL"`
164
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
165
+
146
166
  ### Import Sources
147
167
  - `defineComponent` from `vue` — NOT from `@vue/runtime-core`
148
168
  - Router: `useESRouter` from `@extscreen/es3-router`
@@ -143,6 +143,26 @@ Other CSS rules:
143
143
  <qt-list-view :clipChildren="false" :clipPadding="false" />
144
144
  ```
145
145
 
146
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
147
+
148
+ 当用户通过以下方式表达困惑时:
149
+ - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
150
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
151
+
152
+ **AI 执行协议:**
153
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
154
+ - 提取报错日志(去除绝对路径和私密 Token)。
155
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
156
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
157
+ 2. **寻求授权 (Request Consent)**:
158
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
159
+ 3. **提交方式 (Submission)**:
160
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
161
+ - macOS: `open "URL"`
162
+ - Linux: `xdg-open "URL"`
163
+ - Windows: `start "URL"`
164
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
165
+
146
166
  ### Import Sources
147
167
  - `defineComponent` from `vue` — NOT from `@vue/runtime-core`
148
168
  - Router: `useESRouter` from `@extscreen/es3-router`
@@ -143,6 +143,26 @@ Other CSS rules:
143
143
  <qt-list-view :clipChildren="false" :clipPadding="false" />
144
144
  ```
145
145
 
146
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
147
+
148
+ 当用户通过以下方式表达困惑时:
149
+ - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
150
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
151
+
152
+ **AI 执行协议:**
153
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
154
+ - 提取报错日志(去除绝对路径和私密 Token)。
155
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
156
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
157
+ 2. **寻求授权 (Request Consent)**:
158
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
159
+ 3. **提交方式 (Submission)**:
160
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
161
+ - macOS: `open "URL"`
162
+ - Linux: `xdg-open "URL"`
163
+ - Windows: `start "URL"`
164
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
165
+
146
166
  ### Import Sources
147
167
  - `defineComponent` from `vue` — NOT from `@vue/runtime-core`
148
168
  - Router: `useESRouter` from `@extscreen/es3-router`
package/rules/AGENTS.md CHANGED
@@ -154,6 +154,26 @@ Android clips child views outside parent bounds by default. When using `focusSca
154
154
  <qt-list-view :clipChildren="false" :clipPadding="false" />
155
155
  ```
156
156
 
157
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
158
+
159
+ 当用户通过以下方式表达困惑时:
160
+ - **关键词触发**:当用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
161
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
162
+
163
+ **AI 执行协议 (Execution Protocol):**
164
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
165
+ - 提取报错日志(必须去除绝对路径和私密 Token/API Keys)。
166
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
167
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
168
+ 2. **寻求授权 (Request Consent)**:
169
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
170
+ 3. **提交方式 (Submission)**:
171
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
172
+ - macOS: `open "URL"`
173
+ - Linux: `xdg-open "URL"`
174
+ - Windows: `start "URL"`
175
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
176
+
157
177
  ### Import Sources
158
178
 
159
179
  - `defineComponent` from `vue` — NOT from `@vue/runtime-core`
package/rules/CLAUDE.md CHANGED
@@ -178,6 +178,26 @@ Android 默认裁切超出父容器边界的子元素。TV 端使用 `focusScale
178
178
  <qt-waterfall :clipChildren="false" :clipPadding="false" />
179
179
  ```
180
180
 
181
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
182
+
183
+ 当用户通过以下方式表达困惑时:
184
+ - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
185
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
186
+
187
+ **AI 执行协议:**
188
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
189
+ - 提取报错日志(去除绝对路径和私密 Token)。
190
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
191
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
192
+ 2. **寻求授权 (Request Consent)**:
193
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
194
+ 3. **提交方式 (Submission)**:
195
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
196
+ - macOS: `open "URL"`
197
+ - Linux: `xdg-open "URL"`
198
+ - Windows: `start "URL"`
199
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
200
+
181
201
  ### import 来源
182
202
 
183
203
  - `defineComponent` 从 `vue` 导入(对),不要从 `@vue/runtime-core` 导入
package/rules/GEMINI.md CHANGED
@@ -159,6 +159,26 @@ Android clips child views outside parent bounds by default. When using `focusSca
159
159
  <qt-list-view :clipChildren="false" :clipPadding="false" />
160
160
  ```
161
161
 
162
+ ## 🛡️ AI Sentinel: 框架问题上报机制 (Bug Reporting)
163
+
164
+ 当用户通过以下方式表达困惑时:
165
+ - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
166
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
167
+
168
+ **AI 执行协议:**
169
+ 1. **脱敏诊断 (Sanitized Diagnosis)**:
170
+ - 提取报错日志(去除绝对路径和私密 Token)。
171
+ - 整理环境信息(Node 版本、package.json 中的框架版本)。
172
+ - 编写最小可复现 Demo 代码(Minimum Reproducible Example)。
173
+ 2. **寻求授权 (Request Consent)**:
174
+ - AI 必须询问:“检测到该问题可能属于 QuickTVUI 框架缺陷,我已为您准备好一份脱敏后的诊断报告,是否允许我协助您将其上报到 GitHub 官方仓库以寻求官方支持?”
175
+ 3. **提交方式 (Submission)**:
176
+ - 授权后,**自动打开浏览器**:AI 应尝试根据操作系统执行系统命令以自动打开 Issue 链接:
177
+ - macOS: `open "URL"`
178
+ - Linux: `xdg-open "URL"`
179
+ - Windows: `start "URL"`
180
+ - 如果自动打开失败,则展示 Issue 预填充链接引导用户点击。
181
+
162
182
  ### Import Sources
163
183
 
164
184
  - `defineComponent` from `vue` (correct) — NOT from `@vue/runtime-core`