feat: integrate framework files into monorepo under packages/mosaic/framework/
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

Moves all Mosaic framework runtime files from the separate bootstrap repo
into the monorepo as canonical source. The @mosaic/mosaic npm package now
ships the complete framework — bin scripts, runtime configs, tools, and
templates — enabling standalone installation via npm install.

Structure:
  packages/mosaic/framework/
  ├── bin/          28 CLI scripts (mosaic, mosaic-doctor, mosaic-sync-skills, etc.)
  ├── runtime/      Runtime adapters (claude, codex, opencode, pi, mcp)
  ├── tools/        Shell tooling (git, prdy, orchestrator, quality, etc.)
  ├── templates/    Agent and repo templates
  ├── defaults/     Default identity files (AGENTS.md, STANDARDS.md, SOUL.md, etc.)
  ├── install.sh    Legacy bash installer
  └── remote-install.sh  One-liner remote installer

Key files with Pi support and recent fixes:
- bin/mosaic: launch_pi() with skills-local loop
- bin/mosaic-doctor: --fix auto-wiring for all 4 harnesses
- bin/mosaic-sync-skills: Pi as 4th link target, symlink-aware find
- bin/mosaic-link-runtime-assets: Pi settings.json patching
- bin/mosaic-migrate-local-skills: Pi skill roots, symlink find
- runtime/pi/RUNTIME.md + mosaic-extension.ts

Package ships 251 framework files in the npm tarball (278KB compressed).
This commit is contained in:
Jason Woltje
2026-04-01 21:19:21 -05:00
parent f3cb3e6852
commit b38cfac760
252 changed files with 31477 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
# Woodpecker CI Tool Suite
Interact with Woodpecker CI pipelines (list builds, check status, trigger builds).
## Prerequisites
- `jq` and `curl` installed
- Woodpecker credentials in `~/src/jarvis-brain/credentials.json`
## Setup
A Woodpecker API token is required. To configure:
1. Go to Woodpecker CI → User Settings → API
2. Generate a personal token
3. Add to `credentials.json`:
```json
{
"woodpecker": {
"url": "https://ci.mosaicstack.dev",
"token": "YOUR_TOKEN_HERE"
}
}
```
## Scripts
| Script | Purpose |
| --------------------- | ------------------------------------------- |
| `pipeline-list.sh` | List recent pipelines for a repo |
| `pipeline-status.sh` | Get status of a specific or latest pipeline |
| `pipeline-trigger.sh` | Trigger a new pipeline build |
## Common Options
- `-r owner/repo` — Repository (auto-detected from git remote if omitted)
- `-f json` — JSON output (default: table)
- `-h` — Show help
## API Reference
- Base URL: `https://ci.mosaicstack.dev`
- API prefix: `/api/`
- Auth: Bearer token in `Authorization` header
## Examples
```bash
# List recent builds
~/.config/mosaic/tools/woodpecker/pipeline-list.sh
# Check latest build status
~/.config/mosaic/tools/woodpecker/pipeline-status.sh
# Trigger a build on a specific branch
~/.config/mosaic/tools/woodpecker/pipeline-trigger.sh -b feature/my-branch
```

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
#
# _lib.sh — Shared helpers for Woodpecker CI tool scripts
#
# Usage: source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
#
# Requires: WOODPECKER_URL and WOODPECKER_TOKEN to be set (via load_credentials)
# Resolve owner/repo name to numeric repo ID (required by Woodpecker v3 API)
# Usage: REPO_ID=$(wp_resolve_repo_id "owner/repo")
wp_resolve_repo_id() {
local full_name="$1"
local response http_code body repo_id
response=$(curl -sk -w "\n%{http_code}" \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
"${WOODPECKER_URL}/api/repos/lookup/${full_name}")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [[ "$http_code" != "200" ]]; then
echo "Error: Failed to look up repo '${full_name}' (HTTP $http_code)" >&2
if echo "$body" | jq -e '.message' &>/dev/null; then
echo " $(echo "$body" | jq -r '.message')" >&2
fi
return 1
fi
repo_id=$(echo "$body" | jq -r '.id // empty')
if [[ -z "$repo_id" ]]; then
echo "Error: Repo lookup returned no ID for '${full_name}'" >&2
return 1
fi
echo "$repo_id"
}
# Auto-detect repo name from git remote origin
# Usage: REPO=$(wp_detect_repo)
wp_detect_repo() {
local remote_url
remote_url=$(git remote get-url origin 2>/dev/null || true)
if [[ -n "$remote_url" ]]; then
echo "$remote_url" | sed -E 's|\.git$||' | sed -E 's|.*[:/]([^/]+/[^/]+)$|\1|'
else
echo "Error: -r owner/repo required (not in a git repository)" >&2
return 1
fi
}

