Skip to content

Commit a584264

Browse files
committed
Standardize commit message format in API prompts and extract response content
- Update build-commit-message-prompt.ts to include commit_message_format in the api_prompt, and add the regex extraction logic for "**Commit message:**" to generate-commit-message-with-api.ts so the prefix is consistently requested and explicitly stripped. └── apps └── editor └── src ├── commands │ └── generate-commit-message-commands │ ├── generate-commit-message-commands.ts │ └── utils │ ├── build-commit-message-prompt.ts │ ├── generate-commit-message-with-api.ts │ └── strip-wrapping-quotes.ts ├── constants │ └── instructions.ts └── utils └── send-llm-message.ts
1 parent 9568cf8 commit a584264

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
## Introduction
2525

26-
Autofill 15+ free chatbots, send API requests, or invoke agentic CLIs with **CWC**-constructed, [lean markdown prompts](#prompts). Without ever-growing sessions, **CWC** creates a workflow that is at the frontier of speed, token efficiency, and accuracy.
26+
Autofill 15+ free chatbots, send API requests, or invoke agentic CLIs with **CWC**-constructed, [lean markdown prompts](#prompts). Without ever-growing sessions, **CWC** proposes a workflow that is at the frontier of speed, token efficiency, and accuracy.
2727

2828
## Prompts
2929

‎apps/editor/src/commands/generate-commit-message-commands/utils/build-commit-message-prompt.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const build_commit_message_prompt = async (
218218

219219
prompt_sections = prompt_sections.trimEnd()
220220

221-
const api_prompt = `${prompt_sections}\n\n# Task\n\n${commit_message_prompt}`
221+
const api_prompt = `${prompt_sections}\n\n# Output formatting\n\n${commit_message_format}\n\n# Task\n\n${commit_message_prompt}`
222222
const chatbot_prompt = `${prompt_sections}\n\n# Output formatting\n\n${commit_message_format}\n\n# Task\n\n${commit_message_prompt}`
223223
const cli_prompt = `${prompt_sections}\n\n# Output formatting\n\n${commit_message_format}\n\n# Requirements\n\n- ${cli_edit_ask_requirements.preloaded_context}\n- ${cli_edit_ask_requirements.disable_tool_calling}\n\n# Task\n\n${commit_message_prompt}`
224224

‎apps/editor/src/commands/generate-commit-message-commands/utils/generate-commit-message-with-api.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export const generate_commit_message_with_api = async (params: {
7676
}
7777

7878
let commit_message = response_result.response
79+
const match = commit_message.match(
80+
/\*\*Commit message:\*\*\s*([\s\S]*)/i
81+
)
82+
if (match) {
83+
commit_message = match[1].trim()
84+
}
7985
commit_message = strip_wrapping_quotes(commit_message)
8086
// Sanitize to prevent shell syntax errors
8187
commit_message = commit_message.replace(/[<>`$()]/g, '')

0 commit comments

Comments
 (0)