Commit graph

44 commits

Author SHA1 Message Date
Snider
0955847661 refactor(i18n): move Message struct to interface.go
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:59:33 +00:00
Snider
1477bceb95 refactor(i18n): consolidate interfaces in interface.go
Move MissingKeyHandler, MissingKey, MissingKeyAction, and PluralRule
function types to interface.go for better discoverability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:57:57 +00:00
Snider
b2448fa5f2 refactor(i18n): extract JSON flattening to mutate.go
Move flatten and flattenWithGrammar functions to dedicated file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:54:03 +00:00
Snider
c331c29c05 refactor(i18n): extract type checks to check.go
Move isVerbFormObject, isNounFormObject, hasPluralCategories,
isPluralObject to dedicated file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:51:46 +00:00
Snider
2d1dbcc473 refactor(i18n): extract Service to service.go
Move Service struct, methods, constructors, and singleton management
to dedicated file for better code organization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:50:25 +00:00
Snider
12a77a63cb refactor(i18n): extract type conversions to transform.go
Move getCount, toInt, toInt64, toFloat64 helpers to dedicated file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:46:49 +00:00
Snider
282be9c7bc feat(i18n): add localized time formatting helpers
- Add TimeAgo(t time.Time) for relative time strings
- Add FormatAgo(count, unit) for "N units ago" composition
- Add i18n.ago namespace pattern: T("i18n.ago", 5, "minute")
- Uses existing time.ago.{unit} keys with CLDR pluralization
- Remove local formatTimeAgo from cmd/php in favor of i18n.TimeAgo

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:44:42 +00:00
Snider
7d1b1809cb feat(i18n): add localized number formatting helpers
New i18n.* namespace patterns for number formatting:
- T("i18n.number", 1234567) → "1,234,567" (en) / "1.234.567" (de)
- T("i18n.decimal", 1234.56) → "1,234.56" (en) / "1.234,56" (de)
- T("i18n.percent", 0.85) → "85%" (en) / "85 %" (de)
- T("i18n.bytes", 1536000) → "1.5 MB" (en) / "1,5 MB" (de)
- T("i18n.ordinal", 3) → "3rd" (en) / "3." (de)

Also available as direct functions:
- FormatNumber(n), FormatDecimal(f), FormatPercent(f)
- FormatBytes(n), FormatOrdinal(n)

Language-aware formatting for en, de, fr, es, zh.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:39:15 +00:00
Snider
5e55f66de9 refactor(i18n): rename core.* namespace to i18n.*
More self-documenting: when you see T("i18n.label.status") it's
immediately clear the i18n package is composing it, not looking up a key.

- T("i18n.label.status") → "Status:"
- T("i18n.progress.build") → "Building..."
- T("i18n.count.file", 5) → "5 files"
- T("i18n.done.delete", "file") → "File deleted"
- T("i18n.fail.delete", "file") → "Failed to delete file"

Intent keys (core.delete, core.install, etc.) remain unchanged -
they're semantic intent names, not i18n namespace patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:32:08 +00:00
Snider
39de3c2836 refactor(i18n): slim locale files using composable grammar
Reduce locale files from ~4600 to 338 total lines (93% reduction):
- en_GB.json: 1520 → 262 lines (83% reduction)
- en_US.json: ~1500 → 10 lines (US spelling overrides only)
- en_AU.json: ~1500 → 2 lines (inherits from en_GB)
- de.json: 120 → 64 lines

Removed redundant entries that can now be composed via core.* patterns:
- Labels: T("core.label.status") → "Status:"
- Counts: T("core.count.item", 5) → "5 items"
- Progress: T("core.progress.build") → "Building..."
- Done/Fail: T("core.done.build", subj) → "Build completed"

Updated tests to use new key patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:24:23 +00:00
Snider
621540433b test(i18n): add core.* namespace tests
Tests for core.label, core.progress, core.count, core.done, core.fail
patterns. Also tests Raw() bypasses core.* magic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:58:37 +00:00
Snider
cbe44d28f0 feat(i18n): add core.* namespace magic in T()
T() now auto-composes grammar patterns for core.* keys:
- core.label.{word} → "Status:"
- core.progress.{verb} → "Building..."
- core.count.{noun}, n → "5 files"
- core.done.{verb}, subj → "File deleted"
- core.fail.{verb}, subj → "Failed to delete file"

