@tyvm/knowhow 0.0.109 → 0.0.111

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 (108) hide show
  1. package/autodoc/README.md +324 -0
  2. package/autodoc/chat-guide.md +268 -365
  3. package/autodoc/cli-reference.md +399 -473
  4. package/autodoc/config-reference.md +431 -330
  5. package/autodoc/embeddings-guide.md +223 -322
  6. package/autodoc/generate-guide.md +261 -301
  7. package/autodoc/language-plugin-guide.md +221 -247
  8. package/autodoc/modules-guide.md +242 -215
  9. package/autodoc/plugins-guide.md +470 -469
  10. package/autodoc/quickstart-guide.md +67 -70
  11. package/autodoc/skills-guide.md +455 -339
  12. package/autodoc/worker-guide.md +301 -308
  13. package/package.json +1 -1
  14. package/scripts/build-for-node.sh +10 -24
  15. package/src/agents/tools/list.ts +2 -2
  16. package/src/ai.ts +81 -37
  17. package/src/auth/browserLogin.ts +129 -3
  18. package/src/chat/CliChatService.ts +1 -1
  19. package/src/chat/modules/AgentModule.ts +7 -2
  20. package/src/chat/modules/SessionsModule.ts +40 -1
  21. package/src/chat/modules/SystemModule.ts +2 -2
  22. package/src/clients/anthropic.ts +1 -1
  23. package/src/clients/index.ts +25 -6
  24. package/src/clients/openai.ts +8 -5
  25. package/src/clients/types.ts +29 -6
  26. package/src/clients/withRetry.ts +89 -0
  27. package/src/commands/agent.ts +30 -0
  28. package/src/commands/modules.ts +417 -47
  29. package/src/config.ts +1 -1
  30. package/src/fileSync.ts +20 -12
  31. package/src/hashes.ts +43 -22
  32. package/src/index.ts +4 -2
  33. package/src/login.ts +3 -2
  34. package/src/processors/Base64ImageDetector.ts +73 -0
  35. package/src/services/Mcp.ts +14 -1
  36. package/src/services/MediaProcessorService.ts +79 -10
  37. package/src/services/modules/index.ts +47 -18
  38. package/src/utils/http.ts +9 -2
  39. package/tests/processors/Base64ImageDetector.test.ts +160 -0
  40. package/tests/unit/clients/AIClient.test.ts +446 -0
  41. package/tests/unit/clients/withRetry.test.ts +319 -0
  42. package/tests/unit/commands/github-credentials.test.ts +1 -2
  43. package/ts_build/package.json +1 -1
  44. package/ts_build/src/agents/tools/list.js +2 -2
  45. package/ts_build/src/agents/tools/list.js.map +1 -1
  46. package/ts_build/src/ai.d.ts +3 -3
  47. package/ts_build/src/ai.js +51 -23
  48. package/ts_build/src/ai.js.map +1 -1
  49. package/ts_build/src/auth/browserLogin.d.ts +2 -0
  50. package/ts_build/src/auth/browserLogin.js +91 -3
  51. package/ts_build/src/auth/browserLogin.js.map +1 -1
  52. package/ts_build/src/chat/CliChatService.js +1 -1
  53. package/ts_build/src/chat/CliChatService.js.map +1 -1
  54. package/ts_build/src/chat/modules/AgentModule.js +5 -2
  55. package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
  56. package/ts_build/src/chat/modules/SessionsModule.js +30 -1
  57. package/ts_build/src/chat/modules/SessionsModule.js.map +1 -1
  58. package/ts_build/src/chat/modules/SystemModule.js +2 -2
  59. package/ts_build/src/chat/modules/SystemModule.js.map +1 -1
  60. package/ts_build/src/clients/anthropic.js +1 -1
  61. package/ts_build/src/clients/anthropic.js.map +1 -1
  62. package/ts_build/src/clients/index.js +7 -6
  63. package/ts_build/src/clients/index.js.map +1 -1
  64. package/ts_build/src/clients/openai.js +4 -4
  65. package/ts_build/src/clients/openai.js.map +1 -1
  66. package/ts_build/src/clients/types.d.ts +12 -6
  67. package/ts_build/src/clients/withRetry.d.ts +2 -0
  68. package/ts_build/src/clients/withRetry.js +60 -0
  69. package/ts_build/src/clients/withRetry.js.map +1 -0
  70. package/ts_build/src/commands/agent.js +25 -0
  71. package/ts_build/src/commands/agent.js.map +1 -1
  72. package/ts_build/src/commands/modules.js +359 -32
  73. package/ts_build/src/commands/modules.js.map +1 -1
  74. package/ts_build/src/config.js +1 -1
  75. package/ts_build/src/config.js.map +1 -1
  76. package/ts_build/src/fileSync.d.ts +2 -2
  77. package/ts_build/src/fileSync.js +13 -11
  78. package/ts_build/src/fileSync.js.map +1 -1
  79. package/ts_build/src/hashes.d.ts +2 -2
  80. package/ts_build/src/hashes.js +40 -16
  81. package/ts_build/src/hashes.js.map +1 -1
  82. package/ts_build/src/index.js +1 -1
  83. package/ts_build/src/index.js.map +1 -1
  84. package/ts_build/src/login.js +2 -2
  85. package/ts_build/src/login.js.map +1 -1
  86. package/ts_build/src/processors/Base64ImageDetector.d.ts +3 -0
  87. package/ts_build/src/processors/Base64ImageDetector.js +42 -0
  88. package/ts_build/src/processors/Base64ImageDetector.js.map +1 -1
  89. package/ts_build/src/services/Mcp.js +9 -1
  90. package/ts_build/src/services/Mcp.js.map +1 -1
  91. package/ts_build/src/services/MediaProcessorService.d.ts +5 -4
  92. package/ts_build/src/services/MediaProcessorService.js +53 -8
  93. package/ts_build/src/services/MediaProcessorService.js.map +1 -1
  94. package/ts_build/src/services/modules/index.js +35 -12
  95. package/ts_build/src/services/modules/index.js.map +1 -1
  96. package/ts_build/src/utils/http.d.ts +2 -1
  97. package/ts_build/src/utils/http.js +11 -2
  98. package/ts_build/src/utils/http.js.map +1 -1
  99. package/ts_build/tests/processors/Base64ImageDetector.test.js +111 -0
  100. package/ts_build/tests/processors/Base64ImageDetector.test.js.map +1 -1
  101. package/ts_build/tests/unit/clients/AIClient.test.d.ts +1 -0
  102. package/ts_build/tests/unit/clients/AIClient.test.js +339 -0
  103. package/ts_build/tests/unit/clients/AIClient.test.js.map +1 -0
  104. package/ts_build/tests/unit/clients/withRetry.test.d.ts +1 -0
  105. package/ts_build/tests/unit/clients/withRetry.test.js +225 -0
  106. package/ts_build/tests/unit/clients/withRetry.test.js.map +1 -0
  107. package/ts_build/tests/unit/commands/github-credentials.test.js +1 -2
  108. package/ts_build/tests/unit/commands/github-credentials.test.js.map +1 -1
@@ -1,540 +1,443 @@
1
1
  # `knowhow chat` Guide
2
2
 
3
- `knowhow chat` is the primary interactive interface for the **Knowhow CLI**. It runs a REPL-style chat loop where you type messages and can control behavior using **slash commands** (`/…`).
4
-
5
- At startup, Knowhow typically prints a list of available commands based on:
6
- - enabled chat modules (agent/search/sessions/shell/voice/etc.)
7
- - your configuration (`knowhow.json`)
8
- - the current chat mode (agent vs attached vs voice)
9
-
10
- > **Tip:** Always look at the startup line like `Commands: /agent, /agents, ...` to confirm what your build exposes.
3
+ `knowhow chat` is the primary interactive terminal experience for Knowhow. You’ll start a chat loop, then use built-in slash commands (`/…`) to control agents, sessions, rendering, input modes, and more.
11
4
 
12
5
  ---
13
6
 
14
- ## 1) Starting a chat session
7
+ ## 1) Start a chat session
15
8
 
16
- Start chat with:
9
+ Start Knowhow’s interactive chat:
17
10
 
18
11
  ```bash
19
12
  knowhow chat
20
13
  ```
21
14
 
22
- You then enter a prompt loop where you can type normal messages or slash commands.
23
-
24
- ### Common CLI flags (version/build-dependent)
25
- Your exact flags depend on the CLI build. Check:
26
-
27
- ```bash
28
- knowhow chat --help
29
- ```
30
-
31
- Common patterns you may see include:
32
- - selecting a starting **agent**
33
- - selecting a **renderer**
34
- - enabling **voice**
35
- - attaching/resuming a prior session/task (if your build supports it)
15
+ After starting, Knowhow will show the available commands for the current mode.
36
16
 
37
- Examples (illustrative—verify with `--help`):
38
- ```bash
39
- knowhow chat --agent Patcher
40
- knowhow chat --renderer compact
41
- knowhow chat --voice
42
- ```
17
+ > Tip: While chatting, you can usually discover functionality from `/` commands (documented below). If you’re ever unsure, run:
18
+ >
19
+ > ```bash
20
+ > knowhow chat --help
21
+ > ```
43
22
 
44
23
  ---
45
24
 
46
- ## 2) Chat modes (agent, attached, voice)
47
-
48
- Knowhow changes behavior based on mode. Mode determines:
49
- - how inputs are interpreted
50
- - which slash commands are enabled
51
- - whether you’re controlling a running task (attached) vs just chatting
25
+ ## 2) Chat modes (what changes with `/...`)
52
26
 
