|
| 1 | +# Phase 0: Scan Package 🧭 |
| 2 | + |
| 3 | +> 📍 **Phase 0 — Scan Package** | Detect the package's architecture, customization patterns, and key files. |
| 4 | +
|
| 5 | +## Step 1 — Identify the Package |
| 6 | + |
| 7 | +Ask the user: "Which SDK package should I create a skill for?" |
| 8 | + |
| 9 | +The user should provide either: |
| 10 | +- A package name (e.g., `azure-search-documents`, `azure-ai-projects`, `azure-mgmt-appconfiguration`) |
| 11 | +- A path (e.g., `sdk/search/azure-search-documents`, `sdk/ai/azure-ai-projects`) |
| 12 | + |
| 13 | +Resolve to the package root directory. Verify it exists and contains at least one of: `pyproject.toml`, `setup.py`, `tsp-location.yaml`, or a `swagger/README.md` (legacy autorest). |
| 14 | + |
| 15 | +## Step 2 — Scan the Package |
| 16 | + |
| 17 | +Scan the package using the checklist below. Use file_search / grep_search / read_file tools. |
| 18 | + |
| 19 | +### Scan Checklist |
| 20 | + |
| 21 | +1. **Code generation toolchain**: |
| 22 | + - `tsp-location.yaml` → TypeSpec-generated package. Note the spec directory and commit SHA. |
| 23 | + - `_metadata.json` → if present, record that `apiVersion` lives here (the skill will reconcile it against the hand-maintained `ApiVersion` enum). |
| 24 | + - `swagger/README.md` → legacy autorest-generated (mgmt packages typically). |
| 25 | + - Neither → hand-written package (rare). |
| 26 | + |
| 27 | +2. **Namespace root**: Derive from the package name by replacing `-` with `/` (e.g., `azure-ai-projects` → `<package-path>/azure/ai/projects`). Verify the directory exists. |
| 28 | + |
| 29 | +3. **Generated layout detection**: |
| 30 | + - If `<namespace-root>/_generated/` exists → **nested layout**. Generated files are confined to `_generated/`; everything else is hand-written/customization. |
| 31 | + - If `_generated/` is absent → **inline layout** (newer pattern). Generated files are identified by the header comment `"Code generated by Microsoft (R) Python Code Generator"` at the top of each file. |
| 32 | + |
| 33 | +4. **Customizations** (`_patch.py` at each level): |
| 34 | + - `<namespace-root>/_patch.py` — top-level client customization |
| 35 | + - `<namespace-root>/models/_patch.py` — model customization |
| 36 | + - `<namespace-root>/operations/_patch.py` — sync operations customization |
| 37 | + - `<namespace-root>/aio/_patch.py` — async client customization |
| 38 | + - `<namespace-root>/aio/operations/_patch.py` — async operations customization |
| 39 | + |
| 40 | + For each, check if it is **empty** (only copyright header, default docstring, empty `__all__`, empty `patch_sdk()`) or **non-empty** (defines classes/functions, or `__all__` has entries). Record the non-empty patches. |
| 41 | + |
| 42 | +5. **Hand-written utility modules**: Glob all `.py` files under `<namespace-root>` excluding `_generated/`, `__init__.py`, `_version.py`, `_patch.py`. Classify each as generated (has the header) or custom. For custom utility modules, read the first few lines to get a one-line purpose. |
| 43 | + |
| 44 | +6. **Public API surface**: Read each `__init__.py` (top-level, `models/`, `operations/`, `aio/`, `aio/operations/`). Note re-exports from `_patch.py` and any renames/omissions vs `_generated/__init__.py` (when nested layout). |
| 45 | + |
| 46 | +7. **Async parity**: For each non-empty sync customization file, check whether the async counterpart exists under `aio/`. Record `identical`, `equivalent`, `divergent`, `sync-only`, or `async-only`. |
| 47 | + |
| 48 | +8. **Service API versions**: Search for an `ApiVersion` enum or `api_version` constants under `<namespace-root>` (often inside `_patch.py` itself, not `_generated/`). Record the source file path, but do **not** hard-code the list of versions into the skill — point to the source file. |
| 49 | + |
| 50 | +9. **Hand-authored named classes**: Grep for `class .*Buffered|class .*Batching|class .*Sender|class .*Paged|class .*PageIterator` under `<namespace-root>`. These are hand-authored utilities that the skill must name in its Customization Patterns Reference. |
| 51 | + |
| 52 | +10. **Top public symbols (for import smoke tests)**: Read the top-level `__init__.py` and `aio/__init__.py`. Record up to 3–5 most important public names (clients, senders, key models/enums) so Phase 1 can generate accurate `python -c "from <ns> import <X>"` commands. |
| 53 | + |
| 54 | +11. **Tests**: Check `tests/` directory. Look for `conftest.py`, `*test_base*.py`, `assets.json` (recorded tests via Test Proxy), `testpreparer*.py`. Note whether tests are live, recorded, or both. |
| 55 | + |
| 56 | +12. **Documentation surfaces**: Check for `CHANGELOG.md` and `README.md` at the package root. Both are near-universal; the skill's Step 7 (Update Documentation and Samples) will reference them. |
| 57 | + |
| 58 | +13. **Management vs data plane**: If package name starts with `azure-mgmt-` → management-plane rules apply (see copilot-instructions). Otherwise data-plane. |
| 59 | + |
| 60 | +## Step 3 — Present Package Profile |
| 61 | + |
| 62 | +Print a concise summary: |
| 63 | + |
| 64 | +📋 **Package Profile** |
| 65 | + |
| 66 | +| Field | Value | |
| 67 | +|---|---| |
| 68 | +| Package | `<package-name>` (e.g., `azure-ai-projects`) | |
| 69 | +| Path | `sdk/<service>/<package-name>` | |
| 70 | +| Plane | data / mgmt | |
| 71 | +| Generated | TypeSpec (`tsp-location.yaml`) / autorest (`swagger/README.md`) / hand-written | |
| 72 | +| Metadata | `_metadata.json` present: Y/N | |
| 73 | +| Layout | nested (`_generated/`) / inline (header-based) | |
| 74 | +| Non-empty `_patch.py` files | List which levels have customizations (top / models / operations / aio / aio/operations / indexes…) | |
| 75 | +| Custom utility modules | N hand-written `.py` files outside `_patch.py` | |
| 76 | +| Hand-authored named classes | e.g., `SearchIndexingBufferedSender`, `SearchItemPaged` (or `none`) | |
| 77 | +| Top public symbols | List of 3–5 names used for Phase 1 import smoke tests | |
| 78 | +| Public API surface | Notes on re-exports, renames, omissions | |
| 79 | +| Async parity | summary (identical / divergent / sync-only / async-only) | |
| 80 | +| `ApiVersion` enum | source file + present Y/N | |
| 81 | +| Tests | Unit: Y, Live: Y/N, Recorded (assets.json): Y/N | |
| 82 | +| Docs | `CHANGELOG.md`: Y/N, `README.md`: Y/N | |
| 83 | +| Suggested structure | Option A (step-by-step) / Option B (reference manual) | |
| 84 | + |
| 85 | +## Step 4 — DECIDE |
| 86 | + |
| 87 | +Question: "Does this profile look right? Anything to add or correct?" |
| 88 | + |
| 89 | +📍 **Phase 0 complete** | Package scanned | Next: Phase 1 |
| 90 | + |
| 91 | +--- |
| 92 | +## → Next: Phase 1 — Scaffold SKILL.md |
| 93 | +Read [01-scaffold-skill.md](01-scaffold-skill.md) and begin immediately. |
0 commit comments