Files
memind/scripts/apply-tang-cursor-config-103.mjs
john 91d5c7a1fd chore(infra): update Studio/103 host IP to 114.85.107.50
Replace all references to the previous Portal host 180.159.29.143 with
114.85.107.50 across release scripts, safety gates, runbooks, and docs.

Also add scripts/push-wechat-news-morning-draft-now.mjs for direct draft
push without waiting on the worker poll interval.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 09:49:09 +08:00

102 lines
3.3 KiB
JavaScript
Raw Permalink 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
* node scripts/apply-tang-cursor-config-103.mjs --apply --enable-chat-bridge
*/
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 enableChatBridge = process.argv.includes('--enable-chat-bridge');
const databaseUrl = execSync(
"ssh -o BatchMode=yes -o ConnectTimeout=8 john@114.85.107.50 \"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'],
);
const target = {
...RECOMMENDED,
features: {
...RECOMMENDED.features,
...(enableChatBridge
? { [CURSOR_CHANNEL_FEATURES.CHAT_BRIDGE]: { enabled: true } }
: {}),
},
};
target.intentAllowlist = intentAllowlistFromFeatures(target.features);
if (enableChatBridge) {
target.meta = { ...target.meta, notes: '唐用户 Cursor 灰度 — 页面+问卷+定时任务+聊天 Bridge' };
}
console.log('--- before ---');
console.log(JSON.stringify(before[0]?.config_json ?? null, null, 2));
console.log('--- target ---');
console.log(JSON.stringify(target, 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(target), 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);
});