Skip to content

Commit 75410f7

Browse files
committed
chore: Modify AI instructions build script to optimize and reduce instructions size. Add test examples for later
chore: Modify AI instructions build script to optimize and reduce instructions size. Add test examples for later chore: Modify AI instructions build script to optimize and reduce instructions size. Add test examples for later fix(qol): Agent-agnostic contributing instructions chore(test): Untrack influxdb3 data and plugins used in Docker configurations and testing chore(test): Untrack influxdb3 data and plugins used in Docker configurations and testing chore: Modify AI instructions build script to optimize and reduce instructions size. Add test examples for later
1 parent b8c1156 commit 75410f7

File tree

9 files changed

+147
-1483
lines changed

9 files changed

+147
-1483
lines changed

.github/instructions/contributing.instructions.md

Lines changed: 36 additions & 1418 deletions
Large diffs are not rendered by default.

build-scripts/build-copilot-instructions.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export { buildContributingInstructions };
2323
/** Build instructions from CONTRIBUTING.md
2424
* This script reads CONTRIBUTING.md, formats it appropriately,
2525
* and saves it to .github/instructions/contributing.instructions.md
26+
* Includes optimization to reduce file size for better performance
2627
*/
2728
function buildContributingInstructions() {
2829
// Paths
@@ -41,6 +42,9 @@ function buildContributingInstructions() {
4142
// Read the CONTRIBUTING.md file
4243
let content = fs.readFileSync(contributingPath, 'utf8');
4344

45+
// Optimize content by removing less critical sections for Copilot
46+
content = optimizeContentForContext(content);
47+
4448
// Format the content for Copilot instructions with applyTo attribute
4549
content = `---
4650
applyTo: "content/**/*.md, layouts/**/*.html"
@@ -59,7 +63,17 @@ ${content}`;
5963
// Write the formatted content to the instructions file
6064
fs.writeFileSync(instructionsPath, content);
6165

62-
console.log(`✅ Generated Copilot instructions at ${instructionsPath}`);
66+
const fileSize = fs.statSync(instructionsPath).size;
67+
const sizeInKB = (fileSize / 1024).toFixed(1);
68+
console.log(
69+
`✅ Generated instructions at ${instructionsPath} (${sizeInKB}KB)`
70+
);
71+
72+
if (fileSize > 40000) {
73+
console.warn(
74+
`⚠️ Instructions file is large (${sizeInKB}KB > 40KB) and may impact performance`
75+
);
76+
}
6377

6478
// Add the file to git if it has changed
6579
try {
@@ -74,3 +88,58 @@ ${content}`;
7488
console.warn('⚠️ Could not add instructions file to git:', error.message);
7589
}
7690
}
91+
92+
/**
93+
* Optimize content for Copilot by removing or condensing less critical sections
94+
* while preserving essential documentation guidance
95+
*/
96+
function optimizeContentForContext(content) {
97+
// Remove or condense sections that are less relevant for context assistance
98+
const sectionsToRemove = [
99+
// Installation and setup sections (less relevant for writing docs)
100+
/### Install project dependencies[\s\S]*?(?=\n##|\n###|$)/g,
101+
/### Install Node\.js dependencies[\s\S]*?(?=\n##|\n###|$)/g,
102+
/### Install Docker[\s\S]*?(?=\n##|\n###|$)/g,
103+
/#### Build the test dependency image[\s\S]*?(?=\n##|\n###|$)/g,
104+
/### Install Visual Studio Code extensions[\s\S]*?(?=\n##|\n###|$)/g,
105+
/### Run the documentation locally[\s\S]*?(?=\n##|\n###|$)/g,
106+
107+
// Testing and CI/CD sections (important but can be condensed)
108+
/### Set up test scripts and credentials[\s\S]*?(?=\n##|\n###|$)/g,
109+
/#### Test shell and python code blocks[\s\S]*?(?=\n##|\n###|$)/g,
110+
/#### Troubleshoot tests[\s\S]*?(?=\n##|\n###|$)/g,
111+
/### Pytest collected 0 items[\s\S]*?(?=\n##|\n###|$)/g,
112+
113+
// Long code examples that can be referenced elsewhere
114+
/```[\s\S]{500,}?```/g,
115+
116+
// Repetitive examples
117+
/#### Example[\s\S]*?(?=\n####|\n###|\n##|$)/g,
118+
];
119+
120+
// Remove identified sections
121+
sectionsToRemove.forEach((regex) => {
122+
content = content.replace(regex, '');
123+
});
124+
125+
// Condense whitespace
126+
content = content.replace(/\n{3,}/g, '\n\n');
127+
128+
// Remove HTML comments
129+
content = content.replace(/<!--[\s\S]*?-->/g, '');
130+
131+
// Shorten repetitive content
132+
content = content.replace(/(\{%[^%]+%\})[\s\S]*?\1/g, (match) => {
133+
// If it's a long repeated pattern, show it once with a note
134+
if (match.length > 200) {
135+
const firstOccurrence = match.split('\n\n')[0];
136+
return (
137+
firstOccurrence +
138+
'\n\n[Similar patterns apply - see full CONTRIBUTING.md for complete examples]'
139+
);
140+
}
141+
return match;
142+
});
143+
144+
return content;
145+
}

compose.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,7 @@ services:
303303
container_name: influxdb3-core
304304
image: influxdb:3-core
305305
ports:
306-
- 8181:8181
307-
volumes:
308-
- type: bind
309-
source: test/influxdb3/core/data
310-
target: /var/lib/influxdb3/data
311-
- type: bind
312-
source: test/influxdb3/core/plugins
313-
target: /var/lib/influxdb3-plugins
306+
- 8282:8181
314307
command:
315308
- influxdb3
316309
- serve
@@ -319,6 +312,13 @@ services:
319312
- --object-store=file
320313
- --data-dir=/var/lib/influxdb3/data
321314
- --plugin-dir=/var/lib/influxdb3/plugins
315+
volumes:
316+
- type: bind
317+
source: test/.influxdb3/core/data
318+
target: /var/lib/influxdb3/data
319+
- type: bind
320+
source: test/.influxdb3/core/plugins
321+
target: /var/lib/influxdb3/plugins
322322
influxdb3-enterprise:
323323
container_name: influxdb3-enterprise
324324
image: influxdb:3-enterprise
@@ -339,10 +339,10 @@ services:
339339
- --license-email=${INFLUXDB3_LICENSE_EMAIL}
340340
volumes:
341341
- type: bind
342-
source: test/influxdb3/enterprise/data
342+
source: test/.influxdb3/enterprise/data
343343
target: /var/lib/influxdb3/data
344344
- type: bind
345-
source: test/influxdb3/enterprise/plugins
345+
source: test/.influxdb3/enterprise/plugins
346346
target: /var/lib/influxdb3/plugins
347347
telegraf-pytest:
348348
container_name: telegraf-pytest

test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ tmp
1010
.config*
1111
.env*
1212
**/.env.test
13+
.influxdb3
1314
.pytest_cache
1415
.test-run.txt

test/influxdb3-plugins/request.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/influxdb3-plugins/schedule.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/influxdb3-plugins/wal_table.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/influxdb3/auth.test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# [core3,enterprise3]
3+
# Bearer auth works with v1 /query
4+
curl -v http://localhost:8181/query \
5+
--header "Authorization: Bearer ${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}" \
6+
--data-urlencode "db=sensors" \
7+
--data-urlencode "q=SELECT * FROM home"
8+
9+
# Bearer auth works with v1 /write
10+
curl -v "http://localhost:8181/write?db=sensors" \
11+
--header "Authorization: Bearer ${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}" \
12+
--data-raw "sensors,location=home temperature=23.5 1622547800"
13+
14+
# Basic auth works with v1 /write
15+
curl -v "http://localhost:8181/write?db=sensors" \
16+
--user "admin:${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}" \
17+
--data-raw "sensors,location=home temperature=23.5 1622547800"
18+
19+
# URL auth works with v1 /write
20+
curl -v "http://localhost:8181/write?db=sensors&u=admin&p=${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}" \
21+
--data-raw "sensors,location=home temperature=23.5 1622547800"
22+
23+
# Token auth works with /api/v2/write
24+
curl -v http://localhost:8181/write?db=sensors \
25+
--header "Authorization: Token ${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}" \
26+
--data-raw "sensors,location=home temperature=23.5 1622547800"

test/influxdb3/database.test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [core3,enterprise3]
2+
# Delete a database with hard delete at date
3+
curl -v -X DELETE "http://localhost:8181/api/v3/configure/database?hard_delete_at=20250701&db=sensors" \
4+
--header "Authorization: Bearer ${INFLUXDB3_ENTERPRISE_ADMIN_TOKEN}"

0 commit comments

Comments
 (0)