Skip to content

Conversation

@finettt
Copy link

@finettt finettt commented Oct 15, 2025

Replace OpenRouter integration with OpenAI-like API support, implement robust shell command sanitization, and introduce Napoleon Dynamite personality module. Add multi-step command chaining capabilities and update build configuration for new dependencies.


Note

Migrates to an OpenAI-compatible API, introduces local RAG search, strengthens shell command sanitization, and overhauls the cross‑platform build and configuration.

  • Core/HTTP & JSON:
    • Switch to OpenAI-compatible chat completions (/v1/chat/completions) with configurable OPENAI_BASE, OPENAI_KEY, and OPENAI_MODEL.
    • Rework http_request for temp-file handling, API base normalization, and robust process exit checks.
    • Safer JSON escaping and parsing in src/json.c.
  • Command Execution Security:
    • Implement strict whitelist-based shell command sanitization (allows &&, >, >>; blocks expansions/quoting and dangerous chars).
    • Tool outputs fed back as tool messages.
  • RAG (Retrieval-Augmented Generation):
    • Add grep-based local file search (src/rag.c) with path validation and snippet limits.
    • New CLI flags --rag and --rag-snippets; config via env (RAG_*).
    • Integrate RAG snippets into user prompts when enabled.
  • Build/System:
    • Restructure sources under src/, add build/ objects, and OS-specific targets (Windows/Linux/Darwin) with compression.
    • Conditional compilation via RAG_ENABLED; enhanced CFLAGS/LDFLAGS; cross-platform compatibility macros in headers.
  • CLI/Main/Config:
    • Require OPENAI_KEY; add parse_args; maintain sliding window memory.
  • Docs:
    • README updated for OpenAI usage, RAG features, env vars, examples, and architecture.
    • .gitignore updated to ignore build/.

Written by Cursor Bugbot for commit 74e9cb5. This will update automatically on new commits. Configure here.

…on validation

- Add command sanitization to prevent shell injection attacks
- Replace system() with popen() for safer command execution
- Add validation for dangerous characters and shell constructs
- Enhance configuration system with environment variable validation
- Add proper error handling and buffer size checks
- Improve JSON escaping to prevent injection attacks

BREAKING CHANGE: Environment variable names changed from OR_KEY to OPENAI_KEY, and OPENAI_BASE and OPENAI_MODEL are now required
Replace OpenRouter integration with OpenAI API support, implement robust shell command sanitization, and introduce Napoleon Dynamite personality module. Add multi-step command chaining capabilities and update build configuration for new dependencies.
cursor[bot]

This comment was marked as outdated.

finettt and others added 3 commits October 20, 2025 16:07
- Add GitHub Actions CI matrix build with basic tests
- Add release workflow to build, checksum, and upload assets
- Implement RAG via grep-based local context search
- Add CLI args: --rag PATH and --rag-snippets N; env vars RAG_*
- Integrate RAG snippets into user prompt when enabled
- Add args.c and rag.c; extend Config with RAG fields
- Move sources to src/ and update Makefile SOURCES
- Escape control characters in JSON content
- Secure temp files with 0600 and switch to exit()
- Update README and relocate preview to docs/
… and RAG support

- Add GitHub Actions CI matrix build with basic tests
- Add release workflow to build, checksum, and upload assets
- Implement RAG via grep-based local context search
- Add CLI args: --rag PATH and --rag-snippets N; env vars RAG_*
- Integrate RAG snippets into user prompt when enabled
- Add args.c and rag.c; extend Config with RAG fields
- Move sources to src/ and update Makefile SOURCES
- Escape control characters in JSON content
- Secure temp files with 0600 and switch to exit()
- Update README and relocate preview to docs/
cursor[bot]

This comment was marked as outdated.

- Validate and sanitize path to prevent injection/traversal
- Resolve paths with realpath and ensure they stay within CWD
- Use resolved path in grep command
- Add Windows realpath/getcwd shims and required headers
cursor[bot]

This comment was marked as outdated.

- Update Makefile to improve build flags and streamline Windows build process.
- Implement platform-specific clean and install commands for better user experience.
- Enhance command execution in agent.c with stricter sanitization and error handling.
- Remove deprecated GitHub Actions CI workflow file.
- Update README to reflect changes in API base URL and installation instructions.
cursor[bot]

This comment was marked as outdated.

- Simplify message array building logic in json_request()
- Improve buffer size checking and error handling
- Remove unnecessary compiled binary (agent-c.exe)
- Enhance control character escaping efficiency
- Add better memory management for JSON message construction
cursor[bot]

This comment was marked as outdated.

if (!path || !query || !snippets || size == 0) return -1;

// Create temporary file for query
char query_file[] = "/tmp/rag_query_XXXXXX";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cross-Platform Temp Path Breaks Windows Compatibility

The search_rag_files function uses a hardcoded Unix-specific temporary file path (/tmp/rag_query_XXXXXX) for query files. This causes the function to fail on Windows systems, contradicting the codebase's general aim for cross-platform compatibility.

Fix in Cursor Fix in Web

src++;
}
continue;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Buffer overflow bug changes append to overwrite

In execute_command, the buffer boundary check for the >> operator is flawed. The check for space for the second > character happens after the first > is written, which can cause >> to be truncated to >. This changes command semantics from append to overwrite, risking data loss.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant