@crewx/sdk 0.9.0-rc.73 → 0.9.0-rc.74
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/dist/esm/index.js +153 -97
- package/dist/esm/plugins/index.js +53 -53
- package/dist/esm/repository/index.js +48 -48
- package/dist/index.d.ts +7 -0
- package/dist/index.js +154 -98
- package/dist/migrations/0018_bored_jackal.sql +33 -0
- package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
- package/dist/migrations/meta/0018_snapshot.json +2570 -0
- package/dist/migrations/meta/_journal.json +14 -0
- package/dist/plugins/index.js +53 -53
- package/dist/repository/common-code.repository.d.ts +39 -0
- package/dist/repository/index.d.ts +8 -2
- package/dist/repository/index.js +48 -48
- package/dist/repository/task.repository.d.ts +5 -0
- package/dist/repository/thread-title-common-code-migration.d.ts +13 -0
- package/dist/repository/thread.repository.d.ts +16 -0
- package/dist/schema/common-codes.d.ts +216 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/threads.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS `common_codes` (
|
|
2
|
+
`code_group` text NOT NULL,
|
|
3
|
+
`code` text NOT NULL,
|
|
4
|
+
`code_name` text,
|
|
5
|
+
`color` text DEFAULT 'gray' NOT NULL,
|
|
6
|
+
`sort_order` integer NOT NULL,
|
|
7
|
+
`workspace_id` text,
|
|
8
|
+
`is_builtin` integer DEFAULT 0 NOT NULL,
|
|
9
|
+
`is_archived` integer DEFAULT 0 NOT NULL,
|
|
10
|
+
`metadata` text,
|
|
11
|
+
`created_at` text NOT NULL,
|
|
12
|
+
`updated_at` text NOT NULL,
|
|
13
|
+
PRIMARY KEY(`code_group`, `code`),
|
|
14
|
+
CONSTRAINT "common_codes_metadata_ck" CHECK("common_codes"."metadata" IS NULL OR (json_valid("common_codes"."metadata") AND json_type("common_codes"."metadata") = 'object')),
|
|
15
|
+
CONSTRAINT "common_codes_builtin_ck" CHECK("common_codes"."is_builtin" IN (0, 1)),
|
|
16
|
+
CONSTRAINT "common_codes_archived_ck" CHECK("common_codes"."is_archived" IN (0, 1))
|
|
17
|
+
);
|
|
18
|
+
--> statement-breakpoint
|
|
19
|
+
CREATE INDEX IF NOT EXISTS `idx_common_codes_group_archived_order` ON `common_codes` (`code_group`,`is_archived`,`sort_order`);--> statement-breakpoint
|
|
20
|
+
INSERT OR IGNORE INTO `common_codes`
|
|
21
|
+
(`code_group`, `code`, `code_name`, `color`, `sort_order`, `workspace_id`, `is_builtin`, `is_archived`, `metadata`, `created_at`, `updated_at`)
|
|
22
|
+
VALUES
|
|
23
|
+
('THREAD_PRIORITY', 'urgent', NULL, 'red', 0, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
24
|
+
('THREAD_PRIORITY', 'high', NULL, 'orange', 1, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
25
|
+
('THREAD_PRIORITY', 'medium', NULL, 'blue', 2, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
26
|
+
('THREAD_PRIORITY', 'low', NULL, 'gray', 3, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
27
|
+
('THREAD_STATE', 'investigating', NULL, 'violet', 0, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
28
|
+
('THREAD_STATE', 'in-progress', NULL, 'blue', 1, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
29
|
+
('THREAD_STATE', 'in-review', NULL, 'amber', 2, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
30
|
+
('THREAD_STATE', 'on-hold', NULL, 'gray', 3, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
31
|
+
('THREAD_STATE', 'done', NULL, 'green', 4, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now'));--> statement-breakpoint
|
|
32
|
+
CREATE INDEX IF NOT EXISTS `idx_threads_workspace_thread_state` ON `threads` (`workspace_id`, json_extract(metadata, '$.threadTitle.state'));--> statement-breakpoint
|
|
33
|
+
CREATE INDEX IF NOT EXISTS `idx_threads_workspace_thread_priority` ON `threads` (`workspace_id`, json_extract(metadata, '$.threadTitle.priority'));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
-- Backfill the indexed thread_id before command-based legacy lookups are removed.
|
|
2
|
+
-- The command format stores a thread id as the next whitespace-delimited value
|
|
3
|
+
-- after --thread=. Quoted values are normalized because some older launchers
|
|
4
|
+
-- persisted argv strings with quotes. A prompt can also contain a documented
|
|
5
|
+
-- --thread= example, so the final marker is the actual CLI option appended by
|
|
6
|
+
-- the launcher.
|
|
7
|
+
WITH RECURSIVE thread_markers(id, command, marker_pos) AS (
|
|
8
|
+
SELECT
|
|
9
|
+
id,
|
|
10
|
+
command,
|
|
11
|
+
instr(command, '--thread=') AS marker_pos
|
|
12
|
+
FROM tasks
|
|
13
|
+
WHERE thread_id IS NULL
|
|
14
|
+
AND command IS NOT NULL
|
|
15
|
+
AND instr(command, '--thread=') > 0
|
|
16
|
+
|
|
17
|
+
UNION ALL
|
|
18
|
+
|
|
19
|
+
SELECT
|
|
20
|
+
id,
|
|
21
|
+
command,
|
|
22
|
+
marker_pos
|
|
23
|
+
+ length('--thread=')
|
|
24
|
+
- 1
|
|
25
|
+
+ instr(substr(command, marker_pos + length('--thread=')), '--thread=')
|
|
26
|
+
FROM thread_markers
|
|
27
|
+
WHERE instr(substr(command, marker_pos + length('--thread=')), '--thread=') > 0
|
|
28
|
+
), last_markers AS (
|
|
29
|
+
SELECT id, command, MAX(marker_pos) AS marker_pos
|
|
30
|
+
FROM thread_markers
|
|
31
|
+
GROUP BY id, command
|
|
32
|
+
), legacy_threads AS (
|
|
33
|
+
SELECT
|
|
34
|
+
id,
|
|
35
|
+
substr(command, marker_pos + length('--thread=')) AS tail
|
|
36
|
+
FROM last_markers
|
|
37
|
+
), extracted AS (
|
|
38
|
+
SELECT
|
|
39
|
+
id,
|
|
40
|
+
trim(
|
|
41
|
+
CASE
|
|
42
|
+
WHEN instr(replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '), ' ') > 0
|
|
43
|
+
THEN substr(
|
|
44
|
+
replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '),
|
|
45
|
+
1,
|
|
46
|
+
instr(replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '), ' ') - 1
|
|
47
|
+
)
|
|
48
|
+
ELSE replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' ')
|
|
49
|
+
END
|
|
50
|
+
) AS raw_thread_id
|
|
51
|
+
FROM legacy_threads
|
|
52
|
+
), normalized AS (
|
|
53
|
+
SELECT
|
|
54
|
+
id,
|
|
55
|
+
CASE
|
|
56
|
+
WHEN substr(raw_thread_id, 1, 1) IN ('"', char(39))
|
|
57
|
+
AND substr(raw_thread_id, -1, 1) = substr(raw_thread_id, 1, 1)
|
|
58
|
+
THEN substr(raw_thread_id, 2, length(raw_thread_id) - 2)
|
|
59
|
+
ELSE raw_thread_id
|
|
60
|
+
END AS thread_id
|
|
61
|
+
FROM extracted
|
|
62
|
+
)
|
|
63
|
+
UPDATE tasks
|
|
64
|
+
SET thread_id = (
|
|
65
|
+
SELECT normalized.thread_id
|
|
66
|
+
FROM normalized
|
|
67
|
+
WHERE normalized.id = tasks.id
|
|
68
|
+
)
|
|
69
|
+
WHERE tasks.thread_id IS NULL
|
|
70
|
+
AND tasks.id IN (
|
|
71
|
+
SELECT id
|
|
72
|
+
FROM normalized
|
|
73
|
+
WHERE length(thread_id) > 0
|
|
74
|
+
);
|