53
- ### Agent mode
54
- You’re using a configured agent to respond.
27
+ Knowhow’s CLI chat behavior changes based on active modes.
55
28
 
56
- In this mode, commands like `/agent`, `/agents`, `/render`, `/search`, `/multi`, etc. are usually available.
29
+ ### Default (normal) chat
30
+ - You send plain text (no leading `/`) and Knowhow responds as a standard assistant.
31
+ - Agent mode is **off** until you enable it with `/agent`.
57
32
 
58
- ### Attached mode (`agent:attached`)
59
- In attached mode, Knowhow is connected to a running agent task/session and you can inspect/steer it using attached-only commands (if provided by your agent module).
33
+ ### Agent mode: `/agent` (agent interaction mode)
34
+ When you enable agent mode:
35
+ - Your prompt becomes: `Ask knowhow <AgentName>:`
36
+ - Your input becomes an initial task for that agent.
37
+ - The agent streams events into the active renderer.
60
38
 
61
- ### Voice mode
62
- If voice is available in your build, voice mode switches input handling so speech is transcribed and sent into the chat loop.
39
+ Command:
40
+ - `/agent <agent_name>`
63
41
 
64
- ---
42
+ ### Agent attached mode: `/attach` (agent:attached)
43
+ When you attach to a running task/session:
44
+ - You’re “attached” to a specific agent task that’s already running.
45
+ - Mode switches to `agent:attached`, unlocking attached-mode commands like:
46
+ - `/logs`, `/pause`, `/unpause`, `/kill`, `/detach`, `/done`
65
47
 
66
- ## 3) Built-in slash commands (`/…`)
48
+ Commands:
49
+ - `/attach <taskId>`
50
+ - `/resume <taskId>` (for completed/saved sessions)
67
51
 
68
- Below is the command reference for the commands known to be implemented by the chat modules in the Knowhow codebase (agent/search/sessions/renderer/shell/voice modules).
69
- If your `Commands:` list includes additional items, use those as well—modules register commands at runtime.
52
+ ### Voice mode: `/voice`
53
+ When voice mode is enabled:
54
+ - Input comes from `voiceToText()` instead of the normal text prompt.
55
+ - Mode affects how the CLI collects your next user input.
70
56
 
71
- ### Agent switching
72
- - **`/agent <name>`** — switch to a specific configured agent
73
- **Example**
74
- ```text
75
- /agent Patcher
76
- ```
57
+ Command:
58
+ - `/voice`
77
59
 
78
- - **`/agents`** — list configured agents (and/or selection help)
79
- **Example**
80
- ```text
81
- /agents
82
- ```
60
+ ### Multi-line mode: `/multi`
61
+ When multi-line mode is enabled:
62
+ - Input is collected using a text editor UI (via Inquirer’s editor).
63
+ - After submitting, multiline mode is reset.
83
64
 
84
- > In attached mode, some agent-control commands may be restricted to attached mode only (see below).
65
+ Command:
66
+ - `/multi`
85
67
 
86
- ### Attached-mode controls (if provided by your agent module)
87
- These commands are typically only enabled when you are attached to a running agent task:
68
+ ---
88
69
 
