knowzcode 0.4.0 → 0.5.2

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