Per-track lookback and per-track profiles
Searcher: each track independently tracks when it was last searched via data/track_history.json. New tracks get full lookback (90d), existing tracks look back since their last completion. Keyword-level crash resume preserved. Profiles: search tracks can specify profile_overrides (inline) or profile_path (external file) to customize resume, cover letter, and experience per track. Filter and applier both use the track-specific profile. Base profile.json provides shared info (name, contact, etc). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,13 @@ import { readFileSync, writeFileSync, existsSync, unlinkSync } from 'fs';
|
||||
let progressPath = null;
|
||||
let progress = null;
|
||||
|
||||
export function initProgress(dataDir, lookbackDays) {
|
||||
export function initProgress(dataDir, maxLookbackDays) {
|
||||
progressPath = `${dataDir}/search_progress.json`;
|
||||
|
||||
if (existsSync(progressPath)) {
|
||||
const saved = JSON.parse(readFileSync(progressPath, 'utf8'));
|
||||
if (saved.lookback_days === lookbackDays) {
|
||||
// Resume if an in-progress run exists (has uncompleted tracks)
|
||||
if (saved.started_at && !saved.finished) {
|
||||
progress = saved;
|
||||
const done = progress.completed?.length ?? 0;
|
||||
if (done > 0) {
|
||||
@@ -20,19 +21,27 @@ export function initProgress(dataDir, lookbackDays) {
|
||||
}
|
||||
return progress;
|
||||
}
|
||||
console.log(`🆕 New lookback window (${lookbackDays}d), starting fresh\n`);
|
||||
}
|
||||
|
||||
progress = {
|
||||
lookback_days: lookbackDays,
|
||||
lookback_days: maxLookbackDays,
|
||||
track_lookback: {}, // per-track lookback days, saved on init for crash resume
|
||||
started_at: Date.now(),
|
||||
completed: [],
|
||||
keyword_progress: {}, // key: "platform:track" → last completed keyword index (0-based)
|
||||
keyword_progress: {},
|
||||
};
|
||||
save();
|
||||
return progress;
|
||||
}
|
||||
|
||||
/** Save per-track lookback so crash resume uses the right value */
|
||||
export function saveTrackLookback(trackName, days) {
|
||||
if (!progress) return;
|
||||
if (!progress.track_lookback) progress.track_lookback = {};
|
||||
progress.track_lookback[trackName] = days;
|
||||
save();
|
||||
}
|
||||
|
||||
/** Save generated keywords for a track — reused on resume, never regenerated mid-run */
|
||||
export function saveKeywords(platform, track, keywords) {
|
||||
if (!progress) return;
|
||||
|
||||
Reference in New Issue
Block a user