cfgit 0.1.1__tar.gz → 0.1.2__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.
Files changed (78) hide show
  1. {cfgit-0.1.1 → cfgit-0.1.2}/.gitignore +9 -0
  2. {cfgit-0.1.1 → cfgit-0.1.2}/PKG-INFO +24 -13
  3. {cfgit-0.1.1 → cfgit-0.1.2}/README.md +23 -12
  4. {cfgit-0.1.1 → cfgit-0.1.2}/docs/ADAPTERS.md +2 -2
  5. {cfgit-0.1.1 → cfgit-0.1.2}/docs/AGENTS.md +2 -2
  6. {cfgit-0.1.1 → cfgit-0.1.2}/docs/PUBLISHING.md +6 -6
  7. {cfgit-0.1.1 → cfgit-0.1.2}/docs/README.md +0 -8
  8. {cfgit-0.1.1 → cfgit-0.1.2}/docs/SPEC_CORE.md +1 -1
  9. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/README.md +19 -0
  10. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/overview.py +23 -5
  11. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/base.py +4 -4
  12. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/pyproject.toml +2 -2
  13. {cfgit-0.1.1 → cfgit-0.1.2}/pyproject.toml +1 -1
  14. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/ui/server.py +35 -2
  15. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_impact_boundary.py +36 -0
  16. cfgit-0.1.1/docs/archive/spec-v0.1.md +0 -563
  17. cfgit-0.1.1/docs/project-notes/findings.md +0 -128
  18. cfgit-0.1.1/docs/project-notes/handoff.json +0 -107
  19. cfgit-0.1.1/docs/project-notes/handoff.md +0 -178
  20. cfgit-0.1.1/docs/project-notes/review-findings.md +0 -153
  21. {cfgit-0.1.1 → cfgit-0.1.2}/.github/workflows/ci.yml +0 -0
  22. {cfgit-0.1.1 → cfgit-0.1.2}/.github/workflows/publish.yml +0 -0
  23. {cfgit-0.1.1 → cfgit-0.1.2}/CONTRIBUTING.md +0 -0
  24. {cfgit-0.1.1 → cfgit-0.1.2}/CREDITS.md +0 -0
  25. {cfgit-0.1.1 → cfgit-0.1.2}/LICENSE +0 -0
  26. {cfgit-0.1.1 → cfgit-0.1.2}/NOTICE +0 -0
  27. {cfgit-0.1.1 → cfgit-0.1.2}/SECURITY.md +0 -0
  28. {cfgit-0.1.1 → cfgit-0.1.2}/docs/BRANCHING_PLAN.md +0 -0
  29. {cfgit-0.1.1 → cfgit-0.1.2}/docs/CONFIGURATION.md +0 -0
  30. {cfgit-0.1.1 → cfgit-0.1.2}/docs/IDENTITY_AND_ATTRIBUTION.md +0 -0
  31. {cfgit-0.1.1 → cfgit-0.1.2}/docs/SPEC.md +0 -0
  32. {cfgit-0.1.1 → cfgit-0.1.2}/docs/USAGE.md +0 -0
  33. {cfgit-0.1.1 → cfgit-0.1.2}/docs/screenshots/01-diff.png +0 -0
  34. {cfgit-0.1.1 → cfgit-0.1.2}/docs/screenshots/02-impact.png +0 -0
  35. {cfgit-0.1.1 → cfgit-0.1.2}/docs/screenshots/03-scoped-impact.png +0 -0
  36. {cfgit-0.1.1 → cfgit-0.1.2}/examples/.cfg.toml +0 -0
  37. {cfgit-0.1.1 → cfgit-0.1.2}/examples/cfgit-support-demo.toml +0 -0
  38. {cfgit-0.1.1 → cfgit-0.1.2}/examples/seed_support_demo.py +0 -0
  39. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/__init__.py +0 -0
  40. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/__init__.py +0 -0
  41. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/claude.py +0 -0
  42. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/factory.py +0 -0
  43. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/gemini.py +0 -0
  44. {cfgit-0.1.1 → cfgit-0.1.2}/plugins/cfg_impact/cfg_impact/providers/openai_provider.py +0 -0
  45. {cfgit-0.1.1 → cfgit-0.1.2}/skills/cfgit/SKILL.md +0 -0
  46. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/__init__.py +0 -0
  47. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/adapters/__init__.py +0 -0
  48. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/adapters/base.py +0 -0
  49. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/adapters/mongo.py +0 -0
  50. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/adapters/postgres.py +0 -0
  51. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/approval/__init__.py +0 -0
  52. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/approval/base.py +0 -0
  53. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/cli/__init__.py +0 -0
  54. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/cli/main.py +0 -0
  55. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/__init__.py +0 -0
  56. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/authz.py +0 -0
  57. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/config.py +0 -0
  58. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/diff.py +0 -0
  59. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/engine.py +0 -0
  60. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/hashing.py +0 -0
  61. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/core/identity.py +0 -0
  62. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/interfaces/__init__.py +0 -0
  63. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/interfaces/actions.py +0 -0
  64. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/mcp/__init__.py +0 -0
  65. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/mcp/server.py +0 -0
  66. {cfgit-0.1.1 → cfgit-0.1.2}/src/cfg/ui/__init__.py +0 -0
  67. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_adapter_contract_live.py +0 -0
  68. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_authz.py +0 -0
  69. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_config.py +0 -0
  70. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_console_script.py +0 -0
  71. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_core_purity.py +0 -0
  72. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_engine_safety.py +0 -0
  73. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_hashing.py +0 -0
  74. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_identity.py +0 -0
  75. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_mcp_identity.py +0 -0
  76. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_mongo_history.py +0 -0
  77. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_postgres_history.py +0 -0
  78. {cfgit-0.1.1 → cfgit-0.1.2}/tests/test_ui_server.py +0 -0
