create-principles-disciple 1.102.0 → 1.104.0

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 (160) hide show
  1. package/console/dist/server/config/pd-config-store.d.ts +50 -1
  2. package/console/dist/server/config/pd-config-store.js +364 -1
  3. package/console/dist/server/models/ActivationsConsoleModel.d.ts +7 -4
  4. package/console/dist/server/models/ActivationsConsoleModel.js +7 -6
  5. package/console/dist/server/routes/config.js +92 -2
  6. package/console/dist/ui/api.d.ts +44 -3
  7. package/console/dist/ui/api.js +58 -2
  8. package/console/dist/ui/components/onboarding/DemoResultView.js +19 -1
  9. package/console/dist/ui/i18n/en.json +63 -2
  10. package/console/dist/ui/i18n/zh-CN.json +63 -2
  11. package/console/dist/ui/pages/activation/ActivationPage.js +11 -11
  12. package/console/dist/ui/pages/activation/ActivationValidators.js +14 -13
  13. package/console/dist/ui/pages/control-center/AgentCard.js +56 -7
  14. package/console/dist/ui/pages/control-center/ControlCenterPage.js +2 -1
  15. package/console/dist/ui/pages/control-center/RuntimeProfileManager.d.ts +31 -0
  16. package/console/dist/ui/pages/control-center/RuntimeProfileManager.js +234 -0
  17. package/console/dist/ui/pages/debt/DebtPage.js +2 -2
  18. package/console/dist/ui/utils/validators.d.ts +26 -3
  19. package/console/dist/ui/utils/validators.js +23 -6
  20. package/console/dist/web/assets/app.css +41 -0
  21. package/console/dist/web/assets/app.js +1918 -1160
  22. package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js +8 -10
  23. package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js.map +1 -1
  24. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts +2 -0
  25. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts.map +1 -0
  26. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js +81 -0
  27. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js.map +1 -0
  28. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +25 -6
  29. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
  30. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +8 -0
  31. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  32. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -1
  33. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  34. package/core/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
  35. package/core/dist/runtime-v2/candidate-intake-service.js +92 -6
  36. package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  37. package/core/dist/runtime-v2/candidate-intake.d.ts +38 -0
  38. package/core/dist/runtime-v2/candidate-intake.d.ts.map +1 -1
  39. package/core/dist/runtime-v2/candidate-intake.js +48 -0
  40. package/core/dist/runtime-v2/candidate-intake.js.map +1 -1
  41. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +26 -1
  42. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
  43. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +9 -5
  44. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  45. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +53 -33
  46. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
  47. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +2 -0
  48. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
  49. package/core/dist/runtime-v2/config/pd-config-agent-binding.js +3 -0
  50. package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
  51. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -3
  52. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  53. package/core/dist/runtime-v2/config/pd-config-defaults.js +27 -3
  54. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  55. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  56. package/core/dist/runtime-v2/config/pd-config-redaction.js +5 -2
  57. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  58. package/core/dist/runtime-v2/config/pd-config-types.d.ts +6 -0
  59. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  60. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  61. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  62. package/core/dist/runtime-v2/config/pd-config-validate.js +11 -6
  63. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  64. package/core/dist/runtime-v2/index.d.ts +2 -1
  65. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  66. package/core/dist/runtime-v2/index.js +1 -0
  67. package/core/dist/runtime-v2/index.js.map +1 -1
  68. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js +7 -0
  69. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js.map +1 -1
  70. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +7 -6
  71. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -1
  72. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +1 -1
  73. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js +4 -4
  74. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -1
  75. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +5 -5
  76. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -1
  77. package/core/dist/runtime-v2/internalization/diag-router-runner.js +4 -4
  78. package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -1
  79. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +2 -0
  80. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  81. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +2 -0
  82. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  83. package/dist/installer.d.ts.map +1 -1
  84. package/dist/installer.js +5 -1
  85. package/dist/installer.js.map +1 -1
  86. package/dist/mvp-config.d.ts.map +1 -1
  87. package/dist/mvp-config.js +22 -10
  88. package/dist/mvp-config.js.map +1 -1
  89. package/package.json +1 -1
  90. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js +2 -2
  91. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js.map +1 -1
  92. package/pd-cli/dist/commands/demo-story-a.d.ts.map +1 -1
  93. package/pd-cli/dist/commands/demo-story-a.js +4 -2
  94. package/pd-cli/dist/commands/demo-story-a.js.map +1 -1
  95. package/pd-cli/dist/commands/proven-channel-baseline.d.ts.map +1 -1
  96. package/pd-cli/dist/commands/proven-channel-baseline.js +4 -2
  97. package/pd-cli/dist/commands/proven-channel-baseline.js.map +1 -1
  98. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  99. package/pd-cli/dist/commands/runtime-activation.js +8 -2
  100. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  101. package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
  102. package/pd-cli/dist/commands/runtime-canary.js +4 -2
  103. package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
  104. package/pd-cli/dist/commands/runtime-health-snapshot.d.ts.map +1 -1
  105. package/pd-cli/dist/commands/runtime-health-snapshot.js +4 -2
  106. package/pd-cli/dist/commands/runtime-health-snapshot.js.map +1 -1
  107. package/pd-cli/dist/commands/runtime-init.js +2 -2
  108. package/pd-cli/dist/commands/runtime-init.js.map +1 -1
  109. package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
  110. package/pd-cli/dist/commands/runtime-internalization-integrity.js +4 -2
  111. package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
  112. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  113. package/pd-cli/dist/services/config-doctor.js +9 -2
  114. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  115. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  116. package/pd-cli/dist/services/runtime-adapter-resolver.js +1 -0
  117. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  118. package/plugin/dist/commands/thinking-os.js +25 -7
  119. package/plugin/dist/commands/workflow-debug.d.ts +1 -3
  120. package/plugin/dist/commands/workflow-debug.js +26 -5
  121. package/plugin/dist/core/rule-host.d.ts +5 -2
  122. package/plugin/dist/core/rule-host.js +15 -2
  123. package/plugin/dist/hooks/after-tool-call-helpers.js +20 -3
  124. package/plugin/dist/hooks/gate.js +1 -1
  125. package/plugin/dist/i18n/commands.js +24 -0
  126. package/plugin/dist/index.js +88 -36
  127. package/plugin/dist/service/evolution-dedup.d.ts +1 -1
  128. package/plugin/dist/service/evolution-worker.d.ts +7 -31
  129. package/plugin/dist/service/evolution-worker.js +17 -36
  130. package/plugin/dist/service/queue-io.js +14 -2
  131. package/plugin/dist/service/queue-migration.d.ts +27 -26
  132. package/plugin/dist/service/queue-migration.js +57 -0
  133. package/plugin/docs/COMMAND_REFERENCE.md +0 -1
  134. package/plugin/docs/COMMAND_REFERENCE_EN.md +0 -2
  135. package/plugin/scripts/sync-plugin.mjs +12 -0
  136. package/plugin/templates/langs/en/core/AGENTS.md +2 -2
  137. package/plugin/templates/langs/en/core/TOOLS.md +1 -1
  138. package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +2 -3
  139. package/plugin/templates/langs/zh/core/AGENTS.md +2 -2
  140. package/plugin/templates/langs/zh/core/TOOLS.md +1 -1
  141. package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +2 -3
  142. package/templates/langs/en/core/AGENTS.md +2 -2
  143. package/templates/langs/en/core/BOOTSTRAP.md +4 -17
  144. package/templates/langs/en/core/TOOLS.md +1 -1
  145. package/templates/langs/en/skills/pd-mentor/SKILL.md +8 -26
  146. package/templates/langs/zh/core/AGENTS.md +2 -2
  147. package/templates/langs/zh/core/BOOTSTRAP.md +4 -17
  148. package/templates/langs/zh/core/TOOLS.md +1 -1
  149. package/templates/langs/zh/skills/pd-mentor/SKILL.md +8 -26
  150. package/plugin/dist/constants/diagnostician.d.ts +0 -12
  151. package/plugin/dist/constants/diagnostician.js +0 -65
  152. package/plugin/dist/service/evolution-queue-migration.d.ts +0 -128
  153. package/plugin/dist/service/evolution-queue-migration.js +0 -53
  154. package/plugin/templates/langs/en/skills/pd-diagnostician/SKILL.md +0 -466
  155. package/plugin/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -391
  156. package/templates/langs/en/skills/pd-daily/SKILL.md +0 -199
  157. package/templates/langs/en/skills/pd-grooming/SKILL.md +0 -46
  158. package/templates/langs/zh/skills/pd-daily/SKILL.md +0 -283
  159. package/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -287
  160. package/templates/langs/zh/skills/pd-grooming/SKILL.md +0 -46
