Files
TORCH/src/lock-utils.mjs
T
Claude 639ad6877d chore: code quality, CI/CD, and DX improvements
Phase 3 — Code Quality:
- Deduplicate nowUnix() in lock-ops.mjs (import from utils.mjs)
- Promote ESLint no-unused-vars to error, fix all 46 violations
- Remove dead code: unused imports, variables, and catch bindings
- Add /* global marked */ for CDN-loaded library in dashboard

Phase 4 — CI/CD:
- Add Node.js version matrix (22, 23) to CI workflow
- Add npm audit security scan step to CI
- Add innerHTML usage check to CI pipeline
- Enable Dependabot for npm and GitHub Actions dependencies
- Create PR template

Phase 5 — Developer Experience:
- Create .env.example documenting all environment variables
- Expand CONTRIBUTING.md with commit conventions, agent/prompt
  creation guide, architecture overview, and test integrity
- Add system architecture diagram with Mermaid (docs/architecture/)

https://claude.ai/code/session_01GfwUNbgeMgXreFDbsNQMsS
2026-02-19 21:03:30 +00:00

50 lines
1.6 KiB
JavaScript

import fs from 'node:fs/promises';
import path from 'node:path';
import { todayDateStr, getIsoWeekStr } from './utils.mjs';
/**
* Scans the local log directory to identify agents that have already completed their task
* for the current period (daily or weekly).
*
* @param {string} cadence - 'daily' or 'weekly'
* @param {string} logDir - Path to the log directory (e.g., 'task-logs')
* @param {Object} deps - Dependency injection for testing
* @returns {Promise<Set<string>>} - Set of agent names that have completed their task
*/
export async function getCompletedAgents(cadence, logDir, deps) {
const { readdir = fs.readdir, getDateStr = todayDateStr, getIsoWeek = getIsoWeekStr } = deps;
const completed = new Set();
const targetDir = path.join(logDir, cadence);
try {
const files = await readdir(targetDir);
const today = getDateStr();
const currentWeek = getIsoWeek();
for (const file of files) {
// Format: YYYY-MM-DDTHH-mm-ssZ__<agent>__<status>.md
const match = file.match(/^(\d{4}-\d{2}-\d{2})T.*__([a-zA-Z0-9-_]+)__(.*)\.md$/);
if (!match) continue;
const [, datePart, agent, status] = match;
if (status === 'completed') {
if (cadence === 'daily' && datePart === today) {
completed.add(agent);
} else if (cadence === 'weekly') {
const fileWeek = getIsoWeek(datePart); // datePart is YYYY-MM-DD
if (fileWeek === currentWeek) {
completed.add(agent);
}
}
}
}
} catch (err) {
if (err.code !== 'ENOENT') {
console.error(`Warning: Failed to read log dir ${targetDir}: ${err.message}`);
}
}
return completed;
}