@meridian-flow/mars-schema 0.32.0 → 0.33.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.
- package/README.md +4 -3
- package/fixtures/prepare/legacy-agent-no-frontmatter/expected/mars.toml +4 -0
- package/fixtures/prepare/legacy-agent-no-frontmatter/expected.json +94 -0
- package/fixtures/prepare/legacy-agent-no-frontmatter/input/agents/coder.md +1 -0
- package/fixtures/prepare/legacy-agent-no-frontmatter/input/mars.toml +3 -0
- package/fixtures/prepare/legacy-agent-no-frontmatter/request.json +3 -0
- package/fixtures/prepare/package-tools/expected.json +213 -0
- package/fixtures/prepare/package-tools/input/agents/a.md +7 -0
- package/fixtures/prepare/package-tools/input/agents/b.md +4 -0
- package/fixtures/prepare/package-tools/input/mars.toml +10 -0
- package/fixtures/prepare/package-tools/request.json +3 -0
- package/fixtures/prepare/package-tools-invalid/expected.json +112 -0
- package/fixtures/prepare/package-tools-invalid/input/agents/b.md +4 -0
- package/fixtures/prepare/package-tools-invalid/input/mars.toml +8 -0
- package/fixtures/prepare/package-tools-invalid/request.json +3 -0
- package/fixtures/prepare/schema-1-agent-no-frontmatter/expected.json +95 -0
- package/fixtures/prepare/schema-1-agent-no-frontmatter/input/agents/coder.md +5 -0
- package/fixtures/prepare/schema-1-agent-no-frontmatter/input/mars.toml +4 -0
- package/fixtures/prepare/schema-1-agent-no-frontmatter/request.json +3 -0
- package/fixtures/project/key-with-pattern/expected.json +68 -0
- package/fixtures/project/key-with-pattern/request.json +8 -0
- package/fixtures/read/agent-frontmatter-clean/agent.md +5 -0
- package/fixtures/read/agent-frontmatter-clean/expected.json +37 -0
- package/fixtures/read/agent-no-frontmatter-body-only/agent.md +1 -0
- package/fixtures/read/agent-no-frontmatter-body-only/expected.json +35 -0
- package/fixtures/read/agent-no-frontmatter-stray-line/agent.md +6 -0
- package/fixtures/read/agent-no-frontmatter-stray-line/expected.json +35 -0
- package/index.d.ts +10 -4
- package/node/mars_schema_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/web/mars_schema_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -29,8 +29,8 @@ 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`. |
|
|
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. |
|
|
32
|
+
| `project(rules, host)` | Lowers an Agent's tool rules (a `capability` may be a whole key such as `bash(git *)`) 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`. |
|
|
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. Each Agent's `fields.tools` also holds the package's `[package.tools]` rules for keys the Agent does not name, with `origin: "package"`, as `mars sync` writes them. |
|
|
34
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. |
|
|
35
35
|
| `normalize({tree, source?, hint?, selection?})` | Turns a selection into schema v1 packages with a generated `mars.toml` and provenance. |
|
|
36
36
|
| `satisfies(constraint, version)` | Whether a version meets a dependency entry's `version` (`^1.2`, `v2`, a bare `0.20` as `^0.20`, `latest`; a branch or commit pin is met by none). |
|
|
@@ -58,6 +58,7 @@ interface DefinitionRead<Fields> {
|
|
|
58
58
|
- `fields` has the kebab-case spellings the file uses (`"model-invocable"`, `"harness-overrides"`), `xhigh` and `read-only` as written, and `null` or `[]` where the file sets nothing. `AgentFields`, `SkillFields` and `ManifestFields` are in `index.d.ts`; for `mars.toml`, `frontmatter` holds the pairs of the `[package]` table.
|
|
59
59
|
- `diagnostics` carry a stable `code` (`field.removed`, `field.unknown`, `yaml.anchor`, ...), a `severity` of `error`, `warning` or `info`, and a `path` of keys and indexes into the file (`["model-policies", 0, "when"]`). Locate the diagnostic in the text with your own parser: `range` is for fence and YAML-syntax errors only, and no reader sets it yet. Errors do not stop the reading, so an editor can show the form and the problem together.
|
|
60
60
|
- `frontmatter` omits a key whose value has no JSON form (a YAML tag, a non-string key, an integer beyond ±(2^53 − 1), a `__proto__` key) and reports it as `yaml.non-json-value` (`toml.non-json-value` for `mars.toml`). Mapping keys keep file order at every depth; JavaScript objects list integer-like keys such as `"1"` first.
|
|
61
|
+
- An Agent whose first line is not `---` has no frontmatter, so every field takes its default and the file reads as the widest Agent. `read("agents/<slug>.md", text)` reports it as the error `frontmatter.missing`, with the defaults in `fields` and the whole file in `body`; `prepare` reports it the same way for a schema 1 package. A pre-v1 or foreign package's body-only Agent is not an error, and a skill with no frontmatter keeps its `skill.no-frontmatter` warning.
|
|
61
62
|
- Frontmatter has two limits, because the YAML scanners take time that grows with the square of the nesting depth and a server that reads untrusted files must not stall: a block over 64 KiB is `frontmatter.too-large`, and one that opens `[` or `{` more than 64 deep (counted over the raw text) is `frontmatter.too-deep`. Either gives `fields: null` and no other diagnostic. Real frontmatter is under 2 KiB and nests a few levels; the limits apply to `read`, `prepare` and `normalize` alike.
|
|
62
63
|
|
|
63
64
|
### Editing without losing the rest of the file
|
|
@@ -109,7 +110,7 @@ p.rules[0].status; // "known" | "absent" | "unknown" | "unscopable" | n
|
|
|
109
110
|
|
|
110
111
|
### `prepare`, `inspect`, `normalize`
|
|
111
112
|
|
|
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.
|
|
113
|
+
`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. `fields.tools` of an Agent in `prepare`'s result is what `mars sync` installs: the package's `[package.tools]` rules for each key the Agent's own `tools:` does not name (two spellings of one key are one key) follow its own rules, marked `origin: "package"`; `normalized_bytes` stay the authored file's. `read` sees one file, so it never adds them. When the package's `mars.toml` has any error (an invalid `[package.tools]` entry included), each Agent's reading carries a `package-tools.unreadable` error: `mars sync` refuses that package and installs no Agent, so a consumer must not install it either. `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.
|
|
113
114
|
|
|
114
115
|
`inspect` reports what is in a repository before anything is chosen, and `normalize` builds the packages for a selection. A remote marketplace plugin is fetched by the caller: `inspect` the marketplace, fetch the entry's repository, then `inspect` or `normalize` the fetched tree with `hint.plugin` set to the entry.
|
|
115
116
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"classification": {
|
|
3
|
+
"kind": "mars-legacy"
|
|
4
|
+
},
|
|
5
|
+
"manifest": {
|
|
6
|
+
"source_path": "mars.toml",
|
|
7
|
+
"output_path": "mars.toml",
|
|
8
|
+
"reading": {
|
|
9
|
+
"frontmatter": [
|
|
10
|
+
[
|
|
11
|
+
"name",
|
|
12
|
+
"demo"
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"version",
|
|
16
|
+
"1.0.0"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"schema",
|
|
20
|
+
1
|
|
21
|
+
]
|
|
22
|
+
],
|
|
23
|
+
"fields": {
|
|
24
|
+
"name": "demo",
|
|
25
|
+
"version": "1.0.0",
|
|
26
|
+
"schema": 1
|
|
27
|
+
},
|
|
28
|
+
"body": null,
|
|
29
|
+
"diagnostics": []
|
|
30
|
+
},
|
|
31
|
+
"change": {
|
|
32
|
+
"kind": "edited",
|
|
33
|
+
"paths": [
|
|
34
|
+
[
|
|
35
|
+
"package",
|
|
36
|
+
"schema"
|
|
37
|
+
]
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"definitions": [
|
|
42
|
+
{
|
|
43
|
+
"kind": "agent",
|
|
44
|
+
"slug": "coder",
|
|
45
|
+
"source_path": "agents/coder.md",
|
|
46
|
+
"output_path": "agents/coder.md",
|
|
47
|
+
"reading": {
|
|
48
|
+
"frontmatter": [],
|
|
49
|
+
"fields": {
|
|
50
|
+
"name": null,
|
|
51
|
+
"description": null,
|
|
52
|
+
"harness": null,
|
|
53
|
+
"model": null,
|
|
54
|
+
"mode": null,
|
|
55
|
+
"model-invocable": true,
|
|
56
|
+
"user-invocable": true,
|
|
57
|
+
"approval": null,
|
|
58
|
+
"sandbox": null,
|
|
59
|
+
"network": null,
|
|
60
|
+
"network-allow": [],
|
|
61
|
+
"network-deny": [],
|
|
62
|
+
"effort": null,
|
|
63
|
+
"skills": {
|
|
64
|
+
"load": [],
|
|
65
|
+
"available": []
|
|
66
|
+
},
|
|
67
|
+
"subagents": [],
|
|
68
|
+
"tools": [],
|
|
69
|
+
"harness-overrides": {},
|
|
70
|
+
"model-policies": []
|
|
71
|
+
},
|
|
72
|
+
"body": "Body only\n",
|
|
73
|
+
"diagnostics": []
|
|
74
|
+
},
|
|
75
|
+
"change": {
|
|
76
|
+
"kind": "none"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"payload": [],
|
|
81
|
+
"selection": {
|
|
82
|
+
"definitions": [
|
|
83
|
+
{
|
|
84
|
+
"kind": "agent",
|
|
85
|
+
"slug": "coder",
|
|
86
|
+
"output_path": "agents/coder.md",
|
|
87
|
+
"skills": []
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"edges": [],
|
|
91
|
+
"uses_providers": []
|
|
92
|
+
},
|
|
93
|
+
"diagnostics": {}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Body only
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
{
|
|
2
|
+
"classification": {
|
|
3
|
+
"kind": "schema-1"
|
|
4
|
+
},
|
|
5
|
+
"manifest": {
|
|
6
|
+
"source_path": "mars.toml",
|
|
7
|
+
"output_path": "mars.toml",
|
|
8
|
+
"reading": {
|
|
9
|
+
"frontmatter": [
|
|
10
|
+
[
|
|
11
|
+
"name",
|
|
12
|
+
"p"
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"version",
|
|
16
|
+
"0.1.0"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"schema",
|
|
20
|
+
1
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"tools",
|
|
24
|
+
{
|
|
25
|
+
"write": "deny",
|
|
26
|
+
"bash(git *)": "ask",
|
|
27
|
+
"read": "deny",
|
|
28
|
+
"bash(rm:*)": "deny"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
],
|
|
32
|
+
"fields": {
|
|
33
|
+
"name": "p",
|
|
34
|
+
"version": "0.1.0",
|
|
35
|
+
"schema": 1,
|
|
36
|
+
"tools": {
|
|
37
|
+
"bash(git *)": "ask",
|
|
38
|
+
"bash(rm:*)": "deny",
|
|
39
|
+
"read": "deny",
|
|
40
|
+
"write": "deny"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"body": null,
|
|
44
|
+
"diagnostics": []
|
|
45
|
+
},
|
|
46
|
+
"change": {
|
|
47
|
+
"kind": "none"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"definitions": [
|
|
51
|
+
{
|
|
52
|
+
"kind": "agent",
|
|
53
|
+
"slug": "a",
|
|
54
|
+
"source_path": "agents/a.md",
|
|
55
|
+
"output_path": "agents/a.md",
|
|
56
|
+
"reading": {
|
|
57
|
+
"frontmatter": [
|
|
58
|
+
[
|
|
59
|
+
"name",
|
|
60
|
+
"A"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"tools",
|
|
64
|
+
{
|
|
65
|
+
"read": "allow",
|
|
66
|
+
"bash(rm *)": "allow"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
],
|
|
70
|
+
"fields": {
|
|
71
|
+
"name": "A",
|
|
72
|
+
"description": null,
|
|
73
|
+
"harness": null,
|
|
74
|
+
"model": null,
|
|
75
|
+
"mode": null,
|
|
76
|
+
"model-invocable": true,
|
|
77
|
+
"user-invocable": true,
|
|
78
|
+
"approval": null,
|
|
79
|
+
"sandbox": null,
|
|
80
|
+
"network": null,
|
|
81
|
+
"network-allow": [],
|
|
82
|
+
"network-deny": [],
|
|
83
|
+
"effort": null,
|
|
84
|
+
"skills": {
|
|
85
|
+
"load": [],
|
|
86
|
+
"available": []
|
|
87
|
+
},
|
|
88
|
+
"subagents": [],
|
|
89
|
+
"tools": [
|
|
90
|
+
{
|
|
91
|
+
"capability": "read",
|
|
92
|
+
"pattern": null,
|
|
93
|
+
"action": "allow",
|
|
94
|
+
"origin": "profile"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"capability": "bash",
|
|
98
|
+
"pattern": "rm *",
|
|
99
|
+
"action": "allow",
|
|
100
|
+
"origin": "profile"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"capability": "bash",
|
|
104
|
+
"pattern": "git *",
|
|
105
|
+
"action": "ask",
|
|
106
|
+
"origin": "package"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"capability": "write",
|
|
110
|
+
"pattern": null,
|
|
111
|
+
"action": "deny",
|
|
112
|
+
"origin": "package"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"harness-overrides": {},
|
|
116
|
+
"model-policies": []
|
|
117
|
+
},
|
|
118
|
+
"body": "body\n",
|
|
119
|
+
"diagnostics": []
|
|
120
|
+
},
|
|
121
|
+
"change": {
|
|
122
|
+
"kind": "none"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"kind": "agent",
|
|
127
|
+
"slug": "b",
|
|
128
|
+
"source_path": "agents/b.md",
|
|
129
|
+
"output_path": "agents/b.md",
|
|
130
|
+
"reading": {
|
|
131
|
+
"frontmatter": [
|
|
132
|
+
[
|
|
133
|
+
"name",
|
|
134
|
+
"B"
|
|
135
|
+
]
|
|
136
|
+
],
|
|
137
|
+
"fields": {
|
|
138
|
+
"name": "B",
|
|
139
|
+
"description": null,
|
|
140
|
+
"harness": null,
|
|
141
|
+
"model": null,
|
|
142
|
+
"mode": null,
|
|
143
|
+
"model-invocable": true,
|
|
144
|
+
"user-invocable": true,
|
|
145
|
+
"approval": null,
|
|
146
|
+
"sandbox": null,
|
|
147
|
+
"network": null,
|
|
148
|
+
"network-allow": [],
|
|
149
|
+
"network-deny": [],
|
|
150
|
+
"effort": null,
|
|
151
|
+
"skills": {
|
|
152
|
+
"load": [],
|
|
153
|
+
"available": []
|
|
154
|
+
},
|
|
155
|
+
"subagents": [],
|
|
156
|
+
"tools": [
|
|
157
|
+
{
|
|
158
|
+
"capability": "bash",
|
|
159
|
+
"pattern": "git *",
|
|
160
|
+
"action": "ask",
|
|
161
|
+
"origin": "package"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"capability": "bash",
|
|
165
|
+
"pattern": "rm *",
|
|
166
|
+
"action": "deny",
|
|
167
|
+
"origin": "package"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"capability": "read",
|
|
171
|
+
"pattern": null,
|
|
172
|
+
"action": "deny",
|
|
173
|
+
"origin": "package"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"capability": "write",
|
|
177
|
+
"pattern": null,
|
|
178
|
+
"action": "deny",
|
|
179
|
+
"origin": "package"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"harness-overrides": {},
|
|
183
|
+
"model-policies": []
|
|
184
|
+
},
|
|
185
|
+
"body": "body\n",
|
|
186
|
+
"diagnostics": []
|
|
187
|
+
},
|
|
188
|
+
"change": {
|
|
189
|
+
"kind": "none"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"payload": [],
|
|
194
|
+
"selection": {
|
|
195
|
+
"definitions": [
|
|
196
|
+
{
|
|
197
|
+
"kind": "agent",
|
|
198
|
+
"slug": "a",
|
|
199
|
+
"output_path": "agents/a.md",
|
|
200
|
+
"skills": []
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"kind": "agent",
|
|
204
|
+
"slug": "b",
|
|
205
|
+
"output_path": "agents/b.md",
|
|
206
|
+
"skills": []
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
"edges": [],
|
|
210
|
+
"uses_providers": []
|
|
211
|
+
},
|
|
212
|
+
"diagnostics": {}
|
|
213
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"classification": {
|
|
3
|
+
"kind": "schema-1"
|
|
4
|
+
},
|
|
5
|
+
"manifest": {
|
|
6
|
+
"source_path": "mars.toml",
|
|
7
|
+
"output_path": "mars.toml",
|
|
8
|
+
"reading": {
|
|
9
|
+
"frontmatter": [
|
|
10
|
+
[
|
|
11
|
+
"name",
|
|
12
|
+
"p"
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"version",
|
|
16
|
+
"0.1.0"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"schema",
|
|
20
|
+
1
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"tools",
|
|
24
|
+
{
|
|
25
|
+
"write": "deny",
|
|
26
|
+
"read": "maybe"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
],
|
|
30
|
+
"fields": null,
|
|
31
|
+
"body": null,
|
|
32
|
+
"diagnostics": [
|
|
33
|
+
{
|
|
34
|
+
"code": "manifest.invalid-field",
|
|
35
|
+
"severity": "error",
|
|
36
|
+
"path": [
|
|
37
|
+
"package"
|
|
38
|
+
],
|
|
39
|
+
"message": "invalid package field: unknown variant `maybe`, expected one of `allow`, `deny`, `ask`\nin `tools.read`\n"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"change": {
|
|
44
|
+
"kind": "none"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"definitions": [
|
|
48
|
+
{
|
|
49
|
+
"kind": "agent",
|
|
50
|
+
"slug": "b",
|
|
51
|
+
"source_path": "agents/b.md",
|
|
52
|
+
"output_path": "agents/b.md",
|
|
53
|
+
"reading": {
|
|
54
|
+
"frontmatter": [
|
|
55
|
+
[
|
|
56
|
+
"name",
|
|
57
|
+
"B"
|
|
58
|
+
]
|
|
59
|
+
],
|
|
60
|
+
"fields": {
|
|
61
|
+
"name": "B",
|
|
62
|
+
"description": null,
|
|
63
|
+
"harness": null,
|
|
64
|
+
"model": null,
|
|
65
|
+
"mode": null,
|
|
66
|
+
"model-invocable": true,
|
|
67
|
+
"user-invocable": true,
|
|
68
|
+
"approval": null,
|
|
69
|
+
"sandbox": null,
|
|
70
|
+
"network": null,
|
|
71
|
+
"network-allow": [],
|
|
72
|
+
"network-deny": [],
|
|
73
|
+
"effort": null,
|
|
74
|
+
"skills": {
|
|
75
|
+
"load": [],
|
|
76
|
+
"available": []
|
|
77
|
+
},
|
|
78
|
+
"subagents": [],
|
|
79
|
+
"tools": [],
|
|
80
|
+
"harness-overrides": {},
|
|
81
|
+
"model-policies": []
|
|
82
|
+
},
|
|
83
|
+
"body": "body\n",
|
|
84
|
+
"diagnostics": [
|
|
85
|
+
{
|
|
86
|
+
"code": "package-tools.unreadable",
|
|
87
|
+
"severity": "error",
|
|
88
|
+
"path": [],
|
|
89
|
+
"message": "the package's mars.toml has an error, so its `[package.tools]` rules cannot be added and `mars sync` refuses the package: invalid package field: unknown variant `maybe`, expected one of `allow`, `deny`, `ask`\nin `tools.read`\n"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"change": {
|
|
94
|
+
"kind": "none"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"payload": [],
|
|
99
|
+
"selection": {
|
|
100
|
+
"definitions": [
|
|
101
|
+
{
|
|
102
|
+
"kind": "agent",
|
|
103
|
+
"slug": "b",
|
|
104
|
+
"output_path": "agents/b.md",
|
|
105
|
+
"skills": []
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"edges": [],
|
|
109
|
+
"uses_providers": []
|
|
110
|
+
},
|
|
111
|
+
"diagnostics": {}
|
|
112
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"classification": {
|
|
3
|
+
"kind": "schema-1"
|
|
4
|
+
},
|
|
5
|
+
"manifest": {
|
|
6
|
+
"source_path": "mars.toml",
|
|
7
|
+
"output_path": "mars.toml",
|
|
8
|
+
"reading": {
|
|
9
|
+
"frontmatter": [
|
|
10
|
+
[
|
|
11
|
+
"name",
|
|
12
|
+
"demo"
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"version",
|
|
16
|
+
"1.0.0"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"schema",
|
|
20
|
+
1
|
|
21
|
+
]
|
|
22
|
+
],
|
|
23
|
+
"fields": {
|
|
24
|
+
"name": "demo",
|
|
25
|
+
"version": "1.0.0",
|
|
26
|
+
"schema": 1
|
|
27
|
+
},
|
|
28
|
+
"body": null,
|
|
29
|
+
"diagnostics": []
|
|
30
|
+
},
|
|
31
|
+
"change": {
|
|
32
|
+
"kind": "none"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"definitions": [
|
|
36
|
+
{
|
|
37
|
+
"kind": "agent",
|
|
38
|
+
"slug": "coder",
|
|
39
|
+
"source_path": "agents/coder.md",
|
|
40
|
+
"output_path": "agents/coder.md",
|
|
41
|
+
"reading": {
|
|
42
|
+
"frontmatter": [],
|
|
43
|
+
"fields": {
|
|
44
|
+
"name": null,
|
|
45
|
+
"description": null,
|
|
46
|
+
"harness": null,
|
|
47
|
+
"model": null,
|
|
48
|
+
"mode": null,
|
|
49
|
+
"model-invocable": true,
|
|
50
|
+
"user-invocable": true,
|
|
51
|
+
"approval": null,
|
|
52
|
+
"sandbox": null,
|
|
53
|
+
"network": null,
|
|
54
|
+
"network-allow": [],
|
|
55
|
+
"network-deny": [],
|
|
56
|
+
"effort": null,
|
|
57
|
+
"skills": {
|
|
58
|
+
"load": [],
|
|
59
|
+
"available": []
|
|
60
|
+
},
|
|
61
|
+
"subagents": [],
|
|
62
|
+
"tools": [],
|
|
63
|
+
"harness-overrides": {},
|
|
64
|
+
"model-policies": []
|
|
65
|
+
},
|
|
66
|
+
"body": "stray\n---\nsandbox: read-only\n---\nBody\n",
|
|
67
|
+
"diagnostics": [
|
|
68
|
+
{
|
|
69
|
+
"code": "frontmatter.missing",
|
|
70
|
+
"severity": "error",
|
|
71
|
+
"path": [],
|
|
72
|
+
"message": "an Agent's frontmatter must open with a first line that is exactly `---`; without it every field takes its default"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"change": {
|
|
77
|
+
"kind": "none"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"payload": [],
|
|
82
|
+
"selection": {
|
|
83
|
+
"definitions": [
|
|
84
|
+
{
|
|
85
|
+
"kind": "agent",
|
|
86
|
+
"slug": "coder",
|
|
87
|
+
"output_path": "agents/coder.md",
|
|
88
|
+
"skills": []
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"edges": [],
|
|
92
|
+
"uses_providers": []
|
|
93
|
+
},
|
|
94
|
+
"diagnostics": {}
|
|
95
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host": "claude",
|
|
3
|
+
"default": null,
|
|
4
|
+
"rules": [
|
|
5
|
+
{
|
|
6
|
+
"rule": {
|
|
7
|
+
"capability": "bash",
|
|
8
|
+
"pattern": "git *",
|
|
9
|
+
"action": "ask",
|
|
10
|
+
"origin": "profile"
|
|
11
|
+
},
|
|
12
|
+
"status": "known",
|
|
13
|
+
"native": [
|
|
14
|
+
"Bash(git *)"
|
|
15
|
+
],
|
|
16
|
+
"native_tools": [
|
|
17
|
+
"Bash"
|
|
18
|
+
],
|
|
19
|
+
"note": null,
|
|
20
|
+
"covered_by": null
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"rule": {
|
|
24
|
+
"capability": "bash",
|
|
25
|
+
"pattern": "git push *",
|
|
26
|
+
"action": "deny",
|
|
27
|
+
"origin": "profile"
|
|
28
|
+
},
|
|
29
|
+
"status": "known",
|
|
30
|
+
"native": [
|
|
31
|
+
"Bash(git push *)"
|
|
32
|
+
],
|
|
33
|
+
"native_tools": [
|
|
34
|
+
"Bash"
|
|
35
|
+
],
|
|
36
|
+
"note": null,
|
|
37
|
+
"covered_by": null
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"rule": {
|
|
41
|
+
"capability": "write",
|
|
42
|
+
"pattern": null,
|
|
43
|
+
"action": "deny",
|
|
44
|
+
"origin": "package"
|
|
45
|
+
},
|
|
46
|
+
"status": "known",
|
|
47
|
+
"native": [
|
|
48
|
+
"Write"
|
|
49
|
+
],
|
|
50
|
+
"native_tools": [
|
|
51
|
+
"Write"
|
|
52
|
+
],
|
|
53
|
+
"note": null,
|
|
54
|
+
"covered_by": null
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"allow": [],
|
|
58
|
+
"deny": [
|
|
59
|
+
"Bash(git push *)",
|
|
60
|
+
"Write"
|
|
61
|
+
],
|
|
62
|
+
"ask": [
|
|
63
|
+
"Bash(git *)"
|
|
64
|
+
],
|
|
65
|
+
"available": [
|
|
66
|
+
"Bash(git *)"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host": "claude",
|
|
3
|
+
"rules": [
|
|
4
|
+
{ "capability": "bash(git *)", "pattern": null, "action": "ask" },
|
|
5
|
+
{ "capability": "Bash(git push:*)", "pattern": null, "action": "deny" },
|
|
6
|
+
{ "capability": "write", "pattern": null, "action": "deny", "origin": "package" }
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"frontmatter": [
|
|
3
|
+
[
|
|
4
|
+
"name",
|
|
5
|
+
"reviewer"
|
|
6
|
+
],
|
|
7
|
+
[
|
|
8
|
+
"sandbox",
|
|
9
|
+
"read-only"
|
|
10
|
+
]
|
|
11
|
+
],
|
|
12
|
+
"fields": {
|
|
13
|
+
"name": "reviewer",
|
|
14
|
+
"description": null,
|
|
15
|
+
"harness": null,
|
|
16
|
+
"model": null,
|
|
17
|
+
"mode": null,
|
|
18
|
+
"model-invocable": true,
|
|
19
|
+
"user-invocable": true,
|
|
20
|
+
"approval": null,
|
|
21
|
+
"sandbox": "read-only",
|
|
22
|
+
"network": null,
|
|
23
|
+
"network-allow": [],
|
|
24
|
+
"network-deny": [],
|
|
25
|
+
"effort": null,
|
|
26
|
+
"skills": {
|
|
27
|
+
"load": [],
|
|
28
|
+
"available": []
|
|
29
|
+
},
|
|
30
|
+
"subagents": [],
|
|
31
|
+
"tools": [],
|
|
32
|
+
"harness-overrides": {},
|
|
33
|
+
"model-policies": []
|
|
34
|
+
},
|
|
35
|
+
"body": "You are a reviewer.\n",
|
|
36
|
+
"diagnostics": []
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You are a reviewer.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"frontmatter": [],
|
|
3
|
+
"fields": {
|
|
4
|
+
"name": null,
|
|
5
|
+
"description": null,
|
|
6
|
+
"harness": null,
|
|
7
|
+
"model": null,
|
|
8
|
+
"mode": null,
|
|
9
|
+
"model-invocable": true,
|
|
10
|
+
"user-invocable": true,
|
|
11
|
+
"approval": null,
|
|
12
|
+
"sandbox": null,
|
|
13
|
+
"network": null,
|
|
14
|
+
"network-allow": [],
|
|
15
|
+
"network-deny": [],
|
|
16
|
+
"effort": null,
|
|
17
|
+
"skills": {
|
|
18
|
+
"load": [],
|
|
19
|
+
"available": []
|
|
20
|
+
},
|
|
21
|
+
"subagents": [],
|
|
22
|
+
"tools": [],
|
|
23
|
+
"harness-overrides": {},
|
|
24
|
+
"model-policies": []
|
|
25
|
+
},
|
|
26
|
+
"body": "You are a reviewer.\n",
|
|
27
|
+
"diagnostics": [
|
|
28
|
+
{
|
|
29
|
+
"code": "frontmatter.missing",
|
|
30
|
+
"severity": "error",
|
|
31
|
+
"path": [],
|
|
32
|
+
"message": "an Agent's frontmatter must open with a first line that is exactly `---`; without it every field takes its default"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"frontmatter": [],
|
|
3
|
+
"fields": {
|
|
4
|
+
"name": null,
|
|
5
|
+
"description": null,
|
|
6
|
+
"harness": null,
|
|
7
|
+
"model": null,
|
|
8
|
+
"mode": null,
|
|
9
|
+
"model-invocable": true,
|
|
10
|
+
"user-invocable": true,
|
|
11
|
+
"approval": null,
|
|
12
|
+
"sandbox": null,
|
|
13
|
+
"network": null,
|
|
14
|
+
"network-allow": [],
|
|
15
|
+
"network-deny": [],
|
|
16
|
+
"effort": null,
|
|
17
|
+
"skills": {
|
|
18
|
+
"load": [],
|
|
19
|
+
"available": []
|
|
20
|
+
},
|
|
21
|
+
"subagents": [],
|
|
22
|
+
"tools": [],
|
|
23
|
+
"harness-overrides": {},
|
|
24
|
+
"model-policies": []
|
|
25
|
+
},
|
|
26
|
+
"body": "oops\n---\nname: reviewer\nsandbox: read-only\n---\nYou are a reviewer.\n",
|
|
27
|
+
"diagnostics": [
|
|
28
|
+
{
|
|
29
|
+
"code": "frontmatter.missing",
|
|
30
|
+
"severity": "error",
|
|
31
|
+
"path": [],
|
|
32
|
+
"message": "an Agent's frontmatter must open with a first line that is exactly `---`; without it every field takes its default"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ export interface ToolRule {
|
|
|
88
88
|
capability: string;
|
|
89
89
|
pattern: string | null;
|
|
90
90
|
action: "allow" | "deny" | "ask";
|
|
91
|
+
/**
|
|
92
|
+
* Where the rule came from: `"profile"` (the Agent's own `tools`) or `"package"` (the package's
|
|
93
|
+
* `[package.tools]`, added by `prepare` to an Agent that does not name the key). `read` of one
|
|
94
|
+
* file reports only `"profile"`; the launch bundle also has `"overlay"` and `"project"`.
|
|
95
|
+
*/
|
|
96
|
+
origin: "profile" | "package" | "overlay" | "project";
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
export interface ModelPolicyRule {
|
|
@@ -253,8 +259,8 @@ export type Host = Harness | "meridian-flow";
|
|
|
253
259
|
|
|
254
260
|
/** One rule's lowering on a host. */
|
|
255
261
|
export interface ProjectedRule {
|
|
256
|
-
/** The rule as given, in the shape `read` reports it
|
|
257
|
-
rule: ToolRule
|
|
262
|
+
/** The rule as given, in the shape `read` reports it. `origin` is the input's, `"profile"` when it gave none. */
|
|
263
|
+
rule: ToolRule;
|
|
258
264
|
/**
|
|
259
265
|
* `known`: Mars names the tool; `absent`: the host has no such tool; `unknown`: Mars cannot
|
|
260
266
|
* name it (the host has no switch for it, Mars has no row, or it is not a tool Mars knows),
|
|
@@ -287,12 +293,12 @@ export interface ToolProjection {
|
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
/**
|
|
290
|
-
* Lower tool rules (an Agent's `tools` as `
|
|
296
|
+
* Lower tool rules (an Agent's `tools` as `prepare` reports it) onto a host, the way `mars sync`
|
|
291
297
|
* does for a harness. Throws `input.invalid` for an unknown host or a rule that does not parse.
|
|
292
298
|
* A consumer must refuse a rule whose `status` is `unscopable` or `unknown` rather than read only
|
|
293
299
|
* `allow`/`deny`/`ask`: an unscopable `read(src/**): deny` leaves `allow: ["read"]` granting every read.
|
|
294
300
|
*/
|
|
295
|
-
export function project(rules: { capability: string; pattern
|
|
301
|
+
export function project(rules: { /** A capability, or a whole key such as `bash(git *)` or `Bash(git push:*)` when `pattern` is absent. */ capability: string; pattern?: string | null; action: "allow" | "deny" | "ask"; origin?: ToolRule["origin"] }[], host: Host): ToolProjection;
|
|
296
302
|
|
|
297
303
|
// ---------------------------------------------------------------------------------------
|
|
298
304
|
// prepare, inspect, normalize
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|