kanban-lite 1.0.31 → 1.0.33

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 (40) hide show
  1. package/AGENTS.md +20 -4
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +71 -2
  4. package/dist/cli.js +21058 -11842
  5. package/dist/extension.js +8666 -7017
  6. package/dist/mcp-server.js +2583 -903
  7. package/dist/sdk/index.cjs +2509 -899
  8. package/dist/sdk/index.mjs +2523 -882
  9. package/dist/sdk/sdk/KanbanSDK.d.ts +80 -3
  10. package/dist/sdk/sdk/storage/index.d.ts +58 -0
  11. package/dist/sdk/sdk/storage/markdown.d.ts +49 -0
  12. package/dist/sdk/sdk/storage/sqlite.d.ts +61 -0
  13. package/dist/sdk/sdk/storage/types.d.ts +179 -0
  14. package/dist/sdk/sdk/types.d.ts +22 -1
  15. package/dist/sdk/shared/config.d.ts +12 -0
  16. package/dist/standalone-webview/icons-DqI3jXv3.js.map +1 -1
  17. package/dist/standalone-webview/index.js.map +1 -1
  18. package/dist/standalone-webview/react-vendor-K4aqks7O.js.map +1 -1
  19. package/dist/webview/icons-DqI3jXv3.js.map +1 -1
  20. package/dist/webview/index.js.map +1 -1
  21. package/dist/webview/react-vendor-K4aqks7O.js.map +1 -1
  22. package/docs/sdk.md +84 -1
  23. package/package.json +3 -1
  24. package/pnpm-workspace.yaml +2 -0
  25. package/src/cli/index.ts +55 -0
  26. package/src/extension/KanbanPanel.ts +18 -5
  27. package/src/mcp-server/index.ts +75 -2
  28. package/src/sdk/KanbanSDK.ts +209 -120
  29. package/src/sdk/__tests__/KanbanSDK.test.ts +2 -2
  30. package/src/sdk/__tests__/storage-markdown.test.ts +173 -0
  31. package/src/sdk/__tests__/storage-migration.test.ts +148 -0
  32. package/src/sdk/__tests__/storage-sqlite.test.ts +214 -0
  33. package/src/sdk/fileUtils.ts +5 -2
  34. package/src/sdk/storage/index.ts +97 -0
  35. package/src/sdk/storage/markdown.ts +191 -0
  36. package/src/sdk/storage/sqlite.ts +604 -0
  37. package/src/sdk/storage/types.ts +202 -0
  38. package/src/sdk/types.ts +23 -0
  39. package/src/shared/config.ts +12 -0
  40. package/src/standalone/server.ts +71 -17
package/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Kanban Markdown - Development Guide
2
2
 
3
- A VSCode extension + standalone server + CLI + MCP server for managing kanban boards stored as markdown files.
3
+ A VSCode extension + standalone server + CLI + MCP server for managing kanban boards stored as markdown files (default) or SQLite.
4
4
 
5
5
  ## Architecture
6
6
 
@@ -18,6 +18,10 @@ src/
18
18
  ## Key Files
19
19
 
20
20
  - `src/sdk/KanbanSDK.ts` - Core card/column CRUD operations
21
+ - `src/sdk/storage/types.ts` - StorageEngine interface and BootstrapConfig
22
+ - `src/sdk/storage/markdown.ts` - MarkdownStorageEngine (default)
23
+ - `src/sdk/storage/sqlite.ts` - SqliteStorageEngine (better-sqlite3)
24
+ - `src/sdk/storage/index.ts` - Storage engine factory + readBootstrapConfig
21
25
  - `src/sdk/parser.ts` - Markdown frontmatter parsing and serialization
22
26
  - `src/shared/types.ts` - All TypeScript types and enums
23
27
  - `src/shared/config.ts` - `.kanban.json` config read/write, settings conversion
@@ -54,10 +58,22 @@ Never implement a feature directly in an interface layer without the SDK method
54
58
 
55
59
  ## Data Storage
56
60
 
57
- - Cards: `.kanban/{status}/card-name-YYYY-MM-DD.md` (markdown with YAML frontmatter)
58
- - Config: `.kanban.json` (columns, display settings, label definitions)
61
+ - Cards (markdown engine): `.kanban/boards/<boardId>/<status>/card-name-YYYY-MM-DD.md`
62
+ - Cards (sqlite engine): `.kanban/kanban.db` (configurable via `sqlitePath` in `.kanban.json`)
63
+ - Config: `.kanban.json` (boards, columns, display settings, label definitions)
59
64
  - Webhooks: `.kanban-webhooks.json`
