knowns 0.8.0 → 0.8.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.
package/CLAUDE.md DELETED
@@ -1,999 +0,0 @@
1
- <!-- KNOWNS GUIDELINES START -->
2
- # Knowns CLI Guidelines
3
-
4
- ## Core Principles
5
-
6
- ### 1. CLI-Only Operations
7
- **NEVER edit .md files directly. ALL operations MUST use CLI commands.**
8
-
9
- This ensures data integrity, maintains proper change history, and prevents file corruption.
10
-
11
- ### 2. Documentation-First (For AI Agents)
12
- **ALWAYS read project documentation BEFORE planning or coding.**
13
-
14
- AI agents must understand project context, conventions, and existing patterns before making any changes. This prevents rework and ensures consistency.
15
-
16
- ---
17
-
18
- ## AI Agent Guidelines
19
-
20
- > **CRITICAL**: Before performing ANY task, AI agents MUST read documentation to understand project context.
21
-
22
- ### First-Time Initialization
23
-
24
- When starting a new session or working on an unfamiliar project:
25
-
26
- ```bash
27
- # 1. List all available documentation
28
- knowns doc list --plain
29
-
30
- # 2. Read essential project docs (prioritize these)
31
- knowns doc "README" --plain # Project overview
32
- knowns doc "ARCHITECTURE" --plain # System design
33
- knowns doc "CONVENTIONS" --plain # Coding standards
34
- knowns doc "API" --plain # API specifications
35
-
36
- # 3. Review current task backlog
37
- knowns task list --plain
38
- knowns task list --status in-progress --plain
39
- ```
40
-
41
- ### Before Taking Any Task
42
-
43
- ```bash
44
- # 1. View the task details
45
- knowns task <id> --plain
46
-
47
- # 2. Follow ALL refs in the task (see Reference System section)
48
- # @.knowns/tasks/task-44 - ... → knowns task 44 --plain
49
- # @.knowns/docs/patterns/module.md → knowns doc "patterns/module" --plain
50
-
51
- # 3. Search for additional related documentation
52
- knowns search "<keywords from task>" --type doc --plain
53
-
54
- # 4. Read ALL related docs before planning
55
- knowns doc "<related-doc>" --plain
56
-
57
- # 5. Check for similar completed tasks (learn from history)
58
- knowns search "<keywords>" --type task --status done --plain
59
- ```
60
-
61
- ### Why Documentation First?
62
-
63
- | Without Reading Docs | With Reading Docs |
64
- |---------------------|-------------------|
65
- | Reinvent existing patterns | Reuse established patterns |
66
- | Break conventions | Follow project standards |
67
- | Duplicate code | Use existing utilities |
68
- | Wrong architecture decisions | Align with system design |
69
- | Inconsistent naming | Match naming conventions |
70
-
71
- ### Context Checklist for Agents
72
-
73
- Before writing ANY code, ensure you can answer:
74
-
75
- - [ ] Have I followed ALL refs (`@.knowns/...`) in the task?
76
- - [ ] Have I followed nested refs recursively?
77
- - [ ] What is the project's overall architecture?
78
- - [ ] What coding conventions does this project follow?
79
- - [ ] Are there existing patterns/utilities I should reuse?
80
- - [ ] What are the testing requirements?
81
- - [ ] How should I structure my implementation?
82
-
83
- > **Remember**: A few minutes reading docs saves hours of rework. NEVER skip this step.
84
-
85
- ---
86
-
87
- ## Reference System (Refs)
88
-
89
- Tasks and docs can contain **references** to other tasks/docs. AI agents MUST understand and follow these refs to gather complete context.
90
-
91
- ### Reference Formats
92
-
93
- | Type | When Writing (Input) | When Reading (Output) | CLI Command |
94
- |------|---------------------|----------------------|-------------|
95
- | **Task ref** | `@task-<id>` | `@.knowns/tasks/task-<id> - <title>.md` | `knowns task <id> --plain` |
96
- | **Doc ref** | `@doc/<path>` | `@.knowns/docs/<path>.md` | `knowns doc <path> --plain` |
97
-
98
- > **CRITICAL for AI Agents**:
99
- > - When **WRITING** refs (in descriptions, plans, notes): Use `@task-<id>` and `@doc/<path>`
100
- > - When **READING** output from `--plain`: You'll see `@.knowns/tasks/...` and `@.knowns/docs/...`
101
- > - **NEVER write** the output format (`@.knowns/...`) - always use input format (`@task-<id>`, `@doc/<path>`)
102
-
103
- ### How to Follow Refs
104
-
105
- When you read a task and see refs in system output format, follow them:
106
-
107
- ```bash
108
- # Example: Task 42 output contains:
109
- # @.knowns/tasks/task-44 - CLI Task Create Command.md
110
- # @.knowns/docs/patterns/module.md
111
-
112
- # Follow task ref (extract ID from task-<id>)
113
- knowns task 44 --plain
114
-
115
- # Follow doc ref (extract path, remove .md)
116
- knowns doc "patterns/module" --plain
117
- ```
118
-
119
- ### Parsing Rules
120
-
121
- 1. **Task refs**: `@.knowns/tasks/task-<id> - ...` → extract `<id>` → `knowns task <id> --plain`
122
- 2. **Doc refs**: `@.knowns/docs/<path>.md` → extract `<path>` → `knowns doc "<path>" --plain`
123
-
124
- ### Recursive Following
125
-
126
- Refs can be nested. Follow until complete context is gathered:
127
-
128
- ```
129
- Task 42
130
- → @.knowns/docs/README.md
131
- → @.knowns/docs/patterns/module.md (found in README)
132
- → (read for full pattern details)
133
- ```
134
-
135
- ### When to Follow Refs
136
-
137
- | Situation | Action |
138
- |-----------|--------|
139
- | Refs in Description | ALWAYS follow - critical context |
140
- | Refs in Implementation Plan | Follow if implementing related work |
141
- | Refs in Notes | Optional - for historical context |
142
- | Dependency mentions | Follow if marked as blocker |
143
-
144
- ### Example: Complete Ref Resolution
145
-
146
- ```bash
147
- # 1. Read the task
148
- $ knowns task 42 --plain
149
-
150
- # Output contains:
151
- # @.knowns/tasks/task-44 - CLI Task Create Command.md
152
- # @.knowns/docs/README.md
153
-
154
- # 2. Follow task ref
155
- $ knowns task 44 --plain
156
-
157
- # 3. Follow doc ref
158
- $ knowns doc "README" --plain
159
-
160
- # 4. If README contains more refs, follow them too
161
- # @.knowns/docs/patterns/module.md → knowns doc "patterns/module" --plain
162
-
163
- # Now you have complete context
164
- ```
165
-
166
- > **CRITICAL**: Never assume you understand a task fully without following its refs. Refs contain essential context that may change your implementation approach.
167
-
168
- ---
169
-
170
- ## Quick Start
171
-
172
- ```bash
173
- # Initialize project
174
- knowns init [name]
175
-
176
- # Create task with acceptance criteria
177
- knowns task create "Title" -d "Description" --ac "Criterion 1" --ac "Criterion 2"
178
-
179
- # View task (ALWAYS use --plain for AI)
180
- knowns task <id> --plain # Shorthand
181
- knowns task view <id> --plain # Full command
182
-
183
- # View doc (ALWAYS use --plain for AI)
184
- knowns doc <path> --plain # Shorthand
185
- knowns doc view "<path>" --plain # Full command
186
-
187
- # List tasks
188
- knowns task list --plain
189
-
190
- # Search (tasks + docs)
191
- knowns search "query" --plain
192
- ```
193
-
194
- ---
195
-
196
- ## End-to-End Example
197
-
198
- Here's a complete workflow for an AI agent implementing a feature:
199
-
200
- ```bash
201
- # === AGENT SESSION START (Do this once per session) ===
202
-
203
- # 0a. List all available documentation
204
- $ knowns doc list --plain
205
-
206
- # Output:
207
- # DOC: README.md
208
- # DOC: ARCHITECTURE.md
209
- # DOC: CONVENTIONS.md
210
- # DOC: security-patterns.md
211
- # DOC: api-guidelines.md
212
- # DOC: email-templates.md
213
-
214
- # 0b. Read essential project docs
215
- $ knowns doc "README" --plain
216
- $ knowns doc "ARCHITECTURE" --plain
217
- $ knowns doc "CONVENTIONS" --plain
218
-
219
- # Now the agent understands project context and conventions
220
-
221
- # === TASK WORKFLOW ===
222
-
223
- # 1. Create the task
224
- $ knowns task create "Add password reset flow" \
225
- -d "Users need ability to reset forgotten passwords via email" \
226
- --ac "User can request password reset via email" \
227
- --ac "Reset link expires after 1 hour" \
228
- --ac "User can set new password via reset link" \
229
- --ac "Unit tests cover all scenarios" \
230
- --priority high \
231
- -l "auth,feature"
232
-
233
- # Output: Created task AUTH-042
234
-
235
- # 2. Take the task and start timer (uses defaultAssignee or @me fallback)
236
- $ knowns task edit AUTH-042 -s in-progress -a $(knowns config get defaultAssignee --plain || echo "@me")
237
- $ knowns time start AUTH-042
238
-
239
- # Output: Timer started for AUTH-042
240
-
241
- # 3. Search for related documentation
242
- $ knowns search "password security" --type doc --plain
243
-
244
- # Output:
245
- # DOC: security-patterns.md (score: 0.92)
246
- # DOC: email-templates.md (score: 0.78)
247
-
248
- # 4. Read the documentation
249
- $ knowns doc "security-patterns" --plain
250
-
251
- # 5. Create implementation plan (SHARE WITH USER, WAIT FOR APPROVAL)
252
- $ knowns task edit AUTH-042 --plan $'1. Review security patterns (see @doc/security-patterns)
253
- 2. Design token generation with 1-hour expiry
254
- 3. Create email template (see @doc/email-templates)
255
- 4. Implement /forgot-password endpoint
256
- 5. Implement /reset-password endpoint
257
- 6. Add unit tests
258
- 7. Update API documentation'
259
-
260
- # 6. After approval, implement and check criteria as you go
261
- $ knowns task edit AUTH-042 --check-ac 1
262
- $ knowns task edit AUTH-042 --append-notes "✓ Implemented /forgot-password endpoint"
263
-
264
- $ knowns task edit AUTH-042 --check-ac 2
265
- $ knowns task edit AUTH-042 --append-notes "✓ Token expiry set to 1 hour"
266
-
267
- $ knowns task edit AUTH-042 --check-ac 3
268
- $ knowns task edit AUTH-042 --append-notes "✓ Implemented /reset-password endpoint"
269
-
270
- $ knowns task edit AUTH-042 --check-ac 4
271
- $ knowns task edit AUTH-042 --append-notes "✓ Added 12 unit tests, 100% coverage"
272
-
273
- # 7. Add final implementation notes
274
- $ knowns task edit AUTH-042 --notes $'## Summary
275
- Implemented complete password reset flow with secure token generation.
276
-
277
- ## Changes
278
- - Added POST /forgot-password endpoint
279
- - Added POST /reset-password endpoint
280
- - Created password_reset_tokens table
281
- - Added email template for reset link
282
-
283
- ## Security
284
- - Tokens use crypto.randomBytes(32)
285
- - 1-hour expiry enforced at DB level
286
- - Rate limiting: 3 requests per hour per email
287
-
288
- ## Tests
289
- - 12 unit tests added
290
- - Coverage: 100% for new code
291
-
292
- ## Documentation
293
- - Updated API.md with new endpoints'
294
-
295
- # 8. Stop timer and complete
296
- $ knowns time stop
297
- $ knowns task edit AUTH-042 -s done
298
-
299
- # Output: Task AUTH-042 marked as done
300
- ```
301
-
302
- ---
303
-
304
- ## Task Workflow
305
-
306
- ### Step 1: Take Task
307
-
308
- ```bash
309
- # Assign using defaultAssignee from config (falls back to @me if not set)
310
- knowns task edit <id> -s in-progress -a $(knowns config get defaultAssignee --plain || echo "@me")
311
- ```
312
-
313
- > **Note**: The `defaultAssignee` is configured in `.knowns/config.json` during `knowns init`. If not set, `@me` is used as fallback. To update: `knowns config set defaultAssignee "@username"`
314
-
315
- ### Step 2: Start Time Tracking (REQUIRED)
316
-
317
- ```bash
318
- knowns time start <id>
319
- ```
320
-
321
- > **CRITICAL**: Time tracking is MANDATORY. Always start timer when taking a task and stop when done. This data is essential for:
322
- > - Accurate project estimation
323
- > - Identifying bottlenecks
324
- > - Resource planning
325
- > - Sprint retrospectives
326
-
327
- ### Step 3: Read Related Documentation
328
-
329
- > **FOR AI AGENTS**: This step is MANDATORY, not optional. You must understand the codebase before planning.
330
-
331
- ```bash
332
- # Search for related docs
333
- knowns search "authentication" --type doc --plain
334
-
335
- # View relevant documents
336
- knowns doc "API Guidelines" --plain
337
- knowns doc "Security Patterns" --plain
338
-
339
- # Also check for similar completed tasks
340
- knowns search "auth" --type task --status done --plain
341
- ```
342
-
343
- > **CRITICAL**: ALWAYS read related documentation BEFORE planning! Understanding existing patterns and conventions prevents rework and ensures consistency.
344
-
345
- ### Step 4: Create Implementation Plan
346
-
347
- ```bash
348
- knowns task edit <id> --plan $'1. Research patterns (see @doc/security-patterns)
349
- 2. Design middleware
350
- 3. Implement
351
- 4. Add tests
352
- 5. Update docs'
353
- ```
354
-
355
- > **CRITICAL**:
356
- > - Share plan with user and **WAIT for approval** before coding
357
- > - Include doc references using `@doc/<path>` format
358
-
359
- ### Step 5: Implement
360
-
361
- ```bash
362
- # Work through implementation plan step by step
363
- # IMPORTANT: Only check AC AFTER completing the work, not before
364
-
365
- # After completing work for AC #1:
366
- knowns task edit <id> --check-ac 1
367
- knowns task edit <id> --append-notes "✓ Completed: <brief description>"
368
-
369
- # After completing work for AC #2:
370
- knowns task edit <id> --check-ac 2
371
- knowns task edit <id> --append-notes "✓ Completed: <brief description>"
372
- ```
373
-
374
- > **CRITICAL**: Never check an AC before the work is actually done. ACs represent completed outcomes, not intentions.
375
-
376
- ### Step 6: Handle Dynamic Requests (During Implementation)
377
-
378
- If the user adds new requirements during implementation:
379
-
380
- ```bash
381
- # Add new acceptance criteria
382
- knowns task edit <id> --ac "New requirement from user"
383
-
384
- # Update implementation plan to include new steps
385
- knowns task edit <id> --plan $'1. Original step 1
386
- 2. Original step 2
387
- 3. NEW: Handle user request for X
388
- 4. Continue with remaining work'
389
-
390
- # Append note about scope change
391
- knowns task edit <id> --append-notes "⚠️ Scope updated: Added requirement for X per user request"
392
-
393
- # Continue with Step 5 (Implement) for new requirements
394
- ```
395
-
396
- > **Note**: Always document scope changes. This helps track why a task took longer than expected.
397
-
398
- ### Step 7: Add Implementation Notes
399
-
400
- ```bash
401
- # Add comprehensive notes (suitable for PR description)
402
- knowns task edit <id> --notes $'## Summary
403
-
404
- Implemented JWT auth.
405
-
406
- ## Changes
407
- - Added middleware
408
- - Added tests'
409
-
410
- # OR append progressively (recommended)
411
- knowns task edit <id> --append-notes "✓ Implemented middleware"
412
- knowns task edit <id> --append-notes "✓ Added tests"
413
- ```
414
-
415
- ### Step 8: Stop Time Tracking (REQUIRED)
416
-
417
- ```bash
418
- knowns time stop
419
- ```
420
-
421
- > **CRITICAL**: Never forget to stop the timer. If you forget, use manual entry: `knowns time add <id> <duration> -n "Forgot to stop timer"`
422
-
423
- ### Step 9: Complete Task
424
-
425
- ```bash
426
- knowns task edit <id> -s done
427
- ```
428
-
429
- ### Step 10: Handle Post-Completion Changes (If Applicable)
430
-
431
- If the user requests changes or updates AFTER task is marked done:
432
-
433
- ```bash
434
- # 1. Reopen task - set back to in-progress
435
- knowns task edit <id> -s in-progress
436
-
437
- # 2. Restart time tracking (REQUIRED)
438
- knowns time start <id>
439
-
440
- # 3. Add new AC for the changes requested
441
- knowns task edit <id> --ac "Post-completion fix: <description>"
442
-
443
- # 4. Document the reopen reason
444
- knowns task edit <id> --append-notes "🔄 Reopened: User requested changes - <reason>"
445
-
446
- # 5. Follow Step 5-9 again (Implement → Notes → Stop Timer → Done)
447
- ```
448
-
449
- > **CRITICAL**: Treat post-completion changes as a mini-workflow. Always:
450
- > - Reopen task (in-progress)
451
- > - Start timer again
452
- > - Add AC for traceability
453
- > - Document why it was reopened
454
- > - Follow the same completion process
455
-
456
- ### Step 11: Knowledge Extraction (Post-Completion)
457
-
458
- After completing a task, extract reusable knowledge to docs:
459
-
460
- ```bash
461
- # Search if similar pattern already documented
462
- knowns search "<pattern/concept>" --type doc --plain
463
-
464
- # If new knowledge, create a doc for future reference
465
- knowns doc create "Pattern: <Name>" \
466
- -d "Reusable pattern discovered during task implementation" \
467
- -t "pattern,<domain>" \
468
- -f "patterns"
469
-
470
- # Or append to existing doc
471
- knowns doc edit "<existing-doc>" -a "## New Section\n\nLearned from task <id>: ..."
472
-
473
- # Reference the source task
474
- knowns doc edit "<doc-name>" -a "\n\n> Source: @task-<id>"
475
- ```
476
-
477
- **When to extract knowledge:**
478
- - New patterns/conventions discovered
479
- - Common error solutions
480
- - Reusable code snippets or approaches
481
- - Integration patterns with external services
482
- - Performance optimization techniques
483
-
484
- > **CRITICAL**: Only extract **generalizable** knowledge. Task-specific details belong in implementation notes, not docs.
485
-
486
- ---
487
-
488
- ## Essential Commands
489
-
490
- ### Task Management
491
-
492
- ```bash
493
- # Create task
494
- knowns task create "Title" -d "Description" --ac "Criterion" -l "labels" --priority high
495
-
496
- # Edit task
497
- knowns task edit <id> -t "New title"
498
- knowns task edit <id> -d "New description"
499
- knowns task edit <id> -s in-progress
500
- knowns task edit <id> --priority high
501
- knowns task edit <id> -a <assignee> # $(knowns config get defaultAssignee --plain || echo "@me")
502
-
503
- # Acceptance Criteria
504
- knowns task edit <id> --ac "New criterion" # Add
505
- knowns task edit <id> --check-ac 1 --check-ac 2 # Check (1-indexed)
506
- knowns task edit <id> --uncheck-ac 2 # Uncheck
507
- knowns task edit <id> --remove-ac 3 # Remove
508
-
509
- # Implementation Plan & Notes
510
- knowns task edit <id> --plan $'1. Step\n2. Step'
511
- knowns task edit <id> --notes "Implementation summary"
512
- knowns task edit <id> --append-notes "Progress update"
513
-
514
- # View & List
515
- knowns task <id> --plain # Shorthand (ALWAYS use --plain)
516
- knowns task view <id> --plain # Full command
517
- knowns task list --plain
518
- knowns task list --status in-progress --plain
519
- knowns task list --assignee <assignee> --plain # $(knowns config get defaultAssignee --plain || echo "@me")
520
- knowns task list --tree --plain # Tree hierarchy
521
- ```
522
-
523
- ### Time Tracking
524
-
525
- ```bash
526
- # Timer
527
- knowns time start <id>
528
- knowns time stop
529
- knowns time pause
530
- knowns time resume
531
- knowns time status
532
-
533
- # Manual entry
534
- knowns time add <id> 2h -n "Note" -d "2025-12-25"
535
-
536
- # Reports
537
- knowns time report --from "2025-12-01" --to "2025-12-31"
538
- knowns time report --by-label --csv > report.csv
539
- ```
540
-
541
- ### Documentation
542
-
543
- ```bash
544
- # List & View
545
- knowns doc list --plain
546
- knowns doc list --tag architecture --plain
547
- knowns doc <path> --plain # Shorthand (ALWAYS use --plain)
548
- knowns doc view "<path>" --plain # Full command
549
-
550
- # Create (with optional folder)
551
- knowns doc create "Title" -d "Description" -t "tags"
552
- knowns doc create "Title" -d "Description" -t "tags" -f "folder/path"
553
-
554
- # Edit metadata
555
- knowns doc edit "Doc Name" -t "New Title" --tags "new,tags"
556
-
557
- # Edit content
558
- knowns doc edit "Doc Name" -c "New content" # Replace content
559
- knowns doc edit "Doc Name" -a "Appended content" # Append to content
560
- ```
561
-
562
- #### Doc Organization
563
-
564
- | Doc Type | Location | Example |
565
- |----------|----------|---------|
566
- | **Important/Core docs** | Root `.knowns/docs/` | `README.md`, `ARCHITECTURE.md`, `CONVENTIONS.md` |
567
- | **Guides** | `.knowns/docs/guides/` | `guides/getting-started.md` |
568
- | **Patterns** | `.knowns/docs/patterns/` | `patterns/controller.md` |
569
- | **API docs** | `.knowns/docs/api/` | `api/endpoints.md` |
570
- | **Other categorized docs** | `.knowns/docs/<category>/` | `security/auth-patterns.md` |
571
-
572
- ```bash
573
- # Important docs - at root (no -f flag)
574
- knowns doc create "README" -d "Project overview" -t "core"
575
- knowns doc create "ARCHITECTURE" -d "System design" -t "core"
576
-
577
- # Categorized docs - use -f for folder
578
- knowns doc create "Getting Started" -d "Setup guide" -t "guide" -f "guides"
579
- knowns doc create "Controller Pattern" -d "MVC pattern" -t "pattern" -f "patterns"
580
- ```
581
-
582
- ### Search
583
-
584
- ```bash
585
- # Search everything
586
- knowns search "query" --plain
587
-
588
- # Search specific type
589
- knowns search "auth" --type task --plain
590
- knowns search "patterns" --type doc --plain
591
-
592
- # Filter
593
- knowns search "bug" --status in-progress --priority high --plain
594
- ```
595
-
596
- ---
597
-
598
- ## Task Structure
599
-
600
- ### Title
601
-
602
- Clear summary (WHAT needs to be done).
603
-
604
- | Bad | Good |
605
- |-----|------|
606
- | Do auth stuff | Add JWT authentication |
607
- | Fix bug | Fix login timeout on slow networks |
608
- | Update docs | Document rate limiting in API.md |
609
-
610
- ### Description
611
-
612
- Explains WHY and WHAT (not HOW). **Link related docs using `@doc/<path>`**
613
-
614
- ```markdown
615
- We need JWT authentication because sessions don't scale for our microservices architecture.
616
-
617
- Related docs: @doc/security-patterns, @doc/api-guidelines
618
- ```
619
-
620
- ### Acceptance Criteria
621
-
622
- **Outcome-oriented**, testable criteria. NOT implementation steps.
623
-
624
- | Bad (Implementation details) | Good (Outcomes) |
625
- |------------------------------|-----------------|
626
- | Add function handleLogin() in auth.ts | User can login and receive JWT token |
627
- | Use bcrypt for hashing | Passwords are securely hashed |
628
- | Add try-catch blocks | Errors return appropriate HTTP status codes |
629
-
630
- ### Implementation Plan
631
-
632
- HOW to solve. Added AFTER taking task, BEFORE coding.
633
-
634
- ```markdown
635
- 1. Research JWT libraries (see @doc/security-patterns)
636
- 2. Design token structure (access + refresh tokens)
637
- 3. Implement auth middleware
638
- 4. Add unit tests (aim for 90%+ coverage)
639
- 5. Update API.md with new endpoints
640
- ```
641
-
642
- ### Implementation Notes
643
-
644
- Summary for PR description. Added AFTER completion.
645
-
646
- ```markdown
647
- ## Summary
648
- Implemented JWT auth using jsonwebtoken library.
649
-
650
- ## Changes
651
- - Added auth middleware in src/middleware/auth.ts
652
- - Added /login and /refresh endpoints
653
- - Created JWT utility functions
654
-
655
- ## Tests
656
- - Added 15 unit tests
657
- - Coverage: 94%
658
-
659
- ## Documentation
660
- - Updated API.md with authentication section
661
- ```
662
-
663
- ---
664
-
665
- ## Error Handling
666
-
667
- ### Common Errors and Solutions
668
-
669
- | Error | Cause | Solution |
670
- |-------|-------|----------|
671
- | `Error: Task not found` | Invalid task ID | Run `knowns task list --plain` to find correct ID |
672
- | `Error: No active timer` | Calling `time stop` without active timer | Start timer first: `knowns time start <id>` |
673
- | `Error: Timer already running` | Starting timer when one is active | Stop current: `knowns time stop` |
674
- | `Error: Invalid status` | Wrong status format | Use lowercase with hyphens: `in-progress`, not `In Progress` |
675
- | `Error: AC index out of range` | Checking non-existent criterion | View task first: `knowns task <id> --plain` |
676
- | `Error: Document not found` | Wrong document name | Run `knowns doc list --plain` to find correct name |
677
- | `Error: Not initialized` | Running commands without init | Run `knowns init` first |
678
-
679
- ### Debugging Commands
680
-
681
- ```bash
682
- # Check CLI version
683
- knowns --version
684
-
685
- # Verify project is initialized
686
- knowns status
687
-
688
- # View raw task data (for debugging)
689
- knowns task <id> --json
690
-
691
- # Check timer status
692
- knowns time status
693
- ```
694
-
695
- ---
696
-
697
- ## Definition of Done
698
-
699
- A task is **Done** ONLY when **ALL** criteria are met:
700
-
701
- ### Via CLI (Required)
702
-
703
- - [ ] All acceptance criteria checked: `--check-ac <index>` (only after work is actually done)
704
- - [ ] Implementation notes added: `--notes "..."`
705
- - [ ] ⏱️ Timer stopped: `knowns time stop` (MANDATORY - do not skip!)
706
- - [ ] Status set to done: `-s done`
707
- - [ ] Knowledge extracted to docs (if applicable)
708
-
709
- ### Via Code (Required)
710
-
711
- - [ ] All tests pass
712
- - [ ] Documentation updated
713
- - [ ] Code reviewed (linting, formatting)
714
- - [ ] No regressions introduced
715
-
716
- ---
717
-
718
- ## Status & Priority Reference
719
-
720
- ### Status Values
721
-
722
- Use **lowercase with hyphens**:
723
-
724
- | Status | Description | When to Use |
725
- |--------|-------------|-------------|
726
- | `todo` | Not started | Default for new tasks |
727
- | `in-progress` | Currently working | After taking task |
728
- | `in-review` | In code review | PR submitted |
729
- | `blocked` | Waiting on dependency | External blocker |
730
- | `done` | Completed | All criteria met |
731
-
732
- ### Priority Values
733
-
734
- | Priority | Description |
735
- |----------|-------------|
736
- | `low` | Can wait, nice-to-have |
737
- | `medium` | Normal priority (default) |
738
- | `high` | Urgent, time-sensitive |
739
-
740
- ---
741
-
742
- ## Common Mistakes
743
-
744
- | Wrong | Right |
745
- |-------|-------|
746
- | Edit .md files directly | Use `knowns task edit` |
747
- | Change `- [ ]` to `- [x]` in file | Use `--check-ac <index>` |
748
- | Check AC before completing work | Only check AC AFTER work is actually done |
749
- | Skip time tracking | ALWAYS use `time start` and `time stop` |
750
- | Start coding without reading docs | Read ALL related docs FIRST |
751
- | Skip `knowns doc list` on new project | Always list docs when starting |
752
- | Assume you know the conventions | Read CONVENTIONS/ARCHITECTURE docs |
753
- | Plan without checking docs | Read docs before planning |
754
- | Ignore similar completed tasks | Search done tasks for patterns |
755
- | Missing doc links in description/plan | Link docs using `@doc/<path>` |
756
- | Write refs as `@.knowns/docs/...` or `@.knowns/tasks/...` | Use input format: `@doc/<path>`, `@task-<id>` |
757
- | Forget `--plain` flag | Always use `--plain` for AI |
758
- | Code before plan approval | Share plan, WAIT for approval |
759
- | Mark done without all criteria | Check ALL criteria first |
760
- | Write implementation steps in AC | Write outcome-oriented criteria |
761
- | Use `"In Progress"` or `"Done"` | Use `in-progress`, `done` |
762
- | Use `@yourself` or unknown assignee | Use `$(knowns config get defaultAssignee --plain \|\| echo "@me")` |
763
- | Ignore refs in task description | Follow ALL refs (`@.knowns/...`) before planning |
764
- | See `@.knowns/docs/...` but don't read | Use `knowns doc "<path>" --plain` |
765
- | See `@.knowns/tasks/task-X` but don't check | Use `knowns task X --plain` for context |
766
- | Follow only first-level refs | Recursively follow nested refs until complete |
767
- | Use `--plain` with `task create` | `--plain` is only for view/list commands |
768
- | Use `--plain` with `task edit` | `--plain` is only for view/list commands |
769
- | Use `--plain` with `doc create` | `--plain` is only for view/list commands |
770
- | Use `--plain` with `doc edit` | `--plain` is only for view/list commands |
771
-
772
- ---
773
-
774
- ## The `--plain` Flag (AI Agents)
775
-
776
- > **⚠️ CRITICAL FOR AI AGENTS**: The `--plain` flag is ONLY supported by **view/list/search** commands. Using it with create/edit commands will cause errors!
777
-
778
- ### ✅ Commands that support `--plain`
779
-
780
- These are **read-only** commands - use `--plain` to get clean output:
781
-
782
- ```bash
783
- # Task viewing/listing
784
- knowns task <id> --plain
785
- knowns task view <id> --plain
786
- knowns task list --plain
787
- knowns task list --status in-progress --plain
788
-
789
- # Doc viewing/listing
790
- knowns doc <path> --plain
791
- knowns doc view "<path>" --plain
792
- knowns doc list --plain
793
- knowns doc list --tag <tag> --plain
794
-
795
- # Search
796
- knowns search "<query>" --plain
797
- knowns search "<query>" --type task --plain
798
- knowns search "<query>" --type doc --plain
799
-
800
- # Config
801
- knowns config get <key> --plain
802
- ```
803
-
804
- ### ❌ Commands that do NOT support `--plain`
805
-
806
- These are **write** commands - NEVER use `--plain`:
807
-
808
- ```bash
809
- # Task create/edit - NO --plain!
810
- knowns task create "Title" -d "Description" # ✅ Correct
811
- knowns task create "Title" --plain # ❌ ERROR!
812
- knowns task edit <id> -s done # ✅ Correct
813
- knowns task edit <id> -s done --plain # ❌ ERROR!
814
-
815
- # Doc create/edit - NO --plain!
816
- knowns doc create "Title" -d "Description" # ✅ Correct
817
- knowns doc create "Title" --plain # ❌ ERROR!
818
- knowns doc edit "name" -c "content" # ✅ Correct
819
- knowns doc edit "name" -c "content" --plain # ❌ ERROR!
820
-
821
- # Time tracking - NO --plain!
822
- knowns time start <id> # ✅ Correct
823
- knowns time stop # ✅ Correct
824
- knowns time add <id> 2h # ✅ Correct
825
- ```
826
-
827
- ### Quick Reference Table
828
-
829
- | Command Type | Example | `--plain` Support |
830
- |-------------|---------|-------------------|
831
- | `task <id>` | `knowns task 42 --plain` | ✅ Yes |
832
- | `task list` | `knowns task list --plain` | ✅ Yes |
833
- | `task create` | `knowns task create "Title"` | ❌ No |
834
- | `task edit` | `knowns task edit 42 -s done` | ❌ No |
835
- | `doc <path>` | `knowns doc "README" --plain` | ✅ Yes |
836
- | `doc list` | `knowns doc list --plain` | ✅ Yes |
837
- | `doc create` | `knowns doc create "Title"` | ❌ No |
838
- | `doc edit` | `knowns doc edit "name" -c "..."` | ❌ No |
839
- | `search` | `knowns search "query" --plain` | ✅ Yes |
840
- | `time start/stop` | `knowns time start 42` | ❌ No |
841
- | `time add` | `knowns time add 42 2h` | ❌ No |
842
- | `config get` | `knowns config get key --plain` | ✅ Yes |
843
- | `config set` | `knowns config set key value` | ❌ No |
844
-
845
- ---
846
-
847
- ## Platform-Specific Notes
848
-
849
- ### Multi-line Input
850
-
851
- Different shells handle multi-line strings differently:
852
-
853
- **Bash / Zsh (Recommended)**
854
- ```bash
855
- knowns task edit <id> --plan $'1. First step\n2. Second step\n3. Third step'
856
- ```
857
-
858
- **PowerShell**
859
- ```powershell
860
- knowns task edit <id> --plan "1. First step`n2. Second step`n3. Third step"
861
- ```
862
-
863
- **Cross-platform (Using printf)**
864
- ```bash
865
- knowns task edit <id> --plan "$(printf '1. First step\n2. Second step\n3. Third step')"
866
- ```
867
-
868
- **Using heredoc (for long content)**
869
- ```bash
870
- knowns task edit <id> --plan "$(cat <<EOF
871
- 1. First step
872
- 2. Second step
873
- 3. Third step
874
- EOF
875
- )"
876
- ```
877
-
878
- ### Path Separators
879
-
880
- - **Unix/macOS**: Use forward slashes: `./docs/api.md`
881
- - **Windows**: Both work, but prefer forward slashes for consistency
882
-
883
- ### Windows Command Line Limit
884
-
885
- Windows has ~8191 character limit. For long content, append in chunks:
886
-
887
- ```bash
888
- # 1. Create or reset with short content
889
- knowns doc edit "doc-name" -c "## Overview\n\nShort intro."
890
-
891
- # 2. Append each section separately
892
- knowns doc edit "doc-name" -a "## Section 1\n\nContent..."
893
- knowns doc edit "doc-name" -a "## Section 2\n\nMore content..."
894
- ```
895
-
896
- Or use file-based options:
897
-
898
- ```bash
899
- knowns doc edit "doc-name" --content-file ./content.md
900
- knowns doc edit "doc-name" --append-file ./more.md
901
- ```
902
-
903
- ---
904
-
905
- ## Best Practices Checklist
906
-
907
- ### For AI Agents: Session Start
908
-
909
- - [ ] List all docs: `knowns doc list --plain`
910
- - [ ] Read README/ARCHITECTURE docs
911
- - [ ] Understand coding conventions
912
- - [ ] Review current task backlog
913
-
914
- ### Before Starting Work
915
-
916
- - [ ] Task has clear acceptance criteria
917
- - [ ] ALL refs in task followed (`@.knowns/...`)
918
- - [ ] Nested refs recursively followed until complete context gathered
919
- - [ ] Related docs searched: `knowns search "keyword" --type doc --plain`
920
- - [ ] ALL relevant docs read: `knowns doc "Doc Name" --plain`
921
- - [ ] Similar done tasks reviewed for patterns
922
- - [ ] Task assigned to self: `-a $(knowns config get defaultAssignee --plain || echo "@me")`
923
- - [ ] Status set to in-progress: `-s in-progress`
924
- - [ ] Timer started: `knowns time start <id>`
925
-
926
- ### During Work
927
-
928
- - [ ] Implementation plan created and approved
929
- - [ ] Doc links included in plan: `@doc/<path>`
930
- - [ ] Criteria checked as completed: `--check-ac <index>`
931
- - [ ] Progress notes appended: `--append-notes "✓ ..."`
932
-
933
- ### After Work
934
-
935
- - [ ] All acceptance criteria checked (only after work is done)
936
- - [ ] Implementation notes added: `--notes "..."`
937
- - [ ] Timer stopped: `knowns time stop`
938
- - [ ] Tests passing
939
- - [ ] Documentation updated
940
- - [ ] Status set to done: `-s done`
941
- - [ ] Knowledge extracted to docs (if applicable): patterns, solutions, conventions
942
-
943
- ---
944
-
945
- ## Quick Reference Card
946
-
947
- ```bash
948
- # === AGENT INITIALIZATION (Once per session) ===
949
- knowns doc list --plain
950
- knowns doc "README" --plain
951
- knowns doc "ARCHITECTURE" --plain
952
- knowns doc "CONVENTIONS" --plain
953
-
954
- # === FULL WORKFLOW ===
955
- knowns task create "Title" -d "Description" --ac "Criterion"
956
- knowns task edit <id> -s in-progress -a $(knowns config get defaultAssignee --plain || echo "@me")
957
- knowns time start <id> # ⏱️ REQUIRED: Start timer
958
- knowns search "keyword" --type doc --plain
959
- knowns doc "Doc Name" --plain
960
- knowns search "keyword" --type task --status done --plain # Learn from history
961
- knowns task edit <id> --plan $'1. Step (see @doc/file)\n2. Step'
962
- # ... wait for approval, then implement ...
963
- # Only check AC AFTER completing the work:
964
- knowns task edit <id> --check-ac 1
965
- knowns task edit <id> --append-notes "✓ Completed: feature X"
966
- knowns task edit <id> --check-ac 2
967
- knowns task edit <id> --append-notes "✓ Completed: feature Y"
968
- knowns time stop # ⏱️ REQUIRED: Stop timer
969
- knowns task edit <id> -s done
970
- # Optional: Extract knowledge to docs if generalizable patterns found
971
-
972
- # === VIEW & SEARCH ===
973
- knowns task <id> --plain # Shorthand for view
974
- knowns task list --plain
975
- knowns task list --status in-progress --assignee $(knowns config get defaultAssignee --plain || echo "@me") --plain
976
- knowns search "query" --plain
977
- knowns search "bug" --type task --status in-progress --plain
978
-
979
- # === TIME TRACKING ===
980
- knowns time start <id>
981
- knowns time stop
982
- knowns time status
983
- knowns time report --from "2025-12-01" --to "2025-12-31"
984
-
985
- # === DOCUMENTATION ===
986
- knowns doc list --plain
987
- knowns doc "path/doc-name" --plain # Shorthand for view
988
- knowns doc create "Title" -d "Description" -t "tags" -f "folder"
989
- knowns doc edit "doc-name" -c "New content"
990
- knowns doc edit "doc-name" -a "Appended content"
991
- ```
992
-
993
- ---
994
-
995
- **Maintained By**: Knowns CLI Team
996
-
997
- <!-- KNOWNS GUIDELINES END -->
998
-
999
-