@meridian-flow/mars-schema 0.31.1 → 0.32.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 (32) hide show
  1. package/README.md +14 -0
  2. package/fixtures/project/aliases-reach-one-capability/expected.json +47 -0
  3. package/fixtures/project/aliases-reach-one-capability/request.json +15 -0
  4. package/fixtures/project/claude-allowlist-covered/expected.json +60 -0
  5. package/fixtures/project/claude-allowlist-covered/request.json +20 -0
  6. package/fixtures/project/claude-edit-beats-write/expected.json +53 -0
  7. package/fixtures/project/claude-edit-beats-write/request.json +15 -0
  8. package/fixtures/project/claude-scoped-file-rules/expected.json +68 -0
  9. package/fixtures/project/claude-scoped-file-rules/request.json +20 -0
  10. package/fixtures/project/codex-no-switch-and-absent/expected.json +49 -0
  11. package/fixtures/project/codex-no-switch-and-absent/request.json +20 -0
  12. package/fixtures/project/flow-allowlist/expected.json +44 -0
  13. package/fixtures/project/flow-allowlist/request.json +15 -0
  14. package/fixtures/project/flow-closed-tool-set/expected.json +75 -0
  15. package/fixtures/project/flow-closed-tool-set/request.json +10 -0
  16. package/fixtures/project/flow-gaps-and-ask/expected.json +57 -0
  17. package/fixtures/project/flow-gaps-and-ask/request.json +20 -0
  18. package/fixtures/project/flow-scoped-pattern/expected.json +23 -0
  19. package/fixtures/project/flow-scoped-pattern/request.json +10 -0
  20. package/fixtures/project/flow-write-deny/expected.json +29 -0
  21. package/fixtures/project/flow-write-deny/request.json +10 -0
  22. package/fixtures/vocabulary/expected.json +54 -0
  23. package/index.d.ts +49 -0
  24. package/node/mars_schema_wasm.d.ts +7 -0
  25. package/node/mars_schema_wasm.js +27 -0
  26. package/node/mars_schema_wasm_bg.wasm +0 -0
  27. package/node/mars_schema_wasm_bg.wasm.d.ts +1 -0
  28. package/package.json +1 -1
  29. package/web/mars_schema_wasm.d.ts +8 -0
  30. package/web/mars_schema_wasm.js +26 -0
  31. package/web/mars_schema_wasm_bg.wasm +0 -0
  32. package/web/mars_schema_wasm_bg.wasm.d.ts +1 -0
package/README.md CHANGED
@@ -29,6 +29,7 @@ await init();
29
29
  | `emitValue(value, indent)` | YAML for one value, to splice after a key. |
30
30
  | `rewriteBlock(frontmatter)` | The whole frontmatter block between the `---` fences for ordered `[key, value]` pairs. |
31
31
  | `vocabulary()` | The tool capabilities, their aliases, and the native tools of each host. |
32
+ | `project(rules, host)` | Lowers an Agent's tool rules onto a host with the code `mars sync` uses: the native names each action ends with, each rule's gap or stricter rule, and how the host handles `ask`. |
32
33
  | `prepare({files, context?, declaredDialect?, migrate?})` | Reads one root held in memory: classifies it, upgrades or translates it, and returns each definition's normalized bytes, typed reading and change record. `migrate` adds `mars migrate`'s repair: a removed Agent key whose replacement is a `harness-overrides` key moves there. |
33
34
  | `inspect({tree, hint?})` | Reports what a repository is: a marketplace's plugins, a plugin's or skill tree's items, the dialect and the evidence for it. |
34
35
  | `normalize({tree, source?, hint?, selection?})` | Turns a selection into schema v1 packages with a generated `mars.toml` and provenance. |
@@ -94,6 +95,18 @@ natives["meridian-flow"].work; // { kind: "tools", tools: ["work
94
95
 
