writbase 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +121 -0
  2. package/dist/writbase.js +707 -0
  3. package/migrations/00001_enums.sql +7 -0
  4. package/migrations/00002_core_tables.sql +105 -0
  5. package/migrations/00003_constraints_indexes.sql +69 -0
  6. package/migrations/00004_rls_policies.sql +169 -0
  7. package/migrations/00005_seed_app_settings.sql +2 -0
  8. package/migrations/00006_rate_limit_rpc.sql +14 -0
  9. package/migrations/00007_rate_limit_rpc_search_path.sql +14 -0
  10. package/migrations/00008_indexes_and_cleanup.sql +22 -0
  11. package/migrations/00009_atomic_mutations.sql +175 -0
  12. package/migrations/00010_user_rate_limits.sql +52 -0
  13. package/migrations/00011_atomic_permission_update.sql +31 -0
  14. package/migrations/00012_pg_cron_cleanup.sql +27 -0
  15. package/migrations/00013_max_agent_keys.sql +4 -0
  16. package/migrations/00014_event_log_indexes.sql +2 -0
  17. package/migrations/00015_auth_rate_limits.sql +69 -0
  18. package/migrations/00016_request_log.sql +42 -0
  19. package/migrations/00017_task_search.sql +58 -0
  20. package/migrations/00018_inter_agent_exchange.sql +423 -0
  21. package/migrations/00019_workspaces.sql +782 -0
  22. package/migrations/00020_can_comment.sql +46 -0
  23. package/migrations/00021_webhook_delivery.sql +125 -0
  24. package/migrations/00022_task_archive.sql +380 -0
  25. package/migrations/00023_get_top_tasks.sql +21 -0
  26. package/migrations/00024_agent_key_defaults.sql +55 -0
  27. package/migrations/00025_production_automation.sql +353 -0
  28. package/migrations/00026_top_tasks_exclude_terminal.sql +19 -0
  29. package/migrations/00027_rename_agent_key_defaults.sql +51 -0
  30. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # WritBase CLI
2
+
3
+ Self-hosted operator toolkit for WritBase — agent-first task management.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx writbase init # Interactive setup
9
+ npx writbase migrate # Apply database schema
10
+ npx writbase key create # Create your first agent key
11
+ npx writbase status # Verify everything works
12
+ ```
13
+
14
+ ## Prerequisites
15
+
16
+ - **Node.js 18+**
17
+ - **Supabase CLI** — [Install guide](https://supabase.com/docs/guides/cli)
18
+ - A Supabase project (hosted or local)
19
+
20
+ ## Commands
21
+
22
+ ### `writbase init`
23
+
24
+ Interactive setup wizard. Detects local Supabase instances, validates credentials, and writes a `.env` file.
25
+
26
+ Handles three scenarios:
27
+ - **Hosted Supabase** — prompts for URL, service role key, and database URL
28
+ - **Local Supabase** — auto-detects credentials via `supabase status`
29
+ - **No project yet** — offers to run `supabase init` + `supabase start`
30
+
31
+ ### `writbase migrate`
32
+
33
+ Applies all WritBase database migrations using `supabase migration up`.
34
+
35
+ ```bash
36
+ writbase migrate # Apply migrations
37
+ writbase migrate --dry-run # Preview without applying
38
+ ```
39
+
40
+ Bundles migrations from the WritBase repo and runs them against your database via a temporary project structure. No files are created in your working directory.
41
+
42
+ ### `writbase key create`
43
+
44
+ Interactive agent key creation. Prompts for name, role (worker/manager), and optional project/department scoping.
45
+
46
+ ```bash
47
+ writbase key create
48
+ # Key name: my-agent
49
+ # Role: worker
50
+ # ✓ Agent key created
51
+ # ⚠ Save this key now — it cannot be retrieved later:
52
+ # wb_<uuid>_<secret>
53
+ ```
54
+
55
+ ### `writbase key list`
56
+
57
+ List all agent keys in the workspace.
58
+
59
+ ```bash
60
+ writbase key list
61
+ ```
62
+
63
+ ### `writbase key rotate <name-or-id>`
64
+
65
+ Generate a new secret for an existing key. The old secret stops working immediately.
66
+
67
+ ```bash
68
+ writbase key rotate my-agent
69
+ ```
70
+
71
+ ### `writbase key deactivate <name-or-id>`
72
+
73
+ Deactivate a key. Supports lookup by name or ID prefix.
74
+
75
+ ```bash
76
+ writbase key deactivate my-agent
77
+ ```
78
+
79
+ ### `writbase status`
80
+
81
+ Health check — validates connection and shows resource counts.
82
+
83
+ ```bash
84
+ writbase status
85
+ # ✓ Connected to Supabase
86
+ # ℹ Workspace: <uuid>
87
+ #
88
+ # Resource │ Count
89
+ # ────────────┼───────
90
+ # Agent Keys │ 3
91
+ # Tasks │ 42
92
+ # Projects │ 2
93
+ ```
94
+
95
+ ## Environment Variables
96
+
97
+ WritBase CLI reads from `.env` in the current directory:
98
+
99
+ | Variable | Description |
100
+ |---|---|
101
+ | `SUPABASE_URL` | Your Supabase project URL |
102
+ | `SUPABASE_SERVICE_ROLE_KEY` | Service role key (full admin access) |
103
+ | `DATABASE_URL` | Direct Postgres connection string |
104
+ | `WRITBASE_WORKSPACE_ID` | UUID of the workspace to operate on |
105
+
106
+ ## Troubleshooting
107
+
108
+ ### pg_cron notice on local dev
109
+
110
+ Some migrations reference `pg_cron` which isn't available locally. These are conditional and will be skipped — the notice is expected.
111
+
112
+ ### Finding DATABASE_URL
113
+
114
+ In the Supabase dashboard: **Settings → Database → Connection string → URI**. If the password contains special characters, it must be percent-encoded.
115
+
116
+ ### Migration errors
117
+
118
+ If `writbase migrate` fails, ensure:
119
+ 1. The Supabase CLI is installed and up to date
120
+ 2. `DATABASE_URL` is correct and the database is accessible
121
+ 3. Run with `--dry-run` first to preview changes