@stackmemoryai/stackmemory
Version:
Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, smart retrieval, Claude Code skills, and automatic hooks.
70 lines (56 loc) ⢠2.05 kB
JavaScript
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function removeSTATasks() {
const tasksFile = path.join(__dirname, '..', '.stackmemory', 'tasks.jsonl');
if (!fs.existsSync(tasksFile)) {
console.error('ā Tasks file not found:', tasksFile);
return;
}
// Create backup first
const backupFile = tasksFile + '.backup-' + Date.now();
fs.copyFileSync(tasksFile, backupFile);
console.log(`š¾ Backup created: ${backupFile}`);
// Read all tasks
const lines = fs.readFileSync(tasksFile, 'utf8').split('\n').filter(l => l.trim());
const keptTasks = [];
const removedTasks = [];
for (const line of lines) {
try {
const task = JSON.parse(line);
// Check if task has STA- in title
const hasSTAId = task.title?.includes('[STA-');
if (hasSTAId) {
removedTasks.push(task);
} else {
keptTasks.push(line);
}
} catch (e) {
// Keep unparseable lines as-is
keptTasks.push(line);
}
}
console.log(`\nš Task Analysis:`);
console.log(` Total tasks: ${lines.length}`);
console.log(` STA tasks to remove: ${removedTasks.length}`);
console.log(` Tasks to keep: ${keptTasks.length}`);
if (removedTasks.length > 0) {
console.log('\nšļø Removing STA tasks:');
for (const task of removedTasks.slice(0, 10)) {
const match = task.title.match(/\[(STA-\d+)\]/);
console.log(` - ${match?.[1] || 'STA-???'}: ${task.title.substring(0, 60)}...`);
}
if (removedTasks.length > 10) {
console.log(` ... and ${removedTasks.length - 10} more`);
}
// Write cleaned file
fs.writeFileSync(tasksFile, keptTasks.join('\n') + '\n');
console.log(`\nā
Removed ${removedTasks.length} STA tasks`);
console.log(`š ${keptTasks.length} tasks remaining`);
} else {
console.log('\nā
No STA tasks found to remove');
}
}
removeSTATasks();