Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4ec9473
Refactor condense logic to improve message handling and summary gener…
hannesrudolph Jan 21, 2026
23da730
Fix post-condense consecutive user turns without mutating history
hannesrudolph Jan 21, 2026
e1700aa
feat: enhance slash command processing and summary generation in ment…
hannesrudolph Jan 21, 2026
defdf0c
fix(condense): update comments and remove redundant loop in getEffect…
hannesrudolph Jan 22, 2026
ff6a369
refactor: swap prompt values - detailed instructions as user message,…
hannesrudolph Jan 22, 2026
54f9678
test: update condense tests for swapped prompt values
hannesrudolph Jan 22, 2026
926afbe
feat(condense): improve CONDENSE prompt with structured analysis and …
hannesrudolph Jan 22, 2026
c96010f
fix(condense): update SUMMARY_PROMPT to use general AI assistant intr…
hannesrudolph Jan 22, 2026
b773ddc
test(condense): update expectations for condense-rework
hannesrudolph Jan 22, 2026
fb53935
test(condense): align condense.spec with condense-rework behavior
hannesrudolph Jan 22, 2026
b375498
fix: improve condensation robustness and error handling
hannesrudolph Jan 23, 2026
b38b961
fix: correct CONDENSE prompt section numbering
hannesrudolph Jan 23, 2026
48974b3
fix: await condense_context_error say() call and correct merge comment
hannesrudolph Jan 23, 2026
757dfcf
fix: allow merging regular user messages into summary in API shaping
hannesrudolph Jan 23, 2026
b95584e
refactor: remove dead code from condense module
hannesrudolph Jan 23, 2026
25a4e2f
refactor: simplify CondensationErrorRow and remove JSON encoding
hannesrudolph Jan 23, 2026
7a361ae
fix: use customCondensingPrompt for user message content
hannesrudolph Jan 23, 2026
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
74 changes: 36 additions & 38 deletions src/__tests__/command-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Command Mentions", () => {

