bone-agent 1.4.0 → 2.0.1

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 (126) hide show
  1. package/bin/bone.js +39 -0
  2. package/package.json +25 -39
  3. package/LICENSE +0 -21
  4. package/README.md +0 -201
  5. package/bin/npm-wrapper.js +0 -235
  6. package/bin/rg +0 -0
  7. package/bin/rg.exe +0 -0
  8. package/config.yaml.example +0 -144
  9. package/prompts/main/ask_questions.md +0 -31
  10. package/prompts/main/batch_independent_calls.md +0 -5
  11. package/prompts/main/casual_interactions.md +0 -11
  12. package/prompts/main/code_references.md +0 -8
  13. package/prompts/main/communication_style.md +0 -12
  14. package/prompts/main/context_reliability.md +0 -12
  15. package/prompts/main/conversational_tool_calling.md +0 -15
  16. package/prompts/main/dream.md +0 -50
  17. package/prompts/main/editing_pattern.md +0 -13
  18. package/prompts/main/error_handling.md +0 -6
  19. package/prompts/main/exploration_pattern.md +0 -21
  20. package/prompts/main/intro.md +0 -1
  21. package/prompts/main/obsidian.md +0 -16
  22. package/prompts/main/obsidian_project.md +0 -79
  23. package/prompts/main/professional_objectivity.md +0 -3
  24. package/prompts/main/skills.md +0 -3
  25. package/prompts/main/targeted_searching.md +0 -10
  26. package/prompts/main/task_lists_pattern.md +0 -8
  27. package/prompts/main/temp_folder.md +0 -9
  28. package/prompts/main/think_before_acting.md +0 -10
  29. package/prompts/main/tone_and_style.md +0 -4
  30. package/prompts/main/tool_preferences.md +0 -24
  31. package/prompts/main/trust_subagent_context.md +0 -21
  32. package/prompts/main/when_to_use_sub_agent.md +0 -7
  33. package/prompts/micro/ask_questions.md +0 -1
  34. package/prompts/micro/batch_independent_calls.md +0 -1
  35. package/prompts/micro/casual_interactions.md +0 -1
  36. package/prompts/micro/code_references.md +0 -1
  37. package/prompts/micro/communication_style.md +0 -1
  38. package/prompts/micro/context_reliability.md +0 -1
  39. package/prompts/micro/conversational_tool_calling.md +0 -1
  40. package/prompts/micro/editing_pattern.md +0 -1
  41. package/prompts/micro/error_handling.md +0 -1
  42. package/prompts/micro/exploration_pattern.md +0 -1
  43. package/prompts/micro/intro.md +0 -1
  44. package/prompts/micro/obsidian.md +0 -4
  45. package/prompts/micro/obsidian_project.md +0 -5
  46. package/prompts/micro/professional_objectivity.md +0 -1
  47. package/prompts/micro/skills.md +0 -1
  48. package/prompts/micro/targeted_searching.md +0 -1
  49. package/prompts/micro/task_lists_pattern.md +0 -1
  50. package/prompts/micro/temp_folder.md +0 -1
  51. package/prompts/micro/think_before_acting.md +0 -5
  52. package/prompts/micro/tone_and_style.md +0 -1
  53. package/prompts/micro/tool_preferences.md +0 -1
  54. package/prompts/micro/trust_subagent_context.md +0 -1
  55. package/prompts/micro/when_to_use_sub_agent.md +0 -1
  56. package/requirements.txt +0 -9
  57. package/src/__init__.py +0 -11
  58. package/src/core/__init__.py +0 -1
  59. package/src/core/agentic.py +0 -1085
  60. package/src/core/chat_manager.py +0 -1577
  61. package/src/core/config_manager.py +0 -260
  62. package/src/core/cron.py +0 -578
  63. package/src/core/cron_allowlist.py +0 -118
  64. package/src/core/memory.py +0 -145
  65. package/src/core/metadata.py +0 -75
  66. package/src/core/retry.py +0 -71
  67. package/src/core/skills.py +0 -463
  68. package/src/core/sub_agent.py +0 -376
  69. package/src/core/tool_approval.py +0 -220
  70. package/src/core/tool_feedback.py +0 -789
  71. package/src/exceptions.py +0 -79
  72. package/src/llm/__init__.py +0 -1
  73. package/src/llm/client.py +0 -176
  74. package/src/llm/codex_provider.py +0 -350
  75. package/src/llm/config.py +0 -536
  76. package/src/llm/prompts.py +0 -494
  77. package/src/llm/providers.py +0 -438
  78. package/src/llm/streaming.py +0 -163
  79. package/src/llm/token_tracker.py +0 -399
  80. package/src/tools/__init__.py +0 -151
  81. package/src/tools/constants.py +0 -59
  82. package/src/tools/create_file.py +0 -136
  83. package/src/tools/directory.py +0 -389
  84. package/src/tools/edit.py +0 -549
  85. package/src/tools/file_reader.py +0 -322
  86. package/src/tools/helpers/__init__.py +0 -99
  87. package/src/tools/helpers/base.py +0 -599
  88. package/src/tools/helpers/converters.py +0 -44
  89. package/src/tools/helpers/file_helpers.py +0 -189
  90. package/src/tools/helpers/formatters.py +0 -411
  91. package/src/tools/helpers/loader.py +0 -145
  92. package/src/tools/helpers/parallel_executor.py +0 -231
  93. package/src/tools/helpers/path_resolver.py +0 -283
  94. package/src/tools/helpers/plugin_manifest.py +0 -185
  95. package/src/tools/obsidian.py +0 -96
  96. package/src/tools/review_sub_agent.py +0 -190
  97. package/src/tools/rg_search.py +0 -477
  98. package/src/tools/search_plugins.py +0 -177
  99. package/src/tools/select_option.py +0 -600
  100. package/src/tools/shell.py +0 -302
  101. package/src/tools/sub_agent.py +0 -139
  102. package/src/tools/task_list.py +0 -269
  103. package/src/tools/web_search.py +0 -61
  104. package/src/ui/__init__.py +0 -1
  105. package/src/ui/banner.py +0 -87
  106. package/src/ui/commands.py +0 -3131
  107. package/src/ui/displays.py +0 -239
  108. package/src/ui/loader.py +0 -284
  109. package/src/ui/main.py +0 -643
  110. package/src/ui/prompt_utils.py +0 -113
  111. package/src/ui/setting_selector.py +0 -590
  112. package/src/ui/setup_wizard.py +0 -294
  113. package/src/ui/sub_agent_panel.py +0 -234
  114. package/src/ui/tool_confirmation.py +0 -226
  115. package/src/utils/__init__.py +0 -1
  116. package/src/utils/citation_parser.py +0 -199
  117. package/src/utils/editor.py +0 -207
  118. package/src/utils/gitignore_filter.py +0 -149
  119. package/src/utils/logger.py +0 -254
  120. package/src/utils/paths.py +0 -30
  121. package/src/utils/result_parsers.py +0 -108
  122. package/src/utils/safe_commands.py +0 -243
  123. package/src/utils/settings.py +0 -195
  124. package/src/utils/user_message_logger.py +0 -120
  125. package/src/utils/validation.py +0 -201
  126. package/src/utils/web_search.py +0 -173
