Skip to content

Docs: Integrate docs into main repo#2

Merged
barisgit merged 5 commits into
mainfrom
feature/integrated-docs
Sep 4, 2025
Merged

Docs: Integrate docs into main repo#2
barisgit merged 5 commits into
mainfrom
feature/integrated-docs

Conversation

@barisgit
Copy link
Copy Markdown
Owner

@barisgit barisgit commented Sep 4, 2025

Summary by CodeRabbit

  • New Features

    • Live package badges on the docs landing page; branded footer; full docs site and CLI reference pages added.
  • Documentation

    • Guides: Getting Started, Installation, Configuration, Automatic Updates, Troubleshooting, Community contributor/development/license docs; detailed CLI docs (init, setup, update, add-3d, add-hook, template, pin/unpin, list, status).
  • Bug Fixes

    • Test import corrected for pathlib compatibility.
  • Improvements

    • Safer hook installation with backups/merging and clearer messaging; unpin now rejects incompatible flag combinations.
  • Style

    • New site theme with dark mode, typography tokens, and gradient animations.
  • Tests

    • New unit tests for Git hook utilities and unpin validation.
  • Chores

    • Docs tooling, workspace manifest, package scripts, TS config, and ignore patterns added.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a full Astro + Starlight documentation site under docs/ (configs, styles, components, content), a client-side badge data component, TypeScript/TS config and workspace files, and tests. Introduces git hook utilities and safer hook installation using those utilities, adds an early mutual-exclusivity check to unpin, and fixes a test import. No public library API surface changes.

Changes

Cohort / File(s) Summary
Docs site config & workspace
docs/astro.config.mjs, docs/package.json, docs/pnpm-workspace.yaml, docs/tsconfig.json, docs/.gitignore
New Astro/Starlight site config, package manifest, pnpm workspace file, strict TS config, and a docs-specific .gitignore.
Docs content & pages
docs/README.md, docs/src/content/...
Many new documentation pages: landing, guides (getting-started, installation, configuration, automatic-updates, custom-descriptions, troubleshooting), community (contributing, development, license), and CLI reference pages (init, add-3d, add-hook, config, list, pin, unpin, setup, status, template, update).
Docs styling & assets
docs/src/styles/global.css, docs/src/content/docs/index.mdx
New global CSS with design tokens, dark/light overrides and utilities; new homepage with hero, badges and CTA cards.
Docs components & types
docs/src/components/Footer.astro, docs/src/components/BadgeData.astro, docs/src/env.d.ts, docs/src/content.config.ts
Footer wrapper injecting custom footer content; client BadgeData component fetching PyPI/PyPIStats with timeout/error handling; JSX/Env types; content collection export wired to Starlight loader/schema.
Core git hook utilities
kicad_lib_manager/utils/git_utils.py
New utilities: get_git_hooks_directory, backup_existing_hook, merge_hook_content, create_kilm_hook_content — detect hooks dir (core.hooksPath, worktrees), create backups, and merge KiLM-managed sections.
Hook installation command
kicad_lib_manager/commands/add_hook.py
Reworked to use git_utils for hooks path resolution, backup existing hooks, merge or replace KiLM-managed content, generate dynamic KiLM hook content, preserve executable flags, and raise ClickException on errors.
CLI validation
kicad_lib_manager/commands/unpin.py
Added early mutual-exclusivity check: --all cannot be used with --symbols or --footprints (raises click.UsageError).
Tests: fixes & new tests
tests/test_library_manager.py, tests/test_git_utils.py, tests/test_unpin_command.py
Fixed import to use pathlib.Path; added tests for git_utils (hooks path detection, backup, merge, content) and unpin mutual-exclusivity/usage scenarios using CliRunner.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as Maintainer
  participant CLI as kilm add-hook
  participant GU as git_utils.get_git_hooks_directory
  participant FS as Filesystem
  participant BK as git_utils.backup_existing_hook
  participant MERGE as git_utils.merge_hook_content

  User->>CLI: run `kilm add-hook [--directory] [--force]`
  CLI->>GU: resolve hooks dir for target repo
  alt not a git repo
    GU-->>CLI: raise RuntimeError
    CLI-->>User: error (ClickException)
  else resolved path
    GU-->>CLI: hooks_dir path
    CLI->>FS: read existing post-merge hook (if exists)
    alt hook exists
      CLI->>BK: create timestamped backup
      BK-->>CLI: backup path
      CLI->>MERGE: merge existing content with KiLM block
      MERGE-->>CLI: merged content
    else no hook
      CLI->>CLI: create KiLM hook content
    end
    CLI->>FS: write hook, set +x permissions
    CLI-->>User: success (installed in hooks_dir)
  end
Loading
sequenceDiagram
  autonumber
  actor Browser as User
  participant Badge as BadgeData.astro
  participant PyPI as pypi.org
  participant Stats as pypistats.org

  Browser->>Badge: DOMContentLoaded / load
  Badge->>PyPI: fetch /pypi/kilm/json (with timeout)
  alt success
    PyPI-->>Badge: JSON (info.version, requires_python)
    Badge->>Browser: update #pypi-version, #python-versions
  else error/timeout
    Badge->>Badge: log error, skip updates
  end
  Badge->>Stats: fetch /api/packages/kilm/recent (with timeout)
  alt success
    Stats-->>Badge: JSON (data.last_month)
    Badge->>Browser: update #pypi-downloads (formatted)
  else error/timeout
    Badge->>Badge: log error, apply fallback
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

I nibble docs beneath the moon,
Hooks stitched safe with timestamp tune,
Badges fetch, timeouts set just right,
Sidebars bloom and themes take flight.
Hop, test, merge — we ship tonight! 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e05575d and 39b2cd3.

📒 Files selected for processing (4)
  • docs/src/content/docs/index.mdx (1 hunks)
  • kicad_lib_manager/commands/add_hook.py (3 hunks)
  • kicad_lib_manager/utils/git_utils.py (1 hunks)
  • tests/test_git_utils.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/integrated-docs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 4, 2025

Caution

No docstrings were generated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 16

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/src/content/docs/reference/cli/setup.md (1)

77-125: Examples: minor phrasing/consistency edits.

- Configure only the current symbol/footprint library and current 3D library.
+ Configure only the current symbol/footprint library and the current 3D library.
@@
- Use specific paths for default libs (this might not be relevant if not configuring the default libs) and disable adding them to pinned libraries.
+ Use specific paths for default libraries (if the defaults are being configured) and disable pinning.
@@
- See what changes `kilm setup` would make for the current libraries without applying them.
+ Show what changes `kilm setup` would make for the current libraries without applying them.
@@
- See what changes `kilm setup` would make for all libraries without applying them.
+ Show what changes `kilm setup` would make for all libraries without applying them.
@@
- Get detailed output about the planned changes for current libraries.
+ Get detailed output about the planned changes for the current libraries.
🧹 Nitpick comments (62)
docs/src/content/docs/community/license.md (1)

6-8: Make the LICENSE link repo-agnostic (optional).

Hardcoding the GitHub org/repo reduces forkability. Consider linking via a config-driven URL or a site constant, or at least confirm the path stays correct after transfers/renames. Also remove the trailing space at line 8.

