knowzcode 0.1.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 (73) hide show
  1. package/.claude-plugin/marketplace.json +55 -0
  2. package/.claude-plugin/plugin.json +8 -0
  3. package/LICENSE +121 -0
  4. package/README.md +223 -0
  5. package/agents/analyst.md +121 -0
  6. package/agents/architect.md +121 -0
  7. package/agents/builder.md +155 -0
  8. package/agents/closer.md +148 -0
  9. package/agents/knowledge-migrator.md +349 -0
  10. package/agents/microfix-specialist.md +140 -0
  11. package/agents/reviewer.md +220 -0
  12. package/agents/update-coordinator.md +405 -0
  13. package/bin/knowzcode.mjs +869 -0
  14. package/commands/audit.md +108 -0
  15. package/commands/connect-mcp.md +507 -0
  16. package/commands/fix.md +107 -0
  17. package/commands/init.md +320 -0
  18. package/commands/learn.md +308 -0
  19. package/commands/plan.md +125 -0
  20. package/commands/register.md +724 -0
  21. package/commands/status.md +291 -0
  22. package/commands/telemetry-setup.md +368 -0
  23. package/commands/telemetry.md +188 -0
  24. package/commands/work.md +390 -0
  25. package/knowzcode/automation_manifest.md +59 -0
  26. package/knowzcode/claude_code_execution.md +133 -0
  27. package/knowzcode/enterprise/compliance_manifest.md +132 -0
  28. package/knowzcode/enterprise/compliance_status.md +30 -0
  29. package/knowzcode/enterprise/guidelines/code-quality.md +67 -0
  30. package/knowzcode/enterprise/guidelines/custom/.gitkeep +0 -0
  31. package/knowzcode/enterprise/guidelines/security.md +355 -0
  32. package/knowzcode/enterprise/reports/.gitkeep +0 -0
  33. package/knowzcode/enterprise/templates/guideline-template.md +55 -0
  34. package/knowzcode/gitignore.template +13 -0
  35. package/knowzcode/knowzcode_architecture.md +51 -0
  36. package/knowzcode/knowzcode_log.md +142 -0
  37. package/knowzcode/knowzcode_loop.md +515 -0
  38. package/knowzcode/knowzcode_project.md +233 -0
  39. package/knowzcode/knowzcode_tracker.md +40 -0
  40. package/knowzcode/knowzcode_vaults.md +104 -0
  41. package/knowzcode/mcp_config.md +166 -0
  42. package/knowzcode/planning/Readme.md +6 -0
  43. package/knowzcode/platform_adapters.md +388 -0
  44. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -0
  45. package/knowzcode/prompts/Investigate_Codebase.md +227 -0
  46. package/knowzcode/prompts/Migrate_Knowledge.md +301 -0
  47. package/knowzcode/prompts/Refactor_Node.md +72 -0
  48. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -0
  49. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -0
  50. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -0
  51. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -0
  52. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -0
  53. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -0
  54. package/knowzcode/specs/Readme.md +10 -0
  55. package/knowzcode/telemetry_config.md +89 -0
  56. package/knowzcode/user_preferences.md +120 -0
  57. package/package.json +53 -0
  58. package/skills/alias-resolver.json +15 -0
  59. package/skills/architecture-diff.json +12 -0
  60. package/skills/check-installation-status.json +14 -0
  61. package/skills/continue.md +105 -0
  62. package/skills/environment-guard.json +12 -0
  63. package/skills/generate-workgroup-id.json +25 -0
  64. package/skills/install-knowzcode.json +21 -0
  65. package/skills/load-core-context.json +18 -0
  66. package/skills/log-entry-builder.json +15 -0
  67. package/skills/spec-quality-check.json +14 -0
  68. package/skills/spec-template.json +15 -0
  69. package/skills/spec-validator.json +25 -0
  70. package/skills/start-work.md +224 -0
  71. package/skills/tracker-scan.json +12 -0
  72. package/skills/tracker-update.json +28 -0
  73. package/skills/validate-installation.json +14 -0