89
- - **`/pause`** pause the attached agent
90
- - **`/unpause`** — resume the attached agent
91
- - **`/kill`** terminate the attached agent task (and typically detach)
92
- - **`/detach`** — detach from the attached agent task
93
- - **`/done`** — finish/exit the current attached interaction
70
+ ## 3) Built-in slash commands (`/`)
71
+
72
+ The following commands are available from the CLI modules shown in the code. (Additional commands may exist in other modules or via custom command modules/plugins.)
73
+
74
+ ### Agent controls
75
+ | Command | Description | Mode |
76
+ |---|---|---|
77
+ | `/agent <agent_name>` | Enable agent mode and select an agent | default / non-agent |
78
+ | `/agents` | List available agents, then optionally select one | default / non-agent |
79
+ | `/pause` | Pause the attached agent | `agent:attached` |
80
+ | `/unpause` | Unpause the attached agent | `agent:attached` |
81
+ | `/kill` | Terminate the attached agent | `agent:attached` |
82
+ | `/detach` | Detach from the attached agent task (leaves agent running) | `agent:attached` |
83
+ | `/done` | Exit the current agent interaction (detaches) | `agent:attached` |
84
+
85
+ ### Session / attachment management
86
+ | Command | Description | Mode |
87
+ |---|---|---|
88
+ | `/attach [taskId]` | Attach to a running session/task | any (but useful in agent workflows) |
89
+ | `/resume [taskId]` | Resume a completed/saved session | any |
90
+ | `/sessions` | List sessions (running + optionally completed) | any |
91
+ | `/logs [N]` | Show the last N messages from the attached agent (default `N=20`) | `agent:attached` |
92
+
93
+ Important flags for these commands:
94
+ - `/attach --completed` : show saved/completed sessions in addition to running ones
95
+ - `/sessions --completed` or `/sessions --all`
96
+ - `/sessions --csv` : output sessions as CSV
97
+
98
+ ### Shell execution (command helpers)
99
+ | Command | Description | Mode |
100
+ |---|---|---|
101
+ | `/! <command>` | Execute a shell command (interactive: inherits stdio) | `agent` / `agent:attached` |
102
+ | `/!! <command>` | Execute a shell command, then send its output to the AI | `agent` / `agent:attached` |
103
+
104
+ ### Renderer switching
105
+ | Command | Description | Mode |
106
+ |---|---|---|
107
+ | `/render [specifier]` | Switch output renderer, or show current renderer + built-ins | any |
108
+
109
+ Built-in renderers:
110
+ - `basic`
111
+ - `compact`
112
+ - `fancy`
113
+
114
+ Also supports:
115
+ - a filesystem path (e.g. `./my-renderer.js`)
116
+ - a package name (e.g. `@my-org/knowhow-renderer`)
117
+
118
+ ### Input / chat behavior
119
+ | Command | Description | Mode |
120
+ |---|---|---|
121
+ | `/multi` | Toggle multiline input mode | any |
122
+ | `/voice` | Toggle voice input mode | any |
123
+ | `/exit` | Exit the chat process | any |
124
+
125
+ ### Model / provider / debug / history
126
+ | Command | Description | Mode |
127
+ |---|---|---|
128
+ | `/model` | Select a model for the active context (and update active agent prefs) | any |
129
+ | `/provider` | Select a provider (and update active agent prefs) | any |
130
+ | `/debug` | Toggle debug mode | any |
131
+ | `/clear` | Clear chat history (AI will not remember previous messages) | any |
94
132
 
95
- **Examples**
96
- ```text
97
- /pause
98
- /unpause
99
- /detach
100
- /done
101
- ```
133
+ ### Search
134
+ | Command | Description | Mode |
135
+ |---|---|---|
136
+ | `/search` | Search embeddings interactively | any |
102
137
 
103
- ### Multi-line input
104
- - **`/multi`** — start a multi-line input editor for your *next* message (or until you exit the editor, depending on implementation)
138
+ Inside embedding search, it uses non-slash commands:
139
+ - `next`, `exit`, `embeddings`, `use`
105
140
 
106
- **Example**
107
- ```text
108
- /multi
109
- Write a runbook for:
110
- 1) Setup
111
- 2) Daily use
112
- 3) Troubleshooting
141
+ ### Notes about other commands
142
+ Some commands referenced in fuzzy-match logic (like `help`) may exist in modules not included in the provided code excerpts. If your build includes more modules, run `knowhow chat` and look at the “Commands:” line that appears at startup and updates per mode.
113
143
 
114
- Include a checklist.
115
- ```
144
+ ---
116
145
 
117
- ### Rendering control
118
- - **`/render`** — show current renderer / help for renderer switching
119
- - **`/render <basic|compact|fancy>`** — switch built-in renderer
146
+ ## 4) Switching agents (`/agent` and `/agents`)
120
147
 
121
- **Examples**
148
+ ### List agents
122
149
  ```text
123
- /render basic
124
- /render compact
125
- /render fancy
150
+ /agents
126
151
  ```
127
152
 
128
- #### Custom renderer support (from the renderer module)
129
- Depending on build support, `/render` may also load a renderer from:
130
- - a path
131
- - an npm package specifier
153
+ Knowhow prints available agent names, then prompts:
132
154
 
133
- **Examples**
134
155
  ```text
135
- /render ./my-renderer.js
136
- /render @my-org/knowhow-renderer
156
+ Select an agent to start:
137
157
  ```
138
158
 
139
- ### Search
140
- - **`/search`** — enter the interactive search loop (Search module)
141
-
142
- **Example**
159
+ ### Start a specific agent
143
160
  ```text
144
- /search
161
+ /agent Researcher
145
162
  ```
146
163
 
147
- #### Inside `/search` (interactive sub-commands)
148
- Within the search loop, Knowhow accepts:
149
-
150
- - **`next`** show the next result
151
- - **`exit`** — leave search mode
152
- - **`embeddings`** — list available embedding scopes
153
- - **`use`** — choose which embedding scope(s) to search
154
-
155
- Any other input is treated as a new search query.
164
+ When successful:
165
+ - agent mode is enabled
166
+ - your prompt changes to `Ask knowhow Researcher:`
167
+ - the agent begins a task when you type input (non-command text)
156
168
 
