tt-help-cli-ycl 1.4.2 → 1.4.4
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 +1 -1
- package/src/cli/tag.js +131 -68
- package/src/lib/args.js +0 -4
- package/src/lib/constants.js +2 -1
- package/src/lib/tag-discover.js +218 -10
- package/src/watch/data-store.js +42 -0
- package/src/watch/db-schema.js +19 -0
- package/src/watch/db-tags.js +749 -0
- package/src/watch/public/app.js +27 -0
- package/src/watch/public/index.html +1 -1
- package/src/watch/server.js +255 -2
- package/src/watch/tag-service.js +509 -23
package/src/watch/data-store.js
CHANGED
|
@@ -3203,6 +3203,7 @@ export function createStore(filePath, options = {}) {
|
|
|
3203
3203
|
trackClient,
|
|
3204
3204
|
getActiveClients,
|
|
3205
3205
|
moveSellerJobsToBase, // 将 jobs/raw_jobs 中 tt_seller=1 且 video_count=0 的记录移动到 jobs_base
|
|
3206
|
+
moveRestrictedJobsToBase, // 将 jobs 中 status='restricted' 的记录移动到 jobs_base
|
|
3206
3207
|
registerVideos,
|
|
3207
3208
|
getVideo,
|
|
3208
3209
|
getVideos,
|
|
@@ -3354,4 +3355,45 @@ export function createStore(filePath, options = {}) {
|
|
|
3354
3355
|
availableInBase: available,
|
|
3355
3356
|
};
|
|
3356
3357
|
}
|
|
3358
|
+
|
|
3359
|
+
function moveRestrictedJobsToBase() {
|
|
3360
|
+
const db = getDb();
|
|
3361
|
+
if (!db) return { ok: false, error: "db not ready" };
|
|
3362
|
+
|
|
3363
|
+
const now = Date.now();
|
|
3364
|
+
const countRow = db
|
|
3365
|
+
.prepare("SELECT COUNT(*) as c FROM jobs WHERE status = 'restricted'")
|
|
3366
|
+
.get();
|
|
3367
|
+
if (!countRow?.c) return { ok: true, moved: 0 };
|
|
3368
|
+
|
|
3369
|
+
db.prepare(
|
|
3370
|
+
`
|
|
3371
|
+
INSERT OR REPLACE INTO jobs_base (
|
|
3372
|
+
unique_id, nickname, sources, pinned, no_video, user_update_count,
|
|
3373
|
+
tt_seller, verified, video_count, comment_count, guessed_location,
|
|
3374
|
+
location_created, follower_count, following_count, heart_count,
|
|
3375
|
+
refresh_time, region, signature, sec_uid, status_code,
|
|
3376
|
+
latest_video_time, bio_link, status, restricted, error, claimed_by,
|
|
3377
|
+
claimed_at, processed, processed_at, created_at, updated_at
|
|
3378
|
+
)
|
|
3379
|
+
SELECT
|
|
3380
|
+
unique_id, nickname, sources, pinned, no_video, 0,
|
|
3381
|
+
CASE WHEN tt_seller = 0 THEN NULL ELSE tt_seller END,
|
|
3382
|
+
verified, video_count, comment_count, guessed_location,
|
|
3383
|
+
location_created, follower_count, following_count, heart_count,
|
|
3384
|
+
refresh_time, region, signature, sec_uid, status_code,
|
|
3385
|
+
latest_video_time, bio_link,
|
|
3386
|
+
'pending', 0, NULL, NULL, NULL, 0, NULL,
|
|
3387
|
+
COALESCE(created_at, ?), ?
|
|
3388
|
+
FROM jobs WHERE status = 'restricted'
|
|
3389
|
+
`,
|
|
3390
|
+
).run(now, now);
|
|
3391
|
+
|
|
3392
|
+
const deleted = db
|
|
3393
|
+
.prepare("DELETE FROM jobs WHERE status = 'restricted'")
|
|
3394
|
+
.run();
|
|
3395
|
+
|
|
3396
|
+
markStatsDirty();
|
|
3397
|
+
return { ok: true, moved: deleted.changes || 0 };
|
|
3398
|
+
}
|
|
3357
3399
|
}
|
package/src/watch/db-schema.js
CHANGED
|
@@ -297,6 +297,24 @@ export function initDb(filePath) {
|
|
|
297
297
|
)
|
|
298
298
|
`);
|
|
299
299
|
|
|
300
|
+
// ===== reflection_rules 表(反思闭环:LLM 自我学习规则) =====
|
|
301
|
+
db.exec(`
|
|
302
|
+
CREATE TABLE IF NOT EXISTS reflection_rules (
|
|
303
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
304
|
+
country TEXT NOT NULL,
|
|
305
|
+
rule_type TEXT NOT NULL DEFAULT 'hard',
|
|
306
|
+
rule_text TEXT NOT NULL,
|
|
307
|
+
source TEXT NOT NULL DEFAULT 'reflection',
|
|
308
|
+
trigger_reason TEXT,
|
|
309
|
+
productive_sample TEXT,
|
|
310
|
+
dead_sample TEXT,
|
|
311
|
+
analysis_summary TEXT,
|
|
312
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
313
|
+
superseded_at TEXT,
|
|
314
|
+
is_active INTEGER NOT NULL DEFAULT 1
|
|
315
|
+
)
|
|
316
|
+
`);
|
|
317
|
+
|
|
300
318
|
// ===== 索引 =====
|
|
301
319
|
const indexes = [
|
|
302
320
|
`CREATE INDEX IF NOT EXISTS idx_jobs_status_video ON jobs(status, video_count DESC)`,
|
|
@@ -315,6 +333,7 @@ export function initDb(filePath) {
|
|
|
315
333
|
`CREATE INDEX IF NOT EXISTS idx_tags_status ON tags(status)`,
|
|
316
334
|
`CREATE INDEX IF NOT EXISTS idx_tags_score ON tags(score DESC)`,
|
|
317
335
|
`CREATE INDEX IF NOT EXISTS idx_discover_log_country ON discover_log(country, round DESC)`,
|
|
336
|
+
`CREATE INDEX IF NOT EXISTS idx_reflection_rules_active ON reflection_rules(country, is_active)`,
|
|
318
337
|
];
|
|
319
338
|
for (const sql of indexes) {
|
|
320
339
|
db.exec(sql);
|