Skip to content

Commit ea8bdd9

Browse files
authored
Merge pull request #230 from github/edburns/sync-with-monorepo
Add AgentMode enum and plumb agentMode through message send
2 parents 1d7f37f + befd206 commit ea8bdd9

5 files changed

Lines changed: 189 additions & 14 deletions

File tree

scripts/compare-standalone-to-monorepo.sh

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,44 @@ fi
5959
# ── Collect comparable files from the standalone repo ────────────────
6060
# Excludes: target/, node_modules/, temporary-prompts/, scripts/codegen/
6161
# (these are build artifacts or standalone-only content)
62-
TMPFILE=$(mktemp)
63-
trap 'rm -f "$TMPFILE"' EXIT
62+
TMPFILE_STANDALONE=$(mktemp)
63+
TMPFILE_MONO=$(mktemp)
64+
trap 'rm -f "$TMPFILE_STANDALONE" "$TMPFILE_MONO"' EXIT
6465

6566
(cd "$STANDALONE" && find . -type f \( -name "pom.xml" -o -name "*.java" -o -name "*.properties" \) \
6667
| grep -v '/target/' \
6768
| grep -v '/node_modules/' \
6869
| grep -v '^\./temporary-prompts/' \
6970
| grep -v '^\./scripts/codegen/' \
7071
| sed 's|^\./||' \
71-
| sort) > "$TMPFILE"
72+
| sort) > "$TMPFILE_STANDALONE"
73+
74+
# ── Collect comparable files from the monorepo ───────────────────────
75+
# Excludes: target/, node_modules/, scripts/codegen/
76+
(cd "$MONO_JAVA" && find . -type f \( -name "pom.xml" -o -name "*.java" -o -name "*.properties" \) \
77+
| grep -v '/target/' \
78+
| grep -v '/node_modules/' \
79+
| grep -v '^\./scripts/codegen/' \
80+
| sed 's|^\./||' \
81+
| sort) > "$TMPFILE_MONO"
7282

7383
# ── Compare ──────────────────────────────────────────────────────────
7484
DIFFER_COUNT=0
75-
MISSING_COUNT=0
85+
MISSING_FROM_MONO_COUNT=0
86+
MISSING_FROM_STANDALONE_COUNT=0
7687
SAME_COUNT=0
7788
DIFFER_LIST=""
78-
MISSING_LIST=""
89+
MISSING_FROM_MONO_LIST=""
90+
MISSING_FROM_STANDALONE_LIST=""
7991

92+
# Check standalone files against monorepo
8093
while IFS= read -r relpath; do
8194
standalone_file="${STANDALONE}/${relpath}"
8295
mono_file="${MONO_JAVA}/${relpath}"
8396

8497
if [ ! -f "$mono_file" ]; then
85-
MISSING_COUNT=$((MISSING_COUNT + 1))
86-
MISSING_LIST="${MISSING_LIST}${relpath}
98+
MISSING_FROM_MONO_COUNT=$((MISSING_FROM_MONO_COUNT + 1))
99+
MISSING_FROM_MONO_LIST="${MISSING_FROM_MONO_LIST}${relpath}
87100
"
88101
elif ! diff -q "$standalone_file" "$mono_file" >/dev/null 2>&1; then
89102
DIFFER_COUNT=$((DIFFER_COUNT + 1))
@@ -92,15 +105,28 @@ while IFS= read -r relpath; do
92105
else
93106
SAME_COUNT=$((SAME_COUNT + 1))
94107
fi
95-
done < "$TMPFILE"
108+
done < "$TMPFILE_STANDALONE"
96109

97-
TOTAL_COUNT=$(wc -l < "$TMPFILE" | tr -d ' ')
110+
# Check monorepo files that don't exist in standalone
111+
while IFS= read -r relpath; do
112+
standalone_file="${STANDALONE}/${relpath}"
113+
114+
if [ ! -f "$standalone_file" ]; then
115+
MISSING_FROM_STANDALONE_COUNT=$((MISSING_FROM_STANDALONE_COUNT + 1))
116+
MISSING_FROM_STANDALONE_LIST="${MISSING_FROM_STANDALONE_LIST}${relpath}
117+
"
118+
fi
119+
done < "$TMPFILE_MONO"
120+
121+
STANDALONE_TOTAL=$(wc -l < "$TMPFILE_STANDALONE" | tr -d ' ')
122+
MONO_TOTAL=$(wc -l < "$TMPFILE_MONO" | tr -d ' ')
98123

