feat: Claude Code Monitor — lanes, pipelines and a merged workspace
Internal SmartGift build of a Claude Code monitoring dashboard. Lanes: a durable unit of parallel agent work, one per working directory, tracked across session restarts. Managed lanes are git worktrees the dashboard provisions and can reset or remove behind a three-check destroy guard and a counted preflight; adopted lanes are directories you already own and are never destroyable. Pipelines: a lane moves through pipeline stages. A stage the agent declares with evidence renders green; a stage inferred from the tool-event stream renders dashed amber and never counts as done. Detection is forward-only within a 30-minute window, and never writes the declared stage. Workspace: one page at /run with a lane grid, the selected lane's pipeline, and a full Claude console behind a disclosure.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Compatibility wrapper around Node.js built-in node:sqlite (DatabaseSync).
|
||||
* Provides a better-sqlite3-compatible API so the rest of the codebase
|
||||
* works without the native module.
|
||||
*
|
||||
* Available on Node.js >= 22.5.0 (node:sqlite is experimental).
|
||||
* On older Node versions, require() will throw and the caller should
|
||||
* handle the error (e.g. show an informative message).
|
||||
*
|
||||
* @file This module exports a Database class that wraps node:sqlite's DatabaseSync to provide a better-sqlite3-like API.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const { DatabaseSync } = require("node:sqlite");
|
||||
|
||||
class Database {
|
||||
constructor(filePath) {
|
||||
this._db = new DatabaseSync(filePath);
|
||||
}
|
||||
|
||||
exec(sql) {
|
||||
this._db.exec(sql);
|
||||
return this;
|
||||
}
|
||||
|
||||
pragma(str, options) {
|
||||
if (str.includes("=")) {
|
||||
this._db.exec(`PRAGMA ${str}`);
|
||||
return undefined;
|
||||
}
|
||||
const row = this._db.prepare(`PRAGMA ${str}`).get();
|
||||
if (!row) return undefined;
|
||||
const keys = Object.keys(row);
|
||||
if (options?.simple || keys.length === 1) return row[keys[0]];
|
||||
return row;
|
||||
}
|
||||
|
||||
prepare(sql) {
|
||||
return this._db.prepare(sql);
|
||||
}
|
||||
|
||||
transaction(fn) {
|
||||
const db = this._db;
|
||||
const wrapper = (...args) => {
|
||||
db.exec("BEGIN");
|
||||
try {
|
||||
const result = fn(...args);
|
||||
db.exec("COMMIT");
|
||||
return result;
|
||||
} catch (err) {
|
||||
db.exec("ROLLBACK");
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
close() {
|
||||
this._db.close();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Database;
|
||||
Reference in New Issue
Block a user