157
- **Example session**
169
+ ### Example: switch agents in one session
158
170
  ```text
159
- /search
160
- searching: "postgres query planner tuning"
171
+ > /agents
172
+ Available agents:
173
+ - Patcher
174
+ - Researcher
175
+ - DevOpsBot
176
+ ────────────────────────────────────────────────
161
177
 
162
- ### TEXT
163
- ...match content...
178
+ Select an agent to start: Researcher
164
179
 
165
- ### METADATA
166
- { "source": "...", "chunk": 12 }
180
+ Agent mode enabled. Selected agent: Researcher. Type your task to get started.
167
181
 
168
- searching: next
169
- ### TEXT
170
- ...next match...
171
-
172
- searching: use
173
- Embedding to search: snippets
174
- searching: "how to configure agents"
175
- (search results...)
176
- searching: exit
182
+ Ask knowhow Researcher: Summarize the latest changes in X.
177
183
  ```
178
184
 
179
- ### Session management (attach/resume/logs and listing)
180
- These are implemented by the Sessions module.
185
+ To switch again:
186
+ - start another agent with `/agent <name>` (or disable agent mode by `/agent` with no args—see next tip)
181
187
 
182
- - **`/attach [taskId] [--completed]`**
183
- - With **no args**, opens an interactive selection of attachable sessions/tasks.
184
- - With `<taskId>`, attaches directly.
185
- - `--completed` may include completed items in the chooser; completed items are routed to **`/resume`**.
188
+ ### Disable agent mode
189
+ In `AgentModule.handleAgentCommand`, `/agent` with **no arguments** toggles agent mode off (only if agent mode is already active):
186
190
 
187
- **Examples**
188
191
  ```text
189
- /attach
190
- /attach 8d9f1c2b-3a4e-...
191
- /attach --completed
192
+ /agent
192
193
  ```
193
194
 
194
- - **`/resume [taskId]`**
195
- - With **no args**, opens an interactive list of saved/completed sessions to resume.
196
- - With `<taskId>`, resumes that session.
197
- - When resuming, Knowhow can prompt you to add additional context.
198
-
199
- **Examples**
200
- ```text
201
- /resume
202
- /resume 8d9f1c2b-3a4e-...
203
- ```
204
-
205
- - **`/sessions [--all] [--completed] [--csv]`**
206
- Lists sessions/tasks so you can choose to attach or resume.
207
-
208
- - `--completed` includes completed sessions
209
- - `--all` includes more history/scope (implementation-defined)
210
- - `--csv` outputs table data in CSV format
211
-
212
- **Examples**
213
- ```text
214
- /sessions
215
- /sessions --completed
216
- /sessions --completed --csv
217
- ```
218
-
219
- - **`/logs [N]`**
220
- Shows the last **N** messages from the **currently attached** agent (default `N=20`).
221
- Typically restricted to **attached mode**.
222
-
223
- **Examples**
224
- ```text
225
- /logs
226
- /logs 50
227
- ```
228
-
229
- > **Note on “save/load”:** the Sessions module primarily exposes **attach** (running tasks) and **resume** (completed/saved tasks). If your build includes explicit `save/load` subcommands under `/sessions`, they will appear in your runtime `Commands:` list or via `/sessions` help.
230
-
231
- ### Shell commands
232
- These are provided by the shell module and work in agent/attached modes where enabled.
233
-
234
- - **`/! [command]`** — run shell commands interactively (module behavior may vary)
235
- - **`/!! <command>`** — run a shell command, capture output, and send it to the AI for analysis
195
+ ---
236
196
 
237
- **Examples**
238
- ```text
239
- /!
240
- # (interactive shell mode, if your build uses it)
197
+ ## 5) Multi-line input (`/multi`)
241
198
 
242
- /!! ls -la
243
- /!! cat ./build.log | tail -n 200
244
- ```
199
+ Toggle multi-line mode:
245
200
 
246
- **Typical workflow**
247
201
  ```text
248
- /!
249
- npm test
250
- /!!
251
- npm test
252
- # then ask the AI to explain failures based on captured output
202
+ /multi
253
203
  ```
254
204
 
255
- ### Voice input (if available)
256
- If your build includes voice support, the Voice module typically exposes a command like:
205
+ Then enter a task in a multi-line editor UI.
257
206
 
258
- - **`/voice`** toggle voice mode on/off
207
+ After you submit the edited content:
208
+ - the CLI disables multiline mode automatically (`multilineMode = false` after use)
259
209
 
260
- **Example**
210
+ Example workflow:
261
211
  ```text
262
- /voice
263
- ```
212
+ > /multi
213
+ Multiline mode: enabled
264
214
 
