feat(contentunderstanding): Copilot skills for authoring custom analyzers#49672
Draft
chienyuanchang wants to merge 4 commits into
Draft
feat(contentunderstanding): Copilot skills for authoring custom analyzers#49672chienyuanchang wants to merge 4 commits into
chienyuanchang wants to merge 4 commits into
Conversation
…nalyzers Add two GitHub Copilot skills under .github/skills/ that guide users through the iterative cycle of authoring custom Content Understanding analyzers in VS Code: - cu-sdk-author-analyzer — single-document-type authoring - cu-sdk-author-analyzer-classify-route — classify-and-route pipelines Both skills delegate to a small cu-skill Maven tool under .github/skills/_shared/ that exposes three subcommands (extract-layout, create-and-test, create-and-test-router) and a pure-Java SchemaValidator (no com.azure.* deps) so structural mistakes are caught before a service round-trip. Mirrors the .NET skills shipped in Azure/azure-sdk-for-net#60394 and the Python skills in Azure/azure-sdk-for-python#47218. Live-tested against a real CU resource with mixed_financial_docs.pdf: - extract-layout produces .layout.{json,md} - create-and-test reports per-field fill rate + avg confidence and cleans up the analyzer when --ephemeral is set - create-and-test-router creates N inner + 1 outer analyzer, prints a category-aware summary, and cleans up all four New unit tests: - SchemaValidatorTest (18 cases) mirrors Python's test_skills_shared_schema_validator.py and the .NET SkillSchemaValidatorTests.cs: valid single-type and classify-route schemas, every rejection path, validateFile error handling, KNOWN_BASE_ANALYZER_IDS allow-list sanity, and a purity guard that fails if the validator source ever pulls in com.azure.* or HTTP namespaces. README: - New 'What's New' section and two new entries in the existing 'GitHub Copilot Skills' table. CHANGELOG: - Entry under 1.1.0-beta.3 (Unreleased) describing the new skills. Build: - mvn -B -DskipTests compile: clean - mvn -B test: 18/18 tests pass The Maven module is intentionally NOT a child of azure-client-sdk-parent and is NOT referenced from the package POM, so it has zero effect on the published azure-ai-contentunderstanding artifact.
8 tasks
CI cspell check flagged abbreviated locals and a few domain acronyms in the skill-tooling sources. Replaces them with the full words used elsewhere in the file so the dictionary does not need a new entry. - confs -> confidences (CreateAndTestCommand, CreateAndTestRouterCommand) - fobj -> fieldObj, vobj -> valueObj (CreateAndTestCommand) - IMDS -> metadata-service (ExtractLayoutCommand comment) - prebuilts -> prebuilt analyzers (SchemaValidator javadoc) No behavior change. All 18 unit tests still pass.
…le paths Verify-Links flagged 15 broken relative links in the two analyzer skill docs. The Python source skills referenced 'samples/sample_*.py' files at the package root; the Java port mechanically copied the link structure but the Java layout is different: - Java samples live at src/samples/java/com/azure/ai/contentunderstanding/samples/, not samples/. - Java does not have the per-sample .md companion files Python ships (Sample06_GetAnalyzer.md, Sample02_AnalyzeUrl.md, etc.) — only the .java source files. Rewrites all 15 links to point at the correct .java source under src/samples/java/. All 10 distinct sample files referenced were verified to exist on disk before the rewrite.
…ts from Python Three changes for parity with Python PR #47218: 1. **summarizeRouted denominator bug fix** (was a port-time regression). The denominator for a per-field fill rate must be the per-category segment count, NOT the per-field row count. Two invoice segments where only one has TotalAmount correctly reports 50% (1/2 segments), not 100% (1/1 rows). This matches Python and .NET; the same bug existed in JS and is being fixed on its PR. The comment claiming 'Mirrors Python/.NET semantics' was misleading — fixed in this commit. 2. **New CLI-helper test classes** — CreateAndTestCommandTest and CreateAndTestRouterCommandTest. Together they cover the 4 pure-helper tests Python ships (summarize leaf-row flattening, summarizeRouted per-category denominator, summarizeRouted zero-fill, wireInnerIds alias substitution). The denom regression above was discovered by these tests. Python ships 10 CLI-helper tests total; the remaining 6 either test argparse-specific behaviour (--help smoke, monkey-patched client) or test code structured differently in Java (error-tuple API), so they don't translate 1:1. We cover the substantive behaviour. 3. **Cross-skill SKILL.md updates** that Python's PR #47218 also shipped: a two-stage-pipeline section + a baseAnalyzerId table in cu-sdk-common-knowledge, 'Next step' cross-refs in cu-sdk-sample-run, and a 'step numbering is contract' callout in cu-sdk-setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(contentunderstanding): Copilot skills for authoring custom analyzers
Summary
Adds two GitHub Copilot skills under
sdk/contentunderstanding/azure-ai-contentunderstanding/.github/skills/that guide users through the iterative cycle of authoring custom Content Understanding analyzers directly inside VS Code:cu-sdk-author-analyzercu-sdk-author-analyzer-classify-routeBoth skills delegate to a small
cu-skillMaven tool under.github/skills/_shared/that exposes three subcommands:extract-layout— pulls document structure into.layout.{json,md}so Copilot has ground-truth context for schema drafting.create-and-test— validates a schema locally, creates the analyzer, batch-tests inputs, prints a per-field fill-rate + avg-confidence summary, and (with--ephemeral) cleans up.create-and-test-router— same loop for classify-and-route: creates N inner extractors + 1 outer classifier, wirescontentCategories[*].analyzerId, runs, and prints a category-aware summary.A pure-Java
SchemaValidator(Jackson only, nocom.azure.*imports) catches structural mistakes (unknownbaseAnalyzerId, missingfieldSchema, malformedcontentCategoriesroutes) before a service round-trip.This mirrors the .NET skills shipped in Azure/azure-sdk-for-net#60394 and the Python skills in Azure/azure-sdk-for-python#47218.
Live test
Tested against a real CU resource with
mixed_financial_docs.pdf(an invoice + bank statement + loan application):The router variant created 3 inner + 1 outer analyzer, classified 3 segments, extracted all fields, and cleaned up all 4 analyzers (~59 s end-to-end).
What's in the PR
_shared/SchemaValidator.javacom.azure.*deps; purity-guarded by a unit test_shared/ExtractLayoutCommand.java_shared/CreateAndTestCommand.java_shared/CreateAndTestRouterCommand.java_shared/Cli.java_shared/pom.xml+_shared/README.mdcu-sdk-author-analyzer/SKILL.md+ templatecu-sdk-author-analyzer-classify-route/SKILL.md+ templateSchemaValidatorTest.javaREADME.mdCHANGELOG.mdTest results
Coverage:
analyzerId(catch-all "other" bucket)baseAnalyzerIdrejected (catches theprebuilt-documentAnalyzertypo class)fieldSchemaon non-classifierfieldsobject, unknown fieldtype/methodobject.propertiesandarray.itemsrecursionfieldSchema→ rejectedenableSegment: true→ rejecteddescription→ rejectedvalidateFile: missing file, invalid JSON, valid round-tripKNOWN_BASE_ANALYZER_IDSallow-list sanity checkSchemaValidator.javaever pulls incom.azure.*/java.net.http/HttpURLConnectionBugs fixed during live test
.envvalues typically wrap in"…"; rawexportkeeps the quotes. Added areadEnv()helper that strips one layer of surrounding quotes (mirrors the .NET fix).DefaultAzureCredentialBuilderdoes not exposeexcludeCredentialsin the Java SDK (unlike .NET). Built a focusedChainedTokenCredentialBuilderchain (EnvironmentCredential→AzureCliCredential) so the IMDS probe doesn't stall on dev boxes (~30 s wait on WSL).BinaryDataprotocol overload ofbeginAnalyzeBinary/beginCreateAnalyzerso we can keep the wire format (valueString/valueNumber/...) and unwrap the LRO envelope{id,status,result,usage}to match Python'spoller.result()output and the .NET skill output.results.size()(doc count) instead ofrows.size()(per-field row count), which inflated array-leaf fields to 1300%. Switched to per-field row count to match Python and .NET semantics.Backward compatibility
No public API changes. The skills tree is opt-in tooling that lives under
.github/skills/and is only loaded by Copilot when a user explicitly asks. Thecu-skillMaven module is standalone — not a child ofazure-client-sdk-parent, not referenced from the package POM — so it doesn't affect normal package builds or the publishedazure-ai-contentunderstandingartifact.Checklist
mvn -B -DskipTests compilecleanmvn -B test18/18 passing