60
- - SDK board config: `.kanban/board.json` (used by SDK for column management)
65
+
66
+ ## Storage Engines
67
+
68
+ The `StorageEngine` interface (`src/sdk/storage/types.ts`) abstracts all card I/O. Only card data (cards, comments) is engine-dependent — workspace config always lives in `.kanban.json`.
69
+
70
+ - **MarkdownStorageEngine** — default; full backward compatibility
71
+ - **SqliteStorageEngine** — single DB file; no chokidar watcher needed in server.ts
72
+ - Factory: `createStorageEngine(kanbanDir, options?)` in `src/sdk/storage/index.ts`
73
+ - Bootstrap: `readBootstrapConfig(workspaceRoot)` reads only `storageEngine`/`sqlitePath` before engine creation (chicken-and-egg resolution)
74
+ - SDK migration methods: `migrateToSqlite(dbPath?)` and `migrateToMarkdown()`
75
+ - `filePath` is set to `''` for SQLite cards; `sanitizeCard()` strips it from API responses
76
+ - **Caution**: JSDoc backticks inside `/** ... */` TypeScript interface comments may contain patterns like `**/` which prematurely close the comment block (e.g. glob patterns). Use prose descriptions instead.
61
77
 
62
78
  ## Card Metadata
63
79
 
package/CHANGELOG.md CHANGED
@@ -8,6 +8,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
  ### Added
11
+ - **Attachments subfolder**: attachments for the markdown storage engine are now stored in an `attachments/` subdirectory inside each column folder (e.g. `.kanban/boards/default/backlog/attachments/`) instead of alongside the card `.md` files
12
+ - **Browser-viewable attachments**: PDFs and other binary attachments now open with the OS/browser default viewer in the VS Code extension; the standalone server now serves PDF, JPEG, GIF, WebP, CSV, plain-text, and XML attachments with correct `Content-Type` headers so browsers render them inline in a new tab
13
+ - **KanbanSDK.getAttachmentDir(cardId, boardId?)**: new public SDK method that returns the absolute path to the attachment directory for a card (delegates to the active storage engine)
14
+ - **Pluggable storage engine**: new `StorageEngine` interface (`src/sdk/storage/types.ts`) decouples all card I/O from the SDK business logic
15
+ - **SQLite storage engine**: `SqliteStorageEngine` stores cards and comments in a single `.kanban/kanban.db` file using `better-sqlite3`; config (boards, columns, labels, webhooks) always stays in `.kanban.json`
16
+ - **Markdown storage engine**: `MarkdownStorageEngine` wraps the existing file-based I/O, unchanged default behavior
17
+ - **Storage engine configuration**: `storageEngine` (`"markdown"` | `"sqlite"`) and `sqlitePath` fields in `.kanban.json`
18
+ - **KanbanSDK.migrateToSqlite(dbPath?)**: migrates all markdown cards to SQLite and updates `.kanban.json`
19
+ - **KanbanSDK.migrateToMarkdown()**: migrates all SQLite cards back to markdown files and updates `.kanban.json`
20
+ - **KanbanSDK.close()**: releases storage engine resources (e.g. closes SQLite DB connection)
21
+ - **KanbanSDK.storageEngine** getter: exposes the active `StorageEngine` instance
22
+ - **CLI storage commands**: `kl storage status`, `kl storage migrate-to-sqlite [--sqlite-path <path>]`, `kl storage migrate-to-markdown`
23
+ - **REST API storage endpoints**: `GET /api/storage`, `POST /api/storage/migrate-to-sqlite`, `POST /api/storage/migrate-to-markdown`; `/api/workspace` now includes `storageEngine` and `sqlitePath`
24
+ - **MCP storage tools**: `get_storage_status`, `migrate_to_sqlite`, `migrate_to_markdown`
25
+ - **Storage engine tests**: `storage-markdown.test.ts` (10 tests), `storage-sqlite.test.ts` (15 tests), `storage-migration.test.ts` (5 tests)
26
+
27
+ ### Changed
28
+ - `src/standalone/server.ts`: chokidar file watcher is skipped when the active storage engine is `sqlite` (no `.md` files to watch)
11
29
  - **Multi-select cards**: Cmd/Ctrl+click to toggle individual cards, Shift+click to select a range, "Select All" in column menu
12
30
  - **Bulk actions bar**: floating toolbar when multiple cards are selected with Move to, Priority, Assign, Labels, and Delete actions
13
31
  - Multi-card drag & drop to move selected cards to another column
package/README.md CHANGED
@@ -168,6 +168,11 @@ kl settings update --compactMode true # Update a setting
168
168
  # Workspace
169
169
  kl pwd # Print workspace root path
170
170
 
