Skip to content

Commit 28693ed

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 ed254cf commit 28693ed

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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, gitRuntime } from "@plannotator/server/vcs";
66+
import { type DiffType, getVcsContext, runVcsDiff, gitRuntime, detectVcs } from "@plannotator/server/vcs";
6767
import { fetchRef, createWorktree, removeWorktree, ensureObjectAvailable } from "@plannotator/shared/worktree";
6868
import { parsePRUrl, checkPRAuth, fetchPR, getCliName, getCliInstallUrl, getMRLabel, getMRNumberLabel, getDisplayRepo } from "@plannotator/server/pr";
6969
import { writeRemoteShareLink } from "@plannotator/server/share-url";
@@ -967,10 +967,19 @@ if (args[0] === "sessions") {
967967
// Cleanup
968968
server.stop();
969969

970+
// Check if working directory has version control (git or p4)
971+
const noVcsMessage = await (async () => {
972+
if (!result.approved) return "";
973+
const provider = await detectVcs();
974+
if (await provider.detect()) return "";
975+
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.]";
976+
})();
977+
970978
// Output decision in the appropriate format for the harness
971979
if (isGemini) {
972980
if (result.approved) {
973-
console.log(result.feedback ? JSON.stringify({ systemMessage: result.feedback }) : "{}");
981+
const systemMessage = (result.feedback || "") + noVcsMessage;
982+
console.log(systemMessage ? JSON.stringify({ systemMessage }) : "{}");
974983
} else {
975984
console.log(
976985
JSON.stringify({
@@ -1000,6 +1009,7 @@ if (args[0] === "sessions") {
10001009
decision: {
10011010
behavior: "allow",
10021011
...(updatedPermissions.length > 0 && { updatedPermissions }),
1012+
...(noVcsMessage && { message: noVcsMessage.trim() }),
10031013
},
10041014
},
10051015
})

0 commit comments

Comments
 (0)