feat(coding-agent): add configurable title system prompt for sessions

- add discovery of `TITLE_SYSTEM.md` and pass it through interactive startup context
- route custom title prompts to online and local tiny title generators via protocol
- update session-title docs and changelog with override behavior
- add tests for prompt discovery, forwarding, and fallback to bundled title prompts
This commit is contained in:
Adryel Dearo
2026-06-09 14:13:20 -03:00
committed by can1357
parent 96defff9a5
commit ecbc2a3c15
15 changed files with 232 additions and 19 deletions
@@ -1,7 +1,16 @@
import { describe, expect, it, vi } from "bun:test";
import { submitInteractiveInput } from "@oh-my-pi/pi-coding-agent/main";
import { afterEach, describe, expect, it, vi } from "bun:test";
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { discoverTitleSystemPromptFile, submitInteractiveInput } from "@oh-my-pi/pi-coding-agent/main";
import type { SubmittedUserInput } from "@oh-my-pi/pi-coding-agent/modes/types";
const cleanupDirs: string[] = [];
afterEach(async () => {
await Promise.all(cleanupDirs.splice(0).map(dir => fs.rm(dir, { recursive: true, force: true })));
});
function createInput(overrides: Partial<SubmittedUserInput> = {}): SubmittedUserInput {
return {
text: "hello",
@@ -12,6 +21,19 @@ function createInput(overrides: Partial<SubmittedUserInput> = {}): SubmittedUser
};
}
describe("discoverTitleSystemPromptFile", () => {
it("discovers TITLE_SYSTEM.md from the project omp config directory", async () => {
const projectDir = await fs.mkdtemp(path.join(os.tmpdir(), "omp-title-system-"));
cleanupDirs.push(projectDir);
const configDir = path.join(projectDir, ".omp");
await fs.mkdir(configDir, { recursive: true });
const promptPath = path.join(configDir, "TITLE_SYSTEM.md");
await fs.writeFile(promptPath, "custom title prompt");
expect(discoverTitleSystemPromptFile(projectDir)).toBe(promptPath);
});
});
describe("submitInteractiveInput", () => {
it("routes already-started synthetic continue submissions to a hidden developer prompt", async () => {
const mode = {