_() and Raw() do direct key lookup without magic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:57:34 +00:00
Snider
62e5b0b75a feat(i18n): add composable grammar for minimal locale files
Extend grammar system to support base words and punctuation rules:
- gram.word.* for base word translations
- gram.punct.label for language-specific label suffix (FR: " :")
- gram.punct.progress for progress suffix

Label() and Progress() are now language-aware:
- L("status") → EN: "Status:" / FR: "Statut :"
- P("build")  → EN: "Building..." / FR: "Construction..."

This enables ~80% reduction in locale file size by composing
phrases at runtime instead of storing every variant.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:43:52 +00:00
Snider
92f734e756 refactor(i18n): simplify missing key handler API
Rename MissingKeyAction to MissingKey and add OnMissingKey() handler.
Keeps focus on missing keys only for QA - no unnecessary trace overhead.

- MissingKey: dispatched when T()/C() can't find a key in ModeCollect
- OnMissingKey(): register handler for missing key events
- SetActionHandler(): deprecated, use OnMissingKey()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:36:55 +00:00
Snider
8ea2bdf716 refactor(i18n): extract debug functionality to debug.go
Move debug mode code to dedicated file for better code comprehension.
Go's package-level file globbing allows splitting functionality
across files while maintaining a single cohesive package.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:31:52 +00:00
Snider
4a8db3bcbc refactor(i18n): rename common.{verb,noun,article} to gram.*
Move grammar data (verbs, nouns, articles) from "common" to "gram"
namespace - a tribute to Gram (grandmother) and short for grammar.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:28:29 +00:00
Snider
94723454a8 feat(i18n): add compile-time key validation tool
Adds cmd/i18n-validate that scans Go source files for i18n key usage
and validates them against locale JSON files and registered intents.

Features:
- Scans T(), C(), I(), and qualified i18n.* calls
- Expands ./... pattern to find all Go packages
- Validates message keys against locale JSON files
- Validates intent keys against registered core.* intents
- Reports missing keys with file:line locations
- Skips constant references (type-safe usage)

Usage:
  go run ./cmd/i18n-validate ./...
  task i18n:validate

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:18:58 +00:00
Snider
829be45fcc feat(i18n): add remaining API features for stability
Implements the final features from the semantic i18n plan:

- Template caching: sync.Map cache for compiled templates
- Translator interface: enables mocking for tests
- Custom intent registration: thread-safe RegisterIntents(), UnregisterIntent()
- JSON-based grammar: verb/noun forms in locale files, checked before computed
- Fallback chain: T() tries common.action.{verb} and common.{verb}
- CLI enhancements: Timeout(), Filter(), Multi() options, ChooseMulti()
- Intent key constants: type-safe IntentCore* and Key* constants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:11:58 +00:00
Snider
46f6d4c5fe feat(i18n): add Phase 4 extended language support
Fluent Intent Builder API:
- I("core.delete").For(S("file", path)).Question()
- I("core.delete").With(subject).Compose()
- Convenience methods: Question(), Success(), Failure(), Meta(), IsDangerous()

Formality Levels (for Sie/du, vous/tu languages):
- FormalityNeutral, FormalityInformal, FormalityFormal constants
- Subject.Formal(), Subject.Informal(), Subject.Formality()
- Service.SetFormality(), Service.Formality()
- Package-level SetFormality()

CLDR Plural Categories:
- PluralZero, PluralOne, PluralTwo, PluralFew, PluralMany, PluralOther
- Language-specific plural rules: English, German, French, Spanish, Russian, Polish, Arabic, Chinese, Japanese, Korean
- Message.ForCategory() for proper plural selection
- Service.PluralCategory() for getting category by count

