{"_id":"@ar-llm/pi-custom-compaction","_rev":"4-81d4915469dbcd02a4dde7ce20ced683","name":"@ar-llm/pi-custom-compaction","dist-tags":{"latest":"0.5.0"},"versions":{"0.1.0":{"name":"@ar-llm/pi-custom-compaction","version":"0.1.0","keywords":["pi-package","pi-extension","pi","compaction","summarization"],"license":"Unlicense","_id":"@ar-llm/pi-custom-compaction@0.1.0","maintainers":[{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}],"homepage":"https://github.com/arichiardi/ar-llm/tree/main/extensions/pi-custom-compaction#readme","bugs":{"url":"https://github.com/arichiardi/ar-llm/issues"},"pi":{"extensions":["./src/custom-compaction.ts"]},"dist":{"shasum":"268ef628b1e0df832c32f7baa3a3d201a79f8f50","tarball":"https://registry.npmjs.org/@ar-llm/pi-custom-compaction/-/pi-custom-compaction-0.1.0.tgz","fileCount":5,"integrity":"sha512-/CKfw3cVhBpCiMxNsvoCJSwe6vPg8qzrJFDcizBhCMVwIACvqn694WmdN7CfTajTfZjLANb7aX7ce0ax97QDAA==","signatures":[{"sig":"MEQCID+itfj1qDHlrwTJT8iP6rH4+TpOzTY1EfqVj0P4hkZ9AiA4A6zbbD6W/83yNNqS1RVnzkFIe9NKzrXIoUwQvfL6IA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14199},"type":"module","gitHead":"cb56566469fbc3afe89f4b3fbbcc5ff829fa2914","private":false,"scripts":{"typecheck":"tsc --noEmit"},"_npmUser":{"name":"arichiardi","email":"a.richiardi.work@gmail.com"},"repository":{"url":"git+https://github.com/arichiardi/ar-llm.git","type":"git","directory":"extensions/pi-custom-compaction"},"_npmVersion":"11.12.1","description":"Pi extension that replaces default compaction with a full LLM-generated summary, with configurable model and per-provider request params.","directories":{},"_nodeVersion":"25.9.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@types/node":"^25.6.0","@earendil-works/pi-coding-agent":"0.79.10"},"peerDependencies":{"@earendil-works/pi-ai":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-custom-compaction_0.1.0_1782768388029_0.013003948273324184","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@ar-llm/pi-custom-compaction","version":"0.4.0","keywords":["pi-package","pi-extension","pi","compaction","summarization"],"license":"Unlicense","_id":"@ar-llm/pi-custom-compaction@0.4.0","maintainers":[{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}],"homepage":"https://github.com/arichiardi/ar-llm/tree/main/extensions/pi-custom-compaction#readme","bugs":{"url":"https://github.com/arichiardi/ar-llm/issues"},"pi":{"extensions":["./src/custom-compaction.ts"]},"dist":{"shasum":"5662957c5a4fd81d6f2610ea1318cc494383eef3","tarball":"https://registry.npmjs.org/@ar-llm/pi-custom-compaction/-/pi-custom-compaction-0.4.0.tgz","fileCount":5,"integrity":"sha512-Ak3KLBio4J8W1p6ZBD2MOxo2dXpTc2Xda5gsCRtjqPZzpi/MVL5bqUfU8nfKIZjmRlwOsK7HA39ydfusnaFZxA==","signatures":[{"sig":"MEQCIF3Y63wl/Sdr7z5/RQBxypb0EpjOKRdn7Wa1vIFHksh6AiAWRb1+3XYtsNbHA+WvATXrJy/Ykkk4EgwvZAxhX8SPmA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22157},"type":"module","gitHead":"86d983db6aa9be86b050fe3d0cd03c96c088b3e1","private":false,"scripts":{"typecheck":"tsc --noEmit"},"_npmUser":{"name":"arichiardi","email":"a.richiardi.work@gmail.com"},"repository":{"url":"git+https://github.com/arichiardi/ar-llm.git","type":"git","directory":"extensions/pi-custom-compaction"},"_npmVersion":"11.17.0","description":"Pi extension that replaces default compaction with a full LLM-generated summary. Supports provider-aware configuration so different session providers can use different compaction models, request params, and prompts.","directories":{},"_nodeVersion":"26.5.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@types/node":"^25.6.0","@earendil-works/pi-coding-agent":"0.79.10"},"peerDependencies":{"@earendil-works/pi-ai":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-custom-compaction_0.4.0_1785944570280_0.4978004904703004","host":"s3://npm-registry-packages-npm-production"}},"0.4.1":{"name":"@ar-llm/pi-custom-compaction","version":"0.4.1","keywords":["pi-package","pi-extension","pi","compaction","summarization"],"license":"Unlicense","_id":"@ar-llm/pi-custom-compaction@0.4.1","maintainers":[{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}],"homepage":"https://github.com/arichiardi/ar-llm/tree/main/extensions/pi-custom-compaction#readme","bugs":{"url":"https://github.com/arichiardi/ar-llm/issues"},"pi":{"extensions":["./src/custom-compaction.ts"]},"dist":{"shasum":"34a170bbeb0c1b7120538907a5cf629058e41e34","tarball":"https://registry.npmjs.org/@ar-llm/pi-custom-compaction/-/pi-custom-compaction-0.4.1.tgz","fileCount":5,"integrity":"sha512-AYM4ZeZrq+SOOsyeEc6mADXuj8kcgsCXUBBkHtfAP/XmSJCWxL9D73DUvDdOLEDnfXogcB4IKkmByHg2hsi6Dw==","signatures":[{"sig":"MEUCIQCcNNanKqPrLbXNfZgpOiBdX0PsE6eh29AUQDNNdmTRCQIgJviJyA/KT8quy+110m70OgycdEBB7LzFdZX7e8AxJhs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22157},"type":"module","gitHead":"391f9fb39b54b56a6ef0b83616c287c7aeddbd5f","private":false,"scripts":{"typecheck":"tsc --noEmit"},"_npmUser":{"name":"arichiardi","email":"a.richiardi.work@gmail.com"},"repository":{"url":"git+https://github.com/arichiardi/ar-llm.git","type":"git","directory":"extensions/pi-custom-compaction"},"_npmVersion":"11.17.0","description":"Pi extension that replaces default compaction with a full LLM-generated summary. Supports provider-aware configuration so different session providers can use different compaction models, request params, and prompts.","directories":{},"_nodeVersion":"26.5.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@types/node":"^25.6.0","@earendil-works/pi-coding-agent":"0.79.10"},"peerDependencies":{"@earendil-works/pi-ai":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-custom-compaction_0.4.1_1785945777144_0.577012797725382","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"pi":{"extensions":["./src/custom-compaction.ts"]},"_id":"@ar-llm/pi-custom-compaction@0.5.0","bugs":{"url":"https://github.com/arichiardi/ar-llm/issues"},"dist":{"shasum":"70143cacedd1dffd8ce16aa2f6ee649a2505061d","tarball":"https://registry.npmjs.org/@ar-llm/pi-custom-compaction/-/pi-custom-compaction-0.5.0.tgz","integrity":"sha512-rG5J7ulfSo5Uh6UgcqIhB9uJT0yKj393vcVmXWPGJ4OKd2Du0OZTkdC9aYP7FYlKgtChKMzEdG+b3S8uBqNcCw==","fileCount":8,"unpackedSize":34507,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCNtTOduaFcsmn4fctlk/dhYwhVFtHrM/8KoLtW4f5FkgIgD44xRIsPvjQAwvBkB9ISbPpMQrjhbZvvobIPS4C30zo="}]},"name":"@ar-llm/pi-custom-compaction","type":"module","gitHead":"abdcc66df785195d7197b28b7d86dad195a351ce","license":"Unlicense","private":false,"scripts":{"test":"node --import ./test/register.mjs --test test/config.test.ts","typecheck":"tsc --noEmit"},"version":"0.5.0","_npmUser":{"name":"arichiardi","email":"a.richiardi.work@gmail.com","approver":{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}},"homepage":"https://github.com/arichiardi/ar-llm/tree/main/extensions/pi-custom-compaction#readme","keywords":["pi-package","pi-extension","pi","compaction","summarization"],"repository":{"url":"git+https://github.com/arichiardi/ar-llm.git","type":"git","directory":"extensions/pi-custom-compaction"},"_npmVersion":"12.0.2","description":"Pi extension that replaces default compaction with a full LLM-generated summary. Supports provider-aware configuration so different session providers can use different compaction models, request params, and prompts.","directories":{},"maintainers":[{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}],"_nodeVersion":"26.5.0","devDependencies":{"typescript":"^6.0.3","@types/node":"^25.6.0","@earendil-works/pi-coding-agent":"0.79.10"},"peerDependencies":{"@earendil-works/pi-ai":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-custom-compaction_0.5.0_1789077785442_0.7230677287290677"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-29T21:26:27.891Z","modified":"2026-09-10T22:03:05.701Z","0.1.0":"2026-06-29T21:26:28.156Z","0.4.0":"2026-08-05T15:42:50.415Z","0.4.1":"2026-08-05T16:02:57.332Z","0.5.0":"2026-09-10T22:03:05.527Z"},"bugs":{"url":"https://github.com/arichiardi/ar-llm/issues"},"license":"Unlicense","homepage":"https://github.com/arichiardi/ar-llm/tree/main/extensions/pi-custom-compaction#readme","keywords":["pi-package","pi-extension","pi","compaction","summarization"],"repository":{"url":"git+https://github.com/arichiardi/ar-llm.git","type":"git","directory":"extensions/pi-custom-compaction"},"description":"Pi extension that replaces default compaction with a full LLM-generated summary. Supports provider-aware configuration so different session providers can use different compaction models, request params, and prompts.","maintainers":[{"name":"arichiardi","email":"a.richiardi.work@gmail.com"}],"readme":"# @ar-llm/pi-custom-compaction\n\n[![npm](https://img.shields.io/npm/v/@ar-llm/pi-custom-compaction)](https://www.npmjs.com/package/@ar-llm/pi-custom-compaction) [![Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](./LICENSE)\n\nPi extension that replaces default compaction with a full LLM-generated summary. Supports **provider-aware configuration** so different session providers can use different compaction models, request params, and prompts.\n\nUses `ctx.modelRegistry.runtime.complete()` (the coding-agent's internal ModelRuntime) instead of the deprecated `@earendil-works/pi-ai/compat` `complete()`, so that custom providers (e.g. github-copilot) are properly routed and auth is resolved internally.\n\n## Install\n\n```bash\npi install 'npm:@ar-llm/pi-custom-compaction'\n```\n\nOr try without installing:\n\n```bash\npi -e 'npm:@ar-llm/pi-custom-compaction'\n```\n\n## How It Works\n\nInstead of keeping the last 20k tokens of conversation turns, this extension:\n1. Summarizes **ALL** messages (`messagesToSummarize` + `turnPrefixMessages`)\n2. Discards all old turns completely, keeping only the LLM-generated summary\n\nThe compaction model is selected based on the **active session's provider**. Each provider can configure its own compaction model, request params, and prompts.\n\n## Debug Logging\n\nSet the `PI_CUSTOM_COMPACTION_DEBUG` environment variable to `1` or `true` to enable debug logging:\n\n```bash\nexport PI_CUSTOM_COMPACTION_DEBUG=1\n```\n\nDebug output is written to `$TMPDIR/ar-llm/custom-compaction.log`.\n\n## Configuration\n\nCreate the config file at `~/.config/pi/agent/ar-llm/custom-compaction.json`:\n\n```json\n{\n  \"default-prompts\": {\n    \"system\": \"You are a conversation summarizer. Create a comprehensive summary that captures all information needed to continue the work effectively.\",\n    \"user\": \"Summarize this conversation with clear sections covering:\\n\\n1. Main goals and objectives discussed\\n2. Key decisions made and their rationale\\n3. Important code changes, file modifications, or technical details\\n4. Current state of any ongoing work\\n5. Any blockers, issues, or open questions\\n6. Next steps that were planned or suggested\\n\\nBe thorough but concise. This summary will replace the ENTIRE conversation history.\\n\\nFormat as structured markdown with clear sections.{previous_summary}\\n<conversation>\\n{conversation}\\n</conversation>\",\n    \"includePreviousSummary\": true\n  },\n  \"providers\": {\n    \"openrouter\": {\n      \"model\": \"google/gemma-4-26b-a4b-it:free\"\n    },\n    \"github-copilot\": {\n      \"model\": \"claude-sonnet-4.6\"\n    },\n    \"alba-local\": {\n      \"model\": \"Qwen3.6-27B\",\n      \"stream-options\": {\n        \"maxTokens\": 32758,\n        \"temperature\": 0.6\n      },\n      \"request-params\": {\n        \"chat_template_kwargs\": {\n          \"enable_thinking\": false\n        }\n      }\n    },\n    \"anthropic\": {\n      \"model\": \"claude-sonnet-4.6\",\n      \"enabled\": false\n    }\n  }\n}\n```\n\n### Config Fields\n\n**`default-prompts`** (optional): Shared prompt template used by all providers unless overridden. If omitted, built-in defaults are used.\n\n**`providers`** (required): Map of session provider names to their compaction configuration.\n\n#### Provider Config\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `enabled` | `boolean` | Set to `false` to silently skip compaction for this provider. |\n| `model` | `string` | Model ID to use for compaction (looked up within the session's provider catalog). Required unless `enabled: false`. |\n| `stream-options` | `object` | pi `StreamOptions` fields. Merged over the built-in defaults. |\n| `request-params` | `object` | Raw provider request-body parameters. Forwarded as `StreamOptions.samplingParams`. |\n| `prompt` | `object` | Provider-specific prompt that overrides `default-prompts`. |\n\n#### stream-options vs request-params\n\npi separates two kinds of parameters. The config mirrors that split.\n\n**`stream-options`** holds pi's own `StreamOptions` fields. Use camelCase names.\npi renames the fields for each provider. For example, pi sends `maxTokens` as\n`max_tokens` or `max_completion_tokens`.\n\nBuilt-in defaults, overridable from `stream-options`:\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `maxTokens` | `8192` | Response ceiling for the summary. |\n| `temperature` | provider default | Sampling temperature. Also accepted in `request-params`. |\n| `cacheRetention` | `\"none\"` | Prompt cache retention. |\n| `thinkingEnabled` | `false` | Thinking blocks. Only some APIs read this field. |\n\n`signal` and `sessionId` are set by the extension. The config cannot change them.\n\n**`request-params`** holds raw provider request-body parameters: `top_p`,\n`top_k`, `min_p`, `repetition_penalty`, `chat_template_kwargs`, and similar.\nThe extension passes the object unchanged as `StreamOptions.samplingParams`.\npi merges these keys into the request body after the named fields, so they win.\n\n> Only OpenAI-compatible adapters read `samplingParams` (completions, responses,\n> Azure responses). Other APIs ignore them.\n\n`temperature` is a pi parameter, but the extension accepts it in\n`request-params` too. It copies the value into the pi parameters, so Anthropic\nand Google honour it as well. When both keys are set, `request-params` wins.\n\n> `maxTokens` is a pi parameter. It does not belong in `request-params`.\n\n### Behavior\n\n1. Loads `default-prompts` (or uses built-in defaults)\n2. Gets the active session's provider from `ctx.model.provider`\n3. Looks up `providers.<sessionProvider>` in config\n4. If `enabled: false` → skips compaction silently\n5. Uses provider's `model`, inheriting `default-prompts` unless overridden\n6. Merges `stream-options` over the built-in `StreamOptions` defaults and passes `request-params` as `samplingParams`\n7. If no config exists for the session provider → skips (no fallback)\n\n### Migrating from 0.4.x\n\nThe nested `request-params.providers.<name>` shape is no longer supported. Put\nthe parameters directly under `request-params`. The extension ignores the old\nwrapper and logs a message.\n\n`maxTokens` is a pi parameter. Put it in `stream-options`. The extension moves a\nlegacy `request-params.maxTokens` value into `stream-options` and logs a message.\n\nRename the top-level `defaultPrompt` to `default-prompts`. The old key is\nignored and the extension logs a message.\n\n## License\n\n[The Unlicense](./LICENSE) — public domain. Substantially rewritten from [earendil-works/pi](https://github.com/earendil-works/pi) (see [NOTICE](./NOTICE)).\n","readmeFilename":"README.md"}