Files
directory-content-scanner/flake.nix
Kevin Veen-Birkenbach 039481d3a9 This commit introduces a complete structural and architectural refactor of
Analysis-Ready Code (ARC). The project is now fully migrated to a modern
src/-based Python package layout, with proper packaging via pyproject.toml,
a clean Nix flake, and improved CLI entry points.

Major changes:

• Add `src/arc/` package with clean module structure:
  - arc/__init__.py now contains the main() dispatcher and clipboard helpers
  - arc/__main__.py provides a proper `python -m arc` entry point
  - arc/cli.py rewritten with full argparse-based interface
  - arc/code_processor.py modernized and relocated
  - arc/directory_handler.py rewritten with output_stream support
  - arc/tee.py added for multi-stream output (stdout + buffer)

• Remove legacy top-level modules:
  - cli.py
  - directory_handler.py
  - main.py

• Introduce fully PEP-517 compliant pyproject.toml with console script:
  - arc = arc.__main__:main

• Add Nix flake (`flake.nix`) providing:
  - buildPythonApplication package `arc`
  - `nix run .#arc` app
  - development shell with Python + xclip

• Add Makefile overhaul:
  - automatic detection of Nix vs Python installation
  - unified install/uninstall targets
  - Nix wrapper installation into ~/.local/bin
  - improved help text and shell safety

• Add GitHub CI pipelines:
  - ci-python.yml for Python builds + Makefile tests + arc --help
  - ci-nix.yml for Nix builds, flake checks, dev-shell tests, and `nix run .#arc`

• Refactor and extend unit tests:
  - test_arc.py updated for src/ imports
  - new tests: test_cli.py, test_main.py, test_tee.py
  - improved CodeProcessor and DirectoryHandler tests

• Add egg-info metadata for local builds

• Add build/lib/ tree for compatibility with setuptools (generated)

Overall, this commit modernizes ARC into a clean, robust, and fully packaged
Python/Nix hybrid tool, enabling reproducible builds, solid CLI behavior,
testable architecture, and CI automation.

https://chatgpt.com/share/693933a0-e280-800f-9cf0-26036d15be04
2025-12-10 09:47:19 +01:00

82 lines
2.3 KiB
Nix

{
description = "Analysis-Ready Code (ARC) - recursively scan directories and prepare code for automated analysis.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
python = pkgs.python3;
# Main ARC package built from pyproject.toml
arcPkg = pkgs.python3Packages.buildPythonApplication {
pname = "analysis-ready-code";
version = "0.1.0";
src = ./.;
# We are using pyproject.toml with a PEP 517 backend.
format = "pyproject";
nativeBuildInputs = with pkgs.python3Packages; [
setuptools
wheel
];
# xclip is not a Python lib, but we can still add it as a runtime
# dependency so that `xclip` is available in PATH when running ARC
# inside a Nix environment.
propagatedBuildInputs = with pkgs; [
xclip
];
meta = {
description = "Utility that scans directories and prepares code for AI/computer analysis by stripping comments, filtering files, and optionally compressing content.";
homepage = "https://github.com/kevinveenbirkenbach/analysis-ready-code";
license = pkgs.lib.licenses.agpl3Plus;
platforms = pkgs.lib.platforms.unix;
};
};
in {
# Default package for `nix build .` and `nix build .#arc`
packages.arc = arcPkg;
packages.default = arcPkg;
# App for `nix run .#arc`
apps.arc = {
type = "app";
program = "${arcPkg}/bin/arc";
};
# Default app for `nix run .`
apps.default = self.apps.${system}.arc;
# Dev shell for local development
devShells.default = pkgs.mkShell {
name = "arc-dev-shell";
buildInputs = with pkgs; [
python3
python3Packages.pip
python3Packages.setuptools
python3Packages.wheel
xclip
];
shellHook = ''
echo "ARC dev shell ready. Typical usage:"
echo " make test"
echo " arc . -x"
'';
};
}
);
}