Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ implementation architecture.
| `PLANNOTATOR_REMOTE` | `1`/`true` for remote mode, `0`/`false` for local, unset for SSH auto-detection |
| `PLANNOTATOR_PORT` | Fixed port (default: random locally, `19432` remote) |
| `PLANNOTATOR_BROWSER` | Custom browser to open plans in |
| `PLANNOTATOR_PRESENTER` | Executable implementing the one-request JSON presenter protocol; overrides `config.json` and may run outside Herdr |
| `PLANNOTATOR_AI` | `disabled` to disable Ask AI, Review Agents, and Guided Review; the annotate agent terminal is separate |
| `PLANNOTATOR_SHARE` | `disabled` to turn off URL sharing |
| `PLANNOTATOR_SHARE_URL` | Custom base URL for share links (self-hosted portal) |
Expand All @@ -378,6 +379,24 @@ All Plannotator data lives in a single directory — `~/.plannotator` by default
export PLANNOTATOR_DATA_DIR=~/.local/share/plannotator
```

Host integrations can persist an external presenter in
`~/.plannotator/config.json`:

```json
{
"presenter": {
"command": "/absolute/path/to/presenter",
"when": "herdr"
}
}
```

The command is executed directly without a shell. `when` defaults to
`"herdr"`, so the presenter is selected only when `HERDR_ENV=1`; use
`"always"` to enable it everywhere. An explicitly set
`PLANNOTATOR_PRESENTER` takes priority, and an empty value disables the
configured presenter for that invocation.

---

## Development
Expand Down
49 changes: 49 additions & 0 deletions apps/hook/server/annotate-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,55 @@ async function runCompletion(
}

describe("completeAnnotateCommand", () => {
test("waits for server cleanup before publishing or exiting", async () => {
const events: string[] = [];
let finishCleanup!: () => void;
const cleanupFinished = new Promise<void>((resolve) => {
finishCleanup = resolve;
});
let confirmCleanupStarted!: () => void;
const cleanupStarted = new Promise<void>((resolve) => {
confirmCleanupStarted = resolve;
});

const completion = completeAnnotateCommand({
waitForDecision: async () => {
events.push("decision");
return { approved: true, feedback: "" };
},
settleAfterDecision: async () => {
events.push("settle");
},
stopServer: async () => {
events.push("stop:start");
confirmCleanupStarted();
await cleanupFinished;
events.push("stop:done");
},
requireApproval: false,
emitLegacyOutcome: () => {
events.push("legacy");
},
exit: (code) => {
events.push(`exit:${code}`);
},
});

await cleanupStarted;
expect(events).toEqual(["decision", "settle", "stop:start"]);

finishCleanup();
await completion;
expect(events).toEqual([
"decision",
"settle",
"stop:start",
"stop:done",
"legacy",
"exit:0",
]);
});

test("publishes approved feedback to matching stdout and result bytes", async () => {
const result = await runCompletion(
{
Expand Down
4 changes: 2 additions & 2 deletions apps/hook/server/annotate-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
export interface CompleteAnnotateCommandOptions {
waitForDecision: () => Promise<AnnotateOutcome>;
settleAfterDecision: () => Promise<void>;
stopServer: () => void;
stopServer: () => void | Promise<void>;
requireApproval: boolean;
resultFile?: string;
writeResultFile?: (
Expand Down Expand Up @@ -45,7 +45,7 @@ export async function completeAnnotateCommand({
}: CompleteAnnotateCommandOptions): Promise<void> {
const result = await waitForDecision();
await settleAfterDecision();
stopServer();
await stopServer();

if (requireApproval || resultFile) {
const serialized = serializeStrictAnnotateResult(result);
Expand Down
Loading