doukui 0.0.0-stage → 0.3.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 (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +42 -0
  3. package/README.md +147 -2
  4. package/bin/commands/build.js +178 -0
  5. package/bin/commands/config.js +88 -0
  6. package/bin/commands/help.js +83 -0
  7. package/bin/commands/init.js +194 -0
  8. package/bin/commands/install.js +202 -0
  9. package/bin/commands/interactive.js +352 -0
  10. package/bin/commands/list.js +108 -0
  11. package/bin/commands/loop-server.js +357 -0
  12. package/bin/commands/loop.js +1398 -0
  13. package/bin/commands/migrate.js +120 -0
  14. package/bin/commands/setup-global.js +81 -0
  15. package/bin/commands/status.js +140 -0
  16. package/bin/commands/team-cleanup.js +190 -0
  17. package/bin/commands/validate-config.js +35 -0
  18. package/bin/commands/validate.js +21 -0
  19. package/bin/commands/version.js +22 -0
  20. package/bin/context.js +143 -0
  21. package/bin/doukui.js +216 -0
  22. package/package.json +47 -4
  23. package/plugins/contracts/capabilities.js +268 -0
  24. package/plugins/contracts/checkresult-schema.json +75 -0
  25. package/plugins/contracts/config-schema.json +179 -0
  26. package/plugins/contracts/plugin-interface.js +262 -0
  27. package/plugins/contracts/plugin-schema.json +104 -0
  28. package/plugins/core/hook-session-start/index.js +281 -0
  29. package/plugins/core/hook-session-start/plugin.json +7 -0
  30. package/plugins/core/hook-skill-gate/index.js +661 -0
  31. package/plugins/core/hook-skill-gate/plugin.json +12 -0
  32. package/plugins/core/provider-loop-engine/index.js +1397 -0
  33. package/plugins/core/provider-loop-engine/plugin.json +15 -0
  34. package/plugins/core/provider-memory-store/index.js +510 -0
  35. package/plugins/core/provider-memory-store/plugin.json +9 -0
  36. package/plugins/core/provider-role-registry/index.js +376 -0
  37. package/plugins/core/provider-role-registry/plugin.json +9 -0
  38. package/plugins/core/provider-state-store/index.js +244 -0
  39. package/plugins/core/provider-state-store/plugin.json +9 -0
  40. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
  41. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
  42. package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
  43. package/plugins/core/provider-watchdog/index.js +151 -0
  44. package/plugins/core/provider-watchdog/plugin.json +13 -0
  45. package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
  46. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
  47. package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
  48. package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
  49. package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
  50. package/plugins/core/skill-agentic-loop/plugin.json +20 -0
  51. package/plugins/core/skill-agentic-loop/skill.md +572 -0
  52. package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
  53. package/plugins/core/skill-batch-task-creator/skill.md +620 -0
  54. package/plugins/core/skill-checklist/plugin.json +10 -0
  55. package/plugins/core/skill-checklist/skill.md +171 -0
  56. package/plugins/core/skill-completion-report/plugin.json +10 -0
  57. package/plugins/core/skill-completion-report/skill.md +331 -0
  58. package/plugins/core/skill-doukui-plan/plugin.json +15 -0
  59. package/plugins/core/skill-doukui-plan/skill.md +233 -0
  60. package/plugins/core/skill-doukui-sync/plugin.json +10 -0
  61. package/plugins/core/skill-doukui-sync/skill.md +76 -0
  62. package/plugins/core/skill-experience-logger/plugin.json +10 -0
  63. package/plugins/core/skill-experience-logger/skill.md +235 -0
  64. package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
  65. package/plugins/core/skill-human-checkpoint/skill.md +194 -0
  66. package/plugins/core/skill-progress-tracker/plugin.json +10 -0
  67. package/plugins/core/skill-progress-tracker/skill.md +228 -0
  68. package/plugins/core/skill-role-manager/plugin.json +10 -0
  69. package/plugins/core/skill-role-manager/skill.md +252 -0
  70. package/plugins/core/skill-split-work-package/plugin.json +15 -0
  71. package/plugins/core/skill-split-work-package/skill.md +441 -0
  72. package/plugins/core/skill-task-archive/plugin.json +10 -0
  73. package/plugins/core/skill-task-archive/skill.md +116 -0
  74. package/plugins/core/skill-task-creator/plugin.json +15 -0
  75. package/plugins/core/skill-task-creator/skill.md +886 -0
  76. package/plugins/core/skill-team-cleanup/plugin.json +10 -0
  77. package/plugins/core/skill-team-cleanup/skill.md +266 -0
  78. package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
  79. package/plugins/core/skill-watchdog-manager/skill.md +143 -0
  80. package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
  81. package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
  82. package/plugins/core/validator-doc-sync/index.js +248 -0
  83. package/plugins/core/validator-doc-sync/plugin.json +12 -0
  84. package/plugins/core/validator-work-package/index.js +300 -0
  85. package/plugins/core/validator-work-package/plugin.json +12 -0
  86. package/plugins/plugin-registry.json +186 -0
  87. package/plugins/runtime/agent-def-generator.js +150 -0
  88. package/plugins/runtime/audit-logger.js +311 -0
  89. package/plugins/runtime/build-cli.js +89 -0
  90. package/plugins/runtime/checkresult-validator.js +131 -0
  91. package/plugins/runtime/claude-md-injector.js +159 -0
  92. package/plugins/runtime/cleanup-utils.js +293 -0
  93. package/plugins/runtime/config-manager.js +317 -0
  94. package/plugins/runtime/config-validator.js +320 -0
  95. package/plugins/runtime/context-window.js +81 -0
  96. package/plugins/runtime/event-bus.js +207 -0
  97. package/plugins/runtime/executor-claude.js +828 -0
  98. package/plugins/runtime/executor-default.js +448 -0
  99. package/plugins/runtime/executor-local.js +178 -0
  100. package/plugins/runtime/executor-sdk.js +390 -0
  101. package/plugins/runtime/harness-build.js +1037 -0
  102. package/plugins/runtime/hook-dispatcher.js +315 -0
  103. package/plugins/runtime/logger.js +192 -0
  104. package/plugins/runtime/loop-actuator.js +292 -0
  105. package/plugins/runtime/loop-coordinator.js +347 -0
  106. package/plugins/runtime/loop-defaults.js +29 -0
  107. package/plugins/runtime/loop-dispatch-batch.js +247 -0
  108. package/plugins/runtime/loop-executor.js +120 -0
  109. package/plugins/runtime/loop-report.js +327 -0
  110. package/plugins/runtime/loop-server-core.js +750 -0
  111. package/plugins/runtime/loop-snapshot.js +581 -0
  112. package/plugins/runtime/loop-trace.js +242 -0
  113. package/plugins/runtime/loop-worktree.js +404 -0
  114. package/plugins/runtime/manifest-resolver.js +457 -0
  115. package/plugins/runtime/multi-window-coordinator.js +560 -0
  116. package/plugins/runtime/objective-verifier.js +136 -0
  117. package/plugins/runtime/plan-reader.js +763 -0
  118. package/plugins/runtime/plugin-loader.js +798 -0
  119. package/plugins/runtime/plugin-trust.js +182 -0
  120. package/plugins/runtime/plugin-validator.js +491 -0
  121. package/plugins/runtime/provider-failover.js +114 -0
  122. package/plugins/runtime/provider-resolver.js +342 -0
  123. package/plugins/runtime/reflection-evaluator.js +540 -0
  124. package/plugins/runtime/resolve-plugin-path.js +297 -0
  125. package/plugins/runtime/safe-path.js +119 -0
  126. package/plugins/runtime/sandbox-context.js +235 -0
  127. package/plugins/runtime/sandbox-manager.js +609 -0
  128. package/plugins/runtime/sandbox-worker.js +215 -0
  129. package/plugins/runtime/settings-merger.js +172 -0
  130. package/plugins/runtime/state-store.js +527 -0
  131. package/plugins/runtime/team-cleanup.js +497 -0
  132. package/plugins/runtime/text-tokenize.js +25 -0
  133. package/plugins/runtime/validator-pipeline.js +475 -0
  134. package/plugins/runtime/yaml-parser.js +692 -0
  135. package/templates/harness-config.yaml +388 -0
@@ -0,0 +1,475 @@
1
+ /**
2
+ * ValidatorPipeline - Validator execution pipeline for AI Agent Harness
3
+ *
4
+ * Features:
5
+ * - Execute registered validators at workflow checkpoints
6
+ * - Support blocking mode (fail fast) and non-blocking mode (warnings only)
7
+ * - Auto-run validator-doc-sync after build
8
+ * - Auto-run validator-work-package when WP changes
9
+ * - Event-driven integration with EventBus
10
+ *
11
+ * Usage:
12
+ * var pipeline = new ValidatorPipeline({
13
+ * pluginLoader: pluginLoader,
14
+ * eventBus: eventBus,
15
+ * logger: logger,
16
+ * });
17
+ * await pipeline.runValidator('validator-doc-sync', { blocking: false });
18
+ * var result = await pipeline.runAllValidators({ phase: 'build' });
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var path = require('path');
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Constants
27
+ // ---------------------------------------------------------------------------
28
+
29
+ /**
30
+ * Validator execution modes.
31
+ * @public
32
+ */
33
+ var ExecutionMode = {
34
+ BLOCKING: 'blocking', // Fail on validation error, stop workflow
35
+ NON_BLOCKING: 'non-blocking', // Continue on error, log warnings
36
+ };
37
+
38
+ /**
39
+ * Workflow phases where validators auto-trigger.
40
+ * @public
41
+ */
42
+ var WorkflowPhase = {
43
+ BUILD: 'build', // After `doukui build` completes
44
+ WP_CREATE: 'wp-create', // After WP document creation
45
+ WP_MODIFY: 'wp-modify', // After WP document modification
46
+ MANUAL: 'manual', // Explicit manual invocation
47
+ };
48
+
49
+ // ---------------------------------------------------------------------------
50
+ // ValidatorPipeline class
51
+ // ---------------------------------------------------------------------------
52
+
53
+ /**
54
+ * ValidatorPipeline constructor.
55
+ * @public
56
+ * @param {object} options
57
+ * @param {object} options.pluginLoader - PluginLoader instance
58
+ * @param {object} options.eventBus - EventBus instance
59
+ * @param {object} options.logger - Logger instance
60
+ * @param {string} [options.projectRoot] - Project root directory (default: cwd)
61
+ */
62
+ function ValidatorPipeline(options) {
63
+ options = options || {};
64
+
65
+ if (!options.pluginLoader) {
66
+ throw new Error('ValidatorPipeline: pluginLoader is required');
67
+ }
68
+
69
+ this._pluginLoader = options.pluginLoader;
70
+ this._eventBus = options.eventBus || null;
71
+ this._logger = options.logger || null;
72
+ this._projectRoot = options.projectRoot || process.cwd();
73
+
74
+ /** @type {Map<string, object>} validator execution results cache */
75
+ this._resultsCache = new Map();
76
+
77
+ this._setupEventListeners();
78
+ }
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // Public API
82
+ // ---------------------------------------------------------------------------
83
+
84
+ /**
85
+ * Run a single validator by name.
86
+ *
87
+ * @public
88
+ * @param {string} validatorName - registered validator plugin name
89
+ * @param {object} [options]
90
+ * @param {string} [options.mode='blocking'] - ExecutionMode: 'blocking' or 'non-blocking'
91
+ * @param {object} [options.context] - Additional context to pass to validator
92
+ * @returns {Promise<{ passed: boolean, errors: object[], warnings: object[], mode: string }>}
93
+ */
94
+ ValidatorPipeline.prototype.runValidator = async function runValidator(validatorName, options) {
95
+ options = options || {};
96
+ var mode = options.mode || ExecutionMode.BLOCKING;
97
+ var context = options.context || {};
98
+
99
+ this._log('info', 'Running validator: ' + validatorName + ' (mode: ' + mode + ')');
100
+
101
+ // Get the validator plugin instance
102
+ var validator = this._pluginLoader.getPlugin(validatorName);
103
+ if (!validator) {
104
+ var error = 'Validator plugin "' + validatorName + '" is not loaded';
105
+ this._log('error', error);
106
+ if (mode === ExecutionMode.BLOCKING) {
107
+ throw new Error(error);
108
+ }
109
+ return {
110
+ passed: false,
111
+ errors: [{ message: error }],
112
+ warnings: [],
113
+ mode: mode,
114
+ };
115
+ }
116
+
117
+ // Verify it's actually a ValidatorPlugin
118
+ if (validator.type !== 'validator') {
119
+ error = 'Plugin "' + validatorName + '" is not a validator (type: ' + validator.type + ')';
120
+ this._log('error', error);
121
+ if (mode === ExecutionMode.BLOCKING) {
122
+ throw new Error(error);
123
+ }
124
+ return {
125
+ passed: false,
126
+ errors: [{ message: error }],
127
+ warnings: [],
128
+ mode: mode,
129
+ };
130
+ }
131
+
132
+ // Execute the validator
133
+ var result;
134
+ try {
135
+ result = await validator.validate(context);
136
+ } catch (err) {
137
+ this._log('error', 'Validator "' + validatorName + '" threw exception: ' + err.message);
138
+ result = {
139
+ valid: false,
140
+ errors: [{ message: 'Exception during validation: ' + err.message }],
141
+ warnings: [],
142
+ };
143
+ }
144
+
145
+ // Normalize result format (validators may return { valid, errors, warnings } or { passed, errors, warnings })
146
+ var passed = result.valid !== undefined ? result.valid : (result.passed || false);
147
+ var errors = result.errors || [];
148
+ var warnings = result.warnings || [];
149
+
150
+ // Build standardized result
151
+ var stdResult = {
152
+ passed: passed,
153
+ errors: errors,
154
+ warnings: warnings,
155
+ mode: mode,
156
+ validator: validatorName,
157
+ };
158
+
159
+ // Emit event
160
+ if (this._eventBus) {
161
+ this._eventBus.emit('validator:executed', {
162
+ validator: validatorName,
163
+ passed: passed,
164
+ mode: mode,
165
+ errorsCount: errors.length,
166
+ warningsCount: warnings.length,
167
+ });
168
+ }
169
+
170
+ // Log results
171
+ if (passed) {
172
+ this._log('info', 'Validator "' + validatorName + '" PASSED' + (warnings.length > 0 ? ' with ' + warnings.length + ' warnings' : ''));
173
+ } else {
174
+ this._log('error', 'Validator "' + validatorName + '" FAILED: ' + errors.length + ' errors');
175
+ }
176
+
177
+ // Cache result
178
+ this._resultsCache.set(validatorName, stdResult);
179
+
180
+ // Handle blocking mode
181
+ if (mode === ExecutionMode.BLOCKING && !passed) {
182
+ var errorMessages = errors.map(function (e) { return e.message || String(e); });
183
+ throw new Error('Validator "' + validatorName + '" failed in blocking mode:\n - ' + errorMessages.join('\n - '));
184
+ }
185
+
186
+ return stdResult;
187
+ };
188
+
189
+ /**
190
+ * Run all registered validators for a specific workflow phase.
191
+ *
192
+ * @public
193
+ * @param {object} [options]
194
+ * @param {string} [options.phase='manual'] - WorkflowPhase identifier
195
+ * @param {string} [options.mode='blocking'] - Default execution mode (can be overridden per-validator)
196
+ * @param {boolean} [options.stopOnFirstError=false] - Stop execution on first blocking failure
197
+ * @returns {Promise<{ results: object[], overallPassed: boolean, totalErrors: number, totalWarnings: number }>}
198
+ */
199
+ ValidatorPipeline.prototype.runAllValidators = async function runAllValidators(options) {
200
+ options = options || {};
201
+ var phase = options.phase || WorkflowPhase.MANUAL;
202
+ var defaultMode = options.mode || ExecutionMode.BLOCKING;
203
+ // B5: default false per JSDoc above (was previously true due to `!== false`
204
+ // idiom evaluating undefined → true). Callers that want short-circuit
205
+ // behavior must pass stopOnFirstError: true explicitly.
206
+ var stopOnFirstError = options.stopOnFirstError === true;
207
+
208
+ this._log('info', 'Running all validators for phase: ' + phase);
209
+
210
+ var loadedPlugins = this._pluginLoader.getLoadedNames();
211
+ var validatorNames = [];
212
+
213
+ // Find all validator plugins
214
+ for (var i = 0; i < loadedPlugins.length; i++) {
215
+ var plugin = this._pluginLoader.getPlugin(loadedPlugins[i]);
216
+ if (plugin && plugin.type === 'validator') {
217
+ validatorNames.push(loadedPlugins[i]);
218
+ }
219
+ }
220
+
221
+ if (validatorNames.length === 0) {
222
+ this._log('info', 'No validators registered, skipping');
223
+ return {
224
+ results: [],
225
+ overallPassed: true,
226
+ totalErrors: 0,
227
+ totalWarnings: 0,
228
+ };
229
+ }
230
+
231
+ var results = [];
232
+ var totalErrors = 0;
233
+ var totalWarnings = 0;
234
+ var overallPassed = true;
235
+
236
+ // Determine which validators to run based on phase
237
+ var validatorsToRun = this._filterValidatorsForPhase(validatorNames, phase);
238
+
239
+ for (var j = 0; j < validatorsToRun.length; j++) {
240
+ var validatorName = validatorsToRun[j];
241
+ var validator = this._pluginLoader.getPlugin(validatorName);
242
+
243
+ // Determine execution mode from validator config or default
244
+ var mode = defaultMode;
245
+ if (validator && validator.blocking === false) {
246
+ mode = ExecutionMode.NON_BLOCKING;
247
+ }
248
+
249
+ try {
250
+ var result = await this.runValidator(validatorName, { mode: mode, phase: phase });
251
+ results.push(result);
252
+
253
+ if (!result.passed) {
254
+ overallPassed = false;
255
+ totalErrors += result.errors.length;
256
+ }
257
+ totalWarnings += result.warnings.length;
258
+
259
+ // Stop on first blocking error if requested
260
+ if (stopOnFirstError && mode === ExecutionMode.BLOCKING && !result.passed) {
261
+ this._log('warn', 'Stopping validator execution due to blocking failure');
262
+ break;
263
+ }
264
+ } catch (err) {
265
+ // runValidator throws in blocking mode on failure
266
+ overallPassed = false;
267
+ totalErrors += 1;
268
+ results.push({
269
+ validator: validatorName,
270
+ passed: false,
271
+ errors: [{ message: err.message }],
272
+ warnings: [],
273
+ mode: mode,
274
+ });
275
+
276
+ if (stopOnFirstError && mode === ExecutionMode.BLOCKING) {
277
+ throw err;
278
+ }
279
+ }
280
+ }
281
+
282
+ var summary = {
283
+ results: results,
284
+ overallPassed: overallPassed,
285
+ totalErrors: totalErrors,
286
+ totalWarnings: totalWarnings,
287
+ };
288
+
289
+ // Emit completion event
290
+ if (this._eventBus) {
291
+ this._eventBus.emit('validator:phase-complete', {
292
+ phase: phase,
293
+ overallPassed: overallPassed,
294
+ totalErrors: totalErrors,
295
+ totalWarnings: totalWarnings,
296
+ validatorsExecuted: validatorsToRun.length,
297
+ });
298
+ }
299
+
300
+ this._log('info', 'Validator phase complete: ' + (overallPassed ? 'PASSED' : 'FAILED') + ' (' + totalErrors + ' errors, ' + totalWarnings + ' warnings)');
301
+
302
+ return summary;
303
+ };
304
+
305
+ /**
306
+ * Run validators specifically for post-build phase.
307
+ * This is a convenience method for the build workflow.
308
+ *
309
+ * @public
310
+ *
311
+ * @param {object} [options]
312
+ * @returns {Promise<object>}
313
+ */
314
+ ValidatorPipeline.prototype.runPostBuildValidators = async function runPostBuildValidators(options) {
315
+ options = options || {};
316
+ options.phase = WorkflowPhase.BUILD;
317
+ options.mode = options.mode || ExecutionMode.NON_BLOCKING; // Build should not fail on validation
318
+ return await this.runAllValidators(options);
319
+ };
320
+
321
+ /**
322
+ * Run validators for WP-related operations.
323
+ * This is a convenience method for WP creation/modification workflow.
324
+ *
325
+ * @public
326
+ *
327
+ * @param {string} wpId - Work package ID (e.g., 'WP-001')
328
+ * @param {string} operation - 'create' or 'modify'
329
+ * @param {object} [options]
330
+ * @returns {Promise<object>}
331
+ */
332
+ ValidatorPipeline.prototype.runWPValidators = async function runWPValidators(wpId, operation, options) {
333
+ options = options || {};
334
+ var phase = operation === 'create' ? WorkflowPhase.WP_CREATE : WorkflowPhase.WP_MODIFY;
335
+
336
+ this._log('info', 'Running WP validators for ' + wpId + ' (operation: ' + operation + ')');
337
+
338
+ // Build context with WP-specific info
339
+ var context = options.context || {};
340
+ context.wpId = wpId;
341
+ context.operation = operation;
342
+ context.wpPath = context.wpPath || path.join(this._projectRoot, 'docs', 'wp', wpId + '.md');
343
+
344
+ options.phase = phase;
345
+ options.context = context;
346
+
347
+ return await this.runAllValidators(options);
348
+ };
349
+
350
+ /**
351
+ * Get cached validator result.
352
+ * @public
353
+ * @param {string} validatorName
354
+ * @returns {object|undefined}
355
+ */
356
+ ValidatorPipeline.prototype.getCachedResult = function getCachedResult(validatorName) {
357
+ return this._resultsCache.get(validatorName);
358
+ };
359
+
360
+ /**
361
+ * Clear all cached validator results.
362
+ * @public
363
+ */
364
+ ValidatorPipeline.prototype.clearCache = function clearCache() {
365
+ this._resultsCache.clear();
366
+ this._log('info', 'Validator result cache cleared');
367
+ };
368
+
369
+ // ---------------------------------------------------------------------------
370
+ // Internal helpers
371
+ // ---------------------------------------------------------------------------
372
+
373
+ /**
374
+ * Set up event listeners for automatic validator triggering.
375
+ * @internal
376
+ */
377
+ ValidatorPipeline.prototype._setupEventListeners = function _setupEventListeners() {
378
+ if (!this._eventBus) {
379
+ return;
380
+ }
381
+
382
+ var self = this;
383
+
384
+ // Listen for build completion events
385
+ this._eventBus.on('build:complete', function () {
386
+ self._log('info', 'Build complete detected, running post-build validators');
387
+ self.runPostBuildValidators().catch(function (err) {
388
+ self._log('error', 'Post-build validation failed: ' + err.message);
389
+ });
390
+ });
391
+
392
+ // Listen for WP document events
393
+ this._eventBus.on('wp:created', function (data) {
394
+ var wpId = data && data.wpId;
395
+ if (wpId) {
396
+ self._log('info', 'WP created detected: ' + wpId);
397
+ self.runWPValidators(wpId, 'create').catch(function (err) {
398
+ self._log('error', 'WP validation failed: ' + err.message);
399
+ });
400
+ }
401
+ });
402
+
403
+ this._eventBus.on('wp:modified', function (data) {
404
+ var wpId = data && data.wpId;
405
+ if (wpId) {
406
+ self._log('info', 'WP modified detected: ' + wpId);
407
+ self.runWPValidators(wpId, 'modify').catch(function (err) {
408
+ self._log('error', 'WP validation failed: ' + err.message);
409
+ });
410
+ }
411
+ });
412
+ };
413
+
414
+ /**
415
+ * Filter validators based on workflow phase.
416
+ * Each validator can declare which phases it applies to via metadata.targets or similar.
417
+ *
418
+ * @internal
419
+ * @param {string[]} validatorNames
420
+ * @param {string} phase
421
+ * @returns {string[]}
422
+ */
423
+ ValidatorPipeline.prototype._filterValidatorsForPhase = function _filterValidatorsForPhase(validatorNames, phase) {
424
+ var filtered = [];
425
+
426
+ for (var i = 0; i < validatorNames.length; i++) {
427
+ var validatorName = validatorNames[i];
428
+ var validator = this._pluginLoader.getPlugin(validatorName);
429
+
430
+ if (!validator) {
431
+ continue;
432
+ }
433
+
434
+ // Check if validator has explicit phase targeting
435
+ // First check metadata.targets (from plugin.json), then fall back to instance.targets
436
+ var targets = validator.metadata && validator.metadata.targets;
437
+ if (!targets || (Array.isArray(targets) && targets.length === 0)) {
438
+ targets = validator.targets;
439
+ }
440
+
441
+ if (targets && Array.isArray(targets) && targets.length > 0) {
442
+ // Check if current phase is in targets
443
+ var targetsLower = targets.map(function (t) { return String(t).toLowerCase(); });
444
+ var phaseLower = phase.toLowerCase();
445
+
446
+ if (targetsLower.indexOf(phaseLower) !== -1 || targetsLower.indexOf('all') !== -1) {
447
+ filtered.push(validatorName);
448
+ }
449
+ } else {
450
+ // No explicit targets - apply to all phases
451
+ filtered.push(validatorName);
452
+ }
453
+ }
454
+
455
+ return filtered;
456
+ };
457
+
458
+ /**
459
+ * Internal logging helper.
460
+ */
461
+ ValidatorPipeline.prototype._log = function _log(level, message) {
462
+ if (this._logger && typeof this._logger[level] === 'function') {
463
+ this._logger[level]('validator-pipeline', message);
464
+ }
465
+ };
466
+
467
+ // ---------------------------------------------------------------------------
468
+ // Module exports
469
+ // ---------------------------------------------------------------------------
470
+
471
+ module.exports = {
472
+ ValidatorPipeline: ValidatorPipeline,
473
+ ExecutionMode: ExecutionMode,
474
+ WorkflowPhase: WorkflowPhase,
475
+ };