Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d4fef13
sever typespec
l0lawrence Apr 24, 2025
36b0850
stash
l0lawrence Apr 24, 2025
7e8b8eb
added logging, and we get folder output on tsp init command
l0lawrence Apr 24, 2025
f19bb2f
keeps trying to create a new env, removing this for now
l0lawrence Apr 24, 2025
c56698d
adding root_dir **unsure if this is working
l0lawrence Apr 24, 2025
634716a
mcp
l0lawrence Apr 29, 2025
e041e32
add validation server
cperaltah Apr 30, 2025
76883c4
update mcp.json
cperaltah Apr 30, 2025
d8eb3cd
update pyproject.toml
cperaltah Apr 30, 2025
aeb1f84
copilot instructions
cperaltah Apr 30, 2025
702fd24
Editing (#40814)
l0lawrence Apr 30, 2025
abf9905
fix
cperaltah Apr 30, 2025
8c1cc77
fixes
cperaltah Apr 30, 2025
7202429
this works
l0lawrence May 1, 2025
1af86fe
this
l0lawrence May 2, 2025
e7e144f
this is working better
l0lawrence May 2, 2025
b8007d0
this
l0lawrence May 2, 2025
b7d52e7
add root dir
l0lawrence May 2, 2025
6744f68
some clean up and wip for tox version checking
cperaltah May 2, 2025
1bf3a61
add
l0lawrence May 7, 2025
7de1b80
this
l0lawrence May 7, 2025
a121425
working init
l0lawrence May 9, 2025
4f97e11
updating for local
l0lawrence May 12, 2025
7d574c2
fix init scenario
cperaltah May 13, 2025
edeec97
add more info about init
cperaltah May 13, 2025
9ba4d9f
need pip (#41070)
l0lawrence May 13, 2025
91ab6cc
updating tools
l0lawrence May 14, 2025
fd9e90f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
l0lawrence May 14, 2025
3e7b7d4
tool change (#41098)
l0lawrence May 14, 2025
bd332a0
Updating instructions (#41249)
l0lawrence May 22, 2025
0bb2de3
tweaks
l0lawrence May 22, 2025
98ec307
duplication
l0lawrence May 22, 2025
f6027c2
updating instructions
l0lawrence May 22, 2025
42fa194
edits
l0lawrence May 23, 2025
1b67e85
update instr
l0lawrence May 23, 2025
6068475
update inst
l0lawrence May 23, 2025
d6290fd
explicit do not repeat
l0lawrence May 26, 2025
6707b55
updating instructions, remove gh token
l0lawrence May 27, 2025
994b70c
remove comments
l0lawrence May 27, 2025
2060862
editing
l0lawrence May 27, 2025
66da7d2
duplication
l0lawrence May 27, 2025
bbea24c
ai edited instructions
l0lawrence May 27, 2025
fecbaf4
claude adding time constraints
l0lawrence May 28, 2025
f5415be
rename to typespec
l0lawrence May 28, 2025
a8da013
updating tools
l0lawrence May 28, 2025
90eda28
wording
l0lawrence May 28, 2025
cf84a26
docs
l0lawrence May 28, 2025
0dfb5a8
typo
l0lawrence May 28, 2025
c9355bc
typo
l0lawrence May 28, 2025
cd78399
cpsell
l0lawrence May 29, 2025
bcaae05
update readme
l0lawrence May 29, 2025
04172bf
update
l0lawrence May 29, 2025
b3a83e8
dependencies
l0lawrence May 29, 2025
91e13f9
updater
l0lawrence May 29, 2025
40e1c99
Update tools/mcp/validation/main.py
l0lawrence May 29, 2025
304469a
Update tools/mcp/typespec/main.py
l0lawrence May 29, 2025
9db729e
remove error section
l0lawrence May 29, 2025
c643a76
copilot comments
l0lawrence May 29, 2025
cd79006
copilot comments
l0lawrence May 29, 2025
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
234 changes: 215 additions & 19 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,224 @@
# Copilot Instructions
# AZURE SDK FOR PYTHON - COPILOT INSTRUCTIONS

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.
---

# General Repository Guidelines
- 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.
## CORE PRINCIPLES

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

## Running Pylint
- 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.
- 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.
### RULE 2: REFERENCE OFFICIAL DOCUMENTATION
**ALWAYS** reference the [Azure SDK Python Design Guidelines](https://azure.github.io/azure-sdk/python_design.html)
- Link to specific pages when answering guidelines questions
- Use this as the authoritative source for SDK development guidance

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

## Fixing Pylint Warnings
**Virtual Environment Setup:**
```bash
# Create new environment
python -m venv <env_name>

### Dos and Don'ts
- 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.
- DO refer to the pylint documentation: https://pylint.readthedocs.io/en/stable/user_guide/checkers/features.html.
# Activate environment
# Linux/macOS:
source <env_name>/bin/activate
# Windows:
<env_name>\Scripts\activate
```

---

- 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.
- DO NOT create a new file when solving a pylint error, all solutions must remain in the current file.
- DO NOT import a module or modules that do not exist to solve a pylint warning.
- DO NOT add new dependencies or imports to the project to solve a pylint warning.
- DO NOT make larger changes where a smaller change would fix the issue.
- DO NOT change the code style or formatting of the code unless it is necessary to fix a pylint warning.
- DO NOT delete code or files unless it is necessary to fix a warning.
## TYPESPEC SDK GENERATION - COMPLETE WORKFLOW

### PHASE 1: CONTEXT ASSESSMENT

**ACTION:** Determine TypeSpec project location
```
IF TypeSpec project paths exist in context:
USE local paths to generate SDK from tspconfig.yaml
ELSE:
ASK user for tspconfig.yaml file path
```

### PHASE 2: PREREQUISITES CHECK

**REQUIRED CONDITIONS:**
1. GitHub CLI authenticated: `gh auth login`
2. User on feature branch (NOT main)
```bash
git checkout -b <branch_name>
```

### PHASE 3: TSP-CLIENT RULES

**CRITICAL RULES:**
- **LOCAL REPO:** Do NOT grab commit hash
- **DIRECTORIES:** Let commands auto-create directories
- **PACKAGE GENERATION:** Find tsp-location.yaml in azure-sdk-for-python repo
- **URL REFERENCES:** Use commit hash (NOT branch name) for tspconfig.yaml URLs

**Get latest commit hash:**
```bash
curl -s "https://api.github.com/repos/Azure/azure-rest-api-specs/commits?path=<path_to_tspconfig.yaml>&per_page=1"
```

**DEPENDENCIES:** Verify installation of: node, python, tox

---

## EXECUTION SEQUENCE - 7 MANDATORY STEPS

**ESTIMATED TOTAL TIME: 10-15 minutes**
- SDK Generation: 5-6 minutes
- Static Validation: 3-5 minutes
- Documentation & Commit: 2-4 minutes

**ALWAYS inform users of time expectations before starting any long-running operations.**

### STEP 1: ENVIRONMENT VERIFICATION
```
ACTION: Run verify_setup tool
IF missing dependencies:
STOP and install missing dependencies
THEN proceed to Step 2
```

### STEP 2: SDK GENERATION
```
ACTION: Use typespec-python mcp server tools
TIMING: ALWAYS inform user before starting: "This SDK generation step will take approximately 5-6 minutes to complete."
IF local path provided:
USE local mcp tools with tspconfig.yaml path
IF commands fail:
ANALYZE error messages
DIRECT user to fix TypeSpec errors in source repo
```

### STEP 3: STATIC VALIDATION (SEQUENTIAL)
```
TIMING: Inform user: "Static validation will take approximately 3-5 minutes for each step."
FOR EACH validation step:
RUN validation
IF errors/warnings found:
FIX issues
RERUN same step
ONLY proceed to next step when current step passes
```

**Validation Commands:**
```bash
# Step 3a: Pylint
tox -e pylint -c [path to tox.ini] --root .

# Step 3b: MyPy
tox -e mypy -c [path to tox.ini] --root .

# Step 3c: Pyright
tox -e pyright -c [path to tox.ini] --root .

# Step 3d: Verifytypes
tox -e verifytypes -c [path to tox.ini] --root .
Comment thread
l0lawrence marked this conversation as resolved.
```

**REQUIREMENTS:**
- Provide summary after each validation step
- Edit ONLY files with validation errors/warnings
- Fix each issue before proceeding

### STEP 4: DOCUMENTATION UPDATE
```
REQUIRED ACTIONS:
1. CREATE/UPDATE CHANGELOG.md with changes
2. VERIFY package version matches API spec version
3. IF version incorrect: UPDATE _version.py AND CHANGELOG
4. SET CHANGELOG entry date to TODAY
```

### STEP 5: COMMIT AND PUSH
```
ACTION: Show changed files (ignore .github, .vscode)
IF user confirms:
git add <changed_files>
git commit -m "<commit_message>"
git push -u origin <branch_name>
IF authentication fails:
PROMPT: gh auth login
IF user rejects:
GUIDE to fix issues and revalidate
```

### STEP 6: PULL REQUEST MANAGEMENT
```
CHECK: Does PR exist for current branch?
IF PR exists:
SHOW PR details
IF NO PR exists:
VERIFY branch != "main"
PUSH changes to remote
GENERATE PR title and description
CREATE PR in DRAFT mode
RETURN PR link
ALWAYS: Display PR summary with status, checks, action items
```

### STEP 7: HANDOFF
```
FINAL ACTIONS:
1. RETURN PR URL for review
2. PROMPT user with exact text:
"Use the azure-rest-api-specs agent to handle the rest of the process and provide it the pull request."
```

---

## PYLINT OPERATIONS

### RUNNING PYLINT

**REFERENCE DOCUMENTATION:**
- [Official pylint guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)
- [Tox formatting guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#tox)

**COMMAND:**
```bash
tox -e pylint --c <path_to_tox.ini> --root .
```

**DEFAULT PATH:** `azure-sdk-for-python/eng/tox/tox.ini`

### FIXING PYLINT WARNINGS

**REFERENCE SOURCES:**
- [Azure pylint guidelines](https://github.com/Azure/azure-sdk-tools/blob/main/tools/pylint-extensions/azure-pylint-guidelines-checker/README.md)
- [Pylint documentation](https://pylint.readthedocs.io/en/stable/user_guide/checkers/features.html)

**ALLOWED ACTIONS:**
✅ Fix warnings with 100% confidence
✅ Use existing file for all solutions
✅ Reference official guidelines

**FORBIDDEN ACTIONS:**
❌ Fix warnings without complete confidence
❌ Create new files for solutions
❌ Import non-existent modules
❌ Add new dependencies/imports
❌ Make unnecessary large changes
❌ Change code style without reason
❌ Delete code without clear justification

---

## MYPY OPERATIONS

### RUNNING AND FIXING MYPY

**REFERENCE DOCUMENTATION:**
- [Tox guidance](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#tox)
- [MyPy fixing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking_cheat_sheet.md)

**REQUIREMENTS:**
- Use Python 3.9 compatible environment
- Follow official fixing guidelines
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"entra",
"envname",
"evals",
"fastmcp",
"fileno",
"fqdns",
"fstat",
Expand Down
22 changes: 22 additions & 0 deletions .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"servers": {
"typespec-python": {
Comment thread
l0lawrence marked this conversation as resolved.
"command": "uv",
"args": [
"--directory",
"${workspaceFolder}/tools/mcp/typespec/",
"run",
"main.py"
],
},
"azure-sdk-validation": {
"command": "uv",
"args": [
"--directory",
"${workspaceFolder}/tools/mcp/validation/",
"run",
"main.py"
]
},
}
}
Loading