@myrialabs/clopen 0.4.39 → 0.4.41

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 (173) hide show
  1. package/.env.example +1 -1
  2. package/backend/artifacts/detect.ts +15 -3
  3. package/backend/artifacts/generate.ts +2 -2
  4. package/backend/artifacts/index.ts +12 -4
  5. package/backend/artifacts/markers.ts +24 -1
  6. package/backend/artifacts/matrix.ts +47 -3
  7. package/backend/artifacts/sync.test.ts +3 -3
  8. package/backend/artifacts/sync.ts +8 -20
  9. package/backend/artifacts/types.ts +9 -3
  10. package/backend/auth/permissions.ts +29 -11
  11. package/backend/auth/session-cleanup.ts +10 -1
  12. package/backend/auth/tokens.ts +9 -1
  13. package/backend/chat/stream-manager.ts +42 -0
  14. package/backend/database/crypto/secret-columns.ts +5 -1
  15. package/backend/database/migrations/078_create_worktree_branch_tables.ts +158 -0
  16. package/backend/database/migrations/079_merge_commands_into_skills.ts +222 -0
  17. package/backend/database/migrations/080_create_file_shares.ts +111 -0
  18. package/backend/database/migrations/081_create_push_subscriptions.ts +32 -0
  19. package/backend/database/migrations/index.ts +28 -0
  20. package/backend/database/queries/file-share-queries.ts +163 -0
  21. package/backend/database/queries/index.ts +12 -4
  22. package/backend/database/queries/profile-queries.ts +5 -3
  23. package/backend/database/queries/push-subscription-queries.test.ts +90 -0
  24. package/backend/database/queries/push-subscription-queries.ts +99 -0
  25. package/backend/database/queries/skill-queries.ts +96 -18
  26. package/backend/database/queries/worktree-branch-queries.ts +331 -0
  27. package/backend/db-client/cloning.test.ts +161 -0
  28. package/backend/db-client/cloning.ts +672 -0
  29. package/backend/db-client/connection-url.test.ts +117 -0
  30. package/backend/db-client/connection-url.ts +126 -0
  31. package/backend/db-client/drivers/mongodb.ts +2 -14
  32. package/backend/db-client/drivers/mysql.ts +2 -8
  33. package/backend/db-client/drivers/postgres.ts +10 -13
  34. package/backend/db-client/drivers/redis.ts +2 -6
  35. package/backend/db-client/env/detect.ts +438 -0
  36. package/backend/db-client/env/diff.ts +94 -0
  37. package/backend/db-client/env/env.test.ts +574 -0
  38. package/backend/db-client/env/index.ts +15 -0
  39. package/backend/db-client/env/naming.ts +202 -0
  40. package/backend/db-client/env/service.ts +487 -0
  41. package/backend/db-client/integrations/index.ts +7 -0
  42. package/backend/db-client/integrations/links.ts +41 -10
  43. package/backend/db-client/providers/neon/adapter.ts +522 -0
  44. package/backend/db-client/providers/neon/api-types.ts +182 -0
  45. package/backend/db-client/providers/neon/client.ts +298 -0
  46. package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
  47. package/backend/db-client/providers/neon/endpoints.ts +314 -0
  48. package/backend/db-client/providers/neon/list.test.ts +181 -0
  49. package/backend/db-client/providers/supabase/adapter.ts +25 -2
  50. package/backend/db-client/providers/types.ts +57 -0
  51. package/backend/engine/adapters/claude/stream.ts +2 -1
  52. package/backend/engine/adapters/cline/stream.ts +3 -3
  53. package/backend/engine/adapters/codex/stream.ts +3 -3
  54. package/backend/engine/adapters/copilot/stream.ts +3 -3
  55. package/backend/engine/adapters/cursor/stream.ts +25 -3
  56. package/backend/engine/adapters/opencode/stream.ts +4 -6
  57. package/backend/engine/adapters/pi/stream.ts +2 -2
  58. package/backend/engine/adapters/qwen/stream.ts +2 -2
  59. package/backend/engine/artifact-sync.ts +26 -20
  60. package/backend/engine/docs/artifacts.md +81 -22
  61. package/backend/engine/docs/quick-reference.md +2 -1
  62. package/backend/engine/resolve-model.test.ts +108 -0
  63. package/backend/engine/resolve-model.ts +53 -10
  64. package/backend/engine/structured-helpers.ts +22 -0
  65. package/backend/env-files/discovery.ts +48 -0
  66. package/backend/env-files/edit.ts +213 -0
  67. package/backend/env-files/env-files.test.ts +515 -0
  68. package/backend/env-files/git.ts +27 -0
  69. package/backend/env-files/index.ts +44 -0
  70. package/backend/env-files/keys.ts +69 -0
  71. package/backend/env-files/parse.ts +157 -0
  72. package/backend/env-files/write.ts +229 -0
  73. package/backend/files/file-shares.ts +369 -0
  74. package/backend/files/path-browsing.ts +27 -21
  75. package/backend/http/files-shared.test.ts +505 -0
  76. package/backend/http/files-shared.ts +351 -0
  77. package/backend/http/push.ts +150 -0
  78. package/backend/index.ts +8 -0
  79. package/backend/instructions/index.ts +1 -1
  80. package/backend/instructions/sync.ts +30 -6
  81. package/backend/integrations/health.ts +18 -4
  82. package/backend/integrations/projections/types.ts +9 -2
  83. package/backend/integrations/registry/index.ts +3 -0
  84. package/backend/integrations/registry/providers/context7.ts +1 -0
  85. package/backend/integrations/registry/providers/firecrawl.ts +1 -0
  86. package/backend/integrations/registry/providers/github.ts +1 -0
  87. package/backend/integrations/registry/providers/neon.ts +55 -0
  88. package/backend/integrations/registry/providers/supabase.ts +1 -0
  89. package/backend/integrations/registry/providers/vercel.ts +1 -0
  90. package/backend/integrations/registry/types.ts +2 -0
  91. package/backend/memory/compose.ts +2 -2
  92. package/backend/memory/consolidate.ts +2 -2
  93. package/backend/memory/extract/episodic.ts +2 -2
  94. package/backend/memory/judge.ts +2 -2
  95. package/backend/profiles/service.ts +7 -6
  96. package/backend/push/sender.ts +172 -0
  97. package/backend/push/tags.ts +25 -0
  98. package/backend/push/vapid-keys.ts +77 -0
  99. package/backend/push/webpush-crypto.test.ts +200 -0
  100. package/backend/push/webpush-crypto.ts +231 -0
  101. package/backend/skills/detect.ts +28 -0
  102. package/backend/skills/index.ts +22 -4
  103. package/backend/skills/invoke.test.ts +114 -0
  104. package/backend/skills/invoke.ts +222 -0
  105. package/backend/skills/service.ts +194 -44
  106. package/backend/skills/spec.ts +35 -0
  107. package/backend/skills/sync.ts +85 -55
  108. package/backend/subagents/detect.ts +2 -3
  109. package/backend/subagents/sync.ts +15 -8
  110. package/backend/work/pull-requests.ts +2 -2
  111. package/backend/work/start-work.ts +4 -0
  112. package/backend/worktrees/branching/engine.ts +557 -0
  113. package/backend/worktrees/branching/index.ts +56 -0
  114. package/backend/worktrees/branching/naming.test.ts +118 -0
  115. package/backend/worktrees/branching/naming.ts +97 -0
  116. package/backend/worktrees/branching/projector.test.ts +229 -0
  117. package/backend/worktrees/branching/projector.ts +139 -0
  118. package/backend/worktrees/branching/providers/neon.ts +220 -0
  119. package/backend/worktrees/branching/registry.ts +27 -0
  120. package/backend/worktrees/branching/service.ts +620 -0
  121. package/backend/worktrees/branching/suggest.test.ts +154 -0
  122. package/backend/worktrees/branching/suggest.ts +202 -0
  123. package/backend/worktrees/branching/types.ts +88 -0
  124. package/backend/worktrees/index.ts +7 -0
  125. package/backend/worktrees/service.ts +48 -1
  126. package/backend/ws/chat/stream.ts +100 -8
  127. package/backend/ws/db-client/env.ts +142 -0
  128. package/backend/ws/db-client/index.ts +2 -0
  129. package/backend/ws/files/index.ts +4 -0
  130. package/backend/ws/files/share.ts +95 -0
  131. package/backend/ws/git/branch-name.ts +2 -2
  132. package/backend/ws/git/commit-message.ts +2 -2
  133. package/backend/ws/index.ts +3 -4
  134. package/backend/ws/profiles/crud.ts +2 -3
  135. package/backend/ws/projects/index.ts +6 -1
  136. package/backend/ws/projects/info.ts +70 -6
  137. package/backend/ws/projects/overview.test.ts +108 -0
  138. package/backend/ws/projects/overview.ts +300 -0
  139. package/backend/ws/skills/catalog.ts +5 -1
  140. package/backend/ws/skills/crud.ts +128 -22
  141. package/backend/ws/skills/index.ts +4 -1
  142. package/backend/ws/system/device-info.ts +307 -76
  143. package/backend/ws/user/crud.ts +12 -3
  144. package/backend/ws/worktrees/branching.ts +212 -0
  145. package/backend/ws/worktrees/crud.ts +33 -7
  146. package/backend/ws/worktrees/index.ts +14 -0
  147. package/dist/assets/{index-C8Gi-b6U.js → index-CeNKKSDR.js} +1 -1
  148. package/dist/assets/{index-BrF6nqld.js → index-DW89566K.js} +1 -1
  149. package/dist/assets/main-Cy5DXWPT.js +1207 -0
  150. package/dist/assets/main-DJKj_4By.css +1 -0
  151. package/dist/index.html +7 -2
  152. package/dist/sw.js +112 -0
  153. package/package.json +1 -1
  154. package/shared/constants/engine-tools.ts +31 -6
  155. package/shared/constants/notification-messages.ts +142 -0
  156. package/shared/constants/tool-icons.ts +6 -2
  157. package/shared/types/db-client/env.ts +192 -0
  158. package/shared/types/db-client/index.ts +1 -0
  159. package/shared/types/db-client/integrations.ts +30 -0
  160. package/shared/types/integrations.ts +9 -0
  161. package/shared/types/unified/stream.ts +7 -0
  162. package/shared/types/worktree-branching.ts +315 -0
  163. package/shared/utils/logger.ts +1 -0
  164. package/backend/commands/detect.ts +0 -25
  165. package/backend/commands/index.ts +0 -9
  166. package/backend/commands/service.ts +0 -178
  167. package/backend/commands/store.ts +0 -45
  168. package/backend/commands/sync.ts +0 -94
  169. package/backend/database/queries/command-queries.ts +0 -82
  170. package/backend/ws/commands/crud.ts +0 -157
  171. package/backend/ws/commands/index.ts +0 -8
  172. package/dist/assets/main-Bd3gb79F.css +0 -1
  173. package/dist/assets/main-Bo1hD7mt.js +0 -1191
