mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-12-01 17:33:04 -05:00
* docs(skill): publish the floci agent skill for the CLI and the four emulators skills/floci/ teaches an AI agent to run, wire up and troubleshoot the AWS, GCP, Azure and OCI emulators through floci-cli, docker run or Docker Compose. - SKILL.md with the lifecycle, the hard rules (fake credentials only, verify the endpoint, name the tree, parse -o json) and one reference per cloud. - references/docs.md sends the agent to the published documentation of each emulator instead of copying coverage lists that go stale. - references/docker.md and assets/compose/ give docker run equivalents of 'floci <tree> start' and a ready Compose template per cloud, plus one with all four on a network. - scripts/install-floci.sh and scripts/ensure-running.sh. - .claude-plugin/marketplace.json publishes it as a Claude Code plugin and the root plugin.json as a Kiro power (Agent Plugins format). - SkillDocsTest checks every floci command and flag the skill quotes against the real command tree, its links, its frontmatter and both manifests. - README: an "AI agents" section with the install commands, a Privacy section on what the CLI and the skill send over the network, and support links. - AGENTS.md: a command, flag, env output or exit code change updates the skill in the same change. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * docs(skill): bind published ports to loopback and make the helper fail safely Addresses the review of #69. - The Compose templates and the docker run examples publish the emulator on 127.0.0.1. The emulators accept fake credentials, so a plain 4566:4566 exposed local resources to the network. docker.md says when to drop it and that 'floci <tree> start' still publishes on every interface. - ensure-running.sh no longer replaces a stopped container: it exits 3 and leaves it alone unless FLOCI_REPLACE_STOPPED=1, because start removes the container and, without a profile, its settings. - The documented call is now 'exports="$(...)" && eval "$exports"'. The one-step eval succeeded when the helper failed, so later commands ran with missing or stale wiring. - The templates say that container name, namespace and network name are per project and change together. - docker.md lists the network settings to copy into the multi-cloud file when an app reaches child containers by name. - ci.md installs into a user-writable directory instead of assuming /usr/local/bin or sudo. - SkillDocsTest now reads commands inside assignments and across continued lines, with a test that a wrong flag is found in each form. The helper's own status and env calls were not being checked. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com>
88 lines
3.1 KiB
Bash
Executable File
88 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ensure a Floci emulator is running and print its environment for eval.
|
|
#
|
|
# Usage:
|
|
# exports="$(<skill dir>/scripts/ensure-running.sh <aws|gcp|az|oci> [profile])" && eval "$exports"
|
|
#
|
|
# Not eval "$(...)" in one step: that succeeds even when this script fails.
|
|
#
|
|
# Starts the emulator only if no container exists, waits for readiness, then prints
|
|
# the `floci <tree> env` exports on stdout. Progress goes to stderr.
|
|
# Exit 3: the container exists but is not running. `floci <tree> start` would remove it and
|
|
# create a new one, so this script leaves it alone unless FLOCI_REPLACE_STOPPED=1.
|
|
# Env: FLOCI_WAIT_TIMEOUT (default 120s), FLOCI_REPLACE_STOPPED.
|
|
set -euo pipefail
|
|
|
|
tree="${1:-}"
|
|
profile="${2:-}"
|
|
|
|
case "$tree" in
|
|
aws|gcp|az|oci) ;;
|
|
*) echo "usage: $0 <aws|gcp|az|oci> [profile]" >&2; exit 64 ;;
|
|
esac
|
|
|
|
if ! command -v floci >/dev/null 2>&1; then
|
|
echo "floci CLI not found. Ask the user, then run: $(dirname "$0")/install-floci.sh" >&2
|
|
exit 127
|
|
fi
|
|
|
|
args=()
|
|
if [[ -n "$profile" ]]; then
|
|
args=(--profile "$profile")
|
|
fi
|
|
|
|
status_json="$(floci "$tree" status -o json ${args[@]+"${args[@]}"} 2>/dev/null || true)"
|
|
|
|
state="$(sed -nE 's/.*"state"[[:space:]]*:[[:space:]]*"([^"]*)".*/\1/p' <<<"$status_json" | head -n 1)"
|
|
|
|
start() {
|
|
echo "starting floci $tree${profile:+ ($profile)}..." >&2
|
|
floci "$tree" start --detach -q ${args[@]+"${args[@]}"} >&2
|
|
}
|
|
|
|
case "$state" in
|
|
running)
|
|
echo "floci $tree${profile:+ ($profile)} container already running" >&2
|
|
;;
|
|
"not found")
|
|
start
|
|
;;
|
|
"")
|
|
echo "could not read the state of floci $tree${profile:+ ($profile)}; run 'floci $tree doctor'" >&2
|
|
exit 1
|
|
;;
|
|
*)
|
|
# start removes a container of the same name before creating a new one. Without a profile
|
|
# the new one gets default settings, so a custom port, image or persist mount is lost.
|
|
if [[ "${FLOCI_REPLACE_STOPPED:-}" != "1" ]]; then
|
|
echo "floci $tree${profile:+ ($profile)} container exists but is not running (state: $state)." >&2
|
|
echo "Starting it removes that container and creates a new one. Ask the user, then re-run with FLOCI_REPLACE_STOPPED=1." >&2
|
|
exit 3
|
|
fi
|
|
start
|
|
;;
|
|
esac
|
|
|
|
if ! floci "$tree" wait --timeout "${FLOCI_WAIT_TIMEOUT:-120s}" -q ${args[@]+"${args[@]}"} >&2; then
|
|
echo "floci $tree did not become ready; recent logs:" >&2
|
|
floci "$tree" logs --tail 50 ${args[@]+"${args[@]}"} >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
# -o text: a profile may set 'output: json', which eval cannot use.
|
|
env_out="$(floci "$tree" env -o text ${args[@]+"${args[@]}"})"
|
|
|
|
# Safety net: warn loudly if the endpoint is not local.
|
|
if ! grep -Eq '(localhost|127\.0\.0\.1|localhost\.floci\.io)' <<<"$env_out"; then
|
|
echo "WARNING: floci $tree env does not point at localhost. Verify the endpoint before running mutating commands." >&2
|
|
fi
|
|
|
|
if [[ "$tree" == "az" ]] && ! grep -Eq 'AZURE_CONFIG_DIR|REQUESTS_CA_BUNDLE' <<<"$env_out"; then
|
|
echo "note: run 'floci az setup${profile:+ --profile $profile}' before az control-plane commands" >&2
|
|
fi
|
|
if [[ "$tree" == "oci" ]] && ! grep -q 'OCI_CLI_PROFILE' <<<"$env_out"; then
|
|
echo "note: run 'floci oci setup' before using the oci CLI" >&2
|
|
fi
|
|
|
|
printf '%s\n' "$env_out"
|