diff --git a/scripts/compare-standalone-to-monorepo.sh b/scripts/compare-standalone-to-monorepo.sh index 139eb1b38..2aeba443b 100755 --- a/scripts/compare-standalone-to-monorepo.sh +++ b/scripts/compare-standalone-to-monorepo.sh @@ -59,8 +59,9 @@ fi # ── Collect comparable files from the standalone repo ──────────────── # Excludes: target/, node_modules/, temporary-prompts/, scripts/codegen/ # (these are build artifacts or standalone-only content) -TMPFILE=$(mktemp) -trap 'rm -f "$TMPFILE"' EXIT +TMPFILE_STANDALONE=$(mktemp) +TMPFILE_MONO=$(mktemp) +trap 'rm -f "$TMPFILE_STANDALONE" "$TMPFILE_MONO"' EXIT (cd "$STANDALONE" && find . -type f \( -name "pom.xml" -o -name "*.java" -o -name "*.properties" \) \ | grep -v '/target/' \ @@ -68,22 +69,34 @@ trap 'rm -f "$TMPFILE"' EXIT | grep -v '^\./temporary-prompts/' \ | grep -v '^\./scripts/codegen/' \ | sed 's|^\./||' \ - | sort) > "$TMPFILE" + | sort) > "$TMPFILE_STANDALONE" + +# ── Collect comparable files from the monorepo ─────────────────────── +# Excludes: target/, node_modules/, scripts/codegen/ +(cd "$MONO_JAVA" && find . -type f \( -name "pom.xml" -o -name "*.java" -o -name "*.properties" \) \ + | grep -v '/target/' \ + | grep -v '/node_modules/' \ + | grep -v '^\./scripts/codegen/' \ + | sed 's|^\./||' \ + | sort) > "$TMPFILE_MONO" # ── Compare ────────────────────────────────────────────────────────── DIFFER_COUNT=0 -MISSING_COUNT=0 +MISSING_FROM_MONO_COUNT=0 +MISSING_FROM_STANDALONE_COUNT=0 SAME_COUNT=0 DIFFER_LIST="" -MISSING_LIST="" +MISSING_FROM_MONO_LIST="" +MISSING_FROM_STANDALONE_LIST="" +# Check standalone files against monorepo while IFS= read -r relpath; do standalone_file="${STANDALONE}/${relpath}" mono_file="${MONO_JAVA}/${relpath}" if [ ! -f "$mono_file" ]; then - MISSING_COUNT=$((MISSING_COUNT + 1)) - MISSING_LIST="${MISSING_LIST}${relpath} + MISSING_FROM_MONO_COUNT=$((MISSING_FROM_MONO_COUNT + 1)) + MISSING_FROM_MONO_LIST="${MISSING_FROM_MONO_LIST}${relpath} " elif ! diff -q "$standalone_file" "$mono_file" >/dev/null 2>&1; then DIFFER_COUNT=$((DIFFER_COUNT + 1)) @@ -92,15 +105,28 @@ while IFS= read -r relpath; do else SAME_COUNT=$((SAME_COUNT + 1)) fi -done < "$TMPFILE" +done < "$TMPFILE_STANDALONE" -TOTAL_COUNT=$(wc -l < "$TMPFILE" | tr -d ' ') +# Check monorepo files that don't exist in standalone +while IFS= read -r relpath; do + standalone_file="${STANDALONE}/${relpath}" + + if [ ! -f "$standalone_file" ]; then + MISSING_FROM_STANDALONE_COUNT=$((MISSING_FROM_STANDALONE_COUNT + 1)) + MISSING_FROM_STANDALONE_LIST="${MISSING_FROM_STANDALONE_LIST}${relpath} +" + fi +done < "$TMPFILE_MONO" + +STANDALONE_TOTAL=$(wc -l < "$TMPFILE_STANDALONE" | tr -d ' ') +MONO_TOTAL=$(wc -l < "$TMPFILE_MONO" | tr -d ' ') # ── Output ─────────────────────────────────────────────────────────── -echo "Compared ${TOTAL_COUNT} files (pom.xml, *.java, *.properties)" +echo "Standalone files: ${STANDALONE_TOTAL} Monorepo files: ${MONO_TOTAL}" echo " Identical: ${SAME_COUNT}" echo " Differ: ${DIFFER_COUNT}" -echo " Missing from monorepo: ${MISSING_COUNT}" +echo " Only in standalone (missing from monorepo): ${MISSING_FROM_MONO_COUNT}" +echo " Only in monorepo (missing from standalone): ${MISSING_FROM_STANDALONE_COUNT}" echo "" if [ "$DIFFER_COUNT" -gt 0 ]; then @@ -112,16 +138,25 @@ if [ "$DIFFER_COUNT" -gt 0 ]; then echo "" fi -if [ "$MISSING_COUNT" -gt 0 ]; then +if [ "$MISSING_FROM_MONO_COUNT" -gt 0 ]; then echo "The following files exist in standalone but NOT in monorepo:" echo "" - printf '%s' "$MISSING_LIST" | while IFS= read -r f; do + printf '%s' "$MISSING_FROM_MONO_LIST" | while IFS= read -r f; do [ -n "$f" ] && echo " $f" done echo "" fi -if [ "$DIFFER_COUNT" -eq 0 ] && [ "$MISSING_COUNT" -eq 0 ]; then +if [ "$MISSING_FROM_STANDALONE_COUNT" -gt 0 ]; then + echo "The following files exist in monorepo but NOT in standalone:" + echo "" + printf '%s' "$MISSING_FROM_STANDALONE_LIST" | while IFS= read -r f; do + [ -n "$f" ] && echo " $f" + done + echo "" +fi + +if [ "$DIFFER_COUNT" -eq 0 ] && [ "$MISSING_FROM_MONO_COUNT" -eq 0 ] && [ "$MISSING_FROM_STANDALONE_COUNT" -eq 0 ]; then echo "All files are identical." fi @@ -139,3 +174,31 @@ if [ "$SHOW_DIFF" = true ] && [ "$DIFFER_COUNT" -gt 0 ]; then fi done fi + +if [ "$SHOW_DIFF" = true ] && [ "$MISSING_FROM_STANDALONE_COUNT" -gt 0 ]; then + echo "" + echo "================================================================================" + echo "Files only in monorepo (new files to port to standalone):" + echo "================================================================================" + printf '%s' "$MISSING_FROM_STANDALONE_LIST" | while IFS= read -r f; do + if [ -n "$f" ]; then + echo "" + echo "+++ monorepo/java/$f" + diff -u /dev/null "${MONO_JAVA}/${f}" || true + fi + done +fi + +if [ "$SHOW_DIFF" = true ] && [ "$MISSING_FROM_MONO_COUNT" -gt 0 ]; then + echo "" + echo "================================================================================" + echo "Files only in standalone (not present in monorepo):" + echo "================================================================================" + printf '%s' "$MISSING_FROM_MONO_LIST" | while IFS= read -r f; do + if [ -n "$f" ]; then + echo "" + echo "--- standalone/$f" + diff -u "${STANDALONE}/${f}" /dev/null || true + fi + done +fi diff --git a/src/main/java/com/github/copilot/CopilotSession.java b/src/main/java/com/github/copilot/CopilotSession.java index 6a8676d8f..5b4035959 100644 --- a/src/main/java/com/github/copilot/CopilotSession.java +++ b/src/main/java/com/github/copilot/CopilotSession.java @@ -475,6 +475,7 @@ public CompletableFuture send(MessageOptions options) { request.setPrompt(options.getPrompt()); request.setAttachments(options.getAttachments()); request.setMode(options.getMode()); + request.setAgentMode(options.getAgentMode()); request.setRequestHeaders(options.getRequestHeaders()); return rpc.invoke("session.send", request, SendMessageResponse.class).thenApply(SendMessageResponse::messageId); diff --git a/src/main/java/com/github/copilot/rpc/AgentMode.java b/src/main/java/com/github/copilot/rpc/AgentMode.java new file mode 100644 index 000000000..84054e35b --- /dev/null +++ b/src/main/java/com/github/copilot/rpc/AgentMode.java @@ -0,0 +1,72 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.rpc; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The UI mode the agent is in for a given turn. + *

