@oalacea/daemon 0.7.1 → 0.7.3

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.
Files changed (37) hide show
  1. package/bin/Dockerfile +4 -4
  2. package/dist/prompts/DEPS_EFFICIENCY.md +558 -0
  3. package/dist/prompts/E2E.md +491 -0
  4. package/dist/prompts/EXECUTE.md +1060 -0
  5. package/dist/prompts/INTEGRATION_API.md +484 -0
  6. package/dist/prompts/INTEGRATION_DB.md +425 -0
  7. package/dist/prompts/PERF_API.md +433 -0
  8. package/dist/prompts/PERF_DB.md +430 -0
  9. package/dist/prompts/PERF_FRONT.md +357 -0
  10. package/dist/prompts/REMEDIATION.md +482 -0
  11. package/dist/prompts/UNIT.md +260 -0
  12. package/dist/templates/README.md +221 -0
  13. package/dist/templates/k6/load-test.js +54 -0
  14. package/dist/templates/nestjs/controller.spec.ts +203 -0
  15. package/dist/templates/nestjs/e2e/api.e2e-spec.ts +451 -0
  16. package/dist/templates/nestjs/e2e/auth.e2e-spec.ts +533 -0
  17. package/dist/templates/nestjs/fixtures/test-module.ts +311 -0
  18. package/dist/templates/nestjs/guard.spec.ts +314 -0
  19. package/dist/templates/nestjs/interceptor.spec.ts +458 -0
  20. package/dist/templates/nestjs/module.spec.ts +173 -0
  21. package/dist/templates/nestjs/pipe.spec.ts +474 -0
  22. package/dist/templates/nestjs/service.spec.ts +296 -0
  23. package/dist/templates/playwright/e2e.spec.ts +61 -0
  24. package/dist/templates/rust/Cargo.toml +72 -0
  25. package/dist/templates/rust/actix-controller.test.rs +114 -0
  26. package/dist/templates/rust/axum-handler.test.rs +117 -0
  27. package/dist/templates/rust/integration.test.rs +63 -0
  28. package/dist/templates/rust/rocket-route.test.rs +106 -0
  29. package/dist/templates/rust/unit.test.rs +38 -0
  30. package/dist/templates/vitest/angular-component.test.ts +38 -0
  31. package/dist/templates/vitest/api.test.ts +51 -0
  32. package/dist/templates/vitest/component.test.ts +27 -0
  33. package/dist/templates/vitest/hook.test.ts +36 -0
  34. package/dist/templates/vitest/solid-component.test.ts +34 -0
  35. package/dist/templates/vitest/svelte-component.test.ts +33 -0
  36. package/dist/templates/vitest/vue-component.test.ts +39 -0
  37. package/package.json +2 -2
@@ -0,0 +1,63 @@
1
+ // Integration tests typically live in the `tests/` directory
2
+ // Each file in tests/ is compiled as a separate crate
3
+
4
+ use my_project::add;
5
+
6
+ #[test]
7
+ fn integration_test_add() {
8
+ // Test the public API of your library
9
+ let result = add(2, 3);
10
+ assert_eq!(result, 5);
11
+ }
12
+
13
+ #[test]
14
+ fn integration_test_add_negative_numbers() {
15
+ let result = add(-2, -3);
16
+ assert_eq!(result, -5);
17
+ }
18
+
19
+ #[test]
20
+ #[should_panic(expected = "overflow")]
21
+ fn integration_test_add_overflow() {
22
+ // This test should panic
23
+ let _ = add(i32::MAX, 1);
24
+ }
25
+
26
+ /// Test API endpoint behavior
27
+ #[tokio::test]
28
+ async fn test_api_endpoint() {
29
+ // TODO: Set up test server
30
+ // let app = create_test_app().await;
31
+ // let response = app
32
+ // .oneshot(Request::builder()
33
+ // .uri("/api/test")
34
+ // .body(Body::empty())
35
+ // .unwrap())
36
+ // .await
37
+ // .unwrap();
38
+ // assert_eq!(response.status(), StatusCode::OK);
39
+ }
40
+
41
+ /// Test database operations
42
+ #[tokio::test]
43
+ async fn test_database_operation() {
44
+ // TODO: Set up test database
45
+ // let pool = create_test_pool().await;
46
+ // let result = sqlx::query("SELECT * FROM users WHERE id = $1")
47
+ // .bind(1)
48
+ // .fetch_one(&pool)
49
+ // .await;
50
+ // assert!(result.is_ok());
51
+ }
52
+
53
+ /// Helper to create test application
54
+ async fn create_test_app() -> Router {
55
+ // TODO: Initialize app with test configuration
56
+ Router::new()
57
+ }
58
+
59
+ /// Helper to create test database pool
60
+ async fn create_test_pool() -> SqlitePool {
61
+ // TODO: Create in-memory database for testing
62
+ SqlitePool::connect(":memory:").await.unwrap()
63
+ }
@@ -0,0 +1,106 @@
1
+ #[cfg(test)]
2
+ mod tests {
3
+ use super::*;
4
+ use rocket::http::{Header, ContentType, Status};
5
+ use rocket::local::blocking::Client;
6
+ use rocket::serde::json::Json;
7
+
8
+ /// Helper function to create test client
9
+ fn create_client() -> Client {
10
+ // TODO: Configure Rocket for testing
11
+ // Client::tracked(rocket().build().unwrap()).unwrap()
12
+ unimplemented!()
13
+ }
14
+
15
+ /// Test health check endpoint
16
+ #[test]
17
+ fn test_health_check() {
18
+ let client = create_client();
19
+ let response = client.get("/health").dispatch();
20
+
21
+ assert_eq!(response.status(), Status::Ok);
22
+ }
23
+
24
+ /// Test GET /api/users returns 200
25
+ #[test]
26
+ fn test_get_users_returns_200() {
27
+ let client = create_client();
28
+ let response = client.get("/api/users").dispatch();
29
+
30
+ assert_eq!(response.status(), Status::Ok);
31
+
32
+ // Optionally check response body
33
+ let body = response.into_string().unwrap();
34
+ assert!(!body.is_empty());
35
+ }
36
+
37
+ /// Test GET /api/users with authentication
38
+ #[test]
39
+ fn test_get_users_with_authentication() {
40
+ let client = create_client();
41
+ let token = "valid_token";
42
+
43
+ let response = client
44
+ .get("/api/users")
45
+ .add_header(Header::new("Authorization", format!("Bearer {}", token)))
46
+ .dispatch();
47
+
48
+ assert_eq!(response.status(), Status::Ok);
49
+ }
50
+
51
+ /// Test POST /api/users with valid data returns 201
52
+ #[test]
53
+ fn test_create_user_with_valid_data_returns_201() {
54
+ let client = create_client();
55
+ let body = serde_json::json!({
56
+ "name": "Test User",
57
+ "email": "test@example.com"
58
+ });
59
+
60
+ let response = client
61
+ .post("/api/users")
62
+ .header(ContentType::JSON)
63
+ .body(body.to_string())
64
+ .dispatch();
65
+
66
+ assert_eq!(response.status(), Status::Created);
67
+ }
68
+
69
+ /// Test POST /api/users with invalid data returns 400
70
+ #[test]
71
+ fn test_create_user_with_invalid_data_returns_400() {
72
+ let client = create_client();
73
+ let body = serde_json::json!({
74
+ "name": ""
75
+ });
76
+
77
+ let response = client
78
+ .post("/api/users")
79
+ .header(ContentType::JSON)
80
+ .body(body.to_string())
81
+ .dispatch();
82
+
83
+ assert_eq!(response.status(), Status::BadRequest);
84
+ }
85
+
86
+ /// TODO: Implement route handlers
87
+ #[get("/health")]
88
+ fn health_check() -> &'static str {
89
+ "OK"
90
+ }
91
+
92
+ #[get("/api/users")]
93
+ fn get_users() -> Json<serde_json::Value> {
94
+ Json(serde_json::json!([]))
95
+ }
96
+
97
+ #[post("/api/users", format = "json", data = "<user>")]
98
+ fn create_user(user: Json<serde_json::Value>) -> Status {
99
+ Status::Created
100
+ }
101
+
102
+ fn rocket() -> rocket::Rocket<rocket::Build> {
103
+ rocket::build()
104
+ .mount("/", routes![health_check, get_users, create_user])
105
+ }
106
+ }
@@ -0,0 +1,38 @@
1
+ #[cfg(test)]
2
+ mod tests {
3
+ use super::*;
4
+
5
+ /// Test that a function returns expected value
6
+ #[test]
7
+ fn test_function_returns_expected() {
8
+ let input = "test";
9
+ let result = process(input);
10
+ assert_eq!(result, "expected");
11
+ }
12
+
13
+ /// Test that a function handles empty input
14
+ #[test]
15
+ fn test_function_handles_empty_input() {
16
+ let input = "";
17
+ let result = process(input);
18
+ assert!(result.is_empty());
19
+ }
20
+
21
+ /// Test that a function handles error cases
22
+ #[test]
23
+ fn test_function_handles_errors() {
24
+ let input = "invalid";
25
+ let result = process(input);
26
+ assert!(result.is_err());
27
+ }
28
+
29
+ /// Helper function to create test fixtures
30
+ fn setup_test_fixture() -> String {
31
+ String::from("fixture")
32
+ }
33
+
34
+ /// TODO: Replace with actual function under test
35
+ fn process(input: &str) -> Result<String, Box<dyn std::error::Error>> {
36
+ Ok(input.to_uppercase())
37
+ }
38
+ }
@@ -0,0 +1,38 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { describe, it, expect } from 'vitest';
3
+
4
+ // TODO: Import your component
5
+ // import { ComponentName } from '@/components/component-name.component';
6
+
7
+ describe('ComponentName', () => {
8
+ let component: ComponentFixture<any>;
9
+
10
+ beforeEach(async () => {
11
+ // TODO: Configure TestBed
12
+ // await TestBed.configureTestingModule({
13
+ // imports: [ComponentName],
14
+ // }).compileComponents();
15
+
16
+ // component = TestBed.createComponent(ComponentName);
17
+ // component.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ // TODO: Test component creation
22
+ // expect(component.componentInstance).toBeTruthy();
23
+ });
24
+
25
+ it('should render title', () => {
26
+ // TODO: Test rendered content
27
+ // const compiled = component.nativeElement as HTMLElement;
28
+ // expect(compiled.querySelector('h1')?.textContent).toContain('Test');
29
+ });
30
+
31
+ it('should handle user interaction', () => {
32
+ // TODO: Test events
33
+ // const button = component.nativeElement.querySelector('button');
34
+ // button.click();
35
+ // component.detectChanges();
36
+ // expect(component.instance.value).toBe('updated');
37
+ });
38
+ });
@@ -0,0 +1,51 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
+ import { POST, GET, PATCH, DELETE } from '@/app/api/route';
3
+
4
+ // TODO: Import database setup if needed
5
+ // import { db } from '@test/db';
6
+
7
+ describe('API Endpoint', () => {
8
+ beforeEach(async () => {
9
+ // TODO: Setup test database
10
+ // await db.begin();
11
+ });
12
+
13
+ afterEach(async () => {
14
+ // TODO: Cleanup test database
15
+ // await db.rollback();
16
+ });
17
+
18
+ it('should return 200 for GET request', async () => {
19
+ const request = new Request('http://localhost:3000/api/endpoint', {
20
+ method: 'GET',
21
+ });
22
+
23
+ const response = await GET(request);
24
+ expect(response.status).toBe(200);
25
+ });
26
+
27
+ it('should create resource with POST', async () => {
28
+ const request = new Request('http://localhost:3000/api/endpoint', {
29
+ method: 'POST',
30
+ headers: { 'Content-Type': 'application/json' },
31
+ body: JSON.stringify({ name: 'Test' }),
32
+ });
33
+
34
+ const response = await POST(request);
35
+ expect(response.status).toBe(201);
36
+
37
+ const data = await response.json();
38
+ expect(data).toHaveProperty('id');
39
+ });
40
+
41
+ it('should validate input data', async () => {
42
+ const request = new Request('http://localhost:3000/api/endpoint', {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/json' },
45
+ body: JSON.stringify({ invalid: 'data' }),
46
+ });
47
+
48
+ const response = await POST(request);
49
+ expect(response.status).toBe(400);
50
+ });
51
+ });
@@ -0,0 +1,27 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+ import userEvent from '@testing-library/user-event';
4
+
5
+ // TODO: Import your component
6
+ // import { ComponentName } from '@/components/ComponentName';
7
+
8
+ describe('ComponentName', () => {
9
+ it('should render', () => {
10
+ // TODO: Add component render
11
+ // render(<ComponentName />);
12
+ // expect(screen.getByRole('button')).toBeInTheDocument();
13
+ });
14
+
15
+ it('should render with children', () => {
16
+ // TODO: Test children rendering
17
+ // render(<ComponentName>Test content</ComponentName>);
18
+ // expect(screen.getByText('Test content')).toBeInTheDocument();
19
+ });
20
+
21
+ it('should handle user interaction', async () => {
22
+ // TODO: Test click/hover/etc
23
+ // const user = userEvent.setup();
24
+ // render(<ComponentName onClick={vi.fn()} />);
25
+ // await user.click(screen.getByRole('button'));
26
+ });
27
+ });
@@ -0,0 +1,36 @@
1
+ import { renderHook, act, waitFor } from '@testing-library/react';
2
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
3
+
4
+ // TODO: Import your hook
5
+ // import { useHookName } from '@/hooks/useHookName';
6
+
7
+ describe('useHookName', () => {
8
+ beforeEach(() => {
9
+ vi.clearAllMocks();
10
+ });
11
+
12
+ it('should return initial state', () => {
13
+ // TODO: Test initial state
14
+ // const { result } = renderHook(() => useHookName());
15
+ // expect(result.current).toBeDefined();
16
+ });
17
+
18
+ it('should update state', async () => {
19
+ // TODO: Test state updates
20
+ // const { result } = renderHook(() => useHookName());
21
+ // act(() => {
22
+ // result.current.setValue('test');
23
+ // });
24
+ // await waitFor(() => {
25
+ // expect(result.current.value).toBe('test');
26
+ // });
27
+ });
28
+
29
+ it('should cleanup on unmount', () => {
30
+ // TODO: Test cleanup
31
+ // const { unmount } = renderHook(() => useHookName());
32
+ // const cleanup = vi.fn();
33
+ // unmount();
34
+ // expect(cleanup).toHaveBeenCalled();
35
+ });
36
+ });
@@ -0,0 +1,34 @@
1
+ import { render, screen } from '@solidjs/testing-library';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+
4
+ // TODO: Import your component
5
+ // import ComponentName from '@/components/ComponentName';
6
+
7
+ describe('ComponentName', () => {
8
+ it('should render', () => {
9
+ // TODO: Add component render
10
+ // render(() => <ComponentName />);
11
+ // expect(screen.getByRole('button')).toBeInTheDocument();
12
+ });
13
+
14
+ it('should render with props', () => {
15
+ // TODO: Test props
16
+ // render(() => <ComponentName title="Test Title" />);
17
+ // expect(screen.getByText('Test Title')).toBeInTheDocument();
18
+ });
19
+
20
+ it('should handle user interaction', async () => {
21
+ // TODO: Test events
22
+ // const handleClick = vi.fn();
23
+ // render(() => <ComponentName onClick={handleClick} />);
24
+ // const button = screen.getByRole('button');
25
+ // button.click();
26
+ // expect(handleClick).toHaveBeenCalledTimes(1);
27
+ });
28
+
29
+ it('should update with reactive state', () => {
30
+ // TODO: Test reactivity
31
+ // const { container } = render(() => <ComponentName count={5} />);
32
+ // expect(container.textContent).toContain('5');
33
+ });
34
+ });
@@ -0,0 +1,33 @@
1
+ import { render, screen } from '@testing-library/svelte';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+
4
+ // TODO: Import your component
5
+ // import ComponentName from '@/components/ComponentName.svelte';
6
+
7
+ describe('ComponentName', () => {
8
+ it('should render', () => {
9
+ // TODO: Add component render
10
+ // render(ComponentName);
11
+ // expect(container).toBeTruthy();
12
+ });
13
+
14
+ it('should render with props', () => {
15
+ // TODO: Test props
16
+ // const { container } = render(ComponentName, { props: { title: 'Test Title' } });
17
+ // expect(container.textContent).toContain('Test Title');
18
+ });
19
+
20
+ it('should handle user interaction', async () => {
21
+ // TODO: Test events
22
+ // const { container, component } = render(ComponentName);
23
+ // const button = container.querySelector('button');
24
+ // button.click();
25
+ // expect(component.$$).toBeDefined();
26
+ });
27
+
28
+ it('should update when props change', async () => {
29
+ // TODO: Test reactivity
30
+ // const { container } = render(ComponentName, { props: { count: 0 } });
31
+ // // Update props and check reactivity
32
+ });
33
+ });
@@ -0,0 +1,39 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+
4
+ // TODO: Import your component
5
+ // import ComponentName from '@/components/ComponentName.vue';
6
+
7
+ describe('ComponentName', () => {
8
+ it('should render', () => {
9
+ // TODO: Add component render
10
+ // const wrapper = mount(ComponentName);
11
+ // expect(wrapper.exists()).toBe(true);
12
+ });
13
+
14
+ it('should render with props', () => {
15
+ // TODO: Test props
16
+ // const wrapper = mount(ComponentName, {
17
+ // props: { title: 'Test Title' }
18
+ // });
19
+ // expect(wrapper.text()).toContain('Test Title');
20
+ });
21
+
22
+ it('should handle user interaction', async () => {
23
+ // TODO: Test events
24
+ // const wrapper = mount(ComponentName, {
25
+ // props: { onClick: vi.fn() }
26
+ // });
27
+ // await wrapper.find('button').trigger('click');
28
+ // expect(wrapper.emitted('click')).toBeTruthy();
29
+ });
30
+
31
+ it('should update when props change', async () => {
32
+ // TODO: Test reactivity
33
+ // const wrapper = mount(ComponentName, {
34
+ // props: { count: 0 }
35
+ // });
36
+ // await wrapper.setProps({ count: 5 });
37
+ // expect(wrapper.text()).toContain('5');
38
+ });
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oalacea/daemon",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "AI-powered code quality analysis, scoring, and optimization for web applications",
5
5
  "author": "Yanis",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "daemon": "./dist/cli/index.js"
14
14
  },
15
15
  "scripts": {
16
- "build": "tsc",
16
+ "build": "tsc && node -e \"const fs=require('fs');fs.cpSync('prompts','dist/prompts',{recursive:true});fs.cpSync('templates','dist/templates',{recursive:true});\"",
17
17
  "dev": "tsx src/cli/index.ts",
18
18
  "test": "vitest",
19
19
  "test:run": "node --experimental-strip-types dist/cli/index.js",