Initial version

This commit is contained in:
Flatlogic Bot 2025-08-29 15:43:52 +00:00
commit 06ac787db9
5 changed files with 233 additions and 0 deletions

3
.gemini/settings.json Normal file
View File

@ -0,0 +1,3 @@
{
"contextFileName": ["GEMINI.md"]
}

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
*/node_modules/
*/build/

3
.htaccess Normal file
View File

@ -0,0 +1,3 @@
DirectoryIndex index.php index.html
Options -Indexes

155
GEMINI.md Normal file
View File

@ -0,0 +1,155 @@
Heres a drop-in **`gemini.md`** for the LAMP golden machine. Put it in the project root (i.e., `WORKSPACE_ROOT`, which is also the Apache DocumentRoot). It speaks directly to Gemini CLI and sets guardrails for edits + chat output.
```markdown
# Gemini — Working Instructions (Flatlogic LAMP VM)
You are **Gemini CLI** running inside a **Flatlogic Dev VM** on the **LAMP golden image**.
Your job is to **edit files in-place** under the current working directory and keep the app running and browsable.
---
## Where you are (facts)
- **CWD / Project root:** this folder (the Flatlogic `WORKSPACE_ROOT`).
- It is also the **Apache DocumentRoot**.
- `index.php` lives here and is served as `/`.
- **Stack:** Apache 2.4+ and PHP 8.x (classic LAMP). No framework by default.
- **Network:** The VM exposes HTTP(S) via a **Cloudflare Tunnel**. Locally its served on `http://localhost:80`.
- **Privileges:** You are a regular user. Do **not** attempt system package changes or service reconfiguration.
- **VCS:** A Git repo may be present. You can modify tracked files; commits/pushes are triggered by platform commands (not by you directly).
---
## What to do (capabilities & constraints)
- **Edit files directly** in this folder tree. Prefer small, safe changes.
- **Stay within the project root.** Do not write outside this directory.
- **Do not change Apache/system configs** or assume root access.
- **Keep the app immediately browsable.** After changes, `/` must still load without PHP errors.
- **No database is guaranteed.** If you need persistence, propose **file-based** storage first. If MySQL is explicitly requested later, ask for credentials.
- **Composer/frameworks:** Avoid adding unless asked. Stick to vanilla PHP unless requirements say otherwise.
---
## How Flatlogic Chat sees you
- Your **stdout/stderr is streamed** to a human via Flatlogic Cloud.
- Keep output **concise and actionable**:
1. Start with a one-line **Plan**.
2. Perform changes (write files).
3. Print a **Summary** of what changed.
4. End with **Next** (a yes/no or options).
- If an operation fails, print a short **Error** line and what youll try next.
**Output template (guideline):**
```
Plan: <12 short bullets>
Changed:
* <path>: <very short description>
* <path>: <very short description>
Notes:
* <any caveat or test instruction>
Next: <question or options>
```
> You generally do **not** need to print full file contents. When useful, show **small excerpts only**.
---
## File editing rules (PHP)
- **index.php must keep working.** If you introduce new includes, ensure relative paths exist.
- **Security:** never echo raw user input; use `htmlspecialchars` for HTML contexts.
- **Health endpoint:** ensure `/healthz` returns `ok` with HTTP 200 (lightweight, no PHP warnings).
- Implement as `healthz.php` or route via `index.php`—your choice, but keep it simple.
- **Configuration:** if you create config, use a single `config.php` loaded by `index.php`.
- **Error handling:** avoid `display_errors` changes. Use defensive checks and small try/catch blocks.
---
## Testing after changes
- Print a quick checklist the human can run:
- “Open `/`—should show …”
- “Open `/healthz`—should return ok
- Mention any new endpoints you add.
---
## Git & deploy (how your work is shipped)
- The platform will run `git pull`, `git commit_push`, and `server.restart` when appropriate.
- **You dont run git here.** Just make sure your changes are saved to disk.
**Commit message convention** (for your summaries so humans can reuse):
- `feat: ...` user-visible features
- `fix: ...` bug fix
- `chore: ...` small housekeeping
- `docs: ...` text-only updates
---
## Do not do
- Dont install system packages or restart Apache yourself.
- Dont write outside the project root.
- Dont introduce heavy dependencies without asking.
- Dont leak secrets or create random credentials.
---
## Small starter tasks you can do safely
1) **Add a health check**
- Create `healthz.php` with plain `ok`.
- Optionally link from `index.php` footer for quick access.
2) **Improve the landing page**
- In `index.php`, add a minimal header/footer, and a quick environment box:
- PHP version, current time, and a link to `/healthz`.
3) **Basic contact form (no DB)**
- Add `contact.php` with a POST form and server-side validation.
- On submit, write a sanitized line to `data/contact.log` (create folder if missing).
(Only perform these if asked; otherwise wait for explicit prompts.)
---
## Example: Health check (what good output looks like)
```
Plan: add /healthz endpoint and link it from index.php
Changed:
* healthz.php: returns 'ok' with HTTP 200
* index.php: footer link to /healthz
Notes:
* Tested locally via PHP include; endpoint is static and safe.
Next: Proceed to add a minimal env box on the homepage?
```
---
## Telemetry note
- Your token usage and latencies are measured. Keep prompts/responses compact.
- Prefer **editing files** over dumping large code blocks into chat.
---
**Thats it.** Operate inside this folder, keep `/` working, and narrate succinctly in Flatlogic Chat.
```

69
index.php Normal file
View File

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$server = $_SERVER['SERVER_SOFTWARE'] ?? 'Apache';
$root = realpath(__DIR__) ?: __DIR__;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>LAMP Workspace</title>
<style>
:root { color-scheme: light dark; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
header { background:#111; color:#fff; padding:16px 24px; }
main { max-width: 880px; margin: 32px auto; padding: 0 16px; }
h1 { margin: 0 0 8px; font-size: 22px; }
h2 { margin-top: 28px; font-size: 18px; }
p { margin: 8px 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: #0b1020; color: #cfe7ff; padding: 12px; border-radius: 8px; overflow:auto; }
.grid { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { border:1px solid #ddd; border-radius:8px; padding:12px; }
.muted { color:#666; }
.kv { display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px dashed #e3e3e3; }
.kv:last-child { border-bottom:0; }
footer { color:#777; margin: 28px 0 40px; text-align:center; font-size: 13px; }
</style>
</head>
<body>
<header>
<h1>LAMP stack is ready</h1>
</header>
<main>
<section class="grid">
<div class="card">
<h2>Stack</h2>
<div class="kv"><span>Web server</span><code><?= htmlspecialchars($server) ?></code></div>
<div class="kv"><span>PHP</span><code><?= htmlspecialchars($phpVersion) ?></code></div>
</div>
<div class="card">
<h2>Tips</h2>
<p> Put your app files into this folder.</p>
<p> <code>.htaccess</code> is enabled; <code>index.php</code> has priority.</p>
<p> Errors are shown for development (disable in production).</p>
</div>
</section>
<section>
<h2>Try ideas</h2>
<p class="muted">You can ask the assistant to generate or modify code. Example requests:</p>
<pre><code>"Create a simple landing page with a hero section and a contact form."
"Build an engineering calculator (e.g., beam deflection or resistor color code)."
"Refactor the current PHP file for better readability and error handling."
"Scan the project and list potential security issues in configuration."
"Add basic routing and a simple controller to serve multiple pages."</code></pre>
</section>
<footer>Updated at <?= htmlspecialchars($now) ?> (UTC)</footer>
</main>
</body>
</html>