tachibot-mcp 2.0.2
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/.env.example +260 -0
- package/CHANGELOG.md +54 -0
- package/CODE_OF_CONDUCT.md +56 -0
- package/CONTRIBUTING.md +54 -0
- package/Dockerfile +36 -0
- package/LICENSE +644 -0
- package/README.md +201 -0
- package/SECURITY.md +95 -0
- package/dist/personality/komaai-expressions.js +12 -0
- package/dist/profiles/balanced.json +33 -0
- package/dist/profiles/code_focus.json +33 -0
- package/dist/profiles/full.json +33 -0
- package/dist/profiles/minimal.json +33 -0
- package/dist/profiles/research_power.json +33 -0
- package/dist/scripts/build-profiles.js +46 -0
- package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
- package/dist/src/application/services/focus/FocusTool.service.js +109 -0
- package/dist/src/application/services/focus/ModeRegistry.js +46 -0
- package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
- package/dist/src/application/services/focus/modes/status.mode.js +50 -0
- package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
- package/dist/src/collaborative-orchestrator.js +391 -0
- package/dist/src/config/model-constants.js +188 -0
- package/dist/src/config/model-defaults.js +57 -0
- package/dist/src/config/model-preferences.js +382 -0
- package/dist/src/config/timeout-config.js +130 -0
- package/dist/src/config.js +173 -0
- package/dist/src/domain/interfaces/IFocusMode.js +5 -0
- package/dist/src/domain/interfaces/IProvider.js +6 -0
- package/dist/src/domain/interfaces/ITool.js +5 -0
- package/dist/src/focus-deep.js +245 -0
- package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
- package/dist/src/mcp-client.js +90 -0
- package/dist/src/memory/index.js +17 -0
- package/dist/src/memory/memory-config.js +135 -0
- package/dist/src/memory/memory-interface.js +174 -0
- package/dist/src/memory/memory-manager.js +383 -0
- package/dist/src/memory/providers/devlog-provider.js +385 -0
- package/dist/src/memory/providers/hybrid-provider.js +399 -0
- package/dist/src/memory/providers/local-provider.js +388 -0
- package/dist/src/memory/providers/mem0-provider.js +337 -0
- package/dist/src/modes/architect.js +477 -0
- package/dist/src/modes/auditor.js +362 -0
- package/dist/src/modes/challenger.js +841 -0
- package/dist/src/modes/code-reviewer.js +382 -0
- package/dist/src/modes/commit-guardian.js +424 -0
- package/dist/src/modes/documentation-writer.js +572 -0
- package/dist/src/modes/scout.js +587 -0
- package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
- package/dist/src/modes/shared/helpers/index.js +17 -0
- package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
- package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
- package/dist/src/modes/test-architect.js +767 -0
- package/dist/src/modes/verifier.js +378 -0
- package/dist/src/monitoring/performance-monitor.js +435 -0
- package/dist/src/optimization/batch-executor.js +121 -0
- package/dist/src/optimization/context-pruner.js +196 -0
- package/dist/src/optimization/cost-monitor.js +338 -0
- package/dist/src/optimization/index.js +65 -0
- package/dist/src/optimization/model-router.js +264 -0
- package/dist/src/optimization/result-cache.js +114 -0
- package/dist/src/optimization/token-optimizer.js +257 -0
- package/dist/src/optimization/token-tracker.js +118 -0
- package/dist/src/orchestrator-instructions.js +128 -0
- package/dist/src/orchestrator-lite.js +139 -0
- package/dist/src/orchestrator.js +191 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
- package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
- package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
- package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
- package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
- package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
- package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
- package/dist/src/profiles/balanced.js +37 -0
- package/dist/src/profiles/code_focus.js +37 -0
- package/dist/src/profiles/debug_intensive.js +59 -0
- package/dist/src/profiles/full.js +37 -0
- package/dist/src/profiles/minimal.js +37 -0
- package/dist/src/profiles/research_code.js +59 -0
- package/dist/src/profiles/research_power.js +37 -0
- package/dist/src/profiles/types.js +5 -0
- package/dist/src/profiles/workflow_builder.js +53 -0
- package/dist/src/prompt-engineer-lite.js +78 -0
- package/dist/src/prompt-engineer.js +399 -0
- package/dist/src/reasoning-chain.js +508 -0
- package/dist/src/sequential-thinking.js +291 -0
- package/dist/src/server-diagnostic.js +74 -0
- package/dist/src/server-raw.js +158 -0
- package/dist/src/server-simple.js +58 -0
- package/dist/src/server.js +514 -0
- package/dist/src/session/session-logger.js +617 -0
- package/dist/src/session/session-manager.js +571 -0
- package/dist/src/session/session-tools.js +400 -0
- package/dist/src/tools/advanced-modes.js +200 -0
- package/dist/src/tools/claude-integration.js +356 -0
- package/dist/src/tools/consolidated/ai-router.js +174 -0
- package/dist/src/tools/consolidated/ai-tool.js +48 -0
- package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
- package/dist/src/tools/consolidated/environment-detector.js +80 -0
- package/dist/src/tools/consolidated/index.js +50 -0
- package/dist/src/tools/consolidated/search-tool.js +110 -0
- package/dist/src/tools/consolidated/workflow-tool.js +238 -0
- package/dist/src/tools/gemini-tools.js +329 -0
- package/dist/src/tools/grok-enhanced.js +376 -0
- package/dist/src/tools/grok-tools.js +299 -0
- package/dist/src/tools/lmstudio-tools.js +223 -0
- package/dist/src/tools/openai-tools.js +498 -0
- package/dist/src/tools/openrouter-tools.js +317 -0
- package/dist/src/tools/optimized-wrapper.js +204 -0
- package/dist/src/tools/perplexity-tools.js +294 -0
- package/dist/src/tools/pingpong-tool.js +343 -0
- package/dist/src/tools/qwen-wrapper.js +74 -0
- package/dist/src/tools/tool-router.js +444 -0
- package/dist/src/tools/unified-ai-provider.js +260 -0
- package/dist/src/tools/workflow-runner.js +425 -0
- package/dist/src/tools/workflow-validator-tool.js +107 -0
- package/dist/src/types.js +23 -0
- package/dist/src/utils/input-validator.js +130 -0
- package/dist/src/utils/model-router.js +91 -0
- package/dist/src/utils/progress-stream.js +255 -0
- package/dist/src/utils/provider-router.js +88 -0
- package/dist/src/utils/smart-api-client.js +146 -0
- package/dist/src/utils/table-builder.js +218 -0
- package/dist/src/utils/timestamp-formatter.js +134 -0
- package/dist/src/utils/tool-compressor.js +257 -0
- package/dist/src/utils/tool-config.js +201 -0
- package/dist/src/validators/dependency-graph-validator.js +147 -0
- package/dist/src/validators/interpolation-validator.js +222 -0
- package/dist/src/validators/output-usage-validator.js +151 -0
- package/dist/src/validators/syntax-validator.js +102 -0
- package/dist/src/validators/tool-registry-validator.js +123 -0
- package/dist/src/validators/tool-types.js +97 -0
- package/dist/src/validators/types.js +8 -0
- package/dist/src/validators/workflow-validator.js +134 -0
- package/dist/src/visualizer-lite.js +42 -0
- package/dist/src/visualizer.js +179 -0
- package/dist/src/workflows/circuit-breaker.js +199 -0
- package/dist/src/workflows/custom-workflows.js +451 -0
- package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
- package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
- package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
- package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
- package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
- package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
- package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
- package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
- package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
- package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
- package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
- package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
- package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
- package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
- package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
- package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
- package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
- package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
- package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
- package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
- package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
- package/dist/src/workflows/fallback-strategies.js +373 -0
- package/dist/src/workflows/message-queue.js +455 -0
- package/dist/src/workflows/model-router.js +189 -0
- package/dist/src/workflows/orchestrator-examples.js +174 -0
- package/dist/src/workflows/orchestrator-integration.js +200 -0
- package/dist/src/workflows/self-healing.js +524 -0
- package/dist/src/workflows/tool-mapper.js +407 -0
- package/dist/src/workflows/tool-orchestrator.js +796 -0
- package/dist/src/workflows/workflow-engine.js +573 -0
- package/dist/src/workflows/workflow-parser.js +283 -0
- package/dist/src/workflows/workflow-types.js +95 -0
- package/dist/src/workflows.js +568 -0
- package/dist/test-workflow-file-output.js +93 -0
- package/docs/API_KEYS.md +570 -0
- package/docs/CLAUDE_CODE_SETUP.md +181 -0
- package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
- package/docs/CONFIGURATION.md +745 -0
- package/docs/FOCUS_MODES.md +240 -0
- package/docs/INSTALLATION_BOTH.md +145 -0
- package/docs/TERMS.md +352 -0
- package/docs/TOOLS_REFERENCE.md +1622 -0
- package/docs/TOOL_PARAMETERS.md +496 -0
- package/docs/TOOL_PROFILES.md +236 -0
- package/docs/WORKFLOWS.md +987 -0
- package/docs/WORKFLOW_OUTPUT.md +198 -0
- package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
- package/docs/workflows/design-brainstorm.md +335 -0
- package/package.json +97 -0
- package/profiles/balanced.json +37 -0
- package/profiles/code_focus.json +37 -0
- package/profiles/debug_intensive.json +34 -0
- package/profiles/full.json +37 -0
- package/profiles/minimal.json +37 -0
- package/profiles/research_power.json +37 -0
- package/profiles/workflow_builder.json +37 -0
- package/smithery.yaml +66 -0
- package/start.sh +8 -0
- package/tools.config.json +81 -0
- package/tsconfig.json +18 -0
- package/workflows/accessibility-code-audit.yaml +92 -0
- package/workflows/code-architecture-review.yaml +202 -0
- package/workflows/code-review.yaml +142 -0
- package/workflows/core/iterative-problem-solver.yaml +283 -0
- package/workflows/creative-brainstorm-yaml.yaml +215 -0
- package/workflows/pingpong.yaml +141 -0
- package/workflows/system/README.md +412 -0
- package/workflows/system/challenger.yaml +175 -0
- package/workflows/system/scout.yaml +164 -0
- package/workflows/system/verifier.yaml +133 -0
- package/workflows/ultra-creative-brainstorm.yaml +318 -0
- package/workflows/ux-research-flow.yaml +92 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Interpolation Utility
|
|
3
|
+
* Handles ${variable} and ${step.output} syntax in workflow templates
|
|
4
|
+
*/
|
|
5
|
+
export class VariableInterpolator {
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if value is a FileReference
|
|
8
|
+
*/
|
|
9
|
+
isFileReference(value) {
|
|
10
|
+
return (value &&
|
|
11
|
+
typeof value === 'object' &&
|
|
12
|
+
'stepName' in value &&
|
|
13
|
+
'summary' in value &&
|
|
14
|
+
'getContent' in value &&
|
|
15
|
+
typeof value.getContent === 'function');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Interpolates variables and step outputs in template strings
|
|
19
|
+
*/
|
|
20
|
+
async interpolate(template, context) {
|
|
21
|
+
const mergedContext = {
|
|
22
|
+
...context.variables,
|
|
23
|
+
...Object.fromEntries(context.fileReferences)
|
|
24
|
+
};
|
|
25
|
+
// Collect all variable references
|
|
26
|
+
const matches = [...template.matchAll(/\${([^}]+)}/g)];
|
|
27
|
+
// Resolve each variable (possibly async)
|
|
28
|
+
const replacements = await Promise.all(matches.map(async (match) => {
|
|
29
|
+
const fullMatch = match[0];
|
|
30
|
+
const key = match[1];
|
|
31
|
+
let value;
|
|
32
|
+
// Check for property access (e.g., step.content, step.summary)
|
|
33
|
+
const parts = key.split('.');
|
|
34
|
+
const baseKey = parts[0];
|
|
35
|
+
const property = parts[1];
|
|
36
|
+
// Get base value
|
|
37
|
+
value = mergedContext[baseKey];
|
|
38
|
+
// Support ${step-name.output} syntax
|
|
39
|
+
if (value === undefined && baseKey.endsWith('.output')) {
|
|
40
|
+
const stepName = baseKey.slice(0, -7);
|
|
41
|
+
if (mergedContext[stepName] !== undefined) {
|
|
42
|
+
value = mergedContext[stepName];
|
|
43
|
+
console.error(`🔄 Resolved ${baseKey} → ${stepName}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Handle undefined
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
const available = Object.keys(mergedContext).join(', ');
|
|
49
|
+
throw new Error(`Variable '${key}' not found!\n` +
|
|
50
|
+
`Available: [${available}]\n` +
|
|
51
|
+
`Check previous step's output.variable setting.`);
|
|
52
|
+
}
|
|
53
|
+
// Handle FileReference objects
|
|
54
|
+
if (this.isFileReference(value)) {
|
|
55
|
+
if (!property || property === 'summary') {
|
|
56
|
+
// Default: return summary
|
|
57
|
+
console.error(`✓ Interpolated '${key}': using summary (${value.summary.length} chars)`);
|
|
58
|
+
return { match: fullMatch, replacement: value.summary };
|
|
59
|
+
}
|
|
60
|
+
else if (property === 'content') {
|
|
61
|
+
// Explicit: load full content
|
|
62
|
+
const content = await value.getContent();
|
|
63
|
+
console.error(`✓ Interpolated '${key}': loaded content (${content.length} chars)`);
|
|
64
|
+
return { match: fullMatch, replacement: content };
|
|
65
|
+
}
|
|
66
|
+
else if (property === 'filePath') {
|
|
67
|
+
// Return file path
|
|
68
|
+
const path = value.filePath || 'in-memory';
|
|
69
|
+
console.error(`✓ Interpolated '${key}': filePath = ${path}`);
|
|
70
|
+
return { match: fullMatch, replacement: path };
|
|
71
|
+
}
|
|
72
|
+
else if (property === 'savedTo') {
|
|
73
|
+
// Return filename
|
|
74
|
+
const filename = value.filePath ? value.filePath.split('/').pop() || 'in-memory' : 'in-memory';
|
|
75
|
+
console.error(`✓ Interpolated '${key}': savedTo = ${filename}`);
|
|
76
|
+
return { match: fullMatch, replacement: filename };
|
|
77
|
+
}
|
|
78
|
+
else if (property === 'output') {
|
|
79
|
+
// Handle ${step.output} by returning summary
|
|
80
|
+
console.error(`✓ Interpolated '${key}': using summary (${value.summary.length} chars)`);
|
|
81
|
+
return { match: fullMatch, replacement: value.summary };
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error(`Unknown FileReference property: ${property}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Handle primitive values
|
|
88
|
+
console.error(`✓ Interpolated '${key}': type=${typeof value}, length=${String(value).length}`);
|
|
89
|
+
return { match: fullMatch, replacement: String(value) };
|
|
90
|
+
}));
|
|
91
|
+
// Apply all replacements
|
|
92
|
+
let result = template;
|
|
93
|
+
for (const { match, replacement } of replacements) {
|
|
94
|
+
result = result.replace(match, replacement);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Interpolates variables in an object (recursive)
|
|
100
|
+
*/
|
|
101
|
+
async interpolateObject(obj, context) {
|
|
102
|
+
const result = {};
|
|
103
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
104
|
+
if (typeof value === 'string') {
|
|
105
|
+
result[key] = await this.interpolate(value, context);
|
|
106
|
+
}
|
|
107
|
+
else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
108
|
+
result[key] = await this.interpolateObject(value, context);
|
|
109
|
+
}
|
|
110
|
+
else if (Array.isArray(value)) {
|
|
111
|
+
result[key] = await Promise.all(value.map(item => typeof item === 'string'
|
|
112
|
+
? this.interpolate(item, context)
|
|
113
|
+
: typeof item === 'object' && item !== null
|
|
114
|
+
? this.interpolateObject(item, context)
|
|
115
|
+
: item));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
result[key] = value;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Discovery
|
|
3
|
+
* Handles loading workflows from filesystem (built-in, user, project locations)
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import * as yaml from 'yaml';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname } from 'path';
|
|
11
|
+
export class WorkflowDiscovery {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.workflows = new Map();
|
|
14
|
+
this.validationErrors = [];
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load workflows from all discovery locations
|
|
19
|
+
* Priority: Built-in → User → Project (later overrides earlier)
|
|
20
|
+
*/
|
|
21
|
+
discoverWorkflows() {
|
|
22
|
+
const configDirs = [
|
|
23
|
+
// Priority 1: Built-in workflows (shipped with package)
|
|
24
|
+
{
|
|
25
|
+
path: path.join(this.options.packageRoot, 'workflows'),
|
|
26
|
+
label: 'Built-in',
|
|
27
|
+
},
|
|
28
|
+
// Priority 2: User personal (survives updates)
|
|
29
|
+
{
|
|
30
|
+
path: path.join(os.homedir(), '.config', 'tachibot', 'workflows'),
|
|
31
|
+
label: 'User',
|
|
32
|
+
},
|
|
33
|
+
// Priority 3: Project-specific (git-committed, team-shared)
|
|
34
|
+
{
|
|
35
|
+
path: path.join(process.cwd(), '.tachibot', 'workflows'),
|
|
36
|
+
label: 'Project',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
for (const { path: dir, label } of configDirs) {
|
|
40
|
+
if (!fs.existsSync(dir)) {
|
|
41
|
+
console.error(`📂 [${label}] Skipping: ${dir} (not found)`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
console.error(`📂 [${label}] Loading workflows from: ${dir}`);
|
|
45
|
+
this.loadWorkflowsFromDirectory(dir, label, 0);
|
|
46
|
+
}
|
|
47
|
+
console.error(`✅ Total workflows loaded: ${this.workflows.size}`);
|
|
48
|
+
return {
|
|
49
|
+
workflows: this.workflows,
|
|
50
|
+
errors: this.validationErrors
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Recursively load workflows from directory (max 4 levels deep)
|
|
55
|
+
*/
|
|
56
|
+
loadWorkflowsFromDirectory(dir, source, depth, maxDepth = 4) {
|
|
57
|
+
if (depth >= maxDepth) {
|
|
58
|
+
console.error(`⚠️ [${source}] Max depth (${maxDepth}) reached in: ${dir}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const fullPath = path.join(dir, entry.name);
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
// Recurse into subdirectories
|
|
66
|
+
this.loadWorkflowsFromDirectory(fullPath, source, depth + 1, maxDepth);
|
|
67
|
+
}
|
|
68
|
+
else if (entry.isFile() && entry.name.match(/\.(yaml|yml|json)$/)) {
|
|
69
|
+
try {
|
|
70
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
71
|
+
const data = entry.name.endsWith('.json')
|
|
72
|
+
? JSON.parse(content)
|
|
73
|
+
: yaml.parse(content);
|
|
74
|
+
const variables = data.variables || {};
|
|
75
|
+
const preprocessed = this.options.preprocessVariables(data, variables);
|
|
76
|
+
const workflow = this.options.workflowSchema.parse(preprocessed);
|
|
77
|
+
// Later sources override earlier ones (Project > User > Built-in)
|
|
78
|
+
if (this.workflows.has(workflow.name)) {
|
|
79
|
+
console.error(`🔄 [${source}] Overriding: ${workflow.name}`);
|
|
80
|
+
}
|
|
81
|
+
this.workflows.set(workflow.name, workflow);
|
|
82
|
+
console.error(`✅ [${source}] Loaded: ${workflow.name} from ${entry.name}`);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
86
|
+
this.validationErrors.push({
|
|
87
|
+
file: entry.name,
|
|
88
|
+
source,
|
|
89
|
+
error: errorMsg,
|
|
90
|
+
});
|
|
91
|
+
console.error(`❌ [${source}] Failed to load ${entry.name}:`, error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Load workflow from arbitrary file path
|
|
98
|
+
*/
|
|
99
|
+
loadWorkflowFile(filePath) {
|
|
100
|
+
// Resolve relative paths
|
|
101
|
+
const resolvedPath = path.isAbsolute(filePath)
|
|
102
|
+
? filePath
|
|
103
|
+
: path.join(process.cwd(), filePath);
|
|
104
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
105
|
+
throw new Error(`Workflow file not found: ${resolvedPath}`);
|
|
106
|
+
}
|
|
107
|
+
const content = fs.readFileSync(resolvedPath, 'utf-8');
|
|
108
|
+
const data = resolvedPath.endsWith('.json')
|
|
109
|
+
? JSON.parse(content)
|
|
110
|
+
: yaml.parse(content);
|
|
111
|
+
const variables = data.variables || {};
|
|
112
|
+
const preprocessed = this.options.preprocessVariables(data, variables);
|
|
113
|
+
const workflow = this.options.workflowSchema.parse(preprocessed);
|
|
114
|
+
return workflow;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get package root from import.meta.url
|
|
118
|
+
*/
|
|
119
|
+
static getPackageRoot() {
|
|
120
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
121
|
+
const __dirname = dirname(__filename);
|
|
122
|
+
// Up to tachibot-mcp/ (dist/src/workflows/engine -> dist/src/workflows -> dist/src -> dist -> root)
|
|
123
|
+
return path.join(__dirname, '..', '..', '..', '..');
|
|
124
|
+
}
|
|
125
|
+
}
|