95
96
  `natives` has one table for each of `claude`, `codex`, `opencode`, `pi`, `cursor` and `meridian-flow` (Meridian Flow's own tools, which is not a harness). An entry is the host's tool names (`tools`), file tools scoped through a permission category (`scoped-tools`), `absent` (the host has no such tool) or `no-switch` (the host can do it but has no tool to turn off). The capability table is explained in [Tool capabilities](https://github.com/haowjy/mars-agents/blob/main/docs/config/schema-v1.md#tool-capabilities).
96
97
 
98
+ ### `project`
99
+
100
+ ```ts
101
+ const { tools } = read("agents/a.md", text).fields; // [{ capability, pattern, action }, ...]
102
+ const p = project(tools, "meridian-flow");
103
+ p.allow; p.deny; p.ask; // native tool names after stricter rules win shared names
104
+ p.default; // "deny" for `{"*": deny}`: what a tool no rule names gets; null without a `*` rule
105
+ p.rules[0].status; // "known" | "absent" | "unknown" | "unscopable" | null (for `*`)
106
+ ```
107
+
108
+ `host` is `claude`, `codex`, `pi`, `opencode`, `cursor` or `meridian-flow`. A rule with a gap has `status` other than `known`, no `native` names and the reason in `note`; a rule a stricter rule beats keeps its place in `rules` with `covered_by` set or the shared name missing from `native`. The result decides nothing: whether a gap is a warning or an error is the caller's policy. Meridian Flow's tools take no scope, so a rule with a pattern there is `unscopable`.
109
+
97
110
  ### `prepare`, `inspect`, `normalize`
98
111
 
99
112
  `prepare` is the single-root core. It classifies the root (`schema-1`, `mars-legacy`, `schema-newer`, a foreign dialect, `marketplace`, `invalid` or `empty`), selects definitions, upgrades a pre-v1 package or translates a foreign one, and reads each result. For each definition it returns the source and output paths, the normalized bytes, the typed reading, and a change record (`none`, `generated`, `edited` with the changed key paths, or `fully-rewritten`); payload files come back as source-to-output paths without bytes. Findings are keyed by source path in `diagnostics`; what preparing dropped, moved or repaired in each file (a pre-v1 upgrade's removals, a foreign translation's moves) is keyed the same way in `changes`, and a file counts as changed when its change record is not `none` or `generated`. `context` is `"package"` (the default), `"authored-local"` (a consumer project's `.mars-src`) or `"project"` (a project directory: a `mars.toml` with no `[package]` is consumer configuration, and the tree is read as authored content). A tree with no manifest is read as one dialect, Claude unless an Agent has a `permission` map or a `tools` map of booleans (OpenCode), and the keys only pre-v1 Mars defined are rewritten one by one whatever that dialect is, so they never change how the rest of the tree is read. A translated or upgraded definition is never refused: what schema v1 does not accept is moved under `harness-overrides.<dialect>` or dropped, except a key Mars lowers itself (`model`, `effort`, `tools`, `disallowed-tools`, `skills`, `mode`), which is never moved: a mapping loses only its invalid entries and a scalar is dropped. Losing a restriction is a change coded `field.restriction-lost` that names the agent; report these every time, since each leaves an agent less restricted than its file says. `prepare` is supported on its own, for reading one root without choosing items; `normalize` is `prepare` plus a selection, a generated `mars.toml` and provenance.
@@ -133,6 +146,7 @@ Each package's edges and `uses-providers` are read from `prepared.selection`, so
133
146
  | `prepare` | `input/`, `request.json`, `expected.json` | classifying and reading one root, and with `"migrate": true` the repair `mars migrate` writes back |
134
147
  | `normalize` | `input/`, `request.json`, `inspection.json`, `normalized.json`, `expected/` | reading a foreign repository |
135
148
  | `vocabulary` | `expected.json` | the capabilities, aliases and native tools |
149
+ | `project` | `request.json`, `expected.json` | `project` for one rule list on one host |
136
150
  | `version` | `input.json`, `expected.json` | `satisfies`, `satisfiesRequirement` and `selectVersion`, with the `code` of each refusal (the Rust leg also pins `parse-constraint` and `parse-tag`, which are not exported) |
137
151
  | `selection` | `request.json`, `packages/` (or `packages_from`: a sibling case's), `expected.json` | `selectItems` over packages prepared from `packages/` |
138
152
 
@@ -0,0 +1,47 @@
1
+ {
2
+ "host": "claude",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "bash",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": "known",
13
+ "native": [
14
+ "Bash"
15
+ ],
16
+ "native_tools": [
17
+ "Bash"
18
+ ],
19
+ "note": null,
20
+ "covered_by": null
21
+ },
22
+ {
23
+ "rule": {
24
+ "capability": "bash",
25
+ "pattern": null,
26
+ "action": "allow",
27
+ "origin": "profile"
28
+ },
29
+ "status": "known",
30
+ "native": [],
31
+ "native_tools": [],
32
+ "note": "a stricter rule controls the same native tool and wins (deny, then ask, then allow); this rule is left out",
33
+ "covered_by": {
34
+ "action": "deny",
35
+ "key": "bash"
36
+ }
37
+ }
38
+ ],
39
+ "allow": [],
40
+ "deny": [
41
+ "Bash"
42
+ ],
43
+ "ask": [],
44
+ "available": [
45
+ "Bash"
46
+ ]
47
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "host": "claude",
3
+ "rules": [
4
+ {
5
+ "capability": "shell",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ },
9
+ {
10
+ "capability": "exec_command",
11
+ "pattern": null,
12
+ "action": "allow"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "host": "claude",
3
+ "default": "deny",
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "*",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": null,
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": null,
16
+ "covered_by": null
17
+ },
18
+ {
19
+ "rule": {
20
+ "capability": "bash",
21
+ "pattern": "git status *",
22
+ "action": "allow",
23
+ "origin": "profile"
24
+ },
25
+ "status": "known",
26
+ "native": [],
27
+ "native_tools": [],
28
+ "note": null,
29
+ "covered_by": {
30
+ "action": "deny",
31
+ "key": "bash"
32
+ }
33
+ },
34
+ {
35
+ "rule": {
36
+ "capability": "bash",
37
+ "pattern": null,
38
+ "action": "deny",
39
+ "origin": "profile"
40
+ },
41
+ "status": "known",
42
+ "native": [
43
+ "Bash"
44
+ ],
45
+ "native_tools": [
46
+ "Bash"
47
+ ],
48
+ "note": null,
49
+ "covered_by": null
50
+ }
51
+ ],
52
+ "allow": [],
53
+ "deny": [
54
+ "Bash"
55
+ ],
56
+ "ask": [],
57
+ "available": [
58
+ "Bash(git status *)"
59
+ ]
60
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "host": "claude",
3
+ "rules": [
4
+ {
5
+ "capability": "*",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ },
9
+ {
10
+ "capability": "bash",
11
+ "pattern": "git status *",
12
+ "action": "allow"
13
+ },
14
+ {
15
+ "capability": "bash",
16
+ "pattern": null,
17
+ "action": "deny"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "host": "claude",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "edit",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": "known",
13
+ "native": [
14
+ "Edit",
15
+ "Write",
16
+ "NotebookEdit"
17
+ ],
18
+ "native_tools": [
19
+ "Edit",
20
+ "Write",
21
+ "NotebookEdit"
22
+ ],
23
+ "note": null,
24
+ "covered_by": null
25
+ },
26
+ {
27
+ "rule": {
28
+ "capability": "write",
29
+ "pattern": null,
30
+ "action": "allow",
31
+ "origin": "profile"
32
+ },
33
+ "status": "known",
34
+ "native": [],
35
+ "native_tools": [],
36
+ "note": "a stricter rule controls the same native tool and wins (deny, then ask, then allow); this rule is left out",
37
+ "covered_by": {
38
+ "action": "deny",
39
+ "key": "edit"
40
+ }
41
+ }
42
+ ],
43
+ "allow": [],
44
+ "deny": [
45
+ "Edit",
46
+ "Write",
47
+ "NotebookEdit"
48
+ ],
49
+ "ask": [],
50
+ "available": [
51
+ "Write"
52
+ ]
53
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "host": "claude",
3
+ "rules": [
4
+ {
5
+ "capability": "edit",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ },
9
+ {
10
+ "capability": "write",
11
+ "pattern": null,
12
+ "action": "allow"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "host": "claude",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "write",
8
+ "pattern": "src/**",
9
+ "action": "allow",
10
+ "origin": "profile"
11
+ },
12
+ "status": "known",
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": "a stricter rule controls the same native tool and wins (deny, then ask, then allow); this rule is left out",
16
+ "covered_by": {
17
+ "action": "ask",
18
+ "key": "edit(src/**)"
19
+ }
20
+ },
21
+ {
22
+ "rule": {
23
+ "capability": "edit",
24
+ "pattern": "src/**",
25
+ "action": "ask",
26
+ "origin": "profile"
27
+ },
28
+ "status": "known",
29
+ "native": [
30
+ "Edit(src/**)"
31
+ ],
32
+ "native_tools": [
33
+ "Edit",
34
+ "Write",
35
+ "NotebookEdit"
36
+ ],
37
+ "note": "Claude uses Edit(path) to scope every built-in file-editing tool",
38
+ "covered_by": null
39
+ },
40
+ {
41
+ "rule": {
42
+ "capability": "read",
43
+ "pattern": "src/**",
44
+ "action": "deny",
45
+ "origin": "profile"
46
+ },
47
+ "status": "known",
48
+ "native": [
49
+ "Read(src/**)"
50
+ ],
51
+ "native_tools": [
52
+ "Read"
53
+ ],
54
+ "note": null,
55
+ "covered_by": null
56
+ }
57
+ ],
58
+ "allow": [],
59
+ "deny": [
60
+ "Read(src/**)"
61
+ ],
62
+ "ask": [
63
+ "Edit(src/**)"
64
+ ],
65
+ "available": [
66
+ "Edit(src/**)"
67
+ ]
68
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "host": "claude",
3
+ "rules": [
4
+ {
5
+ "capability": "write",
6
+ "pattern": "src/**",
7
+ "action": "allow"
8
+ },
9
+ {
10
+ "capability": "edit",
11
+ "pattern": "src/**",
12
+ "action": "ask"
13
+ },
14
+ {
15
+ "capability": "read",
16
+ "pattern": "src/**",
17
+ "action": "deny"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "host": "codex",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "read",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": "unknown",
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": "codex reads files through its shell; no switch",
16
+ "covered_by": null
17
+ },
18
+ {
19
+ "rule": {
20
+ "capability": "web_fetch",
21
+ "pattern": null,
22
+ "action": "deny",
23
+ "origin": "profile"
24
+ },
25
+ "status": "unknown",
26
+ "native": [],
27
+ "native_tools": [],
28
+ "note": "codex opens pages through hosted web_search; no separate switch",
29
+ "covered_by": null
30
+ },
31
+ {
32
+ "rule": {
33
+ "capability": "notebook",
34
+ "pattern": null,
35
+ "action": "deny",
36
+ "origin": "profile"
37
+ },
38
+ "status": "absent",
39
+ "native": [],
40
+ "native_tools": [],
41
+ "note": null,
42
+ "covered_by": null
43
+ }
44
+ ],
45
+ "allow": [],
46
+ "deny": [],
47
+ "ask": [],
48
+ "available": []
49
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "host": "codex",
3
+ "rules": [
4
+ {
5
+ "capability": "read",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ },
9
+ {
10
+ "capability": "web_fetch",
11
+ "pattern": null,
12
+ "action": "deny"
13
+ },
14
+ {
15
+ "capability": "notebook",
16
+ "pattern": null,
17
+ "action": "deny"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "default": "deny",
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "*",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": null,
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": null,
16
+ "covered_by": null
17
+ },
18
+ {
19
+ "rule": {
20
+ "capability": "read",
21
+ "pattern": null,
22
+ "action": "allow",
23
+ "origin": "profile"
24
+ },
25
+ "status": "known",
26
+ "native": [
27
+ "read"
28
+ ],
29
+ "native_tools": [
30
+ "read"
31
+ ],
32
+ "note": null,
33
+ "covered_by": null
34
+ }
35
+ ],
36
+ "allow": [
37
+ "read"
38
+ ],
39
+ "deny": [],
40
+ "ask": [],
41
+ "available": [
42
+ "read"
43
+ ]
44
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "rules": [
4
+ {
5
+ "capability": "*",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ },
9
+ {
10
+ "capability": "read",
11
+ "pattern": null,
12
+ "action": "allow"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "default": "deny",
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "*",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": null,
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": null,
16
+ "covered_by": null
17
+ },
18
+ {
19
+ "rule": {
20
+ "capability": "bash",
21
+ "pattern": null,
22
+ "action": "allow",
23
+ "origin": "profile"
24
+ },
25
+ "status": "absent",
26
+ "native": [],
27
+ "native_tools": [],
28
+ "note": null,
29
+ "covered_by": null
30
+ },
31
+ {
32
+ "rule": {
33
+ "capability": "mcp",
34
+ "pattern": "github/*",
35
+ "action": "allow",
36
+ "origin": "profile"
37
+ },
38
+ "status": "absent",
39
+ "native": [],
40
+ "native_tools": [],
41
+ "note": null,
42
+ "covered_by": null
43
+ },
44
+ {
45
+ "rule": {
46
+ "capability": "mcp__github__x",
47
+ "pattern": null,
48
+ "action": "deny",
49
+ "origin": "profile"
50
+ },
51
+ "status": "absent",
52
+ "native": [],
53
+ "native_tools": [],
54
+ "note": null,
55
+ "covered_by": null
56
+ },
57
+ {
58
+ "rule": {
59
+ "capability": "bogus_tool",
60
+ "pattern": null,
61
+ "action": "allow",
62
+ "origin": "profile"
63
+ },
64
+ "status": "unknown",
65
+ "native": [],
66
+ "native_tools": [],
67
+ "note": "no native name known for this tool on this harness; left out",
68
+ "covered_by": null
69
+ }
70
+ ],
71
+ "allow": [],
72
+ "deny": [],
73
+ "ask": [],
74
+ "available": []
75
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "rules": [
4
+ { "capability": "*", "pattern": null, "action": "deny" },
5
+ { "capability": "bash", "pattern": null, "action": "allow" },
6
+ { "capability": "mcp(github)", "pattern": null, "action": "allow" },
7
+ { "capability": "mcp__github__x", "pattern": null, "action": "deny" },
8
+ { "capability": "bogus_tool", "pattern": null, "action": "allow" }
9
+ ]
10
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "bash",
8
+ "pattern": null,
9
+ "action": "allow",
10
+ "origin": "profile"
11
+ },
12
+ "status": "absent",
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": null,
16
+ "covered_by": null
17
+ },
18
+ {
19
+ "rule": {
20
+ "capability": "glob",
21
+ "pattern": null,
22
+ "action": "allow",
23
+ "origin": "profile"
24
+ },
25
+ "status": "absent",
26
+ "native": [],
27
+ "native_tools": [],
28
+ "note": null,
29
+ "covered_by": null
30
+ },
31
+ {
32
+ "rule": {
33
+ "capability": "ask_user",
34
+ "pattern": null,
35
+ "action": "ask",
36
+ "origin": "profile"
37
+ },
38
+ "status": "known",
39
+ "native": [
40
+ "ask_user"
41
+ ],
42
+ "native_tools": [
43
+ "ask_user"
44
+ ],
45
+ "note": null,
46
+ "covered_by": null
47
+ }
48
+ ],
49
+ "allow": [],
50
+ "deny": [],
51
+ "ask": [
52
+ "ask_user"
53
+ ],
54
+ "available": [
55
+ "ask_user"
56
+ ]
57
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "rules": [
4
+ {
5
+ "capability": "bash",
6
+ "pattern": null,
7
+ "action": "allow"
8
+ },
9
+ {
10
+ "capability": "glob",
11
+ "pattern": null,
12
+ "action": "allow"
13
+ },
14
+ {
15
+ "capability": "ask_user",
16
+ "pattern": null,
17
+ "action": "ask"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "write",
8
+ "pattern": "kb/**",
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": "unscopable",
13
+ "native": [],
14
+ "native_tools": [],
15
+ "note": "this host's tool takes no pattern, so the rule cannot be scoped",
16
+ "covered_by": null
17
+ }
18
+ ],
19
+ "allow": [],
20
+ "deny": [],
21
+ "ask": [],
22
+ "available": []
23
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "rules": [
4
+ {
5
+ "capability": "write",
6
+ "pattern": "kb/**",
7
+ "action": "deny"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "default": null,
4
+ "rules": [
5
+ {
6
+ "rule": {
7
+ "capability": "write",
8
+ "pattern": null,
9
+ "action": "deny",
10
+ "origin": "profile"
11
+ },
12
+ "status": "known",
13
+ "native": [
14
+ "write"
15
+ ],
16
+ "native_tools": [
17
+ "write"
18
+ ],
19
+ "note": null,
20
+ "covered_by": null
21
+ }
22
+ ],
23
+ "allow": [],
24
+ "deny": [
25
+ "write"
26
+ ],
27
+ "ask": [],
28
+ "available": []
29
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "host": "meridian-flow",
3
+ "rules": [
4
+ {
5
+ "capability": "write",
6
+ "pattern": null,
7
+ "action": "deny"
8
+ }
9
+ ]
10
+ }
@@ -626,6 +626,12 @@
626
626
  "ask_user"
627
627
  ]
628
628
  },
629
+ "bash": {
630
+ "kind": "absent"
631
+ },
632
+ "cron": {
633
+ "kind": "absent"
634
+ },
629
635
  "edit": {
630
636
  "kind": "tools",
631
637
  "tools": [
@@ -641,30 +647,78 @@
641
647
  "grep"
642
648
  ]
643
649
  },
650
+ "image": {
651
+ "kind": "absent"
652
+ },
644
653
  "ls": {
645
654
  "kind": "tools",
646
655
  "tools": [
647
656
  "ls"
648
657
  ]
649
658
  },
659
+ "lsp": {
660
+ "kind": "absent"
661
+ },
662
+ "monitor": {
663
+ "kind": "absent"
664
+ },
665
+ "notebook": {
666
+ "kind": "absent"
667
+ },
668
+ "notifications": {
669
+ "kind": "absent"
670
+ },
671
+ "plan_mode": {
672
+ "kind": "absent"
673
+ },
650
674
  "read": {
651
675
  "kind": "tools",
652
676
  "tools": [
653
677
  "read"
654
678
  ]
655
679
  },
680
+ "remote_trigger": {
681
+ "kind": "absent"
682
+ },
683
+ "schedule_wakeup": {
684
+ "kind": "absent"
685
+ },
686
+ "send_user_file": {
687
+ "kind": "absent"
688
+ },
656
689
  "skill": {
657
690
  "kind": "tools",
658
691
  "tools": [
659
692
  "skill"
660
693
  ]
661
694
  },
695
+ "task": {
696
+ "kind": "absent"
697
+ },
698
+ "tool_search": {
699
+ "kind": "absent"
700
+ },
701
+ "web": {
702
+ "kind": "absent"
703
+ },
704
+ "web_fetch": {
705
+ "kind": "absent"
706
+ },
707
+ "web_search": {
708
+ "kind": "absent"
709
+ },
662
710
  "work": {
663
711
  "kind": "tools",
664
712
  "tools": [
665
713
  "work"
666
714
  ]
667
715
  },
716
+ "workflow": {
717
+ "kind": "absent"
718
+ },
719
+ "worktree": {
720
+ "kind": "absent"
721
+ },
668
722
  "write": {
669
723
  "kind": "tools",
670
724
  "tools": [
package/index.d.ts CHANGED
@@ -245,6 +245,55 @@ export interface Vocabulary {
245
245
 
246
246
  export function vocabulary(): Vocabulary;
247
247
 
248
+ // ---------------------------------------------------------------------------------------
249
+ // project
250
+ // ---------------------------------------------------------------------------------------
251
+
252
+ export type Host = Harness | "meridian-flow";
253
+
254
+ /** One rule's lowering on a host. */
255
+ export interface ProjectedRule {
256
+ /** The rule as given, in the shape `read` reports it (`origin` is `"profile"`). */
257
+ rule: ToolRule & { origin: string };
258
+ /**
259
+ * `known`: Mars names the tool; `absent`: the host has no such tool; `unknown`: Mars cannot
260
+ * name it (the host has no switch for it, Mars has no row, or it is not a tool Mars knows),
261
+ * with the reason in `note`; `unscopable`: the rule has a pattern and the host's tool takes
262
+ * none. `null` for `*`, which names no tool.
263
+ */
264
+ status: "known" | "absent" | "unknown" | "unscopable" | null;
265
+ /** The permission names the rule keeps. Empty for a gap, and when a stricter rule won every name. */
266
+ native: string[];
267
+ /** The unscoped tool names behind `native`. */
268
+ native_tools: string[];
269
+ /** Why the rule is not applied as written: the gap's reason, or the overlap with a stricter rule. */
270
+ note: string | null;
271
+ /** The stricter rule (`deny bash`) that wins every call or name this rule has. */
272
+ covered_by: { action: "allow" | "deny" | "ask"; key: string } | null;
273
+ }
274
+
275
+ export interface ToolProjection {
276
+ host: Host;
277
+ /** What a tool no rule names gets: the strictest `*` rule's action, or `null` without one. */
278
+ default: "allow" | "deny" | "ask" | null;
279
+ /** In the order given. */
280
+ rules: ProjectedRule[];
281
+ /** The native names that end up allowed, denied and asked, after stricter rules win shared names. */
282
+ allow: string[];
283
+ deny: string[];
284
+ ask: string[];
285
+ /** Every allow and ask rule's names before conflicts were resolved: what an allowlist keeps available. */
286
+ available: string[];
287
+ }
288
+
289
+ /**
290
+ * Lower tool rules (an Agent's `tools` as `read` reports it) onto a host, the way `mars sync`
291
+ * does for a harness. Throws `input.invalid` for an unknown host or a rule that does not parse.
292
+ * A consumer must refuse a rule whose `status` is `unscopable` or `unknown` rather than read only
293
+ * `allow`/`deny`/`ask`: an unscopable `read(src/**): deny` leaves `allow: ["read"]` granting every read.
294
+ */
295
+ export function project(rules: { capability: string; pattern: string | null; action: "allow" | "deny" | "ask" }[], host: Host): ToolProjection;
296
+
248
297
  // ---------------------------------------------------------------------------------------
249
298
  // prepare, inspect, normalize
250
299
  // ---------------------------------------------------------------------------------------
@@ -27,6 +27,13 @@ export function normalize(argument: any): any;
27
27
  */
28
28
  export function prepare(argument: any): any;
29
29
 
30
+ /**
31
+ * Lower tool rules onto a host (`claude`, `codex`, `pi`, `opencode`, `cursor` or
32
+ * `meridian-flow`): the native names per action, each rule's gap or coverage, and how the
33
+ * host handles `ask`. The same code `mars sync` lowers an agent's tools with.
34
+ */
35
+ export function project(rules: any, host: string): any;
36
+
30
37
  /**
31
38
  * Read one schema file. `path` is package-relative and picks the reader: `mars.toml`,
32
39
  * `agents/<slug>.md` or `skills/<slug>/SKILL.md`. Any other path throws.
@@ -104,6 +104,33 @@ function prepare(argument) {
104
104
  }
105
105
  exports.prepare = prepare;
106
106
 
107
+ /**
108
+ * Lower tool rules onto a host (`claude`, `codex`, `pi`, `opencode`, `cursor` or
109
+ * `meridian-flow`): the native names per action, each rule's gap or coverage, and how the
110
+ * host handles `ask`. The same code `mars sync` lowers an agent's tools with.
111
+ * @param {any} rules
112
+ * @param {string} host
113
+ * @returns {any}
114
+ */
115
+ function project(rules, host) {
116
+ try {
117
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
118
+ const ptr0 = passStringToWasm0(host, wasm.__wbindgen_export, wasm.__wbindgen_export2);
119
+ const len0 = WASM_VECTOR_LEN;
120
+ wasm.project(retptr, addHeapObject(rules), ptr0, len0);
121
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
122
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
123
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
124
+ if (r2) {
125
+ throw takeObject(r1);
126
+ }
127
+ return takeObject(r0);
128
+ } finally {
129
+ wasm.__wbindgen_add_to_stack_pointer(16);
130
+ }
131
+ }
132
+ exports.project = project;
133
+
107
134
  /**
108
135
  * Read one schema file. `path` is package-relative and picks the reader: `mars.toml`,
109
136
  * `agents/<slug>.md` or `skills/<slug>/SKILL.md`. Any other path throws.
Binary file
@@ -5,6 +5,7 @@ export const emitValue: (a: number, b: number, c: number) => void;
5
5
  export const inspect: (a: number, b: number) => void;
6
6
  export const normalize: (a: number, b: number) => void;
7
7
  export const prepare: (a: number, b: number) => void;
8
+ export const project: (a: number, b: number, c: number, d: number) => void;
8
9
  export const read: (a: number, b: number, c: number, d: number, e: number) => void;
9
10
  export const renderHooks: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
10
11
  export const rewriteBlock: (a: number, b: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meridian-flow/mars-schema",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "description": "Mars agent schema reader and lossless editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,6 +27,13 @@ export function normalize(argument: any): any;
27
27
  */
28
28
  export function prepare(argument: any): any;
29
29
 
30
+ /**
31
+ * Lower tool rules onto a host (`claude`, `codex`, `pi`, `opencode`, `cursor` or
32
+ * `meridian-flow`): the native names per action, each rule's gap or coverage, and how the
33
+ * host handles `ask`. The same code `mars sync` lowers an agent's tools with.
34
+ */
35
+ export function project(rules: any, host: string): any;
36
+
30
37
  /**
31
38
  * Read one schema file. `path` is package-relative and picks the reader: `mars.toml`,
32
39
  * `agents/<slug>.md` or `skills/<slug>/SKILL.md`. Any other path throws.
@@ -95,6 +102,7 @@ export interface InitOutput {
95
102
  readonly inspect: (a: number, b: number) => void;
96
103
  readonly normalize: (a: number, b: number) => void;
97
104
  readonly prepare: (a: number, b: number) => void;
105
+ readonly project: (a: number, b: number, c: number, d: number) => void;
98
106
  readonly read: (a: number, b: number, c: number, d: number, e: number) => void;
99
107
  readonly renderHooks: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
100
108
  readonly rewriteBlock: (a: number, b: number) => void;
@@ -100,6 +100,32 @@ export function prepare(argument) {
100
100
  }
101
101
  }
102
102
 
103
+ /**
104
+ * Lower tool rules onto a host (`claude`, `codex`, `pi`, `opencode`, `cursor` or
105
+ * `meridian-flow`): the native names per action, each rule's gap or coverage, and how the
106
+ * host handles `ask`. The same code `mars sync` lowers an agent's tools with.
107
+ * @param {any} rules
108
+ * @param {string} host
109
+ * @returns {any}
110
+ */
111
+ export function project(rules, host) {
112
+ try {
113
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
114
+ const ptr0 = passStringToWasm0(host, wasm.__wbindgen_export, wasm.__wbindgen_export2);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ wasm.project(retptr, addHeapObject(rules), ptr0, len0);
117
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
118
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
119
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
120
+ if (r2) {
121
+ throw takeObject(r1);
122
+ }
123
+ return takeObject(r0);
124
+ } finally {
125
+ wasm.__wbindgen_add_to_stack_pointer(16);
126
+ }
127
+ }
128
+
103
129
  /**
104
130
  * Read one schema file. `path` is package-relative and picks the reader: `mars.toml`,
105
131
  * `agents/<slug>.md` or `skills/<slug>/SKILL.md`. Any other path throws.
Binary file
@@ -5,6 +5,7 @@ export const emitValue: (a: number, b: number, c: number) => void;
5
5
  export const inspect: (a: number, b: number) => void;
6
6
  export const normalize: (a: number, b: number) => void;
7
7
  export const prepare: (a: number, b: number) => void;
8
+ export const project: (a: number, b: number, c: number, d: number) => void;
8
9
  export const read: (a: number, b: number, c: number, d: number, e: number) => void;
9
10
  export const renderHooks: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
10
11
  export const rewriteBlock: (a: number, b: number) => void;