pearc 1.1.0 → 1.1.1
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/README.md +30 -0
- package/dist/mcp-server.js +190 -0
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/spec/pear.md +22 -2
package/README.md
CHANGED
|
@@ -11,6 +11,35 @@ fn dist(a:*Point,b:*Point)->f64{dx:f64=a->x-b->x;dy:f64=a->y-b->y;rt sqrt(dx*dx+
|
|
|
11
11
|
fn main()->i32{p1:Point={1.0,2.0};p2:Point={4.0,6.0};printf("%f\n",dist(&p1,&p2));rt 0}
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## For AI Assistants
|
|
15
|
+
|
|
16
|
+
If you've been told to use Pear, follow this bootstrap sequence:
|
|
17
|
+
|
|
18
|
+
**1. Install pearc**
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g pearc
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**2. Add the MCP server** to your MCP client config (Claude Code: `.mcp.json` or settings):
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"pear": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["pearc", "--mcp"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**3. Call `pear_spec`** — this MCP tool returns the complete language specification. Read it before writing any Pear code.
|
|
36
|
+
|
|
37
|
+
**4. Write Pear, run it** — use `pear_run` to test code inline, `pear_to_c` to inspect generated C, or `pear_compile` to produce a binary.
|
|
38
|
+
|
|
39
|
+
> **Why Pear exists:** Every token you spend on code is a token not spent on reasoning. Pear lets you write and iterate on real C-level systems code while spending ~35–50% fewer tokens. The workflow is: write Pear (dense, fast), compile to C to verify correctness, ship the C. Use Pear any time you're generating, reviewing, or iterating on low-level code with an LLM in the loop.
|
|
40
|
+
|
|
41
|
+
> Pear syntax is intentionally opaque to save tokens — do not guess syntax. Always call `pear_spec` first.
|
|
42
|
+
|
|
14
43
|
## Install
|
|
15
44
|
|
|
16
45
|
```bash
|
|
@@ -47,6 +76,7 @@ Add to Claude Code or any MCP client:
|
|
|
47
76
|
|
|
48
77
|
| Tool | Description |
|
|
49
78
|
|------|-------------|
|
|
79
|
+
| `pear_spec` | Get the full language spec — call this first |
|
|
50
80
|
| `pear_to_c` | Compile Pear → C source |
|
|
51
81
|
| `c_to_pear` | Minify C → Pear |
|
|
52
82
|
| `pear_run` | Interpret and run Pear, returns stdout/stderr |
|
package/dist/mcp-server.js
CHANGED
|
@@ -8,8 +8,195 @@ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
|
8
8
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
9
9
|
const compiler_1 = require("./compiler");
|
|
10
10
|
const interpreter_1 = require("./interpreter");
|
|
11
|
+
// ─── Language Spec (embedded for reliable delivery regardless of CWD) ──────────
|
|
12
|
+
const PEAR_SPEC = `# Pear Language Specification
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
Pear exists to reduce LLM token consumption on low-level code. Every token spent on boilerplate
|
|
17
|
+
(return types, long keywords, verbose declarations) is a token not spent on reasoning. Pear lets
|
|
18
|
+
you write real, executable C-level code at ~35–50% of the token cost of idiomatic C.
|
|
19
|
+
|
|
20
|
+
**The workflow:**
|
|
21
|
+
1. Write code in Pear (dense, token-efficient)
|
|
22
|
+
2. Use \`pear_run\` to test it inline — no compiler needed
|
|
23
|
+
3. Use \`pear_to_c\` to inspect or ship the generated C
|
|
24
|
+
4. Use \`pear_compile\` when you need a native binary
|
|
25
|
+
|
|
26
|
+
**Use Pear when:** generating, reviewing, or iterating on systems code with an LLM in the loop.
|
|
27
|
+
**Do not use Pear when:** the code is being written once and never touched by an LLM again — just write C.
|
|
28
|
+
|
|
29
|
+
Pear is an ultra-minified low-level language that transpiles to C. Goal: maximum token density.
|
|
30
|
+
File extension: \`.pr\`
|
|
31
|
+
|
|
32
|
+
## Types
|
|
33
|
+
|
|
34
|
+
| Pear | C |
|
|
35
|
+
|------|---|
|
|
36
|
+
| i8 i16 i32 i64 | int8_t int16_t int32_t int64_t |
|
|
37
|
+
| u8 u16 u32 u64 | uint8_t uint16_t uint32_t uint64_t |
|
|
38
|
+
| f32 f64 | float double |
|
|
39
|
+
| v | void |
|
|
40
|
+
| c | char |
|
|
41
|
+
| b | bool |
|
|
42
|
+
| sz | size_t |
|
|
43
|
+
| *T | pointer to T |
|
|
44
|
+
| T[] | array (= *T) |
|
|
45
|
+
|
|
46
|
+
## Keywords
|
|
47
|
+
|
|
48
|
+
| Pear | C |
|
|
49
|
+
|------|---|
|
|
50
|
+
| fn | function definition |
|
|
51
|
+
| st | struct |
|
|
52
|
+
| un | union |
|
|
53
|
+
| en | enum |
|
|
54
|
+
| tp | typedef |
|
|
55
|
+
| if ei el | if / else if / else |
|
|
56
|
+
| lp | for |
|
|
57
|
+
| wh | while |
|
|
58
|
+
| dw | do...while |
|
|
59
|
+
| sw cs dv | switch / case / default |
|
|
60
|
+
| rt | return |
|
|
61
|
+
| bk ct | break / continue |
|
|
62
|
+
| gt | goto |
|
|
63
|
+
| sc ex in vl cn | static / extern / inline / volatile / const |
|
|
64
|
+
| im | #include |
|
|
65
|
+
| df | #define |
|
|
66
|
+
| nd | #ifndef guard |
|
|
67
|
+
| dn | #endif |
|
|
68
|
+
| pr | #pragma |
|
|
69
|
+
| so | sizeof |
|
|
70
|
+
|
|
71
|
+
## Syntax
|
|
72
|
+
|
|
73
|
+
\`\`\`pear
|
|
74
|
+
// Variable declaration
|
|
75
|
+
name:type
|
|
76
|
+
name:type=value
|
|
77
|
+
name:type[size] // array
|
|
78
|
+
|
|
79
|
+
// Function
|
|
80
|
+
fn name(param:type,...)->rettype{...}
|
|
81
|
+
fn name(param:type,...){...} // void return
|
|
82
|
+
|
|
83
|
+
// Control flow
|
|
84
|
+
if(cond){...}
|
|
85
|
+
if(cond){...}ei(cond){...}el{...}
|
|
86
|
+
lp(i:i32=0;i<n;i++){...}
|
|
87
|
+
wh(cond){...}
|
|
88
|
+
dw{...}wh(cond)
|
|
89
|
+
sw(expr){cs val:{...}bk dv:{...}}
|
|
90
|
+
|
|
91
|
+
// Struct / Union / Enum
|
|
92
|
+
st Name{field:type;...}
|
|
93
|
+
un Name{field:type;...}
|
|
94
|
+
en Name{A,B,C=10}
|
|
95
|
+
tp st Name{...} Name // typedef struct
|
|
96
|
+
tp i32 MyInt // typedef scalar
|
|
97
|
+
|
|
98
|
+
// Preprocessor
|
|
99
|
+
im<stdio.h> // #include <stdio.h>
|
|
100
|
+
im"myfile.h" // #include "myfile.h"
|
|
101
|
+
df NAME value // #define NAME value
|
|
102
|
+
df NAME(a) (a*2) // function-like macro
|
|
103
|
+
nd GUARD_H // #ifndef GUARD_H + #define GUARD_H
|
|
104
|
+
dn // #endif
|
|
105
|
+
pr once // #pragma once
|
|
106
|
+
|
|
107
|
+
// Pointers
|
|
108
|
+
p:*i32=&x // pointer declaration
|
|
109
|
+
*p=42 // dereference
|
|
110
|
+
p->field // arrow access
|
|
111
|
+
|
|
112
|
+
// Cast & sizeof
|
|
113
|
+
(i32)someFloat
|
|
114
|
+
(*i32)malloc(n*so(i32))
|
|
115
|
+
so(i32) // sizeof(int32_t)
|
|
116
|
+
|
|
117
|
+
// Ternary
|
|
118
|
+
x>0?x:-x
|
|
119
|
+
\`\`\`
|
|
120
|
+
|
|
121
|
+
## Auto-Injected Headers
|
|
122
|
+
|
|
123
|
+
The compiler automatically prepends:
|
|
124
|
+
- \`#include <stdint.h>\` when integer types (i8/i16/i32/i64/u8/u16/u32/u64) are used
|
|
125
|
+
- \`#include <stdbool.h>\` when \`b\` (bool) is used
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### Hello World
|
|
130
|
+
\`\`\`pear
|
|
131
|
+
im<stdio.h>
|
|
132
|
+
fn main()->i32{printf("Hello, World!\\n");rt 0}
|
|
133
|
+
\`\`\`
|
|
134
|
+
Compiles to:
|
|
135
|
+
\`\`\`c
|
|
136
|
+
#include <stdio.h>
|
|
137
|
+
int main(){printf("Hello, World!\\n");return 0;}
|
|
138
|
+
\`\`\`
|
|
139
|
+
|
|
140
|
+
### Struct + Function
|
|
141
|
+
\`\`\`pear
|
|
142
|
+
im<math.h>
|
|
143
|
+
st Point{x:f64;y:f64}
|
|
144
|
+
fn dist(a:*Point,b:*Point)->f64{dx:f64=a->x-b->x;dy:f64=a->y-b->y;rt sqrt(dx*dx+dy*dy)}
|
|
145
|
+
fn main()->i32{p1:Point={1.0,2.0};p2:Point={4.0,6.0};printf("%f\\n",dist(&p1,&p2));rt 0}
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
### Pointer Arithmetic
|
|
149
|
+
\`\`\`pear
|
|
150
|
+
im<stdio.h>
|
|
151
|
+
fn swap(a:*i32,b:*i32){tmp:i32=*a;*a=*b;*b=tmp}
|
|
152
|
+
fn sum_array(arr:*i32,n:i32)->i32{total:i32=0;lp(i:i32=0;i<n;i++){total+=arr[i]};rt total}
|
|
153
|
+
fn main()->i32{x:i32=10;y:i32=20;swap(&x,&y);printf("%d %d\\n",x,y);rt 0}
|
|
154
|
+
\`\`\`
|
|
155
|
+
|
|
156
|
+
### Dynamic Memory
|
|
157
|
+
\`\`\`pear
|
|
158
|
+
im<stdio.h>
|
|
159
|
+
im<stdlib.h>
|
|
160
|
+
fn main()->i32{
|
|
161
|
+
n:i32=5
|
|
162
|
+
arr:*i32=(*i32)malloc(n*so(i32))
|
|
163
|
+
lp(i:i32=0;i<n;i++){arr[i]=i*i}
|
|
164
|
+
lp(i:i32=0;i<n;i++){printf("%d\\n",arr[i])}
|
|
165
|
+
free(arr)
|
|
166
|
+
rt 0
|
|
167
|
+
}
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
## MCP Tools
|
|
171
|
+
|
|
172
|
+
| Tool | Description |
|
|
173
|
+
|------|-------------|
|
|
174
|
+
| pear_spec | Get this spec (call first to learn the language) |
|
|
175
|
+
| pear_to_c | Compile Pear source → C source |
|
|
176
|
+
| c_to_pear | Minify/decompile C source → Pear |
|
|
177
|
+
| pear_run | Interpret and run Pear directly, returns stdout/stderr |
|
|
178
|
+
| pear_compile | Compile Pear → native binary via gcc/clang |
|
|
179
|
+
|
|
180
|
+
## Token Savings
|
|
181
|
+
|
|
182
|
+
Pear reduces token count ~35–50% vs idiomatic C:
|
|
183
|
+
- \`fn\` instead of return-type + function name pattern
|
|
184
|
+
- \`i32\` instead of \`int32_t\`, \`f64\` instead of \`double\`
|
|
185
|
+
- \`lp\` instead of \`for\`, \`rt\` instead of \`return\`
|
|
186
|
+
- No semicolons required at statement end (optional)
|
|
187
|
+
- Compact variable declarations: \`x:i32=5\` instead of \`int32_t x = 5;\`
|
|
188
|
+
`;
|
|
11
189
|
// ─── Tool Definitions ─────────────────────────────────────────────────────────
|
|
12
190
|
const TOOLS = [
|
|
191
|
+
{
|
|
192
|
+
name: 'pear_spec',
|
|
193
|
+
description: 'Get the complete Pear language specification. Call this first before writing any Pear code — it returns all types, keywords, syntax rules, and examples needed to write valid Pear.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {},
|
|
197
|
+
required: [],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
13
200
|
{
|
|
14
201
|
name: 'pear_to_c',
|
|
15
202
|
description: 'Compile Pear source code to C source code. Pear is an ultra-minified low-level language that transpiles to C.',
|
|
@@ -106,6 +293,9 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
|
106
293
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
107
294
|
const { name, arguments: args } = request.params;
|
|
108
295
|
switch (name) {
|
|
296
|
+
case 'pear_spec': {
|
|
297
|
+
return { content: [{ type: 'text', text: PEAR_SPEC }] };
|
|
298
|
+
}
|
|
109
299
|
case 'pear_run': {
|
|
110
300
|
const code = args?.code;
|
|
111
301
|
const runArgs = args?.args ?? [];
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;AACA,2BAA2B;AAC3B,+EAA+E;;AAE/E,wEAAmE;AACnE,wEAAiF;AACjF,iEAI4C;AAC5C,yCAA+D;AAC/D,+CAA4C;AAE5C,iFAAiF;AAEjF,MAAM,KAAK,GAAW;IACpB;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,+GAA+G;QAC5H,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6BAA6B;iBAC3C;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,0IAA0I;QACvJ,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oCAAoC;iBAClD;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,8GAA8G;QAC3H,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uCAAuC;iBACrD;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,+CAA+C;iBAC7D;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sCAAsC;iBACpD;aACF;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0BAA0B,MAAM,CAAC,MAAM,EAAE;yBAC9F,CAAC;iBACH,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,OAAO,EAAE,CAAC;4BACR,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,uBAAuB,MAAM,CAAC,KAAK,0BAA0B,MAAM,CAAC,MAAM,EAAE;yBACnF,CAAC;oBACF,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAED;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;gBAC1D,OAAO,EAAE,IAAI;aACd,CAAC;IACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,iFAAiF;AAEjF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,iCAAiC;AACnC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
package/spec/pear.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Pear Language Specification
|
|
2
2
|
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Pear exists to reduce LLM token consumption on low-level code. Every token spent on boilerplate (return types, long keywords, verbose declarations) is a token not spent on reasoning. Pear lets you write real, executable C-level code at ~35–50% of the token cost of idiomatic C.
|
|
6
|
+
|
|
7
|
+
**The workflow:**
|
|
8
|
+
1. Write code in Pear (dense, token-efficient)
|
|
9
|
+
2. Use `pear_run` to test inline — no C compiler needed
|
|
10
|
+
3. Use `pear_to_c` to inspect or ship the generated C
|
|
11
|
+
4. Use `pear_compile` when you need a native binary
|
|
12
|
+
|
|
13
|
+
**Use Pear when:** generating, reviewing, or iterating on systems code with an LLM in the loop.
|
|
14
|
+
**Do not use Pear when:** the code is written once and never touched by an LLM again — just write C.
|
|
15
|
+
|
|
3
16
|
Pear is an ultra-minified low-level language that transpiles to C. The goal is maximum token density — every byte saved matters.
|
|
4
17
|
|
|
5
18
|
File extension: `.pr`
|
|
@@ -206,8 +219,15 @@ pearc --decompile hello.c
|
|
|
206
219
|
|
|
207
220
|
## MCP Server
|
|
208
221
|
|
|
209
|
-
|
|
222
|
+
Start with `pearc --mcp` or via the MCP config:
|
|
223
|
+
```json
|
|
224
|
+
{ "mcpServers": { "pear": { "command": "npx", "args": ["pearc", "--mcp"] } } }
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Tools exposed:
|
|
210
228
|
|
|
229
|
+
- `pear_spec()` — returns this spec; call first before writing any Pear
|
|
211
230
|
- `pear_to_c(code)` — compile Pear to C source
|
|
212
231
|
- `c_to_pear(code)` — decompile C to minified Pear
|
|
213
|
-
- `
|
|
232
|
+
- `pear_run(code, args?, stdin?)` — interpret and run Pear directly, returns stdout/stderr/exitCode
|
|
233
|
+
- `pear_compile(code, output_file, compiler?, flags?)` — compile Pear to binary via gcc/clang
|