Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cd267296e | |||
| 32829ae8ba | |||
| cd77158577 |
@@ -18,6 +18,10 @@ inputs:
|
|||||||
description: "Custom API base URL (for OpenAI-compatible providers). Ignored for built-in providers."
|
description: "Custom API base URL (for OpenAI-compatible providers). Ignored for built-in providers."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
server_url:
|
||||||
|
description: "Override the Gitea/GitHub server URL used for API calls (e.g. http://server:3000 for internal routing inside the runner). Defaults to the auto-detected server URL."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
token:
|
token:
|
||||||
description: "Git platform token for posting PR comments"
|
description: "Git platform token for posting PR comments"
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export PI_API_KEY="${INPUT_API_KEY}"
|
|||||||
export PI_PROVIDER="${INPUT_PROVIDER:-zai}"
|
export PI_PROVIDER="${INPUT_PROVIDER:-zai}"
|
||||||
export PI_MODEL="${INPUT_MODEL:-glm-5.1}"
|
export PI_MODEL="${INPUT_MODEL:-glm-5.1}"
|
||||||
export PI_BASE_URL="${INPUT_BASE_URL:-}"
|
export PI_BASE_URL="${INPUT_BASE_URL:-}"
|
||||||
|
export PI_SERVER_URL="${INPUT_SERVER_URL:-}"
|
||||||
export PI_TOOLS="${INPUT_TOOLS:-read,grep,find,ls}"
|
export PI_TOOLS="${INPUT_TOOLS:-read,grep,find,ls}"
|
||||||
export PI_REVIEW_PROMPT="${INPUT_REVIEW_PROMPT:-}"
|
export PI_REVIEW_PROMPT="${INPUT_REVIEW_PROMPT:-}"
|
||||||
export PI_EXCLUDE="${INPUT_EXCLUDE_PATTERNS:-*.lock package-lock.json yarn.lock pnpm-lock.yaml *.min.js *.min.css *.map}"
|
export PI_EXCLUDE="${INPUT_EXCLUDE_PATTERNS:-*.lock package-lock.json yarn.lock pnpm-lock.yaml *.min.js *.min.css *.map}"
|
||||||
|
|||||||
+21
-11
@@ -86,7 +86,12 @@ REPO="${GITHUB_REPOSITORY:-${GITEA_REPOSITORY:-}}"
|
|||||||
|
|
||||||
# Detect Gitea vs GitHub. Gitea sets $GITHUB_SERVER_URL too, so the only
|
# Detect Gitea vs GitHub. Gitea sets $GITHUB_SERVER_URL too, so the only
|
||||||
# reliable signal is $GITEA_ACTIONS (or a non-github.com server URL).
|
# reliable signal is $GITEA_ACTIONS (or a non-github.com server URL).
|
||||||
SERVER_URL="${GITHUB_SERVER_URL:-${GITEA_SERVER_URL:-}}"
|
#
|
||||||
|
# $PI_SERVER_URL (server_url input) overrides the auto-detected server URL.
|
||||||
|
# Gitea reports its *external* hostname (e.g. git.example.com), which may not
|
||||||
|
# be routable from inside the runner's container network. Setting server_url
|
||||||
|
# to the internal address (e.g. http://server:3000) fixes API calls.
|
||||||
|
SERVER_URL="${PI_SERVER_URL:-${GITHUB_SERVER_URL:-${GITEA_SERVER_URL:-}}}"
|
||||||
if [ -n "${GITEA_ACTIONS:-}" ] || { [ -n "$SERVER_URL" ] && [ "${SERVER_URL#*github.com}" = "$SERVER_URL" ]; }; then
|
if [ -n "${GITEA_ACTIONS:-}" ] || { [ -n "$SERVER_URL" ] && [ "${SERVER_URL#*github.com}" = "$SERVER_URL" ]; }; then
|
||||||
API_BASE="${SERVER_URL}/api/v1"
|
API_BASE="${SERVER_URL}/api/v1"
|
||||||
PLATFORM="gitea"
|
PLATFORM="gitea"
|
||||||
@@ -250,14 +255,21 @@ if [ ! -s /tmp/pi-review.md ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Debug mode: PI_DEBUG=${PI_DEBUG}"
|
||||||
|
|
||||||
# If debug mode, extract tool calls from session and append to review
|
# If debug mode, extract tool calls from session and append to review
|
||||||
if [ "${PI_DEBUG}" = "true" ]; then
|
if [ "${PI_DEBUG}" = "true" ]; then
|
||||||
|
echo "Session dir contents:"
|
||||||
|
find /tmp/pi-session -type f 2>/dev/null || echo " (none)"
|
||||||
SESSION_FILE=$(find /tmp/pi-session -name '*.jsonl' -type f 2>/dev/null | head -1)
|
SESSION_FILE=$(find /tmp/pi-session -name '*.jsonl' -type f 2>/dev/null | head -1)
|
||||||
|
echo "Session file: ${SESSION_FILE:-<none found>}"
|
||||||
TOOL_LOG=""
|
TOOL_LOG=""
|
||||||
|
|
||||||
if [ -n "${SESSION_FILE}" ]; then
|
if [ -n "${SESSION_FILE}" ]; then
|
||||||
# Extract tool-use entries: each line is a JSON object.
|
# Extract tool-call entries from Pi session JSONL.
|
||||||
# Tool calls appear as messages with tool_use/function_call content.
|
# Pi stores assistant messages with content blocks of type "toolCall"
|
||||||
|
# (NOT the Anthropic SDK's "tool_use"), using "arguments" (NOT "input").
|
||||||
|
# Tool results are separate entries with role "toolResult".
|
||||||
TOOL_LOG=$(node -e "
|
TOOL_LOG=$(node -e "
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const lines = fs.readFileSync('${SESSION_FILE}', 'utf8').trim().split('\n');
|
const lines = fs.readFileSync('${SESSION_FILE}', 'utf8').trim().split('\n');
|
||||||
@@ -265,20 +277,18 @@ if [ "${PI_DEBUG}" = "true" ]; then
|
|||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
try {
|
try {
|
||||||
const entry = JSON.parse(line);
|
const entry = JSON.parse(line);
|
||||||
if (entry.type === 'message') {
|
if (entry.type !== 'message') continue;
|
||||||
const msg = entry.message;
|
const msg = entry.message;
|
||||||
// Model requesting tool use
|
if (!msg || !msg.content) continue;
|
||||||
if (msg.role === 'assistant' && msg.content) {
|
|
||||||
const parts = Array.isArray(msg.content) ? msg.content : [msg.content];
|
const parts = Array.isArray(msg.content) ? msg.content : [msg.content];
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
if (typeof part === 'object' && part.type === 'tool_use') {
|
if (typeof part !== 'object') continue;
|
||||||
const input = part.input || {};
|
if (part.type === 'toolCall') {
|
||||||
const args = Object.entries(input).map(([k,v]) => k + '=' + JSON.stringify(v)).join(' ');
|
const args = Object.entries(part.arguments || {})
|
||||||
|
.map(([k,v]) => k + '=' + JSON.stringify(v)).join(' ');
|
||||||
entries.push('[tool:' + part.name + '] ' + args);
|
entries.push('[tool:' + part.name + '] ' + args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
console.log(entries.join('\n'));
|
console.log(entries.join('\n'));
|
||||||
|
|||||||
Reference in New Issue
Block a user