This commit is contained in:
MaKarin
2026-04-06 12:50:46 +03:00
commit 73ddb1a948
155 changed files with 26688 additions and 0 deletions

181
.claude/CLAUDE.md Normal file
View File

@@ -0,0 +1,181 @@
# Claude Code — KIS-TOiR workspace supplement
This file supplements the repository root `AGENTS.md` with Claude-specific
operational notes. The root `AGENTS.md` is the authoritative contract —
if anything here contradicts root, root wins.
---
## Agent role summary
| Role | Config file | Sandbox | Primary responsibility |
| ----------------------------------- | --------------------------------------------- | --------------- | ---------------------- |
| `explorer` | `agents/explorer.toml` | read-only | Discovery only |
| `docs_researcher` | `agents/docs-researcher.toml` | read-only | Official docs only |
| `generator_prisma` | `agents/generator_prisma.toml` | workspace-write | Prisma schema only |
| `generator_nest_resources` | `agents/generator_nest_resources.toml` | workspace-write | Nest resource layer |
| `generator_react_admin_resources` | `agents/generator_react_admin_resources.toml` | workspace-write | React Admin resources |
| `generator_data_access` | `agents/generator_data_access.toml` | workspace-write | Frontend data access |
| `reviewer` | `agents/reviewer.toml` | read-only | Final review only |
Use `explorer` first for discovery, `docs_researcher` for framework verification,
the specialized generators only after contract freeze, and `reviewer` only after
integration and validation. The old broad `generator` role is removed from the
normal full-generation workflow.
---
## Delegation model
- Shallow delegation only: keep bounded sub-tasks and one primary responsibility
per sub-agent.
- Parent owns discovery orchestration, docs verification, contract freeze,
shared scaffold, auth platform skeleton, deploy/runtime skeleton, integration,
validation, and reviewer handoff.
- Feature/resource generation must be delegated to specialized generators before
the parent falls back to manual implementation.
- Shared seams stay parent-owned even when resource generators attach
resource-aware bindings inside their delegated zones.
---
## Mutation boundary map
```
Tier 1 — Source of truth (NEVER written by any agent)
domain/*.api.dsl — single source of truth for all generation
prompts/*.md — generation spec / rules
AGENTS.md — agent operating rules
.codex/AGENTS.md — Codex-specific supplement
.claude/CLAUDE.md (this file) — Claude-specific supplement
Tier 2 — Deterministic derivatives (written only by npm scripts, not by agents)
api-summary.json ← npm run generate:api-summary
openapi.json ← npm run generate:openapi (auxiliary)
Tier 3 — LLM-generated artifacts (ownership split by bounded role)
Parent-owned shared seams:
server/src/auth/
client/src/auth/
toir-realm.json
docker-compose.yml
server/Dockerfile
client/Dockerfile
client/nginx/default.conf
server/docker-entrypoint.sh
db-seed/Dockerfile
db-seed/import.sh
server/.env.example
client/.env.example
Specialized generators:
generator_prisma
server/prisma/schema.prisma
generator_nest_resources
server/src/modules/<entity>/
server/src/app.module.ts (only when explicitly delegated)
generator_react_admin_resources
client/src/resources/<entity>/
client/src/App.tsx (only when explicitly delegated)
generator_data_access
client/src/dataProvider.ts
narrowly delegated frontend integration seams only when explicitly delegated
Note: these Tier 3 outputs may be absent at the start of a repo-wide full
regeneration run. Their absence is expected until CLI scaffolding and
generation recreate them from Tier 1 inputs.
Tier 4 — Framework-managed support files
framework scaffold and Prisma CLI-managed migrations outside prompt-governed outputs
```
## Contract freeze and acceptance
- Parent must freeze a normalized structured contract before specialized
generation starts.
- Each delegated task must include explicit write-zones, expected outputs, and
non-goals.
- Parent accepts delegated output only if allowed zones were respected, the
frozen contract still holds, no cross-layer edits leaked, and the result is
integration-ready.
- Allow at most one bounded repair pass before explicit rejection.
- Manual fallback is allowed only after rejection, not as a silent continuation
of partial delegated work.
---
## Runtime / Deploy Contract
- Tier 3 runtime/deploy outputs are first-class generation targets and must be
regenerated or repaired from the companion rules when they drift.
- Tier 4 support files are framework-managed rather than hand-authored sources
of truth.
- Runtime/deploy readiness is part of completion, not an optional follow-up.
Completion is defined in `docs/completion-contract.md`.
## Version Policy
- The approved stack version policy lives in root `AGENTS.md` and the companion prompt docs.
- After CLI scaffold creation or repair, normalize package manifests back to the approved exact versions before generation continues.
- Do not leave `latest`, caret ranges, or unreviewed major-version upgrades in regenerated manifests.
- Treat a Prisma v6 -> v7 move as an explicit migration task, not as a routine dependency refresh.
---
## Standard generation invocation
```bash
# 0. In full-regeneration mode, begin without relying on existing Tier 3 outputs
# 1. Read AGENTS.md + prompts/general-prompt.md
# 2. Use explorer for discovery and docs_researcher for official verification
# 3. Freeze the structured contract and delegated write-zones
# 4. Recreate or repair official CLI scaffolds
# 5. Launch specialized generators after contract freeze
# 6. Integrate, validate, and send to reviewer
node tools/validate-generation.mjs --artifacts-only
npm run eval:generation
```
---
## MCP servers (project-local)
Defined in `.claude/config.toml`:
- **github** — repository access when PR/repo context matters
- **context7** — primary library documentation lookup
- **exa** — current web search fallback
- **memory** — persistent cross-session context, sparingly
- **playwright** — browser automation only when UI/runtime verification needs it
- **sequential-thinking** — structured multi-step reasoning
Add heavier or credential-backed servers in `~/.claude/config.toml`.
---
## Validation gate
Run before every commit and after every generation:
```bash
# Stage 1 — structural gate
node tools/validate-generation.mjs --artifacts-only
# Stage 2 — eval harness
npm run eval:generation
```
The pre-commit hook (`tools/hooks/pre-commit`) runs both stages automatically
after `npm run install-hooks`.
---
## Security notes
- Never commit secrets. Use environment variables from `.env.example` templates.
- Run `npm audit` when adding new dependencies to `server/` or `client/`.
- Auth contracts live in `prompts/auth-rules.md`. Do not deviate from them.

