twsrt 2.2.0__tar.gz → 3.2.0__tar.gz
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.
- {twsrt-2.2.0 → twsrt-3.2.0}/PKG-INFO +65 -21
- {twsrt-2.2.0 → twsrt-3.2.0}/README.md +64 -20
- {twsrt-2.2.0 → twsrt-3.2.0}/pyproject.toml +6 -2
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/bin/cli.py +158 -138
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/codex.py +2 -2
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/config.py +54 -5
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/models.py +33 -8
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/sources.py +2 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/PKG-INFO +65 -21
- {twsrt-2.2.0 → twsrt-3.2.0}/setup.cfg +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/__init__.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/bin/__init__.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/__init__.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/agent.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/claude.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/composition.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/copilot.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/doctor.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/jsonc.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/probe.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/profiles.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt/lib/symlink.py +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/SOURCES.txt +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/dependency_links.txt +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/entry_points.txt +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/requires.txt +0 -0
- {twsrt-2.2.0 → twsrt-3.2.0}/src/twsrt.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twsrt
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Agent security configuration generator — translates canonical security rules into agent-specific configs
|
|
5
5
|
Author-email: sysid <sysid@gmx.de>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -85,7 +85,10 @@ Three ideas explain the whole tool.
|
|
|
85
85
|
> **The canonical config is the input for every agent translation.**
|
|
86
86
|
> `~/.srt-settings.json` and `bash-rules.json` are the compiled policy of one
|
|
87
87
|
> profile: the single source of truth. SRT reads `~/.srt-settings.json`
|
|
88
|
-
> directly; every agent config is translated from the same compile.
|
|
88
|
+
> directly; every agent config is translated from the same compile. These
|
|
89
|
+
> paths assume `output = "~/.srt-settings.json"`; an omitted `output` writes
|
|
90
|
+
> `srt-settings.json` next to `config.toml`, which srt reads only via
|
|
91
|
+
> `srt -s` ([config.toml](#configtoml)).
|
|
89
92
|
|
|
90
93
|
| | Canonical config | Agent configs |
|
|
91
94
|
|---|---|---|
|
|
@@ -181,9 +184,10 @@ uv tool install twsrt # or: pip install twsrt
|
|
|
181
184
|
|
|
182
185
|
twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
|
|
183
186
|
twsrt edit # opens every fragment: deny paths, domains, command rules
|
|
187
|
+
twsrt config # enable agents: [targets] claude_settings = "~/.claude/settings.full.json"
|
|
184
188
|
|
|
185
|
-
twsrt show # print the compiled canonical
|
|
186
|
-
twsrt generate claude # preview the Claude translation
|
|
189
|
+
twsrt show # print the compiled canonical srt settings
|
|
190
|
+
twsrt generate claude # preview the Claude translation and the files -w would write
|
|
187
191
|
twsrt generate claude -w # write the canonical outputs + ~/.claude/settings.full.json
|
|
188
192
|
twsrt diff # exit 0 when every target matches the fragments
|
|
189
193
|
twsrt test # prove the sandbox enforces the policy (plain terminal)
|
|
@@ -202,6 +206,11 @@ Only `config.toml` and the `.jsonc` fragments are edited by hand. Relative
|
|
|
202
206
|
paths resolve from the directory containing `config.toml`; `~` and absolute
|
|
203
207
|
paths also work. `twsrt config --init` writes a fully commented version.
|
|
204
208
|
|
|
209
|
+
Every compile write-denies `config.toml` and every `[sources]` path (outputs
|
|
210
|
+
and fragments), so a sandboxed agent cannot loosen its own policy: edit them
|
|
211
|
+
from a plain terminal
|
|
212
|
+
([why](SECURITY_CONCEPT.md#34-least-privilege-denyread-implies-denywrite)).
|
|
213
|
+
|
|
205
214
|
| Term | Meaning |
|
|
206
215
|
|---|---|
|
|
207
216
|
| Source kind | A canonical document type: `srt` (filesystem and network policy) and `bash` (command allow/ask/deny lists) |
|
|
@@ -218,14 +227,13 @@ default_profile = "default"
|
|
|
218
227
|
|
|
219
228
|
# --- canonical sources: one compiled output, one or more fragments each ---
|
|
220
229
|
[sources.srt]
|
|
221
|
-
output = "~/.srt-settings.json"
|
|
230
|
+
output = "~/.srt-settings.json" # optional, see below
|
|
222
231
|
[sources.srt.fragments.base]
|
|
223
232
|
path = "srt/base.jsonc"
|
|
224
233
|
[sources.srt.fragments.work]
|
|
225
234
|
path = "srt/work.jsonc"
|
|
226
235
|
|
|
227
|
-
[sources.bash]
|
|
228
|
-
output = "bash-rules.json"
|
|
236
|
+
[sources.bash] # output omitted: bash-rules.json next to config.toml
|
|
229
237
|
[sources.bash.fragments.base]
|
|
230
238
|
path = "bash/base.jsonc"
|
|
231
239
|
|
|
@@ -238,13 +246,14 @@ bash = ["base"]
|
|
|
238
246
|
extends = ["default"]
|
|
239
247
|
srt = ["work"]
|
|
240
248
|
|
|
241
|
-
# --- targets ---
|
|
249
|
+
# --- targets: agents are opt-in; an unset key means "agent not configured" ---
|
|
242
250
|
[targets]
|
|
243
251
|
claude_settings = "~/.claude/settings.full.json" # must not be settings.json (symlink anchor)
|
|
244
252
|
codex_config = "~/.codex/config.toml"
|
|
245
|
-
codex_rules = "~/.codex/rules/twsrt.rules" # optional
|
|
246
|
-
copilot_output = "~/.config/twsrt/copilot-flags.txt"
|
|
247
|
-
# claude_settings_yolo / copilot_output_yolo: optional
|
|
253
|
+
codex_rules = "~/.codex/rules/twsrt.rules" # optional, needs codex_config: escalation rules
|
|
254
|
+
copilot_output = "~/.config/twsrt/copilot-flags.txt"
|
|
255
|
+
# claude_settings_yolo / copilot_output_yolo: optional, each needs its full-mode key;
|
|
256
|
+
# default inserts ".yolo" before the suffix
|
|
248
257
|
|
|
249
258
|
# --- Claude: keep unmanaged settings in sync between full and yolo files ---
|
|
250
259
|
[claude_sync]
|
|
@@ -260,6 +269,28 @@ allowUnsandboxedCommands = false
|
|
|
260
269
|
enabled = false
|
|
261
270
|
```
|
|
262
271
|
|
|
272
|
+
Only `schema_version`, `default_profile`, both `[sources.*]` kinds and one
|
|
273
|
+
profile are required. `config --init` writes exactly that, plus
|
|
274
|
+
`[sandbox_overrides.yolo]`, and leaves every other key commented out with
|
|
275
|
+
its default value.
|
|
276
|
+
|
|
277
|
+
`output` is optional per source kind and defaults to `srt-settings.json` /
|
|
278
|
+
`bash-rules.json` next to `config.toml`. srt itself reads only
|
|
279
|
+
`~/.srt-settings.json`, and when that file is missing it runs with built-in
|
|
280
|
+
defaults, without any `denyRead`. With the default `output`, launch
|
|
281
|
+
`srt -s <config dir>/srt-settings.json`, or set
|
|
282
|
+
`output = "~/.srt-settings.json"` so a bare `srt` picks up the policy.
|
|
283
|
+
|
|
284
|
+
An agent is configured only when its `[targets]` key is set. `generate` and
|
|
285
|
+
`diff` treat every agent the same way:
|
|
286
|
+
|
|
287
|
+
| Agent argument | Agent configured | Agent not configured |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `all` (default) | previewed / written / diffed | skipped, with a note on stderr |
|
|
290
|
+
| named, e.g. `codex` | previewed / written / diffed | error, exit 1, no output |
|
|
291
|
+
|
|
292
|
+
If no agent is configured, `generate -w` writes only the canonical outputs.
|
|
293
|
+
|
|
263
294
|
### Fragments
|
|
264
295
|
|
|
265
296
|
SRT fragments follow the
|
|
@@ -327,12 +358,13 @@ srt-p() { local p=$1 d; shift; d=$(twsrt generate claude -w -p "$p" --project
|
|
|
327
358
|
|
|
328
359
|
**What `--project` changes.** Only where outputs land: `./.twsrt/` of the
|
|
329
360
|
current directory (`cd` first). No symlink flip, no `[claude_sync]` donor,
|
|
330
|
-
no global file touched; preview
|
|
361
|
+
no global file touched; the preview works as usual. `all` means
|
|
331
362
|
`claude`; Codex and Copilot are rejected because they read no per-launch
|
|
332
363
|
settings file. Omitting `-p` compiles `default_profile`, the full policy.
|
|
333
364
|
`--project` also adds `./.twsrt` to the compiled `denyWrite`, because Claude
|
|
334
365
|
reloads settings mid-session and an agent able to write them could loosen
|
|
335
|
-
its own policy.
|
|
366
|
+
its own policy. `config.toml`, the fragments and the global outputs stay
|
|
367
|
+
write-denied as in every compile.
|
|
336
368
|
|
|
337
369
|
Evidence, failure directions and how to re-verify after a Claude upgrade:
|
|
338
370
|
[Claude per-project launch premise](doc/REFERENCE.md#claude-per-project-launch-premise).
|
|
@@ -356,10 +388,20 @@ Rule-by-rule translation for all three:
|
|
|
356
388
|
|
|
357
389
|
### Claude Code
|
|
358
390
|
|
|
359
|
-
- **Files.**
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
391
|
+
- **Files and modes.** Claude Code reads only `~/.claude/settings.json`.
|
|
392
|
+
twsrt writes one file per mode, `settings.full.json` or (with `--yolo`)
|
|
393
|
+
`settings.yolo.json`, and turns `settings.json` into a symlink to it:
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
settings.json ──► settings.full.json after generate -w claude
|
|
397
|
+
──► settings.yolo.json after generate --yolo -w claude
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
The last `-w` decides which mode Claude starts in. A regular
|
|
401
|
+
`settings.json` found on the first `-w` is moved to the target; both
|
|
402
|
+
existing at once is an error. Runtime changes Claude makes land in the
|
|
403
|
+
linked file; `[claude_sync]` carries them to the other mode.
|
|
404
|
+
[How the link works](doc/REFERENCE.md#claude-settings-symlink).
|
|
363
405
|
- **Selective merge.** `-w` replaces only what twsrt owns:
|
|
364
406
|
`permissions.deny`/`ask`, the `WebFetch(domain:…)` allows, and the
|
|
365
407
|
`sandbox` keys SRT defines. Hooks, plugins, model, other allows and
|
|
@@ -409,7 +451,8 @@ is preserved. Restart Codex after generation.
|
|
|
409
451
|
### Copilot CLI
|
|
410
452
|
|
|
411
453
|
twsrt does not manage Copilot's `~/.copilot/settings.json`; it emits a flag
|
|
412
|
-
snippet for the launch command (
|
|
454
|
+
snippet for the launch command (written to `copilot_output`; preview it with
|
|
455
|
+
`twsrt generate copilot`). Nothing kernel-guards Copilot's
|
|
413
456
|
tools, so run it under the SRT wrapper, which enforces the paths and domains:
|
|
414
457
|
|
|
415
458
|
```bash
|
|
@@ -484,6 +527,8 @@ What to know:
|
|
|
484
527
|
| Built-in tools (Read, Edit, WebFetch) run inside the agent process | Only the agent's own permission engine guards them, best-effort | Kernel-protect the highest-value secrets via `denyRead` |
|
|
485
528
|
| macOS: srt keeps a symlinked deny path unresolved | `denyRead: ["~/.aws"]` blocks nothing when `~/.aws` is a symlink | Deny the real path too; `twsrt test` reports it as a `(realpath)` `FAIL` |
|
|
486
529
|
| srt's `denyRead` is no write deny | A read-denied file inside a write root could be overwritten | twsrt compiles every `denyRead` into `denyWrite` ([ADR 0001](doc/adr/0001-deny-read-implies-deny-write.md)) |
|
|
530
|
+
| A write root covers the twsrt config (agent launched in a dotfiles repo) | The agent could loosen the policy it runs under | twsrt write-denies `config.toml` and every `[sources]` path in every compile ([ADR 0008](doc/adr/0008-policy-files-are-write-denied.md)) |
|
|
531
|
+
| srt anchors relative paths and `**/x` at its launch cwd | `"**/.env"` protects nothing outside the launch directory | Use `~/` or absolute prefixes for paths that must hold everywhere |
|
|
487
532
|
| Codex `sandbox_mode` in another config layer | The twsrt profile is silently ignored | `codex doctor` after changing Codex config |
|
|
488
533
|
|
|
489
534
|
Threat model, rationale and every known gap:
|
|
@@ -497,9 +542,8 @@ Threat model, rationale and every known gap:
|
|
|
497
542
|
| `twsrt edit [srt\|bash] [-p P] [-n]` | Open every registered fragment (only profile P's with `-p`) in `$EDITOR`, then report whether targets are stale; `-n` only names them |
|
|
498
543
|
| `twsrt profiles` | Table of every profile with its parents and resolved fragments per source kind; `*` marks `default_profile`, inherited fragments are dimmed, `invalid` marks one that cannot compile on its own |
|
|
499
544
|
| `twsrt show [srt\|bash] [-p P]` | Print the compiled canonical document exactly as `-w` would write it. Writes nothing |
|
|
500
|
-
| `twsrt generate [agent] [-p P]` |
|
|
501
|
-
| `twsrt generate [agent] -w` | Write the canonical outputs (always, whichever agent) and the agent
|
|
502
|
-
| `twsrt generate [agent] -w -n` | Dry run of `-w`: list the paths it would write. `-n` without `-w` changes nothing |
|
|
545
|
+
| `twsrt generate [agent] [-p P]` | Preview: print the agent translation (`claude`, `codex`, `copilot`, default `all`) to stdout and list every file `-w` would write on stderr. Runs the same compile and merge checks as `-w`. Writes nothing |
|
|
546
|
+
| `twsrt generate [agent] -w` | Write those files: the canonical outputs (always, whichever agent) and the agent targets |
|
|
503
547
|
| `twsrt generate [agent] --yolo` | Yolo mode: no ask rules, `*.yolo.*` targets, yolo sandbox overrides |
|
|
504
548
|
| `twsrt generate claude -w -p P --project` | Write profile `P` to `./.twsrt/`; nothing global is written |
|
|
505
549
|
| `twsrt diff [agent] [--yolo] [-p P]` | Compare compiled policy against the files on disk |
|
|
@@ -71,7 +71,10 @@ Three ideas explain the whole tool.
|
|
|
71
71
|
> **The canonical config is the input for every agent translation.**
|
|
72
72
|
> `~/.srt-settings.json` and `bash-rules.json` are the compiled policy of one
|
|
73
73
|
> profile: the single source of truth. SRT reads `~/.srt-settings.json`
|
|
74
|
-
> directly; every agent config is translated from the same compile.
|
|
74
|
+
> directly; every agent config is translated from the same compile. These
|
|
75
|
+
> paths assume `output = "~/.srt-settings.json"`; an omitted `output` writes
|
|
76
|
+
> `srt-settings.json` next to `config.toml`, which srt reads only via
|
|
77
|
+
> `srt -s` ([config.toml](#configtoml)).
|
|
75
78
|
|
|
76
79
|
| | Canonical config | Agent configs |
|
|
77
80
|
|---|---|---|
|
|
@@ -167,9 +170,10 @@ uv tool install twsrt # or: pip install twsrt
|
|
|
167
170
|
|
|
168
171
|
twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
|
|
169
172
|
twsrt edit # opens every fragment: deny paths, domains, command rules
|
|
173
|
+
twsrt config # enable agents: [targets] claude_settings = "~/.claude/settings.full.json"
|
|
170
174
|
|
|
171
|
-
twsrt show # print the compiled canonical
|
|
172
|
-
twsrt generate claude # preview the Claude translation
|
|
175
|
+
twsrt show # print the compiled canonical srt settings
|
|
176
|
+
twsrt generate claude # preview the Claude translation and the files -w would write
|
|
173
177
|
twsrt generate claude -w # write the canonical outputs + ~/.claude/settings.full.json
|
|
174
178
|
twsrt diff # exit 0 when every target matches the fragments
|
|
175
179
|
twsrt test # prove the sandbox enforces the policy (plain terminal)
|
|
@@ -188,6 +192,11 @@ Only `config.toml` and the `.jsonc` fragments are edited by hand. Relative
|
|
|
188
192
|
paths resolve from the directory containing `config.toml`; `~` and absolute
|
|
189
193
|
paths also work. `twsrt config --init` writes a fully commented version.
|
|
190
194
|
|
|
195
|
+
Every compile write-denies `config.toml` and every `[sources]` path (outputs
|
|
196
|
+
and fragments), so a sandboxed agent cannot loosen its own policy: edit them
|
|
197
|
+
from a plain terminal
|
|
198
|
+
([why](SECURITY_CONCEPT.md#34-least-privilege-denyread-implies-denywrite)).
|
|
199
|
+
|
|
191
200
|
| Term | Meaning |
|
|
192
201
|
|---|---|
|
|
193
202
|
| Source kind | A canonical document type: `srt` (filesystem and network policy) and `bash` (command allow/ask/deny lists) |
|
|
@@ -204,14 +213,13 @@ default_profile = "default"
|
|
|
204
213
|
|
|
205
214
|
# --- canonical sources: one compiled output, one or more fragments each ---
|
|
206
215
|
[sources.srt]
|
|
207
|
-
output = "~/.srt-settings.json"
|
|
216
|
+
output = "~/.srt-settings.json" # optional, see below
|
|
208
217
|
[sources.srt.fragments.base]
|
|
209
218
|
path = "srt/base.jsonc"
|
|
210
219
|
[sources.srt.fragments.work]
|
|
211
220
|
path = "srt/work.jsonc"
|
|
212
221
|
|
|
213
|
-
[sources.bash]
|
|
214
|
-
output = "bash-rules.json"
|
|
222
|
+
[sources.bash] # output omitted: bash-rules.json next to config.toml
|
|
215
223
|
[sources.bash.fragments.base]
|
|
216
224
|
path = "bash/base.jsonc"
|
|
217
225
|
|
|
@@ -224,13 +232,14 @@ bash = ["base"]
|
|
|
224
232
|
extends = ["default"]
|
|
225
233
|
srt = ["work"]
|
|
226
234
|
|
|
227
|
-
# --- targets ---
|
|
235
|
+
# --- targets: agents are opt-in; an unset key means "agent not configured" ---
|
|
228
236
|
[targets]
|
|
229
237
|
claude_settings = "~/.claude/settings.full.json" # must not be settings.json (symlink anchor)
|
|
230
238
|
codex_config = "~/.codex/config.toml"
|
|
231
|
-
codex_rules = "~/.codex/rules/twsrt.rules" # optional
|
|
232
|
-
copilot_output = "~/.config/twsrt/copilot-flags.txt"
|
|
233
|
-
# claude_settings_yolo / copilot_output_yolo: optional
|
|
239
|
+
codex_rules = "~/.codex/rules/twsrt.rules" # optional, needs codex_config: escalation rules
|
|
240
|
+
copilot_output = "~/.config/twsrt/copilot-flags.txt"
|
|
241
|
+
# claude_settings_yolo / copilot_output_yolo: optional, each needs its full-mode key;
|
|
242
|
+
# default inserts ".yolo" before the suffix
|
|
234
243
|
|
|
235
244
|
# --- Claude: keep unmanaged settings in sync between full and yolo files ---
|
|
236
245
|
[claude_sync]
|
|
@@ -246,6 +255,28 @@ allowUnsandboxedCommands = false
|
|
|
246
255
|
enabled = false
|
|
247
256
|
```
|
|
248
257
|
|
|
258
|
+
Only `schema_version`, `default_profile`, both `[sources.*]` kinds and one
|
|
259
|
+
profile are required. `config --init` writes exactly that, plus
|
|
260
|
+
`[sandbox_overrides.yolo]`, and leaves every other key commented out with
|
|
261
|
+
its default value.
|
|
262
|
+
|
|
263
|
+
`output` is optional per source kind and defaults to `srt-settings.json` /
|
|
264
|
+
`bash-rules.json` next to `config.toml`. srt itself reads only
|
|
265
|
+
`~/.srt-settings.json`, and when that file is missing it runs with built-in
|
|
266
|
+
defaults, without any `denyRead`. With the default `output`, launch
|
|
267
|
+
`srt -s <config dir>/srt-settings.json`, or set
|
|
268
|
+
`output = "~/.srt-settings.json"` so a bare `srt` picks up the policy.
|
|
269
|
+
|
|
270
|
+
An agent is configured only when its `[targets]` key is set. `generate` and
|
|
271
|
+
`diff` treat every agent the same way:
|
|
272
|
+
|
|
273
|
+
| Agent argument | Agent configured | Agent not configured |
|
|
274
|
+
|---|---|---|
|
|
275
|
+
| `all` (default) | previewed / written / diffed | skipped, with a note on stderr |
|
|
276
|
+
| named, e.g. `codex` | previewed / written / diffed | error, exit 1, no output |
|
|
277
|
+
|
|
278
|
+
If no agent is configured, `generate -w` writes only the canonical outputs.
|
|
279
|
+
|
|
249
280
|
### Fragments
|
|
250
281
|
|
|
251
282
|
SRT fragments follow the
|
|
@@ -313,12 +344,13 @@ srt-p() { local p=$1 d; shift; d=$(twsrt generate claude -w -p "$p" --project
|
|
|
313
344
|
|
|
314
345
|
**What `--project` changes.** Only where outputs land: `./.twsrt/` of the
|
|
315
346
|
current directory (`cd` first). No symlink flip, no `[claude_sync]` donor,
|
|
316
|
-
no global file touched; preview
|
|
347
|
+
no global file touched; the preview works as usual. `all` means
|
|
317
348
|
`claude`; Codex and Copilot are rejected because they read no per-launch
|
|
318
349
|
settings file. Omitting `-p` compiles `default_profile`, the full policy.
|
|
319
350
|
`--project` also adds `./.twsrt` to the compiled `denyWrite`, because Claude
|
|
320
351
|
reloads settings mid-session and an agent able to write them could loosen
|
|
321
|
-
its own policy.
|
|
352
|
+
its own policy. `config.toml`, the fragments and the global outputs stay
|
|
353
|
+
write-denied as in every compile.
|
|
322
354
|
|
|
323
355
|
Evidence, failure directions and how to re-verify after a Claude upgrade:
|
|
324
356
|
[Claude per-project launch premise](doc/REFERENCE.md#claude-per-project-launch-premise).
|
|
@@ -342,10 +374,20 @@ Rule-by-rule translation for all three:
|
|
|
342
374
|
|
|
343
375
|
### Claude Code
|
|
344
376
|
|
|
345
|
-
- **Files.**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
377
|
+
- **Files and modes.** Claude Code reads only `~/.claude/settings.json`.
|
|
378
|
+
twsrt writes one file per mode, `settings.full.json` or (with `--yolo`)
|
|
379
|
+
`settings.yolo.json`, and turns `settings.json` into a symlink to it:
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
settings.json ──► settings.full.json after generate -w claude
|
|
383
|
+
──► settings.yolo.json after generate --yolo -w claude
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
The last `-w` decides which mode Claude starts in. A regular
|
|
387
|
+
`settings.json` found on the first `-w` is moved to the target; both
|
|
388
|
+
existing at once is an error. Runtime changes Claude makes land in the
|
|
389
|
+
linked file; `[claude_sync]` carries them to the other mode.
|
|
390
|
+
[How the link works](doc/REFERENCE.md#claude-settings-symlink).
|
|
349
391
|
- **Selective merge.** `-w` replaces only what twsrt owns:
|
|
350
392
|
`permissions.deny`/`ask`, the `WebFetch(domain:…)` allows, and the
|
|
351
393
|
`sandbox` keys SRT defines. Hooks, plugins, model, other allows and
|
|
@@ -395,7 +437,8 @@ is preserved. Restart Codex after generation.
|
|
|
395
437
|
### Copilot CLI
|
|
396
438
|
|
|
397
439
|
twsrt does not manage Copilot's `~/.copilot/settings.json`; it emits a flag
|
|
398
|
-
snippet for the launch command (
|
|
440
|
+
snippet for the launch command (written to `copilot_output`; preview it with
|
|
441
|
+
`twsrt generate copilot`). Nothing kernel-guards Copilot's
|
|
399
442
|
tools, so run it under the SRT wrapper, which enforces the paths and domains:
|
|
400
443
|
|
|
401
444
|
```bash
|
|
@@ -470,6 +513,8 @@ What to know:
|
|
|
470
513
|
| Built-in tools (Read, Edit, WebFetch) run inside the agent process | Only the agent's own permission engine guards them, best-effort | Kernel-protect the highest-value secrets via `denyRead` |
|
|
471
514
|
| macOS: srt keeps a symlinked deny path unresolved | `denyRead: ["~/.aws"]` blocks nothing when `~/.aws` is a symlink | Deny the real path too; `twsrt test` reports it as a `(realpath)` `FAIL` |
|
|
472
515
|
| srt's `denyRead` is no write deny | A read-denied file inside a write root could be overwritten | twsrt compiles every `denyRead` into `denyWrite` ([ADR 0001](doc/adr/0001-deny-read-implies-deny-write.md)) |
|
|
516
|
+
| A write root covers the twsrt config (agent launched in a dotfiles repo) | The agent could loosen the policy it runs under | twsrt write-denies `config.toml` and every `[sources]` path in every compile ([ADR 0008](doc/adr/0008-policy-files-are-write-denied.md)) |
|
|
517
|
+
| srt anchors relative paths and `**/x` at its launch cwd | `"**/.env"` protects nothing outside the launch directory | Use `~/` or absolute prefixes for paths that must hold everywhere |
|
|
473
518
|
| Codex `sandbox_mode` in another config layer | The twsrt profile is silently ignored | `codex doctor` after changing Codex config |
|
|
474
519
|
|
|
475
520
|
Threat model, rationale and every known gap:
|
|
@@ -483,9 +528,8 @@ Threat model, rationale and every known gap:
|
|
|
483
528
|
| `twsrt edit [srt\|bash] [-p P] [-n]` | Open every registered fragment (only profile P's with `-p`) in `$EDITOR`, then report whether targets are stale; `-n` only names them |
|
|
484
529
|
| `twsrt profiles` | Table of every profile with its parents and resolved fragments per source kind; `*` marks `default_profile`, inherited fragments are dimmed, `invalid` marks one that cannot compile on its own |
|
|
485
530
|
| `twsrt show [srt\|bash] [-p P]` | Print the compiled canonical document exactly as `-w` would write it. Writes nothing |
|
|
486
|
-
| `twsrt generate [agent] [-p P]` |
|
|
487
|
-
| `twsrt generate [agent] -w` | Write the canonical outputs (always, whichever agent) and the agent
|
|
488
|
-
| `twsrt generate [agent] -w -n` | Dry run of `-w`: list the paths it would write. `-n` without `-w` changes nothing |
|
|
531
|
+
| `twsrt generate [agent] [-p P]` | Preview: print the agent translation (`claude`, `codex`, `copilot`, default `all`) to stdout and list every file `-w` would write on stderr. Runs the same compile and merge checks as `-w`. Writes nothing |
|
|
532
|
+
| `twsrt generate [agent] -w` | Write those files: the canonical outputs (always, whichever agent) and the agent targets |
|
|
489
533
|
| `twsrt generate [agent] --yolo` | Yolo mode: no ask rules, `*.yolo.*` targets, yolo sandbox overrides |
|
|
490
534
|
| `twsrt generate claude -w -p P --project` | Write profile `P` to `./.twsrt/`; nothing global is written |
|
|
491
535
|
| `twsrt diff [agent] [--yolo] [-p P]` | Compare compiled policy against the files on disk |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "twsrt"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.2.0"
|
|
4
4
|
description = "Agent security configuration generator — translates canonical security rules into agent-specific configs"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "BSD-3-Clause"
|
|
@@ -45,11 +45,15 @@ dev = [
|
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
[tool.bumpversion]
|
|
48
|
-
current_version = "
|
|
48
|
+
current_version = "3.2.0"
|
|
49
49
|
commit = true
|
|
50
50
|
tag = false
|
|
51
51
|
tag_name = "v{new_version}"
|
|
52
52
|
message = "Bump version to {new_version}"
|
|
53
|
+
# uv.lock records this package's own version: relock and stage it before the
|
|
54
|
+
# bump commit, so the tagged commit is in sync and the next `uv run` leaves
|
|
55
|
+
# the tree clean.
|
|
56
|
+
pre_commit_hooks = ["uv lock", "git add uv.lock"]
|
|
53
57
|
|
|
54
58
|
[tool.bumpversion.file_patterns]
|
|
55
59
|
"src/twsrt/bin/cli.py" = [
|