@genui-a3/create 0.1.8 → 0.1.9
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.
- package/package.json +1 -1
- package/template/.cursor/rules/example-app.mdc +9 -0
- package/template/.cursorrules +112 -0
- package/template/CLAUDE.md +112 -0
- package/template/README.md +4 -0
- package/template/app/agents/age.ts +1 -0
- package/template/app/agents/greeting.ts +1 -0
- package/template/app/lib/providers/anthropic.ts +1 -1
- package/template/docs/CUSTOM_LOGGING.md +36 -0
- package/template/docs/CUSTOM_PROVIDERS.md +642 -0
- package/template/docs/LOGGING.md +104 -0
- package/template/docs/PROVIDERS.md +217 -0
- package/template/docs/QUICK-START-EXAMPLES.md +197 -0
- package/template/docs/RESILIENCE.md +226 -0
- package/template/package.json +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Example app rules (pointer to single source)
|
|
3
|
+
globs: "**"
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Example App
|
|
8
|
+
|
|
9
|
+
When working in this directory, follow the rules in **CLAUDE.md** in this directory (same content as `.cursorrules` via symlink). Do not duplicate rule content here; CLAUDE.md is the single source of truth for Claude Code and Cursor.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Example App
|
|
2
|
+
|
|
3
|
+
Next.js example for @genui-a3/core. AI rules for this app (Claude Code and Cursor). Single source of truth; Cursor uses via symlink `.cursorrules` → this file.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- Next.js 16.1.6 (App Router), React 19, TypeScript 5.9+
|
|
8
|
+
- Testing infrastructure planned (not yet configured)
|
|
9
|
+
- MUI 7 (@mui/material) + styled-components for styling (`app/theme.ts`, `app/ThemeProvider.tsx`)
|
|
10
|
+
|
|
11
|
+
## Dependencies
|
|
12
|
+
|
|
13
|
+
- Pin all npm package versions (no `^` or `~`).
|
|
14
|
+
- Use exact versions in package.json so installs are reproducible.
|
|
15
|
+
|
|
16
|
+
## React / TypeScript
|
|
17
|
+
|
|
18
|
+
- Named functions over arrow function assignments
|
|
19
|
+
- Proper types and interfaces; follow React hooks rules and lifecycle
|
|
20
|
+
- Error boundaries and handling where appropriate
|
|
21
|
+
- Path aliases (from `tsconfig.json`):
|
|
22
|
+
- `@atoms` → `./app/components/atoms`
|
|
23
|
+
- `@molecules` → `./app/components/molecules`
|
|
24
|
+
- `@organisms` → `./app/components/organisms`
|
|
25
|
+
- `@components` → `./app/components`
|
|
26
|
+
- `@constants` → `./app/constants`
|
|
27
|
+
- `types` → `./app/types` (bare module, no @ prefix)
|
|
28
|
+
|
|
29
|
+
## Dev Commands
|
|
30
|
+
|
|
31
|
+
- `npm run dev` — Start Next.js dev server
|
|
32
|
+
- `npm run build` — Build for production
|
|
33
|
+
- `npm run start` — Start production server
|
|
34
|
+
|
|
35
|
+
## Next.js
|
|
36
|
+
|
|
37
|
+
- Use App Router, Server Components, Client Components, Server Actions, middleware as appropriate
|
|
38
|
+
|
|
39
|
+
## Code Organization
|
|
40
|
+
|
|
41
|
+
- Single-responsibility components; separation of concerns
|
|
42
|
+
- Constants for config and string literals; clean folder structure; DRY
|
|
43
|
+
- Use Atomic Design for component hierarchy (see below)
|
|
44
|
+
- `app/api/` — API routes (agui, chat, stream endpoints)
|
|
45
|
+
- `app/(pages)/` — Route groups (agui, chat, stream pages)
|
|
46
|
+
- `app/agents/` — Agent implementations (e.g. age.ts, greeting.ts)
|
|
47
|
+
- `app/lib/providers/` — Provider factory functions (Anthropic, Bedrock, OpenAI)
|
|
48
|
+
|
|
49
|
+
## Component hierarchy (Atomic Design)
|
|
50
|
+
|
|
51
|
+
- Place UI components under `app/components/` in Atomic Design layers:
|
|
52
|
+
1. **atoms/** — Single-purpose primitives (e.g. MessageBubble, buttons, inputs).
|
|
53
|
+
2. **molecules/** — Compositions of atoms (e.g. ChatMessage, ChatInput).
|
|
54
|
+
3. **organisms/** — Compositions of molecules and layout (e.g. Chat, ChatMessageList).
|
|
55
|
+
- Pages import from organisms (or molecules when no organism exists).
|
|
56
|
+
- Each layer may only use components from the same or lower layers (atoms use MUI/styled only; molecules use atoms; organisms use molecules/atoms).
|
|
57
|
+
- Export public components via `index.ts` per folder.
|
|
58
|
+
|
|
59
|
+
## State & Data
|
|
60
|
+
|
|
61
|
+
- Appropriate React hooks; clear data flow
|
|
62
|
+
- Handle loading, error, and success states; predictable updates
|
|
63
|
+
|
|
64
|
+
## Testing
|
|
65
|
+
|
|
66
|
+
Testing infrastructure is not yet configured for the example app.
|
|
67
|
+
When added, tests should be comprehensive, runnable in isolation, and cover error cases.
|
|
68
|
+
|
|
69
|
+
## Naming Conventions
|
|
70
|
+
|
|
71
|
+
- camelCase for variables, functions, and file names
|
|
72
|
+
- PascalCase for React components, interfaces, and type aliases
|
|
73
|
+
- SCREAMING_SNAKE_CASE for module-level constants
|
|
74
|
+
|
|
75
|
+
## API & UX
|
|
76
|
+
|
|
77
|
+
- Proper error handling and loading states; correct response types; separate API logic
|
|
78
|
+
- Loading states, clear error messages, responsive design, accessibility
|
|
79
|
+
|
|
80
|
+
## Security
|
|
81
|
+
|
|
82
|
+
- Sensitive data handled appropriately (HIPAA-aware)
|
|
83
|
+
- Auth/authz where needed; no keys or tokens in code
|
|
84
|
+
|
|
85
|
+
## Docs
|
|
86
|
+
|
|
87
|
+
- Markdown per markdownlint (new line per sentence, "1." for lists; config inherited from root `.markdownlint.json`)
|
|
88
|
+
|
|
89
|
+
## Workflow
|
|
90
|
+
|
|
91
|
+
1. Understand requirements (business, technical, non-functional)
|
|
92
|
+
2. Plan implementation
|
|
93
|
+
3. Write tests, then code that passes them
|
|
94
|
+
4. Document decisions; review for best practices
|
|
95
|
+
|
|
96
|
+
Use latest React and TypeScript syntax. Code should be clean, readable, maintainable, efficient, and DRY.
|
|
97
|
+
|
|
98
|
+
## A3 Framework Documentation
|
|
99
|
+
|
|
100
|
+
The `docs/` directory contains essential A3 framework documentation.
|
|
101
|
+
**You MUST read the relevant files below** before implementing or modifying any feature that touches A3 agents, providers, sessions, resilience, or logging.
|
|
102
|
+
|
|
103
|
+
| File | Topic |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `docs/QUICK-START-EXAMPLES.md` | Agent definitions, registration, multi-agent flows, ChatSession usage |
|
|
106
|
+
| `docs/PROVIDERS.md` | Provider setup (Bedrock, OpenAI, Anthropic), config options, model fallback, per-agent overrides |
|
|
107
|
+
| `docs/RESILIENCE.md` | Retry, backoff, timeout config, error classification, resilience error handling |
|
|
108
|
+
| `docs/LOGGING.md` | Internal logging architecture, `log` singleton, log levels |
|
|
109
|
+
| `docs/CUSTOM_LOGGING.md` | Supplying a custom logger via `configureLogger()` |
|
|
110
|
+
|
|
111
|
+
When in doubt about A3 API usage, patterns, or configuration — **read the relevant doc file first**.
|
|
112
|
+
Any new `.md` files added to `docs/` are part of this documentation set and should be consulted as needed.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Example App
|
|
2
|
+
|
|
3
|
+
Next.js example for @genui-a3/core. AI rules for this app (Claude Code and Cursor). Single source of truth; Cursor uses via symlink `.cursorrules` → this file.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- Next.js 16.1.6 (App Router), React 19, TypeScript 5.9+
|
|
8
|
+
- Testing infrastructure planned (not yet configured)
|
|
9
|
+
- MUI 7 (@mui/material) + styled-components for styling (`app/theme.ts`, `app/ThemeProvider.tsx`)
|
|
10
|
+
|
|
11
|
+
## Dependencies
|
|
12
|
+
|
|
13
|
+
- Pin all npm package versions (no `^` or `~`).
|
|
14
|
+
- Use exact versions in package.json so installs are reproducible.
|
|
15
|
+
|
|
16
|
+
## React / TypeScript
|
|
17
|
+
|
|
18
|
+
- Named functions over arrow function assignments
|
|
19
|
+
- Proper types and interfaces; follow React hooks rules and lifecycle
|
|
20
|
+
- Error boundaries and handling where appropriate
|
|
21
|
+
- Path aliases (from `tsconfig.json`):
|
|
22
|
+
- `@atoms` → `./app/components/atoms`
|
|
23
|
+
- `@molecules` → `./app/components/molecules`
|
|
24
|
+
- `@organisms` → `./app/components/organisms`
|
|
25
|
+
- `@components` → `./app/components`
|
|
26
|
+
- `@constants` → `./app/constants`
|
|
27
|
+
- `types` → `./app/types` (bare module, no @ prefix)
|
|
28
|
+
|
|
29
|
+
## Dev Commands
|
|
30
|
+
|
|
31
|
+
- `npm run dev` — Start Next.js dev server
|
|
32
|
+
- `npm run build` — Build for production
|
|
33
|
+
- `npm run start` — Start production server
|
|
34
|
+
|
|
35
|
+
## Next.js
|
|
36
|
+
|
|
37
|
+
- Use App Router, Server Components, Client Components, Server Actions, middleware as appropriate
|
|
38
|
+
|
|
39
|
+
## Code Organization
|
|
40
|
+
|
|
41
|
+
- Single-responsibility components; separation of concerns
|
|
42
|
+
- Constants for config and string literals; clean folder structure; DRY
|
|
43
|
+
- Use Atomic Design for component hierarchy (see below)
|
|
44
|
+
- `app/api/` — API routes (agui, chat, stream endpoints)
|
|
45
|
+
- `app/(pages)/` — Route groups (agui, chat, stream pages)
|
|
46
|
+
- `app/agents/` — Agent implementations (e.g. age.ts, greeting.ts)
|
|
47
|
+
- `app/lib/providers/` — Provider factory functions (Anthropic, Bedrock, OpenAI)
|
|
48
|
+
|
|
49
|
+
## Component hierarchy (Atomic Design)
|
|
50
|
+
|
|
51
|
+
- Place UI components under `app/components/` in Atomic Design layers:
|
|
52
|
+
1. **atoms/** — Single-purpose primitives (e.g. MessageBubble, buttons, inputs).
|
|
53
|
+
2. **molecules/** — Compositions of atoms (e.g. ChatMessage, ChatInput).
|
|
54
|
+
3. **organisms/** — Compositions of molecules and layout (e.g. Chat, ChatMessageList).
|
|
55
|
+
- Pages import from organisms (or molecules when no organism exists).
|
|
56
|
+
- Each layer may only use components from the same or lower layers (atoms use MUI/styled only; molecules use atoms; organisms use molecules/atoms).
|
|
57
|
+
- Export public components via `index.ts` per folder.
|
|
58
|
+
|
|
59
|
+
## State & Data
|
|
60
|
+
|
|
61
|
+
- Appropriate React hooks; clear data flow
|
|
62
|
+
- Handle loading, error, and success states; predictable updates
|
|
63
|
+
|
|
64
|
+
## Testing
|
|
65
|
+
|
|
66
|
+
Testing infrastructure is not yet configured for the example app.
|
|
67
|
+
When added, tests should be comprehensive, runnable in isolation, and cover error cases.
|
|
68
|
+
|
|
69
|
+
## Naming Conventions
|
|
70
|
+
|
|
71
|
+
- camelCase for variables, functions, and file names
|
|
72
|
+
- PascalCase for React components, interfaces, and type aliases
|
|
73
|
+
- SCREAMING_SNAKE_CASE for module-level constants
|
|
74
|
+
|
|
75
|
+
## API & UX
|
|
76
|
+
|
|
77
|
+
- Proper error handling and loading states; correct response types; separate API logic
|
|
78
|
+
- Loading states, clear error messages, responsive design, accessibility
|
|
79
|
+
|
|
80
|
+
## Security
|
|
81
|
+
|
|
82
|
+
- Sensitive data handled appropriately (HIPAA-aware)
|
|
83
|
+
- Auth/authz where needed; no keys or tokens in code
|
|
84
|
+
|
|
85
|
+
## Docs
|
|
86
|
+
|
|
87
|
+
- Markdown per markdownlint (new line per sentence, "1." for lists; config inherited from root `.markdownlint.json`)
|
|
88
|
+
|
|
89
|
+
## Workflow
|
|
90
|
+
|
|
91
|
+
1. Understand requirements (business, technical, non-functional)
|
|
92
|
+
2. Plan implementation
|
|
93
|
+
3. Write tests, then code that passes them
|
|
94
|
+
4. Document decisions; review for best practices
|
|
95
|
+
|
|
96
|
+
Use latest React and TypeScript syntax. Code should be clean, readable, maintainable, efficient, and DRY.
|
|
97
|
+
|
|
98
|
+
## A3 Framework Documentation
|
|
99
|
+
|
|
100
|
+
The `docs/` directory contains essential A3 framework documentation.
|
|
101
|
+
**You MUST read the relevant files below** before implementing or modifying any feature that touches A3 agents, providers, sessions, resilience, or logging.
|
|
102
|
+
|
|
103
|
+
| File | Topic |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `docs/QUICK-START-EXAMPLES.md` | Agent definitions, registration, multi-agent flows, ChatSession usage |
|
|
106
|
+
| `docs/PROVIDERS.md` | Provider setup (Bedrock, OpenAI, Anthropic), config options, model fallback, per-agent overrides |
|
|
107
|
+
| `docs/RESILIENCE.md` | Retry, backoff, timeout config, error classification, resilience error handling |
|
|
108
|
+
| `docs/LOGGING.md` | Internal logging architecture, `log` singleton, log levels |
|
|
109
|
+
| `docs/CUSTOM_LOGGING.md` | Supplying a custom logger via `configureLogger()` |
|
|
110
|
+
|
|
111
|
+
When in doubt about A3 API usage, patterns, or configuration — **read the relevant doc file first**.
|
|
112
|
+
Any new `.md` files added to `docs/` are part of this documentation set and should be consulted as needed.
|
package/template/README.md
CHANGED
|
@@ -11,6 +11,7 @@ const agePayload = z.object({
|
|
|
11
11
|
|
|
12
12
|
export const ageAgent: Agent<State> = {
|
|
13
13
|
id: 'age',
|
|
14
|
+
description: "Gets the user's age.",
|
|
14
15
|
prompt: `
|
|
15
16
|
You are a friendly agent. Your goal is to learn the user's age.
|
|
16
17
|
If you don't know their age yet, ask for it politely.
|
|
@@ -19,6 +19,7 @@ const greetingPayload = z.object({
|
|
|
19
19
|
|
|
20
20
|
export const greetingAgent: Agent<State> = {
|
|
21
21
|
id: 'greeting',
|
|
22
|
+
description: 'Greets the user and learns their name.',
|
|
22
23
|
prompt: `
|
|
23
24
|
You are a friendly greeting agent. Your goal is to greet the user and learn their name.
|
|
24
25
|
You also handle name changes — if the user wants to update their name, collect the new one.
|
|
@@ -5,7 +5,7 @@ let _instance: ReturnType<typeof createAnthropicProvider> | null = null
|
|
|
5
5
|
export function getAnthropicProvider() {
|
|
6
6
|
if (!_instance) {
|
|
7
7
|
_instance = createAnthropicProvider({
|
|
8
|
-
models: ['claude-sonnet-4-
|
|
8
|
+
models: ['claude-sonnet-4-6', 'claude-haiku-4-5-20251001'],
|
|
9
9
|
})
|
|
10
10
|
}
|
|
11
11
|
return _instance
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Custom Logging
|
|
2
|
+
|
|
3
|
+
By default, A3 logs internally using [tslog](https://tslog.js.org) with no configuration required.
|
|
4
|
+
If you want A3's internal logs to flow through your own logging infrastructure — for example, to include your app's trace IDs, ship logs to a provider like Datadog or OpenTelemetry, or change the output format — you can provide a custom logger.
|
|
5
|
+
|
|
6
|
+
## How it works
|
|
7
|
+
|
|
8
|
+
A3 uses [LogLayer](https://loglayer.dev) as its logging interface.
|
|
9
|
+
LogLayer is a transport-agnostic logging layer: you configure it with a _transport_ that wraps your preferred logging library, and LogLayer routes A3's log calls through it.
|
|
10
|
+
|
|
11
|
+
You do not need to know the LogLayer API to use your own logger — you only need to wrap it in the appropriate LogLayer transport.
|
|
12
|
+
|
|
13
|
+
## Default behaviour
|
|
14
|
+
|
|
15
|
+
Out of the box, A3:
|
|
16
|
+
|
|
17
|
+
- Outputs pretty, human-readable logs in development (`NODE_ENV !== 'production'`)
|
|
18
|
+
- Outputs structured JSON in production
|
|
19
|
+
- Defaults to log level `info`, overridden by the `A3_LOG_LEVEL` environment variable
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Supported levels: silly | trace | debug | info | warn | error | fatal
|
|
23
|
+
A3_LOG_LEVEL=debug node your-app.js
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configuring a custom logger
|
|
27
|
+
|
|
28
|
+
A3 uses the [LogLayer](https://loglayer.dev) interface.
|
|
29
|
+
Call `configureLogger()` with a `LogLayer` instance configured for your preferred logging library.
|
|
30
|
+
See the [LogLayer documentation](https://loglayer.dev) for setup instructions and the full list of available transports.
|
|
31
|
+
|
|
32
|
+
## Further reading
|
|
33
|
+
|
|
34
|
+
- [LogLayer documentation](https://loglayer.dev) — full API, plugins, multi-transport, context, and more
|
|
35
|
+
- [LogLayer transports](https://loglayer.dev/transports) — all available transports with setup instructions
|
|
36
|
+
- [tslog documentation](https://tslog.js.org) — the default A3 logger
|