@tyvm/knowhow 0.0.109 → 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 (94) 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/chat/CliChatService.ts +1 -1
  18. package/src/chat/modules/AgentModule.ts +7 -2
  19. package/src/chat/modules/SessionsModule.ts +40 -1
  20. package/src/chat/modules/SystemModule.ts +2 -2
  21. package/src/clients/anthropic.ts +1 -1
  22. package/src/clients/index.ts +25 -6
  23. package/src/clients/openai.ts +8 -5
  24. package/src/clients/types.ts +29 -6
  25. package/src/clients/withRetry.ts +89 -0
  26. package/src/commands/agent.ts +30 -0
  27. package/src/commands/modules.ts +417 -47
  28. package/src/config.ts +1 -1
  29. package/src/fileSync.ts +20 -12
  30. package/src/hashes.ts +43 -22
  31. package/src/index.ts +4 -2
  32. package/src/processors/Base64ImageDetector.ts +73 -0
  33. package/src/services/MediaProcessorService.ts +79 -10
  34. package/src/services/modules/index.ts +47 -18
  35. package/tests/processors/Base64ImageDetector.test.ts +160 -0
  36. package/tests/unit/clients/AIClient.test.ts +446 -0
  37. package/tests/unit/clients/withRetry.test.ts +319 -0
  38. package/tests/unit/commands/github-credentials.test.ts +1 -2
  39. package/ts_build/package.json +1 -1
  40. package/ts_build/src/agents/tools/list.js +2 -2
  41. package/ts_build/src/agents/tools/list.js.map +1 -1
  42. package/ts_build/src/ai.d.ts +3 -3
  43. package/ts_build/src/ai.js +51 -23
  44. package/ts_build/src/ai.js.map +1 -1
  45. package/ts_build/src/chat/CliChatService.js +1 -1
  46. package/ts_build/src/chat/CliChatService.js.map +1 -1
  47. package/ts_build/src/chat/modules/AgentModule.js +5 -2
  48. package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
  49. package/ts_build/src/chat/modules/SessionsModule.js +30 -1
  50. package/ts_build/src/chat/modules/SessionsModule.js.map +1 -1
  51. package/ts_build/src/chat/modules/SystemModule.js +2 -2
  52. package/ts_build/src/chat/modules/SystemModule.js.map +1 -1
  53. package/ts_build/src/clients/anthropic.js +1 -1
  54. package/ts_build/src/clients/anthropic.js.map +1 -1
  55. package/ts_build/src/clients/index.js +7 -6
  56. package/ts_build/src/clients/index.js.map +1 -1
  57. package/ts_build/src/clients/openai.js +4 -4
  58. package/ts_build/src/clients/openai.js.map +1 -1
  59. package/ts_build/src/clients/types.d.ts +12 -6
  60. package/ts_build/src/clients/withRetry.d.ts +2 -0
  61. package/ts_build/src/clients/withRetry.js +60 -0
  62. package/ts_build/src/clients/withRetry.js.map +1 -0
  63. package/ts_build/src/commands/agent.js +25 -0
  64. package/ts_build/src/commands/agent.js.map +1 -1
  65. package/ts_build/src/commands/modules.js +359 -32
  66. package/ts_build/src/commands/modules.js.map +1 -1
  67. package/ts_build/src/config.js +1 -1
  68. package/ts_build/src/config.js.map +1 -1
  69. package/ts_build/src/fileSync.d.ts +2 -2
  70. package/ts_build/src/fileSync.js +13 -11
  71. package/ts_build/src/fileSync.js.map +1 -1
  72. package/ts_build/src/hashes.d.ts +2 -2
  73. package/ts_build/src/hashes.js +40 -16
  74. package/ts_build/src/hashes.js.map +1 -1
  75. package/ts_build/src/index.js +1 -1
  76. package/ts_build/src/index.js.map +1 -1
  77. package/ts_build/src/processors/Base64ImageDetector.d.ts +3 -0
  78. package/ts_build/src/processors/Base64ImageDetector.js +42 -0
  79. package/ts_build/src/processors/Base64ImageDetector.js.map +1 -1
  80. package/ts_build/src/services/MediaProcessorService.d.ts +5 -4
  81. package/ts_build/src/services/MediaProcessorService.js +53 -8
  82. package/ts_build/src/services/MediaProcessorService.js.map +1 -1
  83. package/ts_build/src/services/modules/index.js +35 -12
  84. package/ts_build/src/services/modules/index.js.map +1 -1
  85. package/ts_build/tests/processors/Base64ImageDetector.test.js +111 -0
  86. package/ts_build/tests/processors/Base64ImageDetector.test.js.map +1 -1
  87. package/ts_build/tests/unit/clients/AIClient.test.d.ts +1 -0
  88. package/ts_build/tests/unit/clients/AIClient.test.js +339 -0
  89. package/ts_build/tests/unit/clients/AIClient.test.js.map +1 -0
  90. package/ts_build/tests/unit/clients/withRetry.test.d.ts +1 -0
  91. package/ts_build/tests/unit/clients/withRetry.test.js +225 -0
  92. package/ts_build/tests/unit/clients/withRetry.test.js.map +1 -0
  93. package/ts_build/tests/unit/commands/github-credentials.test.js +1 -2
  94. package/ts_build/tests/unit/commands/github-credentials.test.js.map +1 -1
@@ -0,0 +1,324 @@
1
+ ```md
2
+ # Knowhow CLI — chat with your project (via plugins, docs, and embeddings) 🤖
3
+
4
+ Knowhow is an AI-powered CLI that turns your repository into an indexable knowledgebase: it generates documentation from your files (`knowhow generate`), builds semantic embeddings for retrieval (`knowhow embed`), and lets you interact through an interactive chat experience (`knowhow chat`) powered by a configurable project in `./.knowhow/`.
5
+
6
+ [![npm version](https://img.shields.io/npm/v/@tyvm/knowhow.svg?style=flat)](https://www.npmjs.com/package/@tyvm/knowhow)
7
+ [![license](https://img.shields.io/npm/l/@tyvm/knowhow.svg?style=flat)](https://www.npmjs.com/package/@tyvm/knowhow)
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ - [🚀 Quickstart](#-quickstart)
14
+ - [💬 knowhow chat](#-knowhow-chat)
15
+ - [⚙️ Configuration](#️-configuration)
16
+ - [🔌 Plugins](#-plugins)
17
+ - [📚 Embeddings](#-embeddings)
18
+ - [📄 Generate Docs](#-generate-docs)
19
+ - [🔧 Worker System](#-worker-system)
20
+ - [🧩 Extending Knowhow](#-extending-knowhow)
21
+ - [📖 CLI Reference](#-cli-reference)
22
+ - [🔗 Links](#-links)
23
+
24
+ ---
25
+
26
+ ## 🚀 Quickstart
27
+
28
+ ### 1) Install
29
+
30
+ ```bash
31
+ npm install -g @tyvm/knowhow
32
+ ```
33
+
34
+ ### 2) Initialize a project (`knowhow init`)
35
+
36
+ From your project folder:
37
+
38
+ ```bash
39
+ knowhow init
40
+ ```
41
+
42
+ This creates a local Knowhow workspace in `./.knowhow/` and sets up global templates in `~/.knowhow/`.
43
+
44
+ You’ll get:
45
+
46
+ - `./.knowhow/knowhow.json` (your project configuration)
47
+ - `./.knowhow/language.json`
48
+ - `./.knowhow/prompts/` (prompt templates)
49
+ - `./.knowhow/docs/` (generated docs output)
50
+ - `./.knowhow/embeddings/` (generated embedding output)
51
+ - plus runtime/support files like `.ignore`, `.hashes.json`, `.jwt`, etc.
52
+
53
+ ### 3) Login (`knowhow login`)
54
+
55
+ ```bash
56
+ knowhow login
57
+ ```
58
+
59
+ Knowhow starts a browser-based OAuth flow, waits for approval, retrieves a JWT, and stores it at:
60
+
61
+ - `./.knowhow/.jwt` (permissioned so only you can read it)
62
+
63
+ If you already have a JWT, you can use:
64
+
65
+ ```bash
66
+ knowhow login --jwt
67
+ ```
68
+
69
+ After authentication, Knowhow updates your `orgId` in `./.knowhow/knowhow.json` and ensures the `knowhow` model provider is enabled.
70
+
71
+ ### 4) First steps after setup ✅
72
+
73
+ Recommended onboarding flow:
74
+
75
+ ```bash
76
+ knowhow embed
77
+ knowhow chat
78
+ ```
79
+
80
+ This builds embeddings for your configured `embedSources`, then starts chat so you can ask questions about what you indexed.
81
+
82
+ ---
83
+
84
+ ## 💬 knowhow chat
85
+
86
+ **Knowhow chat is the primary way to use the tool.** It’s an interactive terminal experience where you can switch between agents, attach/resume tasks, change renderers, and trigger semantic retrieval—using slash commands (`/…`) on top of normal chat.
87
+
88
+ ### Start chat
89
+
90
+ ```bash
91
+ knowhow chat
92
+ ```
93
+
94
+ Once started, Knowhow will show available commands for the current mode.
95
+
96
+ > Tip: While chatting, you can usually discover features by trying `/…` commands. If you want context, run:
97
+ >
98
+ > ```bash
99
+ > knowhow chat --help
100
+ > ```
101
+
102
+ ### Key slash commands (high impact)
103
+
104
+ #### Agents (switch the “brain”)
105
+ - `/agents` — list available agents and select one
106
+ - `/agent <agent_name>` — start a specific agent
107
+ - `/agent` — **toggle agent mode off** (when already enabled)
108
+
109
+ In **agent mode**, your prompt becomes like:
110
+ > `Ask knowhow <AgentName>:`
111
+ and your input becomes a task for that agent.
112
+
113
+ #### Attach / resume long-running work
114
+ - `/attach [taskId]` — attach to a running task
115
+ - `/resume [taskId]` — resume a saved/completed session
116
+ - `/logs [N]` — show last messages (default `N=20`) in attached mode
117
+ - Attached-mode controls:
118
+ - `/pause`, `/unpause`, `/kill`, `/detach`, `/done`
119
+
120
+ #### Renderers (how output is displayed)
121
+ - `/render` — show current renderer + built-ins
122
+ - `/render compact` / `/render basic` / `/render fancy`
123
+ - `/render ./my-renderer.js` — also supports paths and package names
124
+
125
+ #### Input modes
126
+ - `/multi` — toggle multiline editor input
127
+ - `/voice` — toggle voice input
128
+
129
+ #### Model/provider selection (per context)
130
+ - `/provider` — select AI provider
131
+ - `/model` — select model
132
+
133
+ #### Search
134
+ - `/search` — interactive embedding search (inside it, you’ll use commands like `next`, `exit`, `embeddings`, `use`)
135
+
136
+ ### Switching agents (quick pattern)
137
+
138
+ ```text
139
+ /agents
140
+ /agent Researcher
141
+ ```
142
+
143
+ After selecting, agent mode is enabled and your messages become tasks.
144
+
145
+ ### Slash-command “power feature”: shell helpers while chatting
146
+
147
+ When an agent is active, you can run local shell commands:
148
+
149
+ - `/! <command>` — execute and stream output (interactive)
150
+ - `/!! <command>` — capture output and send it to the agent
151
+
152
+ Example:
153
+ ```text
154
+ /agent Patcher
155
+ Ask knowhow Patcher: /!! npm test
156
+ ```
157
+
158
+ ---
159
+
160
+ ## ⚙️ Configuration
161
+
162
+ Your main project configuration is `./.knowhow/knowhow.json`.
163
+
164
+ It controls, among other things:
165
+
166
+ - enabled/disabled plugins
167
+ - what to generate (`sources`)
168
+ - what to embed for retrieval (`embedSources`)
169
+ - model provider configuration
170
+ - worker/tool behavior
171
+
172
+ For the full config schema and examples, see:
173
+ - `autodoc/config-reference.md`
174
+
175
+ ---
176
+
177
+ ## 🔌 Plugins
178
+
179
+ Plugins extend Knowhow with extra context, resolution (URLs, GitHub, etc.), semantic retrieval, and tooling awareness. Enable/disable them via:
180
+
181
+ - `knowhow.json -> plugins.enabled / plugins.disabled`
182
+
183
+ For the complete plugins guide, see:
184
+ - `autodoc/plugins-guide.md`
185
+
186
+ ### Built-in plugins (commonly available)
187
+
188
+ From the shipped defaults you’ll typically see plugins like:
189
+
190
+ - `language`, `embeddings`, `git`, `vim`, `github`, `asana`, `jira`, `linear`, `download`, `url`, `tmux`, `agents-md`, `exec`, `skills`, `figma`, `notion`, etc.
191
+
192
+ ### ⭐ Killer feature: the Language Plugin (hotwords → context injection)
193
+
194
+ The **Language Plugin** lets you define “terms” (hotwords) in **`.knowhow/language.json`**. When those terms appear in chat (or certain file events happen), Knowhow resolves configured sources (files/text/URLs/etc.) and injects that context automatically.
195
+
196
+ Example `./.knowhow/language.json`:
197
+
198
+ ```json
199
+ {
200
+ "API, api, rest*": {
201
+ "sources": [
202
+ { "kind": "file", "data": [".knowhow/docs/api/**/*.md"] }
203
+ ]
204
+ }
205
+ }
206
+ ```
207
+
208
+ Now when you type something like “Explain the API…”, Knowhow will automatically pull in the matching API docs.
209
+
210
+ ---
211
+
212
+ ## 📚 Embeddings
213
+
214
+ Embeddings are the backbone of semantic retrieval.
215
+
216
+ ### Generate embeddings
217
+
218
+ Knowhow uses `embedSources` from your config:
219
+
220
+ ```bash
221
+ knowhow embed
222
+ ```
223
+
224
+ It writes embedding JSON to the configured `embedSources[].output` paths (commonly under `./.knowhow/embeddings/`).
225
+
226
+ ### Upload/download to storage (and cloud KB)
227
+
228
+ - Upload:
229
+ ```bash
230
+ knowhow upload
231
+ ```
232
+ - Download:
233
+ ```bash
234
+ knowhow download
235
+ ```
236
+
237
+ If you’re uploading to Knowhow Cloud, you’ll use `remoteType: "knowhow"` with a `remoteId` (KB ID).
238
+
239
+ Full details:
240
+ - `autodoc/embeddings-guide.md`
241
+
242
+ ---
243
+
244
+ ## 📄 Generate Docs
245
+
246
+ `knowhow generate` runs the **sources pipeline** from `config.sources`.
247
+
248
+ In short, for each `sources[]` entry it:
249
+
250
+ 1. finds inputs (single file, glob, comma list, brace expansion)
251
+ 2. resolves a prompt (from `promptsDir` / file / inline string)
252
+ 3. writes outputs:
253
+ - multi-output mode if `output` ends with `/`
254
+ - single combined output otherwise
255
+ 4. skips work using hashing via `./.knowhow/.hashes.json`
256
+
257
+ Run:
258
+
259
+ ```bash
260
+ knowhow generate
261
+ ```
262
+
263
+ Full guide:
264
+ - `autodoc/generate-guide.md`
265
+
266
+ ---
267
+
268
+ ## 🔧 Worker System
269
+
270
+ The **Knowhow worker** is your bridge between local tools and the Knowhow cloud.
271
+
272
+ It runs a local MCP server that exposes selected tools to cloud agents (so an agent can operate on your repo/tools safely and intentionally).
273
+
274
+ ### Security model highlights
275
+
276
+ - **Docker sandbox mode** (`--sandbox`) for stronger isolation
277
+ - **Passkey authentication** to protect tool access (worker can start “locked” until you unlock)
278
+
279
+ Full worker details:
280
+ - `autodoc/worker-guide.md`
281
+
282
+ ---
283
+
284
+ ## 🧩 Extending Knowhow
285
+
286
+ Knowhow is designed to grow with your workflow—without forking core.
287
+
288
+ ### Modules: add tools/agents/plugins/clients/commands
289
+
290
+ Modules are loaded from the `modules` array in `knowhow.json` (global + local are supported; load order is global then local). A module can register:
291
+
292
+ - tools
293
+ - agents
294
+ - plugins
295
+ - clients
296
+ - chat commands
297
+
298
+ Full guide:
299
+ - `autodoc/modules-guide.md`
300
+
301
+ ### Skills system: reusable instruction packs (`SKILL.md`)
302
+
303
+ Skills let you store reusable instruction bundles as files named **`SKILL.md`** with frontmatter (`name`, `description`) and full markdown instructions.
304
+
305
+ Configured via `knowhow.json -> skills` (scanned recursively), and the Skills plugin injects matching skill content when the user prompt includes the skill name (case-insensitive substring match).
306
+
307
+ Full guide:
308
+ - `autodoc/skills-guide.md`
309
+
310
+ ---
311
+
312
+ ## 📖 CLI Reference
313
+
314
+ For the complete list of commands and their options, see:
315
+ - `autodoc/cli-reference.md`
316
+
317
+ ---
318
+
319
+ ## 🔗 Links
320
+
321
+ - Website: https://knowhow.tyvm.ai
322
+ - Twitter/X: https://x.com/micahriggan
323
+ - npm: https://www.npmjs.com/package/@tyvm/knowhow
324
+ ```