Skip to content

feat(cli): detect project languages and select rule guides with --lang - #69

Merged
amondnet merged 3 commits into
mainfrom
amondnet/65-lang-detection
Oct 23, 2026
Merged

amondnet merged 3 commits into
mainfrom
amondnet/65-lang-detection

Conversation

@amondnet

@amondnet amondnet commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds project language detection to the CLI and a --lang flag that selects which language rule guides init, update, and doctor use. This covers section 2 (language detection) of #65.

  • Detection (root only). Markers at the project root map to a guide: package.json / tsconfig.json → typescript, pubspec.yaml → dart, Cargo.toml → rust, build.gradle(.kts) / pom.xml → java (no Kotlin guide ships), go.mod → go, pyproject.toml → python. Several languages can match at once. Detection depth decision: root only, no workspace walking.
  • --lang <list>. A comma-separated list of ids (the rules/<id>.md names) overrides detection. An unknown value exits 1 and lists the accepted languages. --lang ko|en stays as the deprecated locale alias, and a mix such as ko,dart is rejected.
  • init. Detected languages are pre-selected in a multiselect. --yes uses the detection result.
  • update. Keeps the languages the existing AGENTS.md block already links, which answers the feat(cli): detect languages, run without package.json, and split rules into rules/<lang>.md #65 open question "where to record the selected languages". --lang overrides it. A legacy or missing block falls back to detection.
  • AGENTS.md block. Links the general guide plus each selected guide. The TypeScript-specific bullets appear only when typescript is selected.
  • doctor. Prints the detected languages.
  • Docs. Help text, both READMEs, both cli.mdx pages, and the rules.md index.

Related issue

Refs #65 (stays open: this is one step of it).

Notes for reviewers

  • The old test asserting that --lang dart is an error was replaced, because dart is now a valid language.
  • The invalid-locale result no longer carries a flag field.
  • Existing AGENTS.md tests now write a package.json fixture so the TypeScript expectations still hold.
  • Still out of scope, left for later steps of feat(cli): detect languages, run without package.json, and split rules into rules/<lang>.md #65: running without a package.json, and writing guides into the project instead of node_modules.

Verification

  • 285 tests pass, 0 fail.
  • tsc clean, eslint clean, docs build and lint:docs clean.
  • Manual smoke of init, update, and doctor in a project with package.json and pubspec.yaml.

Checklist

  • PR title follows Conventional Commits
  • Packages build (bun run build)
  • Lint/format pass (bun run lint)
  • Documentation updated if behavior changed
  • No breaking change, or a BREAKING CHANGE: note is included

Summary by cubic

Adds project language detection to the CLI and a --lang flag that selects which language rule guides init, update, and doctor use.

New Features

  • Detects languages from root marker files (package.json/tsconfig.json, pubspec.yaml, Cargo.toml, build.gradle(.kts)/pom.xml, go.mod, pyproject.toml)
  • --lang <list> overrides detection; unknown values exit 1 and list accepted languages
  • init pre-selects detected languages; update keeps the languages the existing AGENTS.md block links, falling back to detection for legacy or missing blocks
  • doctor reports detected languages, or the --lang selection when given
  • AGENTS.md block links the general guide plus each selected guide, with TypeScript bullets only for typescript

Behavior Changes

  • --lang ko|en stays a deprecated locale alias and now selects no languages; mixes like ko,dart are rejected

Written for commit a3aa56b. Summary will update on new commits.

Turn on auto-fix

Demo

doctor detecting typescript and dart, update --lang rust,dart linking the selected guides, a bare update keeping them, and --lang kotlin exiting 1 with the accepted list

Detect languages from root markers: package.json/tsconfig.json, pubspec.yaml,
Cargo.toml, build.gradle(.kts)/pom.xml, go.mod, and pyproject.toml.
--lang <list> overrides detection; an unknown value exits 1 and lists the
accepted languages.
init pre-selects the detected languages. update keeps the languages the
existing AGENTS.md block already links.
The block links the general guide plus each selected guide, and shows the TS
bullets only for typescript. doctor reports the detected languages.

Refs #65

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces programming language detection and language-specific rule linking to the CLI. It adds a --lang <list> flag, implements automatic language detection from root marker files, and updates the init, update, and doctor commands to support these languages. The AGENTS.md generation is refactored to dynamically link the general guide and the selected language guides, conditionally including TypeScript rules. Feedback suggests moving TypeScript-specific test mirroring examples and framework mentions from the general block (AGENTS_GENERAL) to the TypeScript-specific block (AGENTS_TYPESCRIPT) to prevent irrelevant noise in non-TypeScript projects.

Comment thread packages/cli/src/appliers.ts
@codacy-production

codacy-production Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 high

View in Codacy

🟢 Metrics 67 complexity · 0 duplication

Metric Results
Complexity 67
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@amondnet
amondnet marked this pull request as ready for review October 23, 2026 13:40
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

Adds root-level language detection and --lang selection for rule guides.

  • CLI commands detect project languages and accept explicit guide lists.
  • AGENTS.md links to the general guide and the selected language guides.

Reviews (3) · Last reviewed commit: "chore(cli): apply AI code review suggest..." · Reviewed by Greptile

Comment thread packages/cli/src/languages.ts
Move the TypeScript test-layout bullet out of the general AGENTS.md block, and cover the
v0.1.1 block falling back to language detection.

Refs #65
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Deploying code-style with  Cloudflare Pages  Cloudflare Pages

Latest commit: a3aa56b
Status: ✅  Deploy successful!
Preview URL: https://cdc9c345.code-style.pages.dev
Branch Preview URL: https://amondnet-65-lang-detection.code-style.pages.dev

View logs

@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/src/i18n.ts
Comment thread packages/cli/src/appliers.ts
Comment thread packages/cli/src/commands.ts Outdated
Comment thread packages/cli/src/languages.ts
Comment thread apps/docs/src/content/docs/en/cli.mdx Outdated
Comment thread apps/docs/src/content/docs/en/cli.mdx
doctor reports --lang languages as selected rather than detected, the --lang ko|en
warnings stop promising a future --lang, and the docs describe the update default.

Refs #65
@sonarqubecloud

Copy link
Copy Markdown

@amondnet
amondnet merged commit b4d3274 into main Oct 23, 2026
12 of 13 checks passed
@amondnet
amondnet deleted the amondnet/65-lang-detection branch October 23, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant