Skip to content

Commit aa134f6

Browse files
authored
refactor: move from global to context options (#10)
* options, move from global values to defaults and context * server, pass options fallback, apply context to mcp tools * tool, update towards context
1 parent 4e58b28 commit aa134f6

25 files changed

+820
-549
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default [
6565
{
6666
files: ['**/*.test.ts'],
6767
rules: {
68+
'@typescript-eslint/no-explicit-any': 0,
6869
'no-sparse-arrays': 0
6970
}
7071
}

src/__tests__/__snapshots__/docs.local.test.ts.snap

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,32 @@
22

33
exports[`docsLocal should return specific properties 1`] = `
44
{
5-
"LOCAL_DOCS": [
6-
"[@patternfly/react-charts](/documentation/charts/README.md)",
7-
"[@patternfly/react-chatbot](/documentation/chatbot/README.md)",
8-
"[@patternfly/react-component-groups](/documentation/component-groups/README.md)",
9-
"[@patternfly/react-components](/documentation/components/README.md)",
10-
"[@patternfly/react-guidelines](/documentation/guidelines/README.md)",
11-
"[@patternfly/react-resources](/documentation/resources/README.md)",
12-
"[@patternfly/react-setup](/documentation/setup/README.md)",
13-
"[@patternfly/react-troubleshooting](/documentation/troubleshooting/README.md)",
14-
],
5+
"getLocalDocs": [Function],
156
}
167
`;
8+
9+
exports[`getLocalDocs should return local references when called, default 1`] = `
10+
[
11+
"[@patternfly/react-charts](/documentation/charts/README.md)",
12+
"[@patternfly/react-chatbot](/documentation/chatbot/README.md)",
13+
"[@patternfly/react-component-groups](/documentation/component-groups/README.md)",
14+
"[@patternfly/react-components](/documentation/components/README.md)",
15+
"[@patternfly/react-guidelines](/documentation/guidelines/README.md)",
16+
"[@patternfly/react-resources](/documentation/resources/README.md)",
17+
"[@patternfly/react-setup](/documentation/setup/README.md)",
18+
"[@patternfly/react-troubleshooting](/documentation/troubleshooting/README.md)",
19+
]
20+
`;
21+
22+
exports[`getLocalDocs should return local references when called, with custom docsPath 1`] = `
23+
[
24+
"[@patternfly/react-charts](custom/docs/path/charts/README.md)",
25+
"[@patternfly/react-chatbot](custom/docs/path/chatbot/README.md)",
26+
"[@patternfly/react-component-groups](custom/docs/path/component-groups/README.md)",
27+
"[@patternfly/react-components](custom/docs/path/components/README.md)",
28+
"[@patternfly/react-guidelines](custom/docs/path/guidelines/README.md)",
29+
"[@patternfly/react-resources](custom/docs/path/resources/README.md)",
30+
"[@patternfly/react-setup](custom/docs/path/setup/README.md)",
31+
"[@patternfly/react-troubleshooting](custom/docs/path/troubleshooting/README.md)",
32+
]
33+
`;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`main should merge default, cli and programmatic options, merge programmatic options with CLI options 1`] = `
4+
{
5+
"calls": [
6+
[
7+
{
8+
"docsHost": true,
9+
},
10+
],
11+
],
12+
"methodRegistersAs": "main",
13+
"sequence": [
14+
"parse",
15+
"set",
16+
"run",
17+
],
18+
}
19+
`;
20+
21+
exports[`main should merge default, cli and programmatic options, merge programmatic options with CLI options, with start alias 1`] = `
22+
{
23+
"calls": [
24+
[
25+
{
26+
"docsHost": true,
27+
},
28+
],
29+
],
30+
"methodRegistersAs": "main",
31+
"sequence": [
32+
"parse",
33+
"set",
34+
"run",
35+
],
36+
}
37+
`;
38+
39+
exports[`main should merge default, cli and programmatic options, with empty programmatic options 1`] = `
40+
{
41+
"calls": [
42+
[
43+
{
44+
"docsHost": true,
45+
},
46+
],
47+
],
48+
"methodRegistersAs": "main",
49+
"sequence": [
50+
"parse",
51+
"set",
52+
"run",
53+
],
54+
}
55+
`;
56+
57+
exports[`main should merge default, cli and programmatic options, with undefined programmatic options 1`] = `
58+
{
59+
"calls": [
60+
[
61+
{
62+
"docsHost": false,
63+
},
64+
],
65+
],
66+
"methodRegistersAs": "main",
67+
"sequence": [
68+
"parse",
69+
"set",
70+
"run",
71+
],
72+
}
73+
`;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`apply context options should set and get basic options, confirm by applying a potential property outside of typings 1`] = `"lorem = ipsum"`;
4+
5+
exports[`apply context options should set and get basic options, default 1`] = `"docsHost = true"`;
6+
7+
exports[`apply context options should set and get basic options, multiple property updates 1`] = `"name = ipsum"`;
8+
9+
exports[`apply context options should set and get basic options, multiple property updates 2`] = `"name = dolor sit amet"`;
10+
11+
exports[`apply context options should set and get basic options, multiple property updates 3`] = `"name = consectetur adipiscing elit"`;
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`options defaults should return specific properties 1`] = `
4+
{
5+
"DEFAULTS": {
6+
"DEFAULT_OPTIONS": {
7+
"contextPath": "/",
8+
"docsPath": "/documentation",
9+
"llmsFilesPath": "/llms-files",
10+
"name": "@patternfly/patternfly-mcp",
11+
"pfExternal": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content",
12+
"pfExternalAccessibility": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/accessibility",
13+
"pfExternalCharts": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src",
14+
"pfExternalChartsComponents": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/victory/components",
15+
"pfExternalChartsDesign": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/charts",
16+
"pfExternalDesign": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines",
17+
"pfExternalDesignComponents": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/components",
18+
"pfExternalDesignLayouts": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/layouts",
19+
"repoName": "patternfly-mcp",
20+
"resourceMemoOptions": {
21+
"fetchUrl": {
22+
"cacheErrors": false,
23+
"cacheLimit": 100,
24+
"expire": 180000,
25+
},
26+
"readFile": {
27+
"cacheErrors": false,
28+
"cacheLimit": 50,
29+
"expire": 120000,
30+
},
31+
},
32+
"separator": "
33+
34+
---
35+
36+
",
37+
"toolMemoOptions": {
38+
"fetchDocs": {
39+
"cacheErrors": false,
40+
"cacheLimit": 15,
41+
"expire": 60000,
42+
},
43+
"usePatternFlyDocs": {
44+
"cacheErrors": false,
45+
"cacheLimit": 10,
46+
"expire": 60000,
47+
},
48+
},
49+
"urlRegex": /\\^\\(https\\?:\\)\\\\/\\\\//i,
50+
"version": "0.0.0",
51+
},
52+
"DEFAULT_SEPARATOR": "
53+
54+
---
55+
56+
",
57+
"PF_EXTERNAL": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content",
58+
"PF_EXTERNAL_ACCESSIBILITY": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/accessibility",
59+
"PF_EXTERNAL_CHARTS": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src",
60+
"PF_EXTERNAL_CHARTS_COMPONENTS": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/victory/components",
61+
"PF_EXTERNAL_CHARTS_DESIGN": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/charts",
62+
"PF_EXTERNAL_DESIGN": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines",
63+
"PF_EXTERNAL_DESIGN_COMPONENTS": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/components",
64+
"PF_EXTERNAL_DESIGN_LAYOUTS": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/layouts",
65+
"RESOURCE_MEMO_OPTIONS": {
66+
"fetchUrl": {
67+
"cacheErrors": false,
68+
"cacheLimit": 100,
69+
"expire": 180000,
70+
},
71+
"readFile": {
72+
"cacheErrors": false,
73+
"cacheLimit": 50,
74+
"expire": 120000,
75+
},
76+
},
77+
"TOOL_MEMO_OPTIONS": {
78+
"fetchDocs": {
79+
"cacheErrors": false,
80+
"cacheLimit": 15,
81+
"expire": 60000,
82+
},
83+
"usePatternFlyDocs": {
84+
"cacheErrors": false,
85+
"cacheLimit": 10,
86+
"expire": 60000,
87+
},
88+
},
89+
"URL_REGEX": /\\^\\(https\\?:\\)\\\\/\\\\//i,
90+
},
91+
"DEFAULT_OPTIONS": {
92+
"contextPath": "/",
93+
"docsPath": "/documentation",
94+
"llmsFilesPath": "/llms-files",
95+
"name": "@patternfly/patternfly-mcp",
96+
"pfExternal": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content",
97+
"pfExternalAccessibility": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/accessibility",
98+
"pfExternalCharts": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src",
99+
"pfExternalChartsComponents": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/victory/components",
100+
"pfExternalChartsDesign": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/charts",
101+
"pfExternalDesign": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines",
102+
"pfExternalDesignComponents": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/components",
103+
"pfExternalDesignLayouts": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/layouts",
104+
"repoName": "patternfly-mcp",
105+
"resourceMemoOptions": {
106+
"fetchUrl": {
107+
"cacheErrors": false,
108+
"cacheLimit": 100,
109+
"expire": 180000,
110+
},
111+
"readFile": {
112+
"cacheErrors": false,
113+
"cacheLimit": 50,
114+
"expire": 120000,
115+
},
116+
},
117+
"separator": "
118+
119+
---
120+
121+
",
122+
"toolMemoOptions": {
123+
"fetchDocs": {
124+
"cacheErrors": false,
125+
"cacheLimit": 15,
126+
"expire": 60000,
127+
},
128+
"usePatternFlyDocs": {
129+
"cacheErrors": false,
130+
"cacheLimit": 10,
131+
"expire": 60000,
132+
},
133+
},
134+
"urlRegex": /\\^\\(https\\?:\\)\\\\/\\\\//i,
135+
"version": "0.0.0",
136+
},
137+
"DEFAULT_SEPARATOR": "
138+
139+
---
140+
141+
",
142+
"PF_EXTERNAL": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content",
143+
"PF_EXTERNAL_ACCESSIBILITY": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/accessibility",
144+
"PF_EXTERNAL_CHARTS": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src",
145+
"PF_EXTERNAL_CHARTS_COMPONENTS": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/victory/components",
146+
"PF_EXTERNAL_CHARTS_DESIGN": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/packages/react-charts/src/charts",
147+
"PF_EXTERNAL_DESIGN": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines",
148+
"PF_EXTERNAL_DESIGN_COMPONENTS": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/components",
149+
"PF_EXTERNAL_DESIGN_LAYOUTS": "https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/layouts",
150+
"RESOURCE_MEMO_OPTIONS": {
151+
"fetchUrl": {
152+
"cacheErrors": false,
153+
"cacheLimit": 100,
154+
"expire": 180000,
155+
},
156+
"readFile": {
157+
"cacheErrors": false,
158+
"cacheLimit": 50,
159+
"expire": 120000,
160+
},
161+
},
162+
"TOOL_MEMO_OPTIONS": {
163+
"fetchDocs": {
164+
"cacheErrors": false,
165+
"cacheLimit": 15,
166+
"expire": 60000,
167+
},
168+
"usePatternFlyDocs": {
169+
"cacheErrors": false,
170+
"cacheLimit": 10,
171+
"expire": 60000,
172+
},
173+
},
174+
"URL_REGEX": /\\^\\(https\\?:\\)\\\\/\\\\//i,
175+
}
176+
`;

0 commit comments

Comments
 (0)