Skip to content

Commit d0a5ad7

Browse files
committed
feat: add ai setup for lite apps
1 parent 825ba97 commit d0a5ad7

3 files changed

Lines changed: 114 additions & 0 deletions

File tree

src/themes/leaf3/.leaf/CONTEXT.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!-- leaf.context v1 -->
2+
3+
# Project Context
4+
5+
This file is the shared memory for this project. Every AI assistant working here — Claude, Codex, Cursor, or anything else — reads it before making changes and writes useful knowledge back when finished. Treat it as the source of truth for goals, decisions, and conventions.
6+
7+
---
8+
9+
## Working With This File
10+
11+
Read this file before performing any task, together with the project's code and the generated Leaf context. Do not ignore the decisions documented here unless the user explicitly overrides them. When uncertain, prefer preserving existing patterns over introducing new ones.
12+
13+
Format rules, so every agent's edits stay compatible:
14+
15+
1. The first line of this file is its format marker. Never remove or edit it.
16+
2. Sections are `##` headings. Keep them in their current order. Preserve sections you don't recognize — another agent may own them. You may add project-specific sections at the end.
17+
3. A line wrapped in underscores is a placeholder. If it contains `agent:`, it is an instruction to you: act on it, then replace the line with real content (or delete it if it no longer applies).
18+
4. Keep entries to a single line each where possible, so edits from different agents merge cleanly.
19+
5. Never store secrets, keys, or tokens here. Refer to `.env` keys by name only.
20+
6. Do not duplicate mechanical information (routes, models, structure, modules). That lives in the code and in `leaf context`. This file holds only what the code cannot say: goals, decisions, and the reasoning behind them.
21+
22+
When your work is complete:
23+
24+
1. Add a line to Recent Changes: `* YYYY-MM-DD — what changed (key files)`. Newest first, five entries maximum; fold older entries into Known Decisions or delete them.
25+
2. If the Current Goal is done, note it in Recent Changes and replace the goal. If you don't know the next goal, ask the user. Exactly one current goal at a time.
26+
3. Record lasting choices in Known Decisions as `* Decision — reasoning.` A decision without its why gets relitigated by the next agent.
27+
4. Keep this file concise. Summarize instead of appending indefinitely, remove outdated information, and prefer references to files over copying their contents.
28+
29+
---
30+
31+
## Project Summary
32+
33+
An empty Leaf app: a single `index.php` holding routes and logic, growing only when the product asks for it.
34+
35+
The project focuses on simplicity, maintainability, and AI-assisted development.
36+
37+
---
38+
39+
## Current Goal
40+
41+
_agent: ask the user what this app is for, then replace this line with the goal. This section always describes the one thing the team is actively working on._
42+
43+
---
44+
45+
## Architecture
46+
47+
### General
48+
49+
* Simplicity is preferred over cleverness.
50+
* Explicit code is preferred over magic.
51+
* Features should remain easy for humans and AI to understand.
52+
53+
### Structure
54+
55+
* `index.php` is the whole app: routes, handlers, and wiring live there until it earns more structure.
56+
* Handlers return responses: `fn () => response()->json([...])` for single expressions, `return response()->...` otherwise.
57+
* Add capability through modules (`leaf install db`, `auth`, ...) instead of hand-rolling infrastructure.
58+
* When the app outgrows one file, `leaf up` scales it into MVC structure — don't hand-build `app/` folders here.
59+
60+
---
61+
62+
## External Providers
63+
64+
_agent: when the user adopts a provider, replace this line with a yaml block mapping one provider per concern, for example `billing: stripe`, `email: resend-smtp`, `storage: local`._
65+
66+
---
67+
68+
## Coding Conventions
69+
70+
* Keep routes small and readable.
71+
* Reuse existing abstractions before introducing new ones.
72+
* Follow existing naming patterns.
73+
74+
---
75+
76+
## Recent Changes
77+
78+
* _agent: no changes yet. Track them here as `* YYYY-MM-DD — what changed (key files)`, newest first, five maximum._
79+
80+
---
81+
82+
## Known Decisions
83+
84+
* This is a lite Leaf app — one `index.php`, deliberately unstructured until the product demands more.
85+
86+
---
87+
88+
## Future Ideas
89+
90+
* _agent: record ideas the user mentions but isn't building yet._

src/themes/leaf3/AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Agent Instructions
2+
3+
Before performing any task:
4+
5+
1. Read `.leaf/CONTEXT.md` for project goals and architectural decisions.
6+
2. Use Leaf documentation:
7+
8+
- https://leafphp.dev/ai/SKILL.md
9+
- https://leafphp.dev/llms.txt
10+
11+
3. Inspect the codebase and use `leaf context` when you need a concise map of the application's structure.
12+
13+
4. When your work is complete, update `.leaf/CONTEXT.md`.

tests/commands.test.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,14 @@
100100
// pre-release pin here breaks `leaf create --lite` for everyone
101101
expect($theme['require']['leafs/leaf'])->toStartWith('^');
102102
});
103+
104+
test('lite apps are born AI-ready', function () {
105+
leaf('create my-app --lite');
106+
107+
// composer install fails against the shim, but the theme copy happens
108+
// first — the AI context files must be in place
109+
expect(file_exists(getcwd() . '/my-app/AGENTS.md'))->toBeTrue()
110+
->and(file_exists(getcwd() . '/my-app/.leaf/CONTEXT.md'))->toBeTrue()
111+
->and(file_get_contents(getcwd() . '/my-app/.leaf/CONTEXT.md'))->toContain('<!-- leaf.context v1 -->')
112+
->and(file_exists(getcwd() . '/my-app/.htaccess'))->toBeTrue();
113+
});

0 commit comments

Comments
 (0)