Skip to content

Commit c635ab7

Browse files
l0lawrencecperaltahCopilot
authored
Merge initial generate step+tooling (#41316)
* sever typespec * stash * added logging, and we get folder output on tsp init command * keeps trying to create a new env, removing this for now * adding root_dir **unsure if this is working * mcp * add validation server * update mcp.json * update pyproject.toml * copilot instructions * Editing (#40814) * thjis * naming * add ghtoken * only 3.10 and above * trying this * url * fixed * fix * fixes * this works * this * this is working better * this * add root dir * some clean up and wip for tox version checking * add * this * working init * updating for local * fix init scenario * add more info about init * need pip (#41070) * updating tools * tool change (#41098) * Updating instructions (#41249) * wording * wording of mcp server * this? * update tox * stdin issue with tox * try to do the same for tsp-client * needs root dir * tweaks * duplication * updating instructions * edits * update instr * update inst * explicit do not repeat * updating instructions, remove gh token * remove comments * editing * duplication * ai edited instructions * claude adding time constraints * rename to typespec * updating tools * wording * docs * typo * typo * cpsell * update readme * update * dependencies * updater * Update tools/mcp/validation/main.py Co-authored-by: Copilot <[email protected]> * Update tools/mcp/typespec/main.py Co-authored-by: Copilot <[email protected]> * remove error section * copilot comments * copilot comments --------- Co-authored-by: catalinaperalta <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 3b855c6 commit c635ab7

File tree

12 files changed

+2377
-19
lines changed

12 files changed

+2377
-19
lines changed

.github/copilot-instructions.md

Lines changed: 215 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,224 @@
1-
# Copilot Instructions
1+
# AZURE SDK FOR PYTHON - COPILOT INSTRUCTIONS
22

3-
DO prompt the user to create a virtual environment with `<path_to_python_installation>/python.exe -m venv <environment_name>` and activate it, before running any commands.
3+
---
44

5-
# General Repository Guidelines
6-
- DO check this [website](https://azure.github.io/azure-sdk/python_design.html), and link to pages found there, if possible, when asked about guidelines, or guidance on how to write SDKs. The general guidelines for SDK in this repo are defined there.
5+
## CORE PRINCIPLES
76

8-
# Pylint
7+
### RULE 1: DO NOT REPEAT INSTRUCTIONS
8+
**NEVER repeat instructions when guiding users. Users should follow instructions independently.**
99

10-
## Running Pylint
11-
- When asked how to run pylint, or given a command to run pylint, DO check [this website](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md) and guide the user based on the information you find there.
12-
- DO use a python 3.8 environment that is compatible with the code you are working on. If you are not sure, please ask the user for the python version they are using.
10+
### RULE 2: REFERENCE OFFICIAL DOCUMENTATION
11+
**ALWAYS** reference the [Azure SDK Python Design Guidelines](https://azure.github.io/azure-sdk/python_design.html)
12+
- Link to specific pages when answering guidelines questions
13+
- Use this as the authoritative source for SDK development guidance
1314

15+
### RULE 3: VERIFY ENVIRONMENT FIRST
16+
**BEFORE any commands:**
17+
1. Use `verify_setup` tool from azure-sdk-validation server
18+
2. Ensure Python virtual environment is active
1419

15-
## Fixing Pylint Warnings
20+
**Virtual Environment Setup:**
21+
```bash
22+
# Create new environment
23+
python -m venv <env_name>
1624

17-
### Dos and Don'ts
18-
- DO use the table in https://github.com/Azure/azure-sdk-tools/blob/main/tools/pylint-extensions/azure-pylint-guidelines-checker/README.md and the code examples as a guide on how to fix each rule.
19-
- DO refer to the pylint documentation: https://pylint.readthedocs.io/en/stable/user_guide/checkers/features.html.
25+
# Activate environment
26+
# Linux/macOS:
27+
source <env_name>/bin/activate
28+
# Windows:
29+
<env_name>\Scripts\activate
30+
```
2031

32+
---
2133

22-
- DO NOT solve a pylint warning if you are not 100% confident about the answer. If you think your approach might not be the best, stop trying to fix the warning and leave it as is.
23-
- DO NOT create a new file when solving a pylint error, all solutions must remain in the current file.
24-
- DO NOT import a module or modules that do not exist to solve a pylint warning.
25-
- DO NOT add new dependencies or imports to the project to solve a pylint warning.
26-
- DO NOT make larger changes where a smaller change would fix the issue.
27-
- DO NOT change the code style or formatting of the code unless it is necessary to fix a pylint warning.
28-
- DO NOT delete code or files unless it is necessary to fix a warning.
34+
## TYPESPEC SDK GENERATION - COMPLETE WORKFLOW
35+
36+
### PHASE 1: CONTEXT ASSESSMENT
37+
38+
**ACTION:** Determine TypeSpec project location
39+
```
40+
IF TypeSpec project paths exist in context:
41+
USE local paths to generate SDK from tspconfig.yaml
42+
ELSE:
43+
ASK user for tspconfig.yaml file path
44+
```
45+
46+
### PHASE 2: PREREQUISITES CHECK
47+
48+
**REQUIRED CONDITIONS:**
49+
1. GitHub CLI authenticated: `gh auth login`
50+
2. User on feature branch (NOT main)
51+
```bash
52+
git checkout -b <branch_name>
53+
```
54+
55+
### PHASE 3: TSP-CLIENT RULES
56+
57+
**CRITICAL RULES:**
58+
- **LOCAL REPO:** Do NOT grab commit hash
59+
- **DIRECTORIES:** Let commands auto-create directories
60+
- **PACKAGE GENERATION:** Find tsp-location.yaml in azure-sdk-for-python repo
61+
- **URL REFERENCES:** Use commit hash (NOT branch name) for tspconfig.yaml URLs
62+
63+
**Get latest commit hash:**
64+
```bash
65+
curl -s "https://api.github.com/repos/Azure/azure-rest-api-specs/commits?path=<path_to_tspconfig.yaml>&per_page=1"
66+
```
67+
68+
**DEPENDENCIES:** Verify installation of: node, python, tox
69+
70+
---
71+
72+
## EXECUTION SEQUENCE - 7 MANDATORY STEPS
73+
74+
**ESTIMATED TOTAL TIME: 10-15 minutes**
75+
- SDK Generation: 5-6 minutes
76+
- Static Validation: 3-5 minutes
77+
- Documentation & Commit: 2-4 minutes
78+
79+
**ALWAYS inform users of time expectations before starting any long-running operations.**
80+
81+
### STEP 1: ENVIRONMENT VERIFICATION
82+
```
83+
ACTION: Run verify_setup tool
84+
IF missing dependencies:
85+
STOP and install missing dependencies
86+
THEN proceed to Step 2
87+
```
88+
89+
### STEP 2: SDK GENERATION
90+
```
91+
ACTION: Use typespec-python mcp server tools
92+
TIMING: ALWAYS inform user before starting: "This SDK generation step will take approximately 5-6 minutes to complete."
93+
IF local path provided:
94+
USE local mcp tools with tspconfig.yaml path
95+
IF commands fail:
96+
ANALYZE error messages
97+
DIRECT user to fix TypeSpec errors in source repo
98+
```
99+
100+
### STEP 3: STATIC VALIDATION (SEQUENTIAL)
101+
```
102+
TIMING: Inform user: "Static validation will take approximately 3-5 minutes for each step."
103+
FOR EACH validation step:
104+
RUN validation
105+
IF errors/warnings found:
106+
FIX issues
107+
RERUN same step
108+
ONLY proceed to next step when current step passes
109+
```
110+
111+
**Validation Commands:**
112+
```bash
113+
# Step 3a: Pylint
114+
tox -e pylint -c [path to tox.ini] --root .
115+
116+
# Step 3b: MyPy
117+
tox -e mypy -c [path to tox.ini] --root .
118+
119+
# Step 3c: Pyright
120+
tox -e pyright -c [path to tox.ini] --root .
121+
122+
# Step 3d: Verifytypes
123+
tox -e verifytypes -c [path to tox.ini] --root .
124+
```
125+
126+
**REQUIREMENTS:**
127+
- Provide summary after each validation step
128+
- Edit ONLY files with validation errors/warnings
129+
- Fix each issue before proceeding
130+
131+
### STEP 4: DOCUMENTATION UPDATE
132+
```
133+
REQUIRED ACTIONS:
134+
1. CREATE/UPDATE CHANGELOG.md with changes
135+
2. VERIFY package version matches API spec version
136+
3. IF version incorrect: UPDATE _version.py AND CHANGELOG
137+
4. SET CHANGELOG entry date to TODAY
138+
```
139+
140+
### STEP 5: COMMIT AND PUSH
141+
```
142+
ACTION: Show changed files (ignore .github, .vscode)
143+
IF user confirms:
144+
git add <changed_files>
145+
git commit -m "<commit_message>"
146+
git push -u origin <branch_name>
147+
IF authentication fails:
148+
PROMPT: gh auth login
149+
IF user rejects:
150+
GUIDE to fix issues and revalidate
151+
```
152+
153+
### STEP 6: PULL REQUEST MANAGEMENT
154+
```
155+
CHECK: Does PR exist for current branch?
156+
IF PR exists:
157+
SHOW PR details
158+
IF NO PR exists:
159+
VERIFY branch != "main"
160+
PUSH changes to remote
161+
GENERATE PR title and description
162+
CREATE PR in DRAFT mode
163+
RETURN PR link
164+
ALWAYS: Display PR summary with status, checks, action items
165+
```
166+
167+
### STEP 7: HANDOFF
168+
```
169+
FINAL ACTIONS:
170+
1. RETURN PR URL for review
171+
2. PROMPT user with exact text:
172+
"Use the azure-rest-api-specs agent to handle the rest of the process and provide it the pull request."
173+
```
174+
175+
---
176+
177+
## PYLINT OPERATIONS
178+
179+
### RUNNING PYLINT
180+
181+
**REFERENCE DOCUMENTATION:**
182+
- [Official pylint guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)
183+
- [Tox formatting guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#tox)
184+
185+
**COMMAND:**
186+
```bash
187+
tox -e pylint --c <path_to_tox.ini> --root .
188+
```
189+
190+
**DEFAULT PATH:** `azure-sdk-for-python/eng/tox/tox.ini`
191+
192+
### FIXING PYLINT WARNINGS
193+
194+
**REFERENCE SOURCES:**
195+
- [Azure pylint guidelines](https://github.com/Azure/azure-sdk-tools/blob/main/tools/pylint-extensions/azure-pylint-guidelines-checker/README.md)
196+
- [Pylint documentation](https://pylint.readthedocs.io/en/stable/user_guide/checkers/features.html)
197+
198+
**ALLOWED ACTIONS:**
199+
✅ Fix warnings with 100% confidence
200+
✅ Use existing file for all solutions
201+
✅ Reference official guidelines
202+
203+
**FORBIDDEN ACTIONS:**
204+
❌ Fix warnings without complete confidence
205+
❌ Create new files for solutions
206+
❌ Import non-existent modules
207+
❌ Add new dependencies/imports
208+
❌ Make unnecessary large changes
209+
❌ Change code style without reason
210+
❌ Delete code without clear justification
211+
212+
---
213+
214+
## MYPY OPERATIONS
215+
216+
### RUNNING AND FIXING MYPY
217+
218+
**REFERENCE DOCUMENTATION:**
219+
- [Tox guidance](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#tox)
220+
- [MyPy fixing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking_cheat_sheet.md)
221+
222+
**REQUIREMENTS:**
223+
- Use Python 3.9 compatible environment
224+
- Follow official fixing guidelines

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
"entra",
254254
"envname",
255255
"evals",
256+
"fastmcp",
256257
"fileno",
257258
"fqdns",
258259
"fstat",

.vscode/mcp.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"servers": {
3+
"typespec-python": {
4+
"command": "uv",
5+
"args": [
6+
"--directory",
7+
"${workspaceFolder}/tools/mcp/typespec/",
8+
"run",
9+
"main.py"
10+
],
11+
},
12+
"azure-sdk-validation": {
13+
"command": "uv",
14+
"args": [
15+
"--directory",
16+
"${workspaceFolder}/tools/mcp/validation/",
17+
"run",
18+
"main.py"
19+
]
20+
},
21+
}
22+
}

0 commit comments

Comments
 (0)