@tyvm/knowhow 0.0.109-dev.e88af1e → 0.0.110

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 (82) 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/src/agents/tools/list.ts +2 -2
  15. package/src/ai.ts +81 -37
  16. package/src/chat/CliChatService.ts +1 -1
  17. package/src/chat/modules/SystemModule.ts +2 -2
  18. package/src/clients/anthropic.ts +1 -1
  19. package/src/clients/index.ts +25 -6
  20. package/src/clients/openai.ts +8 -5
  21. package/src/clients/types.ts +29 -6
  22. package/src/clients/withRetry.ts +89 -0
  23. package/src/commands/agent.ts +30 -0
  24. package/src/commands/modules.ts +365 -30
  25. package/src/config.ts +1 -1
  26. package/src/hashes.ts +8 -9
  27. package/src/index.ts +4 -2
  28. package/src/processors/Base64ImageDetector.ts +73 -0
  29. package/src/services/MediaProcessorService.ts +79 -10
  30. package/src/services/modules/index.ts +24 -19
  31. package/tests/processors/Base64ImageDetector.test.ts +160 -0
  32. package/tests/unit/clients/AIClient.test.ts +446 -0
  33. package/tests/unit/clients/withRetry.test.ts +319 -0
  34. package/tests/unit/commands/github-credentials.test.ts +1 -2
  35. package/ts_build/package.json +1 -1
  36. package/ts_build/src/agents/tools/list.js +2 -2
  37. package/ts_build/src/agents/tools/list.js.map +1 -1
  38. package/ts_build/src/ai.d.ts +3 -3
  39. package/ts_build/src/ai.js +51 -23
  40. package/ts_build/src/ai.js.map +1 -1
  41. package/ts_build/src/chat/CliChatService.js +1 -1
  42. package/ts_build/src/chat/CliChatService.js.map +1 -1
  43. package/ts_build/src/chat/modules/SystemModule.js +2 -2
  44. package/ts_build/src/chat/modules/SystemModule.js.map +1 -1
  45. package/ts_build/src/clients/anthropic.js +1 -1
  46. package/ts_build/src/clients/anthropic.js.map +1 -1
  47. package/ts_build/src/clients/index.js +7 -6
  48. package/ts_build/src/clients/index.js.map +1 -1
  49. package/ts_build/src/clients/openai.js +4 -4
  50. package/ts_build/src/clients/openai.js.map +1 -1
  51. package/ts_build/src/clients/types.d.ts +12 -6
  52. package/ts_build/src/clients/withRetry.d.ts +2 -0
  53. package/ts_build/src/clients/withRetry.js +60 -0
  54. package/ts_build/src/clients/withRetry.js.map +1 -0
  55. package/ts_build/src/commands/agent.js +25 -0
  56. package/ts_build/src/commands/agent.js.map +1 -1
  57. package/ts_build/src/commands/modules.js +297 -17
  58. package/ts_build/src/commands/modules.js.map +1 -1
  59. package/ts_build/src/config.js +1 -1
  60. package/ts_build/src/config.js.map +1 -1
  61. package/ts_build/src/hashes.js +5 -7
  62. package/ts_build/src/hashes.js.map +1 -1
  63. package/ts_build/src/index.js +1 -1
  64. package/ts_build/src/index.js.map +1 -1
  65. package/ts_build/src/processors/Base64ImageDetector.d.ts +3 -0
  66. package/ts_build/src/processors/Base64ImageDetector.js +42 -0
  67. package/ts_build/src/processors/Base64ImageDetector.js.map +1 -1
  68. package/ts_build/src/services/MediaProcessorService.d.ts +5 -4
  69. package/ts_build/src/services/MediaProcessorService.js +53 -8
  70. package/ts_build/src/services/MediaProcessorService.js.map +1 -1
  71. package/ts_build/src/services/modules/index.js +17 -13
  72. package/ts_build/src/services/modules/index.js.map +1 -1
  73. package/ts_build/tests/processors/Base64ImageDetector.test.js +111 -0
  74. package/ts_build/tests/processors/Base64ImageDetector.test.js.map +1 -1
  75. package/ts_build/tests/unit/clients/AIClient.test.d.ts +1 -0
  76. package/ts_build/tests/unit/clients/AIClient.test.js +339 -0
  77. package/ts_build/tests/unit/clients/AIClient.test.js.map +1 -0
  78. package/ts_build/tests/unit/clients/withRetry.test.d.ts +1 -0
  79. package/ts_build/tests/unit/clients/withRetry.test.js +225 -0
  80. package/ts_build/tests/unit/clients/withRetry.test.js.map +1 -0
  81. package/ts_build/tests/unit/commands/github-credentials.test.js +1 -2
  82. package/ts_build/tests/unit/commands/github-credentials.test.js.map +1 -1
@@ -1,765 +1,691 @@
1
- # Knowhow CLI Reference (`knowhow`)
1
+ # Knowhow CLI Reference
2
2
 
3
- AI CLI with plugins and agents.
4
-
5
- > **Note on source coverage:** The provided code excerpts explicitly detailed only some commands (`knowhow init`, and the operational functions behind `generate/embed/upload/download/purge`, plus the full `knowhow worker` implementation). For commands whose flags/options are not present in the excerpts, this reference documents the command with **usage syntax** and **no flags** (or marks options as “not defined in provided source”).
3
+ > **Binary:** `knowhow`
4
+ > **Version:** `knowhow --version`
5
+ > **Help:** `knowhow --help`
6
6
 
7
7
  ## Table of Contents
8
8
 
