@osfactory/har 0.64.2 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15675 -6536
- package/dist/prompts/system-authoring.md +155 -0
- package/dist/templates/adaptation-prompt-init.md +67 -43
- package/dist/templates/adaptation-prompt-maintain.md +38 -38
- package/dist/templates/agent-skills/har-maintain.md +2 -2
- package/dist/templates/agent-skills/setup-har.md +6 -4
- package/dist/templates/cursor-rule.mdc.template +3 -3
- package/dist/templates/har-boilerplate/docker-compose.agent.yml +1 -1
- package/dist/templates/har-boilerplate/harness.env +11 -155
- package/dist/templates/har-boilerplate/stages.json +51 -2
- package/dist/templates/har-boilerplate-cli/docker-compose.agent.yml +1 -1
- package/dist/templates/har-boilerplate-cli/harness.env +12 -138
- package/dist/templates/har-boilerplate-cli/stages.json +42 -2
- package/dist/templates/har-boilerplate-ios/harness.env +10 -126
- package/dist/templates/har-boilerplate-ios/stages.json +42 -2
- package/dist/templates/migration-prompt.md +54 -0
- package/dist/templates/plugins/custom-stage-skeleton.sh +11 -20
- package/dist/templates/plugins/gitleaks/.github/workflows/gitleaks.yml +1 -1
- package/dist/templates/plugins/gitleaks/.har/stages/GITLEAKS.md +1 -1
- package/dist/templates/plugins/gitleaks/.har/stages/secrets-scan.sh +8 -23
- package/dist/templates/plugins/gitleaks/README.md +1 -1
- package/dist/templates/plugins/gitleaks/template.manifest.json +20 -5
- package/dist/templates/plugins/kerno/.github/workflows/kerno.yml +1 -1
- package/dist/templates/plugins/kerno/.har/stages/backend-validation.sh +8 -23
- package/dist/templates/plugins/kerno/README.md +1 -1
- package/dist/templates/plugins/kerno/template.manifest.json +20 -9
- package/dist/templates/plugins/local-plugin-skeleton/README.md +46 -0
- package/dist/templates/plugins/playwright/.har/stages/browser-e2e.sh +8 -23
- package/dist/templates/plugins/playwright/template.manifest.json +36 -13
- package/dist/templates/plugins/rocketsim/.har/stages/rocketsim-flows.sh +8 -23
- package/dist/templates/plugins/rocketsim/template.manifest.json +20 -8
- package/dist/templates/plugins/semgrep/.har/stages/sast.sh +10 -26
- package/dist/templates/plugins/semgrep/README.md +1 -1
- package/dist/templates/plugins/semgrep/template.manifest.json +16 -7
- package/dist/templates/plugins/trivy/.har/stages/vuln-scan.sh +8 -23
- package/dist/templates/plugins/trivy/README.md +1 -1
- package/dist/templates/plugins/trivy/template.manifest.json +20 -8
- package/dist/templates/{har-boilerplate-cli/CLAUDE.agent.md → profiles/cli/docs/claude-agent/definition-of-done.md} +0 -42
- package/dist/templates/profiles/cli/docs/claude-agent/do-not.md +6 -0
- package/dist/templates/profiles/cli/docs/claude-agent/environment.md +12 -0
- package/dist/templates/profiles/cli/docs/claude-agent/project-commands.md +10 -0
- package/dist/templates/profiles/cli/docs/claude-agent/readiness.md +6 -0
- package/dist/templates/profiles/cli/docs/readme/for-coding-agents.md +9 -0
- package/dist/templates/profiles/cli/docs/readme/intro.md +7 -0
- package/dist/templates/profiles/cli/docs/readme/port-shared-services-cli-profile.md +25 -0
- package/dist/templates/profiles/cli/docs/readme/quick-start.md +24 -0
- package/dist/templates/profiles/cli/docs/readme/verification-contract.md +22 -0
- package/dist/templates/profiles/cli/docs/readme/what-s-in-here.md +27 -0
- package/dist/templates/profiles/cli/profile.manifest.json +56 -1
- package/dist/templates/profiles/default/docs/claude-agent/definition-of-done.md +24 -0
- package/dist/templates/profiles/default/docs/claude-agent/do-not.md +10 -0
- package/dist/templates/profiles/default/docs/claude-agent/environment.md +19 -0
- package/dist/templates/profiles/default/docs/claude-agent/project-commands.md +10 -0
- package/dist/templates/profiles/default/docs/claude-agent/readiness.md +12 -0
- package/dist/templates/profiles/default/docs/readme/architecture.md +11 -0
- package/dist/templates/profiles/default/docs/readme/for-coding-agents.md +9 -0
- package/dist/templates/profiles/default/docs/readme/intro.md +7 -0
- package/dist/templates/profiles/default/docs/readme/port-shared-services.md +41 -0
- package/dist/templates/profiles/default/docs/readme/quick-start.md +24 -0
- package/dist/templates/profiles/default/docs/readme/readiness-layers.md +16 -0
- package/dist/templates/profiles/default/docs/readme/verification-contract.md +17 -0
- package/dist/templates/profiles/default/docs/readme/what-s-in-here.md +28 -0
- package/dist/templates/profiles/default/profile.manifest.json +62 -1
- package/dist/templates/profiles/ios/docs/claude-agent/definition-of-done.md +23 -0
- package/dist/templates/profiles/ios/docs/claude-agent/do-not.md +6 -0
- package/dist/templates/profiles/ios/docs/claude-agent/environment.md +14 -0
- package/dist/templates/profiles/ios/docs/claude-agent/intro.md +3 -0
- package/dist/templates/profiles/ios/docs/claude-agent/project-commands.md +21 -0
- package/dist/templates/profiles/ios/docs/claude-agent/readiness.md +6 -0
- package/dist/templates/profiles/ios/docs/claude-agent/user-flow-validation-rocketsim.md +11 -0
- package/dist/templates/profiles/ios/docs/readme/configuration.md +7 -0
- package/dist/templates/profiles/ios/docs/readme/intro.md +7 -0
- package/dist/templates/profiles/ios/docs/readme/port-shared-services-ios-profile.md +25 -0
- package/dist/templates/profiles/ios/docs/readme/quick-start.md +22 -0
- package/dist/templates/profiles/ios/docs/readme/simulators.md +45 -0
- package/dist/templates/profiles/ios/docs/readme/user-flow-validation.md +9 -0
- package/dist/templates/profiles/ios/docs/readme/verification-contract.md +13 -0
- package/dist/templates/profiles/ios/docs/readme/what-s-in-here.md +27 -0
- package/dist/templates/profiles/ios/profile.manifest.json +59 -3
- package/dist/templates/runtime-bundles/pm2-runtime/attach.sh +8 -15
- package/dist/templates/runtime-bundles/pm2-runtime/env.template +1 -1
- package/dist/templates/runtime-bundles/pm2-runtime/stages/api-health.sh +9 -0
- package/dist/templates/runtime-bundles/shared-kernel/STAGES.md +32 -18
- package/dist/templates/runtime-bundles/shared-kernel/agent-cli.sh +35 -0
- package/dist/templates/runtime-bundles/shared-kernel/launch.sh +35 -0
- package/dist/templates/runtime-bundles/shared-kernel/lib/verify-runner.mjs +129 -0
- package/dist/templates/runtime-bundles/shared-kernel/preflight.sh +35 -0
- package/dist/templates/runtime-bundles/shared-kernel/setup-infra.sh +35 -0
- package/dist/templates/runtime-bundles/shared-kernel/stages/README.sh +1 -1
- package/dist/templates/runtime-bundles/shared-kernel/stages/readiness.sh +14 -0
- package/dist/templates/runtime-bundles/shared-kernel/teardown.sh +35 -0
- package/dist/templates/runtime-bundles/shared-kernel/verify.sh +35 -0
- package/dist/templates/shared-docs/claude-agent/intro.md +3 -0
- package/dist/templates/shared-docs/readme/maintaining-this-harness.md +14 -0
- package/dist/templates/shared-docs/readme/run-history.md +5 -0
- package/dist/templates/shared-docs/readme/session-lifecycle.md +20 -0
- package/package.json +1 -1
- package/dist/templates/har-boilerplate/CLAUDE.agent.md +0 -83
- package/dist/templates/har-boilerplate/README.md +0 -199
- package/dist/templates/har-boilerplate/STAGES.md +0 -99
- package/dist/templates/har-boilerplate/agent-cli.sh +0 -225
- package/dist/templates/har-boilerplate/agent-slot.sh +0 -850
- package/dist/templates/har-boilerplate/attach.sh +0 -22
- package/dist/templates/har-boilerplate/ecosystem.agent.template.cjs +0 -52
- package/dist/templates/har-boilerplate/env.template +0 -40
- package/dist/templates/har-boilerplate/launch.sh +0 -323
- package/dist/templates/har-boilerplate/preflight.sh +0 -32
- package/dist/templates/har-boilerplate/provision-toolchain.sh +0 -766
- package/dist/templates/har-boilerplate/setup-infra.sh +0 -178
- package/dist/templates/har-boilerplate/stages/README.sh +0 -11
- package/dist/templates/har-boilerplate/teardown.sh +0 -87
- package/dist/templates/har-boilerplate/verify.sh +0 -249
- package/dist/templates/har-boilerplate-cli/README.md +0 -157
- package/dist/templates/har-boilerplate-cli/STAGES.md +0 -99
- package/dist/templates/har-boilerplate-cli/agent-cli.sh +0 -160
- package/dist/templates/har-boilerplate-cli/agent-slot.sh +0 -832
- package/dist/templates/har-boilerplate-cli/launch.sh +0 -216
- package/dist/templates/har-boilerplate-cli/preflight.sh +0 -28
- package/dist/templates/har-boilerplate-cli/provision-toolchain.sh +0 -766
- package/dist/templates/har-boilerplate-cli/setup-infra.sh +0 -178
- package/dist/templates/har-boilerplate-cli/stages/README.sh +0 -11
- package/dist/templates/har-boilerplate-cli/teardown.sh +0 -66
- package/dist/templates/har-boilerplate-cli/verify.sh +0 -210
- package/dist/templates/har-boilerplate-ios/ADAPT-PROMPT.md +0 -63
- package/dist/templates/har-boilerplate-ios/CLAUDE.agent.md +0 -90
- package/dist/templates/har-boilerplate-ios/README.md +0 -173
- package/dist/templates/har-boilerplate-ios/STAGES.md +0 -99
- package/dist/templates/har-boilerplate-ios/agent-cli.sh +0 -149
- package/dist/templates/har-boilerplate-ios/agent-slot.sh +0 -479
- package/dist/templates/har-boilerplate-ios/launch.sh +0 -206
- package/dist/templates/har-boilerplate-ios/provision-toolchain.sh +0 -766
- package/dist/templates/har-boilerplate-ios/setup-infra.sh +0 -112
- package/dist/templates/har-boilerplate-ios/simulator.sh +0 -492
- package/dist/templates/har-boilerplate-ios/stages/README.sh +0 -11
- package/dist/templates/har-boilerplate-ios/teardown.sh +0 -68
- package/dist/templates/har-boilerplate-ios/verify.sh +0 -185
- package/dist/templates/runtime-bundles/pm2-runtime/README.md +0 -4
- package/dist/templates/runtime-bundles/shared-kernel/README.md +0 -3
- package/dist/templates/runtime-bundles/shared-kernel/provision-toolchain.sh +0 -766
- package/dist/templates/runtime-bundles/xcode-sim/README.md +0 -4
- package/dist/templates/runtime-bundles/xcode-sim/simulator.sh +0 -492
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# HAR Stages — authoring guide
|
|
2
|
-
|
|
3
|
-
Stages are the harness's single vocabulary for runnable checks and lifecycle
|
|
4
|
-
actions. Everything — shipped plugins (`playwright`, `rocketsim`, `kerno`, `gitleaks`, `trivy`, `semgrep`), your
|
|
5
|
-
project's test/lint commands, bespoke validation scripts — registers in
|
|
6
|
-
`.har/stages.json` with the same schema, and agents interact with stages only
|
|
7
|
-
through that registry (CLI `har env verify`, MCP `har_run_stage` /
|
|
8
|
-
`har_run_verification`), never through stack-specific tooling.
|
|
9
|
-
|
|
10
|
-
Philosophy: *plugins install stages; agents only talk to the stage registry.*
|
|
11
|
-
|
|
12
|
-
## The registry: `.har/stages.json`
|
|
13
|
-
|
|
14
|
-
```jsonc
|
|
15
|
-
{
|
|
16
|
-
"verificationStages": ["typecheck", "unit-tests", "api-health", "browser-e2e"],
|
|
17
|
-
"stages": [
|
|
18
|
-
{
|
|
19
|
-
"id": "browser-e2e", // stable, shell-friendly slug
|
|
20
|
-
"kind": "test", // setup | launch | verify | test | inspect | reset | teardown | custom
|
|
21
|
-
"description": "Playwright E2E",
|
|
22
|
-
"script": "stages/browser-e2e.sh", // relative to .har/ — OR use "command"
|
|
23
|
-
"requiresAgentId": true, // default true for test/verify/custom kinds
|
|
24
|
-
"artifacts": [{ "path": ".har/artifacts/browser-e2e", "kind": "directory" }]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"id": "unit-tests-fast",
|
|
28
|
-
"kind": "test",
|
|
29
|
-
"command": "npm test -- --agent {agentId}" // {agentId} is substituted at run time
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Optional stage fields: `cwd` (working directory), `env` (extra env vars),
|
|
36
|
-
`group`, `acceptsArgs` (extra CLI args the stage accepts, e.g. `["--full"]`).
|
|
37
|
-
|
|
38
|
-
## Two ways to define a stage
|
|
39
|
-
|
|
40
|
-
**Command stages** — the default for simple checks (`npm test`, `swiftlint`,
|
|
41
|
-
`make check`). One JSON entry, zero files:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
har env add-stage unit-tests-fast --custom --kind test --command "npm test" --verification
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**Script stages** — for anything that needs the slot's env, ports, or
|
|
48
|
-
artifacts. Scaffold a contract-compliant skeleton:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
har env add-stage db-integrity --custom --script --description "Check DB invariants"
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
then implement the TODO block in `.har/stages/db-integrity.sh`.
|
|
55
|
-
|
|
56
|
-
## The stage script contract
|
|
57
|
-
|
|
58
|
-
Every script under `.har/stages/` must:
|
|
59
|
-
|
|
60
|
-
1. Source `harness.env` and `agent-slot.sh` from `.har/`. Before sourcing,
|
|
61
|
-
set `SCRIPT_DIR` to the `.har/` directory (not `stages/`) — `agent-slot.sh`
|
|
62
|
-
resolves the slot registry via `$SCRIPT_DIR/slots/...`.
|
|
63
|
-
2. Take the agent slot id as `$1` (validate with `validate_agent_id`); extra
|
|
64
|
-
args may follow.
|
|
65
|
-
3. Load the slot env via `resolve_agent_env_file` and run checks from the
|
|
66
|
-
agent's work dir (`resolve_agent_work_dir`).
|
|
67
|
-
4. Write artifacts (reports, screenshots, logs) under `.har/artifacts/<id>/`.
|
|
68
|
-
5. Print **only** the normalized JSON result object on stdout
|
|
69
|
-
(`status`, `stageId`, `agent_id`, `total_ms`, …); log progress to stderr.
|
|
70
|
-
6. Exit with the real status code (0 = pass).
|
|
71
|
-
|
|
72
|
-
The scaffolded skeleton implements all of this — replace its TODO block.
|
|
73
|
-
|
|
74
|
-
## Verification membership
|
|
75
|
-
|
|
76
|
-
Listing a stage id in `verificationStages` is what includes it in
|
|
77
|
-
`har env verify <id> --full`. Ids that match a registered stage run via their
|
|
78
|
-
script/command; ids without a registry entry (e.g. `typecheck`, `api-health`)
|
|
79
|
-
are inline steps owned by `.har/verify.sh`. Lifecycle kinds
|
|
80
|
-
(`setup`/`launch`/`reset`/`teardown`/`inspect`) and `verify` itself never run
|
|
81
|
-
as part of verification, even if listed.
|
|
82
|
-
|
|
83
|
-
## Commit gate
|
|
84
|
-
|
|
85
|
-
The registry also holds the optional `commitGate` config (installed via
|
|
86
|
-
`har hooks install`): `{ "commitGate": { "mode": "block" | "warn", "scope":
|
|
87
|
-
"worktrees" | "all" } }` controls whether unverified change batches may be
|
|
88
|
-
committed.
|
|
89
|
-
|
|
90
|
-
## Shipped plugins
|
|
91
|
-
|
|
92
|
-
`har env add-plugin --list` shows available plugins; `har env add-plugin
|
|
93
|
-
playwright` (web), `har env add-plugin rocketsim` (iOS), or `har env
|
|
94
|
-
add-plugin kerno` (backend), `har env add-plugin gitleaks` (secrets scanning, any
|
|
95
|
-
stack), or `har env add-plugin trivy` (dependency + IaC security scan, any stack),
|
|
96
|
-
or `har env add-plugin semgrep` (SAST, any stack)
|
|
97
|
-
installs one. A
|
|
98
|
-
plugin is just packaging: it copies files, merges `package.json` fragments,
|
|
99
|
-
and registers stages through the exact same registry as `add-stage --custom`.
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Namespaced CLI for managing a CLI/library agent slot.
|
|
3
|
-
#
|
|
4
|
-
# Usage: ./.har/agent-cli.sh <agent-id> <command> [args...]
|
|
5
|
-
set -euo pipefail
|
|
6
|
-
|
|
7
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
-
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
9
|
-
|
|
10
|
-
# shellcheck source=/dev/null
|
|
11
|
-
source "$SCRIPT_DIR/harness.env"
|
|
12
|
-
# shellcheck source=/dev/null
|
|
13
|
-
source "$SCRIPT_DIR/agent-slot.sh"
|
|
14
|
-
|
|
15
|
-
AGENT_ID="${1:?Usage: agent-cli.sh <agent-id> <command> [args...]}"
|
|
16
|
-
COMMAND="${2:?Usage: agent-cli.sh <agent-id> <command> [args...]}"
|
|
17
|
-
|
|
18
|
-
validate_agent_id "$AGENT_ID"
|
|
19
|
-
|
|
20
|
-
WORKTREE_DIR="$(existing_slot_worktree "$AGENT_ID")"
|
|
21
|
-
DB_PORT="${AGENT_DB_PORT:-15432}"
|
|
22
|
-
export PGPASSWORD="password"
|
|
23
|
-
|
|
24
|
-
resolve_work_dir() {
|
|
25
|
-
local env_file
|
|
26
|
-
env_file="$(resolve_agent_env_file "$AGENT_ID" "$REPO_ROOT")" || {
|
|
27
|
-
echo "No active environment for agent ${AGENT_ID}" >&2
|
|
28
|
-
har_suggest_launch "$AGENT_ID"
|
|
29
|
-
exit 1
|
|
30
|
-
}
|
|
31
|
-
# shellcheck source=/dev/null
|
|
32
|
-
source "$env_file"
|
|
33
|
-
resolve_agent_work_dir "$env_file" "$AGENT_ID"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
case "$COMMAND" in
|
|
37
|
-
status)
|
|
38
|
-
ENV_FILE="$(resolve_agent_env_file "$AGENT_ID" "$REPO_ROOT" || true)"
|
|
39
|
-
REGISTRY_FILE="$(slot_registry_file "$AGENT_ID")"
|
|
40
|
-
|
|
41
|
-
if [ -n "$ENV_FILE" ]; then
|
|
42
|
-
# shellcheck source=/dev/null
|
|
43
|
-
source "$ENV_FILE"
|
|
44
|
-
WT="$(existing_slot_worktree "$AGENT_ID")"
|
|
45
|
-
echo "Agent ${AGENT_ID}: active"
|
|
46
|
-
echo " Work dir: $(resolve_agent_work_dir "$ENV_FILE" "$AGENT_ID")"
|
|
47
|
-
[ -n "$WT" ] && [ -d "$WT" ] && echo " Worktree: $WT"
|
|
48
|
-
BRANCH="$(read_slot_field "$REGISTRY_FILE" branch || true)"
|
|
49
|
-
CREATED="$(read_slot_field "$REGISTRY_FILE" createdAt || true)"
|
|
50
|
-
[ -n "$BRANCH" ] && echo " Branch: $BRANCH"
|
|
51
|
-
[ -n "$CREATED" ] && echo " Since: $CREATED"
|
|
52
|
-
[ -n "$WT" ] && echo " Git: $(slot_dirty_summary "$WT")"
|
|
53
|
-
else
|
|
54
|
-
echo "No active environment for agent ${AGENT_ID}"
|
|
55
|
-
har_suggest_launch "$AGENT_ID"
|
|
56
|
-
fi
|
|
57
|
-
;;
|
|
58
|
-
|
|
59
|
-
logs)
|
|
60
|
-
echo "CLI profile has no managed processes (no PM2)." >&2
|
|
61
|
-
echo "Run project commands in the work dir, e.g.:" >&2
|
|
62
|
-
echo " ./.har/agent-cli.sh ${AGENT_ID} exec make test" >&2
|
|
63
|
-
exit 1
|
|
64
|
-
;;
|
|
65
|
-
|
|
66
|
-
restart)
|
|
67
|
-
echo "CLI profile has no managed processes to restart." >&2
|
|
68
|
-
echo "Re-run launch or use exec for project-specific commands." >&2
|
|
69
|
-
exit 1
|
|
70
|
-
;;
|
|
71
|
-
|
|
72
|
-
psql)
|
|
73
|
-
QUERY="${3:-}"
|
|
74
|
-
if ! har_infra_enabled db; then
|
|
75
|
-
echo "PostgreSQL infra is disabled in harness.env" >&2
|
|
76
|
-
exit 1
|
|
77
|
-
fi
|
|
78
|
-
if [ -n "$QUERY" ]; then
|
|
79
|
-
har_pg psql -d "agent_${AGENT_ID}" -c "$QUERY"
|
|
80
|
-
else
|
|
81
|
-
har_pg psql -d "agent_${AGENT_ID}"
|
|
82
|
-
fi
|
|
83
|
-
;;
|
|
84
|
-
|
|
85
|
-
health)
|
|
86
|
-
API_PORT=$(( HARNESS_API_BASE_PORT + AGENT_ID * 10 ))
|
|
87
|
-
if [ -n "${HARNESS_HEALTH_CHECK_PATH:-}" ]; then
|
|
88
|
-
curl -sf "http://localhost:${API_PORT}${HARNESS_HEALTH_CHECK_PATH}" | node -e "
|
|
89
|
-
const d = require('fs').readFileSync('/dev/stdin','utf8');
|
|
90
|
-
try { console.log(JSON.stringify(JSON.parse(d), null, 2)); } catch { console.log(d); }
|
|
91
|
-
" || curl -v "http://localhost:${API_PORT}${HARNESS_HEALTH_CHECK_PATH}"
|
|
92
|
-
else
|
|
93
|
-
echo "No health check path configured in harness.env"
|
|
94
|
-
fi
|
|
95
|
-
;;
|
|
96
|
-
|
|
97
|
-
url)
|
|
98
|
-
FE_PORT=$(( HARNESS_FE_BASE_PORT + AGENT_ID * 10 ))
|
|
99
|
-
API_PORT=$(( HARNESS_API_BASE_PORT + AGENT_ID * 10 ))
|
|
100
|
-
WORK_DIR="$(resolve_work_dir 2>/dev/null || echo "$REPO_ROOT")"
|
|
101
|
-
echo "Work dir: $WORK_DIR"
|
|
102
|
-
[ -d "$WORKTREE_DIR" ] && echo "Worktree: $WORKTREE_DIR"
|
|
103
|
-
[ -n "${HARNESS_HEALTH_CHECK_PATH:-}" ] && echo "API: http://localhost:${API_PORT}${HARNESS_HEALTH_CHECK_PATH}"
|
|
104
|
-
har_infra_enabled db && echo "Database: agent_${AGENT_ID} @ localhost:${DB_PORT}"
|
|
105
|
-
har_infra_enabled minio && echo "MinIO: http://localhost:19001"
|
|
106
|
-
har_infra_enabled headless-browser && echo "Browser: http://localhost:13001"
|
|
107
|
-
har_infra_enabled mailpit && echo "Mailpit: http://localhost:18025"
|
|
108
|
-
;;
|
|
109
|
-
|
|
110
|
-
reset-db)
|
|
111
|
-
if ! har_infra_enabled db; then
|
|
112
|
-
echo "PostgreSQL infra is disabled in harness.env" >&2
|
|
113
|
-
exit 1
|
|
114
|
-
fi
|
|
115
|
-
echo "==> Resetting database for agent ${AGENT_ID}..."
|
|
116
|
-
har_pg psql -d postgres -c \
|
|
117
|
-
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='agent_${AGENT_ID}';" \
|
|
118
|
-
>/dev/null
|
|
119
|
-
har_pg dropdb --if-exists "agent_${AGENT_ID}"
|
|
120
|
-
har_pg createdb -T "$HARNESS_TEMPLATE_DB" "agent_${AGENT_ID}"
|
|
121
|
-
echo "✓ Database reset to clean state"
|
|
122
|
-
;;
|
|
123
|
-
|
|
124
|
-
slow-queries)
|
|
125
|
-
if ! har_infra_enabled db; then
|
|
126
|
-
echo "PostgreSQL infra is disabled in harness.env" >&2
|
|
127
|
-
exit 1
|
|
128
|
-
fi
|
|
129
|
-
har_pg psql -d "agent_${AGENT_ID}" -c "
|
|
130
|
-
SELECT round(mean_exec_time::numeric, 2) AS mean_ms,
|
|
131
|
-
calls,
|
|
132
|
-
left(query, 120) AS query
|
|
133
|
-
FROM pg_stat_statements
|
|
134
|
-
ORDER BY mean_exec_time DESC
|
|
135
|
-
LIMIT 20;" 2>/dev/null || echo "pg_stat_statements extension not available"
|
|
136
|
-
;;
|
|
137
|
-
|
|
138
|
-
exec)
|
|
139
|
-
shift 2
|
|
140
|
-
if [ $# -eq 0 ]; then
|
|
141
|
-
echo "Usage: agent-cli.sh ${AGENT_ID} exec <command>" >&2
|
|
142
|
-
exit 1
|
|
143
|
-
fi
|
|
144
|
-
WORK_DIR="$(resolve_work_dir)"
|
|
145
|
-
if har_infra_enabled db; then
|
|
146
|
-
PGHOST=localhost PGPORT="$DB_PORT" PGUSER=postgres PGDATABASE="agent_${AGENT_ID}" \
|
|
147
|
-
bash -c "cd '$WORK_DIR' && $*"
|
|
148
|
-
else
|
|
149
|
-
bash -c "cd '$WORK_DIR' && $*"
|
|
150
|
-
fi
|
|
151
|
-
;;
|
|
152
|
-
|
|
153
|
-
*)
|
|
154
|
-
echo "Unknown command: $COMMAND" >&2
|
|
155
|
-
echo ""
|
|
156
|
-
echo "Commands: status, url, exec <cmd>"
|
|
157
|
-
har_infra_enabled db && echo " psql [query], reset-db, slow-queries"
|
|
158
|
-
exit 1
|
|
159
|
-
;;
|
|
160
|
-
esac
|