You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+93-47Lines changed: 93 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,38 @@
1
+
# New TypeSpec projects
2
+
3
+
Before creating or initializing a TypeSpec project, you must know your org name, service name, and the type of service: data-plane or control-plane (ARM).
4
+
5
+
Then create a new project directory under the `specification/<orgName>/resource-manager/<RPNamespace>/<ServiceName>` or `specification/<orgName>/data-plane/<ServiceName>` path, following the guidelines below.
6
+
7
+
```
8
+
specification/
9
+
└── <orgName1>/
10
+
├── cspell.yaml
11
+
└── resource-manager/
12
+
├── readme.md ß NOTE: For ARM schema validation; see bullet #2 below
13
+
└── <RPNamespace>/ ß NOTE: Control-plane only (not data-plane)
14
+
└── <ServiceName1>/ ß Customer-facing service name; each version gets Documentation & SDK package
15
+
├── tspconfig.yaml ß TypeSpec files
16
+
├── main.tsp
17
+
├── models.tsp
18
+
├── readme.md ß autorest readme with YAML blocks
19
+
└── examples/ ß TypeSpec example folder
20
+
└── <api-version>/ ß One folder per service version described in TypeSpec
21
+
└── <example .json files>
22
+
└── preview/ and stable/
23
+
└── <api-version>/ ß One folder per service version described in OpenAPI. These folders are created and populated by compiling the TypeSpec folder for the service.
24
+
├── <OpenAPI .json files>
25
+
└── examples/ ß OpenAPI example folder
26
+
└── <example .json files>
27
+
└── <ServiceName2>/ // Customer-facing service name; contents identical to above structure
28
+
└── data-plane/
29
+
└── <ServiceName3>/ // Customer-facing service name; contents identical to above structure
30
+
```
31
+
32
+
Use the `./specification/widget` directory as a reference for creating your own project directory.
33
+
34
+
Only after the project directory is created according to the above guidelines may you run the `azsdk_init_typespec_project` tool to initialize the project.
35
+
1
36
## Converting a specification from swagger to typespec
2
37
3
38
Users can convert a specification from swagger to typespec by using `tsp-client` a CLI designed to help developers throughout various stages of typespec development.
@@ -120,7 +155,6 @@ Examples of common errors and warnings that should be addressed after running th
- camelCase fixes only apply to the typespec property names, any corresponding string values you should left as is.
132
166
- String values in typespec files should be left untouched.
133
167
168
+
## Up-to-date TypeSpec documentation
169
+
170
+
Follow [typespec docs](../eng/common/instructions/azsdk-tools/typespec-docs.instructions.md) to get the most up-to-date documentation for TypeSpec, including best practices for writing TypeSpec for Azure.
- Check all open files in the editor and check if `main.tsp` or `tspconfig.yaml` are open in the editor. If either of
150
-
these files are open, then use the parent path of the `main.tsp` or `tspconfig.yaml` as default TypeSpec project root
151
-
path.
152
-
- If `main.tsp` and `tspconfig.yaml` are not open in the editor, then check if there are any TypeSpec project paths in
153
-
the context. If there are no TypeSpec project paths in the context, then prompt user to select a TypeSpec project path
154
-
from the list of paths. If user does not have a TypeSpec project, then prompt user to create a new TypeSpec project.
186
+
## Agent context for TypeSpec and SDK process
155
187
188
+
- Check all open files in the editor and check if `main.tsp` or `tspconfig.yaml` are open in the editor. If either of
189
+
these files are open, then use the parent path of the `main.tsp` or `tspconfig.yaml` as default TypeSpec project root
190
+
path.
191
+
- If `main.tsp` and `tspconfig.yaml` are not open in the editor, then check if there are any TypeSpec project paths in
192
+
the context. If there are no TypeSpec project paths in the context, then prompt user to select a TypeSpec project path
193
+
from the list of paths. If user does not have a TypeSpec project, then prompt user to create a new TypeSpec project.
156
194
157
195
### Prerequisites
196
+
158
197
- User should have a GitHub account and should be logged in to GitHub account using GitHub CLI `gh auth login`.
159
198
- run `npm ci` to install the dependencies
160
199
- To use Azure MCP tool calls, the user must have PowerShell installed. Provide [PowerShell installation instructions](https://learn.microsoft.com/powershell/scripting/install/installing-powershell) if not installed, and recommend restarting the IDE to start the MCP server.
161
200
162
-
163
201
### Basic Rules for SDK Generation from TypeSpec
164
202
165
203
1.**User Guidance**:
166
-
- Assume the user is unfamiliar with the SDK release process. Provide clear, concise instructions for each step.
204
+
- Assume the user is unfamiliar with the SDK release process. Provide clear, concise instructions for each step.
167
205
168
206
2.**File Handling**:
169
-
- Do not overwrite `tspconfig.yaml` or `main.tsp`. Use existing files and suggest updates if necessary.
170
-
- Use the path of the `tspconfig.yaml` file already open in the editor or the `.tsp` file path as the project root.
171
-
- If no `.tsp` file or folder is in the current context, prompt the user to select a valid TypeSpec project root path.
207
+
- Do not overwrite `tspconfig.yaml` or `main.tsp`. Use existing files and suggest updates if necessary.
208
+
- Use the path of the `tspconfig.yaml` file already open in the editor or the `.tsp` file path as the project root.
209
+
- If no `.tsp` file or folder is in the current context, prompt the user to select a valid TypeSpec project root path.
172
210
173
211
3.**Process Visibility**:
174
-
- Highlight all steps in the SDK generation process, showing completed and remaining steps.
175
-
- Do not skip any main steps. Ensure all steps are completed before moving to the next.
212
+
- Highlight all steps in the SDK generation process, showing completed and remaining steps.
213
+
- Do not skip any main steps. Ensure all steps are completed before moving to the next.
176
214
177
215
4.**Git Operations**:
178
-
- Avoid using the `main` branch for pull requests. Prompt the user to create or switch to a new branch if necessary.
179
-
- Display git commands (e.g., `git checkout`, `git add`, `git commit`, `git push`) with a "Run" button instead of
180
-
asking the user to copy and paste.
181
-
- Do not run `git diff`
216
+
- Avoid using the `main` branch for pull requests. Prompt the user to create or switch to a new branch if necessary.
217
+
- Display git commands (e.g., `git checkout`, `git add`, `git commit`, `git push`) with a "Run" button instead of
218
+
asking the user to copy and paste.
219
+
- Do not run `git diff`
182
220
183
221
5.**Azure-Specific Rules**:
184
-
- Always use `Azure` as the repo owner in MCP tool calls.
185
-
- Confirm with the user if they want to change the repo owner or target branch, and prompt for new values if needed.
222
+
- Always use `Azure` as the repo owner in MCP tool calls.
223
+
- Confirm with the user if they want to change the repo owner or target branch, and prompt for new values if needed.
186
224
187
225
6.**Exclusions**:
188
-
- Exclude changes to the `.gitignore` file and contents within the `.github` and `.vscode` folders from API spec and SDK pull requests.
226
+
- Exclude changes to the `.gitignore` file and contents within the `.github` and `.vscode` folders from API spec and SDK pull requests.
189
227
190
228
7.**Working Branch Rule**:
191
-
- If the typespec pull request already exists or is merged stay on the `main` branch, otherwise ensure the TypeSpec project repository and the current working repository are not on the `main` branch:
192
-
- Check the current branch name for the cloned GitHub repository:
193
-
- If the current branch is `main`, prompt the user to create a new branch using
194
-
`git checkout -b <branch name>`.
195
-
- If the current branch is not `main`, prompt the user to either select an existing branch or create a
196
-
new one.
197
-
- For branch switching:
198
-
- If a branch already exists and differs from the current branch, prompt the user to switch using
199
-
`git checkout <branch name>`.
200
-
- GitHub pull requests cannot be created from the `main` branch. Ensure all changes are made on a non-`main` branch.
229
+
- If the typespec pull request already exists or is merged stay on the `main` branch, otherwise ensure the TypeSpec project repository and the current working repository are not on the `main` branch:
230
+
- Check the current branch name for the cloned GitHub repository:
231
+
- If the current branch is `main`, prompt the user to create a new branch using
232
+
`git checkout -b <branch name>`.
233
+
- If the current branch is not `main`, prompt the user to either select an existing branch or create a
234
+
new one.
235
+
- For branch switching:
236
+
- If a branch already exists and differs from the current branch, prompt the user to switch using
237
+
`git checkout <branch name>`.
238
+
- GitHub pull requests cannot be created from the `main` branch. Ensure all changes are made on a non-`main` branch.
201
239
202
240
By following these rules, the SDK release process will remain clear, structured, and user-friendly.
203
241
204
242
## Steps to generate SDK from TypeSpec API specification
243
+
205
244
Follow [typespec to sdk](..\eng\common\instructions\azsdk-tools\typespec-to-sdk.instructions.md) to generate and release SDK from TypeSpec API specification. The process is divided into several steps, each with specific actions to ensure a smooth SDK generation and release process.
206
245
Do not skip the step that choose SDK generation method to ensure the user selects the appropriate method for SDK generation, either locally or using the SDK generation pipeline. Do not repeat the steps. Before using tools, check if user has Powershell installed.
207
246
@@ -210,24 +249,31 @@ Do not skip the step that choose SDK generation method to ensure the user select
210
249
3.**Verify Authentication and Repository Status**: Ensure user is authenticated and working in the correct public Azure repository.
211
250
4.**Review and Commit Changes**: Stage and commit TypeSpec modifications, ensuring the current branch is not "main". Do not create pull request yet.
212
251
5.**Create Specification Pull Request**: Create a pull request for TypeSpec changes if not already created. This is required only if there are TypeSpec changes in current branch.
213
-
6.**Choose SDK Generation Method**: Determine how to generate SDKs (locally or via pipeline). Only Python is supported for local SDK generation at this time.
214
-
7.**Generate SDKs via Pipeline**: Generate SDKs using [run sdk gen pipeline](..\eng\common\instructions\azsdk-tools\run-sdk-gen-pipeline.instructions.md), monitor the pipeline status and displaying generated SDK PR links.
252
+
6.**Choose SDK Generation Method**: Determine how to generate SDKs (locally or via pipeline).
253
+
7.**Generate SDKs via Pipeline**: Generate SDKs using [run sdk gen pipeline](..\eng\common\instructions\azsdk-tools\run-sdk-gen-pipeline.instructions.md), monitor the pipeline status and displaying generated SDK PR links.
215
254
8.**Show generated SDK PR**: Display the generated SDK pull request links for review.
216
-
9.**Validate Label and then Codeowners**: Validate the service label and codeowners for the created SDK service using both [validate service label](..\eng\common\instructions\azsdk-tools\validate-service-label.instructions.md) and [validate codeowners](..\eng\common\instructions\azsdk-tools\validate-codeowners.instructions.md).
217
-
10.**Create a release plan**: To create a release plan refer to [create release plan](..\eng\common\instructions\azsdk-tools\create-release-plan.instructions.md)
218
-
11.**Prompt user to change spec pull request to ready for review from draft status**: Update spec pull request to change it to ready for review.
219
-
12.**Release package**: Release the SDK package using `azsdk_release_sdk` tool.
255
+
9.**Create a release plan**: To create a release plan refer to [create release plan](..\eng\common\instructions\azsdk-tools\create-release-plan.instructions.md)
256
+
10.**Prompt user to change spec pull request to ready for review from draft status**: Update spec pull request to change it to ready for review.
257
+
11.**Release package**: Release the SDK package using `azsdk_release_sdk` tool.
220
258
221
259
## Release readiness of SDK and information about the release pipeline
260
+
222
261
Run [check package readiness](..\eng\common\instructions\azsdk-tools\check-package-readiness.instructions.md) to check the release readiness of an SDK package. This prompt will collect the required information from the user, execute the readiness check, and present the results.
223
262
224
263
## Instructions for GitHub coding agent to generate SDKs using GitHub.com
225
-
Run only SDK generation step and Update SDK details back in issue description and release plan. Do not run TypeSpec validation, or service label check. This is applicable only when GitHub copilot coding agent is used to generate SDK and if a Release Plan is available in the context.
264
+
265
+
Run only SDK generation step and Update SDK details back in issue description and release plan. Do not run TypeSpec validation, or service label check. This is applicable only when GitHub copilot coding agent is used to generate SDK and if a Release Plan is available in the context. Run SDK generation tool even if release plan already has SDK generation pipeline URL to support regenerating SDK.
226
266
Coding agent must wait until all SDK generation pipeline are in completed status and then fetch the SDK details from pipeline run. This is applicable only when a GitHub issue is assigned to GitHub coding agent to generate SDK from a TypeSpec project. This is not applicable when running Copilot from Visual Studio and VS Code.
227
-
228
-
steps:
229
-
- Run SDK generation pipeline for the given TypeSpec path for all languages mentioned in the description.
230
-
- Keep checking the pipeline status until pipeline is in completed or failed status.
231
-
- Find SDK pull request links from the pipeline run.
232
-
constraints:
233
-
- Do not invoke other steps
267
+
268
+
### Additional instructions:
269
+
270
+
- Run SDK generation pipeline for the given TypeSpec path for all languages mentioned in the description.
271
+
- Identify absolute path of TypeSpec project root path and send it to Run SDK generation MCP tool call.
272
+
- Keep checking the pipeline status until pipeline is in completed or failed status.
273
+
- Find SDK pull request links from the pipeline run.
274
+
275
+
### Constraints:
276
+
277
+
- Do not invoke other steps.
278
+
- Do not modify main.tsp file or any files in TypeSpec project.
279
+
- Do not add API version to an existing main.tsp if input API version is not present.
0 commit comments