n2-soul 7.0.1 → 7.0.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/README.md +11 -1
- package/index.js +25 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -554,7 +554,17 @@ AI agents waste massive tokens reading irrelevant code:
|
|
|
554
554
|
|----------|:----------:|:---------:|
|
|
555
555
|
| **Paste entire file** | 10,000+ | ~20% relevant |
|
|
556
556
|
| **Dump whole project** | 500,000+ | ~5% relevant |
|
|
557
|
-
| **Arachne** | ~
|
|
557
|
+
| **Arachne** | ~14,000 | **~90% relevant** |
|
|
558
|
+
|
|
559
|
+
### Real-World Benchmark (N2 Browser Project)
|
|
560
|
+
|
|
561
|
+
| Metric | Value |
|
|
562
|
+
|--------|:-----:|
|
|
563
|
+
| **Project size** | 3,219 files, 4.68M tokens |
|
|
564
|
+
| **Arachne output** | 14,074 tokens |
|
|
565
|
+
| **Compression** | **333x** (99.7% reduction) |
|
|
566
|
+
| **Index time** | 627ms (incremental: 0ms) |
|
|
567
|
+
| **DB size** | 24 MB |
|
|
558
568
|
|
|
559
569
|
### How Arachne Works
|
|
560
570
|
|
package/index.js
CHANGED
|
@@ -39,23 +39,32 @@ const ark = createArk({
|
|
|
39
39
|
auditEnabled: true,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
// Ark-wrapped registerTool shim — bridges legacy registerTool() to SDK v1.6.1 server.tool()
|
|
43
|
+
const _origTool = server.tool.bind(server);
|
|
44
|
+
const _arkWrap = (name, handler) => async (args) => {
|
|
45
|
+
const content = JSON.stringify(args);
|
|
46
|
+
const result = ark.check(name, content, 'tool_call');
|
|
47
|
+
if (!result.allowed) {
|
|
48
|
+
return {
|
|
49
|
+
content: [{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: `[n2-ark] BLOCKED: ${result.reason}\n` +
|
|
52
|
+
`Rule: ${result.rule} | Action: ${result.action}\n` +
|
|
53
|
+
`This action requires human approval.`,
|
|
54
|
+
}],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return handler(args);
|
|
58
|
+
};
|
|
59
|
+
// Shim: server.registerTool(name, {title, description, inputSchema}, handler) → server.tool()
|
|
43
60
|
server.registerTool = (name, schema, handler) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
text: `[n2-ark] BLOCKED: ${result.reason}\n` +
|
|
52
|
-
`Rule: ${result.rule} | Action: ${result.action}\n` +
|
|
53
|
-
`This action requires human approval.`,
|
|
54
|
-
}],
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return handler(args);
|
|
58
|
-
});
|
|
61
|
+
const desc = schema.description || schema.title || name;
|
|
62
|
+
_origTool(name, desc, schema.inputSchema || {}, _arkWrap(name, handler));
|
|
63
|
+
};
|
|
64
|
+
// Override: server.tool() with Ark check (for files using new API directly, e.g. arachne.js)
|
|
65
|
+
server.tool = (name, ...rest) => {
|
|
66
|
+
const handler = rest.pop();
|
|
67
|
+
_origTool(name, ...rest, _arkWrap(name, handler));
|
|
59
68
|
};
|
|
60
69
|
// ═══ End Ark ═══
|
|
61
70
|
|