@@ -11,7 +11,7 @@ import { atomicWriteFileSync } from '../utils/io.js';
11
11
  // Re-export queue I/O (extracted to queue-io.ts)
12
12
  export { loadEvolutionQueue, saveEvolutionQueue, withQueueLock, acquireQueueLock, requireQueueLock } from './queue-io.js';
13
13
  export { EVOLUTION_QUEUE_LOCK_SUFFIX, LOCK_MAX_RETRIES, LOCK_RETRY_DELAY_MS, LOCK_STALE_MS } from './queue-io.js';
14
- import { saveEvolutionQueue, requireQueueLock } from './queue-io.js';
14
+ import { saveEvolutionQueue, requireQueueLock, loadEvolutionQueue } from './queue-io.js';
15
15
  import { WorkflowStore } from './subagent-workflow/workflow-store.js';
16
16
  import { PrincipleCompiler } from '../core/principle-compiler/index.js';
17
17
  import { loadLedger, updatePrinciple } from '../core/principle-tree-ledger.js';
@@ -58,8 +58,8 @@ import { runWorkflowWatchdog } from './workflow-watchdog.js';
58
58
  export { runWorkflowWatchdog };
59
59
  let timeoutId = null;
60
60
  // ── Queue Migration (extracted to queue-migration.ts) ────────────────────────
61
- import { migrateToV2, isLegacyQueueItem, migrateQueueToV2, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES } from './queue-migration.js';
62
- export { migrateToV2, isLegacyQueueItem, migrateQueueToV2, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES };
61
+ import { migrateToV2, isLegacyQueueItem, migrateQueueToV2, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem } from './queue-migration.js';
62
+ export { migrateToV2, isLegacyQueueItem, migrateQueueToV2, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem };
63
63
  // Queue lock constants and requireQueueLock are imported from queue-io.ts
