chore: add diagnostic and seeding scripts

- Add script to generate bcrypt admin password hash.
- Add script to seed sample articles for local development.
- Add Kimi/Moonshot API diagnostic scripts (SDK and direct curl).
This commit is contained in:
hermes
2026-06-17 04:34:35 +00:00
parent fd0553a6b9
commit 1b23f57d6c
4 changed files with 210 additions and 0 deletions

37
scripts/test-kimi-curl.ts Normal file
View File

@@ -0,0 +1,37 @@
import { getActiveKey } from '../src/lib/api-keys';
async function main() {
const key = await getActiveKey('KIMI');
if (!key) {
console.log('No active KIMI key found');
return;
}
const model = process.env.KIMI_MODEL || 'moonshot-v1-8k';
const url = process.env.KIMI_API_URL || 'https://api.moonshot.cn/v1';
console.log('Key length:', key.length);
console.log('Key starts with:', key.slice(0, 6));
console.log('API URL:', url);
console.log('Model:', model);
console.log('');
const res = await fetch(`${url}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${key}`,
},
body: JSON.stringify({
model,
messages: [{ role: 'user', content: 'Say hello' }],
temperature: 0.2,
}),
});
const body = await res.text();
console.log('Status:', res.status);
console.log('Body:', body);
}
main().catch(console.error);