Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9471d13

Browse files
committed
address PR comments
1 parent5af888c commit9471d13

File tree

2 files changed

+60
-79
lines changed

2 files changed

+60
-79
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ jobs:
7070
mkdir -p "${HOME}/.local/bin"
7171
curl -fsSL --compressed "$CODER_URL/bin/coder-linux-${ARCH}" -o "${HOME}/.local/bin/coder"
7272
chmod +x "${HOME}/.local/bin/coder"
73+
export PATH="$HOME/.local/bin:$PATH"
74+
coder version
75+
coder whoami
7376
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
74-
"$HOME"/.local/bin/coder version
75-
"$HOME"/.local/bin/coder whoami
7677
7778
-name:Create Coder workspace
7879
id:create-workspace
@@ -101,15 +102,17 @@ jobs:
101102
102103
# Write a prompt to PROMPT_FILE
103104
cat > "${PROMPT_FILE}" <<EOF
104-
Analyze the below GitHub issue description, understand the root cause, and make appropriate changes to resolve the issue.
105+
Analyze the below GitHub issue description, understand the root cause, and make appropriate changes to resolve the issue.
105106
106-
ISSUE URL: ${ISSUE_URL}
107-
ISSUE DESCRIPTION BELOW:
107+
ISSUE URL: ${ISSUE_URL}
108+
ISSUE DESCRIPTION BELOW:
108109
109-
${issue_description}
110+
${issue_description}
110111
EOF
111112
112113
echo "WORKSPACE_NAME: ${WORKSPACE_NAME}"
114+
# This command will run the prompt inside the workspace
115+
# and exit once the agent has completed the task.
113116
PROMPT=$(cat $PROMPT_FILE) ./scripts/traiage.sh prompt
114117
115118
-name:Commit and push changes

‎scripts/traiage.sh‎

Lines changed: 51 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,21 @@ prompt_ssh() {
6262

6363
ssh_config
6464

65-
# Write prompt to a file in the workspace
66-
cat<<<"${PROMPT}">"${TEMPDIR}/prompt.txt"
67-
scp \
68-
-F"${OPENSSH_CONFIG_FILE}" \
69-
"${TEMPDIR}/prompt.txt" \
70-
"${WORKSPACE_NAME}.coder:/tmp/prompt.txt"
71-
72-
# Execute claude over SSH
65+
# Execute claude over SSH and provide prompt via stdin
7366
# Note: use of cat to work around claude-code#7357
7467
ssh \
7568
-F"${OPENSSH_CONFIG_FILE}" \
7669
"${WORKSPACE_NAME}.coder" \
7770
-- \
78-
"cat /tmp/prompt.txt |\"\${HOME}\"/.local/bin/claude --dangerously-skip-permissions --print --verbose --output-format=stream-json"
71+
"cat |\"\${HOME}\"/.local/bin/claude --dangerously-skip-permissions --print --verbose --output-format=stream-json" \
72+
<<<"${PROMPT}"
7973
exit 0
8074
}
8175

8276
prompt_agentapi() {
8377
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME AGENTAPI_SLUG PROMPT
8478

85-
wait
79+
wait_agentapi_stable
8680

8781
username=$(curl \
8882
--fail \
@@ -112,10 +106,10 @@ prompt_agentapi() {
112106
exit 1
113107
fi
114108

115-
wait
109+
wait_agentapi_stable
116110
}
117111

118-
wait() {
112+
wait_agentapi_stable() {
119113
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME PROMPT
120114
username=$(curl \
121115
--fail \
@@ -125,14 +119,8 @@ wait() {
125119
--silent \
126120
"${CODER_URL}/api/v2/users/me"| jq -r'.username')
127121

128-
payload="{
129-
\"content\":\"${PROMPT}\",
130-
\"type\":\"user\"
131-
}"
132-
133-
forattemptin {1..600};do
122+
forattemptin {1..120};do
134123
response=$(curl \
135-
--data-raw"${payload}" \
136124
--fail \
137125
--header"Content-Type: application/json" \
138126
--header"Coder-Session-Token:${CODER_SESSION_TOKEN}" \
@@ -145,39 +133,34 @@ wait() {
145133
echo"AgentAPI stable"
146134
break
147135
fi
148-
echo"Waiting for AgentAPI to report stable status (attempt${attempt}/600)"
149-
sleep1
136+
echo"Waiting for AgentAPI to report stable status (attempt${attempt}/120)"
137+
sleep5
150138
done
151139
}
152140

153141
archive() {
154142
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME DESTINATION_PREFIX
155143
ssh_config
156144

157-
cat>"${TEMPDIR}/archive.sh"<<-EOF
158-
#!/usr/bin/env bash
159-
set -euo pipefail
160-
/tmp/coder-script-data/bin/coder-archive-create
161-
ARCHIVE_NAME=\$(cd && find . -maxdepth 1 -type f -name "*.tar.gz" -print0 | xargs -0 -n 1 basename)
162-
ARCHIVE_PATH="/home/coder/\${ARCHIVE_NAME}"
163-
ARCHIVE_DEST="${DESTINATION_PREFIX%%/}/\${ARCHIVE_NAME}"
164-
if [[ ! -f "\${ARCHIVE_PATH}" ]]; then
165-
echo "FATAL: Archive not found at expected path:\${ARCHIVE_PATH}"
166-
exit 1
167-
fi
168-
gcloud storage cp "\${ARCHIVE_PATH}" "\${ARCHIVE_DEST}"
169-
echo "\${ARCHIVE_DEST}"
170-
exit 0
171-
EOF
172-
173-
scp -F"${OPENSSH_CONFIG_FILE}" \
174-
"${TEMPDIR}/archive.sh" \
175-
"${WORKSPACE_NAME}.coder:/tmp/archive.sh"
176-
145+
# We want the heredoc to be expanded locally and not remotely.
146+
# shellcheck disable=SC2087
177147
ARCHIVE_DEST=$(ssh -F"${OPENSSH_CONFIG_FILE}" \
178148
"${WORKSPACE_NAME}.coder" \
179-
-- \
180-
"chmod +x /tmp/archive.sh && /tmp/archive.sh")
149+
bash<<-EOF
150+
#!/usr/bin/env bash
151+
set -euo pipefail
152+
ARCHIVE_PATH=\$(coder-archive-create)
153+
ARCHIVE_NAME=\$(basename "\${ARCHIVE_PATH}")
154+
ARCHIVE_DEST="${DESTINATION_PREFIX%%/}/\${ARCHIVE_NAME}"
155+
if [[ ! -f "\${ARCHIVE_PATH}" ]]; then
156+
echo "FATAL: Archive not found at expected path:\${ARCHIVE_PATH}"
157+
exit 1
158+
fi
159+
gcloud storage cp "\${ARCHIVE_PATH}" "\${ARCHIVE_DEST}"
160+
echo "\${ARCHIVE_DEST}"
161+
exit 0
162+
EOF
163+
)
181164

182165
echo"${ARCHIVE_DEST}"
183166

@@ -188,38 +171,33 @@ commit_push() {
188171
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME
189172
ssh_config
190173

191-
# For multiple commands, upload a script and run it.
192-
cat>"${TEMPDIR}/commit_push.sh"<<-EOF
193-
#!/usr/bin/env bash
194-
set -euo pipefail
195-
if [[\$(git branch --show-current) != "${WORKSPACE_NAME}" ]]; then
196-
git checkout -b${WORKSPACE_NAME}
197-
fi
198-
199-
if [[ -z\$(git status --porcelain) ]]; then
200-
echo "FATAL: No changes to commit"
201-
exit 1
202-
fi
203-
204-
git add -A
205-
commit_msg=\$(echo -n 'You are a CLI utility that generates a commit message. Generate a concise git commit message for the currently staged changes. Print ONLY the commit message and nothing else.' |\${HOME}/.local/bin/claude --print)
206-
if [[ -z "\${commit_msg}" ]]; then
207-
commit_msg="Default commit message"
208-
fi
209-
git commit -am "\${commit_msg}"
210-
git push origin${WORKSPACE_NAME}
211-
EOF
212-
213-
scp \
214-
-F"${OPENSSH_CONFIG_FILE}" \
215-
"${TEMPDIR}/commit_push.sh" \
216-
"${WORKSPACE_NAME}.coder:/tmp/commit_push.sh"
217-
174+
# We want the heredoc to be expanded locally and not remotely.
175+
# shellcheck disable=SC2087
218176
ssh \
219177
-F"${OPENSSH_CONFIG_FILE}" \
220178
"${WORKSPACE_NAME}.coder" \
221179
-- \
222-
"chmod +x /tmp/commit_push.sh && /tmp/commit_push.sh"
180+
bash<<-EOF
181+
#!/usr/bin/env bash
182+
set -euo pipefail
183+
BRANCH="traiage/${WORKSPACE_NAME}"
184+
if [[\$(git branch --show-current) != "\${BRANCH}" ]]; then
185+
git checkout -b "\${BRANCH}"
186+
fi
187+
188+
if [[ -z\$(git status --porcelain) ]]; then
189+
echo "FATAL: No changes to commit"
190+
exit 1
191+
fi
192+
193+
git add -A
194+
commit_msg=\$(echo -n 'You are a CLI utility that generates a commit message. Generate a concise git commit message for the currently staged changes. Print ONLY the commit message and nothing else.' |\${HOME}/.local/bin/claude --print)
195+
if [[ -z "\${commit_msg}" ]]; then
196+
commit_msg="Default commit message"
197+
fi
198+
git commit -am "\${commit_msg}"
199+
exit 0
200+
EOF
223201

224202
exit$?
225203
}
@@ -258,8 +236,8 @@ main() {
258236
delete)
259237
delete
260238
;;
261-
wait)
262-
wait
239+
wait-agentapi-stable)
240+
wait_agentapi_stable
263241
;;
264242
*)
265243
echo"Unknown option:$1"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp