-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(contentunderstanding): Copilot skills for authoring custom analyzers #49672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chienyuanchang
wants to merge
11
commits into
main
Choose a base branch
from
cu-sdk/custom-analyzer-skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,488
−0
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
10b0077
feat(contentunderstanding): add Copilot skills for authoring custom a…
chienyuanchang 4d37ea8
fix(contentunderstanding): rename short identifiers to satisfy cspell
chienyuanchang 8d14ad6
fix(contentunderstanding): repoint SKILL.md sample links at Java samp…
chienyuanchang 3ab852c
feat(contentunderstanding): port cross-skill updates + CLI helper tes…
chienyuanchang a38654f
fix(contentunderstanding): rephrase 'prebuilts' to satisfy cspell
chienyuanchang 8ba57bc
docs(contentunderstanding): fix stale create_and_test.py reference in…
chienyuanchang bca631f
Address Copilot review feedback
chienyuanchang d185364
docs(contentunderstanding): fix stale sample_update_defaults.py refs
chienyuanchang 7b07a75
fix(contentunderstanding): --schema-dir aliases + natural version sort
chienyuanchang 67b3246
fix(contentunderstanding): validate CLI arg values + drop no-op pom s…
chienyuanchang a2877da
docs(contentunderstanding): move skills entry to Other Changes for cr…
chienyuanchang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...entunderstanding/azure-ai-contentunderstanding/.github/skills/_shared/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # `_shared/` — library, not a skill | ||
|
|
||
| Pure-Java helpers used by the authoring skill scripts under | ||
| `.github/skills/cu-sdk-author-analyzer*/`. | ||
|
|
||
| The leading underscore marks this as a **library directory**, not a skill. It | ||
| is intentionally excluded from the Copilot skill picker. | ||
|
|
||
| Rules for code in `SchemaValidator.java` (the validator): | ||
|
|
||
| - **No `com.azure.*` imports.** No network calls. No I/O beyond reading / | ||
| parsing caller-provided JSON. | ||
| - **No new runtime dependencies.** Jackson (`jackson-databind`) only. | ||
| - **Stable, small, well-tested.** Anything here is referenced by multiple skill | ||
| scripts; breakage cascades. | ||
|
|
||
| The CLI command classes (`ExtractLayoutCommand.java`, | ||
| `CreateAndTestCommand.java`, `CreateAndTestRouterCommand.java`) wrap the | ||
| `ContentUnderstandingClient` from `azure-ai-contentunderstanding`. They are | ||
| allowed to import `com.azure.*` since they're the bridge between the | ||
| validator and the service. | ||
|
|
||
| Current modules: | ||
|
|
||
| - [`SchemaValidator.java`](src/main/java/com/azure/ai/contentunderstanding/skills/SchemaValidator.java) — | ||
| validates analyzer schema JSON before any service call (catches | ||
| `baseAnalyzerId` typos, missing `fieldSchema`, missing | ||
| `contentCategories` analyzer routes, etc.). Pure Jackson. | ||
| - [`Cli.java`](src/main/java/com/azure/ai/contentunderstanding/skills/Cli.java) — | ||
| subcommand dispatcher. | ||
| - [`ExtractLayoutCommand.java`](src/main/java/com/azure/ai/contentunderstanding/skills/ExtractLayoutCommand.java) — | ||
| Stage 1: extract document layout. | ||
| - [`CreateAndTestCommand.java`](src/main/java/com/azure/ai/contentunderstanding/skills/CreateAndTestCommand.java) — | ||
| Stage 2 (single-type). | ||
| - [`CreateAndTestRouterCommand.java`](src/main/java/com/azure/ai/contentunderstanding/skills/CreateAndTestRouterCommand.java) — | ||
| Stage 2 (classify-and-route). | ||
|
|
||
| ## Build | ||
|
|
||
| The Maven module is **intentionally NOT a child of azure-client-sdk-parent** | ||
| and is NOT referenced from the package POM — it lives outside the published | ||
| source tree so it has zero effect on the published | ||
| `azure-ai-contentunderstanding` artifact. | ||
|
|
||
| ```bash | ||
| mvn -B -q -f .github/skills/_shared/pom.xml -DskipTests compile | ||
| ``` | ||
|
|
||
| Dependencies are pulled from Maven Central using published versions; the tool | ||
| builds against the public SDK rather than the local reactor so contributors | ||
| can iterate without first running `mvn install` on the parent. | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| mvn -B -q -f .github/skills/_shared/pom.xml exec:java \ | ||
| -Dexec.args="extract-layout --input <file-or-folder> --output <dir>" | ||
| ``` | ||
|
|
||
| Or, after one `mvn package`, invoke directly: | ||
|
|
||
| ```bash | ||
| java -cp .github/skills/_shared/target/cu-skill-0.1.0.jar:<deps> \ | ||
| com.azure.ai.contentunderstanding.skills.Cli extract-layout ... | ||
| ``` |
99 changes: 99 additions & 0 deletions
99
sdk/contentunderstanding/azure-ai-contentunderstanding/.github/skills/_shared/pom.xml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Copyright (c) Microsoft Corporation. All rights reserved. | ||
| ~ Licensed under the MIT License. | ||
|
|
||
| Standalone Maven module that builds the cu-skill analyzer-authoring tool. | ||
|
|
||
| This module is intentionally NOT a child of azure-client-sdk-parent and is | ||
| NOT referenced from the package POM — it lives outside the published source | ||
| tree under .github/skills/_shared/ so it has zero effect on the published | ||
| azure-ai-contentunderstanding artifact. The skill SKILL.md files invoke it | ||
| via `mvn -f .../pom.xml exec:java -Dexec.mainClass=... -Dexec.args="..."`. | ||
|
|
||
| Dependencies are pulled from Maven Central using the standard published | ||
| versions; the tool builds against the public SDK rather than the local | ||
| reactor so that contributors can iterate without first running `mvn install` | ||
| on the parent. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.azure.ai.contentunderstanding.skills</groupId> | ||
| <artifactId>cu-skill</artifactId> | ||
| <version>0.1.0</version> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>cu-skill — Content Understanding analyzer-authoring tool</name> | ||
| <description> | ||
| Companion CLI for the cu-sdk-author-analyzer / cu-sdk-author-analyzer-classify-route | ||
| GitHub Copilot skills. Wraps the azure-ai-contentunderstanding Java SDK with three | ||
| subcommands (extract-layout, create-and-test, create-and-test-router) and a pure-Java | ||
| schema validator that catches structural mistakes before a service round-trip. | ||
| </description> | ||
|
|
||
| <properties> | ||
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <!-- Skip Checkstyle / SpotBugs / javadoc enforcement; this is internal tooling. --> | ||
| <checkstyle.skip>true</checkstyle.skip> | ||
| <spotbugs.skip>true</spotbugs.skip> | ||
| <maven.javadoc.skip>true</maven.javadoc.skip> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <!-- | ||
| Pin published SDK versions; users only need network access to Maven Central | ||
| (no `mvn install` of the parent reactor required). | ||
| --> | ||
| <dependency> | ||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-ai-contentunderstanding</artifactId> | ||
| <version>1.1.0-beta.2</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-identity</artifactId> | ||
| <version>1.18.4</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-core</artifactId> | ||
| <version>1.58.1</version> | ||
| </dependency> | ||
| <!-- Jackson is pulled in transitively by azure-core; pinning explicitly keeps the | ||
| validator's import set stable even if azure-core swaps serializers later. --> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>2.18.7</version> | ||
| </dependency> | ||
|
|
||
| <!-- Test scope --> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>5.11.4</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <version>3.5.0</version> | ||
| <configuration> | ||
| <mainClass>com.azure.ai.contentunderstanding.skills.Cli</mainClass> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>3.5.2</version> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
61 changes: 61 additions & 0 deletions
61
...ng/.github/skills/_shared/src/main/java/com/azure/ai/contentunderstanding/skills/Cli.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| /* | ||
| * Subcommand dispatcher for the cu-skill tool. Mirrors Python's | ||
| * extract_layout.py / create_and_test.py / create_and_test_router.py | ||
| * entry points and the .NET Program.cs. | ||
| */ | ||
|
|
||
| package com.azure.ai.contentunderstanding.skills; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
|
|
||
| public final class Cli { | ||
|
|
||
| private Cli() { | ||
| } | ||
|
|
||
| public static void main(String[] args) throws IOException { | ||
| if (args.length == 0 || isHelp(args[0])) { | ||
| printUsage(); | ||
| System.exit(args.length == 0 ? 1 : 0); | ||
| return; | ||
| } | ||
| String subcommand = args[0]; | ||
| String[] subArgs = Arrays.copyOfRange(args, 1, args.length); | ||
| int exit; | ||
| switch (subcommand) { | ||
| case "extract-layout": | ||
| exit = ExtractLayoutCommand.run(subArgs); | ||
| break; | ||
| case "create-and-test": | ||
| exit = CreateAndTestCommand.run(subArgs); | ||
| break; | ||
| case "create-and-test-router": | ||
| exit = CreateAndTestRouterCommand.run(subArgs); | ||
| break; | ||
| default: | ||
| System.err.println("unknown subcommand: " + subcommand); | ||
| printUsage(); | ||
| exit = 1; | ||
| } | ||
| System.exit(exit); | ||
| } | ||
|
|
||
| private static boolean isHelp(String arg) { | ||
| return "-h".equals(arg) || "--help".equals(arg) || "help".equals(arg); | ||
| } | ||
|
|
||
| private static void printUsage() { | ||
| System.out.println("cu-skill — Content Understanding analyzer-authoring tool."); | ||
| System.out.println(); | ||
| System.out.println("Subcommands:"); | ||
| System.out.println(" extract-layout extract document layout (stage 1)"); | ||
| System.out.println(" create-and-test validate, create, batch-test a single-type analyzer"); | ||
| System.out.println(" create-and-test-router classify-and-route variant (N inner + 1 outer)"); | ||
| System.out.println(); | ||
| System.out.println("Use '<subcommand> --help' for per-command flags."); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.