There has been a bunch of great work on directed type theory lately, where you talk about types with groupoid structure, as you do in homotopy type theory, but types with category structure.
Riehl-Shulman is the one paper I almost understand like 75% of, after staring at it for a long time. Also Nuyts's work also seeming very interesting although I definitely don't understand the details deeply there.
Despite both of those existing, I'm going to talk a little a bit about what I've been thinking about lately on the topic, even at the risk that it might be subsumed by something already in the literature — because if I understand precisely how, that would be progress for me understanding what's going on, anyway.
How Riehl-Shulman deal with this is by simply refraining from trying to make every type a category; there is some graph-like structure on every set arising from the axiomatization of the interval, but only some types admit composition — namely the 'Segal types' described in the paper — and further only some of those have a kind of univalence-like property that says that isomorphism means equality. ('Rezk types')
But what I've been thinking about lately isn't even trying to equip every type in a type theory with some almost categorical structure and then fishing out the ones that are genuinely categories. To be entirely honest, I'm still a little unclear what I am doing, but I'll describe it as best as I can given what I know.
What I do want to have is
An elementary yoneda-lemma computation tells us what the exponential must look like in functor categories into $\rset$. If we have $F, G : \rset^\C$ and we want to know what $F \imp G : \rset^\C$ looks like, well, for any object $c \in \C$, we have \[(F \imp G)(c) = \hom(\C[c, \dash], F \imp G) = \hom(\C[c, \dash] \x F, G)\] This means if we had a function type \[\alpha : \C \prov A(\alpha) \imp B(\alpha) : \rtype \] and we wanted to have a syntactic notion of substitution of an object $c \in \C$ for the variable $\alpha$, it would be wrong to define \[ [c/\alpha](A(\alpha) \imp B(\alpha)) = (A(c) \imp B(c)) \] because the Kripke-esque "for all future worlds" inherent in the $\C[c, \dash] \x \cdots$ needs to be accounted for. Actually we would need to do something more like \[ [c/\alpha](A(\alpha) \imp B(\alpha)) = \forall d : \C . \forall g : c \to d . (A(d) \imp B(d)) \]
And, thankfully, there is a reasonable categorical notion by which to interpret universal (and existential) quantification over objects of a category: (co)ends! But the kind of thing you take a (co)end over is a functor taking two arguments, one at $\C$ and one at $\C^\op$. So I'm going to make a guess that the meaning of a context \[\Delta = \alpha_1 : \C_1, \ldots, \alpha_n : \C_n\] is actually \[\ll\Delta\rr = (\C_1 \x \C_1^\op) \x \cdots, (\C_n \x \C_n^\op)\] and the meaning of $\Delta \prov A : \rtype$ is a functor from $\ll\Delta\rr$ to $\rset$.
This means that I could imagine a type formation rule \[ {\Delta \prov A : \rtype \qquad \Delta \prov B: \rtype \over \Delta \prov A \to B : \rtype} \] because if $\ll A\rr : \ll\Delta\rr \to \rset$ and $\ll B\rr : \ll\Delta\rr \to \rset$, then we can define a functor by \[ \ll A \to B \rr(\bar c) = \ll A \rr(\tilde c) \to \ll B \rr(\bar c) \] \[ \ll A \to B \rr(\bar f) : (\ll A \rr(\tilde c) \to \ll B \rr(\bar c)) \to (\ll A \rr(\tilde d) \to \ll B \rr(\bar d))\] \[ \ll A \to B \rr (\bar f) = \lambda h . \ll B \rr(\bar f) \o h \o \ll A\rr(\bar f) \] where $\bar c = ((c_1, c'_1), \ldots, (c_n, c'_n))$ and $\tilde c = ((c_1', c_1), \ldots, (c'_n, c_n))$ and and $\bar f = ((f_1, f'_1), \ldots, (f_n, f'_n))$ for any $c_i \in \C_i, c'_i \in \C^\op_i$ and any $f_i : c_i \to d_i \in \C$ and $f'_i : d'_i \to c'_i \in \C$. (note the swapped arguments being fed to $A$!)
Also we could write down a type formation rule for the universal quantifier \[ { \Delta, \alpha : \C \prov A(\alpha) : \rtype \over \Delta \prov \forall \alpha : \C . A(\alpha) : \rtype} \] where the semantics of the rule can be realized with just currying.
I certainly don't know all of the details of how this works out, but I have a bunch of ideas that seem coherent so far. At least in the simply-typed case, the semantics of a term judgment \[ \Delta ; \Gamma \prov M : A \] is that $\ll M \rr$ should be an inhabitant of the end \[\int_{\bar c \in \ll\Delta\rr} \ll\Gamma\rr(\tilde c) \to \ll A \rr(\bar c)\] and you can write down existential quantifiers over category variables as well, and all their semantics works out and all the terms get interpreted at the right types because ends and coends satisfy all kinds of nice laws.
Of course, where things get tricky is dependent types! But I've seen some very promising things happen if you decorate term variables with just a little more information. Maybe by next week I'll have something worked out well enough to talk about...