git-agent for TypeScriptgit-agent splits TypeScript changes across types, implementation, and tests into separate atomic commits, generating precise conventional messages that reflect your type-safe refactors and feature additions.
diff --git a/src/services/auth.ts b/src/services/auth.ts
index c2d4f1a..9e8b3c2 100644
--- a/src/services/auth.ts
+++ b/src/services/auth.ts
@@ -1,5 +1,6 @@
import { sign, verify } from "jsonwebtoken";
import { config } from "../config";
+import { TokenExpiredError } from "../errors";
-export function verifyToken(token: string): { userId: string } {
- return verify(token, config.jwtSecret) as { userId: string };
+export interface TokenPayload {
+ userId: string;
+ iat: number;
+ exp: number;
+}
+
+export function verifyToken(token: string): TokenPayload {
+ try {
+ return verify(token, config.jwtSecret) as TokenPayload;
+ } catch (err) {
+ if (err instanceof Error && err.name === "TokenExpiredError") {
+ throw new TokenExpiredError(token);
+ }
+ throw err;
+ }
}refactor(auth): strengthen verifyToken return type and error handling
- export TokenPayload interface with iat/exp fields for downstream consumers
- wrap jsonwebtoken errors so callers receive domain-specific TokenExpiredError
- remove unsafe cast in favour of typed return signature
Eliminates the implicit any in callers that previously destructured the
return value without type guards; downstream middleware can now distinguish
expired tokens from malformed ones.brew install gitagenthq/tap/git-agent
# in your TypeScript repo
git-agent init # reads tsconfig.json paths to suggest scopesWill git-agent split my TypeScript and JavaScript files into separate commits?Does git-agent understand TypeScript decorators and metadata?Can I configure scopes to match my TypeScript path aliases?git-agent init and it will read your tsconfig paths to suggest scopes. You can then edit .git-agent/project.yml to fine-tune them.