@dsh-plus/agent-preset-rea 0.1.2 → 0.1.3
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/lib/client.js +336 -10
- package/lib/index.d.ts +90 -1
- package/lib/index.js +364 -14
- package/package.json +4 -4
- package/src/client/card.tsx +68 -4
- package/src/client/client.ts +2 -1
- package/src/client/draft.ts +16 -4
- package/src/client/i18n.ts +24 -6
- package/src/client/styles.ts +8 -0
- package/src/config.ts +32 -11
- package/src/definition.ts +55 -6
- package/src/index.ts +17 -0
- package/src/persona-prefix.ts +367 -0
package/src/client/draft.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 卡片草稿的纯逻辑(无 JSX,node --test 可直接测):命名空间解析值 ⇄ 编辑草稿。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `mcpEnabled` / `skillEnabled` / `reverseSkillEnabled`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 卡片编辑六个活动字段(`personaPrefixMode` 提示词来源、`personaPrefix` 提示词正文、
|
|
5
|
+
* `proxyPort` 安装代理端口、`mcpEnabled` / `skillEnabled` / `reverseSkillEnabled`
|
|
6
|
+
* 三个能力开关),其余字段属部署方平面不进卡片;命名空间值是整行配置的脱敏视图,
|
|
7
|
+
* 读取时按字段收窄:值缺席或类型不符一律回落默认(提示词来源 `default`、代理 0、
|
|
8
|
+
* 开关 true)。
|
|
8
9
|
*
|
|
9
10
|
* 代理端口以文本承载:越界/非法不静默改写,标 `invalid` 并禁用保存(见 card.tsx),
|
|
10
11
|
* 避免「输入 99999 被悄悄存成 65535」这类静默数据损坏。
|
|
11
12
|
* @module agent-preset-rea/client/draft
|
|
12
13
|
*/
|
|
14
|
+
import type { PersonaPrefixMode } from '../persona-prefix.ts'
|
|
13
15
|
|
|
14
16
|
/** 命名空间解析值中本卡片消费的部分。 */
|
|
15
17
|
export interface ConfigValue {
|
|
18
|
+
personaPrefixMode?: unknown
|
|
16
19
|
personaPrefix?: unknown
|
|
17
20
|
proxyPort?: unknown
|
|
18
21
|
mcpEnabled?: unknown
|
|
@@ -22,6 +25,8 @@ export interface ConfigValue {
|
|
|
22
25
|
|
|
23
26
|
/** 编辑草稿。 */
|
|
24
27
|
export interface Draft {
|
|
28
|
+
/** persona 前缀来源:`default` = 随包内置,`custom` = 取下面的用户文本。 */
|
|
29
|
+
personaPrefixMode: PersonaPrefixMode
|
|
25
30
|
personaPrefix: string
|
|
26
31
|
/** 代理端口文本(空串与 `'0'` 都表示不用代理)。 */
|
|
27
32
|
proxyPort: string
|
|
@@ -36,12 +41,18 @@ function boolOf(value: unknown, fallback: boolean): boolean {
|
|
|
36
41
|
return typeof value === 'boolean' ? value : fallback
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
/** 模式收窄:只认两个字面量,其余(含缺席与旧配置)回落 `default`。 */
|
|
45
|
+
function modeOf(value: unknown): PersonaPrefixMode {
|
|
46
|
+
return value === 'custom' ? 'custom' : 'default'
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
/** 代理端口上限。 */
|
|
40
50
|
export const PROXY_PORT_MAX = 65535
|
|
41
51
|
|
|
42
52
|
/** 解析值 → 草稿(类型不符一律回落默认)。 */
|
|
43
53
|
export function draftFromValue(value: ConfigValue): Draft {
|
|
44
54
|
return {
|
|
55
|
+
personaPrefixMode: modeOf(value.personaPrefixMode),
|
|
45
56
|
personaPrefix: typeof value.personaPrefix === 'string' ? value.personaPrefix : '',
|
|
46
57
|
proxyPort: typeof value.proxyPort === 'number' ? String(value.proxyPort) : '',
|
|
47
58
|
mcpEnabled: boolOf(value.mcpEnabled, true),
|
|
@@ -65,6 +76,7 @@ export function parseProxyPort(text: string): number | null {
|
|
|
65
76
|
/** 草稿 → 提交形状(只回写本卡片负责的字段)。 */
|
|
66
77
|
export function toPatch(draft: Draft): Record<string, unknown> {
|
|
67
78
|
return {
|
|
79
|
+
personaPrefixMode: draft.personaPrefixMode,
|
|
68
80
|
personaPrefix: draft.personaPrefix,
|
|
69
81
|
proxyPort: parseProxyPort(draft.proxyPort) ?? 0,
|
|
70
82
|
mcpEnabled: draft.mcpEnabled,
|
package/src/client/i18n.ts
CHANGED
|
@@ -9,13 +9,21 @@ export const NS = 'dsh-plus-agent-preset-rea'
|
|
|
9
9
|
|
|
10
10
|
const ownZh = {
|
|
11
11
|
title: '逆向工程预设',
|
|
12
|
-
description:
|
|
12
|
+
description:
|
|
13
|
+
'REA 提示词与安装维护:提示词默认取随包内置文本,也可切到自定义;工具指引与运行时上下文照常注入。',
|
|
13
14
|
summaryLine: '编辑「逆向工程」预设的提示词、开关 REA MCP 与两类 skill,并安装/更新',
|
|
14
15
|
prompt: '系统提示词(persona 前缀)',
|
|
16
|
+
promptMode: '提示词来源',
|
|
17
|
+
promptModeDefault: '随包默认',
|
|
18
|
+
promptModeCustom: '自定义',
|
|
15
19
|
promptHint:
|
|
16
|
-
'写入 system-prompt 的 persona
|
|
20
|
+
'写入 system-prompt 的 persona 前缀段(order 0,早于全部工具指引),仅对「逆向工程」预设的新会话生效。默认取随包内置文本;选「自定义」才用下面输入框的正文。官方工具指引、项目指令与运行时上下文不受影响。保存后新建会话即用新值。',
|
|
21
|
+
promptDefaultHint: '当前使用随包默认:下方为只读预览,切到「自定义」可改写正文。',
|
|
22
|
+
promptLegacyHint: '自定义正文与内置默认不同:「改用随包默认」只改草稿,仍需点保存才生效。',
|
|
23
|
+
promptResetToDefault: '改用随包默认',
|
|
24
|
+
promptChars: '内置文本字符数:',
|
|
17
25
|
promptPlaceholder: '例如:先做证据分级,再动手改二进制;每一步给出可复核的证据链……',
|
|
18
|
-
promptEmpty: '
|
|
26
|
+
promptEmpty: '正文为空:保存后会回落随包内置文本,不会注入空 persona。',
|
|
19
27
|
saveFailed: '保存失败:',
|
|
20
28
|
|
|
21
29
|
installSection: 'REA 安装与更新',
|
|
@@ -87,14 +95,24 @@ const ownZh = {
|
|
|
87
95
|
const ownEn = {
|
|
88
96
|
title: 'Reverse-engineering preset',
|
|
89
97
|
description:
|
|
90
|
-
'REA prompt and installation:
|
|
98
|
+
'REA prompt and installation: the prompt defaults to the bundled text and can be switched to custom; tool guidance and runtime context stay in place.',
|
|
91
99
|
summaryLine: 'Edit the “逆向工程” prompt, toggle REA MCP/skills, install and update them',
|
|
92
100
|
prompt: 'System prompt (persona prefix)',
|
|
101
|
+
promptMode: 'Prompt source',
|
|
102
|
+
promptModeDefault: 'Bundled default',
|
|
103
|
+
promptModeCustom: 'Custom',
|
|
93
104
|
promptHint:
|
|
94
|
-
'Written to the persona-prefix section of the system prompt for new sessions of this preset only.
|
|
105
|
+
'Written to the persona-prefix section of the system prompt (order 0, ahead of every tool-guidance section) for new sessions of this preset only. The default is the bundled text; the textarea below is used only in Custom mode. Official tool guidance, project instructions and runtime context are unaffected. New sessions pick up the saved value.',
|
|
106
|
+
promptDefaultHint:
|
|
107
|
+
'Using the bundled default: the preview below is read-only; switch to Custom to rewrite it.',
|
|
108
|
+
promptLegacyHint:
|
|
109
|
+
'The custom text differs from the bundled default; “Use bundled default” only edits the draft — save to apply.',
|
|
110
|
+
promptResetToDefault: 'Use bundled default',
|
|
111
|
+
promptChars: 'Bundled text characters: ',
|
|
95
112
|
promptPlaceholder:
|
|
96
113
|
'e.g. Grade the evidence first, then patch the binary; every step needs a checkable chain of evidence…',
|
|
97
|
-
promptEmpty:
|
|
114
|
+
promptEmpty:
|
|
115
|
+
'Empty body: saving falls back to the bundled text, so no empty persona is injected.',
|
|
98
116
|
saveFailed: 'Save failed: ',
|
|
99
117
|
|
|
100
118
|
installSection: 'REA installation',
|
package/src/client/styles.ts
CHANGED
|
@@ -24,6 +24,14 @@ const extraCss = `
|
|
|
24
24
|
.apr-textarea:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
|
|
25
25
|
.apr-textarea:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
26
26
|
.apr-textarea::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
27
|
+
.apr-textarea:read-only{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}
|
|
28
|
+
.apr-modes{display:flex;gap:6px;margin:0 0 8px}
|
|
29
|
+
.apr-mode{font:inherit;font-size:12px;line-height:20px;padding:2px 10px;border-radius:999px;cursor:pointer;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover);border:1px solid transparent;transition:color .18s,background .18s,border-color .18s}
|
|
30
|
+
.apr-mode:hover:not(:disabled){color:var(--dsw-alias-label-primary)}
|
|
31
|
+
.apr-mode-on{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-brand-primary)}
|
|
32
|
+
.apr-mode:disabled{cursor:default;opacity:.6}
|
|
33
|
+
.apr-link{font:inherit;font-size:12px;padding:0;border:0;background:none;color:var(--dsw-alias-brand-primary);cursor:pointer;text-decoration:underline}
|
|
34
|
+
.apr-link:disabled{cursor:default;opacity:.6}
|
|
27
35
|
.apr-btnRow{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
|
|
28
36
|
.apr-install{margin:6px 0 0;padding:0;display:flex;flex-direction:column;gap:6px}
|
|
29
37
|
.apr-installRow{display:flex;gap:10px;align-items:baseline;flex-wrap:wrap}
|
package/src/config.ts
CHANGED
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* 与 settings 用户层(GUI 配置卡片写入 profile 行级覆盖层,loader 原位提交活动
|
|
6
6
|
* 引用,消费端 `unwrapVolatile` 现取即热)。
|
|
7
7
|
*
|
|
8
|
-
* **活动字段(`.volatile()
|
|
9
|
-
* `
|
|
10
|
-
* `reverseSkillEnabled
|
|
11
|
-
*
|
|
12
|
-
* `cordis.patch.yml` 整体覆盖,GUI 不提供入口。
|
|
8
|
+
* **活动字段(`.volatile()`)共六个**,全部在配置卡片里有编辑器(见 src/client/card.tsx):
|
|
9
|
+
* `personaPrefixMode` / `personaPrefix`(提示词来源与正文)、`proxyPort`(安装代理)、
|
|
10
|
+
* `mcpEnabled` / `skillEnabled` / `reverseSkillEnabled`(三个能力开关)——保存即热更
|
|
11
|
+
* (预设换代,新建会话生效)。其余字段是**部署方平面**(受管目录、版本钉、skill 组、
|
|
12
|
+
* 超时等运维旋钮),由 `cordis.patch.yml` 整体覆盖,GUI 不提供入口。
|
|
13
13
|
*
|
|
14
|
-
* **persona
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* **persona 默认为随包内置提示词**(见 src/persona-prefix.ts):`personaPrefixMode`
|
|
15
|
+
* 默认 `default`,`persona` 行写入内置文本;切到 `custom` 才由 `personaPrefix` 供文本。
|
|
16
|
+
* 该行只遮蔽**部署级 persona 段**(`deployment:persona-prefix`,order 0),官方装配
|
|
17
|
+
* (harness 身份、工具指引、项目指令、运行时上下文)不受影响。
|
|
17
18
|
*
|
|
18
19
|
* 预设 id 固定为 `rea`(注册表身份,不开放覆盖——改 id 等于换预设,
|
|
19
20
|
* default/selectedDefault 等引用都会落空)。
|
|
@@ -24,6 +25,7 @@ import type { UnwrapVolatile } from '@dsh-plus/shared'
|
|
|
24
25
|
|
|
25
26
|
import { INPUT_SCHEMA_PROFILES, OUTPUT_SCHEMA_PROFILES, REA_PINNED_VERSION } from './mcp.ts'
|
|
26
27
|
import { SETTINGS_NS as NS_LITERAL } from './ns.ts'
|
|
28
|
+
import { DEFAULT_PERSONA_PREFIX } from './persona-prefix.ts'
|
|
27
29
|
|
|
28
30
|
/** settings 命名空间(字面量即合法命名空间;配置卡片与运行期读取同一份)。 */
|
|
29
31
|
export const SETTINGS_NS = NS_LITERAL
|
|
@@ -38,16 +40,35 @@ export const Config = z.object({
|
|
|
38
40
|
.string()
|
|
39
41
|
.description('预设说明(设置 → Agent 预设卡片描述)')
|
|
40
42
|
.default(
|
|
41
|
-
'逆向工程预设:官方 standard 全量行 + 仅本预设可见的 REA MCP 客户端(mcp__rea__*)与随包 REA 官方 skill;persona
|
|
43
|
+
'逆向工程预设:官方 standard 全量行 + 仅本预设可见的 REA MCP 客户端(mcp__rea__*)与随包 REA 官方 skill;persona 默认取随包内置提示词,工具指引沿用官方装配。',
|
|
42
44
|
),
|
|
43
45
|
order: z.number().description('预设名册排序位').default(6),
|
|
46
|
+
personaPrefixMode: z
|
|
47
|
+
.union(['default', 'custom'])
|
|
48
|
+
.description(
|
|
49
|
+
'persona 前缀来源:default = 随包内置提示词(src/persona-prefix.ts),custom = 取 personaPrefix 的用户文本',
|
|
50
|
+
)
|
|
51
|
+
.default('default')
|
|
52
|
+
.volatile(),
|
|
44
53
|
personaPrefix: z
|
|
45
54
|
.string()
|
|
46
55
|
.description(
|
|
47
|
-
'persona
|
|
56
|
+
'persona 前缀正文(system-prompt 的 deployment:persona-prefix 段);仅 personaPrefixMode=custom 时生效,空值回落内置提示词',
|
|
48
57
|
)
|
|
49
|
-
.default(
|
|
58
|
+
.default(DEFAULT_PERSONA_PREFIX)
|
|
50
59
|
.volatile(),
|
|
60
|
+
capabilityProtocol: z
|
|
61
|
+
.string()
|
|
62
|
+
.description(
|
|
63
|
+
'追加到 persona 前缀正文末尾的「能力选用协议」段(任务驱动挑选技能与 MCP;部署方平面,空串 = 不追加)',
|
|
64
|
+
)
|
|
65
|
+
.default(''),
|
|
66
|
+
subagentDirective: z
|
|
67
|
+
.string()
|
|
68
|
+
.description(
|
|
69
|
+
'追加到 persona 前缀正文末尾的「子代理指令继承」段(派发 brief 时须浓缩继承本节规则;部署方平面,空串 = 不追加)',
|
|
70
|
+
)
|
|
71
|
+
.default(''),
|
|
51
72
|
mcpEnabled: z
|
|
52
73
|
.boolean()
|
|
53
74
|
.description('是否挂 REA MCP 客户端行(false = 只保留预设其余能力)')
|
package/src/definition.ts
CHANGED
|
@@ -7,12 +7,18 @@
|
|
|
7
7
|
* tests/upstream-mirror.test.ts 会逼出对齐。本预设不丢任何上游行(与 lean 相反)。
|
|
8
8
|
*
|
|
9
9
|
* 增量仅三处,测试按 {@link ADDED_ROWS} / {@link CONFIG_DELTAS} 白名单放行:
|
|
10
|
-
* 1. `persona` 行 `prefix`
|
|
10
|
+
* 1. `persona` 行 `prefix` 取 `resolvePersonaPrefix()`(默认随包内置提示词;
|
|
11
|
+
* `personaPrefixMode=custom` 时才取用户文本);
|
|
11
12
|
* 2. `skill-filesystem` 行加 `customSkillDirs`(REA skill 源与 reverse-skill 技能组,
|
|
12
13
|
* 各受一个活动开关控制,另加部署方 `extraSkillDirs`);
|
|
13
14
|
* 3. 新增 `mcp-rea` 行:官方 MCP 客户端连 REA stdio 服务,落在本预设作用域内;
|
|
14
15
|
* **未安装 REA 时该行 `disabled`**(不 spawn npx,见 mcp.ts 的说明)。
|
|
15
16
|
*
|
|
17
|
+
* 注入点固定在 `persona` 行:官方 `dsh-persona` 为该行注册 `deployment:persona-prefix`
|
|
18
|
+
* 段(order 0,早于全部工具指引段),且 README 明确这一行是 preset 改身份的**唯一**
|
|
19
|
+
* 入口——部署级 `system-prompt` 行归宿主平面,本预设不挂、也挂不上(作用域外挂载会与
|
|
20
|
+
* 注册表自身的 persona 注册相撞并报错)。
|
|
21
|
+
*
|
|
16
22
|
* {@link RuntimeSnapshot} 是运行期事实(受管安装与 skill 来源),由 manager 现探后
|
|
17
23
|
* 传入;不传即「未安装 + 随包 skill」,测试据此断言两种形态。
|
|
18
24
|
*
|
|
@@ -24,6 +30,7 @@ import type { PresetDefinition } from '@deepseek-ai/dsh-agent-preset-registry'
|
|
|
24
30
|
import type { AgentPresetReaConfig } from './config.ts'
|
|
25
31
|
import type { RuntimeSnapshot } from './manager.ts'
|
|
26
32
|
import { DEFAULT_MCP_COMMAND, reaMcpArgs, reaMcpEnv, reaMcpLaunch } from './mcp.ts'
|
|
33
|
+
import { resolvePersonaPrefix } from './persona-prefix.ts'
|
|
27
34
|
import { PLAN_MODE_SECTION } from './prompt.ts'
|
|
28
35
|
import { emptyReverseState } from './reverse.ts'
|
|
29
36
|
import { BUNDLED_SKILL_ROOT, presetSkillDirs } from './skill.ts'
|
|
@@ -34,6 +41,9 @@ export const REA_PRESET_ID = 'rea'
|
|
|
34
41
|
/** 相对上游 `standard` 新增的行 id(镜像测试按此白名单放行自造行)。 */
|
|
35
42
|
export const ADDED_ROWS: readonly string[] = ['mcp-rea']
|
|
36
43
|
|
|
44
|
+
/** 声明必须具备的组行 id(缺一即注册前失败,见 {@link assertRequiredRows})。 */
|
|
45
|
+
const REQUIRED_GROUP_ROWS: readonly string[] = ['planning', 'compaction', 'delegation']
|
|
46
|
+
|
|
37
47
|
/**
|
|
38
48
|
* 已镜像行 → 允许偏离上游的字段名(其余字段必须逐字一致)。
|
|
39
49
|
* 删除某条等于把该行改回上游原文;改动上游不存在的字段会被测试拦下。
|
|
@@ -43,6 +53,25 @@ export const CONFIG_DELTAS: Readonly<Record<string, readonly string[]>> = {
|
|
|
43
53
|
'skill-filesystem': ['customSkillDirs'],
|
|
44
54
|
}
|
|
45
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 最小(或极简)预设 id 判定:命中时注入文本需做减法适配。
|
|
58
|
+
*
|
|
59
|
+
* 判定面与上游预设命名惯例一致(`minimal` / `sdk-minimal` / `<x>/minimal` /
|
|
60
|
+
* 含 `preset-minimal`),不引入自造 id 概念。
|
|
61
|
+
*/
|
|
62
|
+
export function isMinimalPresetId(id: string | undefined): boolean {
|
|
63
|
+
const value = String(id ?? '')
|
|
64
|
+
.trim()
|
|
65
|
+
.toLowerCase()
|
|
66
|
+
if (value === '') return false
|
|
67
|
+
return (
|
|
68
|
+
value === 'minimal' ||
|
|
69
|
+
value === 'sdk-minimal' ||
|
|
70
|
+
value.endsWith('/minimal') ||
|
|
71
|
+
value.includes('preset-minimal')
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
46
75
|
/** 平台门控表达式:与上游 `standard` 预设逐字相同,Windows 上由 pwsh 顶替 bash。 */
|
|
47
76
|
const WINDOWS_ONLY = { __jsExpr: "process.platform === 'win32'" } as const
|
|
48
77
|
const POSIX_ONLY = { __jsExpr: "process.platform !== 'win32'" } as const
|
|
@@ -73,12 +102,13 @@ type Row = PresetDefinition['plugins'][number]
|
|
|
73
102
|
*/
|
|
74
103
|
function baseRows(config: AgentPresetReaConfig, runtime: RuntimeSnapshot): Row[] {
|
|
75
104
|
return [
|
|
76
|
-
// 身份:沿用官方装配(非 complete
|
|
77
|
-
//
|
|
105
|
+
// 身份:沿用官方装配(非 complete、保留运行时上下文)。前缀来源见
|
|
106
|
+
// resolvePersonaPrefix:默认随包内置提示词,custom 模式才取用户文本。
|
|
107
|
+
// 该行注册 deployment:persona-prefix 段(order 0),遮蔽部署级 persona 而不动工具指引。
|
|
78
108
|
{
|
|
79
109
|
id: 'persona',
|
|
80
110
|
name: '@deepseek-ai/dsh-persona',
|
|
81
|
-
config: { prefix: config
|
|
111
|
+
config: { prefix: resolvePersonaPrefix(config) },
|
|
82
112
|
},
|
|
83
113
|
// 项目指令(AGENTS.md)与逐步时钟上下文(默认 10 分钟一条)。
|
|
84
114
|
{
|
|
@@ -220,11 +250,28 @@ function orchestrationRows(config: AgentPresetReaConfig, runtime: RuntimeSnapsho
|
|
|
220
250
|
},
|
|
221
251
|
},
|
|
222
252
|
{ id: 'present', name: '@deepseek-ai/dsh-tool-present' },
|
|
223
|
-
//
|
|
253
|
+
// 宿主插件管理与插件市场:上游 standard 里同样是 disabled 行。
|
|
224
254
|
{ id: 'tool-plugin-manager', name: '@deepseek-ai/dsh-plugin-manager/tools', disabled: true },
|
|
255
|
+
{ id: 'tool-plugin-market', name: '@deepseek-ai/dsh-plugin-market/tools', disabled: true },
|
|
225
256
|
]
|
|
226
257
|
}
|
|
227
258
|
|
|
259
|
+
/**
|
|
260
|
+
* 声明必备行自检:功能面缺行时在注册前失败,而不是静默少能力。
|
|
261
|
+
*
|
|
262
|
+
* 与 tests/upstream-mirror.test.ts 的分工:夹具测试守「偏离上游」,
|
|
263
|
+
* 这里守「本预设必须自带的组行与增量行」——上游升版把某组行改名或
|
|
264
|
+
* 本文件误删一行时,注册表挂载前就能看到明确错误。
|
|
265
|
+
* @param rows - 展开前后的顶层行清单。
|
|
266
|
+
*/
|
|
267
|
+
function assertRequiredRows(rows: readonly Row[]): void {
|
|
268
|
+
const ids = new Set(rows.map((row) => String(row.id)))
|
|
269
|
+
const missing = [...REQUIRED_GROUP_ROWS, ...ADDED_ROWS].filter((id) => !ids.has(id))
|
|
270
|
+
if (missing.length > 0) {
|
|
271
|
+
throw new Error(`rea 预设声明缺少必备行:${missing.join(', ')}`)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
228
275
|
/**
|
|
229
276
|
* 由配置 + 运行期事实拼出注册表声明。
|
|
230
277
|
* @param config - 已验证的插件配置。
|
|
@@ -235,11 +282,13 @@ export function reaPresetDefinition(
|
|
|
235
282
|
config: AgentPresetReaConfig,
|
|
236
283
|
runtime: RuntimeSnapshot = emptyRuntime(),
|
|
237
284
|
): PresetDefinition {
|
|
285
|
+
const plugins = [...baseRows(config, runtime), ...orchestrationRows(config, runtime)]
|
|
286
|
+
assertRequiredRows(plugins)
|
|
238
287
|
return {
|
|
239
288
|
id: REA_PRESET_ID,
|
|
240
289
|
name: config.name,
|
|
241
290
|
description: config.description,
|
|
242
291
|
order: config.order,
|
|
243
|
-
plugins
|
|
292
|
+
plugins,
|
|
244
293
|
}
|
|
245
294
|
}
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ export {
|
|
|
63
63
|
ADDED_ROWS,
|
|
64
64
|
CONFIG_DELTAS,
|
|
65
65
|
emptyRuntime,
|
|
66
|
+
isMinimalPresetId,
|
|
66
67
|
REA_PRESET_ID,
|
|
67
68
|
reaPresetDefinition,
|
|
68
69
|
} from './definition.ts'
|
|
@@ -122,6 +123,22 @@ export {
|
|
|
122
123
|
reaMcpEnv,
|
|
123
124
|
reaMcpLaunch,
|
|
124
125
|
} from './mcp.ts'
|
|
126
|
+
export {
|
|
127
|
+
appendPersonaExtensions,
|
|
128
|
+
DEFAULT_PERSONA_PREFIX,
|
|
129
|
+
DEFAULT_PERSONA_PREFIX_BYTES,
|
|
130
|
+
DEFAULT_PERSONA_PREFIX_HASH,
|
|
131
|
+
DEFAULT_PERSONA_PREFIX_LENGTH,
|
|
132
|
+
DEFAULT_PERSONA_PREFIX_PREVIEW,
|
|
133
|
+
normalizedDefaultPersonaPrefix,
|
|
134
|
+
normalizePersonaPrefix,
|
|
135
|
+
type PersonaPrefixChoice,
|
|
136
|
+
type PersonaPrefixExtensions,
|
|
137
|
+
type PersonaPrefixMode,
|
|
138
|
+
PREFIX_ENVELOPE_LINE,
|
|
139
|
+
REQUIRED_PREFIX_SECTIONS,
|
|
140
|
+
resolvePersonaPrefix,
|
|
141
|
+
} from './persona-prefix.ts'
|
|
125
142
|
export { PLAN_MODE_SECTION } from './prompt.ts'
|
|
126
143
|
export { createPresetRegistrar, type PresetRegistrar, type Unregister } from './registration.ts'
|
|
127
144
|
export {
|