knowzcode 0.3.6 → 0.4.0

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 (79) hide show
  1. package/.claude-plugin/marketplace.json +61 -61
  2. package/.claude-plugin/plugin.json +8 -8
  3. package/LICENSE +121 -121
  4. package/README.md +354 -320
  5. package/agents/analyst.md +114 -114
  6. package/agents/architect.md +200 -200
  7. package/agents/builder.md +104 -104
  8. package/agents/closer.md +177 -95
  9. package/agents/context-scout.md +54 -54
  10. package/agents/knowledge-migrator.md +349 -349
  11. package/agents/knowz-scout.md +83 -83
  12. package/agents/knowz-scribe.md +180 -180
  13. package/agents/microfix-specialist.md +135 -135
  14. package/agents/project-advisor.md +111 -111
  15. package/agents/reviewer.md +172 -172
  16. package/agents/security-officer.md +194 -194
  17. package/agents/test-advisor.md +162 -162
  18. package/agents/update-coordinator.md +394 -394
  19. package/bin/knowzcode.mjs +1199 -956
  20. package/commands/audit.md +328 -328
  21. package/commands/connect-mcp.md +549 -549
  22. package/commands/fix.md +107 -107
  23. package/commands/init.md +500 -439
  24. package/commands/learn.md +332 -332
  25. package/commands/plan.md +272 -272
  26. package/commands/register.md +733 -733
  27. package/commands/status.md +309 -309
  28. package/commands/telemetry-setup.md +368 -368
  29. package/commands/telemetry.md +188 -188
  30. package/commands/work.md +1204 -1170
  31. package/knowzcode/automation_manifest.md +59 -59
  32. package/knowzcode/claude_code_execution.md +431 -420
  33. package/knowzcode/copilot_execution.md +231 -231
  34. package/knowzcode/enterprise/compliance_manifest.md +137 -137
  35. package/knowzcode/enterprise/compliance_status.md +30 -30
  36. package/knowzcode/enterprise/guidelines/code-quality.md +67 -67
  37. package/knowzcode/enterprise/guidelines/security.md +355 -355
  38. package/knowzcode/enterprise/templates/guideline-template.md +55 -55
  39. package/knowzcode/gitignore.template +13 -13
  40. package/knowzcode/knowzcode_architecture.md +51 -51
  41. package/knowzcode/knowzcode_log.md +142 -142
  42. package/knowzcode/knowzcode_loop.md +596 -593
  43. package/knowzcode/knowzcode_orchestration.md +66 -66
  44. package/knowzcode/knowzcode_project.md +48 -48
  45. package/knowzcode/knowzcode_tracker.md +40 -40
  46. package/knowzcode/knowzcode_vaults.md +257 -257
  47. package/knowzcode/mcp_config.md +191 -191
  48. package/knowzcode/planning/Readme.md +6 -6
  49. package/knowzcode/platform_adapters.md +1260 -1047
  50. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
  51. package/knowzcode/prompts/Investigate_Codebase.md +227 -227
  52. package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
  53. package/knowzcode/prompts/Refactor_Node.md +72 -72
  54. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
  55. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
  56. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
  57. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
  58. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
  59. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
  60. package/knowzcode/specs/Readme.md +10 -10
  61. package/knowzcode/telemetry_config.md +89 -89
  62. package/knowzcode/user_preferences.md +120 -120
  63. package/package.json +53 -53
  64. package/skills/alias-resolver.json +15 -15
  65. package/skills/architecture-diff.json +12 -12
  66. package/skills/check-installation-status.json +14 -14
  67. package/skills/continue.md +126 -126
  68. package/skills/environment-guard.json +12 -12
  69. package/skills/generate-workgroup-id.json +25 -25
  70. package/skills/install-knowzcode.json +21 -21
  71. package/skills/load-core-context.json +18 -18
  72. package/skills/log-entry-builder.json +15 -15
  73. package/skills/spec-quality-check.json +14 -14
  74. package/skills/spec-template.json +15 -15
  75. package/skills/spec-validator.json +25 -25
  76. package/skills/start-work.md +224 -224
  77. package/skills/tracker-scan.json +12 -12
  78. package/skills/tracker-update.json +28 -28
  79. package/skills/validate-installation.json +14 -14
@@ -1,733 +1,733 @@
1
- ---
2
- description: Register for KnowzCode and configure MCP server automatically
3
- argument-hint: "[--scope <local|project|user>] [--dev]"
4
- ---
5
-
6
- # KnowzCode Registration
7
-
8
- You are the **KnowzCode Registration Agent**. Your task is to guide users through account registration and automatically configure the MCP server connection.
9
-
10
- ## Command Syntax
11
-
12
- ```bash
13
- /kc:register [--scope <local|project|user>] [--dev]
14
- ```
15
-
16
- **Parameters:**
17
- - `--scope <scope>` - Optional. Configuration scope: local (default), project, or user
18
- - `--dev` - Optional. Use development environment instead of production
19
-
20
- **Environments:**
21
- | Environment | API Endpoint | MCP Endpoint | When to Use |
22
- |:------------|:-------------|:-------------|:------------|
23
- | **Production** (default) | `https://api.knowz.io/api/v1/auth/register` | `https://mcp.knowz.io/mcp` | Normal usage |
24
- | **Development** | `https://api.dev.knowz.io/api/v1/auth/register` | `https://mcp.dev.knowz.io/mcp` | Testing new features |
25
-
26
- **Examples:**
27
- ```bash
28
- # Standard registration (production)
29
- /kc:register
30
-
31
- # Register with project-wide scope (production)
32
- /kc:register --scope project
33
-
34
- # Register with user-wide scope (production)
35
- /kc:register --scope user
36
-
37
- # Register against development environment
38
- /kc:register --dev
39
-
40
- # Development with specific scope
41
- /kc:register --dev --scope project
42
- ```
43
-
44
- ## What Registration Provides
45
-
46
- Registering for KnowzCode gives you:
47
-
48
- - **API Key** - Unique key for MCP server authentication
49
- - **KnowzCode Vault** - Auto-created vault for learnings, conventions, and patterns
50
- - **Vector Search** - AI-powered code search across your projects
51
- - **Spec Queries** - Query your specifications and documentation
52
- - **Context Retrieval** - Intelligent context for agent decisions
53
- - **Dependency Analysis** - Understand code relationships
54
-
55
- **Free tier includes:**
56
- - 1,000 API calls/month
57
- - Single user
58
- - Basic vector search
59
-
60
- **Upgrades available at:** https://knowz.io/pricing
61
-
62
- ## API Response Structure
63
-
64
- The registration API returns:
65
-
66
- ```json
67
- {
68
- "api_key": "kz_live_abc123...",
69
- "vault_id": "vault_xyz789...",
70
- "vault_name": "KnowzCode"
71
- }
72
- ```
73
-
74
- This vault is automatically configured for you - no manual setup required.
75
-
76
- ## Your Task
77
-
78
- Guide the user through registration **step-by-step, one question at a time**. This is an interactive conversational flow - do NOT ask multiple questions at once.
79
-
80
- **CRITICAL: Interactive Flow Rules**
81
- 1. Ask ONE question, then WAIT for user response
82
- 2. After each response, validate and then ask the NEXT question
83
- 3. Never combine multiple questions into a single message
84
- 4. Use AskUserQuestion tool for each input collection step
85
- 5. After each AskUserQuestion, STOP and wait for the user's answer
86
-
87
- ### Conversation Flow Summary
88
-
89
- ```
90
- YOU USER
91
- ─────────────────────────────────────────────────
92
- 1. Check MCP config
93
- 2. Welcome + Ask name ──────────► [User types name]
94
- 3. Validate name
95
- 4. Ask email ───────────────────► [User types email]
96
- 5. Validate email
97
- 6. Ask password ────────────────► [User types password]
98
- 7. Validate password
99
- 8. Show summary + confirm ──────► [User confirms: Yes/No/Edit]
100
- 9. Call API
101
- 10. Configure MCP + base vault
102
- 11. Vault discovery ───────────► [User: Yes/No to configure more]
103
- 12. (If Yes) Vault selection ──► [User selects vaults + descriptions]
104
- 13. Write vault config
105
- 14. Show success
106
- ```
107
-
108
- ### Steps to Execute
109
-
110
- #### Step 1: Check Existing Configuration
111
-
112
- 1. Check if MCP server already configured:
113
- ```bash
114
- CLAUDECODE= claude mcp get knowz
115
- ```
116
-
117
- 2. If already configured, display:
118
- ```
119
- ⚠️ KnowzCode MCP server is already configured.
120
-
121
- Options:
122
- 1. Keep existing configuration (abort registration)
123
- 2. Remove existing and register new account
124
-
125
- If you want to register a new account, the existing configuration
126
- will be replaced with the new API key.
127
- ```
128
-
129
- Use AskUserQuestion to get user choice. If they choose to keep existing, STOP.
130
- If they choose to continue, run `CLAUDECODE= claude mcp remove knowz` first.
131
-
132
- 3. If not configured: Continue to Step 2.
133
-
134
- #### Step 2: Welcome Message and First Question
135
-
136
- Display welcome message, then IMMEDIATELY ask the first question (name):
137
-
138
- ```
139
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
140
- ◆ KnowzCode REGISTRATION
141
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
142
-
143
- Welcome! Let's set up your KnowzCode account.
144
-
145
- This will:
146
- 1. Create your KnowzCode account
147
- 2. Generate an API key
148
- 3. Configure the MCP server automatically
149
-
150
- I'll ask you a few questions one at a time.
151
- All data transmitted securely over HTTPS.
152
- Privacy policy: https://knowz.io/privacy
153
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
154
- ```
155
-
156
- **Then immediately use AskUserQuestion** to collect name:
157
-
158
- **Question:** "What name would you like for your account?"
159
-
160
- **STOP HERE and wait for user response.**
161
-
162
- #### Step 3: Validate Name and Ask Email
163
-
164
- After receiving the name:
165
-
166
- **Validation:**
167
- - Must be non-empty
168
- - Must be 2-100 characters
169
- - Allow: letters, spaces, hyphens, apostrophes
170
-
171
- If invalid, explain the issue and re-prompt for name.
172
-
173
- If valid, store the name and proceed to ask for email.
174
-
175
- #### Step 4: Ask for Email
176
-
177
- Use AskUserQuestion to collect the user's email:
178
-
179
- **Question:** "What is your email address?"
180
-
181
- **STOP HERE and wait for user response.**
182
-
183
- #### Step 5: Validate Email and Ask Password
184
-
185
- After receiving the email:
186
-
187
- **Validation:**
188
- - Must match email pattern (contains @ and domain)
189
- - No leading/trailing whitespace
190
-
191
- If invalid:
192
- ```
193
- ⚠️ Invalid email format.
194
- Please enter a valid email address (e.g., user@example.com)
195
- ```
196
- Re-prompt for email.
197
-
198
- If valid, store the email and proceed to ask for password.
199
-
200
- Use AskUserQuestion to collect the password:
201
-
202
- **Question:** "Create a password (minimum 8 characters)"
203
-
204
- Display this note with the question:
205
- ```
206
- Your password will be sent securely over HTTPS to create your account.
207
- It will NOT be stored locally or displayed in any logs.
208
- ```
209
-
210
- **STOP HERE and wait for user response.**
211
-
212
- #### Step 6: Validate Password
213
-
214
- After receiving the password:
215
-
216
- **Validation:**
217
- - Minimum 8 characters
218
-
219
- If invalid:
220
- ```
221
- ⚠️ Password must be at least 8 characters.
222
- ```
223
- Re-prompt for password.
224
-
225
- If valid, store the password and proceed to confirmation.
226
-
227
- #### Step 7: Confirm Details
228
-
229
- Display collected information for confirmation:
230
-
231
- ```
232
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
233
- ◆ CONFIRM REGISTRATION DETAILS
234
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
235
-
236
- Please confirm your registration details:
237
-
238
- Name: {collected_name}
239
- Email: {collected_email}
240
- Password: ********
241
-
242
- Is this correct?
243
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
244
- ```
245
-
246
- Use AskUserQuestion with options:
247
- - **Yes** - Proceed with registration
248
- - **No** - Cancel registration
249
- - **Edit** - Go back and re-enter information
250
-
251
- **STOP HERE and wait for user response.**
252
-
253
- - If "Edit": Return to Step 2 to re-collect all information (name first).
254
- - If "No": Display cancellation message and STOP.
255
- - If "Yes": Proceed to Step 8.
256
-
257
- #### Step 8: Call Registration API
258
-
259
- **Determine endpoint based on `--dev` flag:**
260
- - If `--dev` flag present: Use `https://api.dev.knowz.io/api/v1/auth/register`
261
- - Otherwise (default): Use `https://api.knowz.io/api/v1/auth/register`
262
-
263
- Make HTTP POST request to registration endpoint:
264
-
265
- ```bash
266
- # Production (default)
267
- curl -X POST https://api.knowz.io/api/v1/auth/register \
268
- -H "Content-Type: application/json" \
269
- -d '{
270
- "name": "{collected_name}",
271
- "email": "{collected_email}",
272
- "password": "{collected_password}"
273
- }'
274
-
275
- # Development (with --dev flag)
276
- curl -X POST https://api.dev.knowz.io/api/v1/auth/register \
277
- -H "Content-Type: application/json" \
278
- -d '{
279
- "name": "{collected_name}",
280
- "email": "{collected_email}",
281
- "password": "{collected_password}"
282
- }'
283
- ```
284
-
285
- **Handle Response Codes:**
286
-
287
- | Code | Meaning | Action |
288
- |------|---------|--------|
289
- | 200/201 | Success | Extract API key AND vault_id, continue to Step 9 |
290
- | 400 | Validation error | Show error details, return to relevant step |
291
- | 409 | Email exists | Show recovery options (see Error Handling) |
292
- | 429 | Rate limited | Show wait message (see Error Handling) |
293
- | 500+ | Server error | Show error and support link |
294
-
295
- **Parse Response:**
296
- - Extract `api_key` (or `apiKey` or `token` field)
297
- - Extract `vault_id` (auto-created "KnowzCode" vault)
298
- - Extract `vault_name` (typically "KnowzCode")
299
-
300
- #### Step 9: Configure MCP, Vault, and Show Success
301
-
302
- **On successful registration:**
303
-
304
- 1. **Extract from response:**
305
- - API key (look for `apiKey`, `api_key`, or `token` field)
306
- - Vault ID (look for `vault_id` or `vaultId` field)
307
- - Vault name (look for `vault_name` or `vaultName` field, default: "KnowzCode")
308
-
309
- 2. **Parse scope** from command arguments (default: `local`)
310
-
311
- 3. **If scope is `project`**, show security warning:
312
- ```
313
- ⚠️ Security Note: Project Scope Selected
314
-
315
- With project scope, your API key will be stored in .mcp.json
316
- which is typically committed to git.
317
-
318
- This is appropriate for:
319
- • Team/shared API keys
320
- • CI/CD automation keys
321
-
322
- For personal keys, consider using --scope local (default)
323
-
324
- Continue with project scope?
325
- ```
326
- Use AskUserQuestion to confirm. If user declines, use `local` scope instead.
327
-
328
- 4. **Configure MCP server** (use same environment as registration):
329
- ```bash
330
- # Production (default)
331
- claude mcp add --transport http \
332
- --scope <chosen-scope> \
333
- knowz \
334
- https://mcp.knowz.io/mcp \
335
- --header "Authorization: Bearer <api_key>" \
336
- --header "X-Project-Path: $(pwd)"
337
-
338
- # Development (with --dev flag)
339
- claude mcp add --transport http \
340
- --scope <chosen-scope> \
341
- knowz \
342
- https://mcp.dev.knowz.io/mcp \
343
- --header "Authorization: Bearer <api_key>" \
344
- --header "X-Project-Path: $(pwd)"
345
- ```
346
-
347
- 5. **Verify MCP configuration**:
348
- ```bash
349
- CLAUDECODE= claude mcp get knowz
350
- ```
351
-
352
- 6. **Configure vault in mcp_config.md**:
353
-
354
- Check if `knowzcode/mcp_config.md` exists:
355
- - If exists: **Merge** vault configuration (preserve existing Code Vault if set)
356
- - If not exists: Create from template with vault configured
357
-
358
- Update `knowzcode/mcp_config.md` with:
359
- ```markdown
360
- # KnowzCode MCP Configuration
361
-
362
- ## Connection Status
363
- - **Connected**: Yes
364
- - **Endpoint**: {endpoint}
365
- - **Last Verified**: {ISO timestamp}
366
-
367
- ---
368
-
369
- ## Vaults
370
-
371
- ### Ecosystem Vault (Primary)
372
- - **Vault ID**: {vault_id from registration}
373
- - **Vault Name**: {vault_name from registration}
374
- - **Purpose**: Decisions, conventions, security, integrations, business rules
375
- - **Auto-configured**: Yes (via /kc:register)
376
-
377
- ### Code Vault (Optional)
378
- - **Vault ID**: (not configured)
379
- - **Purpose**: Implementation patterns, workarounds, performance
380
- - **Note**: Code search uses local grep/glob by default.
381
- Configure code vault for large codebases with /kc:connect-mcp --configure-vaults
382
-
383
- ### Finalizations Vault (Optional)
384
- - **Vault ID**: (not configured)
385
- - **Purpose**: WorkGroup completion summaries, outcome records
386
- - **Note**: Finalizations vault tracks completed work.
387
- Configure for teams that want searchable completion history.
388
- ```
389
-
390
- **Edge case - existing vault config**:
391
- If `knowzcode/mcp_config.md` already has an Ecosystem Vault ID configured:
392
- - Use AskUserQuestion: "You already have a vault configured. Replace with new vault from registration? [Yes/No/Keep both]"
393
- - If "Yes": Replace Ecosystem Vault ID
394
- - If "No": Keep existing vault config
395
- - If "Keep both": Add new vault as secondary
396
-
397
- 7. **Display success message** with vault info:
398
-
399
- ```
400
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
401
- ◆ KnowzCode REGISTRATION COMPLETE
402
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
403
-
404
- ✅ Account created and configured!
405
-
406
- Account Details:
407
- • Email: {email}
408
- • API Key: {masked_key}
409
-
410
- MCP Configuration:
411
- • Scope: {chosen-scope}
412
- • Endpoint: {endpoint}
413
- • Environment: {Production OR Development}
414
- • Status: Configured
415
-
416
- Vault Configuration:
417
- • Vault: {vault_name} ({vault_id prefix...})
418
- • Purpose: Learnings, conventions, patterns
419
- • Status: Ready for use
420
-
421
- 🔄 Please restart Claude Code to activate MCP features.
422
-
423
- After restart, you'll have access to:
424
- • search_knowledge - Vector search across vaults
425
- • ask_question - AI Q&A with research mode
426
- • create_knowledge - Save learnings (via /kc:learn)
427
- • update_knowledge - Update existing knowledge items
428
-
429
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
430
-
431
- 📋 Next Steps:
432
- 1. Restart Claude Code
433
- 2. Verify connection: /kc:status
434
- 3. Try learning capture: /kc:learn "Your first insight"
435
- 4. Start building: /kc:work "your feature"
436
-
437
- Need help? https://knowz.io/docs
438
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
439
- ```
440
-
441
- **Masking:**
442
- - API Key: Show only first 6 and last 4 characters (e.g., `kz_liv...wxyz`)
443
- - Vault ID: Show only first 8 characters (e.g., `vault_xy...`)
444
-
445
- #### Step 9.5: Vault Discovery and Multi-Vault Selection
446
-
447
- After MCP is configured and before showing the final success message, offer vault discovery:
448
-
449
- 1. **Fetch available vaults**
450
-
451
- Use the `list_vaults` MCP tool (if available after restart) or display guidance:
452
-
453
- ```
454
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
455
- ◆ VAULT CONFIGURATION
456
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
457
-
458
- Your account includes one vault by default:
459
- • {vault_name} ({vault_id prefix...})
460
-
461
- You can connect additional vaults for multi-vault routing.
462
- This allows queries to be automatically routed to the right vault
463
- based on the type of question (code vs. conventions vs. processes).
464
-
465
- Would you like to configure additional vaults now?
466
- ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
467
- ```
468
-
469
- Use AskUserQuestion with options:
470
- - **Yes** - Configure additional vaults now
471
- - **No** - Skip for now (can configure later with /kc:connect-mcp --configure-vaults)
472
-
473
- **STOP HERE and wait for user response.**
474
-
475
- - If "No": Proceed to write single vault to `knowzcode_vaults.md` and show success message
476
- - If "Yes": Continue with vault discovery
477
-
478
- 2. **Call list_vaults() to discover available vaults**
479
-
480
- If MCP tools are already active (rare after fresh registration):
481
- ```
482
- list_vaults(includeStats: true)
483
- ```
484
-
485
- If MCP tools not yet available (common - requires restart):
486
- ```
487
- Note: MCP tools require a restart to activate.
488
- After restart, run /kc:connect-mcp --configure-vaults to add more vaults.
489
- ```
490
-
491
- If vaults are returned, display them:
492
- ```
493
- Available Vaults:
494
- ┌────┬──────────────────────┬──────────────────┬───────────┐
495
- │ # │ Name │ Type │ Documents │
496
- ├────┼──────────────────────┼──────────────────┼───────────┤
497
- │ 1 │ KnowzCode (default) │ ecosystem │ 0 │
498
- │ 2 │ my-project-code │ code │ 1,234 │
499
- │ 3 │ engineering-wiki │ ecosystem │ 89 │
500
- └────┴──────────────────────┴──────────────────┴───────────┘
501
- ```
502
-
503
- 3. **Interactive vault selection loop**
504
-
505
- For each vault discovered (including the default one):
506
-
507
- a. Ask if user wants to connect this vault:
508
- ```
509
- Would you like to connect vault "KnowzCode" (research)?
510
- ```
511
- Options: [Yes] [No]
512
-
513
- b. If "Yes", prompt for description:
514
- ```
515
- Describe what this vault contains (for intelligent routing):
516
-
517
- Example descriptions:
518
- • "Team learnings, conventions, architectural decisions"
519
- • "Source code for the main API project"
520
- • "Company processes, onboarding docs, team structure"
521
-
522
- This helps KnowzCode route queries to the right vault automatically.
523
- ```
524
-
525
- Use AskUserQuestion to collect description (free text).
526
-
527
- c. Store vault info: ID, name, type, description
528
-
529
- d. Ask if user wants to connect another vault:
530
- ```
531
- Would you like to connect another vault?
532
- ```
533
- Options: [Yes] [No]
534
-
535
- - If "Yes" and more vaults available: Loop back to step a
536
- - If "No" or no more vaults: Exit loop
537
-
538
- 4. **Write vault configuration to knowzcode_vaults.md**
539
-
540
- Create or update `knowzcode/knowzcode_vaults.md` with selected vaults:
541
-
542
- ```markdown
543
- # KnowzCode Vault Configuration
544
-
545
- Multi-vault routing configuration for intelligent vault selection.
546
-
547
- ---
548
-
549
- ## Connected Vaults
550
-
551
- ### {vault_id_1}
552
- - **Name**: {vault_name}
553
- - **ID**: {vault_id}
554
- - **Type**: {code | ecosystem | finalizations}
555
- - **Description**: {user_provided_description}
556
-
557
- ### {vault_id_2}
558
- - **Name**: {vault_name}
559
- - **ID**: {vault_id}
560
- - **Type**: {code | ecosystem | finalizations}
561
- - **Description**: {user_provided_description}
562
-
563
- ---
564
-
565
- ## Vault Routing Rules
566
-
567
- - **Code questions** (implementations, files, structure) → {first code vault}
568
- - **Convention questions** (patterns, decisions, best practices) → {first ecosystem vault}
569
- - **Completion records** → {first finalizations vault}
570
- - **Learning capture** → {default ecosystem vault}
571
- ```
572
-
573
- **Null GUID detection**: After writing vault configuration to `knowzcode_vaults.md`, check for entries with empty **ID** fields. If found, prompt: "Found {N} default vault(s) not yet created. Create them now?" On confirmation, create each vault via MCP and update the ID fields.
574
-
575
- 5. **Show vault configuration summary**
576
-
577
- After writing configuration:
578
- ```
579
- Vault configuration saved to knowzcode/knowzcode_vaults.md
580
-
581
- Connected Vaults:
582
- • KnowzCode (ecosystem) - "Team learnings and conventions"
583
- • my-code (code) - "Source code for API project"
584
-
585
- Queries will be automatically routed based on your descriptions.
586
- You can edit knowzcode/knowzcode_vaults.md to update routing rules.
587
- ```
588
-
589
- ## Error Handling
590
-
591
- ### Email Already Registered (HTTP 409)
592
-
593
- ```
594
- ⚠️ Email Already Registered
595
-
596
- The email {email} is already associated with a KnowzCode account.
597
-
598
- Options:
599
- 1. Use a different email → Run /kc:register again
600
- 2. Retrieve existing API key → Visit https://knowz.io/api-keys
601
- 3. Reset password → https://knowz.io/forgot-password
602
-
603
- If this is your account, you can configure your existing key:
604
- /kc:connect-mcp <your-existing-api-key>
605
- ```
606
-
607
- ### Invalid Input (HTTP 400)
608
-
609
- ```
610
- ❌ Registration Failed
611
-
612
- The server reported validation errors:
613
- {error_message_from_response}
614
-
615
- Please correct the issue and try again.
616
- ```
617
-
618
- Return to the step corresponding to the invalid field.
619
-
620
- ### Rate Limited (HTTP 429)
621
-
622
- ```
623
- ⏳ Too Many Requests
624
-
625
- Registration is temporarily rate limited.
626
- Please wait a few minutes and try again.
627
-
628
- If you continue to see this error, contact support:
629
- https://knowz.io/support
630
- ```
631
-
632
- ### Network Error
633
-
634
- ```
635
- ❌ Network Error
636
-
637
- Cannot reach KnowzCode registration server.
638
-
639
- Troubleshooting:
640
- 1. Check your internet connection
641
- 2. Verify firewall/proxy settings allow HTTPS to api.knowz.io (or api.dev.knowz.io for --dev)
642
- 3. Try again in a few moments
643
-
644
- If the issue persists:
645
- • Status page: https://status.knowz.io
646
- • Support: https://knowz.io/support
647
- ```
648
-
649
- ### Server Error (HTTP 500+)
650
-
651
- ```
652
- ❌ Server Error
653
-
654
- KnowzCode registration service encountered an error.
655
-
656
- This is not your fault. Please:
657
- 1. Try again in a few minutes
658
- 2. Check status: https://status.knowz.io
659
- 3. Contact support if persists: https://knowz.io/support
660
- ```
661
-
662
- ### MCP Configuration Failed
663
-
664
- If registration succeeds but MCP configuration fails:
665
-
666
- ```
667
- ⚠️ Account Created, but MCP Configuration Failed
668
-
669
- Your account was created successfully:
670
- • Email: {email}
671
- • API Key: {masked_key}
672
- • Vault: {vault_name} ({vault_id prefix...})
673
-
674
- However, automatic MCP configuration failed:
675
- {error_details}
676
-
677
- You can configure manually:
678
- /kc:connect-mcp {masked_key}
679
-
680
- Or visit https://knowz.io/api-keys to retrieve your key later.
681
- ```
682
-
683
- ### API Response Missing Vault ID
684
-
685
- If registration succeeds but API returns no vault_id:
686
-
687
- ```
688
- ⚠️ Account Created, but Vault Not Provisioned
689
-
690
- Your account was created and MCP is configured:
691
- • Email: {email}
692
- • API Key: {masked_key}
693
- • MCP: Configured
694
-
695
- However, no vault was auto-created. This may indicate:
696
- • Account provisioning is still in progress
697
- • Server-side configuration needed
698
-
699
- You can:
700
- 1. Wait a few minutes and run /kc:status to check
701
- 2. Contact support: https://knowz.io/support
702
- 3. Manually configure vault later: /kc:connect-mcp --configure-vaults
703
- ```
704
-
705
- ## Security Considerations
706
-
707
- ### Data Protection
708
- - **HTTPS only** - All API calls use HTTPS
709
- - **Password not stored** - Password sent once, never saved locally
710
- - **Password not logged** - Never display password in output
711
- - **Minimal data** - Only collect what's needed for registration
712
-
713
- ### API Key Security
714
- - **Mask displayed keys**: Show only `kz_abc...xyz` format (first 6 + last 4 chars)
715
- - **Never log full keys**: Exclude from any diagnostic output
716
- - **Warn about project scope**: If `--scope project`, warn that API key will be in `.mcp.json`
717
- - **Recommend local scope**: Default to most secure option
718
-
719
- ## Scope Comparison
720
-
721
- | Scope | Storage | Visibility | Best For |
722
- |-------|---------|------------|----------|
723
- | **local** (default) | Claude Code internal | Only you, this project | Personal development |
724
- | **project** | `.mcp.json` (git) | Team via git | Shared team key |
725
- | **user** | Claude Code user config | Only you, all projects | Personal, multi-project |
726
-
727
- ## Related Commands
728
-
729
- - `/kc:connect-mcp` - Configure MCP with existing API key
730
- - `/kc:status` - Check MCP connection status
731
- - `/kc:init` - Initialize KnowzCode in project
732
-
733
- Execute this registration flow now.
1
+ ---
2
+ description: Register for KnowzCode and configure MCP server automatically
3
+ argument-hint: "[--scope <local|project|user>] [--dev]"
4
+ ---
5
+
6
+ # KnowzCode Registration
7
+
8
+ You are the **KnowzCode Registration Agent**. Your task is to guide users through account registration and automatically configure the MCP server connection.
9
+
10
+ ## Command Syntax
11
+
12
+ ```bash
13
+ /kc:register [--scope <local|project|user>] [--dev]
14
+ ```
15
+
16
+ **Parameters:**
17
+ - `--scope <scope>` - Optional. Configuration scope: local (default), project, or user
18
+ - `--dev` - Optional. Use development environment instead of production
19
+
20
+ **Environments:**
21
+ | Environment | API Endpoint | MCP Endpoint | When to Use |
22
+ |:------------|:-------------|:-------------|:------------|
23
+ | **Production** (default) | `https://api.knowz.io/api/v1/auth/register` | `https://mcp.knowz.io/mcp` | Normal usage |
24
+ | **Development** | `https://api.dev.knowz.io/api/v1/auth/register` | `https://mcp.dev.knowz.io/mcp` | Testing new features |
25
+
26
+ **Examples:**
27
+ ```bash
28
+ # Standard registration (production)
29
+ /kc:register
30
+
31
+ # Register with project-wide scope (production)
32
+ /kc:register --scope project
33
+
34
+ # Register with user-wide scope (production)
35
+ /kc:register --scope user
36
+
37
+ # Register against development environment
38
+ /kc:register --dev
39
+
40
+ # Development with specific scope
41
+ /kc:register --dev --scope project
42
+ ```
43
+
44
+ ## What Registration Provides
45
+
46
+ Registering for KnowzCode gives you:
47
+
48
+ - **API Key** - Unique key for MCP server authentication
49
+ - **KnowzCode Vault** - Auto-created vault for learnings, conventions, and patterns
50
+ - **Vector Search** - AI-powered code search across your projects
51
+ - **Spec Queries** - Query your specifications and documentation
52
+ - **Context Retrieval** - Intelligent context for agent decisions
53
+ - **Dependency Analysis** - Understand code relationships
54
+
55
+ **Free tier includes:**
56
+ - 1,000 API calls/month
57
+ - Single user
58
+ - Basic vector search
59
+
60
+ **Upgrades available at:** https://knowz.io/pricing
61
+
62
+ ## API Response Structure
63
+
64
+ The registration API returns:
65
+
66
+ ```json
67
+ {
68
+ "api_key": "kz_live_abc123...",
69
+ "vault_id": "vault_xyz789...",
70
+ "vault_name": "KnowzCode"
71
+ }
72
+ ```
73
+
74
+ This vault is automatically configured for you - no manual setup required.
75
+
76
+ ## Your Task
77
+
78
+ Guide the user through registration **step-by-step, one question at a time**. This is an interactive conversational flow - do NOT ask multiple questions at once.
79
+
80
+ **CRITICAL: Interactive Flow Rules**
81
+ 1. Ask ONE question, then WAIT for user response
82
+ 2. After each response, validate and then ask the NEXT question
83
+ 3. Never combine multiple questions into a single message
84
+ 4. Use AskUserQuestion tool for each input collection step
85
+ 5. After each AskUserQuestion, STOP and wait for the user's answer
86
+
87
+ ### Conversation Flow Summary
88
+
89
+ ```
90
+ YOU USER
91
+ ─────────────────────────────────────────────────
92
+ 1. Check MCP config
93
+ 2. Welcome + Ask name ──────────► [User types name]
94
+ 3. Validate name
95
+ 4. Ask email ───────────────────► [User types email]
96
+ 5. Validate email
97
+ 6. Ask password ────────────────► [User types password]
98
+ 7. Validate password
99
+ 8. Show summary + confirm ──────► [User confirms: Yes/No/Edit]
100
+ 9. Call API
101
+ 10. Configure MCP + base vault
102
+ 11. Vault discovery ───────────► [User: Yes/No to configure more]
103
+ 12. (If Yes) Vault selection ──► [User selects vaults + descriptions]
104
+ 13. Write vault config
105
+ 14. Show success
106
+ ```
107
+
108
+ ### Steps to Execute
109
+
110
+ #### Step 1: Check Existing Configuration
111
+
112
+ 1. Check if MCP server already configured:
113
+ ```bash
114
+ CLAUDECODE= claude mcp get knowz
115
+ ```
116
+
117
+ 2. If already configured, display:
118
+ ```
119
+ ⚠️ KnowzCode MCP server is already configured.
120
+
121
+ Options:
122
+ 1. Keep existing configuration (abort registration)
123
+ 2. Remove existing and register new account
124
+
125
+ If you want to register a new account, the existing configuration
126
+ will be replaced with the new API key.
127
+ ```
128
+
129
+ Use AskUserQuestion to get user choice. If they choose to keep existing, STOP.
130
+ If they choose to continue, run `CLAUDECODE= claude mcp remove knowz` first.
131
+
132
+ 3. If not configured: Continue to Step 2.
133
+
134
+ #### Step 2: Welcome Message and First Question
135
+
136
+ Display welcome message, then IMMEDIATELY ask the first question (name):
137
+
138
+ ```
139
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
140
+ ◆ KnowzCode REGISTRATION
141
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
142
+
143
+ Welcome! Let's set up your KnowzCode account.
144
+
145
+ This will:
146
+ 1. Create your KnowzCode account
147
+ 2. Generate an API key
148
+ 3. Configure the MCP server automatically
149
+
150
+ I'll ask you a few questions one at a time.
151
+ All data transmitted securely over HTTPS.
152
+ Privacy policy: https://knowz.io/privacy
153
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
154
+ ```
155
+
156
+ **Then immediately use AskUserQuestion** to collect name:
157
+
158
+ **Question:** "What name would you like for your account?"
159
+
160
+ **STOP HERE and wait for user response.**
161
+
162
+ #### Step 3: Validate Name and Ask Email
163
+
164
+ After receiving the name:
165
+
166
+ **Validation:**
167
+ - Must be non-empty
168
+ - Must be 2-100 characters
169
+ - Allow: letters, spaces, hyphens, apostrophes
170
+
171
+ If invalid, explain the issue and re-prompt for name.
172
+
173
+ If valid, store the name and proceed to ask for email.
174
+
175
+ #### Step 4: Ask for Email
176
+
177
+ Use AskUserQuestion to collect the user's email:
178
+
179
+ **Question:** "What is your email address?"
180
+
181
+ **STOP HERE and wait for user response.**
182
+
183
+ #### Step 5: Validate Email and Ask Password
184
+
185
+ After receiving the email:
186
+
187
+ **Validation:**
188
+ - Must match email pattern (contains @ and domain)
189
+ - No leading/trailing whitespace
190
+
191
+ If invalid:
192
+ ```
193
+ ⚠️ Invalid email format.
194
+ Please enter a valid email address (e.g., user@example.com)
195
+ ```
196
+ Re-prompt for email.
197
+
198
+ If valid, store the email and proceed to ask for password.
199
+
200
+ Use AskUserQuestion to collect the password:
201
+
202
+ **Question:** "Create a password (minimum 8 characters)"
203
+
204
+ Display this note with the question:
205
+ ```
206
+ Your password will be sent securely over HTTPS to create your account.
207
+ It will NOT be stored locally or displayed in any logs.
208
+ ```
209
+
210
+ **STOP HERE and wait for user response.**
211
+
212
+ #### Step 6: Validate Password
213
+
214
+ After receiving the password:
215
+
216
+ **Validation:**
217
+ - Minimum 8 characters
218
+
219
+ If invalid:
220
+ ```
221
+ ⚠️ Password must be at least 8 characters.
222
+ ```
223
+ Re-prompt for password.
224
+
225
+ If valid, store the password and proceed to confirmation.
226
+
227
+ #### Step 7: Confirm Details
228
+
229
+ Display collected information for confirmation:
230
+
231
+ ```
232
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
233
+ ◆ CONFIRM REGISTRATION DETAILS
234
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
235
+
236
+ Please confirm your registration details:
237
+
238
+ Name: {collected_name}
239
+ Email: {collected_email}
240
+ Password: ********
241
+
242
+ Is this correct?
243
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
244
+ ```
245
+
246
+ Use AskUserQuestion with options:
247
+ - **Yes** - Proceed with registration
248
+ - **No** - Cancel registration
249
+ - **Edit** - Go back and re-enter information
250
+
251
+ **STOP HERE and wait for user response.**
252
+
253
+ - If "Edit": Return to Step 2 to re-collect all information (name first).
254
+ - If "No": Display cancellation message and STOP.
255
+ - If "Yes": Proceed to Step 8.
256
+
257
+ #### Step 8: Call Registration API
258
+
259
+ **Determine endpoint based on `--dev` flag:**
260
+ - If `--dev` flag present: Use `https://api.dev.knowz.io/api/v1/auth/register`
261
+ - Otherwise (default): Use `https://api.knowz.io/api/v1/auth/register`
262
+
263
+ Make HTTP POST request to registration endpoint:
264
+
265
+ ```bash
266
+ # Production (default)
267
+ curl -X POST https://api.knowz.io/api/v1/auth/register \
268
+ -H "Content-Type: application/json" \
269
+ -d '{
270
+ "name": "{collected_name}",
271
+ "email": "{collected_email}",
272
+ "password": "{collected_password}"
273
+ }'
274
+
275
+ # Development (with --dev flag)
276
+ curl -X POST https://api.dev.knowz.io/api/v1/auth/register \
277
+ -H "Content-Type: application/json" \
278
+ -d '{
279
+ "name": "{collected_name}",
280
+ "email": "{collected_email}",
281
+ "password": "{collected_password}"
282
+ }'
283
+ ```
284
+
285
+ **Handle Response Codes:**
286
+
287
+ | Code | Meaning | Action |
288
+ |------|---------|--------|
289
+ | 200/201 | Success | Extract API key AND vault_id, continue to Step 9 |
290
+ | 400 | Validation error | Show error details, return to relevant step |
291
+ | 409 | Email exists | Show recovery options (see Error Handling) |
292
+ | 429 | Rate limited | Show wait message (see Error Handling) |
293
+ | 500+ | Server error | Show error and support link |
294
+
295
+ **Parse Response:**
296
+ - Extract `api_key` (or `apiKey` or `token` field)
297
+ - Extract `vault_id` (auto-created "KnowzCode" vault)
298
+ - Extract `vault_name` (typically "KnowzCode")
299
+
300
+ #### Step 9: Configure MCP, Vault, and Show Success
301
+
302
+ **On successful registration:**
303
+
304
+ 1. **Extract from response:**
305
+ - API key (look for `apiKey`, `api_key`, or `token` field)
306
+ - Vault ID (look for `vault_id` or `vaultId` field)
307
+ - Vault name (look for `vault_name` or `vaultName` field, default: "KnowzCode")
308
+
309
+ 2. **Parse scope** from command arguments (default: `local`)
310
+
311
+ 3. **If scope is `project`**, show security warning:
312
+ ```
313
+ ⚠️ Security Note: Project Scope Selected
314
+
315
+ With project scope, your API key will be stored in .mcp.json
316
+ which is typically committed to git.
317
+
318
+ This is appropriate for:
319
+ • Team/shared API keys
320
+ • CI/CD automation keys
321
+
322
+ For personal keys, consider using --scope local (default)
323
+
324
+ Continue with project scope?
325
+ ```
326
+ Use AskUserQuestion to confirm. If user declines, use `local` scope instead.
327
+
328
+ 4. **Configure MCP server** (use same environment as registration):
329
+ ```bash
330
+ # Production (default)
331
+ claude mcp add --transport http \
332
+ --scope <chosen-scope> \
333
+ knowz \
334
+ https://mcp.knowz.io/mcp \
335
+ --header "Authorization: Bearer <api_key>" \
336
+ --header "X-Project-Path: $(pwd)"
337
+
338
+ # Development (with --dev flag)
339
+ claude mcp add --transport http \
340
+ --scope <chosen-scope> \
341
+ knowz \
342
+ https://mcp.dev.knowz.io/mcp \
343
+ --header "Authorization: Bearer <api_key>" \
344
+ --header "X-Project-Path: $(pwd)"
345
+ ```
346
+
347
+ 5. **Verify MCP configuration**:
348
+ ```bash
349
+ CLAUDECODE= claude mcp get knowz
350
+ ```
351
+
352
+ 6. **Configure vault in mcp_config.md**:
353
+
354
+ Check if `knowzcode/mcp_config.md` exists:
355
+ - If exists: **Merge** vault configuration (preserve existing Code Vault if set)
356
+ - If not exists: Create from template with vault configured
357
+
358
+ Update `knowzcode/mcp_config.md` with:
359
+ ```markdown
360
+ # KnowzCode MCP Configuration
361
+
362
+ ## Connection Status
363
+ - **Connected**: Yes
364
+ - **Endpoint**: {endpoint}
365
+ - **Last Verified**: {ISO timestamp}
366
+
367
+ ---
368
+
369
+ ## Vaults
370
+
371
+ ### Ecosystem Vault (Primary)
372
+ - **Vault ID**: {vault_id from registration}
373
+ - **Vault Name**: {vault_name from registration}
374
+ - **Purpose**: Decisions, conventions, security, integrations, business rules
375
+ - **Auto-configured**: Yes (via /kc:register)
376
+
377
+ ### Code Vault (Optional)
378
+ - **Vault ID**: (not configured)
379
+ - **Purpose**: Implementation patterns, workarounds, performance
380
+ - **Note**: Code search uses local grep/glob by default.
381
+ Configure code vault for large codebases with /kc:connect-mcp --configure-vaults
382
+
383
+ ### Finalizations Vault (Optional)
384
+ - **Vault ID**: (not configured)
385
+ - **Purpose**: WorkGroup completion summaries, outcome records
386
+ - **Note**: Finalizations vault tracks completed work.
387
+ Configure for teams that want searchable completion history.
388
+ ```
389
+
390
+ **Edge case - existing vault config**:
391
+ If `knowzcode/mcp_config.md` already has an Ecosystem Vault ID configured:
392
+ - Use AskUserQuestion: "You already have a vault configured. Replace with new vault from registration? [Yes/No/Keep both]"
393
+ - If "Yes": Replace Ecosystem Vault ID
394
+ - If "No": Keep existing vault config
395
+ - If "Keep both": Add new vault as secondary
396
+
397
+ 7. **Display success message** with vault info:
398
+
399
+ ```
400
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
401
+ ◆ KnowzCode REGISTRATION COMPLETE
402
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
403
+
404
+ ✅ Account created and configured!
405
+
406
+ Account Details:
407
+ • Email: {email}
408
+ • API Key: {masked_key}
409
+
410
+ MCP Configuration:
411
+ • Scope: {chosen-scope}
412
+ • Endpoint: {endpoint}
413
+ • Environment: {Production OR Development}
414
+ • Status: Configured
415
+
416
+ Vault Configuration:
417
+ • Vault: {vault_name} ({vault_id prefix...})
418
+ • Purpose: Learnings, conventions, patterns
419
+ • Status: Ready for use
420
+
421
+ 🔄 Please restart Claude Code to activate MCP features.
422
+
423
+ After restart, you'll have access to:
424
+ • search_knowledge - Vector search across vaults
425
+ • ask_question - AI Q&A with research mode
426
+ • create_knowledge - Save learnings (via /kc:learn)
427
+ • update_knowledge - Update existing knowledge items
428
+
429
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
430
+
431
+ 📋 Next Steps:
432
+ 1. Restart Claude Code
433
+ 2. Verify connection: /kc:status
434
+ 3. Try learning capture: /kc:learn "Your first insight"
435
+ 4. Start building: /kc:work "your feature"
436
+
437
+ Need help? https://knowz.io/docs
438
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
439
+ ```
440
+
441
+ **Masking:**
442
+ - API Key: Show only first 6 and last 4 characters (e.g., `kz_liv...wxyz`)
443
+ - Vault ID: Show only first 8 characters (e.g., `vault_xy...`)
444
+
445
+ #### Step 9.5: Vault Discovery and Multi-Vault Selection
446
+
447
+ After MCP is configured and before showing the final success message, offer vault discovery:
448
+
449
+ 1. **Fetch available vaults**
450
+
451
+ Use the `list_vaults` MCP tool (if available after restart) or display guidance:
452
+
453
+ ```
454
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
455
+ ◆ VAULT CONFIGURATION
456
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
457
+
458
+ Your account includes one vault by default:
459
+ • {vault_name} ({vault_id prefix...})
460
+
461
+ You can connect additional vaults for multi-vault routing.
462
+ This allows queries to be automatically routed to the right vault
463
+ based on the type of question (code vs. conventions vs. processes).
464
+
465
+ Would you like to configure additional vaults now?
466
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
467
+ ```
468
+
469
+ Use AskUserQuestion with options:
470
+ - **Yes** - Configure additional vaults now
471
+ - **No** - Skip for now (can configure later with /kc:connect-mcp --configure-vaults)
472
+
473
+ **STOP HERE and wait for user response.**
474
+
475
+ - If "No": Proceed to write single vault to `knowzcode_vaults.md` and show success message
476
+ - If "Yes": Continue with vault discovery
477
+
478
+ 2. **Call list_vaults() to discover available vaults**
479
+
480
+ If MCP tools are already active (rare after fresh registration):
481
+ ```
482
+ list_vaults(includeStats: true)
483
+ ```
484
+
485
+ If MCP tools not yet available (common - requires restart):
486
+ ```
487
+ Note: MCP tools require a restart to activate.
488
+ After restart, run /kc:connect-mcp --configure-vaults to add more vaults.
489
+ ```
490
+
491
+ If vaults are returned, display them:
492
+ ```
493
+ Available Vaults:
494
+ ┌────┬──────────────────────┬──────────────────┬───────────┐
495
+ │ # │ Name │ Type │ Documents │
496
+ ├────┼──────────────────────┼──────────────────┼───────────┤
497
+ │ 1 │ KnowzCode (default) │ ecosystem │ 0 │
498
+ │ 2 │ my-project-code │ code │ 1,234 │
499
+ │ 3 │ engineering-wiki │ ecosystem │ 89 │
500
+ └────┴──────────────────────┴──────────────────┴───────────┘
501
+ ```
502
+
503
+ 3. **Interactive vault selection loop**
504
+
505
+ For each vault discovered (including the default one):
506
+
507
+ a. Ask if user wants to connect this vault:
508
+ ```
509
+ Would you like to connect vault "KnowzCode" (research)?
510
+ ```
511
+ Options: [Yes] [No]
512
+
513
+ b. If "Yes", prompt for description:
514
+ ```
515
+ Describe what this vault contains (for intelligent routing):
516
+
517
+ Example descriptions:
518
+ • "Team learnings, conventions, architectural decisions"
519
+ • "Source code for the main API project"
520
+ • "Company processes, onboarding docs, team structure"
521
+
522
+ This helps KnowzCode route queries to the right vault automatically.
523
+ ```
524
+
525
+ Use AskUserQuestion to collect description (free text).
526
+
527
+ c. Store vault info: ID, name, type, description
528
+
529
+ d. Ask if user wants to connect another vault:
530
+ ```
531
+ Would you like to connect another vault?
532
+ ```
533
+ Options: [Yes] [No]
534
+
535
+ - If "Yes" and more vaults available: Loop back to step a
536
+ - If "No" or no more vaults: Exit loop
537
+
538
+ 4. **Write vault configuration to knowzcode_vaults.md**
539
+
540
+ Create or update `knowzcode/knowzcode_vaults.md` with selected vaults:
541
+
542
+ ```markdown
543
+ # KnowzCode Vault Configuration
544
+
545
+ Multi-vault routing configuration for intelligent vault selection.
546
+
547
+ ---
548
+
549
+ ## Connected Vaults
550
+
551
+ ### {vault_id_1}
552
+ - **Name**: {vault_name}
553
+ - **ID**: {vault_id}
554
+ - **Type**: {code | ecosystem | finalizations}
555
+ - **Description**: {user_provided_description}
556
+
557
+ ### {vault_id_2}
558
+ - **Name**: {vault_name}
559
+ - **ID**: {vault_id}
560
+ - **Type**: {code | ecosystem | finalizations}
561
+ - **Description**: {user_provided_description}
562
+
563
+ ---
564
+
565
+ ## Vault Routing Rules
566
+
567
+ - **Code questions** (implementations, files, structure) → {first code vault}
568
+ - **Convention questions** (patterns, decisions, best practices) → {first ecosystem vault}
569
+ - **Completion records** → {first finalizations vault}
570
+ - **Learning capture** → {default ecosystem vault}
571
+ ```
572
+
573
+ **Null GUID detection**: After writing vault configuration to `knowzcode_vaults.md`, check for entries with empty **ID** fields. If found, prompt: "Found {N} default vault(s) not yet created. Create them now?" On confirmation, create each vault via MCP and update the ID fields.
574
+
575
+ 5. **Show vault configuration summary**
576
+
577
+ After writing configuration:
578
+ ```
579
+ Vault configuration saved to knowzcode/knowzcode_vaults.md
580
+
581
+ Connected Vaults:
582
+ • KnowzCode (ecosystem) - "Team learnings and conventions"
583
+ • my-code (code) - "Source code for API project"
584
+
585
+ Queries will be automatically routed based on your descriptions.
586
+ You can edit knowzcode/knowzcode_vaults.md to update routing rules.
587
+ ```
588
+
589
+ ## Error Handling
590
+
591
+ ### Email Already Registered (HTTP 409)
592
+
593
+ ```
594
+ ⚠️ Email Already Registered
595
+
596
+ The email {email} is already associated with a KnowzCode account.
597
+
598
+ Options:
599
+ 1. Use a different email → Run /kc:register again
600
+ 2. Retrieve existing API key → Visit https://knowz.io/api-keys
601
+ 3. Reset password → https://knowz.io/forgot-password
602
+
603
+ If this is your account, you can configure your existing key:
604
+ /kc:connect-mcp <your-existing-api-key>
605
+ ```
606
+
607
+ ### Invalid Input (HTTP 400)
608
+
609
+ ```
610
+ ❌ Registration Failed
611
+
612
+ The server reported validation errors:
613
+ {error_message_from_response}
614
+
615
+ Please correct the issue and try again.
616
+ ```
617
+
618
+ Return to the step corresponding to the invalid field.
619
+
620
+ ### Rate Limited (HTTP 429)
621
+
622
+ ```
623
+ ⏳ Too Many Requests
624
+
625
+ Registration is temporarily rate limited.
626
+ Please wait a few minutes and try again.
627
+
628
+ If you continue to see this error, contact support:
629
+ https://knowz.io/support
630
+ ```
631
+
632
+ ### Network Error
633
+
634
+ ```
635
+ ❌ Network Error
636
+
637
+ Cannot reach KnowzCode registration server.
638
+
639
+ Troubleshooting:
640
+ 1. Check your internet connection
641
+ 2. Verify firewall/proxy settings allow HTTPS to api.knowz.io (or api.dev.knowz.io for --dev)
642
+ 3. Try again in a few moments
643
+
644
+ If the issue persists:
645
+ • Status page: https://status.knowz.io
646
+ • Support: https://knowz.io/support
647
+ ```
648
+
649
+ ### Server Error (HTTP 500+)
650
+
651
+ ```
652
+ ❌ Server Error
653
+
654
+ KnowzCode registration service encountered an error.
655
+
656
+ This is not your fault. Please:
657
+ 1. Try again in a few minutes
658
+ 2. Check status: https://status.knowz.io
659
+ 3. Contact support if persists: https://knowz.io/support
660
+ ```
661
+
662
+ ### MCP Configuration Failed
663
+
664
+ If registration succeeds but MCP configuration fails:
665
+
666
+ ```
667
+ ⚠️ Account Created, but MCP Configuration Failed
668
+
669
+ Your account was created successfully:
670
+ • Email: {email}
671
+ • API Key: {masked_key}
672
+ • Vault: {vault_name} ({vault_id prefix...})
673
+
674
+ However, automatic MCP configuration failed:
675
+ {error_details}
676
+
677
+ You can configure manually:
678
+ /kc:connect-mcp {masked_key}
679
+
680
+ Or visit https://knowz.io/api-keys to retrieve your key later.
681
+ ```
682
+
683
+ ### API Response Missing Vault ID
684
+
685
+ If registration succeeds but API returns no vault_id:
686
+
687
+ ```
688
+ ⚠️ Account Created, but Vault Not Provisioned
689
+
690
+ Your account was created and MCP is configured:
691
+ • Email: {email}
692
+ • API Key: {masked_key}
693
+ • MCP: Configured
694
+
695
+ However, no vault was auto-created. This may indicate:
696
+ • Account provisioning is still in progress
697
+ • Server-side configuration needed
698
+
699
+ You can:
700
+ 1. Wait a few minutes and run /kc:status to check
701
+ 2. Contact support: https://knowz.io/support
702
+ 3. Manually configure vault later: /kc:connect-mcp --configure-vaults
703
+ ```
704
+
705
+ ## Security Considerations
706
+
707
+ ### Data Protection
708
+ - **HTTPS only** - All API calls use HTTPS
709
+ - **Password not stored** - Password sent once, never saved locally
710
+ - **Password not logged** - Never display password in output
711
+ - **Minimal data** - Only collect what's needed for registration
712
+
713
+ ### API Key Security
714
+ - **Mask displayed keys**: Show only `kz_abc...xyz` format (first 6 + last 4 chars)
715
+ - **Never log full keys**: Exclude from any diagnostic output
716
+ - **Warn about project scope**: If `--scope project`, warn that API key will be in `.mcp.json`
717
+ - **Recommend local scope**: Default to most secure option
718
+
719
+ ## Scope Comparison
720
+
721
+ | Scope | Storage | Visibility | Best For |
722
+ |-------|---------|------------|----------|
723
+ | **local** (default) | Claude Code internal | Only you, this project | Personal development |
724
+ | **project** | `.mcp.json` (git) | Team via git | Shared team key |
725
+ | **user** | Claude Code user config | Only you, all projects | Personal, multi-project |
726
+
727
+ ## Related Commands
728
+
729
+ - `/kc:connect-mcp` - Configure MCP with existing API key
730
+ - `/kc:status` - Check MCP connection status
731
+ - `/kc:init` - Initialize KnowzCode in project
732
+
733
+ Execute this registration flow now.