Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ context-mode-guidance-*/
.claude-worktrees/
.vibetree/
.cw/
result
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "Description for the project";

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
perSystem =
{ system, ... }:
let
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
context-mode = pkgs.callPackage ./nix/package.nix { };
in
{
packages.default = context-mode;
packages.context-mode = context-mode;

apps.default = {
type = "app";
program = "${context-mode}/bin/context-mode";
};
};
};
}
79 changes: 79 additions & 0 deletions nix/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
lib,
stdenvNoCC,
makeWrapper,
nodejs_22,
python3,
bun,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "context-mode";
version = "1.0.89";

src = lib.cleanSource ../.;

nativeBuildInputs = [ makeWrapper ];

installPhase = ''
runHook preInstall

install -d "$out/lib/${finalAttrs.pname}" "$out/bin"

cp package.json "$out/lib/${finalAttrs.pname}/package.json"
cp README.md "$out/lib/${finalAttrs.pname}/README.md"
cp LICENSE "$out/lib/${finalAttrs.pname}/LICENSE"
cp start.mjs "$out/lib/${finalAttrs.pname}/start.mjs"
cp server.bundle.mjs "$out/lib/${finalAttrs.pname}/server.bundle.mjs"
cp cli.bundle.mjs "$out/lib/${finalAttrs.pname}/cli.bundle.mjs"

cp -r hooks "$out/lib/${finalAttrs.pname}/hooks"
cp -r configs "$out/lib/${finalAttrs.pname}/configs"
cp -r insight "$out/lib/${finalAttrs.pname}/insight"

if [ -d skills ]; then
cp -r skills "$out/lib/${finalAttrs.pname}/skills"
fi

if [ -d .claude-plugin ]; then
cp -r .claude-plugin "$out/lib/${finalAttrs.pname}/.claude-plugin"
fi

if [ -d .openclaw-plugin ]; then
cp -r .openclaw-plugin "$out/lib/${finalAttrs.pname}/.openclaw-plugin"
fi

if [ -d .pi ]; then
cp -r .pi "$out/lib/${finalAttrs.pname}/.pi"
fi

if [ -f .mcp.json ]; then
cp .mcp.json "$out/lib/${finalAttrs.pname}/.mcp.json"
fi

if [ -f openclaw.plugin.json ]; then
cp openclaw.plugin.json "$out/lib/${finalAttrs.pname}/openclaw.plugin.json"
fi

chmod +x "$out/lib/${finalAttrs.pname}/cli.bundle.mjs"
chmod +x "$out/lib/${finalAttrs.pname}/server.bundle.mjs"

makeWrapper ${lib.getExe nodejs_22} "$out/bin/context-mode" \
--add-flags "$out/lib/${finalAttrs.pname}/cli.bundle.mjs" \
--prefix PATH : ${
lib.makeBinPath [
python3
bun
]
}

runHook postInstall
'';

meta = {
description = "MCP plugin and CLI for reducing context-window usage";
homepage = "https://github.com/mksglu/context-mode";
license = lib.licenses.elastic20;
mainProgram = "context-mode";
platforms = lib.platforms.all;
};
})