From d73425d3b3ae76112c2eb5896daaf1a96fccb42e Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:09:55 +0530 Subject: [PATCH 01/10] chore: add .editorconfig and .gitattributes LF endings and the same indentation the code already uses, so editors agree with the hooks. The lockfiles and the detect-secrets baseline are marked linguist-generated: GitHub collapses them in diffs. --- .editorconfig | 15 +++++++++++++++ .gitattributes | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6b7f9e3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.py] +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..86bc95a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +* text=auto eol=lf +*.png binary +*.ico binary + +# Written by tools, not by hand. GitHub collapses these in pull request diffs +# and leaves them out of language stats. +uv.lock linguist-generated=true +website/package-lock.json linguist-generated=true +.secrets.baseline linguist-generated=true From a96e1ae37835d06c8523614ac8c2e990f66e3193 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:16:48 +0530 Subject: [PATCH 02/10] ci: audit workflows with zizmor and actionlint, spell-check with typos New pre-commit hooks, pinned to commit SHAs: - actionlint lints workflow syntax and expressions, which the schema check does not. - zizmor audits workflows for security problems. - typos spell-checks the repo. It runs report-only: its default writes suggestions into the files, and it wanted to rename the `pn` CSS prefix to `on`. _typos.toml lists what is spelled on purpose and what is generated. - check-json, plus the schema checks for issue forms, the issue chooser and CITATION.cff. Fixed what they found: every checkout now sets persist-credentials: false (none of the jobs push), and Dependabot waits 7 days after a release. The one zizmor note left, softprops/action-gh-release, is silenced with the reason: replacing it changes the release job, which cannot be tried before a release. detect-secrets skips .pre-commit-config.yaml, whose commit SHAs it takes for secrets. --- .github/dependabot.yml | 9 +++++++++ .github/workflows/ci.yml | 7 +++++++ .github/workflows/release.yml | 6 +++++- .github/workflows/website.yml | 6 ++++++ .pre-commit-config.yaml | 32 +++++++++++++++++++++++++++++++- _typos.toml | 22 ++++++++++++++++++++++ 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 _typos.toml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f1d1b5a..d20339f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,14 @@ +# Version updates are grouped per ecosystem and wait 7 days after a release +# (cooldown), so a bad release is usually yanked before we are offered it. +# Security updates are not delayed. version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weekly + cooldown: + default-days: 7 groups: actions: patterns: ["*"] @@ -11,6 +16,8 @@ updates: directory: / schedule: interval: weekly + cooldown: + default-days: 7 groups: python: patterns: ["*"] @@ -18,6 +25,8 @@ updates: directory: /website schedule: interval: weekly + cooldown: + default-days: 7 groups: website: patterns: ["*"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23aa61c..ef19f44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 with: python-version: "3.12" @@ -43,6 +45,8 @@ jobs: python: "3.12" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 with: python-version: ${{ matrix.python }} @@ -70,6 +74,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 with: python-version: "3.12" @@ -100,6 +106,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0 env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34f95b1..b21646f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,8 @@ jobs: attestations: write # record it with GitHub, for `gh attestation verify` steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 with: python-version: "3.12" @@ -85,6 +87,8 @@ jobs: contents: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: dist @@ -102,7 +106,7 @@ jobs: on {print} ' CHANGELOG.md > notes.md test -s notes.md || echo "Release $GITHUB_REF_NAME" > notes.md - - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 # zizmor: ignore[superfluous-actions] `gh release create` would do, but a release job cannot be tried before a release with: body_path: notes.md files: | diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 97e2823..209e4d9 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -47,6 +47,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -81,6 +83,8 @@ jobs: name: preview steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -121,6 +125,8 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb09811..040de41 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,7 @@ # Runs on every commit (and `pytest` on every push). CI runs the same hooks, # so what passes here passes there. Install once per clone: # uv run pre-commit install --install-hooks -t pre-commit -t pre-push +# New hooks below are pinned to commit SHAs (the comment names the release). default_install_hook_types: [pre-commit, pre-push] default_stages: [pre-commit] @@ -17,6 +18,7 @@ repos: - id: check-yaml - id: check-toml - id: check-merge-conflict + - id: check-json - id: check-added-large-files args: [--maxkb=500] # kdev handles OAuth tokens, tunnel credentials and deploy keys; none @@ -29,13 +31,41 @@ repos: # A mistyped key in a workflow fails silently on GitHub; catch it here. - id: check-github-workflows - id: check-dependabot + - id: check-github-issue-forms + - id: check-github-issue-config + - id: check-citation-file-format + + # Lints workflow syntax and expressions, which check-github-workflows + # (a schema check) does not. + - repo: https://github.com/rhysd/actionlint + rev: 914e7df21a07ef503a81201c76d2b11c789d3fca # frozen: v1.7.12 + hooks: + - id: actionlint + + # Security audit of workflows: template injection, over-broad permissions, + # persisted credentials, unpinned actions, dependabot without a cooldown. + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: c7d31dc612dffdd4d3b2f2b88b9660d3ab057ee8 # frozen: v1.33.1 + hooks: + - id: zizmor + + # Spell check; the config is _typos.toml. + - repo: https://github.com/crate-ci/typos + rev: 276087d9a4f06398b3e04825487805e2d7375888 # frozen: v1.52.2 + hooks: + - id: typos + # Report only. The default writes its suggestions into the files, which + # would rename identifiers that are spelled on purpose. + args: [--force-exclude] - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: - id: detect-secrets args: [--baseline, .secrets.baseline] - exclude: ^(uv\.lock|website/package-lock\.json)$ + # Pinned hook revisions in this file are 40-hex commit SHAs, which look + # like secrets; gitleaks still scans it. + exclude: ^(uv\.lock|website/package-lock\.json|\.pre-commit-config\.yaml)$ - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.16.8 diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..1fcbf65 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,22 @@ +# Spell check (https://github.com/crate-ci/typos), run by pre-commit. +[files] +extend-exclude = [ + # Generated or fetched, not written by hand. + "uv.lock", + "website/package-lock.json", + ".secrets.baseline", + # Checked-in site assets: key files and search-engine verification files. + "website/public/*.txt", + "website/public/google*.html", + # Local design kit, not part of kdev. + ".agents/", +] + +[default.extend-identifiers] +# "the box's own": an apostrophe cannot be part of a Python name. +test_restore_uses_the_boxs_own_notebook_not_this_machines = "test_restore_uses_the_boxs_own_notebook_not_this_machines" +test_only_the_boxs_own_runtime_files_are_skipped = "test_only_the_boxs_own_runtime_files_are_skipped" + +[default.extend-words] +# CSS class prefix for the previous/next links in website/src/layouts/Docs.astro. +pn = "pn" From d89e4c9d2e45e49423221667e0c85fbe5320a869 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:17:14 +0530 Subject: [PATCH 03/10] ci: check that commits and pull request titles are Conventional Commits The history already follows the convention, but nothing enforced it. - A conventional-pre-commit commit-msg hook checks each commit message. - The "PR title" workflow checks the title of each pull request with the same types. We squash-merge, so the title is the commit on main. Any scope is accepted: `fix(config):` and Dependabot's `build(deps-dev):` are both in the history. It runs on pull_request_target but never checks out pull request code, and reads only the title. --- .github/workflows/pr-title.yml | 45 ++++++++++++++++++++++++ .pre-commit-config.yaml | 14 ++++++-- CONTRIBUTING.md | 18 ++++++---- website/src/content/docs/contributing.md | 18 ++++++---- 4 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/pr-title.yml diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 0000000..5a39688 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,45 @@ +# Pull requests are squash-merged and the PR title becomes the commit on main, +# so lint it as a Conventional Commit. The types match the commit-msg hook in +# .pre-commit-config.yaml. See CONTRIBUTING.md. +# pull_request_target runs this file from main and never checks out pull request code. +name: PR title + +on: + pull_request_target: # zizmor: ignore[dangerous-triggers] no checkout; the title is read through the API + types: [opened, edited, synchronize, reopened] + +permissions: {} + +concurrency: + group: pr-title-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + conventional-title: + name: Conventional PR title + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + pull-requests: read # read the title + steps: + - uses: amannn/action-semantic-pull-request@2252a14e810aa9b85c2d560bd7070c802206ecf6 # v6.1.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + types: | + build + chore + ci + docs + feat + fix + perf + refactor + revert + style + test + requireScope: false + subjectPattern: ^(?![A-Z][a-z]).+[^.]$ + subjectPatternError: >- + The subject "{subject}" in "{title}" must not start with a capitalised + word ("add the flag", not "Add the flag") and must not end with a period. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 040de41..941860d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,8 @@ # Runs on every commit (and `pytest` on every push). CI runs the same hooks, # so what passes here passes there. Install once per clone: -# uv run pre-commit install --install-hooks -t pre-commit -t pre-push +# uv run pre-commit install --install-hooks -t pre-commit -t commit-msg -t pre-push # New hooks below are pinned to commit SHAs (the comment names the release). -default_install_hook_types: [pre-commit, pre-push] +default_install_hook_types: [pre-commit, commit-msg, pre-push] default_stages: [pre-commit] repos: @@ -58,6 +58,16 @@ repos: # would rename identifiers that are spelled on purpose. args: [--force-exclude] + # Commit messages are Conventional Commits, as CONTRIBUTING.md asks. The + # pull-request title check (.github/workflows/pr-title.yml) uses the same + # types; any scope is accepted (`fix(config):`, `build(deps):`). + - repo: https://github.com/compilerla/conventional-pre-commit + rev: 33b50eb042bee26eac0ee96ad84aa9c1b4dccdd8 # frozen: v4.5.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] + - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 691b8d5..a152536 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ You need Python 3.11+ and [uv](https://docs.astral.sh/uv/). ```bash git clone https://github.com/tushar-mahalya/kdev && cd kdev uv sync -uv run pre-commit install # hooks on commit, tests on push +uv run pre-commit install # hooks on commit and commit message, tests on push uv run basedpyright # basic-mode type check, also on every commit uv run pytest # unit and regression tests, no network needed uv run pytest --cov # the same suite with a local coverage report @@ -45,8 +45,9 @@ uv run kdev -v … # the working tree, with API logging ``` Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets scan -(`detect-secrets`, private-key detection), config validation and a lockfile -check; every push runs the tests. CI runs the same hooks, the tests on Python +(`detect-secrets`, private-key detection), a spell check (`typos`), config +validation, a workflow security audit (`zizmor`, `actionlint`) and a lockfile +check, and its message must be a Conventional Commit; every push runs the tests. CI runs the same hooks, the tests on Python 3.11–3.13, a build-and-install check, and `gitleaks` over the full history. ## Trying a change against real Kaggle @@ -88,9 +89,14 @@ on-box restore against a temporary directory. - **Match the code around you.** `kdev_box.py` stays standard-library only. Everything the user sees goes through `ui.py`. A failure the user can act on is a `KdevError` with the command that fixes it. -- **Commit messages** follow [Conventional Commits](https://www.conventionalcommits.org/) - (`fix:`, `feat:`, `docs:`, `test:`, `ci:`, `refactor:`), with the *why* in - the body. +- **Commit messages and the pull request title** follow + [Conventional Commits](https://www.conventionalcommits.org/): `type: subject` + or `type(scope): subject`, with the type one of `feat`, `fix`, `docs`, + `test`, `ci`, `build`, `chore`, `refactor`, `perf`, `style` or `revert`. Start + the subject with a lowercase word and leave off the final period; put the + *why* in the body. A `commit-msg` hook checks each commit, and a check on the + pull request checks its title, because we squash-merge and the title becomes + the commit on `main`. - **Record what users will notice** under `## [Unreleased]` in [CHANGELOG.md](CHANGELOG.md). If a command or its behaviour changes, update the [README](README.md), the [website docs](website/src/content/docs/) and, diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index eed19f4..0040cd4 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -35,7 +35,7 @@ You need Python 3.11+ and [uv](https://docs.astral.sh/uv/). ```bash git clone https://github.com/tushar-mahalya/kdev && cd kdev uv sync -uv run pre-commit install # hooks on commit, tests on push +uv run pre-commit install # hooks on commit and commit message, tests on push uv run basedpyright # basic-mode type check, also on every commit uv run pytest # unit and regression tests, no network needed uv run pytest --cov # the same suite with a local coverage report @@ -43,8 +43,9 @@ uv run kdev -v … # the working tree, with API logging ``` Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets scan -(`detect-secrets`, private-key detection), config validation and a lockfile -check; every push runs the tests. CI runs the same hooks, the tests on Python +(`detect-secrets`, private-key detection), a spell check (`typos`), config +validation, a workflow security audit (`zizmor`, `actionlint`) and a lockfile +check, and its message must be a Conventional Commit; every push runs the tests. CI runs the same hooks, the tests on Python 3.11–3.13, a build-and-install check, and `gitleaks` over the full history. ## Trying a change against real Kaggle @@ -86,9 +87,14 @@ on-box restore against a temporary directory. - **Match the code around you.** `kdev_box.py` stays standard-library only. Everything the user sees goes through `ui.py`. A failure the user can act on is a `KdevError` with the command that fixes it. -- **Commit messages** follow [Conventional Commits](https://www.conventionalcommits.org/) - (`fix:`, `feat:`, `docs:`, `test:`, `ci:`, `refactor:`), with the *why* in - the body. +- **Commit messages and the pull request title** follow + [Conventional Commits](https://www.conventionalcommits.org/): `type: subject` + or `type(scope): subject`, with the type one of `feat`, `fix`, `docs`, + `test`, `ci`, `build`, `chore`, `refactor`, `perf`, `style` or `revert`. Start + the subject with a lowercase word and leave off the final period; put the + *why* in the body. A `commit-msg` hook checks each commit, and a check on the + pull request checks its title, because we squash-merge and the title becomes + the commit on `main`. - **Record what users will notice** under `## [Unreleased]` in [CHANGELOG.md](https://github.com/tushar-mahalya/kdev/blob/main/CHANGELOG.md), and update the README if a command or its behaviour changes. From 1e1479927207a6d9e2a9a5632478a1f8079e8bb3 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:17:22 +0530 Subject: [PATCH 04/10] ci: review the dependencies a pull request adds actions/dependency-review-action fails a pull request that adds a Python or npm package, or a GitHub Action, with a known high or critical vulnerability. It needs only read access to the contents. --- .github/workflows/dependency-review.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dependency-review.yml diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..3c33172 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,25 @@ +# Block pull requests that add dependencies (Python or npm packages, GitHub +# Actions) with known high or critical vulnerabilities. +name: Dependency review + +on: + pull_request: + +permissions: {} + +concurrency: + group: dependency-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + dependency-review: + name: Dependency review + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 + with: + fail-on-severity: high + show-patched-versions: true From eb29dae333b411b1d4ca1691b8f2b64c713b1109 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:17:35 +0530 Subject: [PATCH 05/10] ci: keep labels as code, label pull requests by path, and group release notes - .github/labels.yml lists the repository labels, the existing ones included, plus an "area: ..." set for kdev's modules, tests, docs, website, ci and deps. The old `ci` label is renamed to `area: ci`, so it stays on what it is already on. The "Sync labels" workflow applies the file on main and never deletes a label. - .github/labeler.yml and the "Labeler" workflow add an area label to each pull request from the paths it changes, and a type label from the branch prefix. The workflow runs on pull_request_target but never checks out pull request code. - .github/release.yml sorts GitHub's generated release notes into categories. The release workflow still publishes the CHANGELOG section; this applies to "Generate release notes" in the GitHub UI. --- .github/labeler.yml | 88 ++++++++++++++++++++++++ .github/labels.yml | 85 +++++++++++++++++++++++ .github/release.yml | 21 ++++++ .github/workflows/labeler.yml | 25 +++++++ .github/workflows/sync-labels.yml | 33 +++++++++ CONTRIBUTING.md | 10 +++ website/src/content/docs/contributing.md | 10 +++ 7 files changed, 272 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/labels.yml create mode 100644 .github/release.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/sync-labels.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..51ee259 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,88 @@ +# Pull request labels for actions/labeler (.github/workflows/labeler.yml). +# Area labels follow changed paths. Type labels follow the head branch prefix +# (feat/, fix/, docs/) described in CONTRIBUTING.md. Labels are defined in .github/labels.yml. + +"area: cli": + - changed-files: + - any-glob-to-any-file: + - src/kdev/cli.py + - src/kdev/__main__.py + - src/kdev/commands/** + - src/kdev/errors.py + - src/kdev/menu.py + - src/kdev/ui.py + - src/kdev/wizard.py + +"area: box": + - changed-files: + - any-glob-to-any-file: + - src/kdev/bootstrap.py + - src/kdev/kdev_box.py + - src/kdev/notebook.py + - src/kdev/persistence.py + - src/kdev/quota.py + - src/kdev/safety.py + - src/kdev/session.py + +"area: tunnel": + - changed-files: + - any-glob-to-any-file: + - src/kdev/cloudflared.py + - src/kdev/sshcfg.py + - src/kdev/tunnel.py + +"area: kaggle": + - changed-files: + - any-glob-to-any-file: + - src/kdev/api.py + - src/kdev/auth.py + - src/kdev/config.py + +"area: tests": + - changed-files: + - any-glob-to-any-file: + - tests/** + +"area: docs": + - changed-files: + - any-glob-to-any-file: + - docs/** + - CITATION.cff + - all-globs-to-any-file: ["*.md", "!CHANGELOG.md"] + +"area: website": + - changed-files: + - any-glob-to-any-file: + - website/** + - .github/workflows/website.yml + +"area: ci": + - changed-files: + - any-glob-to-any-file: + - .github/** + - .pre-commit-config.yaml + - .coderabbit.yaml + - .gitignore + - _typos.toml + - .editorconfig + - .gitattributes + +"area: deps": + - changed-files: + - any-glob-to-any-file: + - pyproject.toml + - uv.lock + - website/package.json + - website/package-lock.json + +enhancement: + - head-branch: ["^feat/"] + +bug: + - head-branch: ["^fix/"] + +documentation: + - head-branch: ["^docs/"] + +dependencies: + - head-branch: ["^dependabot/", "^deps/"] diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..a319f52 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,85 @@ +# Repository labels as code. .github/workflows/sync-labels.yml applies this file on main. +# Labels missing from this file are kept (skip-delete), so remove a label here and in the UI. +# Rename a label with `from_name` to keep it on existing issues and pull requests. + +# Type +- name: bug + color: "d73a4a" + description: Something isn't working +- name: enhancement + color: "a2eeef" + description: New feature or request +- name: documentation + color: "0075ca" + description: Improvements or additions to documentation +- name: dependencies + color: "0366d6" + description: Pull requests that update a dependency file +- name: performance + color: "5319e7" + description: Makes kdev or the box faster +- name: quota + color: "fbca04" + description: Saves Kaggle GPU/TPU quota or session time +- name: breaking-change + color: "b60205" + description: Changes behavior or configuration in a way users must act on +- name: security + color: "ee0701" + description: Hardening or a fix for a security weakness +- name: accessibility + color: "f143ab" + description: Barrier affecting people with disabilities + +# Area (applied to pull requests by .github/labeler.yml) +- name: "area: cli" + color: "c5def5" + description: Commands, prompts and the terminal UI +- name: "area: box" + color: "c5def5" + description: Starting, stopping and restoring the box, quota, and kdev_box.py +- name: "area: tunnel" + color: "c5def5" + description: Cloudflare tunnel, SSH config and port forwarding +- name: "area: kaggle" + color: "c5def5" + description: Kaggle API client, accounts and settings +- name: "area: tests" + color: "c5def5" + description: Test suite +- name: "area: docs" + color: "c5def5" + description: README, architecture notes and community files +- name: "area: website" + color: "c5def5" + description: Project website and its docs pages +- name: "area: ci" + from_name: ci + color: "c5def5" + description: Workflows, hooks and release packaging +- name: "area: deps" + color: "c5def5" + description: Dependency manifests and lockfiles + +# Triage and status +- name: question + color: "d876e3" + description: Further information is requested +- name: good first issue + color: "7057ff" + description: Good for newcomers +- name: help wanted + color: "008672" + description: Extra attention is needed +- name: duplicate + color: "cfd3d7" + description: This issue or pull request already exists +- name: invalid + color: "e4e669" + description: This doesn't seem right +- name: wontfix + color: "ffffff" + description: This will not be worked on +- name: ignore-for-release + color: "ededed" + description: Leave out of generated release notes diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f760341 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,21 @@ +# Categories for GitHub's generated release notes ("Generate release notes" and +# `gh release create --generate-notes`). Pull requests are sorted into the first match. +# The release workflow itself uses the CHANGELOG.md section as the notes. +changelog: + exclude: + labels: [ignore-for-release, duplicate, invalid, wontfix] + categories: + - title: Breaking changes + labels: [breaking-change] + - title: Features + labels: [enhancement] + - title: Fixes + labels: [bug, security] + - title: Performance + labels: [performance] + - title: Documentation + labels: [documentation] + - title: Dependencies + labels: [dependencies] + - title: Other changes + labels: ["*"] diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..9815f6d --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,25 @@ +# Label pull requests by changed paths and branch prefix (.github/labeler.yml). +# pull_request_target lets fork PRs be labeled. It reads the config from main through +# the API and never checks out pull request code. +name: Labeler + +on: + pull_request_target: # zizmor: ignore[dangerous-triggers] no checkout; the config is read through the API + types: [opened, synchronize, reopened] + +permissions: {} + +concurrency: + group: labeler-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + label: + name: Label pull request + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read # read .github/labeler.yml from main + pull-requests: write # add labels + steps: + - uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0 diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..32324b8 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,33 @@ +# Apply .github/labels.yml to the repository labels after it changes on main. +name: Sync labels + +on: + push: + branches: [main] + paths: + - .github/labels.yml + - .github/workflows/sync-labels.yml + workflow_dispatch: + +permissions: {} + +concurrency: + group: sync-labels + cancel-in-progress: false + +jobs: + sync: + name: Sync labels + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + issues: write # create and update repository labels + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d # v6.0.0 + with: + yaml-file: .github/labels.yml + skip-delete: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a152536..0934207 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -123,6 +123,16 @@ your first pull request with a link, and signing takes one click with your GitHub account. It covers all your later pull requests. If the agreement itself changes, the bot asks you to sign the new version. +## Labels + +Labels are defined in [`.github/labels.yml`](.github/labels.yml). The "Sync +labels" workflow applies that file when it changes on `main`: it creates and +updates labels and never deletes one. A second workflow labels each pull +request from the paths it changes (`area: cli`, `area: box`, `area: website` +and so on, in [`.github/labeler.yml`](.github/labeler.yml)) and from its branch +prefix (`feat/`, `fix/`, `docs/`). The labels also sort the notes GitHub +generates for a release ([`.github/release.yml`](.github/release.yml)). + ## Releasing For maintainers: bump `version` in `pyproject.toml`, move the `Unreleased` diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index 0040cd4..339c135 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -120,6 +120,16 @@ your first pull request with a link, and signing takes one click with your GitHub account. It covers all your later pull requests. If the agreement itself changes, the bot asks you to sign the new version. +## Labels + +Labels are defined in [`.github/labels.yml`](https://github.com/tushar-mahalya/kdev/blob/main/.github/labels.yml). The "Sync +labels" workflow applies that file when it changes on `main`: it creates and +updates labels and never deletes one. A second workflow labels each pull +request from the paths it changes (`area: cli`, `area: box`, `area: website` +and so on, in [`.github/labeler.yml`](https://github.com/tushar-mahalya/kdev/blob/main/.github/labeler.yml)) and from its branch +prefix (`feat/`, `fix/`, `docs/`). The labels also sort the notes GitHub +generates for a release ([`.github/release.yml`](https://github.com/tushar-mahalya/kdev/blob/main/.github/release.yml)). + ## Releasing For maintainers: bump `version` in `pyproject.toml`, move the `Unreleased` From 5854f7dcf587f20d8a5eec4825b86aee54cb6cd0 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:17:59 +0530 Subject: [PATCH 06/10] ci: test the lowest supported dependencies and set a coverage floor The new "lowest" job runs the suite on Python 3.11 with `uv run --isolated --resolution lowest-direct`, which resolves every dependency named in pyproject.toml to the lowest version it allows (uv.lock is left alone). It found two floors that were wrong: - typer 0.27.0 and 0.27.1 have no `typer.TyperException`, which cli.py catches, so any failing command crashed. The floor is now 0.27.2. - questionary 2.0 has no `description` on `Choice`, which every numbered list prompt passes. The floor is now 2.1. A "CI passed" job needs all the others, so branch protection can require one check instead of one per matrix cell. Coverage is measured on the kdev package alone, and `fail_under` is 71: the total is 74.8%, so it cannot drop unnoticed. --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++ CHANGELOG.md | 6 +++++ CONTRIBUTING.md | 15 +++++++---- pyproject.toml | 21 ++++++++++++---- uv.lock | 4 +-- website/src/content/docs/contributing.md | 15 +++++++---- 6 files changed, 76 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef19f44..939b5f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,21 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" fi + lowest: + name: tests (lowest direct dependencies, py3.11) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + with: + python-version: "3.11" + # Resolves every dependency kdev names to the lowest version pyproject.toml + # allows, on the oldest supported Python, without touching uv.lock. If this + # fails, a floor in pyproject.toml is lower than kdev really works with. + - run: uv run --isolated --resolution lowest-direct pytest + package: name: package builds and installs runs-on: ubuntu-latest @@ -111,3 +126,20 @@ jobs: - uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # One check for branch protection to require: the job names above change with + # the test matrix, this one does not. + ci-passed: + name: CI passed + if: ${{ always() }} + needs: [checks, tests, lowest, package, secrets] + runs-on: ubuntu-latest + steps: + - name: Require every job to succeed + env: + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + echo "Job results: $RESULTS" + for result in $RESULTS; do + if [ "$result" != "success" ]; then exit 1; fi + done diff --git a/CHANGELOG.md b/CHANGELOG.md index 2954268..acd29bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes are recorded here. The format follows ## [Unreleased] +### Changed +- The minimum versions of two dependencies are now the ones kdev works with: + typer 0.27.2 (0.27.0 and 0.27.1 crash when a command fails) and questionary 2.1 + (2.0 fails on every numbered list prompt). CI now runs the tests against the + lowest versions the package allows, so the declared floors stay true. + ## [0.2.0] - 2026-11-16 ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0934207..ffd5963 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,15 +40,20 @@ uv sync uv run pre-commit install # hooks on commit and commit message, tests on push uv run basedpyright # basic-mode type check, also on every commit uv run pytest # unit and regression tests, no network needed -uv run pytest --cov # the same suite with a local coverage report +uv run pytest --cov # the same suite with a coverage report; fails under 71% uv run kdev -v … # the working tree, with API logging ``` -Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets scan -(`detect-secrets`, private-key detection), a spell check (`typos`), config +Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets +scan (`detect-secrets`, private-key detection), a spell check (`typos`), config validation, a workflow security audit (`zizmor`, `actionlint`) and a lockfile -check, and its message must be a Conventional Commit; every push runs the tests. CI runs the same hooks, the tests on Python -3.11–3.13, a build-and-install check, and `gitleaks` over the full history. +check, and its message must be a Conventional Commit; every push runs the tests. + +CI runs the same hooks, the tests on Python 3.11–3.13, the tests again on the +lowest version of each dependency that `pyproject.toml` allows (if they fail, +raise that floor), a build-and-install check, and `gitleaks` over the full +history. The single job `CI passed` is green only when all of those are. Pull +requests also get a review of the dependencies they add. ## Trying a change against real Kaggle diff --git a/pyproject.toml b/pyproject.toml index bde6e8e..45f14b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,14 +20,16 @@ classifiers = [ "Programming Language :: Python :: 3.13", "Topic :: Software Development", ] -# Floors are the versions kdev is tested against: typer 0.27 is the first -# with its own exception types, kaggle 2.2 ships the OAuth `auth login` flow -# and the kagglesdk that token refresh depends on. +# Floors are the versions kdev is tested against (CI runs the suite on the +# lowest ones): typer 0.27.2 is the first to export `typer.TyperException`, +# questionary 2.1 is the first whose `Choice` takes a `description`, kaggle 2.2 +# ships the OAuth `auth login` flow and the kagglesdk that token refresh +# depends on. dependencies = [ "httpx>=0.27,<1", "kaggle>=2.2,<3", - "typer>=0.27,<1", - "questionary>=2.0,<3", + "typer>=0.27.2,<1", + "questionary>=2.1,<3", # The home menu is a small prompt_toolkit app of its own (questionary is # built on it too). "prompt-toolkit>=3.0.36,<4", @@ -84,3 +86,12 @@ ignore = ["E501", "RUF001", "RUF002", "RUF003"] # the design glyphs are deliber include = ["src", "tests"] pythonVersion = "3.11" typeCheckingMode = "basic" + +# Measured on the package alone, wherever `--cov` is run from. The floor sits a +# few points under the current total (74.8%), so coverage cannot drop unnoticed; +# raise it when the total rises. +[tool.coverage.run] +source = ["kdev"] + +[tool.coverage.report] +fail_under = 71 diff --git a/uv.lock b/uv.lock index 1c6d9d8..1522b12 100644 --- a/uv.lock +++ b/uv.lock @@ -520,9 +520,9 @@ requires-dist = [ { name = "httpx", specifier = ">=0.27,<1" }, { name = "kaggle", specifier = ">=2.2,<3" }, { name = "prompt-toolkit", specifier = ">=3.0.36,<4" }, - { name = "questionary", specifier = ">=2.0,<3" }, + { name = "questionary", specifier = ">=2.1,<3" }, { name = "rich", specifier = ">=13,<16" }, - { name = "typer", specifier = ">=0.27,<1" }, + { name = "typer", specifier = ">=0.27.2,<1" }, ] [package.metadata.requires-dev] diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index 339c135..062d054 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -38,15 +38,20 @@ uv sync uv run pre-commit install # hooks on commit and commit message, tests on push uv run basedpyright # basic-mode type check, also on every commit uv run pytest # unit and regression tests, no network needed -uv run pytest --cov # the same suite with a local coverage report +uv run pytest --cov # the same suite with a coverage report; fails under 71% uv run kdev -v … # the working tree, with API logging ``` -Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets scan -(`detect-secrets`, private-key detection), a spell check (`typos`), config +Every commit runs formatting, lint, type-checking (`basedpyright`), a secrets +scan (`detect-secrets`, private-key detection), a spell check (`typos`), config validation, a workflow security audit (`zizmor`, `actionlint`) and a lockfile -check, and its message must be a Conventional Commit; every push runs the tests. CI runs the same hooks, the tests on Python -3.11–3.13, a build-and-install check, and `gitleaks` over the full history. +check, and its message must be a Conventional Commit; every push runs the tests. + +CI runs the same hooks, the tests on Python 3.11–3.13, the tests again on the +lowest version of each dependency that `pyproject.toml` allows (if they fail, +raise that floor), a build-and-install check, and `gitleaks` over the full +history. The single job `CI passed` is green only when all of those are. Pull +requests also get a review of the dependencies they add. ## Trying a change against real Kaggle From 15b49267bde3a1d1e038bfa6278111d6c7586b5c Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:19:05 +0530 Subject: [PATCH 07/10] docs: add AGENTS.md for coding agents What the project is, the commands that set up, test, lint and type-check it (each one run on this tree), where things live, the conventions CONTRIBUTING.md asks for, and the hard rules for an agent: no secrets, offline tests, no hand-edited generated files, no commit trailers unless asked, no issues, pull requests or comments on its own, and run the checks before saying it is done. CLAUDE.md only imports it, so there is one copy to keep current. --- AGENTS.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 1 + 2 files changed, 87 insertions(+) create mode 100644 AGENTS.md create mode 100644 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..218d971 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,86 @@ +# AGENTS.md + +Instructions for AI coding agents working in this repository. Humans: see +[CONTRIBUTING.md](CONTRIBUTING.md), which this file summarises. + +## What kdev is + +kdev is a Python CLI (`kdev-cli` on PyPI) that turns a Kaggle notebook session +into a remote dev box: SSH and VS Code in over a Cloudflare tunnel, with the +working directory restored from the notebook's saved versions on every start. +The project site is in `website/` (Astro, Cloudflare Pages). + +## Setup and checks + +Needs Python 3.11+ and [uv](https://docs.astral.sh/uv/). + +```bash +uv sync # create .venv with the dev tools +uv run pre-commit install # commit, commit-msg and push hooks +uv run pytest # the test suite; offline +uv run pytest --cov=kdev # with coverage; fails under 71% +uv run ruff check . # lint +uv run ruff format --check . # formatting (drop --check to fix) +uv run basedpyright # type check, basic mode +uv run pre-commit run --all-files # every hook, as CI runs them +uv run kdev -v ... # run the working tree, with API logging +``` + +Website, from `website/`: `npm ci`, `npm run check` (types), `npm run build`, +`npm run check:links` (run it after the build). + +## Layout + +- `src/kdev/cli.py`: entry point and error handling. `commands/`: one module + per command group; they parse arguments, call logic and render with `ui`. +- `session.py`, `persistence.py`, `quota.py`, `notebook.py`, `bootstrap.py`: + the behaviour, testable without a terminal. `tunnel.py`, `cloudflared.py`, + `sshcfg.py`: the tunnel and SSH config. `api.py`, `auth.py`, `config.py`: + Kaggle access, accounts, settings. +- `src/kdev/kdev_box.py` runs inside the Kaggle container: standard library + only, never import from the rest of the package. +- `src/kdev/ui.py`: every visual element. `errors.KdevError`: every failure a + user can act on, with the command that fixes it. +- `tests/`: one file per module. `tests/test_cli.py` runs commands through the + real entry point against a fake Kaggle. `tests/conftest.py` fakes the home + directory and blocks the network. +- `docs/ARCHITECTURE.md`: how it works, read it before changing the box, the + tunnel or the restore. `website/src/content/docs/`: the user docs. + +## Conventions + +- Commits and pull request titles are Conventional Commits: `type: subject` or + `type(scope): subject`; types `feat fix docs test ci build chore refactor perf + style revert`; lowercase subject, no final period, the why in the body. A + `commit-msg` hook checks it. +- Anything users will notice goes under `## [Unreleased]` in `CHANGELOG.md`. + Update the README, `website/src/content/docs/` and `docs/ARCHITECTURE.md` + when a command or how things work changes. +- A bug fix comes with a test that fails without the fix. Take expected values + from an independent source, not from the code under test. +- Match the surrounding code: no new comments or long docstrings it does not + already have. Everything the user sees goes through `ui.py`. +- Every GitHub Action is pinned to a full commit SHA with the version in a + comment (`@ # v1.2.3`); new pre-commit hooks are pinned the same way. + Every workflow sets least-privilege `permissions:`. +- Contributors sign the [CLA](CLA.md) on their first pull request; the bot asks. +- Lower bounds in `pyproject.toml` must be true: CI runs the tests against the + lowest versions allowed (`uv run --isolated --resolution lowest-direct pytest`). + +## Rules for agents + +- Never commit or print secrets: Kaggle tokens, tunnel credentials, deploy + keys, `~/.kaggle`, `~/.config/kdev`. Tests use a throwaway home. +- Tests stay offline. Use the fake Kaggle in `tests/test_cli.py`; do not add a + test that needs a Kaggle account, a network or a real `cloudflared`. +- Do not hand-edit generated files: `uv.lock` (use `uv lock`), + `website/package-lock.json` (use npm), `.secrets.baseline`, `website/dist/`. +- Do not add `Co-Authored-By` or "Generated with" trailers to commits unless + the human asks. +- Do not open issues or pull requests, post comments, push, or change GitHub + settings unless the human asks. Do not force push. +- Keep changes small and on topic: one change per pull request, no drive-by + reformatting. +- Run `uv run pytest` and `uv run pre-commit run --all-files` before saying a + change is done, and say what you did not run. +- Disclose AI assistance in the pull request, as the template asks. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md From d443395478aeda00196df335e6553a2adee5976c Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:19:07 +0530 Subject: [PATCH 08/10] docs: add an AI-assisted contributions policy AI tools are welcome when a person directs the work, reviews every line, runs the tests and can explain every change. Fully agentic pull requests are not accepted. Agents do not open issues or pull requests, comment or mention maintainers on their own; descriptions and review replies come from the author; tests take their expected values from an independent source; AI use is disclosed; and only code the author may license under the MIT license and the CLA is submitted. The pull request template gains one checkbox and a line for the tools used. The website's contributing page carries the same section. --- .github/pull_request_template.md | 3 +++ CONTRIBUTING.md | 28 ++++++++++++++++++++++++ website/src/content/docs/contributing.md | 28 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b7911ba..749f8a3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -13,3 +13,6 @@ - [ ] `uv run pytest` and `uv run pre-commit run --all-files` pass locally - [ ] What users will notice is under `## [Unreleased]` in `CHANGELOG.md` - [ ] The README is updated if a command or its behaviour changed +- [ ] Any AI-generated code has been reviewed line by line by me, and I can explain it + +AI tools used (if any): diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ffd5963..1e2cda8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,6 +107,34 @@ on-box restore against a temporary directory. the [README](README.md), the [website docs](website/src/content/docs/) and, for how things work inside, [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). +## AI-assisted contributions + +AI tools are welcome here, as long as a person is behind the pull request. +Agent-assisted work is fine when you direct it, review every line, run the +tests and can explain every change. [AGENTS.md](AGENTS.md) tells agents how the +repository works. + +- **Fully agentic pull requests are not accepted.** If an agent wrote the code, + the tests and the description and no person reviewed them, we may close the + pull request without a detailed review. +- **Agents act through you.** An agent must not open an issue or a pull + request, post a comment or mention a maintainer on its own. You do that, and + you have read what you post. +- **Write in your own words.** The description of a pull request, an issue and + your replies in review should show what you understand. Answer reviewers' + questions yourself. +- **Say what you used.** The pull request template asks which AI tools you + used and for which parts: code, tests, description, something else. +- **Tests do not come from the code under test.** A bug fix needs a test that + fails without the fix. Take the expected values from somewhere independent + (Kaggle's documentation, behaviour you saw on a real box, the spec of the + tool), not from whatever the code returns today. +- **Match the code around you.** Leave out comments and long docstrings the + surrounding code does not have, and abstractions nobody asked for. +- **Submit only what you may license.** A model can reproduce code from other + projects. Send only what you are allowed to license under the + [MIT license](LICENSE) and the [Contributor License Agreement](CLA.md). + ## Automated review [CodeRabbit](https://coderabbit.ai) reviews every pull request: it posts a diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index 062d054..6cb631d 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -104,6 +104,34 @@ on-box restore against a temporary directory. [CHANGELOG.md](https://github.com/tushar-mahalya/kdev/blob/main/CHANGELOG.md), and update the README if a command or its behaviour changes. +## AI-assisted contributions + +AI tools are welcome here, as long as a person is behind the pull request. +Agent-assisted work is fine when you direct it, review every line, run the +tests and can explain every change. [AGENTS.md](https://github.com/tushar-mahalya/kdev/blob/main/AGENTS.md) tells agents how the +repository works. + +- **Fully agentic pull requests are not accepted.** If an agent wrote the code, + the tests and the description and no person reviewed them, we may close the + pull request without a detailed review. +- **Agents act through you.** An agent must not open an issue or a pull + request, post a comment or mention a maintainer on its own. You do that, and + you have read what you post. +- **Write in your own words.** The description of a pull request, an issue and + your replies in review should show what you understand. Answer reviewers' + questions yourself. +- **Say what you used.** The pull request template asks which AI tools you + used and for which parts: code, tests, description, something else. +- **Tests do not come from the code under test.** A bug fix needs a test that + fails without the fix. Take the expected values from somewhere independent + (Kaggle's documentation, behaviour you saw on a real box, the spec of the + tool), not from whatever the code returns today. +- **Match the code around you.** Leave out comments and long docstrings the + surrounding code does not have, and abstractions nobody asked for. +- **Submit only what you may license.** A model can reproduce code from other + projects. Send only what you are allowed to license under the + [MIT license](https://github.com/tushar-mahalya/kdev/blob/main/LICENSE) and the [Contributor License Agreement](https://github.com/tushar-mahalya/kdev/blob/main/CLA.md). + ## Automated review [CodeRabbit](https://coderabbit.ai) reviews every pull request: it posts a From 45df4fee1855cc7142276cd5d1c11b0d14a04eb3 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:19:38 +0530 Subject: [PATCH 09/10] ci: keep the repository rulesets as code .github/rulesets holds the main and release-tag rulesets as they are set today, so a change to branch protection is reviewed in a pull request: - main.json: pull request with one code-owner approval, resolved threads, squash only, linear history, up to date, and the checks "CI passed" and "license/cla". The live ruleset lists each test job by name, which breaks whenever the matrix changes; "CI passed" is the one job that needs them all. - main-integrity.json: no force push and no deletion of main, with no bypass. These two rules moved out of main.json, which the maintainer can bypass. - release-tags.json: v* tags cannot be created, moved or deleted, except by the maintainer. Unchanged. CONTRIBUTING.md explains what they enforce and how a maintainer applies them. Nothing is applied by this commit. --- .github/rulesets/main-integrity.json | 13 ++++++++ .github/rulesets/main.json | 38 ++++++++++++++++++++++++ .github/rulesets/release-tags.json | 16 ++++++++++ CONTRIBUTING.md | 30 +++++++++++++++++++ website/src/content/docs/contributing.md | 30 +++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 .github/rulesets/main-integrity.json create mode 100644 .github/rulesets/main.json create mode 100644 .github/rulesets/release-tags.json diff --git a/.github/rulesets/main-integrity.json b/.github/rulesets/main-integrity.json new file mode 100644 index 0000000..1c3fc5d --- /dev/null +++ b/.github/rulesets/main-integrity.json @@ -0,0 +1,13 @@ +{ + "name": "main-integrity", + "target": "branch", + "enforcement": "active", + "conditions": { + "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } + }, + "bypass_actors": [], + "rules": [ + { "type": "deletion" }, + { "type": "non_fast_forward" } + ] +} diff --git a/.github/rulesets/main.json b/.github/rulesets/main.json new file mode 100644 index 0000000..7a2251e --- /dev/null +++ b/.github/rulesets/main.json @@ -0,0 +1,38 @@ +{ + "name": "main", + "target": "branch", + "enforcement": "active", + "conditions": { + "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } + }, + "bypass_actors": [ + { "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "pull_request" }, + { "actor_id": 78840863, "actor_type": "User", "bypass_mode": "always" } + ], + "rules": [ + { "type": "required_linear_history" }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": true, + "require_code_owner_review": true, + "require_last_push_approval": true, + "required_review_thread_resolution": true, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["squash"] + } + }, + { + "type": "required_status_checks", + "parameters": { + "strict_required_status_checks_policy": true, + "do_not_enforce_on_create": false, + "required_status_checks": [ + { "context": "CI passed", "integration_id": 15368 }, + { "context": "license/cla", "integration_id": 128106 } + ] + } + } + ] +} diff --git a/.github/rulesets/release-tags.json b/.github/rulesets/release-tags.json new file mode 100644 index 0000000..9c08e2e --- /dev/null +++ b/.github/rulesets/release-tags.json @@ -0,0 +1,16 @@ +{ + "name": "release tags", + "target": "tag", + "enforcement": "active", + "conditions": { + "ref_name": { "include": ["refs/tags/v*"], "exclude": [] } + }, + "bypass_actors": [ + { "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "always" } + ], + "rules": [ + { "type": "creation" }, + { "type": "update" }, + { "type": "deletion" } + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e2cda8..7ec9328 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -166,6 +166,36 @@ and so on, in [`.github/labeler.yml`](.github/labeler.yml)) and from its branch prefix (`feat/`, `fix/`, `docs/`). The labels also sort the notes GitHub generates for a release ([`.github/release.yml`](.github/release.yml)). +## Repository rulesets + +Branch and tag protection is written down in [`.github/rulesets`](.github/rulesets), +so a change to it is reviewed like any other: + +- `main.json`: a change reaches `main` only through a pull request that + passes `CI passed` and `license/cla` (the CLA Assistant check), has one + approval from a code owner, has every review thread resolved, and is + squash-merged, so history stays linear. The branch must be up to date with + `main` before it merges. The maintainer can bypass this, for a release or an + urgent fix; CI still runs on what is pushed. +- `main-integrity.json`: nobody, the maintainer included, can force-push to + or delete `main`. It has no bypass. +- `release-tags.json`: `v*` tags cannot be created, moved or deleted, except + by the maintainer. + +`CI passed` is the last job in `ci.yml`; it needs every other job there. Pull +requests also run `PR title`, `Dependency review` and the labeler, which are +not required checks. + +The files are not applied by themselves. A maintainer applies a changed one +with the GitHub CLI, `POST` for a ruleset that does not exist yet and `PUT` +with its ID to update one (`gh api repos/tushar-mahalya/kdev/rulesets` lists +the IDs): + +```bash +gh api repos/tushar-mahalya/kdev/rulesets --method POST --input .github/rulesets/main-integrity.json +gh api repos/tushar-mahalya/kdev/rulesets/ --method PUT --input .github/rulesets/main.json +``` + ## Releasing For maintainers: bump `version` in `pyproject.toml`, move the `Unreleased` diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index 6cb631d..303c604 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -163,6 +163,36 @@ and so on, in [`.github/labeler.yml`](https://github.com/tushar-mahalya/kdev/blo prefix (`feat/`, `fix/`, `docs/`). The labels also sort the notes GitHub generates for a release ([`.github/release.yml`](https://github.com/tushar-mahalya/kdev/blob/main/.github/release.yml)). +## Repository rulesets + +Branch and tag protection is written down in [`.github/rulesets`](https://github.com/tushar-mahalya/kdev/tree/main/.github/rulesets), +so a change to it is reviewed like any other: + +- `main.json`: a change reaches `main` only through a pull request that + passes `CI passed` and `license/cla` (the CLA Assistant check), has one + approval from a code owner, has every review thread resolved, and is + squash-merged, so history stays linear. The branch must be up to date with + `main` before it merges. The maintainer can bypass this, for a release or an + urgent fix; CI still runs on what is pushed. +- `main-integrity.json`: nobody, the maintainer included, can force-push to + or delete `main`. It has no bypass. +- `release-tags.json`: `v*` tags cannot be created, moved or deleted, except + by the maintainer. + +`CI passed` is the last job in `ci.yml`; it needs every other job there. Pull +requests also run `PR title`, `Dependency review` and the labeler, which are +not required checks. + +The files are not applied by themselves. A maintainer applies a changed one +with the GitHub CLI, `POST` for a ruleset that does not exist yet and `PUT` +with its ID to update one (`gh api repos/tushar-mahalya/kdev/rulesets` lists +the IDs): + +```bash +gh api repos/tushar-mahalya/kdev/rulesets --method POST --input .github/rulesets/main-integrity.json +gh api repos/tushar-mahalya/kdev/rulesets/ --method PUT --input .github/rulesets/main.json +``` + ## Releasing For maintainers: bump `version` in `pyproject.toml`, move the `Unreleased` From 9758ec686349b0f00603c2145207d5c5c59dfe10 Mon Sep 17 00:00:00 2001 From: tushar-mahalya Date: Thu, 26 Nov 2026 02:20:10 +0530 Subject: [PATCH 10/10] docs: add GOVERNANCE.md, SUPPORT.md and a documentation issue form - GOVERNANCE.md: the one maintainer, how decisions are made, how someone becomes a maintainer, and how the repository is protected (pointing to the rulesets in CONTRIBUTING.md). - SUPPORT.md: where to ask, report a bug or a documentation problem, what to try first (`kdev doctor`), and what to expect from one maintainer. - A "Documentation problem" issue form, next to the bug and feature ones. CONTRIBUTING.md and its page on the website link to the first two. --- .github/ISSUE_TEMPLATE/documentation.yml | 40 ++++++++++++++++++++++++ CONTRIBUTING.md | 3 ++ GOVERNANCE.md | 38 ++++++++++++++++++++++ SUPPORT.md | 23 ++++++++++++++ website/src/content/docs/contributing.md | 3 ++ 5 files changed, 107 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/documentation.yml create mode 100644 GOVERNANCE.md create mode 100644 SUPPORT.md diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000..a012ecc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,40 @@ +name: Documentation problem +description: Missing, unclear or incorrect documentation, or a command's help text. +title: "docs: " +labels: [documentation] +body: + - type: markdown + attributes: + value: | + For a question about using kdev, ask in [Q&A](https://github.com/tushar-mahalya/kdev/discussions/categories/q-a) instead. + - type: input + id: location + attributes: + label: Where + description: The URL or path of the page or section, or the command whose `--help` is wrong. + placeholder: "https://kdev-cli.pages.dev/docs/troubleshooting/ or kdev forward --help" + validations: + required: true + - type: dropdown + id: kind + attributes: + label: What kind of problem + options: + - Incorrect or out of date + - Missing + - Unclear or hard to follow + - Broken link or anchor + - Other + validations: + required: true + - type: textarea + id: problem + attributes: + label: What is wrong or missing + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: What it should say + description: Optional. Proposed wording. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7ec9328..1d97190 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,6 +11,9 @@ Before you change the box, the tunnel or the restore, read By taking part you agree to the [Code of Conduct](CODE_OF_CONDUCT.md). +How decisions are made is in [GOVERNANCE.md](GOVERNANCE.md); where to get help is +in [SUPPORT.md](SUPPORT.md). + ## Ways to help - **Ask a question** in [Discussions](https://github.com/tushar-mahalya/kdev/discussions): diff --git a/GOVERNANCE.md b/GOVERNANCE.md new file mode 100644 index 0000000..5d39d37 --- /dev/null +++ b/GOVERNANCE.md @@ -0,0 +1,38 @@ +# Governance + +kdev has one maintainer. This page says what that means for decisions. + +## Roles + +| Role | Who | Responsibilities | +| --- | --- | --- | +| Maintainer | [@tushar-mahalya](https://github.com/tushar-mahalya) | Sets direction, reviews and merges pull requests, publishes releases, enforces the [Code of Conduct](CODE_OF_CONDUCT.md). | +| Contributor | Anyone | Opens issues, discussions and pull requests under [CONTRIBUTING.md](CONTRIBUTING.md). | + +The maintainer listed in [CODEOWNERS](.github/CODEOWNERS) reviews every change to `main`. + +## Decisions + +- Small changes are decided in the pull request. +- A change to a command's behaviour, to what kdev saves or restores, to the + workflows or to how kdev is distributed needs an issue first, so the idea is + agreed before the code is written. +- The maintainer makes the final decision when there is no consensus, and + says why in the issue or pull request. +- Contributors do not need to sign anything beyond the + [Contributor License Agreement](CLA.md). + +## Becoming a maintainer + +Contributors with a sustained record of good reviews and pull requests may be +invited. A new maintainer is added to CODEOWNERS and to this page in a pull +request. + +## Repository protection + +`main` and the release tags are protected by repository rulesets. Their +definitions are versioned in [.github/rulesets](.github/rulesets). Contributors +change `main` through reviewed pull requests. The maintainer may push to `main` +directly, for a release or an urgent fix. Nobody can force-push to or delete +`main`. [CONTRIBUTING.md](CONTRIBUTING.md#repository-rulesets) has the details +and how a maintainer applies them. diff --git a/SUPPORT.md b/SUPPORT.md new file mode 100644 index 0000000..fa0ac1b --- /dev/null +++ b/SUPPORT.md @@ -0,0 +1,23 @@ +# Support + +## Get help + +- **Questions and ideas:** use [GitHub Discussions](https://github.com/tushar-mahalya/kdev/discussions). + Choose *Q&A* for how to do something or whether what you see is expected. +- **Bugs:** open a [bug report](https://github.com/tushar-mahalya/kdev/issues/new?template=bug_report.yml). + Include the output of the same command with `-v`, the kdev version and your + operating system. +- **Documentation problems:** open a [documentation issue](https://github.com/tushar-mahalya/kdev/issues/new?template=documentation.yml). +- **Security issues:** do not use a public issue. Follow [SECURITY.md](SECURITY.md). + +## Before you ask + +1. Read the [README](README.md) and the [troubleshooting page](https://kdev-cli.pages.dev/docs/troubleshooting/). +2. Run `kdev doctor`. It checks every dependency, each account's token, the + workspace and the tunnel's DNS. +3. Search existing issues and discussions. + +## Expectations + +kdev is maintained by one person in their own time. There is no guaranteed +response time. Only the latest release receives fixes. diff --git a/website/src/content/docs/contributing.md b/website/src/content/docs/contributing.md index 303c604..6ae9647 100644 --- a/website/src/content/docs/contributing.md +++ b/website/src/content/docs/contributing.md @@ -10,6 +10,9 @@ is small and opinionated, so for anything bigger than a fix, open an issue first and say what you want to change and why. It saves you writing code that goes a different way than the project. +How decisions are made is in [GOVERNANCE.md](https://github.com/tushar-mahalya/kdev/blob/main/GOVERNANCE.md); where to get help is +in [SUPPORT.md](https://github.com/tushar-mahalya/kdev/blob/main/SUPPORT.md). + ## Ways to help - **Ask a question** in [Discussions](https://github.com/tushar-mahalya/kdev/discussions):