This repository is a TypeScript library and CLI that generates initial logos — similar to JS or TS logos — based on specified text, colors, sizes, and other parameters.
AI agents should propose and implement changes in the following order of priority:
- Correctness
- Type safety
- API consistency
- Output determinism
- Maintainability
- Performance
- Language: TypeScript (Strict Mode)
- Runtime: Node.js v18+
- Package Manager: bun
- Bundler: tsup
- Test Runner: vitest
- Module Format: ESM first
- Target: Library + CLI
- The primary goal of this project is to stably generate visually appealing initial logos from short strings.
- Generation results should be as deterministic as possible. The same input must always return the same output.
- Treat SVG as the first-class output format.
- If raster image output such as PNG is added, handle it in the adapter or CLI layer, not in Core.
- Keep Core Logic environment-agnostic — do not directly depend on DOM, Canvas, fs, process, or similar APIs.
- Implement the CLI as a thin interface that calls Core.
- Prefer functional programming; use classes only when necessary.
- Design with pure functions as much as possible — do not introduce hidden state.
anyis prohibited.- Leverage type inference to its fullest; limit explicit type annotations to cases where they are necessary.
- Avoid type assertions whenever possible.
as, double assertions, and non-null assertions (!) are last resorts.- Solve problems using type guards, discriminated unions, generics, and appropriate data structures.
- In library code, use exceptions appropriately and write error messages that help users understand what corrective action to take.
- Do not use
console.login library logic. - Use ESNext syntax.
- Avoid unnecessary abstraction.
- Do not introduce breaking changes without a clear reason.
Structure the implementation into the following layers.
Responsibilities:
- Input validation
- String normalization
- Layout calculation
- Color determination
- SVG string or intermediate representation generation
Constraints:
- Must not depend on Node.js-specific APIs
- Must not depend on browser-specific APIs
- Must not carry CLI concerns into this layer
Responsibilities:
- Converting to output formats other than SVG
- Abstracting runtime environment differences
- File saving and encoding
Constraints:
- Must not break Core's purity
- Dependencies must be contained within the adapter
Responsibilities:
- Receiving arguments
- Resolving input/output paths
- Displaying errors
- Controlling exit codes
Constraints:
- Must not directly modify Core
- Must not contain business logic
- Keep the public API minimal.
- Design exports carefully.
- Do not rename or remove published types or functions without sufficient justification.
- Prefer options grouped by meaning over flat structures that are too shallow.
- Use string unions and
readonlyto make the API easy to autocomplete for users. - Define default values explicitly.
- Prefer predictable behavior over implicit behavior.
- Logo generation logic should prioritize reproducibility and consistency, not just visual appearance.
- Clearly define trimming, case handling, and Unicode treatment for input strings.
- Handle edge cases: empty strings, single characters, two or more characters, emoji, combining characters, and full-width characters.
- When a color is explicitly specified, always use that value.
- When generating colors automatically, use a deterministic method that produces the same color for the same input.
- Ensure sufficient contrast between foreground and background colors.
- When size changes, ensure that padding, border radius, font size, and text position do not break.
- If font dependencies cannot be reduced, document those constraints clearly in both code and documentation.
- In SVG output, avoid unnecessary decimal places and redundant attributes to balance readability and stability.
- Write error messages that help users understand what corrective action to take.
- Distinguish between validation errors, conversion errors, and I/O errors.
- In the CLI, format failure reasons in a human-readable way and return the appropriate exit code.
- Write tests assuming vitest.
- Focus on unit tests for Core.
- For SVG output per string input, do not rely solely on snapshots — explicitly verify important attributes.
- At minimum, test the following cases:
- Empty string
- Single character
- Two characters
- String that is too long
- Japanese text
- Emoji
- Explicitly specified color
- Auto-generated color
- Invalid size specification
- Test that output is stable for identical inputs.
- For the CLI, test argument parsing, file output, and non-zero exit codes on failure.
- Avoid over-optimization for small inputs.
- Prefer designs that do not repeat the same computation.
- Avoid unnecessary string concatenation and heavy transformations.
- Be mindful of bundle size — evaluate new dependencies carefully.
- Keep dependencies minimal.
- Do not add heavy dependencies for a single small operation.
- For any dependency added, verify: necessity, alternatives, size, and maintenance status.
- Do not add Node.js-specific dependencies to Core.
- Treat the CLI as a public tool, not a script.
- Use intuitive option names.
- Prefer clear naming such as
--text,--bg,--fg,--size,--output, and--format. - Consider a design where SVG can be written to stdout.
- File writing should only occur when explicitly specified.
- Keep CLI usage and error messages short and clear.
- Prefer tsup; add complex configuration only when necessary.
- Manage package exports explicitly.
- Separate the library entry point from the CLI entry point.
- Avoid designs that hinder tree-shaking.
- Define
sideEffectsaccurately according to the implementation.
- At minimum, the README must include:
- What the library does
- Installation instructions
- Library usage examples
- CLI usage examples
- Key options
- Output examples
- Constraints
- Prioritize sample code in the documentation that can be run as-is.
- If the implementation and README diverge, update the README as well.
- Before modifying existing code, confirm which layer it belongs to: Core, Adapter, or CLI.
- Prefer small, safe diffs.
- Do not mix in unrelated refactoring.
- Clearly state breaking changes.
- When changing the API, explain the impact from the user's perspective.
- Introducing
any - Unnecessary use of classes
- Mixing environment-dependent APIs into Core
- Using
console.loginside library code - Casual reliance on type assertions
- Adding complex logic without tests
- Adding dependencies without solid justification
When proposing code, follow these rules:
- Briefly describe the change strategy first
- Then show the complete code
- Split by file if necessary
- If existing code is broken, clearly state the affected scope
- Do not over-fill ambiguities with assumptions — state your premises explicitly
Prioritize concrete, implementable proposals over unnecessarily long explanations.