@ycodium-ai/plugin-api 0.2.6182 → 0.2.6212

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 (36) hide show
  1. package/README.md +5 -1
  2. package/dist/_private/ycodium-composer-tokens/composerLogic.d.ts +1 -1
  3. package/dist/_private/ycodium-composer-tokens/composerTrigger.d.ts +3 -4
  4. package/dist/_private/ycodium-composer-tokens/composerTrigger.js +2 -4
  5. package/dist/_private/ycodium-composer-tokens/providerSkills.d.ts +25 -3
  6. package/dist/_private/ycodium-composer-tokens/providerSkills.js +45 -3
  7. package/dist/_private/ycodium-composer-tokens/slashMenu.d.ts +20 -11
  8. package/dist/_private/ycodium-composer-tokens/slashMenu.js +24 -21
  9. package/dist/_private/ycodium-executor-common/eventTypes.d.ts +1 -1
  10. package/dist/composer.d.ts +1 -1
  11. package/dist/composer.d.ts.map +1 -1
  12. package/dist/composer.js +1 -1
  13. package/dist/composer.js.map +1 -1
  14. package/dist/conversationComposerEnvironment.d.ts +2 -0
  15. package/dist/conversationComposerEnvironment.d.ts.map +1 -1
  16. package/dist/conversationSkills.d.ts +5 -0
  17. package/dist/conversationSkills.d.ts.map +1 -1
  18. package/dist/conversationTrajectory.d.ts +3 -0
  19. package/dist/conversationTrajectory.d.ts.map +1 -1
  20. package/dist/dataPorts.gen.d.ts +68 -6
  21. package/dist/dataPorts.gen.d.ts.map +1 -1
  22. package/dist/source/_private/ycodium-composer-tokens/composerLogic.ts +1 -1
  23. package/dist/source/_private/ycodium-composer-tokens/composerTrigger.ts +3 -5
  24. package/dist/source/_private/ycodium-composer-tokens/providerSkills.ts +83 -7
  25. package/dist/source/_private/ycodium-composer-tokens/slashMenu.ts +52 -26
  26. package/dist/source/_private/ycodium-executor-common/eventTypes.ts +1 -0
  27. package/dist/source/composer.ts +4 -0
  28. package/dist/source/conversationComposerEnvironment.ts +2 -0
  29. package/dist/source/conversationSkills.ts +6 -0
  30. package/dist/source/conversationTrajectory.ts +4 -0
  31. package/dist/source/dataPorts.gen.ts +26 -26
  32. package/dist/source/version.ts +2 -2
  33. package/dist/version.d.ts +2 -2
  34. package/dist/version.d.ts.map +1 -1
  35. package/dist/version.js +1 -1
  36. package/package.json +4 -4
@@ -11,7 +11,7 @@ import {
11
11
  } from "./composerTrigger.ts";
12
12
  import { isComposerWhitespace } from "./skillTokens.ts";
13
13
 
14
- export type ComposerSlashCommand = "model" | "plan" | "default";
14
+ export type ComposerSlashCommand = "model" | "effort" | "mode" | "compact" | "plan" | "default";
15
15
  export type ComposerSubmissionIntent = "foreground" | "background" | "steer";
16
16
 
17
17
  /**
@@ -3,10 +3,9 @@ import { isComposerWhitespace, SKILL_TOKEN_NAME_PATTERN } from "./skillTokens.ts
3
3
  /**
4
4
  * - `slash-command`:行首的 `/query`,菜单列内置命令、provider 命令与技能。
5
5
  * - `slash-skill`:句中(前面是空白)的 `/query`,菜单只列技能,选中插入 `$name`;内置命令只认行首。
6
- * - `skill`:任意位置的 `$query`。
7
6
  * - `path`:任意位置的 `@query`。
8
7
  */
9
- export type ComposerTriggerKind = "path" | "slash-command" | "slash-skill" | "skill";
8
+ export type ComposerTriggerKind = "path" | "slash-command" | "slash-skill";
10
9
 