RTL Text Direction Support:
- TextDirection type (DirLTR, DirRTL)
- IsRTLLanguage() for language detection
- Service.Direction(), Service.IsRTL()
- Package-level Direction(), IsRTL()

GrammaticalGender type:
- GenderNeuter, GenderMasculine, GenderFeminine, GenderCommon
- For future gender agreement in gendered languages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:55:41 +00:00
Snider
fa6d62e385 feat(i18n): add debug mode and NewSubject alias
- Add SetDebug()/Debug() methods for showing key prefixes in output
- Debug mode shows: "[cli.success] Success" instead of "Success"
- Add NewSubject() as alias for S() for readability
- Both T() and C() respect debug mode

Debug mode is useful for:
- Identifying which translation keys are used where
- Verifying correct key usage during development
- QA testing of translation coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:47:28 +00:00
Snider
fc74d4df9c refactor(i18n): use grammar engine for progress messages
- Replace cli.progress.* keys with i18n.P() dynamic generation
- Remove 7 static progress keys from en_GB.json (building, checking, etc.)
- Add additional core.* intents (format, analyse, link, unlink, fetch, etc.)
- Add grammar helpers: Progress(), ProgressSubject(), ActionResult(), Label()
- Add package-level convenience functions: P(), PS(), L()
- Update commands to use common.prompt.abort instead of cli.confirm.abort

The grammar engine now generates progress messages dynamically:
  i18n.P("check")  → "Checking..."
  i18n.P("fetch")  → "Fetching..."

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:43:03 +00:00
Snider
f85064a954 feat(i18n): implement semantic i18n system with grammar engine
Add semantic intent system for natural language CLI interactions:

- Mode system (Normal/Strict/Collect) for missing key handling
- Subject type with fluent builder for typed subjects
- Composed type with Question/Confirm/Success/Failure forms
- 30+ core.* intents (delete, create, commit, push, etc.)
- Grammar engine: verb conjugation, noun pluralization, articles
- Template functions: title, lower, upper, past, plural, article
- Enhanced CLI: Confirm with options, Question, Choose functions
- Collect mode handler for QA testing

Usage:
  i18n.T("core.delete", i18n.S("file", "config.yaml"))
  result := i18n.C("core.delete", subject)
  cli.ConfirmIntent("core.delete", subject)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:29:44 +00:00
Snider
6f6ee99008 refactor(i18n): consolidate 85 keys into reusable templates
Replace specific messages with parameterized templates:

- 60 "failed to X" errors -> common.error.failed + Action
- 10 "Running X" messages -> common.progress.running + Task
- 4 "Checking X" messages -> common.progress.checking + Item
- 13 "X successfully" messages -> common.success.completed + Action

This reduces translation maintenance - translators only need to
translate 3 templates instead of 85 individual messages.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:44:45 +00:00
Snider
bcf74fe84e refactor(i18n): use common.error.failed template for all error messages
Replace specific error keys with the generic template:
- common.error.working_dir -> common.error.failed + Action
- common.error.load_config -> common.error.failed + Action
- common.error.build_failed -> common.error.failed + Action
- common.error.get_logs -> common.error.failed + Action
- common.error.tests_failed -> common.error.failed + Action

This reduces 5 duplicate error keys to 1 reusable template:
"Failed to {{.Action}}"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:35:38 +00:00
Snider
3169728d3a refactor(i18n): consolidate duplicate translation keys into common section
Add common.* keys for reusable translations:
- common.label.* - UI labels (error, done, status, version, etc.)
- common.status.* - status words (running, stopped, dirty, synced)
- common.error.* - error messages (failed, not_found, working_dir)
- common.flag.* - CLI flag descriptions (registry, verbose, etc.)
- common.count.* - count templates (failed, passed, skipped)
- common.result.* - result messages (all_passed, no_issues)
- common.progress.* - progress messages (running, checking)
- common.hint.* - help hints (install_with, fix_deps)

Update all cmd/* files to use common keys instead of duplicated
command-specific keys. Reduces translation maintenance burden
and ensures consistency across the CLI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:32:25 +00:00
Snider
a00a3240a6 refactor(i18n): use nested JSON format for translation files
- Rewrite i18n package to handle nested JSON natively
- Remove go-i18n dependency in favour of simple custom implementation
- Flatten nested keys to dot notation internally (cli.confirm.yes)
- Support pluralisation with one/other keys
- Template interpolation with {{.Var}} syntax
- Update tests for new API and nested structure

Nested JSON is the standard format for translation tools,
making it easier to manage with external translation services.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:11:07 +00:00
Snider
a0f4baafad feat(framework): add core DI framework and improve dev commands
- Add pkg/framework/core with GUI-agnostic DI/service framework
  (extracted from core-gui, Wails dependencies removed)
- Add pkg/agentic/prompts with embedded commit instructions
- Improve dev push: detect uncommitted changes, offer Claude commit
- Add claudeEditCommit for cases needing Write/Edit permissions
- Add i18n keys for diverged branches and uncommitted changes
- Fix infinite loop when only untracked files remain after commit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:02:16 +00:00
Snider
58596ea00e feat(push): handle diverged branches with pull-and-retry
When push fails due to non-fast-forward rejection (local and remote
have diverged), offer to pull with rebase and retry the push instead
of just failing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:02:27 +00:00
Snider
2252d6bda1 feat(i18n): add regional English variants with en_GB as default
- Rename en.json to en_GB.json (British English)
- Add en_US.json with American spellings (color, analyze, etc.)
- Add en_AU.json for Australian English
- Set BritishEnglish as the bundle default language

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:48:36 +00:00
Snider
e8e48127c2 feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm

Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
Snider
0c3bccfceb feat(i18n): add internationalization package for CLI
- Service with embedded locale files (en, de)
- Auto-detect system language from LANG/LC_* env vars
- Template support for interpolation and pluralization
- Extensible: GUI can load additional translations via LoadFS()
- Global default service with T() shorthand
- Thread-safe with sync.RWMutex

Designed to be extended by core-gui which can import this
package and add GUI-specific translations on top.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 01:42:53 +00:00
Snider
dbe617c23e refactor: remove GUI packages for CGO-free CLI
Move all Wails-dependent packages to core-gui repo:
- pkg/core, pkg/display, pkg/docs, pkg/help, pkg/ide
- pkg/runtime, pkg/webview, pkg/workspace, pkg/ws
- pkg/plugin, pkg/config, pkg/i18n, pkg/module
- pkg/crypt, pkg/io, pkg/process

Add pkg/errors with simple E() helper for error wrapping.
Update go.work to only include CLI-relevant packages.
CLI now builds with CGO_ENABLED=0 - no linker warnings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:15:01 +00:00
Snider
5e0252b5ee chore(deps): sync go modules after SDK implementation
Updates go.mod and go.sum files across all workspace modules
after adding oasdiff and kin-openapi dependencies for SDK generation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 01:29:39 +00:00
Snider
9fe47a9bc6 feat(build): implement core build system with cross-compilation
Add pkg/build package replacing goreleaser with native build system:

- Project discovery (go.mod, wails.json, package.json, composer.json)
- Go cross-compilation with GOOS/GOARCH, CGO_ENABLED=0, ldflags
- Config loading from .core/build.yaml with sensible defaults
- Archive creation (tar.gz for linux/darwin, zip for windows)
- SHA256 checksum generation with CHECKSUMS.txt

CLI integration via `core build`:
- Auto-detect project type or specify with --type
- Cross-compile with --targets (e.g., linux/amd64,darwin/arm64)
- CI mode with --ci for JSON output
- Archive/checksum flags (--archive, --checksum)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:59:02 +00:00
Snider
41a0faba75 refactor: migrate module path from Snider/Core to host-uk/core
Move Go module from github.com/Snider/Core to github.com/host-uk/core
to match the new repository location under the host-uk organization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:29:42 +00:00
Snider
858c9b4462 fix(dependencies): update golang.org/x modules to latest versions 2026-01-28 15:19:39 +00:00
Snider
0ad5c09ee6 feat: add initial project structure with configuration files and components 2026-01-15 22:46:50 +00:00
Snider
8acdb10eb6 Merge branch 'main' into dev
Bring in workspace management and IPC event handling features:
- Workspace management features
- IPC event handling
- Config test improvements
- Display improvements (menu, tray, tests)
- i18n test improvements
- Restored pkg/crypt, pkg/io, pkg/runtime, pkg/workspace

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 15:36:00 +00:00
Snider
4e02d5bc97 refactor: bring external packages home and restructure
- Imported packages from separate repos:
  - github.com/Snider/config -> pkg/config
  - github.com/Snider/display -> pkg/display
  - github.com/Snider/help -> pkg/help
  - github.com/Snider/i18n -> pkg/i18n
  - github.com/Snider/updater -> pkg/updater
- Moved core code from root to pkg/core
- Flattened nested package structures
- Updated all import paths to github.com/Snider/Core/pkg/*
- Added Display interface to Core
- Updated go.work for workspace modules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 15:30:43 +00:00
Snider
6c366e5ef4 feat(workspace): implement workspace management features and IPC event handling 2026-01-13 23:33:01 +00:00
614aed51ba refactor: Remove config, display, and i18n packages (#26)
Removes the following unused packages:
- pkg/config
- pkg/display
- pkg/i18n

Also removes the dependencies from pkg/runtime and cleans up the go.mod and go.sum files.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-11-13 16:45:48 +00:00
Snider
32f1d0ab5d Feature add tdd core tests (#22)
* feat: Add TDD tests for core package

Adds a new `tdd/` directory for TDD-style contract tests.

Implements a comprehensive test suite for the `pkg/core` package, covering:
- `New()`
- `WithService()`
- `WithName()`
- `WithWails()`
- `WithAssets()`
- `WithServiceLock()`
- `RegisterService()`
- `Service()`
- `ServiceFor()`
- `MustServiceFor()`
- `ACTION()`
- `RegisterAction()`
- `RegisterActions()`

To support testing, a public `Assets()` method was added to the `Core` struct.

* feat: Add TDD tests for e, io, runtime, and config packages

Adds comprehensive TDD tests to the `tdd/` directory for the following packages:
- `pkg/e`
- `pkg/io`
- `pkg/runtime`
- `pkg/config`

This significantly improves the test coverage of the project.

To support testing the `runtime` package, the `newWithFactories` function was exported as `NewWithFactories`.

The existing tests for the `config` package were moved from the `internal` package to the `tdd/` directory and adapted to use the public API.

* fix: Update tdd tests for config, core, and runtime

Updates the TDD tests for the `config`, `core`, and `runtime` packages to improve their coverage and correctness.

- In `tdd/config_test.go`, the `TestIsFeatureEnabled` test is updated to use `s.Set` to modify the `features` slice, ensuring that the persistence logic is exercised.
- In `tdd/core_test.go`, the `TestCore_WithAssets_Good` test is updated to use a real embedded filesystem with `//go:embed` to verify the contents of a test file.
- In `tdd/runtime_test.go`, the `TestNew_Good` test is converted to a table-driven test to cover the happy path, error cases, and a case with a non-nil `application.App`.

* fix: Fix build and improve test coverage

This commit fixes a build failure in the `pkg/runtime` tests and significantly improves the test coverage for several packages.

- Fixes a build failure in `pkg/runtime/runtime_test.go` by updating a call to an exported function.
- Moves TDD tests for `config` and `e` packages into their respective package directories to ensure accurate coverage reporting.
- Adds a new test suite for the `pkg/i18n` package, including a test helper to inject a mock i18n bundle.
- Moves and updates tests for the `pkg/crypt` package to use its public API.
- The coverage for `config` and `e` is now 100%.
- The coverage for `crypt` and `i18n` has been significantly improved.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-11-02 22:29:17 +00:00
Snider
2af6c4ad3e Refactor PGP module with helper functions and error handling title (#8) 2025-10-30 14:18:37 +00:00
Snider
11e65079ac Add documentation for Core modules: Config, Crypt, Display, Docs, IO, and Workspace (#3) 2025-10-27 03:14:50 +00:00