# Implementation Plan - GreetingApp Feature

## Revision History
| Version | Date | Description | Author |
|---|---|---|---|
| v1.0 | 2026-06-22 | Initial implementation plan for GreetingApp | Antigravity Orchestrator |

---

## 1. Objectives
Implement the GreetingApp feature within the `main-awf` workspace, integrating:
- A shared Greeting Engine at `core/GreetingEngine`.
- CLI Interface command `awkit greet` in `bin/awk.js`.
- REST API endpoint `GET /api/greet` in `symphony/app/api/greet/route.js`.
- Light history logging via JSON Lines at `~/.gemini/antigravity/greeting_history.jsonl` (and local project fallback).

---

## 2. Proposed Changes

### Phase A: Core Engine and Locales
#### 1. Locales Definition
Create locales JSON files under `core/GreetingEngine/locales/`:
- `en.json`: English templates.
- `vi.json`: Vietnamese templates.
- `ja.json`: Japanese templates.

#### 2. Greeting Engine (`core/GreetingEngine/index.js`)
Create the core processor. It will:
- Parse `name` (default: "Guest"), `lang` (default: "en"), and `timezone` (default: local).
- Determine time-of-day period (`morning` 5-11:59, `afternoon` 12-17:59, `evening` 18-21:59, `night` 22-4:59).
- Load localization strings, format the template by replacing `{name}`, and return the object.
- Record transactions to `greeting_history.jsonl`.
- Provide stats functions.

### Phase B: CLI Integration
#### 1. CLI Commands (`bin/awk.js`)
- Register the `greet` subcommand in the main switch-case.
- Parse flags: `--name` / `-n`, `--lang` / `-l`, and `--timezone` / `-t` (or use system timezone).
- Print the generated greeting and save to the history log.

### Phase C: REST API Integration
#### 1. API Route Handler (`symphony/app/api/greet/route.js`)
- Define `GET` handler.
- Extract `name`, `lang`, and `timezone` query parameters.
- Call the Greeting Engine.
- Return structured JSON response following spec.

---

## 3. Verification Plan

### Automated/Unit Tests
- Verify engine resolves times and timezones correctly.
- Verify fallback to `en` on unrecognized language inputs.
- Verify JSON structure matches specifications.

### Manual Verification
- Execute `node bin/awk.js greet --name="Alice" --lang="vi"`.
- Execute `node bin/awk.js greet --name="Bob" --lang="ja"`.
- Query Symphony REST API `/api/greet?name=Charlie&lang=en` locally.
- Inspect the history log at the designated path.