@@ -116,6 +116,15 @@ activemq-data/
116
116
  .cfg/
117
117
  /.cfg.toml
118
118
 
119
+ # Local project notes and recording drafts
120
+ docs/project-notes/
121
+ *.mp4
122
+ *.mov
123
+ *.webm
124
+ *.mkv
125
+ *.avi
126
+ *.m4v
127
+
119
128
  # Local secrets and overrides
120
129
  *.local
121
130
  .streamlit/secrets.toml
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cfgit
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -336,25 +336,39 @@ system, or schema migration tool.
336
336
 
337
337
  ## Install
338
338
 
339
- From a checkout:
339
+ From PyPI:
340
+
341
+ - [`cfgit`](https://pypi.org/project/cfgit/)
342
+ - [`cfgit-impact`](https://pypi.org/project/cfgit-impact/) for optional impact narration
340
343
 
341
344
  ```bash
342
- python -m venv .venv
343
- . .venv/bin/activate
344
- pip install -e '.[mongo,postgres,mcp,dev]'
345
- pip install -e plugins/cfg_impact
345
+ pip install 'cfgit[mongo,postgres,mcp]'
346
346
  ```
347
347
 
348
348
  Minimal install for Mongo only:
349
349
 
350
350
  ```bash
351
- pip install -e '.[mongo]'
351
+ pip install 'cfgit[mongo]'
352
352
  ```
353
353
 
354
354
  Minimal install for Postgres only:
355
355
 
356
356
  ```bash
357
- pip install -e '.[postgres]'
357
+ pip install 'cfgit[postgres]'
358
+ ```
359
+
360
+ Optional impact plugin:
361
+
362
+ ```bash
363
+ pip install cfgit-impact
364
+ ```
365
+
366
+ If you use `pipx`, install cfgit first and inject the optional plugin into the
367
+ same isolated environment:
368
+
369
+ ```bash
370
+ pipx install 'cfgit[mongo,postgres,mcp]'
371
+ pipx inject cfgit cfgit-impact
358
372
  ```
359
373
 
360
374
  ## Quick start
@@ -686,7 +700,7 @@ explains in plain language what the change does, what it ripples into, and how t
686
700
  roll it back:
687
701
 
688
702
  ```bash
689
- pip install -e plugins/cfg_impact
703
+ pip install cfgit-impact
690
704
  cfg impact agent_configs:agent_planner --llm --json
691
705
  ```
692
706
 
@@ -759,10 +773,7 @@ against a safe environment.
759
773
  - [docs/AGENTS.md](docs/AGENTS.md): MCP, skill, and impact plugin usage
760
774
  - [docs/SPEC_CORE.md](docs/SPEC_CORE.md): project framing and v1 scope
761
775
  - [docs/SPEC.md](docs/SPEC.md): deeper engine reference
762
- - [docs/README.md](docs/README.md): full documentation index, including archived project notes and historical specs
763
- - [docs/project-notes/findings.md](docs/project-notes/findings.md): implementation findings from the origin build
764
- - [docs/project-notes/handoff.md](docs/project-notes/handoff.md): archived handoff notes
765
- - [docs/archive/spec-v0.1.md](docs/archive/spec-v0.1.md): original historical spec
776
+ - [docs/README.md](docs/README.md): full documentation index
766
777
 
767
778
  ## Development
768
779
 
@@ -103,25 +103,39 @@ system, or schema migration tool.
103
103
 
104
104
  ## Install
105
105
 
106
- From a checkout:
106
+ From PyPI:
107
+
108
+ - [`cfgit`](https://pypi.org/project/cfgit/)
109
+ - [`cfgit-impact`](https://pypi.org/project/cfgit-impact/) for optional impact narration
107
110
 
108
111
  ```bash
109
- python -m venv .venv
110
- . .venv/bin/activate
111
- pip install -e '.[mongo,postgres,mcp,dev]'
112
- pip install -e plugins/cfg_impact
112
+ pip install 'cfgit[mongo,postgres,mcp]'
113
113
  ```
114
114
 
115
115
  Minimal install for Mongo only:
116
116
 
117
117
  ```bash
118
- pip install -e '.[mongo]'
118
+ pip install 'cfgit[mongo]'
119
119
  ```
120
120
 
121
121
  Minimal install for Postgres only:
122
122
 
123
123
  ```bash
124
- pip install -e '.[postgres]'
124
+ pip install 'cfgit[postgres]'
125
+ ```
126
+
127
+ Optional impact plugin:
128
+
129
+ ```bash
130
+ pip install cfgit-impact
131
+ ```
132
+
133
+ If you use `pipx`, install cfgit first and inject the optional plugin into the
134
+ same isolated environment:
135
+
136
+ ```bash
137
+ pipx install 'cfgit[mongo,postgres,mcp]'
138
+ pipx inject cfgit cfgit-impact
125
139
  ```
126
140
 
127
141
  ## Quick start
@@ -453,7 +467,7 @@ explains in plain language what the change does, what it ripples into, and how t
453
467
  roll it back:
454
468
 
455
469
  ```bash
456
- pip install -e plugins/cfg_impact
470
+ pip install cfgit-impact
457
471
  cfg impact agent_configs:agent_planner --llm --json
458
472
  ```
459
473
 
@@ -526,10 +540,7 @@ against a safe environment.
526
540
  - [docs/AGENTS.md](docs/AGENTS.md): MCP, skill, and impact plugin usage
527
541
  - [docs/SPEC_CORE.md](docs/SPEC_CORE.md): project framing and v1 scope
528
542
  - [docs/SPEC.md](docs/SPEC.md): deeper engine reference
529
- - [docs/README.md](docs/README.md): full documentation index, including archived project notes and historical specs
530
- - [docs/project-notes/findings.md](docs/project-notes/findings.md): implementation findings from the origin build
531
- - [docs/project-notes/handoff.md](docs/project-notes/handoff.md): archived handoff notes
532
- - [docs/archive/spec-v0.1.md](docs/archive/spec-v0.1.md): original historical spec
543
+ - [docs/README.md](docs/README.md): full documentation index
533
544
 
534
545
  ## Development
535
546
 
@@ -8,7 +8,7 @@ details. Core owns hashing, history semantics, drift detection, and restore logi
8
8
  Install:
9
9
 
10
10
  ```bash
11
- pip install -e '.[mongo]'
11
+ pip install 'cfgit[mongo]'
12
12
  ```
13
13
 
14
14
  Configuration:
@@ -45,7 +45,7 @@ Mongo notes:
45
45
  Install:
46
46
 
47
47
  ```bash
48
- pip install -e '.[postgres]'
48
+ pip install 'cfgit[postgres]'
49
49
  ```
50
50
 
51
51
  Configuration:
@@ -54,7 +54,7 @@ tokens through MCP unless that client/session is trusted for secrets.
54
54
  Install the MCP extra:
55
55
 
56
56
  ```bash
57
- pip install -e '.[mcp]'
57
+ pip install 'cfgit[mcp]'
58
58
  ```
59
59
 
60
60
  Run:
@@ -120,7 +120,7 @@ as token/DB-principal based rather than author-string based.
120
120
  Install:
121
121
 
122
122
  ```bash
123
- pip install -e plugins/cfg_impact
123
+ pip install cfgit-impact
124
124
  ```
125
125
 
126
126
  Deterministic impact:
@@ -7,7 +7,7 @@ cfgit publishes two Python distributions:
7
7
  - `cfgit-impact`: optional plugin for deterministic system-impact summaries and
8
8
  opt-in LLM narration of database record diffs.
9
9
 
10
- Current release version: `0.1.1`.
10
+ Current release version: `0.1.2`.
11
11
 
12
12
  ## One-Time PyPI Setup
13
13
 
@@ -49,8 +49,8 @@ python -m twine check dist/*
49
49
  ```bash
50
50
  python -m venv /tmp/cfgit-publish-smoke
51
51
  /tmp/cfgit-publish-smoke/bin/python -m pip install \
52
- 'dist/cfgit-0.1.1-py3-none-any.whl[mcp]' \
53
- plugins/cfg_impact/dist/cfgit_impact-0.1.1-py3-none-any.whl
52
+ 'dist/cfgit-0.1.2-py3-none-any.whl[mcp]' \
53
+ plugins/cfg_impact/dist/cfgit_impact-0.1.2-py3-none-any.whl
54
54
  /tmp/cfgit-publish-smoke/bin/cfg --help
55
55
  /tmp/cfgit-publish-smoke/bin/python -c 'import cfg; import cfg.mcp.server; import cfg_impact; print("imports ok")'
56
56
  ```
@@ -63,9 +63,9 @@ release from a tag:
63
63
  ```bash
64
64
  git checkout main
65
65
  git pull origin main
66
- git tag v0.1.1
67
- git push origin v0.1.1
68
- gh release create v0.1.1 --title "v0.1.1" --notes "cfgit 0.1.1 package release."
66
+ git tag v0.1.2
67
+ git push origin v0.1.2
68
+ gh release create v0.1.2 --title "v0.1.2" --notes "cfgit 0.1.2 package release."
69
69
  ```
70
70
 
71
71
  The release triggers `.github/workflows/publish.yml`, which publishes `cfgit`
@@ -12,11 +12,3 @@ Technical references:
12
12
 
13
13
  - [Core spec](SPEC_CORE.md): framing and v1 scope.
14
14
  - [Engine spec](SPEC.md): detailed engine and adapter reference.
15
-
16
- Project notes and historical artifacts:
17
-
18
- - [Implementation findings](project-notes/findings.md): source-code and data-shape findings from the origin implementation.
19
- - [Review findings](project-notes/review-findings.md): implementation audit defects and fix order.
20
- - [Session handoff](project-notes/handoff.md): archived implementation handoff.
21
- - [Session handoff JSON](project-notes/handoff.json): machine-readable handoff archive.
22
- - [Original v0.1 spec](archive/spec-v0.1.md): early historical spec.
@@ -189,7 +189,7 @@ writers = ["alice@*", "bob@*", "carol@*"]
189
189
  admin_actions = ["init", "restore_system"]
190
190
  ```
191
191
 
192
- > **First-task gate (archived in `docs/project-notes/handoff.md`):** before building, pin each collection's real id + live-rule against the actual data. `modelgarden_models` already has duplicate `model_id` values in local dev data, while `model_path` is unique and runtime-authoritative in the code paths checked. Use `model_path` unless production data proves otherwise. Getting this wrong makes the tool wrong on day one.
192
+ > **First-task gate for any real deployment:** before tracking a collection, pin the stable id field and live-record rule against actual data. If multiple rows or documents can share the apparent id, configure a different id field or an explicit `live_when` selector before importing history. Getting this wrong makes the tool wrong on day one.
193
193
 
194
194
  ---
195
195
 
@@ -4,6 +4,25 @@ Optional system-impact analysis for cfgit.
4
4
 
5
5
  This package is deliberately outside `src/cfg/core/`. The cfgit core stays LLM-free and provider-free; this plugin owns both deterministic impact analysis and optional LLM narration.
6
6
 
7
+ ## Install
8
+
9
+ Install cfgit with the database extras you use, then install the optional impact
10
+ plugin from PyPI into the same Python environment:
11
+
12
+ - [`cfgit-impact`](https://pypi.org/project/cfgit-impact/)
13
+
14
+ ```bash
15
+ pip install 'cfgit[mongo,postgres,mcp]'
16
+ pip install cfgit-impact
17
+ ```
18
+
19
+ For `pipx` installs:
20
+
21
+ ```bash
22
+ pipx install 'cfgit[mongo,postgres,mcp]'
23
+ pipx inject cfgit cfgit-impact
24
+ ```
25
+
7
26
  ## Boundary
8
27
 
9
28
  - `src/cfg/core/` never imports this plugin.
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import json
7
+ import re
7
8
  import sys
8
9
  from typing import Any
9
10
 
@@ -106,7 +107,7 @@ async def overview_with_optional_llm(
106
107
  payload,
107
108
  json_dumps=lambda payload: json.dumps(payload, indent=2, sort_keys=True),
108
109
  temperature=0.1,
109
- max_tokens=1100,
110
+ max_tokens=4096,
110
111
  )
111
112
  parsed = _parse_jsonish(result.get("content", ""))
112
113
  overview_data["llm"] = {
@@ -422,11 +423,28 @@ def _parse_jsonish(text: str) -> dict[str, Any] | None:
422
423
  if not raw:
423
424
  return None
424
425
  if raw.startswith("```"):
425
- raw = raw.strip("`")
426
- if raw.startswith("json"):
427
- raw = raw[4:]
426
+ raw = raw[3:].strip()
427
+ if raw.lower().startswith("json"):
428
+ raw = raw[4:].strip()
429
+ fence_end = raw.rfind("```")
430
+ if fence_end != -1:
431
+ raw = raw[:fence_end].strip()
428
432
  try:
429
433
  data = json.loads(raw)
430
434
  except json.JSONDecodeError:
431
- return None
435
+ return _parse_partial_json_fields(raw)
432
436
  return data if isinstance(data, dict) else None
437
+
438
+
439
+ def _parse_partial_json_fields(raw: str) -> dict[str, Any] | None:
440
+ parsed: dict[str, Any] = {}
441
+ for key in ("summary", "behavior_change", "blast_radius", "risk_level", "rollback_note"):
442
+ match = re.search(rf'"{key}"\s*:\s*"((?:\\.|[^"\\])*)"', raw, flags=re.DOTALL)
443
+ if match:
444
+ try:
445
+ parsed[key] = json.loads(f'"{match.group(1)}"')
446
+ except json.JSONDecodeError:
447
+ parsed[key] = match.group(1)
448
+ if '"unknowns"' in raw:
449
+ parsed.setdefault("unknowns", [])
450
+ return parsed or None
@@ -49,10 +49,10 @@ class BaseImpactProvider(ABC):
49
49
  "upstream/downstream roles, overlapping responsibilities), naming the specific "
50
50
  "config_ids. Do NOT say 'impact unknown' when the diff is present, read it. Only list a "
51
51
  "genuine unknown if it truly cannot be inferred from the provided data.\n"
52
- "Return concise JSON with keys: summary (one concrete sentence), behavior_change (what "
53
- "the agent will now do differently, specifically), blast_radius (which named configs or "
54
- "consumers are affected and why), risk_level (low|medium|high), rollback_note, unknowns "
55
- "(array of only real unknowns)."
52
+ "Return terse JSON with keys: summary (one concrete sentence), behavior_change (one "
53
+ "short sentence), blast_radius (one short sentence naming affected configs), risk_level "
54
+ "(low|medium|high), rollback_note (one short sentence), unknowns (array of only real "
55
+ "unknowns). Return raw JSON only; do not wrap it in Markdown or code fences."
56
56
  ),
57
57
  },
58
58
  {"role": "user", "content": json_dumps(payload)},
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "cfgit-impact"
3
- version = "0.1.1"
3
+ version = "0.1.2"
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.1.1,<0.2.0",
10
+ "cfgit>=0.1.2,<0.2.0",
11
11
  "httpx>=0.27",
12
12
  ]
13
13
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cfgit"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Git-style history, diff, drift detection, and rollback for live database records without migrating or owning your datastore"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  from http import HTTPStatus
6
6
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
7
7
  import json
8
+ import os
8
9
  import socket
9
10
  from typing import Any
10
11
  from urllib.parse import parse_qs, urlparse
@@ -107,6 +108,11 @@ class CfgUIHandler(BaseHTTPRequestHandler):
107
108
  for item in project.collections
108
109
  ],
109
110
  "connections": actions.to_json(project.connections),
111
+ "impact": {
112
+ "provider": os.getenv("CFGIT_UI_IMPACT_PROVIDER")
113
+ or project.connections.ai_provider,
114
+ "model": os.getenv("CFGIT_UI_IMPACT_MODEL") or None,
115
+ },
110
116
  },
111
117
  }
112
118
  except Exception as exc:
@@ -641,7 +647,7 @@ UI_HTML = r"""<!doctype html>
641
647
  <div class="mbg" id="mbg"><div class="modal" id="modal"></div></div>
642
648
 
643
649
  <script>
644
- const S={records:[],recent:[],branches:[],prs:[],filter:"all",q:"",sel:null,against:new Set(),hist:[],who:null,open:{}};
650
+ const S={records:[],recent:[],branches:[],prs:[],filter:"all",q:"",sel:null,against:new Set(),hist:[],who:null,open:{},impact:{}};
645
651
  const $=id=>document.getElementById(id);
646
652
  const esc=v=>String(v==null?"":v).replace(/[&<>"']/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
647
653
  // inline markdown for LLM narration: escape first (XSS-safe), then render the small
@@ -678,6 +684,7 @@ async function loadState(){
678
684
  const sc=await fetch("/api/schema?"+qs()).then(r=>r.json()).catch(()=>null);
679
685
  if(sc&&sc.data&&Array.isArray(sc.data.envs)&&sc.data.envs.length){
680
686
  const cur=$("env").value; $("env").innerHTML=sc.data.envs.map(e=>`<option ${e===cur?"selected":""}>${esc(e)}</option>`).join("");}
687
+ if(sc&&sc.data&&sc.data.impact)S.impact=sc.data.impact;
681
688
  S.records=(st.data&&st.data.status)?st.data.status:[];
682
689
  S.recent=(st.data&&st.data.recent_history)?st.data.recent_history:[];
683
690
  S.branches=(st.data&&st.data.branches)?st.data.branches:[];
@@ -869,6 +876,8 @@ async function showImpact(){
869
876
  const against=[...S.against].filter(k=>k!==S.sel);
870
877
  const btn=$("aImpact"); if(btn){btn.disabled=true;btn.textContent="Analyzing…";}
871
878
  const payload={record:S.sel,a:S.diffCtx.a,b:S.diffCtx.b,use_llm:true};
879
+ if(S.impact&&S.impact.provider)payload.provider=S.impact.provider;
880
+ if(S.impact&&S.impact.model)payload.model=S.impact.model;
872
881
  if(against.length)payload.against=against;
873
882
  const r=await api("impact",payload);
874
883
  if(btn){btn.disabled=false;}
@@ -1119,11 +1128,35 @@ async function showBranchDiff(){
1119
1128
  $("dTitle").innerHTML=`Branch diff · <b>main..${esc(br)}</b>`;
1120
1129
  $("dActs").innerHTML="";
1121
1130
  if(!rows.length){$("diff").innerHTML=`<div class="paper"><div class="nodiff">No draft changes on this branch.</div></div>`;return;}
1122
- $("diff").innerHTML=`<div class="paper doconly"><div class="paper-h"><div>branch draft changes</div></div><div class="docbody">${esc(JSON.stringify(rows,null,2))}</div></div>`;
1131
+ if(rows.length===1){
1132
+ const row=rows[0];
1133
+ const rec=`${row.collection}:${row.record_id}`;
1134
+ $("dTitle").innerHTML=`Branch diff · <b>main..${esc(br)}</b> · ${esc(rec)}`;
1135
+ renderDiff({data:{changes:row.changes||[]}},"main",br,"No field-level draft changes.");
1136
+ return;
1137
+ }
1138
+ const cards=rows.map(row=>`<div class="frow"><div class="fname">${esc(row.collection+":"+row.record_id)}</div>
1139
+ <div class="docbody">${esc(JSON.stringify(row.changes||[],null,2))}</div></div>`).join("");
1140
+ $("diff").innerHTML=`<div class="paper doconly"><div class="paper-h"><div>branch draft changes</div></div>${cards}</div>`;
1123
1141
  }
1124
1142
  function openPrModal(){
1125
1143
  const br=selectedBranch();
1126
1144
  if(br==="main"){toast("select a non-main branch",true);return;}
1145
+ const prs=S.prs.filter(p=>p.head_branch===br&&p.status==="open");
1146
+ if(prs.length){
1147
+ const body=prs.map(p=>`<div class="desc">
1148
+ <b>${esc(p.id)}</b><br>
1149
+ ${esc(p.message||"review draft")}<br>
1150
+ <span class="mono">${esc(p.base_branch||"main")} ← ${esc(p.head_branch||br)}</span><br>
1151
+ ${(p.records||[]).map(r=>`<span class="cat">${esc(r.collection+":"+r.record_id)}</span>`).join(" ")}
1152
+ </div>`).join("");
1153
+ modal(`<h3>Open PR</h3><div class="b">
1154
+ ${body}
1155
+ <div class="desc">This is review metadata in cfgit's sidecar store. Runtime remains unchanged until the separate merge action.</div>
1156
+ </div>
1157
+ <div class="f"><button class="btn go" onclick="closeModal()">Close</button></div>`);
1158
+ return;
1159
+ }
1127
1160
  modal(`<h3>Open PR</h3><div class="b">
1128
1161
  <div class="desc">Open a review object for <b>${esc(br)}</b>. Runtime is unchanged until merge.</div>
1129
1162
  <div><label>Message</label><input id="mMsg" value="merge ${esc(br)}" autocomplete="off"></div></div>
@@ -122,6 +122,42 @@ def test_impact_payload_includes_actual_field_diff_values() -> None:
122
122
  assert "changes" not in payload
123
123
 
124
124
 
125
+ def test_parse_jsonish_strips_fenced_json() -> None:
126
+ sys.path.insert(0, str(ROOT / "plugins" / "cfg_impact"))
127
+ try:
128
+ from cfg_impact.overview import _parse_jsonish
129
+ finally:
130
+ sys.path.pop(0)
131
+
132
+ assert _parse_jsonish('```json\n{"summary":"ok"}\n```') == {"summary": "ok"}
133
+
134
+
135
+ def test_parse_jsonish_recovers_partial_json_fields() -> None:
136
+ sys.path.insert(0, str(ROOT / "plugins" / "cfg_impact"))
137
+ try:
138
+ from cfg_impact.overview import _parse_jsonish
139
+ finally:
140
+ sys.path.pop(0)
141
+
142
+ broken = (
143
+ '{"summary":"Refund agent now expands courtesy credits.",'
144
+ '"behavior_change":"Approves larger refunds.",'
145
+ '"blast_radius":"Affects refund_resolution and support_orchestrator.",'
146
+ '"risk_level":"high",'
147
+ '"rollback_note":"Restore the previous refund policy.",'
148
+ '"unknowns":["truncated"'
149
+ )
150
+
151
+ assert _parse_jsonish(broken) == {
152
+ "summary": "Refund agent now expands courtesy credits.",
153
+ "behavior_change": "Approves larger refunds.",
154
+ "blast_radius": "Affects refund_resolution and support_orchestrator.",
155
+ "risk_level": "high",
156
+ "rollback_note": "Restore the previous refund policy.",
157
+ "unknowns": [],
158
+ }
159
+
160
+
125
161
  def test_changed_string_values_reads_before_after_keys() -> None:
126
162
  sys.path.insert(0, str(ROOT / "plugins" / "cfg_impact"))
127
163
  try: