giton 0.1.2__py3-none-any.whl

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.
giton/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """giton — local AI layer for git, between commit and push."""
2
+
3
+ __version__ = "0.1.2"
giton/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ from giton.cli import app
2
+
3
+ if __name__ == "__main__":
4
+ app()
giton/catalog.py ADDED
@@ -0,0 +1,173 @@
1
+ """Built-in plugin catalog.
2
+
3
+ Defaults bundle three local-ecosystem plugins that are most useful in a
4
+ day-to-day commit -> push loop. Extra entries are grouped into categories
5
+ so the user can quickly install more via `giton plugin install <name>` or
6
+ `giton plugin add-category <category>`.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass
11
+
12
+ from giton.config import PluginRecord
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class CatalogEntry:
17
+ record: PluginRecord
18
+ pip_local_path: str | None = None # sibling repo path under semcod/
19
+
20
+
21
+ # --- Defaults: three plugins activated by `giton init` ---------------------
22
+ DEFAULT_PLUGIN_NAMES: tuple[str, ...] = ("pyqual", "vallm", "pretest")
23
+
24
+
25
+ def _entry(
26
+ name: str,
27
+ desc: str,
28
+ *,
29
+ category: str,
30
+ triggers: list[str],
31
+ command: str,
32
+ pypi: str | None = None,
33
+ local: str | None = None,
34
+ ) -> CatalogEntry:
35
+ return CatalogEntry(
36
+ record=PluginRecord(
37
+ name=name,
38
+ description=desc,
39
+ category=category,
40
+ exec_type="cli",
41
+ command=command,
42
+ triggers=triggers,
43
+ install=pypi or local,
44
+ source="default",
45
+ ),
46
+ pip_local_path=local,
47
+ )
48
+
49
+
50
+ CATALOG: dict[str, CatalogEntry] = {
51
+ # --- Default plugins -------------------------------------------------
52
+ "pyqual": _entry(
53
+ "pyqual",
54
+ "Python code quality checks (lint, types, complexity).",
55
+ category="lang:python",
56
+ triggers=["pre-commit"],
57
+ command="pyqual check {paths}",
58
+ pypi="pyqual",
59
+ local="../pyqual",
60
+ ),
61
+ "vallm": _entry(
62
+ "vallm",
63
+ "Validate LLM-generated code/patches before they land in history.",
64
+ category="task:validate",
65
+ triggers=["post-commit"],
66
+ command="vallm check --diff {diff_file}",
67
+ pypi="vallm",
68
+ local="../vallm",
69
+ ),
70
+ "pretest": _entry(
71
+ "pretest",
72
+ "Run / generate tests before push.",
73
+ category="task:test",
74
+ triggers=["pre-push"],
75
+ command="pretest run",
76
+ pypi="pretest",
77
+ local="../pretest",
78
+ ),
79
+
80
+ # --- Quick-extend: language plugins ---------------------------------
81
+ "domd": _entry(
82
+ "domd",
83
+ "Markdown / docs linter and fixer.",
84
+ category="lang:markdown",
85
+ triggers=["pre-commit"],
86
+ command="domd lint {paths}",
87
+ pypi="domd",
88
+ local="../domd",
89
+ ),
90
+ "code2llm": _entry(
91
+ "code2llm",
92
+ "Pack the repo into LLM-ready context for AI plugins.",
93
+ category="lang:any",
94
+ triggers=["post-commit"],
95
+ command="code2llm pack --staged",
96
+ pypi="code2llm",
97
+ local="../code2llm",
98
+ ),
99
+
100
+ # --- Quick-extend: task plugins -------------------------------------
101
+ "prefact": _entry(
102
+ "prefact",
103
+ "AI refactoring suggestions as fixup! commits.",
104
+ category="task:refactor",
105
+ triggers=["post-commit"],
106
+ command="prefact suggest --diff {diff_file}",
107
+ pypi="prefact",
108
+ local="../prefact",
109
+ ),
110
+ "redsl": _entry(
111
+ "redsl",
112
+ "Auto-fix lint/style issues and stage as fixup.",
113
+ category="task:autofix",
114
+ triggers=["pre-commit"],
115
+ command="redsl autofix {paths}",
116
+ pypi="redsl",
117
+ local="../redsl",
118
+ ),
119
+ "pfix": _entry(
120
+ "pfix",
121
+ "Generic patch fixer — apply small AI-proposed patches.",
122
+ category="task:fix",
123
+ triggers=["post-commit"],
124
+ command="pfix apply --diff {diff_file}",
125
+ pypi="pfix",
126
+ local="../pfix",
127
+ ),
128
+ "todocs": _entry(
129
+ "todocs",
130
+ "Generate / update docs from staged changes.",
131
+ category="task:docs",
132
+ triggers=["pre-push"],
133
+ command="todocs sync --staged",
134
+ pypi="todocs",
135
+ local="../todocs",
136
+ ),
137
+ "prellm": _entry(
138
+ "prellm",
139
+ "Pre-LLM gate: redact secrets / shrink context before AI calls.",
140
+ category="task:security",
141
+ triggers=["pre-commit"],
142
+ command="prellm scan {paths}",
143
+ pypi="prellm",
144
+ local="../prellm",
145
+ ),
146
+
147
+ # --- Quick-extend: integrations -------------------------------------
148
+ "git-commit-mcp": _entry(
149
+ "git-commit-mcp",
150
+ "External MCP server for Conventional Commit messages.",
151
+ category="integration:mcp",
152
+ triggers=["pre-push"],
153
+ command="git-commit-mcp-server --once",
154
+ pypi="git-commit-mcp-server",
155
+ ),
156
+ }
157
+
158
+
159
+ def list_categories() -> dict[str, list[str]]:
160
+ out: dict[str, list[str]] = {}
161
+ for name, entry in CATALOG.items():
162
+ out.setdefault(entry.record.category, []).append(name)
163
+ for v in out.values():
164
+ v.sort()
165
+ return dict(sorted(out.items()))
166
+
167
+
168
+ def find(name: str) -> CatalogEntry | None:
169
+ return CATALOG.get(name)
170
+
171
+
172
+ def defaults() -> list[CatalogEntry]:
173
+ return [CATALOG[n] for n in DEFAULT_PLUGIN_NAMES]
giton/cli.py ADDED
@@ -0,0 +1,171 @@
1
+ """giton CLI — Typer entry point."""
2
+ from __future__ import annotations
3
+
4
+ from pathlib import Path
5
+
6
+ import typer
7
+ from rich.console import Console
8
+
9
+ from giton import __version__, plugins as plug, shell as giton_shell
10
+ from giton.context import collect, repo_root
11
+ from giton.hooks import install as install_hooks, uninstall as uninstall_hooks
12
+ from giton.runner import run_trigger
13
+
14
+ app = typer.Typer(
15
+ add_completion=False,
16
+ no_args_is_help=True,
17
+ help="giton — local AI layer for git, between commit and push.",
18
+ )
19
+ plugin_app = typer.Typer(no_args_is_help=True, help="Manage plugins")
20
+ hook_app = typer.Typer(no_args_is_help=True, help="Run hook logic (used by .git/hooks)")
21
+ app.add_typer(plugin_app, name="plugin")
22
+ app.add_typer(hook_app, name="hook")
23
+
24
+ console = Console()
25
+
26
+
27
+ @app.callback(invoke_without_command=True)
28
+ def _root(
29
+ ctx: typer.Context,
30
+ version: bool = typer.Option(False, "--version", help="Show version and exit."),
31
+ ):
32
+ if version:
33
+ console.print(f"giton {__version__}")
34
+ raise typer.Exit()
35
+ if ctx.invoked_subcommand is None:
36
+ typer.echo(ctx.get_help())
37
+
38
+
39
+ # --- top-level commands -----------------------------------------------------
40
+
41
+ @app.command()
42
+ def init(
43
+ install_default_plugins: bool = typer.Option(
44
+ True, "--with-defaults/--no-defaults",
45
+ help="Also install the 3 default plugins.",
46
+ ),
47
+ ):
48
+ """Install giton git hooks in the current repository."""
49
+ root = repo_root()
50
+ if not root:
51
+ console.print("[red]not inside a git repository[/red]")
52
+ raise typer.Exit(1)
53
+ written = install_hooks(root)
54
+ console.print(f"[green]✓ installed {len(written)} hook(s) in {root}/.git/hooks[/green]")
55
+ for w in written:
56
+ console.print(f" • {w.name}")
57
+ if install_default_plugins:
58
+ console.print("\n[bold]Installing default plugins…[/bold]")
59
+ plug.install_defaults()
60
+ console.print(
61
+ "\n[dim]Tip: open the interactive shell with `giton shell`.[/dim]"
62
+ )
63
+
64
+
65
+ @app.command()
66
+ def uninit():
67
+ """Remove giton hooks from the current repository (restore backups)."""
68
+ root = repo_root()
69
+ if not root:
70
+ console.print("[red]not inside a git repository[/red]")
71
+ raise typer.Exit(1)
72
+ removed = uninstall_hooks(root)
73
+ console.print(f"[green]removed {len(removed)} giton hook(s)[/green]")
74
+
75
+
76
+ @app.command()
77
+ def status():
78
+ """Show repo summary."""
79
+ ctx = collect()
80
+ if not ctx:
81
+ console.print("[yellow]not inside a git repository[/yellow]")
82
+ raise typer.Exit(1)
83
+ console.print(f"[bold]repo[/bold] {ctx.root}")
84
+ console.print(f"[bold]last[/bold] {ctx.last_commit_subject or '(no commits yet)'}")
85
+ console.print(f"[bold]staged[/bold] {len(ctx.staged_paths)} file(s)")
86
+ for p in ctx.staged_paths:
87
+ console.print(f" • {p}")
88
+
89
+
90
+ @app.command()
91
+ def shell():
92
+ """Launch the interactive giton shell."""
93
+ giton_shell.run()
94
+
95
+
96
+ @app.command()
97
+ def doctor():
98
+ """Quick environment check."""
99
+ import shutil
100
+ git_ok = shutil.which("git") is not None
101
+ console.print(f"git available: {'[green]yes[/green]' if git_ok else '[red]no[/red]'}")
102
+ root = repo_root()
103
+ console.print(f"git repo: {root if root else '[yellow]not in a repo[/yellow]'}")
104
+ plug.show_table()
105
+
106
+
107
+ # --- plugin subcommands -----------------------------------------------------
108
+
109
+ @plugin_app.command("list")
110
+ def plugin_list():
111
+ """List registered plugins."""
112
+ plug.show_table()
113
+
114
+
115
+ @plugin_app.command("catalog")
116
+ def plugin_catalog():
117
+ """Show the catalog of available plugins."""
118
+ plug.show_catalog()
119
+
120
+
121
+ @plugin_app.command("install")
122
+ def plugin_install(name: str):
123
+ """Install a plugin by catalog name."""
124
+ plug.install_from_catalog(name)
125
+
126
+
127
+ @plugin_app.command("install-defaults")
128
+ def plugin_install_defaults():
129
+ """Install the 3 default plugins (pyqual, vallm, pretest)."""
130
+ plug.install_defaults()
131
+
132
+
133
+ @plugin_app.command("install-category")
134
+ def plugin_install_category(category: str):
135
+ """Install every plugin in the given catalog category (e.g. lang:python)."""
136
+ n = plug.install_category(category)
137
+ console.print(f"[green]installed {n} plugin(s) from category '{category}'[/green]")
138
+
139
+
140
+ @plugin_app.command("remove")
141
+ def plugin_remove(name: str):
142
+ """Unregister a plugin."""
143
+ plug.uninstall(name)
144
+
145
+
146
+ # --- hook subcommands -------------------------------------------------------
147
+
148
+ @hook_app.command("pre-commit")
149
+ def hook_pre_commit():
150
+ """Run pre-commit plugins."""
151
+ results = run_trigger("pre-commit")
152
+ if any(not r.ok for r in results):
153
+ raise typer.Exit(1)
154
+
155
+
156
+ @hook_app.command("post-commit")
157
+ def hook_post_commit():
158
+ """Run post-commit plugins (never blocks the commit)."""
159
+ run_trigger("post-commit")
160
+
161
+
162
+ @hook_app.command("pre-push")
163
+ def hook_pre_push():
164
+ """Run pre-push plugins."""
165
+ results = run_trigger("pre-push")
166
+ if any(not r.ok for r in results):
167
+ raise typer.Exit(1)
168
+
169
+
170
+ if __name__ == "__main__":
171
+ app()
giton/config.py ADDED
@@ -0,0 +1,74 @@
1
+ """User and repository config for giton."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import os
6
+ from dataclasses import dataclass, field
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+
11
+ def _xdg_config_home() -> Path:
12
+ return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
13
+
14
+
15
+ USER_CONFIG_DIR = _xdg_config_home() / "giton"
16
+ USER_PLUGINS_FILE = USER_CONFIG_DIR / "plugins.json"
17
+ REPO_CONFIG_PATH = ".giton/config.yaml"
18
+
19
+
20
+ @dataclass
21
+ class PluginRecord:
22
+ name: str
23
+ description: str = ""
24
+ category: str = "task" # "lang" | "task" | "integration"
25
+ exec_type: str = "cli" # "cli" | "mcp" | "rest"
26
+ command: str = "" # shell command template, e.g. "pyqual check {paths}"
27
+ triggers: list[str] = field(default_factory=lambda: ["pre-commit"])
28
+ install: str | None = None # pip target (PyPI name, VCS URL, or local path)
29
+ enabled: bool = True
30
+ source: str = "user" # "default" | "user"
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ return self.__dict__.copy()
34
+
35
+ @classmethod
36
+ def from_dict(cls, d: dict[str, Any]) -> "PluginRecord":
37
+ return cls(**{k: v for k, v in d.items() if k in cls.__dataclass_fields__})
38
+
39
+
40
+ def ensure_user_dirs() -> None:
41
+ USER_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
42
+
43
+
44
+ def load_plugins() -> list[PluginRecord]:
45
+ ensure_user_dirs()
46
+ if not USER_PLUGINS_FILE.exists():
47
+ return []
48
+ try:
49
+ raw = json.loads(USER_PLUGINS_FILE.read_text())
50
+ except json.JSONDecodeError:
51
+ return []
52
+ return [PluginRecord.from_dict(p) for p in raw.get("plugins", [])]
53
+
54
+
55
+ def save_plugins(plugins: list[PluginRecord]) -> None:
56
+ ensure_user_dirs()
57
+ payload = {"plugins": [p.to_dict() for p in plugins]}
58
+ USER_PLUGINS_FILE.write_text(json.dumps(payload, indent=2))
59
+
60
+
61
+ def upsert_plugin(plugin: PluginRecord) -> None:
62
+ plugins = load_plugins()
63
+ plugins = [p for p in plugins if p.name != plugin.name]
64
+ plugins.append(plugin)
65
+ save_plugins(plugins)
66
+
67
+
68
+ def remove_plugin(name: str) -> bool:
69
+ plugins = load_plugins()
70
+ new = [p for p in plugins if p.name != name]
71
+ if len(new) == len(plugins):
72
+ return False
73
+ save_plugins(new)
74
+ return True
giton/context.py ADDED
@@ -0,0 +1,66 @@
1
+ """Collect git context (status, staged diff, recent commits)."""
2
+ from __future__ import annotations
3
+
4
+ import subprocess
5
+ from dataclasses import dataclass, field
6
+ from pathlib import Path
7
+
8
+
9
+ def _run(cmd: list[str], cwd: Path | None = None) -> str:
10
+ res = subprocess.run(
11
+ cmd, cwd=cwd, check=False, capture_output=True, text=True
12
+ )
13
+ return res.stdout
14
+
15
+
16
+ def repo_root(cwd: Path | None = None) -> Path | None:
17
+ out = _run(["git", "rev-parse", "--show-toplevel"], cwd=cwd).strip()
18
+ return Path(out) if out else None
19
+
20
+
21
+ @dataclass
22
+ class GitContext:
23
+ root: Path
24
+ staged_paths: list[str] = field(default_factory=list)
25
+ staged_diff: str = ""
26
+ last_commit_subject: str = ""
27
+ last_commit_body: str = ""
28
+ upstream_range: str = ""
29
+
30
+ def diff_file(self) -> Path:
31
+ f = self.root / ".giton" / "last_diff.patch"
32
+ f.parent.mkdir(parents=True, exist_ok=True)
33
+ f.write_text(self.staged_diff)
34
+ return f
35
+
36
+ def paths_arg(self) -> str:
37
+ return " ".join(self.staged_paths) if self.staged_paths else "."
38
+
39
+
40
+ def collect(cwd: Path | None = None) -> GitContext | None:
41
+ root = repo_root(cwd)
42
+ if not root:
43
+ return None
44
+ staged_names = [
45
+ p.strip()
46
+ for p in _run(
47
+ ["git", "diff", "--cached", "--name-only"], cwd=root
48
+ ).splitlines()
49
+ if p.strip()
50
+ ]
51
+ staged_diff = _run(["git", "diff", "--cached"], cwd=root)
52
+ last_subject = _run(["git", "log", "-1", "--pretty=%s"], cwd=root).strip()
53
+ last_body = _run(["git", "log", "-1", "--pretty=%b"], cwd=root).strip()
54
+ upstream = _run(
55
+ ["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
56
+ cwd=root,
57
+ ).strip()
58
+ rng = f"{upstream}..HEAD" if upstream else ""
59
+ return GitContext(
60
+ root=root,
61
+ staged_paths=staged_names,
62
+ staged_diff=staged_diff,
63
+ last_commit_subject=last_subject,
64
+ last_commit_body=last_body,
65
+ upstream_range=rng,
66
+ )
giton/hooks.py ADDED
@@ -0,0 +1,48 @@
1
+ """Install / uninstall git hooks that delegate to `giton hook <name>`."""
2
+ from __future__ import annotations
3
+
4
+ import os
5
+ import stat
6
+ from pathlib import Path
7
+
8
+ HOOKS = ("pre-commit", "post-commit", "pre-push")
9
+
10
+ HOOK_TEMPLATE = """#!/bin/sh
11
+ # Installed by giton — delegates to: giton hook {name}
12
+ exec giton hook {name} "$@"
13
+ """
14
+
15
+
16
+ def hooks_dir(repo_root: Path) -> Path:
17
+ return repo_root / ".git" / "hooks"
18
+
19
+
20
+ def install(repo_root: Path) -> list[Path]:
21
+ hd = hooks_dir(repo_root)
22
+ if not hd.exists():
23
+ raise FileNotFoundError(f"Not a git repository: {repo_root}")
24
+ written: list[Path] = []
25
+ for hook in HOOKS:
26
+ target = hd / hook
27
+ if target.exists():
28
+ backup = target.with_suffix(target.suffix + ".giton-backup")
29
+ if not backup.exists():
30
+ target.rename(backup)
31
+ target.write_text(HOOK_TEMPLATE.format(name=hook))
32
+ target.chmod(target.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
33
+ written.append(target)
34
+ return written
35
+
36
+
37
+ def uninstall(repo_root: Path) -> list[Path]:
38
+ hd = hooks_dir(repo_root)
39
+ removed: list[Path] = []
40
+ for hook in HOOKS:
41
+ target = hd / hook
42
+ if target.exists() and "giton hook" in target.read_text():
43
+ target.unlink()
44
+ backup = target.with_suffix(target.suffix + ".giton-backup")
45
+ if backup.exists():
46
+ backup.rename(target)
47
+ removed.append(target)
48
+ return removed
giton/plugins.py ADDED
@@ -0,0 +1,120 @@
1
+ """Plugin install / list / enable management."""
2
+ from __future__ import annotations
3
+
4
+ import shutil
5
+ import subprocess
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ from rich.console import Console
10
+ from rich.table import Table
11
+
12
+ from giton import catalog
13
+ from giton.config import (
14
+ PluginRecord,
15
+ load_plugins,
16
+ remove_plugin,
17
+ upsert_plugin,
18
+ )
19
+
20
+ console = Console()
21
+
22
+
23
+ def _pip_install(target: str) -> int:
24
+ cmd = [sys.executable, "-m", "pip", "install", target]
25
+ console.print(f"[dim]$ {' '.join(cmd)}[/dim]")
26
+ return subprocess.run(cmd, check=False).returncode
27
+
28
+
29
+ def install_from_catalog(name: str, *, prefer_local: bool = True) -> bool:
30
+ entry = catalog.find(name)
31
+ if entry is None:
32
+ console.print(f"[red]Unknown plugin: {name}[/red]")
33
+ return False
34
+
35
+ target: str | None = None
36
+ if prefer_local and entry.pip_local_path:
37
+ local = (Path(__file__).resolve().parents[2] / entry.pip_local_path).resolve()
38
+ if local.exists() and (local / "pyproject.toml").exists():
39
+ target = str(local)
40
+ if target is None:
41
+ target = entry.record.install or name
42
+
43
+ rc = _pip_install(target)
44
+ if rc != 0:
45
+ console.print(
46
+ f"[yellow]pip install failed for {name}; "
47
+ f"registering plugin record anyway[/yellow]"
48
+ )
49
+ upsert_plugin(entry.record)
50
+ console.print(f"[green]✓ registered plugin '{name}'[/green]")
51
+ return rc == 0
52
+
53
+
54
+ def install_defaults() -> None:
55
+ for entry in catalog.defaults():
56
+ install_from_catalog(entry.record.name)
57
+
58
+
59
+ def install_category(category: str) -> int:
60
+ matches = [e for e in catalog.CATALOG.values() if e.record.category == category]
61
+ if not matches:
62
+ console.print(f"[red]No plugins in category '{category}'[/red]")
63
+ return 0
64
+ n = 0
65
+ for e in matches:
66
+ if install_from_catalog(e.record.name):
67
+ n += 1
68
+ return n
69
+
70
+
71
+ def uninstall(name: str) -> bool:
72
+ if remove_plugin(name):
73
+ console.print(f"[green]✓ removed plugin '{name}'[/green]")
74
+ return True
75
+ console.print(f"[yellow]plugin '{name}' was not registered[/yellow]")
76
+ return False
77
+
78
+
79
+ def show_table() -> None:
80
+ plugins = load_plugins()
81
+ table = Table(title="giton plugins", show_lines=False)
82
+ table.add_column("name", style="bold")
83
+ table.add_column("category")
84
+ table.add_column("triggers")
85
+ table.add_column("command", style="dim")
86
+ table.add_column("status")
87
+ for p in plugins:
88
+ present = "✓" if shutil.which(p.command.split()[0]) else "✗"
89
+ status = f"{'enabled' if p.enabled else 'disabled'} / cmd:{present}"
90
+ table.add_row(
91
+ p.name,
92
+ p.category,
93
+ ",".join(p.triggers),
94
+ p.command,
95
+ status,
96
+ )
97
+ if not plugins:
98
+ console.print("[dim]No plugins registered. Try: giton plugin install-defaults[/dim]")
99
+ else:
100
+ console.print(table)
101
+
102
+
103
+ def show_catalog() -> None:
104
+ table = Table(title="giton catalog (available plugins)")
105
+ table.add_column("name", style="bold")
106
+ table.add_column("category")
107
+ table.add_column("default", justify="center")
108
+ table.add_column("description")
109
+ defaults = set(catalog.DEFAULT_PLUGIN_NAMES)
110
+ for name, entry in catalog.CATALOG.items():
111
+ table.add_row(
112
+ name,
113
+ entry.record.category,
114
+ "★" if name in defaults else "",
115
+ entry.record.description,
116
+ )
117
+ console.print(table)
118
+ console.print("\n[bold]Categories[/bold]")
119
+ for cat, names in catalog.list_categories().items():
120
+ console.print(f" [cyan]{cat}[/cyan]: {', '.join(names)}")
giton/runner.py ADDED
@@ -0,0 +1,85 @@
1
+ """Run plugins for a given hook trigger."""
2
+ from __future__ import annotations
3
+
4
+ import shlex
5
+ import subprocess
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+
9
+ from rich.console import Console
10
+
11
+ from giton.config import PluginRecord, load_plugins
12
+ from giton.context import GitContext, collect
13
+
14
+ console = Console()
15
+
16
+
17
+ @dataclass
18
+ class PluginResult:
19
+ plugin: str
20
+ returncode: int
21
+ stdout: str
22
+ stderr: str
23
+
24
+ @property
25
+ def ok(self) -> bool:
26
+ return self.returncode == 0
27
+
28
+
29
+ def _format_command(cmd: str, ctx: GitContext) -> str:
30
+ return cmd.format(
31
+ paths=ctx.paths_arg(),
32
+ diff_file=str(ctx.diff_file()),
33
+ root=str(ctx.root),
34
+ )
35
+
36
+
37
+ def run_trigger(trigger: str, cwd: Path | None = None) -> list[PluginResult]:
38
+ ctx = collect(cwd)
39
+ if ctx is None:
40
+ console.print("[yellow]giton: not inside a git repository[/yellow]")
41
+ return []
42
+
43
+ plugins = [p for p in load_plugins() if p.enabled and trigger in p.triggers]
44
+ if not plugins:
45
+ console.print(f"[dim]giton: no plugins registered for {trigger}[/dim]")
46
+ return []
47
+
48
+ results: list[PluginResult] = []
49
+ for plugin in plugins:
50
+ results.append(_run_plugin(plugin, ctx))
51
+ return results
52
+
53
+
54
+ def _run_plugin(plugin: PluginRecord, ctx: GitContext) -> PluginResult:
55
+ if plugin.exec_type != "cli":
56
+ console.print(
57
+ f"[yellow]giton: exec_type '{plugin.exec_type}' not yet "
58
+ f"implemented for plugin {plugin.name}[/yellow]"
59
+ )
60
+ return PluginResult(plugin.name, 0, "", "skipped")
61
+
62
+ cmd_str = _format_command(plugin.command, ctx)
63
+ console.print(f"[bold cyan]› {plugin.name}[/bold cyan] [dim]{cmd_str}[/dim]")
64
+ try:
65
+ proc = subprocess.run(
66
+ shlex.split(cmd_str),
67
+ cwd=ctx.root,
68
+ check=False,
69
+ capture_output=True,
70
+ text=True,
71
+ )
72
+ except FileNotFoundError:
73
+ console.print(
74
+ f"[red]giton: plugin '{plugin.name}' not installed "
75
+ f"(command: {cmd_str.split()[0]})[/red]"
76
+ )
77
+ return PluginResult(plugin.name, 127, "", "command not found")
78
+
79
+ if proc.stdout:
80
+ console.print(proc.stdout.rstrip())
81
+ if proc.stderr:
82
+ console.print(f"[dim]{proc.stderr.rstrip()}[/dim]")
83
+ status = "[green]ok[/green]" if proc.returncode == 0 else f"[red]fail ({proc.returncode})[/red]"
84
+ console.print(f" → {status}")
85
+ return PluginResult(plugin.name, proc.returncode, proc.stdout, proc.stderr)
giton/shell.py ADDED
@@ -0,0 +1,168 @@
1
+ """Interactive `giton shell` REPL.
2
+
3
+ Lightweight, dependency-free (uses builtin `input`). Provides shortcuts for
4
+ the most common operations: managing plugins, running hooks, inspecting
5
+ the current repo. Type `help` to see commands.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import shlex
10
+ from pathlib import Path
11
+
12
+ from rich.console import Console
13
+ from rich.panel import Panel
14
+
15
+ from giton import catalog, plugins as plug
16
+ from giton.context import collect, repo_root
17
+ from giton.hooks import install as install_hooks
18
+ from giton.runner import run_trigger
19
+
20
+ console = Console()
21
+
22
+ BANNER = """[bold cyan]giton[/bold cyan] interactive shell — local AI layer for git
23
+ type [bold]help[/bold] for commands, [bold]exit[/bold] to quit
24
+ """
25
+
26
+ HELP = """\
27
+ [bold]Plugins[/bold]
28
+ ls list registered plugins
29
+ catalog show available plugins + categories
30
+ install <name> install a plugin from the catalog
31
+ install-defaults install the 3 default plugins (pyqual, vallm, pretest)
32
+ install-category <cat> install all plugins of a category (e.g. lang:python)
33
+ remove <name> unregister a plugin
34
+ enable <name> / disable <name>
35
+
36
+ [bold]Repo / hooks[/bold]
37
+ init install git hooks in the current repo
38
+ status show repo + staged-files summary
39
+ hook <pre-commit|post-commit|pre-push>
40
+ run all plugins for that trigger
41
+
42
+ [bold]Misc[/bold]
43
+ help show this help
44
+ exit / quit leave the shell
45
+ """
46
+
47
+
48
+ def _set_enabled(name: str, value: bool) -> None:
49
+ from giton.config import load_plugins, save_plugins
50
+ plugins = load_plugins()
51
+ found = False
52
+ for p in plugins:
53
+ if p.name == name:
54
+ p.enabled = value
55
+ found = True
56
+ if found:
57
+ save_plugins(plugins)
58
+ console.print(f"[green]{'enabled' if value else 'disabled'} {name}[/green]")
59
+ else:
60
+ console.print(f"[yellow]plugin '{name}' not registered[/yellow]")
61
+
62
+
63
+ def _cmd_status() -> None:
64
+ ctx = collect()
65
+ if not ctx:
66
+ console.print("[yellow]not inside a git repo[/yellow]")
67
+ return
68
+ console.print(
69
+ Panel.fit(
70
+ f"[bold]repo[/bold] {ctx.root}\n"
71
+ f"[bold]last[/bold] {ctx.last_commit_subject or '(no commits yet)'}\n"
72
+ f"[bold]staged[/bold] {len(ctx.staged_paths)} file(s)"
73
+ + ("\n " + "\n ".join(ctx.staged_paths) if ctx.staged_paths else ""),
74
+ title="giton status",
75
+ )
76
+ )
77
+
78
+
79
+ def _cmd_init() -> None:
80
+ root = repo_root()
81
+ if not root:
82
+ console.print("[red]not inside a git repository[/red]")
83
+ return
84
+ written = install_hooks(root)
85
+ console.print(f"[green]installed {len(written)} hook(s) in {root}/.git/hooks[/green]")
86
+ for w in written:
87
+ console.print(f" • {w.name}")
88
+
89
+
90
+ COMMANDS = {
91
+ "ls", "catalog", "install", "install-defaults", "install-category",
92
+ "remove", "enable", "disable", "init", "status", "hook",
93
+ "help", "exit", "quit",
94
+ }
95
+
96
+
97
+ def dispatch(line: str) -> bool:
98
+ """Return False if the shell should exit."""
99
+ line = line.strip()
100
+ if not line:
101
+ return True
102
+ parts = shlex.split(line)
103
+ cmd, args = parts[0], parts[1:]
104
+
105
+ if cmd in {"exit", "quit"}:
106
+ return False
107
+ if cmd == "help":
108
+ console.print(HELP)
109
+ elif cmd == "ls":
110
+ plug.show_table()
111
+ elif cmd == "catalog":
112
+ plug.show_catalog()
113
+ elif cmd == "install":
114
+ if not args:
115
+ console.print("[yellow]usage: install <name>[/yellow]")
116
+ else:
117
+ plug.install_from_catalog(args[0])
118
+ elif cmd == "install-defaults":
119
+ plug.install_defaults()
120
+ elif cmd == "install-category":
121
+ if not args:
122
+ console.print("[yellow]usage: install-category <category>[/yellow]")
123
+ console.print("Categories: " + ", ".join(catalog.list_categories()))
124
+ else:
125
+ plug.install_category(args[0])
126
+ elif cmd == "remove":
127
+ if not args:
128
+ console.print("[yellow]usage: remove <name>[/yellow]")
129
+ else:
130
+ plug.uninstall(args[0])
131
+ elif cmd == "enable":
132
+ if not args:
133
+ console.print("[yellow]usage: enable <name>[/yellow]")
134
+ else:
135
+ _set_enabled(args[0], True)
136
+ elif cmd == "disable":
137
+ if not args:
138
+ console.print("[yellow]usage: disable <name>[/yellow]")
139
+ else:
140
+ _set_enabled(args[0], False)
141
+ elif cmd == "init":
142
+ _cmd_init()
143
+ elif cmd == "status":
144
+ _cmd_status()
145
+ elif cmd == "hook":
146
+ if not args or args[0] not in {"pre-commit", "post-commit", "pre-push"}:
147
+ console.print("[yellow]usage: hook <pre-commit|post-commit|pre-push>[/yellow]")
148
+ else:
149
+ run_trigger(args[0])
150
+ else:
151
+ console.print(f"[red]unknown command: {cmd}[/red] — try 'help'")
152
+ return True
153
+
154
+
155
+ def run() -> None:
156
+ console.print(Panel(BANNER, border_style="cyan"))
157
+ while True:
158
+ try:
159
+ line = input("giton> ")
160
+ except (EOFError, KeyboardInterrupt):
161
+ console.print()
162
+ break
163
+ try:
164
+ if not dispatch(line):
165
+ break
166
+ except Exception as e: # pragma: no cover - defensive
167
+ console.print(f"[red]error:[/red] {e}")
168
+ console.print("[dim]bye.[/dim]")
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: giton
3
+ Version: 0.1.2
4
+ Summary: Local AI layer for git: orchestrates policies & plugins between commit and push.
5
+ Author: semcod
6
+ Author-email: Tom Sapletta <tom@sapletta.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: pyyaml>=6.0
11
+ Requires-Dist: rich>=13.7
12
+ Requires-Dist: typer>=0.12
13
+ Provides-Extra: dev
14
+ Requires-Dist: costs>=0.1.20; extra == 'dev'
15
+ Requires-Dist: goal>=2.1.0; extra == 'dev'
16
+ Requires-Dist: pfix>=0.1.60; extra == 'dev'
17
+ Requires-Dist: pytest>=8.0; extra == 'dev'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # giton
21
+
22
+
23
+ ## AI Cost Tracking
24
+
25
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.2-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
26
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.41-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-3.0h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
27
+
28
+ - 🤖 **LLM usage:** $0.4093 (6 commits)
29
+ - 👤 **Human dev:** ~$300 (3.0h @ $100/h, 30min dedup)
30
+
31
+ Generated on 2026-05-27 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
32
+
33
+ ---
34
+
35
+ `giton` is a local AI layer for Git that works between `commit` and `push`.
36
+ It helps standardize commits, propose safe code fixes, and orchestrate external tools via plugins.
37
+
38
+ ## Does something like this already exist?
39
+
40
+ Partially: there are tools for AI commit messages, git hooks, and commit-history rewriting.
41
+ What is still missing is one local operator that:
42
+
43
+ - interacts with the user right after commit,
44
+ - proposes code fixes as additional commits (`fixup!`),
45
+ - cleans up history before `push`,
46
+ - integrates plugins via MCP/REST/CLI/gRPC.
47
+
48
+ ## Proposed direction for `gix`
49
+
50
+ 1. **Local-first with safe defaults**
51
+ - AI proposes changes, user approves them.
52
+ - Prefer `fixup!` commits over automatic history rewriting.
53
+
54
+ 2. **Git hook layer**
55
+ - `pre-commit`: policy validation and quick fixes.
56
+ - `post-commit`: inspect the fresh commit and propose follow-up patches.
57
+ - `pre-push`: standardize history (`autosquash`, commit naming, final checks).
58
+
59
+ 3. **Plugin architecture**
60
+ - Shared input/output contract (JSON schema).
61
+ - Plugin adapters: MCP, REST, CLI shell, gRPC/protobuf.
62
+
63
+ ## MVP usage example
64
+
65
+ After `giton init`, hooks are installed and run automatically from Git lifecycle events.
66
+ The commands below show equivalent manual execution for demonstration/debugging.
67
+
68
+ ```bash
69
+ # 1) initialize hooks in the repository
70
+ giton init
71
+
72
+ # 2) user makes a normal commit
73
+ git add -p
74
+ git commit -m "update stuff"
75
+
76
+ # 3) equivalent manual run: post-commit hook logic
77
+ giton hook post-commit
78
+
79
+ # 4) equivalent manual run: pre-push hook logic
80
+ giton hook pre-push
81
+ ```
82
+
83
+ Example interaction:
84
+
85
+ ```text
86
+ giton: Found 2 issues (example: null check, commit message policy).
87
+ giton: Apply patch and add commit "fixup! ..."? [Y/n]
88
+ ```
89
+
90
+ ## MVP plan
91
+
92
+ - MVP 1: hooks + policy engine + interactive CLI
93
+ - MVP 2: patching + fixup workflow + pre-push autosquash
94
+ - MVP 3: stable plugin API and MCP/REST/CLI/gRPC integrations
95
+
96
+ ## Install
97
+
98
+ ```bash
99
+ pip install giton
100
+ ```
101
+
102
+ ## Quick start
103
+
104
+ ```bash
105
+ giton init # install git hooks + 3 default plugins
106
+ giton shell # interactive REPL
107
+ giton plugin catalog # browse all available plugins
108
+ giton plugin install domd # install a specific extension
109
+ giton plugin install-category lang:python # install everything for a language
110
+ ```
111
+
112
+ ### Default plugins
113
+
114
+ The 3 plugins activated by `gix init` cover the most common
115
+ day-to-day needs in a `commit → push` loop:
116
+
117
+ | name | category | trigger | role |
118
+ | --------- | --------------- | ------------ | ------------------------------------------ |
119
+ | `pyqual` | `lang:python` | `pre-commit` | Python lint / type / complexity checks |
120
+ | `vallm` | `task:validate` | `post-commit`| Validate AI-generated code/patches |
121
+ | `pretest` | `task:test` | `pre-push` | Run / generate tests before push |
122
+
123
+ ### Quick-extend categories
124
+
125
+ Each plugin in the catalog is tagged with a category, so you can install
126
+ groups at once:
127
+
128
+ - **languages:** `lang:python`, `lang:markdown`, `lang:any`
129
+ - **tasks:** `task:validate`, `task:test`, `task:refactor`,
130
+ `task:autofix`, `task:fix`, `task:docs`, `task:security`
131
+ - **integrations:** `integration:mcp`
132
+
133
+ ```bash
134
+ giton plugin install-category task:autofix
135
+ ```
136
+
137
+ ### Interactive shell
138
+
139
+ ```text
140
+ $ giton shell
141
+ giton> help
142
+ giton> install-defaults
143
+ giton> hook pre-commit
144
+ giton> catalog
145
+ giton> install prefact
146
+ ```
147
+
148
+ ### Plugin contract
149
+
150
+ A plugin is any executable command (CLI). The catalog entry declares its
151
+ trigger, category, install target (PyPI/local path) and command template.
152
+ The runner expands `{paths}`, `{diff_file}` and `{root}` placeholders
153
+ with the current git context before invocation.
154
+
155
+ Future exec types (`mcp`, `rest`) will share the same JSON in/out
156
+ contract: input = git context + policy findings, output = list of
157
+ proposed actions (patches, fixup commits, warnings).
158
+
159
+
160
+ ## License
161
+
162
+ Licensed under Apache-2.0.
@@ -0,0 +1,15 @@
1
+ giton/__init__.py,sha256=y-NNnl_lgT4vtmm9UzbpyR2x2bUM1Y0u8lM8CVV0uVk,88
2
+ giton/__main__.py,sha256=heJWDTM0XZjRAsWupjf4c4gB5f-T-KdtqJAqtQtnFhw,64
3
+ giton/catalog.py,sha256=Q_rmEofo47o9qp1HtngjK3WnxpkFLjekcNLzi1UQs6o,4931
4
+ giton/cli.py,sha256=T1XI-8wIOCAxwXq9Hlk6-47QPFwLj_lxJAcpyt8xw1E,4977
5
+ giton/config.py,sha256=0COeuXAO7iTObSwuVao9fVU5FjalJ2jLg2t3Yoz4g-I,2190
6
+ giton/context.py,sha256=oyhLV0_A_2bCYIUuwvtJqCw_qzWeAa39iB2YuC8NOVA,1979
7
+ giton/hooks.py,sha256=UtGnbycg6f4_vYFfFIe7kxlcoI7aACWtzo_fdvNVMN8,1480
8
+ giton/plugins.py,sha256=0L1palw9afn6TnTy3dC4tW_LwgPTWV75xdQkaifyhPo,3639
9
+ giton/runner.py,sha256=_CBMsp51Y7d6zNp9Mr_MmSxa87HJRF5S3QsTYHyi_uc,2511
10
+ giton/shell.py,sha256=wY3jMSzQSpcHLM5pF9RyLWDFeyNM5F-l7TQl83W8yMc,5367
11
+ giton-0.1.2.dist-info/METADATA,sha256=9wPeZj9aZTLBQEwiVxz2mzdAjC-RYBl2VKjk2SD00SM,5236
12
+ giton-0.1.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
13
+ giton-0.1.2.dist-info/entry_points.txt,sha256=qAbV6Ovw8-ES88rDx6xlWYtPi1zh-EDFA4WBgn1ZmdE,40
14
+ giton-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ giton-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ giton = giton.cli:app
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.