cfgit 0.2.0__tar.gz → 0.4.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.2.0 → cfgit-0.4.0}/PKG-INFO +38 -2
- {cfgit-0.2.0 → cfgit-0.4.0}/README.md +37 -1
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/USAGE.md +49 -1
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/pyproject.toml +2 -2
- {cfgit-0.2.0 → cfgit-0.4.0}/pyproject.toml +1 -1
- {cfgit-0.2.0 → cfgit-0.4.0}/skills/cfgit/SKILL.md +11 -3
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/cli/main.py +73 -5
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/engine.py +38 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/remedy.py +1 -1
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/interfaces/actions.py +131 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/mcp/server.py +42 -2
- cfgit-0.4.0/src/cfg/update.py +263 -0
- cfgit-0.4.0/tests/test_export_import.py +214 -0
- cfgit-0.4.0/tests/test_update_check.py +189 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/.github/workflows/ci.yml +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/.github/workflows/publish.yml +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/.gitignore +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/CONTRIBUTING.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/CREDITS.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/LICENSE +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/NOTICE +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/SECURITY.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/ADAPTERS.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/AGENTS.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/BRANCHING_PLAN.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/CONFIGURATION.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/IDENTITY_AND_ATTRIBUTION.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/PUBLISHING.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/README.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/SPEC.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/SPEC_CORE.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/screenshots/01-diff.png +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/screenshots/02-impact.png +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/docs/screenshots/03-scoped-impact.png +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/examples/.cfg.toml +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/examples/cfgit-support-demo.toml +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/examples/seed_support_demo.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/README.md +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/overview.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/base.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/claude.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/factory.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/gemini.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/plugins/cfg_impact/cfg_impact/providers/openai_provider.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/adapters/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/adapters/base.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/adapters/mongo.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/adapters/postgres.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/approval/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/approval/base.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/cli/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/authz.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/config.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/diff.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/hashing.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/core/identity.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/interfaces/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/mcp/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/ui/__init__.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/src/cfg/ui/server.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_adapter_contract_live.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_authz.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_awareness.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_commit_dry_run.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_config.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_config_discovery.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_console_script.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_core_purity.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_engine_safety.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_hashing.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_identity.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_impact_boundary.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_mcp_identity.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_mongo_history.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_output_mode.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_postgres_history.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_remedy.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_set_fields.py +0 -0
- {cfgit-0.2.0 → cfgit-0.4.0}/tests/test_ui_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cfgit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.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
|
|
@@ -479,11 +479,34 @@ Commit multiple records as one batch intent:
|
|
|
479
479
|
|
|
480
480
|
```bash
|
|
481
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
|
|
482
483
|
```
|
|
483
484
|
|
|
484
485
|
Bulk commit preflights the whole batch before writing. If any target has
|
|
485
486
|
un-adopted drift, is missing, duplicates another target, or trips the secret
|
|
486
|
-
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.
|
|
487
510
|
|
|
488
511
|
Draft changes on a branch before mutating runtime:
|
|
489
512
|
|
|
@@ -557,12 +580,15 @@ cfg init
|
|
|
557
580
|
cfg doctor [record]
|
|
558
581
|
cfg doctor --status
|
|
559
582
|
cfg import --all -m "initial import"
|
|
583
|
+
cfg export [record] [--out file.json]
|
|
584
|
+
cfg import --from <export.json> [--dry-run] -m "message"
|
|
560
585
|
cfg status [record]
|
|
561
586
|
cfg diff <record> [from] [to]
|
|
562
587
|
cfg impact <record> [from] [to]
|
|
563
588
|
cfg commit <record> --from <file.json> -m "message"
|
|
564
589
|
cfg commit <record> --from <file.json> --dry-run
|
|
565
590
|
cfg commit --bulk-from <batch.json> -m "message"
|
|
591
|
+
cfg commit --bulk-from <batch.json> --dry-run
|
|
566
592
|
cfg set <record> field=value nested.field=value -m "message"
|
|
567
593
|
cfg edit <record> -m "message"
|
|
568
594
|
cfg branch list
|
|
@@ -588,9 +614,16 @@ cfg restore --as-of <date> --dry-run -m "message"
|
|
|
588
614
|
cfg restore --tag <name> --dry-run -m "message"
|
|
589
615
|
cfg fsck
|
|
590
616
|
cfg whoami
|
|
617
|
+
cfg check-update [--snooze [DAYS]]
|
|
591
618
|
cfg ui
|
|
592
619
|
```
|
|
593
620
|
|
|
621
|
+
cfgit checks PyPI for a newer release on cheap read commands (throttled to once a day) and, for an
|
|
622
|
+
interactive terminal, prints a one-line nudge to stderr with what's new — it never upgrades for
|
|
623
|
+
you (run `pip install -U cfgit`) and never prints on `--json`/piped output. `cfg check-update`
|
|
624
|
+
forces a check; `cfg check-update --snooze 30` silences it for 30 days; `CFGIT_NO_UPDATE_CHECK=1`
|
|
625
|
+
disables it entirely.
|
|
626
|
+
|
|
594
627
|
Every command supports `--json` for scripts and agents. By default output is human-readable
|
|
595
628
|
when stdout is a terminal and JSON when piped or redirected; set `CFG_OUTPUT=json|human|auto`
|
|
596
629
|
to control this, and `--json` always forces JSON.
|
|
@@ -697,6 +730,8 @@ Tools include:
|
|
|
697
730
|
- `cfg_commit`
|
|
698
731
|
- `cfg_bulk_commit`
|
|
699
732
|
- `cfg_set`
|
|
733
|
+
- `cfg_export`
|
|
734
|
+
- `cfg_import`
|
|
700
735
|
- `cfg_branch_list`
|
|
701
736
|
- `cfg_branch_create`
|
|
702
737
|
- `cfg_branch_delete`
|
|
@@ -717,6 +752,7 @@ Tools include:
|
|
|
717
752
|
- `cfg_whoami`
|
|
718
753
|
- `cfg_init`
|
|
719
754
|
- `cfg_identity_hash`
|
|
755
|
+
- `cfg_check_update`
|
|
720
756
|
|
|
721
757
|
A portable skill lives at `skills/cfgit/SKILL.md`.
|
|
722
758
|
`cfg_impact` accepts the same `against` list/string as the CLI `--against` flag,
|
|
@@ -246,11 +246,34 @@ Commit multiple records as one batch intent:
|
|
|
246
246
|
|
|
247
247
|
```bash
|
|
248
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
|
|
249
250
|
```
|
|
250
251
|
|
|
251
252
|
Bulk commit preflights the whole batch before writing. If any target has
|
|
252
253
|
un-adopted drift, is missing, duplicates another target, or trips the secret
|
|
253
|
-
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.
|
|
254
277
|
|
|
255
278
|
Draft changes on a branch before mutating runtime:
|
|
256
279
|
|
|
@@ -324,12 +347,15 @@ cfg init
|
|
|
324
347
|
cfg doctor [record]
|
|
325
348
|
cfg doctor --status
|
|
326
349
|
cfg import --all -m "initial import"
|
|
350
|
+
cfg export [record] [--out file.json]
|
|
351
|
+
cfg import --from <export.json> [--dry-run] -m "message"
|
|
327
352
|
cfg status [record]
|
|
328
353
|
cfg diff <record> [from] [to]
|
|
329
354
|
cfg impact <record> [from] [to]
|
|
330
355
|
cfg commit <record> --from <file.json> -m "message"
|
|
331
356
|
cfg commit <record> --from <file.json> --dry-run
|
|
332
357
|
cfg commit --bulk-from <batch.json> -m "message"
|
|
358
|
+
cfg commit --bulk-from <batch.json> --dry-run
|
|
333
359
|
cfg set <record> field=value nested.field=value -m "message"
|
|
334
360
|
cfg edit <record> -m "message"
|
|
335
361
|
cfg branch list
|
|
@@ -355,9 +381,16 @@ cfg restore --as-of <date> --dry-run -m "message"
|
|
|
355
381
|
cfg restore --tag <name> --dry-run -m "message"
|
|
356
382
|
cfg fsck
|
|
357
383
|
cfg whoami
|
|
384
|
+
cfg check-update [--snooze [DAYS]]
|
|
358
385
|
cfg ui
|
|
359
386
|
```
|
|
360
387
|
|
|
388
|
+
cfgit checks PyPI for a newer release on cheap read commands (throttled to once a day) and, for an
|
|
389
|
+
interactive terminal, prints a one-line nudge to stderr with what's new — it never upgrades for
|
|
390
|
+
you (run `pip install -U cfgit`) and never prints on `--json`/piped output. `cfg check-update`
|
|
391
|
+
forces a check; `cfg check-update --snooze 30` silences it for 30 days; `CFGIT_NO_UPDATE_CHECK=1`
|
|
392
|
+
disables it entirely.
|
|
393
|
+
|
|
361
394
|
Every command supports `--json` for scripts and agents. By default output is human-readable
|
|
362
395
|
when stdout is a terminal and JSON when piped or redirected; set `CFG_OUTPUT=json|human|auto`
|
|
363
396
|
to control this, and `--json` always forces JSON.
|
|
@@ -464,6 +497,8 @@ Tools include:
|
|
|
464
497
|
- `cfg_commit`
|
|
465
498
|
- `cfg_bulk_commit`
|
|
466
499
|
- `cfg_set`
|
|
500
|
+
- `cfg_export`
|
|
501
|
+
- `cfg_import`
|
|
467
502
|
- `cfg_branch_list`
|
|
468
503
|
- `cfg_branch_create`
|
|
469
504
|
- `cfg_branch_delete`
|
|
@@ -484,6 +519,7 @@ Tools include:
|
|
|
484
519
|
- `cfg_whoami`
|
|
485
520
|
- `cfg_init`
|
|
486
521
|
- `cfg_identity_hash`
|
|
522
|
+
- `cfg_check_update`
|
|
487
523
|
|
|
488
524
|
A portable skill lives at `skills/cfgit/SKILL.md`.
|
|
489
525
|
`cfg_impact` accepts the same `against` list/string as the CLI `--against` flag,
|
|
@@ -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:
|
|
@@ -345,3 +377,19 @@ export CFG_AUTHOR=you@example.com # default author (open identity mo
|
|
|
345
377
|
cfgit also discovers `.cfg.toml` by walking up from the current directory, so you can run it
|
|
346
378
|
from a subdirectory without `--config-file`. Global flags (`--config-file`, `--env`, `--author`,
|
|
347
379
|
`--branch`, `--json`) go before the subcommand: `cfg --env prod status`.
|
|
380
|
+
|
|
381
|
+
## Updates
|
|
382
|
+
|
|
383
|
+
cfgit checks PyPI for a newer release on cheap read commands (`status`/`doctor`/`whoami`/`log`),
|
|
384
|
+
throttled to once a day. For an interactive terminal it prints a one-line nudge to stderr with a
|
|
385
|
+
short "what's new" excerpt from the release notes — never on `--json`/piped output, and it never
|
|
386
|
+
upgrades for you:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
cfg check-update # force a check now (shows what's new + the release link)
|
|
390
|
+
cfg check-update --snooze 30 # don't remind me for 30 days
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Set `CFGIT_NO_UPDATE_CHECK=1` to disable the check entirely. Over MCP, the `cfg_check_update` tool
|
|
394
|
+
does the same (pass `snooze_days` to snooze); agents should offer the upgrade but never run it.
|
|
395
|
+
The check is best-effort — if the network is unavailable it stays silent.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cfgit-impact"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.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.4.0,<0.5.0",
|
|
11
11
|
"httpx>=0.27",
|
|
12
12
|
]
|
|
13
13
|
|
|
@@ -13,7 +13,9 @@ Use cfgit as the safety layer around a live datastore. The app still reads and w
|
|
|
13
13
|
- Never use cross-project Mongo URIs for writes. Remote managed Mongo writes are forbidden unless the user explicitly grants a per-turn exception and asks for that exact target.
|
|
14
14
|
- Treat `changed_outside_cfgit` as the central state. Do not commit over it. Run `cfg diff`, explain what changed, then `cfg adopt` if the user wants to fold that live state into history.
|
|
15
15
|
- If `[branches] enabled = true`, draft risky changes on a non-main branch and open a cfgit PR. Branch commits and PR creation do not mutate runtime; `cfg pr merge` is the only branch command that does.
|
|
16
|
-
-
|
|
16
|
+
- At the start of a cfgit session, call `cfg_check_update` (or `cfg check-update --json`). If `data.update_available` is true and `data.snoozed` is false, tell the user the new version, show `data.notes` (what's new), and offer to upgrade (`pip install -U cfgit`) or snooze — call `cfg_check_update` with `snooze_days=30` if they want to be reminded later. NEVER upgrade for them. It is best-effort and silent when there is nothing to say; skip if `data.disabled` (they set `CFGIT_NO_UPDATE_CHECK`).
|
|
17
|
+
- Prefer `--json` for agent parsing. Output is otherwise human-on-a-TTY / JSON-when-piped; `CFG_OUTPUT=json|human|auto` overrides. To avoid repeating flags, `CFG_ENV`, `CFG_CONFIG`, and `CFG_AUTHOR` set session defaults, and cfgit discovers `.cfg.toml` by walking up from the cwd.
|
|
18
|
+
- Run `cfg doctor --status` to confirm where you are pointed (config, env, target db, identity mode + whether verified, reachability, tracked/drift counts) before mutating an unfamiliar env. It warns if a `needs_approval` env is still in `open` identity mode — writes there succeed UNAUDITED; surface that to the user.
|
|
17
19
|
- Use deterministic `cfg impact` first. Add `--llm` only when the user asks for LLM narration and the impact plugin is installed. Use `--against <collection:id>` when the user wants narration scoped to specific related records instead of the whole system.
|
|
18
20
|
- Before the FIRST `cfg import` against a new database or `.cfg.toml`, run `cfg doctor` (read-only). It reports every secret-deny match, oversized field, and key issue at once, with paste-ready `secret_fields`/`ignore_fields` snippets. Fix `.cfg.toml` from its output, then import. This avoids import failing one secret at a time.
|
|
19
21
|
- In `authenticated` or `enforced` identity mode, the process must already have a verified identity source, usually `CFGIT_IDENTITY_TOKEN` or a per-user DB principal. `--author` and MCP `author` are hints only; cfgit rejects them if they do not match the verified identity.
|
|
@@ -52,7 +54,8 @@ Use cfgit as the safety layer around a live datastore. The app still reads and w
|
|
|
52
54
|
(returns `would_commit` with the delta, or `changed_outside_cfgit`/`noop`; writes nothing).
|
|
53
55
|
- Every outcome now carries a top-level `next` block (why + remedy + copy-paste `commands`);
|
|
54
56
|
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": {...}}`.
|
|
57
|
+
- 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.
|
|
58
|
+
- 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). If export prints a size warning, the config may be pointed at a data-plane collection (events/content/jobs) cfgit is not built to version — flag it. To roll back, `cfg import --from backup.json -m "<message>" --json` writes them back through the drift-guarded path (preview with `--dry-run`). If it returns `partial` with `cancelled: true` (the user interrupted), already-applied records are durable and rerunning the same command resumes. For an in-tool rollback with no file, use `cfg tag` + `cfg restore --tag` instead.
|
|
56
59
|
- 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.
|
|
57
60
|
- If commit returns `changed_outside_cfgit`, stop and inspect drift.
|
|
58
61
|
- 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.
|
|
@@ -61,6 +64,7 @@ Use cfgit as the safety layer around a live datastore. The app still reads and w
|
|
|
61
64
|
4. Reconcile drift.
|
|
62
65
|
- `cfg diff <record> =HEAD =live --json`
|
|
63
66
|
- `cfg adopt <record> -m "<message>" --json`
|
|
67
|
+
- 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.
|
|
64
68
|
|
|
65
69
|
5. Restore.
|
|
66
70
|
- Single record: `cfg restore <record> <ref> -m "<message>" --json`
|
|
@@ -85,6 +89,9 @@ If the cfgit MCP server is available, prefer its tools over shelling out:
|
|
|
85
89
|
- `cfg_impact`
|
|
86
90
|
- `cfg_commit`
|
|
87
91
|
- `cfg_bulk_commit`
|
|
92
|
+
- `cfg_set` for a few scalar field edits (routes through the drift-guarded commit path)
|
|
93
|
+
- `cfg_export`
|
|
94
|
+
- `cfg_import` (pass `from_export` to restore a snapshot; `dry_run` to preview)
|
|
88
95
|
- `cfg_branch_list`
|
|
89
96
|
- `cfg_branch_create`
|
|
90
97
|
- `cfg_branch_delete`
|
|
@@ -105,7 +112,8 @@ If the cfgit MCP server is available, prefer its tools over shelling out:
|
|
|
105
112
|
- `cfg_whoami`
|
|
106
113
|
- `cfg_init`
|
|
107
114
|
- `cfg_identity_hash` for setup only. Prefer the local CLI for real tokens because MCP clients may log tool inputs.
|
|
115
|
+
- `cfg_check_update` — check PyPI for a newer cfgit; pass `snooze_days` to snooze. Never upgrades.
|
|
108
116
|
|
|
109
|
-
Every MCP tool returns the same envelope
|
|
117
|
+
Every MCP tool returns the same envelope: `status`, `code`, `message`, `data`, plus top-level `state` and `next`. `state` echoes the outcome's terminal state (e.g. `changed_outside_cfgit`, `noop`, `blocked`, `would_commit`); `next` is a self-teaching remedy `{why, remedy, commands}` when the outcome needs one, else null. Branch on `state` and follow `next.commands` on a refusal instead of guessing.
|
|
110
118
|
For MCP bulk commits, pass `items` as structured JSON (`[{record, doc}]`) when the client supports it; use a JSON string only when the client cannot send nested objects cleanly.
|
|
111
119
|
For MCP history/env mismatches, branch on `status="error"` and `code=6`; surface the `message` to the user and do not continue mutation.
|
|
@@ -68,12 +68,21 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
68
68
|
except ValueError as exc:
|
|
69
69
|
_emit_error("error", str(exc), args)
|
|
70
70
|
return EXIT_ARG
|
|
71
|
+
if args.cmd == "check-update":
|
|
72
|
+
from cfg import update
|
|
73
|
+
|
|
74
|
+
if args.snooze is not None:
|
|
75
|
+
_emit(update.snooze(args.snooze), json_mode=args.json)
|
|
76
|
+
return EXIT_OK
|
|
77
|
+
_emit(update.check(force=True).to_json(), json_mode=args.json)
|
|
78
|
+
return EXIT_OK
|
|
71
79
|
try:
|
|
72
80
|
project = load_config(args.config_file)
|
|
73
81
|
engine = _engine(project, args.env, author=args.author)
|
|
74
82
|
_warn_open_mode(engine, args)
|
|
75
83
|
result, code = _dispatch(engine, args)
|
|
76
84
|
_emit(result, json_mode=args.json, record=getattr(args, "record", None))
|
|
85
|
+
_maybe_update_nudge(args)
|
|
77
86
|
return code
|
|
78
87
|
except AmbiguousConfig as exc:
|
|
79
88
|
_emit_error("bad_config", str(exc), args, exc=exc)
|
|
@@ -145,8 +154,15 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
145
154
|
p_import = sub.add_parser("import")
|
|
146
155
|
p_import.add_argument("record", nargs="?")
|
|
147
156
|
p_import.add_argument("--all", action="store_true")
|
|
157
|
+
p_import.add_argument("--from", dest="from_file",
|
|
158
|
+
help="restore documents from a `cfg export` file (writes via the drift-guarded bulk-commit path)")
|
|
148
159
|
p_import.add_argument("-m", "--message", default="initial import")
|
|
149
160
|
p_import.add_argument("--allow-secret", action="store_true")
|
|
161
|
+
p_import.add_argument("--dry-run", action="store_true", help="with --from: preview the bulk write without applying")
|
|
162
|
+
|
|
163
|
+
p_export = sub.add_parser("export", help="dump live documents to a portable, re-importable JSON snapshot")
|
|
164
|
+
p_export.add_argument("record", nargs="?", help="one collection:id; omit to export every configured collection")
|
|
165
|
+
p_export.add_argument("--out", help="write the snapshot to this file instead of stdout")
|
|
150
166
|
|
|
151
167
|
p_doctor = sub.add_parser("doctor")
|
|
152
168
|
p_doctor.add_argument("record", nargs="?")
|
|
@@ -191,7 +207,7 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
191
207
|
p_commit.add_argument(
|
|
192
208
|
"--dry-run",
|
|
193
209
|
action="store_true",
|
|
194
|
-
help="preview the
|
|
210
|
+
help="preview the delta and exit without writing; works with --from (single) and --bulk-from (per-record)",
|
|
195
211
|
)
|
|
196
212
|
|
|
197
213
|
p_set = sub.add_parser("set", help="edit scalar fields in place; routes through commit (drift-guarded)")
|
|
@@ -238,6 +254,10 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
238
254
|
p_identity_hash.add_argument("token", nargs="?")
|
|
239
255
|
p_identity_hash.add_argument("--stdin", action="store_true")
|
|
240
256
|
|
|
257
|
+
p_update = sub.add_parser("check-update", help="check PyPI for a newer cfgit (never upgrades for you)")
|
|
258
|
+
p_update.add_argument("--snooze", nargs="?", type=int, const=30, default=None,
|
|
259
|
+
metavar="DAYS", help="silence the update nudge for DAYS (default 30)")
|
|
260
|
+
|
|
241
261
|
p_ui = sub.add_parser("ui")
|
|
242
262
|
p_ui.add_argument("--host", default="127.0.0.1")
|
|
243
263
|
p_ui.add_argument("--port", type=int, default=8765)
|
|
@@ -321,8 +341,18 @@ def _dispatch(engine: Engine, args: argparse.Namespace) -> tuple[Any, int]:
|
|
|
321
341
|
raise ValueError(f"unknown PR command: {args.pr_cmd}")
|
|
322
342
|
|
|
323
343
|
if args.cmd == "import":
|
|
344
|
+
if getattr(args, "from_file", None):
|
|
345
|
+
from cfg.interfaces.actions import import_from_file
|
|
346
|
+
|
|
347
|
+
return import_from_file(
|
|
348
|
+
engine,
|
|
349
|
+
_load_json_any(args.from_file),
|
|
350
|
+
message=args.message if args.message != "initial import" else "import from export file",
|
|
351
|
+
allow_secret=args.allow_secret,
|
|
352
|
+
dry_run=args.dry_run,
|
|
353
|
+
)
|
|
324
354
|
if not args.all and not args.record:
|
|
325
|
-
raise ValueError("import needs --all or
|
|
355
|
+
raise ValueError("import needs --all, a record, or --from <export.json>")
|
|
326
356
|
result = engine.import_records(
|
|
327
357
|
_parse_record(args.record) if args.record else None,
|
|
328
358
|
message=args.message,
|
|
@@ -330,6 +360,18 @@ def _dispatch(engine: Engine, args: argparse.Namespace) -> tuple[Any, int]:
|
|
|
330
360
|
)
|
|
331
361
|
return result, EXIT_OK
|
|
332
362
|
|
|
363
|
+
if args.cmd == "export":
|
|
364
|
+
from cfg.interfaces.actions import export_records as _export_action
|
|
365
|
+
|
|
366
|
+
report, _ = _export_action(engine, args.record if args.record else None)
|
|
367
|
+
warning = report.pop("warning", None)
|
|
368
|
+
if warning:
|
|
369
|
+
print(f"⚠ {warning}", file=sys.stderr)
|
|
370
|
+
if getattr(args, "out", None):
|
|
371
|
+
Path(args.out).write_text(json.dumps(_to_json(report), indent=2), encoding="utf-8")
|
|
372
|
+
return {"state": "exported", "out": args.out, "count": report["count"]}, EXIT_OK
|
|
373
|
+
return report, EXIT_OK
|
|
374
|
+
|
|
333
375
|
if args.cmd == "status":
|
|
334
376
|
rows = engine.status(_parse_record(args.record) if args.record else None)
|
|
335
377
|
code = EXIT_DIRTY if any(r.state == "changed_outside_cfgit" for r in rows) else EXIT_OK
|
|
@@ -383,11 +425,15 @@ def _dispatch(engine: Engine, args: argparse.Namespace) -> tuple[Any, int]:
|
|
|
383
425
|
if args.bulk_from_file:
|
|
384
426
|
if args.record or args.from_file:
|
|
385
427
|
raise ValueError("bulk commit uses --bulk-from without record or --from")
|
|
386
|
-
|
|
387
|
-
raise ValueError("bulk commit needs -m/--message")
|
|
388
|
-
from cfg.interfaces.actions import bulk_commit_exit_code, parse_bulk_commit_items
|
|
428
|
+
from cfg.interfaces.actions import bulk_commit_exit_code, bulk_commit_preview, parse_bulk_commit_items
|
|
389
429
|
|
|
390
430
|
items = parse_bulk_commit_items(_load_json_any(args.bulk_from_file))
|
|
431
|
+
if args.dry_run:
|
|
432
|
+
if branch != engine.config.branches.default_branch:
|
|
433
|
+
raise ValueError("--dry-run is only supported on the main-branch commit path")
|
|
434
|
+
return bulk_commit_preview(engine, items), EXIT_OK
|
|
435
|
+
if not args.message:
|
|
436
|
+
raise ValueError("bulk commit needs -m/--message")
|
|
391
437
|
if branch != engine.config.branches.default_branch:
|
|
392
438
|
result = engine.branch_commit_many(
|
|
393
439
|
branch,
|
|
@@ -607,6 +653,26 @@ def _load_json_any(path: str) -> Any:
|
|
|
607
653
|
|
|
608
654
|
_MUTATING_CMDS = {"commit", "set", "edit", "adopt", "import", "restore"}
|
|
609
655
|
|
|
656
|
+
# Cheap, read-only commands safe to piggyback a throttled update check onto — never a write path,
|
|
657
|
+
# so a version check never sits in front of a prod mutation.
|
|
658
|
+
_READ_COMMANDS = {"status", "doctor", "whoami", "log"}
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def _maybe_update_nudge(args: argparse.Namespace) -> None:
|
|
662
|
+
"""Deterministic npm/brew-style nudge: after a cheap read command, if a newer cfgit is on
|
|
663
|
+
PyPI (throttled daily, snooze-aware, kill-switchable), print one line to stderr — but only
|
|
664
|
+
for an interactive human (TTY, not --json). Never touches stdout; never raises."""
|
|
665
|
+
if args.cmd not in _READ_COMMANDS or getattr(args, "json", False) or not sys.stdout.isatty():
|
|
666
|
+
return
|
|
667
|
+
try:
|
|
668
|
+
from cfg import update
|
|
669
|
+
|
|
670
|
+
status = update.check()
|
|
671
|
+
if status.message:
|
|
672
|
+
print(status.message, file=sys.stderr)
|
|
673
|
+
except Exception: # noqa: BLE001 - a nudge must never break the command
|
|
674
|
+
pass
|
|
675
|
+
|
|
610
676
|
|
|
611
677
|
def _warn_open_mode(engine: Engine, args: argparse.Namespace) -> None:
|
|
612
678
|
"""Loud stderr warning when a mutating command runs against a needs_approval env still in
|
|
@@ -674,6 +740,8 @@ def _format_status_report(r: dict[str, Any]) -> str:
|
|
|
674
740
|
]
|
|
675
741
|
for warning in r.get("warnings") or []:
|
|
676
742
|
lines.append(f"⚠ {warning}")
|
|
743
|
+
for nudge in r.get("nudges") or []:
|
|
744
|
+
lines.append(f"→ {nudge}")
|
|
677
745
|
return "\n".join(lines)
|
|
678
746
|
|
|
679
747
|
|
|
@@ -493,6 +493,32 @@ class Engine:
|
|
|
493
493
|
results.append({"collection": item.collection, "record_id": item.record_id, "state": "imported", "seq": result.seq, "oid": result.oid})
|
|
494
494
|
return results
|
|
495
495
|
|
|
496
|
+
def export_records(self, ref: RecordRef | None = None) -> dict[str, Any]:
|
|
497
|
+
"""Read-only snapshot of live documents into a portable, re-importable artifact.
|
|
498
|
+
|
|
499
|
+
With a ref, exports that one record; without, exports every configured collection's live
|
|
500
|
+
records. Each item carries its live doc plus the current cfgit head seq/oid (or null if
|
|
501
|
+
untracked), so the snapshot records exactly which version it represents. Writes nothing.
|
|
502
|
+
"""
|
|
503
|
+
refs = [ref] if ref else self._all_refs(include_history=False)
|
|
504
|
+
items: list[dict[str, Any]] = []
|
|
505
|
+
for item in sorted(refs, key=lambda r: (r.collection, r.record_id)):
|
|
506
|
+
live = self.adapter.get_record(item.collection, item.record_id)
|
|
507
|
+
if live is None:
|
|
508
|
+
continue
|
|
509
|
+
head = self.adapter.get_head(item.collection, item.record_id)
|
|
510
|
+
items.append(
|
|
511
|
+
{
|
|
512
|
+
"record": f"{item.collection}:{item.record_id}",
|
|
513
|
+
"collection": item.collection,
|
|
514
|
+
"record_id": item.record_id,
|
|
515
|
+
"head_seq": head.get("seq") if head else None,
|
|
516
|
+
"head_oid": head.get("oid") if head else None,
|
|
517
|
+
"doc": live,
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
return {"version": 1, "kind": "cfgit-export", "count": len(items), "items": items}
|
|
521
|
+
|
|
496
522
|
def doctor(self, ref: RecordRef | None = None, *, large_field_bytes: int = 20000) -> dict[str, Any]:
|
|
497
523
|
"""Read-only preflight. Walks live records and reports what would trip an
|
|
498
524
|
import/commit BEFORE anything is written: secret-deny matches (grouped by
|
|
@@ -748,6 +774,18 @@ class Engine:
|
|
|
748
774
|
expected_live_oid=plan["expected_live"],
|
|
749
775
|
make_head=True,
|
|
750
776
|
)
|
|
777
|
+
except KeyboardInterrupt:
|
|
778
|
+
# A cancel between per-record writes: each apply() is atomic, so already-committed
|
|
779
|
+
# records are durable. Return a clean partial report (what landed, what did not)
|
|
780
|
+
# instead of dying silently and leaving the operator guessing about DB state.
|
|
781
|
+
pending = [_plan_result(p) for p in plans[offset:]]
|
|
782
|
+
return {
|
|
783
|
+
"state": "partial",
|
|
784
|
+
"cancelled": True,
|
|
785
|
+
"results": results,
|
|
786
|
+
"failed": [],
|
|
787
|
+
"pending": pending,
|
|
788
|
+
}
|
|
751
789
|
except Exception as exc:
|
|
752
790
|
failed = [
|
|
753
791
|
{
|
|
@@ -102,7 +102,7 @@ _STATE_REMEDIES: dict[str, Next] = {
|
|
|
102
102
|
commands=("cfg commit {record} --from <file> -m '<why>'",),
|
|
103
103
|
),
|
|
104
104
|
"dry_run": Next(
|
|
105
|
-
why="Dry run: this is what
|
|
105
|
+
why="Dry run: this is what would change. Nothing was written.",
|
|
106
106
|
remedy="Rerun without --dry-run to apply.",
|
|
107
107
|
commands=(),
|
|
108
108
|
),
|