mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-05-23 21:25:27 +00:00
- Replace AgentSessionRuntimeHost and bootstrap abstractions with AgentSessionRuntime - Runtime creation is now closure-based via CreateAgentSessionRuntimeFactory - Factory closes over process-global fixed inputs, recreates cwd-bound services per effective cwd - Session config (model, thinking, tools, scoped models) re-resolved per target cwd - CLI resource paths resolved once at startup as absolute paths - Swap lifecycle: teardown old, create next, apply next (hard fail on creation error) - Unified diagnostics model (info/warning/error) for args, services, session resolution, resources - No logging or process exits inside creation/parsing logic - Removed session_directory support - Removed session_switch and session_fork extension events (use session_start with reason) - Moved package/config CLI to package-manager-cli.ts - Fixed theme init for --resume session picker - Fixed flaky reftable footer test (content-based polling) - Fixed silent drop of unknown single-dash CLI flags - Added error diagnostics for missing explicit CLI resource paths - Updated SDK docs, examples, plans, exports, tests, changelog fixes #2753
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import type { Args } from "../src/cli/args.js";
|
|
import { buildInitialMessage } from "../src/cli/initial-message.js";
|
|
|
|
function createArgs(messages: string[] = []): Args {
|
|
return {
|
|
messages: [...messages],
|
|
fileArgs: [],
|
|
unknownFlags: new Map(),
|
|
diagnostics: [],
|
|
};
|
|
}
|
|
|
|
describe("buildInitialMessage", () => {
|
|
test("merges piped stdin with the first CLI message into one prompt", () => {
|
|
const parsed = createArgs(["Summarize the text given"]);
|
|
const result = buildInitialMessage({
|
|
parsed,
|
|
stdinContent: "README contents\n",
|
|
});
|
|
|
|
expect(result.initialMessage).toBe("README contents\nSummarize the text given");
|
|
expect(parsed.messages).toEqual([]);
|
|
});
|
|
|
|
test("uses stdin as the initial prompt when no CLI message is present", () => {
|
|
const parsed = createArgs();
|
|
const result = buildInitialMessage({
|
|
parsed,
|
|
stdinContent: "README contents",
|
|
});
|
|
|
|
expect(result.initialMessage).toBe("README contents");
|
|
expect(parsed.messages).toEqual([]);
|
|
});
|
|
|
|
test("combines stdin, file text, and first CLI message in one prompt", () => {
|
|
const parsed = createArgs(["Explain it", "Second message"]);
|
|
const result = buildInitialMessage({
|
|
parsed,
|
|
stdinContent: "stdin\n",
|
|
fileText: "file\n",
|
|
});
|
|
|
|
expect(result.initialMessage).toBe("stdin\nfile\nExplain it");
|
|
expect(parsed.messages).toEqual(["Second message"]);
|
|
});
|
|
});
|