Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .beads/issues.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@
{"id":"t2p-wln","title":"CLI integration","description":"Implement src/index.ts with Commander setup, wire up init and work commands, add CLI options (--model, --verbose), test global installation (npm link). Verify shebang works correctly.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-11-30T13:26:34.40176-05:00","updated_at":"2025-11-30T13:59:36.034896-05:00","closed_at":"2025-11-30T13:59:36.034896-05:00","dependencies":[{"issue_id":"t2p-wln","depends_on_id":"t2p-prg","type":"blocks","created_at":"2025-11-30T13:26:34.402376-05:00","created_by":"daemon","metadata":"{}"},{"issue_id":"t2p-wln","depends_on_id":"t2p-68n","type":"blocks","created_at":"2025-11-30T13:26:34.403063-05:00","created_by":"daemon","metadata":"{}"}]}
{"id":"t2p-wzt","title":"Refactor init.ts so that the embedded prompts are pulled from individual .md files in the source code","description":"Currently init.ts has large string constants (STYLE_TEMPLATE, WORK_TEMPLATE, SYSTEM_TEMPLATE, ANALYSIS_TEMPLATE) embedded in the code. Refactor to load these from individual .md files in the source code (e.g., src/templates/style.md).\n\nBenefits:\n- Easier to maintain and edit templates\n- Better separation of content from code\n- Cleaner TypeScript files\n- Templates can be reviewed/edited without reading TS code\n\nImplementation:\n- Create src/templates/ directory\n- Move each template constant to a .md file\n- Update init.ts to read from these files using readFileSync\n- Ensure templates are included in npm package distribution","status":"closed","priority":1,"issue_type":"task","created_at":"2025-11-30T14:48:00.459557-05:00","updated_at":"2025-11-30T14:52:49.196814-05:00","closed_at":"2025-11-30T14:52:49.196814-05:00"}
{"id":"t2p-x3h","title":"ship blog-from-x: Generate blog posts from successful X posts","status":"closed","priority":2,"issue_type":"feature","created_at":"2025-12-24T10:06:25.728784-05:00","updated_at":"2025-12-24T10:12:35.814251-05:00","closed_at":"2025-12-24T10:12:35.814251-05:00","dependencies":[{"issue_id":"t2p-x3h","depends_on_id":"t2p-bb2","type":"blocks","created_at":"2025-12-24T10:07:19.949131-05:00","created_by":"ryw","metadata":"{}"},{"issue_id":"t2p-x3h","depends_on_id":"t2p-g06","type":"blocks","created_at":"2025-12-24T10:07:25.105074-05:00","created_by":"ryw","metadata":"{}"},{"issue_id":"t2p-x3h","depends_on_id":"t2p-4db","type":"blocks","created_at":"2025-12-24T10:07:30.294792-05:00","created_by":"ryw","metadata":"{}"},{"issue_id":"t2p-x3h","depends_on_id":"t2p-k7d","type":"blocks","created_at":"2025-12-24T10:07:35.583141-05:00","created_by":"ryw","metadata":"{}"}]}
{"id":"t2p-perf4","title":"Performance: Replace CPU-spinning busy-wait loop with Atomics.wait() in file locking","description":"The file locking mechanism in file-system.ts used a CPU-spinning busy-wait loop (lines 29-30) that continuously consumed CPU cycles while waiting to acquire a lock. This was wasteful and could cause system slowdown.\n\nFixed by replacing the busy-wait with Atomics.wait() on a SharedArrayBuffer, which properly yields the CPU and blocks without spinning.\n\nFile: src/services/file-system.ts:29-30\nSeverity: Medium\nCategory: Performance","status":"closed","priority":2,"issue_type":"task","created_at":"2026-03-14T08:10:00Z","updated_at":"2026-03-14T08:20:00Z","closed_at":"2026-03-14T08:20:00Z"}
{"id":"t2p-qual5","title":"Add explicit null checks before non-null assertions in ollama.ts","description":"Multiple lines in ollama.ts use non-null assertions (config.ollama\!) without prior explicit null checks (lines 34, 48, 55, 65, 72). While the constructor validates config.ollama exists, defensive programming suggests adding explicit type guards or runtime checks.\n\nAffected lines:\n- Line 34: models.models.some((m) => m.name.includes(this.config.ollama\!.model))\n- Line 48: message.content = this.config.ollama\!.model...\n- Line 55: model: this.config.ollama\!.model\n- Line 65: model: this.config.ollama\!.model\n- Line 72: model: this.config.ollama\!.model\n\nRecommendation:\n- Store validated config in a narrowed type property\n- Or add runtime checks before accessing\n- Consider using a type predicate to narrow the config type\n\nFile: src/services/ollama.ts\nSeverity: Low-Medium\nCategory: Type Safety / Defensive Programming","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-14T08:15:00Z","updated_at":"2026-03-14T08:15:00Z"}
15 changes: 12 additions & 3 deletions src/services/file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import { validateConfig } from '../utils/validation.js';
const LOCK_TIMEOUT_MS = 10_000;
const LOCK_RETRY_MS = 50;

/**
* Synchronous sleep using Atomics.wait on a SharedArrayBuffer.
* Unlike busy-waiting, this properly yields the CPU and doesn't spin.
*/
function sleepSync(ms: number): void {
const sab = new SharedArrayBuffer(4);
const int32 = new Int32Array(sab);
Atomics.wait(int32, 0, 0, ms);
}

function acquireLock(lockPath: string): void {
const deadline = Date.now() + LOCK_TIMEOUT_MS;
while (true) {
Expand All @@ -25,9 +35,8 @@ function acquireLock(lockPath: string): void {
try { mkdirSync(lockPath); return; } catch {}
throw new FileSystemError('Failed to acquire posts lock — another process may be writing');
}
// Busy wait
const until = Date.now() + LOCK_RETRY_MS;
while (Date.now() < until) { /* spin */ }
// Sleep without spinning the CPU
sleepSync(LOCK_RETRY_MS);
}
}
}
Expand Down