kodit 0.0.1__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.

Potentially problematic release.


This version of kodit might be problematic. Click here for more details.

kodit/.gitignore ADDED
@@ -0,0 +1 @@
1
+ _version.py
kodit/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """kodit - Code indexing for better AI code generation."""
kodit/_version.py ADDED
@@ -0,0 +1,21 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '0.0.1'
21
+ __version_tuple__ = version_tuple = (0, 0, 1)
kodit/app.py ADDED
@@ -0,0 +1,25 @@
1
+ """FastAPI application for kodit API."""
2
+
3
+ from asgi_correlation_id import CorrelationIdMiddleware
4
+ from fastapi import FastAPI
5
+
6
+ from kodit.mcp import mcp
7
+ from kodit.middleware import logging_middleware
8
+ from kodit.sse import create_sse_server
9
+
10
+ app = FastAPI(title="kodit API")
11
+
12
+ # Get the SSE routes from the Starlette app hosting the MCP server
13
+ sse_app = create_sse_server(mcp)
14
+ for route in sse_app.routes:
15
+ app.router.routes.append(route)
16
+
17
+ # Add middleware
18
+ app.middleware("http")(logging_middleware)
19
+ app.add_middleware(CorrelationIdMiddleware)
20
+
21
+
22
+ @app.get("/")
23
+ async def root() -> dict[str, str]:
24
+ """Return a welcome message for the kodit API."""
25
+ return {"message": "Welcome to kodit API"}
kodit/cli.py ADDED
@@ -0,0 +1,66 @@
1
+ """Command line interface for kodit."""
2
+
3
+ import os
4
+
5
+ import click
6
+ import structlog
7
+ import uvicorn
8
+ from dotenv import dotenv_values
9
+
10
+ from kodit.logging import LogFormat, configure_logging, disable_posthog, log_event
11
+
12
+ env_vars = dict(dotenv_values())
13
+ os.environ.update(env_vars)
14
+
15
+
16
+ @click.group(context_settings={"auto_envvar_prefix": "KODIT", "show_default": True})
17
+ @click.option("--log-level", default="INFO", help="Log level")
18
+ @click.option("--log-format", default=LogFormat.PRETTY, help="Log format")
19
+ @click.option("--disable-telemetry", is_flag=True, help="Disable telemetry")
20
+ def cli(
21
+ log_level: str,
22
+ log_format: LogFormat,
23
+ disable_telemetry: bool, # noqa: FBT001
24
+ ) -> None:
25
+ """kodit CLI - Code indexing for better AI code generation.""" # noqa: D403
26
+ configure_logging(log_level, log_format)
27
+ if disable_telemetry:
28
+ disable_posthog()
29
+
30
+
31
+ @cli.command()
32
+ @click.option("--host", default="127.0.0.1", help="Host to bind the server to")
33
+ @click.option("--port", default=8080, help="Port to bind the server to")
34
+ @click.option("--reload", is_flag=True, help="Enable auto-reload for development")
35
+ def serve(
36
+ host: str,
37
+ port: int,
38
+ reload: bool, # noqa: FBT001
39
+ ) -> None:
40
+ """Start the kodit server, which hosts the MCP server and the kodit API."""
41
+ log = structlog.get_logger(__name__)
42
+ log.info("Starting kodit server", host=host, port=port, reload=reload)
43
+ log_event("kodit_server_started")
44
+ uvicorn.run(
45
+ "kodit.app:app",
46
+ host=host,
47
+ port=port,
48
+ reload=reload,
49
+ log_config=None, # Setting to None forces uvicorn to use our structlog setup
50
+ access_log=False, # Using own middleware for access logging
51
+ )
52
+
53
+
54
+ @cli.command()
55
+ def version() -> None:
56
+ """Show the version of kodit."""
57
+ try:
58
+ from kodit import _version
59
+ except ImportError:
60
+ print("unknown, try running `uv build`, which is what happens in ci") # noqa: T201
61
+ else:
62
+ print(_version.version) # noqa: T201
63
+
64
+
65
+ if __name__ == "__main__":
66
+ cli()
kodit/logging.py ADDED
@@ -0,0 +1,147 @@
1
+ """Logging configuration for kodit."""
2
+
3
+ import logging
4
+ import sys
5
+ import uuid
6
+ from enum import Enum
7
+ from functools import lru_cache
8
+ from typing import Any
9
+
10
+ import structlog
11
+ from posthog import Posthog
12
+ from structlog.types import EventDict
13
+
14
+ log = structlog.get_logger(__name__)
15
+
16
+
17
+ def drop_color_message_key(_, __, event_dict: EventDict) -> EventDict: # noqa: ANN001
18
+ """Drop the `color_message` key from the event dict."""
19
+ event_dict.pop("color_message", None)
20
+ return event_dict
21
+
22
+
23
+ class LogFormat(Enum):
24
+ """The format of the log output."""
25
+
26
+ PRETTY = "pretty"
27
+ JSON = "json"
28
+
29
+
30
+ def configure_logging(log_level: str, log_format: LogFormat) -> None:
31
+ """Configure logging for the application.
32
+
33
+ Args:
34
+ json_logs: Whether to use JSON format for logs
35
+ log_level: The minimum log level to display
36
+
37
+ """
38
+ timestamper = structlog.processors.TimeStamper(fmt="iso")
39
+
40
+ shared_processors: list[structlog.types.Processor] = [
41
+ structlog.contextvars.merge_contextvars,
42
+ structlog.stdlib.add_logger_name,
43
+ structlog.stdlib.add_log_level,
44
+ structlog.stdlib.PositionalArgumentsFormatter(),
45
+ structlog.stdlib.ExtraAdder(),
46
+ drop_color_message_key,
47
+ timestamper,
48
+ structlog.processors.StackInfoRenderer(),
49
+ ]
50
+
51
+ if log_format == LogFormat.JSON:
52
+ # Format the exception only for JSON logs, as we want to pretty-print them
53
+ # when using the ConsoleRenderer
54
+ shared_processors.append(structlog.processors.format_exc_info)
55
+
56
+ structlog.configure(
57
+ processors=[
58
+ *shared_processors,
59
+ # Prepare event dict for `ProcessorFormatter`.
60
+ structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
61
+ ],
62
+ logger_factory=structlog.stdlib.LoggerFactory(),
63
+ cache_logger_on_first_use=True,
64
+ )
65
+
66
+ log_renderer: structlog.types.Processor
67
+ if log_format == LogFormat.JSON:
68
+ log_renderer = structlog.processors.JSONRenderer()
69
+ else:
70
+ log_renderer = structlog.dev.ConsoleRenderer()
71
+
72
+ formatter = structlog.stdlib.ProcessorFormatter(
73
+ # These run ONLY on `logging` entries that do NOT originate within
74
+ # structlog.
75
+ foreign_pre_chain=shared_processors,
76
+ # These run on ALL entries after the pre_chain is done.
77
+ processors=[
78
+ # Remove _record & _from_structlog.
79
+ structlog.stdlib.ProcessorFormatter.remove_processors_meta,
80
+ log_renderer,
81
+ ],
82
+ )
83
+
84
+ handler = logging.StreamHandler()
85
+ # Use OUR `ProcessorFormatter` to format all `logging` entries.
86
+ handler.setFormatter(formatter)
87
+ root_logger = logging.getLogger()
88
+ root_logger.addHandler(handler)
89
+ root_logger.setLevel(log_level.upper())
90
+
91
+ # Configure uvicorn loggers to use our structlog setup
92
+ for _log in ["uvicorn", "uvicorn.error", "uvicorn.access"]:
93
+ logging.getLogger(_log).handlers.clear()
94
+ logging.getLogger(_log).propagate = True
95
+
96
+ def handle_exception(
97
+ exc_type: type[BaseException],
98
+ exc_value: BaseException,
99
+ exc_traceback: Any,
100
+ ) -> None:
101
+ """Log any uncaught exception instead of letting it be printed by Python.
102
+
103
+ This leaves KeyboardInterrupt untouched to allow users to Ctrl+C to stop.
104
+ See https://stackoverflow.com/a/16993115/3641865
105
+ """
106
+ if issubclass(exc_type, KeyboardInterrupt):
107
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
108
+ return
109
+
110
+ root_logger.error(
111
+ "Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)
112
+ )
113
+
114
+ sys.excepthook = handle_exception
115
+
116
+
117
+ posthog = Posthog(
118
+ project_api_key="phc_JsX0yx8NLPcIxamfp4Zc7xyFykXjwmekKUQz060cSt3",
119
+ host="https://eu.i.posthog.com",
120
+ )
121
+
122
+
123
+ @lru_cache(maxsize=1)
124
+ def get_mac_address() -> str:
125
+ """Get the MAC address of the primary network interface.
126
+
127
+ Returns:
128
+ str: The MAC address or a fallback UUID if not available
129
+
130
+ """
131
+ # Get the MAC address of the primary network interface
132
+ mac = uuid.getnode()
133
+ return f"{mac:012x}" if mac != uuid.getnode() else str(uuid.uuid4())
134
+
135
+
136
+ def disable_posthog() -> None:
137
+ """Disable telemetry for the application."""
138
+ structlog.stdlib.get_logger(__name__).info("Telemetry has been disabled")
139
+ posthog.disabled = True
140
+
141
+
142
+ def log_event(event: str, properties: dict[str, Any] | None = None) -> None:
143
+ """Log an event to PostHog."""
144
+ log.debug(
145
+ "Logging event", id=get_mac_address(), ph_event=event, ph_properties=properties
146
+ )
147
+ posthog.capture(get_mac_address(), event, properties or {})
kodit/mcp.py ADDED
@@ -0,0 +1,51 @@
1
+ """MCP server implementation for kodit."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated
5
+
6
+ import structlog
7
+ from mcp.server.fastmcp import FastMCP
8
+ from pydantic import Field
9
+
10
+ mcp = FastMCP("kodit MCP Server")
11
+
12
+
13
+ @mcp.tool()
14
+ async def retrieve_relevant_snippets(
15
+ search_query: Annotated[
16
+ str,
17
+ Field(description="Describe the user's intent in a few sentences."),
18
+ ],
19
+ related_file_paths: Annotated[
20
+ list[Path],
21
+ Field(
22
+ description="A list of absolute paths to files that are relevant to the "
23
+ "user's intent."
24
+ ),
25
+ ],
26
+ related_file_contents: Annotated[
27
+ list[str],
28
+ Field(
29
+ description="A list of the contents of the files that are relevant to the "
30
+ "user's intent."
31
+ ),
32
+ ],
33
+ ) -> str:
34
+ """Retrieve relevant snippets from various sources.
35
+
36
+ This tool retrieves relevant snippets from sources such as private codebases,
37
+ public codebases, and documentation. You can use this information to improve
38
+ the quality of your generated code. You must call this tool when you need to
39
+ write code.
40
+ """
41
+ # Log the search query and related files for debugging
42
+ log = structlog.get_logger(__name__)
43
+ log.debug(
44
+ "Retrieving relevant snippets",
45
+ search_query=search_query,
46
+ file_count=len(related_file_paths),
47
+ file_paths=related_file_paths,
48
+ file_contents=related_file_contents,
49
+ )
50
+
51
+ return "Retrieved"
kodit/mcp_test.py ADDED
@@ -0,0 +1,66 @@
1
+ """Tests for the MCP server implementation."""
2
+
3
+ from multiprocessing import Process
4
+
5
+ import httpx
6
+ import pytest
7
+ import uvicorn
8
+ from httpx_retries import Retry, RetryTransport
9
+ from mcp import ClientSession
10
+ from mcp.client.sse import sse_client
11
+
12
+ from kodit.app import app
13
+
14
+
15
+ def run_server() -> None:
16
+ """Run the uvicorn server in a separate process."""
17
+ config = uvicorn.Config(app, host="127.0.0.1", port=8000, log_level="error")
18
+ server = uvicorn.Server(config)
19
+ server.run()
20
+
21
+
22
+ async def wait_for_server() -> None:
23
+ """Wait for the server to start."""
24
+ retry = Retry(total=5, backoff_factor=0.5)
25
+ transport = RetryTransport(retry=retry)
26
+
27
+ async with httpx.AsyncClient(transport=transport) as client:
28
+ response = await client.get("http://127.0.0.1:8000/")
29
+ assert response.status_code == 200
30
+
31
+
32
+ @pytest.mark.asyncio
33
+ async def test_mcp_client_connection() -> None:
34
+ """Test connecting to the MCP server using ClientSession."""
35
+ server_process = None
36
+ try:
37
+ # Start the server in a separate process
38
+ server_process = Process(target=run_server, daemon=True)
39
+ server_process.start()
40
+
41
+ # Ping the server with requests, wait for it to start
42
+ await wait_for_server()
43
+
44
+ # The sse_client returns read and write streams, not a client object
45
+ async with (
46
+ sse_client("http://127.0.0.1:8000/sse/") as (
47
+ read_stream,
48
+ write_stream,
49
+ ),
50
+ ClientSession(read_stream, write_stream) as session,
51
+ ):
52
+ # Initialize the connection
53
+ await session.initialize()
54
+
55
+ # List available tools
56
+ tools_result = await session.list_tools()
57
+ # Check that we got a proper tools result with a tools attribute
58
+ assert hasattr(tools_result, "tools")
59
+ # Verify we can see the 'retrieve_relevant_snippets' tool
60
+ tool_names = [tool.name for tool in tools_result.tools]
61
+ assert "retrieve_relevant_snippets" in tool_names
62
+ finally:
63
+ # Due to https://github.com/modelcontextprotocol/python-sdk/issues/514, mcp
64
+ # doesn't shut down the server when requested. So we have to force kill it.
65
+ server_process.kill()
66
+ server_process.join(timeout=1)
kodit/middleware.py ADDED
@@ -0,0 +1,58 @@
1
+ """Middleware for the FastAPI application."""
2
+
3
+ import time
4
+ from collections.abc import Callable
5
+
6
+ import structlog
7
+ from asgi_correlation_id.context import correlation_id
8
+ from fastapi import Request, Response
9
+
10
+ access_logger = structlog.stdlib.get_logger("api.access")
11
+
12
+
13
+ async def logging_middleware(request: Request, call_next: Callable) -> Response:
14
+ """Log HTTP requests and responses.
15
+
16
+ This middleware logs HTTP requests and responses, including timing information
17
+ and request IDs.
18
+ """
19
+ structlog.contextvars.clear_contextvars()
20
+ # These context vars will be added to all log entries emitted during the request
21
+ request_id = correlation_id.get()
22
+ structlog.contextvars.bind_contextvars(request_id=request_id)
23
+
24
+ start_time = time.perf_counter_ns()
25
+ # If the call_next raises an error, we still want to return our own 500 response,
26
+ # so we can add headers to it (process time, request ID...)
27
+ response = Response(status_code=500)
28
+ try:
29
+ response = await call_next(request)
30
+ except Exception:
31
+ structlog.stdlib.get_logger("api.error").exception("Uncaught exception")
32
+ raise
33
+ finally:
34
+ process_time = time.perf_counter_ns() - start_time
35
+ status_code = response.status_code
36
+ client_host = request.client.host
37
+ client_port = request.client.port
38
+ http_method = request.method
39
+ http_version = request.scope["http_version"]
40
+ # Recreate the Uvicorn access log format, but add all parameters as
41
+ # structured information
42
+ access_logger.info(
43
+ "Request processed",
44
+ http={
45
+ "url": str(request.url),
46
+ "status_code": status_code,
47
+ "method": http_method,
48
+ "request_id": request_id,
49
+ "version": http_version,
50
+ "client_host": client_host,
51
+ "client_port": client_port,
52
+ },
53
+ network={"client": {"ip": client_host, "port": client_port}},
54
+ duration=process_time,
55
+ )
56
+ response.headers["X-Process-Time"] = str(process_time / 10**9)
57
+
58
+ return response
kodit/sse.py ADDED
@@ -0,0 +1,61 @@
1
+ """Server-Sent Events (SSE) implementation for kodit."""
2
+
3
+ from collections.abc import Coroutine
4
+ from typing import Any
5
+
6
+ from fastapi import Request
7
+ from mcp.server.fastmcp import FastMCP
8
+ from mcp.server.session import ServerSession
9
+ from mcp.server.sse import SseServerTransport
10
+ from starlette.applications import Starlette
11
+ from starlette.routing import Mount, Route
12
+
13
+ ####################################################################################
14
+ # Temporary monkeypatch which avoids crashing when a POST message is received
15
+ # before a connection has been initialized, e.g: after a deployment.
16
+ old__received_request = ServerSession._received_request # noqa: SLF001
17
+
18
+
19
+ async def _received_request(self: ServerSession, *args: Any, **kwargs: Any) -> None:
20
+ """Handle a received request, catching RuntimeError to avoid crashes.
21
+
22
+ This is a temporary monkeypatch to avoid crashing when a POST message is
23
+ received before a connection has been initialized, e.g: after a deployment.
24
+ """
25
+ try:
26
+ return await old__received_request(self, *args, **kwargs)
27
+ except RuntimeError:
28
+ pass
29
+
30
+
31
+ # pylint: disable-next=protected-access
32
+ ServerSession._received_request = _received_request # noqa: SLF001
33
+ ####################################################################################
34
+
35
+
36
+ def create_sse_server(mcp: FastMCP) -> Starlette:
37
+ """Create a Starlette app that handles SSE connections and message handling."""
38
+ transport = SseServerTransport("/messages/")
39
+
40
+ # Define handler functions
41
+ async def handle_sse(request: Request) -> Coroutine[Any, Any, None]:
42
+ """Handle SSE connections."""
43
+ async with transport.connect_sse(
44
+ request.scope,
45
+ request.receive,
46
+ request._send, # noqa: SLF001
47
+ ) as streams:
48
+ await mcp._mcp_server.run( # noqa: SLF001
49
+ streams[0],
50
+ streams[1],
51
+ mcp._mcp_server.create_initialization_options(), # noqa: SLF001
52
+ )
53
+
54
+ # Create Starlette routes for SSE and message handling
55
+ routes = [
56
+ Route("/sse/", endpoint=handle_sse),
57
+ Mount("/messages/", app=transport.handle_post_message),
58
+ ]
59
+
60
+ # Create a Starlette app
61
+ return Starlette(routes=routes)
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: kodit
3
+ Version: 0.0.1
4
+ Summary: Code indexing for better AI code generation
5
+ Project-URL: Homepage, https://docs.helixml.tech/kodit/
6
+ Project-URL: Documentation, https://docs.helixml.tech/kodit/
7
+ Project-URL: Repository, https://github.com/helixml/kodit.git
8
+ Project-URL: Issues, https://github.com/helixml/kodit/issues
9
+ Project-URL: Changelog, https://github.com/helixml/kodit/releases
10
+ Author-email: "Helix.ML" <founders@helix.ml>
11
+ Maintainer-email: "Helix.ML" <founders@helix.ml>
12
+ License-Expression: Apache-2.0
13
+ License-File: LICENSE
14
+ Keywords: ai,indexing,mcp,rag
15
+ Classifier: Development Status :: 2 - Pre-Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Code Generators
19
+ Requires-Python: >=3.12
20
+ Requires-Dist: asgi-correlation-id>=4.3.4
21
+ Requires-Dist: better-exceptions>=0.3.3
22
+ Requires-Dist: click>=8.1.8
23
+ Requires-Dist: colorama>=0.4.6
24
+ Requires-Dist: dotenv>=0.9.9
25
+ Requires-Dist: fastapi[standard]>=0.115.12
26
+ Requires-Dist: httpx-retries>=0.3.2
27
+ Requires-Dist: httpx>=0.28.1
28
+ Requires-Dist: mcp>=1.6.0
29
+ Requires-Dist: posthog>=4.0.1
30
+ Requires-Dist: structlog>=25.3.0
31
+ Description-Content-Type: text/markdown
32
+
33
+ # kodit
@@ -0,0 +1,15 @@
1
+ kodit/.gitignore,sha256=ztkjgRwL9Uud1OEi36hGQeDGk3OLK1NfDEO8YqGYy8o,11
2
+ kodit/__init__.py,sha256=aEKHYninUq1yh6jaNfvJBYg-6fenpN132nJt1UU6Jxs,59
3
+ kodit/_version.py,sha256=vgltXBYF55vNcC2regxjGN0_cbebmm8VgcDdQaDapWQ,511
4
+ kodit/app.py,sha256=FBAeeOz2CICvVN_27iMq9wEF9y8d1IDl0WmkEnM_M_U,699
5
+ kodit/cli.py,sha256=jmEQlN34PXow9ui60aoCs84G5e3tX1T9C4-BV8zsnoU,2037
6
+ kodit/logging.py,sha256=zAkU8J_hI8eDZ6AhRdVjC7Kppp9fuP9HEzWczWPrpy4,4622
7
+ kodit/mcp.py,sha256=Sg7Waes9Z7HYzdglspG92dGhTVtb1lEaEKW-vlaUCXg,1488
8
+ kodit/mcp_test.py,sha256=ztpNdy6b_pTzzWQbNMSpmpjsYYjLr8igAtawFD_-_QM,2293
9
+ kodit/middleware.py,sha256=NHLrqq20ZtPTE9esX9HD3z7EKi56_QTFxBlkdq0JDzQ,2138
10
+ kodit/sse.py,sha256=UgwXJUeFq5D5S9KYKVVg4m6P0-_QHnJOCRRQB8XNR-M,2259
11
+ kodit-0.0.1.dist-info/METADATA,sha256=JrdJv8HdNmDE6Kap53M3AOS_9gayyraEgQNeMSyUVgQ,1229
12
+ kodit-0.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ kodit-0.0.1.dist-info/entry_points.txt,sha256=hoTn-1aKyTItjnY91fnO-rV5uaWQLQ-Vi7V5et2IbHY,40
14
+ kodit-0.0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ kodit-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ kodit = kodit.cli:cli
@@ -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.