-
Notifications
You must be signed in to change notification settings - Fork 662
feat(cli): lingo.dev init cursor Command for .cursorrules Setup (#1101) #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c77b54f
85a1a0e
d59ed3d
2239479
85b681b
6746cec
89ddbff
6df021e
890c58f
8d30df1
55a079a
e864fbf
d657c6d
44f9963
a80466e
5a530f3
4fe3d16
f361eb9
ebe9d6e
13d14a9
00714d9
8e567eb
a068b0e
cdcaa90
6273c63
bd3f99b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "lingo.dev": minor | ||
| --- | ||
|
|
||
| feat: add init cursor command for .cursorrules setup |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Cursor AI i18n Rules | ||
|
|
||
| The following rules and guidelines should be followed to ensure proper internationalization (i18n) support in Cursor AI agents: | ||
|
|
||
| 1. **Use translation keys**: All user-facing strings must use translation keys instead of hardcoded text. Reference the appropriate key from your locale files. | ||
| 2. **Locale files**: Store translations in locale-specific files (e.g., `en.json`, `fr.json`). Ensure all supported languages are kept in sync. | ||
| 3. **Fallback language**: Always provide a fallback language (usually English) for missing translations. | ||
| 4. **Pluralization and formatting**: Use i18n libraries that support pluralization, date, and number formatting according to the user's locale. | ||
| 5. **No concatenation**: Avoid string concatenation for translatable text. Use interpolation features provided by your i18n library. | ||
| 6. **Contextual translations**: Provide context for translators where necessary, especially for ambiguous terms. | ||
| 7. **Testing**: Test agents in multiple locales to ensure all strings are translated and formatting is correct. | ||
|
|
||
| _For more details, refer to the Cursor AI i18n documentation or contact the localization team._ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { ensurePatterns } from "../utils/ensure-patterns"; | |
| import updateGitignore from "../utils/update-gitignore"; | ||
| import initCICD from "../utils/init-ci-cd"; | ||
| import open from "open"; | ||
| import cursorInitCmd from "./init/cursor"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be imported in the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hii @The-Best-Codes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh gosh you might be right on that lol. Let me make sure when I get a chance
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SK8-infi I was wrong about this! So you might do something like this:
...at least, that's what I would do. You can ask a maintainer too if you want more clarification!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to be a systematic approach to me too(beneficial for other agent sub commands). But would require directory changes... Maybe I should ask maintainers' views |
||
|
|
||
| const openUrl = (path: string) => { | ||
| const settings = getSettings(undefined); | ||
|
|
@@ -116,7 +117,6 @@ export default new InteractiveCommand() | |
| throw new Error(`Invalid path: ${p}`); | ||
| } | ||
| } | ||
|
|
||
| return values; | ||
| }) | ||
| .prompt(undefined) // make non-interactive | ||
|
|
@@ -258,4 +258,5 @@ export default new InteractiveCommand() | |
| if (!isInteractive) { | ||
| Ora().info("Please see https://lingo.dev/cli"); | ||
| } | ||
| }); | ||
| }) | ||
| .addCommand(cursorInitCmd); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { InteractiveCommand, InteractiveOption } from "interactive-commander"; | ||
| import Ora from "ora"; | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
| import { fileURLToPath } from "url"; | ||
| import { confirm } from "@inquirer/prompts"; | ||
|
|
||
| // Get the directory of this file (works in both dev and production) | ||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| // Access agents.md from assets directory (bundled with published package) | ||
| const AGENTS_MD = path.resolve(__dirname, "../assets/agents.md"); | ||
| // Create .cursorrules in user's current working directory (their project) | ||
| const CURSORRULES = path.resolve(process.cwd(), ".cursorrules"); | ||
|
|
||
| export default new InteractiveCommand() | ||
| .command("cursor") | ||
| .description( | ||
| "Initialize .cursorrules with i18n-specific instructions for Cursor AI.", | ||
| ) | ||
| .addOption( | ||
| new InteractiveOption( | ||
| "-f, --force", | ||
| "Overwrite .cursorrules without prompt.", | ||
| ).default(false), | ||
| ) | ||
| .action(async (options) => { | ||
| const spinner = Ora(); | ||
| // Read agents.md | ||
| let template: string; | ||
| try { | ||
| template = fs.readFileSync(AGENTS_MD, "utf-8"); | ||
| } catch (err) { | ||
| spinner.fail("Template file agents.md not found. Please reinstall the package."); | ||
| return process.exit(1); | ||
| } | ||
| // Check for existing .cursorrules | ||
| const exists = fs.existsSync(CURSORRULES); | ||
| let shouldWrite; | ||
| if (exists && !options.force) { | ||
| shouldWrite = await confirm({ | ||
| message: ".cursorrules already exists. Overwrite?", | ||
| }); | ||
| if (!shouldWrite) { | ||
| spinner.info("Skipped: .cursorrules left unchanged."); | ||
| return; | ||
| } | ||
| } | ||
| try { | ||
| fs.writeFileSync(CURSORRULES, template); | ||
| spinner.succeed("Created .cursorrules"); | ||
| spinner.info( | ||
| ".cursorrules has been created with i18n-specific instructions for Cursor AI.", | ||
| ); | ||
| } catch (err) { | ||
| spinner.fail(`Failed to write .cursorrules: ${err}`); | ||
| process.exit(1); | ||
| } | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.