botnote 0.2.15 → 0.2.17

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 (138) hide show
  1. package/README.md +26 -506
  2. package/dist/bin.js +28 -21
  3. package/dist/bin.js.map +1 -1
  4. package/dist/config.d.ts +0 -4
  5. package/dist/config.js +0 -31
  6. package/dist/config.js.map +1 -1
  7. package/dist/mcp/http-client.d.ts +6 -5
  8. package/dist/mcp/http-client.js +28 -4
  9. package/dist/mcp/http-client.js.map +1 -1
  10. package/dist/mcp/server.js +16 -16
  11. package/dist/mcp/server.js.map +1 -1
  12. package/dist/mcp/stdio.d.ts +8 -0
  13. package/dist/mcp/stdio.js +46 -0
  14. package/dist/mcp/stdio.js.map +1 -0
  15. package/package.json +8 -40
  16. package/dist/cli.d.ts +0 -1
  17. package/dist/cli.js +0 -186
  18. package/dist/cli.js.map +0 -1
  19. package/dist/db/client.d.ts +0 -14
  20. package/dist/db/client.js +0 -16
  21. package/dist/db/client.js.map +0 -1
  22. package/dist/db/migrate.d.ts +0 -1
  23. package/dist/db/migrate.js +0 -57
  24. package/dist/db/migrate.js.map +0 -1
  25. package/dist/db/migrations/0001_init.sql +0 -89
  26. package/dist/db/migrations/0002_tasks_due_at.sql +0 -16
  27. package/dist/db/migrations/0003_task_priority_and_sequence.sql +0 -45
  28. package/dist/db/migrations/0004_pinned.sql +0 -8
  29. package/dist/db/migrations/0005_nullable_title_and_parent.sql +0 -5
  30. package/dist/db/migrations/0006_project_color_icon.sql +0 -3
  31. package/dist/db/migrations/0007_tokens.sql +0 -14
  32. package/dist/db/migrations/0008_simplify_kinds_drop_actors.sql +0 -21
  33. package/dist/db/migrations/0009_sessions.sql +0 -14
  34. package/dist/db/migrations/0010_completed_at.sql +0 -17
  35. package/dist/db/migrations/0011_completed_at_backfill_fix.sql +0 -14
  36. package/dist/db/migrations/0012_completed_at_backfill_due.sql +0 -16
  37. package/dist/db/migrations/0013_due_at_noon_utc.sql +0 -13
  38. package/dist/db/migrations/0014_recoverable_api_tokens.sql +0 -3
  39. package/dist/db/migrations/0015_collapse_delayed_archived_statuses.sql +0 -18
  40. package/dist/db/migrations/0016_embedding_settings.sql +0 -23
  41. package/dist/db/migrations/0017_recurrence_rules.sql +0 -55
  42. package/dist/db/migrations/0018_project_archived_at.sql +0 -8
  43. package/dist/db/migrations/0019_project_status.sql +0 -20
  44. package/dist/db/migrations/0020_project_archived_status.sql +0 -20
  45. package/dist/db/migrations/0021_workspace_settings.sql +0 -18
  46. package/dist/db/migrations/0022_recurrence_split.sql +0 -13
  47. package/dist/db/migrations/0023_comment_kind.sql +0 -24
  48. package/dist/db/migrations/0024_memory_access.sql +0 -12
  49. package/dist/db/migrations/0025_soft_delete.sql +0 -12
  50. package/dist/db/migrations/0026_sequence_counter.sql +0 -61
  51. package/dist/db/migrations/0027_self_parent_repair.sql +0 -10
  52. package/dist/db/migrations/0028_workspaces.sql +0 -65
  53. package/dist/db/migrations/0029_drop_global_uniques.sql +0 -38
  54. package/dist/db/migrations/0030_entity_actor_token.sql +0 -12
  55. package/dist/db/migrations/0031_entity_revisions.sql +0 -19
  56. package/dist/db/migrations/0032_touch_respects_explicit_updated_at.sql +0 -18
  57. package/dist/db/schema.d.ts +0 -2023
  58. package/dist/db/schema.js +0 -245
  59. package/dist/db/schema.js.map +0 -1
  60. package/dist/rest/attribution.d.ts +0 -22
  61. package/dist/rest/attribution.js +0 -62
  62. package/dist/rest/attribution.js.map +0 -1
  63. package/dist/rest/auth.d.ts +0 -47
  64. package/dist/rest/auth.js +0 -116
  65. package/dist/rest/auth.js.map +0 -1
  66. package/dist/rest/routes.d.ts +0 -3
  67. package/dist/rest/routes.js +0 -831
  68. package/dist/rest/routes.js.map +0 -1
  69. package/dist/rest/server.d.ts +0 -28
  70. package/dist/rest/server.js +0 -276
  71. package/dist/rest/server.js.map +0 -1
  72. package/dist/service/blockers.d.ts +0 -37
  73. package/dist/service/blockers.js +0 -46
  74. package/dist/service/blockers.js.map +0 -1
  75. package/dist/service/dates.d.ts +0 -19
  76. package/dist/service/dates.js +0 -52
  77. package/dist/service/dates.js.map +0 -1
  78. package/dist/service/embedding.d.ts +0 -75
  79. package/dist/service/embedding.js +0 -318
  80. package/dist/service/embedding.js.map +0 -1
  81. package/dist/service/embedding_settings.d.ts +0 -16
  82. package/dist/service/embedding_settings.js +0 -82
  83. package/dist/service/embedding_settings.js.map +0 -1
  84. package/dist/service/entities.d.ts +0 -96
  85. package/dist/service/entities.js +0 -628
  86. package/dist/service/entities.js.map +0 -1
  87. package/dist/service/feedback.d.ts +0 -13
  88. package/dist/service/feedback.js +0 -50
  89. package/dist/service/feedback.js.map +0 -1
  90. package/dist/service/hierarchy.d.ts +0 -31
  91. package/dist/service/hierarchy.js +0 -76
  92. package/dist/service/hierarchy.js.map +0 -1
  93. package/dist/service/index.d.ts +0 -10
  94. package/dist/service/index.js +0 -10
  95. package/dist/service/index.js.map +0 -1
  96. package/dist/service/locks.d.ts +0 -25
  97. package/dist/service/locks.js +0 -34
  98. package/dist/service/locks.js.map +0 -1
  99. package/dist/service/opening_brief.d.ts +0 -24
  100. package/dist/service/opening_brief.js +0 -210
  101. package/dist/service/opening_brief.js.map +0 -1
  102. package/dist/service/projects.d.ts +0 -9
  103. package/dist/service/projects.js +0 -59
  104. package/dist/service/projects.js.map +0 -1
  105. package/dist/service/recurrence.d.ts +0 -93
  106. package/dist/service/recurrence.js +0 -799
  107. package/dist/service/recurrence.js.map +0 -1
  108. package/dist/service/revisions.d.ts +0 -31
  109. package/dist/service/revisions.js +0 -53
  110. package/dist/service/revisions.js.map +0 -1
  111. package/dist/service/scope.d.ts +0 -14
  112. package/dist/service/scope.js +0 -19
  113. package/dist/service/scope.js.map +0 -1
  114. package/dist/service/search.d.ts +0 -34
  115. package/dist/service/search.js +0 -198
  116. package/dist/service/search.js.map +0 -1
  117. package/dist/service/sessions.d.ts +0 -24
  118. package/dist/service/sessions.js +0 -89
  119. package/dist/service/sessions.js.map +0 -1
  120. package/dist/service/tasks.d.ts +0 -48
  121. package/dist/service/tasks.js +0 -354
  122. package/dist/service/tasks.js.map +0 -1
  123. package/dist/service/tokens.d.ts +0 -21
  124. package/dist/service/tokens.js +0 -71
  125. package/dist/service/tokens.js.map +0 -1
  126. package/dist/service/transfer.d.ts +0 -64
  127. package/dist/service/transfer.js +0 -629
  128. package/dist/service/transfer.js.map +0 -1
  129. package/dist/service/types.d.ts +0 -770
  130. package/dist/service/types.js +0 -272
  131. package/dist/service/types.js.map +0 -1
  132. package/dist/service/workspace_settings.d.ts +0 -9
  133. package/dist/service/workspace_settings.js +0 -49
  134. package/dist/service/workspace_settings.js.map +0 -1
  135. package/web/dist/assets/index-C0u0ZrR4.css +0 -1
  136. package/web/dist/assets/index-CwZxw-xa.js +0 -235
  137. package/web/dist/favicon.svg +0 -13
  138. package/web/dist/index.html +0 -22
@@ -1,61 +0,0 @@
1
- -- Replace the MAX(sequence_id)+1 trigger with a per-project counter.
2
- --
3
- -- The old trigger read MAX(sequence_id) outside any lock, so two concurrent
4
- -- inserts into one project could both become KEY-55. The counter lives on
5
- -- projects.next_seq; the trigger's UPDATE takes the project's row lock, which
6
- -- serializes writers. A partial unique index makes a duplicate impossible
7
- -- rather than merely unlikely.
8
- --
9
- -- Expand-only: the previous release never reads next_seq, and the replaced
10
- -- trigger keeps the same signature and guards.
11
-
12
- DO $$
13
- DECLARE
14
- dup_count integer;
15
- BEGIN
16
- SELECT count(*) INTO dup_count FROM (
17
- SELECT project_id, sequence_id FROM entities
18
- WHERE sequence_id IS NOT NULL
19
- GROUP BY project_id, sequence_id HAVING count(*) > 1
20
- ) d;
21
- IF dup_count > 0 THEN
22
- RAISE EXCEPTION
23
- 'migration 0026 aborted: % duplicate (project_id, sequence_id) pair(s) exist; resolve them before adding the unique index',
24
- dup_count;
25
- END IF;
26
- END $$;
27
-
28
- ALTER TABLE projects ADD COLUMN IF NOT EXISTS next_seq integer NOT NULL DEFAULT 1;
29
-
30
- UPDATE projects p
31
- SET next_seq = COALESCE(
32
- (SELECT MAX(e.sequence_id) FROM entities e WHERE e.project_id = p.id), 0
33
- ) + 1;
34
-
35
- CREATE OR REPLACE FUNCTION botnote_set_sequence_id()
36
- RETURNS TRIGGER AS $$
37
- BEGIN
38
- IF NEW.project_id IS NULL OR NEW.kind = 'comment' THEN
39
- RETURN NEW;
40
- END IF;
41
-
42
- IF NEW.sequence_id IS NULL THEN
43
- UPDATE projects
44
- SET next_seq = next_seq + 1
45
- WHERE id = NEW.project_id
46
- RETURNING next_seq - 1 INTO NEW.sequence_id;
47
- ELSE
48
- -- An explicit sequence id (imports, repairs) must never leave the
49
- -- counter behind it, or the next auto-assigned id would collide.
50
- UPDATE projects
51
- SET next_seq = GREATEST(next_seq, NEW.sequence_id + 1)
52
- WHERE id = NEW.project_id;
53
- END IF;
54
-
55
- RETURN NEW;
56
- END;
57
- $$ LANGUAGE plpgsql;
58
-
59
- CREATE UNIQUE INDEX IF NOT EXISTS entities_project_seq_unique
60
- ON entities (project_id, sequence_id)
61
- WHERE sequence_id IS NOT NULL;
@@ -1,10 +0,0 @@
1
- -- Repair entities that point at themselves as their own parent.
2
- --
3
- -- The Letheia import wrote parent_id = id (and a matching parent_of self
4
- -- edge) for 1034 notes, so listChildren and get_entity_by_key listed each
5
- -- note as its own child. Data fix only, no schema change; both statements
6
- -- are no-ops once applied, and the service now rejects self-parenting.
7
-
8
- UPDATE entities SET parent_id = NULL WHERE parent_id = id;
9
-
10
- DELETE FROM edges WHERE from_id = to_id;
@@ -1,65 +0,0 @@
1
- -- Workspaces: the tenant boundary shared by the single-user OSS build and the
2
- -- hosted multi-user build (BOT-113, subtask 1 of BOT-101).
3
- --
4
- -- Schema only. Every tenant table gains workspace_id with a DEFAULT pointing
5
- -- at the fixed default workspace, which backfills existing rows in the same
6
- -- statement and keeps inserts from the previous release working. Service code
7
- -- starts filtering by it in the next release (BOT-114); the old global unique
8
- -- indexes stay until that release has shipped.
9
-
10
- CREATE TABLE IF NOT EXISTS workspaces (
11
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
12
- slug text NOT NULL,
13
- name text NOT NULL,
14
- created_at timestamptz NOT NULL DEFAULT now(),
15
- updated_at timestamptz NOT NULL DEFAULT now()
16
- );
17
-
18
- CREATE UNIQUE INDEX IF NOT EXISTS workspaces_slug_idx ON workspaces (slug);
19
-
20
- DROP TRIGGER IF EXISTS workspaces_touch_updated_at ON workspaces;
21
- CREATE TRIGGER workspaces_touch_updated_at
22
- BEFORE UPDATE ON workspaces
23
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
24
-
25
- INSERT INTO workspaces (id, slug, name)
26
- VALUES ('00000000-0000-4000-8000-000000000001', 'default', 'Default workspace')
27
- ON CONFLICT (id) DO NOTHING;
28
-
29
- ALTER TABLE projects
30
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
31
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
32
- ALTER TABLE entities
33
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
34
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
35
- ALTER TABLE recurrence_rules
36
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
37
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
38
- ALTER TABLE tokens
39
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
40
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
41
- ALTER TABLE sessions
42
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
43
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
44
- ALTER TABLE embedding_settings
45
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
46
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
47
- ALTER TABLE workspace_settings
48
- ADD COLUMN IF NOT EXISTS workspace_id uuid NOT NULL
49
- DEFAULT '00000000-0000-4000-8000-000000000001' REFERENCES workspaces(id);
50
-
51
- -- Tenant-scoped uniqueness. The global projects_key_idx and
52
- -- entities_idempotency_idx remain for one release so the current code keeps
53
- -- its guarantees; BOT-114 drops them once every query is scoped.
54
- CREATE UNIQUE INDEX IF NOT EXISTS projects_ws_key_unique
55
- ON projects (workspace_id, key);
56
- CREATE UNIQUE INDEX IF NOT EXISTS entities_ws_idem_unique
57
- ON entities (workspace_id, idempotency_key)
58
- WHERE idempotency_key IS NOT NULL;
59
-
60
- CREATE INDEX IF NOT EXISTS entities_ws_kind_created_idx
61
- ON entities (workspace_id, kind, created_at DESC);
62
- CREATE INDEX IF NOT EXISTS recurrence_rules_ws_idx
63
- ON recurrence_rules (workspace_id, enabled, next_occurrence_at);
64
- CREATE INDEX IF NOT EXISTS tokens_ws_idx ON tokens (workspace_id);
65
- CREATE INDEX IF NOT EXISTS sessions_ws_idx ON sessions (workspace_id);
@@ -1,38 +0,0 @@
1
- -- Workspace scoping is live in service code as of this release (BOT-114,
2
- -- subtask 2 of BOT-101): every tenant-facing query filters by workspace_id and
3
- -- every insert stamps it.
4
- --
5
- -- 1. The per-workspace unique indexes from 0028 (projects_ws_key_unique,
6
- -- entities_ws_idem_unique) now carry the invariant, so the pre-workspace
7
- -- global uniques are redundant and would wrongly reject the same project
8
- -- key or idempotency key reused in a second workspace.
9
- --
10
- -- 2. workspace_settings and embedding_settings were singletons keyed by
11
- -- id = 'default'. They become one row per workspace: the primary key moves
12
- -- to workspace_id and `id` stays as a constant discriminator column. The
13
- -- CHECK (id = 'default') is kept on purpose — it no longer limits the row
14
- -- count once id is not unique, and keeping it means the N-1 code path
15
- -- (INSERT id='default' ... ON CONFLICT DO NOTHING; SELECT WHERE id='default')
16
- -- still runs unchanged against this schema.
17
-
18
- DROP INDEX IF EXISTS projects_key_idx;
19
- DROP INDEX IF EXISTS entities_idempotency_idx;
20
-
21
- DO $$
22
- BEGIN
23
- IF EXISTS (SELECT 1 FROM pg_constraint
24
- WHERE conname = 'workspace_settings_pkey'
25
- AND conrelid = 'workspace_settings'::regclass
26
- AND pg_get_constraintdef(oid) = 'PRIMARY KEY (id)') THEN
27
- ALTER TABLE workspace_settings DROP CONSTRAINT workspace_settings_pkey;
28
- ALTER TABLE workspace_settings ADD CONSTRAINT workspace_settings_pkey PRIMARY KEY (workspace_id);
29
- END IF;
30
-
31
- IF EXISTS (SELECT 1 FROM pg_constraint
32
- WHERE conname = 'embedding_settings_pkey'
33
- AND conrelid = 'embedding_settings'::regclass
34
- AND pg_get_constraintdef(oid) = 'PRIMARY KEY (id)') THEN
35
- ALTER TABLE embedding_settings DROP CONSTRAINT embedding_settings_pkey;
36
- ALTER TABLE embedding_settings ADD CONSTRAINT embedding_settings_pkey PRIMARY KEY (workspace_id);
37
- END IF;
38
- END $$;
@@ -1,12 +0,0 @@
1
- -- Write attribution (BOT-108): remember which API token wrote an entity so
2
- -- the brief and the UI can say "written by <token name>" instead of the bare
3
- -- actor_kind. Nullable and expand-only: rows written through a session
4
- -- cookie, the trusted loopback path, or by N-1 code simply carry NULL.
5
- -- Revoking a token keeps the rows and clears the reference.
6
-
7
- ALTER TABLE entities
8
- ADD COLUMN IF NOT EXISTS actor_token_id uuid REFERENCES tokens(id) ON DELETE SET NULL;
9
-
10
- CREATE INDEX IF NOT EXISTS entities_actor_token_idx
11
- ON entities (actor_token_id)
12
- WHERE actor_token_id IS NOT NULL;
@@ -1,19 +0,0 @@
1
- -- Content history: one row per content-changing update, holding the values
2
- -- as they were BEFORE that update. actor_* name who made the change that
3
- -- replaced this snapshot. Expand-only; 0.2.x code ignores the table.
4
- CREATE TABLE IF NOT EXISTS entity_revisions (
5
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
6
- entity_id uuid NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
7
- revision integer NOT NULL,
8
- title text,
9
- body text NOT NULL DEFAULT '',
10
- tags text[] NOT NULL DEFAULT '{}'::text[],
11
- priority text NOT NULL DEFAULT 'none',
12
- status text NOT NULL DEFAULT 'open',
13
- actor_kind text NOT NULL DEFAULT 'human',
14
- actor_token_id uuid REFERENCES tokens(id) ON DELETE SET NULL,
15
- created_at timestamptz NOT NULL DEFAULT now()
16
- );
17
-
18
- CREATE UNIQUE INDEX IF NOT EXISTS entity_revisions_entity_revision_idx
19
- ON entity_revisions (entity_id, revision DESC);
@@ -1,18 +0,0 @@
1
- -- botnote_touch_updated_at used to overwrite updated_at on every UPDATE, so
2
- -- nothing could ever restore a historical timestamp: the sequence trigger's
3
- -- counter bump on projects (0026) stamped "now" on every project that
4
- -- received an imported entity, and a workspace import could not round-trip
5
- -- projects.updated_at. The function now leaves updated_at alone when the
6
- -- statement itself changed it, and keeps stamping now() otherwise.
7
- --
8
- -- Expand-only: 0.2.x code only ever writes updated_at = now(), which this
9
- -- version treats exactly as before. Same signature, same triggers.
10
- CREATE OR REPLACE FUNCTION botnote_touch_updated_at() RETURNS trigger AS $$
11
- BEGIN
12
- IF NEW.updated_at IS DISTINCT FROM OLD.updated_at THEN
13
- RETURN NEW;
14
- END IF;
15
- NEW.updated_at = now();
16
- RETURN NEW;
17
- END;
18
- $$ LANGUAGE plpgsql;