64
64
  export function extractEvolutionTaskId(task) {
65
65
  if (!task)
@@ -302,30 +302,12 @@ async function processEvolutionQueue(wctx, logger, _eventLog, _api) {
302
302
  logger?.info?.(`[PD:EvolutionWorker] Dropped ${beforeLegacyPainDrop - queue.length} legacy pain_diagnosis queue item(s); use PainSignalBridge/pd pain record`);
303
303
  }
304
304
  // Validate queue items — filter out malformed entries before processing.
305
- // Malformed items are logged + skipped; they never crash the evolution cycle.
305
+ // rc-1/rc-4 (ERR-007): consolidated in validateQueueItem (queue-migration.ts)
306
+ // so every load path applies the same filter. Malformed items are logged +
307
+ // skipped; they never crash the evolution cycle.
306
308
  const beforeValidation = queue.length;
307
309
  queue = queue.filter((item) => {
308
- const errors = [];
309
- if (!item.id || typeof item.id !== 'string')
310
- errors.push('missing/invalid id');
311
- if (!item.source || typeof item.source !== 'string')
312
- errors.push('missing/invalid source');
313
- if (typeof item.score !== 'number')
314
- errors.push('missing/invalid score');
315
- if (!item.status || typeof item.status !== 'string')
316
- errors.push('missing/invalid status');
317
- if (!item.taskKind || typeof item.taskKind !== 'string')
318
- errors.push('missing/invalid taskKind');
319
- else {
320
- const validTaskKinds = ['model_eval'];
321
- if (!validTaskKinds.includes(item.taskKind)) {
322
- errors.push(`invalid taskKind value '${item.taskKind}' (expected one of: ${validTaskKinds.join(', ')})`);
323
- }
324
- }
325
- if (typeof item.retryCount !== 'number')
326
- errors.push('missing/invalid retryCount');
327
- if (typeof item.maxRetries !== 'number')
328
- errors.push('missing/invalid maxRetries');
310
+ const errors = validateQueueItem(item);
329
311
  if (errors.length > 0) {
330
312
  logger?.warn?.(`[PD:EvolutionWorker] Skipping malformed queue item: ${errors.join(', ')} | ${JSON.stringify(item).slice(0, 200)}`);
331
313
  SystemLogger.log(wctx.workspaceDir, 'QUEUE_ITEM_MALFORMED', `Skipped: ${errors.join(', ')} | id=${item.id || 'N/A'}`);
@@ -361,16 +343,11 @@ export async function registerEvolutionTaskSession(workspaceResolve, taskId, ses
361
343
  return false;
362
344
  const releaseLock = await requireQueueLock(queuePath, logger, 'registerEvolutionTaskSession');
363
345
  try {
364
- let rawQueue;
365
- try {
366
- rawQueue = JSON.parse(fs.readFileSync(queuePath, 'utf8'));
367
- }
368
- catch (parseErr) {
369
- logger?.warn?.(`[PD:EvolutionWorker] Failed to parse EVOLUTION_QUEUE for session registration: ${queuePath} - ${parseErr instanceof Error ? parseErr.message : String(parseErr)}`);
370
- return false;
371
- }
372
- // V2: Migrate queue to current schema
373
- const queue = migrateQueueToV2(rawQueue);
346
+ // loadEvolutionQueue handles JSON parse + migrate + validate (rc-1/rc-4).
347
+ // Previously this inlined JSON.parse + migrate cast without validating,
348
+ // so malformed queue items could reach the find() below. Reusing the
349
+ // shared loader keeps a single chokepoint for queue validation.
350
+ const queue = loadEvolutionQueue(queuePath);
374
351
  const task = queue.find((item) => item.id === taskId && item.status === 'in_progress');
375
352
  if (!task) {
376
353
  logger?.warn?.(`[PD:EvolutionWorker] Could not find in-progress evolution task ${taskId} for session assignment`);
@@ -406,7 +383,11 @@ async function processEvolutionQueueWithResult(wctx, logger, eventLog, api) {
406
383
  if (!fs.existsSync(queuePath)) {
407
384
  return { queue: queueResult, errors };
408
385
  }
409
- const queue = JSON.parse(fs.readFileSync(queuePath, 'utf8'));
386
+ // rc-1/rc-2/rc-4 (ERR-001/ERR-005/ERR-007): use the canonical loader
387
+ // instead of raw JSON.parse + cast. loadEvolutionQueue handles parse,
388
+ // migrate, and element-wise validation; malformed items are dropped
389
+ // with a console.warn (rc-9: no silent fallback).
390
+ const queue = loadEvolutionQueue(queuePath);
410
391
  // Purge stale failed tasks before processing (keeps queue lean)
411
392
  const purgeResult = purgeStaleFailedTasks(queue, logger);
412
393
  if (purgeResult.purged > 0) {
@@ -11,7 +11,7 @@ import { createHash } from 'crypto';
11
11
  import { acquireLockAsync, releaseLock as releaseImportedLock } from '../utils/file-lock.js';
12
12
  import { atomicWriteFileSync } from '../utils/io.js';
13
13
  import { LockUnavailableError } from '../config/errors.js';
14
- import { migrateQueueToV2 } from './queue-migration.js';
14
+ import { migrateQueueToV2, validateQueueItem } from './queue-migration.js';
15
15
  export const EVOLUTION_QUEUE_LOCK_SUFFIX = '.lock';
16
16
  export const LOCK_MAX_RETRIES = 50;
17
17
  export const LOCK_RETRY_DELAY_MS = 50;
@@ -72,7 +72,19 @@ export function loadEvolutionQueue(queuePath) {
72
72
  rawQueue = [];
73
73
  }
74
74
  }
75
- return migrateQueueToV2(rawQueue);
75
+ // rc-1/rc-4 (ERR-007): every element of the parsed array is untrusted disk
76
+ // JSON — validate before returning. Malformed items are filtered out and
77
+ // reported via console.warn (rc-9: no silent drop). This is the single
78
+ // chokepoint that loadEvolutionQueue callers inherit.
79
+ const migrated = migrateQueueToV2(rawQueue);
80
+ return migrated.filter((item) => {
81
+ const errors = validateQueueItem(item);
82
+ if (errors.length > 0) {
83
+ console.warn(`[queue-io] Dropping malformed queue item: ${errors.join(', ')} | id=${item?.id ?? 'N/A'}`);
84
+ return false;
85
+ }
86
+ return true;
87
+ });
76
88
  }
77
89
  export function saveEvolutionQueue(queuePath, queue) {
78
90
  atomicWriteFileSync(queuePath, JSON.stringify(queue, null, 2));
@@ -5,32 +5,8 @@
5
5
  * to the V2 schema. Zero I/O, zero imports from evolution-worker.ts.
6
6
  */
7
7
  import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
8
- export type QueueStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
9
- export type TaskResolution = 'success' | 'failure' | 'skipped';
10
- export interface EvolutionQueueItem {
11
- id: string;
12
- taskKind: TaskKind;
13
- priority: TaskPriority;
14
- source: string;
15
- traceId?: string;
16
- task?: string;
17
- score: number;
18
- reason: string;
19
- timestamp: string;
20
- enqueued_at?: string;
21
- started_at?: string;
22
- completed_at?: string;
23
- assigned_session_key?: string;
24
- trigger_text_preview?: string;
25
- status: QueueStatus;
26
- resolution?: TaskResolution;
27
- session_id?: string;
28
- agent_id?: string;
29
- retryCount: number;
30
- maxRetries: number;
31
- lastError?: string;
32
- resultRef?: string;
33
- }
8
+ import type { EvolutionQueueItem } from '../core/evolution-types.js';
9
+ export type { QueueStatus, TaskResolution, EvolutionQueueItem } from '../core/evolution-types.js';
34
10
  /**
35
11
  * Legacy queue item shape (pre-V2) for migration compatibility.
36
12
  * These items lack taskKind, priority, retryCount, maxRetries, lastError fields.
@@ -81,3 +57,28 @@ export declare function isLegacyQueueItem(item: RawQueueItem): boolean;
81
57
  * Returns a new array with all items migrated to V2 format.
82
58
  */
83
59
  export declare function migrateQueueToV2(queue: RawQueueItem[]): EvolutionQueueItem[];
60
+ /**
61
+ * Canonical set of valid taskKind values. Single source of truth — mirrors
62
+ * TaskKind in trajectory-types.ts. Previously the inline validator in
63
+ * evolution-worker.ts hard-coded `['model_eval']`, which silently rejected
64
+ * three legitimate taskKind values (pain_diagnosis / sleep_reflection /
65
+ * keyword_optimization). Keep this in sync with TaskKind.
66
+ */
67
+ export declare const VALID_TASK_KINDS: readonly TaskKind[];
68
+ /**
69
+ * Validate a single queue item loaded from untrusted disk JSON.
70
+ *
71
+ * Returns an array of human-readable error reasons; an empty array means the
72
+ * item is valid. Use {@link isValidQueueItem} for a type-guard form.
73
+ *
74
+ * This consolidates the inline validation that lived in processEvolutionQueue
75
+ * (evolution-worker.ts) so every queue load path (loadEvolutionQueue,
76
+ * registerEvolutionTaskSession) applies the same filter. rc-4 (ERR-007):
77
+ * array elements from parsed JSON must be element-wise validated.
78
+ */
79
+ export declare function validateQueueItem(item: unknown): string[];
80
+ /**
81
+ * Type-guard convenience over {@link validateQueueItem}.
82
+ * Drops the reason strings (callers that need them should call validateQueueItem).
83
+ */
84
+ export declare function isValidQueueItem(item: unknown): item is EvolutionQueueItem;
@@ -54,3 +54,60 @@ export function isLegacyQueueItem(item) {
54
54
  export function migrateQueueToV2(queue) {
55
55
  return queue.map(item => isLegacyQueueItem(item) ? migrateToV2(item) : item);
56
56
  }
57
+ // ── Validation (rc-1/rc-2, rc-4: validate array elements from untrusted JSON) ─
58
+ /**
59
+ * Canonical set of valid taskKind values. Single source of truth — mirrors
60
+ * TaskKind in trajectory-types.ts. Previously the inline validator in
61
+ * evolution-worker.ts hard-coded `['model_eval']`, which silently rejected
62
+ * three legitimate taskKind values (pain_diagnosis / sleep_reflection /
63
+ * keyword_optimization). Keep this in sync with TaskKind.
64
+ */
65
+ export const VALID_TASK_KINDS = [
66
+ 'pain_diagnosis',
67
+ 'sleep_reflection',
68
+ 'model_eval',
69
+ 'keyword_optimization',
70
+ ];
71
+ /**
72
+ * Validate a single queue item loaded from untrusted disk JSON.
73
+ *
74
+ * Returns an array of human-readable error reasons; an empty array means the
75
+ * item is valid. Use {@link isValidQueueItem} for a type-guard form.
76
+ *
77
+ * This consolidates the inline validation that lived in processEvolutionQueue
78
+ * (evolution-worker.ts) so every queue load path (loadEvolutionQueue,
79
+ * registerEvolutionTaskSession) applies the same filter. rc-4 (ERR-007):
80
+ * array elements from parsed JSON must be element-wise validated.
81
+ */
82
+ export function validateQueueItem(item) {
83
+ const errors = [];
84
+ if (item === null || typeof item !== 'object' || Array.isArray(item)) {
85
+ return ['item is not an object'];
86
+ }
87
+ const it = item;
88
+ if (!it.id || typeof it.id !== 'string')
89
+ errors.push('missing/invalid id');
90
+ if (!it.source || typeof it.source !== 'string')
91
+ errors.push('missing/invalid source');
92
+ if (typeof it.score !== 'number')
93
+ errors.push('missing/invalid score');
94
+ if (!it.status || typeof it.status !== 'string')
95
+ errors.push('missing/invalid status');
96
+ if (!it.taskKind || typeof it.taskKind !== 'string')
97
+ errors.push('missing/invalid taskKind');
98
+ else if (!VALID_TASK_KINDS.includes(it.taskKind)) {
99
+ errors.push(`invalid taskKind value '${it.taskKind}' (expected one of: ${VALID_TASK_KINDS.join(', ')})`);
100
+ }
101
+ if (typeof it.retryCount !== 'number')
102
+ errors.push('missing/invalid retryCount');
103
+ if (typeof it.maxRetries !== 'number')
104
+ errors.push('missing/invalid maxRetries');
105
+ return errors;
106
+ }
107
+ /**
108
+ * Type-guard convenience over {@link validateQueueItem}.
109
+ * Drops the reason strings (callers that need them should call validateQueueItem).
110
+ */
111
+ export function isValidQueueItem(item) {
112
+ return validateQueueItem(item).length === 0;
113
+ }
@@ -12,7 +12,6 @@
12
12
  | `/pd-evolution-status` | 查看控制面与进化面的当前状态 | 读取 `RuntimeSummaryService` 的 canonical state |
13
13
  | `/pd-status empathy` | 查看情绪/共情事件统计 | 用于观察 `user_empathy` 与 `system_infer` 事件是否稳定落日志 |
14
14
  | `/pd-rollback last` | 回滚最近一次情绪惩罚 | 只回滚 `user_empathy` 对应的 GFI slice |
15
- | `/pd-evolve` | 执行进化任务 | 属于学习面,通过 EP 积累提升权限 |
16
15
  | `/pd-help` | 显示帮助 | |
17
16
 
18
17
  ---
@@ -11,8 +11,6 @@
11
11
  | `/pd-evolution-status` | View EP tier, GFI, pain flag, and gate events |
12
12
  | `/pd-status empathy` | Inspect empathy/frustration event statistics |
13
13
  | `/pd-rollback last` | Roll back the latest empathy penalty |
14
- | `/pd-evolve` | Run an evolution task |
15
- | `/pd-evolution-points` | View current EP balance and tier |
16
14
 
17
15
  ---
18
16
 
@@ -383,6 +383,18 @@ function buildPlugin() {
383
383
  process.exit(1);
384
384
  }
385
385
 
386
+ // Generate .d.ts declarations separately so a tsc failure on unrelated
387
+ // files does not invalidate the esbuild bundle. Matches install.mjs pattern.
388
+ console.log('📝 Generating TypeScript declaration files...');
389
+ try {
390
+ execSync('npx tsc --emitDeclarationOnly', {
391
+ cwd: SOURCE_DIR,
392
+ stdio: 'inherit'
393
+ });
394
+ } catch (error) {
395
+ console.warn(' ⚠️ Declaration generation failed (non-blocking):', error.message);
396
+ }
397
+
386
398
  verifyBundleContents();
387
399
  }
388
400
 
@@ -200,6 +200,6 @@ When completing any coding task (via AI coding assistant or direct):
200
200
  Use this to avoid confusing peer agents with Principles internal workers:
201
201
 
202
202
  - **Peer agents / peer sessions**: `agents_list`, `sessions_list`, `sessions_send`, `sessions_spawn`
203
- - **Internal workers** (for example `diagnostician`, `explorer`): use `sessions_spawn with pd-diagnostician/pd-explorer skills`
203
+ - **Internal workers** (for example `explorer`): use `sessions_spawn with pd-explorer skill`
204
204
  - **Inspect internal workers**: use `subagents`
205
- - **Do not** treat `diagnostician` or `explorer` as peer session targets
205
+ - **Do not** treat `explorer` as a peer session target
@@ -10,6 +10,6 @@
10
10
  ## 4. Agent Routing Clarification
11
11
 
12
12
  - `agents_list`, `sessions_list`, `sessions_send`, and `sessions_spawn` are for peer agents and peer sessions
13
- - Use `sessions_spawn` with `pd-diagnostician` or `pd-explorer` skills to start Principles internal workers
13
+ - Use `sessions_spawn` with `pd-explorer` skill to start Principles internal workers (e.g., explorer)
14
14
  - `subagents` inspects already-started internal workers and their outputs
15
15
  - Do not use peer-session tools to pretend an internal worker is a peer agent
@@ -29,7 +29,6 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
29
29
  | `/pd-bootstrap` | Environment tool scan and upgrade | Tool upgrade |
30
30
  | `/pd-research` | Initiate tool upgrade research | Deep research |
31
31
  | `/pd-thinking` | Manage mental models and candidates | Metacognition |
32
- | `/pd-evolve` | Execute full evolution loop | Bug fix |
33
32
  | `/pd-evolution-status` | View trust score and security stage | Permission check |
34
33
  | `/pd-status` | View system status (GFI and Pain Dictionary) | Health check |
35
34
  | `/pd-help` | Get interactive command guidance | This skill |
@@ -57,7 +56,7 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
57
56
 
58
57
  **Recommended Flow**:
59
58
  1. `/pd-status` - Check system status (GFI and Pain Dictionary)
60
- 2. `/pd-evolve` - Start full evolution loop
59
+ 2. `/pd-evolution-status` - View EP tier and evolution status
61
60
 
62
61
  **Script**: "Problems are the fuel of evolution. Let me help you diagnose and fix systematically."
63
62
 
@@ -170,7 +169,7 @@ For complex scenarios, combine multiple skills:
170
169
 
171
170
  | Scenario | Combined Flow |
172
171
  |----------|---------------|
173
- | Major refactor | `/pd-evolve` → `deductive-audit` → execute |
172
+ | Major refactor | `/pd-evolution-status` → `deductive-audit` → execute |
174
173
  | System optimization | `/pd-status` → `root-cause` → optimize |
175
174
  | Project review | `/pd-evolution-status` → `/pd-status` → `reflection-log` |
176
175
 
@@ -192,6 +192,6 @@ _This folder is home. Treat it that way._
192
192
  用下面这几条避免把同级代理和 Principles 内部 worker 混淆:
193
193
 
194
194
  - **同级代理 / 同级会话**:`agents_list`、`sessions_list`、`sessions_send`、`sessions_spawn`
195
- - **内部 worker**(例如 `diagnostician`、`explorer`):使用 `sessions_spawn` 配合 `pd-diagnostician/pd-explorer` skill 启动
195
+ - **内部 worker**(例如 `explorer`):使用 `sessions_spawn` 配合 `pd-explorer` skill 启动
196
196
  - **查询内部 worker**:使用 `subagents`
197
- - **不要**把 `diagnostician` 或 `explorer` 当成同级 peer session 目标
197
+ - **不要**把 `explorer` 当成同级 peer session 目标
@@ -10,6 +10,6 @@
10
10
  ## 4. 智能体路由澄清
11
11
 
12
12
  - `agents_list`、`sessions_list`、`sessions_send`、`sessions_spawn` 用于同级代理和同级会话
13
- - 使用 `sessions_spawn` 配合 `pd-diagnostician/pd-explorer` skill 启动 Principles 内部 worker,例如 `diagnostician`、`explorer`
13
+ - 使用 `sessions_spawn` 配合 `pd-explorer` skill 启动 Principles 内部 worker,例如 `explorer`
14
14
  - `subagents` 用于查看已启动内部 worker 的状态和输出
15
15
  - 不要用同级会话工具把内部 worker 伪装成同级代理
@@ -29,7 +29,6 @@ disable-model-invocation: true
29
29
  | `/pd-bootstrap` | 环境工具扫描与升级 | 装备升级 |
30
30
  | `/pd-research` | 发起工具升级研究 | 深度调研 |
31
31
  | `/pd-thinking` | 管理思维模型与候选方案 | 元认知管理 |
32
- | `/pd-evolve` | 执行完整进化循环 | 问题修复 |
33
32
  | `/pd-evolution-status` | 查看EP等级与安全状态 | 状态查询 |
34
33
  | `/pd-status` | 查看系统状态(GFI和痛苦词典) | 健康检查 |
35
34
  | `/pd-help` | 获取交互式命令引导 | 本技能 |
@@ -57,7 +56,7 @@ disable-model-invocation: true
57
56
 
58
57
  **推荐流程**:
59
58
  1. `/pd-status` - 检查系统状态(GFI 和痛苦词典)
60
- 2. `/pd-evolve` - 启动完整的进化循环
59
+ 2. `/pd-evolution-status` - 查看 EP 等级和进化状态
61
60
 
62
61
  **话术**: "问题就是进化的燃料。让我帮你系统化地诊断和修复。"
63
62
 
@@ -170,7 +169,7 @@ disable-model-invocation: true
170
169
 
171
170
  | 场景 | 组合流程 |
172
171
  |------|----------|
173
- | 大型重构 | `/pd-evolve` → `deductive-audit` → 执行 |
172
+ | 大型重构 | `/pd-evolution-status` → `deductive-audit` → 执行 |
174
173
  | 系统优化 | `/pd-status` → `root-cause` → 优化实施 |
175
174
  | 项目复盘 | `/pd-evolution-status` → `/pd-status` → `reflection-log` |
176
175
 
@@ -200,6 +200,6 @@ When completing any coding task (via AI coding assistant or direct):
200
200
  Use this to avoid confusing peer agents with Principles internal workers:
201
201
 
202
202
  - **Peer agents / peer sessions**: `agents_list`, `sessions_list`, `sessions_send`, `sessions_spawn`
203
- - **Internal workers** (for example `diagnostician`, `explorer`): use `sessions_spawn with pd-diagnostician/pd-explorer skills`
203
+ - **Internal workers** (for example `explorer`): use `sessions_spawn with pd-explorer skill`
204
204
  - **Inspect internal workers**: use `subagents`
205
- - **Do not** treat `diagnostician` or `explorer` as peer session targets
205
+ - **Do not** treat `explorer` as a peer session target
@@ -162,20 +162,7 @@ If the user has clear project goals, run `/init-strategy` skill to:
162
162
 
163
163
  If the user agrees, **execute these commands:**
164
164
 
165
- ### 1. Grooming (Daily at 2 AM)
166
-
167
- **What it does:** Cleans workspace temp files daily to prevent clutter buildup.
168
-
169
- ```bash
170
- openclaw cron add --name "pd-grooming-daily" \
171
- --cron "0 2 * * *" --tz "UTC" \
172
- --session isolated \
173
- --light-context \
174
- --no-deliver \
175
- --message 'Execute pd-grooming skill: Check workspace root, clean temp files and digital clutter. Follow safety rules strictly. Do not delete business code.'
176
- ```
177
-
178
- ### 2. Health Check (Every 4 hours)
165
+ ### 1. Health Check (Every 4 hours)
179
166
 
180
167
  **What it does:** Verifies core tools (rg, node, python) are available and alerts on failure.
181
168
 
@@ -186,7 +173,7 @@ openclaw cron add --name "health-check" \
186
173
  --system-event 'Health check: Verify core tools (rg, node, python) are available. Check if workspace state matches actual progress.'
187
174
  ```
188
175
 
189
- ### 3. Strategy Alignment (Daily at 9 AM)
176
+ ### 2. Strategy Alignment (Daily at 9 AM)
190
177
 
191
178
  **What it does:** Checks if daily operations have drifted from CURRENT_FOCUS.md strategic goals.
192
179
 
@@ -198,7 +185,7 @@ openclaw cron add --name "strategy-alignment" \
198
185
  --message 'Execute strategy alignment check: Compare against memory/okr/CURRENT_FOCUS.md. Confirm if past 24 hours of operations have drifted from strategic focus. Alert user if drifted.'
199
186
  ```
200
187
 
201
- ### 4. Memory Weekly Cleanup (Monday 10 AM)
188
+ ### 3. Memory Weekly Cleanup (Monday 10 AM)
202
189
 
203
190
  **What it does:** Reviews daily memory files, extracts important content to MEMORY.md, cleans outdated info.
204
191
 
@@ -210,7 +197,7 @@ openclaw cron add --name "memory-weekly" \
210
197
  --message 'Execute weekly memory cleanup: Review recent memory/YYYY-MM-DD.md files, extract important content to MEMORY.md, clean outdated info.'
211
198
  ```
212
199
 
213
- ### 5. Weekly Governance (Sunday Midnight UTC)
200
+ ### 4. Weekly Governance (Sunday Midnight UTC)
214
201
 
215
202
  Update WEEK_STATE.json and validate CURRENT_FOCUS.md:
216
203
 
@@ -53,6 +53,6 @@ Tool returns: Blind Spots → Risk Warnings → Alternative Approaches → Recom
53
53
  ## 4. Agent Routing Clarification
54
54
 
55
55
  - `agents_list`, `sessions_list`, `sessions_send`, and `sessions_spawn` are for peer agents and peer sessions
56
- - Use `sessions_spawn` with `pd-diagnostician` or `pd-explorer` skills to start Principles internal workers
56
+ - Use `sessions_spawn` with `pd-explorer` skill to start Principles internal workers (e.g., explorer)
57
57
  - `subagents` inspects already-started internal workers and their outputs
58
58
  - Do not use peer-session tools to pretend an internal worker is a peer agent
@@ -26,15 +26,10 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
26
26
  | Command | Purpose | Use Case |
27
27
  |---------|---------|----------|
28
28
  | `/pd-init` | Initialize strategy and OKRs | New project startup |
29
- | `/pd-okr` | Objectives and Key Results management | Weekly/monthly review |
30
29
  | `/pd-bootstrap` | Environment tool scan and upgrade | Tool upgrade |
31
30
  | `/pd-research` | Initiate tool upgrade research | Deep research |
32
31
  | `/pd-thinking` | Manage mental models and candidates | Metacognition |
33
- | `/pd-evolve` | Execute full evolution loop | Bug fix |
34
- | `/pd-daily` | Configure and send evolution daily report | Daily review |
35
- | `/pd-trust` | View trust score and security stage | Permission check |
36
32
  | `/pd-status` | View system status (GFI and Pain Dictionary) | Health check |
37
- | `/pd-grooming` | Workspace digital cleanup | Entropy reduction |
38
33
  | `/pd-help` | Get interactive command guidance | This skill |
39
34
 
40
35
  ---
@@ -60,7 +55,7 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
60
55
 
61
56
  **Recommended Flow**:
62
57
  1. `/pd-status` - Check system status (GFI and Pain Dictionary)
63
- 2. `/pd-evolve` - Start full evolution loop
58
+ 2. `/pd-evolution-status` - Start full evolution loop
64
59
 
65
60
  **Script**: "Problems are the fuel of evolution. Let me help you diagnose and fix systematically."
66
61
 
@@ -71,38 +66,26 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
71
66
  **Trigger**: User says "what did I do today", "check progress", "give me a report"
72
67
 
73
68
  **Recommended Flow**:
74
- 1. `/pd-daily` - Send today's evolution report
75
- 2. `/pd-trust` - View current trust score
76
- 3. `/pd-okr` - Check OKR alignment
69
+ 1. `/pd-evolution-status` - Send today's evolution report
70
+ 2. `/pd-evolution-status` - View current trust score
77
71
 
78
72
  **Script**: "Daily report in hand, evolution I command. Let me help you review today's achievements."
79
73
 
80
74
  ---
81
75
 
82
- ### Scenario 4: Messy Workspace
83
-
84
- **Trigger**: User says "project is too messy", "too many files", "need to organize"
85
-
86
- **Recommended Flow**:
87
- 1. `/pd-grooming` - Start workspace cleanup
88
-
89
- **Script**: "Digital cleanliness is a virtue. Let me help you reduce entropy."
90
-
91
- ---
92
-
93
- ### Scenario 5: Permission or Security Related
76
+ ### Scenario 4: Permission or Security Related
94
77
 
95
78
  **Trigger**: User says "not enough permissions", "blocked", "security level"
96
79
 
97
80
  **Recommended Flow**:
98
- 1. `/pd-trust` - View trust score and security stage
81
+ 1. `/pd-evolution-status` - View trust score and security stage
99
82
  2. Explain current stage's capability boundaries
100
83
 
101
84
  **Script**: "Trust is earned, not given. Let me help you understand your current security level."
102
85
 
103
86
  ---
104
87
 
105
- ### Scenario 6: Tool Upgrade Needs
88
+ ### Scenario 5: Tool Upgrade Needs
106
89
 
107
90
  **Trigger**: User says "want to upgrade tools", "research new version", "tech stack update"
108
91
 
@@ -160,7 +143,6 @@ Use `AskUserQuestion` to ask user about current task scenario:
160
143
  - 🆕 New project initialization
161
144
  - 🐛 Bug fix
162
145
  - 📊 Daily review
163
- - 🧹 Workspace cleanup
164
146
  - 🔐 Permission/Security
165
147
  - 🔧 Tool upgrade
166
148
  - ❓ Other
@@ -185,9 +167,9 @@ For complex scenarios, combine multiple skills:
185
167
 
186
168
  | Scenario | Combined Flow |
187
169
  |----------|---------------|
188
- | Major refactor | `/pd-evolve` → `deductive-audit` → execute |
170
+ | Major refactor | `/pd-evolution-status` → `deductive-audit` → execute |
189
171
  | System optimization | `/pd-status` → `evolve-system` → `root-cause` |
190
- | Project review | `/pd-daily` → `/pd-okr` → `reflection-log` |
172
+ | Project review | `/pd-evolution-status` → `/pd-okr` → `reflection-log` |
191
173
 
192
174
  ### Internal Skill Calls
193
175
 
@@ -192,6 +192,6 @@ _This folder is home. Treat it that way._
192
192
  用下面这几条避免把同级代理和 Principles 内部 worker 混淆:
193
193
 
194
194
  - **同级代理 / 同级会话**:`agents_list`、`sessions_list`、`sessions_send`、`sessions_spawn`
195
- - **内部 worker**(例如 `diagnostician`、`explorer`):使用 `sessions_spawn` 配合 `pd-diagnostician/pd-explorer` skill 启动
195
+ - **内部 worker**(例如 `explorer`):使用 `sessions_spawn` 配合 `pd-explorer` skill 启动
196
196
  - **查询内部 worker**:使用 `subagents`
197
- - **不要**把 `diagnostician` 或 `explorer` 当成同级 peer session 目标
197
+ - **不要**把 `explorer` 当成同级 peer session 目标
@@ -162,20 +162,7 @@ memory/
162
162
 
163
163
  如果用户同意,**执行以下命令:**
164
164
 
165
- ### 1. 熵减巡检(每天凌晨 2 点)
166
-
167
- **功能:** 每天清理工作区临时文件,保持项目整洁。
168
-
169
- ```bash
170
- openclaw cron add --name "pd-grooming-daily" \
171
- --cron "0 2 * * *" --tz "UTC" \
172
- --session isolated \
173
- --light-context \
174
- --no-deliver \
175
- --message '执行 pd-grooming 技能:检查工作区根目录,清理临时文件和数字垃圾。严格遵循安全红线,不要删除业务代码。'
176
- ```
177
-
178
- ### 2. 环境健康检查(每 4 小时)
165
+ ### 1. 环境健康检查(每 4 小时)
179
166
 
180
167
  **功能:** 验证核心工具(rg, node, python)是否可用,异常时告警。
181
168
 
@@ -186,7 +173,7 @@ openclaw cron add --name "health-check" \
186
173
  --system-event '环境健康检查:验证核心工具(rg, node, python)是否可用,检查工作区状态与实际进度是否一致。'
187
174
  ```
188
175
 
189
- ### 3. 战略对齐检查(每天上午 9 点)
176
+ ### 2. 战略对齐检查(每天上午 9 点)
190
177
 
191
178
  **功能:** 检查过去 24 小时的操作是否偏离 CURRENT_FOCUS.md 战略目标。
192
179
 
@@ -198,7 +185,7 @@ openclaw cron add --name "strategy-alignment" \
198
185
  --message '执行战略对齐检查:对比 memory/okr/CURRENT_FOCUS.md,确认过去24小时的操作是否偏离战略重点。如有偏离,提醒用户。'
199
186
  ```
200
187
 
201
- ### 4. Memory 周度整理(每周一上午 10 点)
188
+ ### 3. Memory 周度整理(每周一上午 10 点)
202
189
 
203
190
  **功能:** 回顾每日记忆文件,提炼重要内容到 MEMORY.md,清理过时信息。
204
191
 
@@ -210,7 +197,7 @@ openclaw cron add --name "memory-weekly" \
210
197
  --message '执行 Memory 周度整理:翻阅近期的 memory/YYYY-MM-DD.md 文件,提炼重要内容到 MEMORY.md,清理过时信息。'
211
198
  ```
212
199
 
213
- ### 5. 周治理(每周日 UTC 0 点)
200
+ ### 4. 周治理(每周日 UTC 0 点)
214
201
 
215
202
  更新 WEEK_STATE.json 并验证 CURRENT_FOCUS.md:
216
203
 
@@ -53,6 +53,6 @@ deep_reflect(
53
53
  ## 4. 智能体路由澄清
54
54
 
55
55
  - `agents_list`、`sessions_list`、`sessions_send`、`sessions_spawn` 用于同级代理和同级会话
56
- - 使用 `sessions_spawn` 配合 `pd-diagnostician/pd-explorer` skill 启动 Principles 内部 worker,例如 `diagnostician`、`explorer`
56
+ - 使用 `sessions_spawn` 配合 `pd-explorer` skill 启动 Principles 内部 worker,例如 `explorer`
57
57
  - `subagents` 用于查看已启动内部 worker 的状态和输出
58
58
  - 不要用同级会话工具把内部 worker 伪装成同级代理