feat: add task_update and task_comment tools (#33)

Closes #26

This PR adds two new DevClaw tools for better task lifecycle management:

- task_update: Change issue state programmatically without full pickup/complete flow
- task_comment: Add review comments or notes to issues with optional role attribution
This commit is contained in:
Lauren ten Hoor
2026-02-10 09:20:27 +08:00
committed by GitHub
parent 78bc95efb3
commit a9e5b9ef3e
7 changed files with 370 additions and 2 deletions

View File

@@ -197,6 +197,26 @@ export class GitHubProvider implements TaskManager {
}
}
async addComment(issueId: number, body: string): Promise<void> {
// Write body to temp file to preserve newlines
const tempFile = join(tmpdir(), `devclaw-comment-${Date.now()}.md`);
await writeFile(tempFile, body, "utf-8");
try {
await this.gh([
"issue", "comment", String(issueId),
"--body-file", tempFile,
]);
} finally {
// Clean up temp file
try {
await unlink(tempFile);
} catch {
// Ignore cleanup errors
}
}
}
async healthCheck(): Promise<boolean> {
try {
await this.gh(["auth", "status"]);

View File

@@ -160,6 +160,31 @@ export class GitLabProvider implements TaskManager {
}
}
async addComment(issueId: number, body: string): Promise<void> {
// Write body to temp file to preserve newlines
const tempFile = join(tmpdir(), `devclaw-comment-${Date.now()}.md`);
await writeFile(tempFile, body, "utf-8");
try {
const { exec } = await import("node:child_process");
const { promisify } = await import("node:util");
const execAsync = promisify(exec);
const cmd = `glab issue note ${issueId} --message "$(cat ${tempFile})"`;
await execAsync(cmd, {
cwd: this.repoPath,
timeout: 30_000,
});
} finally {
// Clean up temp file
try {
await unlink(tempFile);
} catch {
// Ignore cleanup errors
}
}
}
async healthCheck(): Promise<boolean> {
try {
await this.glab(["auth", "status"]);

View File

@@ -75,6 +75,9 @@ export interface TaskManager {
/** Check if any merged MR/PR exists for a specific issue. */
hasMergedMR(issueId: number): Promise<boolean>;
/** Add a comment to an issue. */
addComment(issueId: number, body: string): Promise<void>;
/** Verify the task manager is working (CLI available, auth valid, repo accessible). */
healthCheck(): Promise<boolean>;
}