@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.
- package/.env.example +1 -1
- package/backend/artifacts/detect.ts +15 -3
- package/backend/artifacts/generate.ts +2 -2
- package/backend/artifacts/index.ts +12 -4
- package/backend/artifacts/markers.ts +24 -1
- package/backend/artifacts/matrix.ts +47 -3
- package/backend/artifacts/sync.test.ts +3 -3
- package/backend/artifacts/sync.ts +8 -20
- package/backend/artifacts/types.ts +9 -3
- package/backend/auth/permissions.ts +29 -11
- package/backend/auth/session-cleanup.ts +10 -1
- package/backend/auth/tokens.ts +9 -1
- package/backend/chat/stream-manager.ts +42 -0
- package/backend/database/crypto/secret-columns.ts +5 -1
- package/backend/database/migrations/078_create_worktree_branch_tables.ts +158 -0
- package/backend/database/migrations/079_merge_commands_into_skills.ts +222 -0
- package/backend/database/migrations/080_create_file_shares.ts +111 -0
- package/backend/database/migrations/081_create_push_subscriptions.ts +32 -0
- package/backend/database/migrations/index.ts +28 -0
- package/backend/database/queries/file-share-queries.ts +163 -0
- package/backend/database/queries/index.ts +12 -4
- package/backend/database/queries/profile-queries.ts +5 -3
- package/backend/database/queries/push-subscription-queries.test.ts +90 -0
- package/backend/database/queries/push-subscription-queries.ts +99 -0
- package/backend/database/queries/skill-queries.ts +96 -18
- package/backend/database/queries/worktree-branch-queries.ts +331 -0
- package/backend/db-client/cloning.test.ts +161 -0
- package/backend/db-client/cloning.ts +672 -0
- package/backend/db-client/connection-url.test.ts +117 -0
- package/backend/db-client/connection-url.ts +126 -0
- package/backend/db-client/drivers/mongodb.ts +2 -14
- package/backend/db-client/drivers/mysql.ts +2 -8
- package/backend/db-client/drivers/postgres.ts +10 -13
- package/backend/db-client/drivers/redis.ts +2 -6
- package/backend/db-client/env/detect.ts +438 -0
- package/backend/db-client/env/diff.ts +94 -0
- package/backend/db-client/env/env.test.ts +574 -0
- package/backend/db-client/env/index.ts +15 -0
- package/backend/db-client/env/naming.ts +202 -0
- package/backend/db-client/env/service.ts +487 -0
- package/backend/db-client/integrations/index.ts +7 -0
- package/backend/db-client/integrations/links.ts +41 -10
- package/backend/db-client/providers/neon/adapter.ts +522 -0
- package/backend/db-client/providers/neon/api-types.ts +182 -0
- package/backend/db-client/providers/neon/client.ts +298 -0
- package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
- package/backend/db-client/providers/neon/endpoints.ts +314 -0
- package/backend/db-client/providers/neon/list.test.ts +181 -0
- package/backend/db-client/providers/supabase/adapter.ts +25 -2
- package/backend/db-client/providers/types.ts +57 -0
- package/backend/engine/adapters/claude/stream.ts +2 -1
- package/backend/engine/adapters/cline/stream.ts +3 -3
- package/backend/engine/adapters/codex/stream.ts +3 -3
- package/backend/engine/adapters/copilot/stream.ts +3 -3
- package/backend/engine/adapters/cursor/stream.ts +25 -3
- package/backend/engine/adapters/opencode/stream.ts +4 -6
- package/backend/engine/adapters/pi/stream.ts +2 -2
- package/backend/engine/adapters/qwen/stream.ts +2 -2
- package/backend/engine/artifact-sync.ts +26 -20
- package/backend/engine/docs/artifacts.md +81 -22
- package/backend/engine/docs/quick-reference.md +2 -1
- package/backend/engine/resolve-model.test.ts +108 -0
- package/backend/engine/resolve-model.ts +53 -10
- package/backend/engine/structured-helpers.ts +22 -0
- package/backend/env-files/discovery.ts +48 -0
- package/backend/env-files/edit.ts +213 -0
- package/backend/env-files/env-files.test.ts +515 -0
- package/backend/env-files/git.ts +27 -0
- package/backend/env-files/index.ts +44 -0
- package/backend/env-files/keys.ts +69 -0
- package/backend/env-files/parse.ts +157 -0
- package/backend/env-files/write.ts +229 -0
- package/backend/files/file-shares.ts +369 -0
- package/backend/files/path-browsing.ts +27 -21
- package/backend/http/files-shared.test.ts +505 -0
- package/backend/http/files-shared.ts +351 -0
- package/backend/http/push.ts +150 -0
- package/backend/index.ts +8 -0
- package/backend/instructions/index.ts +1 -1
- package/backend/instructions/sync.ts +30 -6
- package/backend/integrations/health.ts +18 -4
- package/backend/integrations/projections/types.ts +9 -2
- package/backend/integrations/registry/index.ts +3 -0
- package/backend/integrations/registry/providers/context7.ts +1 -0
- package/backend/integrations/registry/providers/firecrawl.ts +1 -0
- package/backend/integrations/registry/providers/github.ts +1 -0
- package/backend/integrations/registry/providers/neon.ts +55 -0
- package/backend/integrations/registry/providers/supabase.ts +1 -0
- package/backend/integrations/registry/providers/vercel.ts +1 -0
- package/backend/integrations/registry/types.ts +2 -0
- package/backend/memory/compose.ts +2 -2
- package/backend/memory/consolidate.ts +2 -2
- package/backend/memory/extract/episodic.ts +2 -2
- package/backend/memory/judge.ts +2 -2
- package/backend/profiles/service.ts +7 -6
- package/backend/push/sender.ts +172 -0
- package/backend/push/tags.ts +25 -0
- package/backend/push/vapid-keys.ts +77 -0
- package/backend/push/webpush-crypto.test.ts +200 -0
- package/backend/push/webpush-crypto.ts +231 -0
- package/backend/skills/detect.ts +28 -0
- package/backend/skills/index.ts +22 -4
- package/backend/skills/invoke.test.ts +114 -0
- package/backend/skills/invoke.ts +222 -0
- package/backend/skills/service.ts +194 -44
- package/backend/skills/spec.ts +35 -0
- package/backend/skills/sync.ts +85 -55
- package/backend/subagents/detect.ts +2 -3
- package/backend/subagents/sync.ts +15 -8
- package/backend/work/pull-requests.ts +2 -2
- package/backend/work/start-work.ts +4 -0
- package/backend/worktrees/branching/engine.ts +557 -0
- package/backend/worktrees/branching/index.ts +56 -0
- package/backend/worktrees/branching/naming.test.ts +118 -0
- package/backend/worktrees/branching/naming.ts +97 -0
- package/backend/worktrees/branching/projector.test.ts +229 -0
- package/backend/worktrees/branching/projector.ts +139 -0
- package/backend/worktrees/branching/providers/neon.ts +220 -0
- package/backend/worktrees/branching/registry.ts +27 -0
- package/backend/worktrees/branching/service.ts +620 -0
- package/backend/worktrees/branching/suggest.test.ts +154 -0
- package/backend/worktrees/branching/suggest.ts +202 -0
- package/backend/worktrees/branching/types.ts +88 -0
- package/backend/worktrees/index.ts +7 -0
- package/backend/worktrees/service.ts +48 -1
- package/backend/ws/chat/stream.ts +100 -8
- package/backend/ws/db-client/env.ts +142 -0
- package/backend/ws/db-client/index.ts +2 -0
- package/backend/ws/files/index.ts +4 -0
- package/backend/ws/files/share.ts +95 -0
- package/backend/ws/git/branch-name.ts +2 -2
- package/backend/ws/git/commit-message.ts +2 -2
- package/backend/ws/index.ts +3 -4
- package/backend/ws/profiles/crud.ts +2 -3
- package/backend/ws/projects/index.ts +6 -1
- package/backend/ws/projects/info.ts +70 -6
- package/backend/ws/projects/overview.test.ts +108 -0
- package/backend/ws/projects/overview.ts +300 -0
- package/backend/ws/skills/catalog.ts +5 -1
- package/backend/ws/skills/crud.ts +128 -22
- package/backend/ws/skills/index.ts +4 -1
- package/backend/ws/system/device-info.ts +307 -76
- package/backend/ws/user/crud.ts +12 -3
- package/backend/ws/worktrees/branching.ts +212 -0
- package/backend/ws/worktrees/crud.ts +33 -7
- package/backend/ws/worktrees/index.ts +14 -0
- package/dist/assets/{index-C8Gi-b6U.js → index-CeNKKSDR.js} +1 -1
- package/dist/assets/{index-BrF6nqld.js → index-DW89566K.js} +1 -1
- package/dist/assets/main-Cy5DXWPT.js +1207 -0
- package/dist/assets/main-DJKj_4By.css +1 -0
- package/dist/index.html +7 -2
- package/dist/sw.js +112 -0
- package/package.json +1 -1
- package/shared/constants/engine-tools.ts +31 -6
- package/shared/constants/notification-messages.ts +142 -0
- package/shared/constants/tool-icons.ts +6 -2
- package/shared/types/db-client/env.ts +192 -0
- package/shared/types/db-client/index.ts +1 -0
- package/shared/types/db-client/integrations.ts +30 -0
- package/shared/types/integrations.ts +9 -0
- package/shared/types/unified/stream.ts +7 -0
- package/shared/types/worktree-branching.ts +315 -0
- package/shared/utils/logger.ts +1 -0
- package/backend/commands/detect.ts +0 -25
- package/backend/commands/index.ts +0 -9
- package/backend/commands/service.ts +0 -178
- package/backend/commands/store.ts +0 -45
- package/backend/commands/sync.ts +0 -94
- package/backend/database/queries/command-queries.ts +0 -82
- package/backend/ws/commands/crud.ts +0 -157
- package/backend/ws/commands/index.ts +0 -8
- package/dist/assets/main-Bd3gb79F.css +0 -1
- package/dist/assets/main-Bo1hD7mt.js +0 -1191
package/backend/skills/sync.ts
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Engine sync for Skills —
|
|
3
|
-
* (`backend/artifacts/`).
|
|
4
|
-
* has been generalized into {@link materializeArtifacts}, and this module simply
|
|
5
|
-
* supplies the skill item set plus the exact preamble text skills have always
|
|
6
|
-
* emitted (preserved verbatim so retrofitting introduces no behavior change).
|
|
2
|
+
* Engine sync for Skills — a thin adapter over the shared artifact framework
|
|
3
|
+
* (`backend/artifacts/`).
|
|
7
4
|
*
|
|
8
|
-
* Materialization by engine
|
|
9
|
-
* - NATIVE (Claude, Qwen, Copilot): mirror each enabled skill folder into
|
|
10
|
-
* engine's skills dir.
|
|
11
|
-
* - SYNTHETIC (Codex, OpenCode):
|
|
12
|
-
* (name + description + absolute SKILL.md path)
|
|
13
|
-
* memory file
|
|
5
|
+
* Materialization by engine:
|
|
6
|
+
* - NATIVE (Claude, Qwen, Copilot, Pi): mirror each enabled skill folder into
|
|
7
|
+
* the engine's skills dir.
|
|
8
|
+
* - SYNTHETIC (Codex, OpenCode, Cline, Cursor): no native skills dir, so the
|
|
9
|
+
* preamble (name + description + absolute SKILL.md path) is injected into
|
|
10
|
+
* each turn's prompt instead of a shared global memory file — a global file
|
|
11
|
+
* can't encode a per-session Profile and leaks across concurrent sessions.
|
|
12
|
+
*
|
|
13
|
+
* Only `auto`-triggered skills are ADVERTISED. A `slash`-only skill is invoked
|
|
14
|
+
* by the user and expanded by Clopen (see `./invoke.ts`), so listing it here
|
|
15
|
+
* would just invite the model to run it unprompted.
|
|
14
16
|
*
|
|
15
17
|
* Sync never throws — a stream never breaks because skills couldn't sync.
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
|
-
import { skillQueries } from '$backend/database/queries';
|
|
20
|
+
import { skillQueries, parseTriggers } from '$backend/database/queries';
|
|
19
21
|
import { debug } from '$shared/utils/logger';
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
materializeArtifacts,
|
|
24
|
+
resolveArtifact,
|
|
25
|
+
isPromptScopedEngine,
|
|
26
|
+
writeManagedBlock,
|
|
27
|
+
markersForType,
|
|
28
|
+
ARTIFACT_ENGINES,
|
|
29
|
+
type ManagedArtifact,
|
|
30
|
+
type ArtifactEngine
|
|
31
|
+
} from '$backend/artifacts';
|
|
21
32
|
import { artifactFilter } from '$backend/profiles';
|
|
22
33
|
import { getSkillMdPath, getSkillDir } from './store';
|
|
23
34
|
import { stat } from 'node:fs/promises';
|
|
@@ -25,16 +36,6 @@ import { stat } from 'node:fs/promises';
|
|
|
25
36
|
/** Kept for backwards-compatible imports; identical to {@link ArtifactEngine}. */
|
|
26
37
|
export type SkillEngine = ArtifactEngine;
|
|
27
38
|
|
|
28
|
-
interface EnabledSkill {
|
|
29
|
-
slug: string;
|
|
30
|
-
name: string;
|
|
31
|
-
description: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getEnabledSkills(): EnabledSkill[] {
|
|
35
|
-
return skillQueries.getEnabled().map(r => ({ slug: r.slug, name: r.name, description: r.description }));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
39
|
/** The skills preamble — exact original wording, without the markers (added by the writer). */
|
|
39
40
|
function buildSkillsPreamble(items: ManagedArtifact[]): string {
|
|
40
41
|
if (items.length === 0) return '';
|
|
@@ -66,28 +67,31 @@ async function pathExists(path: string): Promise<boolean> {
|
|
|
66
67
|
*
|
|
67
68
|
* A profile is the source of truth for what's active: an item it references is
|
|
68
69
|
* included even if globally disabled, and its enable toggle is ignored. With no
|
|
69
|
-
* profile filter, only the globally-enabled set applies
|
|
70
|
+
* profile filter, only the globally-enabled set applies.
|
|
71
|
+
*
|
|
72
|
+
* With `autoOnly`, `slash`-only skills are excluded. They exist to be invoked by
|
|
73
|
+
* name, and Clopen expands them itself, so an engine must neither be told about
|
|
74
|
+
* them nor be given a copy it could act on. Their content is still reachable —
|
|
75
|
+
* the canonical store is what the preamble and `uses:` reference by path.
|
|
70
76
|
*/
|
|
71
|
-
export function resolveEnabledSkills(profileId?: number): ManagedArtifact[] {
|
|
77
|
+
export function resolveEnabledSkills(profileId?: number, options?: { autoOnly?: boolean }): ManagedArtifact[] {
|
|
72
78
|
const filter = artifactFilter(profileId, 'skill');
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
sourceDir: getSkillDir(s.slug)
|
|
83
|
-
}));
|
|
79
|
+
const rows = (filter ? skillQueries.getAll() : skillQueries.getEnabled())
|
|
80
|
+
.filter(r => !filter || filter.has(r.slug))
|
|
81
|
+
.filter(r => !options?.autoOnly || parseTriggers(r.triggers).includes('auto'));
|
|
82
|
+
return rows.map(r => ({
|
|
83
|
+
slug: r.slug,
|
|
84
|
+
name: r.name,
|
|
85
|
+
description: r.description,
|
|
86
|
+
sourceDir: getSkillDir(r.slug)
|
|
87
|
+
}));
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
91
|
* Whether skills for this engine are delivered per-session via prompt injection
|
|
88
92
|
* INSTEAD of the shared global memory file — true only for a synthetic (no native
|
|
89
93
|
* dir) skill target on a prompt-scoped engine. Native skill engines
|
|
90
|
-
* (Claude/Qwen/Copilot) keep the folder mirror+prune.
|
|
94
|
+
* (Claude/Qwen/Copilot/Pi) keep the folder mirror+prune.
|
|
91
95
|
*/
|
|
92
96
|
function skillsViaPromptInjection(engine: SkillEngine): boolean {
|
|
93
97
|
const synthetic = resolveArtifact('skill', { engine, scope: 'global' }).format === 'preamble-region';
|
|
@@ -96,33 +100,26 @@ function skillsViaPromptInjection(engine: SkillEngine): boolean {
|
|
|
96
100
|
|
|
97
101
|
/**
|
|
98
102
|
* The profile-scoped skills preamble for PER-SESSION injection into a synthetic
|
|
99
|
-
* engine's prompt (OpenCode/
|
|
100
|
-
*
|
|
101
|
-
* from now being correctly scoped to the session's active Profile.
|
|
103
|
+
* engine's prompt (Codex/OpenCode/Copilot/Cline/Cursor). Returns '' when no skill
|
|
104
|
+
* applies.
|
|
102
105
|
*/
|
|
103
106
|
export function buildSkillsPromptContext(profileId?: number): string {
|
|
104
|
-
return buildSkillsPreamble(resolveEnabledSkills(profileId));
|
|
107
|
+
return buildSkillsPreamble(resolveEnabledSkills(profileId, { autoOnly: true }));
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* Sync enabled skills for one engine. Safe to call at every stream start.
|
|
109
112
|
* Never throws: failures are logged and swallowed so streaming is unaffected.
|
|
110
|
-
*
|
|
111
|
-
* NATIVE engines (Claude/Qwen/Copilot) mirror the profile-narrowed skill folders
|
|
112
|
-
* into the engine's skills dir and prune the rest — a per-query-correct filter.
|
|
113
|
-
*
|
|
114
|
-
* SYNTHETIC engines (OpenCode/Codex) do NOT advertise skills through the shared
|
|
115
|
-
* global memory file here: a single global file can't encode a per-session
|
|
116
|
-
* profile choice and would leak across concurrent sessions (and their persistent
|
|
117
|
-
* server may not re-read it). Instead they inject the resolved preamble into each
|
|
118
|
-
* turn's prompt (see the adapters + {@link buildSkillsPromptContext}). We still
|
|
119
|
-
* materialize an EMPTY set for them so any legacy `CLOPEN:SKILLS` block left in
|
|
120
|
-
* AGENTS.md is stripped.
|
|
121
113
|
*/
|
|
122
114
|
export async function syncSkills(engine: SkillEngine, profileId?: number): Promise<void> {
|
|
123
115
|
try {
|
|
124
116
|
const viaPrompt = skillsViaPromptInjection(engine);
|
|
125
|
-
|
|
117
|
+
// Auto-only, in the native dir as well as the preamble. Mirroring a
|
|
118
|
+
// slash-only skill into e.g. Claude's `skills/` would hand it to Claude's
|
|
119
|
+
// own Skill tool, which is precisely the autonomous invocation that trigger
|
|
120
|
+
// rules out. Nothing is lost by withholding it: the canonical store is what
|
|
121
|
+
// the preamble and `uses:` point at, and Clopen expands `/slug` itself.
|
|
122
|
+
const enabled: ManagedArtifact[] = viaPrompt ? [] : resolveEnabledSkills(profileId, { autoOnly: true });
|
|
126
123
|
const managedSlugs = skillQueries.getAll().map(s => s.slug);
|
|
127
124
|
await materializeArtifacts('skill', { engine, scope: 'global' }, {
|
|
128
125
|
enabled,
|
|
@@ -135,10 +132,43 @@ export async function syncSkills(engine: SkillEngine, profileId?: number): Promi
|
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Remove everything earlier versions materialized for the separate Commands
|
|
137
|
+
* feature: the per-engine command/prompt directories AND any `CLOPEN:COMMANDS`
|
|
138
|
+
* block left inside a memory file.
|
|
139
|
+
*
|
|
140
|
+
* Commands are `slash` Skills now and are expanded by Clopen before the prompt
|
|
141
|
+
* reaches the engine (see `./invoke.ts`), so nothing should be written to those
|
|
142
|
+
* locations any more. Without this sweep a renamed or deleted command would keep
|
|
143
|
+
* being offered by Claude's or Codex's own command picker forever.
|
|
144
|
+
*
|
|
145
|
+
* Materializing an EMPTY set is exactly the right primitive: in an exclusive
|
|
146
|
+
* (Clopen-owned, isolated) directory it prunes every entry, and for a synthetic
|
|
147
|
+
* target it strips the managed block while preserving the user's own content.
|
|
148
|
+
*/
|
|
149
|
+
export async function stripLegacyCommandArtifacts(engine: ArtifactEngine): Promise<void> {
|
|
150
|
+
try {
|
|
151
|
+
const ctx = { engine, scope: 'global' } as const;
|
|
152
|
+
const resolution = resolveArtifact('command', ctx);
|
|
153
|
+
const directoryBacked = resolution.format === 'folder-md' || resolution.format === 'single-md';
|
|
154
|
+
if (directoryBacked && !(await pathExists(resolution.locateEffective(ctx)))) {
|
|
155
|
+
// Nothing was ever written there. Don't let the generic materializer
|
|
156
|
+
// create the directory just to find it empty — but a stale managed block
|
|
157
|
+
// can still exist in the memory file from before this engine had a
|
|
158
|
+
// native command dir, so clear that unconditionally.
|
|
159
|
+
const memoryFile = resolveArtifact('instruction', ctx).locateEffective(ctx);
|
|
160
|
+
if (memoryFile) await writeManagedBlock(memoryFile, '', markersForType('command'));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await materializeArtifacts('command', ctx, { enabled: [], managedSlugs: [] });
|
|
164
|
+
} catch (error) {
|
|
165
|
+
debug.warn('skills', `⚠️ Legacy command cleanup for ${engine} failed (continuing):`, error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
138
169
|
/** Re-sync every engine — used after a mutation so changes propagate eagerly. */
|
|
139
170
|
export async function syncSkillsAllEngines(): Promise<void> {
|
|
140
|
-
|
|
141
|
-
await Promise.all(engines.map(syncSkills));
|
|
171
|
+
await Promise.all(ARTIFACT_ENGINES.map(engine => syncSkills(engine)));
|
|
142
172
|
}
|
|
143
173
|
|
|
144
174
|
/** Validate that a skill's SKILL.md exists on disk (used by the WS status surface). */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the Settings UI.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { detectArtifacts, type DetectedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
6
|
+
import { detectArtifacts, ARTIFACT_ENGINES, type DetectedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
7
7
|
|
|
8
8
|
export interface DetectedSubagentGroup {
|
|
9
9
|
engine: ArtifactEngine;
|
|
@@ -11,10 +11,9 @@ export interface DetectedSubagentGroup {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export async function detectSubagents(projectPath?: string): Promise<DetectedSubagentGroup[]> {
|
|
14
|
-
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode', 'pi'];
|
|
15
14
|
const scope = projectPath ? 'project' : 'global';
|
|
16
15
|
const groups = await Promise.all(
|
|
17
|
-
|
|
16
|
+
ARTIFACT_ENGINES.map(async engine => ({
|
|
18
17
|
engine,
|
|
19
18
|
detected: await detectArtifacts('subagent', { engine, scope, projectPath })
|
|
20
19
|
}))
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { subagentQueries } from '$backend/database/queries';
|
|
11
11
|
import { debug } from '$shared/utils/logger';
|
|
12
|
-
import { materializeArtifacts, resolveArtifact, isPromptScopedEngine, parseDoc, serializeDoc, parseEngineMap, artifactEngineToType, type ManagedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
12
|
+
import { materializeArtifacts, resolveArtifact, isPromptScopedEngine, canDelegateSubagents, parseDoc, serializeDoc, parseEngineMap, artifactEngineToType, ARTIFACT_ENGINES, type ManagedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
13
13
|
import { artifactFilter } from '$backend/profiles';
|
|
14
14
|
import { readSubagentMd } from './store';
|
|
15
15
|
|
|
@@ -56,11 +56,17 @@ function resolveEnabledSubagentsMeta(profileId?: number): ManagedArtifact[] {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* The profile-scoped subagents preamble for PER-SESSION injection into a
|
|
59
|
-
* prompt-scoped engine's prompt
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* prompt-scoped engine's prompt. Returns '' when none apply. Advisory: it steers
|
|
60
|
+
* which subagents the model delegates to, on top of whatever the engine's own
|
|
61
|
+
* (possibly stale/shared) agent registry exposes.
|
|
62
|
+
*
|
|
63
|
+
* Engines with no way to delegate (Codex, Copilot, Qwen) are told nothing. They
|
|
64
|
+
* used to receive the same "you can delegate matching tasks to these" preamble
|
|
65
|
+
* as engines that can, which described a capability they do not have — the model
|
|
66
|
+
* could only respond by inventing the delegation or ignoring the block.
|
|
62
67
|
*/
|
|
63
|
-
export function buildSubagentsPromptContext(profileId?: number): string {
|
|
68
|
+
export function buildSubagentsPromptContext(engine: ArtifactEngine, profileId?: number): string {
|
|
69
|
+
if (!canDelegateSubagents(engine)) return '';
|
|
64
70
|
return buildSubagentsPreamble(resolveEnabledSubagentsMeta(profileId));
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -111,7 +117,9 @@ export async function syncSubagents(engine: ArtifactEngine, profileId?: number):
|
|
|
111
117
|
// In both cases materialize an EMPTY set so any stale dir/block is stripped.
|
|
112
118
|
// Claude keeps its native filtered files; Qwen (per-query) keeps its preamble.
|
|
113
119
|
const synthetic = resolveArtifact('subagent', { engine, scope: 'global' }).format === 'preamble-region';
|
|
114
|
-
|
|
120
|
+
// An engine that cannot delegate gets an empty set too: no files, no block,
|
|
121
|
+
// no advertisement anywhere (see {@link buildSubagentsPromptContext}).
|
|
122
|
+
const viaPrompt = (synthetic && isPromptScopedEngine(engine)) || engine === 'opencode' || !canDelegateSubagents(engine);
|
|
115
123
|
const filter = artifactFilter(profileId, 'subagent');
|
|
116
124
|
// A profile activates the subagents it references even if globally disabled;
|
|
117
125
|
// with no profile filter, only the enabled set applies (unchanged).
|
|
@@ -139,6 +147,5 @@ export async function syncSubagents(engine: ArtifactEngine, profileId?: number):
|
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
export async function syncSubagentsAllEngines(): Promise<void> {
|
|
142
|
-
|
|
143
|
-
await Promise.all(engines.map(syncSubagents));
|
|
150
|
+
await Promise.all(ARTIFACT_ENGINES.map(engine => syncSubagents(engine)));
|
|
144
151
|
}
|
|
@@ -14,7 +14,7 @@ import { execGit } from '$backend/git/git-executor';
|
|
|
14
14
|
import { gitService } from '$backend/git/git-service';
|
|
15
15
|
import { workLinkQueries } from '$backend/database/queries';
|
|
16
16
|
import { initializeEngine } from '$backend/engine';
|
|
17
|
-
import { resolveGenerationTarget } from '$backend/engine/resolve-model';
|
|
17
|
+
import { resolveGenerationTarget, GENERATION_SETTINGS } from '$backend/engine/resolve-model';
|
|
18
18
|
import { buildBudgetedDiff, PR_DESCRIPTION_BUDGET, rangeScope } from '$backend/ws/git/diff-budget';
|
|
19
19
|
import type { EngineType } from '$shared/types/unified';
|
|
20
20
|
import type { GitBranchInfo } from '$shared/types/git';
|
|
@@ -226,7 +226,7 @@ export async function draftPullRequestDescription(input: {
|
|
|
226
226
|
diffTruncated: diff.truncated
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
const target = await resolveGenerationTarget(engine, input.modelId, input.providerSlug);
|
|
229
|
+
const target = await resolveGenerationTarget(engine, input.modelId, input.providerSlug, GENERATION_SETTINGS.commit);
|
|
230
230
|
debug.log('work', `Drafting a PR description via ${input.engine}/${target.providerSlug}/${target.modelId}`);
|
|
231
231
|
|
|
232
232
|
const result = await engine.generateStructured<GeneratedDescription>({
|
|
@@ -41,6 +41,10 @@ function slugify(text: string, maxWords = 6): string {
|
|
|
41
41
|
return text
|
|
42
42
|
.toLowerCase()
|
|
43
43
|
.normalize('NFKD')
|
|
44
|
+
// Combining marks are dropped rather than left for the character class to
|
|
45
|
+
// turn into spaces: `ü` decomposes to `u` + a diaeresis, and without this
|
|
46
|
+
// an issue titled "münchen" produces the branch `mu-nchen`.
|
|
47
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
44
48
|
.replace(/[^\w\s-]/g, ' ')
|
|
45
49
|
.trim()
|
|
46
50
|
.split(/[\s_-]+/)
|