View File

@@ -0,0 +1,79 @@
#!/usr/bin/env bash
#
# pipeline-list.sh — List Woodpecker CI pipelines
#
# Usage: pipeline-list.sh [-r owner/repo] [-l limit] [-f format] [-a instance]
#
# Options:
# -r repo Repository in owner/repo format (default: current repo)
# -l limit Number of pipelines to show (default: 20)
# -f format Output format: table (default), json
# -a instance Woodpecker instance name (e.g. usc, mosaic)
# -h Show this help
#
# Requires: woodpecker credentials in credentials.json
set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
source "$MOSAIC_HOME/tools/_lib/credentials.sh"
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
REPO=""
LIMIT=20
FORMAT="table"
WP_INSTANCE=""
while getopts "r:l:f:a:h" opt; do
case $opt in
r) REPO="$OPTARG" ;;
l) LIMIT="$OPTARG" ;;
f) FORMAT="$OPTARG" ;;
a) WP_INSTANCE="$OPTARG" ;;
h) head -14 "$0" | grep "^#" | sed 's/^# \?//'; exit 0 ;;
*) echo "Usage: $0 [-r owner/repo] [-l limit] [-f format] [-a instance]" >&2; exit 1 ;;
esac
done
if [[ -n "$WP_INSTANCE" ]]; then
load_credentials "woodpecker-${WP_INSTANCE}"
else
load_credentials woodpecker
fi
# Auto-detect repo from git remote if not specified
if [[ -z "$REPO" ]]; then
REPO=$(wp_detect_repo) || exit 1
fi
# Resolve owner/repo to numeric ID (Woodpecker v3 API)
REPO_ID=$(wp_resolve_repo_id "$REPO") || exit 1
response=$(curl -sk -w "\n%{http_code}" \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
"${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines?per_page=${LIMIT}")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [[ "$http_code" != "200" ]]; then
echo "Error: Failed to list pipelines (HTTP $http_code)" >&2
exit 1
fi
if [[ "$FORMAT" == "json" ]]; then
echo "$body" | jq '.'
exit 0
fi
echo "NUMBER STATUS BRANCH EVENT MESSAGE"
echo "------ -------- -------------------- -------- ----------------------------------------"
echo "$body" | jq -r '.[] | [
(.number | tostring),
.status,
.branch,
.event,
(.message | split("\n")[0])
] | @tsv' | while IFS=$'\t' read -r number status branch event message; do
printf "%-6s %-8s %-20s %-8s %s\n" \
"$number" "$status" "${branch:0:20}" "$event" "${message:0:40}"
done

View File

