From 2ec8efcfa7494448b654b0de60b1c9d8ffbb9eba Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Tue, 4 Mar 2025 15:36:18 -0500 Subject: [PATCH 1/2] Fix GitHub newlines issue #83 using markdown files approach --- packages/agent/src/core/toolAgent/config.ts | 6 ++++ packages/cli/README.md | 23 +++++++++++++ packages/cli/tests/github-mode-test.md | 36 +++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 packages/cli/tests/github-mode-test.md diff --git a/packages/agent/src/core/toolAgent/config.ts b/packages/agent/src/core/toolAgent/config.ts index e66737c..3c9cd0c 100644 --- a/packages/agent/src/core/toolAgent/config.ts +++ b/packages/agent/src/core/toolAgent/config.ts @@ -76,6 +76,12 @@ export function getDefaultSystemPrompt(toolContext: ToolContext): string { '- Create additional GitHub issues for follow-up tasks or ideas', '', 'You can use the GitHub CLI (`gh`) for all GitHub interactions.', + '', + 'When creating GitHub issues, PRs, or comments, use temporary markdown files for the content instead of inline text:', + '- Create a temporary markdown file with the content you want to include', + '- Use the file with GitHub CLI commands (e.g., `gh issue create --body-file temp.md`)', + '- Clean up the temporary file when done', + '- This approach preserves formatting, newlines, and special characters correctly', ].join('\n') : ''; diff --git a/packages/cli/README.md b/packages/cli/README.md index 3a2a40b..63a59c6 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -61,6 +61,29 @@ Requirements for GitHub mode: - GitHub CLI (`gh`) needs to be installed and authenticated - User needs to have appropriate GitHub permissions for the target repository +When using GitHub mode, MyCoder uses temporary markdown files for creating issues, PRs, and comments to ensure proper formatting: + +```bash +# Example of how MyCoder handles GitHub content +# 1. Creates a temporary markdown file +cat > temp.md << 'EOF' +## Description +This is a description with proper +newlines and formatting. + +- Bullet point 1 +- Bullet point 2 +EOF + +# 2. Uses the file with GitHub CLI +gh issue create --title "Issue Title" --body-file temp.md + +# 3. Cleans up the temporary file +rm temp.md +``` + +This approach ensures that formatting, newlines, and special characters are preserved correctly in GitHub content. + ## Configuration MyCoder stores configuration in `~/.mycoder/config.json`. You can manage configuration using the `config` command: diff --git a/packages/cli/tests/github-mode-test.md b/packages/cli/tests/github-mode-test.md new file mode 100644 index 0000000..18d2efd --- /dev/null +++ b/packages/cli/tests/github-mode-test.md @@ -0,0 +1,36 @@ +# GitHub Mode Markdown File Approach Test + +This is a test to verify that using temporary markdown files for GitHub issues, PRs, and comments works correctly. + +## Key Benefits +- Preserves formatting +- Handles newlines properly +- Supports special characters +- More robust than inline text + +## Example Usage +```bash +# Create a temporary markdown file +cat > temp.md << 'EOF' +# Issue Title + +## Description +This is a description with proper +newlines and formatting. + +- Bullet point 1 +- Bullet point 2 + +```code block +example code +``` +EOF + +# Use the file with GitHub CLI +gh issue create --title "Test Issue" --body-file temp.md + +# Clean up +rm temp.md +``` + +This approach should fix issue #83. \ No newline at end of file From 5e3747bfe4774af5f88821a83f1aeaf427054804 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Tue, 4 Mar 2025 15:45:09 -0500 Subject: [PATCH 2/2] Remove markdown approach details from README and delete test file --- .../agent/src/tools/interaction/subAgent.ts | 2 +- packages/cli/README.md | 23 ------------ packages/cli/tests/github-mode-test.md | 36 ------------------- 3 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 packages/cli/tests/github-mode-test.md diff --git a/packages/agent/src/tools/interaction/subAgent.ts b/packages/agent/src/tools/interaction/subAgent.ts index 25e80b3..4fc9456 100644 --- a/packages/agent/src/tools/interaction/subAgent.ts +++ b/packages/agent/src/tools/interaction/subAgent.ts @@ -1,8 +1,8 @@ import { z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; -import { getDefaultSystemPrompt } from '../../core/toolAgent/index.js'; import { getModel } from '../../core/toolAgent/config.js'; +import { getDefaultSystemPrompt } from '../../core/toolAgent/index.js'; import { toolAgent } from '../../core/toolAgent.js'; import { Tool, ToolContext } from '../../core/types.js'; import { getTools } from '../getTools.js'; diff --git a/packages/cli/README.md b/packages/cli/README.md index 63a59c6..3a2a40b 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -61,29 +61,6 @@ Requirements for GitHub mode: - GitHub CLI (`gh`) needs to be installed and authenticated - User needs to have appropriate GitHub permissions for the target repository -When using GitHub mode, MyCoder uses temporary markdown files for creating issues, PRs, and comments to ensure proper formatting: - -```bash -# Example of how MyCoder handles GitHub content -# 1. Creates a temporary markdown file -cat > temp.md << 'EOF' -## Description -This is a description with proper -newlines and formatting. - -- Bullet point 1 -- Bullet point 2 -EOF - -# 2. Uses the file with GitHub CLI -gh issue create --title "Issue Title" --body-file temp.md - -# 3. Cleans up the temporary file -rm temp.md -``` - -This approach ensures that formatting, newlines, and special characters are preserved correctly in GitHub content. - ## Configuration MyCoder stores configuration in `~/.mycoder/config.json`. You can manage configuration using the `config` command: diff --git a/packages/cli/tests/github-mode-test.md b/packages/cli/tests/github-mode-test.md deleted file mode 100644 index 18d2efd..0000000 --- a/packages/cli/tests/github-mode-test.md +++ /dev/null @@ -1,36 +0,0 @@ -# GitHub Mode Markdown File Approach Test - -This is a test to verify that using temporary markdown files for GitHub issues, PRs, and comments works correctly. - -## Key Benefits -- Preserves formatting -- Handles newlines properly -- Supports special characters -- More robust than inline text - -## Example Usage -```bash -# Create a temporary markdown file -cat > temp.md << 'EOF' -# Issue Title - -## Description -This is a description with proper -newlines and formatting. - -- Bullet point 1 -- Bullet point 2 - -```code block -example code -``` -EOF - -# Use the file with GitHub CLI -gh issue create --title "Test Issue" --body-file temp.md - -# Clean up -rm temp.md -``` - -This approach should fix issue #83. \ No newline at end of file