99124
# ── Output ───────────────────────────────────────────────────────────
100-
echo "Compared ${TOTAL_COUNT} files (pom.xml, *.java, *.properties)"
125+
echo "Standalone files: ${STANDALONE_TOTAL} Monorepo files: ${MONO_TOTAL}"
101126
echo " Identical: ${SAME_COUNT}"
102127
echo " Differ: ${DIFFER_COUNT}"
103-
echo " Missing from monorepo: ${MISSING_COUNT}"
128+
echo " Only in standalone (missing from monorepo): ${MISSING_FROM_MONO_COUNT}"
129+
echo " Only in monorepo (missing from standalone): ${MISSING_FROM_STANDALONE_COUNT}"
104130
echo ""
105131

106132
if [ "$DIFFER_COUNT" -gt 0 ]; then
@@ -112,16 +138,25 @@ if [ "$DIFFER_COUNT" -gt 0 ]; then
112138
echo ""
113139
fi
114140

115-
if [ "$MISSING_COUNT" -gt 0 ]; then
141+
if [ "$MISSING_FROM_MONO_COUNT" -gt 0 ]; then
116142
echo "The following files exist in standalone but NOT in monorepo:"
117143
echo ""
118-
printf '%s' "$MISSING_LIST" | while IFS= read -r f; do
144+
printf '%s' "$MISSING_FROM_MONO_LIST" | while IFS= read -r f; do
119145
[ -n "$f" ] && echo " $f"
120146
done
121147
echo ""
122148
fi
123149

124-
if [ "$DIFFER_COUNT" -eq 0 ] && [ "$MISSING_COUNT" -eq 0 ]; then
150+
if [ "$MISSING_FROM_STANDALONE_COUNT" -gt 0 ]; then
151+
echo "The following files exist in monorepo but NOT in standalone:"
152+
echo ""
153+
printf '%s' "$MISSING_FROM_STANDALONE_LIST" | while IFS= read -r f; do
154+
[ -n "$f" ] && echo " $f"
155+
done
156+
echo ""
157+
fi
158+
159+
if [ "$DIFFER_COUNT" -eq 0 ] && [ "$MISSING_FROM_MONO_COUNT" -eq 0 ] && [ "$MISSING_FROM_STANDALONE_COUNT" -eq 0 ]; then
125160
echo "All files are identical."
126161
fi
127162

@@ -139,3 +174,31 @@ if [ "$SHOW_DIFF" = true ] && [ "$DIFFER_COUNT" -gt 0 ]; then
139174
fi
140175
done
141176
fi
177+
178+
if [ "$SHOW_DIFF" = true ] && [ "$MISSING_FROM_STANDALONE_COUNT" -gt 0 ]; then
179+
echo ""
180+
echo "================================================================================"
181+
echo "Files only in monorepo (new files to port to standalone):"
182+
echo "================================================================================"
183+
printf '%s' "$MISSING_FROM_STANDALONE_LIST" | while IFS= read -r f; do
184+
if [ -n "$f" ]; then
185+
echo ""
186+
echo "+++ monorepo/java/$f"
187+
diff -u /dev/null "${MONO_JAVA}/${f}" || true
188+
fi
189+
done
190+
fi
191+
192+
if [ "$SHOW_DIFF" = true ] && [ "$MISSING_FROM_MONO_COUNT" -gt 0 ]; then
193+
echo ""
194+
echo "================================================================================"
195+
echo "Files only in standalone (not present in monorepo):"
196+
echo "================================================================================"
197+
printf '%s' "$MISSING_FROM_MONO_LIST" | while IFS= read -r f; do
198+
if [ -n "$f" ]; then
199+
echo ""
200+
echo "--- standalone/$f"
201+
diff -u "${STANDALONE}/${f}" /dev/null || true
202+
fi
203+
done
204+
fi

src/main/java/com/github/copilot/CopilotSession.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ public CompletableFuture<String> send(MessageOptions options) {
475475
request.setPrompt(options.getPrompt());
476476
request.setAttachments(options.getAttachments());
477477
request.setMode(options.getMode());
478+
request.setAgentMode(options.getAgentMode());
478479
request.setRequestHeaders(options.getRequestHeaders());
479480

480481
return rpc.invoke("session.send", request, SendMessageResponse.class).thenApply(SendMessageResponse::messageId);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.rpc;
6+
7+
import com.fasterxml.jackson.annotation.JsonCreator;
8+
import com.fasterxml.jackson.annotation.JsonValue;
9+
10+
/**
11+
* The UI mode the agent is in for a given turn.
12+
* <p>
13+
* Set on {@link MessageOptions#setAgentMode(AgentMode)} to send a message in a
14+
* specific mode; defaults to the session's current mode when unset.
15+
*
16+
* @see MessageOptions
17+
* @since 1.1.0
18+
*/
19+
public enum AgentMode {
20+
21+
/** The agent is responding interactively to the user. */
22+
INTERACTIVE("interactive"),
23+
24+
/** The agent is preparing a plan before making changes. */
25+
PLAN("plan"),
26+
27+
/** The agent is working autonomously toward task completion. */
28+
AUTOPILOT("autopilot"),
29+
30+
/** The agent is in shell-focused UI mode. */
31+
SHELL("shell");
32+
33+
private final String value;
34+
35+
AgentMode(String value) {
36+
this.value = value;
37+
}
38+
39+
/**
40+
* Returns the JSON value for this agent mode.
41+
*
42+
* @return the string value used in JSON serialization
43+
*/
44+
@JsonValue
45+
public String getValue() {
46+
return value;
47+
}
48+
49+
/**
50+
* Deserializes a JSON string value into the corresponding {@code AgentMode}
51+
* enum constant.
52+
*
53+
* @param value
54+
* the JSON string value
55+
* @return the matching {@code AgentMode}, or {@code null} if value is
56+
* {@code null}
57+
* @throws IllegalArgumentException
58+
* if the value does not match any known agent mode
59+
*/
60+
@JsonCreator
61+
public static AgentMode fromValue(String value) {
62+
if (value == null) {
63+
return null;
64+
}
65+
for (AgentMode mode : values()) {
66+
if (mode.value.equals(value)) {
67+
return mode;
68+
}
69+
}
70+
throw new IllegalArgumentException("Unknown AgentMode: " + value);
71+
}
72+
}

src/main/java/com/github/copilot/rpc/MessageOptions.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class MessageOptions {
4545
private String prompt;
4646
private List<MessageAttachment> attachments;
4747
private String mode;
48+
private AgentMode agentMode;
4849
private Map<String, String> requestHeaders;
4950

5051
/**
@@ -126,6 +127,30 @@ public String getMode() {
126127
return mode;
127128
}
128129

130+
/**
131+
* Sets the per-message agent UI mode.
132+
* <p>
133+
* Defaults to the session's current mode when unset.
134+
*
135+
* @param agentMode
136+
* the agent mode (for example {@link AgentMode#PLAN} or
137+
* {@link AgentMode#AUTOPILOT})
138+
* @return this options instance for method chaining
139+
*/
140+
public MessageOptions setAgentMode(AgentMode agentMode) {
141+
this.agentMode = agentMode;
142+
return this;
143+
}
144+
145+
/**
146+
* Gets the per-message agent UI mode.
147+
*
148+
* @return the agent mode, or {@code null} if not set
149+
*/
150+
public AgentMode getAgentMode() {
151+
return agentMode;
152+
}
153+
129154
/**
130155
* Gets the custom per-turn HTTP headers for outbound model requests.
131156
*
@@ -167,6 +192,7 @@ public MessageOptions clone() {
167192
copy.prompt = this.prompt;
168193
copy.attachments = this.attachments != null ? new ArrayList<>(this.attachments) : null;
169194
copy.mode = this.mode;
195+
copy.agentMode = this.agentMode;
170196
copy.requestHeaders = this.requestHeaders != null ? new HashMap<>(this.requestHeaders) : null;
171197
return copy;
172198
}

src/main/java/com/github/copilot/rpc/SendMessageRequest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public final class SendMessageRequest {
3737
@JsonProperty("mode")
3838
private String mode;
3939

40+
@JsonProperty("agentMode")
41+
private AgentMode agentMode;
42+
4043
@JsonProperty("requestHeaders")
4144
private Map<String, String> requestHeaders;
4245

@@ -80,6 +83,16 @@ public void setMode(String mode) {
8083
this.mode = mode;
8184
}
8285

86+
/** Gets the per-message agent UI mode. @return the agent mode */
87+
public AgentMode getAgentMode() {
88+
return agentMode;
89+
}
90+
91+
/** Sets the per-message agent UI mode. @param agentMode the agent mode */
92+
public void setAgentMode(AgentMode agentMode) {
93+
this.agentMode = agentMode;
94+
}
95+
8396
/** Gets the per-turn request headers. @return the headers map */
8497
public Map<String, String> getRequestHeaders() {
8598
return requestHeaders == null ? null : Collections.unmodifiableMap(requestHeaders);

0 commit comments

Comments
 (0)