Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
91 changes: 77 additions & 14 deletions scripts/compare-standalone-to-monorepo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,44 @@ 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/' \
| grep -v '/node_modules/' \
| 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))
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
1 change: 1 addition & 0 deletions src/main/java/com/github/copilot/CopilotSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public CompletableFuture<String> 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);
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/github/copilot/rpc/AgentMode.java
Original file line number Diff line number Diff line change
@@ -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.
* <p>
* 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;
}

/**
Comment thread
edburns marked this conversation as resolved.
* 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);
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/github/copilot/rpc/MessageOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class MessageOptions {
private String prompt;
private List<MessageAttachment> attachments;
private String mode;
private AgentMode agentMode;
private Map<String, String> requestHeaders;

/**
Expand Down Expand Up @@ -126,6 +127,30 @@ public String getMode() {
return mode;
}

/**
* Sets the per-message agent UI mode.
* <p>
* 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.
*
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/github/copilot/rpc/SendMessageRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public final class SendMessageRequest {
@JsonProperty("mode")
private String mode;

@JsonProperty("agentMode")
private AgentMode agentMode;

@JsonProperty("requestHeaders")
private Map<String, String> requestHeaders;

Expand Down Expand Up @@ -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<String, String> getRequestHeaders() {
return requestHeaders == null ? null : Collections.unmodifiableMap(requestHeaders);
Expand Down
Loading