package/bin/bone.js ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('node:child_process');
4
+ const path = require('node:path');
5
+
6
+ const packages = {
7
+ 'linux-x64': 'bone-agent-linux-x64',
8
+ 'linux-arm64': 'bone-agent-linux-arm64',
9
+ 'darwin-x64': 'bone-agent-darwin-x64',
10
+ 'darwin-arm64': 'bone-agent-darwin-arm64',
11
+ 'win32-x64': 'bone-agent-windows-x64'
12
+ };
13
+
14
+ const key = `${process.platform}-${process.arch}`;
15
+ const packageName = packages[key];
16
+
17
+ if (!packageName) {
18
+ console.error(`bone-agent does not support ${key}`);
19
+ process.exit(1);
20
+ }
21
+
22
+ let packageJson;
23
+ try {
24
+ packageJson = require.resolve(`${packageName}/package.json`);
25
+ } catch {
26
+ console.error(`Missing native package ${packageName}. Try reinstalling bone-agent.`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const exe = process.platform === 'win32' ? 'bone.exe' : 'bone';
31
+ const bin = path.join(path.dirname(packageJson), 'bin', exe);
32
+ const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
33
+
34
+ if (result.error) {
35
+ console.error(result.error.message);
36
+ process.exit(1);
37
+ }
38
+
39
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,54 +1,40 @@
1
1
  {
2
2
  "name": "bone-agent",
3
- "version": "1.4.0",
4
- "description": "A terminal-based AI coding assistant powered by OpenAI-style function calling",
5
- "main": "src/ui/main.py",
3
+ "version": "2.0.1",
4
+ "description": "A terminal-based AI coding assistant",
6
5
  "bin": {
7
- "bone": "bin/npm-wrapper.js"
6
+ "bone": "bin/bone.js"
8
7
  },
9
8
  "files": [
10
- "package.json",
11
- "LICENSE",
12
- "README.md",
13
- "requirements.txt",
14
- "config.yaml.example",
15
- "bin/npm-wrapper.js",
16
- "bin/rg",
17
- "bin/rg.exe",
18
- "src/**/*.py",
19
- "prompts"
9
+ "bin"
20
10
  ],
21
- "scripts": {
22
- "postinstall": "echo 'bone-agent installed! Run with: bone'",
23
- "start": "node bin/npm-wrapper.js"
11
+ "optionalDependencies": {
12
+ "bone-agent-linux-x64": "2.0.1",
13
+ "bone-agent-linux-arm64": "2.0.1",
14
+ "bone-agent-darwin-x64": "2.0.1",
15
+ "bone-agent-darwin-arm64": "2.0.1",
16
+ "bone-agent-windows-x64": "2.0.1"
24
17
  },
25
- "keywords": [
26
- "ai",
27
- "coding-assistant",
28
- "terminal",
29
- "llm",
30
- "function-calling",
31
- "python",
32
- "gpt",
33
- "claude",
34
- "bone-agent"
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "os": [
22
+ "darwin",
23
+ "linux",
24
+ "win32"
25
+ ],
26
+ "cpu": [
27
+ "x64",
28
+ "arm64"
35
29
  ],
36
30
  "author": "Vincent Miranda <vincentmiranda65@gmail.com>",
37
31
  "license": "MIT",
32
+ "homepage": "https://github.com/vincentm65/bone",
38
33
  "repository": {
39
34
  "type": "git",
40
- "url": "git+https://github.com/vincentm65/bone-agent.git"
35
+ "url": "git+https://github.com/vincentm65/bone.git"
41
36
  },
42
37
  "bugs": {
43
- "url": "https://github.com/vincentm65/bone-agent/issues"
44
- },
45
- "homepage": "https://github.com/vincentm65/bone-agent",
46
- "engines": {
47
- "node": ">=14.0.0"
48
- },
49
- "os": [
50
- "darwin",
51
- "linux",
52
- "win32"
53
- ]
38
+ "url": "https://github.com/vincentm65/bone/issues"
39
+ }
54
40
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Vincent Miranda
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,201 +0,0 @@
1
- ## bone-agent
2
-
3
- A CLI-based AI coding assistant capable of codebase search, file editing, computer use, and web search.
4
-
5
- <img width="1850" height="396" alt="image" src="https://github.com/user-attachments/assets/4f20cc22-a7d9-4423-afbf-15bbe1e29890" />
6
-
7
- ## Features
8
-
9
- - **Multiple LLM Provider Support**: bone-agent (built-in proxy), OpenAI, Anthropic, OpenRouter, GLM, Gemini, Kimi, MiniMax, and local models
10
- - **Tool-Based Interaction**: Code search (`rg`), file editing, directory operations, and web search
11
- - **Multiple Modes**: Edit (full access), Plan (read-only), and Learn (documentation style)
12
- - **Parallel Execution**: Run multiple tools concurrently for efficiency
13
- - **Conversation History**: Markdown logging with context compaction
14
- - **Approval Workflows**: Safety checks for dangerous commands
15
-
16
- ## Installation
17
-
18
- ### Option 1: npm install (Recommended)
19
-
20
- ```bash
21
- # Install globally (requires Python 3.9+)
22
- npm install -g bone-agent
23
-
24
- # Run bone
25
- bone
26
- ```
27
-
28
- Or use npx without installing:
29
-
30
- ```bash
31
- npx bone
32
- ```
33
-
34
- ### What Gets Installed
35
-
36
- The npm package automatically:
37
- 1. Checks for Python 3.9+ on your system
38
- 2. Installs Python dependencies via pip
39
- 3. Creates `~/.bone/config.yaml` from `config.yaml.example` if missing (persists across updates)
40
- 4. Sets up the `bone` command globally
41
-
42
- **Requirements:**
43
- - Node.js 14+ (for npm)
44
- - Python 3.9+ (for the application)
45
- - pip (to install Python dependencies)
46
-
47
- If Python is not found, the installer will guide you through installing it.
48
-
49
- ### Option 2: Git Clone
50
-
51
- ```bash
52
- # Clone the repository
53
- git clone https://github.com/vincentm65/bone-agent.git
54
- cd bone-agent
55
-
56
- # Install Python dependencies
57
- pip install -r requirements.txt
58
-
59
- # Run bone-agent
60
- python src/ui/main.py
61
- ```
62
-
63
- **Requirements:**
64
- - Python 3.9+
65
- - pip (to install Python dependencies)
66
-
67
- ## Configuration
68
-
69
- ### Setting API Keys
70
-
71
- You have three options to set your API keys:
72
-
73
- #### Option 1: Interactive Commands (Recommended)
74
-
75
- Run the app and use the built-in commands:
76
- ```
77
- > /key sk-your-api-key-here
78
- > /provider openai
79
- ```
80
-
81
- #### Option 2: Edit config.yaml Directly
82
-
83
- Edit `~/.bone/config.yaml` and add your keys:
84
-
85
- ```yaml
86
- # OpenAI
87
- OPENAI_API_KEY: "sk-your-key-here"
88
- OPENAI_MODEL: gpt-4o-mini
89
-
90
- # Anthropic (Claude)
91
- ANTHROPIC_API_KEY: "sk-ant-your-key-here"
92
- ANTHROPIC_MODEL: claude-3-5-sonnet-20241022
93
-
94
- # Or any other supported provider...
95
- ```
96
-
97
- **Note:** Config is stored at `~/.bone/config.yaml` — it persists across npm updates and is never tracked by git.
98
-
99
- #### Option 3: Environment Variables
100
-
101
- Set environment variables (they take precedence over ~/.bone/config.yaml):
102
-
103
- ```bash
104
- export OPENAI_API_KEY="sk-your-key-here"
105
- export ANTHROPIC_API_KEY="sk-ant-your-key-here"
106
-
107
- bone
108
- ```
109
-
110
- ### Available Environment Variables
111
-
112
- - `ANTHROPIC_API_KEY` - Anthropic (Claude) API key
113
- - `OPENAI_API_KEY` - OpenAI API key
114
- - `GLM_API_KEY` - GLM (Zhipu AI) API key
115
- - `GEMINI_API_KEY` - Google Gemini API key
116
- - `OPENROUTER_API_KEY` - OpenRouter API key
117
- - `KIMI_API_KEY` - Kimi (Moonshot AI) API key
118
- - `MINIMAX_API_KEY` - MiniMax API key
119
- - `BONE_API_KEY` - bone-agent (proxy) API key (auto-set via `/signup`)
120
- - `BONE_API_BASE` - bone-agent (proxy) API base URL (default: `https://api.vmcode.dev`)
121
-
122
- ## Commands
123
-
124
- - `/provider <name>` - Switch LLM provider
125
- - `/model <name>` - Set model for current provider
126
- - `/key <api_key>` - Set API key for current provider
127
- - `/mode <edit|plan|learn>` - Switch interaction mode
128
- - `/config` - Show all configuration settings
129
- - `/signup <email>` - Create a bone-agent account and get API key
130
- - `/account` - View your bone-agent account and plan details
131
- - `/plan` - View available plans and pricing
132
- - `/upgrade` - Upgrade your subscription
133
- - `/skills list [query]` - List saved skills, optionally filtered by name or content
134
- - `/skills show <name>` - Display a saved skill
135
- - `/skills add <name>` - Create a reusable prompt skill in your editor
136
- - `/skills edit <name>` - Open a saved skill in your editor
137
- - `/skills modify <name> [prompt]` - Update an existing saved skill inline or in your editor
138
- - `/skills load <name>` - Load a saved skill into the current chat
139
- - `/skills use <name>` - Alias for `/skills load`
140
- - `/skills remove <name>` - Delete a saved skill
141
- - `/skills dir` - Print the skills directory path
142
- - `/help` - Display all available commands
143
-
144
- Example:
145
-
146
- ```text
147
- /skills add frontend_design
148
- /skills modify frontend_design Use restrained, production-quality UI patterns.
149
- /skills use frontend_design
150
- ```
151
-
152
- /help Menu:
153
- <img width="1843" height="1349" alt="image" src="https://github.com/user-attachments/assets/631ab805-f012-4bb6-a031-c82a339e94c5" />
154
-
155
-
156
- ## Project Structure
157
-
158
- ```
159
- bone-agent/
160
- ├── bin/
161
- │ ├── npm-wrapper.js # npm entry point
162
- │ ├── rg # ripgrep binary (Linux/macOS)
163
- │ └── rg.exe # ripgrep binary (Windows)
164
- ├── config.yaml.example # Configuration template
165
- ├── requirements.txt # Python dependencies
166
- ├── package.json # npm package definition
167
- ├── .npmignore # npm package exclusions
168
- ├── .gitignore # git exclusions
169
- ├── src/
170
- │ ├── core/ # Core orchestration and state management
171
- │ ├── llm/ # LLM client and provider configurations
172
- │ ├── ui/ # CLI interface and commands
173
- │ └── utils/ # Utilities (file ops, search, validation)
174
- └── tests/ # Test suite (for development)
175
- ```
176
-
177
- ## bone-agent Plan (Built-in Proxy)
178
-
179
- bone-agent offers a built-in proxy provider for a seamless setup experience. Create an account and start coding without configuring third-party API keys.
180
-
181
- ```
182
- > /signup you@example.com
183
- ```
184
-
185
- Available plans: **Free**, **Lite**, and **Pro**. Use `/plan` to see details and `/upgrade` to change plans.
186
-
187
- *Paid plans coming soon.*
188
-
189
- ## Security
190
-
191
- - User config lives at `~/.bone/config.yaml` — outside the repo and git, persists across updates
192
- - Never commit API keys or sensitive configuration
193
- - Use environment variables for CI/CD or shared environments
194
-
195
- ## Development
196
-
197
- bone-agent is currently in active development. Production readiness is in progress with focus on:
198
- - Comprehensive test coverage
199
- - Documentation
200
- - Error handling improvements
201
- - Performance optimizations
@@ -1,235 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * bone-agent - npm wrapper for Python application
4
- * This script launches the Python bone-agent application
5
- */
6
-
7
- const { spawn } = require('child_process');
8
- const os = require('os');
9
- const path = require('path');
10
- const fs = require('fs');
11
-
12
- // Get the package directory - handle both local and global npm installs
13
- // For global installs, the wrapper is typically in node_modules/.bin or npm's global bin directory
14
- let packageDir = __dirname;
15
-
16
- // First check if package.json exists in current directory (local install)
17
- if (!fs.existsSync(path.join(packageDir, 'package.json'))) {
18
- // For global installs: check if we're in node_modules/.bin (go up to node_modules/package-name)
19
- const nodeModulesBin = path.join(packageDir, '..', 'bone-agent-cli', 'package.json');
20
- if (fs.existsSync(nodeModulesBin)) {
21
- packageDir = path.join(packageDir, '..', 'bone-agent-cli');
22
- } else {
23
- // Alternative: walk up the directory tree looking for package.json
24
- let found = false;
25
- let searchDir = packageDir;
26
- while (searchDir !== path.dirname(searchDir)) {
27
- const pkgJson = path.join(searchDir, 'package.json');
28
- if (fs.existsSync(pkgJson)) {
29
- packageDir = searchDir;
30
- found = true;
31
- break;
32
- }
33
- searchDir = path.dirname(searchDir);
34
- }
35
- if (!found) {
36
- console.error('Error: Could not find package.json. Installation may be corrupted.');
37
- console.error(`Searched from: ${__dirname}`);
38
- process.exit(1);
39
- }
40
- }
41
- }
42
-
43
- const pythonScript = path.join(packageDir, 'src', 'ui', 'main.py');
44
-
45
- function findPython() {
46
- const possibleCommands = ['python3', 'python', 'python3.9', 'python3.10', 'python3.11', 'python3.12'];
47
-
48
- for (const cmd of possibleCommands) {
49
- try {
50
- const result = spawnSync(cmd, ['--version'], { stdio: 'ignore' });
51
- if (result.status === 0) {
52
- return cmd;
53
- }
54
- } catch (e) {
55
- // Continue to next command
56
- }
57
- }
58
-
59
- return null;
60
- }
61
-
62
- function spawnSync(command, args, options) {
63
- const { spawnSync: sync } = require('child_process');
64
- return sync(command, args, options);
65
- }
66
-
67
- function checkPythonDependencies(pythonCmd) {
68
- // Check if requirements are installed
69
- const requirementsFile = path.join(packageDir, 'requirements.txt');
70
-
71
- if (!fs.existsSync(requirementsFile)) {
72
- return true; // No requirements file, assume OK
73
- }
74
-
75
- try {
76
- // Try importing a key module to check if dependencies are installed
77
- const result = spawnSync(pythonCmd, ['-c', 'import rich, requests, yaml, readability, html2text, ddgs, pathspec, prompt_toolkit, pygments'], {
78
- stdio: 'ignore',
79
- cwd: packageDir
80
- });
81
-
82
- return result.status === 0;
83
- } catch (e) {
84
- return false;
85
- }
86
- }
87
-
88
- function installPythonDependencies(pythonCmd) {
89
- console.log('Installing Python dependencies...');
90
- const requirementsFile = path.join(packageDir, 'requirements.txt');
91
-
92
- const installProcess = spawn(pythonCmd, ['-m', 'pip', 'install', '-r', requirementsFile], {
93
- stdio: 'inherit',
94
- cwd: packageDir
95
- });
96
-
97
- return new Promise((resolve, reject) => {
98
- installProcess.on('close', (code) => {
99
- if (code === 0) {
100
- resolve();
101
- } else {
102
- reject(new Error(`Failed to install Python dependencies (exit code ${code})`));
103
- }
104
- });
105
- });
106
- }
107
-
108
- function showSetupMessage() {
109
- console.log('\n' + '='.repeat(60));
110
- console.log('bone-agent - Terminal-based AI coding assistant');
111
- console.log('='.repeat(60));
112
- console.log('\nFirst-time setup needed!\n');
113
- console.log('1. Python is required (3.9 or later)');
114
- console.log('2. Python dependencies need to be installed\n');
115
- console.log('To complete setup, run:');
116
- console.log(' npm run install\n');
117
- console.log('Or manually:');
118
- console.log(' python3 -m pip install -r requirements.txt\n');
119
- console.log('Then run bone-agent again.\n');
120
- }
121
-
122
- function ensureUserConfig() {
123
- // User config lives in ~/.bone/config.yaml (persists across npm updates)
124
- const boneDir = path.join(os.homedir(), '.bone');
125
- const configFile = path.join(boneDir, 'config.yaml');
126
- const configExample = path.join(packageDir, 'config.yaml.example');
127
-
128
- if (!fs.existsSync(boneDir)) {
129
- fs.mkdirSync(boneDir, { recursive: true });
130
- }
131
-
132
- if (!fs.existsSync(configFile)) {
133
- if (fs.existsSync(configExample)) {
134
- try {
135
- fs.copyFileSync(configExample, configFile);
136
- console.log('✓ Config created: ~/.bone/config.yaml');
137
- } catch (e) {
138
- console.log('Failed to create config:', e.message);
139
- }
140
- }
141
- }
142
-
143
- return configFile;
144
- }
145
-
146
- // Handle subcommands before launching Python
147
- const subcommand = process.argv[2];
148
-
149
- if (subcommand === 'update') {
150
- console.log('Updating bone-agent-cli to latest version...');
151
- const updateProcess = spawn('npm', ['install', '-g', 'bone-agent-cli@latest'], {
152
- stdio: 'inherit',
153
- shell: true
154
- });
155
-
156
- updateProcess.on('close', (code) => {
157
- if (code === 0) {
158
- console.log('\n✓ bone-agent-cli updated successfully');
159
- } else {
160
- console.error('\n❌ Update failed (exit code ' + code + ')');
161
- console.error('Try running manually: npm install -g bone-agent-cli@latest');
162
- }
163
- process.exit(code || 0);
164
- });
165
-
166
- updateProcess.on('error', (err) => {
167
- console.error('❌ Failed to run update:', err.message);
168
- process.exit(1);
169
- });
170
- return;
171
- }
172
-
173
- async function main() {
174
- // Find Python executable
175
- const pythonCmd = findPython();
176
-
177
- if (!pythonCmd) {
178
- console.error('\n❌ Error: Python 3.9+ is not installed or not in PATH');
179
- console.error('Please install Python from https://python.org\n');
180
- process.exit(1);
181
- }
182
-
183
- console.log(`✓ Using Python: ${pythonCmd}`);
184
-
185
- // Check and install Python dependencies
186
- if (!checkPythonDependencies(pythonCmd)) {
187
- console.log('\n⚠️ Python dependencies not installed');
188
- try {
189
- await installPythonDependencies(pythonCmd);
190
- console.log('✓ Python dependencies installed\n');
191
- } catch (e) {
192
- console.error('\n❌ Failed to install dependencies:', e.message);
193
- console.error('Try running: npm run install\n');
194
- process.exit(1);
195
- }
196
- }
197
-
198
- // Ensure user config exists in ~/.bone/ (persists across npm updates)
199
- const userConfigPath = ensureUserConfig();
200
-
201
- // Run the Python application
202
- // BONE_CONFIG_PATH points to user's persistent config.yaml in ~/.bone/
203
- const pythonProcess = spawn(pythonCmd, [pythonScript], {
204
- stdio: 'inherit',
205
- cwd: process.cwd(),
206
- env: {
207
- ...process.env,
208
- BONE_CONFIG_PATH: userConfigPath,
209
- }
210
- });
211
-
212
- pythonProcess.on('close', (code) => {
213
- process.exit(code || 0);
214
- });
215
-
216
- pythonProcess.on('error', (err) => {
217
- console.error('\n❌ Failed to start bone-agent:', err.message);
218
- process.exit(1);
219
- });
220
-
221
- // Forward signals
222
- process.on('SIGINT', () => {
223
- pythonProcess.kill('SIGINT');
224
- });
225
-
226
- process.on('SIGTERM', () => {
227
- pythonProcess.kill('SIGTERM');
228
- });
229
- }
230
-
231
- // Run main function
232
- main().catch(err => {
233
- console.error('\n❌ Unexpected error:', err);
234
- process.exit(1);
235
- });
package/bin/rg DELETED
Binary file
package/bin/rg.exe DELETED
Binary file