v0.2.0: add message operation, role filter, showTools, full session IDs

- Add message operation to retrieve a single message by ID (cleaner output,
  higher default maxLength of 8000)
- Add role filter to messages operation (user/assistant/system)
- Hide tool-call parts by default in messages/message output; showTools:true
  to include them
- Show full session IDs instead of truncating to 12 chars
- Make per-message maxLength configurable (default 2000 for messages, 8000
  for message)
- Increase search snippet length from 300 to 500 chars
- Add local development & testing docs to AGENTS.md with symlink instructions
- Bump version from 0.1.0 to 0.2.0
This commit is contained in:
2026-04-21 21:15:28 +00:00
parent cb9d981b6f
commit 047621d834
6 changed files with 184 additions and 24 deletions

View File

@@ -1,33 +1,34 @@
import { describe, expect, test } from "bun:test";
import { formatMessageList, formatSessionList } from "../src/history/format";
import { formatMessageList, formatSessionList, formatSingleMessage } from "../src/history/format";
describe("formatSessionList", () => {
test("returns message for empty list", () => {
expect(formatSessionList([])).toBe("No sessions found.");
});
test("formats sessions as markdown table", () => {
test("formats sessions as markdown table with full IDs", () => {
const rows = [
{ id: "ses_abc123def", title: "Test Session", updated: "2024-01-15 10:30:00", msgs: 12 },
];
const result = formatSessionList(rows);
expect(result).toContain("# Recent Sessions");
expect(result).toContain("| ID | Title | Updated | Messages |");
expect(result).toContain("ses_abc123de...");
expect(result).toContain("ses_abc123def");
expect(result).toContain("Test Session");
});
test("truncates long IDs and titles", () => {
test("shows full IDs even for long session IDs", () => {
const rows = [
{
id: "ses_verylongidthatshouldbetruncated1234567890",
id: "ses_verylongidthatshouldnotbetruncated1234567890",
title: "A very long title that should be truncated for display",
updated: "2024-01-15",
msgs: 5,
},
];
const result = formatSessionList(rows);
expect(result).toContain("ses_verylong...");
expect(result).toContain("ses_verylongidthatshouldnotbetruncated1234567890");
expect(result).toContain("A very long title that should be truncat");
});
test("handles untitled sessions", () => {
@@ -55,10 +56,41 @@ describe("formatMessageList", () => {
expect(result).toContain("Hi there");
});
test("truncates long text", () => {
test("truncates long text at default maxLength 2000", () => {
const longText = "x".repeat(3000);
const rows = [{ role: "assistant", time: "2024-01-15", text: longText }];
const result = formatMessageList(rows);
expect(result.length).toBeLessThan(longText.length + 200);
expect(result).toContain("3000 chars total");
});
test("respects custom maxLength", () => {
const longText = "x".repeat(500);
const rows = [{ role: "assistant", time: "2024-01-15", text: longText }];
const result = formatMessageList(rows, { maxLength: 100 });
expect(result).toContain("500 chars total");
expect(result.length).toBeLessThan(500);
});
test("does not truncate short text", () => {
const rows = [{ role: "assistant", time: "2024-01-15", text: "Short message" }];
const result = formatMessageList(rows);
expect(result).toContain("Short message");
expect(result).not.toContain("chars total");
});
});
describe("formatSingleMessage", () => {
test("formats a single message", () => {
const row = { role: "assistant", time: "2024-01-15 10:00:00", text: "Hello world" };
const result = formatSingleMessage(row);
expect(result).toContain("assistant");
expect(result).toContain("Hello world");
});
test("respects custom maxLength", () => {
const row = { role: "assistant", time: "2024-01-15", text: "x".repeat(10000) };
const result = formatSingleMessage(row, { maxLength: 500 });
expect(result).toContain("10000 chars total");
});
});