Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
61 changes: 61 additions & 0 deletions sdk/ai/.skills/codegen/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: codegen
description: Generate code from TypeSpec via tsp-client (update, sync, generate). Requires a tsp-location.yaml in the current working directory. Supports updating the commit hash before running.
---

# TypeSpec Code Generation (tsp-client)

Use this skill to run `tsp-client` workflows for projects that include a `tsp-location.yaml` file.

## Preconditions
- You must be in the directory that contains `tsp-location.yaml`.
- If the file is missing, warn the user and ask for the correct directory (do not run commands).

## Commit hash update
If the user provides a commit hash, update the `commit:` field in `tsp-location.yaml` **before** running tsp-client.
- Read the file and locate the `commit:` line.
- Replace the value with the provided hash (keep the same key name and formatting).
- Example:
- Before: `commit: 6267b6...`
- After: `commit: <new_hash>`

## Commands

### `tsp-client update`
Pull the latest codegen tooling or definitions (default action when the user is vague).
```bash
tsp-client update
```

### `tsp-client sync`
Fetch/sync TypeSpec inputs for the project.
```bash
tsp-client sync
```

### `tsp-client generate`
Generate code from TypeSpec inputs.
```bash
tsp-client generate
```

Keep the synced TypeSpec inputs:
```bash
tsp-client generate --save-inputs
```

## Steps
1. Verify `tsp-location.yaml` exists in the current directory. If not, stop and ask for the correct location.
2. If the user provided a commit hash, update the `commit:` value in `tsp-location.yaml`.
3. Determine the user intent:
- **Refresh/update/ingest changes from a commit**: run `tsp-client update`.
- **Fetch/sync spec from the current commit**: run `tsp-client sync`.
- **Generate from fetched spec**: run `tsp-client generate` (use `--save-inputs` only if the user asks to keep inputs).
- **Generate (no fetch requested)**: run `tsp-client generate`.
4. If the user doesn’t specify, default to `tsp-client update`.
5. If the project defines or creates a `TempTypeSpecFiles` folder and the user wants code generation, run `tsp-client generate` (with `--save-inputs` if requested).
6. If a tsp-client command fails, report the error output and suggest checking the TypeSpec repo/commit referenced in `tsp-location.yaml`. Build a GitHub URL from `repo:` and `directory:` (and include the `commit:` as the ref), e.g.:
- Repo: `Azure/azure-rest-api-specs`
- Commit: `6267b6...`
- Directory: `specification/cognitiveservices/OpenAI.Inference`
- URL: `https://github.com/Azure/azure-rest-api-specs/tree/6267b6.../specification/cognitiveservices/OpenAI.Inference`
15 changes: 15 additions & 0 deletions sdk/ai/.skills/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import:
- ../../../.vscode/cspell.json
overrides:
- filename: "**/sdk/ai/.skills/*"
words:
- Danimal
- Dcheckstyle
- Dcodesnippet
- Djacoco
- dpkg
- Drevapi
- Dspotbugs
- Dspotless
- FQCN
- javap
61 changes: 61 additions & 0 deletions sdk/ai/.skills/dup-classes/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: dup-classes
description: Verify whether generated Java classes duplicate openai-java models by comparing fields/types (names may differ). Use when checking for duplicate model coverage.
---

# Duplicate Class Verification (Generated vs openai-java)

Use this skill to compare generated Java models against the `openai-java` dependency. The goal is **field-by-field** comparison of model shapes, even when class or field names differ.

## Inputs to confirm
- Generated source root (e.g., `src/main/java/...`)
- The relevant `pom.xml` (module) to resolve the `openai-java` dependency version
- Optional: package or class name hints to narrow the search

## Steps
1. **Locate the pom.xml** in the current directory tree (`find . -name pom.xml`). If multiple, ask which module to use.
2. **Resolve openai-java**:
- Search the chosen pom for `openai-java` (or an explicit group/artifact provided by the user).
- Resolve the version (including properties) and locate the JAR in `~/.m2/repository`.
3. **List candidate classes**:
- Generated classes: scan the source root for `class` and `record` declarations.
- openai-java classes: `jar tf <jar> | rg '\.class$'` (filter by package hints if provided).
4. **Extract field signatures** (names may differ; compare shape):
- **Generated source**:
- For `record`, use the component list in the `record` declaration.
- For `class`, extract non-static field declarations (type + count) and note any `@JsonProperty` names.
- **openai-java JAR**:
- Use `javap -classpath <jar> -p <FQCN>` to list fields (ignore `static`).
- If you need annotations, use `javap -classpath <jar> -p -verbose <FQCN>` and look for `RuntimeVisibleAnnotations`.
5. **Compare shapes**:
- Compare **field count** and **field types** (order-independent).
- If `@JsonProperty` names exist in generated sources, compare those names with the openai-java field names.
6. **Report duplicates**:
- Provide a table: generated class → openai-java class, with matching field types and any name mismatches.
- Flag candidates with high similarity (same count and same types) even if names differ.