@@ -1,82 +0,0 @@
1
- /**
2
- * Command Queries
3
- *
4
- * CRUD for user-managed custom slash Commands (Settings → Commands). Like
5
- * Skills, the `commands` table holds only METADATA + the enable toggle; the
6
- * command's Markdown document lives on disk in the canonical store under
7
- * `{clopenDir}/commands/<slug>.md` (see `backend/commands/store.ts`).
8
- */
9
-
10
- import { getDatabase } from '../index';
11
-
12
- export type CommandSource = 'custom' | 'imported';
13
-
14
- export interface CommandRow {
15
- id: number;
16
- slug: string;
17
- name: string;
18
- description: string;
19
- argument_hint: string | null;
20
- /** JSON map of EngineType → model id ({} = inherit everywhere). */
21
- model_by_engine: string;
22
- source: CommandSource;
23
- is_enabled: number;
24
- created_at: string;
25
- }
26
-
27
- export interface CommandInput {
28
- slug: string;
29
- name: string;
30
- description: string;
31
- argumentHint?: string | null;
32
- /** JSON string: EngineType → model id. */
33
- modelByEngine?: string;
34
- source?: CommandSource;
35
- }
36
-
37
- export const commandQueries = {
38
- getAll(): CommandRow[] {
39
- return getDatabase().prepare(`SELECT * FROM commands ORDER BY created_at ASC`).all() as CommandRow[];
40
- },
41
-
42
- getEnabled(): CommandRow[] {
43
- return getDatabase().prepare(`SELECT * FROM commands WHERE is_enabled = 1 ORDER BY created_at ASC`).all() as CommandRow[];
44
- },
45
-
46
- getById(id: number): CommandRow | null {
47
- return getDatabase().prepare(`SELECT * FROM commands WHERE id = ?`).get(id) as CommandRow | null;
48
- },
49
-
50
- getBySlug(slug: string): CommandRow | null {
51
- return getDatabase().prepare(`SELECT * FROM commands WHERE slug = ?`).get(slug) as CommandRow | null;
52
- },
53
-
54
- insert(input: CommandInput): CommandRow {
55
- const result = getDatabase().prepare(
56
- `INSERT INTO commands (slug, name, description, argument_hint, model_by_engine, source)
57
- VALUES (?, ?, ?, ?, ?, ?)`
58
- ).run(
59
- input.slug,
60
- input.name,
61
- input.description,
62
- input.argumentHint ?? null,
63
- input.modelByEngine ?? '{}',
64
- input.source ?? 'custom'
65
- ) as { lastInsertRowid: number | bigint };
66
- return this.getById(Number(result.lastInsertRowid))!;
67
- },
68
-
69
- updateMeta(id: number, name: string, description: string, argumentHint: string | null, modelByEngine: string): void {
70
- getDatabase().prepare(
71
- `UPDATE commands SET name = ?, description = ?, argument_hint = ?, model_by_engine = ? WHERE id = ?`
72
- ).run(name, description, argumentHint, modelByEngine, id);
73
- },
74
-
75
- setEnabled(id: number, enabled: boolean): void {
76
- getDatabase().prepare(`UPDATE commands SET is_enabled = ? WHERE id = ?`).run(enabled ? 1 : 0, id);
77
- },
78
-
79
- remove(id: number): void {
80
- getDatabase().prepare(`DELETE FROM commands WHERE id = ?`).run(id);
81
- }
82
- };
@@ -1,157 +0,0 @@
1
- /**
2
- * Command CRUD Handlers (Settings → Commands)
3
- *
4
- * - commands:list / get / create / update / parse-import / import / toggle / delete
5
- * - commands:detect — on-disk commands (managed + adoptable) per engine
6
- *
7
- * Mutations are admin-gated. Changes take effect on the next chat stream, when
8
- * each engine re-syncs its commands.
9
- */
10
-
11
- import { t } from 'elysia';
12
- import { createRouter } from '$shared/utils/ws-server';
13
- import { debug } from '$shared/utils/logger';
14
- import { commandService, detectCommands, syncCommandsAllEngines } from '$backend/commands';
15
- import { resolveActiveProfileId, artifactFilter } from '$backend/profiles';
16
-
17
- /** EngineType → value map (model id / tool list). {} = inherit / all. */
18
- const ENGINE_MAP_SCHEMA = t.Record(t.String(), t.String());
19
-
20
- const COMMAND_SCHEMA = t.Object({
21
- id: t.Number(),
22
- slug: t.String(),
23
- name: t.String(),
24
- description: t.String(),
25
- argumentHint: t.Union([t.String(), t.Null()]),
26
- modelByEngine: ENGINE_MAP_SCHEMA,
27
- source: t.Union([t.Literal('custom'), t.Literal('imported')]),
28
- enabled: t.Boolean(),
29
- present: t.Boolean(),
30
- createdAt: t.String()
31
- });
32
-
33
- const FIELDS_SCHEMA = {
34
- name: t.String(),
35
- description: t.String(),
36
- argumentHint: t.Optional(t.Union([t.String(), t.Null()])),
37
- modelByEngine: t.Optional(ENGINE_MAP_SCHEMA),
38
- body: t.String()
39
- };
40
-
41
- const DETECTED_SCHEMA = t.Object({
42
- engine: t.String(),
43
- detected: t.Array(t.Object({
44
- slug: t.String(),
45
- name: t.String(),
46
- description: t.String(),
47
- path: t.String(),
48
- managed: t.Boolean(),
49
- adoptable: t.Boolean()
50
- }))
51
- });
52
-
53
- export const commandCrudHandler = createRouter()
54
- .http('commands:list', {
55
- data: t.Object({}),
56
- response: t.Object({ commands: t.Array(COMMAND_SCHEMA) })
57
- }, async () => {
58
- debug.log('path', 'commands:list');
59
- return { commands: await commandService.list() };
60
- })
61
- .http('commands:get', {
62
- data: t.Object({ id: t.Number() }),
63
- response: t.Object({ command: COMMAND_SCHEMA, body: t.String() })
64
- }, async ({ data }) => {
65
- debug.log('path', `commands:get ${data.id}`);
66
- const result = await commandService.get(data.id);
67
- if (!result) throw new Error('Command not found');
68
- return result;
69
- })
70
- .http('commands:create', {
71
- data: t.Object(FIELDS_SCHEMA),
72
- response: t.Object({ command: COMMAND_SCHEMA })
73
- }, async ({ data }) => {
74
- debug.log('path', `commands:create ${data.name}`);
75
- if (!data.name.trim()) throw new Error('A command name is required');
76
- const command = await commandService.create(data);
77
- await syncCommandsAllEngines();
78
- return { command };
79
- })
80
- .http('commands:update', {
81
- data: t.Object({ id: t.Number(), ...FIELDS_SCHEMA }),
82
- response: t.Object({ command: COMMAND_SCHEMA })
83
- }, async ({ data }) => {
84
- debug.log('path', `commands:update ${data.id}`);
85
- if (!data.name.trim()) throw new Error('A command name is required');
86
- const command = await commandService.update(data.id, data);
87
- await syncCommandsAllEngines();
88
- return { command };
89
- })
90
- .http('commands:parse-import', {
91
- data: t.Object({ text: t.String() }),
92
- response: t.Object({
93
- name: t.String(),
94
- description: t.String(),
95
- argumentHint: t.Union([t.String(), t.Null()]),
96
- modelByEngine: ENGINE_MAP_SCHEMA,
97
- body: t.String()
98
- })
99
- }, async ({ data }) => {
100
- debug.log('path', 'commands:parse-import');
101
- return commandService.parsePreview(data.text);
102
- })
103
- .http('commands:import', {
104
- data: t.Object({ text: t.String(), name: t.Optional(t.String()) }),
105
- response: t.Object({ command: COMMAND_SCHEMA })
106
- }, async ({ data }) => {
107
- debug.log('path', 'commands:import');
108
- const command = await commandService.import(data.text, data.name);
109
- await syncCommandsAllEngines();
110
- return { command };
111
- })
112
- .http('commands:toggle', {
113
- data: t.Object({ id: t.Number(), enabled: t.Boolean() }),
114
- response: t.Object({ command: COMMAND_SCHEMA })
115
- }, async ({ data }) => {
116
- debug.log('path', `commands:toggle ${data.id} → ${data.enabled}`);
117
- const command = commandService.toggle(data.id, data.enabled);
118
- await syncCommandsAllEngines();
119
- return { command };
120
- })
121
- .http('commands:delete', {
122
- data: t.Object({ id: t.Number() }),
123
- response: t.Object({ success: t.Boolean() })
124
- }, async ({ data }) => {
125
- debug.log('path', `commands:delete ${data.id}`);
126
- await commandService.remove(data.id);
127
- await syncCommandsAllEngines();
128
- return { success: true };
129
- })
130
- .http('commands:available', {
131
- // Non-admin: commands for the chat "/" picker (display fields only),
132
- // narrowed by the session's active profile (if any) same as stream sync.
133
- data: t.Object({
134
- profileId: t.Optional(t.Union([t.Number(), t.Null()])),
135
- projectId: t.Optional(t.String())
136
- }),
137
- response: t.Object({
138
- commands: t.Array(t.Object({
139
- slug: t.String(),
140
- name: t.String(),
141
- description: t.String(),
142
- argumentHint: t.Union([t.String(), t.Null()])
143
- }))
144
- })
145
- }, async ({ data }) => {
146
- debug.log('path', 'commands:available');
147
- const activeProfileId = resolveActiveProfileId(data.profileId ?? null, data.projectId);
148
- const filter = artifactFilter(activeProfileId, 'command');
149
- return { commands: commandService.available(filter) };
150
- })
151
- .http('commands:detect', {
152
- data: t.Object({ projectPath: t.Optional(t.String()) }),
153
- response: t.Object({ groups: t.Array(DETECTED_SCHEMA) })
154
- }, async ({ data }) => {
155
- debug.log('path', 'commands:detect');
156
- return { groups: await detectCommands(data.projectPath) };
157
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Commands Router — Settings → Commands CRUD + on-disk detection.
3
- */
4
-
5
- import { createRouter } from '$shared/utils/ws-server';
6
- import { commandCrudHandler } from './crud';
7
-
8
- export const commandsRouter = createRouter().merge(commandCrudHandler);