265
- If `/voice` isn’t present, voice may be controlled only via CLI flags—check:
266
- ```bash
267
- knowhow chat --help
215
+ > (editor opens)
216
+ Write a detailed plan for migrating service A to service B:
217
+ - include risks
218
+ - include rollback steps
219
+ - include timeline
268
220
  ```
269
221
 
270
222
  ---
271
223
 
272
- ## 4) Switching agents (`/agent` and `/agents`)
224
+ ## 6) Shell commands (`/!` and `/!!`)
273
225
 
274
- ### List agents
275
- ```text
276
- /agents
277
- ```
226
+ These commands exist specifically to help you run local shell work while an agent is active.
278
227
 
279
- ### Switch to a configured agent
280
- ```text
281
- /agent <AgentName>
282
- ```
228
+ ### `/!` interactive execution
229
+ Runs a shell command and uses inherited stdio (so interactive prompts work):
283
230
 
284
- **Example**
285
231
  ```text
286
- /agents
287
- /agent Researcher
288
- Summarize the tradeoffs between two approaches...
232
+ /! ls -la
289
233
  ```
290
234
 
291
- > If you attach/resume a session, Knowhow may also restore the session’s agent context (when the agent still exists in your `knowhow.json`).
292
-
293
- ---
294
-
295
- ## 5) Multi-line input (`/multi`)
296
-
297
- Use `/multi` when you want to paste structured content (requirements, logs, code blocks, JSON/YAML).
235
+ ### `/!!` send output to the AI
236
+ Runs a command, captures its output, and sends that output to the agent as message content.
298
237
 
299
- **Example**
300
238
  ```text
301
- /multi
302
- Create a step-by-step plan to debug a failing CI job.
303
-
304
- Input:
305
- - command I ran:
306
- - relevant log excerpt:
307
- - what I already tried:
308
-
309
- Output:
310
- - hypotheses
311
- - commands to verify
312
- - minimal fix suggestions
239
+ /!! cat package.json
313
240
  ```
314
241
 
315
- ---
316
-
317
- ## 6) Shell commands (`/!` and `/!!`)
318
-
319
- ### `/!` — interactive shell
320
- Use `/!` to run shell commands in an interactive way (depending on your build). For some builds, `/!` may also accept a command directly.
242
+ The command output will be wrapped and forwarded to the agent like:
321
243
 
322
- **Example**
323
244
  ```text
324
- /!
325
- ls -la
326
- cat package.json
245
+ Command output from `cat package.json`:
246
+ <output...>
327
247
  ```
328
248
 
329
- ### `/!!` send shell output to the AI
330
- Use `/!!` when you want Knowhow to *capture* command output and include it in the AI context.
331
-
332
- **Example**
249
+ ### Example: use shell output to guide an agent
333
250
  ```text
334
- /!! npm test --silent
335
- ```
251
+ > /agent Patcher
252
+ Agent mode enabled. Selected agent: Patcher. Type your task to get started.
336
253
 
337
- Then ask:
338
- ```text
339
- What caused the failure, and what minimal changes should I make?
340
- ```
254
+ Ask knowhow Patcher: Inspect the repo and patch any failing tests.
341
255
 
342
- > **Safety note:** Shell commands run on your machine. Be careful with commands that modify or delete files.
256
+ Ask knowhow Patcher: /!! npm test
257
+ ```
343
258
 
344
259
  ---
345
260
 
346
- ## 7) Session management (attach/resume and listing)
261
+ ## 7) Session management (attach/resume + session persistence)
262
+
263
+ Knowhow supports continuing work across time and processes by saving agent session state.
347
264
 
348
- Think of sessions in two categories:
349
- - **Attach** to a **running** task/taskId
350
- - **Resume** a **completed/saved** task/taskId
265
+ ### Key concepts
266
+ - **Running tasks** can be attached to with `/attach`.
267
+ - **Completed/saved sessions** can be resumed with `/resume`.
268
+ - Session metadata may also exist on disk under agent process directories (used for filesystem-backed attachments).
351
269
 
352
- ### List sessions/tasks
270
+ ### List sessions
353
271
  ```text
354
272
  /sessions
355
273
  ```
356
274
 
357
- Include completed items:
358
- ```text
359
- /sessions --completed
360
- ```
275
+ Options:
276
+ - `/sessions --completed` : include saved/completed
277
+ - `/sessions --all` : include more historical sessions
278
+ - `/sessions --csv` : CSV output
361
279
 
362
- CSV output:
280
+ ### Attach to a running task
363
281
  ```text
364
- /sessions --completed --csv
282
+ /attach <taskId>
365
283
  ```
366
284
 
367
- ### Attach to a running task
285
+ Or interactively:
368
286
  ```text
369
287
  /attach
370
288
  ```
371
289
 
372
- Direct attach:
290
+ The session list can include filesystem/web tasks, depending on what’s available.
291
+
292
+ ### Resume a completed session
373
293
  ```text