// Helper function to call parseMentions with required parameters
const callParseMentions = async (text: string) => {
const result = await parseMentions(
return parseMentions(
text,
"/test/cwd", // cwd
mockUrlContentFetcher, // urlContentFetcher
Expand All @@ -38,8 +38,6 @@ describe("Command Mentions", () => {
50, // maxDiagnosticMessages
undefined, // maxReadFileLine
)
// Return just the text for backward compatibility with existing tests
return result.text
}

describe("parseMentions with command support", () => {
Expand All @@ -56,10 +54,10 @@ describe("Command Mentions", () => {
const result = await callParseMentions(input)

expect(mockGetCommand).toHaveBeenCalledWith("/test/cwd", "setup")
expect(result).toContain('<command name="setup">')
expect(result).toContain(commandContent)
expect(result).toContain("</command>")
expect(result).toContain("Please help me set up the project")
expect(result.slashCommandHelp).toContain('<command name="setup">')
expect(result.slashCommandHelp).toContain(commandContent)
expect(result.slashCommandHelp).toContain("</command>")
expect(result.text).toContain("Please help me set up the project")
})

it("should handle multiple commands in message", async () => {
Expand Down Expand Up @@ -99,10 +97,10 @@ describe("Command Mentions", () => {
expect(mockGetCommand).toHaveBeenCalledWith("/test/cwd", "setup")
expect(mockGetCommand).toHaveBeenCalledWith("/test/cwd", "deploy")
expect(mockGetCommand).toHaveBeenCalledTimes(2) // Each unique command called once (optimized)
expect(result).toContain('<command name="setup">')
expect(result).toContain("# Setup Environment")
expect(result).toContain('<command name="deploy">')
expect(result).toContain("# Deploy Environment")
expect(result.slashCommandHelp).toContain('<command name="setup">')
expect(result.slashCommandHelp).toContain("# Setup Environment")
expect(result.slashCommandHelp).toContain('<command name="deploy">')
expect(result.slashCommandHelp).toContain("# Deploy Environment")
})

it("should leave non-existent commands unchanged", async () => {
Expand All @@ -114,10 +112,10 @@ describe("Command Mentions", () => {

expect(mockGetCommand).toHaveBeenCalledWith("/test/cwd", "nonexistent")
// The command should remain unchanged in the text
expect(result).toBe("/nonexistent command")
expect(result.text).toBe("/nonexistent command")
// Should not contain any command tags
expect(result).not.toContain('<command name="nonexistent">')
expect(result).not.toContain("Command 'nonexistent' not found")
expect(result.slashCommandHelp).toBeUndefined()
expect(result.text).not.toContain("Command 'nonexistent' not found")
})

it("should handle command loading errors during existence check", async () => {
Expand All @@ -129,8 +127,8 @@ describe("Command Mentions", () => {

// When getCommand throws an error during existence check,
// the command is treated as non-existent and left unchanged
expect(result).toBe("/error-command test")
expect(result).not.toContain('<command name="error-command">')
expect(result.text).toBe("/error-command test")
expect(result.slashCommandHelp).toBeUndefined()
})

it("should handle command loading errors during processing", async () => {
Expand All @@ -145,9 +143,9 @@ describe("Command Mentions", () => {
const input = "/error-command test"
const result = await callParseMentions(input)

expect(result).toContain('<command name="error-command">')
expect(result).toContain("# Error command")
expect(result).toContain("</command>")
expect(result.slashCommandHelp).toContain('<command name="error-command">')
expect(result.slashCommandHelp).toContain("# Error command")
expect(result.slashCommandHelp).toContain("</command>")
})

it("should handle command names with hyphens and underscores at start", async () => {
Expand All @@ -162,8 +160,8 @@ describe("Command Mentions", () => {
const result = await callParseMentions(input)

expect(mockGetCommand).toHaveBeenCalledWith("/test/cwd", "setup-dev")
expect(result).toContain('<command name="setup-dev">')
expect(result).toContain("# Dev setup")
expect(result.slashCommandHelp).toContain('<command name="setup-dev">')
expect(result.slashCommandHelp).toContain("# Dev setup")
})

it("should preserve command content formatting", async () => {
Expand Down Expand Up @@ -192,13 +190,13 @@ npm install
const input = "/complex command"
const result = await callParseMentions(input)

expect(result).toContain('<command name="complex">')
expect(result).toContain("# Complex Command")
expect(result).toContain("```bash")
expect(result).toContain("npm install")
expect(result).toContain("- Check file1.js")
expect(result).toContain("> **Note**: This is important!")
expect(result).toContain("</command>")
expect(result.slashCommandHelp).toContain('<command name="complex">')
expect(result.slashCommandHelp).toContain("# Complex Command")
expect(result.slashCommandHelp).toContain("```bash")
expect(result.slashCommandHelp).toContain("npm install")
expect(result.slashCommandHelp).toContain("- Check file1.js")
expect(result.slashCommandHelp).toContain("> **Note**: This is important!")
expect(result.slashCommandHelp).toContain("</command>")
})

it("should handle empty command content", async () => {
Expand All @@ -212,8 +210,8 @@ npm install
const input = "/empty command"
const result = await callParseMentions(input)

expect(result).toContain('<command name="empty">')
expect(result).toContain("</command>")
expect(result.slashCommandHelp).toContain('<command name="empty">')
expect(result.slashCommandHelp).toContain("</command>")
// Should still include the command tags even with empty content
})
})
Expand Down Expand Up @@ -295,7 +293,7 @@ npm install
const input = "/setup the project"
const result = await callParseMentions(input)

expect(result).toContain("Command 'setup' (see below for command content)")
expect(result.text).toContain("Command 'setup' (see below for command content)")
})

it("should leave non-existent command mentions unchanged", async () => {
Expand All @@ -304,7 +302,7 @@ npm install
const input = "/nonexistent the project"
const result = await callParseMentions(input)

expect(result).toBe("/nonexistent the project")
expect(result.text).toBe("/nonexistent the project")
})

it("should process multiple commands in message", async () => {
Expand All @@ -325,8 +323,8 @@ npm install
const input = "/setup the project\nThen /deploy later"
const result = await callParseMentions(input)

expect(result).toContain("Command 'setup' (see below for command content)")
expect(result).toContain("Command 'deploy' (see below for command content)")
expect(result.text).toContain("Command 'setup' (see below for command content)")
expect(result.text).toContain("Command 'deploy' (see below for command content)")
})

it("should match commands anywhere with proper word boundaries", async () => {
Expand All @@ -340,22 +338,22 @@ npm install
// At the beginning - should match
let input = "/build the project"
let result = await callParseMentions(input)
expect(result).toContain("Command 'build'")
expect(result.text).toContain("Command 'build'")

// After space - should match
input = "Please /build and test"
result = await callParseMentions(input)
expect(result).toContain("Command 'build'")
expect(result.text).toContain("Command 'build'")

// At the end - should match
input = "Run the /build"
result = await callParseMentions(input)
expect(result).toContain("Command 'build'")
expect(result.text).toContain("Command 'build'")

// At start of new line - should match
input = "Some text\n/build the project"
result = await callParseMentions(input)
expect(result).toContain("Command 'build'")
expect(result.text).toContain("Command 'build'")
})
})
})
Loading
Loading