@@ -0,0 +1,118 @@
#!/usr/bin/env bash
#
# pipeline-status.sh — Check Woodpecker CI pipeline status
#
# Usage: pipeline-status.sh [-r owner/repo] [-n number] [-f format] [-a instance]
#
# Options:
# -r repo Repository in owner/repo format (default: current repo)
# -n number Pipeline number (default: latest)
# -f format Output format: table (default), json
# -a instance Woodpecker instance name (e.g. usc, mosaic)
# -h Show this help
#
# Requires: woodpecker credentials in credentials.json
set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
source "$MOSAIC_HOME/tools/_lib/credentials.sh"
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
REPO=""
NUMBER=""
FORMAT="table"
WP_INSTANCE=""
while getopts "r:n:f:a:h" opt; do
case $opt in
r) REPO="$OPTARG" ;;
n) NUMBER="$OPTARG" ;;
f) FORMAT="$OPTARG" ;;
a) WP_INSTANCE="$OPTARG" ;;
h) head -14 "$0" | grep "^#" | sed 's/^# \?//'; exit 0 ;;
*) echo "Usage: $0 [-r owner/repo] [-n number] [-f format] [-a instance]" >&2; exit 1 ;;
esac
done
if [[ -n "$WP_INSTANCE" ]]; then
load_credentials "woodpecker-${WP_INSTANCE}"
else
load_credentials woodpecker
fi
if [[ -z "$REPO" ]]; then
REPO=$(wp_detect_repo) || exit 1
fi
# Resolve owner/repo to numeric ID (Woodpecker v3 API)
REPO_ID=$(wp_resolve_repo_id "$REPO") || exit 1
_wp_fetch() {
local ep="$1"
local resp http_code body
resp=$(curl -sk -w "\n%{http_code}" \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
"$ep")
http_code=$(echo "$resp" | tail -n1)
body=$(echo "$resp" | sed '$d')
if [[ "$http_code" != "200" ]]; then
echo "Error: HTTP $http_code from $ep" >&2
return 1
fi
echo "$body"
}
if [[ -z "$NUMBER" ]]; then
# Get latest pipeline number from list, then fetch full detail
list_body=$(_wp_fetch "${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines?per_page=1") || exit 1
NUMBER=$(echo "$list_body" | jq -r '.[0].number // empty')
if [[ -z "$NUMBER" ]]; then
echo "Error: No pipelines found" >&2
exit 1
fi
fi
# Always fetch the single-pipeline endpoint (includes workflows/steps)
body=$(_wp_fetch "${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines/${NUMBER}") || exit 1
if [[ "$FORMAT" == "json" ]]; then
echo "$body" | jq '.'
exit 0
fi
echo "Pipeline Status"
echo "==============="
echo "$body" | jq -r '
def ts: if . and . > 0 then todate else "—" end;
" Number: \(.number)\n" +
" Status: \(.status)\n" +
" Branch: \(.branch)\n" +
" Event: \(.event)\n" +
" Commit: \(.commit[:12])\n" +
" Message: \(.message | split("\n")[0])\n" +
" Author: \(.author)\n" +
" Started: \(.started | ts)\n" +
" Finished: \(.finished | ts)"
'
# Show step-level details if workflows exist
has_workflows=$(echo "$body" | jq 'has("workflows") and (.workflows | length > 0)')
if [[ "$has_workflows" == "true" ]]; then
echo ""
echo "Steps"
echo "-----"
echo "$body" | jq -r '
.workflows[] | .children[]? |
select(.type != "clone") |
" " +
(if .state == "success" then "OK"
elif .state == "failure" then "FAIL"
elif .state == "running" then "RUN"
elif .state == "skipped" then "SKIP"
elif .state == "pending" then "WAIT"
else .state end) +
" " + .name +
(if .error and .error != "" then " (" + .error + ")" else "" end) +
(if .exit_code and .exit_code != 0 then " [exit " + (.exit_code | tostring) + "]" else "" end)
'
fi

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
#
# pipeline-trigger.sh — Trigger a Woodpecker CI pipeline
#
# Usage: pipeline-trigger.sh [-r owner/repo] [-b branch] [-a instance]
#
# Options:
# -r repo Repository in owner/repo format (default: current repo)
# -b branch Branch to build (default: main)
# -a instance Woodpecker instance name (e.g. usc, mosaic)
# -h Show this help
#
# Requires: woodpecker credentials in credentials.json
set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
source "$MOSAIC_HOME/tools/_lib/credentials.sh"
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
REPO=""
BRANCH="main"
WP_INSTANCE=""
while getopts "r:b:a:h" opt; do
case $opt in
r) REPO="$OPTARG" ;;
b) BRANCH="$OPTARG" ;;
a) WP_INSTANCE="$OPTARG" ;;
h) head -14 "$0" | grep "^#" | sed 's/^# \?//'; exit 0 ;;
*) echo "Usage: $0 [-r owner/repo] [-b branch] [-a instance]" >&2; exit 1 ;;
esac
done
if [[ -n "$WP_INSTANCE" ]]; then
load_credentials "woodpecker-${WP_INSTANCE}"
else
load_credentials woodpecker
fi
if [[ -z "$REPO" ]]; then
REPO=$(wp_detect_repo) || exit 1
fi
# Resolve owner/repo to numeric ID (Woodpecker v3 API)
REPO_ID=$(wp_resolve_repo_id "$REPO") || exit 1
echo "Triggering pipeline for $REPO on branch $BRANCH..."
response=$(curl -sk -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg b "$BRANCH" '{branch: $b}')" \
"${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [[ "$http_code" != "200" && "$http_code" != "201" ]]; then
echo "Error: Failed to trigger pipeline (HTTP $http_code)" >&2
echo "$body" | jq -r '.' 2>/dev/null >&2 || echo "$body" >&2
exit 1
fi
number=$(echo "$body" | jq -r '.number')
echo "Pipeline #$number triggered successfully"