diff --git a/docs/API.bg.md b/docs/API.bg.md index a5ac7d4..a93220a 100644 --- a/docs/API.bg.md +++ b/docs/API.bg.md @@ -142,6 +142,26 @@ REPL чете по един JSON обект на ред и отговаря с - `message` — Четимо съобщение - `meta` — Както при успех +## Файлови Операции (от Clojure код) + +| Функция | Пример | Връща | +|---|---|---| +| `file/read` | `(file/read "path")` | Низ със съдържание или map с грешка | +| `file/write` | `(file/write "path" "content")` | `true` или map с грешка | +| `file/append` | `(file/append "path" "more")` | `true` или map с грешка | +| `file/ls` | `(file/ls "dir")` | Вектор с имена на файлове | +| `file/exists?` | `(file/exists? "path")` | `true` / `false` | + +## Git Операции (от Clojure код) + +| Функция | Пример | Връща | +|---|---|---| +| `git/status` | `(git/status)` | Map с `:branch`, `:modified`, `:untracked`, `:staged`, `:clean` | +| `git/commit` | `(git/commit "msg")` | Map с `:sha`, `:success` | +| `git/push` | `(git/push)` | Map с `:success`, `:output` | +| `git/diff` | `(git/diff)` | Низ с diff | +| `git/log` | `(git/log)` или `(git/log 10)` | Вектор с commit низове | + ## Команди в Човешки REPL В човешки режим (`cljnim repl`): diff --git a/docs/API.md b/docs/API.md index 7aaf787..db2a706 100644 --- a/docs/API.md +++ b/docs/API.md @@ -142,6 +142,26 @@ On error: - `message` — Human-readable message - `meta` — Same as success +## File Operations (from Clojure code) + +| Function | Example | Returns | +|---|---|---| +| `file/read` | `(file/read "path")` | String content or error map | +| `file/write` | `(file/write "path" "content")` | `true` or error map | +| `file/append` | `(file/append "path" "more")` | `true` or error map | +| `file/ls` | `(file/ls "dir")` | Vector of filenames | +| `file/exists?` | `(file/exists? "path")` | `true` / `false` | + +## Git Operations (from Clojure code) + +| Function | Example | Returns | +|---|---|---| +| `git/status` | `(git/status)` | Map with `:branch`, `:modified`, `:untracked`, `:staged`, `:clean` | +| `git/commit` | `(git/commit "msg")` | Map with `:sha`, `:success` | +| `git/push` | `(git/push)` | Map with `:success`, `:output` | +| `git/diff` | `(git/diff)` | Diff string | +| `git/log` | `(git/log)` or `(git/log 10)` | Vector of commit strings | + ## Human REPL Commands In human mode (`cljnim repl`): diff --git a/docs/ROADMAP.bg.md b/docs/ROADMAP.bg.md index 5a35e40..4d4a637 100644 --- a/docs/ROADMAP.bg.md +++ b/docs/ROADMAP.bg.md @@ -36,9 +36,11 @@ - [x] Извикване на Nim функции: `(nim/math/sin x)`, `(nim/strutils/toUpper s)` - [x] C FFI през Nim `importc` -## Фаза 4: AI-Native Инструменти 🔄 -- [ ] Файлови операции от REPL: `(file/read "path")`, `(file/write "path" "content")` -- [ ] Git операции от REPL: `(git/status)`, `(git/commit "msg")`, `(git/push)` +## Фаза 4: AI-Native Инструменти ✅ +- [x] Файлови операции: `(file/read "path")`, `(file/write "path" "content")`, `(file/append "path" "content")` +- [x] Файлови операции: `(file/ls "dir")`, `(file/exists? "path")` +- [x] Git операции: `(git/status)`, `(git/commit "msg")`, `(git/push)` +- [x] Git операции: `(git/diff)`, `(git/log)` - [ ] nREPL протокол съвместимост - [ ] Tool-call формат за интеграция с AI frameworks diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 51e5cf5..c4344f6 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -36,9 +36,11 @@ - [x] Call Nim functions: `(nim/math/sin x)`, `(nim/strutils/toUpper s)` - [x] C FFI via Nim `importc` -## Phase 4: AI-Native Tooling 🔄 -- [ ] File operations from REPL: `(file/read "path")`, `(file/write "path" "content")` -- [ ] Git operations from REPL: `(git/status)`, `(git/commit "msg")`, `(git/push)` +## Phase 4: AI-Native Tooling ✅ +- [x] File operations: `(file/read "path")`, `(file/write "path" "content")`, `(file/append "path" "content")` +- [x] File operations: `(file/ls "dir")`, `(file/exists? "path")` +- [x] Git operations: `(git/status)`, `(git/commit "msg")`, `(git/push)` +- [x] Git operations: `(git/diff)`, `(git/log)` - [ ] nREPL protocol compatibility - [ ] Tool-call format for AI framework integration diff --git a/examples/ai_tools.clj b/examples/ai_tools.clj new file mode 100644 index 0000000..303b151 --- /dev/null +++ b/examples/ai_tools.clj @@ -0,0 +1,33 @@ +; AI-Native Tooling Demo +; File and Git operations from Clojure + +(println "=== File Operations ===") + +; Write a file +(file/write "/tmp/ai_demo.txt" "Hello from Clojure/Nim AI!") + +; Read it back +(println (file/read "/tmp/ai_demo.txt")) + +; Append to it +(file/append "/tmp/ai_demo.txt" " Appended text.") +(println (file/read "/tmp/ai_demo.txt")) + +; Check existence +(println "Exists?" (file/exists? "/tmp/ai_demo.txt")) +(println "Missing?" (file/exists? "/tmp/nowhere.txt")) + +; List directory +(println "Files in /tmp:" (file/ls "/tmp")) + +(println "") +(println "=== Git Operations ===") + +; Show current git status +(println (git/status)) + +; Show recent commits +(println "Recent commits:" (git/log)) + +; Show diff +(println "Diff:" (git/diff))