Skip to content

Commit f25f182

Browse files
committed
chore: migrate from husky to lefthook and fix angular tests
- Replace husky with lefthook for git hooks management - Pre-commit runs lint --fix, format, test, and check:packages in parallel with auto-staging of fixes via stage_fixed - Commit-msg runs commitlint - Add dependsOn ^build to test target in nx.json so dependencies are built before tests run - Upgrade @analogjs/vite-plugin-angular and @analogjs/vitest-angular from ^1.20.2 to ^2.2.3 for vite 7 compatibility - Add pnpm packageExtensions to declare missing vite peer dependency on @analogjs/vite-plugin-angular - Fix lint issues: let -> const in agent and react packages - Disable nx TUI in pre-commit hooks via NX_TUI env var
1 parent 9bd0418 commit f25f182

8 files changed

Lines changed: 193 additions & 56 deletions

File tree

.husky/commit-msg

Lines changed: 0 additions & 6 deletions
This file was deleted.

lefthook.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
pre-commit:
2+
parallel: true
3+
commands:
4+
lint-fix:
5+
env:
6+
NX_TUI: "false"
7+
run: pnpm run lint --fix && pnpm run format
8+
stage_fixed: true
9+
test:
10+
env:
11+
NX_TUI: "false"
12+
run: pnpm run test
13+
check-packages:
14+
env:
15+
NX_TUI: "false"
16+
run: pnpm run check:packages
17+
18+
commit-msg:
19+
commands:
20+
commitlint:
21+
run: pnpm commitlint --edit {1}

nx.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
"cache": false
4141
},
4242
"test": {
43+
"dependsOn": [
44+
"^build"
45+
],
4346
"inputs": [
4447
"test"
4548
],

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"demo:next:angular": "nx run-many -t dev --projects=examples/v2/angular/demo,examples/v2/angular/demo-server",
3434
"demo:next:react": "pnpm -C examples/v2/react/demo dev",
3535
"changeset": "changeset",
36-
"prepare": "husky",
36+
"prepare": "lefthook install",
3737
"graph": "nx graph",
3838
"publint": "nx run-many -t publint --projects=packages/**",
3939
"attw": "nx run-many -t attw --projects=packages/**",
@@ -66,7 +66,7 @@
6666
"eslint": "^8.56.0",
6767
"eslint-config-custom": "workspace:*",
6868
"glob": "^10.3.12",
69-
"husky": "^9.1.4",
69+
"lefthook": "^2.1.1",
7070
"install": "^0.13.0",
7171
"npm": "^10.7.0",
7272
"nx": "^22.5.0",
@@ -109,6 +109,13 @@
109109
"publicHoistPattern": [
110110
"@ag-ui/*"
111111
],
112+
"packageExtensions": {
113+
"@analogjs/vite-plugin-angular": {
114+
"peerDependencies": {
115+
"vite": "*"
116+
}
117+
}
118+
},
112119
"patchedDependencies": {
113120
"@changesets/assemble-release-plan@6.0.9": "patches/@changesets__assemble-release-plan@6.0.9.patch"
114121
}

packages/v2/agent/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,23 +413,23 @@ export function convertJsonSchemaToZodSchema(
413413
jsonSchema.required ? jsonSchema.required.includes(key) : false,
414414
);
415415
}
416-
let schema = z.object(spec).describe(jsonSchema.description ?? "");
416+
const schema = z.object(spec).describe(jsonSchema.description ?? "");
417417
return required ? schema : schema.optional();
418418
} else if (jsonSchema.type === "string") {
419-
let schema = z.string().describe(jsonSchema.description ?? "");
419+
const schema = z.string().describe(jsonSchema.description ?? "");
420420
return required ? schema : schema.optional();
421421
} else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
422-
let schema = z.number().describe(jsonSchema.description ?? "");
422+
const schema = z.number().describe(jsonSchema.description ?? "");
423423
return required ? schema : schema.optional();
424424
} else if (jsonSchema.type === "boolean") {
425-
let schema = z.boolean().describe(jsonSchema.description ?? "");
425+
const schema = z.boolean().describe(jsonSchema.description ?? "");
426426
return required ? schema : schema.optional();
427427
} else if (jsonSchema.type === "array") {
428428
if (!jsonSchema.items) {
429429
throw new Error("Array type must have items property");
430430
}
431-
let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
432-
let schema = z.array(itemSchema).describe(jsonSchema.description ?? "");
431+
const itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
432+
const schema = z.array(itemSchema).describe(jsonSchema.description ?? "");
433433
return required ? schema : schema.optional();
434434
}
435435
console.error("Invalid JSON schema:", JSON.stringify(jsonSchema, null, 2));

packages/v2/angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"rxjs": "^7.8.0"
4747
},
4848
"devDependencies": {
49-
"@analogjs/vite-plugin-angular": "^1.20.2",
50-
"@analogjs/vitest-angular": "^1.20.2",
49+
"@analogjs/vite-plugin-angular": "^2.2.3",
50+
"@analogjs/vitest-angular": "^2.2.3",
5151
"@angular/cdk": "^18.0.0",
5252
"@angular/common": "^18.0.0",
5353
"@angular/compiler": "^18.0.0",

packages/v2/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
describe("useFrontendTool E2E - Dynamic Registration", () => {
3131
describe("Minimal dynamic registration without chat run", () => {
3232
it("registers tool and renders tool call via ToolCallsView", async () => {
33-
// eslint-disable-next-line no-console
3433
// No agent run; we render ToolCallsView directly
3534
const DynamicToolComponent: React.FC = () => {
3635
const tool: ReactFrontendTool<{ message: string }> = {
@@ -1905,7 +1904,7 @@ describe("useFrontendTool E2E - Dynamic Registration", () => {
19051904
describe("Wildcard Handler", () => {
19061905
it("should handle unknown tools with wildcard", async () => {
19071906
const agent = new MockStepwiseAgent();
1908-
let wildcardHandlerCalls: { name: string; args: any }[] = [];
1907+
const wildcardHandlerCalls: { name: string; args: any }[] = [];
19091908

19101909
// Note: Wildcard tools work as fallback renderers when no specific tool is found
19111910
// The wildcard renderer receives the original tool name and arguments

0 commit comments

Comments
 (0)