{"id":51052386,"url":"https://github.com/neumachen/aiderdesk-conditional-rules","last_synced_at":"2026-06-22T18:03:03.899Z","repository":{"id":363217909,"uuid":"1262371714","full_name":"neumachen/aiderdesk-conditional-rules","owner":"neumachen","description":"AiderDesk extension that loads rule files only when the current task's context contains files matching the rule's globs. Cursor-style on-demand rule selection — drop .mdc files with YAML frontmatter (globs:, alwaysApply:) next to your .md rules and they activate per task automatically.","archived":false,"fork":false,"pushed_at":"2026-06-07T23:30:44.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-08T01:20:45.281Z","etag":null,"topics":["ai-coding-assistant","aider-desk","aider-desk-extension","aiderdesk","aiderdesk-extension","cursor-rules","glob-matching","nodejs","rules","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neumachen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-07T23:12:55.000Z","updated_at":"2026-06-07T23:30:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/neumachen/aiderdesk-conditional-rules","commit_stats":null,"previous_names":["neumachen/aiderdesk-conditional-rules"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/neumachen/aiderdesk-conditional-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neumachen%2Faiderdesk-conditional-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neumachen%2Faiderdesk-conditional-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neumachen%2Faiderdesk-conditional-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neumachen%2Faiderdesk-conditional-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neumachen","download_url":"https://codeload.github.com/neumachen/aiderdesk-conditional-rules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neumachen%2Faiderdesk-conditional-rules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34659898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-coding-assistant","aider-desk","aider-desk-extension","aiderdesk","aiderdesk-extension","cursor-rules","glob-matching","nodejs","rules","typescript"],"created_at":"2026-06-22T18:03:02.883Z","updated_at":"2026-06-22T18:03:03.885Z","avatar_url":"https://github.com/neumachen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aiderdesk-conditional-rules\n\nAiderDesk extension that loads rule files **only when the current task is\nworking on files that match the rule's globs.** Cursor-style on-demand\nrule selection for AiderDesk.\n\nIf you've ever wished AiderDesk would load your Go style rules **only**\nwhen you're editing Go code, and your Docker rules **only** when you're\ntouching a `Dockerfile`, this is that.\n\n## How it works\n\nAiderDesk's native rule loader reads every `.md` file in\n`~/.aider-desk/rules/` and `\u003cproject\u003e/.aider-desk/rules/` into the system\nprompt on every turn. This extension layers conditional loading on top\nby handling **`.mdc` files** in the same directories (the native loader\nignores them).\n\nEach `.mdc` file declares its activation condition via YAML frontmatter:\n\n```yaml\n---\ndescription: Go coding conventions\nglobs:\n  - '**/*.go'\n  - '**/go.mod'\n  - '**/go.sum'\nalwaysApply: false\n---\n# Go Rule: Core Style\n…body of the rule…\n```\n\nOn every agent turn, the extension:\n\n1. Scans `~/.aider-desk/rules/` and `\u003cproject\u003e/.aider-desk/rules/` for\n   `.mdc` files.\n2. Parses each one's YAML frontmatter.\n3. Asks AiderDesk for the **files currently in the task's context.**\n4. Includes a rule when:\n   - `alwaysApply: true`, **or**\n   - at least one `globs:` entry matches at least one context file.\n5. Returns the augmented rule list. AiderDesk's prompt manager reads\n   each included rule from disk verbatim and injects it.\n\nThe decision is **file-glob-driven, not agent-decision-driven.** For a\npolyglot task (Go + Dockerfile in context), Go and Docker rules both\nload. For a Go-only task, only the Go rules load.\n\n## Frontmatter schema\n\nAll fields optional.\n\n| Field         | Type                 | Default | Behaviour                                                                                                                  |\n| ------------- | -------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |\n| `description` | string               | —       | Human-readable. Not used for matching; appears in the prompt so the agent sees a one-liner explaining why the rule loaded. |\n| `globs`       | string \\| string\\[\\] | —       | Patterns matched against context file paths. A single string is treated as comma-separated (`\"**/*.go, **/go.mod\"`).       |\n| `alwaysApply` | boolean              | `false` | When `true`, the rule loads on every turn regardless of globs.                                                             |\n\n| Frontmatter state                                   | Result                      |\n| --------------------------------------------------- | --------------------------- |\n| `alwaysApply: true`                                 | always include              |\n| no frontmatter at all                               | include (defensive default) |\n| `globs:` present, ≥ 1 glob matches ≥ 1 context file | include                     |\n| `globs:` present, no glob matches                   | **exclude**                 |\n\n## Glob matching\n\n- Globs are matched against **two forms** of each context file path:\n  project-relative and absolute. So `**/*.go` matches both `src/foo.go`\n  and `/abs/path/src/foo.go`.\n- Implementation uses [`picomatch`](https://github.com/micromatch/picomatch)\n  with `{ dot: true }` so `.env`-style filenames work.\n- **No glob negation in v0.1.0.** Patterns like `!**/*_test.go` are\n  ignored. Use the body of the rule to handle exclusions.\n- **No subdirectory recursion in v0.1.0.** Only top-level `.mdc` files\n  in each rules directory are scanned.\n\n## File layout\n\nPut `.mdc` files alongside your `.md` rules:\n\n```\n~/.aider-desk/rules/\n├── SECURITY-01-SECRETS.md          # always-on (native loader)\n├── GIT-01-COMMIT-MESSAGES.md       # always-on (native loader)\n├── GOLANG-01-STYLE.mdc             # globs: [\"**/*.go\"]\n├── GOLANG-08-TESTING.mdc           # globs: [\"**/*.go\"]\n├── DOCKER-01-HOST-ACCESS.mdc       # globs: [\"**/Dockerfile*\", …]\n└── PYTHON-01-STYLE.mdc             # globs: [\"**/*.py\"]\n```\n\nThe `.md` files keep their existing always-on behaviour. The `.mdc`\nfiles are handled exclusively by this extension.\n\n## Install\n\n### One-off (current user)\n\n```bash\nnpx @aiderdesk/extensions install https://github.com/neumachen/aiderdesk-conditional-rules \\\n  --directory ~/.aider-desk/extensions\n```\n\nRestart AiderDesk.\n\n### Inside the shiki container image\n\nAdd the GitHub URL to `AIDER_DESK_EXTENSIONS_DEFAULT` in your\n`private_dot_config/exact_shiki/shiki.Dockerfile`:\n\n```dockerfile\nARG AIDER_DESK_EXTENSIONS_DEFAULT=\"…, \\\n    https://github.com/neumachen/aiderdesk-conditional-rules\"\n```\n\nThen rebuild:\n\n```bash\nshiki --rebuild\n```\n\nEvery new shiki session will have the extension active.\n\n## Configuration\n\nThe extension creates `\u003cextensionDir\u003e/config.json` on first save. Schema:\n\n```json\n{\n  \"scanProjectRules\": true,\n  \"scanGlobalRules\": true,\n  \"extraRuleDirs\": \"\"\n}\n```\n\n- `scanProjectRules` — whether to scan `\u003cproject\u003e/.aider-desk/rules/`. Default `true`.\n- `scanGlobalRules` — whether to scan `~/.aider-desk/rules/`. Default `true`.\n- `extraRuleDirs` — comma-separated additional directories to scan.\n  Paths are absolute, `~`-expanded, or relative to the project dir.\n\nThere is no UI config component in v0.1.0; edit the JSON directly if you\nneed to tweak.\n\n## What this does NOT do\n\n- It does not change how `.md` files are loaded. Those remain always-on.\n- It does not change content of any rule file. Frontmatter will appear\n  in the prompt.\n- It does not handle Cursor's `agent_requested` / `manual` modes. Only\n  `alwaysApply` and `globs:` are honoured. (Future v0.2 candidate.)\n- It does not de-duplicate rules with the same basename across global +\n  project dirs. If you have `~/.aider-desk/rules/GOLANG-01.mdc` AND\n  `\u003cproject\u003e/.aider-desk/rules/GOLANG-01.mdc`, both will load. The\n  project rule wins by virtue of appearing later in the list and getting\n  the last word in the prompt.\n\n## Status \u0026 roadmap\n\n- **v0.1.0 (current draft):** core hook, `.mdc` scanning, frontmatter\n  parsing, glob matching, three test suites, working stub implementation.\n- **v0.2 (tentative):** glob negation, subdirectory recursion, config UI\n  component, possibly augmenting the context match set with files\n  explicitly named in the user's prompt.\n\n## Development\n\n```bash\nnvm use\nnpm install\n\nnpm run typecheck    # tsc --noEmit\nnpm run lint         # eslint\nnpm run format:check # prettier --check\nnpm test             # vitest run\nnpm run check        # all of the above\n```\n\nNode 22 (see `.nvmrc`).\n\n## License\n\nMIT. See [LICENSE](./LICENSE).\n\n## Related projects\n\n- [`neumachen/aiderdesk-codex-extension`](https://github.com/neumachen/aiderdesk-codex-extension) — sibling extension; same packaging conventions.\n- [`hotovo/aider-desk`](https://github.com/hotovo/aider-desk) — the host application this extension plugs into.\n- [Cursor rules docs](https://docs.cursor.com/context/rules) — the convention this extension implements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneumachen%2Faiderdesk-conditional-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneumachen%2Faiderdesk-conditional-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneumachen%2Faiderdesk-conditional-rules/lists"}