@@ -0,0 +1,724 @@
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
+ claude mcp get knowzcode
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 `claude mcp remove knowzcode` 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
+ knowzcode \
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
+ knowzcode \
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
+ claude mcp get knowzcode
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
+ ### Research Vault (Primary)
372
+ - **Vault ID**: {vault_id from registration}
373
+ - **Vault Name**: {vault_name from registration}
374
+ - **Purpose**: Learnings, conventions, decisions, patterns
375
+ - **Auto-configured**: Yes (via /kc:register)
376
+
377
+ ### Code Vault (Optional)
378
+ - **Vault ID**: (not configured)
379
+ - **Purpose**: Indexed source code for semantic search
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
+
384
+ **Edge case - existing vault config**:
385
+ If `knowzcode/mcp_config.md` already has a Research Vault ID configured:
386
+ - Use AskUserQuestion: "You already have a vault configured. Replace with new vault from registration? [Yes/No/Keep both]"
387
+ - If "Yes": Replace Research Vault ID
388
+ - If "No": Keep existing vault config
389
+ - If "Keep both": Add new vault as secondary
390
+
391
+ 7. **Display success message** with vault info:
392
+
393
+ ```
394
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
395
+ ◆ KnowzCode REGISTRATION COMPLETE
396
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
397
+
398
+ ✅ Account created and configured!
399
+
400
+ Account Details:
401
+ • Email: {email}
402
+ • API Key: {masked_key}
403
+
404
+ MCP Configuration:
405
+ • Scope: {chosen-scope}
406
+ • Endpoint: {endpoint}
407
+ • Environment: {Production OR Development}
408
+ • Status: Configured
409
+
410
+ Vault Configuration:
411
+ • Vault: {vault_name} ({vault_id prefix...})
412
+ • Purpose: Learnings, conventions, patterns
413
+ • Status: Ready for use
414
+
415
+ 🔄 Please restart Claude Code to activate MCP features.
416
+
417
+ After restart, you'll have access to:
418
+ • search_knowledge - Vector search across vaults
419
+ • ask_question - AI Q&A with research mode
420
+ • create_knowledge - Save learnings (via /kc:learn)
421
+ • update_knowledge - Update existing knowledge items
422
+
423
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
424
+
425
+ 📋 Next Steps:
426
+ 1. Restart Claude Code
427
+ 2. Verify connection: /kc:status
428
+ 3. Try learning capture: /kc:learn "Your first insight"
429
+ 4. Start building: /kc:work "your feature"
430
+
431
+ Need help? https://knowz.io/docs
432
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
433
+ ```
434
+
435
+ **Masking:**
436
+ - API Key: Show only first 6 and last 4 characters (e.g., `kz_liv...wxyz`)
437
+ - Vault ID: Show only first 8 characters (e.g., `vault_xy...`)
438
+
439
+ #### Step 9.5: Vault Discovery and Multi-Vault Selection
440
+
441
+ After MCP is configured and before showing the final success message, offer vault discovery:
442
+
443
+ 1. **Fetch available vaults**
444
+
445
+ Use the `list_vaults` MCP tool (if available after restart) or display guidance:
446
+
447
+ ```
448
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
449
+ ◆ VAULT CONFIGURATION
450
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
451
+
452
+ Your account includes one vault by default:
453
+ • {vault_name} ({vault_id prefix...})
454
+
455
+ You can connect additional vaults for multi-vault routing.
456
+ This allows queries to be automatically routed to the right vault
457
+ based on the type of question (code vs. conventions vs. processes).
458
+
459
+ Would you like to configure additional vaults now?
460
+ ◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
461
+ ```
462
+
463
+ Use AskUserQuestion with options:
464
+ - **Yes** - Configure additional vaults now
465
+ - **No** - Skip for now (can configure later with /kc:connect-mcp --configure-vaults)
466
+
467
+ **STOP HERE and wait for user response.**
468
+
469
+ - If "No": Proceed to write single vault to `knowzcode_vaults.md` and show success message
470
+ - If "Yes": Continue with vault discovery
471
+
472
+ 2. **Call list_vaults() to discover available vaults**
473
+
474
+ If MCP tools are already active (rare after fresh registration):
475
+ ```
476
+ list_vaults(includeStats: true)
477
+ ```
478
+
479
+ If MCP tools not yet available (common - requires restart):
480
+ ```
481
+ Note: MCP tools require a restart to activate.
482
+ After restart, run /kc:connect-mcp --configure-vaults to add more vaults.
483
+ ```
484
+
485
+ If vaults are returned, display them:
486
+ ```
487
+ Available Vaults:
488
+ ┌────┬──────────────────────┬──────────────────┬───────────┐
489
+ │ # │ Name │ Type │ Documents │
490
+ ├────┼──────────────────────┼──────────────────┼───────────┤
491
+ │ 1 │ KnowzCode (default) │ research │ 0 │
492
+ │ 2 │ my-project-code │ code │ 1,234 │
493
+ │ 3 │ engineering-wiki │ research │ 89 │
494
+ └────┴──────────────────────┴──────────────────┴───────────┘
495
+ ```
496
+
497
+ 3. **Interactive vault selection loop**
498
+
499
+ For each vault discovered (including the default one):
500
+
501
+ a. Ask if user wants to connect this vault:
502
+ ```
503
+ Would you like to connect vault "KnowzCode" (research)?
504
+ ```
505
+ Options: [Yes] [No]
506
+
507
+ b. If "Yes", prompt for description:
508
+ ```
509
+ Describe what this vault contains (for intelligent routing):
510
+
511
+ Example descriptions:
512
+ • "Team learnings, conventions, architectural decisions"
513
+ • "Source code for the main API project"
514
+ • "Company processes, onboarding docs, team structure"
515
+
516
+ This helps KnowzCode route queries to the right vault automatically.
517
+ ```
518
+
519
+ Use AskUserQuestion to collect description (free text).
520
+
521
+ c. Store vault info: ID, name, type, description
522
+
523
+ d. Ask if user wants to connect another vault:
524
+ ```
525
+ Would you like to connect another vault?
526
+ ```
527
+ Options: [Yes] [No]
528
+
529
+ - If "Yes" and more vaults available: Loop back to step a
530
+ - If "No" or no more vaults: Exit loop
531
+
532
+ 4. **Write vault configuration to knowzcode_vaults.md**
533
+
534
+ Create or update `knowzcode/knowzcode_vaults.md` with selected vaults:
535
+
536
+ ```markdown
537
+ # KnowzCode Vault Configuration
538
+
539
+ Multi-vault routing configuration for intelligent vault selection.
540
+
541
+ ---
542
+
543
+ ## Connected Vaults
544
+
545
+ ### {vault_id_1}
546
+ - **Name**: {vault_name}
547
+ - **ID**: {vault_id}
548
+ - **Type**: {code | research}
549
+ - **Description**: {user_provided_description}
550
+
551
+ ### {vault_id_2}
552
+ - **Name**: {vault_name}
553
+ - **ID**: {vault_id}
554
+ - **Type**: {code | research}
555
+ - **Description**: {user_provided_description}
556
+
557
+ ---
558
+
559
+ ## Vault Routing Rules
560
+
561
+ - **Code questions** (implementations, files, structure) → {first code vault}
562
+ - **Convention questions** (patterns, decisions, best practices) → {first research vault}
563
+ - **Learning capture** → {default research vault}
564
+ ```
565
+
566
+ 5. **Show vault configuration summary**
567
+
568
+ After writing configuration:
569
+ ```
570
+ Vault configuration saved to knowzcode/knowzcode_vaults.md
571
+
572
+ Connected Vaults:
573
+ • KnowzCode (research) - "Team learnings and conventions"
574
+ • my-code (code) - "Source code for API project"
575
+
576
+ Queries will be automatically routed based on your descriptions.
577
+ You can edit knowzcode/knowzcode_vaults.md to update routing rules.
578
+ ```
579
+
580
+ ## Error Handling
581
+
582
+ ### Email Already Registered (HTTP 409)
583
+
584
+ ```
585
+ ⚠️ Email Already Registered
586
+
587
+ The email {email} is already associated with a KnowzCode account.
588
+
589
+ Options:
590
+ 1. Use a different email → Run /kc:register again
591
+ 2. Retrieve existing API key → Visit https://knowz.io/api-keys
592
+ 3. Reset password → https://knowz.io/forgot-password
593
+
594
+ If this is your account, you can configure your existing key:
595
+ /kc:connect-mcp <your-existing-api-key>
596
+ ```
597
+
598
+ ### Invalid Input (HTTP 400)
599
+
600
+ ```
601
+ ❌ Registration Failed
602
+
603
+ The server reported validation errors:
604
+ {error_message_from_response}
605
+
606
+ Please correct the issue and try again.
607
+ ```
608
+
609
+ Return to the step corresponding to the invalid field.
610
+
611
+ ### Rate Limited (HTTP 429)
612
+
613
+ ```
614
+ ⏳ Too Many Requests
615
+
616
+ Registration is temporarily rate limited.
617
+ Please wait a few minutes and try again.
618
+
619
+ If you continue to see this error, contact support:
620
+ https://knowz.io/support
621
+ ```
622
+
623
+ ### Network Error
624
+
625
+ ```
626
+ ❌ Network Error
627
+
628
+ Cannot reach KnowzCode registration server.
629
+
630
+ Troubleshooting:
631
+ 1. Check your internet connection
632
+ 2. Verify firewall/proxy settings allow HTTPS to api.knowz.io (or api.dev.knowz.io for --dev)
633
+ 3. Try again in a few moments
634
+
635
+ If the issue persists:
636
+ • Status page: https://status.knowz.io
637
+ • Support: https://knowz.io/support
638
+ ```
639
+
640
+ ### Server Error (HTTP 500+)
641
+
642
+ ```
643
+ ❌ Server Error
644
+
645
+ KnowzCode registration service encountered an error.
646
+
647
+ This is not your fault. Please:
648
+ 1. Try again in a few minutes
649
+ 2. Check status: https://status.knowz.io
650
+ 3. Contact support if persists: https://knowz.io/support
651
+ ```
652
+
653
+ ### MCP Configuration Failed
654
+
655
+ If registration succeeds but MCP configuration fails:
656
+
657
+ ```
658
+ ⚠️ Account Created, but MCP Configuration Failed
659
+
660
+ Your account was created successfully:
661
+ • Email: {email}
662
+ • API Key: {masked_key}
663
+ • Vault: {vault_name} ({vault_id prefix...})
664
+
665
+ However, automatic MCP configuration failed:
666
+ {error_details}
667
+
668
+ You can configure manually:
669
+ /kc:connect-mcp {masked_key}
670
+
671
+ Or visit https://knowz.io/api-keys to retrieve your key later.
672
+ ```
673
+
674
+ ### API Response Missing Vault ID
675
+
676
+ If registration succeeds but API returns no vault_id:
677
+
678
+ ```
679
+ ⚠️ Account Created, but Vault Not Provisioned
680
+
681
+ Your account was created and MCP is configured:
682
+ • Email: {email}
683
+ • API Key: {masked_key}
684
+ • MCP: Configured
685
+
686
+ However, no vault was auto-created. This may indicate:
687
+ • Account provisioning is still in progress
688
+ • Server-side configuration needed
689
+
690
+ You can:
691
+ 1. Wait a few minutes and run /kc:status to check
692
+ 2. Contact support: https://knowz.io/support
693
+ 3. Manually configure vault later: /kc:connect-mcp --configure-vaults
694
+ ```
695
+
696
+ ## Security Considerations
697
+
698
+ ### Data Protection
699
+ - **HTTPS only** - All API calls use HTTPS
700
+ - **Password not stored** - Password sent once, never saved locally
701
+ - **Password not logged** - Never display password in output
702
+ - **Minimal data** - Only collect what's needed for registration
703
+
704
+ ### API Key Security
705
+ - **Mask displayed keys**: Show only `kz_abc...xyz` format (first 6 + last 4 chars)
706
+ - **Never log full keys**: Exclude from any diagnostic output
707
+ - **Warn about project scope**: If `--scope project`, warn that API key will be in `.mcp.json`
708
+ - **Recommend local scope**: Default to most secure option
709
+
710
+ ## Scope Comparison
711
+
712
+ | Scope | Storage | Visibility | Best For |
713
+ |-------|---------|------------|----------|
714
+ | **local** (default) | Claude Code internal | Only you, this project | Personal development |
715
+ | **project** | `.mcp.json` (git) | Team via git | Shared team key |
716
+ | **user** | Claude Code user config | Only you, all projects | Personal, multi-project |
717
+
718
+ ## Related Commands
719
+
720
+ - `/kc:connect-mcp` - Configure MCP with existing API key
721
+ - `/kc:status` - Check MCP connection status
722
+ - `/kc:init` - Initialize KnowzCode in project
723
+
724
+ Execute this registration flow now.