Add beads: Skill v4 epic (1bg), Quality gates (n1h), Brainstorm epics (jq5, 2e6), memory nodes
This commit is contained in:
parent
80c3d06284
commit
835018c183
6 changed files with 2189 additions and 136 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { runBdCommand } from './bridge';
|
||||
import { getDoltConnection } from './dolt-client';
|
||||
import type { ResultSetHeader } from 'mysql2';
|
||||
|
||||
export interface BeadInteraction {
|
||||
id: string;
|
||||
|
|
@ -36,3 +38,54 @@ export async function readInteractionsViaBd(projectRoot: string, beadId: string)
|
|||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function asNonEmptyProjectRoot(projectRoot: string): string {
|
||||
if (typeof projectRoot !== 'string' || !projectRoot.trim()) {
|
||||
throw new Error('projectRoot is required.');
|
||||
}
|
||||
|
||||
return projectRoot.trim();
|
||||
}
|
||||
|
||||
function asValidCommentId(commentId: number): number {
|
||||
if (!Number.isInteger(commentId) || commentId <= 0) {
|
||||
throw new Error('commentId must be a positive integer.');
|
||||
}
|
||||
|
||||
return commentId;
|
||||
}
|
||||
|
||||
function asNonEmptyCommentText(text: string): string {
|
||||
if (typeof text !== 'string' || !text.trim()) {
|
||||
throw new Error('text is required.');
|
||||
}
|
||||
|
||||
return text.trim();
|
||||
}
|
||||
|
||||
export async function updateCommentViaDolt(projectRoot: string, commentId: number, text: string): Promise<boolean> {
|
||||
const root = asNonEmptyProjectRoot(projectRoot);
|
||||
const id = asValidCommentId(commentId);
|
||||
const nextText = asNonEmptyCommentText(text);
|
||||
|
||||
const pool = await getDoltConnection(root);
|
||||
const [result] = await pool.execute<ResultSetHeader>(
|
||||
'UPDATE comments SET text = ? WHERE id = ?',
|
||||
[nextText, id],
|
||||
);
|
||||
|
||||
return result.affectedRows > 0;
|
||||
}
|
||||
|
||||
export async function deleteCommentViaDolt(projectRoot: string, commentId: number): Promise<boolean> {
|
||||
const root = asNonEmptyProjectRoot(projectRoot);
|
||||
const id = asValidCommentId(commentId);
|
||||
|
||||
const pool = await getDoltConnection(root);
|
||||
const [result] = await pool.execute<ResultSetHeader>(
|
||||
'DELETE FROM comments WHERE id = ?',
|
||||
[id],
|
||||
);
|
||||
|
||||
return result.affectedRows > 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue