@bniladridas/cursor 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.clang-tidy +28 -0
  2. package/.dockerignore +56 -0
  3. package/.env.example +29 -0
  4. package/.github/CODEOWNERS +2 -0
  5. package/.github/ISSUE_TEMPLATE/blank.md +27 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  8. package/.github/SECURITY.md +24 -0
  9. package/.github/codeql/codeql-config.yml +8 -0
  10. package/.github/dependabot.yml +14 -0
  11. package/.github/labeler.yml +50 -0
  12. package/.github/packaging/brand-cursor.png +0 -0
  13. package/.github/packaging/database/init.sql +48 -0
  14. package/.github/packaging/docker/Dockerfile +111 -0
  15. package/.github/packaging/docker/docker-compose.yml +56 -0
  16. package/.github/packaging/scripts/preflight.sh +413 -0
  17. package/.github/packaging/scripts/prepare-release.sh +141 -0
  18. package/.github/packaging/scripts/release.sh +22 -0
  19. package/.github/packaging/scripts/setup-git-hooks.sh +73 -0
  20. package/.github/pull_request_template.md +31 -0
  21. package/.github/signed.json +9 -0
  22. package/.github/workflows/README.md +23 -0
  23. package/.github/workflows/ci.yml +181 -0
  24. package/.github/workflows/cla.yml +33 -0
  25. package/.github/workflows/formula-sha.yml +63 -0
  26. package/.github/workflows/issue-response.yml +44 -0
  27. package/.github/workflows/labeler.yml +42 -0
  28. package/.github/workflows/pr-body.yml +49 -0
  29. package/.github/workflows/release.yml +176 -0
  30. package/.github/workflows/security.yml +94 -0
  31. package/.github/workflows/stale.yml +38 -0
  32. package/AGENTS.md +49 -0
  33. package/CHANGELOG.md +3 -0
  34. package/CMakeLists.txt +646 -0
  35. package/Formula/cursor.rb +46 -0
  36. package/LICENSE +201 -0
  37. package/Makefile +28 -0
  38. package/README.md +46 -0
  39. package/cli.js +16 -0
  40. package/include/agent.h +86 -0
  41. package/include/agent_mode.h +17 -0
  42. package/include/memory_manager.h +102 -0
  43. package/include/services/ai_service.h +31 -0
  44. package/include/services/auth_service.h +87 -0
  45. package/include/services/checkpoint_service.h +69 -0
  46. package/include/services/codebase_service.h +38 -0
  47. package/include/services/command_service.h +23 -0
  48. package/include/services/context_service.h +74 -0
  49. package/include/services/database_service.h +56 -0
  50. package/include/services/error_service.h +106 -0
  51. package/include/services/file_service.h +51 -0
  52. package/include/services/git_service.h +29 -0
  53. package/include/services/github_service.h +85 -0
  54. package/include/services/mcp_service.h +85 -0
  55. package/include/services/multi_file_service.h +93 -0
  56. package/include/services/sandbox_service.h +96 -0
  57. package/include/services/theme_service.h +67 -0
  58. package/include/services/web_service.h +52 -0
  59. package/include/utils/config.h +68 -0
  60. package/include/utils/memory_utils.h +79 -0
  61. package/include/utils/platform.h +56 -0
  62. package/include/utils/ui.h +43 -0
  63. package/include/utils/validation.h +63 -0
  64. package/include/utils/version.h.in +17 -0
  65. package/install.js +49 -0
  66. package/package.json +16 -0
  67. package/release/checksums.txt +3 -0
  68. package/release/cursor-linux/cursor_v0.1.7_linux_amd64.tar.gz +0 -0
  69. package/release/cursor-macos/cursor_v0.1.7_darwin_arm64.tar.gz +0 -0
  70. package/release/cursor-windows/cursor__windows_amd64.zip +0 -0
  71. package/src/agent.cpp +2026 -0
  72. package/src/main.cpp +97 -0
  73. package/src/memory_manager.cpp +814 -0
  74. package/src/services/ai_service.cpp +366 -0
  75. package/src/services/auth_service.cpp +779 -0
  76. package/src/services/checkpoint_service.cpp +465 -0
  77. package/src/services/codebase_service.cpp +233 -0
  78. package/src/services/command_service.cpp +82 -0
  79. package/src/services/context_service.cpp +348 -0
  80. package/src/services/database_service.cpp +148 -0
  81. package/src/services/error_service.cpp +438 -0
  82. package/src/services/file_service.cpp +349 -0
  83. package/src/services/git_service.cpp +148 -0
  84. package/src/services/github_service.cpp +435 -0
  85. package/src/services/mcp_service.cpp +481 -0
  86. package/src/services/multi_file_service.cpp +591 -0
  87. package/src/services/sandbox_service.cpp +678 -0
  88. package/src/services/theme_service.cpp +429 -0
  89. package/src/services/web_service.cpp +532 -0
  90. package/src/utils/config.cpp +77 -0
  91. package/src/utils/memory_utils.cpp +93 -0
  92. package/src/utils/ui.cpp +307 -0
  93. package/src/utils/validation.cpp +306 -0
  94. package/src/utils/version.cpp +175 -0
  95. package/tests/e2e/docker-compose.yml +195 -0
  96. package/tests/e2e/run_e2e_tests.sh +70 -0
  97. package/tests/e2e/run_tests_in_docker.sh +115 -0
  98. package/tests/main_test.cpp +16 -0
  99. package/tests/mocks/mock_ollama.py +98 -0
  100. package/tests/mocks/start_nginx.sh +64 -0
@@ -0,0 +1,93 @@
1
+ #pragma once
2
+ #include <set>
3
+ #include <string>
4
+ #include <vector>
5
+
6
+ namespace Services {
7
+
8
+ struct FileMatch {
9
+ std::string file_path{};
10
+ std::string relative_path{};
11
+ std::string content{};
12
+ size_t size{0};
13
+ std::string file_type{};
14
+ };
15
+
16
+ enum class GitStatusFilter {
17
+ ALL, // All files
18
+ TRACKED, // Only tracked files
19
+ UNTRACKED, // Only untracked files
20
+ MODIFIED, // Only modified files
21
+ STAGED, // Only staged files
22
+ UNSTAGED // Only unstaged changes
23
+ };
24
+
25
+ struct MultiFileOptions {
26
+ std::vector<std::string> include_patterns;
27
+ std::vector<std::string> exclude_patterns;
28
+ bool respect_gitignore = true;
29
+ bool recursive = true;
30
+ size_t max_files = 100;
31
+ size_t max_file_size = 1024 * 1024; // 1MB
32
+ size_t max_total_size = 10 * 1024 * 1024; // 10MB
33
+
34
+ // Advanced Git filtering
35
+ GitStatusFilter git_filter = GitStatusFilter::ALL;
36
+ bool only_text_files = false;
37
+ bool include_hidden_files = false;
38
+ std::vector<std::string>
39
+ language_filters; // e.g., "cpp", "python", "javascript"
40
+ };
41
+
42
+ class MultiFileService {
43
+ public:
44
+ // Read multiple files based on patterns
45
+ static std::vector<FileMatch>
46
+ read_many_files(const std::vector<std::string> &paths,
47
+ const MultiFileOptions &options = MultiFileOptions{});
48
+
49
+ // Read files from directory with patterns
50
+ static std::vector<FileMatch>
51
+ read_directory_files(const std::string &directory,
52
+ const MultiFileOptions &options = MultiFileOptions{});
53
+
54
+ // Check if file should be included based on patterns
55
+ static bool should_include_file(const std::string &file_path,
56
+ const MultiFileOptions &options);
57
+
58
+ // Get file type from extension
59
+ static std::string get_file_type(const std::string &file_path);
60
+
61
+ // Load gitignore patterns
62
+ static std::set<std::string>
63
+ load_gitignore_patterns(const std::string &directory);
64
+
65
+ // Check if path matches gitignore patterns
66
+ static bool matches_gitignore(const std::string &file_path,
67
+ const std::set<std::string> &patterns);
68
+
69
+ // Format multi-file content for AI
70
+ static std::string
71
+ format_multi_file_content(const std::vector<FileMatch> &files,
72
+ const std::string &context_description = "");
73
+
74
+ // Advanced Git-aware filtering
75
+ static std::vector<std::string>
76
+ get_git_status_files(const std::string &directory, GitStatusFilter filter);
77
+
78
+ static bool is_text_file(const std::string &file_path);
79
+ static bool
80
+ matches_language_filter(const std::string &file_path,
81
+ const std::vector<std::string> &language_filters);
82
+
83
+ static std::string get_language_from_extension(const std::string &file_path);
84
+
85
+ private:
86
+ // Default exclude patterns
87
+ static std::vector<std::string> get_default_exclude_patterns();
88
+
89
+ // Check if file matches pattern (supports glob-like patterns)
90
+ static bool matches_pattern(const std::string &file_path,
91
+ const std::string &pattern);
92
+ };
93
+ } // namespace Services
@@ -0,0 +1,96 @@
1
+ #pragma once
2
+ #include <map>
3
+ #include <memory>
4
+ #include <string>
5
+ #include <vector>
6
+
7
+ namespace Services {
8
+
9
+ struct SandboxConfig {
10
+ std::string name;
11
+ std::string image;
12
+ std::vector<std::string> volumes;
13
+ std::map<std::string, std::string> environment_vars;
14
+ std::vector<std::string> allowed_commands;
15
+ size_t memory_limit_mb = 512;
16
+ size_t cpu_limit_percent = 50;
17
+ int timeout_seconds = 300;
18
+ bool network_access = false;
19
+ std::string working_directory = "/workspace";
20
+ };
21
+
22
+ struct SandboxResult {
23
+ int exit_code;
24
+ std::string stdout_output;
25
+ std::string stderr_output;
26
+ bool timed_out = false;
27
+ double execution_time_seconds = 0.0;
28
+ std::string error_message;
29
+ };
30
+
31
+ class SandboxService {
32
+ private:
33
+ static std::map<std::string, SandboxConfig> sandbox_configs_;
34
+ static std::string get_sandbox_config_path();
35
+ static void ensure_sandbox_directory();
36
+ static void initialize_default_configs();
37
+ static std::string generate_container_name();
38
+ static bool is_docker_available();
39
+ static std::string escape_shell_arg(const std::string &arg);
40
+
41
+ public:
42
+ // Sandbox management
43
+ static void initialize();
44
+ static bool create_sandbox_config(const std::string &name,
45
+ const SandboxConfig &config);
46
+ static bool remove_sandbox_config(const std::string &name);
47
+ static std::vector<std::string> list_sandbox_configs();
48
+ static SandboxConfig get_sandbox_config(const std::string &name);
49
+
50
+ // Command execution
51
+ static SandboxResult
52
+ execute_command(const std::string &command,
53
+ const std::string &sandbox_name = "default",
54
+ const std::string &working_dir = "");
55
+ static SandboxResult
56
+ execute_script(const std::string &script_content,
57
+ const std::string &script_type,
58
+ const std::string &sandbox_name = "default");
59
+ static SandboxResult
60
+ execute_file(const std::string &file_path,
61
+ const std::string &sandbox_name = "default");
62
+
63
+ // File operations
64
+ static bool copy_file_to_sandbox(const std::string &host_path,
65
+ const std::string &container_path,
66
+ const std::string &container_name);
67
+ static bool copy_file_from_sandbox(const std::string &container_path,
68
+ const std::string &host_path,
69
+ const std::string &container_name);
70
+
71
+ // Container management
72
+ static std::vector<std::string> list_active_containers();
73
+ static bool stop_container(const std::string &container_name);
74
+ static bool remove_container(const std::string &container_name);
75
+ static void cleanup_old_containers();
76
+
77
+ // Security validation
78
+ static bool is_command_safe(const std::string &command);
79
+ static bool validate_sandbox_config(const SandboxConfig &config,
80
+ std::string &error_message);
81
+ static std::vector<std::string>
82
+ get_security_warnings(const std::string &command);
83
+
84
+ // Configuration management
85
+ static bool save_sandbox_config();
86
+ static bool load_sandbox_config();
87
+ static bool update_sandbox_limits(const std::string &name, size_t memory_mb,
88
+ size_t cpu_percent);
89
+
90
+ // Utility functions
91
+ static bool check_docker_installation();
92
+ static std::string get_docker_version();
93
+ static bool pull_docker_image(const std::string &image);
94
+ static std::vector<std::string> list_available_images();
95
+ };
96
+ } // namespace Services
@@ -0,0 +1,67 @@
1
+ #pragma once
2
+ #include <map>
3
+ #include <string>
4
+ #include <vector>
5
+
6
+ namespace Services {
7
+
8
+ enum class ThemeColor {
9
+ PRIMARY,
10
+ SECONDARY,
11
+ SUCCESS,
12
+ WARNING,
13
+ ERROR,
14
+ INFO,
15
+ TEXT,
16
+ BACKGROUND,
17
+ ACCENT,
18
+ MUTED
19
+ };
20
+
21
+ struct Theme {
22
+ std::string name;
23
+ std::string description;
24
+ std::map<ThemeColor, std::string> colors;
25
+ bool is_dark_theme = false;
26
+ };
27
+
28
+ class ThemeService {
29
+ private:
30
+ static std::string current_theme_name_;
31
+ static std::map<std::string, Theme> available_themes_;
32
+ static std::string get_theme_config_path();
33
+ static void ensure_theme_directory();
34
+ static void initialize_default_themes();
35
+ static std::string get_ansi_color_code(const std::string &color);
36
+
37
+ public:
38
+ // Theme management
39
+ static void initialize();
40
+ static bool set_theme(const std::string &theme_name);
41
+ static std::string get_current_theme();
42
+ static std::vector<std::string> list_available_themes();
43
+ static Theme get_theme_info(const std::string &theme_name);
44
+
45
+ // Color utilities
46
+ static std::string colorize(const std::string &text, ThemeColor color);
47
+ static std::string colorize_command(const std::string &text);
48
+ static std::string colorize_success(const std::string &text);
49
+ static std::string colorize_error(const std::string &text);
50
+ static std::string colorize_warning(const std::string &text);
51
+ static std::string colorize_info(const std::string &text);
52
+ static std::string colorize_accent(const std::string &text);
53
+
54
+ // Theme persistence
55
+ static bool save_theme_config();
56
+ static bool load_theme_config();
57
+
58
+ // Theme creation
59
+ static bool create_custom_theme(const std::string &name, const Theme &theme);
60
+ static bool delete_custom_theme(const std::string &name);
61
+
62
+ // Utility functions
63
+ static void print_theme_preview(const std::string &theme_name);
64
+ static void reset_colors();
65
+ static bool is_color_supported();
66
+ };
67
+ } // namespace Services
@@ -0,0 +1,52 @@
1
+ #pragma once
2
+ #include <algorithm>
3
+ #include <map>
4
+ #include <string>
5
+
6
+ // Local case-insensitive comparison function for headers
7
+ struct CaseInsensitiveCompare {
8
+ bool operator()(const std::string &lhs,
9
+ const std::string &rhs) const noexcept {
10
+ return std::lexicographical_compare(
11
+ lhs.begin(), lhs.end(), rhs.begin(), rhs.end(),
12
+ [](unsigned char ac, unsigned char bc) {
13
+ return std::tolower(ac) < std::tolower(bc);
14
+ });
15
+ }
16
+ };
17
+
18
+ using HeaderMap = std::map<std::string, std::string, CaseInsensitiveCompare>;
19
+
20
+ namespace Services {
21
+ struct WebResponse {
22
+ int status_code;
23
+ std::string content;
24
+ std::string content_type;
25
+ HeaderMap headers;
26
+ bool success;
27
+ std::string error_message;
28
+ };
29
+
30
+ class WebService {
31
+ private:
32
+ static std::string get_api_key();
33
+ static std::string extract_text_content(const std::string &html);
34
+ static std::string sanitize_content(const std::string &content);
35
+
36
+ public:
37
+ // Existing search functionality
38
+ static std::string search(const std::string &query);
39
+ static bool is_available();
40
+
41
+ // New web fetch capabilities
42
+ static WebResponse fetch_url(const std::string &url);
43
+ static std::string fetch_text(const std::string &url);
44
+ static std::string fetch_json(const std::string &url);
45
+ static WebResponse fetch_with_headers(const std::string &url,
46
+ const HeaderMap &headers);
47
+ static WebResponse post_json(const std::string &url,
48
+ const std::string &json_body,
49
+ const HeaderMap &headers);
50
+ static bool is_valid_url(const std::string &url);
51
+ };
52
+ } // namespace Services
@@ -0,0 +1,68 @@
1
+ #pragma once
2
+
3
+ // Define DLL export/import macros for Windows
4
+ #if defined(_WIN32) || defined(_WIN64)
5
+ #ifndef CURSOR_API
6
+ #ifdef CURSOR_LIBRARY
7
+ #define CURSOR_API __declspec(dllexport)
8
+ #else
9
+ #define CURSOR_API __declspec(dllimport)
10
+ #endif
11
+ #endif
12
+
13
+ // Disable warning about STL types in the interface
14
+ #ifndef _HAS_CXX17
15
+ #define _HAS_CXX17 1
16
+ #endif
17
+
18
+ #ifndef _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
19
+ #define _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
20
+ #endif
21
+
22
+ #pragma warning(disable \
23
+ : 4251) // Disable warning about STL types in the interface
24
+ #pragma warning( \
25
+ disable \
26
+ : 4275) // Disable warning about non dll-interface class used as base
27
+
28
+ // Enable secure CRT functions
29
+ #ifndef _CRT_SECURE_NO_WARNINGS
30
+ #define _CRT_SECURE_NO_WARNINGS
31
+ #endif
32
+
33
+ // Disable min/max macros from windows.h
34
+ #ifndef NOMINMAX
35
+ #define NOMINMAX
36
+ #endif
37
+ #else
38
+ #ifndef CURSOR_API
39
+ #define CURSOR_API __attribute__((visibility("default")))
40
+ #endif
41
+
42
+ // On non-Windows, we can use visibility attributes for better control
43
+ #ifdef __GNUC__
44
+ #ifndef CURSOR_LOCAL
45
+ #define CURSOR_LOCAL __attribute__((visibility("hidden")))
46
+ #endif
47
+ #else
48
+ #ifndef CURSOR_LOCAL
49
+ #define CURSOR_LOCAL
50
+ #endif
51
+ #endif
52
+ #endif
53
+
54
+ // Disable exporting of STL templates
55
+ #ifdef _MSC_VER
56
+ #define CURSOR_NO_EXPORT_TEMPLATE template class CURSOR_API
57
+ #else
58
+ #define CURSOR_NO_EXPORT_TEMPLATE extern template class CURSOR_API
59
+ #endif
60
+
61
+ #include <string>
62
+
63
+ namespace Utils::Config {
64
+ CURSOR_API void load_environment(const std::string &filename = ".env");
65
+ CURSOR_API std::string get_env_var(const std::string &key,
66
+ const std::string &default_value = "");
67
+ CURSOR_API bool has_env_var(const std::string &key);
68
+ } // namespace Utils::Config
@@ -0,0 +1,79 @@
1
+ #pragma once
2
+ #include <string>
3
+ #include <string_view>
4
+ #include <vector>
5
+
6
+ namespace Utils {
7
+ namespace Memory {
8
+
9
+ // String optimization utilities
10
+ class StringBuilder {
11
+ private:
12
+ std::string buffer_;
13
+
14
+ public:
15
+ explicit StringBuilder(size_t reserve_size = 1024) {
16
+ buffer_.reserve(reserve_size);
17
+ }
18
+
19
+ StringBuilder &append(const std::string &str) {
20
+ buffer_.append(str);
21
+ return *this;
22
+ }
23
+
24
+ StringBuilder &append(char c) {
25
+ buffer_.push_back(c);
26
+ return *this;
27
+ }
28
+
29
+ std::string build() { return std::move(buffer_); }
30
+
31
+ size_t size() const { return buffer_.size(); }
32
+
33
+ const std::string &str() const { return buffer_; }
34
+ void clear() { buffer_.clear(); }
35
+ void reserve(size_t size) { buffer_.reserve(size); }
36
+ };
37
+
38
+ // Efficient string splitting using string_view
39
+ std::vector<std::string_view> split_view(std::string_view input,
40
+ char delimiter);
41
+ std::vector<std::string_view> split_view(std::string_view input,
42
+ std::string_view delimiter);
43
+
44
+ // Memory usage tracking
45
+ class MemoryTracker {
46
+ private:
47
+ static size_t current_usage_;
48
+ static size_t peak_usage_;
49
+
50
+ public:
51
+ static void add_allocation(size_t size);
52
+ static void remove_allocation(size_t size);
53
+ static size_t get_current_usage() { return current_usage_; }
54
+ static size_t get_peak_usage() { return peak_usage_; }
55
+ static void reset_peak() { peak_usage_ = current_usage_; }
56
+ static std::string format_bytes(size_t bytes);
57
+ };
58
+
59
+ // RAII memory tracker for automatic tracking
60
+ class ScopedMemoryTracker {
61
+ private:
62
+ size_t size_;
63
+
64
+ public:
65
+ explicit ScopedMemoryTracker(size_t size) : size_(size) {
66
+ MemoryTracker::add_allocation(size_);
67
+ }
68
+
69
+ ~ScopedMemoryTracker() { MemoryTracker::remove_allocation(size_); }
70
+
71
+ // Non-copyable, movable
72
+ ScopedMemoryTracker(const ScopedMemoryTracker &) = delete;
73
+ ScopedMemoryTracker &operator=(const ScopedMemoryTracker &) = delete;
74
+ ScopedMemoryTracker(ScopedMemoryTracker &&) = default;
75
+ ScopedMemoryTracker &operator=(ScopedMemoryTracker &&) = default;
76
+ };
77
+
78
+ } // namespace Memory
79
+ } // namespace Utils
@@ -0,0 +1,56 @@
1
+ #pragma once
2
+
3
+ #ifdef _WIN32
4
+ #include <io.h>
5
+ #include <process.h>
6
+ #include <windows.h>
7
+ #define popen _popen
8
+ #define pclose _pclose
9
+ #define NULL_DEVICE "NUL"
10
+ #define PATH_SEPARATOR "\\"
11
+ #define SHELL_REDIRECT " 2>NUL"
12
+ #define SHELL_REDIRECT_BOTH " >NUL 2>&1"
13
+ #else
14
+ #include <sys/wait.h>
15
+ #include <unistd.h>
16
+ #define NULL_DEVICE "/dev/null"
17
+ #define PATH_SEPARATOR "/"
18
+ #define SHELL_REDIRECT " 2>/dev/null"
19
+ #define SHELL_REDIRECT_BOTH " >/dev/null 2>&1"
20
+ #endif
21
+
22
+ #include <cstdio>
23
+ #include <string>
24
+
25
+ namespace Utils {
26
+ namespace Platform {
27
+
28
+ // Cross-platform command execution
29
+ inline FILE *open_process(const std::string &command, const char *mode) {
30
+ return popen(command.c_str(), mode);
31
+ }
32
+
33
+ inline int close_process(FILE *pipe) { return pclose(pipe); }
34
+
35
+ // Cross-platform null device
36
+ inline std::string get_null_device() { return NULL_DEVICE; }
37
+
38
+ // Cross-platform path separator
39
+ inline std::string get_path_separator() { return PATH_SEPARATOR; }
40
+
41
+ // Cross-platform shell redirection
42
+ inline std::string get_shell_redirect() { return SHELL_REDIRECT; }
43
+
44
+ inline std::string get_shell_redirect_both() { return SHELL_REDIRECT_BOTH; }
45
+
46
+ // Check if running on Windows
47
+ inline bool is_windows() {
48
+ #ifdef _WIN32
49
+ return true;
50
+ #else
51
+ return false;
52
+ #endif
53
+ }
54
+
55
+ } // namespace Platform
56
+ } // namespace Utils
@@ -0,0 +1,43 @@
1
+ #pragma once
2
+ #include "utils/config.h" // For CURSOR_API
3
+ #include <atomic>
4
+ #include <string>
5
+
6
+ namespace Utils {
7
+ // Color namespace
8
+ namespace Color {
9
+ extern CURSOR_API const std::string RESET;
10
+ extern CURSOR_API const std::string GREEN;
11
+ extern CURSOR_API const std::string YELLOW;
12
+ extern CURSOR_API const std::string RED;
13
+ extern CURSOR_API const std::string CYAN;
14
+ extern CURSOR_API const std::string BOLD;
15
+ extern CURSOR_API const std::string DIM;
16
+ extern CURSOR_API const std::string PINK;
17
+ } // namespace Color
18
+
19
+ // UI namespace
20
+ namespace UI {
21
+ // Core functions
22
+ CURSOR_API void print_logo();
23
+ CURSOR_API void print_help();
24
+ CURSOR_API void print_enterprise_status();
25
+ CURSOR_API void spinner(const std::string &message, int duration_ms);
26
+ CURSOR_API void spinner(std::atomic<bool> &done); // For threaded spinner
27
+
28
+ // Status messages
29
+ CURSOR_API void print_success(const std::string &message);
30
+ CURSOR_API void print_error(const std::string &message);
31
+ CURSOR_API void print_warning(const std::string &message);
32
+ CURSOR_API void print_info(const std::string &message);
33
+
34
+ // Utility functions
35
+ CURSOR_API void print_divider();
36
+ CURSOR_API void print_quick_help();
37
+ CURSOR_API void print_system_info(const std::string &mode,
38
+ const std::string &model);
39
+ CURSOR_API void print_ready_interface(const std::string &mode,
40
+ const std::string &model);
41
+ CURSOR_API std::string prompt_user(const std::string &prompt_text);
42
+ } // namespace UI
43
+ } // namespace Utils
@@ -0,0 +1,63 @@
1
+ #pragma once
2
+ #include <functional>
3
+ #include <string>
4
+ #include <vector>
5
+
6
+ namespace Utils {
7
+ struct ValidationResult {
8
+ bool is_valid;
9
+ std::string error_message;
10
+ std::vector<std::string> warnings;
11
+ };
12
+
13
+ class Validator {
14
+ public:
15
+ // File path validation
16
+ static ValidationResult
17
+ validate_file_path(const std::string &path,
18
+ const std::string &base_directory = "");
19
+ static ValidationResult validate_file_exists(const std::string &path);
20
+ static ValidationResult validate_file_writable(const std::string &path);
21
+
22
+ // Text validation
23
+ static ValidationResult
24
+ validate_non_empty(const std::string &text,
25
+ const std::string &field_name = "text");
26
+ static ValidationResult validate_regex_pattern(const std::string &pattern);
27
+
28
+ // Command validation
29
+ static ValidationResult validate_command_safe(const std::string &command);
30
+ static ValidationResult validate_search_query(const std::string &query);
31
+
32
+ // Parameter validation
33
+ static ValidationResult validate_line_range(int start_line, int line_count,
34
+ int total_lines);
35
+ static ValidationResult validate_replacement_count(int expected, int actual);
36
+
37
+ // Composite validation
38
+ static ValidationResult
39
+ combine_results(const std::vector<ValidationResult> &results);
40
+
41
+ // Utility functions
42
+ static bool is_safe_path(const std::string &path);
43
+ static bool is_text_file_extension(const std::string &extension);
44
+ static const std::vector<std::string> &get_text_extensions();
45
+ static std::string sanitize_input(const std::string &input);
46
+ };
47
+
48
+ // Validation helper macros
49
+ #define VALIDATE_AND_RETURN(validation) \
50
+ do { \
51
+ auto result = validation; \
52
+ if (!result.is_valid) { \
53
+ return result.error_message; \
54
+ } \
55
+ } while (0)
56
+
57
+ #define VALIDATE_PARAM(condition, message) \
58
+ do { \
59
+ if (!(condition)) { \
60
+ return ValidationResult{false, message, {}}; \
61
+ } \
62
+ } while (0)
63
+ } // namespace Utils
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+ #include <string>
3
+
4
+ constexpr int cursor_version_major = @PROJECT_VERSION_MAJOR@;
5
+ constexpr int cursor_version_minor = @PROJECT_VERSION_MINOR@;
6
+ constexpr int cursor_version_patch = @PROJECT_VERSION_PATCH@;
7
+ constexpr const char* cursor_version_string = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@";
8
+ #define CURSOR_BUILD_DATE __DATE__
9
+ #define CURSOR_BUILD_TIME __TIME__
10
+
11
+ namespace Version {
12
+ const char* get_version();
13
+ const char* get_build_info();
14
+ void print_version_info();
15
+ std::string check_update();
16
+ bool download_and_install(const std::string& version);
17
+ }
package/install.js ADDED
@@ -0,0 +1,49 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const https = require('https');
5
+
6
+ const pkg = require('./package.json');
7
+ const version = pkg.version;
8
+ const binaryDir = path.join(__dirname, 'binary');
9
+
10
+ const platformMap = {
11
+ darwin: 'cursor-macos.tar.gz',
12
+ linux: 'cursor-linux.tar.gz',
13
+ win32: 'cursor-windows.zip',
14
+ };
15
+
16
+ const archive = platformMap[process.platform];
17
+ if (!archive) {
18
+ console.error(`unsupported platform: ${process.platform}`);
19
+ process.exit(1);
20
+ }
21
+
22
+ const url = `https://github.com/bniladridas/cursor/releases/download/v${version}/${archive}`;
23
+
24
+ fs.mkdirSync(binaryDir, { recursive: true });
25
+
26
+ console.log(`downloading cursor v${version}...`);
27
+
28
+ const file = fs.createWriteStream(path.join(binaryDir, archive));
29
+ https.get(url, (res) => {
30
+ if (res.statusCode !== 200) {
31
+ console.error(`download failed (${res.statusCode}): ${url}`);
32
+ process.exit(1);
33
+ }
34
+ res.pipe(file);
35
+ file.on('finish', () => {
36
+ file.close();
37
+ console.log('extracting...');
38
+ if (process.platform === 'win32') {
39
+ execSync(`tar -xf "${path.join(binaryDir, archive)}" -C "${binaryDir}"`, { stdio: 'inherit' });
40
+ } else {
41
+ execSync(`tar -xzf "${path.join(binaryDir, archive)}" -C "${binaryDir}"`, { stdio: 'inherit' });
42
+ }
43
+ fs.unlinkSync(path.join(binaryDir, archive));
44
+ console.log('done');
45
+ });
46
+ }).on('error', (err) => {
47
+ console.error(`download failed: ${err.message}`);
48
+ process.exit(1);
49
+ });