Compare commits
2 Commits
fix/git-wr
...
fix/pi-tok
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37d3b6e425 | ||
|
|
3ff3f20b70 |
@@ -58,6 +58,8 @@ mosaic yolo pi # Pi in yolo mode
|
|||||||
|
|
||||||
The launcher verifies your config, checks for `SOUL.md`, injects your `AGENTS.md` standards into the runtime, and forwards all arguments.
|
The launcher verifies your config, checks for `SOUL.md`, injects your `AGENTS.md` standards into the runtime, and forwards all arguments.
|
||||||
|
|
||||||
|
Pi launches default to a token-lean skill posture: `mosaic pi` passes `--no-skills` so Pi does not preload every global skill description into the system prompt. Use `MOSAIC_PI_SKILL_MODE=all mosaic pi` for the legacy all-skills catalog, or `MOSAIC_PI_SKILL_MODE=discover mosaic pi` to let Pi use its native settings/project skill discovery.
|
||||||
|
|
||||||
### TUI & Gateway
|
### TUI & Gateway
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ gitea_get_branch_head_sha() {
|
|||||||
local branch="$3"
|
local branch="$3"
|
||||||
local token="$4"
|
local token="$4"
|
||||||
local url="https://${host}/api/v1/repos/${repo}/branches/${branch}"
|
local url="https://${host}/api/v1/repos/${repo}/branches/${branch}"
|
||||||
curl -fsS -H "Authorization: token ${token}" "$url" | python3 -c '
|
curl -fsSL -H "Authorization: token ${token}" "$url" | python3 -c '
|
||||||
import json, sys
|
import json, sys
|
||||||
data = json.load(sys.stdin)
|
data = json.load(sys.stdin)
|
||||||
commit = data.get("commit") or {}
|
commit = data.get("commit") or {}
|
||||||
@@ -151,7 +151,7 @@ gitea_get_commit_status_json() {
|
|||||||
local sha="$3"
|
local sha="$3"
|
||||||
local token="$4"
|
local token="$4"
|
||||||
local url="https://${host}/api/v1/repos/${repo}/commits/${sha}/status"
|
local url="https://${host}/api/v1/repos/${repo}/commits/${sha}/status"
|
||||||
curl -fsS -H "Authorization: token ${token}" "$url"
|
curl -fsSL -H "Authorization: token ${token}" "$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|||||||
@@ -74,16 +74,6 @@ get_repo_name() {
|
|||||||
echo "${repo_info##*/}"
|
echo "${repo_info##*/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_repo_slug() {
|
|
||||||
get_repo_info
|
|
||||||
}
|
|
||||||
|
|
||||||
get_gitea_repo_args() {
|
|
||||||
local repo
|
|
||||||
repo=$(get_repo_slug) || return 1
|
|
||||||
printf -- '--repo %q --login %q' "$repo" "${GITEA_LOGIN:-mosaicstack}"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_remote_host() {
|
get_remote_host() {
|
||||||
local remote_url
|
local remote_url
|
||||||
remote_url=$(git remote get-url origin 2>/dev/null || true)
|
remote_url=$(git remote get-url origin 2>/dev/null || true)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [[ "$PLATFORM" == "github" ]]; then
|
|||||||
gh issue comment "$ISSUE_NUMBER" --body "$COMMENT"
|
gh issue comment "$ISSUE_NUMBER" --body "$COMMENT"
|
||||||
echo "Added comment to GitHub issue #$ISSUE_NUMBER"
|
echo "Added comment to GitHub issue #$ISSUE_NUMBER"
|
||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
tea issue comment "$ISSUE_NUMBER" "$COMMENT" $(get_gitea_repo_args)
|
tea issue comment "$ISSUE_NUMBER" "$COMMENT"
|
||||||
echo "Added comment to Gitea issue #$ISSUE_NUMBER"
|
echo "Added comment to Gitea issue #$ISSUE_NUMBER"
|
||||||
else
|
else
|
||||||
echo "Error: Unknown platform"
|
echo "Error: Unknown platform"
|
||||||
|
|||||||
@@ -112,22 +112,20 @@ PLATFORM=$(detect_platform)
|
|||||||
|
|
||||||
case "$PLATFORM" in
|
case "$PLATFORM" in
|
||||||
github)
|
github)
|
||||||
CMD=(gh issue create --title "$TITLE")
|
CMD="gh issue create --title \"$TITLE\""
|
||||||
[[ -n "$BODY" ]] && CMD+=(--body "$BODY")
|
[[ -n "$BODY" ]] && CMD="$CMD --body \"$BODY\""
|
||||||
[[ -n "$LABELS" ]] && CMD+=(--label "$LABELS")
|
[[ -n "$LABELS" ]] && CMD="$CMD --label \"$LABELS\""
|
||||||
[[ -n "$MILESTONE" ]] && CMD+=(--milestone "$MILESTONE")
|
[[ -n "$MILESTONE" ]] && CMD="$CMD --milestone \"$MILESTONE\""
|
||||||
"${CMD[@]}"
|
eval "$CMD"
|
||||||
;;
|
;;
|
||||||
gitea)
|
gitea)
|
||||||
if command -v tea >/dev/null 2>&1; then
|
if command -v tea >/dev/null 2>&1; then
|
||||||
REPO_SLUG=$(get_repo_slug)
|
CMD="tea issue create --title \"$TITLE\""
|
||||||
REPO_ARGS=(--repo "$REPO_SLUG" --login "${GITEA_LOGIN:-mosaicstack}")
|
[[ -n "$BODY" ]] && CMD="$CMD --description \"$BODY\""
|
||||||
CMD=(tea issue create "${REPO_ARGS[@]}" --title "$TITLE")
|
[[ -n "$LABELS" ]] && CMD="$CMD --labels \"$LABELS\""
|
||||||
[[ -n "$BODY" ]] && CMD+=(--description "$BODY")
|
|
||||||
[[ -n "$LABELS" ]] && CMD+=(--labels "$LABELS")
|
|
||||||
# tea accepts milestone by name directly (verified 2026-02-05)
|
# tea accepts milestone by name directly (verified 2026-02-05)
|
||||||
[[ -n "$MILESTONE" ]] && CMD+=(--milestone "$MILESTONE")
|
[[ -n "$MILESTONE" ]] && CMD="$CMD --milestone \"$MILESTONE\""
|
||||||
if "${CMD[@]}"; then
|
if eval "$CMD"; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Warning: tea issue create failed, trying Gitea API fallback..." >&2
|
echo "Warning: tea issue create failed, trying Gitea API fallback..." >&2
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ case "$PLATFORM" in
|
|||||||
eval "$CMD"
|
eval "$CMD"
|
||||||
;;
|
;;
|
||||||
gitea)
|
gitea)
|
||||||
REPO_ARGS=$(get_gitea_repo_args)
|
CMD="tea issues list --state $STATE --limit $LIMIT"
|
||||||
CMD="tea issues list $REPO_ARGS --state $STATE --limit $LIMIT"
|
|
||||||
[[ -n "$LABEL" ]] && CMD="$CMD --labels \"$LABEL\""
|
[[ -n "$LABEL" ]] && CMD="$CMD --labels \"$LABEL\""
|
||||||
[[ -n "$MILESTONE" ]] && CMD="$CMD --milestones \"$MILESTONE\""
|
[[ -n "$MILESTONE" ]] && CMD="$CMD --milestones \"$MILESTONE\""
|
||||||
# Note: tea may not support assignee filter directly
|
# Note: tea may not support assignee filter directly
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ if [[ "$PLATFORM" == "github" ]]; then
|
|||||||
echo "Reopened GitHub issue #$ISSUE_NUMBER"
|
echo "Reopened GitHub issue #$ISSUE_NUMBER"
|
||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
if [[ -n "$COMMENT" ]]; then
|
if [[ -n "$COMMENT" ]]; then
|
||||||
tea issue comment "$ISSUE_NUMBER" "$COMMENT" $(get_gitea_repo_args)
|
tea issue comment "$ISSUE_NUMBER" "$COMMENT"
|
||||||
fi
|
fi
|
||||||
tea issue reopen "$ISSUE_NUMBER" $(get_gitea_repo_args)
|
tea issue reopen "$ISSUE_NUMBER"
|
||||||
echo "Reopened Gitea issue #$ISSUE_NUMBER"
|
echo "Reopened Gitea issue #$ISSUE_NUMBER"
|
||||||
else
|
else
|
||||||
echo "Error: Unknown platform"
|
echo "Error: Unknown platform"
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ if [[ "$PLATFORM" == "github" ]]; then
|
|||||||
gh issue view "$ISSUE_NUMBER"
|
gh issue view "$ISSUE_NUMBER"
|
||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
if command -v tea >/dev/null 2>&1; then
|
if command -v tea >/dev/null 2>&1; then
|
||||||
if tea issue "$ISSUE_NUMBER" $(get_gitea_repo_args); then
|
if tea issue "$ISSUE_NUMBER"; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Warning: tea issue view failed, trying Gitea API fallback..." >&2
|
echo "Warning: tea issue view failed, trying Gitea API fallback..." >&2
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ gitea_get_pr_head_sha() {
|
|||||||
local repo="$2"
|
local repo="$2"
|
||||||
local token="$3"
|
local token="$3"
|
||||||
local url="https://${host}/api/v1/repos/${repo}/pulls/${PR_NUMBER}"
|
local url="https://${host}/api/v1/repos/${repo}/pulls/${PR_NUMBER}"
|
||||||
curl -fsS -H "Authorization: token ${token}" "$url" | python3 -c '
|
curl -fsSL -H "Authorization: token ${token}" "$url" | python3 -c '
|
||||||
import json, sys
|
import json, sys
|
||||||
data = json.load(sys.stdin)
|
data = json.load(sys.stdin)
|
||||||
print((data.get("head") or {}).get("sha", ""))
|
print((data.get("head") or {}).get("sha", ""))
|
||||||
@@ -123,7 +123,7 @@ gitea_get_commit_status_json() {
|
|||||||
local token="$3"
|
local token="$3"
|
||||||
local sha="$4"
|
local sha="$4"
|
||||||
local url="https://${host}/api/v1/repos/${repo}/commits/${sha}/status"
|
local url="https://${host}/api/v1/repos/${repo}/commits/${sha}/status"
|
||||||
curl -fsS -H "Authorization: token ${token}" "$url"
|
curl -fsSL -H "Authorization: token ${token}" "$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ if [[ "$PLATFORM" == "github" ]]; then
|
|||||||
echo "Closed GitHub PR #$PR_NUMBER"
|
echo "Closed GitHub PR #$PR_NUMBER"
|
||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
if [[ -n "$COMMENT" ]]; then
|
if [[ -n "$COMMENT" ]]; then
|
||||||
tea pr comment "$PR_NUMBER" "$COMMENT" $(get_gitea_repo_args)
|
tea pr comment "$PR_NUMBER" "$COMMENT"
|
||||||
fi
|
fi
|
||||||
tea pr close "$PR_NUMBER" $(get_gitea_repo_args)
|
tea pr close "$PR_NUMBER"
|
||||||
echo "Closed Gitea PR #$PR_NUMBER"
|
echo "Closed Gitea PR #$PR_NUMBER"
|
||||||
else
|
else
|
||||||
echo "Error: Unknown platform"
|
echo "Error: Unknown platform"
|
||||||
|
|||||||
@@ -17,51 +17,6 @@ MILESTONE=""
|
|||||||
DRAFT=false
|
DRAFT=false
|
||||||
ISSUE=""
|
ISSUE=""
|
||||||
|
|
||||||
# get_remote_host, get_gitea_token, get_repo_info, and get_gitea_repo_args are provided by detect-platform.sh
|
|
||||||
|
|
||||||
gitea_pr_create_api() {
|
|
||||||
local host repo token url payload
|
|
||||||
host=$(get_remote_host) || {
|
|
||||||
echo "Error: could not determine remote host for API fallback" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
repo=$(get_repo_info) || {
|
|
||||||
echo "Error: could not determine repo owner/name for API fallback" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
token=$(get_gitea_token "$host") || {
|
|
||||||
echo "Error: Gitea token not found for API fallback (set GITEA_TOKEN or configure ~/.git-credentials)" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ -n "$LABELS" || -n "$MILESTONE" || "$DRAFT" == true ]]; then
|
|
||||||
echo "Warning: API fallback applies title/body/head/base only; labels/milestone/draft require authenticated tea setup." >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
payload=$(TITLE="$TITLE" BODY="$BODY" HEAD_BRANCH="$HEAD_BRANCH" BASE_BRANCH="$BASE_BRANCH" python3 - <<'PY'
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
|
|
||||||
payload = {
|
|
||||||
"title": os.environ["TITLE"],
|
|
||||||
"head": os.environ["HEAD_BRANCH"],
|
|
||||||
"base": os.environ["BASE_BRANCH"] or "main",
|
|
||||||
}
|
|
||||||
body = os.environ.get("BODY", "")
|
|
||||||
if body:
|
|
||||||
payload["body"] = body
|
|
||||||
print(json.dumps(payload))
|
|
||||||
PY
|
|
||||||
)
|
|
||||||
|
|
||||||
url="https://${host}/api/v1/repos/${repo}/pulls"
|
|
||||||
curl -fsS -X POST \
|
|
||||||
-H "Authorization: token ${token}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$payload" \
|
|
||||||
"$url"
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename "$0") [OPTIONS]
|
Usage: $(basename "$0") [OPTIONS]
|
||||||
@@ -163,37 +118,33 @@ PLATFORM=$(detect_platform)
|
|||||||
|
|
||||||
case "$PLATFORM" in
|
case "$PLATFORM" in
|
||||||
github)
|
github)
|
||||||
CMD=(gh pr create --title "$TITLE")
|
CMD="gh pr create --title \"$TITLE\""
|
||||||
[[ -n "$BODY" ]] && CMD+=(--body "$BODY")
|
[[ -n "$BODY" ]] && CMD="$CMD --body \"$BODY\""
|
||||||
[[ -n "$BASE_BRANCH" ]] && CMD+=(--base "$BASE_BRANCH")
|
[[ -n "$BASE_BRANCH" ]] && CMD="$CMD --base \"$BASE_BRANCH\""
|
||||||
[[ -n "$HEAD_BRANCH" ]] && CMD+=(--head "$HEAD_BRANCH")
|
[[ -n "$HEAD_BRANCH" ]] && CMD="$CMD --head \"$HEAD_BRANCH\""
|
||||||
[[ -n "$LABELS" ]] && CMD+=(--label "$LABELS")
|
[[ -n "$LABELS" ]] && CMD="$CMD --label \"$LABELS\""
|
||||||
[[ -n "$MILESTONE" ]] && CMD+=(--milestone "$MILESTONE")
|
[[ -n "$MILESTONE" ]] && CMD="$CMD --milestone \"$MILESTONE\""
|
||||||
[[ "$DRAFT" == true ]] && CMD+=(--draft)
|
[[ "$DRAFT" == true ]] && CMD="$CMD --draft"
|
||||||
"${CMD[@]}"
|
eval "$CMD"
|
||||||
;;
|
;;
|
||||||
gitea)
|
gitea)
|
||||||
# tea pull create syntax. Always pass --repo because tea repo inference
|
# tea pull create syntax
|
||||||
# is unreliable in Mosaic worktrees/profile shells. Use arrays instead
|
CMD="tea pr create --title \"$TITLE\""
|
||||||
# of eval so markdown backticks/body content are not shell-executed.
|
[[ -n "$BODY" ]] && CMD="$CMD --description \"$BODY\""
|
||||||
REPO_SLUG=$(get_repo_slug)
|
[[ -n "$BASE_BRANCH" ]] && CMD="$CMD --base \"$BASE_BRANCH\""
|
||||||
REPO_ARGS=(--repo "$REPO_SLUG" --login "${GITEA_LOGIN:-mosaicstack}")
|
[[ -n "$HEAD_BRANCH" ]] && CMD="$CMD --head \"$HEAD_BRANCH\""
|
||||||
CMD=(tea pr create "${REPO_ARGS[@]}" --title "$TITLE")
|
|
||||||
[[ -n "$BODY" ]] && CMD+=(--description "$BODY")
|
|
||||||
[[ -n "$BASE_BRANCH" ]] && CMD+=(--base "$BASE_BRANCH")
|
|
||||||
[[ -n "$HEAD_BRANCH" ]] && CMD+=(--head "$HEAD_BRANCH")
|
|
||||||
|
|
||||||
# Handle labels for tea
|
# Handle labels for tea
|
||||||
if [[ -n "$LABELS" ]]; then
|
if [[ -n "$LABELS" ]]; then
|
||||||
# tea may use --labels flag
|
# tea may use --labels flag
|
||||||
CMD+=(--labels "$LABELS")
|
CMD="$CMD --labels \"$LABELS\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle milestone for tea
|
# Handle milestone for tea
|
||||||
if [[ -n "$MILESTONE" ]]; then
|
if [[ -n "$MILESTONE" ]]; then
|
||||||
MILESTONE_ID=$(tea milestones list "${REPO_ARGS[@]}" 2>/dev/null | grep -E "^\s*[0-9]+" | grep "$MILESTONE" | awk '{print $1}' | head -1)
|
MILESTONE_ID=$(tea milestones list 2>/dev/null | grep -E "^\s*[0-9]+" | grep "$MILESTONE" | awk '{print $1}' | head -1)
|
||||||
if [[ -n "$MILESTONE_ID" ]]; then
|
if [[ -n "$MILESTONE_ID" ]]; then
|
||||||
CMD+=(--milestone "$MILESTONE_ID")
|
CMD="$CMD --milestone $MILESTONE_ID"
|
||||||
else
|
else
|
||||||
echo "Warning: Could not find milestone '$MILESTONE', creating without milestone" >&2
|
echo "Warning: Could not find milestone '$MILESTONE', creating without milestone" >&2
|
||||||
fi
|
fi
|
||||||
@@ -204,11 +155,7 @@ case "$PLATFORM" in
|
|||||||
echo "Note: Draft PR may not be supported by your tea version" >&2
|
echo "Note: Draft PR may not be supported by your tea version" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "${CMD[@]}"; then
|
eval "$CMD"
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "Warning: tea pr create failed, trying Gitea API fallback..." >&2
|
|
||||||
gitea_pr_create_api
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Could not detect git platform" >&2
|
echo "Error: Could not detect git platform" >&2
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ case "$PLATFORM" in
|
|||||||
;;
|
;;
|
||||||
gitea)
|
gitea)
|
||||||
# tea pr list - note: tea uses 'pulls' subcommand in some versions
|
# tea pr list - note: tea uses 'pulls' subcommand in some versions
|
||||||
REPO_ARGS=$(get_gitea_repo_args)
|
CMD="tea pr list --state $STATE --limit $LIMIT"
|
||||||
CMD="tea pr list $REPO_ARGS --state $STATE --limit $LIMIT"
|
|
||||||
|
|
||||||
# tea filtering may be limited
|
# tea filtering may be limited
|
||||||
if [[ -n "$LABEL" ]]; then
|
if [[ -n "$LABEL" ]]; then
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ if [[ "$PLATFORM" == "github" ]]; then
|
|||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
case $ACTION in
|
case $ACTION in
|
||||||
approve)
|
approve)
|
||||||
tea pr approve "$PR_NUMBER" $(get_gitea_repo_args) ${COMMENT:+--comment "$COMMENT"}
|
tea pr approve "$PR_NUMBER" ${COMMENT:+--comment "$COMMENT"}
|
||||||
echo "Approved Gitea PR #$PR_NUMBER"
|
echo "Approved Gitea PR #$PR_NUMBER"
|
||||||
;;
|
;;
|
||||||
request-changes)
|
request-changes)
|
||||||
@@ -93,7 +93,7 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
|
|||||||
echo "Error: Comment required for request-changes"
|
echo "Error: Comment required for request-changes"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
tea pr reject "$PR_NUMBER" $(get_gitea_repo_args) --comment "$COMMENT"
|
tea pr reject "$PR_NUMBER" --comment "$COMMENT"
|
||||||
echo "Requested changes on Gitea PR #$PR_NUMBER"
|
echo "Requested changes on Gitea PR #$PR_NUMBER"
|
||||||
;;
|
;;
|
||||||
comment)
|
comment)
|
||||||
@@ -101,7 +101,7 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
|
|||||||
echo "Error: Comment required"
|
echo "Error: Comment required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
tea pr comment "$PR_NUMBER" "$COMMENT" $(get_gitea_repo_args)
|
tea pr comment "$PR_NUMBER" "$COMMENT"
|
||||||
echo "Added comment to Gitea PR #$PR_NUMBER"
|
echo "Added comment to Gitea PR #$PR_NUMBER"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ detect_platform
|
|||||||
if [[ "$PLATFORM" == "github" ]]; then
|
if [[ "$PLATFORM" == "github" ]]; then
|
||||||
gh pr view "$PR_NUMBER"
|
gh pr view "$PR_NUMBER"
|
||||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||||
tea pr "$PR_NUMBER" $(get_gitea_repo_args)
|
tea pr "$PR_NUMBER"
|
||||||
else
|
else
|
||||||
echo "Error: Unknown platform"
|
echo "Error: Unknown platform"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
22
packages/mosaic/src/commands/git-wrapper-redirects.spec.ts
Normal file
22
packages/mosaic/src/commands/git-wrapper-redirects.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
const packageRoot = join(import.meta.dirname, '..', '..');
|
||||||
|
const gitToolsDir = join(packageRoot, 'framework', 'tools', 'git');
|
||||||
|
|
||||||
|
function readGitTool(scriptName: string): string {
|
||||||
|
return readFileSync(join(gitToolsDir, scriptName), 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Gitea git wrapper API calls', () => {
|
||||||
|
it.each(['ci-queue-wait.sh', 'pr-ci-wait.sh'])(
|
||||||
|
'%s follows Gitea API redirects before parsing JSON',
|
||||||
|
(scriptName) => {
|
||||||
|
const script = readGitTool(scriptName);
|
||||||
|
|
||||||
|
expect(script).not.toContain('curl -fsS -H "Authorization: token');
|
||||||
|
expect(script).toContain('curl -fsSL -H "Authorization: token');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect, vi, beforeEach, afterEach, type MockInstance } from 'vitest';
|
import { describe, it, expect, vi, beforeEach, afterEach, type MockInstance } from 'vitest';
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { registerRuntimeLaunchers, type RuntimeLaunchHandler } from './launch.js';
|
import { buildPiSkillArgs, registerRuntimeLaunchers, type RuntimeLaunchHandler } from './launch.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the commander wiring between `mosaic <runtime>` / `mosaic yolo <runtime>`
|
* Tests for the commander wiring between `mosaic <runtime>` / `mosaic yolo <runtime>`
|
||||||
@@ -22,6 +22,8 @@ function buildProgram(handler: RuntimeLaunchHandler): Command {
|
|||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fakeSkills = ['--skill', '/skills/test-driven-development', '--skill', '/skills/pdf'];
|
||||||
|
|
||||||
// `process.exit` returns `never`, so vi.spyOn demands a replacement with the
|
// `process.exit` returns `never`, so vi.spyOn demands a replacement with the
|
||||||
// same signature. We throw from the mock to short-circuit into test-land.
|
// same signature. We throw from the mock to short-circuit into test-land.
|
||||||
const exitThrows = (): never => {
|
const exitThrows = (): never => {
|
||||||
@@ -63,6 +65,30 @@ describe('registerRuntimeLaunchers — non-yolo subcommands', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('buildPiSkillArgs', () => {
|
||||||
|
it('defaults to disabling Pi skill discovery to keep startup context small', () => {
|
||||||
|
expect(buildPiSkillArgs([], {}, fakeSkills)).toEqual(['--no-skills']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps explicit user skills while disabling automatic discovery', () => {
|
||||||
|
expect(buildPiSkillArgs(['--skill', '/tmp/custom'], {}, fakeSkills)).toEqual(['--no-skills']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports legacy all-skills mode without double-loading settings skills', () => {
|
||||||
|
expect(buildPiSkillArgs([], { MOSAIC_PI_SKILL_MODE: 'all' }, fakeSkills)).toEqual([
|
||||||
|
'--no-skills',
|
||||||
|
'--skill',
|
||||||
|
'/skills/test-driven-development',
|
||||||
|
'--skill',
|
||||||
|
'/skills/pdf',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports native Pi discovery when explicitly requested', () => {
|
||||||
|
expect(buildPiSkillArgs([], { MOSAIC_PI_SKILL_MODE: 'discover' }, fakeSkills)).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('registerRuntimeLaunchers — yolo <runtime>', () => {
|
describe('registerRuntimeLaunchers — yolo <runtime>', () => {
|
||||||
let mockExit: MockInstance<typeof process.exit>;
|
let mockExit: MockInstance<typeof process.exit>;
|
||||||
let mockError: MockInstance<typeof console.error>;
|
let mockError: MockInstance<typeof console.error>;
|
||||||
|
|||||||
@@ -447,6 +447,32 @@ function discoverPiSkills(): string[] {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PiSkillMode = 'none' | 'all' | 'discover';
|
||||||
|
|
||||||
|
function normalizePiSkillMode(env: NodeJS.ProcessEnv): PiSkillMode {
|
||||||
|
const value = env['MOSAIC_PI_SKILL_MODE']?.trim().toLowerCase();
|
||||||
|
if (value === 'all' || value === 'discover') return value;
|
||||||
|
return 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildPiSkillArgs(
|
||||||
|
_runtimeArgs: string[],
|
||||||
|
env: NodeJS.ProcessEnv = process.env,
|
||||||
|
discoveredSkillArgs: string[] = discoverPiSkills(),
|
||||||
|
): string[] {
|
||||||
|
const mode = normalizePiSkillMode(env);
|
||||||
|
|
||||||
|
if (mode === 'discover') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode === 'all') {
|
||||||
|
return ['--no-skills', ...discoveredSkillArgs];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['--no-skills'];
|
||||||
|
}
|
||||||
|
|
||||||
function discoverPiExtension(): string[] {
|
function discoverPiExtension(): string[] {
|
||||||
const ext = join(MOSAIC_HOME, 'runtime', 'pi', 'mosaic-extension.ts');
|
const ext = join(MOSAIC_HOME, 'runtime', 'pi', 'mosaic-extension.ts');
|
||||||
return existsSync(ext) ? ['--extension', ext] : [];
|
return existsSync(ext) ? ['--extension', ext] : [];
|
||||||
@@ -523,7 +549,7 @@ function launchRuntime(runtime: RuntimeName, args: string[], yolo: boolean): nev
|
|||||||
case 'pi': {
|
case 'pi': {
|
||||||
const prompt = buildRuntimePrompt('pi');
|
const prompt = buildRuntimePrompt('pi');
|
||||||
const cliArgs = ['--append-system-prompt', prompt];
|
const cliArgs = ['--append-system-prompt', prompt];
|
||||||
cliArgs.push(...discoverPiSkills());
|
cliArgs.push(...buildPiSkillArgs(args));
|
||||||
cliArgs.push(...discoverPiExtension());
|
cliArgs.push(...discoverPiExtension());
|
||||||
if (hasMissionNoArgs) {
|
if (hasMissionNoArgs) {
|
||||||
cliArgs.push(missionPrompt);
|
cliArgs.push(missionPrompt);
|
||||||
|
|||||||
Reference in New Issue
Block a user