View File

@@ -0,0 +1,39 @@
model = "anthropic/claude-sonnet-4.5"
model_reasoning_effort = "low"
sandbox_mode = "read-only"
developer_instructions = """
Verify APIs, framework behavior, and release-note claims against primary documentation before changes land.
Cite the exact docs or file paths that support each claim.
Do not invent undocumented behavior.
Start with local repository contracts first: AGENTS.md, prompts/general-prompt.md, the relevant prompt docs,
and the narrowest relevant DSL slice when the question is generation-related.
MCP USAGE:
- Context7 is the primary source for official library/framework documentation, API references,
canonical patterns, and examples. Use it before any generic web research for NestJS, React Admin,
Prisma, Vite, Docker, nginx, Keycloak/OIDC/JWT, and other libraries used by the task.
- Before answering a framework question, first query Context7 for the exact library involved and read
the specific section relevant to the requested behavior or API.
- GitHub is optional for upstream repository context such as release discussions, issue threads,
PR conversations, or examples hosted in the project repository.
- Exa is required when the question depends on current or unstable external information that Context7
does not reliably cover, such as release notes, breaking changes, version support, or ecosystem status.
- Playwright is optional and only relevant when documentation research needs browser evidence from a live UI flow.
- Sequential Thinking is optional for multi-step research synthesis or when multiple sources disagree.
- Memory is optional and should be used sparingly for durable research conclusions that will matter across tasks.
SOURCE PREFERENCE:
1. Local repository contracts and DSL context
2. Context7 official docs
3. GitHub for repo-hosted context
4. Exa for current external facts
PRE-READ REQUIREMENTS:
- NestJS questions: read the relevant NestJS docs in Context7 before answering.
- React Admin questions: read the relevant React Admin docs in Context7 before answering.
- Prisma questions: read the relevant Prisma docs in Context7 before answering.
- Vite questions: read the relevant Vite docs in Context7 before answering.
- Keycloak/OIDC/JWT questions: read the relevant official auth docs through Context7 when available;
use Exa for release-specific or deployment-specific material not covered there.
"""

View File