11
10
  export interface ComposerTrigger {
12
11
  kind: ComposerTriggerKind;
@@ -24,8 +23,8 @@ function clampCursor(text: string, cursor: number): number {
24
23
  }
25
24
 
26
25
  /**
27
- * 光标处正在输入的触发器(`/command`、`/skill`、`$skill`、`@path`)。`isWhitespaceChar` 给有内联
28
- * 占位字符的输入区(web 的终端上下文芯片)把它们也当 token 边界。
26
+ * 光标处正在输入的触发器(`/command`、`/skill`、`@path`)。`$` 留给普通文本(环境变量、金额等),不触发补全菜单。
27
+ * `isWhitespaceChar` 给有内联占位字符的输入区(web 的终端上下文芯片)把它们也当 token 边界。
29
28
  */
30
29
  export function detectComposerTrigger(
31
30
  text: string,
@@ -50,7 +49,6 @@ export function detectComposerTrigger(
50
49
  }
51
50
  const token = text.slice(tokenStart, cursor);
52
51
  const range = { query: token.slice(1), rangeStart: tokenStart, rangeEnd: cursor };
53
- if (token.startsWith("$")) return { kind: "skill", ...range };
54
52
  if (token.startsWith("@")) return { kind: "path", ...range };
55
53
  if (!token.startsWith("/")) return null;
56
54
 
@@ -9,13 +9,40 @@ export interface ProviderSkillFields {
9
9
  readonly displayName?: string | undefined;
10
10
  readonly shortDescription?: string | undefined;
11
11
  readonly description?: string | undefined;
12
+ readonly summary?: Readonly<Record<string, string>> | undefined;
12
13
  readonly path: string;
13
14
  readonly scope?: string | undefined;
15
+ readonly originScope?: "repo" | "project" | "global" | "builtin" | undefined;
16
+ readonly originLabel?: string | undefined;
17
+ readonly overridesGlobal?: boolean | undefined;
14
18
  readonly enabled: boolean;
15
19
  readonly userInvocable?: boolean | undefined;
16
20
  }
17
21
 
18
- export type ProviderSkillSourceKind = "app" | "repo" | "project" | "personal" | "system" | "other";
22
+ export type ProviderSkillSourceKind =
23
+ | "builtin"
24
+ | "app"
25
+ | "repo"
26
+ | "project"
27
+ | "personal"
28
+ | "system"
29
+ | "other";
30
+
31
+ export type ProviderSkillScopeBadgeKind =
32
+ | "repo"
33
+ | "project"
34
+ | "global"
35
+ | "builtin"
36
+ | "personal"
37
+ | "app"
38
+ | "system"
39
+ | "other";
40
+
41
+ export interface ProviderSkillScopeBadge {
42
+ readonly kind: ProviderSkillScopeBadgeKind;
43
+ readonly customLabel: string | null;
44
+ readonly overridesGlobal: boolean;
45
+ }
19
46
 
20
47
  function titleCaseWords(value: string): string {
21
48
  const words: string[] = [];
@@ -37,12 +64,31 @@ export function formatProviderSkillDisplayName(
37
64
  if (displayName) {
38
65
  return displayName;
39
66
  }
40
- return titleCaseWords(skill.name);
67
+ const trimmedName = skill.name.trim();
68
+ const stripped = /^ycodium[-:_](.+)$/i.exec(trimmedName)?.[1] ?? trimmedName;
69
+ return titleCaseWords(stripped);
70
+ }
71
+
72
+ export function resolveProviderSkillSummary(
73
+ skill: Pick<ProviderSkillFields, "summary" | "shortDescription" | "description">,
74
+ language?: string | undefined,
75
+ ): string {
76
+ if (skill.summary) {
77
+ if (language) {
78
+ const exact = skill.summary[language];
79
+ if (exact) return exact;
80
+ const base = language.split("-")[0];
81
+ if (base && skill.summary[base]) return skill.summary[base]!;
82
+ if (base === "zh" && skill.summary["zh-CN"]) return skill.summary["zh-CN"]!;
83
+ }
84
+ if (skill.summary["en"]) return skill.summary["en"]!;
85
+ }
86
+ return skill.shortDescription?.trim() || skill.description?.trim() || "";
41
87
  }
42
88
 
43
89
  export function getProviderSkillsForSlashMenu<S extends ProviderSkillFields>(
44
90
  skills: ReadonlyArray<S>,
45
- showSkillsInSlashMenu: boolean,
91
+ showSkillsInSlashMenu: boolean = true,
46
92
  ): S[] {
47
93
  return showSkillsInSlashMenu ? skills.filter(isProviderSkillUserInvocable) : [];
48
94
  }
@@ -55,16 +101,29 @@ export function getProviderSlashCommandsForSlashMenu<C extends { readonly name:
55
101
  return slashCommands.filter((command) => !skillNames.has(command.name.trim().toLowerCase()));
56
102
  }
57
103
 
58
- export function resolveProviderSkillSourceKind(
59
- skill: Pick<ProviderSkillFields, "path" | "scope">,
60
- ): ProviderSkillSourceKind {
61
- const normalizedPath = normalizePathSeparators(skill.path);
104
+ export function resolveProviderSkillSourceKind(skill: {
105
+ readonly path?: string | undefined;
106
+ readonly scope?: string | undefined;
107
+ readonly originScope?: "repo" | "project" | "global" | "builtin" | undefined;
108
+ }): ProviderSkillSourceKind {
109
+ if (skill.originScope === "repo") return "repo";
110
+ if (skill.originScope === "project") return "project";
111
+ if (skill.originScope === "builtin") return "builtin";
112
+ if (skill.originScope === "global") return "personal";
113
+
114
+ const normalizedPath = normalizePathSeparators(skill.path ?? "");
115
+ if (normalizedPath.includes("/session-skills/")) {
116
+ return "builtin";
117
+ }
62
118
  if (normalizedPath.includes("/.codex/plugins/") || normalizedPath.includes("/.agents/plugins/")) {
63
119
  return "app";
64
120
  }
65
121
 
66
122
  const normalizedScope = skill.scope?.trim().toLowerCase();
67
123
  switch (normalizedScope) {
124
+ case "ycodium":
125
+ case "builtin":
126
+ return "builtin";
68
127
  case "repo":
69
128
  case "repository":
70
129
  return "repo";
@@ -74,6 +133,7 @@ export function resolveProviderSkillSourceKind(
74
133
  return "project";
75
134
  case "user":
76
135
  case "personal":
136
+ case "global":
77
137
  return "personal";
78
138
  case "system":
79
139
  return "system";
@@ -84,3 +144,19 @@ export function resolveProviderSkillSourceKind(
84
144
  return "other";
85
145
  }
86
146
  }
147
+
148
+ export function resolveProviderSkillScopeBadge(skill: {
149
+ readonly path?: string | undefined;
150
+ readonly scope?: string | undefined;
151
+ readonly originScope?: "repo" | "project" | "global" | "builtin" | undefined;
152
+ readonly originLabel?: string | undefined;
153
+ readonly overridesGlobal?: boolean | undefined;
154
+ }): ProviderSkillScopeBadge {
155
+ const kind: ProviderSkillScopeBadgeKind =
156
+ skill.originScope ?? resolveProviderSkillSourceKind(skill);
157
+ return {
158
+ kind,
159
+ customLabel: skill.originLabel?.trim() || null,
160
+ overridesGlobal: skill.overridesGlobal === true,
161
+ };
162
+ }
@@ -1,3 +1,8 @@
1
+ import {
2
+ formatProviderSkillDisplayName,
3
+ resolveProviderSkillSummary,
4
+ type ProviderSkillScopeBadgeKind,
5
+ } from "./providerSkills.ts";
1
6
  import { isProviderSkillUserInvocable } from "./skillTokens.ts";
2
7
  import { scoreQueryMatch } from "./searchRanking.ts";
3
8
 
@@ -9,7 +14,11 @@ export interface MenuSkill {
9
14
  readonly displayName?: string | undefined;
10
15
  readonly shortDescription?: string | undefined;
11
16
  readonly description?: string | undefined;
17
+ readonly summary?: Readonly<Record<string, string>> | undefined;
12
18
  readonly scope?: string | undefined;
19
+ readonly originScope?: "repo" | "project" | "global" | "builtin" | undefined;
20
+ readonly originLabel?: string | undefined;
21
+ readonly overridesGlobal?: boolean | undefined;
13
22
  readonly pluginId?: string | undefined;
14
23
  }
15
24
 
@@ -25,6 +34,7 @@ export interface PluginSlashMenuCommand {
25
34
  readonly kind: "prompt" | "action";
26
35
  readonly description?: string | undefined;
27
36
  readonly argumentHint?: string | undefined;
37
+ readonly originScope?: ProviderSkillScopeBadgeKind | undefined;
28
38
  }
29
39
  export type PluginSlashBinding = Pick<PluginSlashMenuCommand, "pluginId" | "name">;
30
40
  export type SlashMenuSection = "recent" | "builtIn" | "provider" | "skills" | "plugins";
@@ -34,7 +44,12 @@ type MenuRow = {
34
44
  readonly description: string;
35
45
  readonly section?: SlashMenuSection | undefined;
36
46
  };
37
- export type SlashMenuItem<B extends string = string> = MenuRow &
47
+ export type SlashMenuItem<
48
+ B extends string = string,
49
+ P extends string = string,
50
+ S extends MenuSkill = MenuSkill,
51
+ C extends MenuProviderCommand = MenuProviderCommand,
52
+ > = MenuRow &
38
53
  (
39
54
  | {
40
55
  readonly type: "plugin-slash-command";
@@ -44,10 +59,10 @@ export type SlashMenuItem<B extends string = string> = MenuRow &
44
59
  | { readonly type: "slash-command"; readonly command: B }
45
60
  | {
46
61
  readonly type: "provider-slash-command";
47
- readonly command: MenuProviderCommand;
48
- readonly provider: string;
62
+ readonly command: C;
63
+ readonly provider: P;
49
64
  }
50
- | { readonly type: "skill"; readonly skill: MenuSkill; readonly provider: string }
65
+ | { readonly type: "skill"; readonly skill: S; readonly provider: P }
51
66
  );
52
67
 
53
68
  const score = (value: string, query: string, base = 0) =>
@@ -77,15 +92,11 @@ export function searchSlashCommandItems<T extends SlashMenuItem>(
77
92
  : item.type === "skill"
78
93
  ? item.skill.name
79
94
  : item.command.name;
80
- const skillQuery = item.type === "skill" && q.startsWith("skill:") ? q.slice(6) : q;
81
- const scores = [score(name, skillQuery), score(item.description, skillQuery, 20)];
95
+ const scores = [score(name, q), score(item.description, q, 20)];
82
96
  if (item.type === "skill") {
83
- scores.push(
84
- score(item.skill.displayName ?? item.skill.name.replace(/[-_]/g, " "), skillQuery, 1),
85
- );
86
- scores.push(score(item.skill.description ?? "", skillQuery, 30));
87
- scores.push(score(item.skill.scope ?? "", skillQuery, 40));
88
- if ("skill".startsWith(q)) scores.push(q === "skill" ? 0 : Number.MAX_SAFE_INTEGER);
97
+ scores.push(score(item.skill.displayName ?? item.skill.name.replace(/[-_]/g, " "), q, 1));
98
+ scores.push(score(item.skill.description ?? "", q, 30));
99
+ scores.push(score(item.skill.scope ?? "", q, 40));
89
100
  }
90
101
  const matches = scores.filter((n): n is number => n !== null);
91
102
  if (!matches.length) return [];
@@ -139,20 +150,31 @@ export function groupSlashMenuItemsForEmptyQuery<T extends Pick<SlashMenuItem, "
139
150
  }
140
151
 
141
152
  /** 两端传入可执行的内置命令与本地设置;来源去重、过滤、打分和分组只在这里做。 */
142
- export function buildSlashMenu<B extends string>(input: {
143
- readonly builtIns: readonly { readonly command: B; readonly description: string }[];
144
- readonly provider: string;
145
- readonly commands: readonly MenuProviderCommand[];
146
- readonly skills: readonly MenuSkill[];
147
- readonly showSkills: boolean;
153
+ export function buildSlashMenu<
154
+ B extends string,
155
+ P extends string = string,
156
+ S extends MenuSkill = MenuSkill,
157
+ C extends MenuProviderCommand = MenuProviderCommand,
158
+ >(input: {
159
+ readonly builtIns: readonly {
160
+ readonly command: B;
161
+ readonly description: string;
162
+ readonly hasChildren?: boolean | undefined;
163
+ }[];
164
+ readonly provider: P;
165
+ readonly commands: readonly C[];
166
+ readonly skills: readonly S[];
167
+ readonly showSkills?: boolean | undefined;
148
168
  readonly query: string;
169
+ readonly language?: string | undefined;
149
170
  readonly recentIds?: readonly string[];
150
171
  readonly providerDescription: string;
151
172
  readonly plugins?: readonly PluginSlashMenuCommand[] | undefined;
152
173
  }) {
174
+ const showSkills = input.showSkills !== false;
153
175
  const skillNames = new Set(input.skills.map((skill) => skill.name.trim().toLowerCase()));
154
176
  const builtInNames = new Set<string>(input.builtIns.map((item) => item.command));
155
- const items: SlashMenuItem<B>[] = [
177
+ const items: SlashMenuItem<B, P, S, C>[] = [
156
178
  ...input.builtIns.map((item) => ({
157
179
  ...item,
158
180
  id: `slash:${item.command}`,
@@ -171,13 +193,13 @@ export function buildSlashMenu<B extends string>(input: {
171
193
  label: `/${command.name}`,
172
194
  description: command.description ?? command.input?.hint ?? input.providerDescription,
173
195
  })),
174
- ...(input.showSkills ? input.skills.filter(isProviderSkillUserInvocable) : []).map((skill) => ({
196
+ ...(showSkills ? input.skills.filter(isProviderSkillUserInvocable) : []).map((skill) => ({
175
197
  id: `skill:${input.provider}:${skill.name}`,
176
198
  type: "skill" as const,
177
199
  provider: input.provider,
178
200
  skill,
179
- label: `/skill:${skill.name}`,
180
- description: skill.shortDescription ?? skill.description ?? "",
201
+ label: formatProviderSkillDisplayName(skill),
202
+ description: resolveProviderSkillSummary(skill, input.language),
181
203
  })),
182
204
  ...(input.plugins ?? []).map((command) => ({
183
205
  id: `plugin-slash:${command.pluginId}:${command.name}`,
@@ -242,6 +264,7 @@ export const retainSlashBinding = (text: string, binding: PluginSlashBinding | u
242
264
  export function pluginSlashMenuCommands(
243
265
  plugins: readonly {
244
266
  readonly pluginId: string;
267
+ readonly origin?: string | undefined;
245
268
  readonly state: string;
246
269
  readonly threadId?: string | null | undefined;
247
270
  readonly slashCommands?:
@@ -275,11 +298,14 @@ export function pluginSlashMenuCommands(
275
298
  if (!previous || (previous.threadId != null && plugin.threadId == null))
276
299
  byPlugin.set(plugin.pluginId, plugin);
277
300
  }
278
- return [...byPlugin.values()].flatMap((plugin) =>
279
- (plugin.slashCommands ?? []).map((command) => ({
301
+ return [...byPlugin.values()].flatMap((plugin) => {
302
+ const originScope: ProviderSkillScopeBadgeKind =
303
+ plugin.origin === "builtin" ? "builtin" : plugin.origin === "project" ? "repo" : "global";
304
+ return (plugin.slashCommands ?? []).map((command) => ({
280
305
  pluginId: plugin.pluginId,
281
306
  name: command.name,
282
307
  kind: command.kind,
308
+ originScope,
283
309
  description:
284
310
  command.translations?.[language]?.description ??
285
311
  command.translations?.en?.description ??
@@ -288,6 +314,6 @@ export function pluginSlashMenuCommands(
288
314
  command.translations?.[language]?.argumentHint ??
289
315
  command.translations?.en?.argumentHint ??
290
316
  command.argumentHint,
291
- })),
292
- );
317
+ }));
318
+ });
293
319
  }
@@ -29,6 +29,7 @@ export type ExecutorEventType =
29
29
  | "item.updated"
30
30
  | "item.completed"
31
31
  | "content.delta"
32
+ | "turn.interactions.bound"
32
33
  | "request.opened"
33
34
  | "request.resolved"
34
35
  | "user-input.requested"
@@ -65,8 +65,12 @@ export {
65
65
  export {
66
66
  formatProviderSkillDisplayName,
67
67
  getProviderSkillsForSlashMenu,
68
+ type ProviderSkillScopeBadge,
69
+ type ProviderSkillScopeBadgeKind,
68
70
  type ProviderSkillSourceKind,
71
+ resolveProviderSkillScopeBadge,
69
72
  resolveProviderSkillSourceKind,
73
+ resolveProviderSkillSummary,
70
74
  } from "./_private/ycodium-composer-tokens/providerSkills.ts";
71
75
  export { searchProviderSkills } from "./_private/ycodium-composer-tokens/providerSkillSearch.ts";
72
76
  export {
@@ -55,6 +55,8 @@ export interface ConversationShortcutMatchOptions {
55
55
  terminalFocus?: boolean;
56
56
  terminalOpen?: boolean;
57
57
  modelPickerOpen?: boolean;
58
+ composerFocus?: boolean;
59
+ editableFocus?: boolean;
58
60
  };
59
61
  }
60
62
 
@@ -1,13 +1,19 @@
1
1
  /** 宿主报给会话插件的技能与斜杠命令(`ServerProviderSkill` / `ServerProviderSlashCommand` 的结构子集)。 */
2
2
 
3
+ export type ConversationSkillOriginScope = "repo" | "project" | "global" | "builtin";
4
+
3
5
  export interface ConversationServerProviderSkill {
4
6
  pluginId?: string | undefined;
5
7
  name: string;
6
8
  displayName?: string | undefined;
7
9
  shortDescription?: string | undefined;
8
10
  description?: string | undefined;
11
+ summary?: Readonly<Record<string, string>> | undefined;
9
12
  path: string;
10
13
  scope?: string | undefined;
14
+ originScope?: ConversationSkillOriginScope | undefined;
15
+ originLabel?: string | undefined;
16
+ overridesGlobal?: boolean | undefined;
11
17
  enabled: boolean;
12
18
  userInvocationOnly?: boolean | undefined;
13
19
  userInvocable?: boolean | undefined;
@@ -75,10 +75,14 @@ export interface ConversationToolCallCounts {
75
75
  readonly matchedFailedCalls: number;
76
76
  }
77
77
 
78
+ export type ConversationExtensionScopeKind = "repo" | "project" | "global" | "builtin";
79
+
78
80
  export interface ConversationTrajectorySourceQuery {
79
81
  readonly sources: readonly ConversationToolCallFilter[];
80
82
  /** 缺席表示尚无该轮的完整计数,不能拿当前窗口行数替代。 */
81
83
  readonly turnCounts: ReadonlyMap<string | null, ConversationToolCallCounts>;
84
+ readonly scopeByPluginId?: Readonly<Record<string, ConversationExtensionScopeKind>> | undefined;
85
+ readonly scopeByMcpServer?: Readonly<Record<string, ConversationExtensionScopeKind>> | undefined;
82
86
  readonly loading: boolean;
83
87
  readonly error: string | null;
84
88
  retry(): void;