@yeaft/webchat-agent 0.1.242 → 0.1.243
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/index.js +34 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -138,22 +138,26 @@ async function ensureDependencies() {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
// 确保 yeaft-skills
|
|
141
|
+
// 确保 yeaft-skills 插件已安装到 Claude CLI plugin 系统并注册为 marketplace
|
|
142
142
|
async function ensureYeaftSkills() {
|
|
143
|
-
const
|
|
143
|
+
const MARKETPLACE_NAME = 'yeaft-skills-dev';
|
|
144
144
|
const REPO_URL = 'https://github.com/yeaft/yeaft-skills.git';
|
|
145
|
+
const pluginsDir = join(homedir(), '.claude', 'plugins');
|
|
146
|
+
const marketplacesDir = join(pluginsDir, 'marketplaces');
|
|
147
|
+
const installDir = join(marketplacesDir, MARKETPLACE_NAME);
|
|
148
|
+
const knownFile = join(pluginsDir, 'known_marketplaces.json');
|
|
145
149
|
|
|
146
150
|
try {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
mkdirSync(
|
|
151
|
-
await execAsync(`git clone ${REPO_URL} "${
|
|
151
|
+
// Clone or update the marketplace repo
|
|
152
|
+
if (!existsSync(installDir)) {
|
|
153
|
+
console.log('[Startup] yeaft-skills not found, installing as marketplace plugin...');
|
|
154
|
+
mkdirSync(marketplacesDir, { recursive: true });
|
|
155
|
+
await execAsync(`git clone ${REPO_URL} "${installDir}"`, { timeout: 60000 });
|
|
152
156
|
console.log('[Startup] yeaft-skills installed');
|
|
153
157
|
} else {
|
|
154
158
|
console.log('[Startup] yeaft-skills found, checking for updates...');
|
|
155
159
|
const { stdout } = await execAsync('git pull --ff-only', {
|
|
156
|
-
cwd:
|
|
160
|
+
cwd: installDir,
|
|
157
161
|
timeout: 30000
|
|
158
162
|
});
|
|
159
163
|
if (stdout.includes('Already up to date')) {
|
|
@@ -162,6 +166,28 @@ async function ensureYeaftSkills() {
|
|
|
162
166
|
console.log('[Startup] yeaft-skills updated');
|
|
163
167
|
}
|
|
164
168
|
}
|
|
169
|
+
|
|
170
|
+
// Register in known_marketplaces.json (idempotent)
|
|
171
|
+
let known = {};
|
|
172
|
+
if (existsSync(knownFile)) {
|
|
173
|
+
try {
|
|
174
|
+
known = JSON.parse(readFileSync(knownFile, 'utf-8'));
|
|
175
|
+
} catch { /* corrupted file, will recreate */ }
|
|
176
|
+
}
|
|
177
|
+
if (!known[MARKETPLACE_NAME]) {
|
|
178
|
+
known[MARKETPLACE_NAME] = {
|
|
179
|
+
source: { source: 'github', repo: 'yeaft/yeaft-skills' },
|
|
180
|
+
installLocation: installDir,
|
|
181
|
+
lastUpdated: new Date().toISOString()
|
|
182
|
+
};
|
|
183
|
+
writeFileSync(knownFile, JSON.stringify(known, null, 2));
|
|
184
|
+
console.log('[Startup] yeaft-skills registered in known_marketplaces.json');
|
|
185
|
+
} else {
|
|
186
|
+
// Update lastUpdated timestamp
|
|
187
|
+
known[MARKETPLACE_NAME].lastUpdated = new Date().toISOString();
|
|
188
|
+
known[MARKETPLACE_NAME].installLocation = installDir;
|
|
189
|
+
writeFileSync(knownFile, JSON.stringify(known, null, 2));
|
|
190
|
+
}
|
|
165
191
|
} catch (e) {
|
|
166
192
|
console.warn('[Startup] yeaft-skills sync failed (skills will be unavailable):', e.message);
|
|
167
193
|
}
|