70 changed files with 4180 additions and 439 deletions
@ -0,0 +1,75 @@ |
|||
# Architecture Rules Directory |
|||
|
|||
**Author**: Matthew Raymer |
|||
**Date**: 2025-08-20 |
|||
**Status**: 🎯 **ACTIVE** - Architecture protection guidelines |
|||
|
|||
## Overview |
|||
|
|||
This directory contains MDC (Model Directive Configuration) rules that protect |
|||
critical architectural components of the TimeSafari project. These rules ensure |
|||
that changes to system architecture follow proper review, testing, and |
|||
documentation procedures. |
|||
|
|||
## Available Rules |
|||
|
|||
### Build Architecture Guard (`build_architecture_guard.mdc`) |
|||
|
|||
Protects the multi-platform build system including: |
|||
|
|||
- Vite configuration files |
|||
- Build scripts and automation |
|||
- Platform-specific configurations (iOS, Android, Electron, Web) |
|||
- Docker and deployment infrastructure |
|||
- CI/CD pipeline components |
|||
|
|||
**When to use**: Any time you're modifying build scripts, configuration files, |
|||
or deployment processes. |
|||
|
|||
**Authorization levels**: |
|||
|
|||
- **Level 1**: Minor changes (review required) |
|||
- **Level 2**: Moderate changes (testing required) |
|||
- **Level 3**: Major changes (ADR required) |
|||
|
|||
## Usage Guidelines |
|||
|
|||
### For Developers |
|||
|
|||
1. **Check the rule**: Before making architectural changes, review the relevant |
|||
rule |
|||
2. **Follow the process**: Use the appropriate authorization level |
|||
3. **Complete validation**: Run through the required checklist |
|||
4. **Update documentation**: Keep BUILDING.md and related docs current |
|||
|
|||
### For Reviewers |
|||
|
|||
1. **Verify authorization**: Ensure changes match the required level |
|||
2. **Check testing**: Confirm appropriate testing has been completed |
|||
3. **Validate documentation**: Ensure BUILDING.md reflects changes |
|||
4. **Assess risk**: Consider impact on other platforms and systems |
|||
|
|||
## Integration with Other Rules |
|||
|
|||
- **Version Control**: Works with `workflow/version_control.mdc` |
|||
- **Research & Diagnostic**: Supports `research_diagnostic.mdc` for |
|||
investigations |
|||
- **Software Development**: Aligns with development best practices |
|||
- **Markdown Automation**: Integrates with `docs/markdown-automation.mdc` for |
|||
consistent documentation formatting |
|||
|
|||
## Emergency Procedures |
|||
|
|||
If architectural changes cause system failures: |
|||
|
|||
1. **Immediate rollback** to last known working state |
|||
2. **Document the failure** with full error details |
|||
3. **Investigate root cause** using diagnostic workflows |
|||
4. **Update procedures** to prevent future failures |
|||
|
|||
--- |
|||
|
|||
**Status**: Active architecture protection |
|||
**Priority**: Critical |
|||
**Maintainer**: Development team |
|||
**Next Review**: 2025-09-20 |
@ -0,0 +1,373 @@ |
|||
--- |
|||
description: Guards against unauthorized changes to the TimeSafari building |
|||
architecture |
|||
alwaysApply: false |
|||
--- |
|||
|
|||
# Build Architecture Guard Directive |
|||
|
|||
**Author**: Matthew Raymer |
|||
**Date**: 2025-08-22 |
|||
**Status**: 🎯 **ACTIVE** - Build system protection guidelines |
|||
|
|||
## Purpose |
|||
|
|||
Protect the TimeSafari building architecture from unauthorized changes that |
|||
could break the multi-platform build pipeline, deployment processes, or |
|||
development workflow. This directive ensures all build system modifications |
|||
follow proper review, testing, and documentation procedures. |
|||
|
|||
**Note**: Recent Android build system enhancements (2025-08-22) include sophisticated asset validation, platform-specific API routing, and automatic resource regeneration. These features require enhanced testing and validation procedures. |
|||
|
|||
## Protected Architecture Components |
|||
|
|||
### Core Build Infrastructure |
|||
|
|||
- **Vite Configuration Files**: `vite.config.*.mts` files |
|||
- **Build Scripts**: All scripts in `scripts/` directory |
|||
- **Package Scripts**: `package.json` build-related scripts |
|||
- **Platform Configs**: `capacitor.config.ts`, `electron/`, `android/`, |
|||
`ios/` |
|||
- **Docker Configuration**: `Dockerfile`, `docker-compose.yml` |
|||
- **Environment Files**: `.env.*`, `.nvmrc`, `.node-version` |
|||
|
|||
### Android-Specific Build Validation |
|||
|
|||
- **Asset Validation Scripts**: `validate_android_assets()` function and resource checking |
|||
- **Resource Generation**: `capacitor-assets` integration and verification |
|||
- **Platform-Specific IP Handling**: Android emulator vs physical device API routing |
|||
- **Build Mode Validation**: Development/test/production mode handling |
|||
- **Resource Fallback Logic**: Automatic regeneration of missing Android resources |
|||
|
|||
### Critical Build Dependencies |
|||
|
|||
- **Build Tools**: Vite, Capacitor, Electron, Android SDK, Xcode |
|||
- **Asset Management**: `capacitor-assets.config.json`, asset scripts |
|||
- **Testing Infrastructure**: Playwright, Jest, mobile test scripts |
|||
- **CI/CD Pipeline**: GitHub Actions, build validation scripts |
|||
- **Service Worker Assembly**: `sw_scripts/`, `sw_combine.js`, WASM copy steps |
|||
|
|||
## Change Authorization Requirements |
|||
|
|||
### Level 1: Minor Changes (Requires Review) |
|||
|
|||
- Documentation updates to `BUILDING.md` |
|||
- Non-breaking script improvements |
|||
- Test additions or improvements |
|||
- Asset configuration updates |
|||
|
|||
**Process**: Code review + basic testing |
|||
|
|||
### Level 2: Moderate Changes (Requires Testing) |
|||
|
|||
- New build script additions |
|||
- Environment variable changes |
|||
- Dependency version updates |
|||
- Platform-specific optimizations |
|||
- **Build script argument parsing**: New flag handling (--api-ip, --auto-run, --deploy) |
|||
- **Platform-specific environment overrides**: Android API server IP customization |
|||
- **Asset regeneration logic**: Automatic fallback for missing Android resources |
|||
|
|||
**Process**: Code review + platform testing + documentation update |
|||
|
|||
### Level 3: Major Changes (Requires ADR) |
|||
|
|||
- Build system architecture changes |
|||
- New platform support |
|||
- Breaking changes to build scripts |
|||
- Major dependency migrations |
|||
|
|||
**Process**: ADR creation + comprehensive testing + team review |
|||
|
|||
## Prohibited Actions |
|||
|
|||
### ❌ Never Allow Without ADR |
|||
|
|||
- **Delete or rename** core build scripts |
|||
- **Modify** `package.json` build script names |
|||
- **Change** Vite configuration structure |
|||
- **Remove** platform-specific build targets |
|||
- **Alter** Docker build process |
|||
- **Modify** CI/CD pipeline without testing |
|||
|
|||
### ❌ Never Allow Without Testing |
|||
|
|||
- **Update** build dependencies |
|||
- **Change** environment configurations |
|||
- **Modify** asset generation scripts |
|||
- **Alter** test infrastructure |
|||
- **Update** platform SDK versions |
|||
|
|||
## Required Validation Checklist |
|||
|
|||
### Before Any Build System Change |
|||
|
|||
- [ ] **Impact Assessment**: Which platforms are affected? |
|||
- [ ] **Testing Plan**: How will this be tested across platforms? |
|||
- [ ] **Rollback Plan**: How can this be reverted if it breaks? |
|||
- [ ] **Documentation**: Will `BUILDING.md` need updates? |
|||
- [ ] **Dependencies**: Are all required tools available? |
|||
|
|||
### After Build System Change |
|||
|
|||
- [ ] **Web Platform**: Does `npm run build:web:dev` work? |
|||
- [ ] **Mobile Platforms**: Do iOS/Android builds succeed? |
|||
- [ ] **Desktop Platform**: Does Electron build and run? |
|||
- [ ] **Tests Pass**: Do all build-related tests pass? |
|||
- [ ] **Documentation Updated**: Is `BUILDING.md` current? |
|||
|
|||
## Specific Test Commands (Minimum Required) |
|||
|
|||
### Web Platform |
|||
|
|||
- **Development**: `npm run build:web:dev` - serve and load app |
|||
- **Production**: `npm run build:web:prod` - verify SW and WASM present |
|||
|
|||
### Mobile Platforms |
|||
|
|||
- **Android**: `npm run build:android:test` or `:prod` - confirm assets copied |
|||
- **iOS**: `npm run build:ios:test` or `:prod` - verify build succeeds |
|||
|
|||
### Android Platform (Enhanced) |
|||
- **Development Mode**: `npm run build:android --dev` - verify 10.0.2.2 API routing |
|||
- **Custom IP Mode**: `npm run build:android --dev --api-ip 192.168.1.100` - verify custom IP |
|||
- **Asset Validation**: `npm run build:android --assets` - verify resource generation |
|||
- **Deploy Mode**: `npm run build:android --deploy` - verify device deployment |
|||
|
|||
### Desktop Platform |
|||
|
|||
- **Electron**: `npm run build:electron:dev` and packaging for target OS |
|||
- **Verify**: Single-instance behavior and app boot |
|||
|
|||
### Auto-run (if affected) |
|||
|
|||
- **Test Mode**: `npm run auto-run:test` and platform variants |
|||
- **Production Mode**: `npm run auto-run:prod` and platform variants |
|||
|
|||
### Clean and Rebuild |
|||
|
|||
- Run relevant `clean:*` scripts and ensure re-build works |
|||
|
|||
## Emergency Procedures |
|||
|
|||
### Build System Broken |
|||
|
|||
1. **Immediate**: Revert to last known working commit |
|||
2. **Investigation**: Create issue with full error details |
|||
3. **Testing**: Verify all platforms work after revert |
|||
4. **Documentation**: Update `BUILDING.md` with failure notes |
|||
|
|||
### Platform-Specific Failure |
|||
|
|||
1. **Isolate**: Identify which platform is affected |
|||
2. **Test Others**: Verify other platforms still work |
|||
3. **Rollback**: Revert platform-specific changes |
|||
4. **Investigation**: Debug in isolated environment |
|||
|
|||
## Integration Points |
|||
|
|||
### With Version Control |
|||
|
|||
- **Branch Protection**: Require reviews for build script changes |
|||
- **Commit Messages**: Must reference ADR for major changes |
|||
- **Testing**: All build changes must pass CI/CD pipeline |
|||
|
|||
### With Documentation |
|||
|
|||
- **BUILDING.md**: Must be updated for any script changes |
|||
- **README.md**: Must reflect new build requirements |
|||
- **CHANGELOG.md**: Must document breaking build changes |
|||
|
|||
### With Testing |
|||
|
|||
- **Pre-commit**: Run basic build validation |
|||
- **CI/CD**: Full platform build testing |
|||
- **Manual Testing**: Human verification of critical paths |
|||
|
|||
## Risk Matrix & Required Validation |
|||
|
|||
### Environment Handling |
|||
|
|||
- **Trigger**: Change to `.env.*` loading / variable names |
|||
- **Validation**: Prove `dev/test/prod` builds; show environment echo in logs |
|||
|
|||
### Script Flow |
|||
|
|||
- **Trigger**: Reorder steps (prebuild → build → package), new flags |
|||
- **Validation**: Dry-run + normal run, show exit codes & timing |
|||
|
|||
### Platform Packaging |
|||
|
|||
- **Trigger**: Electron NSIS/DMG/AppImage, Android/iOS bundle |
|||
- **Validation**: Produce installer/artifact and open it; verify single-instance, |
|||
icons, signing |
|||
|
|||
### Service Worker / WASM |
|||
|
|||
- **Trigger**: `sw_combine.js`, WASM copy path |
|||
- **Validation**: Verify combined SW exists and is injected; page loads offline; |
|||
WASM present |
|||
|
|||
### Docker |
|||
|
|||
- **Trigger**: New base image, build args |
|||
- **Validation**: Build image locally; run container; list produced `/dist` |
|||
|
|||
### Android Asset Management |
|||
- **Trigger**: Changes to `validate_android_assets()` function or resource paths |
|||
- **Validation**: Run `npm run build:android --assets` and verify all mipmap/drawable resources |
|||
- **Risk**: Missing splash screens or app icons causing build failures |
|||
|
|||
### Android API Routing |
|||
- **Trigger**: Changes to Android-specific API server IP logic |
|||
- **Validation**: Test both emulator (10.0.2.2) and custom IP modes |
|||
- **Risk**: API connectivity failures on different device types |
|||
|
|||
### Signing/Notarization |
|||
|
|||
- **Trigger**: Cert path/profiles |
|||
- **Validation**: Show signing logs + verify on target OS |
|||
|
|||
## PR Template (Paste into Description) |
|||
|
|||
- [ ] **Level**: L1 / L2 / L3 + justification |
|||
- [ ] **Files & platforms touched**: |
|||
- [ ] **Risk triggers & mitigations**: |
|||
- [ ] **Commands run (paste logs)**: |
|||
- [ ] **Artifacts (names + sha256)**: |
|||
- [ ] **Docs updated (sections/links)**: |
|||
- [ ] **Rollback steps verified**: |
|||
- [ ] **CI**: Jobs passing and artifacts uploaded |
|||
|
|||
## Rollback Playbook |
|||
|
|||
### Immediate Rollback |
|||
|
|||
1. `git revert` or `git reset --hard <prev>`; restore prior `scripts/` or config |
|||
files |
|||
2. Rebuild affected targets; verify old behavior returns |
|||
3. Post-mortem notes → update this guard and `BUILDING.md` if gaps found |
|||
|
|||
### Rollback Verification |
|||
|
|||
- **Web**: `npm run build:web:dev` and `npm run build:web:prod` |
|||
- **Mobile**: `npm run build:android:test` and `npm run build:ios:test` |
|||
- **Desktop**: `npm run build:electron:dev` and packaging commands |
|||
- **Clean**: Run relevant `clean:*` scripts and verify re-build works |
|||
|
|||
### Android-Specific Rollback Verification |
|||
- **Asset Generation**: `npm run build:android --assets` - verify resources regenerate |
|||
- **API Routing**: Test both `--dev` and `--dev --api-ip <custom>` modes |
|||
- **Resource Validation**: Check `android/app/src/main/res/` for all required assets |
|||
- **Build Modes**: Verify development, test, and production modes all work |
|||
- **Resource Fallback**: Confirm missing resources trigger automatic regeneration |
|||
|
|||
## ADR Trigger List |
|||
|
|||
Raise an ADR when you propose any of: |
|||
|
|||
- **New build stage** or reorder of canonical stages |
|||
- **Replacement of packager** / packaging format |
|||
- **New environment model** or secure secret handling scheme |
|||
- **New service worker assembly** strategy or cache policy |
|||
- **New Docker base** or multi-stage pipeline |
|||
- **Relocation of build outputs** or directory conventions |
|||
- **New Android build modes** or argument parsing logic |
|||
- **Changes to asset validation** or resource generation strategy |
|||
- **Modifications to platform-specific API routing** (Android emulator vs physical) |
|||
- **New Android deployment strategies** or device management |
|||
|
|||
**ADR must include**: motivation, alternatives, risks, validation plan, rollback, |
|||
doc diffs. |
|||
|
|||
## Competence Hooks |
|||
|
|||
### Why This Works |
|||
|
|||
- **Prevents Build Failures**: Catches issues before they reach production |
|||
- **Maintains Consistency**: Ensures all platforms build identically |
|||
- **Reduces Debugging Time**: Prevents build system regressions |
|||
|
|||
### Common Pitfalls |
|||
|
|||
- **Silent Failures**: Changes that work on one platform but break others |
|||
- **Dependency Conflicts**: Updates that create version incompatibilities |
|||
- **Documentation Drift**: Build scripts that don't match documentation |
|||
|
|||
### Next Skill Unlock |
|||
|
|||
- Learn to test build changes across all platforms simultaneously |
|||
|
|||
### Teach-back |
|||
|
|||
- "What three platforms must I test before committing a build script change?" |
|||
|
|||
## Collaboration Hooks |
|||
|
|||
### Team Review Requirements |
|||
|
|||
- **Platform Owners**: iOS, Android, Electron, Web specialists |
|||
- **DevOps**: CI/CD pipeline maintainers |
|||
- **QA**: Testing infrastructure owners |
|||
|
|||
### Discussion Prompts |
|||
|
|||
- "Which platforms will be affected by this build change?" |
|||
- "How can we test this change without breaking existing builds?" |
|||
- "What's our rollback plan if this change fails?" |
|||
|
|||
## Self-Check (Before Allowing Changes) |
|||
|
|||
- [ ] **Authorization Level**: Is this change appropriate for the level? |
|||
- [ ] **Testing Plan**: Is there a comprehensive testing strategy? |
|||
- [ ] **Documentation**: Will BUILDING.md be updated? |
|||
- [ ] **Rollback**: Is there a safe rollback mechanism? |
|||
- [ ] **Team Review**: Have appropriate stakeholders been consulted? |
|||
- [ ] **CI/CD**: Will this pass the build pipeline? |
|||
|
|||
## Continuous Improvement & Feedback |
|||
|
|||
### Feedback Collection |
|||
|
|||
The Build Architecture Guard system includes feedback mechanisms to continuously improve its effectiveness: |
|||
|
|||
- **User Feedback**: Script includes feedback prompts for guard improvements |
|||
- **Pattern Analysis**: Monitor which file patterns trigger false positives/negatives |
|||
- **Documentation Gaps**: Track which changes lack proper documentation |
|||
- **Testing Effectiveness**: Measure how often guard catches actual issues |
|||
|
|||
### Feedback Integration Process |
|||
|
|||
1. **Collect Feedback**: Monitor guard execution logs and user reports |
|||
2. **Analyze Patterns**: Identify common false positives or missed patterns |
|||
3. **Update Rules**: Modify `build_architecture_guard.mdc` based on feedback |
|||
4. **Enhance Script**: Update `build-arch-guard.sh` with new validations |
|||
5. **Test Changes**: Verify guard improvements don't introduce new issues |
|||
6. **Document Updates**: Update guard documentation with new patterns |
|||
|
|||
### Feedback Categories |
|||
|
|||
- **False Positives**: Files flagged as sensitive that shouldn't be |
|||
- **False Negatives**: Sensitive files that weren't caught |
|||
- **Missing Patterns**: New file types that should be protected |
|||
- **Overly Strict**: Patterns that are too restrictive |
|||
- **Documentation Gaps**: Missing guidance for specific change types |
|||
- **Testing Improvements**: Better validation procedures |
|||
|
|||
### Feedback Reporting |
|||
|
|||
When reporting guard issues, include: |
|||
- **File patterns** that triggered false positives/negatives |
|||
- **Build system changes** that weren't properly caught |
|||
- **Documentation gaps** in current guard rules |
|||
- **Testing procedures** that could be improved |
|||
- **User experience** issues with guard enforcement |
|||
|
|||
--- |
|||
|
|||
**Status**: Active build system protection |
|||
**Priority**: Critical |
|||
**Estimated Effort**: Ongoing vigilance |
|||
**Dependencies**: All build system components |
|||
**Stakeholders**: Development team, DevOps, Platform owners |
|||
**Next Review**: 2025-09-22 |
@ -0,0 +1,79 @@ |
|||
--- |
|||
alwaysApply: true |
|||
--- |
|||
|
|||
# Markdown Automation System |
|||
|
|||
**Author**: Matthew Raymer |
|||
**Date**: 2025-08-20 |
|||
**Status**: 🎯 **ACTIVE** - Markdown formatting automation |
|||
|
|||
## Overview |
|||
|
|||
The Markdown Automation System ensures your markdown formatting standards are |
|||
followed **during content generation** by AI agents, not just applied after the |
|||
fact. |
|||
|
|||
## AI-First Approach |
|||
|
|||
### **Primary Method**: AI Agent Compliance |
|||
|
|||
- **AI agents follow markdown rules** while generating content |
|||
- **No post-generation fixes needed** - content is compliant from creation |
|||
- **Consistent formatting** across all generated documentation |
|||
|
|||
### **Secondary Method**: Automated Validation |
|||
|
|||
- **Pre-commit hooks** catch any remaining issues |
|||
- **GitHub Actions** validate formatting before merge |
|||
- **Manual tools** for bulk fixes when needed |
|||
|
|||
## How It Works |
|||
|
|||
### 1. **AI Agent Compliance** (Primary) |
|||
|
|||
- **When**: Every time AI generates markdown content |
|||
- **What**: AI follows markdown rules during generation |
|||
- **Result**: Content is properly formatted from creation |
|||
|
|||
### 2. **Pre-commit Hooks** (Backup) |
|||
|
|||
- **When**: Every time you commit |
|||
- **What**: Catches any remaining formatting issues |
|||
- **Result**: Clean, properly formatted markdown files |
|||
|
|||
### 3. **GitHub Actions** (Pre-merge) |
|||
|
|||
- **When**: Every pull request |
|||
- **What**: Validates markdown formatting across all files |
|||
- **Result**: Blocks merge if formatting issues exist |
|||
|
|||
## AI Agent Rules Integration |
|||
|
|||
The AI agent follows markdown rules defined in `.cursor/rules/docs/markdown.mdc`: |
|||
|
|||
- **alwaysApply: true** - Rules are enforced during generation |
|||
- **Line Length**: AI never generates lines > 80 characters |
|||
- **Blank Lines**: AI adds proper spacing around all elements |
|||
- **Structure**: AI uses established templates and patterns |
|||
|
|||
## Available Commands |
|||
|
|||
### NPM Scripts |
|||
|
|||
- **`npm run markdown:setup`** - Install the automation system |
|||
- **`npm run markdown:fix`** - Fix formatting in all markdown files |
|||
- **`npm run markdown:check`** - Validate formatting without fixing |
|||
|
|||
## Benefits |
|||
|
|||
- **No more manual fixes** - AI generates compliant content from start |
|||
- **Consistent style** - All files follow same standards |
|||
- **Faster development** - No need to fix formatting manually |
|||
|
|||
--- |
|||
|
|||
**Status**: Active automation system |
|||
**Priority**: High |
|||
**Maintainer**: Development team |
|||
**Next Review**: 2025-09-20 |
@ -0,0 +1,206 @@ |
|||
--- |
|||
alwaysApply: true |
|||
inherits: base_context.mdc |
|||
--- |
|||
```json |
|||
{ |
|||
"coaching_level": "standard", |
|||
"socratic_max_questions": 2, |
|||
"verbosity": "concise", |
|||
"timebox_minutes": 10, |
|||
"format_enforcement": "strict" |
|||
} |
|||
``` |
|||
|
|||
# Harbor Pilot — Universal Directive for Human-Facing Technical Guides |
|||
|
|||
**Author**: System/Shared |
|||
**Date**: 2025-08-21 (UTC) |
|||
**Status**: 🚢 ACTIVE — General ruleset extending *Base Context — Human Competence First* |
|||
|
|||
> **Alignment with Base Context** |
|||
> - **Purpose fit**: Prioritizes human competence and collaboration while delivering reproducible artifacts. |
|||
> - **Output Contract**: This directive **adds universal constraints** for any technical topic while **inheriting** the Base Context contract sections. |
|||
> - **Toggles honored**: Uses the same toggle semantics; defaults above can be overridden by the caller. |
|||
|
|||
--- |
|||
|
|||
## Objective |
|||
Produce a **developer-grade, reproducible guide** for any technical topic that onboards a competent practitioner **without meta narration** and **with evidence-backed steps**. |
|||
|
|||
## Scope & Constraints |
|||
- **One Markdown document** as the deliverable. |
|||
- Use **absolute dates** in **UTC** (e.g., `2025-08-21T14:22Z`) — avoid “today/yesterday”. |
|||
- Include at least **one diagram** (Mermaid preferred). Choose the most fitting type: |
|||
- `sequenceDiagram` (protocols/flows), `flowchart`, `stateDiagram`, `gantt` (timelines), or `classDiagram` (schemas). |
|||
- Provide runnable examples where applicable: |
|||
- **APIs**: `curl` + one client library (e.g., `httpx` for Python). |
|||
- **CLIs**: literal command blocks and expected output snippets. |
|||
- **Code**: minimal, self-contained samples (language appropriate). |
|||
- Cite **evidence** for *Works/Doesn’t* items (timestamps, filenames, line numbers, IDs/status codes, or logs). |
|||
- If something is unknown, output `TODO:<missing>` — **never invent**. |
|||
|
|||
## Required Sections (extends Base Output Contract) |
|||
Follow this exact order **after** the Base Contract’s **Objective → Result → Use/Run** headers: |
|||
|
|||
1. **Context & Scope** |
|||
- Problem statement, audience, in/out-of-scope bullets. |
|||
2. **Artifacts & Links** |
|||
- Repos/PRs, design docs, datasets/HARs/pcaps, scripts/tools, dashboards. |
|||
3. **Environment & Preconditions** |
|||
- OS/runtime, versions/build IDs, services/endpoints/URLs, credentials/auth mode (describe acquisition, do not expose secrets). |
|||
4. **Architecture / Process Overview** |
|||
- Short prose + **one diagram** selected from the list above. |
|||
5. **Interfaces & Contracts (choose one)** |
|||
- **API-based**: Endpoint table (*Step, Method, Path/URL, Auth, Key Headers/Params, Sample Req/Resp ref*). |
|||
- **Data/Files**: I/O contract table (*Source, Format, Schema/Columns, Size, Validation rules*). |
|||
- **Systems/Hardware**: Interfaces table (*Port/Bus, Protocol, Voltage/Timing, Constraints*). |
|||
6. **Repro: End-to-End Procedure** |
|||
- Minimal copy-paste steps with code/commands and **expected outputs**. |
|||
7. **What Works (with Evidence)** |
|||
- Each item: **Time (UTC)** • **Artifact/Req IDs** • **Status/Result** • **Where to verify**. |
|||
8. **What Doesn’t (Evidence & Hypotheses)** |
|||
- Each failure: locus (file/endpoint/module), evidence snippet; short hypothesis and **next probe**. |
|||
9. **Risks, Limits, Assumptions** |
|||
- SLOs/limits, rate/size caps, security boundaries (CORS/CSRF/ACLs), retries/backoff/idempotency patterns. |
|||
10. **Next Steps (Owner • Exit Criteria • Target Date)** |
|||
- Actionable, assigned, and time-bound. |
|||
11. **References** |
|||
- Canonical docs, specs, tickets, prior analyses. |
|||
|
|||
> **Competence Hooks (per Base Context; keep lightweight):** |
|||
> - *Why this works* (≤3 bullets) — core invariants or guarantees. |
|||
> - *Common pitfalls* (≤3 bullets) — the traps we saw in evidence. |
|||
> - *Next skill unlock* (1 line) — the next capability to implement/learn. |
|||
> - *Teach-back* (1 line) — prompt the reader to restate the flow/architecture. |
|||
|
|||
> **Collaboration Hooks (per Base Context):** |
|||
> - Name reviewers for **Interfaces & Contracts** and the **diagram**. |
|||
> - Short **sign-off checklist** before merging/publishing the guide. |
|||
|
|||
## Do / Don’t (Base-aligned) |
|||
- **Do** quantify progress only against a defined scope with acceptance criteria. |
|||
- **Do** include minimal sample payloads/headers or I/O schemas; redact sensitive values. |
|||
- **Do** keep commentary lean; if timeboxed, move depth to **Deferred for depth**. |
|||
- **Don’t** use marketing language or meta narration (“Perfect!”, “tool called”, “new chat”). |
|||
- **Don’t** include IDE-specific chatter or internal rules unrelated to the task. |
|||
|
|||
## Validation Checklist (self-check before returning) |
|||
- [ ] All Required Sections present and ordered. |
|||
- [ ] Diagram compiles (basic Mermaid syntax) and fits the problem. |
|||
- [ ] If API-based, **Auth** and **Key Headers/Params** are listed for each endpoint. |
|||
- [ ] Repro section includes commands/code **and expected outputs**. |
|||
- [ ] Every Works/Doesn’t item has **UTC timestamp**, **status/result**, and **verifiable evidence**. |
|||
- [ ] Next Steps include **Owner**, **Exit Criteria**, **Target Date**. |
|||
- [ ] Unknowns are `TODO:<missing>` — no fabrication. |
|||
- [ ] Base **Output Contract** sections satisfied (Objective/Result/Use/Run/Competence/Collaboration/Assumptions/References). |
|||
|
|||
## Universal Template (fill-in) |
|||
```markdown |
|||
# <Title> — Working Notes (As of YYYY-MM-DDTHH:MMZ) |
|||
|
|||
## Objective |
|||
<one line> |
|||
|
|||
## Result |
|||
<link to the produced guide file or say “this document”> |
|||
|
|||
## Use/Run |
|||
<how to apply/test and where to run samples> |
|||
|
|||
## Context & Scope |
|||
- Audience: <role(s)> |
|||
- In scope: <bullets> |
|||
- Out of scope: <bullets> |
|||
|
|||
## Artifacts & Links |
|||
- Repo/PR: <link> |
|||
- Data/Logs: <paths or links> |
|||
- Scripts/Tools: <paths> |
|||
- Dashboards: <links> |
|||
|
|||
## Environment & Preconditions |
|||
- OS/Runtime: <details> |
|||
- Versions/Builds: <list> |
|||
- Services/Endpoints: <list> |
|||
- Auth mode: <Bearer/Session/Keys + how acquired> |
|||
|
|||
## Architecture / Process Overview |
|||
<short prose> |
|||
```mermaid |
|||
<one suitable diagram: sequenceDiagram | flowchart | stateDiagram | gantt | classDiagram> |
|||
``` |
|||
|
|||
## Interfaces & Contracts |
|||
### If API-based |
|||
| Step | Method | Path/URL | Auth | Key Headers/Params | Sample | |
|||
|---|---|---|---|---|---| |
|||
| <…> | <…> | <…> | <…> | <…> | below | |
|||
|
|||
### If Data/Files |
|||
| Source | Format | Schema/Columns | Size | Validation | |
|||
|---|---|---|---|---| |
|||
| <…> | <…> | <…> | <…> | <…> | |
|||
|
|||
### If Systems/Hardware |
|||
| Interface | Protocol | Timing/Voltage | Constraints | Notes | |
|||
|---|---|---|---|---| |
|||
| <…> | <…> | <…> | <…> | <…> | |
|||
|
|||
## Repro: End-to-End Procedure |
|||
```bash |
|||
# commands / curl examples (redacted where necessary) |
|||
``` |
|||
```python |
|||
# minimal client library example (language appropriate) |
|||
``` |
|||
> Expected output: <snippet/checks> |
|||
|
|||
## What Works (Evidence) |
|||
- ✅ <short statement> |
|||
- **Time**: <YYYY-MM-DDTHH:MMZ> |
|||
- **Evidence**: file/line/log or request id/status |
|||
- **Verify at**: <where> |
|||
|
|||
## What Doesn’t (Evidence & Hypotheses) |
|||
- ❌ <short failure> at `<component/endpoint/file>` |
|||
- **Time**: <YYYY-MM-DDTHH:MMZ> |
|||
- **Evidence**: <snippet/id/status> |
|||
- **Hypothesis**: <short> |
|||
- **Next probe**: <short> |
|||
|
|||
## Risks, Limits, Assumptions |
|||
<bullets: limits, security boundaries, retries/backoff, idempotency, SLOs> |
|||
|
|||
## Next Steps |
|||
| Owner | Task | Exit Criteria | Target Date (UTC) | |
|||
|---|---|---|---| |
|||
| <name> | <action> | <measurable outcome> | <YYYY-MM-DD> | |
|||
|
|||
## References |
|||
<links/titles> |
|||
|
|||
## Competence Hooks |
|||
- *Why this works*: <≤3 bullets> |
|||
- *Common pitfalls*: <≤3 bullets> |
|||
- *Next skill unlock*: <1 line> |
|||
- *Teach-back*: <1 line> |
|||
|
|||
## Collaboration Hooks |
|||
- Reviewers: <names/roles> |
|||
- Sign-off checklist: <≤5 checks> |
|||
|
|||
## Assumptions & Limits |
|||
<bullets> |
|||
|
|||
## Deferred for depth |
|||
<park deeper material here to respect timeboxing> |
|||
``` |
|||
|
|||
--- |
|||
|
|||
**Notes for Implementers:** |
|||
- Respect Base *Do-Not* (no filler, no invented facts, no censorship). |
|||
- Prefer clarity over completeness when timeboxed; capture unknowns explicitly. |
|||
- Apply historical comment management rules (see `.cursor/rules/historical_comment_management.mdc`) |
|||
- Apply realistic time estimation rules (see `.cursor/rules/realistic_time_estimation.mdc`) |
@ -0,0 +1,236 @@ |
|||
--- |
|||
description: when comments are generated by the model |
|||
alwaysApply: false |
|||
--- |
|||
# Historical Comment Management — Harbor Pilot Directive |
|||
|
|||
> **Agent role**: When encountering historical comments about removed methods, deprecated patterns, or architectural changes, apply these guidelines to maintain code clarity and developer guidance. |
|||
|
|||
## 🎯 Purpose |
|||
|
|||
Historical comments should either be **removed entirely** or **transformed into actionable guidance** for future developers. Avoid keeping comments that merely state what was removed without explaining why or what to do instead. |
|||
|
|||
## 📋 Decision Framework |
|||
|
|||
### Remove Historical Comments When: |
|||
- **Obsolete Information**: Comment describes functionality that no longer exists |
|||
- **No Action Required**: Comment doesn't help future developers make decisions |
|||
- **Outdated Context**: Comment refers to old patterns that are no longer relevant |
|||
- **Self-Evident**: The current code clearly shows the current approach |
|||
|
|||
### Transform Historical Comments When: |
|||
- **Architectural Context**: The change represents a significant pattern shift |
|||
- **Migration Guidance**: Future developers might need to understand the evolution |
|||
- **Decision Rationale**: The "why" behind the change is still relevant |
|||
- **Alternative Approaches**: The comment can guide future implementation choices |
|||
|
|||
## 🔄 Transformation Patterns |
|||
|
|||
### 1. From Removal Notice to Migration Note |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// turnOffNotifyingFlags method removed - notification state is now managed by NotificationSection component |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: Notification state management has been migrated to NotificationSection component |
|||
// which handles its own lifecycle and persistence via PlatformServiceMixin |
|||
``` |
|||
|
|||
### 2. From Deprecation Notice to Implementation Guide |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// This will be handled by the NewComponent now |
|||
// No need to call oldMethod() as it's no longer needed |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: This functionality has been migrated to NewComponent |
|||
// which provides better separation of concerns and testability |
|||
``` |
|||
|
|||
### 3. From Historical Note to Architectural Context |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// Old approach: used direct database calls |
|||
// New approach: uses service layer |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: Database access has been abstracted through service layer |
|||
// for better testability and platform independence |
|||
``` |
|||
|
|||
## 🚫 Anti-Patterns to Remove |
|||
|
|||
- Comments that only state what was removed |
|||
- Comments that don't explain the current approach |
|||
- Comments that reference non-existent methods |
|||
- Comments that are self-evident from the code |
|||
- Comments that don't help future decision-making |
|||
|
|||
## ✅ Best Practices |
|||
|
|||
### When Keeping Historical Context: |
|||
1. **Explain the "Why"**: Why was the change made? |
|||
2. **Describe the "What"**: What is the current approach? |
|||
3. **Provide Context**: When might this information be useful? |
|||
4. **Use Actionable Language**: Guide future decisions, not just document history |
|||
|
|||
### When Removing Historical Context: |
|||
1. **Verify Obsoleteness**: Ensure the information is truly outdated |
|||
2. **Check for Dependencies**: Ensure no other code references the old approach |
|||
3. **Update Related Docs**: If removing from code, consider adding to documentation |
|||
4. **Preserve in Git History**: The change is preserved in version control |
|||
|
|||
## 🔍 Implementation Checklist |
|||
|
|||
- [ ] Identify historical comments about removed/deprecated functionality |
|||
- [ ] Determine if comment provides actionable guidance |
|||
- [ ] Transform useful comments into migration notes or architectural context |
|||
- [ ] Remove comments that are purely historical without guidance value |
|||
- [ ] Ensure remaining comments explain current approach and rationale |
|||
- [ ] Update related documentation if significant context is removed |
|||
|
|||
## 📚 Examples |
|||
|
|||
### Good Historical Comment (Keep & Transform) |
|||
```typescript |
|||
// Note: Database access has been migrated from direct IndexedDB calls to PlatformServiceMixin |
|||
// This provides better platform abstraction and consistent error handling across web/mobile/desktop |
|||
// When adding new database operations, use this.$getContact(), this.$saveSettings(), etc. |
|||
``` |
|||
|
|||
### Bad Historical Comment (Remove) |
|||
```typescript |
|||
// Old method getContactFromDB() removed - now handled by PlatformServiceMixin |
|||
// No need to call the old method anymore |
|||
``` |
|||
|
|||
## 🎯 Integration with Harbor Pilot |
|||
|
|||
This rule works in conjunction with: |
|||
- **Component Creation Ideals**: Maintains architectural consistency |
|||
- **Migration Patterns**: Documents evolution of patterns |
|||
- **Code Review Guidelines**: Ensures comments provide value |
|||
|
|||
## 📝 Version History |
|||
|
|||
### v1.0.0 (2025-08-21) |
|||
- Initial creation based on notification system cleanup |
|||
- Established decision framework for historical comment management |
|||
- Added transformation patterns and anti-patterns |
|||
- Integrated with existing Harbor Pilot architecture rules |
|||
# Historical Comment Management — Harbor Pilot Directive |
|||
|
|||
> **Agent role**: When encountering historical comments about removed methods, deprecated patterns, or architectural changes, apply these guidelines to maintain code clarity and developer guidance. |
|||
|
|||
## 🎯 Purpose |
|||
|
|||
Historical comments should either be **removed entirely** or **transformed into actionable guidance** for future developers. Avoid keeping comments that merely state what was removed without explaining why or what to do instead. |
|||
|
|||
## 📋 Decision Framework |
|||
|
|||
### Remove Historical Comments When: |
|||
- **Obsolete Information**: Comment describes functionality that no longer exists |
|||
- **No Action Required**: Comment doesn't help future developers make decisions |
|||
- **Outdated Context**: Comment refers to old patterns that are no longer relevant |
|||
- **Self-Evident**: The current code clearly shows the current approach |
|||
|
|||
### Transform Historical Comments When: |
|||
- **Architectural Context**: The change represents a significant pattern shift |
|||
- **Migration Guidance**: Future developers might need to understand the evolution |
|||
- **Decision Rationale**: The "why" behind the change is still relevant |
|||
- **Alternative Approaches**: The comment can guide future implementation choices |
|||
|
|||
## 🔄 Transformation Patterns |
|||
|
|||
### 1. From Removal Notice to Migration Note |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// turnOffNotifyingFlags method removed - notification state is now managed by NotificationSection component |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: Notification state management has been migrated to NotificationSection component |
|||
// which handles its own lifecycle and persistence via PlatformServiceMixin |
|||
``` |
|||
|
|||
### 2. From Deprecation Notice to Implementation Guide |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// This will be handled by the NewComponent now |
|||
// No need to call oldMethod() as it's no longer needed |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: This functionality has been migrated to NewComponent |
|||
// which provides better separation of concerns and testability |
|||
``` |
|||
|
|||
### 3. From Historical Note to Architectural Context |
|||
```typescript |
|||
// ❌ REMOVE THIS |
|||
// Old approach: used direct database calls |
|||
// New approach: uses service layer |
|||
|
|||
// ✅ TRANSFORM TO THIS |
|||
// Note: Database access has been abstracted through service layer |
|||
// for better testability and platform independence |
|||
``` |
|||
|
|||
## 🚫 Anti-Patterns to Remove |
|||
|
|||
- Comments that only state what was removed |
|||
- Comments that don't explain the current approach |
|||
- Comments that reference non-existent methods |
|||
- Comments that are self-evident from the code |
|||
- Comments that don't help future decision-making |
|||
|
|||
## ✅ Best Practices |
|||
|
|||
### When Keeping Historical Context: |
|||
1. **Explain the "Why"**: Why was the change made? |
|||
2. **Describe the "What"**: What is the current approach? |
|||
3. **Provide Context**: When might this information be useful? |
|||
4. **Use Actionable Language**: Guide future decisions, not just document history |
|||
|
|||
### When Removing Historical Context: |
|||
1. **Verify Obsoleteness**: Ensure the information is truly outdated |
|||
2. **Check for Dependencies**: Ensure no other code references the old approach |
|||
3. **Update Related Docs**: If removing from code, consider adding to documentation |
|||
4. **Preserve in Git History**: The change is preserved in version control |
|||
|
|||
## 🔍 Implementation Checklist |
|||
|
|||
- [ ] Identify historical comments about removed/deprecated functionality |
|||
- [ ] Determine if comment provides actionable guidance |
|||
- [ ] Transform useful comments into migration notes or architectural context |
|||
- [ ] Remove comments that are purely historical without guidance value |
|||
- [ ] Ensure remaining comments explain current approach and rationale |
|||
- [ ] Update related documentation if significant context is removed |
|||
|
|||
## 📚 Examples |
|||
|
|||
### Good Historical Comment (Keep & Transform) |
|||
```typescript |
|||
// Note: Database access has been migrated from direct IndexedDB calls to PlatformServiceMixin |
|||
// This provides better platform abstraction and consistent error handling across web/mobile/desktop |
|||
// When adding new database operations, use this.$getContact(), this.$saveSettings(), etc. |
|||
``` |
|||
|
|||
### Bad Historical Comment (Remove) |
|||
```typescript |
|||
// Old method getContactFromDB() removed - now handled by PlatformServiceMixin |
|||
// No need to call the old method anymore |
|||
``` |
|||
|
|||
## 🎯 Integration with Harbor Pilot |
|||
|
|||
This rule works in conjunction with: |
|||
- **Component Creation Ideals**: Maintains architectural consistency |
|||
- **Migration Patterns**: Documents evolution of patterns |
|||
- **Code Review Guidelines**: Ensures comments provide value |
|||
|
|||
## 📝 Version History |
|||
|
|||
### v1.0.0 (2025-08-21) |
|||
- Initial creation based on notification system cleanup |
|||
- Established decision framework for historical comment management |
|||
- Added transformation patterns and anti-patterns |
|||
- Integrated with existing Harbor Pilot architecture rules |
@ -0,0 +1,49 @@ |
|||
--- |
|||
description: Enforce minimalist fixes for bugs/features; future-proofing requires prior discussion and strong evidence. |
|||
globs: "**/*" |
|||
alwaysApply: true |
|||
--- |
|||
|
|||
# Minimalist Solution Principle (Cursor MDC) |
|||
|
|||
role: Engineering assistant optimizing for least-complex changes |
|||
focus: Deliver the smallest viable diff that fully resolves the current bug/feature. Defer generalization unless justified with evidence. |
|||
language: Match repository languages and conventions |
|||
|
|||
## Rules |
|||
1. **Default to the least complex solution.** Fix the problem directly where it occurs; avoid new layers, indirection, or patterns unless strictly necessary. |
|||
2. **Keep scope tight.** Implement only what is needed to satisfy the acceptance criteria and tests for *this* issue. |
|||
3. **Avoid speculative abstractions.** Use the **Rule of Three**: don’t extract helpers/patterns until the third concrete usage proves the shape. |
|||
4. **No drive-by refactors.** Do not rename, reorder, or reformat unrelated code in the same change set. |
|||
5. **Minimize surface area.** Prefer local changes over cross-cutting rewires; avoid new public APIs unless essential. |
|||
6. **Be dependency-frugal.** Do not add packages or services for single, simple needs unless there’s a compelling, documented reason. |
|||
7. **Targeted tests only.** Add the smallest set of tests that prove the fix and guard against regression; don’t rewrite suites. |
|||
8. **Document the “why enough.”** Include a one-paragraph note explaining why this minimal solution is sufficient *now*. |
|||
|
|||
## Future-Proofing Requires Evidence + Discussion |
|||
Any added complexity “for the future” **must** include: |
|||
- A referenced discussion/ADR (or issue link) summarizing the decision. |
|||
- **Substantial evidence**, e.g.: |
|||
- Recurring incidents or tickets that this prevents (list IDs). |
|||
- Benchmarks or profiling showing a real bottleneck. |
|||
- Concrete upcoming requirements with dates/owners, not hypotheticals. |
|||
- Risk assessment comparing maintenance cost vs. expected benefit. |
|||
- A clear trade-off table showing why minimal won’t suffice. |
|||
|
|||
If this evidence is not available, **ship the minimal fix** and open a follow-up discussion item. |
|||
|
|||
## PR / Change Checklist (enforced by reviewer + model) |
|||
- [ ] Smallest diff that fully fixes the issue (attach `git diff --stat` if useful). |
|||
- [ ] No unrelated refactors or formatting. |
|||
- [ ] No new dependencies, or justification + ADR link provided. |
|||
- [ ] Abstractions only if ≥3 call sites or strong evidence says otherwise (cite). |
|||
- [ ] Targeted tests proving the fix/regression guard. |
|||
- [ ] Short “Why this is enough now” note in the PR description. |
|||
- [ ] Optional: “Future Work (non-blocking)” section listing deferred ideas. |
|||
|
|||
## Assistant Output Contract |
|||
When proposing a change, provide: |
|||
1. **Minimal Plan**: 3–6 bullet steps scoped to the immediate fix. |
|||
2. **Patch Sketch**: Focused diffs/snippets touching only necessary files. |
|||
3. **Risk & Rollback**: One paragraph each on risk, quick rollback, and test points. |
|||
4. **(If proposing complexity)**: Link/inline ADR summary + evidence + trade-offs; otherwise default to minimal. |
@ -0,0 +1,348 @@ |
|||
--- |
|||
description: when generating text that has project task work estimates |
|||
alwaysApply: false |
|||
--- |
|||
# No Time Estimates — Harbor Pilot Directive |
|||
|
|||
> **Agent role**: **DO NOT MAKE TIME ESTIMATES**. Instead, use phases, milestones, and complexity levels. Time estimates are consistently wrong and create unrealistic expectations. |
|||
|
|||
## 🎯 Purpose |
|||
|
|||
Development time estimates are consistently wrong and create unrealistic expectations. This rule ensures we focus on phases, milestones, and complexity rather than trying to predict specific timeframes. |
|||
|
|||
## 🚨 Critical Rule |
|||
|
|||
**DO NOT MAKE TIME ESTIMATES** |
|||
- **Never provide specific time estimates** - they are always wrong |
|||
- **Use phases and milestones** instead of days/weeks |
|||
- **Focus on complexity and dependencies** rather than time |
|||
- **Set expectations based on progress, not deadlines** |
|||
|
|||
## 📊 Planning Framework (Not Time Estimates) |
|||
|
|||
### **Complexity Categories** |
|||
- **Simple**: Text changes, styling updates, minor bug fixes |
|||
- **Medium**: New features, refactoring, component updates |
|||
- **Complex**: Architecture changes, integrations, cross-platform work |
|||
- **Unknown**: New technologies, APIs, or approaches |
|||
|
|||
### **Platform Complexity** |
|||
- **Single platform**: Web-only or mobile-only changes |
|||
- **Two platforms**: Web + mobile or web + desktop |
|||
- **Three platforms**: Web + mobile + desktop |
|||
- **Cross-platform consistency**: Ensuring behavior matches across all platforms |
|||
|
|||
### **Testing Complexity** |
|||
- **Basic**: Unit tests for new functionality |
|||
- **Comprehensive**: Integration tests, cross-platform testing |
|||
- **User acceptance**: User testing, feedback integration |
|||
|
|||
## 🔍 Planning Process (No Time Estimates) |
|||
|
|||
### **Step 1: Break Down the Work** |
|||
- Identify all subtasks and dependencies |
|||
- Group related work into logical phases |
|||
- Identify critical path and blockers |
|||
|
|||
### **Step 2: Define Phases and Milestones** |
|||
- **Phase 1**: Foundation work (basic fixes, core functionality) |
|||
- **Phase 2**: Enhancement work (new features, integrations) |
|||
- **Phase 3**: Polish work (testing, user experience, edge cases) |
|||
|
|||
### **Step 3: Identify Dependencies** |
|||
- **Technical dependencies**: What must be built first |
|||
- **Platform dependencies**: What works on which platforms |
|||
- **Testing dependencies**: What can be tested when |
|||
|
|||
### **Step 4: Set Progress Milestones** |
|||
- **Milestone 1**: Basic functionality working |
|||
- **Milestone 2**: All platforms supported |
|||
- **Milestone 3**: Fully tested and polished |
|||
|
|||
## 📋 Planning Checklist (No Time Estimates) |
|||
|
|||
- [ ] Work broken down into logical phases |
|||
- [ ] Dependencies identified and mapped |
|||
- [ ] Milestones defined with clear criteria |
|||
- [ ] Complexity levels assigned to each phase |
|||
- [ ] Platform requirements identified |
|||
- [ ] Testing strategy planned |
|||
- [ ] Risk factors identified |
|||
- [ ] Success criteria defined |
|||
|
|||
## 🎯 Example Planning (No Time Estimates) |
|||
|
|||
### **Example 1: Simple Feature** |
|||
``` |
|||
Phase 1: Core implementation |
|||
- Basic functionality |
|||
- Single platform support |
|||
- Unit tests |
|||
|
|||
Phase 2: Platform expansion |
|||
- Multi-platform support |
|||
- Integration tests |
|||
|
|||
Phase 3: Polish |
|||
- User testing |
|||
- Edge case handling |
|||
``` |
|||
|
|||
### **Example 2: Complex Cross-Platform Feature** |
|||
``` |
|||
Phase 1: Foundation |
|||
- Architecture design |
|||
- Core service implementation |
|||
- Basic web platform support |
|||
|
|||
Phase 2: Platform Integration |
|||
- Mobile platform support |
|||
- Desktop platform support |
|||
- Cross-platform consistency |
|||
|
|||
Phase 3: Testing & Polish |
|||
- Comprehensive testing |
|||
- Error handling |
|||
- User experience refinement |
|||
``` |
|||
|
|||
## 🚫 Anti-Patterns to Avoid |
|||
|
|||
- **"This should take X days"** - Red flag for time estimation |
|||
- **"Just a few hours"** - Ignores complexity and testing |
|||
- **"Similar to X"** - Without considering differences |
|||
- **"Quick fix"** - Nothing is ever quick in software |
|||
- **"No testing needed"** - Testing always takes effort |
|||
|
|||
## ✅ Best Practices |
|||
|
|||
### **When Planning:** |
|||
1. **Break down everything** - no work is too small to plan |
|||
2. **Consider all platforms** - web, mobile, desktop differences |
|||
3. **Include testing strategy** - unit, integration, and user testing |
|||
4. **Account for unknowns** - there are always surprises |
|||
5. **Focus on dependencies** - what blocks what |
|||
|
|||
### **When Presenting Plans:** |
|||
1. **Show the phases** - explain the logical progression |
|||
2. **Highlight dependencies** - what could block progress |
|||
3. **Define milestones** - clear success criteria |
|||
4. **Identify risks** - what could go wrong |
|||
5. **Suggest alternatives** - ways to reduce scope or complexity |
|||
|
|||
## 🔄 Continuous Improvement |
|||
|
|||
### **Track Progress** |
|||
- Record planned vs. actual phases completed |
|||
- Identify what took longer than expected |
|||
- Learn from complexity misjudgments |
|||
- Adjust planning process based on experience |
|||
|
|||
### **Learn from Experience** |
|||
- **Underestimated complexity**: Increase complexity categories |
|||
- **Missed dependencies**: Improve dependency mapping |
|||
- **Platform surprises**: Better platform research upfront |
|||
|
|||
## 🎯 Integration with Harbor Pilot |
|||
|
|||
This rule works in conjunction with: |
|||
- **Project Planning**: Focuses on phases and milestones |
|||
- **Resource Allocation**: Based on complexity, not time |
|||
- **Risk Management**: Identifies blockers and dependencies |
|||
- **Stakeholder Communication**: Sets progress-based expectations |
|||
|
|||
## 📝 Version History |
|||
|
|||
### v2.0.0 (2025-08-21) |
|||
- **Major Change**: Completely removed time estimation approach |
|||
- **New Focus**: Phases, milestones, and complexity-based planning |
|||
- **Eliminated**: All time multipliers, estimates, and calculations |
|||
- **Added**: Dependency mapping and progress milestone framework |
|||
|
|||
### v1.0.0 (2025-08-21) |
|||
- Initial creation based on user feedback about estimation accuracy |
|||
- ~~Established realistic estimation multipliers and process~~ |
|||
- ~~Added comprehensive estimation checklist and examples~~ |
|||
- Integrated with Harbor Pilot planning and risk management |
|||
|
|||
--- |
|||
|
|||
## 🚨 Remember |
|||
|
|||
**DO NOT MAKE TIME ESTIMATES. Use phases, milestones, and complexity instead. Focus on progress, not deadlines.** |
|||
|
|||
## 🚨 Remember |
|||
|
|||
**Your first estimate is wrong. Your second estimate is probably still wrong. Focus on progress, not deadlines.** |
|||
# No Time Estimates — Harbor Pilot Directive |
|||
|
|||
> **Agent role**: **DO NOT MAKE TIME ESTIMATES**. Instead, use phases, milestones, and complexity levels. Time estimates are consistently wrong and create unrealistic expectations. |
|||
|
|||
## 🎯 Purpose |
|||
|
|||
Development time estimates are consistently wrong and create unrealistic expectations. This rule ensures we focus on phases, milestones, and complexity rather than trying to predict specific timeframes. |
|||
|
|||
## 🚨 Critical Rule |
|||
|
|||
**DO NOT MAKE TIME ESTIMATES** |
|||
- **Never provide specific time estimates** - they are always wrong |
|||
- **Use phases and milestones** instead of days/weeks |
|||
- **Focus on complexity and dependencies** rather than time |
|||
- **Set expectations based on progress, not deadlines** |
|||
|
|||
## 📊 Planning Framework (Not Time Estimates) |
|||
|
|||
### **Complexity Categories** |
|||
- **Simple**: Text changes, styling updates, minor bug fixes |
|||
- **Medium**: New features, refactoring, component updates |
|||
- **Complex**: Architecture changes, integrations, cross-platform work |
|||
- **Unknown**: New technologies, APIs, or approaches |
|||
|
|||
### **Platform Complexity** |
|||
- **Single platform**: Web-only or mobile-only changes |
|||
- **Two platforms**: Web + mobile or web + desktop |
|||
- **Three platforms**: Web + mobile + desktop |
|||
- **Cross-platform consistency**: Ensuring behavior matches across all platforms |
|||
|
|||
### **Testing Complexity** |
|||
- **Basic**: Unit tests for new functionality |
|||
- **Comprehensive**: Integration tests, cross-platform testing |
|||
- **User acceptance**: User testing, feedback integration |
|||
|
|||
## 🔍 Planning Process (No Time Estimates) |
|||
|
|||
### **Step 1: Break Down the Work** |
|||
- Identify all subtasks and dependencies |
|||
- Group related work into logical phases |
|||
- Identify critical path and blockers |
|||
|
|||
### **Step 2: Define Phases and Milestones** |
|||
- **Phase 1**: Foundation work (basic fixes, core functionality) |
|||
- **Phase 2**: Enhancement work (new features, integrations) |
|||
- **Phase 3**: Polish work (testing, user experience, edge cases) |
|||
|
|||
### **Step 3: Identify Dependencies** |
|||
- **Technical dependencies**: What must be built first |
|||
- **Platform dependencies**: What works on which platforms |
|||
- **Testing dependencies**: What can be tested when |
|||
|
|||
### **Step 4: Set Progress Milestones** |
|||
- **Milestone 1**: Basic functionality working |
|||
- **Milestone 2**: All platforms supported |
|||
- **Milestone 3**: Fully tested and polished |
|||
|
|||
## 📋 Planning Checklist (No Time Estimates) |
|||
|
|||
- [ ] Work broken down into logical phases |
|||
- [ ] Dependencies identified and mapped |
|||
- [ ] Milestones defined with clear criteria |
|||
- [ ] Complexity levels assigned to each phase |
|||
- [ ] Platform requirements identified |
|||
- [ ] Testing strategy planned |
|||
- [ ] Risk factors identified |
|||
- [ ] Success criteria defined |
|||
|
|||
## 🎯 Example Planning (No Time Estimates) |
|||
|
|||
### **Example 1: Simple Feature** |
|||
``` |
|||
Phase 1: Core implementation |
|||
- Basic functionality |
|||
- Single platform support |
|||
- Unit tests |
|||
|
|||
Phase 2: Platform expansion |
|||
- Multi-platform support |
|||
- Integration tests |
|||
|
|||
Phase 3: Polish |
|||
- User testing |
|||
- Edge case handling |
|||
``` |
|||
|
|||
### **Example 2: Complex Cross-Platform Feature** |
|||
``` |
|||
Phase 1: Foundation |
|||
- Architecture design |
|||
- Core service implementation |
|||
- Basic web platform support |
|||
|
|||
Phase 2: Platform Integration |
|||
- Mobile platform support |
|||
- Desktop platform support |
|||
- Cross-platform consistency |
|||
|
|||
Phase 3: Testing & Polish |
|||
- Comprehensive testing |
|||
- Error handling |
|||
- User experience refinement |
|||
``` |
|||
|
|||
## 🚫 Anti-Patterns to Avoid |
|||
|
|||
- **"This should take X days"** - Red flag for time estimation |
|||
- **"Just a few hours"** - Ignores complexity and testing |
|||
- **"Similar to X"** - Without considering differences |
|||
- **"Quick fix"** - Nothing is ever quick in software |
|||
- **"No testing needed"** - Testing always takes effort |
|||
|
|||
## ✅ Best Practices |
|||
|
|||
### **When Planning:** |
|||
1. **Break down everything** - no work is too small to plan |
|||
2. **Consider all platforms** - web, mobile, desktop differences |
|||
3. **Include testing strategy** - unit, integration, and user testing |
|||
4. **Account for unknowns** - there are always surprises |
|||
5. **Focus on dependencies** - what blocks what |
|||
|
|||
### **When Presenting Plans:** |
|||
1. **Show the phases** - explain the logical progression |
|||
2. **Highlight dependencies** - what could block progress |
|||
3. **Define milestones** - clear success criteria |
|||
4. **Identify risks** - what could go wrong |
|||
5. **Suggest alternatives** - ways to reduce scope or complexity |
|||
|
|||
## 🔄 Continuous Improvement |
|||
|
|||
### **Track Progress** |
|||
- Record planned vs. actual phases completed |
|||
- Identify what took longer than expected |
|||
- Learn from complexity misjudgments |
|||
- Adjust planning process based on experience |
|||
|
|||
### **Learn from Experience** |
|||
- **Underestimated complexity**: Increase complexity categories |
|||
- **Missed dependencies**: Improve dependency mapping |
|||
- **Platform surprises**: Better platform research upfront |
|||
|
|||
## 🎯 Integration with Harbor Pilot |
|||
|
|||
This rule works in conjunction with: |
|||
- **Project Planning**: Focuses on phases and milestones |
|||
- **Resource Allocation**: Based on complexity, not time |
|||
- **Risk Management**: Identifies blockers and dependencies |
|||
- **Stakeholder Communication**: Sets progress-based expectations |
|||
|
|||
## 📝 Version History |
|||
|
|||
### v2.0.0 (2025-08-21) |
|||
- **Major Change**: Completely removed time estimation approach |
|||
- **New Focus**: Phases, milestones, and complexity-based planning |
|||
- **Eliminated**: All time multipliers, estimates, and calculations |
|||
- **Added**: Dependency mapping and progress milestone framework |
|||
|
|||
### v1.0.0 (2025-08-21) |
|||
- Initial creation based on user feedback about estimation accuracy |
|||
- ~~Established realistic estimation multipliers and process~~ |
|||
- ~~Added comprehensive estimation checklist and examples~~ |
|||
- Integrated with Harbor Pilot planning and risk management |
|||
|
|||
--- |
|||
|
|||
## 🚨 Remember |
|||
|
|||
**DO NOT MAKE TIME ESTIMATES. Use phases, milestones, and complexity instead. Focus on progress, not deadlines.** |
|||
|
|||
## 🚨 Remember |
|||
|
|||
**Your first estimate is wrong. Your second estimate is probably still wrong. Focus on progress, not deadlines.** |
@ -1,142 +0,0 @@ |
|||
name: Asset Validation & CI Safeguards |
|||
|
|||
on: |
|||
pull_request: |
|||
paths: |
|||
- 'resources/**' |
|||
- 'config/assets/**' |
|||
- 'capacitor-assets.config.json' |
|||
- 'capacitor.config.ts' |
|||
- 'capacitor.config.json' |
|||
push: |
|||
branches: [main, develop] |
|||
paths: |
|||
- 'resources/**' |
|||
- 'config/assets/**' |
|||
- 'capacitor-assets.config.json' |
|||
- 'capacitor.config.ts' |
|||
- 'capacitor.config.json' |
|||
|
|||
jobs: |
|||
asset-validation: |
|||
runs-on: ubuntu-latest |
|||
steps: |
|||
- name: Checkout code |
|||
uses: actions/checkout@v4 |
|||
|
|||
- name: Setup Node.js |
|||
uses: actions/setup-node@v4 |
|||
with: |
|||
node-version-file: '.nvmrc' |
|||
cache: 'npm' |
|||
|
|||
- name: Install dependencies |
|||
run: npm ci |
|||
|
|||
- name: Validate asset configuration |
|||
run: npm run assets:validate |
|||
|
|||
- name: Check for committed platform assets (Android) |
|||
run: | |
|||
if git ls-files -z android/app/src/main/res | grep -E '(AppIcon.*\.png|Splash.*\.png|mipmap-.*/ic_launcher.*\.png)' > /dev/null; then |
|||
echo "❌ Android platform assets found in VCS - these should be generated at build-time" |
|||
git ls-files -z android/app/src/main/res | grep -E '(AppIcon.*\.png|Splash.*\.png|mipmap-.*/ic_launcher.*\.png)' |
|||
exit 1 |
|||
fi |
|||
echo "✅ No Android platform assets committed" |
|||
|
|||
- name: Check for committed platform assets (iOS) |
|||
run: | |
|||
if git ls-files -z ios/App/App/Assets.xcassets | grep -E '(AppIcon.*\.png|Splash.*\.png)' > /dev/null; then |
|||
echo "❌ iOS platform assets found in VCS - these should be generated at build-time" |
|||
git ls-files -z ios/App/App/Assets.xcassets | grep -E '(AppIcon.*\.png|Splash.*\.png)' |
|||
exit 1 |
|||
fi |
|||
echo "✅ No iOS platform assets committed" |
|||
|
|||
- name: Test asset generation |
|||
run: | |
|||
echo "🧪 Testing asset generation workflow..." |
|||
npm run build:capacitor |
|||
npx cap sync |
|||
npx capacitor-assets generate --dry-run || npx capacitor-assets generate |
|||
echo "✅ Asset generation test completed" |
|||
|
|||
- name: Verify clean tree after build |
|||
run: | |
|||
if [ -n "$(git status --porcelain)" ]; then |
|||
echo "❌ Dirty tree after build - asset configs were modified" |
|||
git status |
|||
git diff |
|||
exit 1 |
|||
fi |
|||
echo "✅ Build completed with clean tree" |
|||
|
|||
schema-validation: |
|||
runs-on: ubuntu-latest |
|||
steps: |
|||
- name: Checkout code |
|||
uses: actions/checkout@v4 |
|||
|
|||
- name: Setup Node.js |
|||
uses: actions/setup-node@v4 |
|||
with: |
|||
node-version-file: '.nvmrc' |
|||
cache: 'npm' |
|||
|
|||
- name: Install dependencies |
|||
run: npm ci |
|||
|
|||
- name: Validate schema compliance |
|||
run: | |
|||
echo "🔍 Validating schema compliance..." |
|||
node -e " |
|||
const fs = require('fs'); |
|||
const config = JSON.parse(fs.readFileSync('capacitor-assets.config.json', 'utf8')); |
|||
const schema = JSON.parse(fs.readFileSync('config/assets/schema.json', 'utf8')); |
|||
|
|||
// Basic schema validation |
|||
if (!config.icon || !config.splash) { |
|||
throw new Error('Missing required sections: icon and splash'); |
|||
} |
|||
|
|||
if (!config.icon.source || !config.splash.source) { |
|||
throw new Error('Missing required source fields'); |
|||
} |
|||
|
|||
if (!/^resources\/.*\.(png|svg)$/.test(config.icon.source)) { |
|||
throw new Error('Icon source must be in resources/ directory'); |
|||
} |
|||
|
|||
if (!/^resources\/.*\.(png|svg)$/.test(config.splash.source)) { |
|||
throw new Error('Splash source must be in resources/ directory'); |
|||
} |
|||
|
|||
console.log('✅ Schema validation passed'); |
|||
" |
|||
|
|||
- name: Check source file existence |
|||
run: | |
|||
echo "📁 Checking source file existence..." |
|||
node -e " |
|||
const fs = require('fs'); |
|||
const config = JSON.parse(fs.readFileSync('capacitor-assets.config.json', 'utf8')); |
|||
|
|||
const requiredFiles = [ |
|||
config.icon.source, |
|||
config.splash.source |
|||
]; |
|||
|
|||
if (config.splash.darkSource) { |
|||
requiredFiles.push(config.splash.darkSource); |
|||
} |
|||
|
|||
const missingFiles = requiredFiles.filter(file => !fs.existsSync(file)); |
|||
|
|||
if (missingFiles.length > 0) { |
|||
console.error('❌ Missing source files:', missingFiles); |
|||
process.exit(1); |
|||
} |
|||
|
|||
console.log('✅ All source files exist'); |
|||
" |
@ -1,27 +0,0 @@ |
|||
name: Playwright Tests |
|||
on: |
|||
push: |
|||
branches: [ main, master ] |
|||
pull_request: |
|||
branches: [ main, master ] |
|||
jobs: |
|||
test: |
|||
timeout-minutes: 60 |
|||
runs-on: ubuntu-latest |
|||
steps: |
|||
- uses: actions/checkout@v4 |
|||
- uses: actions/setup-node@v4 |
|||
with: |
|||
node-version: lts/* |
|||
- name: Install dependencies |
|||
run: npm ci |
|||
- name: Install Playwright Browsers |
|||
run: npx playwright install --with-deps |
|||
- name: Run Playwright tests |
|||
run: npx playwright test |
|||
- uses: actions/upload-artifact@v4 |
|||
if: always() |
|||
with: |
|||
name: playwright-report |
|||
path: playwright-report/ |
|||
retention-days: 30 |
@ -0,0 +1,40 @@ |
|||
#!/usr/bin/env sh |
|||
# |
|||
# Husky Helper Script |
|||
# This file is sourced by all Husky hooks |
|||
# |
|||
if [ -z "$husky_skip_init" ]; then |
|||
debug () { |
|||
if [ "$HUSKY_DEBUG" = "1" ]; then |
|||
echo "husky (debug) - $1" |
|||
fi |
|||
} |
|||
|
|||
readonly hook_name="$(basename -- "$0")" |
|||
debug "starting $hook_name..." |
|||
|
|||
if [ "$HUSKY" = "0" ]; then |
|||
debug "HUSKY env variable is set to 0, skipping hook" |
|||
exit 0 |
|||
fi |
|||
|
|||
if [ -f ~/.huskyrc ]; then |
|||
debug "sourcing ~/.huskyrc" |
|||
. ~/.huskyrc |
|||
fi |
|||
|
|||
readonly husky_skip_init=1 |
|||
export husky_skip_init |
|||
sh -e "$0" "$@" |
|||
exitCode="$?" |
|||
|
|||
if [ $exitCode != 0 ]; then |
|||
echo "husky - $hook_name hook exited with code $exitCode (error)" |
|||
fi |
|||
|
|||
if [ $exitCode = 127 ]; then |
|||
echo "husky - command not found in PATH=$PATH" |
|||
fi |
|||
|
|||
exit $exitCode |
|||
fi |
@ -0,0 +1,10 @@ |
|||
#!/usr/bin/env bash |
|||
# |
|||
# Husky Commit Message Hook |
|||
# Validates commit message format using commitlint |
|||
# |
|||
. "$(dirname -- "$0")/_/husky.sh" |
|||
|
|||
# Run commitlint but don't fail the commit (|| true) |
|||
# This provides helpful feedback without blocking commits |
|||
npx commitlint --edit "$1" || true |
@ -0,0 +1,33 @@ |
|||
#!/usr/bin/env bash |
|||
# |
|||
# Husky Pre-commit Hook |
|||
# Runs lint-fix and Build Architecture Guard on staged files |
|||
# |
|||
. "$(dirname -- "$0")/_/husky.sh" |
|||
|
|||
echo "🔍 Running pre-commit hooks..." |
|||
|
|||
# Run lint-fix first |
|||
echo "📝 Running lint-fix..." |
|||
npm run lint-fix || { |
|||
echo |
|||
echo "❌ Linting failed. Please fix the issues and try again." |
|||
echo "💡 To bypass this check for emergency commits, use:" |
|||
echo " git commit --no-verify" |
|||
echo |
|||
exit 1 |
|||
} |
|||
|
|||
# Then run Build Architecture Guard |
|||
echo "🏗️ Running Build Architecture Guard..." |
|||
bash ./scripts/build-arch-guard.sh --staged || { |
|||
echo |
|||
echo "❌ Build Architecture Guard failed. Please fix the issues and try again." |
|||
echo "💡 To bypass this check for emergency commits, use:" |
|||
echo " git commit --no-verify" |
|||
echo |
|||
exit 1 |
|||
} |
|||
|
|||
echo "✅ All pre-commit checks passed!" |
|||
|
@ -0,0 +1,27 @@ |
|||
#!/usr/bin/env bash |
|||
# |
|||
# Husky Pre-push Hook |
|||
# Runs Build Architecture Guard to check commits being pushed |
|||
# |
|||
. "$(dirname -- "$0")/_/husky.sh" |
|||
|
|||
echo "🔍 Running Build Architecture Guard (pre-push)..." |
|||
|
|||
# Get the remote branch we're pushing to |
|||
REMOTE_BRANCH="origin/$(git rev-parse --abbrev-ref HEAD)" |
|||
|
|||
# Check if remote branch exists |
|||
if git show-ref --verify --quiet "refs/remotes/$REMOTE_BRANCH"; then |
|||
RANGE="$REMOTE_BRANCH...HEAD" |
|||
else |
|||
# If remote branch doesn't exist, check last commit |
|||
RANGE="HEAD~1..HEAD" |
|||
fi |
|||
|
|||
bash ./scripts/build-arch-guard.sh --range "$RANGE" || { |
|||
echo |
|||
echo "💡 To bypass this check for emergency pushes, use:" |
|||
echo " git push --no-verify" |
|||
echo |
|||
exit 1 |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,82 @@ |
|||
# Pull Request Template |
|||
|
|||
## Location |
|||
|
|||
The Build Architecture Guard PR template is located at: |
|||
|
|||
- **`pull_request_template.md`** (root directory) |
|||
|
|||
## Usage |
|||
|
|||
When creating a pull request in Gitea, this template will automatically populate the PR description with the required checklist. |
|||
|
|||
## Template Features |
|||
|
|||
### Change Level Classification |
|||
|
|||
- **L1**: Minor changes, documentation updates |
|||
- **L2**: Moderate changes, new features, environment changes |
|||
- **L3**: Major changes, architecture changes, new platforms |
|||
|
|||
### Required Fields for All Levels |
|||
|
|||
- Change level selection |
|||
- Scope and impact description |
|||
- Commands executed and their output |
|||
- Documentation updates (BUILDING.md) |
|||
- Rollback verification steps |
|||
|
|||
### Additional Requirements for L3 |
|||
|
|||
- **ADR link**: Must provide URL to Architectural Decision Record |
|||
- **Artifacts with SHA256**: Must list artifacts with cryptographic hashes |
|||
|
|||
## Integration |
|||
|
|||
This template works with: |
|||
|
|||
- **Gitea Actions**: `.gitea/workflows/build-guard.yml` |
|||
- **Client-side hooks**: `.husky/` pre-commit and pre-push hooks |
|||
- **Guard script**: `scripts/build-arch-guard.sh` |
|||
|
|||
## Example Usage |
|||
|
|||
```markdown |
|||
### Change Level |
|||
- [x] Level: **L2** |
|||
|
|||
**Why:** Adding new build script for Docker deployment |
|||
|
|||
### Scope & Impact |
|||
- [x] Files & platforms touched: scripts/build-docker.sh, |
|||
BUILDING.md |
|||
- [x] Risk triggers: Docker build process changes |
|||
- [x] Mitigations/validation done: Tested on local Docker environment |
|||
|
|||
### Commands Run |
|||
- [x] Web: `npm run build:web:docker` ✅ |
|||
- [x] Docker: `docker build -t test-image .` ✅ |
|||
|
|||
### Artifacts |
|||
- [x] Names + **sha256** of artifacts/installers: |
|||
|
|||
Artifacts: |
|||
```text |
|||
test-image.tar a1b2c3d4e5f6... |
|||
``` |
|||
|
|||
### Docs |
|||
- [x] **BUILDING.md** updated (sections): Docker deployment |
|||
- [x] Troubleshooting updated: Added Docker troubleshooting section |
|||
|
|||
### Rollback |
|||
- [x] Verified steps to restore previous behavior: |
|||
1. `git revert HEAD` |
|||
2. `docker rmi test-image` |
|||
3. Restore previous BUILDING.md |
|||
``` |
|||
|
|||
--- |
|||
|
|||
**Note**: This template is enforced by the Build Architecture Guard |
|||
system. Complete all required fields to ensure your PR can be merged. |
@ -0,0 +1,336 @@ |
|||
# Build Architecture Guard - Husky Implementation |
|||
|
|||
## Overview |
|||
|
|||
The Build Architecture Guard protects your build system by enforcing |
|||
documentation requirements through **Git hooks**. When you modify |
|||
build-critical files, the system automatically blocks commits/pushes |
|||
until you update `BUILDING.md`. |
|||
|
|||
## 🎯 **Why Husky-Only?** |
|||
|
|||
**Advantages:** |
|||
|
|||
- ✅ **Immediate feedback** - Hooks run before commit/push |
|||
- ✅ **Works everywhere** - No server-side CI/CD required |
|||
- ✅ **Simple setup** - One tool, one configuration |
|||
- ✅ **Fast execution** - No network delays or server queues |
|||
- ✅ **Offline support** - Works without internet connection |
|||
|
|||
**Trade-offs:** |
|||
|
|||
- ⚠️ **Can be bypassed** - `git commit --no-verify` or `git push --no-verify` |
|||
- ⚠️ **Developer discipline** - Relies on team following the rules |
|||
|
|||
## 🏗️ **Architecture** |
|||
|
|||
```bash |
|||
Developer Workflow: |
|||
1. Modify build files (scripts/, vite.config.*, etc.) |
|||
2. Try to commit → Husky pre-commit hook runs |
|||
3. Guard script checks if BUILDING.md was updated |
|||
4. ✅ Commit succeeds if docs updated |
|||
5. ❌ Commit blocked if docs missing |
|||
``` |
|||
|
|||
## 🚀 **Quick Start** |
|||
|
|||
### 1. Install Dependencies |
|||
|
|||
```bash |
|||
npm install |
|||
npm run prepare # Sets up Husky hooks |
|||
``` |
|||
|
|||
### 2. Test the System |
|||
|
|||
```bash |
|||
# Modify a build file without updating BUILDING.md |
|||
echo "# test" >> scripts/test.sh |
|||
|
|||
# Try to commit (should be blocked) |
|||
git add scripts/test.sh |
|||
git commit -m "test: add build script" |
|||
# ❌ Hook blocks commit with helpful message |
|||
``` |
|||
|
|||
### 3. Fix and Retry |
|||
|
|||
```bash |
|||
# Update BUILDING.md with your changes |
|||
echo "## New Build Script" >> BUILDING.md |
|||
echo "Added test.sh for testing purposes" >> BUILDING.md |
|||
|
|||
# Now commit should succeed |
|||
git add BUILDING.md |
|||
git commit -m "feat: add test build script with docs" |
|||
# ✅ Commit succeeds |
|||
``` |
|||
|
|||
## 🔧 **How It Works** |
|||
|
|||
### Pre-commit Hook (`.husky/pre-commit`) |
|||
|
|||
- **When**: Every `git commit` |
|||
- **What**: Runs `./scripts/build-arch-guard.sh --staged` |
|||
- **Result**: Blocks commit if build files changed without BUILDING.md update |
|||
|
|||
### Pre-push Hook (`.husky/pre-push`) |
|||
|
|||
- **When**: Every `git push` |
|||
- **What**: Runs `./scripts/build-arch-guard.sh --range` |
|||
- **Result**: Blocks push if commits contain undocumented build changes |
|||
|
|||
### Guard Script (`scripts/build-arch-guard.sh`) |
|||
|
|||
- **Detects**: Changes to build-sensitive file patterns |
|||
- **Validates**: BUILDING.md was updated alongside changes |
|||
- **Reports**: Clear error messages with guidance |
|||
|
|||
## 📁 **Protected File Patterns** |
|||
|
|||
The guard script monitors these paths for changes: |
|||
|
|||
```text |
|||
Build Configuration: |
|||
├── vite.config.* # Vite configuration |
|||
├── capacitor.config.ts # Capacitor configuration |
|||
├── package.json # Package configuration |
|||
├── package-lock.json # Lock files |
|||
├── yarn.lock |
|||
└── pnpm-lock.yaml |
|||
|
|||
Build Scripts: |
|||
├── scripts/** # All build and automation scripts |
|||
├── electron/** # Electron build files |
|||
├── android/** # Android build configuration |
|||
├── ios/** # iOS build configuration |
|||
├── sw_scripts/** # Service worker scripts |
|||
└── sw_combine.js # Service worker combination |
|||
|
|||
Deployment: |
|||
├── Dockerfile # Docker configuration |
|||
└── docker/** # Docker services |
|||
``` |
|||
|
|||
## 🎭 **Usage Scenarios** |
|||
|
|||
### Scenario 1: Adding a New Build Script |
|||
|
|||
```bash |
|||
# ❌ This will be blocked |
|||
echo '#!/bin/bash' > scripts/new-build.sh |
|||
git add scripts/new-build.sh |
|||
git commit -m "feat: add new build script" |
|||
# Hook blocks: "Build-sensitive files changed but BUILDING.md not updated" |
|||
|
|||
# ✅ This will succeed |
|||
echo '#!/bin/bash' > scripts/new-build.sh |
|||
echo '## New Build Script' >> BUILDING.md |
|||
echo 'Added new-build.sh for feature X' >> BUILDING.md |
|||
git add scripts/new-build.sh BUILDING.md |
|||
git commit -m "feat: add new build script with docs" |
|||
# ✅ Commit succeeds |
|||
``` |
|||
|
|||
### Scenario 2: Updating Vite Configuration |
|||
|
|||
```bash |
|||
# ❌ This will be blocked |
|||
echo 'export default { newOption: true }' >> vite.config.ts |
|||
git add vite.config.ts |
|||
git commit -m "config: add new vite option" |
|||
# Hook blocks: "Build-sensitive files changed but BUILDING.md not updated" |
|||
|
|||
# ✅ This will succeed |
|||
echo 'export default { newOption: true }' >> vite.config.ts |
|||
echo '### New Vite Option' >> BUILDING.md |
|||
echo 'Added newOption for improved performance' >> BUILDING.md |
|||
git add vite.config.ts BUILDING.md |
|||
git commit -m "config: add new vite option with docs" |
|||
# ✅ Commit succeeds |
|||
``` |
|||
|
|||
## 🚨 **Emergency Bypass** |
|||
|
|||
**⚠️ Use sparingly and only for emergencies:** |
|||
|
|||
```bash |
|||
# Skip pre-commit hook |
|||
git commit -m "emergency: critical fix" --no-verify |
|||
|
|||
# Skip pre-push hook |
|||
git push --no-verify |
|||
|
|||
# Remember to update BUILDING.md later! |
|||
``` |
|||
|
|||
## 🔍 **Troubleshooting** |
|||
|
|||
### Hooks Not Running |
|||
|
|||
```bash |
|||
# Reinstall hooks |
|||
npm run prepare |
|||
|
|||
# Check hook files exist and are executable |
|||
ls -la .husky/ |
|||
chmod +x .husky/* |
|||
|
|||
# Verify Git hooks path |
|||
git config core.hooksPath |
|||
# Should show: .husky |
|||
``` |
|||
|
|||
### Guard Script Issues |
|||
|
|||
```bash |
|||
# Test guard script manually |
|||
./scripts/build-arch-guard.sh --help |
|||
|
|||
# Check script permissions |
|||
chmod +x scripts/build-arch-guard.sh |
|||
|
|||
# Test with specific files |
|||
./scripts/build-arch-guard.sh --staged |
|||
``` |
|||
|
|||
### False Positives |
|||
|
|||
```bash |
|||
# If guard blocks legitimate changes, check: |
|||
# 1. Are you modifying a protected file pattern? |
|||
# 2. Did you update BUILDING.md? |
|||
# 3. Is BUILDING.md staged for commit? |
|||
|
|||
# View what the guard sees |
|||
git diff --name-only --cached |
|||
``` |
|||
|
|||
## 📋 **Best Practices** |
|||
|
|||
### For Developers |
|||
|
|||
1. **Update BUILDING.md first** - Document changes before implementing |
|||
2. **Test locally** - Run `./scripts/build-arch-guard.sh --staged` before committing |
|||
3. **Use descriptive commits** - Include context about build changes |
|||
4. **Don't bypass lightly** - Only use `--no-verify` for true emergencies |
|||
|
|||
### For Teams |
|||
|
|||
1. **Document the system** - Ensure everyone understands the guard |
|||
2. **Review BUILDING.md updates** - Verify documentation quality |
|||
3. **Monitor bypass usage** - Track when hooks are skipped |
|||
4. **Regular audits** - Check that BUILDING.md stays current |
|||
|
|||
### For Maintainers |
|||
|
|||
1. **Update protected patterns** - Modify `scripts/build-arch-guard.sh` as needed |
|||
2. **Monitor effectiveness** - Track how often the guard catches issues |
|||
3. **Team training** - Help developers understand the system |
|||
4. **Continuous improvement** - Refine patterns and error messages |
|||
|
|||
## 🚨 **Troubleshooting** |
|||
|
|||
### Common Issues |
|||
|
|||
#### mapfile Command Not Found |
|||
|
|||
**Problem**: Pre-commit hook fails with `mapfile: command not found` |
|||
|
|||
**Cause**: The `mapfile` command is bash-specific and not available in all shell environments |
|||
|
|||
**Solution**: The script has been updated to use portable alternatives. If you encounter this issue: |
|||
|
|||
```bash |
|||
# Verify the script is executable |
|||
chmod +x scripts/build-arch-guard.sh |
|||
|
|||
# Test the script directly |
|||
./scripts/build-arch-guard.sh --help |
|||
|
|||
# Check your shell environment |
|||
echo $SHELL |
|||
bash --version |
|||
``` |
|||
|
|||
**Prevention**: Ensure your development environment uses bash and the script has proper permissions |
|||
|
|||
### False Positives |
|||
|
|||
```bash |
|||
# If guard blocks legitimate changes, check: |
|||
# 1. Are you modifying a protected file pattern? |
|||
# 2. Did you update BUILDING.md? |
|||
# 3. Is BUILDING.md staged for commit? |
|||
|
|||
# View what the guard sees |
|||
git diff --name-only --cached |
|||
``` |
|||
|
|||
## 🔄 **Customization** |
|||
|
|||
### Adding New Protected Paths |
|||
|
|||
Edit `scripts/build-arch-guard.sh`: |
|||
|
|||
```bash |
|||
SENSITIVE=( |
|||
# ... existing patterns ... |
|||
"new-pattern/**" # Add your new pattern |
|||
"*.config.js" # Add file extensions |
|||
) |
|||
``` |
|||
|
|||
### Modifying Error Messages |
|||
|
|||
Edit the guard script to customize: |
|||
|
|||
- Error message content |
|||
- File pattern matching |
|||
- Documentation requirements |
|||
- Bypass instructions |
|||
|
|||
### Adding New Validation Rules |
|||
|
|||
Extend the guard script to check for: |
|||
|
|||
- Specific file content patterns |
|||
- Required documentation sections |
|||
- Commit message formats |
|||
- Branch naming conventions |
|||
|
|||
## 📚 **Integration with PR Template** |
|||
|
|||
The `pull_request_template.md` works with this system by: |
|||
|
|||
- **Guiding developers** through required documentation |
|||
- **Ensuring consistency** across all build changes |
|||
- **Providing checklist** for comprehensive updates |
|||
- **Supporting L1/L2/L3** change classification |
|||
|
|||
## 🎯 **Success Metrics** |
|||
|
|||
Track the effectiveness of your Build Architecture Guard: |
|||
|
|||
- **Hook execution rate** - How often hooks run successfully |
|||
- **Bypass frequency** - How often `--no-verify` is used |
|||
- **Documentation quality** - BUILDING.md stays current |
|||
- **Build failures** - Fewer issues from undocumented changes |
|||
- **Team adoption** - Developers follow the process |
|||
|
|||
--- |
|||
|
|||
**Status**: Active protection system |
|||
**Architecture**: Client-side Git hooks only |
|||
**Dependencies**: Husky, Git, Bash |
|||
**Maintainer**: Development team |
|||
**Related**: `pull_request_template.md`, `scripts/build-arch-guard.sh` |
|||
|
|||
## 📝 **Changelog** |
|||
|
|||
### 2025-08-22 - Shell Compatibility Fix |
|||
- **Fixed**: Replaced `mapfile` command with portable alternative for cross-shell compatibility |
|||
- **Impact**: Resolves "mapfile: command not found" errors in pre-commit hooks |
|||
- **Files**: `scripts/build-arch-guard.sh` |
|||
- **Testing**: Script now works across different shell environments |
@ -0,0 +1,238 @@ |
|||
# Android Asset Validation System |
|||
|
|||
**Author**: Matthew Raymer |
|||
**Date**: 2025-08-22 |
|||
**Status**: 🎯 **ACTIVE** - Production Ready |
|||
|
|||
## Overview |
|||
|
|||
The Android Asset Validation System automatically detects and fixes missing Android resources before building, preventing common build failures related to missing splash screens and app icons. |
|||
|
|||
## Problem Solved |
|||
|
|||
Previously, Android builds would fail with errors like: |
|||
``` |
|||
error: resource drawable/splash (aka app.timesafari.app:drawable/splash) not found. |
|||
error: resource mipmap/ic_launcher (aka app.timesafari.app:mipmap/ic_launcher) not found. |
|||
``` |
|||
|
|||
This happened when: |
|||
- Source assets existed but weren't generated into Android resources |
|||
- Android resource directories were missing |
|||
- Asset generation tools weren't run before building |
|||
|
|||
## Solution |
|||
|
|||
### Enhanced Build Script Validation |
|||
|
|||
The `scripts/build-android.sh` script now includes comprehensive asset validation that: |
|||
|
|||
1. **Checks Source Assets**: Validates that required source files exist in `resources/` |
|||
2. **Checks Android Resources**: Verifies that generated Android resources exist |
|||
3. **Auto-Regenerates**: Automatically regenerates missing resources when detected |
|||
4. **Verifies Results**: Confirms that regeneration was successful |
|||
|
|||
### Validation Process |
|||
|
|||
```bash |
|||
# Validates and regenerates if needed |
|||
npm run assets:validate:android |
|||
|
|||
# Full build with validation |
|||
npm run build:android:studio |
|||
``` |
|||
|
|||
### What Gets Validated |
|||
|
|||
#### Source Assets (Required) |
|||
- `resources/icon.png` - App icon source |
|||
- `resources/splash.png` - Splash screen source |
|||
- `resources/splash_dark.png` - Dark mode splash source |
|||
|
|||
#### Android Resources (Generated) |
|||
- `android/app/src/main/res/drawable/splash.png` - Splash screen drawable |
|||
- `android/app/src/main/res/mipmap-*/ic_launcher.png` - App icons for all densities |
|||
- `android/app/src/main/res/mipmap-*/ic_launcher_round.png` - Round app icons for all densities |
|||
|
|||
### Density Levels Checked |
|||
- `mipmap-mdpi` (1x) |
|||
- `mipmap-hdpi` (1.5x) |
|||
- `mipmap-xhdpi` (2x) |
|||
- `mipmap-xxhdpi` (3x) |
|||
- `mipmap-xxxhdpi` (4x) |
|||
|
|||
## Usage |
|||
|
|||
### Automatic Validation (Recommended) |
|||
The validation runs automatically during all Android builds: |
|||
|
|||
```bash |
|||
# Development build with validation |
|||
npm run build:android:studio |
|||
|
|||
# Production build with validation |
|||
npm run build:android:prod |
|||
|
|||
# Debug build with validation |
|||
npm run build:android:debug |
|||
``` |
|||
|
|||
### Manual Validation |
|||
Run validation only to check/fix assets: |
|||
|
|||
```bash |
|||
# Validate and regenerate if needed |
|||
npm run assets:validate:android |
|||
|
|||
# Alternative command |
|||
./scripts/build-android.sh --assets-only |
|||
``` |
|||
|
|||
### Validation Only (No Regeneration) |
|||
Check configuration without fixing: |
|||
|
|||
```bash |
|||
npm run assets:validate |
|||
``` |
|||
|
|||
## Error Handling |
|||
|
|||
### Missing Source Assets |
|||
If source assets are missing, the build fails with clear error messages: |
|||
|
|||
``` |
|||
[ERROR] Missing source assets: |
|||
[ERROR] - resources/icon.png |
|||
[ERROR] - resources/splash.png |
|||
[ERROR] Please ensure all required assets are present in the resources/ directory. |
|||
``` |
|||
|
|||
### Missing Generated Resources |
|||
If generated resources are missing, they're automatically regenerated: |
|||
|
|||
``` |
|||
[WARN] Missing Android resources detected: |
|||
[WARN] - drawable/splash.png |
|||
[WARN] - mipmap-mdpi/ic_launcher.png |
|||
[INFO] Regenerating Android assets... |
|||
[SUCCESS] Android assets regenerated successfully |
|||
``` |
|||
|
|||
### Generation Failure |
|||
If regeneration fails, helpful guidance is provided: |
|||
|
|||
``` |
|||
[ERROR] Failed to generate Android assets |
|||
[INFO] You may need to manually create the missing resources: |
|||
[INFO] - android/app/src/main/res/drawable/splash.png |
|||
[INFO] - android/app/src/main/res/mipmap-mdpi/ic_launcher.png |
|||
``` |
|||
|
|||
## Integration Points |
|||
|
|||
### Build Script Integration |
|||
The validation is integrated into the main build process: |
|||
|
|||
```bash |
|||
# In scripts/build-android.sh |
|||
validate_dependencies |
|||
validate_android_assets || { |
|||
log_error "Android asset validation failed. Please fix the issues above and try again." |
|||
exit 9 |
|||
} |
|||
``` |
|||
|
|||
### NPM Scripts |
|||
New npm scripts for asset management: |
|||
|
|||
```json |
|||
{ |
|||
"assets:validate": "npx tsx scripts/assets-validator.ts", |
|||
"assets:validate:android": "./scripts/build-android.sh --assets-only", |
|||
"assets:clean": "rimraf android/app/src/main/res/mipmap-* ios/App/App/Assets.xcassets/**/AppIcon*.png ios/App/App/Assets.xcassets/**/Splash*.png || true" |
|||
} |
|||
``` |
|||
|
|||
## Benefits |
|||
|
|||
### For Developers |
|||
- **No More Build Failures**: Automatic detection and fixing of missing resources |
|||
- **Faster Development**: No need to manually run asset generation tools |
|||
- **Clear Error Messages**: Helpful guidance when issues occur |
|||
- **Consistent Results**: Same validation on all development machines |
|||
|
|||
### For CI/CD |
|||
- **Reliable Builds**: Consistent asset validation across environments |
|||
- **Early Detection**: Catches issues before they reach production |
|||
- **Automated Fixes**: Self-healing builds when possible |
|||
|
|||
### For Project Maintenance |
|||
- **Reduced Support**: Fewer "build doesn't work" issues |
|||
- **Documentation**: Clear requirements for required assets |
|||
- **Standardization**: Consistent asset structure across the project |
|||
|
|||
## Troubleshooting |
|||
|
|||
### Common Issues |
|||
|
|||
#### "No assets found in the asset path" |
|||
This occurs when the `assets/` directory is empty. The validation system automatically copies source assets and regenerates them. |
|||
|
|||
#### "Failed to generate Android assets" |
|||
Check that: |
|||
- Source assets exist in `resources/` |
|||
- `@capacitor/assets` is installed |
|||
- You have write permissions to the Android directories |
|||
|
|||
#### "Asset generation completed but some resources are still missing" |
|||
This indicates a problem with the asset generation tool. Try: |
|||
1. Running `npm install` to ensure dependencies are up to date |
|||
2. Manually running `npx @capacitor/assets generate` |
|||
3. Checking the asset generation logs for specific errors |
|||
|
|||
### Manual Recovery |
|||
If automatic regeneration fails, you can manually create the missing resources: |
|||
|
|||
```bash |
|||
# Create missing directories |
|||
mkdir -p android/app/src/main/res/drawable |
|||
mkdir -p android/app/src/main/res/mipmap-{mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi} |
|||
|
|||
# Copy source assets to assets directory |
|||
cp resources/icon.png assets/ |
|||
cp resources/splash.png assets/ |
|||
cp resources/splash_dark.png assets/ |
|||
|
|||
# Generate assets manually |
|||
npx @capacitor/assets generate |
|||
|
|||
# Clean up |
|||
rm assets/icon.png assets/splash.png assets/splash_dark.png |
|||
``` |
|||
|
|||
## Future Enhancements |
|||
|
|||
### Planned Improvements |
|||
- **iOS Asset Validation**: Extend validation to iOS assets |
|||
- **Asset Quality Checks**: Validate image dimensions and formats |
|||
- **Performance Optimization**: Cache validation results |
|||
- **CI/CD Integration**: Add validation to GitHub Actions |
|||
|
|||
### Configuration Options |
|||
- **Custom Asset Paths**: Support for different asset directory structures |
|||
- **Validation Rules**: Configurable validation requirements |
|||
- **Skip Options**: Ability to skip validation for specific scenarios |
|||
|
|||
## References |
|||
|
|||
- [Capacitor Assets Documentation](https://github.com/ionic-team/capacitor-assets) |
|||
- [Android Resource System](https://developer.android.com/guide/topics/resources/providing-resources) |
|||
- [Build Script Documentation](./build-android.sh) |
|||
- [Asset Configuration](./capacitor-assets.config.json) |
|||
|
|||
--- |
|||
|
|||
**Status**: Active validation system |
|||
**Priority**: High |
|||
**Maintainer**: Development team |
|||
**Next Review**: 2025-09-22 |
@ -0,0 +1,47 @@ |
|||
# Build Architecture Guard PR Template |
|||
|
|||
## Change Level |
|||
|
|||
- [ ] Level: **L1** / **L2** / **L3** (pick one) |
|||
|
|||
**Why:** … |
|||
|
|||
## Scope & Impact |
|||
|
|||
- [ ] Files & platforms touched: … |
|||
- [ ] Risk triggers (env / script flow / packaging / SW+WASM / |
|||
Docker / signing): … |
|||
- [ ] Mitigations/validation done: … |
|||
|
|||
## Commands Run (paste exact logs/snips) |
|||
|
|||
- [ ] Web: `npm run build:web` / `:prod` |
|||
- [ ] Electron: `npm run build:electron:dev` / package step |
|||
- [ ] Mobile: `npm run build:android:test` / iOS equivalent |
|||
- [ ] Clean/auto-run impacted scripts |
|||
|
|||
## Artifacts |
|||
|
|||
- [ ] Names + **sha256** of artifacts/installers: |
|||
|
|||
Artifacts: |
|||
|
|||
```text |
|||
<name-1> <sha256-1> |
|||
<name-2> <sha256-2> |
|||
``` |
|||
|
|||
## Docs |
|||
|
|||
- [ ] **BUILDING.md** updated (sections): … |
|||
- [ ] Troubleshooting updated (if applicable) |
|||
|
|||
## Rollback |
|||
|
|||
- [ ] Verified steps (1–3 cmds) to restore previous behavior |
|||
|
|||
## L3 only |
|||
|
|||
- [ ] ADR link: |
|||
|
|||
ADR: https://… |
@ -0,0 +1,355 @@ |
|||
#!/usr/bin/env bash |
|||
# |
|||
# Build Architecture Guard Script |
|||
# |
|||
# Author: Matthew Raymer |
|||
# Date: 2025-08-22 |
|||
# Purpose: Protects build-critical files by requiring BUILDING.md updates |
|||
# Enhanced to protect Android build system including asset validation, |
|||
# API routing, and resource generation logic |
|||
# |
|||
# Usage: |
|||
# ./scripts/build-arch-guard.sh --staged # Check staged files (pre-commit) |
|||
# ./scripts/build-arch-guard.sh --range # Check range (pre-push) |
|||
# ./scripts/build-arch-guard.sh # Check working directory |
|||
# |
|||
|
|||
set -euo pipefail |
|||
|
|||
# Sensitive paths that require BUILDING.md updates when modified |
|||
SENSITIVE=( |
|||
"vite.config.*" |
|||
"scripts/**" |
|||
"electron/**" |
|||
"android/**" |
|||
"ios/**" |
|||
"sw_scripts/**" |
|||
"sw_combine.js" |
|||
"Dockerfile" |
|||
"docker/**" |
|||
"capacitor.config.ts" |
|||
"capacitor-assets.config.json" # Critical for Android assets |
|||
"package.json" |
|||
"package-lock.json" |
|||
"yarn.lock" |
|||
"pnpm-lock.yaml" |
|||
"resources/**" # Source assets for Android |
|||
) |
|||
|
|||
# Documentation files that must be updated alongside sensitive changes |
|||
DOCS_REQUIRED=( |
|||
"BUILDING.md" |
|||
"doc/README-BUILD-GUARD.md" # Guard documentation |
|||
) |
|||
|
|||
# Colors for output |
|||
RED='\033[0;31m' |
|||
GREEN='\033[0;32m' |
|||
YELLOW='\033[1;33m' |
|||
BLUE='\033[0;34m' |
|||
NC='\033[0m' # No Color |
|||
|
|||
log_info() { |
|||
echo -e "${BLUE}[guard]${NC} $1" |
|||
} |
|||
|
|||
log_warn() { |
|||
echo -e "${YELLOW}[guard]${NC} $1" |
|||
} |
|||
|
|||
log_error() { |
|||
echo -e "${RED}[guard]${NC} $1" |
|||
} |
|||
|
|||
log_success() { |
|||
echo -e "${GREEN}[guard]${NC} $1" |
|||
} |
|||
|
|||
# Collect files based on mode |
|||
collect_files() { |
|||
if [[ "${1:-}" == "--staged" ]]; then |
|||
# Pre-commit: check staged files |
|||
git diff --name-only --cached |
|||
elif [[ "${1:-}" == "--range" ]]; then |
|||
# Pre-push: check commits being pushed |
|||
RANGE="${2:-HEAD~1..HEAD}" |
|||
git diff --name-only "$RANGE" |
|||
else |
|||
# Default: check working directory changes |
|||
git diff --name-only HEAD |
|||
fi |
|||
} |
|||
|
|||
# Check if a file matches any sensitive pattern |
|||
matches_sensitive() { |
|||
local f="$1" |
|||
for pat in "${SENSITIVE[@]}"; do |
|||
# Convert glob pattern to regex |
|||
local rx="^${pat//\./\.}$" |
|||
rx="${rx//\*\*/.*}" |
|||
rx="${rx//\*/[^/]*}" |
|||
|
|||
if [[ "$f" =~ $rx ]]; then |
|||
return 0 |
|||
fi |
|||
done |
|||
return 1 |
|||
} |
|||
|
|||
# Check if documentation was updated |
|||
check_docs_updated() { |
|||
local changed_files=("$@") |
|||
|
|||
for changed_file in "${changed_files[@]}"; do |
|||
for required_doc in "${DOCS_REQUIRED[@]}"; do |
|||
if [[ "$changed_file" == "$required_doc" ]]; then |
|||
return 0 |
|||
fi |
|||
done |
|||
done |
|||
return 1 |
|||
} |
|||
|
|||
# Check if Android build system was modified |
|||
check_android_build_changes() { |
|||
local changed_files=("$@") |
|||
|
|||
for file in "${changed_files[@]}"; do |
|||
if [[ "$file" =~ ^android/ ]] || [[ "$file" =~ ^scripts/build-android\.sh$ ]]; then |
|||
return 0 |
|||
fi |
|||
done |
|||
return 1 |
|||
} |
|||
|
|||
# Check if asset configuration was modified |
|||
check_asset_config_changes() { |
|||
local changed_files=("$@") |
|||
|
|||
for file in "${changed_files[@]}"; do |
|||
if [[ "$file" =~ ^capacitor-assets\.config\.json$ ]] || [[ "$file" =~ ^resources/ ]]; then |
|||
return 0 |
|||
fi |
|||
done |
|||
return 1 |
|||
} |
|||
|
|||
# Enhanced validation for Android changes |
|||
validate_android_changes() { |
|||
local changed_files=("$@") |
|||
|
|||
if check_android_build_changes "${changed_files[@]}"; then |
|||
log_warn "Android build system changes detected!" |
|||
echo |
|||
echo "Android build system changes require enhanced validation:" |
|||
echo " - Test asset generation: npm run build:android --assets" |
|||
echo " - Test API routing modes: --dev and --dev --api-ip <custom>" |
|||
echo " - Verify resource fallback mechanisms" |
|||
echo " - Test across development/test/production modes" |
|||
echo |
|||
echo "Please ensure BUILDING.md includes Android-specific testing procedures." |
|||
echo |
|||
fi |
|||
|
|||
if check_asset_config_changes "${changed_files[@]}"; then |
|||
log_warn "Asset configuration changes detected!" |
|||
echo |
|||
echo "Asset configuration changes require validation:" |
|||
echo " - Test asset generation across all platforms" |
|||
echo " - Verify resource files are properly created" |
|||
echo " - Test asset validation scripts" |
|||
echo |
|||
fi |
|||
} |
|||
|
|||
# Feedback collection for continuous improvement |
|||
collect_feedback_data() { |
|||
local mode="$1" |
|||
local sensitive_touched=("${@:2}") |
|||
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
|||
|
|||
# Create feedback log entry |
|||
local feedback_log=".guard-feedback.log" |
|||
echo "[$timestamp] Guard execution: $mode" >> "$feedback_log" |
|||
echo " Sensitive files: ${sensitive_touched[*]}" >> "$feedback_log" |
|||
|
|||
# Log Android-specific changes for analysis |
|||
if check_android_build_changes "${sensitive_touched[@]}"; then |
|||
echo " Android changes detected" >> "$feedback_log" |
|||
fi |
|||
|
|||
# Log asset configuration changes for analysis |
|||
if check_asset_config_changes "${sensitive_touched[@]}"; then |
|||
echo " Asset config changes detected" >> "$feedback_log" |
|||
fi |
|||
|
|||
echo "" >> "$feedback_log" |
|||
} |
|||
|
|||
# Enhanced error handling with Android-specific guidance |
|||
handle_documentation_error() { |
|||
local sensitive_touched=("$@") |
|||
|
|||
log_error "Build-sensitive files changed but BUILDING.md was not updated!" |
|||
echo |
|||
echo "The following build-sensitive files were modified:" |
|||
for file in "${sensitive_touched[@]}"; do |
|||
echo " - $file" |
|||
done |
|||
echo |
|||
echo "When modifying build-critical files, you must also update BUILDING.md" |
|||
echo "to document any changes to the build process." |
|||
echo |
|||
|
|||
# Add Android-specific guidance |
|||
if check_android_build_changes "${sensitive_touched[@]}"; then |
|||
echo "⚠️ ANDROID BUILD SYSTEM CHANGES DETECTED ⚠️" |
|||
echo "Android changes require enhanced documentation including:" |
|||
echo " - Asset validation procedures" |
|||
echo " - API routing configuration" |
|||
echo " - Resource generation testing" |
|||
echo " - Platform-specific build modes" |
|||
echo |
|||
fi |
|||
|
|||
if check_asset_config_changes "${sensitive_touched[@]}"; then |
|||
echo "🎨 ASSET CONFIGURATION CHANGES DETECTED 🎨" |
|||
echo "Asset changes require documentation including:" |
|||
echo " - Asset generation procedures" |
|||
echo " - Resource validation steps" |
|||
echo " - Platform-specific asset requirements" |
|||
echo |
|||
fi |
|||
|
|||
echo "Please:" |
|||
echo " 1. Update BUILDING.md with relevant changes" |
|||
echo " 2. Stage the BUILDING.md changes: git add BUILDING.md" |
|||
echo " 3. Retry your commit/push" |
|||
echo |
|||
echo "💡 Feedback: If this guard is too strict or missing patterns," |
|||
echo " please report to the development team for continuous improvement." |
|||
echo |
|||
echo "📊 Feedback Categories:" |
|||
echo " - False positives (files flagged that shouldn't be)" |
|||
echo " - False negatives (sensitive files not caught)" |
|||
echo " - Missing patterns (new file types to protect)" |
|||
echo " - Overly strict (patterns too restrictive)" |
|||
echo " - Documentation gaps (missing guidance)" |
|||
echo " - Testing improvements (better procedures)" |
|||
echo |
|||
echo "📝 Report feedback to: Development team with specific examples" |
|||
echo |
|||
} |
|||
|
|||
# Main guard logic |
|||
main() { |
|||
local mode="${1:-}" |
|||
local arg="${2:-}" |
|||
|
|||
log_info "Running Build Architecture Guard..." |
|||
|
|||
# Collect changed files |
|||
changed_files=() |
|||
while IFS= read -r line; do |
|||
[[ -n "$line" ]] && changed_files+=("$line") |
|||
done < <(collect_files "$mode" "$arg") |
|||
|
|||
if [[ ${#changed_files[@]} -eq 0 ]]; then |
|||
log_info "No files changed, guard check passed" |
|||
exit 0 |
|||
fi |
|||
|
|||
log_info "Checking ${#changed_files[@]} changed files..." |
|||
|
|||
# Find sensitive files that were touched |
|||
sensitive_touched=() |
|||
for file in "${changed_files[@]}"; do |
|||
if matches_sensitive "$file"; then |
|||
sensitive_touched+=("$file") |
|||
fi |
|||
done |
|||
|
|||
# If no sensitive files were touched, allow the change |
|||
if [[ ${#sensitive_touched[@]} -eq 0 ]]; then |
|||
log_success "No build-sensitive files changed, guard check passed" |
|||
exit 0 |
|||
fi |
|||
|
|||
# Sensitive files were touched, log them |
|||
log_warn "Build-sensitive paths changed:" |
|||
for file in "${sensitive_touched[@]}"; do |
|||
echo " - $file" |
|||
done |
|||
|
|||
# Enhanced validation for Android changes |
|||
validate_android_changes "${changed_files[@]}" |
|||
|
|||
# Collect feedback data for continuous improvement |
|||
collect_feedback_data "$mode" "${sensitive_touched[@]}" |
|||
|
|||
# Check if required documentation was updated |
|||
if check_docs_updated "${changed_files[@]}"; then |
|||
log_success "BUILDING.md updated alongside build changes, guard check passed" |
|||
exit 0 |
|||
else |
|||
# Enhanced error handling with Android-specific guidance |
|||
handle_documentation_error "${sensitive_touched[@]}" |
|||
exit 2 |
|||
fi |
|||
} |
|||
|
|||
# Handle help flag |
|||
if [[ "${1:-}" =~ ^(-h|--help)$ ]]; then |
|||
echo "Build Architecture Guard Script" |
|||
echo |
|||
echo "Usage:" |
|||
echo " $0 [--staged|--range [RANGE]]" |
|||
echo |
|||
echo "Options:" |
|||
echo " --staged Check staged files (for pre-commit hook)" |
|||
echo " --range [RANGE] Check git range (for pre-push hook)" |
|||
echo " Default range: HEAD~1..HEAD" |
|||
echo " (no args) Check working directory changes" |
|||
echo " --feedback Show feedback analysis (for maintainers)" |
|||
echo |
|||
echo "Examples:" |
|||
echo " $0 --staged # Pre-commit check" |
|||
echo " $0 --range origin/main..HEAD # Pre-push check" |
|||
echo " $0 # Working directory check" |
|||
echo " $0 --feedback # Analyze guard effectiveness" |
|||
exit 0 |
|||
fi |
|||
|
|||
# Handle feedback analysis |
|||
if [[ "${1:-}" == "--feedback" ]]; then |
|||
if [[ -f ".guard-feedback.log" ]]; then |
|||
echo "Build Architecture Guard Feedback Analysis" |
|||
echo "==========================================" |
|||
echo |
|||
echo "Recent guard executions:" |
|||
echo |
|||
tail -20 ".guard-feedback.log" | while IFS= read -r line; do |
|||
if [[ "$line" =~ ^\[ ]]; then |
|||
echo "📅 $line" |
|||
elif [[ "$line" =~ ^\s*Sensitive\ files: ]]; then |
|||
echo "🔍 $line" |
|||
elif [[ "$line" =~ ^\s*Android\ changes ]]; then |
|||
echo "🤖 $line" |
|||
elif [[ "$line" =~ ^\s*Asset\ config ]]; then |
|||
echo "🎨 $line" |
|||
elif [[ "$line" =~ ^\s*$ ]]; then |
|||
echo "" |
|||
else |
|||
echo " $line" |
|||
fi |
|||
done |
|||
echo |
|||
echo "💡 Use this data to improve guard patterns and documentation" |
|||
echo "📊 Total executions: $(grep -c "Guard execution" .guard-feedback.log 2>/dev/null || echo "0")" |
|||
else |
|||
echo "No feedback data available yet. Run the guard to collect data." |
|||
fi |
|||
exit 0 |
|||
fi |
|||
|
|||
main "$@" |
@ -0,0 +1,19 @@ |
|||
#!/usr/bin/env bash |
|||
set -euo pipefail |
|||
|
|||
echo "🔧 Auto-fixing markdown formatting..." |
|||
|
|||
# Check if markdownlint is available |
|||
if ! command -v npx &> /dev/null; then |
|||
echo "❌ npx not found. Please install Node.js and npm first." |
|||
exit 1 |
|||
fi |
|||
|
|||
# Run markdownlint with auto-fix on project markdown files (exclude node_modules) |
|||
echo "📝 Fixing project markdown files..." |
|||
npx markdownlint "*.md" "*.mdc" "scripts/**/*.md" "src/**/*.md" "test-playwright/**/*.md" "resources/**/*.md" --config .markdownlint.json --fix 2>/dev/null || { |
|||
echo "⚠️ Some issues could not be auto-fixed. Check manually." |
|||
} |
|||
|
|||
echo "✅ Markdown auto-fix complete!" |
|||
echo "💡 Run 'npm run markdown:check' to verify all issues are resolved." |
@ -0,0 +1,214 @@ |
|||
#!/bin/bash |
|||
|
|||
# Setup Markdown Pre-commit Hooks |
|||
# This script installs pre-commit hooks that automatically fix markdown formatting |
|||
|
|||
set -e |
|||
|
|||
echo "🔧 Setting up Markdown Pre-commit Hooks..." |
|||
|
|||
# Check if pre-commit is installed |
|||
if ! command -v pre-commit &> /dev/null; then |
|||
echo "📦 Installing pre-commit..." |
|||
pip install pre-commit |
|||
else |
|||
echo "✅ pre-commit already installed" |
|||
fi |
|||
|
|||
# Create .pre-commit-config.yaml if it doesn't exist |
|||
if [ ! -f .pre-commit-config.yaml ]; then |
|||
echo "📝 Creating .pre-commit-config.yaml..." |
|||
cat > .pre-commit-config.yaml << 'EOF' |
|||
repos: |
|||
- repo: https://github.com/igorshubovych/markdownlint-cli |
|||
rev: v0.38.0 |
|||
hooks: |
|||
- id: markdownlint |
|||
args: [--fix, --config, .markdownlint.json] |
|||
files: \.(md|mdc)$ |
|||
description: "Auto-fix markdown formatting issues" |
|||
stages: [commit] |
|||
additional_dependencies: [markdownlint-cli] |
|||
|
|||
- repo: local |
|||
hooks: |
|||
- id: markdown-format-check |
|||
name: Markdown Format Validation |
|||
entry: bash -c 'echo "Checking markdown files..." && npx markdownlint --config .markdownlint.json "$@"' |
|||
language: system |
|||
files: \.(md|mdc)$ |
|||
stages: [commit] |
|||
description: "Validate markdown formatting" |
|||
pass_filenames: true |
|||
|
|||
- repo: local |
|||
hooks: |
|||
- id: markdown-line-length |
|||
name: Markdown Line Length Check |
|||
entry: bash -c ' |
|||
for file in "$@"; do |
|||
if [[ "$file" =~ \.(md|mdc)$ ]]; then |
|||
echo "Checking line length in $file..." |
|||
if grep -q ".\{81,\}" "$file"; then |
|||
echo "❌ Line length violations found in $file" |
|||
echo "Lines exceeding 80 characters:" |
|||
grep -n ".\{81,\}" "$file" | head -5 |
|||
exit 1 |
|||
fi |
|||
fi |
|||
done |
|||
' |
|||
language: system |
|||
files: \.(md|mdc)$ |
|||
stages: [commit] |
|||
description: "Check markdown line length (80 chars max)" |
|||
pass_filenames: true |
|||
|
|||
- repo: local |
|||
hooks: |
|||
- id: markdown-blank-lines |
|||
name: Markdown Blank Line Validation |
|||
entry: bash -c ' |
|||
for file in "$@"; do |
|||
if [[ "$file" =~ \.(md|mdc)$ ]]; then |
|||
echo "Checking blank lines in $file..." |
|||
# Check for multiple consecutive blank lines |
|||
if grep -q "^$" "$file" && grep -A1 "^$" "$file" | grep -q "^$"; then |
|||
echo "❌ Multiple consecutive blank lines found in $file" |
|||
exit 1 |
|||
fi |
|||
# Check for missing blank lines around headings |
|||
if grep -B1 "^##" "$file" | grep -v "^##" | grep -v "^$" | grep -v "^--"; then |
|||
echo "❌ Missing blank line before heading in $file" |
|||
exit 1 |
|||
fi |
|||
fi |
|||
done |
|||
' |
|||
language: system |
|||
files: \.(md|mdc)$ |
|||
stages: [commit] |
|||
description: "Validate markdown blank line formatting" |
|||
pass_filenames: true |
|||
EOF |
|||
echo "✅ Created .pre-commit-config.yaml" |
|||
else |
|||
echo "✅ .pre-commit-config.yaml already exists" |
|||
fi |
|||
|
|||
# Install the pre-commit hooks |
|||
echo "🔗 Installing pre-commit hooks..." |
|||
pre-commit install |
|||
|
|||
# Install markdownlint if not present |
|||
if ! command -v npx &> /dev/null; then |
|||
echo "📦 Installing Node.js dependencies..." |
|||
npm install --save-dev markdownlint-cli |
|||
else |
|||
if ! npx markdownlint --version &> /dev/null; then |
|||
echo "📦 Installing markdownlint-cli..." |
|||
npm install --save-dev markdownlint-cli |
|||
else |
|||
echo "✅ markdownlint-cli already available" |
|||
fi |
|||
fi |
|||
|
|||
# Create a markdown auto-fix script |
|||
echo "📝 Creating markdown auto-fix script..." |
|||
cat > scripts/fix-markdown.sh << 'EOF' |
|||
#!/bin/bash |
|||
|
|||
# Auto-fix markdown formatting issues |
|||
# Usage: ./scripts/fix-markdown.sh [file_or_directory] |
|||
|
|||
set -e |
|||
|
|||
FIX_MARKDOWN() { |
|||
local target="$1" |
|||
|
|||
if [ -f "$target" ]; then |
|||
# Fix single file |
|||
if [[ "$target" =~ \.(md|mdc)$ ]]; then |
|||
echo "🔧 Fixing markdown formatting in $target..." |
|||
npx markdownlint --fix "$target" || true |
|||
fi |
|||
elif [ -d "$target" ]; then |
|||
# Fix all markdown files in directory |
|||
echo "🔧 Fixing markdown formatting in $target..." |
|||
find "$target" -name "*.md" -o -name "*.mdc" | while read -r file; do |
|||
echo " Processing $file..." |
|||
npx markdownlint --fix "$file" || true |
|||
done |
|||
else |
|||
echo "❌ Target $target not found" |
|||
exit 1 |
|||
fi |
|||
} |
|||
|
|||
# Default to current directory if no target specified |
|||
TARGET="${1:-.}" |
|||
FIX_MARKDOWN "$TARGET" |
|||
|
|||
echo "✅ Markdown formatting fixes applied!" |
|||
echo "💡 Run 'git diff' to see what was changed" |
|||
EOF |
|||
|
|||
chmod +x scripts/fix-markdown.sh |
|||
|
|||
# Create a markdown validation script |
|||
echo "📝 Creating markdown validation script..." |
|||
cat > scripts/validate-markdown.sh << 'EOF' |
|||
#!/bin/bash |
|||
|
|||
# Validate markdown formatting without auto-fixing |
|||
# Usage: ./scripts/validate-markdown.sh [file_or_directory] |
|||
|
|||
set -e |
|||
|
|||
VALIDATE_MARKDOWN() { |
|||
local target="$1" |
|||
|
|||
if [ -f "$target" ]; then |
|||
# Validate single file |
|||
if [[ "$target" =~ \.(md|mdc)$ ]]; then |
|||
echo "🔍 Validating markdown formatting in $target..." |
|||
npx markdownlint "$target" |
|||
fi |
|||
elif [ -d "$target" ]; then |
|||
# Validate all markdown files in directory |
|||
echo "🔍 Validating markdown formatting in $target..." |
|||
find "$target" -name "*.md" -o -name "*.mdc" | while read -r file; do |
|||
echo " Checking $file..." |
|||
npx markdownlint "$file" || true |
|||
done |
|||
else |
|||
echo "❌ Target $target not found" |
|||
exit 1 |
|||
fi |
|||
} |
|||
|
|||
# Default to current directory if no target specified |
|||
TARGET="${1:-.}" |
|||
VALIDATE_MARKDOWN "$TARGET" |
|||
|
|||
echo "✅ Markdown validation complete!" |
|||
EOF |
|||
|
|||
chmod +x scripts/validate-markdown.sh |
|||
|
|||
echo "" |
|||
echo "🎉 Markdown Pre-commit Hooks Setup Complete!" |
|||
echo "" |
|||
echo "📋 What was installed:" |
|||
echo " ✅ pre-commit hooks for automatic markdown formatting" |
|||
echo " ✅ .pre-commit-config.yaml with markdown rules" |
|||
echo " ✅ scripts/fix-markdown.sh for manual fixes" |
|||
echo " ✅ scripts/validate-markdown.sh for validation" |
|||
echo "" |
|||
echo "🚀 Usage:" |
|||
echo " • Hooks run automatically on commit" |
|||
echo " • Manual fix: ./scripts/fix-markdown.sh [file/dir]" |
|||
echo " • Manual check: ./scripts/validate-markdown.sh [file/dir]" |
|||
echo " • Test hooks: pre-commit run --all-files" |
|||
echo "" |
|||
echo "💡 The hooks will now automatically fix markdown issues before commits!" |
@ -0,0 +1,19 @@ |
|||
#!/usr/bin/env bash |
|||
set -euo pipefail |
|||
|
|||
echo "🔍 Validating markdown formatting..." |
|||
|
|||
# Check if markdownlint is available |
|||
if ! command -v npx &> /dev/null; then |
|||
echo "❌ npx not found. Please install Node.js and npm first." |
|||
exit 1 |
|||
fi |
|||
|
|||
# Run markdownlint on project markdown files (exclude node_modules) |
|||
echo "📝 Checking project markdown files..." |
|||
npx markdownlint "*.md" "*.mdc" "scripts/**/*.md" "src/**/*.md" "test-playwright/**/*.md" "resources/**/*.md" --config .markdownlint.json 2>/dev/null || { |
|||
echo "❌ Markdown validation failed. Run 'npm run markdown:fix' to auto-fix issues." |
|||
exit 1 |
|||
} |
|||
|
|||
echo "✅ All markdown files pass validation!" |
Loading…
Reference in new issue