+ * Set on {@link MessageOptions#setAgentMode(AgentMode)} to send a message in a + * specific mode; defaults to the session's current mode when unset. + * + * @see MessageOptions + * @since 1.1.0 + */ +public enum AgentMode { + + /** The agent is responding interactively to the user. */ + INTERACTIVE("interactive"), + + /** The agent is preparing a plan before making changes. */ + PLAN("plan"), + + /** The agent is working autonomously toward task completion. */ + AUTOPILOT("autopilot"), + + /** The agent is in shell-focused UI mode. */ + SHELL("shell"); + + private final String value; + + AgentMode(String value) { + this.value = value; + } + + /** + * Returns the JSON value for this agent mode. + * + * @return the string value used in JSON serialization + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * Deserializes a JSON string value into the corresponding {@code AgentMode} + * enum constant. + * + * @param value + * the JSON string value + * @return the matching {@code AgentMode}, or {@code null} if value is + * {@code null} + * @throws IllegalArgumentException + * if the value does not match any known agent mode + */ + @JsonCreator + public static AgentMode fromValue(String value) { + if (value == null) { + return null; + } + for (AgentMode mode : values()) { + if (mode.value.equals(value)) { + return mode; + } + } + throw new IllegalArgumentException("Unknown AgentMode: " + value); + } +} diff --git a/src/main/java/com/github/copilot/rpc/MessageOptions.java b/src/main/java/com/github/copilot/rpc/MessageOptions.java index 49b25c094..a6cd02b0a 100644 --- a/src/main/java/com/github/copilot/rpc/MessageOptions.java +++ b/src/main/java/com/github/copilot/rpc/MessageOptions.java @@ -45,6 +45,7 @@ public class MessageOptions { private String prompt; private List attachments; private String mode; + private AgentMode agentMode; private Map requestHeaders; /** @@ -126,6 +127,30 @@ public String getMode() { return mode; } + /** + * Sets the per-message agent UI mode. + *

+ * Defaults to the session's current mode when unset. + * + * @param agentMode + * the agent mode (for example {@link AgentMode#PLAN} or + * {@link AgentMode#AUTOPILOT}) + * @return this options instance for method chaining + */ + public MessageOptions setAgentMode(AgentMode agentMode) { + this.agentMode = agentMode; + return this; + } + + /** + * Gets the per-message agent UI mode. + * + * @return the agent mode, or {@code null} if not set + */ + public AgentMode getAgentMode() { + return agentMode; + } + /** * Gets the custom per-turn HTTP headers for outbound model requests. * @@ -167,6 +192,7 @@ public MessageOptions clone() { copy.prompt = this.prompt; copy.attachments = this.attachments != null ? new ArrayList<>(this.attachments) : null; copy.mode = this.mode; + copy.agentMode = this.agentMode; copy.requestHeaders = this.requestHeaders != null ? new HashMap<>(this.requestHeaders) : null; return copy; } diff --git a/src/main/java/com/github/copilot/rpc/SendMessageRequest.java b/src/main/java/com/github/copilot/rpc/SendMessageRequest.java index bdd904a59..b73d2caa2 100644 --- a/src/main/java/com/github/copilot/rpc/SendMessageRequest.java +++ b/src/main/java/com/github/copilot/rpc/SendMessageRequest.java @@ -37,6 +37,9 @@ public final class SendMessageRequest { @JsonProperty("mode") private String mode; + @JsonProperty("agentMode") + private AgentMode agentMode; + @JsonProperty("requestHeaders") private Map requestHeaders; @@ -80,6 +83,16 @@ public void setMode(String mode) { this.mode = mode; } + /** Gets the per-message agent UI mode. @return the agent mode */ + public AgentMode getAgentMode() { + return agentMode; + } + + /** Sets the per-message agent UI mode. @param agentMode the agent mode */ + public void setAgentMode(AgentMode agentMode) { + this.agentMode = agentMode; + } + /** Gets the per-turn request headers. @return the headers map */ public Map getRequestHeaders() { return requestHeaders == null ? null : Collections.unmodifiableMap(requestHeaders);