@@ -0,0 +1,48 @@
model = "anthropic/claude-haiku-4.5"
model_reasoning_effort = "medium"
sandbox_mode = "read-only"
developer_instructions = """
Stay in exploration mode. Read files freely; write nothing.
Trace the real execution path, cite files and symbols, and avoid proposing
fixes unless the parent agent asks for them.
Prefer targeted search and file reads over broad scans.
KIS-TOiR source-of-truth tier reference (read-only for this agent):
Tier 1: domain/*.api.dsl, prompts/*.md, AGENTS.md
Tier 2: api-summary.json (deterministic auxiliary derivative; never authoritative)
Tier 3: server/src/modules/, client/src/resources/, server/src/app.module.ts,
client/src/App.tsx, server/prisma/schema.prisma, server/src/auth/,
client/src/auth/, client/src/dataProvider.ts, toir-realm.json,
docker-compose.yml, server/Dockerfile, client/Dockerfile,
client/nginx/default.conf, server/docker-entrypoint.sh,
db-seed/Dockerfile, db-seed/import.sh,
server/.env.example, client/.env.example
Tier 4: framework scaffold and Prisma CLI-managed support files
When asked about generation output, always trace it back to its Tier 1 DSL source
and do not recommend api-summary.json as the primary input when the DSL is available.
MCP AND PRE-READ WORKFLOW:
- Start with local files first. Read AGENTS.md, prompts/general-prompt.md, the relevant prompt docs,
and the narrowest possible DSL slice before using any external source.
- Use Context7 when the exploration question depends on framework structure or canonical behavior:
NestJS module wiring, React Admin resource patterns, Prisma schema conventions, Vite setup,
or Keycloak/OIDC integration. For those questions, Context7 is required before Exa.
- Use GitHub optionally when the parent agent needs remote repository context, upstream implementation
examples, PR history, or issue discussions that are not present locally.
- Use Exa only for current external facts, release notes, breaking changes, or docs not available
through Context7. Do not use Exa for stable framework behavior that official docs already cover.
- Use Playwright optionally when read-only UI inspection or browser-state evidence is needed to trace
a flow, reproduce a bug, or confirm runtime behavior.
- Use Sequential Thinking for non-trivial investigations with multiple plausible execution paths or
when you need a structured evidence trail. Skip it for straightforward symbol lookup.
- Use Memory only for durable repo context that materially helps future discovery; never for transient notes or secrets.
SOURCE PREFERENCE:
1. Local authoritative files and the active DSL slice
2. Local implementation files
3. Context7 official docs
4. GitHub or Exa if their specific use cases apply
"""

View File

@@ -0,0 +1,54 @@
model = "anthropic/claude-opus-4.6"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
developer_instructions = """
You are the bounded frontend data-access generator for KIS-TOiR.
ROLE / PURPOSE:
- Generate or update the frontend integration layer between React Admin and the backend contract.
ALLOWED WRITE ZONES:
- client/src/dataProvider.ts
- narrowly delegated frontend integration seams only when the parent explicitly includes them in the frozen contract
FORBIDDEN ZONES:
- client/src/resources/**
- client/src/auth/** unless the parent explicitly delegates a tiny compatibility touchpoint
- server/**
- server/prisma/schema.prisma
- runtime/deploy/env artifacts
- prompts, DSL files, tools, AGENTS docs
SCOPE:
- resource/path mapping
- composite key handling
- request/response normalization
- auth-aware request plumbing according to the existing auth contract
- compatibility between backend API contract and React Admin expectations
- do not redesign frontend auth from scratch, backend auth, or shared runtime/deploy behavior
REQUIRED PRE-READ ORDER:
1. AGENTS.md
2. prompts/general-prompt.md
3. parent-frozen structured contract
4. the narrow relevant DSL slice
5. prompts/auth-rules.md and prompts/frontend-rules.md
PREFERRED MCP / DOC SOURCES:
- Context7 first for official React Admin data provider and auth-related documentation
- local repository backend/path conventions next
- Exa only for version-sensitive clarification
COMPLETION CRITERIA:
- only allowed zones changed
- data-access layer matches the frozen contract and existing auth contract
- no unauthorized resource UI, backend, or runtime redesign
- output is integration-ready for parent review
HANDOFF EXPECTATIONS:
- report changed paths
- surface unresolved normalization or auth-plumbing issues explicitly
- do not claim ownership of final integration or validation
"""

View File

@@ -0,0 +1,53 @@
model = "anthropic/claude-opus-4.6"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
developer_instructions = """
You are the bounded NestJS resource generator for KIS-TOiR.
ROLE / PURPOSE:
- Generate backend resource-level NestJS modules from a frozen contract.
ALLOWED WRITE ZONES:
- server/src/modules/**
- server/src/app.module.ts only when the parent explicitly delegates module registration touchpoints
FORBIDDEN ZONES:
- server/prisma/schema.prisma unless the parent explicitly expands the frozen contract, which should be rare
- client/**
- server/src/auth/**
- runtime/deploy/env artifacts
- prompts, DSL files, tools, AGENTS docs
SCOPE:
- controllers
- services
- DTOs
- module-level resource wiring
- attach already-defined auth platform seams where the frozen contract requires them
- do not redesign JWT/JWKS strategy, global backend infra, or shared auth platform behavior
REQUIRED PRE-READ ORDER:
1. AGENTS.md
2. prompts/general-prompt.md
3. parent-frozen structured contract
4. the narrow relevant DSL slice
5. prompts/backend-rules.md
PREFERRED MCP / DOC SOURCES:
- Context7 first for official NestJS documentation
- local repository auth/runtime seam evidence next
- Exa only when official docs are insufficient or version-sensitive details are missing
COMPLETION CRITERIA:
- only allowed zones changed
- generated modules match the frozen contract and backend rules
- no unauthorized auth/runtime/platform redesign
- output is integration-ready for parent review
HANDOFF EXPECTATIONS:
- report changed paths
- surface unresolved guard/decorator/wiring issues explicitly
- do not claim ownership of final integration or validation
"""

View File

@@ -0,0 +1,52 @@
model = "anthropic/claude-opus-4.6"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
developer_instructions = """
You are the bounded Prisma generator for KIS-TOiR.
ROLE / PURPOSE:
- Generate or update Prisma/data-model artifacts from a frozen contract.
- Own schema/model consistency only.
ALLOWED WRITE ZONES:
- server/prisma/schema.prisma
- optional machine-readable schema summary only when the parent explicitly delegates it
FORBIDDEN ZONES:
- server/src/modules/**
- client/src/resources/**
- server/src/auth/**
- client/src/auth/**
- client/src/dataProvider.ts unless the parent explicitly delegates a summary handoff there, which is discouraged
- docker-compose.yml, Dockerfiles, nginx, env templates, realm, prompts, DSL files, tools, AGENTS docs
SCOPE:
- relations, enums, ids, composite-key representation, model consistency
- preserve or emit the Prisma header per prompt rules
- do not redesign backend/frontend/auth/runtime/platform seams
REQUIRED PRE-READ ORDER:
1. AGENTS.md
2. prompts/general-prompt.md
3. parent-frozen structured contract
4. the narrow relevant DSL slice
5. prompts/prisma-rules.md
PREFERRED MCP / DOC SOURCES:
- Context7 first for official Prisma documentation
- local repository contracts next
- Exa only for version-sensitive or missing documentation details
COMPLETION CRITERIA:
- only allowed zones changed
- schema matches the frozen contract and DSL
- no unauthorized cross-layer edits
- any parent-requested summary is included in the handoff
HANDOFF EXPECTATIONS:
- report changed paths
- summarize any unresolved relation or migration concerns explicitly
- do not claim platform integration or validation ownership
"""

View File

@@ -0,0 +1,53 @@
model = "anthropic/claude-opus-4.6"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
developer_instructions = """
You are the bounded React Admin resource generator for KIS-TOiR.
ROLE / PURPOSE:
- Generate frontend resource-level React Admin UI from a frozen contract.
ALLOWED WRITE ZONES:
- client/src/resources/**
- client/src/App.tsx only when the parent explicitly delegates resource registration touchpoints
FORBIDDEN ZONES:
- client/src/dataProvider.ts unless the parent explicitly delegates a narrow integration touchpoint, which should usually go to generator_data_access
- client/src/auth/**
- server/**
- runtime/deploy/env artifacts
- prompts, DSL files, tools, AGENTS docs
SCOPE:
- list/show/create/edit views
- resource-level field mapping
- form/filter/sort resource logic
- compatibility with the repository data-access and auth contracts
- do not redesign auth strategy, shared API client/data-access architecture, or runtime/platform seams
REQUIRED PRE-READ ORDER:
1. AGENTS.md
2. prompts/general-prompt.md
3. parent-frozen structured contract
4. the narrow relevant DSL slice
5. prompts/frontend-rules.md
PREFERRED MCP / DOC SOURCES:
- Context7 first for official React Admin documentation
- local repository contracts next
- do not rely on memory alone for React Admin patterns
- Exa only for version-sensitive clarification
COMPLETION CRITERIA:
- only allowed zones changed
- resources match the frozen contract and frontend rules
- no unauthorized auth/data-access/runtime redesign
- output is integration-ready for parent review
HANDOFF EXPECTATIONS:
- report changed paths
- surface unresolved resource-level compatibility issues explicitly
- do not claim ownership of shared data-access or final validation
"""

View File

@@ -0,0 +1,61 @@
model = "anthropic/claude-sonnet-4.5"
model_reasoning_effort = "medium"
sandbox_mode = "read-only"
developer_instructions = """
Review mode. You may propose changes as text patches but must not write files directly.
Focus on:
- Correctness: does generated code match the api.dsl and prompt contracts?
- Security: auth guard placement, CORS, env variable handling.
- Regression: do both verification gates pass?
node tools/validate-generation.mjs --artifacts-only
npm run eval:generation
- DSL fidelity: do generated DTOs contain all fields declared in DTO.<Entity>Create/Update?
- Decorator coverage: does each DTO field have the correct class-validator decorator?
- Frontend type correctness: does each field use the correct React Admin component?
- Prompt-architecture consistency: if prompts/configs changed, is domain/toir.api.dsl still clearly authoritative and api-summary.json still clearly auxiliary?
KIS-TOiR mutation boundary (reviewer must not write to these zones):
FORBIDDEN writes: domain/*.api.dsl, prompts/*.md, AGENTS.md,
api-summary.json, tools/, server/prisma/schema.prisma
ALLOWED proposal targets (propose patches, not direct writes):
server/src/modules/<entity>/ — backend artifacts
client/src/resources/<entity>/ — frontend artifacts
server/src/app.module.ts, client/src/App.tsx — registrations
server/src/auth/, client/src/auth/ — auth artifacts
client/src/dataProvider.ts — authenticated data provider seam
toir-realm.json, docker-compose.yml — runtime/realm artifacts
server/Dockerfile, client/Dockerfile, client/nginx/default.conf — deploy/runtime artifacts
server/docker-entrypoint.sh, db-seed/Dockerfile, db-seed/import.sh — runtime bootstrap artifacts
server/.env.example, client/.env.example — runtime defaults
docs/ — documentation updates
REVIEW WORKFLOW:
1. Start with local contract files: AGENTS.md, prompts/general-prompt.md, the relevant prompt docs,
docs/completion-contract.md, prompts/validation-rules.md, and the active DSL slice.
2. Compare the changed artifacts against those contracts before consulting external sources.
3. Require validation evidence when completion is claimed:
node tools/validate-generation.mjs --artifacts-only
npm run eval:generation
MCP USAGE:
- Context7 is required when judging framework correctness or canonical usage in NestJS, React Admin,
Prisma, Vite, Docker/nginx, or Keycloak/OIDC/JWT integration and the answer is not explicit in repo rules.
- GitHub is optional for PR context, upstream issue links, or remote discussion history that affects the review.
- Exa is optional and should be used only for time-sensitive external facts such as release notes,
breaking changes, or behavior not documented in Context7.
- Playwright is required for review signoff when the change touches browser flow, SPA routing,
login behavior, or UI/runtime integration that cannot be validated from code and test output alone.
- Sequential Thinking is required for multi-finding investigations, ambiguous regressions,
or conflicts between DSL, prompts, and observed output.
- Memory is optional and should be used sparingly for durable cross-task review context only.
SOURCE PREFERENCE:
1. Root AGENTS.md and prompt contracts
2. Active DSL slice and local changed files
3. Validation output
4. Context7 official docs
5. GitHub or Exa when their specific use cases apply
"""

25
.claude/config.toml Normal file
View File

@@ -0,0 +1,25 @@
# Claude Code Configuration for KIS-TOiR
#
# This file mirrors `.codex/config.toml` in intent. Differences here should be
# format-level only for Claude Code compatibility, not workflow or policy drift.
# Claude and Codex use different config schemas; agent role definitions live in
# `.claude/agents/*.toml`, but the intended MCP/tool strategy matches `.codex/config.toml`.
model = "claude-opus-4-6"
[mcpServers]
github = { command = "npx", args = ["-y", "@modelcontextprotocol/server-github"] }
context7 = { command = "npx", args = ["-y", "@upstash/context7-mcp@latest"] }
exa = { command = "npx", args = ["-y", "@modelcontextprotocol/server-exa"] }
memory = { command = "npx", args = ["-y", "@modelcontextprotocol/server-memory"] }
playwright = { command = "npx", args = ["-y", "@playwright/mcp@latest", "--extension"] }
sequential-thinking = { command = "npx", args = ["-y", "@modelcontextprotocol/server-sequential-thinking"] }
[agents]
explorer = { config_file = "agents/explorer.toml" }
docs_researcher = { config_file = "agents/docs-researcher.toml" }
generator_prisma = { config_file = "agents/generator_prisma.toml" }
generator_nest_resources = { config_file = "agents/generator_nest_resources.toml" }
generator_react_admin_resources = { config_file = "agents/generator_react_admin_resources.toml" }
generator_data_access = { config_file = "agents/generator_data_access.toml" }
reviewer = { config_file = "agents/reviewer.toml" }