# Step 1 Prompt: System Setup Source: `laravel/resources/prompts/_source/STEP-1-SYSTEM-SETUP.md` Prompt version: 76c704a4673d You are running Step 1 of the Agents HQ product-spec setup. Your job is to prepare the local filesystem, validate Paperclip/governor health, create or confirm the Paperclip company, seed policy files, and provision the Blast Radius Specialist. ## Inputs To Collect - Company name - Company prefix for `~/Agents/{company-prefix}/` - Paperclip base URL, default `http://127.0.0.1:3100` - `ADAPTER_TYPE`, default `pi_local` - Whether the user wants Laravel-backed custom connectors now Initialize these variables before doing any write: ```bash export PAPERCLIP_URL="${PAPERCLIP_URL:-http://127.0.0.1:3100}" export ADAPTER_TYPE="${ADAPTER_TYPE:-pi_local}" export COMPANY_NAME="REPLACE_WITH_COMPANY_NAME" export COMPANY_PREFIX="REPLACE_WITH_COMPANY_PREFIX" export BASE="$HOME/Agents/$COMPANY_PREFIX" ``` `COMPANY_PREFIX` must be lowercase kebab case. If the user gives a display name, derive a prefix with only `a-z`, `0-9`, and `-`, then ask for confirmation. ## Filesystem Layout Create this structure exactly: ```text ~/Agents/{company-prefix}/ artifacts/ policies/ goals/ projects/ _inbox/ agents/ reviews/ governance/ dream-cycle/ raw/ no-gos/ state/ ``` Use commands equivalent to: ```bash mkdir -p \ "$BASE/artifacts" \ "$BASE/policies" \ "$BASE/goals" \ "$BASE/projects/_inbox" \ "$BASE/agents" \ "$BASE/reviews" \ "$BASE/governance/dream-cycle/raw" \ "$BASE/governance/no-gos" \ "$BASE/state" ``` Preserve `_inbox` exactly, including the leading underscore. Seed per-bucket policy and goal files for: - `cockpit` - `wings` - `left-engine` - `right-engine` - `fuel-tank` - `fuselage` Download seeded assets from Laravel: - `http://agents.tractionstudio.ai/downloads/policies/company-policy.md` - `http://agents.tractionstudio.ai/downloads/policies/bucket-policy.md` - `http://agents.tractionstudio.ai/downloads/policies/bucket-goals.md` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius.md` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-rules.md` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-rules.json` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-overrides.md` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-overrides.json` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-task-schema.md` - `http://agents.tractionstudio.ai/downloads/policies/reviewer-policy.md` - `http://agents.tractionstudio.ai/downloads/policies/dream-cycle.md` - `http://agents.tractionstudio.ai/downloads/policies/blast-radius-specialist-agents-md.md` Use commands equivalent to: ```bash curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/company-policy.md" -o "$BASE/policies/company.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/reviewer-policy.md" -o "$BASE/policies/reviewer.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius.md" -o "$BASE/policies/blast-radius.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius-rules.md" -o "$BASE/policies/blast-radius-rules.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius-rules.json" -o "$BASE/policies/blast-radius-rules.json" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius-overrides.md" -o "$BASE/policies/blast-radius-overrides.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius-overrides.json" -o "$BASE/policies/blast-radius-overrides.json" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/blast-radius-task-schema.md" -o "$BASE/policies/blast-radius-task-schema.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/dream-cycle.md" -o "$BASE/governance/dream-cycle/policy.md" cat > "$BASE/goals/company.md" <<'EOF' # Company Goals To be synthesized from business artifacts in Step 2. EOF for bucket in cockpit wings left-engine right-engine fuel-tank fuselage; do curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/bucket-policy.md" -o "$BASE/policies/$bucket.md" curl -fsSL "http://agents.tractionstudio.ai/downloads/policies/bucket-goals.md" -o "$BASE/goals/$bucket.md" BUCKET="$bucket" COMPANY_NAME="$COMPANY_NAME" COMPANY_PREFIX="$COMPANY_PREFIX" \ perl -0pi -e 's/\{\{\s*bucket\s*\}\}/$ENV{BUCKET}/g; s/\{\{\s*company_name\s*\}\}/$ENV{COMPANY_NAME}/g; s/\{\{\s*company_prefix\s*\}\}/$ENV{COMPANY_PREFIX}/g' \ "$BASE/policies/$bucket.md" "$BASE/goals/$bucket.md" done COMPANY_NAME="$COMPANY_NAME" COMPANY_PREFIX="$COMPANY_PREFIX" \ perl -0pi -e 's/\{\{\s*company_name\s*\}\}/$ENV{COMPANY_NAME}/g; s/\{\{\s*company_prefix\s*\}\}/$ENV{COMPANY_PREFIX}/g' \ "$BASE/policies/company.md" ``` Use `perl -pi -e` or `perl -0pi -e` for replacements. Do not use `sed -i`. Write an initial state file: ```bash cat > "$BASE/state/setup.json" < "$BASE/state/blast-radius-agent-payload.json" < "$REGISTRY" tmp="$(mktemp)" jq \ --arg companyId "$PAPERCLIP_COMPANY_ID" \ --arg name "specialist-of-blast-radius" \ --arg id "$BR_AGENT_ID" \ --arg path "$BASE/agents/specialist-of-blast-radius/AGENTS.md" \ '.companyId = $companyId | .agents = (.agents // {}) | .agents[$name] = { paperclipAgentId: $id, productRole: "specialist", paperclipRole: "general", bucket: "cockpit", specialty: "blast-radius", reportsToName: "ceo", agentsMdPath: $path }' "$REGISTRY" > "$tmp" && mv "$tmp" "$REGISTRY" ``` ## Optional Laravel Link Laravel account linking is optional. Only require `AGENTS_HQ_USER_TOKEN` when the user wants setup telemetry or Laravel-backed custom connectors. If `AGENTS_HQ_USER_TOKEN` is missing and legacy `AGENTS_HQ_TOKEN` is set, treat it as a bootstrap user-token alias and emit: `AGENTS_HQ_TOKEN is deprecated for setup bootstrap; use AGENTS_HQ_USER_TOKEN.` If `AGENTS_HQ_USER_TOKEN` is set, create a setup session before mutating local state: ```bash curl -fsS -X POST "http://agents.tractionstudio.ai/api/v1/setup-sessions" \ -H "Authorization: Bearer $AGENTS_HQ_USER_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "status": "running", "current_step": "step-1", "prompt_version": "76c704a4673d", "local_root_path": "'"$BASE"'", "company_prefix": "'"$COMPANY_PREFIX"'", "paperclip_base_url": "'"$PAPERCLIP_URL"'" }' \ -o "$BASE/state/setup-session.json" SETUP_SESSION_ID="$(jq -r '.data.id // empty' "$BASE/state/setup-session.json")" ``` Save the returned setup session ID in `$BASE/state/setup-session.json`. After each blocking checkpoint, `PATCH /api/v1/setup-sessions/{id}` with `status`, `current_step`, and `last_error` when applicable. If the user wants custom connectors: 1. Confirm `AGENTS_HQ_USER_TOKEN` is set. 2. `POST http://agents.tractionstudio.ai/api/v1/companies/from-paperclip` after the Paperclip company ID exists. Include `setup_session_id` when telemetry is enabled and include `runtime_profile` fields: ```json { "paperclip_team_id": "$PAPERCLIP_COMPANY_ID", "name": "$COMPANY_NAME", "setup_session_id": "$SETUP_SESSION_ID", "runtime_profile": { "company_prefix": "$COMPANY_PREFIX", "local_root_path": "$BASE", "paperclip_base_url": "$PAPERCLIP_URL", "policy_version": "76c704a4673d", "governor_status": "$GOVERNOR_STATUS", "plugin_status": "$CONNECTORS_PLUGIN_STATUS", "setup_step": "step-1g" } } ``` 3. Save `data.company_api_key.plain_key` to the connectors plugin company config as `AGENTS_HQ_COMPANY_TOKEN` only when `data.company_api_key.generated` is `true`. If `generated` is `false`, keep the existing saved company key. Never save `AGENTS_HQ_USER_TOKEN` to the plugin. Use commands equivalent to: ```bash LINK_RESPONSE="$(mktemp)" curl -fsS -X POST "http://agents.tractionstudio.ai/api/v1/companies/from-paperclip" \ -H "Authorization: Bearer $AGENTS_HQ_USER_TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d @- \ -o "$LINK_RESPONSE" < "$BASE/state/laravel-link.json" rm -f "$LINK_RESPONSE" ``` Use the current plugin action endpoint first: ```bash curl -fsS -X POST "$PAPERCLIP_URL/api/plugins/paperclip-plugin-connectors/actions/admin.laravel.config.company.save" \ -H "Content-Type: application/json" \ -d "{\"params\":{\"companyId\":\"$PAPERCLIP_COMPANY_ID\",\"baseUrl\":\"http://agents.tractionstudio.ai\",\"apiToken\":\"$AGENTS_HQ_COMPANY_TOKEN\"}}" tmp="$(mktemp)" jq '.company_token_saved = true' "$BASE/state/laravel-link.json" > "$tmp" && mv "$tmp" "$BASE/state/laravel-link.json" ``` If the user does not want custom connectors now, skip cleanly. ## Step 1 Done Report the company prefix, Paperclip company ID, governor status, policy files written, Blast Radius Specialist ID, and whether Laravel connector linking was configured or skipped.