elixir: add package README with hex.pm install instructions
Swadhin Biswas committed 7 months ago
8b2dcda
1 parent fcd1d5c
commit 8b2dcda
1 file changed
+76 -0
Showing 1 changed file+76-0
▼ELIXIR/README.md
+76-0
| @@ -0,0 +1,76 @@ | ||
1 | +# contexa — Elixir | |
2 | + | |
3 | +Git-inspired context management for LLM agents — **COMMIT**, **BRANCH**, **MERGE**, and **CONTEXT** operations over a persistent versioned memory workspace. | |
4 | + | |
5 | +Based on the paper *"Git Context Controller: Manage the Context of LLM-based Agents like Git"* ([arXiv:2508.00031](https://arxiv.org/abs/2508.00031)). | |
6 | + | |
7 | +## Install | |
8 | + | |
9 | +Add to your `mix.exs`: | |
10 | + | |
11 | +```elixir | |
12 | +def deps do | |
13 | + [ | |
14 | + {:contexa, "~> 0.1.1"} | |
15 | + ] | |
16 | +end | |
17 | +``` | |
18 | + | |
19 | +## Quick Start | |
20 | + | |
21 | +```elixir | |
22 | +alias Contexa.{Workspace, Models} | |
23 | + | |
24 | +# Create workspace | |
25 | +ws = Workspace.new("/tmp/my-project") | |
26 | +ws = Workspace.init(ws, "Build an AI agent") | |
27 | + | |
28 | +# Log observations | |
29 | +{ws, _ota} = Workspace.log_ota(ws, "User asked about weather", "Need to call API", "Called weather API") | |
30 | + | |
31 | +# Commit milestone | |
32 | +{ws, _commit} = Workspace.commit(ws, "Implemented weather lookup") | |
33 | + | |
34 | +# Branch for exploration | |
35 | +ws = Workspace.branch(ws, "alt-approach", "Try different API") | |
36 | +{ws, _ota} = Workspace.log_ota(ws, "Testing new API", "Seems faster", "Switched to new API") | |
37 | +{ws, _commit} = Workspace.commit(ws, "New API integration") | |
38 | + | |
39 | +# Merge back | |
40 | +{ws, _merge} = Workspace.merge(ws, "alt-approach", nil, "main") | |
41 | + | |
42 | +# Retrieve context | |
43 | +ctx = Workspace.context(ws, "main", 3) | |
44 | +IO.puts(Models.context_summary(ctx)) | |
45 | +``` | |
46 | + | |
47 | +## API | |
48 | + | |
49 | +### `Contexa.Workspace` | |
50 | + | |
51 | +| Function | Description | | |
52 | +|----------|-------------| | |
53 | +| `new(root)` | Create workspace handle | | |
54 | +| `init(ws, roadmap \\ "")` | Initialize `.GCC/` directory | | |
55 | +| `load(ws)` | Attach to existing workspace | | |
56 | +| `log_ota(ws, obs, thought, action)` | Append OTA record | | |
57 | +| `commit(ws, contribution, prev \\ nil, roadmap \\ nil)` | Create milestone commit | | |
58 | +| `branch(ws, name, purpose)` | Create isolated branch | | |
59 | +| `merge(ws, branch, summary \\ nil, target \\ "main")` | Merge branch into target | | |
60 | +| `context(ws, branch \\ nil, k \\ 1)` | Retrieve hierarchical context | | |
61 | +| `switch_branch(ws, name)` | Switch active branch | | |
62 | +| `list_branches(ws)` | List all branches | | |
63 | + | |
64 | +### Functional Style | |
65 | + | |
66 | +The Elixir implementation uses a functional approach — workspace state is an immutable struct returned from each operation: | |
67 | + | |
68 | +```elixir | |
69 | +ws = Workspace.new("/tmp/project") |> Workspace.init() | |
70 | +{ws, _} = Workspace.log_ota(ws, "obs", "thought", "action") | |
71 | +{ws, _} = Workspace.commit(ws, "milestone") | |
72 | +``` | |
73 | + | |
74 | +## License | |
75 | + | |
76 | +MIT | |
0 | 77 | |