refactor(monorepo): extract inbox and orch runtimes
This commit is contained in:
@@ -3,70 +3,5 @@
|
||||
set -euo pipefail
|
||||
|
||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
readonly BUILD_DIR="$(mktemp -d "${TMPDIR:-/tmp}/skill-clis.XXXXXX")"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "${BUILD_DIR}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
require_command() {
|
||||
local cmd="$1"
|
||||
if ! command -v "${cmd}" >/dev/null 2>&1; then
|
||||
printf 'missing required command: %s\n' "${cmd}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
build_binary() {
|
||||
local name="$1"
|
||||
local package_path="$2"
|
||||
local output_path="${BUILD_DIR}/${name}"
|
||||
|
||||
printf 'building %s from %s\n' "${name}" "${package_path}" >&2
|
||||
(
|
||||
cd "${REPO_ROOT}"
|
||||
go build -trimpath -o "${output_path}" "${package_path}"
|
||||
)
|
||||
|
||||
printf '%s\n' "${output_path}"
|
||||
}
|
||||
|
||||
install_binary() {
|
||||
local source_path="$1"
|
||||
shift
|
||||
|
||||
local destination_path
|
||||
for destination_path in "$@"; do
|
||||
mkdir -p "$(dirname "${destination_path}")"
|
||||
install -m 0755 "${source_path}" "${destination_path}"
|
||||
printf 'installed %s\n' "${destination_path}"
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
require_command go
|
||||
require_command install
|
||||
require_command mktemp
|
||||
|
||||
local inbox_binary
|
||||
local orch_binary
|
||||
|
||||
inbox_binary="$(build_binary inbox ./cmd/inbox)"
|
||||
orch_binary="$(build_binary orch ./cmd/orch)"
|
||||
|
||||
install_binary \
|
||||
"${inbox_binary}" \
|
||||
"${REPO_ROOT}/skills/inbox/assets/inbox"
|
||||
|
||||
install_binary \
|
||||
"${orch_binary}" \
|
||||
"${REPO_ROOT}/skills/orch/assets/orch" \
|
||||
"${REPO_ROOT}/skills/council-review/assets/orch"
|
||||
|
||||
printf 'skill CLI packaging complete\n'
|
||||
}
|
||||
|
||||
main "$@"
|
||||
exec bash "${SCRIPT_DIR}/package_skill_runtimes.sh" package "$@"
|
||||
|
||||
@@ -5,15 +5,17 @@ set -euo pipefail
|
||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
readonly MANIFEST_PATH="${REPO_ROOT}/scripts/skill-bundles.json"
|
||||
BUILD_DIR=""
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
package_skill_runtimes.sh plan
|
||||
package_skill_runtimes.sh validate
|
||||
package_skill_runtimes.sh package
|
||||
|
||||
Phase 1 only bootstraps declarative bundle metadata.
|
||||
Actual runtime packaging will be added once package-owned entrypoints exist.
|
||||
The bundle manifest is package-oriented. Bundles in state=planned are skipped by
|
||||
the package command until their package-owned entrypoints exist.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -44,6 +46,12 @@ emit_bundles() {
|
||||
' "${MANIFEST_PATH}"
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${BUILD_DIR}" && -d "${BUILD_DIR}" ]]; then
|
||||
rm -rf "${BUILD_DIR}"
|
||||
fi
|
||||
}
|
||||
|
||||
plan() {
|
||||
printf 'skill bundle plan from %s\n' "${MANIFEST_PATH}"
|
||||
while IFS=$'\t' read -r skill type runtime_package entrypoint output build_state; do
|
||||
@@ -98,6 +106,37 @@ validate() {
|
||||
printf 'skill bundle manifest validated\n'
|
||||
}
|
||||
|
||||
package_bundles() {
|
||||
validate
|
||||
|
||||
require_command go
|
||||
require_command install
|
||||
require_command mktemp
|
||||
|
||||
BUILD_DIR="$(mktemp -d "${TMPDIR:-/tmp}/skill-runtimes.XXXXXX")"
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
while IFS=$'\t' read -r skill type runtime_package entrypoint output build_state; do
|
||||
if [[ "${build_state}" != "ready" ]]; then
|
||||
printf 'skipping %s (%s)\n' "${skill}" "${build_state}"
|
||||
continue
|
||||
fi
|
||||
|
||||
local output_path="${REPO_ROOT}/${output}"
|
||||
local artifact_path="${BUILD_DIR}/${skill}"
|
||||
|
||||
printf 'building %s from %s\n' "${skill}" "${entrypoint}"
|
||||
(
|
||||
cd "${REPO_ROOT}"
|
||||
go build -trimpath -o "${artifact_path}" "${entrypoint}"
|
||||
)
|
||||
|
||||
mkdir -p "$(dirname "${output_path}")"
|
||||
install -m 0755 "${artifact_path}" "${output_path}"
|
||||
printf 'installed %s\n' "${output}"
|
||||
done < <(emit_bundles)
|
||||
}
|
||||
|
||||
main() {
|
||||
require_command node
|
||||
|
||||
@@ -109,6 +148,9 @@ main() {
|
||||
validate)
|
||||
validate
|
||||
;;
|
||||
package)
|
||||
package_bundles
|
||||
;;
|
||||
""|-h|--help|help)
|
||||
usage
|
||||
;;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"runtimePackage": "./packages/inbox-runtime",
|
||||
"entrypoint": "./packages/inbox-runtime/cmd/inbox",
|
||||
"output": "skills/inbox/assets/inbox",
|
||||
"buildState": "planned"
|
||||
"buildState": "ready"
|
||||
},
|
||||
{
|
||||
"skill": "orch",
|
||||
@@ -15,7 +15,7 @@
|
||||
"runtimePackage": "./packages/orch-runtime",
|
||||
"entrypoint": "./packages/orch-runtime/cmd/orch",
|
||||
"output": "skills/orch/assets/orch",
|
||||
"buildState": "planned"
|
||||
"buildState": "ready"
|
||||
},
|
||||
{
|
||||
"skill": "council-review",
|
||||
@@ -23,7 +23,7 @@
|
||||
"runtimePackage": "./packages/orch-runtime",
|
||||
"entrypoint": "./packages/orch-runtime/cmd/orch",
|
||||
"output": "skills/council-review/assets/orch",
|
||||
"buildState": "planned"
|
||||
"buildState": "ready"
|
||||
},
|
||||
{
|
||||
"skill": "repo-memory",
|
||||
|
||||
Reference in New Issue
Block a user