principles-disciple 1.28.1 → 1.28.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.
Files changed (101) hide show
  1. package/openclaw.plugin.json +4 -4
  2. package/package.json +1 -1
  3. package/src/commands/archive-impl.ts +3 -0
  4. package/src/commands/context.ts +4 -0
  5. package/src/commands/disable-impl.ts +2 -0
  6. package/src/commands/evolution-status.ts +2 -0
  7. package/src/commands/focus.ts +4 -0
  8. package/src/commands/nocturnal-train.ts +9 -1
  9. package/src/commands/pain.ts +3 -0
  10. package/src/commands/pd-reflect.ts +2 -0
  11. package/src/commands/principle-rollback.ts +1 -0
  12. package/src/commands/rollback-impl.ts +5 -0
  13. package/src/commands/rollback.ts +2 -1
  14. package/src/commands/samples.ts +1 -0
  15. package/src/commands/workflow-debug.ts +1 -0
  16. package/src/core/adaptive-thresholds.ts +2 -0
  17. package/src/core/code-implementation-storage.ts +2 -0
  18. package/src/core/config.ts +1 -0
  19. package/src/core/diagnostician-task-store.ts +2 -0
  20. package/src/core/dictionary.ts +1 -0
  21. package/src/core/empathy-keyword-matcher.ts +4 -0
  22. package/src/core/event-log.ts +6 -1
  23. package/src/core/evolution-engine.ts +4 -0
  24. package/src/core/evolution-logger.ts +1 -0
  25. package/src/core/external-training-contract.ts +2 -0
  26. package/src/core/focus-history.ts +15 -0
  27. package/src/core/init.ts +3 -0
  28. package/src/core/merge-gate-audit.ts +3 -0
  29. package/src/core/model-deployment-registry.ts +1 -0
  30. package/src/core/model-training-registry.ts +1 -0
  31. package/src/core/nocturnal-arbiter.ts +4 -0
  32. package/src/core/nocturnal-candidate-scoring.ts +5 -0
  33. package/src/core/nocturnal-compliance.ts +22 -0
  34. package/src/core/nocturnal-dataset.ts +3 -0
  35. package/src/core/nocturnal-executability.ts +1 -0
  36. package/src/core/nocturnal-export.ts +5 -0
  37. package/src/core/nocturnal-reasoning-deriver.ts +6 -0
  38. package/src/core/nocturnal-rule-implementation-validator.ts +1 -0
  39. package/src/core/nocturnal-snapshot-contract.ts +1 -0
  40. package/src/core/nocturnal-trinity.ts +24 -0
  41. package/src/core/pain-context-extractor.ts +3 -0
  42. package/src/core/pain.ts +3 -0
  43. package/src/core/pd-task-reconciler.ts +3 -0
  44. package/src/core/pd-task-service.ts +1 -0
  45. package/src/core/pd-task-store.ts +1 -0
  46. package/src/core/principle-internalization/deprecated-readiness.ts +2 -0
  47. package/src/core/principle-internalization/principle-lifecycle-service.ts +1 -0
  48. package/src/core/principle-training-state.ts +2 -0
  49. package/src/core/principle-tree-ledger.ts +4 -0
  50. package/src/core/principle-tree-migration.ts +2 -0
  51. package/src/core/promotion-gate.ts +7 -1
  52. package/src/core/replay-engine.ts +10 -0
  53. package/src/core/risk-calculator.ts +2 -0
  54. package/src/core/rule-host.ts +3 -0
  55. package/src/core/session-tracker.ts +5 -0
  56. package/src/core/shadow-observation-registry.ts +1 -0
  57. package/src/core/thinking-models.ts +1 -0
  58. package/src/core/thinking-os-parser.ts +1 -0
  59. package/src/core/trajectory.ts +9 -1
  60. package/src/hooks/bash-risk.ts +2 -0
  61. package/src/hooks/edit-verification.ts +3 -0
  62. package/src/hooks/gate-block-helper.ts +3 -0
  63. package/src/hooks/gate.ts +8 -0
  64. package/src/hooks/gfi-gate.ts +2 -0
  65. package/src/hooks/lifecycle-routing.ts +1 -0
  66. package/src/hooks/lifecycle.ts +1 -0
  67. package/src/hooks/llm.ts +1 -0
  68. package/src/hooks/pain.ts +3 -0
  69. package/src/hooks/progressive-trust-gate.ts +3 -0
  70. package/src/hooks/prompt.ts +5 -1
  71. package/src/hooks/subagent.ts +1 -0
  72. package/src/hooks/thinking-checkpoint.ts +1 -0
  73. package/src/hooks/trajectory-collector.ts +2 -0
  74. package/src/http/principles-console-route.ts +5 -0
  75. package/src/index.ts +7 -0
  76. package/src/service/central-database.ts +2 -0
  77. package/src/service/central-health-service.ts +1 -0
  78. package/src/service/central-overview-service.ts +2 -0
  79. package/src/service/central-sync-service.ts +1 -0
  80. package/src/service/control-ui-query-service.ts +2 -0
  81. package/src/service/event-log-auditor.ts +2 -0
  82. package/src/service/evolution-query-service.ts +1 -0
  83. package/src/service/evolution-worker.ts +31 -0
  84. package/src/service/health-query-service.ts +6 -1
  85. package/src/service/monitoring-query-service.ts +4 -0
  86. package/src/service/nocturnal-runtime.ts +7 -1
  87. package/src/service/nocturnal-service.ts +21 -0
  88. package/src/service/nocturnal-target-selector.ts +2 -0
  89. package/src/service/runtime-summary-service.ts +6 -0
  90. package/src/service/subagent-workflow/deep-reflect-workflow-manager.ts +2 -0
  91. package/src/service/subagent-workflow/empathy-observer-workflow-manager.ts +2 -0
  92. package/src/service/subagent-workflow/nocturnal-workflow-manager.ts +3 -0
  93. package/src/service/subagent-workflow/subagent-error-utils.ts +1 -0
  94. package/src/service/subagent-workflow/workflow-manager-base.ts +6 -0
  95. package/src/service/subagent-workflow/workflow-store.ts +2 -0
  96. package/src/tools/critique-prompt.ts +1 -0
  97. package/src/tools/deep-reflect.ts +9 -0
  98. package/src/tools/model-index.ts +1 -0
  99. package/src/tools/write-pain-flag.ts +1 -0
  100. package/src/utils/file-lock.ts +1 -0
  101. package/src/utils/io.ts +2 -0
@@ -156,6 +156,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
156
156
  * Subclasses override to add type-specific fields.
157
157
  */
158
158
 
159
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
159
160
  protected createWorkflowMetadata<TResult>(
160
161
  spec: SubagentWorkflowSpec<TResult>,
161
162
  options: {
@@ -182,6 +183,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
182
183
  * Subclasses override to call store.createWorkflow() with type-specific metadata.
183
184
  */
184
185
 
186
+ // eslint-disable-next-line @typescript-eslint/max-params
185
187
  protected async createWorkflowRecord<TResult>(
186
188
  workflowId: string,
187
189
  childSessionKey: string,
@@ -214,6 +216,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
214
216
  // ── Protected Helpers ────────────────────────────────────────────────────
215
217
 
216
218
 
219
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
217
220
  protected buildRunParams<TResult>(
218
221
  spec: SubagentWorkflowSpec<TResult>,
219
222
  options: {
@@ -312,6 +315,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
312
315
  error?: string
313
316
  ): Promise<void> {
314
317
 
318
+ // eslint-disable-next-line @typescript-eslint/init-declarations
315
319
  let workflow;
316
320
  try {
317
321
  workflow = this.store.getWorkflow(workflowId);
@@ -449,6 +453,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
449
453
  }
450
454
  }
451
455
 
456
+
452
457
  async sweepExpiredWorkflows(maxAgeMs?: number): Promise<number> {
453
458
  const ttl = maxAgeMs ?? this.defaultTtlMs;
454
459
  const expired = this.store.getExpiredWorkflows(ttl);
@@ -522,6 +527,7 @@ export abstract class WorkflowManagerBase implements WorkflowManager {
522
527
 
523
528
  // ── Private Helpers ───────────────────────────────────────────────────────
524
529
 
530
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
525
531
  protected generateWorkflowId(): string {
526
532
  // Subclasses override the prefix part via wf_ prefix pattern
527
533
  return `wf_${Date.now()}_${Math.random().toString(36).substring(2, 10)}`;
@@ -233,6 +233,7 @@ export class WorkflowStore {
233
233
  }
234
234
 
235
235
 
236
+ // eslint-disable-next-line @typescript-eslint/max-params
236
237
  recordEvent(
237
238
  workflowId: string,
238
239
  eventType: string,
@@ -269,6 +270,7 @@ export class WorkflowStore {
269
270
  * same idempotency_key already exists, this is a no-op (idempotent).
270
271
  */
271
272
 
273
+ // eslint-disable-next-line @typescript-eslint/max-params
272
274
  recordStageOutput(
273
275
  workflowId: string,
274
276
  stage: 'dreamer' | 'philosopher',
@@ -17,6 +17,7 @@ const DEPTH_INSTRUCTIONS = {
17
17
  * 严格按照测试用例的调用习惯和断言要求进行重写。
18
18
  * 增加 OpenClaw 兼容性路径解析。
19
19
  */
20
+ // eslint-disable-next-line complexity -- complexity 12, refactor candidate
20
21
  export function buildCritiquePromptV2(
21
22
  params: {
22
23
  context: string;
@@ -108,6 +108,7 @@ export function createDeepReflectTool(api: OpenClawPluginApi) {
108
108
  }
109
109
 
110
110
 
111
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
111
112
  const effectiveWorkspaceDir = resolveReflectionWorkspace(api);
112
113
 
113
114
  const config = loadConfig(effectiveWorkspaceDir, api);
@@ -121,9 +122,11 @@ export function createDeepReflectTool(api: OpenClawPluginApi) {
121
122
 
122
123
  try {
123
124
 
125
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
124
126
  return await executeReflectionWorkflow(effectiveWorkspaceDir, config, context, depth, model_id, api);
125
127
  } catch (err) {
126
128
 
129
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
127
130
  return handleReflectionError(err, context, depth, model_id, effectiveWorkspaceDir, api);
128
131
  }
129
132
  }
@@ -146,6 +149,7 @@ function resolveReflectionWorkspace(api: OpenClawPluginApi): string {
146
149
  * Execute the deep reflection workflow: start, poll, collect results.
147
150
  */
148
151
 
152
+ // eslint-disable-next-line @typescript-eslint/max-params
149
153
  async function executeReflectionWorkflow(
150
154
  effectiveWorkspaceDir: string,
151
155
  config: DeepReflectionConfig,
@@ -177,6 +181,7 @@ async function executeReflectionWorkflow(
177
181
  const startTime = Date.now();
178
182
  const timeoutMs = config.timeout_ms ?? 60000;
179
183
 
184
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
180
185
  return await pollReflectionCompletion(manager, handle, timeoutMs, startTime, eventLog, effectiveWorkspaceDir, context, model_id, depth);
181
186
  } finally {
182
187
  manager.dispose();
@@ -187,6 +192,7 @@ async function executeReflectionWorkflow(
187
192
  * Poll the reflection workflow until completion, timeout, or error.
188
193
  */
189
194
 
195
+ // eslint-disable-next-line @typescript-eslint/max-params
190
196
  async function pollReflectionCompletion(
191
197
  manager: DeepReflectWorkflowManager,
192
198
  handle: { workflowId: string; childSessionKey: string },
@@ -207,6 +213,7 @@ async function pollReflectionCompletion(
207
213
 
208
214
  if (workflowState === 'completed') {
209
215
 
216
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
210
217
  return formatReflectionSuccess(handle, context, depth, model_id, startTime, eventLog, workspaceDir);
211
218
  }
212
219
 
@@ -222,6 +229,7 @@ async function pollReflectionCompletion(
222
229
  * Format the success response from a completed reflection.
223
230
  */
224
231
 
232
+ // eslint-disable-next-line @typescript-eslint/max-params
225
233
  function formatReflectionSuccess(
226
234
  handle: { childSessionKey: string },
227
235
  context: string,
@@ -275,6 +283,7 @@ ${insights || '反思完成,详见 REFLECTION_LOG。'}
275
283
  * Handle reflection errors and format error response.
276
284
  */
277
285
 
286
+ // eslint-disable-next-line @typescript-eslint/max-params
278
287
  function handleReflectionError(
279
288
  err: unknown,
280
289
  context: string,
@@ -62,6 +62,7 @@ export function loadModelIndex(
62
62
  const customConfig = loadCustomConfig(wctx);
63
63
 
64
64
 
65
+ // eslint-disable-next-line @typescript-eslint/init-declarations
65
66
  let modelsDir: string;
66
67
  if (customConfig?.modelsDir) {
67
68
  modelsDir = path.isAbsolute(customConfig.modelsDir)
@@ -1,5 +1,6 @@
1
1
  import type { OpenClawPluginApi } from '../openclaw-sdk.js';
2
2
  import { Type } from '@sinclair/typebox';
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
4
  import { buildPainFlag, writePainFlag } from '../core/pain.js';
4
5
  import { resolveWorkspaceDirFromApi } from '../core/path-resolver.js';
5
6
  import * as fs from 'fs';
@@ -335,6 +335,7 @@ export async function withAsyncLock<T>(
335
335
 
336
336
  // 创建新的 Promise 链
337
337
 
338
+ // eslint-disable-next-line @typescript-eslint/init-declarations
338
339
  let resolveRelease: () => void;
339
340
  const releasePromise = new Promise<void>(resolve => {
340
341
  resolveRelease = resolve;
package/src/utils/io.ts CHANGED
@@ -2,6 +2,7 @@ import * as path from 'path';
2
2
  import * as fs from 'fs';
3
3
  import { resolvePdPath } from '../core/paths.js';
4
4
 
5
+
5
6
  export function normalizePath(filePath: string, projectDir: string): string {
6
7
  if (!filePath) return '';
7
8
 
@@ -17,6 +18,7 @@ export function normalizePath(filePath: string, projectDir: string): string {
17
18
  }
18
19
 
19
20
 
21
+ // eslint-disable-next-line @typescript-eslint/init-declarations
20
22
  let rel: string;
21
23
  if (projectIsWin) {
22
24
  const projectAbs = path.resolve(projectDir);