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,57 +0,0 @@
1
- import { readFileSync, readdirSync } from "node:fs";
2
- import { join, dirname } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { createPool } from "./client.js";
5
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
- const MIGRATIONS_DIR = join(__dirname, "migrations");
7
- export async function migrate() {
8
- const pool = createPool();
9
- try {
10
- await pool.query(`
11
- CREATE TABLE IF NOT EXISTS _migrations (
12
- name text PRIMARY KEY,
13
- applied_at timestamptz NOT NULL DEFAULT now()
14
- )
15
- `);
16
- const applied = new Set((await pool.query("SELECT name FROM _migrations")).rows.map((r) => r.name));
17
- const files = readdirSync(MIGRATIONS_DIR)
18
- .filter((f) => f.endsWith(".sql"))
19
- .sort();
20
- for (const file of files) {
21
- if (applied.has(file)) {
22
- console.log(`skip ${file} (already applied)`);
23
- continue;
24
- }
25
- const sql = readFileSync(join(MIGRATIONS_DIR, file), "utf8");
26
- console.log(`apply ${file}`);
27
- const client = await pool.connect();
28
- try {
29
- await client.query("BEGIN");
30
- await client.query(sql);
31
- await client.query("INSERT INTO _migrations (name) VALUES ($1)", [file]);
32
- await client.query("COMMIT");
33
- }
34
- catch (err) {
35
- await client.query("ROLLBACK");
36
- throw err;
37
- }
38
- finally {
39
- client.release();
40
- }
41
- }
42
- console.log("migrations done");
43
- }
44
- finally {
45
- await pool.end();
46
- }
47
- }
48
- const isDirectInvocation = import.meta.url === `file://${process.argv[1]}` ||
49
- process.argv[1]?.endsWith("/migrate.ts") ||
50
- process.argv[1]?.endsWith("/migrate.js");
51
- if (isDirectInvocation) {
52
- migrate().catch((err) => {
53
- console.error(err);
54
- process.exit(1);
55
- });
56
- }
57
- //# sourceMappingURL=migrate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/db/migrate.ts"],"names":[],"mappings":"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"}
@@ -1,89 +0,0 @@
1
- -- botnote 0001 init schema
2
- -- Idempotent: safe to re-run.
3
-
4
- CREATE EXTENSION IF NOT EXISTS vector;
5
-
6
- CREATE TABLE IF NOT EXISTS projects (
7
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
8
- key text NOT NULL,
9
- name text NOT NULL,
10
- agents_md text NOT NULL DEFAULT '',
11
- created_at timestamptz NOT NULL DEFAULT now(),
12
- updated_at timestamptz NOT NULL DEFAULT now()
13
- );
14
- CREATE UNIQUE INDEX IF NOT EXISTS projects_key_idx ON projects(key);
15
-
16
- CREATE TABLE IF NOT EXISTS actors (
17
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
18
- name text NOT NULL,
19
- kind text NOT NULL,
20
- key text,
21
- created_at timestamptz NOT NULL DEFAULT now()
22
- );
23
- CREATE UNIQUE INDEX IF NOT EXISTS actors_name_idx ON actors(name);
24
- CREATE UNIQUE INDEX IF NOT EXISTS actors_key_idx ON actors(key);
25
-
26
- CREATE TABLE IF NOT EXISTS entities (
27
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
28
- project_id uuid REFERENCES projects(id) ON DELETE SET NULL,
29
- kind text NOT NULL,
30
- title text NOT NULL,
31
- body text NOT NULL DEFAULT '',
32
- tags text[] NOT NULL DEFAULT '{}'::text[],
33
- status text NOT NULL DEFAULT 'open',
34
- actor_id uuid REFERENCES actors(id),
35
- actor_kind text NOT NULL DEFAULT 'human',
36
- idempotency_key text,
37
- parent_id uuid REFERENCES entities(id) ON DELETE SET NULL,
38
- body_tsv tsvector GENERATED ALWAYS AS (
39
- setweight(to_tsvector('simple', coalesce(title, '')), 'A') ||
40
- setweight(to_tsvector('simple', coalesce(body, '')), 'B')
41
- ) STORED,
42
- body_vec vector(384),
43
- metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
44
- created_at timestamptz NOT NULL DEFAULT now(),
45
- updated_at timestamptz NOT NULL DEFAULT now()
46
- );
47
-
48
- CREATE INDEX IF NOT EXISTS entities_project_created_idx
49
- ON entities(project_id, created_at DESC);
50
- CREATE INDEX IF NOT EXISTS entities_project_kind_created_idx
51
- ON entities(project_id, kind, created_at DESC);
52
- CREATE INDEX IF NOT EXISTS entities_actor_created_idx
53
- ON entities(actor_id, created_at DESC);
54
- CREATE UNIQUE INDEX IF NOT EXISTS entities_idempotency_idx
55
- ON entities(idempotency_key) WHERE idempotency_key IS NOT NULL;
56
- CREATE INDEX IF NOT EXISTS entities_body_tsv_idx
57
- ON entities USING GIN(body_tsv);
58
- CREATE INDEX IF NOT EXISTS entities_body_vec_idx
59
- ON entities USING hnsw (body_vec vector_cosine_ops);
60
- CREATE INDEX IF NOT EXISTS entities_tags_idx
61
- ON entities USING GIN(tags);
62
-
63
- CREATE TABLE IF NOT EXISTS edges (
64
- from_id uuid NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
65
- to_id uuid NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
66
- kind text NOT NULL,
67
- created_at timestamptz NOT NULL DEFAULT now(),
68
- PRIMARY KEY (from_id, to_id, kind)
69
- );
70
- CREATE INDEX IF NOT EXISTS edges_to_idx ON edges(to_id, kind);
71
- CREATE INDEX IF NOT EXISTS edges_from_idx ON edges(from_id, kind);
72
-
73
- -- updated_at trigger
74
- CREATE OR REPLACE FUNCTION botnote_touch_updated_at() RETURNS trigger AS $$
75
- BEGIN
76
- NEW.updated_at = now();
77
- RETURN NEW;
78
- END;
79
- $$ LANGUAGE plpgsql;
80
-
81
- DROP TRIGGER IF EXISTS entities_touch_updated_at ON entities;
82
- CREATE TRIGGER entities_touch_updated_at
83
- BEFORE UPDATE ON entities
84
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
85
-
86
- DROP TRIGGER IF EXISTS projects_touch_updated_at ON projects;
87
- CREATE TRIGGER projects_touch_updated_at
88
- BEFORE UPDATE ON projects
89
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
@@ -1,16 +0,0 @@
1
- -- botnote 0002 — tasks need due dates for the Calendar view.
2
- -- Idempotent: safe to re-run.
3
-
4
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS due_at timestamptz;
5
-
6
- CREATE INDEX IF NOT EXISTS entities_due_at_idx
7
- ON entities(due_at) WHERE due_at IS NOT NULL;
8
-
9
- CREATE INDEX IF NOT EXISTS entities_kind_due_at_idx
10
- ON entities(kind, due_at) WHERE due_at IS NOT NULL;
11
-
12
- CREATE INDEX IF NOT EXISTS entities_task_due_idx
13
- ON entities(due_at) WHERE kind = 'task' AND due_at IS NOT NULL;
14
-
15
- CREATE INDEX IF NOT EXISTS entities_task_no_due_idx
16
- ON entities(created_at DESC) WHERE kind = 'task' AND due_at IS NULL AND status <> 'done';
@@ -1,45 +0,0 @@
1
- -- botnote 0003 — priority + per-project sequence id (DEMO-12 style).
2
- -- Idempotent.
3
-
4
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS priority text NOT NULL DEFAULT 'none';
5
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS sequence_id integer;
6
-
7
- CREATE INDEX IF NOT EXISTS entities_project_seq_idx
8
- ON entities(project_id, sequence_id) WHERE sequence_id IS NOT NULL;
9
-
10
- -- per-project sequence trigger. Assign sequence_id on INSERT when project_id
11
- -- is set (workspace-wide entities stay null).
12
- CREATE OR REPLACE FUNCTION botnote_set_sequence_id() RETURNS trigger AS $$
13
- BEGIN
14
- IF NEW.sequence_id IS NULL AND NEW.project_id IS NOT NULL THEN
15
- SELECT COALESCE(MAX(sequence_id), 0) + 1
16
- INTO NEW.sequence_id
17
- FROM entities
18
- WHERE project_id = NEW.project_id;
19
- END IF;
20
- RETURN NEW;
21
- END;
22
- $$ LANGUAGE plpgsql;
23
-
24
- DROP TRIGGER IF EXISTS entities_set_sequence_id ON entities;
25
- CREATE TRIGGER entities_set_sequence_id
26
- BEFORE INSERT ON entities
27
- FOR EACH ROW EXECUTE FUNCTION botnote_set_sequence_id();
28
-
29
- -- Backfill existing rows that have project_id but no sequence_id, ordered by created_at.
30
- DO $$
31
- DECLARE
32
- rec record;
33
- counters jsonb := '{}'::jsonb;
34
- next_n integer;
35
- BEGIN
36
- FOR rec IN
37
- SELECT id, project_id FROM entities
38
- WHERE project_id IS NOT NULL AND sequence_id IS NULL
39
- ORDER BY project_id, created_at
40
- LOOP
41
- next_n := COALESCE((counters->>rec.project_id::text)::int, 0) + 1;
42
- counters := jsonb_set(counters, ARRAY[rec.project_id::text], to_jsonb(next_n));
43
- UPDATE entities SET sequence_id = next_n WHERE id = rec.id;
44
- END LOOP;
45
- END $$;
@@ -1,8 +0,0 @@
1
- -- botnote 0004 — pinned flag for project-level context surfacing.
2
- -- Idempotent.
3
-
4
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS pinned boolean NOT NULL DEFAULT false;
5
-
6
- CREATE INDEX IF NOT EXISTS entities_pinned_idx
7
- ON entities(project_id, pinned)
8
- WHERE pinned = true;
@@ -1,5 +0,0 @@
1
- -- Allow title to be null (notes without a title use body-derived placeholder in UI).
2
- ALTER TABLE entities ALTER COLUMN title DROP NOT NULL;
3
-
4
- -- Index parent_id for fast lookups of related entities (e.g. notes linked to a task).
5
- CREATE INDEX IF NOT EXISTS entities_parent_idx ON entities(parent_id) WHERE parent_id IS NOT NULL;
@@ -1,3 +0,0 @@
1
- -- Per-project color + icon. Defaults match the Linear-ish indigo accent and a simple circle dot.
2
- ALTER TABLE projects ADD COLUMN IF NOT EXISTS color text NOT NULL DEFAULT '#5e6ad2';
3
- ALTER TABLE projects ADD COLUMN IF NOT EXISTS icon text NOT NULL DEFAULT 'circle';
@@ -1,14 +0,0 @@
1
- -- API tokens. token_hash stores sha256 of the plaintext token; prefix is the first
2
- -- 8 chars of the plaintext (for display). Auth middleware enforcement is off by
3
- -- default for local deployments; these endpoints let the UI grant/revoke tokens
4
- -- when public or proxy-gated access is enabled.
5
- CREATE TABLE IF NOT EXISTS tokens (
6
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
7
- name text NOT NULL,
8
- token_hash text NOT NULL UNIQUE,
9
- prefix text NOT NULL,
10
- last_used_at timestamptz,
11
- created_at timestamptz NOT NULL DEFAULT now()
12
- );
13
-
14
- CREATE INDEX IF NOT EXISTS tokens_created_idx ON tokens(created_at DESC);
@@ -1,21 +0,0 @@
1
- -- 0008: simplify entity kinds and drop the actors table.
2
- --
3
- -- Why: the original schema had 7 entity kinds (task, note, decision, doc,
4
- -- comment, log, memory) and a separate `actors` table for writer identity.
5
- -- In practice only task and note carry real semantic weight in the UI/agent
6
- -- flows; the others are folded into note with the legacy kind preserved as a
7
- -- tag so nothing is lost. Identity is now expressed by the existing
8
- -- entities.actor_kind text column (human / agent / system) — the actors
9
- -- lookup table never accumulated rows, so we drop it.
10
-
11
- -- Fold legacy kinds into 'note'. The previous kind name is appended to tags
12
- -- so we can still query e.g. tag='decision' or tag='memory' if needed.
13
- UPDATE entities
14
- SET tags = array_append(tags, kind), kind = 'note'
15
- WHERE kind IN ('decision', 'doc', 'comment', 'log', 'memory');
16
-
17
- -- Drop the FK first to avoid a dependency error, then the column, then the
18
- -- table. None of these had any live rows referencing them.
19
- ALTER TABLE entities DROP CONSTRAINT IF EXISTS entities_actor_id_fkey;
20
- ALTER TABLE entities DROP COLUMN IF EXISTS actor_id;
21
- DROP TABLE IF EXISTS actors;
@@ -1,14 +0,0 @@
1
- -- Browser session cookies. Each row corresponds to one logged-in browser;
2
- -- plaintext is the cookie value (random 32 bytes hex), DB stores sha256.
3
-
4
- CREATE TABLE IF NOT EXISTS sessions (
5
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
6
- token_hash text NOT NULL,
7
- expires_at timestamptz NOT NULL,
8
- user_agent text,
9
- last_used_at timestamptz,
10
- created_at timestamptz NOT NULL DEFAULT now()
11
- );
12
-
13
- CREATE UNIQUE INDEX IF NOT EXISTS sessions_token_hash_idx ON sessions(token_hash);
14
- CREATE INDEX IF NOT EXISTS sessions_expires_at_idx ON sessions(expires_at);
@@ -1,17 +0,0 @@
1
- -- Add completed_at column to entities. Set automatically on a status
2
- -- transition into 'done' (and cleared when leaving). Backfill existing done
3
- -- rows from updated_at as the best available approximation. Legacy-imported
4
- -- tasks may have lost their original timestamp, so this clusters them on the
5
- -- migration day rather than guessing. New transitions are exact.
6
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS completed_at timestamptz;
7
-
8
- UPDATE entities
9
- SET completed_at = updated_at
10
- WHERE kind = 'task' AND status = 'done' AND completed_at IS NULL;
11
-
12
- -- Partial index — only done rows have a non-null completed_at, so this stays
13
- -- small and keeps range scans cheap when the calendar queries by completed
14
- -- date.
15
- CREATE INDEX IF NOT EXISTS entities_completed_at_idx
16
- ON entities (completed_at)
17
- WHERE completed_at IS NOT NULL;
@@ -1,14 +0,0 @@
1
- -- Fix the 0010 backfill. The first pass used updated_at, which for imported
2
- -- tasks can be the migration day, so every legacy done task piled onto the
3
- -- same calendar cell. Re-backfill with COALESCE(due_at, updated_at) so legacy
4
- -- done items render on their original due date (the pre-change behavior),
5
- -- while freshly-completed tasks still get an exact stamp from the service
6
- -- layer at status-transition time.
7
- UPDATE entities
8
- SET completed_at = COALESCE(due_at, updated_at)
9
- WHERE kind = 'task'
10
- AND status = 'done'
11
- -- Only rows whose completed_at matches the 0010 backfill exactly (i.e.
12
- -- never updated since). Real recent completions have completed_at != updated_at
13
- -- once anything else touches the row, so this avoids stomping on real data.
14
- AND completed_at = updated_at;
@@ -1,16 +0,0 @@
1
- -- 0011's WHERE clause assumed completed_at = updated_at after 0010, but the
2
- -- BEFORE-UPDATE trigger bumps updated_at on every UPDATE, so 0010 set
3
- -- completed_at to OLD.updated_at and the trigger then advanced updated_at past
4
- -- it. As a result 0011 matched nothing.
5
- --
6
- -- This pass forces COALESCE(due_at, updated_at) onto every done task whose
7
- -- completed_at still falls before the 0010 backfill window — i.e. data the
8
- -- service layer has not freshly written. Anything completed by the running
9
- -- daemon after 0010 ran will have a strictly later completed_at and is left
10
- -- alone.
11
- UPDATE entities
12
- SET completed_at = COALESCE(due_at, updated_at)
13
- WHERE kind = 'task'
14
- AND status = 'done'
15
- AND completed_at IS NOT NULL
16
- AND completed_at < '2026-06-03 23:56:00+00';
@@ -1,13 +0,0 @@
1
- -- Date-only due dates may be imported as `YYYY-MM-DD T00:00:00Z`,
2
- -- which lands the previous calendar day in any UTC-negative timezone
3
- -- (e.g. UTC midnight = 5pm Pacific the day before). Bump every midnight-UTC
4
- -- due_at to noon-UTC so it stays on the intended calendar day in every
5
- -- timezone (UTC-12 .. UTC+11). The service layer applies the same
6
- -- normalization to new writes so this stays clean going forward.
7
- UPDATE entities
8
- SET due_at = date_trunc('day', due_at AT TIME ZONE 'UTC') + INTERVAL '12 hours'
9
- WHERE kind = 'task'
10
- AND due_at IS NOT NULL
11
- AND EXTRACT(HOUR FROM due_at AT TIME ZONE 'UTC') = 0
12
- AND EXTRACT(MINUTE FROM due_at AT TIME ZONE 'UTC') = 0
13
- AND EXTRACT(SECOND FROM due_at AT TIME ZONE 'UTC') = 0;
@@ -1,3 +0,0 @@
1
- -- Store newly generated API tokens so Settings can copy them after creation.
2
- -- Existing tokens remain NULL because only their sha256 hashes were stored.
3
- ALTER TABLE tokens ADD COLUMN IF NOT EXISTS plaintext text;
@@ -1,18 +0,0 @@
1
- -- Collapse retired task statuses into done.
2
- --
3
- -- delayed and archived were both ambiguous terminal-ish states. The product
4
- -- now has four task states: open, in_progress, done, rejected. Preserve the
5
- -- best available terminal timestamp by using the previous updated_at value as
6
- -- completed_at before the touch trigger advances updated_at.
7
- UPDATE entities
8
- SET
9
- status = 'done',
10
- completed_at = COALESCE(completed_at, updated_at, now())
11
- WHERE kind = 'task'
12
- AND status IN ('delayed', 'archived');
13
-
14
- DROP INDEX IF EXISTS entities_task_no_due_idx;
15
-
16
- CREATE INDEX IF NOT EXISTS entities_task_no_due_idx
17
- ON entities(created_at DESC)
18
- WHERE kind = 'task' AND due_at IS NULL AND status <> 'done';
@@ -1,23 +0,0 @@
1
- -- botnote 0016 embedding settings
2
- -- Idempotent: safe to re-run.
3
-
4
- CREATE TABLE IF NOT EXISTS embedding_settings (
5
- id text PRIMARY KEY DEFAULT 'default' CHECK (id = 'default'),
6
- enabled boolean NOT NULL DEFAULT true,
7
- provider text NOT NULL DEFAULT 'openai',
8
- model text NOT NULL DEFAULT 'text-embedding-3-small',
9
- base_url text,
10
- api_key text,
11
- dimensions integer NOT NULL DEFAULT 384,
12
- created_at timestamptz NOT NULL DEFAULT now(),
13
- updated_at timestamptz NOT NULL DEFAULT now()
14
- );
15
-
16
- INSERT INTO embedding_settings (id)
17
- VALUES ('default')
18
- ON CONFLICT (id) DO NOTHING;
19
-
20
- DROP TRIGGER IF EXISTS embedding_settings_touch_updated_at ON embedding_settings;
21
- CREATE TRIGGER embedding_settings_touch_updated_at
22
- BEFORE UPDATE ON embedding_settings
23
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
@@ -1,55 +0,0 @@
1
- -- botnote 0017 — recurring task rules.
2
- -- Idempotent: safe to re-run.
3
-
4
- CREATE TABLE IF NOT EXISTS recurrence_rules (
5
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
6
- series_id uuid NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
7
- current_occurrence_id uuid REFERENCES entities(id) ON DELETE SET NULL,
8
- enabled boolean NOT NULL DEFAULT true,
9
- rrule text NOT NULL,
10
- dtstart timestamptz NOT NULL,
11
- timezone text NOT NULL DEFAULT 'UTC',
12
- all_day boolean NOT NULL DEFAULT true,
13
- anchor text NOT NULL DEFAULT 'scheduled',
14
- max_instances_ahead integer NOT NULL DEFAULT 1,
15
- generated_count integer NOT NULL DEFAULT 1,
16
- last_occurrence_at timestamptz,
17
- next_occurrence_at timestamptz,
18
- ended_at timestamptz,
19
- created_at timestamptz NOT NULL DEFAULT now(),
20
- updated_at timestamptz NOT NULL DEFAULT now()
21
- );
22
-
23
- CREATE UNIQUE INDEX IF NOT EXISTS recurrence_rules_series_idx
24
- ON recurrence_rules(series_id);
25
-
26
- CREATE INDEX IF NOT EXISTS recurrence_rules_current_occurrence_idx
27
- ON recurrence_rules(current_occurrence_id);
28
-
29
- CREATE INDEX IF NOT EXISTS recurrence_rules_next_occurrence_idx
30
- ON recurrence_rules(next_occurrence_at)
31
- WHERE enabled = true;
32
-
33
- CREATE INDEX IF NOT EXISTS recurrence_rules_enabled_idx
34
- ON recurrence_rules(enabled, next_occurrence_at);
35
-
36
- DROP TRIGGER IF EXISTS recurrence_rules_touch_updated_at ON recurrence_rules;
37
- CREATE TRIGGER recurrence_rules_touch_updated_at
38
- BEFORE UPDATE ON recurrence_rules
39
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
40
-
41
- CREATE TABLE IF NOT EXISTS recurrence_exceptions (
42
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
43
- rule_id uuid NOT NULL REFERENCES recurrence_rules(id) ON DELETE CASCADE,
44
- occurrence_at timestamptz NOT NULL,
45
- action text NOT NULL,
46
- entity_id uuid REFERENCES entities(id) ON DELETE SET NULL,
47
- metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
48
- created_at timestamptz NOT NULL DEFAULT now()
49
- );
50
-
51
- CREATE INDEX IF NOT EXISTS recurrence_exceptions_rule_occurrence_idx
52
- ON recurrence_exceptions(rule_id, occurrence_at);
53
-
54
- CREATE INDEX IF NOT EXISTS recurrence_exceptions_entity_idx
55
- ON recurrence_exceptions(entity_id);
@@ -1,8 +0,0 @@
1
- -- botnote 0018 — project archival state.
2
- -- Idempotent: safe to re-run.
3
-
4
- ALTER TABLE projects ADD COLUMN IF NOT EXISTS archived_at timestamptz;
5
-
6
- CREATE INDEX IF NOT EXISTS projects_active_key_idx
7
- ON projects(key)
8
- WHERE archived_at IS NULL;
@@ -1,20 +0,0 @@
1
- -- botnote 0019 — project lifecycle status.
2
- -- Idempotent: safe to re-run.
3
-
4
- ALTER TABLE projects ADD COLUMN IF NOT EXISTS status text NOT NULL DEFAULT 'active';
5
-
6
- UPDATE projects
7
- SET status = 'active'
8
- WHERE status IS NULL;
9
-
10
- DO $$
11
- BEGIN
12
- ALTER TABLE projects ADD CONSTRAINT projects_status_check
13
- CHECK (status IN ('planned', 'active', 'watching', 'paused', 'archived'));
14
- EXCEPTION
15
- WHEN duplicate_object THEN NULL;
16
- END $$;
17
-
18
- CREATE INDEX IF NOT EXISTS projects_active_status_idx
19
- ON projects(status, key)
20
- WHERE status <> 'archived';
@@ -1,20 +0,0 @@
1
- -- botnote 0020 — make archive a project status.
2
- -- Idempotent: safe to re-run.
3
-
4
- ALTER TABLE projects DROP CONSTRAINT IF EXISTS projects_status_check;
5
-
6
- ALTER TABLE projects ADD CONSTRAINT projects_status_check
7
- CHECK (status IN ('planned', 'active', 'watching', 'paused', 'archived'));
8
-
9
- UPDATE projects
10
- SET status = 'archived'
11
- WHERE archived_at IS NOT NULL
12
- AND status <> 'archived';
13
-
14
- UPDATE projects
15
- SET archived_at = now()
16
- WHERE status = 'archived'
17
- AND archived_at IS NULL;
18
-
19
- CREATE INDEX IF NOT EXISTS projects_status_key_idx
20
- ON projects(status, key);
@@ -1,18 +0,0 @@
1
- -- botnote 0021 workspace settings
2
- -- Idempotent: safe to re-run.
3
-
4
- CREATE TABLE IF NOT EXISTS workspace_settings (
5
- id text PRIMARY KEY DEFAULT 'default' CHECK (id = 'default'),
6
- timezone text NOT NULL DEFAULT 'UTC',
7
- created_at timestamptz NOT NULL DEFAULT now(),
8
- updated_at timestamptz NOT NULL DEFAULT now()
9
- );
10
-
11
- INSERT INTO workspace_settings (id)
12
- VALUES ('default')
13
- ON CONFLICT (id) DO NOTHING;
14
-
15
- DROP TRIGGER IF EXISTS workspace_settings_touch_updated_at ON workspace_settings;
16
- CREATE TRIGGER workspace_settings_touch_updated_at
17
- BEFORE UPDATE ON workspace_settings
18
- FOR EACH ROW EXECUTE FUNCTION botnote_touch_updated_at();
@@ -1,13 +0,0 @@
1
- -- botnote 0022 — allow splitting a recurrence series.
2
- -- A split keeps the old rule as frozen history (enabled = false, bounded by
3
- -- UNTIL) and creates a new enabled rule that shares the SAME series_id so the
4
- -- UI still groups history + future as one continuous series. That requires more
5
- -- than one rule per series, so the unique constraint is relaxed to a PARTIAL
6
- -- unique index: at most one ENABLED rule per series, unlimited disabled history.
7
- -- Idempotent: safe to re-run.
8
-
9
- DROP INDEX IF EXISTS recurrence_rules_series_idx;
10
-
11
- CREATE UNIQUE INDEX IF NOT EXISTS recurrence_rules_series_idx
12
- ON recurrence_rules(series_id)
13
- WHERE enabled = true;
@@ -1,24 +0,0 @@
1
- -- botnote 0023 — reintroduce the 'comment' entity kind as an append-only
2
- -- worklog attached to a task (parent_id). Unlike the pre-0008 comment kind,
3
- -- these have a concrete product role: agent/human progress notes that the
4
- -- opening brief surfaces for in_progress tasks.
5
- -- Idempotent.
6
-
7
- -- Comments carry project_id (so project-scoped search/recent include them)
8
- -- but must NOT consume a per-project sequence number — KEY-SEQ identifiers
9
- -- are for addressable work items (tasks/notes), not log lines.
10
- CREATE OR REPLACE FUNCTION botnote_set_sequence_id() RETURNS trigger AS $$
11
- BEGIN
12
- IF NEW.sequence_id IS NULL AND NEW.project_id IS NOT NULL AND NEW.kind <> 'comment' THEN
13
- SELECT COALESCE(MAX(sequence_id), 0) + 1
14
- INTO NEW.sequence_id
15
- FROM entities
16
- WHERE project_id = NEW.project_id;
17
- END IF;
18
- RETURN NEW;
19
- END;
20
- $$ LANGUAGE plpgsql;
21
-
22
- -- Fast "latest comment per task" lookups for the opening brief.
23
- CREATE INDEX IF NOT EXISTS entities_comment_parent_created_idx
24
- ON entities(parent_id, created_at DESC) WHERE kind = 'comment';
@@ -1,12 +0,0 @@
1
- -- Memory upgrade: access tracking + supersedes edges.
2
- --
3
- -- last_accessed_at / access_count are bumped on explicit entity reads
4
- -- (GET /v1/entities/:id and by-key lookups) and feed a light boost into
5
- -- hybrid search so frequently-recalled memories rank slightly higher.
6
- --
7
- -- The 'supersedes' edge kind (new note -> outdated note) needs no schema
8
- -- change (edges.kind is text); search downweights entities that are the
9
- -- target of a supersedes edge.
10
-
11
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS last_accessed_at timestamptz;
12
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS access_count integer NOT NULL DEFAULT 0;
@@ -1,12 +0,0 @@
1
- -- Soft delete / trash bin. deleted_at marks an entity as trashed: hidden from
2
- -- every read path (search, recent, tasks-range, briefs, comments, feedback)
3
- -- but restorable until the retention purge hard-deletes it. Projects are not
4
- -- part of the trash — they keep their own archive lifecycle.
5
-
6
- ALTER TABLE entities ADD COLUMN IF NOT EXISTS deleted_at timestamptz;
7
-
8
- -- Partial index: the trash view and the retention purge only ever scan
9
- -- trashed rows, which stay a tiny fraction of the table.
10
- CREATE INDEX IF NOT EXISTS entities_deleted_at_idx
11
- ON entities (deleted_at)
12
- WHERE deleted_at IS NOT NULL;