Files
memind/scripts/apply-tang-cursor-config-103.mjs
T
john 617ff0d1dd
Memind CI / Test, build, and release guards (push) Has been cancelled
Add per-feature Cursor channel toggles for admin and runtime.
Expose page/data/scheduled-task/chat-bridge switches in the智趣体验通道 config so Tang can roll out Cursor paths independently with DeepSeek fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 09:40:52 +08:00

86 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* 将唐用户智趣体验通道更新为推荐配置(103 生产库)
* 默认 dry-run--apply 才写入 h5_wechat_cursor_executor_config
*
* Usage:
* node scripts/apply-tang-cursor-config-103.mjs
* node scripts/apply-tang-cursor-config-103.mjs --apply
*/
import process from 'node:process';
import { execSync } from 'node:child_process';
import mysql from 'mysql2/promise';
import {
CURSOR_CHANNEL_FEATURES,
defaultCursorChannelFeatures,
intentAllowlistFromFeatures,
} from '../cursor-channel-features.mjs';
const TANG = 'a70ff537-8908-486e-9b6c-042e07cc25db';
const RECOMMENDED = {
enabled: true,
userAllowlist: [TANG],
channelAllowlist: ['h5', 'wechat_mp'],
features: {
...defaultCursorChannelFeatures(),
[CURSOR_CHANNEL_FEATURES.PAGE_GENERATE]: { enabled: true },
[CURSOR_CHANNEL_FEATURES.PAGE_DATA]: { enabled: true },
[CURSOR_CHANNEL_FEATURES.EXCEL_ANALYSIS]: { enabled: false },
[CURSOR_CHANNEL_FEATURES.CHAT_BRIDGE]: { enabled: false },
[CURSOR_CHANNEL_FEATURES.SCHEDULED_TASKS]: { enabled: true },
},
fallbackToDeepseek: true,
meta: { notes: '唐用户 Cursor 灰度 — 页面+问卷+定时任务' },
};
RECOMMENDED.intentAllowlist = intentAllowlistFromFeatures(RECOMMENDED.features);
async function main() {
const apply = process.argv.includes('--apply');
const databaseUrl = execSync(
"ssh -o BatchMode=yes -o ConnectTimeout=8 john@58.38.22.103 \"grep '^DATABASE_URL=' /Users/john/Project/Memind/.env | cut -d= -f2-\"",
{ encoding: 'utf8' },
).trim();
const pool = mysql.createPool({ uri: databaseUrl, connectionLimit: 2 });
const now = Date.now();
const [before] = await pool.query(
'SELECT config_json FROM h5_wechat_cursor_executor_config WHERE config_scope = ? LIMIT 1',
['global'],
);
console.log('--- before ---');
console.log(JSON.stringify(before[0]?.config_json ?? null, null, 2));
console.log('--- target ---');
console.log(JSON.stringify(RECOMMENDED, null, 2));
if (!apply) {
console.log('\n(dry-run) 追加 --apply 写入生产库');
await pool.end();
return;
}
await pool.query(
`INSERT INTO h5_wechat_cursor_executor_config
(config_scope, config_json, updated_by, updated_at)
VALUES ('global', ?, NULL, ?)
ON DUPLICATE KEY UPDATE
config_json = VALUES(config_json),
updated_at = VALUES(updated_at)`,
[JSON.stringify(RECOMMENDED), now],
);
const [after] = await pool.query(
'SELECT config_json, updated_at FROM h5_wechat_cursor_executor_config WHERE config_scope = ? LIMIT 1',
['global'],
);
console.log('\n--- applied ---');
console.log(JSON.stringify(after[0] ?? null, null, 2));
await pool.end();
}
main().catch((err) => {
console.error(err);
process.exit(1);
});