Skip to content

Replace shell commands with Node.js APIs for cross-platform compatibility #98

@bhouston

Description

@bhouston

Replace shell commands with Node.js APIs for system information gathering

Currently, the agent gathers system information using Unix/Linux shell commands like pwd, ls -la, and uname -a via execSync. This approach is not cross-platform and will fail on Windows systems.

Problem

  • Commands like pwd, ls -la, and uname -a are Unix/Linux specific
  • Windows users will see error messages in the agent prompt
  • Reduces reliability and consistency across different operating systems

Proposed Solution

Replace shell commands with Node.js native APIs:

  • Current directory: process.cwd() instead of pwd
  • File listing: fs.readdirSync() with formatting instead of ls -la
  • System info: os module instead of uname -a
  • Date/time: Already using JavaScript's new Date().toString() (no change needed)

Benefits

  • Cross-platform compatibility (Windows, macOS, Linux)
  • More reliable and consistent behavior
  • Removes dependency on external shell commands
  • Better error handling

Implementation Notes

  • Update getDefaultSystemPrompt function in packages/agent/src/core/toolAgent/config.ts
  • Maintain similar formatting of output for consistency
  • Ensure proper error handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions