@blanklogic/refinery-core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +53 -6
- package/assets/icon.png +0 -0
- package/package.json +8 -5
- package/src/index.js +12 -1
- package/src/inputLimits.js +24 -0
- package/src/refineryCompiler.js +3 -0
- package/src/refinerySanitizer.js +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.2] - 2026-05-18
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **512 KB** max input guard (`inputLimits.js`) for all refine/sanitize paths.
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Package description and README branding aligned with blanklogic.io.
|
|
10
|
+
|
|
11
|
+
## [0.1.1] - 2026-05-18
|
|
12
|
+
|
|
13
|
+
- Initial public release with shared compiler and sanitizer engines.
|
package/README.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @blanklogic/refinery-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/icon.png" width="96" height="96" alt="BlankLogic" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
**Shared local engine for BlankLogic Refinery — de-bloat, secret redaction, and full refine.**
|
|
8
|
+
|
|
9
|
+
This package powers the CLI, MCP server, proxy transforms, and extension backend. It is local-only: no network calls, no API keys, no BlankLogic server dependency.
|
|
10
|
+
|
|
11
|
+
## What's new in 0.1.2
|
|
12
|
+
|
|
13
|
+
- **512 KB** max input guard on all refine/sanitize entry points.
|
|
14
|
+
|
|
15
|
+
## Saved tokens or caught a secret?
|
|
16
|
+
|
|
17
|
+
If BlankLogic trimmed noise, redacted secrets, or cut token waste for you, a quick review helps others find it:
|
|
18
|
+
|
|
19
|
+
- **Cursor / Open VSX:** [Rate BlankLogic Refinery on Open VSX](https://open-vsx.org/extension/blanklogic/blanklogic-refinery-vscode)
|
|
20
|
+
- **VS Code:** [Leave a review on the Marketplace](https://marketplace.visualstudio.com/items?itemName=blanklogic.blanklogic-refinery-vscode&ssr=false#review-details)
|
|
21
|
+
- **Feedback:** [blanklogic.io/#bugs](https://blanklogic.io/#bugs)
|
|
22
|
+
|
|
23
|
+
## Install
|
|
4
24
|
|
|
5
25
|
```bash
|
|
6
26
|
npm install @blanklogic/refinery-core
|
|
@@ -14,8 +34,35 @@ import { refineFull, runCodeDebloater, runTokenSanitizer } from '@blanklogic/ref
|
|
|
14
34
|
const cleaned = refineFull(input)
|
|
15
35
|
```
|
|
16
36
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
| Function | Behavior |
|
|
38
|
+
|----------|----------|
|
|
39
|
+
| `runCodeDebloater(input)` | Remove tracker noise, comments, and boilerplate |
|
|
40
|
+
| `runTokenSanitizer(input)` | Redact obvious secrets; compact text |
|
|
41
|
+
| `refineFull(input)` | De-bloat, then sanitize |
|
|
42
|
+
|
|
43
|
+
## When to use this package
|
|
44
|
+
|
|
45
|
+
- Building integrations on top of Refinery
|
|
46
|
+
- Monorepo workspaces that need the engine without the CLI binary
|
|
47
|
+
- Advanced pipelines that call de-bloat and sanitize separately
|
|
48
|
+
|
|
49
|
+
Most users should start with [@blanklogic/refinery](https://www.npmjs.com/package/@blanklogic/refinery) (CLI) or the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=blanklogic.blanklogic-refinery-vscode).
|
|
50
|
+
|
|
51
|
+
## Related BlankLogic tools
|
|
52
|
+
|
|
53
|
+
| Product | Link |
|
|
54
|
+
|---------|------|
|
|
55
|
+
| **CLI** | [`@blanklogic/refinery`](https://www.npmjs.com/package/@blanklogic/refinery) |
|
|
56
|
+
| **MCP** | [`@blanklogic/refinery-mcp`](https://www.npmjs.com/package/@blanklogic/refinery-mcp) |
|
|
57
|
+
| **Proxy** | [`@blanklogic/proxy`](https://www.npmjs.com/package/@blanklogic/proxy) |
|
|
58
|
+
| **Homepage** | [blanklogic.io](https://blanklogic.io/) |
|
|
59
|
+
| **Refinery web app** | [blanklogic.io/refinery](https://blanklogic.io/refinery/) |
|
|
60
|
+
|
|
61
|
+
## Privacy
|
|
62
|
+
|
|
63
|
+
Local-only. No Stripe, BlankLogic servers, Ollama, or third-party APIs.
|
|
64
|
+
|
|
65
|
+
## Support
|
|
20
66
|
|
|
21
|
-
|
|
67
|
+
- Homepage: [blanklogic.io](https://blanklogic.io/)
|
|
68
|
+
- Bug reports: [blanklogic.io/#bugs](https://blanklogic.io/#bugs)
|
package/assets/icon.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blanklogic/refinery-core",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Clean context before AI sees it — shared BlankLogic Refinery engines (local, no upload).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"src"
|
|
11
|
+
"src",
|
|
12
|
+
"assets",
|
|
13
|
+
"README.md",
|
|
14
|
+
"CHANGELOG.md"
|
|
12
15
|
],
|
|
13
16
|
"publishConfig": {
|
|
14
17
|
"access": "public"
|
|
15
18
|
},
|
|
16
19
|
"license": "UNLICENSED",
|
|
17
|
-
"homepage": "https://blanklogic.io/
|
|
20
|
+
"homepage": "https://blanklogic.io/",
|
|
18
21
|
"bugs": {
|
|
19
|
-
"url": "https://blanklogic.io
|
|
22
|
+
"url": "https://blanklogic.io/#bugs"
|
|
20
23
|
},
|
|
21
24
|
"keywords": [
|
|
22
25
|
"blanklogic",
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { runCodeDebloater, roughTokenCount, byteSize, lineCount } from './refineryCompiler.js'
|
|
2
2
|
import { runTokenSanitizer } from './refinerySanitizer.js'
|
|
3
|
+
import { assertInputWithinLimit, MAX_REFINERY_INPUT_BYTES, inputByteSize } from './inputLimits.js'
|
|
3
4
|
|
|
4
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
runCodeDebloater,
|
|
7
|
+
roughTokenCount,
|
|
8
|
+
byteSize,
|
|
9
|
+
lineCount,
|
|
10
|
+
runTokenSanitizer,
|
|
11
|
+
assertInputWithinLimit,
|
|
12
|
+
MAX_REFINERY_INPUT_BYTES,
|
|
13
|
+
inputByteSize,
|
|
14
|
+
}
|
|
5
15
|
|
|
6
16
|
export function refineFull(inputValue) {
|
|
7
17
|
const input = String(inputValue ?? '')
|
|
18
|
+
assertInputWithinLimit(input)
|
|
8
19
|
const debloated = runCodeDebloater(input)
|
|
9
20
|
const sanitized = runTokenSanitizer(debloated.output)
|
|
10
21
|
const bytesIn = byteSize(input)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Shared max input size for Refinery engines (matches refinery-api MAX_INPUT_BYTES). */
|
|
2
|
+
export const MAX_REFINERY_INPUT_BYTES = 512 * 1024
|
|
3
|
+
|
|
4
|
+
export function inputByteSize(value) {
|
|
5
|
+
const text = typeof value === 'string' ? value : String(value ?? '')
|
|
6
|
+
if (typeof Buffer !== 'undefined') {
|
|
7
|
+
return Buffer.byteLength(text, 'utf8')
|
|
8
|
+
}
|
|
9
|
+
if (typeof TextEncoder !== 'undefined') {
|
|
10
|
+
return new TextEncoder().encode(text).length
|
|
11
|
+
}
|
|
12
|
+
return text.length
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} input
|
|
17
|
+
* @throws {Error} when input exceeds MAX_REFINERY_INPUT_BYTES
|
|
18
|
+
*/
|
|
19
|
+
export function assertInputWithinLimit(input) {
|
|
20
|
+
const byteSize = inputByteSize(input)
|
|
21
|
+
if (byteSize <= MAX_REFINERY_INPUT_BYTES) return
|
|
22
|
+
const limitKb = MAX_REFINERY_INPUT_BYTES / 1024
|
|
23
|
+
throw new Error(`Input exceeds ${limitKb} KB limit (${byteSize} bytes).`)
|
|
24
|
+
}
|
package/src/refineryCompiler.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assertInputWithinLimit } from './inputLimits.js'
|
|
2
|
+
|
|
1
3
|
const TRACKER_BLOCK_RE = /<(script|noscript)\b[^>]*>[\s\S]*?<\/\1>/gi
|
|
2
4
|
|
|
3
5
|
const TRACKER_VENDOR_RE =
|
|
@@ -8,6 +10,7 @@ const RAW_BLOCK_RE = /<(script|style|pre|code|textarea)\b[^>]*>[\s\S]*?<\/\1>/gi
|
|
|
8
10
|
export function runCodeDebloater(inputValue) {
|
|
9
11
|
const start = now()
|
|
10
12
|
const input = String(inputValue ?? '')
|
|
13
|
+
assertInputWithinLimit(input)
|
|
11
14
|
const normalized = input.replace(/\r\n?/g, '\n')
|
|
12
15
|
const htmlLike = /<\/?[a-z][\s\S]*>/i.test(normalized)
|
|
13
16
|
const result = htmlLike ? compactHtml(normalized) : compactLooseCode(normalized)
|
package/src/refinerySanitizer.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assertInputWithinLimit } from './inputLimits.js'
|
|
2
|
+
|
|
1
3
|
const SECRET_PATTERNS = [
|
|
2
4
|
{
|
|
3
5
|
pattern: /\bsk-[A-Za-z0-9_-]{12,}\b/g,
|
|
@@ -35,6 +37,7 @@ const NAMED_SECRET_ASSIGNMENT_RE =
|
|
|
35
37
|
export function runTokenSanitizer(inputValue) {
|
|
36
38
|
const start = now()
|
|
37
39
|
const input = String(inputValue ?? '')
|
|
40
|
+
assertInputWithinLimit(input)
|
|
38
41
|
const normalized = input.replace(/\r\n?/g, '\n')
|
|
39
42
|
let secretsRedacted = 0
|
|
40
43
|
let protectedText = normalized.replace(NAMED_SECRET_ASSIGNMENT_RE, (_match, prefix, assignment, quote, _value) => {
|