|
1 | 1 | # lerim ask |
2 | 2 |
|
3 | | -Ask a question using accumulated memory as context. |
| 3 | +Ask a question using Lerim memory as context. |
4 | 4 |
|
5 | 5 | ## Overview |
6 | 6 |
|
7 | | -One-shot query: ask Lerim a question and get an answer informed by memories extracted from your agent sessions. |
| 7 | +`lerim ask` sends a question to the running Lerim service. The ask flow reads project memories and returns a grounded answer. |
| 8 | + |
| 9 | +Default scope is all registered projects. Use `--scope project --project ...` to narrow. |
8 | 10 |
|
9 | 11 | !!! note |
10 | | - This command requires a running Lerim server. Start it with `lerim up` (Docker) or `lerim serve` (direct). |
| 12 | + This command requires a running Lerim server (`lerim up` or `lerim serve`). |
11 | 13 |
|
12 | 14 | ## Syntax |
13 | 15 |
|
14 | 16 | ```bash |
15 | | -lerim ask <question> [--project NAME] [--json] |
| 17 | +lerim ask <question> [--scope all|project] [--project NAME] [--json] |
16 | 18 | ``` |
17 | 19 |
|
18 | 20 | ## Parameters |
19 | 21 |
|
20 | | -<div class="param-field"> |
21 | | - <div class="param-header"> |
22 | | - <span class="param-name">question</span> |
23 | | - <span class="param-type">string</span> |
24 | | - <span class="param-badge required">required</span> |
25 | | - </div> |
26 | | - <p class="param-desc">Your question (use quotes if it contains spaces).</p> |
27 | | -</div> |
28 | | - |
29 | | -<div class="param-field"> |
30 | | - <div class="param-header"> |
31 | | - <span class="param-name">--project</span> |
32 | | - <span class="param-type">string</span> |
33 | | - </div> |
34 | | - <p class="param-desc">Scope to a specific project. <strong>Note:</strong> Not yet implemented.</p> |
35 | | -</div> |
36 | | - |
37 | | -<div class="param-field"> |
38 | | - <div class="param-header"> |
39 | | - <span class="param-name">--json</span> |
40 | | - <span class="param-type">boolean</span> |
41 | | - <span class="param-badge default">default: false</span> |
42 | | - </div> |
43 | | - <p class="param-desc">Output structured JSON instead of human-readable text.</p> |
44 | | -</div> |
| 22 | +| Parameter | Default | Description | |
| 23 | +|---|---|---| |
| 24 | +| `question` | required | The question to ask | |
| 25 | +| `--scope` | `all` | Read from all projects or one project | |
| 26 | +| `--project` | -- | Project name/path when `--scope=project` | |
| 27 | +| `--json` | off | Output structured JSON payload | |
45 | 28 |
|
46 | 29 | ## Examples |
47 | 30 |
|
48 | | -### Basic question |
49 | | - |
50 | | -Ask about authentication patterns: |
51 | | - |
52 | 31 | ```bash |
53 | | -lerim ask 'What auth pattern do we use?' |
54 | | -``` |
55 | | - |
56 | | -**Output:** |
57 | | - |
58 | | -``` |
59 | | -Based on your project memories, you use bearer token authentication |
60 | | -for API requests. This pattern was chosen for its simplicity and |
61 | | -compatibility with standard HTTP clients. |
62 | | -``` |
63 | | - |
64 | | -### JSON output |
65 | | - |
66 | | -Get structured output for parsing: |
67 | | - |
68 | | -```bash |
69 | | -lerim ask "What testing framework do we use?" --json |
70 | | -``` |
71 | | - |
72 | | -**Output:** |
73 | | - |
74 | | -```json |
75 | | -{ |
76 | | - "answer": "Your project uses pytest...", |
77 | | - "agent_session_id": "4f5e0c0a-...", |
78 | | - "memories_used": [], |
79 | | - "error": false, |
80 | | - "cost_usd": 0.0012 |
81 | | -} |
| 32 | +lerim ask "Why did we choose this architecture?" |
| 33 | +lerim ask "What changed in auth recently?" --scope project --project lerim-cli |
| 34 | +lerim ask "What should I watch out for?" --json |
82 | 35 | ``` |
83 | 36 |
|
84 | 37 | ## How it works |
85 | 38 |
|
86 | | -1. Your question is sent to the running Lerim server via HTTP POST to `/api/ask` |
87 | | -2. Lerim asks the PydanticAI ask agent to scan/read relevant memory files |
88 | | -3. The model generates an answer grounded in the memory files it read |
89 | | -4. The answer is returned as plain text (or JSON with metadata using `--json`) |
90 | | - |
91 | | -!!! tip |
92 | | - For best results, ask specific questions about decisions, patterns, or procedures in your project. |
| 39 | +1. CLI posts your question to `/api/ask` |
| 40 | +2. Ask flow retrieves relevant memory files from selected scope |
| 41 | +3. Model answers using retrieved memory context |
| 42 | +4. CLI prints text (or full JSON when `--json`) |
93 | 43 |
|
94 | 44 | ## Exit codes |
95 | 45 |
|
96 | | -- **0**: Success — answer generated |
97 | | -- **1**: Error — server not running or authentication failed |
98 | | -- **2**: Usage error — invalid arguments |
| 46 | +| Code | Meaning | |
| 47 | +|---|---| |
| 48 | +| `0` | Success | |
| 49 | +| `1` | Server or provider/auth error | |
| 50 | +| `2` | Usage error | |
99 | 51 |
|
100 | 52 | ## Related commands |
101 | 53 |
|
102 | 54 | <div class="grid cards" markdown> |
103 | 55 |
|
104 | | -- :material-format-list-bulleted: **lerim memory list** |
| 56 | +- :material-chart-box: **lerim status** |
105 | 57 |
|
106 | 58 | --- |
107 | 59 |
|
108 | | - Browse stored memory files |
| 60 | + Check project streams and queue health |
109 | 61 |
|
110 | | - [:octicons-arrow-right-24: lerim memory](memory.md) |
| 62 | + [:octicons-arrow-right-24: lerim status](status.md) |
111 | 63 |
|
112 | | -- :material-chart-box: **lerim status** |
| 64 | +- :material-format-list-bulleted: **lerim memory list** |
113 | 65 |
|
114 | 66 | --- |
115 | 67 |
|
116 | | - Check server status |
| 68 | + List memory files in scope |
117 | 69 |
|
118 | | - [:octicons-arrow-right-24: lerim status](status.md) |
| 70 | + [:octicons-arrow-right-24: lerim memory](memory.md) |
119 | 71 |
|
120 | 72 | </div> |
121 | | - |
122 | | -## Notes |
123 | | - |
124 | | -- Ask uses memory scan/read tools to ground its answers in local memory files |
125 | | -- If provider auth fails (missing API key), the CLI returns exit code 1 |
126 | | -- The `--project` flag is reserved for future project-scoped queries |
0 commit comments