BREAKING CHANGE: the marketplace slug, the agent namespace (linkedin-studio:<agent>), and the runtime state-file path (~/.claude/linkedin-studio.local.md) all change. Reinstall required; existing state migrated in place (post metrics, streak, history preserved). The /linkedin:* commands are unchanged — the command namespace is set per-command in frontmatter and was always independent of the plugin slug. Functionality is byte-identical to v2.4.0; this release is pure identity. - dir + manifests: plugins/linkedin-studio + plugin.json + root marketplace.json - agent namespace updated in commands/newsletter.md (only functional invoker) - state path updated in 4 hook scripts + topic-rotation prompt + state template - catch-all skill dir renamed skills/linkedin-studio (5 functional skills unchanged) - docs + version bump to 3.0.0 across README badge, CHANGELOG, root README/CLAUDE.md - historical records (CHANGELOG past entries, docs/ build artifacts, config-audit v5.0.0 snapshots) intentionally retain the old slug Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
// Pure function for week-rollover logic.
|
|
// Exported separately for testability.
|
|
|
|
/**
|
|
* Apply week rollover to state file content.
|
|
* Returns updated content string if rollover was applied, null otherwise.
|
|
*
|
|
* @param {string} stateContent - Full state file content (with YAML frontmatter)
|
|
* @param {string} currentWeek - Week value from state file (e.g. "2026-W14")
|
|
* @param {string} actualWeek - Computed current ISO week (e.g. "2026-W15")
|
|
* @returns {{ content: string, message: string } | null}
|
|
*/
|
|
export function applyWeekRollover(stateContent, currentWeek, actualWeek) {
|
|
if (!actualWeek) return null;
|
|
|
|
// Case 1: current_week is empty — initialize without resetting posts
|
|
if (!currentWeek) {
|
|
const updated = stateContent.replace(
|
|
/^current_week: .*/m,
|
|
`current_week: "${actualWeek}"`
|
|
);
|
|
if (updated === stateContent) return null;
|
|
return {
|
|
content: updated,
|
|
message: `Initialized current_week to ${actualWeek}.`
|
|
};
|
|
}
|
|
|
|
// Case 2: week matches — no action needed
|
|
if (currentWeek === actualWeek) return null;
|
|
|
|
// Case 3: week changed — reset posts_this_week and update current_week
|
|
let updated = stateContent;
|
|
updated = updated.replace(
|
|
/^posts_this_week: .*/m,
|
|
'posts_this_week: 0'
|
|
);
|
|
updated = updated.replace(
|
|
/^current_week: .*/m,
|
|
`current_week: "${actualWeek}"`
|
|
);
|
|
|
|
if (updated === stateContent) return null;
|
|
|
|
return {
|
|
content: updated,
|
|
message: `Auto-reset: posts_this_week → 0 for new week ${actualWeek} (was ${currentWeek}).`
|
|
};
|
|
}
|