jiva-core 0.1.0

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 (94) hide show
  1. package/.env.example +18 -0
  2. package/.fluen/cache/state.json +7 -0
  3. package/README.md +350 -0
  4. package/actions/action_registry.py +75 -0
  5. package/actions/python_coder.py +470 -0
  6. package/api/main.py +269 -0
  7. package/dist/core/agent.d.ts +69 -0
  8. package/dist/core/agent.d.ts.map +1 -0
  9. package/dist/core/agent.js +214 -0
  10. package/dist/core/agent.js.map +1 -0
  11. package/dist/core/config.d.ts +222 -0
  12. package/dist/core/config.d.ts.map +1 -0
  13. package/dist/core/config.js +138 -0
  14. package/dist/core/config.js.map +1 -0
  15. package/dist/core/workspace.d.ts +53 -0
  16. package/dist/core/workspace.d.ts.map +1 -0
  17. package/dist/core/workspace.js +164 -0
  18. package/dist/core/workspace.js.map +1 -0
  19. package/dist/index.d.ts +17 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +17 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/interfaces/cli/index.d.ts +6 -0
  24. package/dist/interfaces/cli/index.d.ts.map +1 -0
  25. package/dist/interfaces/cli/index.js +257 -0
  26. package/dist/interfaces/cli/index.js.map +1 -0
  27. package/dist/interfaces/cli/repl.d.ts +9 -0
  28. package/dist/interfaces/cli/repl.d.ts.map +1 -0
  29. package/dist/interfaces/cli/repl.js +139 -0
  30. package/dist/interfaces/cli/repl.js.map +1 -0
  31. package/dist/interfaces/cli/setup-wizard.d.ts +9 -0
  32. package/dist/interfaces/cli/setup-wizard.d.ts.map +1 -0
  33. package/dist/interfaces/cli/setup-wizard.js +321 -0
  34. package/dist/interfaces/cli/setup-wizard.js.map +1 -0
  35. package/dist/mcp/client.d.ts +58 -0
  36. package/dist/mcp/client.d.ts.map +1 -0
  37. package/dist/mcp/client.js +178 -0
  38. package/dist/mcp/client.js.map +1 -0
  39. package/dist/mcp/server-manager.d.ts +58 -0
  40. package/dist/mcp/server-manager.d.ts.map +1 -0
  41. package/dist/mcp/server-manager.js +135 -0
  42. package/dist/mcp/server-manager.js.map +1 -0
  43. package/dist/models/base.d.ts +57 -0
  44. package/dist/models/base.d.ts.map +1 -0
  45. package/dist/models/base.js +5 -0
  46. package/dist/models/base.js.map +1 -0
  47. package/dist/models/harmony.d.ts +78 -0
  48. package/dist/models/harmony.d.ts.map +1 -0
  49. package/dist/models/harmony.js +226 -0
  50. package/dist/models/harmony.js.map +1 -0
  51. package/dist/models/krutrim.d.ts +30 -0
  52. package/dist/models/krutrim.d.ts.map +1 -0
  53. package/dist/models/krutrim.js +185 -0
  54. package/dist/models/krutrim.js.map +1 -0
  55. package/dist/models/orchestrator.d.ts +49 -0
  56. package/dist/models/orchestrator.d.ts.map +1 -0
  57. package/dist/models/orchestrator.js +140 -0
  58. package/dist/models/orchestrator.js.map +1 -0
  59. package/dist/utils/errors.d.ts +23 -0
  60. package/dist/utils/errors.d.ts.map +1 -0
  61. package/dist/utils/errors.js +45 -0
  62. package/dist/utils/errors.js.map +1 -0
  63. package/dist/utils/logger.d.ts +24 -0
  64. package/dist/utils/logger.d.ts.map +1 -0
  65. package/dist/utils/logger.js +74 -0
  66. package/dist/utils/logger.js.map +1 -0
  67. package/docs/BUILD.md +317 -0
  68. package/docs/DEV_WORKFLOW.md +197 -0
  69. package/docs/FILESYSTEM_ACCESS.md +244 -0
  70. package/docs/IMPLEMENTATION_SUMMARY.md +459 -0
  71. package/docs/QUICKSTART.md +162 -0
  72. package/docs/TROUBLESHOOTING.md +393 -0
  73. package/examples/code-review-directive.md +26 -0
  74. package/examples/data-analysis-directive.md +26 -0
  75. package/examples/programmatic-usage.ts +120 -0
  76. package/jiva-directive.md +24 -0
  77. package/package.json +46 -0
  78. package/setup.sh +65 -0
  79. package/src/core/agent.ts +275 -0
  80. package/src/core/config.ts +177 -0
  81. package/src/core/workspace.ts +205 -0
  82. package/src/index.ts +21 -0
  83. package/src/interfaces/cli/index.ts +290 -0
  84. package/src/interfaces/cli/repl.ts +182 -0
  85. package/src/interfaces/cli/setup-wizard.ts +355 -0
  86. package/src/mcp/client.ts +231 -0
  87. package/src/mcp/server-manager.ts +168 -0
  88. package/src/models/base.ts +63 -0
  89. package/src/models/harmony.ts +301 -0
  90. package/src/models/krutrim.ts +236 -0
  91. package/src/models/orchestrator.ts +180 -0
  92. package/src/utils/errors.ts +41 -0
  93. package/src/utils/logger.ts +87 -0
  94. package/tsconfig.json +22 -0
package/docs/BUILD.md ADDED
@@ -0,0 +1,317 @@
1
+ # Build & Development Instructions
2
+
3
+ ## Initial Setup (First Time)
4
+
5
+ ### 1. Install Dependencies
6
+
7
+ ```bash
8
+ cd /Users/abidev/dev/Jiva
9
+ npm install
10
+ ```
11
+
12
+ ### 2. Build the Project
13
+
14
+ ```bash
15
+ npm run build
16
+ ```
17
+
18
+ This compiles TypeScript to JavaScript in the `dist/` directory.
19
+
20
+ ### 3. Link Globally
21
+
22
+ ```bash
23
+ npm link
24
+ ```
25
+
26
+ This creates a global symlink to your local package, making the `jiva` command available system-wide.
27
+
28
+ ### 4. Add npm Global Bin to PATH (If Needed)
29
+
30
+ Check where npm installs global packages:
31
+
32
+ ```bash
33
+ npm config get prefix
34
+ ```
35
+
36
+ If the output is something like `/Users/yourusername/.npm-global`, you need to add the bin directory to your PATH.
37
+
38
+ **For Zsh (default on modern macOS):**
39
+ ```bash
40
+ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
41
+ source ~/.zshrc
42
+ ```
43
+
44
+ **For Bash:**
45
+ ```bash
46
+ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
47
+ source ~/.bashrc
48
+ ```
49
+
50
+ ### 5. Verify Installation
51
+
52
+ ```bash
53
+ which jiva
54
+ # Should output: /Users/yourusername/.npm-global/bin/jiva (or /usr/local/bin/jiva)
55
+
56
+ jiva --version
57
+ # Should output: 0.1.0
58
+
59
+ jiva --help
60
+ # Should show available commands
61
+ ```
62
+
63
+ **Alternative: Use the full path without PATH setup:**
64
+ ```bash
65
+ /Users/abidev/.npm-global/bin/jiva --help
66
+ # or
67
+ npx jiva --help
68
+ ```
69
+
70
+ ## Development Workflow (Subsequent Updates)
71
+
72
+ When you make changes to the code and want to test:
73
+
74
+ ### Method 1: Using npx (Recommended for Testing)
75
+
76
+ ```bash
77
+ # 1. Rebuild
78
+ npm run build
79
+
80
+ # 2. Test immediately with npx
81
+ npx jiva --help
82
+ npx jiva setup
83
+ npx jiva chat
84
+ # etc.
85
+ ```
86
+
87
+ **Advantages:**
88
+ - No PATH setup required
89
+ - Works immediately after `npm link`
90
+ - Portable across different shells
91
+
92
+ ### Method 2: Using Global Command (If PATH is set)
93
+
94
+ ```bash
95
+ # 1. Rebuild
96
+ npm run build
97
+
98
+ # 2. Test immediately (no relinking needed - npm link creates a symlink)
99
+ jiva --help
100
+ jiva setup
101
+ # etc.
102
+ ```
103
+
104
+ **Note:** Since `npm link` creates a symlink to your local `dist/` folder, rebuilding is all you need. The global `jiva` command automatically uses the latest built code.
105
+
106
+ ### Development Mode (Watch & Auto-rebuild)
107
+
108
+ For active development with automatic rebuilding on file changes:
109
+
110
+ ```bash
111
+ # Terminal 1: Start TypeScript compiler in watch mode
112
+ npx tsc --watch
113
+
114
+ # Terminal 2: Test your changes
115
+ npx jiva chat --debug
116
+ ```
117
+
118
+ ### Testing Without Global Install
119
+
120
+ If you don't want to use `npm link`, you can test directly:
121
+
122
+ ```bash
123
+ # Build first
124
+ npm run build
125
+
126
+ # Run directly with node
127
+ node dist/interfaces/cli/index.js --help
128
+ node dist/interfaces/cli/index.js setup
129
+ node dist/interfaces/cli/index.js chat
130
+
131
+ # Or use npm script
132
+ npm run dev -- --help
133
+ npm run dev -- setup
134
+ npm run dev -- chat
135
+ ```
136
+
137
+ ## Complete Development Cycle
138
+
139
+ ```bash
140
+ # 1. Make your code changes in src/
141
+ vim src/core/agent.ts
142
+
143
+ # 2. Rebuild
144
+ npm run build
145
+
146
+ # 3. Test
147
+ jiva chat --debug
148
+
149
+ # 4. Check for TypeScript errors without building
150
+ npm run type-check
151
+
152
+ # 5. If everything works, commit
153
+ git add .
154
+ git commit -m "Your changes"
155
+ ```
156
+
157
+ ## Troubleshooting
158
+
159
+ ### "command not found: jiva"
160
+
161
+ **Cause:** Package not linked globally.
162
+
163
+ **Solution:**
164
+ ```bash
165
+ cd /Users/abidev/dev/Jiva
166
+ npm link
167
+ ```
168
+
169
+ ### "Cannot find module" errors
170
+
171
+ **Cause:** Dependencies not installed or build is stale.
172
+
173
+ **Solution:**
174
+ ```bash
175
+ # Reinstall dependencies
176
+ rm -rf node_modules package-lock.json
177
+ npm install
178
+
179
+ # Rebuild
180
+ npm run build
181
+
182
+ # Relink if needed
183
+ npm unlink -g jiva
184
+ npm link
185
+ ```
186
+
187
+ ### Changes not reflected after rebuild
188
+
189
+ **Cause:** Multiple versions or cached builds.
190
+
191
+ **Solution:**
192
+ ```bash
193
+ # Unlink and relink
194
+ npm unlink -g jiva
195
+ npm run build
196
+ npm link
197
+
198
+ # Clear any npm cache
199
+ npm cache clean --force
200
+ ```
201
+
202
+ ### Permission errors when running jiva
203
+
204
+ **Cause:** CLI file not executable.
205
+
206
+ **Solution:**
207
+ ```bash
208
+ chmod +x dist/interfaces/cli/index.js
209
+ ```
210
+
211
+ ## Uninstalling
212
+
213
+ To remove the global `jiva` command:
214
+
215
+ ```bash
216
+ # Unlink from global
217
+ npm unlink -g jiva
218
+
219
+ # Or if that doesn't work
220
+ npm uninstall -g jiva
221
+
222
+ # Verify it's gone
223
+ which jiva # Should output nothing
224
+ ```
225
+
226
+ ## Building for Production
227
+
228
+ When ready to publish or distribute:
229
+
230
+ ```bash
231
+ # Clean build
232
+ rm -rf dist/
233
+ npm run build
234
+
235
+ # Test the production build
236
+ node dist/interfaces/cli/index.js setup
237
+
238
+ # Create tarball for distribution
239
+ npm pack
240
+ # This creates jiva-0.1.0.tgz
241
+ ```
242
+
243
+ ## IDE Setup
244
+
245
+ ### VS Code
246
+
247
+ Recommended extensions:
248
+ - ESLint
249
+ - Prettier
250
+ - TypeScript and JavaScript Language Features
251
+
252
+ Add to `.vscode/settings.json`:
253
+ ```json
254
+ {
255
+ "editor.formatOnSave": true,
256
+ "typescript.tsdk": "node_modules/typescript/lib",
257
+ "typescript.enablePromptUseWorkspaceTsdk": true
258
+ }
259
+ ```
260
+
261
+ ### Build Task (VS Code)
262
+
263
+ Add to `.vscode/tasks.json`:
264
+ ```json
265
+ {
266
+ "version": "2.0.0",
267
+ "tasks": [
268
+ {
269
+ "label": "Build Jiva",
270
+ "type": "npm",
271
+ "script": "build",
272
+ "group": {
273
+ "kind": "build",
274
+ "isDefault": true
275
+ },
276
+ "problemMatcher": ["$tsc"]
277
+ },
278
+ {
279
+ "label": "Watch Build",
280
+ "type": "shell",
281
+ "command": "npx tsc --watch",
282
+ "problemMatcher": ["$tsc-watch"],
283
+ "isBackground": true
284
+ }
285
+ ]
286
+ }
287
+ ```
288
+
289
+ Now you can press `Cmd+Shift+B` (Mac) or `Ctrl+Shift+B` (Windows/Linux) to build.
290
+
291
+ ## Quick Reference
292
+
293
+ | Task | Command |
294
+ |------|---------|
295
+ | Install dependencies | `npm install` |
296
+ | Build | `npm run build` |
297
+ | Link globally | `npm link` |
298
+ | Unlink globally | `npm unlink -g jiva` |
299
+ | Type check only | `npm run type-check` |
300
+ | Watch mode | `npx tsc --watch` |
301
+ | Dev mode | `npm run dev -- chat` |
302
+ | Clean build | `rm -rf dist/ && npm run build` |
303
+
304
+ ## Environment Variables (Optional)
305
+
306
+ For development, you can set default API credentials:
307
+
308
+ ```bash
309
+ # Add to ~/.zshrc or ~/.bashrc
310
+ export KRUTRIM_API_KEY="your-key-here"
311
+ export JIVA_DEBUG=true
312
+ ```
313
+
314
+ Then in code, you can use:
315
+ ```typescript
316
+ apiKey: process.env.KRUTRIM_API_KEY || 'fallback'
317
+ ```
@@ -0,0 +1,197 @@
1
+ # Development Workflow Summary
2
+
3
+ ## ๐ŸŽฏ Your Daily Development Cycle
4
+
5
+ ### 1๏ธโƒฃ Edit Code
6
+
7
+ ```bash
8
+ # Edit any TypeScript file
9
+ vim src/core/agent.ts
10
+ # or use your preferred editor
11
+ code .
12
+ ```
13
+
14
+ ### 2๏ธโƒฃ Rebuild
15
+
16
+ ```bash
17
+ npm run build
18
+ ```
19
+
20
+ ### 3๏ธโƒฃ Test with npx
21
+
22
+ ```bash
23
+ npx jiva --help
24
+ npx jiva setup
25
+ npx jiva chat
26
+ npx jiva run "your test prompt"
27
+ ```
28
+
29
+ **That's it!** No relinking, no PATH issues, just build and test.
30
+
31
+ ---
32
+
33
+ ## ๐Ÿ“‹ Common Tasks
34
+
35
+ ### Running the Setup Wizard
36
+
37
+ ```bash
38
+ npx jiva setup
39
+ ```
40
+
41
+ ### Interactive Chat
42
+
43
+ ```bash
44
+ npx jiva chat
45
+
46
+ # With debug mode
47
+ npx jiva chat --debug
48
+
49
+ # With custom workspace
50
+ npx jiva chat --workspace ~/myproject
51
+
52
+ # With directive file
53
+ npx jiva chat --directive ./my-directive.md
54
+ ```
55
+
56
+ ### Single Prompt Execution
57
+
58
+ ```bash
59
+ npx jiva run "What files are in this directory?"
60
+ ```
61
+
62
+ ### Update Configuration
63
+
64
+ ```bash
65
+ npx jiva config
66
+ ```
67
+
68
+ ---
69
+
70
+ ## ๐Ÿ”„ Watch Mode (Continuous Development)
71
+
72
+ Open two terminals:
73
+
74
+ **Terminal 1 - Auto Rebuild:**
75
+ ```bash
76
+ npx tsc --watch
77
+ ```
78
+
79
+ **Terminal 2 - Testing:**
80
+ ```bash
81
+ npx jiva chat --debug
82
+ # Make changes in your editor
83
+ # Save the file
84
+ # Terminal 1 rebuilds automatically
85
+ # Just restart jiva to see changes
86
+ ```
87
+
88
+ ---
89
+
90
+ ## ๐Ÿงช Before Committing
91
+
92
+ ```bash
93
+ # 1. Type check
94
+ npm run type-check
95
+
96
+ # 2. Clean build
97
+ rm -rf dist/
98
+ npm run build
99
+
100
+ # 3. Quick test
101
+ npx jiva --version
102
+ npx jiva --help
103
+
104
+ # 4. Functional test
105
+ npx jiva run "Test prompt"
106
+
107
+ # 5. Commit if all pass
108
+ git add .
109
+ git commit -m "Your changes"
110
+ ```
111
+
112
+ ---
113
+
114
+ ## ๐Ÿ› Troubleshooting
115
+
116
+ ### Build Fails
117
+
118
+ ```bash
119
+ # Check TypeScript errors
120
+ npm run type-check
121
+
122
+ # Clean and rebuild
123
+ rm -rf dist/ node_modules/
124
+ npm install
125
+ npm run build
126
+ ```
127
+
128
+ ### Runtime Errors
129
+
130
+ ```bash
131
+ # Run with debug logging
132
+ npx jiva chat --debug
133
+
134
+ # Check the output for detailed error messages
135
+ ```
136
+
137
+ ### "Cannot find module" Error
138
+
139
+ ```bash
140
+ # Reinstall dependencies
141
+ rm -rf node_modules package-lock.json
142
+ npm install
143
+ npm run build
144
+ npm link
145
+ ```
146
+
147
+ ### Config Issues
148
+
149
+ ```bash
150
+ # View config
151
+ npx jiva config
152
+
153
+ # Reset config (will prompt to reconfigure)
154
+ rm -rf ~/Library/Preferences/jiva-nodejs/
155
+ npx jiva setup
156
+ ```
157
+
158
+ ---
159
+
160
+ ## ๐Ÿ“š Documentation Files
161
+
162
+ - **[TESTING.md](TESTING.md)** - Comprehensive testing guide
163
+ - **[BUILD.md](BUILD.md)** - Full build instructions
164
+ - **[QUICKSTART.md](QUICKSTART.md)** - Quick start guide
165
+ - **[README.md](README.md)** - Main documentation
166
+ - **[IMPLEMENTATION_SUMMARY.md](IMPLEMENTATION_SUMMARY.md)** - Technical details
167
+
168
+ ---
169
+
170
+ ## ๐Ÿ’ก Pro Tips
171
+
172
+ 1. **Use watch mode** for rapid iteration
173
+ 2. **Always rebuild** before testing changes
174
+ 3. **Use `--debug`** flag when debugging
175
+ 4. **Test incrementally** - don't make too many changes at once
176
+ 5. **Check type errors first** - they're faster than runtime errors
177
+
178
+ ---
179
+
180
+ ## ๐ŸŽฏ Quick Reference
181
+
182
+ ```bash
183
+ # Edit โ†’ Build โ†’ Test cycle
184
+ vim src/file.ts && npm run build && npx jiva test-command
185
+
186
+ # Watch mode
187
+ npx tsc --watch
188
+
189
+ # Debug mode
190
+ npx jiva chat --debug
191
+
192
+ # Type check only (fast)
193
+ npm run type-check
194
+
195
+ # Clean build
196
+ rm -rf dist/ && npm run build
197
+ ```