9
- 1. [Global](#global)
10
- 2. [Commands](#commands)
11
- - [`init`](#init)
12
- - [`login`](#login)
13
- - [`logout`](#logout)
14
- - [`update`](#update)
15
- - [`generate`](#generate)
16
- - [`gen`](#gen)
17
- - [`embed`](#embed)
18
- - [`embed:purge`](#embedpurge)
19
- - [`purge`](#purge)
20
- - [`upload`](#upload)
21
- - [`download`](#download)
22
- - [`chat`](#chat)
23
- - [`agent`](#agent)
24
- - [`ask`](#ask)
25
- - [`setup`](#setup)
26
- - [`search`](#search)
27
- - [`sessions`](#sessions)
28
- - [`worker`](#worker)
29
- - [`files`](#files)
30
- - [`workers`](#workers)
31
- - [`github-credentials`](#github-credentials)
32
- 3. [Exit Codes / Error Handling](#exit-codes--error-handling)
33
-
34
- ---
35
-
36
- ## Global
37
-
38
- - **Binary name:** `knowhow`
39
- - **Version:** `knowhow --version`
40
- - **Config migration:** On startup, the CLI runs config migration (`migrateConfig()`) before dispatching commands.
41
- - Many operational commands call `setupServices()` first to wire services/clients/tools (and connect to configured backends).
9
+ 1. [Project Initialization](#project-initialization)
10
+ 2. [Authentication](#authentication)
11
+ 3. [Chat & Agents](#chat--agents)
12
+ 4. [Run Pipelines (Generate)](#run-pipelines-generate)
13
+ 5. [Embeddings](#embeddings)
14
+ 6. [Remote Sync (Upload/Download)](#remote-sync-uploaddownload)
15
+ 7. [Workers](#workers)
16
+ 8. [File Sync](#file-sync)
17
+ 9. [Cloud Workers](#cloud-workers)
18
+ 10. [Modules](#modules)
19
+ 11. [Git Credential Helper](#git-credential-helper)
42
20
 
43
21
  ---
44
22
 
45
- ## Commands
46
-
47
- ### `init`
23
+ ## Project Initialization
48
24
 
49
- #### Purpose
50
- Initialize Knowhow configuration and project-local folders/templates.
25
+ ### `knowhow init`
26
+ **Purpose:** Initialize Knowhow configuration files and folder structure:
27
+ - Creates **global** config in `~/.knowhow/`
28
+ - Creates **local** config in `./.knowhow/`
29
+ - Ensures built-in template prompts/files exist
30
+ - Adds `@tyvm/knowhow-module-script` to the global `~/.knowhow/knowhow.json` modules (if missing)
51
31
 
52
- #### Usage syntax
32
+ **Usage:**
53
33
  ```bash
54
34
  knowhow init
55
35
  ```
56
36
 
57
- #### Options / flags
58
- None defined in the provided source excerpts.
59
-
60
- #### What it creates/writes
61
- - Creates local directory structure under `./.knowhow/`:
62
- - `./.knowhow/`
63
- - `./.knowhow/prompts/`
64
- - `./.knowhow/docs/`
65
- - `./.knowhow/embeddings/`
66
- - Creates global template/config directory under `~/.knowhow/` and copies template files if missing:
67
- - `./.knowhow/knowhow.json` (local)
68
- - `./.knowhow/language.json` (local)
69
- - `./.knowhow/.ignore`, `./.knowhow/.hashes.json`, `./.knowhow/.jwt` (local)
70
- - Prompt templates: `./.knowhow/prompts/*.mdx` (local)
71
- - Template folder/file permissions are set when created (folder `0o744`, files `0o600`).
72
-
73
- #### Example
37
+ **Example:**
74
38
  ```bash
75
39
  knowhow init
76
40
  ```
77
41
 
78
42
  ---
79
43
 
80
- ### `login`
44
+ ## Authentication
81
45
 
82
- #### Purpose
83
- Authenticate the CLI with Knowhow.
46
+ ### `knowhow login`
47
+ **Purpose:** Log in to Knowhow. Supports either browser-based login flow or manual JWT input.
84
48
 
85
- #### Usage syntax
49
+ **Usage:**
86
50
  ```bash
87
- knowhow login [--jwt <jwt>]
51
+ knowhow login [--jwt]
88
52
  ```
89
53
 
90
- #### Options / flags
91
- - `--jwt <jwt>` — Use manual JWT input instead of browser login.
92
-
93
- > If `--jwt` is provided, the implementation passes it to the login routine.
54
+ **Options:**
55
+ - `--jwt` — Use manual JWT input instead of browser login
94
56
 
95
- #### Example
57
+ **Example:**
96
58
  ```bash
97
59
  knowhow login
98
60
  ```
99
61
 
62
+ Manual JWT (exact behavior depends on `login()` implementation):
100
63
  ```bash
101
- knowhow login --jwt "<your-jwt>"
64
+ knowhow login --jwt
102
65
  ```
103
66
 
67
+ > ✅ **Note:** In the provided code, there is **no `knowhow logout` command registered**. (It may exist elsewhere, but it’s not present in the snippets you provided.)
68
+
104
69
  ---
105
70
 
106
- ### `logout`
71
+ ## Chat & Agents
72
+
73
+ ### `knowhow chat`
74
+ **Purpose:** Start an interactive chat interface.
107
75
 
108
- #### Purpose
109
- Log out (clear authentication credentials).
76
+ **Usage:**
77
+ ```bash
78
+ knowhow chat
79
+ ```
110
80
 
111
- #### Usage syntax
81
+ **Example:**
112
82
  ```bash
113
- knowhow logout
83
+ knowhow chat
114
84
  ```
115
85
 
116
- #### Options / flags
117
- Not defined in the provided source excerpts.
86
+ ---
87
+
88
+ ### `knowhow agent`
89
+ **Purpose:** Run a one-shot agent task directly from the CLI (default agent: `Patcher`). Can also resume a previously started task.
118
90
 
119
- #### Example
91
+ **Usage:**
120
92
  ```bash
121
- knowhow logout
93
+ knowhow agent [options]
122
94
  ```
123
95
 
124
- ---
96
+ #### Options
97
+ - `--provider <provider>`
98
+ AI provider (e.g. `openai`, `anthropic`, `google`, `xai`)
99
+ - `--model <model>`
100
+ Specific model for the selected provider
101
+ - `--agent-name <name>`
102
+ Which agent to use (default: `Patcher`)
103
+ - `--max-time-limit <minutes>`
104
+ Execution time limit in minutes (default: `30`)
105
+ - `--max-spend-limit <dollars>`
106
+ Cost limit in dollars (default: `10`)
107
+ - `--message-id <messageId>`
108
+ Knowhow message ID for task tracking
109
+ - `--sync-fs`
110
+ Enable filesystem-based synchronization
111
+ - `--task-id <taskId>`
112
+ Pre-generated task ID (used with `--sync-fs` for predictable agent directory)
113
+ - `--prompt-file <path>`
114
+ Custom prompt template file with a `{text}` placeholder
115
+ - `--input <text>`
116
+ Task input (fallback to stdin if not provided)
117
+ - `--resume`
118
+ Resume a previously started task using `--task-id` (local FS or remote)
119
+ - `--renderer <name>`
120
+ Renderer to use: `basic`, `compact`, `fancy`, or a path/package
121
+ (default: from config or `basic`)
125
122
 
126
- ### `update`
123
+ #### Input rules
124
+ - If you don’t pass `--input` and don’t pass `--prompt-file`, the CLI reads from **stdin** (only if stdin is not a TTY).
125
+ - `--prompt-file` is processed through `readPromptFile(options.promptFile, input)`.
127
126
 
128
- #### Purpose
129
- Update the globally installed `knowhow` CLI to the latest npm version.
127
+ **Examples**
130
128
 
131
- #### Usage syntax
129
+ Run the default agent with inline input:
132
130
  ```bash
133
- knowhow update
131
+ knowhow agent --input "Summarize the project in 10 bullets"
134
132
  ```
135
133
 
136
- #### Options / flags
137
- None.
134
+ Use a custom prompt template file:
135
+ ```bash
136
+ knowhow agent --prompt-file .knowhow/prompts/BasicCodeDocumenter.mdx --input "src/index.ts"
137
+ ```
138
138
 
139
- #### Behavior
140
- Runs:
139
+ Resume a task:
141
140
  ```bash
142
- npm install -g knowhow@latest
141
+ knowhow agent --resume --task-id 123 --message-id 456 --input "Continue where you left off"
143
142
  ```
144
143
 
145
- #### Example
144
+ Choose provider + renderer:
146
145
  ```bash
147
- knowhow update
146
+ knowhow agent --provider openai --model gpt-4.1-mini --renderer fancy --input "Fix the failing tests"
148
147
  ```
149
148
 
150
149
  ---
151
150
 
152
- ### `generate`
153
-
154
- #### Purpose
155
- Run the configured sources pipeline to generate outputs (summaries/docs/etc.) based on `config.sources`.
151
+ ### `knowhow ask`
152
+ **Purpose:** Direct AI questioning without agent overhead.
156
153
 
157
- #### Usage syntax
154
+ **Usage:**
158
155
  ```bash
159
- knowhow generate
156
+ knowhow ask [options]
160
157
  ```
161
158
 
162
- #### Options / flags
163
- No flags defined in the provided excerpts. Behavior is **configuration-driven**.
159
+ #### Options
160
+ - `--provider <provider>` AI provider to use
161
+ - `--model <model>` — Specific model
162
+ - `--input <text>` — Question (fallback to stdin if not provided)
163
+ - `--prompt-file <path>` — Custom prompt template file
164
164
 
165
- #### Configuration behavior (high level)
166
- From `config.sources`, the CLI:
167
- - Computes hashes (prompt hash and input file hash) and skips work if unchanged.
168
- - For each source:
169
- - If `source.kind === "file"` (or falsy): generates from matching files (`source.input`)
170
- - Otherwise: treats `source.kind` as a plugin “kind”, writes to `source.output`, then continues with file-handling logic.
165
+ **Input rules**
166
+ - If `--input` is not provided and `--prompt-file` is not provided, it reads from **stdin** (non-TTY).
171
167
 
172
- #### Example
168
+ **Example:**
173
169
  ```bash
174
- knowhow generate
170
+ knowhow ask --input "What does Knowhow do?"
175
171
  ```
176
172
 
177
- ---
173
+ With a prompt template:
174
+ ```bash
175
+ knowhow ask --prompt-file .knowhow/prompts/BasicAsk.mdx --input "Explain embeddings."
176
+ ```
178
177
 
179
- ### `gen`
178
+ ---
180
179
 
181
- #### Purpose
182
- Alias of `knowhow generate`.
180
+ ### `knowhow setup`
181
+ **Purpose:** Ask the agent to configure Knowhow (runs the setup agent flow).
183
182
 
184
- #### Usage syntax
183
+ **Usage:**
185
184
  ```bash
186
- knowhow gen
185
+ knowhow setup
187
186
  ```
188
187
 
189
- #### Options / flags
190
- Not defined in provided excerpts (assumed equivalent to `generate`).
191
-
192
- #### Example
188
+ **Example:**
193
189
  ```bash
194
- knowhow gen
190
+ knowhow setup
195
191
  ```
196
192
 
197
193
  ---
198
194
 
199
- ### `embed`
200
-
201
- #### Purpose
202
- Generate embeddings for sources configured in `config.embedSources`.
195
+ ### `knowhow search`
196
+ **Purpose:** Search embeddings directly from the CLI.
203
197
 
204
- #### Usage syntax
198
+ **Usage:**
205
199
  ```bash
206
- knowhow embed
200
+ knowhow search [options]
207
201
  ```
208
202
 
209
- #### Options / flags
210
- No flags defined in the provided excerpts. Behavior is **configuration-driven**.
203
+ #### Options
204
+ - `--input <text>` Search query (fallback to stdin if not provided)
205
+ - `-e, --embedding <path>` — Specific embedding path (default: `all`)
211
206
 
212
- #### Configuration behavior (high level)
213
- From `config.embedSources` (if unset, it exits immediately):
214
- - Uses `config.embeddingModel` or defaults to `EmbeddingModels.openai.EmbeddingAda2`
215
- - Uses ignore pattern from `getIgnorePattern()`
216
- - Calls `embedSource(defaultModel, source, ignorePattern)` per configured embedding source.
207
+ **Example:**
208
+ ```bash
209
+ knowhow search --input "How do I configure auth?" --embedding .knowhow/embeddings/docs.json
210
+ ```
217
211
 
218
- #### Example
212
+ Read query from stdin:
219
213
  ```bash
220
- knowhow embed
214
+ echo "What is a worker?" | knowhow search
221
215
  ```
222
216
 
223
217
  ---
224
218
 
225
- ### `embed:purge`
226
-
227
- #### Purpose
228
- Purge embeddings matching a glob pattern.
229
- (Depending on the CLI implementation, this may be an alias of `knowhow purge`.)
219
+ ### `knowhow sessions`
220
+ **Purpose:** Manage agent sessions from CLI (prints session table, optionally all historical sessions).
230
221
 
231
- #### Usage syntax
222
+ **Usage:**
232
223
  ```bash
233
- knowhow embed:purge <pattern>
224
+ knowhow sessions [options]
234
225
  ```
235
226
 
236
- #### Options / flags
237
- None defined in provided excerpts.
227
+ #### Options
228
+ - `--all` Show all historical sessions (default: current process only)
229
+ - `--csv` — Output sessions as CSV
238
230
 
239
- #### Arguments
240
- - `<pattern>` — Glob expression for files/chunks to purge.
231
+ **Example:**
232
+ ```bash
233
+ knowhow sessions
234
+ ```
241
235
 
242
- #### Example
236
+ All sessions as CSV:
243
237
  ```bash
244
- knowhow embed:purge "**/*.md"
238
+ knowhow sessions --all --csv
245
239
  ```
246
240
 
247
241
  ---
248
242
 
249
- ### `purge`
243
+ ## Run Pipelines (Generate)
250
244
 
251
- #### Purpose
252
- Purge (remove) embedding chunks for files matching a provided glob.
245
+ ### `knowhow generate`
246
+ **Purpose:** Run the **sources pipeline** for documentation generation based on `config.sources`.
253
247
 
254
- #### Usage syntax
248
+ **Usage:**
255
249
  ```bash
256
- knowhow purge <globPath>
250
+ knowhow generate
257
251
  ```
258
252
 
259
- #### Options / flags
260
- None defined in the provided excerpts.
261
-
262
- #### Arguments
263
- - `<globPath>` — Glob expression for matching files whose chunks should be purged.
264
-
265
- #### Behavior (from provided excerpt)
266
- - Matches files via `globSync(globPath)`
267
- - Loads configured embeddings map and config (`config.embedSources`)
268
- - For each embedding “file” key:
269
- - Filters out entries whose:
270
- - `id` starts with `"./" + filePath` (removes chunks for that file)
271
- - `text.length` exceeds the configured `chunkSize` for that embedding output
272
- - Saves the pruned embeddings.
273
-
274
- #### Example
253
+ **Example:**
275
254
  ```bash
276
- knowhow purge "src/**/*.ts"
255
+ knowhow generate
277
256
  ```
278
257
 
258
+ > ✅ **Note:** The provided code registers `generate` only. There is **no `knowhow gen` alias** in the snippets you provided.
259
+
279
260
  ---
280
261
 
281
- ### `upload`
262
+ ## Embeddings
282
263
 
283
- #### Purpose
284
- Upload embedding JSON artifacts to remote storage destinations configured in `config.embedSources`.
264
+ ### `knowhow embed`
265
+ **Purpose:** Create embeddings for entries in `config.embedSources`.
285
266
 
286
- #### Usage syntax
267
+ **Usage:**
287
268
  ```bash
288
- knowhow upload
269
+ knowhow embed
289
270
  ```
290
271
 
291
- #### Options / flags
292
- No flags defined in the provided excerpts. Behavior is **configuration-driven**.
293
-
294
- #### Configuration behavior (high level)
295
- For each `config.embedSources[]` entry:
296
- - Requires `source.remoteType`
297
- - Reads embedding JSON from `source.output`
298
- - Determines `embeddingName` from the output filename
299
-
300
- Supports:
301
- - **`remoteType: "s3"`**
302
- - Uploads to: `s3://{bucketName}/{embeddingName}.json`
303
- - **`remoteType: "knowhow"`**
304
- - Requires `source.remoteId`
305
- - Gets a presigned upload URL from the Knowhow API
306
- - Uploads via S3 helper
307
- - Calls `updateEmbeddingMetadata(...)` to sync metadata back to the backend
308
- - Other types: skipped with a log.
309
-
310
- #### Example
272
+ **Example:**
311
273
  ```bash
312
- knowhow upload
274
+ knowhow embed
313
275
  ```
314
276
 
315
- ---
277
+ ### `knowhow embed:purge <pattern>`
278
+ **Purpose:** Purge embeddings matching a glob pattern.
316
279
 
317
- ### `download`
280
+ **Usage:**
281
+ ```bash
282
+ knowhow embed:purge <pattern>
283
+ ```
318
284
 
319
- #### Purpose
320
- Download embedding JSON artifacts from remote storage into local `source.output` paths.
285
+ **Arguments**
286
+ - `<pattern>` Glob pattern to match files for purging
321
287
 
322
- #### Usage syntax
288
+ **Example:**
323
289
  ```bash
324
- knowhow download
290
+ knowhow embed:purge "src/**/old*.ts"
325
291
  ```
326
292
 
327
- #### Options / flags
328
- No flags defined in the provided excerpts. Behavior is **configuration-driven**.
293
+ ---
329
294
 
330
- #### Configuration behavior (high level)
331
- For each `config.embedSources[]` entry:
332
- - Requires `source.remoteType`
333
- - Computes destination:
334
- - `fileName = "${name}.json"` where `name` is derived from `source.output`
335
- - `destinationPath = source.output`
295
+ ## Remote Sync (Upload/Download)
336
296
 
337
- Supports:
338
- - **`remoteType: "s3"`**
339
- - Downloads `/{bucket}/{fileName}` into `destinationPath`
340
- - **`remoteType: "github"`**
341
- - Downloads from GitHub into local `.knowhow/embeddings/${fileName}`
342
- - **`remoteType: "knowhow"`**
343
- - Requires `source.remoteId`
344
- - Gets presigned download URL from Knowhow API and downloads locally
345
- - Other types: logs message.
297
+ ### `knowhow upload`
298
+ **Purpose:** Upload generated embeddings/configured embedding outputs to configured remotes (`config.embedSources`).
346
299
 
347
- #### Example
300
+ **Usage:**
348
301
  ```bash
349
- knowhow download
302
+ knowhow upload
350
303
  ```
351
304
 
352
- ---
353
-
354
- ### `chat`
305
+ **Example:**
306
+ ```bash
307
+ knowhow upload
308
+ ```
355
309
 
356
- #### Purpose
357
- Start an interactive chat session with configured agents.
310
+ ### `knowhow download`
311
+ **Purpose:** Download embeddings from configured remotes.
358
312
 
359
- #### Usage syntax
313
+ **Usage:**
360
314
  ```bash
361
- knowhow chat
315
+ knowhow download
362
316
  ```
363
317
 
364
- #### Options / flags
365
- Not defined in provided source excerpts.
366
-
367
- #### Example
318
+ **Example:**
368
319
  ```bash
369
- knowhow chat
320
+ knowhow download
370
321
  ```
371
322
 
372
323
  ---
373
324
 
374
- ### `agent`
325
+ ## Workers
375
326
 
376
- #### Purpose
377
- Run a one-shot agent task with limits and optional resume.
327
+ ### `knowhow worker`
328
+ **Purpose:** Start a worker process (optionally registering it). Supports host mode or sandbox mode (Docker).
378
329
 
379
- #### Usage syntax
330
+ **Usage:**
380
331
  ```bash
381
- knowhow agent [options]
332
+ knowhow worker [options]
382
333
  ```
383
334
 
384
- #### Options / flags
385
- Not defined in provided source excerpts.
335
+ #### Options
336
+ - `--register`
337
+ Register current directory as a worker path
338
+ - `--share`
339
+ Share this worker with your organization
340
+ - `--unshare`
341
+ Make this worker private (only you can use it)
342
+ - `--sandbox`
343
+ Run worker in a Docker container for isolation
344
+ - `--no-sandbox`
345
+ Run worker directly on host (disable sandbox mode)
346
+ - `--passkey`
347
+ Set up passkey authentication for this worker
348
+ - `--passkey-reset`
349
+ Remove passkey authentication requirement
350
+ - *(internal, not a direct CLI flag)* `allowedTools`
351
+ Used by tunnel mode to restrict tool set; not exposed as a CLI option in the provided code.
386
352
 
387
- > If you have the command/CLI parser code for `agent`, share it and this section can be updated with exact flags/options.
353
+ #### Examples
388
354
 
389
- #### Example
355
+ Start in default mode:
390
356
  ```bash
391
- knowhow agent
357
+ knowhow worker
392
358
  ```
393
359
 
394
- ---
395
-
396
- ### `ask`
360
+ Register and share:
361
+ ```bash
362
+ knowhow worker --register --share
363
+ ```
397
364
 
398
- #### Purpose
399
- Direct AI questioning without agent orchestration.
365
+ Sandbox mode:
366
+ ```bash
367
+ knowhow worker --sandbox
368
+ ```
400
369
 
401
- #### Usage syntax
370
+ Host mode:
402
371
  ```bash
403
- knowhow ask [options]
372
+ knowhow worker --no-sandbox
404
373
  ```
405
374
 
406
- #### Options / flags
407
- Not defined in provided source excerpts.
375
+ Setup passkey:
376
+ ```bash
377
+ knowhow worker --passkey
378
+ ```
408
379
 
409
- #### Example
380
+ Reset passkey requirement:
410
381
  ```bash
411
- knowhow ask "What is Knowhow?"
382
+ knowhow worker --passkey-reset
412
383
  ```
413
384
 
414
385
  ---
415
386
 
416
- ### `setup`
387
+ ### `knowhow workers`
388
+ **Purpose:** Manage and start all registered workers.
417
389
 
418
- #### Purpose
419
- Ask the agent to configure Knowhow (runs setup workflow).
420
-
421
- #### Usage syntax
390
+ **Usage:**
422
391
  ```bash
423
- knowhow setup
392
+ knowhow workers [options]
424
393
  ```
425
394
 
426
- #### Options / flags
427
- Not defined in provided source excerpts.
395
+ #### Options (mutually exclusive in practice)
396
+ - `--list`
397
+ List all registered worker paths
398
+ - `--unregister <path>`
399
+ Unregister a worker path
400
+ - `--clear`
401
+ Clear all registered worker paths
428
402
 
429
- #### Example
403
+ **Examples**
404
+ List:
430
405
  ```bash
431
- knowhow setup
406
+ knowhow workers --list
432
407
  ```
433
408
 
434
- ---
435
-
436
- ### `search`
437
-
438
- #### Purpose
439
- Search embeddings directly from the CLI.
440
-
441
- #### Usage syntax
409
+ Unregister:
442
410
  ```bash
443
- knowhow search [options]
411
+ knowhow workers --unregister /path/to/worker
444
412
  ```
445
413
 
446
- #### Options / flags
447
- Not defined in provided source excerpts.
414
+ Start all workers (default action):
415
+ ```bash
416
+ knowhow workers
417
+ ```
448
418
 
449
- #### Example
419
+ Clear registry:
450
420
  ```bash
451
- knowhow search "how to configure plugins"
421
+ knowhow workers --clear
452
422
  ```
453
423
 
454
424
  ---
455
425
 
456
- ### `sessions`
457
-
458
- #### Purpose
459
- Manage and list agent sessions from the CLI.
426
+ ### `knowhow tunnel`
427
+ **Purpose:** Start a minimal worker with **tunnel enabled** (exposes local ports to the cloud). Registers essential tools needed by the backend.
460
428
 
461
- #### Usage syntax
429
+ **Usage:**
462
430
  ```bash
463
- knowhow sessions [options]
431
+ knowhow tunnel [options]
464
432
  ```
465
433
 
466
- #### Options / flags
467
- Not defined in provided source excerpts.
434
+ #### Options
435
+ - `--share` Share this tunnel with your organization
436
+ - `--unshare` — Make this tunnel private (only you can use it)
468
437
 
469
- #### Example
438
+ **Example:**
470
439
  ```bash
471
- knowhow sessions --all
440
+ knowhow tunnel --share
472
441
  ```
473
442
 
474
443
  ---
475
444
 
476
- ### `worker`
477
-
478
- #### Purpose
479
- Start a Knowhow **worker** process exposing worker’s MCP tools over WebSocket to the Knowhow API.
480
-
481
- Worker can run in:
482
- - **Host mode** (default)
483
- - **Docker sandbox mode** (`--sandbox`)
484
- - **Passkey-gated locked mode** (when passkey auth is configured; worker starts locked)
445
+ ## File Sync
485
446
 
486
- It can also register/share/unshare the worker and can set up a tunnel (config-driven).
447
+ ### `knowhow files`
448
+ **Purpose:** Sync files between local filesystem and Knowhow FS using `fileMounts` config.
487
449
 
488
- #### Usage syntax
450
+ **Usage:**
489
451
  ```bash
490
- knowhow worker [options]
452
+ knowhow files [options]
491
453
  ```
492
454
 
493
- #### Options / flags (from `src/worker.ts`)
494
-
495
- ##### `--register`
496
- - **Type:** boolean
497
- - **Purpose:** Register the current directory (`process.cwd()`) as a worker path.
498
- - **Effect:** Calls `registerWorkerPath(process.cwd())` and **exits** (does not start the worker loop).
455
+ #### Options
456
+ - `--upload`
457
+ Force upload direction for all mounts
458
+ - `--download`
459
+ Force download direction for all mounts
460
+ - `--config <path>`
461
+ Path to `knowhow.json` (default: `./knowhow.json`)
462
+ - `--dry-run`
463
+ Print what would be synced without doing it
499
464
 
500
- **Example**
465
+ **Examples**
466
+ Dry-run:
501
467
  ```bash
502
- knowhow worker --register
468
+ knowhow files --dry-run
503
469
  ```
504
470
 
505
- ---
506
-
507
- ##### `--share`
508
- - **Type:** boolean
509
- - **Purpose:** Share this worker with your organization.
510
- - **Effect:** Adds request header `Shared: "true"`.
511
-
512
- **Example**
471
+ Force upload:
513
472
  ```bash
514
- knowhow worker --share
473
+ knowhow files --upload
515
474
  ```
516
475
 
517
- ---
518
-
519
- ##### `--unshare`
520
- - **Type:** boolean
521
- - **Purpose:** Make this worker private/unshared.
522
- - **Effect:** Adds request header `Shared: "false"`.
523
-
524
- **Example**
476
+ Use a custom config path:
525
477
  ```bash
526
- knowhow worker --unshare
478
+ knowhow files --config ./my-knowhow.json --download
527
479
  ```
528
480
 
529
481
  ---
530
482
 
531
- ##### `--sandbox`
532
- - **Type:** boolean
533
- - **Purpose:** Run the worker in a **Docker container** for isolation.
534
- - **Effect in code:**
535
- - Checks Docker availability
536
- - Rebuilds worker Docker image (`Docker.buildWorkerImage()`)
537
- - Starts Docker with:
538
- - `workspaceDir: process.cwd()`
539
- - JWT + API URL + tunnel/config wiring
540
- - share/unshare mapping via container options
541
- - Persists config preference: `config.worker.sandbox = true`
483
+ ## Cloud Workers
484
+
485
+ ### `knowhow cloudworker`
486
+ **Purpose:** Create or sync a cloud worker with your local knowhow config.
542
487
 
543
- **Example**
488
+ **Usage:**
544
489
  ```bash
545
- knowhow worker --sandbox
490
+ knowhow cloudworker [options]
546
491
  ```
547
492
 
548
- ---
549
-
550
- ##### `--no-sandbox`
551
- - **Type:** boolean
552
- - **Purpose:** Force host mode (disable Docker sandbox).
553
- - **Effect:** Persists `config.worker.sandbox = false`.
493
+ #### Options
494
+ - `--init`
495
+ Initialize `config.files` entries based on what exists in `.knowhow/` (run once before `--push`)
496
+ - `--create`
497
+ Create a new cloud worker with synced config and files
498
+ - `--push <uid>`
499
+ Push/sync local config and files to an existing cloud worker (by `<uid>`)
500
+ - `--pull <id>`
501
+ Pull the latest `workerConfigJson` from a cloud worker and update local config
502
+ - `--name <name>`
503
+ Name for the cloud worker (used with `--create`)
504
+ - `--dry-run`
505
+ Print what would be synced without doing it
554
506
 
555
- **Example**
507
+ **Examples**
508
+ Initialize config files entries:
556
509
  ```bash
557
- knowhow worker --no-sandbox
510
+ knowhow cloudworker --init
558
511
  ```
559
512
 
560
- ---
561
-
562
- ##### `--passkey`
563
- - **Type:** boolean
564
- - **Purpose:** Run passkey setup for this worker (browser-based registration flow).
565
- - **Effect in code:**
566
- - Requires you to be logged in (`loadJwt()`).
567
- - If not logged in: prints error:
568
- - `You must be logged in to set up a passkey. Run 'knowhow login' first.`
569
- - Calls `new PasskeySetupService().setup(jwt)`
570
-
571
- **Example**
513
+ Create a new cloud worker:
572
514
  ```bash
573
- knowhow worker --passkey
515
+ knowhow cloudworker --create --name "My Cloud Worker"
574
516
  ```
575
517
 
576
- ---
518
+ Push to an existing worker:
519
+ ```bash
520
+ knowhow cloudworker --push 9f2c1a
521
+ ```
577
522
 
578
- ##### `--passkey-reset`
579
- - **Type:** boolean
580
- - **Purpose:** Reset/remove passkey configuration.
581
- - **Effect:** Calls `new PasskeySetupService().reset()` and exits.
523
+ Pull latest config:
524
+ ```bash
525
+ knowhow cloudworker --pull 12345
526
+ ```
582
527
 
583
- **Example**
528
+ Dry-run push:
584
529
  ```bash
585
- knowhow worker --passkey-reset
530
+ knowhow cloudworker --push 9f2c1a --dry-run
586
531
  ```
587
532
 
588
533
  ---
589
534
 
590
- #### Behavior notes
535
+ ## Modules
591
536
 
592
- ##### Docker-in-Docker detection
593
- If `process.env.KNOWHOW_DOCKER === "true"`:
594
- - It forces sandbox off:
595
- - `options.sandbox = false`
596
- - `options.noSandbox = true`
537
+ All commands are under:
538
+ ```bash
539
+ knowhow modules <subcommand>
540
+ ```
597
541
 
598
- ##### Sandbox mode selection priority
599
- - CLI flags `--sandbox` / `--no-sandbox`
600
- - then config: `config.worker?.sandbox`
601
- - default: host mode (`false`)
542
+ ### `knowhow modules setup`
543
+ **Purpose:** Add default built-in modules to your config and install them into `./.knowhow/node_modules`.
602
544
 
603
- ##### Allowed tools auto-initialization
604
- If `config.worker.allowedTools` is missing:
605
- - Populates allowed tools from `Tools.getToolNames()`
606
- - Persists it via `updateConfig(config)`
607
- - Exits without starting worker loop.
545
+ **Usage:**
546
+ ```bash
547
+ knowhow modules setup [--global]
548
+ ```
608
549
 
609
- ##### Passkey-gated locked worker
610
- If config includes:
611
- - `config.worker?.auth?.passkey?.publicKey`
612
- - `config.worker?.auth?.passkey?.credentialId`
550
+ #### Options
551
+ - `--global`
552
+ Use the global config `~/.knowhow/knowhow.json` instead of local `./.knowhow/knowhow.json`
613
553
 
614
- Then:
615
- - Worker starts **locked**
616
- - Tool calls are wrapped so tools return:
617
- ```json
618
- {
619
- "error": "WORKER_LOCKED",
620
- "message": "Worker is locked. Call the `unlock` tool with your passkey assertion to unlock it first."
621
- }
554
+ **Example:**
555
+ ```bash
556
+ knowhow modules setup
622
557
  ```
623
558
 
624
- Additionally, the tools `unlock` and `lock` are registered.
625
-
626
- ##### Tunnel configuration (config-driven)
627
- If `config.worker.tunnel.enabled === true`, the worker may open an additional WebSocket to `/ws/tunnel` and configure:
628
- - `allowedPorts` (warns if unset)
629
- - `maxConcurrentStreams` (default `50`)
630
- - `localHost` (auto-detects `host.docker.internal` when inside Docker, otherwise `127.0.0.1`)
631
- - URL rewriting behavior (config-driven)
559
+ Global setup:
560
+ ```bash
561
+ knowhow modules setup --global
562
+ ```
632
563
 
633
- No CLI flags are defined for tunnel options in the provided excerpt.
564
+ ---
634
565
 
635
- #### Examples
566
+ ### `knowhow modules install [module]`
567
+ **Purpose:** Install a module into `./.knowhow/node_modules` and add it to your config.
568
+ If no module is provided, installs all installable modules already listed in config.
636
569
 
637
- Start worker in host mode:
570
+ **Usage:**
638
571
  ```bash
639
- knowhow worker
572
+ knowhow modules install [module] [--global] [--latest]
640
573
  ```
641
574
 
642
- Start worker in Docker sandbox and share it:
575
+ #### Options
576
+ - `--global` — Use global config
577
+ - `--latest` — Force install the latest version (bypasses package-lock)
578
+
579
+ **Examples**
580
+ Install a specific module:
643
581
  ```bash
644
- knowhow worker --sandbox --share
582
+ knowhow modules install @tyvm/knowhow-module-script
645
583
  ```
646
584
 
647
- Register current directory as a worker:
585
+ Install into global config:
648
586
  ```bash
649
- knowhow worker --register
587
+ knowhow modules install @tyvm/knowhow-module-script --global
650
588
  ```
651
589
 
652
- Set up passkey auth (requires `knowhow login` first):
590
+ Install all modules from config:
653
591
  ```bash
654
- knowhow worker --passkey
592
+ knowhow modules install
655
593
  ```
656
594
 
657
- Reset passkey:
595
+ Install latest version of a module:
658
596
  ```bash
659
- knowhow worker --passkey-reset
597
+ knowhow modules install @tyvm/knowhow-module-script --latest
660
598
  ```
661
599
 
662
600
  ---
663
601
 
664
- ### `files`
602
+ ### `knowhow modules list`
603
+ **Purpose:** List modules in your config (global and/or local).
665
604
 
666
- #### Purpose
667
- Sync files between local filesystem and Knowhow FS using configured `fileMounts`.
668
-
669
- #### Usage syntax
605
+ **Usage:**
670
606
  ```bash
671
- knowhow files [options]
607
+ knowhow modules list [--global]
672
608
  ```
673
609
 
674
- #### Options / flags
675
- Not defined in provided source excerpts.
610
+ #### Options
611
+ - `--global` Show global config modules only
676
612
 
677
- #### Example
613
+ **Example:**
678
614
  ```bash
679
- knowhow files --dry-run --download
615
+ knowhow modules list
680
616
  ```
681
617
 
682
- ---
683
-
684
- ### `workers`
685
-
686
- #### Purpose
687
- Manage and start registered workers.
688
-
689
- #### Usage syntax
618
+ Global only:
690
619
  ```bash
691
- knowhow workers [options]
620
+ knowhow modules list --global
692
621
  ```
693
622
 
694
- #### Options / flags
695
- Not defined in provided source excerpts.
623
+ ---
696
624
 
697
- #### Examples
698
- ```bash
699
- knowhow workers --list
700
- ```
625
+ ### `knowhow modules update`
626
+ **Purpose:** Check for updates to all modules in your config and update them.
627
+ Shows installed vs latest (with publish date) before updating.
701
628
 
629
+ **Usage:**
702
630
  ```bash
703
- knowhow workers --unregister /path/to/worker
631
+ knowhow modules update [--global] [-y]
704
632
  ```
705
633
 
634
+ #### Options
635
+ - `--global` — Use the global config
636
+ - `-y, --yes` — Skip confirmation prompt; update all outdated modules automatically
637
+
638
+ **Example:**
706
639
  ```bash
707
- knowhow workers --clear
640
+ knowhow modules update
708
641
  ```
709
642
 
710
- Start all workers:
643
+ Auto-update without confirmation:
711
644
  ```bash
712
- knowhow workers
645
+ knowhow modules update --yes
713
646
  ```
714
647
 
715
648
  ---
716
649
 
717
- ### `github-credentials`
650
+ ## Git Credential Helper
718
651
 
719
- #### Purpose
720
- Git credential helper for GitHub using Knowhow as the backend.
652
+ ### `knowhow github-credentials [action]`
653
+ **Purpose:** Provide GitHub credentials to Git via Git’s credential helper protocol.
654
+
655
+ Designed to be used with:
656
+ ```bash
657
+ git config credential.helper 'knowhow github-credentials'
658
+ ```
721
659
 
722
- #### Usage syntax
660
+ **Usage:**
723
661
  ```bash
724
662
  knowhow github-credentials [action] [--repo <repo>]
725
663
  ```
726
664
 
727
665
  #### Arguments
728
- - `[action]` — credential helper action (commonly `get`, `store`, `erase`)
729
- - `--repo <repo>` repository in `owner/repo` format
730
-
731
- #### Options / flags
732
- - `--repo <repo>` — Repo to fetch credentials for.
733
- - If omitted, and `git remote get-url origin` exists, it attempts to infer `owner/repo` from origin URL.
734
-
735
- #### Behavior (from provided excerpt)
736
- - If `action === "get"`:
737
- - Reads stdin for git credential protocol/host lines (implementation ignores parsed host and always fetches for the repo)
738
- - Fetches credentials via `KnowhowSimpleClient().getGitCredential(repo || "")`
739
- - Outputs:
740
- - `protocol=...`
741
- - `host=...`
742
- - `username=...`
743
- - `password=...`
744
- - If `action` is `store` or `erase`:
745
- - exits successfully without output.
666
+ - `[action]` — Optional. Supported behaviors in the code:
667
+ - `get`read credentials from stdin and output credential lines
668
+ - `store` — exit immediately
669
+ - `erase` exit immediately
670
+
671
+ #### Options
672
+ - `--repo <repo>` — Repository in `owner/repo` format (e.g. `myorg/myrepo`)
746
673
 
747
674
  #### Examples
748
675
 
749
- Configure git to use the helper:
676
+ Configure git:
750
677
  ```bash
751
- git config credential.helper 'knowhow github-credentials'
678
+ git config --global credential.helper 'knowhow github-credentials'
752
679
  ```
753
680
 
754
- Manual credential request:
681
+ Request credentials for a repo explicitly:
755
682
  ```bash
756
- knowhow github-credentials get --repo "myorg/myrepo"
683
+ knowhow github-credentials get --repo myorg/myrepo
757
684
  ```
758
685
 
759
- ---
686
+ > If `--repo` is not provided, the helper attempts to infer it from:
687
+ > `git remote get-url origin`.
760
688
 
761
- ## Exit Codes / Error Handling
689
+ ---
762
690
 
763
- - Many command implementations use `try/catch` and call `process.exit(1)` on errors.
764
- - For `update`, npm install errors are logged and exit code is `1`.
765
- - On startup, command dispatch is handled by `program.parseAsync(...)`, and the CLI follows standard Node process error handling when uncaught errors occur.
691
+ If you share additional source files (e.g., `src/login.ts`, `src/chat/*`, `src/fileSync.ts`, `src/commands/*` beyond what’s included), I can extend this reference to cover any commands currently missing from the snippets you provided (such as a possible `knowhow logout`, `knowhow gen` alias, or additional chat subcommands).