374
- /attach <taskId>
294
+ /resume <taskId>
375
295
  ```
376
296
 
377
- ### Resume a saved/completed session
378
- Resume interactively:
297
+ Or interactively:
379
298
  ```text
380
299
  /resume
381
300
  ```
382
301
 
383
- Resume by id:
384
- ```text
385
- /resume <taskId>
386
- ```
302
+ You’ll be prompted to add additional context for resuming.
387
303
 
388
- ### View logs from attached agent
389
- ```text
390
- /attach <taskId>
391
- /logs
392
- ```
304
+ ### Attach/detach during `agent:attached`
305
+ While attached:
306
+ - `/detach` detaches from the running task
307
+ - `/done` exits interaction (detaches)
393
308
 
394
309
  ---
395
310
 
396
- ## 8) Renderers (basic, compact, fancy) and switching with `/render`
311
+ ## 8) Renderers (`/render`)
397
312
 
398
- Use renderers to change how output appears in your terminal.
313
+ Knowhow can change how messages/events are displayed.
399
314
 
400
- ### Switch renderer
315
+ ### Built-in renderers
316
+ `/render` shows:
317
+ - Current renderer
318
+ - Built-ins: `basic`, `compact`, `fancy`
319
+
320
+ Switch to a built-in:
401
321
  ```text
402
- /render basic
403
322
  /render compact
404
- /render fancy
405
323
  ```
406
324
 
407
- ### Custom renderers (if supported)
325
+ ### Example: show renderer info
408
326
  ```text
409
- /render ./my-renderer.js
410
- /render @my-org/knowhow-renderer
327
+ /render
411
328
  ```
412
329
 
413
- **Example flow**
414
- ```text
415
- /render compact
416
- Write release notes for version 1.4.2 based on these changes:
417
- (multi-line text...)
418
- ```
330
+ ### Switching while an agent is running
331
+ When you switch renderers:
332
+ - the CLI preserves the active task id (if one exists)
333
+ - agent event wiring is rewired so live agent output continues to render in the new renderer
419
334
 
420
335
  ---
421
336
 
422
- ## 9) Voice input (if available)
423
-
424
- If voice is enabled in your build, toggle voice mode with:
337
+ ## 9) Voice input (`/voice`)
425
338
 
339
+ Enable voice mode:
426
340
  ```text
427
341
  /voice
428
342
  ```
429
343
 
430
- Then speak your prompt. Knowhow will transcribe and send it into the same pipeline as typed input.
344
+ When enabled, the next input prompt is satisfied by calling `voiceToText()` (microphone integration). If voice input fails or isn’t configured, you may get an empty string / an error.
431
345
 
432
- If `/voice` isn’t available, use startup flags (check `knowhow chat --help`).
346
+ Disable it again:
347
+ ```text
348
+ /voice
349
+ ```
433
350
 
434
351
  ---
435
352
 
436
- ## 10) Custom agents (`knowhow.json` → `agents` array)
353
+ ## 10) Custom agents (configure in `knowhow.json`)
437
354
 
438
- You can define custom agents in `knowhow.json` under an `agents` array.
355
+ Custom agents are loaded as agent constructors (used by `/agent` and `/agents`). In this guide, custom agents are configured in `knowhow.json` under an `agents` array.
439
356
 
440
- ### Example `knowhow.json` with custom agents
357
+ > ⚠️ The exact schema of your agent config can depend on your Knowhow version and agent implementation. The examples below show the typical structure and the most important part: the **agent name** you will use with `/agent <name>`.
441
358
 
359
+ ### Example `knowhow.json` with custom agents
442
360
  ```json
443
361
  {
444
362
  "agents": [
445
363
  {
446
- "name": "Patcher",
447
- "description": "Edits code safely and provides patch-style output.",
448
- "model": "gpt-4.1-mini",
364
+ "name": "ResearcherPro",
449
365
  "provider": "openai",
450
- "tools": ["repo", "diff", "tests"],
451
- "systemPrompt": "You are a careful code patcher. Make minimal changes, explain reasoning, and include a test plan."
366
+ "model": "gpt-5.4-nano",
367
+ "systemPrompt": "You are a rigorous research agent. Provide sourced, structured answers.",
368
+ "tools": ["search", "render", "code-execution"]
452
369
  },
453
370
  {
454
- "name": "Researcher",
455
- "description": "Focuses on explanation, tradeoffs, and decision guidance.",
456
- "model": "gpt-4.1-mini",
457
- "provider": "openai",
458
- "tools": ["web", "search"],
459
- "systemPrompt": "You are a research assistant. Provide sourced tradeoffs and clear recommendations."
371
+ "name": "PatchMaster",
372
+ "provider": "anthropic",
373
+ "model": "sonnet-4-6",
374
+ "systemPrompt": "You are an expert software patching agent. Be precise and safe.",
375
+ "tools": ["askHuman", "file-edit", "diff-preview"]
460
376
  }
461
377
  ]
462
378
  }
