github-issue-tower-defence-management 2.183.2 → 2.183.4

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/README.test.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  * @jest-environment node
3
3
  */
4
4
  import fs from 'node:fs';
5
+ import os from 'node:os';
5
6
  import path from 'node:path';
6
7
  import YAML from 'yaml';
8
+ import { loadStartPreparationFleetSettings } from './src/adapter/entry-points/cli/fleetConfig';
7
9
 
8
10
  const readmeText = fs.readFileSync(path.join(__dirname, 'README.md'), 'utf8');
9
11
 
@@ -53,6 +55,35 @@ const parseExampleYamlBlock = (
53
55
  return YAML.parse(yamlBlockText) as Record<string, unknown>;
54
56
  };
55
57
 
58
+ const extractMapExampleYamlBlockText = (markdown: string): string => {
59
+ const label = 'Example with the map:';
60
+ const lines = markdown.split('\n');
61
+ const labelIndex = lines.findIndex((line) => line === label);
62
+ if (labelIndex === -1) {
63
+ throw new Error(`README.md label not found: ${label}`);
64
+ }
65
+
66
+ let openingFenceIndex = labelIndex + 1;
67
+ while (
68
+ openingFenceIndex < lines.length &&
69
+ lines[openingFenceIndex].trim() === ''
70
+ ) {
71
+ openingFenceIndex += 1;
72
+ }
73
+ if (lines[openingFenceIndex] !== '```yaml') {
74
+ throw new Error(`YAML opening fence not found after: ${label}`);
75
+ }
76
+
77
+ const closingFenceIndex = lines.findIndex(
78
+ (line, index) => index > openingFenceIndex && line === '```',
79
+ );
80
+ if (closingFenceIndex === -1) {
81
+ throw new Error(`YAML closing fence not found after: ${label}`);
82
+ }
83
+
84
+ return lines.slice(openingFenceIndex + 1, closingFenceIndex).join('\n');
85
+ };
86
+
56
87
  describe('README.md Example YAML blocks document agentDefinitionsDirectoryPath', () => {
57
88
  test.each<{ sectionHeading: string; isNested: boolean }>([
58
89
  { sectionHeading: '### Schedule Command Config', isNested: true },
@@ -82,3 +113,25 @@ describe('README.md Example YAML blocks document agentDefinitionsDirectoryPath',
82
113
  },
83
114
  );
84
115
  });
116
+
117
+ test('README.md llmModelNameByAgentName map example is accepted by the fleet reader', () => {
118
+ const temporaryDirectory = fs.mkdtempSync(
119
+ path.join(os.tmpdir(), 'readme-llm-model-map-'),
120
+ );
121
+ const fleetConfigFilePath = path.join(
122
+ temporaryDirectory,
123
+ 'fleet-config.yaml',
124
+ );
125
+
126
+ try {
127
+ const yamlBlockText = extractMapExampleYamlBlockText(readmeText);
128
+ fs.writeFileSync(fleetConfigFilePath, yamlBlockText);
129
+ const settings = loadStartPreparationFleetSettings(fleetConfigFilePath);
130
+ const modelMap = settings.llmModelNameByAgentName;
131
+
132
+ expect(modelMap).not.toBeNull();
133
+ expect(Object.keys(modelMap ?? {}).length).toBeGreaterThan(0);
134
+ } finally {
135
+ fs.rmSync(temporaryDirectory, { force: true, recursive: true });
136
+ }
137
+ });