Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions guidelines/agent_coding.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ All tools and resources MUST follow the **Creator Pattern** for dependency injec
- **Options Injection Pattern**: Environment-dependent helpers should accept an optional `options` parameter that defaults to `getOptions()`. This allows for explicit dependency injection in tests while maintaining ergonomics via `AsyncLocalStorage` in production. Pure transforms should remain option-agnostic.
- **Internal Tools**: `(options = getOptions()): McpTool` -> Returns `[name, schema, handler]`.
- **Internal Resources**: `(options = getOptions()): McpResource` -> Returns `[name, uri, config, handler]`.
- **Internal Collections**: `(options = getOptions()): McpCollection` -> Returns `[name, config, handler, _config?]` (see `McpCollection` in `src/collections.ts`).
- **External Tool Plugins**: Authored with `createMcpTool` from `@patternfly/patternfly-mcp/tools`, using an object configuration, exported as `default`.
- **Testing**: Creators allow easy mocking: `const tool = usePatternFlyDocsTool(mockOptions)`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`composeCollections should match snapshot for composed collection creators 1`] = `
[
{
"config": {
"_config": {
"_isInternal": true,
"isRequired": false,
},
Expand Down
11 changes: 6 additions & 5 deletions src/__tests__/collection.patternFlyApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ describe('patternFlyApiCollection', () => {
});

it('should return the correct collection name and configuration', async () => {
const [name, callback, config] = patternFlyApiCollection();
const [name, config, callback, _config] = patternFlyApiCollection();

expect(name).toBe('patternfly-api');
expect(config).toBeDefined();
expect(callback).toBeDefined();
expect(typeof config?.initial).toBe('function');
expect(config?.retainLastViable).toBe(true);
expect(config?.runParallel).toContain('#collection');
expect(config?.runSchedule).toBeDefined();
expect(typeof _config?.initial).toBe('function');
expect(_config?.retainLastViable).toBe(true);
expect(_config?.runParallel).toContain('#collection');
expect(_config?.runSchedule).toBeDefined();
});
});

Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/collection.patternFlyDocs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ describe('patternFlyDocsCollection', () => {
});

it('should return the correct collection name and configuration', () => {
const [name, callback, config] = patternFlyDocsCollection();
const [name, config, callback, _config] = patternFlyDocsCollection();

expect(name).toBe('patternfly-docs');
expect(config).toBeDefined();
expect(callback).toBeDefined();
expect(config?.isRequired).toBe(true);
expect(_config?.isRequired).toBe(true);
});
});

Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/collection.patternFlySchemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ describe('patternFlySchemasCollection', () => {
});

it('should return the correct collection name and configuration', () => {
const [name, callback, config] = patternFlySchemasCollection();
const [name, config, callback, _config] = patternFlySchemasCollection();

expect(name).toBe('patternfly-component-schemas');
expect(config).toBeDefined();
expect(callback).toBeDefined();
expect(config?.isRequired).toBe(true);
expect(_config?.isRequired).toBe(true);
});
});

Expand Down
Loading
Loading