-You can find the full license text in the [LICENSE file](https://github.com/barisgit/kilm/blob/main/LICENSE) in the source repository. 
+You can find the full license text in the [LICENSE file](https://github.com/barisgit/KiLM/blob/main/LICENSE) in the source repository.

If available, prefer a config var (e.g., import from site config) to avoid hardcoding.

docs/package.json (1)

1-22: Harden package metadata; ensure Node/sharp compatibility; relocate pnpm config.

  • Mark package private to avoid accidental publish.
  • Add engines to prevent unsupported Node versions.
  • sharp ^0.32.x often lags new Node majors; consider ^0.33.x.
  • Move onlyBuiltDependencies here (see pnpm note).
 {
   "name": "kilm-docs",
   "type": "module",
   "version": "0.0.1",
+  "private": true,
+  "engines": {
+    "node": ">=18.18 || >=20"
+  },
+  "pnpm": {
+    "onlyBuiltDependencies": ["esbuild", "sharp"]
+  },
   "scripts": {
@@
   "devDependencies": {
-    "sharp": "^0.32.6"
+    "sharp": "^0.33.5"
   }
 }

Optionally pin the package manager to ensure consistent CI:

+  "packageManager": "pnpm@9"
docs/.gitignore (1)

16-21: Ignore common local env variants (optional).

Include .env.local and pattern for other env files.

 # environment variables
-.env
-.env.production
+.env
+.env.local
+.env.*.local
+.env.production
docs/src/env.d.ts (1)

4-9: Avoid global JSX index signature with any; it nukes type-safety project-wide.

Prefer narrowing or removing the override. If you only need to allow a few custom elements, type them explicitly; otherwise extend Astro’s intrinsic elements rather than using any.

Apply one of these diffs:

Option A — safer generic attrs:

 declare namespace JSX {
   interface IntrinsicElements {
-    // Allow any JSX element
-    [name: string]: any;
+    // Allow arbitrary elements with unknown attrs (safer than `any`)
+    [name: string]: Record<string, unknown>;
   }
 }

Option B — remove the blanket override (keep Astro defaults):

-declare namespace JSX {
-  interface IntrinsicElements {
-    // Allow any JSX element
-    [name: string]: any;
-  }
-}
+// Rely on Astro's provided JSX typings; no global override needed.

If this override exists to silence TSX component prop errors, consider typing those components instead of widening globally.

docs/src/content.config.ts (1)

5-7: Optional: add a type guard to catch misconfig at build time.

Using a “satisfies”-style annotation on collections helps surface schema/loader mismatches early.

Example:

-import { defineCollection } from 'astro:content';
+import { defineCollection } from 'astro:content';
+// Optional type guard:
+// import type { /* ContentCollections */ } from 'astro:content';

 export const collections = {
-  docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
-};
+  docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
+  // } satisfies ContentCollections;
+};
docs/src/components/Footer.astro (1)

18-37: Optional: move styles to a shared CSS file for caching and consistency.

Co-located styles are fine, but extracting to src/styles/global.css (or a footer CSS module) reduces inlined CSS and centralizes theming.

-<style>
-  .site-footer {
-    margin-top: 1rem;
-    padding: 0 1rem 1rem;
-    text-align: center;
-    font-size: 0.8rem;
-    color: var(--sl-color-gray-3);
-  }
-  .site-footer a {
-    color: var(--sl-color-gray-3);
-    text-decoration: none;
-  }
-  .site-footer a:hover {
-    text-decoration: underline;
-  }
-  .author-name {
-    font-weight: bold;
-    color: var(--sl-color-gray-2);
-  }
-</style>
+<!-- Move these rules into src/styles/global.css under a `.site-footer` section -->

Also consider checking contrast of --sl-color-gray-3 on your backgrounds for WCAG AA.

docs/src/content/docs/guides/installation.md (1)

47-55: Optional: include uv tool install for a pipx-like global install.

uv pip install targets the active env; uv tool install mirrors pipx UX.

 # Install kilm using uv
-uv pip install kilm
+uv pip install kilm
+
+# Alternatively, install as a user-wide tool (similar to pipx):
+uv tool install kilm
docs/src/content/docs/reference/cli/list.md (4)

6-9: Tighten intro phrasing.

Minor clarity/grammar improvements.

-The `kilm list` command scans a specified directory (typically your main KiCad library directory) and lists the symbol (`.kicad_sym`) and footprint (`.pretty`) libraries it finds within it.
+The `kilm list` command scans a target directory (typically your main KiCad library directory) and lists any symbol (`.kicad_sym`) and footprint (`.pretty`) libraries it finds.
 
-This is useful for verifying the contents of a specific library directory, independent of KiLM's own configuration.
+Use it to verify the contents of a library directory, independent of KiLM’s configuration.

18-23: Option docs: streamline defaults and example.

Minor wording and formatting tweaks.

-- `--kicad-lib-dir TEXT`: 
-  Specify the path to the KiCad library directory you want to scan. 
-  If not provided, KiLM will look for the `KICAD_USER_LIB` environment variable and use its value.
-  *Default:* Uses `KICAD_USER_LIB` environment variable.
-  *Example:* `kilm list --kicad-lib-dir /path/to/my/libraries`
+- `--kicad-lib-dir TEXT`  
+  Path to the KiCad library directory to scan.  
+  Default: the value of the `KICAD_USER_LIB` environment variable.  
+  Example: `kilm list --kicad-lib-dir /path/to/my/libraries`

29-35: Behavior list: minor formatting cleanup.

Make steps crisp and parallel.

-1.  **Determines Target Directory:** Uses the path provided via `--kicad-lib-dir` or falls back to the `KICAD_USER_LIB` environment variable.
-2.  **Scans Directory:** Recursively scans the target directory.
-3.  **Identifies Libraries:** 
-    - Looks for files ending in `.kicad_sym` to identify symbol libraries.
-    - Looks for directories ending in `.pretty` to identify footprint libraries.
-4.  **Prints Lists:** Outputs separate lists of the symbol and footprint library names found.
+1. **Determine target directory:** Use `--kicad-lib-dir` or fall back to `KICAD_USER_LIB`.
+2. **Scan directory:** Recursively scan the target directory.
+3. **Identify libraries:** 
+   - Files ending in `.kicad_sym` → symbol libraries
+   - Directories ending in `.pretty` → footprint libraries
+4. **Print results:** Output separate lists of symbol and footprint library names.

38-44: Section headers: use sentence case for consistency.

Small style tweak.

-**List Libraries in Default Directory:**
+**List libraries in the default directory:**
docs/README.md (1)

20-26: Optional: add prerequisites section (Node/PNPM versions).

State minimum Node.js and pnpm versions to avoid local dev surprises.

docs/src/content/docs/reference/cli/update.md (1)

26-41: Clarify auto-setup behavior and prerequisites.

  • Specify what flags (if any) are forwarded to kilm setup when --auto-setup is used.
  • Add a short “Prerequisites” note (Git installed; network access).
docs/src/content/docs/reference/cli/status.md (2)

52-76: Version-specific paths and env vars may mislead users.

Examples hard-code KiCad 7 (e.g., .../kicad/7.0/, KICAD7_*). Consider parametrizing or noting that versions vary (6/7/8).


79-79: US spelling for consistency.

Use “recognized” (US) to match the rest of the docs.

Apply:

-... state recognised by both KiLM and KiCad.
+... state recognized by both KiLM and KiCad.
docs/src/content/docs/guides/configuration.mdx (1)

13-15: Verify Windows config path; recommend using %APPDATA%.

On Windows, user config typically lives under %APPDATA%. If KiLM actually stores under Path.home()/.config, document that explicitly; otherwise, adjust the path.

Proposed text:

-- **Windows**: Typically `C:\Users\<YourUsername>\.config\kicad-lib-manager\config.yaml` (derived from `Path.home()`)
+- **Windows**: `%APPDATA%\kicad-lib-manager\config.yaml` (e.g., `C:\Users\<YourUsername>\AppData\Roaming\kicad-lib-manager\config.yaml`)
+  If your installation uses a custom path (e.g., under `Path.home()`), KiLM will print it in `kilm status`.
docs/src/content/docs/community/development.md (1)

12-15: Align clone URL with this repository.

Use the canonical repo path from this PR.

Apply:

-git clone https://github.com/barisgit/kilm.git
-cd kilm
+git clone https://github.com/barisgit/KiLM.git
+cd KiLM
docs/src/content/docs/reference/cli/setup.md (4)

29-36: Document env var naming rules and version nuance.

KiCad env vars differ by version (e.g., KICAD8_3DMODEL_DIR). Also, custom vars should be UPPER_SNAKE_CASE, ASCII, no spaces/hyphens. Add a brief note to prevent invalid names and set expectations.

-  Directly specify the path for the primary 3D models directory. This path might be used to set a default environment variable like `KICAD_3D_LIB`. Overrides environment variables (`KICAD_3D_LIB`).
+  Directly specify the path for the primary 3D models directory. This path might be used to set a default environment variable (e.g., `KICAD8_3DMODEL_DIR` or a custom `KICAD_3D_LIB`). Note: environment variable names should be UPPER_SNAKE_CASE, ASCII, and contain only letters, numbers, and underscores. Exact defaults may vary by KiCad version.

10-18: Add OS-specific config paths and define “invalid URI formats.”

Users will benefit from knowing where these files live on Linux/macOS/Windows and what “invalid URI formats” means (e.g., missing file://, backslashes vs slashes).

  1.  Finds KiCad configuration files (`sym-lib-table`, `fp-lib-table`, `kicad_common.json`).
+     - Typical locations:
+       - Linux: `~/.config/kicad/`…
+       - macOS: `~/Library/Preferences/kicad/`…
+       - Windows: `%APPDATA%\kicad\`…
+     (Exact paths may vary by KiCad major version.)
@@
-  8.  Attempts to fix known invalid URI formats in library tables.
+  8.  Attempts to fix known invalid URI formats in library tables (e.g., missing `file://` prefix, backslashes on Windows, or unescaped spaces).

66-68: List item formatting renders oddly.

The “--help” bullet may collapse with the following heading in some themes. Add a blank line after the bullet.

 - `--help`: 
   Show this help message and exit.
 
+ 
 ## Behavior Details

71-74: Tighten “logical name” definition and metadata sources.

If you rely on kilm.yaml/.kilm_cloud_metadata, state precedence and fallbacks to avoid confusion when multiple sources disagree.

- **Environment Variables:** KiLM attempts to read metadata (e.g., `kilm.yaml` or `.kilm_cloud_metadata`) to find the correct environment variable name (like `KICAD_COMPANY_LIB`) associated with each library path. If specific `--kicad-lib-dir` or `--kicad-3d-dir` options are given, they might influence default variables like `KICAD_USER_LIB` or `KICAD_3D_LIB`.
+ **Environment Variables:** KiLM reads metadata (e.g., `kilm.yaml`, then `.kilm_cloud_metadata`) to resolve the environment variable name (like `KICAD_COMPANY_LIB`) for each library path. If provided, `--kicad-lib-dir` and `--kicad-3d-dir` override derived defaults for the “current” libraries.
docs/src/content/docs/guides/custom-descriptions.mdx (3)

14-16: Add explicit file placement and scope.

Specify that the YAML must be in the library root managed by kilm init (next to the .kicad_sym or .pretty folder), and that only those libraries are affected.

- If you place a file named `library_descriptions.yaml` in the root of a library directory that you have initialized with `kilm init`, KiLM will read this file when running `kilm setup`.
+ Place `library_descriptions.yaml` in the root of a library directory initialized with `kilm init` (i.e., the directory that contains your `.kicad_sym` file or `.pretty/` folder). KiLM reads this file during `kilm setup` and applies descriptions only to libraries under that directory.

18-28: YAML example: add quoting/escaping guidance.

Descriptions may include colons or quotes; add a brief note to avoid YAML parse errors.

   MyCustomFootprints: "Footprints for custom breakout boards."
+
+# Tip: If descriptions include `:` or quotes, wrap them in double quotes and escape inner quotes.

6-11: Tighten the intro.

Small grammar/flow tweaks.

- While KiLM manages adding libraries to KiCad, KiCad itself displays a description for each library in its managers.
+ While KiLM manages adding libraries to KiCad, KiCad displays a description for each library in its managers.
@@
- KiLM allows you to define these descriptions centrally within your library repository by looking for a specific YAML file.
+ KiLM lets you define these descriptions centrally in your library repository via a specific YAML file.
docs/src/content/docs/reference/cli/add-3d.md (2)

35-41: Document env var naming constraints and generation rules.

Avoid generating invalid names (hyphens, lowercase, leading digits). State the algorithm briefly so users can predict the result.

-  Specifies a custom KiCad environment variable name (e.g., `MY_CUSTOM_3D`) to associate with this library's path. If not provided (and `--no-env-var` isn't used), a name is automatically generated (e.g., `KICAD_3D_STANDARD_3D_LIB`). This variable will be set in KiCad when you run `kilm setup`.
+  Specifies a custom KiCad environment variable name (e.g., `MY_CUSTOM_3D`) to associate with this library's path. If not provided (and `--no-env-var` isn't used), KiLM auto-generates an UPPER_SNAKE_CASE name from `--name` (non-alphanumeric replaced with `_`, no leading digits). This variable is set in KiCad when you run `kilm setup`.

73-80: Cross-link and clarify the dependency on setup.

Make the “Note” a callout and explicitly say that kilm setup writes the env var into KiCad’s config.

- **Note:** After adding 3D libraries, you usually need to run [`kilm setup`](/reference/cli/setup/) to create or update the associated environment variables (like `KICAD_OFFICIAL_3D` in the example) in KiCad's configuration. 
+ > Note: After adding 3D libraries, run [`kilm setup`](/reference/cli/setup/) to write/update the associated environment variables (e.g., `KICAD_OFFICIAL_3D`) in KiCad’s configuration.
docs/src/content/docs/community/contributing.md (3)

10-18: Improve “Reporting Issues” checklist for reproducibility.

Add minimal reproducible example and KiCad major version; move “--verbose” into a code fence example.

 - **Provide Details:** If creating a new issue, please include:
-    - KiLM version (`kilm --version`)
-    - KiCad version
+    - KiLM version (`kilm --version`)
+    - KiCad major/minor version
     - Operating System
     - Clear description of the bug or feature request
-    - Steps to reproduce the issue (for bugs)
-    - Any relevant error messages or logs (use `--verbose` flag if applicable)
+    - Minimal steps to reproduce (for bugs), ideally with a small example repo/project
+    - Relevant logs (run commands with `--verbose` when applicable)

21-27: Use canonical repo casing and link to Issues in one place.

Minor polish; GitHub is case-insensitive but consistent casing improves branding.

-1.  **Fork the Repository:** Create your own fork of the [KiLM repository](https://github.com/barisgit/kilm) on GitHub.
+1.  **Fork the Repository:** Create your own fork of the [KiLM repository](https://github.com/barisgit/KiLM) on GitHub.

55-61: Style section: add test expectations and doc build.

 - Use [Black](https://github.com/psf/black) for code formatting.
 - Write clear and concise code with comments where necessary.
+ - Ensure new features include unit tests; update or add docs as needed (run the docs site locally to verify navigation and formatting).
docs/src/content/docs/reference/cli/add-hook.md (3)

34-46: Add set -e and quiet mode; note Windows compatibility.

Small robustness improvements and cross-platform caveat.

-#!/bin/sh
+#!/bin/sh
+set -e
@@
-echo "Running KiCad Library Manager update..."
-kilm update
+echo "Running KiCad Library Manager update..."
+kilm update ${KILM_UPDATE_FLAGS:-}
@@
-# Uncomment to set up libraries automatically (use with caution)
-# kilm setup
+# Uncomment to set up libraries automatically (use with caution)
+# kilm setup ${KILM_SETUP_FLAGS:-}

Add after the code block:

+ Note: On Windows, the hook runs under Git Bash. Ensure `kilm` is on the PATH in that environment.

62-79: Customization example: mirror the robustness changes.

Keep examples consistent with the generated script.

-#!/bin/sh
+#!/bin/sh
+set -e
@@
-kilm update
+kilm update ${KILM_UPDATE_FLAGS:-}
@@
-kilm setup
+kilm setup ${KILM_SETUP_FLAGS:-}

26-28: Formatting nit: add a blank line before “Behavior” for cleaner rendering.

 - `--help`: 
   Show the help message and exit.
 
+ 
 ## Behavior
docs/src/content/docs/guides/automatic-updates.mdx (2)

6-6: Remove unused import.

Aside isn’t used in this page. Drop the import to reduce bundle noise.

-import { Aside } from '@astrojs/starlight/components';

58-58: Clarify the manual alternative.

Suggest running kilm update explicitly (not git pull in library dirs), since kilm update likely encapsulates per-library pulls.

-*Note: You can also manually run `git pull` in library directories and `kilm setup` in your terminal.*
+*Note: You can also manually run `kilm update` (and optionally `kilm setup`) from your terminal as needed.*
docs/src/content/docs/reference/cli/pin.md (2)

64-65: Call out idempotency/duplicate handling.

State whether duplicate pins are skipped and original order preserved to set expectations.

-7.  Adds the names of the determined libraries (all or selected) to the respective lists.
+7.  Adds the determined libraries to the respective lists, skipping duplicates and preserving existing order.

74-76: Minor wording polish.

-**Pin all libraries found in the default directory:**
-(Assumes `KICAD_USER_LIB` is set)
+**Pin all libraries found in the default directory**
+(Assumes that `KICAD_USER_LIB` is set)
docs/src/content/docs/guides/troubleshooting.md (1)

12-12: US English variant.

Use “Afterward” instead of “Afterwards.”

-Afterwards, KiLM should be able to find them.
+Afterward, KiLM should be able to find them.
docs/src/components/BadgeData.astro (3)

40-43: Defensive JSON access for version.

Avoid potential undefined access if PyPI response shape changes.

-        const data = JSON.parse(response);
-        console.log("PyPI version data:", data.info.version);
-        element.textContent = data.info.version;
+        const data = JSON.parse(response);
+        const version = data?.info?.version;
+        if (version) {
+          console.log("PyPI version data:", version);
+          element.textContent = version;
+        }

95-101: Compact, locale-aware formatting (optional).

Consider Intl.NumberFormat with compact notation for friendlier badges.

-            if (downloads >= 1000000) {
-              element.textContent = Math.floor(downloads / 1000000) + "M+";
-            } else if (downloads >= 1000) {
-              element.textContent = Math.floor(downloads / 1000) + "K+";
-            } else {
-              element.textContent = downloads + "+";
-            }
+            const fmt = new Intl.NumberFormat(undefined, { notation: "compact", maximumFractionDigits: 1 });
+            element.textContent = fmt.format(downloads) + "+";

117-122: Avoid duplicate listeners and run immediately if already loaded.

Prevents multiple handlers if the component is rendered more than once.

-  document.addEventListener("DOMContentLoaded", () => {
-    console.log("DOM loaded, updating badges...");
-    updatePyPIVersion();
-    updatePythonVersions();
-    updateDownloadCount();
-  });
+  const run = () => {
+    console.log("DOM loaded, updating badges...");
+    updatePyPIVersion();
+    updatePythonVersions();
+    updateDownloadCount();
+  };
+  if (document.readyState === "loading") {
+    document.addEventListener("DOMContentLoaded", run, { once: true });
+  } else {
+    run();
+  }
docs/src/content/docs/reference/cli/init.md (2)

14-14: Make config path OS-agnostic.

Hardcoding ~/.config/... is Linux-centric; clarify platform-specific locations.

-4.  Adds an entry for this library (with its path and type `github`) to the main KiLM configuration file (`~/.config/kicad-lib-manager/config.yaml`).
+4.  Adds an entry for this library (with its path and type `github`) to the main KiLM configuration file (e.g., `~/.config/kicad-lib-manager/config.yaml` on Linux; platform-specific path on macOS/Windows).

87-87: US English variant.

Use “afterward.”

-**Note:** Running `kilm init` registers the library with KiLM and prepares the directory. You still need to run [`kilm setup`](/reference/cli/setup/) afterwards to make KiCad aware of this library by updating KiCad's configuration files. 
+**Note:** Running `kilm init` registers the library with KiLM and prepares the directory. You still need to run [`kilm setup`](/reference/cli/setup/) afterward to make KiCad aware of this library by updating KiCad's configuration files. 
docs/src/content/docs/reference/cli/config.mdx (3)

36-37: Consistent help text phrasing (“this help message”).

Minor copy fix for consistency across pages.

- - `--help`: 
-   Show the help message and exit.
+ - `--help`: 
+   Show this help message and exit.

Also applies to: 84-86, 134-136


64-67: Link related commands for quicker navigation.

Add cross-links to referenced commands.

- The `current_library` setting in `config.yaml` determines which library path is used by default in commands like `status` or `setup` (when not using `--all-libraries` or specific library flags).
+ The `current_library` setting in `config.yaml` determines which library path is used by default in commands like [`status`](/reference/cli/status/) or [`setup`](/reference/cli/setup/) (when not using `--all-libraries` or specific library flags).

112-113: Clarify non-destructive removal.

Add a short warning to avoid confusion.

- Removes a registered library from the KiLM configuration (`config.yaml`). This does *not* delete the library files or its metadata file, only the entry in KiLM's central config.
+ Removes a registered library from the KiLM configuration (`config.yaml`). This does *not* delete the library files or metadata; it only removes the entry from KiLM’s central config.
+ :::note
+ Library contents on disk are untouched.
+ :::
docs/src/styles/global.css (4)

9-11: Add robust font fallbacks (fonts aren’t imported).

Without @font-face/@import, use a resilient stack.

-  --font-sans: "Atkinson Hyperlegible";
+  --font-sans: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
-  --font-mono: "IBM Plex Mono";
+  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

76-78: Smoother gradient animation.

Add background-size to avoid a static-looking shift.

 .animate-gradient {
   animation: gradient 15s ease infinite;
+  background-size: 200% 200%;
 }

94-98: Advertise color-scheme to the UA.

Improves form controls and scrollbar theming in dark mode.

 :root[data-theme="dark"] {
   --sl-color-bg: var(--custom-bg-primary);
   --sl-color-bg-nav: var(--custom-bg-secondary);
   --sl-color-bg-sidebar: var(--custom-bg-tertiary);
+  color-scheme: dark;
 }

81-91: Use Starlight tokens directly for dark backgrounds
Replace the explicit dark:bg-[var(--custom-bg-*)] usages in docs/src/styles/global.css (lines 81-91) with the corresponding Starlight CSS variables—e.g. dark:bg-[var(--sl-color-bg)], dark:bg-[var(--sl-color-bg-nav)], and dark:bg-[var(--sl-color-bg-sidebar)]—so all background values are driven by --sl-color-bg* alone and avoid duplication.

docs/src/content/docs/reference/cli/template.mdx (2)

30-34: Tighten option sentence fragments.

Convert “Can be used multiple times.” fragments to full sentences.

- - `--variable TEXT`: Define a variable for the template (key=value pair). Can be used multiple times.
+ - `--variable TEXT`: Define a variable for the template (key=value pair). This option can be used multiple times.
- - `--exclude TEXT`: Glob pattern [...] Can be used multiple times.
+ - `--exclude TEXT`: Glob pattern [...] This option can be used multiple times.
- - `--set-var TEXT`: Set a value for a template variable (key=value). Can be used multiple times.
+ - `--set-var TEXT`: Set a value for a template variable (key=value). This option can be used multiple times.

Also applies to: 91-96, 145-149


119-124: Quoting guidance for values with spaces.

Avoid parsing surprises on Windows shells.

-    --set-var default_author="My Name"
+    --set-var "default_author=My Name"
docs/src/content/docs/reference/cli/unpin.md (2)

44-46: Consistent help text phrasing (“this help message”).

- - `--help`: 
-   Show this help message and exit.
+ - `--help`: 
+   Show this help message and exit.

49-57: Backup behavior edge cases.

Document what happens if backup rotation fails or kicad_common.json is missing/corrupt; suggest explicit error messages.

docs/src/content/docs/guides/getting-started.mdx (5)

52-54: Tighten wording and file/dir terminology.

Minor clarity improvement.

Apply:

-Add your KiCad symbol (`.kicad_sym`), footprint (`.pretty`), and other library files into the appropriate subdirectories within `my-shared-kicad-lib`.
+Add your KiCad symbol libraries (`*.kicad_sym`), footprint libraries (`*.pretty/`), and other assets to the appropriate subdirectories in `my-shared-kicad-lib`.

58-62: Quote paths with spaces in examples.

Safer cross‑platform copy/paste.

Apply:

-                --directory /path/to/shared/google-drive/kicad-3d-models \
+                --directory "/path/to/shared/Google Drive/kicad-3d-models" \

Optionally add a Windows example:

kilm add-3d --name shared-3d-models --directory "C:\Shared\Google Drive\kicad-3d-models" --env-var ACME_3D_MODELS

116-119: Keep Consumer example flags consistent with Creator.

Example references reusing the same --name/--env-var; include it explicitly.

-                --directory /Users/myuser/GoogleDrive/kicad-3d-models
+                --directory "/Users/myuser/Google Drive/kicad-3d-models" \
+                --env-var ACME_3D_MODELS

68-72: Verify template subcommand name.

Confirm whether the CLI uses kilm template make vs kilm template create/new. Align the example with the actual command and update the linked reference page accordingly.

I can sync the examples with the CLI help once you confirm the current command names.


80-81: Set upstream on first push.

Small quality-of-life tweak.

-git push origin main
+git push -u origin main
docs/src/content/docs/index.mdx (3)

47-49: Prefer internal link for “Documentation”.

Avoid hard-coding the external domain; use a relative link so it works across environments.

-  <a href="https://kilm.aristovnik.me" className="inline-flex items-center bg-[rgba(30,30,40,0.8)] rounded-lg py-2 px-4 text-sm font-medium text-white/90 shadow-md transition-all duration-200 hover:translate-y-[-2px] hover:shadow-lg hover:text-white border border-white/10">
+  <a href="/" className="inline-flex items-center bg-[rgba(30,30,40,0.8)] rounded-lg py-2 px-4 text-sm font-medium text-white/90 shadow-md transition-all duration-200 hover:translate-y-[-2px] hover:shadow-lg hover:text-white border border-white/10">

36-43: Use neutral fallbacks for dynamic badges.

Reduce the risk of stale info if client JS fails.

-    v<span id="pypi-version" className="text-[#60efff] font-semibold mx-1">Latest</span>
+    v<span id="pypi-version" className="text-[#60efff] font-semibold mx-1">loading…</span>
...
-    <span className="mr-2">🐍</span> Python <span id="python-versions" className="ml-1 font-semibold">3.6+</span>
+    <span className="mr-2">🐍</span> Python <span id="python-versions" className="ml-1 font-semibold">loading…</span>
...
-    <span className="mr-2">📊</span> <span id="pypi-downloads" className="text-[#60efff] font-semibold mr-1">4K+</span> Downloads
+    <span className="mr-2">📊</span> <span id="pypi-downloads" className="text-[#60efff] font-semibold mr-1">loading…</span> Downloads

80-80: Avoid pinning a fictitious version in the demo output.

Keep this evergreen.

-    <div className="my-2 mb-4 text-[#a9b1d6] opacity-90">Successfully installed kilm-1.0.0</div>
+    <div className="my-2 mb-4 text-[#a9b1d6] opacity-90">Successfully installed kilm</div>
docs/astro.config.mjs (1)

13-15: Allow site and base to be overridden via environment variables Use Vite’s loadEnv in astro.config.mjs (config files don’t auto-load .env). For example:

-import { defineConfig } from "astro/config";
+import { defineConfig } from "astro/config";
+import { loadEnv } from "vite";

-export default defineConfig({
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, process.cwd(), "");
   site: env.SITE || "https://kilm.aristovnik.me",
+  base: env.BASE || "/",
+});
 integrations: [

If you prefer setting SITE and BASE via your CLI or CI, you can instead use process.env.SITE/process.env.BASE (remember that .env files aren’t loaded in config by default) (docs.astro.build)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d5a8288 and 05274ea.

⛔ Files ignored due to path filters (2)
  • docs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • docs/public/favicon.svg is excluded by !**/*.svg
📒 Files selected for processing (33)
  • docs/.gitignore (1 hunks)
  • docs/README.md (1 hunks)
  • docs/astro.config.mjs (1 hunks)
  • docs/package.json (1 hunks)
  • docs/pnpm-workspace.yaml (1 hunks)
  • docs/src/components/BadgeData.astro (1 hunks)
  • docs/src/components/Footer.astro (1 hunks)
  • docs/src/content.config.ts (1 hunks)
  • docs/src/content/docs/community/contributing.md (1 hunks)
  • docs/src/content/docs/community/development.md (1 hunks)
  • docs/src/content/docs/community/license.md (1 hunks)
  • docs/src/content/docs/guides/automatic-updates.mdx (1 hunks)
  • docs/src/content/docs/guides/configuration.mdx (1 hunks)
  • docs/src/content/docs/guides/custom-descriptions.mdx (1 hunks)
  • docs/src/content/docs/guides/getting-started.mdx (1 hunks)
  • docs/src/content/docs/guides/installation.md (1 hunks)
  • docs/src/content/docs/guides/troubleshooting.md (1 hunks)
  • docs/src/content/docs/index.mdx (1 hunks)
  • docs/src/content/docs/reference/cli/add-3d.md (1 hunks)
  • docs/src/content/docs/reference/cli/add-hook.md (1 hunks)
  • docs/src/content/docs/reference/cli/config.mdx (1 hunks)
  • docs/src/content/docs/reference/cli/index.md (1 hunks)
  • docs/src/content/docs/reference/cli/init.md (1 hunks)
  • docs/src/content/docs/reference/cli/list.md (1 hunks)
  • docs/src/content/docs/reference/cli/pin.md (1 hunks)
  • docs/src/content/docs/reference/cli/setup.md (1 hunks)
  • docs/src/content/docs/reference/cli/status.md (1 hunks)
  • docs/src/content/docs/reference/cli/template.mdx (1 hunks)
  • docs/src/content/docs/reference/cli/unpin.md (1 hunks)
  • docs/src/content/docs/reference/cli/update.md (1 hunks)
  • docs/src/env.d.ts (1 hunks)
  • docs/src/styles/global.css (1 hunks)
  • docs/tsconfig.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/src/content/docs/reference/cli/list.md

[grammar] ~24-~24: There might be a mistake here.
Context: ...dir /path/to/my/libraries ---help`: Show this help message and exit. ## Beh...

(QB_NEW_EN)


[grammar] ~30-~30: There might be a mistake here.
Context: ... Recursively scans the target directory. 3. Identifies Libraries: - Looks for...

(QB_NEW_EN)


[grammar] ~38-~38: There might be a mistake here.
Context: ...List Libraries in Default Directory: Scans the directory specified by the `KI...

(QB_NEW_EN)


[grammar] ~58-~58: There might be a mistake here.
Context: ...ist Libraries in a Specific Directory:** Scans the specified directory `/home/use...

(QB_NEW_EN)

docs/src/content/docs/community/contributing.md

[grammar] ~11-~11: There might be a mistake here.
Context: ...If creating a new issue, please include: - KiLM version (kilm --version) - Ki...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...e: - KiLM version (kilm --version) - KiCad version - Operating System ...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ...n (kilm --version) - KiCad version - Operating System - Clear description...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ... - KiCad version - Operating System - Clear description of the bug or feature ...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...escription of the bug or feature request - Steps to reproduce the issue (for bugs) ...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ... Steps to reproduce the issue (for bugs) - Any relevant error messages or logs (use...

(QB_NEW_EN)


[grammar] ~21-~21: There might be a mistake here.
Context: ...s://github.com/barisgit/kilm) on GitHub. 2. Clone Your Fork: Clone your forked rep...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/setup.md

[grammar] ~54-~54: There might be a mistake here.
Context: ...braries: Default: --pin-libraries`. Controls whether the configured librar...

(QB_NEW_EN)


[grammar] ~66-~66: There might be a mistake here.
Context: ...e:* kilm setup --verbose - --help: Show this help message and exit. ## Beh...

(QB_NEW_EN)


[grammar] ~77-~77: There might be a mistake here.
Context: ... Setup Current Libraries (Default): Configure only the current symbol/footpr...

(QB_NEW_EN)


[grammar] ~84-~84: There might be a mistake here.
Context: ...``` Setup All Registered Libraries: Configure all libraries defined in `conf...

(QB_NEW_EN)


[grammar] ~91-~91: There might be a mistake here.
Context: ...aries ``` Setup Specific Libraries: Only configure the symbol/footprint libr...

(QB_NEW_EN)


[grammar] ~98-~98: There might be a mistake here.
Context: ...up with Specific Paths and No Pinning:** Use specific paths for default libs (thi...

(QB_NEW_EN)


[grammar] ~105-~105: There might be a mistake here.
Context: ...view Changes (Default - Current Libs):** See what changes kilm setup would make...

(QB_NEW_EN)


[grammar] ~112-~112: There might be a mistake here.
Context: ...run ``` Preview Changes (All Libs): See what changes kilm setup would make...

(QB_NEW_EN)


[grammar] ~119-~119: There might be a mistake here.
Context: ...``` Verbose Dry Run (Current Libs): Get detailed output about the planned ch...

(QB_NEW_EN)

docs/src/content/docs/index.mdx

[grammar] ~21-~21: There might be a mistake here.
Context: ... } from '@astrojs/starlight/components'; import BadgeData from '../../components/...

(QB_NEW_EN)


[grammar] ~57-~57: There might be a mistake here.
Context: ...adient"> ## 🚀 Take a guided tour Follow the [Getting Started tutorial](/g...

(QB_NEW_EN)


[grammar] ~92-~92: There might be a mistake here.
Context: ...guration, and more. ## 📖 Learn

Key Features

Learn about KiLM's core capabilities and how they can improve your workflow.

Explore Features

Project Architecture

Understand how KiLM organizes and manages your libraries.

View Architecture

Command Reference

Explore the complete list of commands and their options.

View Commands

Configuration Options

Learn how to customize KiLM to fit your specific needs.

View Config Options
## 🔮 Extend <Card title="Add...

(QB_NEW_EN)


[grammar] ~132-~132: There might be a mistake here.
Context: ...] animate-gradient">

## 🔮 Extend Integrate third-party symbol, footprint, and 3D model libraries. Standardize designs with reusable project templates. Configure KiCad environment variables directly through KiLM. Keep your favorite libraries readily accessible within KiCad.

(QB_NEW_EN)

docs/src/content/docs/reference/cli/add-3d.md

[grammar] ~32-~32: There might be a mistake here.
Context: ...or this 3D library to the metadata file. Example: `kilm add-3d --directory .....

(QB_NEW_EN)


[grammar] ~47-~47: There might be a mistake here.
Context: ...d --directory ... --force ---help`: Show the help message and exit. ## Beha...

(QB_NEW_EN)


[grammar] ~66-~66: There might be a mistake here.
Context: ...Add a 3D library with specific names:* Register the directory `/opt/kicad/packa...

(QB_NEW_EN)

docs/README.md

[grammar] ~8-~8: There might be a mistake here.
Context: ...stations. ## 📚 Documentation Structure The documentation is organized into the ...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...Step-by-step tutorials and how-to guides - Reference: Detailed command and API re...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ...e**: Detailed command and API references - Community: Information about contribut...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ...ributing and development ## 🧞 Commands All commands are run from the root of th...

(QB_NEW_EN)


[grammar] ~20-~20: There might be a mistake here.
Context: ... | | :------------------------ | :---------...

(QB_NEW_EN)


[grammar] ~21-~21: There might be a mistake here.
Context: ...-------------------------------------- | | pnpm install | Installs d...

(QB_NEW_EN)


[grammar] ~22-~22: There might be a mistake here.
Context: ...ependencies | | pnpm dev | Starts loc...

(QB_NEW_EN)


[grammar] ~23-~23: There might be a mistake here.
Context: ...al dev server at localhost:4321 | | pnpm build | Build your...

(QB_NEW_EN)


[grammar] ~24-~24: There might be a mistake here.
Context: ... production site to ./dist/ | | pnpm preview | Preview yo...

(QB_NEW_EN)


[grammar] ~27-~27: There might be a mistake here.
Context: ...eploying | ## 🛠️ Project Structure . ├── public/ # Static assets ├── src/ │ ├── assets/ # Images and other assets │ ├── content/ │ │ ├── docs/ # Documentation content │ │ │ ├── guides/ # User guides and tutorials │ │ │ ├── reference/ # Command reference and API docs │ │ │ └── community/ # Contributing guidelines │ └── content.config.ts # Content collection config ├── astro.config.mjs # Astro configuration └── package.json ## 🔗 Links - [KiLM Documentation Website]...

(QB_NEW_EN)


[grammar] ~44-~44: There might be a mistake here.
Context: ...ration └── package.json ``` ## 🔗 Links - [KiLM Documentation Website](https://kilm...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/unpin.md

[grammar] ~44-~44: There might be a mistake here.
Context: ... unpin -s MyLib --verbose ---help`: Show this help message and exit. ## Beh...

(QB_NEW_EN)


[grammar] ~54-~54: There might be a mistake here.
Context: ...s libraries specified via -s and -f. 5. Removes the target library names from th...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/update.md

[grammar] ~30-~30: There might be a mistake here.
Context: ...kilm update --auto-setup - --help: Show the help message and exit. ## Beha...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/status.md

[grammar] ~16-~16: There might be a mistake here.
Context: ... [OPTIONS] ``` ## Options - --help: Show the help message and exit. ## Beha...

(QB_NEW_EN)


[grammar] ~25-~25: There might be a mistake here.
Context: ...within KiCad's kicad_common.json file. - KiCad Pinned Libraries: Shows the symb...

(QB_NEW_EN)


[style] ~26-~26: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...n KiCad's kicad_common.json file. - KiCad Pinned Libraries: Shows the symbol an...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~27-~27: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...es (pinned) in kicad_common.json. - KiCad Configured Libraries: Lists the symbo...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

docs/src/content/docs/reference/cli/index.md

[grammar] ~14-~14: There might be a mistake here.
Context: ...ation settings and registered libraries. - setup: Configure KiCad (library tables, envir...

(QB_NEW_EN)


[grammar] ~18-~18: There might be a mistake here.
Context: ...eate and manage KiCad project templates. - list: List symbol and footprint libraries fo...

(QB_NEW_EN)

docs/src/content/docs/guides/getting-started.mdx

[grammar] ~52-~52: There might be a mistake here.
Context: ... 3. Add Library Content: Add your KiCad symbol (.kicad_sym), fo...

(QB_NEW_EN)


[grammar] ~83-~83: There might be a mistake here.
Context: ...Configure Creator's KiCad (Optional):* The Creator can run kilm setup to conf...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/add-hook.md

[grammar] ~26-~26: There might be a mistake here.
Context: ...:* kilm add-hook --force - --help: Show the help message and exit. ## Beha...

(QB_NEW_EN)

docs/src/content/docs/guides/automatic-updates.mdx

[grammar] ~32-~32: There might be a mistake here.
Context: ...oks ``` 2. Create Hook Script: Create a file named `.git/hooks/post-mer...

(QB_NEW_EN)


[grammar] ~35-~35: There might be a mistake here.
Context: ...ost-merge`. 3. Add Script Content: Add the commands you want to run. ...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/config.mdx

[grammar] ~36-~36: There might be a mistake here.
Context: ...ilm config list --verbose ---help`: Show the help message and exit. #### Ex...

(QB_NEW_EN)


[grammar] ~84-~84: There might be a mistake here.
Context: ...ompts for a cloud library) - --help: Show the help message and exit. #### Ex...

(QB_NEW_EN)


[grammar] ~134-~134: There might be a mistake here.
Context: ...e old-project-lib --force ---help`: Show the help message and exit. #### Ex...

(QB_NEW_EN)

docs/src/content/docs/guides/configuration.mdx

[grammar] ~13-~13: There might be a mistake here.
Context: ...lowing XDG Base Directory specification) - Windows: Typically `C:\Users<YourUser...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/template.mdx

[style] ~32-~32: To form a complete sentence, be sure to include a subject.
Context: ...able for the template (key=value pair). Can be used multiple times. These variables...

(MISSING_IT_THERE)


[style] ~33-~33: To form a complete sentence, be sure to include a subject.
Context: ...files or directories from the template. Can be used multiple times. - `--output-dir...

(MISSING_IT_THERE)


[grammar] ~65-~65: There might be a mistake here.
Context: ...e make basic-mcu ``` **Create template from specific path with variables, excluding...

(QB_NEW_EN)


[style] ~92-~92: To form a complete sentence, be sure to include a subject.
Context: ...ue for a template variable (key=value). Can be used multiple times. Overrides defau...

(MISSING_IT_THERE)


[grammar] ~95-~95: There might be a mistake here.
Context: ...project creation without creating files. - --help: Show help message. #### Behavior 1. ...

(QB_NEW_EN)


[grammar] ~107-~107: There might be a mistake here.
Context: ... output path. 5. Processes Templates: - Renders filenames using Windows-compatib...

(QB_NEW_EN)


[grammar] ~108-~108: There might be a mistake here.
Context: ...upport for legacy {{variable}} syntax) - Renders file content using Jinja2 `{{var...

(QB_NEW_EN)


[grammar] ~109-~109: There might be a mistake here.
Context: ...{{variable}}syntax for.jinja2files 6. **(Optional) Runs Hooks:** Executes theh...

(QB_NEW_EN)


[grammar] ~119-~119: There might be a mistake here.
Context: ...create MyNewBoard ``` **Create project in specific dir, specifying template, sett...

(QB_NEW_EN)


[grammar] ~119-~119: There might be a mistake here.
Context: ... **Create project in specific dir, specifying template, setting variables:**bash ...

(QB_NEW_EN)


[grammar] ~147-~147: There might be a mistake here.
Context: ...--json: Output the list in JSON format. - --help`: Show help message. #### Examples **L...

(QB_NEW_EN)


[grammar] ~275-~275: There might be a mistake here.
Context: ...ent ...] ``` :::tip[Syntax Differences] - File content (inside .jinja2 files):...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/init.md

[style] ~12-~12: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d for richer descriptions in KiCad. 3. Creates or updates a metadata file named `kilm....

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[grammar] ~12-~12: There might be a mistake here.
Context: ...lities (symbols, footprints, templates). 4. Adds an entry for this library (with its...

(QB_NEW_EN)


[grammar] ~51-~51: There might be a mistake here.
Context: ...mple:* kilm init --force - --help: Show the help message and exit. ## Beha...

(QB_NEW_EN)


[grammar] ~63-~63: There might be a mistake here.
Context: ... ## Examples Basic Initialization: Initialize the current directory, creati...

(QB_NEW_EN)


[grammar] ~71-~71: There might be a mistake here.
Context: ...it ``` Initialization with Options: Initialize with a specific name, descrip...

(QB_NEW_EN)


[grammar] ~79-~79: There might be a mistake here.
Context: ...rrent ``` Re-initialize with Force: Overwrite existing kilm.yaml with defa...

(QB_NEW_EN)


[locale-violation] ~87-~87: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...n kilm setup afterwards to make KiCad aware of this library by ...

(AFTERWARDS_US)

docs/src/content/docs/guides/troubleshooting.md

[locale-violation] ~12-~12: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...ard location for your operating system. Afterwards, KiLM should be able to find them. ## ...

(AFTERWARDS_US)


[grammar] ~25-~25: There might be a mistake here.
Context: ...ashrc) or opened a new terminal window. - **System (Windows):** After using SetEnvi...

(QB_NEW_EN)


[grammar] ~32-~32: There might be a mistake here.
Context: ...cts, temporary files, unusual symlinks). - Solution: - Clean Project: Ens...

(QB_NEW_EN)

docs/src/content/docs/reference/cli/pin.md

[grammar] ~53-~53: There might be a mistake here.
Context: ...lm pin -s MyLib --verbose ---help`: Show this help message and exit. ## Beh...

(QB_NEW_EN)


[grammar] ~60-~60: There might be a mistake here.
Context: ...print libraries in the target directory. 4. If specific libraries are provided via `...

(QB_NEW_EN)


[grammar] ~61-~61: There might be a mistake here.
Context: ...rectory (issues a warning if not found). 5. Creates a backup of kicad_common.json ...

(QB_NEW_EN)


[grammar] ~74-~74: There might be a mistake here.
Context: ...raries found in the default directory:** (Assumes KICAD_USER_LIB is set) ```bas...

(QB_NEW_EN)

Comment thread docs/README.md Outdated
Comment thread docs/src/components/BadgeData.astro
Comment thread docs/src/components/BadgeData.astro
Comment thread docs/src/content/docs/guides/automatic-updates.mdx
Comment thread docs/src/content/docs/guides/automatic-updates.mdx Outdated
Comment thread docs/src/content/docs/reference/cli/add-hook.md Outdated
Comment thread docs/src/content/docs/reference/cli/setup.md Outdated
Comment thread docs/src/content/docs/reference/cli/setup.md Outdated
Comment thread docs/src/content/docs/reference/cli/template.mdx Outdated
Comment thread docs/src/content/docs/reference/cli/unpin.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/test_library_manager.py (1)

117-120: Footprint library should be a directory, not a file.

KiCad footprint libs are directories (*.pretty). Creating it with .touch() makes a file and risks false positives/negatives depending on add_libraries implementation. Align with your UTF-8 test which uses .mkdir().

Apply this diff:

-    (lib_dir / "symbols" / "test_lib.kicad_sym").touch()
-    (lib_dir / "footprints" / "test_lib.pretty").touch()
+    (lib_dir / "symbols" / "test_lib.kicad_sym").touch()
+    (lib_dir / "footprints" / "test_lib.pretty").mkdir()
🧹 Nitpick comments (3)
tests/test_library_manager.py (3)

127-131: Avoid env var leakage across tests with monkeypatch.

Use pytest’s monkeypatch.setenv so the environment is restored automatically after the test.

Apply this diff:

-def test_add_libraries_integration(tmp_path):
+def test_add_libraries_integration(tmp_path, monkeypatch):
@@
-    os.environ["KICAD_LIB"] = str(lib_dir)
+    monkeypatch.setenv("KICAD_LIB", str(lib_dir))
@@
-    os.environ["TEST_LIB"] = str(lib_dir)
+    monkeypatch.setenv("TEST_LIB", str(lib_dir))

Also applies to: 133-136


28-28: Use raw strings for Windows literals.

Raw strings reduce escape noise and the risk of typos.

Apply this diff:

-        format_uri("C:\\path\\to\\lib", "test_lib", "symbols")
+        format_uri(r"C:\path\to\lib", "test_lib", "symbols")
@@
-        format_uri("C:\\path\\to\\lib", "test_lib", "footprints")
+        format_uri(r"C:\path\to\lib", "test_lib", "footprints")

Also applies to: 32-32


168-170: Minor I/O cleanup with Path helpers.

Use write_text/read_text for brevity and clarity.

Apply this diff:

-    with Path(table_path).open("w", encoding="utf-8") as f:
-        f.write("(fp_lib_table\n  (version 7)\n)\n")
+    table_path.write_text("(fp_lib_table\n  (version 7)\n)\n", encoding="utf-8")
@@
-    with Path(table_path).open(encoding="utf-8") as f:
-        content = f.read()
+    content = table_path.read_text(encoding="utf-8")

Also applies to: 191-193

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 05274ea and a3e3e0b.

📒 Files selected for processing (1)
  • tests/test_library_manager.py (1 hunks)
🔇 Additional comments (1)
tests/test_library_manager.py (1)

2-2: Good fix: use public pathlib API.

Switching to from pathlib import Path avoids reliance on private internals and improves portability.

Repository owner deleted a comment from coderabbitai Bot Sep 4, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
kicad_lib_manager/utils/git_utils.py (1)

145-157: New files need a shebang; provide a full-script helper for first install.

create_kilm_hook_content() returns only the managed block; creating a brand‑new hook without a shebang will fail to execute.

 def create_kilm_hook_content() -> str:
@@
-    return """# BEGIN KiLM-managed section
+    return """# BEGIN KiLM-managed section
 # KiCad Library Manager auto-update hook
 # Added by kilm add-hook command
@@
 echo "KiCad libraries update complete."
 # END KiLM-managed section"""
+
+def create_kilm_hook_script() -> str:
+    """
+    Create a complete, POSIX‑sh hook script for first-time installs.
+    Includes a shebang, strict mode, and a guard if KiLM is missing.
+    """
+    return f"""#!/bin/sh
+set -eu
+if ! command -v kilm >/dev/null 2>&1; then
+  echo "kilm not found; skipping update."
+  exit 0
+fi
+{create_kilm_hook_content()}
+"""
kicad_lib_manager/commands/add_hook.py (1)

114-116: Return a non-zero exit code on write failure.

Raise a ClickException instead of echoing.

-    except Exception as e:
-        click.echo(f"Error creating hook: {str(e)}", err=True)
+    except Exception as e:
+        raise click.ClickException(f"Error creating hook: {e}")
docs/src/content/docs/reference/cli/update.md (1)

1-69: Align exit‐code docs with implementation: The kilm update command in commands/update.py has no explicit exit‐code handling (no sys.exit calls or integer returns), so it always exits 0 unless an unhandled exception is raised. Implement proper exit codes for partial‐failure scenarios or adjust the docs to reflect the current behavior.

♻️ Duplicate comments (7)
docs/README.md (1)

6-6: Repo link correction looks good.

Link now points to https://github.com/barisgit/KiLM as requested earlier.

docs/src/content/docs/reference/cli/setup.md (2)

37-44: Flag name vs. description mismatch (“-dirs” but accepts names).

The options read like directory inputs yet the text says “library names,” which is confusing. Either rename the flags or adjust the copy to clearly accept names or directories—whichever the CLI truly supports. Below is a docs-only fix that keeps current flag names but clarifies they take directories. If the CLI actually takes names, prefer renaming the flags in a follow-up.

Run this to verify the real option semantics in the CLI parser:

#!/bin/bash
# Find option definitions/usages for setup flags
rg -nP --type=py -C2 "(--symbol-lib-dirs|--threed-lib-dirs|symbol_lib_dirs|threed_lib_dirs)\b"

Proposed doc tweak:

- - `--symbol-lib-dirs TEXT`:
-   Specify a comma-separated list of library _names_ (as defined in KiLM config) to set up. Only these specific symbol/footprint libraries will be configured. This takes precedence over the default behavior and `--all-libraries`.
+ - `--symbol-lib-dirs TEXT`:
+   Specify a comma-separated list of symbol/footprint library directories (paths) to set up. Only these libraries are configured. Overrides the default behavior and `--all-libraries`.
@@
- - `--threed-lib-dirs TEXT`:
-   Specify a comma-separated list of 3D library _names_ (as defined in KiLM config) to set up. Only the environment variables for these specific 3D libraries will be configured. This takes precedence over the default behavior and `--all-libraries`.
+ - `--threed-lib-dirs TEXT`:
+   Specify a comma-separated list of 3D library directories (paths) to set up. Only these 3D libraries are configured. Overrides the default behavior and `--all-libraries`.

53-56: Tighten wording for pin-libraries option.

Minor grammar/clarity tweak.

 - `--pin-libraries / --no-pin-libraries`:
   Default: `--pin-libraries`.
-  Controls whether the configured libraries should be added to KiCad's "Pinned Libraries" list for quick access in the managers.
+  Controls whether configured libraries are added to KiCad's "Pinned Libraries" list for quick access in the managers.
docs/src/content/docs/reference/cli/add-3d.md (1)

57-65: Example heading/text tweaks for brevity.

Align with previous suggestion.

-## Examples
-
-**Add a 3D library (using defaults where possible):**
-Register the directory `/home/user/cad/my_3d_parts`. A name and environment variable will be generated automatically.
+## Example
+
+**Add a 3D library (using defaults):**
+Register `/home/user/cad/my_3d_parts`. A name and environment variable are generated automatically.
docs/src/content/docs/guides/automatic-updates.mdx (2)

48-62: Harden manual hook script (POSIX-safe strict mode and kilm guard).

-#!/bin/sh
+#!/bin/sh
+set -eu
 # BEGIN KiLM-managed section
 # KiCad Library Manager auto-update hook
 # Added manually
 
-echo "Running KiCad Library Manager update..."
-kilm update
+if command -v kilm >/dev/null 2>&1; then
+  echo "Running KiCad Library Manager update..."
+  kilm update
+else
+  echo "kilm not found; skipping update."
+fi

20-21: Fix: post-merge doesn’t run on fast-forward pulls.

-This creates a `.git/hooks/post-merge` script that automatically executes `kilm update` every time you successfully run `git pull` or `git merge` in that repository.
+This creates a `.git/hooks/post-merge` script that runs `kilm update` after a merge commit (e.g., `git merge`, or a `git pull` that produces a merge). Note: fast‑forward pulls and rebases do not trigger `post-merge`. For broader coverage, consider also wiring the same script to `post-checkout` and `post-rewrite`.
docs/src/content/docs/index.mdx (1)

133-141: Resolved: broken “Explore Features” anchor fixed.

The href no longer includes the invalid “#features” fragment. Looks good.

🧹 Nitpick comments (50)
docs/src/content/docs/reference/cli/list.md (3)

18-23: Clarify fallback and failure behavior when no directory is provided.

Spell out what happens if --kicad-lib-dir is omitted and KICAD_USER_LIB is unset or empty, and document the exit code on failure.

 -  If not provided, KiLM will look for the `KICAD_USER_LIB` environment variable and use its value.
-  _Default:_ Uses `KICAD_USER_LIB` environment variable.
+  If not provided, KiLM will look for the `KICAD_USER_LIB` environment variable and use its value.
+  If neither is set or the path does not exist, the command prints an error and exits non‑zero.
+  _Default:_ Uses `KICAD_USER_LIB` environment variable when available.

29-35: Specify scan semantics (recursion, symlinks, naming, sorting).

Note whether recursion follows symlinks, whether hidden dirs are skipped, how “names” are derived (basename vs. full path), and if output is sorted for determinism.

 2.  **Scans Directory:** Recursively scans the target directory.
-3.  **Identifies Libraries:**
+   - Symlinks: {follows|does not follow} symlinks.
+   - Hidden paths: {includes|skips} hidden files/directories.
+3.  **Identifies Libraries & Names:**
     - Looks for files ending in `.kicad_sym` to identify symbol libraries.
     - Looks for directories ending in `.pretty` to identify footprint libraries.
-4.  **Prints Lists:** Outputs separate lists of the symbol and footprint library names found.
+   - Each library “name” is derived from the basename of the file/directory (e.g., `Device.kicad_sym` → `Device`).
+4.  **Prints Lists:** Outputs separate, alphabetically sorted lists of the symbol and footprint library names found.

45-57: Tighten the example output and mark it clearly as illustrative.

Small edits for clarity and deterministic expectations.

-_Expected Output (example):_
+_Example output (illustrative; your results will vary):_
@@
-Available Symbol Libraries:
+Available Symbol Libraries (sorted):
@@
-Available Footprint Libraries:
+Available Footprint Libraries (sorted):
docs/README.md (1)

46-47: Prefer resilient links for previews/forks.

Consider adding a relative link to the docs root alongside the external site to keep the README useful in preview builds and forks.

- - [KiLM Documentation Website](https://kilm.aristovnik.me)
+ - [KiLM Documentation Website](https://kilm.aristovnik.me)
+ - [Local preview root](/) _(when running `pnpm dev`)_
docs/src/content/docs/guides/configuration.mdx (3)

16-18: Validate Windows config path.

Confirm that Windows uses %USERPROFILE%\.config\kicad-lib-manager\config.yaml. Many apps prefer %APPDATA% (AppData\Roaming). If intentional, a short note explaining the choice will prevent confusion.


30-33: Document max_backups edge cases and policy.

State what 0 means and how pruning works so users can set it confidently.

 - **Maximum Backups (`max_backups`):** An integer defining the maximum number of timestamped backups KiLM should keep when modifying KiCad's native configuration files.
+ - **Maximum Backups (`max_backups`):** Integer cap on timestamped backups KiLM keeps when modifying KiCad’s config files.
+   - `0` disables creating backups.
+   - When the limit is exceeded, the oldest backups are deleted first (FIFO).

55-63: Explicitly state the pruning behavior here too.

Echo the retention rule next to the filenames list for quick reference.

   original files *before* making any changes. The number of backups retained is
-  controlled by the `max_backups` setting in `config.yaml`. This allows you to
+  controlled by the `max_backups` setting in `config.yaml` (oldest backups are pruned first). This allows you to
   easily revert if something goes wrong.
docs/src/content/docs/guides/getting-started.mdx (3)

41-49: Add a cross-link to the init command reference.

Quick link improves navigation.

-    Run `kilm init` _inside_ the library directory, providing all relevant metadata. This creates the `kilm.yaml` file which stores the canonical information for this library and gets committed to Git.
+    Run `kilm init` _inside_ the library directory, providing all relevant metadata. This creates the `kilm.yaml` file which stores the canonical information for this library and gets committed to Git. See also: [CLI › `init`](/reference/cli/init/).

135-138: Include --env-var in the Consumer 3D example for parity with the Creator step.

You advise reusing the same name/env-var; reflect that in the example.

-    kilm add-3d --name shared-3d-models \
-                --directory /Users/myuser/GoogleDrive/kicad-3d-models
+    kilm add-3d --name shared-3d-models \
+                --directory /Users/myuser/GoogleDrive/kicad-3d-models \
+                --env-var ACME_3D_MODELS

160-171: Add a cross-link to the add-hook reference.

Makes it easy to discover details and flags.

-    This sets up a Git hook _in the project repository_ so that after you run `git pull` _in this project_, it automatically runs `kilm setup` for you, ensuring KiCad stays synced if the library was updated.
+    This sets up a Git hook _in the project repository_ so that after you run `git pull` _in this project_, it automatically runs `kilm setup` for you, ensuring KiCad stays synced if the library was updated. See also: [CLI › `add-hook`](/reference/cli/add-hook/).
docs/src/content/docs/community/contributing.md (2)

10-11: Normalize repository casing in links.

Use the canonical KiLM casing for consistency.

-- **Search Existing Issues:** Before creating a new issue, please check if a similar one already exists on the [GitHub Issues page](https://github.com/barisgit/kilm/issues).
+- **Search Existing Issues:** Before creating a new issue, please check if a similar one already exists on the [GitHub Issues page](https://github.com/barisgit/KiLM/issues).

21-26: Align repo URL and clone command with canonical casing.

Minor polish; GitHub is case-insensitive, but consistency helps.

-1.  **Fork the Repository:** Create your own fork of the [KiLM repository](https://github.com/barisgit/kilm) on GitHub.
+1.  **Fork the Repository:** Create your own fork of the [KiLM repository](https://github.com/barisgit/KiLM) on GitHub.
@@
-    git clone https://github.com/YOUR_USERNAME/kilm.git
-    cd kilm
+    git clone https://github.com/YOUR_USERNAME/KiLM.git
+    cd KiLM
docs/src/content/docs/reference/cli/setup.md (1)

71-74: Minor style/clarity nits.

Streamline and avoid hedging.

- **Backups:** Backups are crucial for recovery if KiCad's configuration gets corrupted. They are stored in the same directory as the KiCad configuration files and are named with a timestamp.
+ **Backups:** Stored alongside KiCad config files, named with a timestamp, to aid recovery if configuration becomes corrupted.
docs/src/content/docs/reference/cli/status.md (2)

23-28: Reduce repetition and use consistent US English.

Tighten bullets and change “recognised” → “recognized”.

-- **KiLM Configuration:** Details from `config.yaml`, such as registered library names and potentially paths.
-- **KiCad Configuration Directory:** The location KiLM detected for KiCad's configuration files.
-- **KiCad Environment Variables:** Lists the environment variables currently set within KiCad's `kicad_common.json` file.
-- **KiCad Pinned Libraries:** Shows the symbol and footprint libraries currently marked as favorites (pinned) in `kicad_common.json`.
-- **KiCad Configured Libraries:** Lists the symbol and footprint libraries currently present in KiCad's `sym-lib-table` and `fp-lib-table`.
+- **KiLM Configuration:** Details from `config.yaml` (registered libraries and paths).
+- **KiCad Config Directory:** Detected location of KiCad configuration files.
+- **Environment Variables:** Variables set in `kicad_common.json`.
+- **Pinned Libraries:** Symbol/footprint favorites in `kicad_common.json`.
+- **Configured Libraries:** Entries in `sym-lib-table` and `fp-lib-table`.

80-80: US spelling.

-This command is useful for verifying that your `kilm setup` commands have applied correctly and for understanding the current state recognised by both KiLM and KiCad.
+This command is useful for verifying that your `kilm setup` commands have applied correctly and for understanding the current state recognized by both KiLM and KiCad.
docs/src/content/docs/reference/cli/add-3d.md (1)

66-71: Minor wording polish.

-**Add a 3D library with specific names:**
-Register the directory `/opt/kicad/packages3d`, name it `kicad-official-3d`, and assign the environment variable `KICAD_OFFICIAL_3D`.
+**Add a 3D library with specific values:**
+Register `/opt/kicad/packages3d`, name it `kicad-official-3d`, and assign the environment variable `KICAD_OFFICIAL_3D`.
docs/src/content/docs/reference/cli/pin.md (3)

35-40: Clarify default selection semantics and mutual exclusivity.

Make the default explicit and phrasing concise.

-- `--all / --selected`:
-  Determines which libraries to pin.
-  - `--all` (Default): Pins _all_ symbol and footprint libraries found within the directory specified by `--kicad-lib-dir`. Cannot be used if `-s` or `-f` are specified.
-  - `--selected`: Pins only the libraries explicitly listed using `-s` or `-f`. This is implicitly active when `-s` or `-f` are used.
+- `--all / --selected`:
+  Controls which libraries to pin.
+  - `--all` (default): Pins all symbol and footprint libraries in `--kicad-lib-dir`. Cannot be combined with `-s` or `-f`.
+  - `--selected`: Pins only libraries provided via `-s`/`-f`. Automatically active when `-s` or `-f` are used.

49-51: Minor grammar tweak.

-  Show detailed output during the pinning process, including listing libraries found and pinned.
+  Show detailed output during the pinning process, including the libraries found and pinned.

56-66: Tighten Behavior steps.

Small clarity pass.

-3.  If `--all` is active (default and no `-s`/`-f`), lists all symbol/footprint libraries in the target directory.
-4.  If specific libraries are provided via `-s`/`-f`, validates they exist in the target directory (issues a warning if not found).
+3.  If `--all` (default) and no `-s`/`-f`, list all symbol/footprint libraries in the target directory.
+4.  If `-s`/`-f` provided, validate they exist in the target directory (warn if not found).
docs/src/content/docs/reference/cli/init.md (2)

35-38: Consistent example casing and clarity.

Minor style/clarity improvement.

-  _Example:_ `kilm init --env-var MY_LIB_PATH`
+  _Example:_ `kilm init --env-var MY_LIB_PATH`
+  (Run `kilm setup` afterward to propagate this variable into KiCad.)

87-87: US variant of “afterward.”

-**Note:** Running `kilm init` registers the library with KiLM and prepares the directory. You still need to run [`kilm setup`](/reference/cli/setup/) afterwards to make KiCad aware of this library by updating KiCad's configuration files.
+**Note:** Running `kilm init` registers the library with KiLM and prepares the directory. You still need to run [`kilm setup`](/reference/cli/setup/) afterward to make KiCad aware of this library by updating KiCad's configuration files.
docs/src/content/docs/guides/troubleshooting.md (4)

10-13: Use American English “Afterward.”

Replace “Afterwards” with “Afterward” to match the project’s US English style.

-This will initialize its configuration directory and files in the standard location for your operating system. Afterwards, KiLM should be able to find them.
+This will initialize its configuration directory and files in the standard location for your operating system. Afterward, KiLM should be able to find them.

24-27: Clarify Windows env-var guidance (use setx or PowerShell API).

“SetEnvironmentVariable” is ambiguous. Suggest concrete commands.

-**System (Windows):** After using `SetEnvironmentVariable` in PowerShell or editing System Properties, you might need to restart KiCad, or potentially log out and back in, for the changes to take effect globally.
+**System (Windows):** After setting variables (e.g., `setx KICAD_USER_LIB "C:\path\to\lib"` in CMD/PowerShell, or `\[System.Environment]::SetEnvironmentVariable('KICAD_USER_LIB','C:\path\to\lib','User')` in PowerShell), you might need to restart KiCad—or log out and back in—for changes to take effect.

31-38: Tighten wording and fix minor grammar in Template section.

Small copyedits for flow/clarity.

-- **Cause:** This can happen if the source project directory contains unexpected or non-standard files/directories that interfere with the template creation logic (e.g., complex build artifacts, temporary files, unusual symlinks).
+- **Cause:** This can happen when the source project contains unexpected or non‑standard files/directories that interfere with template creation (e.g., build artifacts, temporary files, unusual symlinks).
@@
-  - **Clean Project:** Ensure your source project directory is clean and doesn't contain unnecessary temporary or build files.
+  - **Clean Project:** Ensure your source project is clean and doesn’t include unnecessary temporary or build files.

46-49: Optional: add default config path note.

Mention the default KiLM config path per OS to help users find it faster.

-2.  **Update KiLM Config:** Manually edit `~/.config/kicad-lib-manager/config.yaml` (or equivalent) and add the desired `env_var: YOUR_VAR_NAME` key/value pair to the library entry.
+2.  **Update KiLM Config:** Manually edit KiLM’s config (`~/.config/kicad-lib-manager/config.yaml` on Linux, `%APPDATA%\kicad-lib-manager\config.yaml` on Windows, `~/Library/Application Support/kicad-lib-manager/config.yaml` on macOS) and add `env_var: YOUR_VAR_NAME` to the library entry.
docs/src/content/docs/reference/cli/config.mdx (2)

25-31: Minor grammar/punctuation fixes in options.

Improve readability; no behavior change.

-- `--type [github|cloud|all]`:
-  Filters the libraries shown by type.
+- `--type [github|cloud|all]`:
+  Filter libraries by type.
@@
-  - `all`: Shows all types (default).
+  - `all`: Show all types (default).

84-90: Tighten wording for --type under set-default.

Small clarity tweak.

-- `--type [github|cloud]`:
-  Specifies the type of library to choose from when prompting (if `LIBRARY_NAME` is omitted) or to disambiguate if names clash. Default: `github`.
+- `--type [github|cloud]`:
+  Choose among GitHub (symbols/footprints/templates) or Cloud (3D) libraries when prompting (if `LIBRARY_NAME` is omitted) or to disambiguate name clashes. Default: `github`.
docs/src/content/docs/reference/cli/add-hook.md (2)

20-28: Clarify when post-merge runs (not on fast-forward or rebase).

Avoid overpromising execution on every pull.

-This hook is designed to automatically run `kilm update` after successful `git pull` or `git merge` operations.
+This hook runs `kilm update` after a merge commit is created (e.g., `git merge`, or a `git pull` that results in a merge). Note: fast‑forward pulls and rebases do not trigger `post-merge`.

43-57: Harden the sample hook content (POSIX-safe, guard kilm).

Make the example resilient if kilm is missing and fail-safe.

-#!/bin/sh
+#!/bin/sh
+set -eu
+# Skip gracefully if KiLM is not installed
+if ! command -v kilm >/dev/null 2>&1; then
+  echo "kilm not found; skipping update."
+  exit 0
+fi
 # BEGIN KiLM-managed section
 # KiCad Library Manager auto-update hook
 # Added by kilm add-hook command
docs/src/content/docs/guides/automatic-updates.mdx (2)

72-78: Align “How It Works” with hook semantics.

Clarify trigger conditions and suggest broader coverage if desired.

-1.  Git executes the `post-merge` hook automatically
+1.  Git executes the `post-merge` hook after a merge commit is created (not on fast‑forward pulls or rebases)

95-100: Troubleshooting: mention fast-forward/rebase case.

Add a bullet for “hook not running” when pulls are fast-forward or rebase.

 - Ensure the hook file has execute permissions (`chmod +x .git/hooks/post-merge`)
 - Check that you're running `git pull` or `git merge` (not `git fetch`)
 - Verify the hook is in the correct repository's `.git/hooks` directory
+- If your pulls are fast‑forward or you use `git pull --rebase`, `post-merge` won’t run; consider also using `post-checkout` and `post-rewrite`.
kicad_lib_manager/utils/git_utils.py (2)

88-99: Preserve metadata when backing up hooks.

Use shutil.copy2 to retain timestamps/permissions; no need for manual chmod logic.

@@
-    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
-    backup_path = hook_path.with_suffix(f".backup.{timestamp}")
-
-    # Copy the file content
-    backup_path.write_text(hook_path.read_text())
-
-    # Preserve executable permissions
-    if hook_path.stat().st_mode & 0o111:  # Check if executable
-        backup_path.chmod(0o755)
+    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
+    backup_path = hook_path.with_suffix(f".backup.{timestamp}")
+    import shutil
+    shutil.copy2(hook_path, backup_path)
 
     return backup_path

1-4: Address failing test in CI (“Not a Git repository”).

The new rev-parse approach will yield a clearer failure. If tests expect a fallback temp path, adjust tests or guard calls in non-repo scenarios.

Happy to update tests to mock git rev-parse and cover worktrees, hooksPath, and non-repo paths.

kicad_lib_manager/commands/add_hook.py (2)

59-66: “Overwrite” prompt doesn’t actually overwrite.

If the user accepts overwrite (or passes --force), the code still merges. Either change the wording to “Update (merge)” or implement real overwrite. Suggest implementing overwrite to match the flag/prompt.

-    if post_merge_hook.exists():
+    if post_merge_hook.exists():
+        replace = force
         if not force:
             click.echo(f"Post-merge hook already exists at {post_merge_hook}")
             if not click.confirm("Overwrite existing hook?", default=False):
                 click.echo("Hook installation cancelled.")
                 return
+            replace = True

91-94: Write file with explicit encoding.

Be explicit to avoid locale-dependent behavior.

-        with post_merge_hook.open("w") as f:
+        with post_merge_hook.open("w", encoding="utf-8") as f:
             f.write(new_content)
tests/test_git_utils.py (1)

79-92: Patch where the function is used, not the global.

Consider patching kicad_lib_manager.utils.git_utils.subprocess.run to avoid bleed-through if other modules import subprocess differently.

Also applies to: 93-109, 110-121, 153-159

docs/src/content/docs/reference/cli/template.mdx (2)

32-34: Tighten option phrasing.

Avoid fragments; clarify multiplicity.

- - `--variable TEXT`: Define a variable for the template (key=value pair). Can be used multiple times. These variables can be used within template filenames using `%{variable}` syntax and within file content using Jinja2 `{{variable}}` syntax.
+ - `--variable TEXT`: Define a variable for the template as `key=value`. May be repeated. Variables apply to filenames using `%{variable}` and to file content using Jinja2 `{{variable}}`.
- - `--exclude TEXT`: Glob pattern (like `.gitignore`) to exclude specific files or directories from the template. Can be used multiple times.
+ - `--exclude TEXT`: Glob pattern (like `.gitignore`) to exclude files or directories. May be repeated.

91-96: Consistency: multiplicity phrasing.

Mirror wording used above.

- - `--set-var TEXT`: Set a value for a template variable (key=value). Can be used multiple times. Overrides default values from `metadata.yaml`.
+ - `--set-var TEXT`: Set a template variable as `key=value`. May be repeated. Overrides defaults from `metadata.yaml`.
kicad_lib_manager/commands/unpin.py (3)

27-31: Avoid shadowing Python’s built-in all (rename parameter).

Rename the Click param to unpin_all to prevent confusion and improve readability.

 @click.option(
-    "--all",
-    is_flag=True,
-    help="Unpin all libraries",
+    "--all",
+    "unpin_all",
+    is_flag=True,
+    help="Unpin all libraries",
 )
@@
-def unpin(symbols, footprints, all, dry_run, max_backups, verbose):
+def unpin(symbols, footprints, unpin_all, dry_run, max_backups, verbose):
@@
-    if all and (symbols or footprints):
+    if unpin_all and (symbols or footprints):
         raise click.UsageError("'--all' cannot be used with '--symbols' or '--footprints'")
@@
-    if all:
+    if unpin_all:
         try:
@@
-    if not symbols and not footprints and not all:
+    if not symbols and not footprints and not unpin_all:
         click.echo("Error: No libraries specified to unpin", err=True)

Also applies to: 49-54, 71-72, 101-104


118-121: Report actual removals (not just requested), and show accurate verbose lists.

Currently counts/verbose lists reflect requested inputs, which can be misleading if some targets weren’t pinned. Track and print the actual removed items.

         with kicad_common.open() as f:
             config = json.load(f)
 
         changes_needed = False
+        removed_symbols: list[str] = []
+        removed_footprints: list[str] = []
@@
         # Handle symbol libraries
         if "pinned_symbol_libs" in config["session"] and symbols:
             current_symbols = config["session"]["pinned_symbol_libs"]
             new_symbols = [lib for lib in current_symbols if lib not in symbols]
+            removed_symbols = [lib for lib in current_symbols if lib not in new_symbols]
@@
         # Handle footprint libraries
         if "pinned_fp_libs" in config["session"] and footprints:
             current_footprints = config["session"]["pinned_fp_libs"]
             new_footprints = [
                 lib for lib in current_footprints if lib not in footprints
             ]
+            removed_footprints = [lib for lib in current_footprints if lib not in new_footprints]
@@
         if changes_needed:
             if dry_run:
                 click.echo(
-                    f"Would unpin {len(symbols) if symbols else 0} symbol and {len(footprints) if footprints else 0} footprint libraries in KiCad"
+                    f"Would unpin {len(removed_symbols)} symbol and {len(removed_footprints)} footprint libraries in KiCad"
                 )
             else:
                 click.echo(
-                    f"Unpinned {len(symbols) if symbols else 0} symbol and {len(footprints) if footprints else 0} footprint libraries in KiCad"
+                    f"Unpinned {len(removed_symbols)} symbol and {len(removed_footprints)} footprint libraries in KiCad"
                 )
                 click.echo("Created backup of kicad_common.json")
                 click.echo("Restart KiCad for changes to take effect")
@@
         if verbose:
-            if symbols:
+            if removed_symbols:
                 click.echo("\nUnpinned Symbol Libraries:")
-                for symbol in sorted(symbols):
+                for symbol in sorted(removed_symbols):
                     click.echo(f"  - {symbol}")
 
-            if footprints:
+            if removed_footprints:
                 click.echo("\nUnpinned Footprint Libraries:")
-                for footprint in sorted(footprints):
+                for footprint in sorted(removed_footprints):
                     click.echo(f"  - {footprint}")

Also applies to: 130-151, 160-184


73-75: Specify UTF-8 encoding when reading/writing JSON.

Prevents locale-dependent behavior on some systems.

-            with kicad_common.open() as f:
+            with kicad_common.open(encoding="utf-8") as f:
                 config = json.load(f)
@@
-        with kicad_common.open() as f:
+        with kicad_common.open(encoding="utf-8") as f:
             config = json.load(f)
@@
-            with kicad_common.open("w") as f:
+            with kicad_common.open("w", encoding="utf-8") as f:
                 json.dump(config, f, indent=2)

Also applies to: 118-120, 157-159

tests/test_unpin_command.py (4)

5-11: Use mock_open for cleaner JSON stubbing.

Simplifies setup and avoids manual __enter__/read wiring.

-from unittest.mock import patch
+from unittest.mock import patch, mock_open

38-53: Make “--all only” test fully hermetic (no real FS ops).

Add --dry-run and stub backups/opens via mock_open.

         with patch('kicad_lib_manager.commands.unpin.find_kicad_config') as mock_find_config:
             mock_find_config.return_value = Path("/tmp/kicad")
 
             with patch('pathlib.Path.exists') as mock_exists:
                 mock_exists.return_value = True
 
-                with patch('builtins.open') as mock_open:
-                    mock_open.return_value.__enter__.return_value.read.return_value = '{"session": {"pinned_symbol_libs": [], "pinned_fp_libs": []}}'
+                m = mock_open(read_data='{"session": {"pinned_symbol_libs": [], "pinned_fp_libs": []}}')
+                with patch('builtins.open', m), patch('kicad_lib_manager.commands.unpin.create_backup'):
 
                     # Should not raise an error
-                    result = self.runner.invoke(unpin, ['--all'])
+                    result = self.runner.invoke(unpin, ['--all', '--dry-run'])
                     # Exit code 0 means success, or 1 if no libraries found (which is expected)
                     assert result.exit_code in [0, 1]

54-69: Hermetic “symbols only” test; avoid real backups/writes.

Use mock_open and stub create_backup; add --dry-run.

         with patch('kicad_lib_manager.commands.unpin.find_kicad_config') as mock_find_config:
             mock_find_config.return_value = Path("/tmp/kicad")
 
             with patch('pathlib.Path.exists') as mock_exists:
                 mock_exists.return_value = True
 
-                with patch('builtins.open') as mock_open:
-                    mock_open.return_value.__enter__.return_value.read.return_value = '{"session": {"pinned_symbol_libs": ["lib1"], "pinned_fp_libs": []}}'
+                m = mock_open(read_data='{"session": {"pinned_symbol_libs": ["lib1"], "pinned_fp_libs": []}}')
+                with patch('builtins.open', m), patch('kicad_lib_manager.commands.unpin.create_backup'):
 
                     # Should not raise an error
-                    result = self.runner.invoke(unpin, ['--symbols', 'lib1'])
+                    result = self.runner.invoke(unpin, ['--symbols', 'lib1', '--dry-run'])
                     # Exit code 0 means success, or 1 if no libraries found (which is expected)
                     assert result.exit_code in [0, 1]

70-85: Hermetic “footprints only” test; avoid real backups/writes.

Same rationale as above.

         with patch('kicad_lib_manager.commands.unpin.find_kicad_config') as mock_find_config:
             mock_find_config.return_value = Path("/tmp/kicad")
 
             with patch('pathlib.Path.exists') as mock_exists:
                 mock_exists.return_value = True
 
-                with patch('builtins.open') as mock_open:
-                    mock_open.return_value.__enter__.return_value.read.return_value = '{"session": {"pinned_symbol_libs": [], "pinned_fp_libs": ["lib1"]}}'
+                m = mock_open(read_data='{"session": {"pinned_symbol_libs": [], "pinned_fp_libs": ["lib1"]}}')
+                with patch('builtins.open', m), patch('kicad_lib_manager.commands.unpin.create_backup'):
 
                     # Should not raise an error
-                    result = self.runner.invoke(unpin, ['--footprints', 'lib1'])
+                    result = self.runner.invoke(unpin, ['--footprints', 'lib1', '--dry-run'])
                     # Exit code 0 means success, or 1 if no libraries found (which is expected)
                     assert result.exit_code in [0, 1]
docs/src/content/docs/reference/cli/unpin.md (1)

1-83: Add exit codes to align docs with CLI/tests.

Clarifies that mutual exclusivity errors are usage errors (exit 2).

 ## Behavior
@@
 6.  Writes the updated lists back to `kicad_common.json` (unless `--dry-run`).
 
+## Exit codes
+
+- `0`: Success (including “nothing to unpin”).
+- `1`: Operational error (e.g., failed to locate KiCad config, read/write error).
+- `2`: Usage error (e.g., `--all` used together with `-s/--symbols` or `-f/--footprints`).
+
 ## Examples
docs/src/content/docs/index.mdx (4)

70-74: Point “Documentation” to the in-repo docs (avoid external site).

The external URL likely predates this PR. Link internally.

-  <a
-    href="https://kilm.aristovnik.me"
+  <a
+    href="/"
     className="inline-flex items-center bg-[rgba(30,30,40,0.8)] rounded-lg py-2 px-4 text-sm font-medium text-white/90 shadow-md transition-all duration-200 hover:translate-y-[-2px] hover:shadow-lg hover:text-white border border-white/10"
   >
     <span className="mr-2">📚</span> Documentation
   </a>

21-25: Avoid duplicate “live badge” mechanisms.

You render and also a manual badge block with IDs (pypi-version, python-versions, pypi-downloads). Pick one to prevent drift and DOM duplication.

If BadgeData already fetches/prints these, remove the manual badges (lines 34–63). Want me to fold those into BadgeData and drop the IDs?

Also applies to: 34-63


204-226: Use valid, namespaced Iconify icons for Card icons.

Unqualified names like "add-document", "document", "pin" may not resolve. Suggest Tabler set:

  • Add External Libraries → tabler:library-plus
  • Create Project Templates → tabler:template
  • Set Environment Variables → tabler:settings
  • Manage Pinned Libraries → tabler:pin
-  <Card
-    title="Add External Libraries"
-    link="/reference/cli/add-3d/"
-    icon="add-document"
-  >
+  <Card title="Add External Libraries" link="/reference/cli/add-3d/" icon="tabler:library-plus">
     Integrate third-party symbol, footprint, and 3D model libraries.
   </Card>
-  <Card
-    title="Create Project Templates"
-    link="/reference/cli/template/"
-    icon="document"
-  >
+  <Card title="Create Project Templates" link="/reference/cli/template/" icon="tabler:template">
     Standardize designs with reusable project templates.
   </Card>
-  <Card
-    title="Set Environment Variables"
-    link="/reference/cli/config/"
-    icon="seti:config"
-  >
+  <Card title="Set Environment Variables" link="/reference/cli/config/" icon="tabler:settings">
     Configure KiCad environment variables directly through KiLM.
   </Card>
-  <Card title="Manage Pinned Libraries" link="/reference/cli/pin/" icon="pin">
+  <Card title="Manage Pinned Libraries" link="/reference/cli/pin/" icon="tabler:pin">
     Keep your favorite libraries readily accessible within KiCad.
   </Card>

106-108: Don’t pin a fake version in the terminal demo.

Hardcoding “kilm-1.0.0” will go stale. Prefer a placeholder.

-      Successfully installed kilm-1.0.0
+      Successfully installed kilm-x.y.z

Comment thread docs/src/content/docs/index.mdx Outdated
Comment thread docs/src/content/docs/index.mdx
Comment thread kicad_lib_manager/commands/add_hook.py
Comment thread kicad_lib_manager/commands/add_hook.py
Comment thread kicad_lib_manager/utils/git_utils.py Outdated
Comment thread kicad_lib_manager/utils/git_utils.py
Comment thread tests/test_git_utils.py Outdated
@barisgit barisgit merged commit 611dcb1 into main Sep 4, 2025
6 of 7 checks passed
@barisgit barisgit deleted the feature/integrated-docs branch September 4, 2025 20:05
This was referenced Sep 4, 2025
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