463
379
  ```
464
380
 
465
- ### Use your custom agents in chat
381
+ ### Using your custom agent
382
+ After updating `knowhow.json`, restart Knowhow and run:
383
+
466
384
  ```text
467
385
  /agents
468
- /agent Researcher
469
- Ask knowhow: What are the tradeoffs between approach A and approach B?
386
+ /agent ResearcherPro
470
387
  ```
471
388
 
472
- > **Field names can vary by version/build.** The key requirement is that each agent has a unique **`name`** so it can be selected via `/agent <name>`.
389
+ Then provide your task as normal text (non-slash).
473
390
 
474
391
  ---
475
392
 
476
- ## Practical examples
393
+ ## End-to-end examples
477
394
 
478
- ### Example A: Switch agent + compact renderer + normal prompt
395
+ ### Example A: Start an agent and run work
479
396
  ```text
480
- /agents
481
- /agent Researcher
482
- /render compact
483
- Summarize the pros/cons of using RAG vs fine-tuning for my product.
397
+ > /agent Patcher
398
+ Agent mode enabled. Selected agent: Patcher. Type your task to get started.
399
+
400
+ Ask knowhow Patcher: Fix the failing unit test in the repo.
484
401
  ```
485
402
 
486
- ### Example B: Multi-line spec
403
+ ### Example B: Run a shell command and feed output to the agent
487
404
  ```text
488
- /multi
489
- You are helping me design a CLI command system.
490
-
491
- Requirements:
492
- - Commands begin with `/`
493
- - Support agent switching
494
- - Include rendering and sessions
495
-
496
- Return:
497
- 1) Proposed architecture
498
- 2) Command registry design
499
- 3) Example user flows
405
+ > /agent Patcher
406
+ Ask knowhow Patcher: /!! npm test
407
+ Ask knowhow Patcher: Based on the output, propose a minimal patch.
500
408
  ```
501
409
 
502
- ### Example C: Run shell command and ask the AI to interpret
410
+ ### Example C: Attach to a running agent task and view logs
503
411
  ```text
504
- /!! cat ./build.log | tail -n 200
505
- What does the failure indicate, and what is the likely fix?
412
+ > /sessions
413
+ 1) a1b2c3... (running) Patcher
414
+ 2) d4e5f6... (saved) ResearcherPro
415
+
416
+ > /attach a1b2c3...
417
+ 🔄 Attached to running task: a1b2c3...
418
+ Agent : Patcher
419
+ Task : Fix the failing unit test...
420
+ Status: running
421
+
422
+ > /logs 10
506
423
  ```
507
424
 
508
- ### Example D: Attach to a running task and inspect logs
425
+ ### Example D: Resume a completed session
509
426
  ```text
510
- /sessions
511
- /attach <taskId>
512
- /logs 30
427
+ > /resume d4e5f6...
428
+ 📋 Session found: d4e5f6...
429
+ Agent : ResearcherPro
430
+ Task : Summarize...
431
+
432
+ Add any additional context for resuming this session (or press Enter to skip): Focus on migration risks.
513
433
  ```
514
434
 
515
- ### Example E: Resume a completed session later
435
+ ### Example E: Switch renderer mid-session
516
436
  ```text
517
- /resume <taskId>
518
- Add a brief test plan for the next iteration.
437
+ > /render fancy
438
+ Renderer switched to: fancy
519
439
  ```
520
440
 
521
441
  ---
522
442
 
523
- ## Quick command reference
524
-
525
- - **Start chat:** `knowhow chat`
526
- - **List agents:** `/agents`
527
- - **Switch agent:** `/agent <name>`
528
- - **Multi-line input:** `/multi`
529
- - **Renderers:** `/render basic|compact|fancy`
530
- - **Search:** `/search` (then use `next`, `exit`, `embeddings`, `use`)
531
- - **Sessions listing:** `/sessions [--completed] [--all] [--csv]`
532
- - **Attach:** `/attach [taskId] [--completed]`
533
- - **Resume:** `/resume [taskId]`
534
- - **Attached logs:** `/logs [N]`
535
- - **Shell:** `/!` and `/!! <command>`
536
- - **Voice (if available):** `/voice`
537
-
538
- ---
539
-
540
- If you paste the actual module source files that register the `/…` commands in your environment (agent/search/sessions/shell/voice/system modules), I can turn the “known commands” above into a **fully exact** reference (including any optional flags and exact argument syntax for every subcommand).
443
+ If you want, paste your `knowhow.json` (redact secrets) and I can help you write a correct custom-agent schema that matches how your Knowhow build expects agent definitions.