## Useful commands

### List generated class names
```bash
rg -n "^(public\s+)?(final\s+)?(class|record)\s+" <generated_root>
```

### Extract field lines from source (classes)
```bash
rg -n "^(\s*)(public|protected|private)\s+(static\s+)?(final\s+)?[A-Za-z0-9_<>,\[\].]+\s+[A-Za-z0-9_]+;" <generated_root>
```

### Extract record components
```bash
rg -n "record\s+[A-Za-z0-9_]+\s*\(([^)]*)\)" <generated_root>
```

### Inspect fields in a JAR class
```bash
javap -classpath <jar> -p <fully.qualified.ClassName>
```

## Notes
- Use `search-m2` if you need help locating the dependency version or JAR path.
- If the user provides only a vague class hint, narrow candidates by package or field count first.
156 changes: 156 additions & 0 deletions sdk/ai/.skills/github/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
name: github
description: "Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries."
---

# GitHub Skill

Use the `gh` CLI to interact with GitHub. Always pass `--repo owner/repo` when not inside a cloned git directory.

## Pull Requests

List open PRs:
```bash
gh pr list --repo owner/repo
```

View a specific PR (summary, checks, comments):
```bash
gh pr view 55 --repo owner/repo
```

Check CI status on a PR:
```bash
gh pr checks 55 --repo owner/repo
```

## CI / Workflow Runs

List recent runs:
```bash
gh run list --repo owner/repo --limit 10
```

View a run summary (steps, status):
```bash
gh run view <run-id> --repo owner/repo
```

View logs for failed steps only:
```bash
gh run view <run-id> --repo owner/repo --log-failed
```

Re-run failed jobs:
```bash
gh run rerun <run-id> --repo owner/repo --failed
```

## Issues

List open issues (optionally filter by label):
```bash
gh issue list --repo owner/repo
gh issue list --repo owner/repo --label bug
```

View a specific issue:
```bash
gh issue view 42 --repo owner/repo
```

Create an issue:
```bash
gh issue create --repo owner/repo --title "Title" --body "Description" --label bug
```

## JSON Output & Filtering

Most commands support `--json` with `--jq` for structured output:

```bash
# List PR numbers and titles
gh pr list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'

# List issues with assignees
gh issue list --repo owner/repo --json number,title,assignees \
--jq '.[] | "\(.number): \(.title) → \(.assignees[].login // "unassigned")"'
```

## Advanced: `gh api`

Use `gh api` for data or actions not covered by other subcommands.

Fetch a PR with specific fields:
```bash
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
```

List check runs for a commit:
```bash
gh api repos/owner/repo/commits/<sha>/check-runs \
--jq '.check_runs[] | "\(.name): \(.conclusion)"'
```

Paginate results (e.g., all issues):
```bash
gh api --paginate repos/owner/repo/issues --jq '.[].title'
```

## Steps

1. Check if `gh` is installed by running `gh --version`.
- If the command is **not found**, install it (see [Installation](#installation) below).
2. Check if `gh` is authenticated by running `gh auth status`.
- If not authenticated, run `gh auth login`.
3. If `owner/repo` is not provided, check if there is a `.git` directory and infer the remote via `gh repo view --json nameWithOwner`. Otherwise ask the user for the repo.
4. Choose the appropriate subcommand (`pr`, `issue`, `run`, `api`) based on the user's request.
5. Prefer structured subcommands (`gh pr`, `gh issue`, `gh run`) over raw `gh api` when they cover the use case.
6. Use `--json` + `--jq` when the user needs specific fields or wants to pipe output into further processing.
7. If a workflow run is failing, start with `gh pr checks` for a quick overview, then `gh run view --log-failed` for detailed output.
8. Report results clearly; if output is large, summarize and highlight the relevant parts.

## Installation

If `gh` is missing, install it using the recommended method for the current OS.
Detect the OS first, then run the matching command.

### Windows
```powershell
winget install --id GitHub.cli
```
> Note: open a **new terminal window** after installation for PATH changes to take effect.

### macOS
```shell
brew install gh
```

### Linux (Debian / Ubuntu)
```bash
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
```

### Linux (Fedora / RHEL / CentOS)
```bash
sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli
```

After installation, verify with `gh --version`, then authenticate with `gh auth login` if needed.

## Notes

- `gh` must be authenticated (`gh auth status`). If not, run `gh auth login` first.
- `--repo` accepts both `owner/repo` shorthand and full HTTPS URLs.
- For `gh api`, use `--method POST/PATCH/DELETE` for write operations and pass body fields with `-f field=value` or `-F field=<int>`.
- `gh run list` defaults to the current branch when run inside a git repo; pass `--branch <name>` to target a specific branch.
Loading