Skip to content

Commit 86866e3

Browse files
yslee-abuttonclaude
andcommitted
feat(hook): notify agent when no VCS detected on plan approval
When a plan is approved in a directory without version control, include a message in the approval output so the agent can ask the user to initialize git before making changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 70b0cfb commit 86866e3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

apps/hook/server/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import {
6363
startAnnotateServer,
6464
handleAnnotateServerReady,
6565
} from "@plannotator/server/annotate";
66-
import { type DiffType, getVcsContext, runVcsDiff } from "@plannotator/server/vcs";
66+
import { type DiffType, getVcsContext, runVcsDiff, detectVcs } from "@plannotator/server/vcs";
6767
import { parsePRUrl, checkPRAuth, fetchPR, getCliName, getCliInstallUrl, getMRLabel, getMRNumberLabel, getDisplayRepo } from "@plannotator/server/pr";
6868
import { writeRemoteShareLink } from "@plannotator/server/share-url";
6969
import { resolveMarkdownFile, hasMarkdownFiles } from "@plannotator/shared/resolve-file";
@@ -820,10 +820,19 @@ if (args[0] === "sessions") {
820820
// Cleanup
821821
server.stop();
822822

823+
// Check if working directory has version control (git or p4)
824+
const noVcsMessage = await (async () => {
825+
if (!result.approved) return "";
826+
const provider = await detectVcs();
827+
if (await provider.detect()) return "";
828+
return "\n\n[Note: No version control detected in this directory. Before making changes, ask the user if they want to initialize git to enable change tracking.]";
829+
})();
830+
823831
// Output decision in the appropriate format for the harness
824832
if (isGemini) {
825833
if (result.approved) {
826-
console.log(result.feedback ? JSON.stringify({ systemMessage: result.feedback }) : "{}");
834+
const systemMessage = (result.feedback || "") + noVcsMessage;
835+
console.log(systemMessage ? JSON.stringify({ systemMessage }) : "{}");
827836
} else {
828837
console.log(
829838
JSON.stringify({
@@ -853,6 +862,7 @@ if (args[0] === "sessions") {
853862
decision: {
854863
behavior: "allow",
855864
...(updatedPermissions.length > 0 && { updatedPermissions }),
865+
...(noVcsMessage && { message: noVcsMessage.trim() }),
856866
},
857867
},
858868
})

0 commit comments

Comments
 (0)