cfgit 0.1.3__tar.gz → 0.3.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.
- {cfgit-0.1.3 → cfgit-0.3.0}/PKG-INFO +72 -6
- {cfgit-0.1.3 → cfgit-0.3.0}/README.md +71 -5
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/USAGE.md +99 -7
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/pyproject.toml +2 -2
- {cfgit-0.1.3 → cfgit-0.3.0}/pyproject.toml +1 -1
- {cfgit-0.1.3 → cfgit-0.3.0}/skills/cfgit/SKILL.md +16 -2
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/cli/main.py +257 -19
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/config.py +12 -1
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/engine.py +148 -1
- cfgit-0.3.0/src/cfg/core/remedy.py +278 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/interfaces/actions.py +323 -14
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/mcp/server.py +69 -5
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/ui/server.py +29 -2
- cfgit-0.3.0/tests/test_awareness.py +57 -0
- cfgit-0.3.0/tests/test_commit_dry_run.py +59 -0
- cfgit-0.3.0/tests/test_config_discovery.py +74 -0
- cfgit-0.3.0/tests/test_export_import.py +214 -0
- cfgit-0.3.0/tests/test_output_mode.py +31 -0
- cfgit-0.3.0/tests/test_remedy.py +113 -0
- cfgit-0.3.0/tests/test_set_fields.py +109 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_ui_server.py +10 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/.github/workflows/ci.yml +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/.github/workflows/publish.yml +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/.gitignore +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/CONTRIBUTING.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/CREDITS.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/LICENSE +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/NOTICE +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/SECURITY.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/ADAPTERS.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/AGENTS.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/BRANCHING_PLAN.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/CONFIGURATION.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/IDENTITY_AND_ATTRIBUTION.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/PUBLISHING.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/README.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/SPEC.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/SPEC_CORE.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/screenshots/01-diff.png +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/screenshots/02-impact.png +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/docs/screenshots/03-scoped-impact.png +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/examples/.cfg.toml +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/examples/cfgit-support-demo.toml +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/examples/seed_support_demo.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/README.md +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/overview.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/base.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/claude.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/factory.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/gemini.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/plugins/cfg_impact/cfg_impact/providers/openai_provider.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/adapters/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/adapters/base.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/adapters/mongo.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/adapters/postgres.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/approval/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/approval/base.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/cli/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/authz.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/diff.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/hashing.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/core/identity.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/interfaces/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/mcp/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/src/cfg/ui/__init__.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_adapter_contract_live.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_authz.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_config.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_console_script.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_core_purity.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_engine_safety.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_hashing.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_identity.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_impact_boundary.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_mcp_identity.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_mongo_history.py +0 -0
- {cfgit-0.1.3 → cfgit-0.3.0}/tests/test_postgres_history.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cfgit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Git-style history, diff, drift detection, and rollback for live database records without migrating or owning your datastore
|
|
5
5
|
Project-URL: Homepage, https://github.com/AusafMo/cfgit
|
|
6
6
|
Project-URL: Repository, https://github.com/AusafMo/cfgit
|
|
@@ -436,7 +436,10 @@ cfg status
|
|
|
436
436
|
`cfg doctor` is read-only. Run it before the first import for a new database or
|
|
437
437
|
`.cfg.toml`; it reports secret-deny matches, large fields, and live-rule/key
|
|
438
438
|
issues in one pass, with paste-ready `secret_fields` and `ignore_fields`
|
|
439
|
-
suggestions.
|
|
439
|
+
suggestions. `cfg doctor --status` prints a "where am I" header: the resolved config
|
|
440
|
+
file, env, target database, identity mode and whether it is verified, store reachability,
|
|
441
|
+
and how many records are tracked or drifted — plus a warning if a `needs_approval`
|
|
442
|
+
environment is still in `open` identity mode (writes would succeed unaudited).
|
|
440
443
|
|
|
441
444
|
Check drift:
|
|
442
445
|
|
|
@@ -445,10 +448,24 @@ cfg status
|
|
|
445
448
|
cfg diff agent_configs:agent_planner =HEAD =live
|
|
446
449
|
```
|
|
447
450
|
|
|
448
|
-
|
|
451
|
+
Edit a few fields in place (the fast path — no temp file). `cfg set` fetches the live
|
|
452
|
+
document and commits the change through the same drift-guarded path as `cfg commit`, so
|
|
453
|
+
it refuses on out-of-band drift rather than clobbering it:
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
cfg set modelgarden_models:openai/gpt-4o-mini enabled=true retry.max=3 -m "enable + retry"
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
Values are JSON-coerced (`enabled=true` → bool, `n=5` → int, `tags=["a","b"]` → list);
|
|
460
|
+
prefix with `str:` to force a string (`version=str:1.0`). Use `cfg edit <record>` to hand-edit
|
|
461
|
+
the whole document in `$EDITOR`.
|
|
462
|
+
|
|
463
|
+
Commit a full JSON document (add `--dry-run` to preview the field-level delta and exit
|
|
464
|
+
without writing):
|
|
449
465
|
|
|
450
466
|
```bash
|
|
451
467
|
cfg commit agent_configs:agent_planner --from planner.json -m "tune planner routing"
|
|
468
|
+
cfg commit agent_configs:agent_planner --from planner.json --dry-run
|
|
452
469
|
```
|
|
453
470
|
|
|
454
471
|
Commit multiple records as one batch intent:
|
|
@@ -462,11 +479,34 @@ Commit multiple records as one batch intent:
|
|
|
462
479
|
|
|
463
480
|
```bash
|
|
464
481
|
cfg commit --bulk-from batch.json -m "switch planner routing"
|
|
482
|
+
cfg commit --bulk-from batch.json --dry-run # preview every record's delta, write nothing
|
|
465
483
|
```
|
|
466
484
|
|
|
467
485
|
Bulk commit preflights the whole batch before writing. If any target has
|
|
468
486
|
un-adopted drift, is missing, duplicates another target, or trips the secret
|
|
469
|
-
policy, cfgit applies none of the batch.
|
|
487
|
+
policy, cfgit applies none of the batch. `--dry-run` previews the per-record delta
|
|
488
|
+
(`would_commit` / `noop` / `changed_outside_cfgit`) for the whole batch without writing —
|
|
489
|
+
run it before any collection-scale replace.
|
|
490
|
+
|
|
491
|
+
### Snapshot and restore a whole collection
|
|
492
|
+
|
|
493
|
+
For "back it up, replace many rows, roll the whole thing back," `cfg export` writes a portable,
|
|
494
|
+
re-importable snapshot of the current live documents (each stamped with its cfgit head seq/oid),
|
|
495
|
+
and `cfg import --from` writes those documents back through the drift-guarded bulk-commit path —
|
|
496
|
+
so the restore is recorded in history like any other change:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
cfg export --out backup.json # snapshot every collection to a file
|
|
500
|
+
cfg export modelgarden_models:openai/gpt-4o-mini # or one record, to stdout
|
|
501
|
+
# ... do a risky bulk change ...
|
|
502
|
+
cfg import --from backup.json --dry-run # preview the restore
|
|
503
|
+
cfg import --from backup.json -m "restore from backup"
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
This is the file-based backup artifact (portable, out-of-tool, diffable). For an in-tool
|
|
507
|
+
rollback with no file, use `cfg tag` + `cfg restore --tag` / `cfg restore --as-of <date>`, which
|
|
508
|
+
version the whole system inside cfgit. Both record the restore in history; export/import also
|
|
509
|
+
gives you a standalone file to keep or share.
|
|
470
510
|
|
|
471
511
|
Draft changes on a branch before mutating runtime:
|
|
472
512
|
|
|
@@ -538,12 +578,19 @@ Common commands:
|
|
|
538
578
|
```bash
|
|
539
579
|
cfg init
|
|
540
580
|
cfg doctor [record]
|
|
581
|
+
cfg doctor --status
|
|
541
582
|
cfg import --all -m "initial import"
|
|
583
|
+
cfg export [record] [--out file.json]
|
|
584
|
+
cfg import --from <export.json> [--dry-run] -m "message"
|
|
542
585
|
cfg status [record]
|
|
543
586
|
cfg diff <record> [from] [to]
|
|
544
587
|
cfg impact <record> [from] [to]
|
|
545
588
|
cfg commit <record> --from <file.json> -m "message"
|
|
589
|
+
cfg commit <record> --from <file.json> --dry-run
|
|
546
590
|
cfg commit --bulk-from <batch.json> -m "message"
|
|
591
|
+
cfg commit --bulk-from <batch.json> --dry-run
|
|
592
|
+
cfg set <record> field=value nested.field=value -m "message"
|
|
593
|
+
cfg edit <record> -m "message"
|
|
547
594
|
cfg branch list
|
|
548
595
|
cfg branch create <name> --from main
|
|
549
596
|
cfg branch delete <name>
|
|
@@ -570,7 +617,17 @@ cfg whoami
|
|
|
570
617
|
cfg ui
|
|
571
618
|
```
|
|
572
619
|
|
|
573
|
-
Every command supports `--json` for scripts and agents.
|
|
620
|
+
Every command supports `--json` for scripts and agents. By default output is human-readable
|
|
621
|
+
when stdout is a terminal and JSON when piped or redirected; set `CFG_OUTPUT=json|human|auto`
|
|
622
|
+
to control this, and `--json` always forces JSON.
|
|
623
|
+
|
|
624
|
+
Every refusal and terminal outcome also carries a `next` block — a plain-language reason plus
|
|
625
|
+
the exact next command(s) to run. On the CLI it prints to stderr; over `--json`/MCP it is a
|
|
626
|
+
structured `next` field so agents can act on `next.commands` directly.
|
|
627
|
+
|
|
628
|
+
Environment defaults: `CFG_ENV` (default env), `CFG_CONFIG` (config file path), and
|
|
629
|
+
`CFG_AUTHOR` (author) let you set a session once instead of repeating flags. cfgit also
|
|
630
|
+
discovers `.cfg.toml` by walking up from the current directory.
|
|
574
631
|
|
|
575
632
|
Refs:
|
|
576
633
|
|
|
@@ -646,10 +703,17 @@ The MCP server exposes the same operations with a uniform envelope:
|
|
|
646
703
|
"status": "ok",
|
|
647
704
|
"code": 0,
|
|
648
705
|
"message": "",
|
|
649
|
-
"data": {}
|
|
706
|
+
"data": {},
|
|
707
|
+
"state": null,
|
|
708
|
+
"next": null
|
|
650
709
|
}
|
|
651
710
|
```
|
|
652
711
|
|
|
712
|
+
`state` echoes the outcome's terminal state (for example `changed_outside_cfgit`), and `next`
|
|
713
|
+
carries a self-teaching remedy — `{why, remedy, commands, docs}` — when the outcome needs one
|
|
714
|
+
(a refusal, drift, a blocked batch, an identity/permission failure). Agents should branch on
|
|
715
|
+
`state` and follow `next.commands`; both are `null` on a clean success.
|
|
716
|
+
|
|
653
717
|
Tools include:
|
|
654
718
|
|
|
655
719
|
- `cfg_status`
|
|
@@ -658,6 +722,8 @@ Tools include:
|
|
|
658
722
|
- `cfg_impact`
|
|
659
723
|
- `cfg_commit`
|
|
660
724
|
- `cfg_bulk_commit`
|
|
725
|
+
- `cfg_set`
|
|
726
|
+
- `cfg_export`
|
|
661
727
|
- `cfg_branch_list`
|
|
662
728
|
- `cfg_branch_create`
|
|
663
729
|
- `cfg_branch_delete`
|
|
@@ -203,7 +203,10 @@ cfg status
|
|
|
203
203
|
`cfg doctor` is read-only. Run it before the first import for a new database or
|
|
204
204
|
`.cfg.toml`; it reports secret-deny matches, large fields, and live-rule/key
|
|
205
205
|
issues in one pass, with paste-ready `secret_fields` and `ignore_fields`
|
|
206
|
-
suggestions.
|
|
206
|
+
suggestions. `cfg doctor --status` prints a "where am I" header: the resolved config
|
|
207
|
+
file, env, target database, identity mode and whether it is verified, store reachability,
|
|
208
|
+
and how many records are tracked or drifted — plus a warning if a `needs_approval`
|
|
209
|
+
environment is still in `open` identity mode (writes would succeed unaudited).
|
|
207
210
|
|
|
208
211
|
Check drift:
|
|
209
212
|
|
|
@@ -212,10 +215,24 @@ cfg status
|
|
|
212
215
|
cfg diff agent_configs:agent_planner =HEAD =live
|
|
213
216
|
```
|
|
214
217
|
|
|
215
|
-
|
|
218
|
+
Edit a few fields in place (the fast path — no temp file). `cfg set` fetches the live
|
|
219
|
+
document and commits the change through the same drift-guarded path as `cfg commit`, so
|
|
220
|
+
it refuses on out-of-band drift rather than clobbering it:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
cfg set modelgarden_models:openai/gpt-4o-mini enabled=true retry.max=3 -m "enable + retry"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Values are JSON-coerced (`enabled=true` → bool, `n=5` → int, `tags=["a","b"]` → list);
|
|
227
|
+
prefix with `str:` to force a string (`version=str:1.0`). Use `cfg edit <record>` to hand-edit
|
|
228
|
+
the whole document in `$EDITOR`.
|
|
229
|
+
|
|
230
|
+
Commit a full JSON document (add `--dry-run` to preview the field-level delta and exit
|
|
231
|
+
without writing):
|
|
216
232
|
|
|
217
233
|
```bash
|
|
218
234
|
cfg commit agent_configs:agent_planner --from planner.json -m "tune planner routing"
|
|
235
|
+
cfg commit agent_configs:agent_planner --from planner.json --dry-run
|
|
219
236
|
```
|
|
220
237
|
|
|
221
238
|
Commit multiple records as one batch intent:
|
|
@@ -229,11 +246,34 @@ Commit multiple records as one batch intent:
|
|
|
229
246
|
|
|
230
247
|
```bash
|
|
231
248
|
cfg commit --bulk-from batch.json -m "switch planner routing"
|
|
249
|
+
cfg commit --bulk-from batch.json --dry-run # preview every record's delta, write nothing
|
|
232
250
|
```
|
|
233
251
|
|
|
234
252
|
Bulk commit preflights the whole batch before writing. If any target has
|
|
235
253
|
un-adopted drift, is missing, duplicates another target, or trips the secret
|
|
236
|
-
policy, cfgit applies none of the batch.
|
|
254
|
+
policy, cfgit applies none of the batch. `--dry-run` previews the per-record delta
|
|
255
|
+
(`would_commit` / `noop` / `changed_outside_cfgit`) for the whole batch without writing —
|
|
256
|
+
run it before any collection-scale replace.
|
|
257
|
+
|
|
258
|
+
### Snapshot and restore a whole collection
|
|
259
|
+
|
|
260
|
+
For "back it up, replace many rows, roll the whole thing back," `cfg export` writes a portable,
|
|
261
|
+
re-importable snapshot of the current live documents (each stamped with its cfgit head seq/oid),
|
|
262
|
+
and `cfg import --from` writes those documents back through the drift-guarded bulk-commit path —
|
|
263
|
+
so the restore is recorded in history like any other change:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
cfg export --out backup.json # snapshot every collection to a file
|
|
267
|
+
cfg export modelgarden_models:openai/gpt-4o-mini # or one record, to stdout
|
|
268
|
+
# ... do a risky bulk change ...
|
|
269
|
+
cfg import --from backup.json --dry-run # preview the restore
|
|
270
|
+
cfg import --from backup.json -m "restore from backup"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
This is the file-based backup artifact (portable, out-of-tool, diffable). For an in-tool
|
|
274
|
+
rollback with no file, use `cfg tag` + `cfg restore --tag` / `cfg restore --as-of <date>`, which
|
|
275
|
+
version the whole system inside cfgit. Both record the restore in history; export/import also
|
|
276
|
+
gives you a standalone file to keep or share.
|
|
237
277
|
|
|
238
278
|
Draft changes on a branch before mutating runtime:
|
|
239
279
|
|
|
@@ -305,12 +345,19 @@ Common commands:
|
|
|
305
345
|
```bash
|
|
306
346
|
cfg init
|
|
307
347
|
cfg doctor [record]
|
|
348
|
+
cfg doctor --status
|
|
308
349
|
cfg import --all -m "initial import"
|
|
350
|
+
cfg export [record] [--out file.json]
|
|
351
|
+
cfg import --from <export.json> [--dry-run] -m "message"
|
|
309
352
|
cfg status [record]
|
|
310
353
|
cfg diff <record> [from] [to]
|
|
311
354
|
cfg impact <record> [from] [to]
|
|
312
355
|
cfg commit <record> --from <file.json> -m "message"
|
|
356
|
+
cfg commit <record> --from <file.json> --dry-run
|
|
313
357
|
cfg commit --bulk-from <batch.json> -m "message"
|
|
358
|
+
cfg commit --bulk-from <batch.json> --dry-run
|
|
359
|
+
cfg set <record> field=value nested.field=value -m "message"
|
|
360
|
+
cfg edit <record> -m "message"
|
|
314
361
|
cfg branch list
|
|
315
362
|
cfg branch create <name> --from main
|
|
316
363
|
cfg branch delete <name>
|
|
@@ -337,7 +384,17 @@ cfg whoami
|
|
|
337
384
|
cfg ui
|
|
338
385
|
```
|
|
339
386
|
|
|
340
|
-
Every command supports `--json` for scripts and agents.
|
|
387
|
+
Every command supports `--json` for scripts and agents. By default output is human-readable
|
|
388
|
+
when stdout is a terminal and JSON when piped or redirected; set `CFG_OUTPUT=json|human|auto`
|
|
389
|
+
to control this, and `--json` always forces JSON.
|
|
390
|
+
|
|
391
|
+
Every refusal and terminal outcome also carries a `next` block — a plain-language reason plus
|
|
392
|
+
the exact next command(s) to run. On the CLI it prints to stderr; over `--json`/MCP it is a
|
|
393
|
+
structured `next` field so agents can act on `next.commands` directly.
|
|
394
|
+
|
|
395
|
+
Environment defaults: `CFG_ENV` (default env), `CFG_CONFIG` (config file path), and
|
|
396
|
+
`CFG_AUTHOR` (author) let you set a session once instead of repeating flags. cfgit also
|
|
397
|
+
discovers `.cfg.toml` by walking up from the current directory.
|
|
341
398
|
|
|
342
399
|
Refs:
|
|
343
400
|
|
|
@@ -413,10 +470,17 @@ The MCP server exposes the same operations with a uniform envelope:
|
|
|
413
470
|
"status": "ok",
|
|
414
471
|
"code": 0,
|
|
415
472
|
"message": "",
|
|
416
|
-
"data": {}
|
|
473
|
+
"data": {},
|
|
474
|
+
"state": null,
|
|
475
|
+
"next": null
|
|
417
476
|
}
|
|
418
477
|
```
|
|
419
478
|
|
|
479
|
+
`state` echoes the outcome's terminal state (for example `changed_outside_cfgit`), and `next`
|
|
480
|
+
carries a self-teaching remedy — `{why, remedy, commands, docs}` — when the outcome needs one
|
|
481
|
+
(a refusal, drift, a blocked batch, an identity/permission failure). Agents should branch on
|
|
482
|
+
`state` and follow `next.commands`; both are `null` on a clean success.
|
|
483
|
+
|
|
420
484
|
Tools include:
|
|
421
485
|
|
|
422
486
|
- `cfg_status`
|
|
@@ -425,6 +489,8 @@ Tools include:
|
|
|
425
489
|
- `cfg_impact`
|
|
426
490
|
- `cfg_commit`
|
|
427
491
|
- `cfg_bulk_commit`
|
|
492
|
+
- `cfg_set`
|
|
493
|
+
- `cfg_export`
|
|
428
494
|
- `cfg_branch_list`
|
|
429
495
|
- `cfg_branch_create`
|
|
430
496
|
- `cfg_branch_delete`
|
|
@@ -109,7 +109,39 @@ cfg commit --bulk-from batch.json -m "switch planner routing"
|
|
|
109
109
|
|
|
110
110
|
Bulk commit preflights every target before writing. If any record has un-adopted
|
|
111
111
|
drift, is missing, duplicates another target, or trips the secret policy, no
|
|
112
|
-
record in the batch is applied.
|
|
112
|
+
record in the batch is applied. Add `--dry-run` to preview the per-record delta for the whole
|
|
113
|
+
batch (`would_commit` / `noop` / `changed_outside_cfgit`) without writing — run it before any
|
|
114
|
+
collection-scale replace:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cfg commit --bulk-from batch.json --dry-run
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Snapshot and restore a collection
|
|
121
|
+
|
|
122
|
+
`cfg export` writes a portable, re-importable snapshot of the current live documents, each
|
|
123
|
+
stamped with its cfgit head seq/oid. `cfg import --from` writes those documents back through the
|
|
124
|
+
drift-guarded bulk-commit path, so the restore is recorded in history like any other change.
|
|
125
|
+
Together they make "back it up, do the bulk change, roll it back" a fully in-cfgit workflow:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
cfg export --out backup.json # snapshot every collection to a file
|
|
129
|
+
cfg export modelgarden_models:openai/gpt-4o-mini # or one record, to stdout
|
|
130
|
+
# ... risky bulk change ...
|
|
131
|
+
cfg import --from backup.json --dry-run # preview the restore
|
|
132
|
+
cfg import --from backup.json -m "restore from backup"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
For an in-tool rollback without a file, use `cfg tag` + `cfg restore --tag` (or
|
|
136
|
+
`cfg restore --as-of <date>`) instead — see [Tags](#tags) and [Restore](#restore). Both record
|
|
137
|
+
the restore in history; export/import additionally gives you a standalone file to keep or share.
|
|
138
|
+
|
|
139
|
+
`cfg export` warns (without stopping) when a snapshot is large by control-plane standards — a
|
|
140
|
+
strong hint that the config points at a data-plane collection (events, user content, jobs),
|
|
141
|
+
which cfgit is not designed to version. If you cancel an `import --from` partway, cfgit reports
|
|
142
|
+
`partial` with `cancelled: true` listing what committed and what is still pending; each record
|
|
143
|
+
is applied atomically, so rerunning the same command resumes (already-applied records are
|
|
144
|
+
no-ops).
|
|
113
145
|
|
|
114
146
|
If the live record changed after cfgit last recorded it, commit returns
|
|
115
147
|
`changed_outside_cfgit` and does not apply your document. Inspect the drift first:
|
|
@@ -125,6 +157,48 @@ secret-shaped fields and values from `[secrets]`. Fields in `secret_fields` are
|
|
|
125
157
|
stripped before history. Use `--allow-secret` only for intentional fixtures or
|
|
126
158
|
false positives; cfgit records that override in history metadata.
|
|
127
159
|
|
|
160
|
+
## Preview a commit
|
|
161
|
+
|
|
162
|
+
Add `--dry-run` to a single-record commit to see the exact field-level delta versus the live
|
|
163
|
+
record and exit without writing. It returns `would_commit` with the changes, or the same
|
|
164
|
+
`changed_outside_cfgit` / `noop` a real commit would, and still runs the secret policy so a
|
|
165
|
+
blocked secret surfaces before you write:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
cfg commit agent_configs:agent_planner --from planner.json --dry-run
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Fast field edits (set / edit)
|
|
172
|
+
|
|
173
|
+
For a few scalar fields you do not need a full document or a temp file. `cfg set` fetches the
|
|
174
|
+
live document, applies your changes, and commits through the same path as `cfg commit` — so it
|
|
175
|
+
still refuses on out-of-band drift instead of clobbering it (it is not a raw write):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cfg set modelgarden_models:openai/gpt-4o-mini enabled=true retry.max=3 -m "enable + retry"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Paths are dotted, with list indices as `tags[0]`. Values are JSON-coerced — `enabled=true`
|
|
182
|
+
becomes a boolean, `n=5` an integer, `tags=["a","b"]` a list — and a `str:` prefix forces a
|
|
183
|
+
string (`version=str:1.0`). Add `--dry-run` to preview. To hand-edit the whole document in your
|
|
184
|
+
`$EDITOR` instead, use `cfg edit <record> -m "message"`.
|
|
185
|
+
|
|
186
|
+
## Situational awareness
|
|
187
|
+
|
|
188
|
+
`cfg doctor --status` prints a one-look header of where you are pointed: resolved config file,
|
|
189
|
+
env, target database, identity mode and whether it is verified, store reachability, and the
|
|
190
|
+
number of tracked and drifted records. If a `needs_approval` environment is still in `open`
|
|
191
|
+
identity mode — so writes would succeed unaudited — it prints a warning with the fix. That same
|
|
192
|
+
warning also prints on any mutating command against such an environment; suppress it in scripts
|
|
193
|
+
with `CFG_WARN_OPEN_MODE=0`.
|
|
194
|
+
|
|
195
|
+
## Guidance on every outcome
|
|
196
|
+
|
|
197
|
+
Every refusal and terminal outcome carries a `next` block: a plain-language reason plus the
|
|
198
|
+
exact next command(s) to run (for drift, that is `cfg diff` then `cfg adopt`). On the CLI it
|
|
199
|
+
prints to stderr; over `--json` and MCP it is a structured `next` field, so agents can follow
|
|
200
|
+
`next.commands` without guessing.
|
|
201
|
+
|
|
128
202
|
## Branches and PRs
|
|
129
203
|
|
|
130
204
|
Branching is opt-in:
|
|
@@ -274,14 +348,32 @@ shows recent activity across all configured records: current live drift plus the
|
|
|
274
348
|
latest cfgit history entries. Selecting one of those entries opens that record's
|
|
275
349
|
normal history and diff view.
|
|
276
350
|
|
|
277
|
-
##
|
|
351
|
+
## Output mode
|
|
352
|
+
|
|
353
|
+
By default output is human-readable when stdout is a terminal and JSON when piped or
|
|
354
|
+
redirected, so interactive use reads well while pipelines stay parseable. Control it with
|
|
355
|
+
`CFG_OUTPUT`:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
cfg status # human on a TTY, JSON when piped
|
|
359
|
+
cfg --json status # always JSON
|
|
360
|
+
CFG_OUTPUT=json cfg status # always JSON
|
|
361
|
+
CFG_OUTPUT=human cfg status # always human
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
`--json` and `CFG_OUTPUT=json` always force JSON. Agents and scripts should branch on `status`
|
|
365
|
+
and `state`, not on human-readable text.
|
|
366
|
+
|
|
367
|
+
## Session defaults
|
|
278
368
|
|
|
279
|
-
|
|
369
|
+
To avoid repeating flags, set environment defaults once:
|
|
280
370
|
|
|
281
371
|
```bash
|
|
282
|
-
|
|
283
|
-
cfg
|
|
372
|
+
export CFG_ENV=prod # default for --env
|
|
373
|
+
export CFG_CONFIG=./cfgit/aistudio.cfg.toml # default for --config-file
|
|
374
|
+
export CFG_AUTHOR=you@example.com # default author (open identity mode)
|
|
284
375
|
```
|
|
285
376
|
|
|
286
|
-
|
|
287
|
-
|
|
377
|
+
cfgit also discovers `.cfg.toml` by walking up from the current directory, so you can run it
|
|
378
|
+
from a subdirectory without `--config-file`. Global flags (`--config-file`, `--env`, `--author`,
|
|
379
|
+
`--branch`, `--json`) go before the subcommand: `cfg --env prod status`.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cfgit-impact"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Optional cfgit plugin for deterministic system-impact summaries and opt-in LLM narration of database record diffs"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
license = "Apache-2.0"
|
|
8
8
|
authors = [{ name = "Mohammad Ausaf" }]
|
|
9
9
|
dependencies = [
|
|
10
|
-
"cfgit>=0.
|
|
10
|
+
"cfgit>=0.3.0,<0.4.0",
|
|
11
11
|
"httpx>=0.27",
|
|
12
12
|
]
|
|
13
13
|
|
|
@@ -39,9 +39,21 @@ Use cfgit as the safety layer around a live datastore. The app still reads and w
|
|
|
39
39
|
- If history lookup reports an env mismatch, re-run against the stamped env before making changes.
|
|
40
40
|
|
|
41
41
|
3. Mutate through cfgit.
|
|
42
|
-
-
|
|
42
|
+
- For a few scalar fields, prefer the fast path — no temp file needed:
|
|
43
|
+
`cfg set <record> field=value other.nested=value -m "<message>" --json`.
|
|
44
|
+
Values are JSON-coerced (`enabled=true`, `n=5`, `tags=["a","b"]`); prefix with `str:` to
|
|
45
|
+
force a string (`version=str:1.0`). `cfg set` fetches the LIVE doc and routes through the
|
|
46
|
+
same commit path, so it refuses on drift exactly like `commit` (it is not a raw write).
|
|
47
|
+
Add `--dry-run` to preview the field-level delta without writing.
|
|
48
|
+
- For a hand edit of the whole doc, `cfg edit <record> -m "<message>"` opens it in $EDITOR.
|
|
49
|
+
- For a large or scripted change, write the full target document to a temp JSON file.
|
|
43
50
|
- Run `cfg commit <record> --from <file> -m "<message>" --json`.
|
|
44
|
-
-
|
|
51
|
+
- Preview any commit before writing with `cfg commit <record> --from <file> --dry-run --json`
|
|
52
|
+
(returns `would_commit` with the delta, or `changed_outside_cfgit`/`noop`; writes nothing).
|
|
53
|
+
- Every outcome now carries a top-level `next` block (why + remedy + copy-paste `commands`);
|
|
54
|
+
on a refusal, follow `next.commands` rather than guessing.
|
|
55
|
+
- For a coupled multi-record change, write a batch JSON file and run `cfg commit --bulk-from <file> -m "<message>" --json`. The batch file can be `[{"record":"collection:id","doc":{...}}]` or `{"collection:id": {...}}`. Preview a collection-scale batch first with `cfg commit --bulk-from <file> --dry-run --json` — it reports each record's `would_commit`/`noop`/`changed_outside_cfgit` and writes nothing.
|
|
56
|
+
- Before a risky bulk change, snapshot the current live docs with `cfg export --out backup.json --json` (a portable, re-importable artifact stamped with head seq/oid). To roll back, `cfg import --from backup.json -m "<message>" --json` writes them back through the drift-guarded path (preview with `--dry-run`). For an in-tool rollback with no file, use `cfg tag` + `cfg restore --tag` instead.
|
|
45
57
|
- For a draft branch, use `cfg --branch <branch> commit <record> --from <file> -m "<message>" --json` or `cfg --branch <branch> commit --bulk-from <file> -m "<message>" --json`. This writes cfgit refs only; runtime is unchanged.
|
|
46
58
|
- If commit returns `changed_outside_cfgit`, stop and inspect drift.
|
|
47
59
|
- If bulk commit returns `blocked`, no record was applied; inspect `failed`. If it returns `partial`, some records were applied before a race/failure; inspect `results`, `failed`, and `pending` before continuing.
|
|
@@ -50,6 +62,7 @@ Use cfgit as the safety layer around a live datastore. The app still reads and w
|
|
|
50
62
|
4. Reconcile drift.
|
|
51
63
|
- `cfg diff <record> =HEAD =live --json`
|
|
52
64
|
- `cfg adopt <record> -m "<message>" --json`
|
|
65
|
+
- If `cfg doctor --status` reports a high drift ratio (many records `changed_outside_cfgit`), baseline the whole collection once with `cfg adopt --all -m "<message>" --json` so later edits and restore work without a per-record adopt.
|
|
53
66
|
|
|
54
67
|
5. Restore.
|
|
55
68
|
- Single record: `cfg restore <record> <ref> -m "<message>" --json`
|
|
@@ -74,6 +87,7 @@ If the cfgit MCP server is available, prefer its tools over shelling out:
|
|
|
74
87
|
- `cfg_impact`
|
|
75
88
|
- `cfg_commit`
|
|
76
89
|
- `cfg_bulk_commit`
|
|
90
|
+
- `cfg_export`
|
|
77
91
|
- `cfg_branch_list`
|
|
78
92
|
- `cfg_branch_create`
|
|
79
93
|
- `cfg_branch_delete`
|