Unverified Commit 24f4a11d authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

llm: re-add `withPlugins`, add many plugins, 0.25 -> 0.26 (#411459)

parents e0c2e8b0 837cff79
Loading
Loading
Loading
Loading
+2 −42
Original line number Diff line number Diff line
{
  lib,
  python3Packages,
  fetchFromGitHub,
  versionCheckHook,
}:
{ python3Packages }:

python3Packages.buildPythonApplication rec {
  pname = "files-to-prompt";
  version = "0.6";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "simonw";
    repo = "files-to-prompt";
    tag = version;
    hash = "sha256-LWp/DNP3bsh7/goQGkpi4x2N11tRuhLVh2J8H6AUH0w=";
  };

  build-system = with python3Packages; [
    setuptools
  ];

  dependencies = with python3Packages; [
    click
  ];

  nativeCheckInputs = with python3Packages; [
    pytestCheckHook
    versionCheckHook
  ];

  versionCheckProgramArg = "--version";

  meta = {
    description = "Concatenate a directory full of files into a single prompt for use with LLMs";
    homepage = "https://github.com/simonw/files-to-prompt/";
    changelog = "https://github.com/simonw/files-to-prompt/releases/tag/${src.tag}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ erethon ];
    mainProgram = "files-to-prompt";
  };
}
python3Packages.toPythonApplication python3Packages.files-to-prompt
+2 −40
Original line number Diff line number Diff line
{
  lib,
  python3Packages,
  fetchFromGitHub,
  bash,
  git,
  less,
}:
{ python3Packages }:

python3Packages.buildPythonApplication rec {
  pname = "icdiff";
  version = "2.0.7";

  src = fetchFromGitHub {
    owner = "jeffkaufman";
    repo = "icdiff";
    tag = "release-${version}";
    hash = "sha256-XOw/xhPGlzi1hAgzQ1EtioUM476A+lQWLlvvaxd9j08=";
  };

  # error: could not lock config file /homeless-shelter/.gitconfig: No such file or directory
  doCheck = false;

  nativeCheckInputs = [
    bash
    git
    less
  ];

  checkPhase = ''
    patchShebangs test.sh
    ./test.sh ${python3Packages.python.interpreter}
  '';

  meta = {
    homepage = "https://www.jefftk.com/icdiff";
    description = "Side-by-side highlighted command line diffs";
    maintainers = [ ];
    license = lib.licenses.psfl;
  };
}
python3Packages.toPythonApplication python3Packages.icdiff
+46 −0
Original line number Diff line number Diff line
# The `...` allows this derivation to be overridden with `enable-<llm-plugin>`.
#
# Example:
#
# ```nix
# llm.override {
#    enable-llm-anthropic = true;
#    enable-llm-gemini = true;
#    enable-llm-cmd = true;
#    enable-llm-templates-github = true;
# }
# ```
#
# Whatever names are accepted by `llm.withPlugins` are accepted with an added `enable-` prefix as
# an override of this derivation. The user can also do `llm.withPlugins { llm-anthropic = true; }`.
{ lib, python3Packages, ... }@args:

let
  inherit (python3Packages) llm;

  hasEnablePrefix = lib.hasPrefix "enable-";
  addEnablePrefix = name: "enable-${name}";
  removeEnablePrefix = lib.removePrefix "enable-";

  # Filter to just the attributes which are named "enable-<plugin-name>"
  enableArgs = lib.filterAttrs (name: value: hasEnablePrefix name) args;
  pluginArgs = lib.mapAttrs' (
    name: value: lib.nameValuePair (removeEnablePrefix name) value
  ) enableArgs;

  # Provide some diagnostics for the plugin names
  pluginNames = lib.attrNames (lib.functionArgs llm.withPlugins);
  enableNames = lib.map addEnablePrefix pluginNames;
  unknownPluginNames = lib.removeAttrs pluginArgs pluginNames;
  unknownNames = lib.map addEnablePrefix (lib.attrNames unknownPluginNames);
  unknownNamesDiagnostic = ''
    Unknown plugins specified in override: ${lib.concatStringsSep ", " unknownNames}

    Valid overrides:
      - ${lib.concatStringsSep "\n  - " enableNames}
  '';
in

assert lib.assertMsg (lib.length unknownNames == 0) unknownNamesDiagnostic;

llm.withPlugins pluginArgs
+45 −0
Original line number Diff line number Diff line
{
  lib,
  click,
  setuptools,
  fetchFromGitHub,
  buildPythonPackage,
  pytestCheckHook,
  versionCheckHook,
}:

buildPythonPackage rec {
  pname = "files-to-prompt";
  version = "0.6";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "simonw";
    repo = "files-to-prompt";
    tag = version;
    hash = "sha256-LWp/DNP3bsh7/goQGkpi4x2N11tRuhLVh2J8H6AUH0w=";
  };

  build-system = [ setuptools ];

  dependencies = [ click ];

  nativeCheckInputs = [
    pytestCheckHook
    versionCheckHook
  ];

  versionCheckProgramArg = "--version";

  meta = {
    mainProgram = "files-to-prompt";
    description = "Concatenate a directory full of files into a single prompt for use with LLMs";
    homepage = "https://github.com/simonw/files-to-prompt";
    changelog = "https://github.com/simonw/files-to-prompt/releases/tag/${src.tag}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      erethon
      philiptaron
    ];
  };
}
+35 −0
Original line number Diff line number Diff line
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Philip Taron <philip.taron@gmail.com>
Date: Thu, 29 May 2025 14:47:58 -0700
Subject: [PATCH] Don't test black or flake8

Signed-off-by: Philip Taron <philip.taron@gmail.com>
---
 test.sh | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/test.sh b/test.sh
index 1dd6c4be579e8a61d2d284b042c54cd2a1e0ff77..dc9ecab4a9097878a0a65c45df38a4fa25eb9fa2 100755
--- a/test.sh
+++ b/test.sh
@@ -210,20 +210,6 @@ function ensure_installed() {
   fi
 }
 
-ensure_installed "black"
-echo 'Running black formatter...'
-if ! black icdiff --quiet --line-length 79 --check; then
-  echo ""
-  echo 'Consider running `black icdiff --line-length 79`'
-  fail
-fi
-
-ensure_installed "flake8"
-echo 'Running flake8 linter...'
-if ! flake8 icdiff; then
-  fail
-fi
-
 if ! $REGOLD; then
   echo PASS
 fi
Loading