|
1 | | -## Pangu.js |
| 1 | +# GEMINI.md |
2 | 2 |
|
3 | | -Pangu.js is a TypeScript library that automatically adds spacing between Chinese, Japanese, and Korean (CJK) characters and half-width characters (English letters, numbers, and symbols). This improves readability on web pages and in text files. |
4 | | - |
5 | | -The project is structured into a shared core, a browser-specific implementation, and a Node.js-specific implementation. It also includes a command-line interface (CLI) and a Chrome extension. |
6 | | - |
7 | | -### Project Structure |
8 | | - |
9 | | -- **`src/shared`**: The core logic of the library, which is platform-agnostic. |
10 | | -- **`src/node`**: The Node.js-specific implementation, which provides a CLI and can be used to space text files. |
11 | | -- **`src/browser`**: The browser-specific implementation, which uses `MutationObserver` to automatically space web pages. |
12 | | -- **`browser_extensions/chrome`**: The source code for the Chrome extension. |
13 | | -- **`tests`**: The test suite for the project, which includes unit tests and end-to-end tests. |
14 | | - |
15 | | -### How to Build |
16 | | - |
17 | | -The project is built using `vite`. To build the project, run the following command: |
18 | | - |
19 | | -```bash |
20 | | -npm run build |
21 | | -``` |
22 | | - |
23 | | -This will build the library and the Chrome extension. |
24 | | - |
25 | | -### How to Test |
26 | | - |
27 | | -The project uses `vitest` and `playwright` for testing. To run the tests, run the following command: |
28 | | - |
29 | | -```bash |
30 | | -npm run test |
31 | | -``` |
32 | | - |
33 | | -### How to Use |
34 | | - |
35 | | -The library can be used in the browser, in Node.js, or as a CLI. |
36 | | - |
37 | | -**Browser** |
38 | | - |
39 | | -```html |
40 | | -<script src="pangu/dist/browser/pangu.umd.js"></script> |
41 | | -<script> |
42 | | - const text = pangu.spacingText('當你凝視著bug,bug也凝視著你'); |
43 | | - // text = '當你凝視著 bug,bug 也凝視著你' |
44 | | -
|
45 | | - pangu.spacingElementById('main'); |
46 | | - pangu.spacingElementByClassName('comment'); |
47 | | - pangu.spacingElementByTagName('p'); |
48 | | -
|
49 | | - document.addEventListener('DOMContentLoaded', () => { |
50 | | - // listen to any DOM change and automatically perform spacing via MutationObserver() |
51 | | - pangu.autoSpacingPage(); |
52 | | - }); |
53 | | -</script> |
54 | | -``` |
55 | | - |
56 | | -**Node.js** |
57 | | - |
58 | | -```javascript |
59 | | -import pangu from 'pangu'; |
60 | | -// or |
61 | | -const pangu = require('pangu'); |
62 | | - |
63 | | -const text = pangu.spacingText('不能信任那些Terminal或Editor用白底的人'); |
64 | | -// text = '不能信任那些 Terminal 或 Editor 用白底的人' |
65 | | - |
66 | | -const content = await pangu.spacingFile('/path/to/text.txt'); |
67 | | -``` |
68 | | - |
69 | | -**CLI** |
70 | | - |
71 | | -```bash |
72 | | -pangu "與PM戰鬥的人,應當小心自己不要成為PM" |
73 | | -``` |
74 | | - |
75 | | -### Commit Guidelines |
76 | | - |
77 | | -Strive for atomic commits. Each commit should represent a single, logical change. If your work involves multiple unrelated changes (e.g., a bug fix and a documentation update), please separate them into individual commits. This practice helps maintain a clean and understandable project history. |
78 | | - |
79 | | -## Gemini Code Instructions |
80 | | - |
81 | | -### Core Workflow |
82 | | - |
83 | | -Always follow: **Understand → Plan → Implement → Verify** |
84 | | - |
85 | | -1. **Understand**: Analyze the request, understand context, identify constraints, and validate assumptions. Use available tools to gather information. |
86 | | -2. **Plan**: Design a clear approach, anticipate edge cases, and choose the most efficient path. |
87 | | -3. **Implement**: Apply changes using available tools, adhering to project conventions and best practices. |
88 | | -4. **Verify**: Confirm changes by running tests, linters, or build commands as appropriate. |
89 | | - |
90 | | -### Response Guidelines |
91 | | - |
92 | | -- **Concise & Direct**: Aim for minimal output, focusing strictly on the user's query. Avoid conversational filler. |
93 | | -- **No Emojis**: Never use emojis in code, comments, commits, or responses. |
94 | | -- **Clarity over Brevity (When Needed)**: Prioritize clarity for essential explanations or when seeking necessary clarification. |
95 | | -- **Action over Theory**: Show code or tool usage instead of just describing them. |
96 | | -- **Model Selection**: Always use the most powerful available model, even if it means longer response times. |
97 | | - |
98 | | -### Critical Analysis |
99 | | - |
100 | | -- **Challenge Premise**: Question if the proposed problem is the right one to solve. |
101 | | -- **Question Assumptions**: Identify and clarify any underlying assumptions. |
102 | | -- **Propose Alternatives**: Suggest simpler or more effective approaches when applicable. |
103 | | -- **Direct Feedback**: Provide clear and specific feedback on approaches or issues. |
104 | | - |
105 | | -### Implementation Rules |
106 | | - |
107 | | -- **Start Minimal**: Implement the smallest working code that validates the approach. |
108 | | -- **One File Preference**: Prefer modifying existing files over creating new ones unless necessary. |
109 | | -- **Self-Documenting Code**: Prioritize clear naming; add comments sparingly, focusing on *why* rather than *what*. |
110 | | -- **Fast Failure**: Validate inputs early and provide descriptive errors. |
111 | | -- **No Premature Optimization**: Focus on correctness and clarity before optimizing. |
112 | | - |
113 | | -### Automation Guidelines |
114 | | - |
115 | | -- **Reversible Actions**: For actions that are easily reversible (e.g., git commits, file modifications that can be rolled back by git), proceed without explicit confirmation. |
| 3 | +Read @CLAUDE.md |
0 commit comments