okft 0.1.0__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.
- okft/__init__.py +3 -0
- okft/bundle.py +158 -0
- okft/cli.py +99 -0
- okft/lint.py +168 -0
- okft/server.py +121 -0
- okft-0.1.0.dist-info/METADATA +144 -0
- okft-0.1.0.dist-info/RECORD +10 -0
- okft-0.1.0.dist-info/WHEEL +4 -0
- okft-0.1.0.dist-info/entry_points.txt +2 -0
- okft-0.1.0.dist-info/licenses/LICENSE +202 -0
okft/__init__.py
ADDED
okft/bundle.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Load an OKF bundle from disk into a simple in-memory model.
|
|
2
|
+
|
|
3
|
+
An OKF bundle (spec v0.1) is a directory tree of markdown files:
|
|
4
|
+
|
|
5
|
+
* concept files — YAML frontmatter (required ``type`` field) + markdown body
|
|
6
|
+
* ``index.md`` — reserved, directory listing, no frontmatter
|
|
7
|
+
* ``log.md`` — reserved, chronological update history
|
|
8
|
+
|
|
9
|
+
Links between concepts are ordinary markdown links. Absolute targets
|
|
10
|
+
(``/analytics/tables/customers``) resolve from the bundle root; relative
|
|
11
|
+
targets resolve from the linking file's directory. ``[[wiki-style]]`` links
|
|
12
|
+
are also recognized since they appear in bundles in the wild.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
from dataclasses import dataclass, field
|
|
19
|
+
from pathlib import Path, PurePosixPath
|
|
20
|
+
|
|
21
|
+
import yaml
|
|
22
|
+
|
|
23
|
+
RESERVED_NAMES = {"index.md", "log.md"}
|
|
24
|
+
|
|
25
|
+
# [text](target) — inline markdown links, excluding images handled separately
|
|
26
|
+
_MD_LINK_RE = re.compile(r"!?\[[^\]]*\]\(([^)\s]+)(?:\s+\"[^\"]*\")?\)")
|
|
27
|
+
_WIKI_LINK_RE = re.compile(r"\[\[([^\]|#]+)(?:#[^\]|]*)?(?:\|[^\]]*)?\]\]")
|
|
28
|
+
_EXTERNAL_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9+.-]*:") # any URI scheme
|
|
29
|
+
_FRONTMATTER_RE = re.compile(r"\A---\s*\n(.*?)\n---\s*(?:\n|\Z)", re.DOTALL)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class Link:
|
|
34
|
+
"""A link found in a document, with its resolution against the bundle."""
|
|
35
|
+
|
|
36
|
+
raw: str # the target as written
|
|
37
|
+
line: int # 1-based line number where the link appears
|
|
38
|
+
resolved: str | None # bundle-relative posix path it resolves to, or None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Document:
|
|
43
|
+
"""One markdown file in the bundle."""
|
|
44
|
+
|
|
45
|
+
path: str # bundle-relative posix path, e.g. "analytics/tables/customers.md"
|
|
46
|
+
reserved: bool
|
|
47
|
+
frontmatter: dict | None = None # parsed YAML, None if absent
|
|
48
|
+
frontmatter_error: str | None = None # YAML parse error message, if any
|
|
49
|
+
has_frontmatter_block: bool = False # a "---" block exists, parseable or not
|
|
50
|
+
body: str = ""
|
|
51
|
+
links: list[Link] = field(default_factory=list)
|
|
52
|
+
inbound: set[str] = field(default_factory=set) # paths of documents linking here
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class Bundle:
|
|
57
|
+
root: Path
|
|
58
|
+
documents: dict[str, Document] = field(default_factory=dict) # path -> Document
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def concepts(self) -> dict[str, Document]:
|
|
62
|
+
return {p: d for p, d in self.documents.items() if not d.reserved}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def split_frontmatter(text: str) -> tuple[str | None, str]:
|
|
66
|
+
"""Return (frontmatter_yaml_source, body). Frontmatter source is None if absent."""
|
|
67
|
+
m = _FRONTMATTER_RE.match(text)
|
|
68
|
+
if not m:
|
|
69
|
+
return None, text
|
|
70
|
+
return m.group(1), text[m.end():]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _resolve_target(raw: str, doc_path: str, root: Path) -> str | None:
|
|
74
|
+
"""Resolve a link target to a bundle-relative path, or None if unresolvable.
|
|
75
|
+
|
|
76
|
+
Tries the target as written, then with ``.md`` appended, then as a
|
|
77
|
+
directory containing ``index.md``. External URIs and pure anchors
|
|
78
|
+
resolve to None without being treated as internal.
|
|
79
|
+
"""
|
|
80
|
+
target = raw.split("#", 1)[0]
|
|
81
|
+
if not target or _EXTERNAL_RE.match(target):
|
|
82
|
+
return None
|
|
83
|
+
if target.startswith("/"):
|
|
84
|
+
candidate = PurePosixPath(target.lstrip("/"))
|
|
85
|
+
else:
|
|
86
|
+
candidate = PurePosixPath(doc_path).parent / target
|
|
87
|
+
# normalize ".." / "." segments
|
|
88
|
+
parts: list[str] = []
|
|
89
|
+
for part in candidate.parts:
|
|
90
|
+
if part == "..":
|
|
91
|
+
if not parts:
|
|
92
|
+
return None # escapes the bundle root
|
|
93
|
+
parts.pop()
|
|
94
|
+
elif part != ".":
|
|
95
|
+
parts.append(part)
|
|
96
|
+
rel = PurePosixPath(*parts) if parts else PurePosixPath(".")
|
|
97
|
+
for attempt in (rel, rel.with_suffix(rel.suffix + ".md") if rel.suffix != ".md" else None, rel / "index.md"):
|
|
98
|
+
if attempt is None:
|
|
99
|
+
continue
|
|
100
|
+
if (root / attempt).is_file():
|
|
101
|
+
return str(attempt)
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _extract_links(body: str, fm_line_offset: int, doc_path: str, root: Path) -> list[Link]:
|
|
106
|
+
links: list[Link] = []
|
|
107
|
+
for lineno, line in enumerate(body.splitlines(), start=fm_line_offset + 1):
|
|
108
|
+
for m in _MD_LINK_RE.finditer(line):
|
|
109
|
+
raw = m.group(1)
|
|
110
|
+
if _EXTERNAL_RE.match(raw) or raw.startswith("#"):
|
|
111
|
+
continue
|
|
112
|
+
links.append(Link(raw=raw, line=lineno, resolved=_resolve_target(raw, doc_path, root)))
|
|
113
|
+
for m in _WIKI_LINK_RE.finditer(line):
|
|
114
|
+
raw = m.group(1).strip()
|
|
115
|
+
# wiki links are conventionally bundle-root-relative
|
|
116
|
+
links.append(Link(raw=raw, line=lineno, resolved=_resolve_target("/" + raw.lstrip("/"), doc_path, root)))
|
|
117
|
+
return links
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def load_bundle(root: str | Path) -> Bundle:
|
|
121
|
+
root = Path(root).resolve()
|
|
122
|
+
bundle = Bundle(root=root)
|
|
123
|
+
|
|
124
|
+
for file in sorted(root.rglob("*.md")):
|
|
125
|
+
if any(part.startswith(".") for part in file.relative_to(root).parts):
|
|
126
|
+
continue # skip .git, .obsidian, etc.
|
|
127
|
+
rel = file.relative_to(root).as_posix()
|
|
128
|
+
reserved = file.name in RESERVED_NAMES
|
|
129
|
+
try:
|
|
130
|
+
text = file.read_text(encoding="utf-8")
|
|
131
|
+
except UnicodeDecodeError:
|
|
132
|
+
doc = Document(path=rel, reserved=reserved, frontmatter_error="file is not valid UTF-8")
|
|
133
|
+
bundle.documents[rel] = doc
|
|
134
|
+
continue
|
|
135
|
+
|
|
136
|
+
fm_source, body = split_frontmatter(text)
|
|
137
|
+
doc = Document(path=rel, reserved=reserved, body=body)
|
|
138
|
+
fm_lines = 0
|
|
139
|
+
if fm_source is not None:
|
|
140
|
+
doc.has_frontmatter_block = True
|
|
141
|
+
fm_lines = fm_source.count("\n") + 3 # opening ---, content, closing ---
|
|
142
|
+
try:
|
|
143
|
+
parsed = yaml.safe_load(fm_source)
|
|
144
|
+
if parsed is not None and not isinstance(parsed, dict):
|
|
145
|
+
doc.frontmatter_error = f"frontmatter is a {type(parsed).__name__}, expected a mapping"
|
|
146
|
+
else:
|
|
147
|
+
doc.frontmatter = parsed or {}
|
|
148
|
+
except yaml.YAMLError as e:
|
|
149
|
+
doc.frontmatter_error = str(e).splitlines()[0]
|
|
150
|
+
doc.links = _extract_links(body, fm_lines, rel, root)
|
|
151
|
+
bundle.documents[rel] = doc
|
|
152
|
+
|
|
153
|
+
for path, doc in bundle.documents.items():
|
|
154
|
+
for link in doc.links:
|
|
155
|
+
if link.resolved and link.resolved in bundle.documents:
|
|
156
|
+
bundle.documents[link.resolved].inbound.add(path)
|
|
157
|
+
|
|
158
|
+
return bundle
|
okft/cli.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""okft — lint and serve Open Knowledge Format bundles."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .bundle import load_bundle
|
|
12
|
+
from .lint import lint_bundle
|
|
13
|
+
|
|
14
|
+
_RED = "\033[31m"
|
|
15
|
+
_YELLOW = "\033[33m"
|
|
16
|
+
_DIM = "\033[2m"
|
|
17
|
+
_RESET = "\033[0m"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _print_human(findings, bundle, use_color: bool) -> None:
|
|
21
|
+
def paint(text, color):
|
|
22
|
+
return f"{color}{text}{_RESET}" if use_color else text
|
|
23
|
+
|
|
24
|
+
for f in findings:
|
|
25
|
+
color = _RED if f.severity == "error" else _YELLOW
|
|
26
|
+
print(f"{f.path}:{f.line} {paint(f.severity, color)} {paint(f.code, _DIM)} {f.message}")
|
|
27
|
+
|
|
28
|
+
errors = sum(1 for f in findings if f.severity == "error")
|
|
29
|
+
warnings = len(findings) - errors
|
|
30
|
+
n = len(bundle.concepts)
|
|
31
|
+
if findings:
|
|
32
|
+
print()
|
|
33
|
+
print(f"{n} concept{'s' if n != 1 else ''} checked: "
|
|
34
|
+
f"{paint(f'{errors} error(s)', _RED if errors else _DIM)}, "
|
|
35
|
+
f"{paint(f'{warnings} warning(s)', _YELLOW if warnings else _DIM)}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def cmd_lint(args: argparse.Namespace) -> int:
|
|
39
|
+
root = Path(args.path)
|
|
40
|
+
if not root.is_dir():
|
|
41
|
+
print(f"okf: {root} is not a directory", file=sys.stderr)
|
|
42
|
+
return 2
|
|
43
|
+
bundle = load_bundle(root)
|
|
44
|
+
if not bundle.documents:
|
|
45
|
+
print(f"okf: no markdown files found under {root}", file=sys.stderr)
|
|
46
|
+
return 2
|
|
47
|
+
findings = lint_bundle(bundle, orphans=not args.no_orphans)
|
|
48
|
+
|
|
49
|
+
if args.format == "json":
|
|
50
|
+
print(json.dumps({
|
|
51
|
+
"bundle": str(bundle.root),
|
|
52
|
+
"concepts": len(bundle.concepts),
|
|
53
|
+
"findings": [f.to_dict() for f in findings],
|
|
54
|
+
}, indent=2))
|
|
55
|
+
else:
|
|
56
|
+
_print_human(findings, bundle, use_color=sys.stdout.isatty())
|
|
57
|
+
|
|
58
|
+
has_errors = any(f.severity == "error" for f in findings)
|
|
59
|
+
if has_errors or (args.strict and findings):
|
|
60
|
+
return 1
|
|
61
|
+
return 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def cmd_serve(args: argparse.Namespace) -> int:
|
|
65
|
+
root = Path(args.path)
|
|
66
|
+
if not root.is_dir():
|
|
67
|
+
print(f"okf: {root} is not a directory", file=sys.stderr)
|
|
68
|
+
return 2
|
|
69
|
+
from .server import serve
|
|
70
|
+
serve(str(root), name=args.name)
|
|
71
|
+
return 0
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def main(argv: list[str] | None = None) -> int:
|
|
75
|
+
parser = argparse.ArgumentParser(
|
|
76
|
+
prog="okft",
|
|
77
|
+
description="Lint and serve Open Knowledge Format (OKF) bundles.",
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument("--version", action="version", version=f"okft {__version__}")
|
|
80
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
81
|
+
|
|
82
|
+
p_lint = sub.add_parser("lint", help="check a bundle for spec conformance and hygiene issues")
|
|
83
|
+
p_lint.add_argument("path", nargs="?", default=".", help="bundle root (default: current directory)")
|
|
84
|
+
p_lint.add_argument("--format", choices=["text", "json"], default="text")
|
|
85
|
+
p_lint.add_argument("--strict", action="store_true", help="exit non-zero on warnings too")
|
|
86
|
+
p_lint.add_argument("--no-orphans", action="store_true", help="skip orphan-concept detection")
|
|
87
|
+
p_lint.set_defaults(func=cmd_lint)
|
|
88
|
+
|
|
89
|
+
p_serve = sub.add_parser("serve", help="serve a bundle to AI agents as an MCP server (stdio)")
|
|
90
|
+
p_serve.add_argument("path", nargs="?", default=".", help="bundle root (default: current directory)")
|
|
91
|
+
p_serve.add_argument("--name", default="okf", help="MCP server name (default: okf)")
|
|
92
|
+
p_serve.set_defaults(func=cmd_serve)
|
|
93
|
+
|
|
94
|
+
args = parser.parse_args(argv)
|
|
95
|
+
return args.func(args)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
sys.exit(main())
|
okft/lint.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Lint rules for OKF v0.1 bundles.
|
|
2
|
+
|
|
3
|
+
Errors are spec-conformance violations; warnings are hygiene issues a
|
|
4
|
+
conforming bundle may still have. Notably, the spec says consumers MUST
|
|
5
|
+
tolerate broken links, so unresolved links are warnings, never errors.
|
|
6
|
+
|
|
7
|
+
Rules
|
|
8
|
+
-----
|
|
9
|
+
E001 concept file has no YAML frontmatter block
|
|
10
|
+
E002 frontmatter is not parseable YAML (or not a mapping)
|
|
11
|
+
E003 frontmatter has a missing or empty ``type`` field
|
|
12
|
+
E004 reserved file (index.md / log.md) has frontmatter
|
|
13
|
+
W001 link target does not resolve inside the bundle
|
|
14
|
+
W002 ``timestamp`` is not an ISO 8601 date/datetime
|
|
15
|
+
W003 ``tags`` is not a list of strings
|
|
16
|
+
W004 concept is an orphan (no inbound links from any document)
|
|
17
|
+
W005 bundle root has no index.md (progressive-disclosure entry point)
|
|
18
|
+
W006 log.md has headings but none are ISO 8601 dates
|
|
19
|
+
W007 concept has no ``title`` (recommended field)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import datetime as _dt
|
|
25
|
+
import re
|
|
26
|
+
from dataclasses import dataclass
|
|
27
|
+
from pathlib import PurePosixPath
|
|
28
|
+
|
|
29
|
+
from .bundle import Bundle, Document
|
|
30
|
+
|
|
31
|
+
_HEADING_RE = re.compile(r"^#{1,6}\s+(.*)$", re.MULTILINE)
|
|
32
|
+
_ISO_DATE_PREFIX_RE = re.compile(r"^\d{4}-\d{2}-\d{2}")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class Finding:
|
|
37
|
+
severity: str # "error" | "warning"
|
|
38
|
+
code: str
|
|
39
|
+
path: str
|
|
40
|
+
line: int
|
|
41
|
+
message: str
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict:
|
|
44
|
+
return {
|
|
45
|
+
"severity": self.severity,
|
|
46
|
+
"code": self.code,
|
|
47
|
+
"path": self.path,
|
|
48
|
+
"line": self.line,
|
|
49
|
+
"message": self.message,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _valid_timestamp(value) -> bool:
|
|
54
|
+
if isinstance(value, (_dt.date, _dt.datetime)):
|
|
55
|
+
return True # YAML already parsed it as a date
|
|
56
|
+
if not isinstance(value, str):
|
|
57
|
+
return False
|
|
58
|
+
try:
|
|
59
|
+
_dt.datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
60
|
+
return True
|
|
61
|
+
except ValueError:
|
|
62
|
+
try:
|
|
63
|
+
_dt.date.fromisoformat(value)
|
|
64
|
+
return True
|
|
65
|
+
except ValueError:
|
|
66
|
+
return False
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _check_frontmatter(doc: Document, findings: list[Finding]) -> None:
|
|
70
|
+
if doc.reserved:
|
|
71
|
+
if doc.has_frontmatter_block:
|
|
72
|
+
findings.append(Finding(
|
|
73
|
+
"error", "E004", doc.path, 1,
|
|
74
|
+
f"reserved file {PurePosixPath(doc.path).name} must not have frontmatter",
|
|
75
|
+
))
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
if not doc.has_frontmatter_block:
|
|
79
|
+
findings.append(Finding(
|
|
80
|
+
"error", "E001", doc.path, 1,
|
|
81
|
+
"concept file has no YAML frontmatter block",
|
|
82
|
+
))
|
|
83
|
+
return
|
|
84
|
+
if doc.frontmatter_error is not None:
|
|
85
|
+
findings.append(Finding(
|
|
86
|
+
"error", "E002", doc.path, 1,
|
|
87
|
+
f"frontmatter does not parse: {doc.frontmatter_error}",
|
|
88
|
+
))
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
fm = doc.frontmatter or {}
|
|
92
|
+
type_value = fm.get("type")
|
|
93
|
+
if not isinstance(type_value, str) or not type_value.strip():
|
|
94
|
+
findings.append(Finding(
|
|
95
|
+
"error", "E003", doc.path, 1,
|
|
96
|
+
"frontmatter must include a non-empty `type` field",
|
|
97
|
+
))
|
|
98
|
+
|
|
99
|
+
if "timestamp" in fm and not _valid_timestamp(fm["timestamp"]):
|
|
100
|
+
findings.append(Finding(
|
|
101
|
+
"warning", "W002", doc.path, 1,
|
|
102
|
+
f"`timestamp` is not ISO 8601: {fm['timestamp']!r}",
|
|
103
|
+
))
|
|
104
|
+
|
|
105
|
+
if "tags" in fm:
|
|
106
|
+
tags = fm["tags"]
|
|
107
|
+
if not isinstance(tags, list) or not all(isinstance(t, str) for t in tags):
|
|
108
|
+
findings.append(Finding(
|
|
109
|
+
"warning", "W003", doc.path, 1,
|
|
110
|
+
"`tags` should be a YAML list of strings",
|
|
111
|
+
))
|
|
112
|
+
|
|
113
|
+
if "title" not in fm:
|
|
114
|
+
findings.append(Finding(
|
|
115
|
+
"warning", "W007", doc.path, 1,
|
|
116
|
+
"concept has no `title` (recommended field)",
|
|
117
|
+
))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _check_links(doc: Document, findings: list[Finding]) -> None:
|
|
121
|
+
for link in doc.links:
|
|
122
|
+
if link.resolved is None:
|
|
123
|
+
findings.append(Finding(
|
|
124
|
+
"warning", "W001", doc.path, link.line,
|
|
125
|
+
f"link target does not resolve in bundle: {link.raw}",
|
|
126
|
+
))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _check_orphans(bundle: Bundle, findings: list[Finding]) -> None:
|
|
130
|
+
for path, doc in bundle.concepts.items():
|
|
131
|
+
if not doc.inbound:
|
|
132
|
+
findings.append(Finding(
|
|
133
|
+
"warning", "W004", path, 1,
|
|
134
|
+
"concept is never linked from any other document",
|
|
135
|
+
))
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _check_indexes(bundle: Bundle, findings: list[Finding]) -> None:
|
|
139
|
+
if bundle.concepts and "index.md" not in bundle.documents:
|
|
140
|
+
findings.append(Finding(
|
|
141
|
+
"warning", "W005", "index.md", 1,
|
|
142
|
+
"bundle root has no index.md — agents rely on it as the entry point",
|
|
143
|
+
))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _check_logs(bundle: Bundle, findings: list[Finding]) -> None:
|
|
147
|
+
for path, doc in bundle.documents.items():
|
|
148
|
+
if PurePosixPath(path).name != "log.md":
|
|
149
|
+
continue
|
|
150
|
+
headings = _HEADING_RE.findall(doc.body)
|
|
151
|
+
if headings and not any(_ISO_DATE_PREFIX_RE.match(h.strip()) for h in headings):
|
|
152
|
+
findings.append(Finding(
|
|
153
|
+
"warning", "W006", path, 1,
|
|
154
|
+
"log.md headings should be ISO 8601 dates (e.g. `## 2026-07-14`)",
|
|
155
|
+
))
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def lint_bundle(bundle: Bundle, orphans: bool = True) -> list[Finding]:
|
|
159
|
+
findings: list[Finding] = []
|
|
160
|
+
for doc in bundle.documents.values():
|
|
161
|
+
_check_frontmatter(doc, findings)
|
|
162
|
+
_check_links(doc, findings)
|
|
163
|
+
if orphans:
|
|
164
|
+
_check_orphans(bundle, findings)
|
|
165
|
+
_check_indexes(bundle, findings)
|
|
166
|
+
_check_logs(bundle, findings)
|
|
167
|
+
findings.sort(key=lambda f: (f.path, f.line, f.code))
|
|
168
|
+
return findings
|
okft/server.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""MCP server exposing an OKF bundle to AI agents over stdio.
|
|
2
|
+
|
|
3
|
+
Tools mirror how the spec expects a bundle to be consumed: start at the
|
|
4
|
+
root index, navigate links deterministically, read one concept at a time.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from pathlib import PurePosixPath
|
|
11
|
+
|
|
12
|
+
from .bundle import Bundle, load_bundle
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _doc_summary(bundle: Bundle, path: str) -> dict:
|
|
16
|
+
doc = bundle.documents[path]
|
|
17
|
+
fm = doc.frontmatter or {}
|
|
18
|
+
return {
|
|
19
|
+
"path": path,
|
|
20
|
+
"type": fm.get("type"),
|
|
21
|
+
"title": fm.get("title") or PurePosixPath(path).stem,
|
|
22
|
+
"description": fm.get("description"),
|
|
23
|
+
"tags": fm.get("tags", []),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_server(bundle_root: str, name: str = "okf"):
|
|
28
|
+
try:
|
|
29
|
+
from mcp.server.fastmcp import FastMCP
|
|
30
|
+
except ImportError as e: # pragma: no cover
|
|
31
|
+
raise SystemExit(
|
|
32
|
+
"The `mcp` package is required for `okf serve`.\n"
|
|
33
|
+
"Install it with: pip install 'okf-cli[serve]'"
|
|
34
|
+
) from e
|
|
35
|
+
|
|
36
|
+
bundle = load_bundle(bundle_root)
|
|
37
|
+
mcp = FastMCP(name, instructions=(
|
|
38
|
+
"This server exposes an Open Knowledge Format (OKF) bundle: a knowledge "
|
|
39
|
+
"graph of markdown concept files. Start with okf_overview, then navigate "
|
|
40
|
+
"with okf_read following the links each concept declares. Prefer link "
|
|
41
|
+
"traversal over search when you know where a concept lives."
|
|
42
|
+
))
|
|
43
|
+
|
|
44
|
+
@mcp.tool()
|
|
45
|
+
def okf_overview() -> dict:
|
|
46
|
+
"""Bundle overview: root index content plus every concept grouped by type."""
|
|
47
|
+
by_type: dict[str, list[dict]] = {}
|
|
48
|
+
for path in bundle.concepts:
|
|
49
|
+
summary = _doc_summary(bundle, path)
|
|
50
|
+
by_type.setdefault(summary["type"] or "(untyped)", []).append(summary)
|
|
51
|
+
root_index = bundle.documents.get("index.md")
|
|
52
|
+
return {
|
|
53
|
+
"root": str(bundle.root),
|
|
54
|
+
"concept_count": len(bundle.concepts),
|
|
55
|
+
"root_index": root_index.body if root_index else None,
|
|
56
|
+
"concepts_by_type": by_type,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@mcp.tool()
|
|
60
|
+
def okf_read(path: str) -> dict:
|
|
61
|
+
"""Read one document by bundle-relative path (e.g. 'analytics/metrics/wau.md').
|
|
62
|
+
|
|
63
|
+
Returns frontmatter, body, and the resolved outbound/inbound links so
|
|
64
|
+
you can keep traversing the graph.
|
|
65
|
+
"""
|
|
66
|
+
path = path.lstrip("/")
|
|
67
|
+
if path not in bundle.documents and f"{path}.md" in bundle.documents:
|
|
68
|
+
path = f"{path}.md"
|
|
69
|
+
doc = bundle.documents.get(path)
|
|
70
|
+
if doc is None:
|
|
71
|
+
close = [p for p in bundle.documents if PurePosixPath(p).stem == PurePosixPath(path).stem]
|
|
72
|
+
return {"error": f"no document at {path!r}", "did_you_mean": close[:5]}
|
|
73
|
+
return {
|
|
74
|
+
"path": path,
|
|
75
|
+
"frontmatter": doc.frontmatter,
|
|
76
|
+
"body": doc.body,
|
|
77
|
+
"outbound_links": sorted({l.resolved for l in doc.links if l.resolved}),
|
|
78
|
+
"inbound_links": sorted(doc.inbound),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@mcp.tool()
|
|
82
|
+
def okf_search(query: str, limit: int = 10) -> list[dict]:
|
|
83
|
+
"""Full-text search across all concepts. Returns ranked matches with snippets.
|
|
84
|
+
|
|
85
|
+
Use this only when you don't know where a concept lives — link
|
|
86
|
+
traversal from okf_overview is more reliable.
|
|
87
|
+
"""
|
|
88
|
+
terms = [t for t in re.split(r"\W+", query.lower()) if t]
|
|
89
|
+
if not terms:
|
|
90
|
+
return []
|
|
91
|
+
scored = []
|
|
92
|
+
for path, doc in bundle.concepts.items():
|
|
93
|
+
fm = doc.frontmatter or {}
|
|
94
|
+
title = str(fm.get("title", ""))
|
|
95
|
+
haystacks = [(title.lower(), 5), (str(fm.get("description", "")).lower(), 3), (doc.body.lower(), 1)]
|
|
96
|
+
score = sum(w * text.count(t) for text, w in haystacks for t in terms)
|
|
97
|
+
if score:
|
|
98
|
+
idx = min((doc.body.lower().find(t) for t in terms if t in doc.body.lower()), default=0)
|
|
99
|
+
snippet = doc.body[max(0, idx - 60): idx + 140].strip().replace("\n", " ")
|
|
100
|
+
scored.append((score, {**_doc_summary(bundle, path), "snippet": snippet}))
|
|
101
|
+
scored.sort(key=lambda s: -s[0])
|
|
102
|
+
return [item for _, item in scored[:limit]]
|
|
103
|
+
|
|
104
|
+
@mcp.tool()
|
|
105
|
+
def okf_list(type: str | None = None, tag: str | None = None) -> list[dict]:
|
|
106
|
+
"""List concepts, optionally filtered by frontmatter type and/or tag."""
|
|
107
|
+
out = []
|
|
108
|
+
for path, doc in bundle.concepts.items():
|
|
109
|
+
fm = doc.frontmatter or {}
|
|
110
|
+
if type and fm.get("type") != type:
|
|
111
|
+
continue
|
|
112
|
+
if tag and tag not in (fm.get("tags") or []):
|
|
113
|
+
continue
|
|
114
|
+
out.append(_doc_summary(bundle, path))
|
|
115
|
+
return out
|
|
116
|
+
|
|
117
|
+
return mcp
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def serve(bundle_root: str, name: str = "okf") -> None:
|
|
121
|
+
build_server(bundle_root, name).run()
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: okft
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lint and serve Open Knowledge Format (OKF) bundles — a validator and MCP server for the OKF v0.1 spec
|
|
5
|
+
Project-URL: Homepage, https://github.com/PoorvaJ-WW/okft
|
|
6
|
+
Project-URL: Specification, https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md
|
|
7
|
+
Author: Poorva
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: knowledge-graph,lint,llm,markdown,mcp,okf,open-knowledge-format
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: mcp>=1.2.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
22
|
+
Provides-Extra: serve
|
|
23
|
+
Requires-Dist: mcp>=1.2.0; extra == 'serve'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# okft
|
|
27
|
+
|
|
28
|
+
**Lint and serve [Open Knowledge Format](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) (OKF) bundles.**
|
|
29
|
+
|
|
30
|
+
OKF is Google's open spec for representing organizational knowledge as a
|
|
31
|
+
directory of markdown files with YAML frontmatter — a knowledge graph that
|
|
32
|
+
both humans and AI agents can read natively. `okft` covers the two
|
|
33
|
+
sides of keeping a bundle healthy and useful:
|
|
34
|
+
|
|
35
|
+
- **`okft lint`** — validate a bundle against the OKF v0.1 spec, plus hygiene
|
|
36
|
+
checks (broken links, orphaned concepts, malformed timestamps). Wire it
|
|
37
|
+
into CI so your knowledge bundle can't rot silently.
|
|
38
|
+
- **`okft serve`** — expose a bundle to any MCP-capable AI agent (Claude,
|
|
39
|
+
Gemini CLI, Cursor, …) as a set of navigation tools: overview, read,
|
|
40
|
+
search, list. Deterministic graph traversal, no embeddings, no database.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
pip install okft # lint only
|
|
46
|
+
pip install 'okft[serve]' # lint + MCP server
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Lint
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
okft lint path/to/bundle
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
analytics/tables/orders.md:1 error E003 frontmatter must include a non-empty `type` field
|
|
57
|
+
analytics/metrics/churn.md:24 warning W001 link target does not resolve in bundle: /analytics/tables/order
|
|
58
|
+
engineering/runbook.md:1 warning W004 concept is never linked from any other document
|
|
59
|
+
|
|
60
|
+
12 concepts checked: 1 error(s), 2 warning(s)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Exit code is `1` on errors (or on warnings with `--strict`), so it drops
|
|
64
|
+
straight into CI. `--format json` emits machine-readable findings.
|
|
65
|
+
|
|
66
|
+
### Rules
|
|
67
|
+
|
|
68
|
+
| Code | Severity | Check |
|
|
69
|
+
|------|----------|-------|
|
|
70
|
+
| E001 | error | concept file has no YAML frontmatter block |
|
|
71
|
+
| E002 | error | frontmatter is not parseable YAML |
|
|
72
|
+
| E003 | error | missing or empty `type` field |
|
|
73
|
+
| E004 | error | reserved file (`index.md` / `log.md`) has frontmatter |
|
|
74
|
+
| W001 | warning | link target does not resolve inside the bundle¹ |
|
|
75
|
+
| W002 | warning | `timestamp` is not ISO 8601 |
|
|
76
|
+
| W003 | warning | `tags` is not a list of strings |
|
|
77
|
+
| W004 | warning | orphan concept — nothing links to it (`--no-orphans` to skip) |
|
|
78
|
+
| W005 | warning | bundle root has no `index.md` |
|
|
79
|
+
| W006 | warning | `log.md` headings are not ISO 8601 dates |
|
|
80
|
+
| W007 | warning | concept has no `title` |
|
|
81
|
+
|
|
82
|
+
¹ The spec requires consumers to *tolerate* broken links, so they are
|
|
83
|
+
warnings, never conformance errors.
|
|
84
|
+
|
|
85
|
+
Both standard markdown links (`/analytics/tables/customers.md`, relative
|
|
86
|
+
paths) and `[[wiki-style]]` links are resolved.
|
|
87
|
+
|
|
88
|
+
## Serve to an AI agent
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
okft serve path/to/bundle
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Runs an MCP server (stdio) with four tools:
|
|
95
|
+
|
|
96
|
+
| Tool | Purpose |
|
|
97
|
+
|------|---------|
|
|
98
|
+
| `okf_overview` | root index + every concept grouped by type |
|
|
99
|
+
| `okf_read` | one concept: frontmatter, body, outbound & inbound links |
|
|
100
|
+
| `okf_search` | ranked full-text search with snippets |
|
|
101
|
+
| `okf_list` | filter concepts by `type` and/or `tag` |
|
|
102
|
+
|
|
103
|
+
Register it with Claude Code:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
claude mcp add acme-brain -- okft serve /path/to/bundle
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
or in any MCP client config:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"acme-brain": { "command": "okft", "args": ["serve", "/path/to/bundle"] }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Try it
|
|
120
|
+
|
|
121
|
+
A small example bundle ships in [`examples/acme_brain`](examples/acme_brain):
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
okft lint examples/acme_brain
|
|
125
|
+
okft serve examples/acme_brain
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## CI example (GitHub Actions)
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
- uses: actions/setup-python@v5
|
|
132
|
+
with: { python-version: "3.12" }
|
|
133
|
+
- run: pip install okft
|
|
134
|
+
- run: okft lint knowledge/ --strict
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Status
|
|
138
|
+
|
|
139
|
+
Tracks OKF **v0.1**. The spec is young and so is this tool — issues and PRs
|
|
140
|
+
welcome, especially reports of real-world bundles that lint incorrectly.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
Apache-2.0
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
okft/__init__.py,sha256=i3pKCoQMBq1kwtzciM_TkJ_qNqivHNyCEO_5vQZ3A1g,87
|
|
2
|
+
okft/bundle.py,sha256=wQICp8aP-yLHpvaRHxrKzkCCMCgeOKr_gzOwOTBEEq8,6201
|
|
3
|
+
okft/cli.py,sha256=lRBVAOM2S4kOEGLzoA_gJm1DE3e4P5FZFO2wsnzI-_c,3451
|
|
4
|
+
okft/lint.py,sha256=KV-Cu0_qORkTZjpZ2QF6i5i4CseKmBI162xYB6yADWY,5544
|
|
5
|
+
okft/server.py,sha256=J-nuFNfn1EEJcMJtfwzsTrSvyUF1upkLYr5H3RqZFYg,4752
|
|
6
|
+
okft-0.1.0.dist-info/METADATA,sha256=sQ__roiiez4LKxtQM8UPugTJcsxaokSIZET1qYCzmrw,4635
|
|
7
|
+
okft-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
8
|
+
okft-0.1.0.dist-info/entry_points.txt,sha256=BAcbcZgw21Ieztc3nnXTxZ9bSJyNydKFztFF2DXpowo,39
|
|
9
|
+
okft-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
okft-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|