171
+ # Storage engine
172
+ kl storage status # Show current engine
173
+ kl storage migrate-to-sqlite --sqlite-path .kanban/kanban.db # Migrate to SQLite
174
+ kl storage migrate-to-markdown # Migrate back to markdown
175
+
171
176
  # Start web server
172
177
  kl serve # Start on port 3000
173
178
  kl serve --port 8080 --no-browser # Custom port, no auto-open
@@ -272,7 +277,10 @@ Board-scoped equivalents are available at `/api/boards/:boardId/tasks/...`.
272
277
 
273
278
  | Method | Endpoint | Description |
274
279
  |--------|----------|-------------|
275
- | `GET` | `/api/workspace` | Get workspace root path |
280
+ | `GET` | `/api/workspace` | Get workspace root path and storage engine |
281
+ | `GET` | `/api/storage` | Get current storage engine type and config |
282
+ | `POST` | `/api/storage/migrate-to-sqlite` | Migrate cards to SQLite (`{ sqlitePath? }`) |
283
+ | `POST` | `/api/storage/migrate-to-markdown` | Migrate cards back to markdown files |
276
284
 
277
285
  #### Comments
278
286
 
@@ -510,7 +518,10 @@ kanban-mcp --dir .kanban # Via dedicated binary
510
518
  | `add_webhook` | Register a new webhook |
511
519
  | `update_webhook` | Update a webhook (url, events, secret, active) |
512
520
  | `remove_webhook` | Remove a webhook |
513
- | `get_workspace_info` | Get workspace root path and features directory |
521
+ | `get_workspace_info` | Get workspace root path, storage engine, and features directory |
522
+ | `get_storage_status` | Get current storage engine type and configuration |
523
+ | `migrate_to_sqlite` | Migrate all card data from markdown to SQLite |
524
+ | `migrate_to_markdown` | Migrate all card data from SQLite back to markdown files |
514
525
 
515
526
  All card, column, comment, and attachment tools accept an optional `boardId` parameter to target a specific board.
516
527
 
@@ -613,6 +624,64 @@ Yes, good idea. I'll add that as a follow-up.
613
624
 
614
625
  Comments are stored as additional YAML documents in the same file, keeping everything in one place and version-controllable.
615
626
 
627
+ ## Storage Engines
628
+
629
+ By default cards are stored as markdown files. You can optionally switch to a **SQLite** backend to keep all card data in a single database file — useful for programmatic access or performance at scale.
630
+
631
+ The active engine is configured in `.kanban.json`:
632
+
633
+ ```json
634
+ {
635
+ "storageEngine": "sqlite",
636
+ "sqlitePath": ".kanban/kanban.db"
637
+ }
638
+ ```
639
+
640
+ | Engine | Default | Card storage | Config storage |
641
+ |--------|---------|--------------|----------------|
642
+ | `markdown` | ✓ | `.kanban/boards/<board>/<status>/*.md` | `.kanban.json` |
643
+ | `sqlite` | | `.kanban/kanban.db` (configurable) | `.kanban.json` |
644
+
645
+ In both cases `.kanban.json` remains the source of truth for board config, columns, labels, settings, and webhooks.
646
+
647
+ ### Migrating between engines
648
+
649
+ **CLI:**
650
+ ```bash
651
+ # Check current engine
652
+ kl storage status
653
+
654
+ # Migrate to SQLite
655
+ kl storage migrate-to-sqlite --sqlite-path .kanban/kanban.db
656
+
657
+ # Migrate back to markdown
658
+ kl storage migrate-to-markdown
659
+ ```
660
+
661
+ **REST API:**
662
+ ```bash
663
+ curl -X POST http://localhost:3000/api/storage/migrate-to-sqlite \
664
+ -H 'Content-Type: application/json' \
665
+ -d '{"sqlitePath": ".kanban/kanban.db"}'
666
+ ```
667
+
668
+ **SDK:**
669
+ ```ts
670
+ const sdk = new KanbanSDK('.kanban')
671
+ await sdk.init()
672
+
673
+ // Migrate to SQLite
674
+ const count = await sdk.migrateToSqlite('.kanban/kanban.db')
675
+ console.log(`Migrated ${count} cards to SQLite`)
676
+
677
+ // Or migrate back
678
+ await sdk.migrateToMarkdown()
679
+ ```
680
+
681
+ Existing files / the database are **not deleted** during migration — they serve as a manual backup until you remove them.
682
+
683
+ **MCP tools:** `get_storage_status`, `migrate_to_sqlite`, `migrate_to_markdown`
684
+
616
685
  ## Configuration
617
686
 
618
687
  Board configuration is stored in `.kanban.json` at your project root. It supports multiple boards, each with their own columns and settings: