principles-disciple 1.6.0 → 1.7.1
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/commands/context.js +7 -3
- package/dist/commands/evolution-status.d.ts +4 -0
- package/dist/commands/evolution-status.js +134 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +45 -0
- package/dist/commands/focus.js +9 -6
- package/dist/commands/pain.js +8 -0
- package/dist/commands/principle-rollback.d.ts +4 -0
- package/dist/commands/principle-rollback.js +22 -0
- package/dist/commands/rollback.js +9 -3
- package/dist/commands/samples.d.ts +2 -0
- package/dist/commands/samples.js +55 -0
- package/dist/commands/trust.js +64 -81
- package/dist/core/config.d.ts +5 -0
- package/dist/core/control-ui-db.d.ts +68 -0
- package/dist/core/control-ui-db.js +274 -0
- package/dist/core/detection-funnel.d.ts +1 -1
- package/dist/core/detection-funnel.js +4 -0
- package/dist/core/dictionary.d.ts +2 -0
- package/dist/core/dictionary.js +13 -0
- package/dist/core/event-log.d.ts +7 -1
- package/dist/core/event-log.js +10 -0
- package/dist/core/evolution-engine.d.ts +5 -5
- package/dist/core/evolution-engine.js +18 -18
- package/dist/core/evolution-migration.d.ts +5 -0
- package/dist/core/evolution-migration.js +65 -0
- package/dist/core/evolution-reducer.d.ts +69 -0
- package/dist/core/evolution-reducer.js +369 -0
- package/dist/core/evolution-types.d.ts +103 -0
- package/dist/core/path-resolver.js +75 -36
- package/dist/core/paths.d.ts +7 -8
- package/dist/core/paths.js +48 -40
- package/dist/core/profile.js +1 -1
- package/dist/core/session-tracker.d.ts +14 -2
- package/dist/core/session-tracker.js +75 -9
- package/dist/core/thinking-models.d.ts +38 -0
- package/dist/core/thinking-models.js +170 -0
- package/dist/core/trajectory.d.ts +184 -0
- package/dist/core/trajectory.js +817 -0
- package/dist/core/trust-engine.d.ts +6 -0
- package/dist/core/trust-engine.js +50 -29
- package/dist/core/workspace-context.d.ts +13 -0
- package/dist/core/workspace-context.js +50 -7
- package/dist/hooks/gate.js +171 -87
- package/dist/hooks/llm.js +119 -71
- package/dist/hooks/pain.js +105 -5
- package/dist/hooks/prompt.d.ts +11 -14
- package/dist/hooks/prompt.js +283 -57
- package/dist/hooks/subagent.js +69 -28
- package/dist/hooks/trajectory-collector.d.ts +32 -0
- package/dist/hooks/trajectory-collector.js +256 -0
- package/dist/http/principles-console-route.d.ts +2 -0
- package/dist/http/principles-console-route.js +257 -0
- package/dist/i18n/commands.js +16 -0
- package/dist/index.js +105 -4
- package/dist/service/control-ui-query-service.d.ts +217 -0
- package/dist/service/control-ui-query-service.js +537 -0
- package/dist/service/empathy-observer-manager.d.ts +2 -0
- package/dist/service/empathy-observer-manager.js +43 -1
- package/dist/service/evolution-worker.d.ts +27 -0
- package/dist/service/evolution-worker.js +256 -41
- package/dist/service/runtime-summary-service.d.ts +79 -0
- package/dist/service/runtime-summary-service.js +319 -0
- package/dist/service/trajectory-service.d.ts +2 -0
- package/dist/service/trajectory-service.js +15 -0
- package/dist/tools/agent-spawn.d.ts +27 -6
- package/dist/tools/agent-spawn.js +339 -87
- package/dist/tools/deep-reflect.d.ts +27 -7
- package/dist/tools/deep-reflect.js +210 -121
- package/dist/types/event-types.d.ts +10 -2
- package/dist/types.d.ts +10 -0
- package/dist/types.js +5 -0
- package/openclaw.plugin.json +43 -11
- package/package.json +14 -4
- package/templates/langs/zh/skills/pd-daily/SKILL.md +97 -13
|
@@ -112,105 +112,176 @@ function loadConfig(workspaceDir, api) {
|
|
|
112
112
|
}
|
|
113
113
|
return DEFAULT_CONFIG;
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Helper to read string parameter from rawParams
|
|
117
|
+
* Supports both camelCase and snake_case parameter names
|
|
118
|
+
*/
|
|
119
|
+
function readStringParam(rawParams, key) {
|
|
120
|
+
const value = rawParams[key];
|
|
121
|
+
if (typeof value === 'string')
|
|
122
|
+
return value.trim() || undefined;
|
|
123
|
+
// Try snake_case alias
|
|
124
|
+
const snakeKey = key.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
125
|
+
const snakeValue = rawParams[snakeKey];
|
|
126
|
+
if (typeof snakeValue === 'string')
|
|
127
|
+
return snakeValue.trim() || undefined;
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper to read number parameter from rawParams
|
|
132
|
+
* Supports both camelCase and snake_case parameter names
|
|
133
|
+
*/
|
|
134
|
+
function readNumberParam(rawParams, key) {
|
|
135
|
+
const value = rawParams[key];
|
|
136
|
+
if (typeof value === 'number')
|
|
137
|
+
return value;
|
|
138
|
+
// Try snake_case alias
|
|
139
|
+
const snakeKey = key.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
140
|
+
const snakeValue = rawParams[snakeKey];
|
|
141
|
+
if (typeof snakeValue === 'number')
|
|
142
|
+
return snakeValue;
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create Deep Reflect Tool
|
|
147
|
+
*
|
|
148
|
+
* Uses factory pattern to capture `api` in closure, following OpenClaw plugin SDK conventions.
|
|
149
|
+
* The execute signature must be: async (_toolCallId: string, rawParams: Record<string, unknown>)
|
|
150
|
+
*/
|
|
151
|
+
export function createDeepReflectTool(api) {
|
|
152
|
+
return {
|
|
153
|
+
name: 'deep_reflect',
|
|
154
|
+
description: '执行深层次的元认知反思,分析当前任务的潜在风险、逻辑漏洞或架构改进点。',
|
|
155
|
+
parameters: Type.Object({
|
|
156
|
+
context: Type.String({ description: '需要反思的任务上下文、代码片段或当前遇到的困难。' }),
|
|
157
|
+
depth: Type.Optional(Type.Number({ description: '反思深度 (1-3)。1: 快速扫描, 2: 均衡分析, 3: 彻底解构。默认为 2。', minimum: 1, maximum: 3 })),
|
|
158
|
+
model_id: Type.Optional(Type.String({ description: '可选:强制指定使用的思维模型 ID。' }))
|
|
159
|
+
}),
|
|
160
|
+
/**
|
|
161
|
+
* Tool execution logic
|
|
162
|
+
*
|
|
163
|
+
* OpenClaw tool execute signature:
|
|
164
|
+
* - First parameter: _toolCallId (string) - the tool call ID
|
|
165
|
+
* - Second parameter: rawParams (Record<string, unknown>) - the actual parameters
|
|
166
|
+
* - Third parameter (optional): signal (AbortSignal) - for cancellation
|
|
167
|
+
*/
|
|
168
|
+
async execute(_toolCallId, rawParams) {
|
|
169
|
+
const context = readStringParam(rawParams, 'context') || '';
|
|
170
|
+
const depth = readNumberParam(rawParams, 'depth') ?? 2;
|
|
171
|
+
const model_id = readStringParam(rawParams, 'model_id');
|
|
172
|
+
if (!context) {
|
|
173
|
+
return {
|
|
174
|
+
content: [{
|
|
175
|
+
type: 'text',
|
|
176
|
+
text: '❌ 错误: 必须提供反思上下文 (context)。'
|
|
177
|
+
}]
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// 路径解析优先级:api.config > api.workspaceDir > api.resolvePath
|
|
181
|
+
const effectiveWorkspaceDir = api.config?.workspaceDir
|
|
182
|
+
|| api.workspaceDir
|
|
183
|
+
|| api.resolvePath?.('.');
|
|
184
|
+
if (!effectiveWorkspaceDir) {
|
|
185
|
+
return {
|
|
186
|
+
content: [{
|
|
187
|
+
type: 'text',
|
|
188
|
+
text: '❌ 反思执行失败: Workspace directory is required for deep reflection.。请检查 API 配置或网络连接。'
|
|
189
|
+
}]
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const config = loadConfig(effectiveWorkspaceDir, api);
|
|
193
|
+
if (config.mode === 'disabled' || !config.enabled) {
|
|
194
|
+
return {
|
|
195
|
+
content: [{
|
|
196
|
+
type: 'text',
|
|
197
|
+
text: '⏭️ Deep Reflection 已禁用。'
|
|
198
|
+
}]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (model_id) {
|
|
202
|
+
safeLog(api, 'warn', `[DeepReflect] The 'model_id' parameter is deprecated. The agent will now auto-select models based on the context index.`);
|
|
173
203
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
204
|
+
const agentId = 'main';
|
|
205
|
+
const sessionKey = `agent:${agentId}:reflection:${randomUUID()}`;
|
|
206
|
+
const sessionId = sessionKey.split(':').pop();
|
|
207
|
+
const stateDir = resolvePdPath(effectiveWorkspaceDir, 'STATE_DIR');
|
|
208
|
+
const eventLog = EventLogService.get(stateDir, api.logger);
|
|
209
|
+
try {
|
|
210
|
+
const extraSystemPrompt = buildCritiquePromptV2({
|
|
211
|
+
context,
|
|
212
|
+
depth,
|
|
213
|
+
model_id,
|
|
214
|
+
api,
|
|
215
|
+
workspaceDir: effectiveWorkspaceDir
|
|
216
|
+
});
|
|
217
|
+
const startTime = Date.now();
|
|
218
|
+
const subagentRuntime = api.runtime.subagent;
|
|
219
|
+
if (!subagentRuntime)
|
|
220
|
+
throw new Error('OpenClaw subagent runtime not found.');
|
|
221
|
+
await subagentRuntime.run({
|
|
222
|
+
sessionKey,
|
|
223
|
+
message: `请对我当前的任务进行深层次反思。\n\n上下文:${context}`,
|
|
224
|
+
extraSystemPrompt,
|
|
225
|
+
deliver: false
|
|
226
|
+
});
|
|
227
|
+
const finalStatus = await subagentRuntime.waitForRun({ runId: sessionKey });
|
|
228
|
+
const duration = Date.now() - startTime;
|
|
229
|
+
if (finalStatus.status === 'timeout') {
|
|
230
|
+
return {
|
|
231
|
+
content: [{
|
|
232
|
+
type: 'text',
|
|
233
|
+
text: '⚠️ 反思任务执行超时。你可以尝试减少上下文长度或增加深度。'
|
|
234
|
+
}]
|
|
235
|
+
};
|
|
179
236
|
}
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
insights =
|
|
237
|
+
if (finalStatus.status === 'ok') {
|
|
238
|
+
const rawMessages = await subagentRuntime.getSessionMessages({ sessionKey });
|
|
239
|
+
let insights = '';
|
|
240
|
+
if (rawMessages.assistantTexts && Array.isArray(rawMessages.assistantTexts)) {
|
|
241
|
+
insights = rawMessages.assistantTexts.join('\n');
|
|
185
242
|
}
|
|
186
|
-
else
|
|
187
|
-
|
|
243
|
+
else {
|
|
244
|
+
const messages = rawMessages.messages || [];
|
|
245
|
+
const lastMessage = messages[messages.length - 1];
|
|
246
|
+
if (typeof lastMessage?.content === 'string') {
|
|
247
|
+
insights = lastMessage.content;
|
|
248
|
+
}
|
|
249
|
+
else if (Array.isArray(lastMessage?.content)) {
|
|
250
|
+
insights = lastMessage.content.filter((c) => c.type === 'text').map((c) => c.text).join('\n');
|
|
251
|
+
}
|
|
188
252
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
253
|
+
if (insights.includes('REFLECTION_OK')) {
|
|
254
|
+
return {
|
|
255
|
+
content: [{
|
|
256
|
+
type: 'text',
|
|
257
|
+
text: '✅ 反思完成:当前任务逻辑严密,未发现显著问题。'
|
|
258
|
+
}]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (eventLog && sessionId) {
|
|
262
|
+
eventLog.recordDeepReflection(sessionId, {
|
|
263
|
+
modelId: model_id || 'auto-select',
|
|
264
|
+
modelSelectionMode: model_id ? 'manual' : 'auto',
|
|
265
|
+
depth,
|
|
266
|
+
contextPreview: context.substring(0, 200),
|
|
267
|
+
resultPreview: insights.substring(0, 300),
|
|
268
|
+
durationMs: duration,
|
|
269
|
+
passed: true,
|
|
270
|
+
timeout: false
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
// Write to reflection log and cleanup old entries
|
|
274
|
+
try {
|
|
275
|
+
writeToReflectionLog(effectiveWorkspaceDir, context, insights, model_id, depth);
|
|
276
|
+
cleanupReflectionLog(effectiveWorkspaceDir);
|
|
277
|
+
}
|
|
278
|
+
catch (logErr) {
|
|
279
|
+
safeLog(api, 'warn', `[DeepReflect] Failed to write reflection log: ${String(logErr)}`);
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
content: [{
|
|
283
|
+
type: 'text',
|
|
284
|
+
text: `
|
|
214
285
|
# 💎 Deep Reflection Insights
|
|
215
286
|
---
|
|
216
287
|
**Selected Model(s)**: ${model_id || 'auto-select'}
|
|
@@ -221,34 +292,52 @@ ${insights}
|
|
|
221
292
|
|
|
222
293
|
---
|
|
223
294
|
*Generated by Principles Disciple Meta-Cognitive Engine*
|
|
224
|
-
`.trim()
|
|
295
|
+
`.trim()
|
|
296
|
+
}]
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
throw new Error(`Subagent status: ${finalStatus.status}`);
|
|
301
|
+
}
|
|
225
302
|
}
|
|
226
|
-
|
|
227
|
-
|
|
303
|
+
catch (err) {
|
|
304
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
305
|
+
safeLog(api, 'error', `[DeepReflect] Reflection failed: ${errorMsg}`);
|
|
306
|
+
if (eventLog && sessionId) {
|
|
307
|
+
eventLog.recordDeepReflection(sessionId, {
|
|
308
|
+
modelId: model_id || 'auto-select',
|
|
309
|
+
modelSelectionMode: model_id ? 'manual' : 'auto',
|
|
310
|
+
depth,
|
|
311
|
+
contextPreview: context.substring(0, 200),
|
|
312
|
+
durationMs: 0,
|
|
313
|
+
passed: false,
|
|
314
|
+
timeout: errorMsg.toLowerCase().includes('timeout'),
|
|
315
|
+
error: errorMsg
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (errorMsg === 'API throw')
|
|
319
|
+
throw err;
|
|
320
|
+
return {
|
|
321
|
+
content: [{
|
|
322
|
+
type: 'text',
|
|
323
|
+
text: `❌ 反思执行失败: ${errorMsg}。请检查 API 配置或网络连接。`
|
|
324
|
+
}]
|
|
325
|
+
};
|
|
228
326
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
safeLog(api, 'error', `[DeepReflect] Reflection failed: ${errorMsg}`);
|
|
233
|
-
if (eventLog && sessionId) {
|
|
234
|
-
eventLog.recordDeepReflection(sessionId, {
|
|
235
|
-
modelId: model_id || 'auto-select',
|
|
236
|
-
modelSelectionMode: model_id ? 'manual' : 'auto',
|
|
237
|
-
depth,
|
|
238
|
-
contextPreview: context.substring(0, 200),
|
|
239
|
-
durationMs: 0,
|
|
240
|
-
passed: false,
|
|
241
|
-
timeout: errorMsg.toLowerCase().includes('timeout'),
|
|
242
|
-
error: errorMsg
|
|
243
|
-
});
|
|
327
|
+
finally {
|
|
328
|
+
if (api.runtime.subagent)
|
|
329
|
+
await api.runtime.subagent.deleteSession({ sessionKey }).catch(() => { });
|
|
244
330
|
}
|
|
245
|
-
if (errorMsg === 'API throw')
|
|
246
|
-
throw err;
|
|
247
|
-
return `❌ 反思执行失败: ${errorMsg}。请检查 API 配置或网络连接。`;
|
|
248
|
-
}
|
|
249
|
-
finally {
|
|
250
|
-
if (api.runtime.subagent)
|
|
251
|
-
await api.runtime.subagent.deleteSession({ sessionKey }).catch(() => { });
|
|
252
331
|
}
|
|
253
|
-
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// Legacy export for backward compatibility with tests that call execute directly
|
|
335
|
+
export const deepReflectTool = {
|
|
336
|
+
name: 'deep_reflect',
|
|
337
|
+
description: '执行深层次的元认知反思,分析当前任务的潜在风险、逻辑漏洞或架构改进点。',
|
|
338
|
+
parameters: Type.Object({
|
|
339
|
+
context: Type.String({ description: '需要反思的任务上下文、代码片段或当前遇到的困难。' }),
|
|
340
|
+
depth: Type.Optional(Type.Number({ description: '反思深度 (1-3)。1: 快速扫描, 2: 均衡分析, 3: 彻底解构。默认为 2。', minimum: 1, maximum: 3 })),
|
|
341
|
+
model_id: Type.Optional(Type.String({ description: '可选:强制指定使用的思维模型 ID。' }))
|
|
342
|
+
}),
|
|
254
343
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Event types for structured logging and daily statistics.
|
|
3
3
|
*/
|
|
4
|
-
export type EventType = 'tool_call' | 'pain_signal' | 'rule_match' | 'rule_promotion' | 'hook_execution' | 'gate_block' | 'plan_approval' | 'evolution_task' | 'deep_reflection' | 'trust_change' | 'empathy_rollback' | 'error' | 'warn';
|
|
5
|
-
export type EventCategory = 'success' | 'failure' | 'detected' | 'blocked' | 'approved' | 'enqueued' | 'completed' | 'promoted' | 'passed' | 'changed' | 'rolled_back';
|
|
4
|
+
export type EventType = 'tool_call' | 'pain_signal' | 'rule_match' | 'rule_promotion' | 'hook_execution' | 'gate_block' | 'gate_bypass' | 'plan_approval' | 'evolution_task' | 'deep_reflection' | 'trust_change' | 'empathy_rollback' | 'error' | 'warn';
|
|
5
|
+
export type EventCategory = 'success' | 'failure' | 'detected' | 'blocked' | 'bypassed' | 'approved' | 'enqueued' | 'completed' | 'promoted' | 'passed' | 'changed' | 'rolled_back';
|
|
6
6
|
/**
|
|
7
7
|
* Base event structure for JSONL logging.
|
|
8
8
|
*/
|
|
@@ -40,6 +40,7 @@ export interface ToolCallEventData {
|
|
|
40
40
|
export interface PainSignalEventData {
|
|
41
41
|
score: number;
|
|
42
42
|
source: string;
|
|
43
|
+
eventId?: string;
|
|
43
44
|
reason?: string;
|
|
44
45
|
isRisky?: boolean;
|
|
45
46
|
origin?: 'assistant_self_report' | 'user_manual' | 'system_infer';
|
|
@@ -75,6 +76,13 @@ export interface GateBlockEventData {
|
|
|
75
76
|
reason: string;
|
|
76
77
|
planStatus?: string;
|
|
77
78
|
}
|
|
79
|
+
export interface GateBypassEventData {
|
|
80
|
+
toolName: string;
|
|
81
|
+
filePath: string;
|
|
82
|
+
bypassType: 'stage4_architect' | 'plan_approved' | 'whitelisted';
|
|
83
|
+
trustScore: number;
|
|
84
|
+
trustStage: number;
|
|
85
|
+
}
|
|
78
86
|
export interface PlanApprovalEventData {
|
|
79
87
|
toolName: string;
|
|
80
88
|
filePath: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export type { PluginCommandContext, PluginCommandResult } from './openclaw-sdk.j
|
|
|
7
7
|
* This is by design - principles are the foundation of the agent's behavior.
|
|
8
8
|
*/
|
|
9
9
|
export type ProjectFocusMode = 'full' | 'summary' | 'off';
|
|
10
|
+
export interface EvolutionContextConfig {
|
|
11
|
+
/** Enable conversation context in evolution task (default: true) */
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/** Max recent messages included in evolution task (default: 4) */
|
|
14
|
+
maxMessages: number;
|
|
15
|
+
/** Max chars per message snippet (default: 200) */
|
|
16
|
+
maxCharsPerMessage: number;
|
|
17
|
+
}
|
|
10
18
|
export interface ContextInjectionConfig {
|
|
11
19
|
/** Thinking OS (mental models) - can be toggled */
|
|
12
20
|
thinkingOs: boolean;
|
|
@@ -16,6 +24,8 @@ export interface ContextInjectionConfig {
|
|
|
16
24
|
reflectionLog: boolean;
|
|
17
25
|
/** Trust score awareness - can be toggled */
|
|
18
26
|
trustScore: boolean;
|
|
27
|
+
/** Evolution task context injection settings */
|
|
28
|
+
evolutionContext: EvolutionContextConfig;
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
21
31
|
* Default context injection configuration
|
package/dist/types.js
CHANGED
|
@@ -12,6 +12,11 @@ export const defaultContextConfig = {
|
|
|
12
12
|
projectFocus: 'off',
|
|
13
13
|
reflectionLog: true,
|
|
14
14
|
trustScore: true,
|
|
15
|
+
evolutionContext: {
|
|
16
|
+
enabled: true,
|
|
17
|
+
maxMessages: 4,
|
|
18
|
+
maxCharsPerMessage: 200,
|
|
19
|
+
},
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
22
|
* Reflection log retention configuration
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,27 +2,38 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
|
|
5
|
-
"version": "1.
|
|
6
|
-
"skills": [
|
|
5
|
+
"version": "1.7.1",
|
|
6
|
+
"skills": [
|
|
7
|
+
"./skills"
|
|
8
|
+
],
|
|
7
9
|
"configSchema": {
|
|
8
10
|
"type": "object",
|
|
9
11
|
"additionalProperties": false,
|
|
10
12
|
"properties": {
|
|
11
13
|
"language": {
|
|
12
14
|
"type": "string",
|
|
13
|
-
"enum": [
|
|
15
|
+
"enum": [
|
|
16
|
+
"en",
|
|
17
|
+
"zh"
|
|
18
|
+
],
|
|
14
19
|
"default": "zh",
|
|
15
20
|
"description": "系统提示词和交互语言 (默认推荐: zh)"
|
|
16
21
|
},
|
|
17
22
|
"auditLevel": {
|
|
18
23
|
"type": "string",
|
|
19
|
-
"enum": [
|
|
24
|
+
"enum": [
|
|
25
|
+
"low",
|
|
26
|
+
"medium",
|
|
27
|
+
"high"
|
|
28
|
+
],
|
|
20
29
|
"default": "medium",
|
|
21
30
|
"description": "安全防爆级别:\n- low: 极客模式,几乎不拦截,AI 可以自由飞翔。\n- medium (推荐): 平衡模式,允许 AI 大胆尝试,但拦截毁灭性操作。\n- high: 严格模式,所有大范围修改都需要你明确授权。"
|
|
22
31
|
},
|
|
23
32
|
"riskPaths": {
|
|
24
33
|
"type": "array",
|
|
25
|
-
"items": {
|
|
34
|
+
"items": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
26
37
|
"default": [],
|
|
27
38
|
"description": "自定义高危目录(例如 .git/, prod_db/)。AI 试图修改这些目录前,将被强制拦截并要求出具安全计划。"
|
|
28
39
|
},
|
|
@@ -31,16 +42,37 @@
|
|
|
31
42
|
"additionalProperties": false,
|
|
32
43
|
"description": "当 AI 遇到复杂问题或连续报错时,是否允许它停下来进行深度自我反思?",
|
|
33
44
|
"properties": {
|
|
34
|
-
"enabled": {
|
|
35
|
-
|
|
45
|
+
"enabled": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"default": true,
|
|
48
|
+
"description": "开启 AI 深度反思功能"
|
|
49
|
+
},
|
|
50
|
+
"mode": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"enum": [
|
|
53
|
+
"auto",
|
|
54
|
+
"forced"
|
|
55
|
+
],
|
|
56
|
+
"default": "auto",
|
|
57
|
+
"description": "auto: 遇到困难自动触发; forced: 每次回答前都强制反思(极耗时间,不推荐)"
|
|
58
|
+
}
|
|
36
59
|
}
|
|
37
60
|
}
|
|
38
61
|
}
|
|
39
62
|
},
|
|
40
63
|
"uiHints": {
|
|
41
|
-
"language": {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
64
|
+
"language": {
|
|
65
|
+
"label": "交互语言"
|
|
66
|
+
},
|
|
67
|
+
"auditLevel": {
|
|
68
|
+
"label": "防爆拦截级别",
|
|
69
|
+
"placeholder": "medium"
|
|
70
|
+
},
|
|
71
|
+
"riskPaths": {
|
|
72
|
+
"label": "☠️ 绝对高危目录 (空表示不设限)"
|
|
73
|
+
},
|
|
74
|
+
"deep_reflection": {
|
|
75
|
+
"label": "💡 AI 深度反思功能"
|
|
76
|
+
}
|
|
45
77
|
}
|
|
46
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Native OpenClaw plugin for Principles Disciple",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,17 +33,23 @@
|
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc",
|
|
36
|
-
"build:
|
|
37
|
-
"build:
|
|
36
|
+
"build:web": "node scripts/build-web.mjs",
|
|
37
|
+
"build:bundle": "node esbuild.config.js && node scripts/build-web.mjs",
|
|
38
|
+
"build:production": "tsc && node esbuild.config.js --production && node scripts/build-web.mjs --production",
|
|
38
39
|
"test": "vitest run",
|
|
39
40
|
"postinstall": "node scripts/install-dependencies.cjs"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
43
|
+
"@testing-library/react": "^16.3.0",
|
|
44
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
42
45
|
"@types/micromatch": "^4.0.10",
|
|
43
46
|
"@types/node": "^25.5.0",
|
|
47
|
+
"@types/react": "^19.2.2",
|
|
48
|
+
"@types/react-dom": "^19.2.2",
|
|
44
49
|
"@types/ws": "^8.5.13",
|
|
45
50
|
"@vitest/coverage-v8": "^4.1.0",
|
|
46
51
|
"esbuild": "^0.27.4",
|
|
52
|
+
"jsdom": "^26.1.0",
|
|
47
53
|
"typescript": "^5.0.0",
|
|
48
54
|
"vitest": "^4.1.0",
|
|
49
55
|
"ws": "^8.18.0"
|
|
@@ -58,6 +64,10 @@
|
|
|
58
64
|
},
|
|
59
65
|
"dependencies": {
|
|
60
66
|
"@sinclair/typebox": "^0.34.48",
|
|
61
|
-
"
|
|
67
|
+
"better-sqlite3": "^11.10.0",
|
|
68
|
+
"micromatch": "^4.0.8",
|
|
69
|
+
"react": "^19.2.0",
|
|
70
|
+
"react-dom": "^19.2.0",
|
|
71
|
+
"react-router-dom": "^7.9.4"
|
|
62
72
|
}
|
|
63
73
|
}
|