-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
126 lines (104 loc) · 4.28 KB
/
Copy pathJustfile
File metadata and controls
126 lines (104 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
set shell := ["bash", "-cu"]
binary := "tldw"
justfile_dir := justfile_directory()
tunnel_client := env_var_or_default("TLDW_TUNNEL_CLIENT", "./bin/tunnel-client")
tunnel_profile := env_var_or_default("TLDW_TUNNEL_PROFILE", "tldw")
tunnel_id := env_var_or_default("TLDW_TUNNEL_ID", "")
mcp_http_command := env_var_or_default("TLDW_MCP_HTTP_COMMAND", "tldw mcp --transport=http")
mcp_http_host := env_var_or_default("TLDW_MCP_HTTP_HOST", "127.0.0.1")
mcp_http_port := env_var_or_default("TLDW_MCP_HTTP_PORT", "8765")
mcp_server_url := env_var_or_default("TLDW_MCP_SERVER_URL", "http://" + mcp_http_host + ":" + mcp_http_port + "/mcp")
tunnel_health_addr := env_var_or_default("TLDW_TUNNEL_HEALTH_ADDR", "127.0.0.1:8080")
launchd_label := env_var_or_default("TLDW_TUNNEL_LAUNCHD_LABEL", "dev.rtzll.tldw.tunnel")
launchd_keychain_service := env_var_or_default("TLDW_TUNNEL_KEYCHAIN_SERVICE", "tldw-tunnel-control-plane-api-key")
default: help
build:
go build -o {{binary}} -v .
test:
go test ./...
test-race:
go test -race ./...
fuzz:
go test ./internal/tldw -run '^$' -fuzz '^FuzzParseReference$' -fuzztime=5s
go test ./internal/ytdlp -run '^$' -fuzz '^FuzzParseSRT$' -fuzztime=5s
# Run the opt-in end-to-end transcription check (requires network access and yt-dlp).
smoke-transcription:
go test -tags=smoke ./smoke -run TestTranscriptionThroughCLIAndMCP -v -count=1
lint:
golangci-lint run
install-tools:
@echo "Installing golangci-lint..."
@which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
tidy:
go mod tidy
update:
go get -u ./...
go mod tidy
fmt:
go fmt ./...
check: fmt lint test test-race
tunnel-init:
#!/usr/bin/env bash
set -euo pipefail
test -n "{{tunnel_id}}" || { echo "Set TLDW_TUNNEL_ID=tunnel_..."; exit 1; }
test -x "{{tunnel_client}}" || { echo "Install tunnel-client at {{tunnel_client}} or set TLDW_TUNNEL_CLIENT"; exit 1; }
"{{tunnel_client}}" init \
--sample sample_mcp_with_dcr \
--profile "{{tunnel_profile}}" \
--tunnel-id "{{tunnel_id}}" \
--mcp-server-url "{{mcp_server_url}}" \
--health-listen-addr "{{tunnel_health_addr}}"
tunnel-doctor:
test -x "{{tunnel_client}}" || { echo "Install tunnel-client at {{tunnel_client}} or set TLDW_TUNNEL_CLIENT"; exit 1; }
"{{tunnel_client}}" doctor --profile "{{tunnel_profile}}" --explain
tunnel-run:
#!/usr/bin/env bash
set -euo pipefail
test -x "{{tunnel_client}}" || { echo "Install tunnel-client at {{tunnel_client}} or set TLDW_TUNNEL_CLIENT"; exit 1; }
cleanup() {
if [[ -n "${mcp_pid:-}" ]] && kill -0 "$mcp_pid" >/dev/null 2>&1; then
kill "$mcp_pid" >/dev/null 2>&1 || true
wait "$mcp_pid" >/dev/null 2>&1 || true
fi
}
wait_for_mcp() {
for _ in {1..50}; do
if (:</dev/tcp/{{mcp_http_host}}/{{mcp_http_port}}) >/dev/null 2>&1; then
return 0
fi
if ! kill -0 "$mcp_pid" >/dev/null 2>&1; then
echo "tldw MCP server exited before {{mcp_server_url}} became reachable"
return 1
fi
sleep 0.2
done
echo "Timed out waiting for {{mcp_server_url}}"
return 1
}
trap 'cleanup' EXIT
trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM
{{mcp_http_command}} --host "{{mcp_http_host}}" --port "{{mcp_http_port}}" &
mcp_pid="$!"
wait_for_mcp
"{{tunnel_client}}" run --profile "{{tunnel_profile}}"
tunnel-launchd-install:
/bin/bash "{{justfile_dir}}/scripts/tunnel-launchd" install \
"{{launchd_label}}" \
"{{launchd_keychain_service}}" \
"{{tunnel_client}}" \
"{{tunnel_profile}}" \
"{{justfile_dir}}" \
"{{mcp_http_command}}" \
"{{mcp_http_host}}" \
"{{mcp_http_port}}"
tunnel-launchd-uninstall:
/bin/bash "{{justfile_dir}}/scripts/tunnel-launchd" uninstall "{{launchd_label}}"
tunnel-launchd-status:
/bin/bash "{{justfile_dir}}/scripts/tunnel-launchd" status "{{launchd_label}}"
tunnel-launchd-restart:
/bin/bash "{{justfile_dir}}/scripts/tunnel-launchd" restart "{{launchd_label}}"
tunnel-launchd-logs mode="":
/bin/bash "{{justfile_dir}}/scripts/tunnel-launchd" logs {{mode}}
help:
@just --list