@smeltjs/core 0.1.0 → 0.2.0

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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/cli/args.d.ts +12 -1
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +61 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/config.d.ts +22 -0
  7. package/dist/cli/config.d.ts.map +1 -1
  8. package/dist/cli/config.js +32 -1
  9. package/dist/cli/config.js.map +1 -1
  10. package/dist/cli/hooks.d.ts +153 -0
  11. package/dist/cli/hooks.d.ts.map +1 -0
  12. package/dist/cli/hooks.js +1180 -0
  13. package/dist/cli/hooks.js.map +1 -0
  14. package/dist/cli/init.d.ts +3 -1
  15. package/dist/cli/init.d.ts.map +1 -1
  16. package/dist/cli/init.js +6 -0
  17. package/dist/cli/init.js.map +1 -1
  18. package/dist/cli/run.d.ts +1 -1
  19. package/dist/cli/run.d.ts.map +1 -1
  20. package/dist/cli/run.js +19 -0
  21. package/dist/cli/run.js.map +1 -1
  22. package/dist/hooks/guard-core.d.ts +164 -0
  23. package/dist/hooks/guard-core.d.ts.map +1 -0
  24. package/dist/hooks/guard-core.js +513 -0
  25. package/dist/hooks/guard-core.js.map +1 -0
  26. package/dist/hooks/shim.d.ts +85 -0
  27. package/dist/hooks/shim.d.ts.map +1 -0
  28. package/dist/hooks/shim.js +107 -0
  29. package/dist/hooks/shim.js.map +1 -0
  30. package/dist/hooks/shims/claude-code.d.ts +23 -0
  31. package/dist/hooks/shims/claude-code.d.ts.map +1 -0
  32. package/dist/hooks/shims/claude-code.js +61 -0
  33. package/dist/hooks/shims/claude-code.js.map +1 -0
  34. package/dist/hooks/shims/cline.d.ts +17 -0
  35. package/dist/hooks/shims/cline.d.ts.map +1 -0
  36. package/dist/hooks/shims/cline.js +39 -0
  37. package/dist/hooks/shims/cline.js.map +1 -0
  38. package/dist/hooks/shims/codex.d.ts +23 -0
  39. package/dist/hooks/shims/codex.d.ts.map +1 -0
  40. package/dist/hooks/shims/codex.js +56 -0
  41. package/dist/hooks/shims/codex.js.map +1 -0
  42. package/dist/hooks/shims/cursor.d.ts +19 -0
  43. package/dist/hooks/shims/cursor.d.ts.map +1 -0
  44. package/dist/hooks/shims/cursor.js +47 -0
  45. package/dist/hooks/shims/cursor.js.map +1 -0
  46. package/dist/hooks/shims/gemini.d.ts +23 -0
  47. package/dist/hooks/shims/gemini.d.ts.map +1 -0
  48. package/dist/hooks/shims/gemini.js +53 -0
  49. package/dist/hooks/shims/gemini.js.map +1 -0
  50. package/dist/hooks/shims/grok.d.ts +18 -0
  51. package/dist/hooks/shims/grok.d.ts.map +1 -0
  52. package/dist/hooks/shims/grok.js +37 -0
  53. package/dist/hooks/shims/grok.js.map +1 -0
  54. package/dist/hooks/shims/hermes.d.ts +22 -0
  55. package/dist/hooks/shims/hermes.d.ts.map +1 -0
  56. package/dist/hooks/shims/hermes.js +50 -0
  57. package/dist/hooks/shims/hermes.js.map +1 -0
  58. package/dist/net/policy.d.ts.map +1 -1
  59. package/dist/net/policy.js +1 -0
  60. package/dist/net/policy.js.map +1 -1
  61. package/package.json +12 -4
