Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
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 ...
```
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>
Comment thread
chienyuanchang marked this conversation as resolved.
Outdated
</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>
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.");
}
}
Loading
Loading