Skip to content

Commit e571bc6

Browse files
committed
feat(preflight): register imported agents before template loading
Ensure imported agents are registered prior to template loading to allow resolveStep() to find agents from imported packages. This is done by calling ensureImportedAgentsRegistered() which clears and re-registers agents from all installed imports.
1 parent 9bf4560 commit e571bc6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/workflows/preflight.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,24 @@ import { getTemplatePathFromTracking, getSelectedTrack, hasSelectedConditions, g
1212
import { validateSpecification } from '../runtime/services/index.js';
1313
import { ensureWorkspaceStructure } from '../runtime/services/workspace/index.js';
1414
import type { AgentDefinition } from '../shared/agents/config/types.js';
15+
import { registerImportedAgents, clearImportedAgents } from './utils/config.js';
16+
import { getAllInstalledImports } from '../shared/imports/index.js';
1517

1618
export { ValidationError } from '../runtime/services/index.js';
1719

20+
/**
21+
* Ensure imported agents are registered before loading templates
22+
* This must be called before any loadTemplateWithPath() call to ensure
23+
* resolveStep() can find agents from imported packages
24+
*/
25+
function ensureImportedAgentsRegistered(): void {
26+
clearImportedAgents();
27+
const importedPackages = getAllInstalledImports();
28+
for (const imp of importedPackages) {
29+
registerImportedAgents(imp.resolvedPaths.config);
30+
}
31+
}
32+
1833
/**
1934
* Onboarding requirements - what the user needs to configure before workflow can start
2035
*/
@@ -40,6 +55,10 @@ export async function checkOnboardingRequired(options: { cwd?: string } = {}): P
4055
// Ensure workspace structure exists
4156
await ensureWorkspaceStructure({ cwd });
4257

58+
// Ensure imported agents are registered before loading template
59+
// This allows resolveStep() to find agents from imported packages
60+
ensureImportedAgentsRegistered();
61+
4362
// Load template
4463
const templatePath = await getTemplatePathFromTracking(cmRoot);
4564
const { template } = await loadTemplateWithPath(cwd, templatePath);
@@ -87,6 +106,10 @@ export async function checkSpecificationRequired(options: { cwd?: string } = {})
87106
// Ensure workspace structure exists
88107
await ensureWorkspaceStructure({ cwd });
89108

109+
// Ensure imported agents are registered before loading template
110+
// This allows resolveStep() to find agents from imported packages
111+
ensureImportedAgentsRegistered();
112+
90113
// Load template to check specification requirement
91114
const templatePath = await getTemplatePathFromTracking(cmRoot);
92115
const { template } = await loadTemplateWithPath(cwd, templatePath);

0 commit comments

Comments
 (0)