@@ -0,0 +1,50 @@
1
+ import { asRecord, isMainModule, runShimMain, toolCallRequest } from '../shim.js';
2
+ /**
3
+ * Hermes Agent shim — EXPERIMENTAL tier: schema mapped from the capability matrix
4
+ * (docs/research/2026-09-02-harness-capability-matrix.md, Hermes Agent row; primary
5
+ * source <https://hermes-agent.nousresearch.com/docs/user-guide/features/hooks>),
6
+ * not yet smoke-tested against the real binary.
7
+ *
8
+ * - event: `pre_tool_call`; stdin carries the tool name and its arguments
9
+ * (`tool_name` + `args`, with `tool_input` accepted as a fallback spelling).
10
+ * - deny: `{ "action": "block", "reason": … }`.
11
+ * - rewrite: `{ "action": "modify", "args": { … } }` — a **shallow merge** into the
12
+ * tool's arguments, so this shim sends only the `command` key and the harness
13
+ * keeps the rest. The modify schema has **no reason field**, so the substitution
14
+ * is announced on stderr — a rewrite must never be silent.
15
+ *
16
+ * Carried caveat from the matrix: Hermes has a known bypass where memory tools
17
+ * ignore `disabled_toolsets` (<https://github.com/NousResearch/hermes-agent/issues/46171>) —
18
+ * tool gating there is leaky at the edges, so treat this hook as best-effort
19
+ * steering, not a boundary.
20
+ */
21
+ export const adapter = {
22
+ toRequest: (raw) => {
23
+ const fields = asRecord(raw);
24
+ return toolCallRequest(fields['tool_name'], fields['args'] ?? fields['tool_input'], {
25
+ read: ['read_file', 'Read', 'ReadFile'],
26
+ bash: ['execute_command', 'terminal', 'bash', 'Bash', 'shell'],
27
+ });
28
+ },
29
+ pass: () => ({ stdout: '', exitCode: 0 }),
30
+ deny: (_raw, _request, decision) => ({
31
+ stdout: `${JSON.stringify({
32
+ action: 'block',
33
+ reason: decision.reason ?? 'denied by the smelt guard',
34
+ })}\n`,
35
+ exitCode: 0,
36
+ }),
37
+ rewrite: (_raw, _request, decision) => ({
38
+ stdout: `${JSON.stringify({
39
+ action: 'modify',
40
+ args: { command: decision.suggestion },
41
+ })}\n`,
42
+ // Hermes's modify action carries no reason field — announce on stderr instead.
43
+ stderr: `smelt guard (rewrite mode): substituted the command in-flight with ` +
44
+ `\`${decision.suggestion ?? ''}\`. ${decision.reason ?? ''}\n`,
45
+ exitCode: 0,
46
+ }),
47
+ };
48
+ if (isMainModule(import.meta.url))
49
+ runShimMain(adapter);
50
+ //# sourceMappingURL=hermes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../../src/hooks/shims/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAgB;IAClC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,QAA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ources":["../../src/net/policy.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAenD,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAQ9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAYlD,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAG7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAc,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,CAS5D"}
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAenD,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAQ9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAalD,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAG7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAc,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,CAS5D"}
@@ -72,6 +72,7 @@ export const ALLOWED_NODE_BUILTINS = [
72
72
  'node:module', // web-tree-sitter's own loader shim needs createRequire
73
73
  'node:util', // parseArgs, for the CLI. Argument parsing with zero dependencies.
74
74
  'node:process', // argv, stdin/stdout/stderr and the exit code, for the CLI
75
+ 'node:os', // homedir(), for `smelt hooks install` harness detection — reads a path, opens nothing
75
76
  'node:readline/promises', // line-by-line answers for `smelt init` — reads streams it is handed, opens nothing
76
77
  'node:tty', // isatty(0) for the CLI's TTY check — a plain syscall, no stream, no socket
77
78
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;CACX,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,KAAK;IACL,IAAI;IACJ,YAAY;IACZ,IAAI;IACJ,kBAAkB;IAClB,aAAa;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,OAAO;IACP,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,WAAW;IACX,YAAY;IACZ,QAAQ;CACT,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,aAAa,EAAE,wCAAwC;IACvD,SAAS,EAAE,uCAAuC;IAClD,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,aAAa;IACb,aAAa,EAAE,wDAAwD;IACvE,WAAW,EAAE,mEAAmE;IAChF,cAAc,EAAE,2DAA2D;IAC3E,wB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mB;IACrD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,kBAAkB,CAC1B,qBAAqB,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,QAAQ,kBAAkB;YAC5E,qCAAqC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,KAAK,CAAC,KAAmB;IAChC,IAAI,KAAK,YAAY,GAAG;QAAE,OAAO,KAAK,CAAC;IACvC,8EAA8E;IAC9E,gFAAgF;IAChF,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,kBAAkB,CAAC,qBAAqB,KAAK,iCAAiC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC;AACvE,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@smeltjs/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Structure-aware, reversible, offline context optimization for AI coding agents.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "mong-x",
7
- "homepage": "https://github.com/mong-x/smelt#readme",
7
+ "homepage": "https://github.com/smeltjs/smelt#readme",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/mong-x/smelt.git",
10
+ "url": "git+https://github.com/smeltjs/smelt.git",
11
11
  "directory": "packages/core"
12
12
  },
13
- "bugs": "https://github.com/mong-x/smelt/issues",
13
+ "bugs": "https://github.com/smeltjs/smelt/issues",
14
14
  "keywords": [
15
15
  "llm",
16
16
  "context",
@@ -38,6 +38,14 @@
38
38
  "import": "./dist/index.js",
39
39
  "default": "./dist/index.js"
40
40
  },
41
+ "./hooks/guard-core": "./dist/hooks/guard-core.js",
42
+ "./hooks/shims/claude-code": "./dist/hooks/shims/claude-code.js",
43
+ "./hooks/shims/codex": "./dist/hooks/shims/codex.js",
44
+ "./hooks/shims/gemini": "./dist/hooks/shims/gemini.js",
45
+ "./hooks/shims/grok": "./dist/hooks/shims/grok.js",
46
+ "./hooks/shims/hermes": "./dist/hooks/shims/hermes.js",
47
+ "./hooks/shims/cursor": "./dist/hooks/shims/cursor.js",
48
+ "./hooks/shims/cline": "./dist/hooks/shims/cline.js",
41
49
  "./package.json": "./package.json"
42
50
  },
43
51
  "bin": {