mindslice-tui 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.
- mindslice_tui/__init__.py +0 -0
- mindslice_tui/__main__.py +36 -0
- mindslice_tui/app.py +118 -0
- mindslice_tui/app.tcss +78 -0
- mindslice_tui/i18n.py +105 -0
- mindslice_tui/screens.py +202 -0
- mindslice_tui/store.py +195 -0
- mindslice_tui/widgets.py +200 -0
- mindslice_tui-0.1.0.dist-info/METADATA +101 -0
- mindslice_tui-0.1.0.dist-info/RECORD +14 -0
- mindslice_tui-0.1.0.dist-info/WHEEL +5 -0
- mindslice_tui-0.1.0.dist-info/entry_points.txt +2 -0
- mindslice_tui-0.1.0.dist-info/licenses/LICENSE +202 -0
- mindslice_tui-0.1.0.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Browse a MindSlice workspace in the terminal, read-only."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from mindslice import MindSliceError
|
|
10
|
+
|
|
11
|
+
from . import i18n
|
|
12
|
+
from .app import MindSliceApp
|
|
13
|
+
from .store import Store
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> None:
|
|
17
|
+
parser = argparse.ArgumentParser(prog="mindslice-tui", description=__doc__)
|
|
18
|
+
parser.add_argument("-w", "--workspace", default=os.environ.get("MINDSLICE_WORKSPACE"),
|
|
19
|
+
help="workspace root (default: $MINDSLICE_WORKSPACE or nearest dir with mounts.toml)")
|
|
20
|
+
parser.add_argument("--lang", choices=i18n.LANGUAGES, default=i18n.LANGUAGES[0],
|
|
21
|
+
help="language of the interface at start (the L key switches it)")
|
|
22
|
+
args = parser.parse_args()
|
|
23
|
+
i18n.use(args.lang)
|
|
24
|
+
try:
|
|
25
|
+
store = Store(args.workspace)
|
|
26
|
+
app = MindSliceApp(store) # loads the workspace
|
|
27
|
+
except MindSliceError as error:
|
|
28
|
+
sys.exit(f"mindslice-tui: {error}")
|
|
29
|
+
try:
|
|
30
|
+
app.run()
|
|
31
|
+
finally:
|
|
32
|
+
store.close()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
main()
|
mindslice_tui/app.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""The MindSlice TUI application: three panes driven by one focus card."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from textual.app import App
|
|
6
|
+
from textual.binding import Binding
|
|
7
|
+
from textual.containers import Horizontal
|
|
8
|
+
from textual.widgets import Footer
|
|
9
|
+
|
|
10
|
+
from mindslice import MindSliceError
|
|
11
|
+
|
|
12
|
+
from . import i18n
|
|
13
|
+
from .i18n import t
|
|
14
|
+
from .screens import HistoryScreen, NeighborsScreen, OverviewScreen, SearchScreen
|
|
15
|
+
from .store import Store
|
|
16
|
+
from .widgets import CardChosen, CardView, RelationsPanel, SliceTree
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class MindSliceApp(App):
|
|
20
|
+
CSS_PATH = "app.tcss"
|
|
21
|
+
TITLE = "MindSlice"
|
|
22
|
+
# (key, action, key shown in the footer). The label is t(action), set in relabel().
|
|
23
|
+
KEYS = (("slash", "search", "/"), ("g", "neighbors", None), ("o", "overview", None), ("h", "history", None),
|
|
24
|
+
("r", "refresh", None), ("backspace", "back", None), ("l", "language", None), ("q", "quit", None))
|
|
25
|
+
|
|
26
|
+
def __init__(self, store: Store) -> None:
|
|
27
|
+
super().__init__()
|
|
28
|
+
self.store = store
|
|
29
|
+
self.snapshot = store.load()
|
|
30
|
+
self.address: str | None = None # the focus card
|
|
31
|
+
self.trail: list[str] = [] # earlier focus cards, for 'back'
|
|
32
|
+
|
|
33
|
+
def compose(self):
|
|
34
|
+
with Horizontal():
|
|
35
|
+
yield SliceTree(id="slices")
|
|
36
|
+
yield CardView(id="card")
|
|
37
|
+
yield RelationsPanel(id="relations")
|
|
38
|
+
yield Footer()
|
|
39
|
+
|
|
40
|
+
def on_mount(self) -> None:
|
|
41
|
+
self.relabel()
|
|
42
|
+
tree = self.query_one(SliceTree)
|
|
43
|
+
tree.load(self.snapshot)
|
|
44
|
+
tree.focus()
|
|
45
|
+
self.show(tree.first_card(), remember=False)
|
|
46
|
+
|
|
47
|
+
def relabel(self) -> None:
|
|
48
|
+
"""Put the current language on the key hints and pane titles."""
|
|
49
|
+
for key, action, display in self.KEYS:
|
|
50
|
+
# Textual cannot relabel a binding, so swap it where the footer reads bindings from.
|
|
51
|
+
self._bindings.key_to_bindings[key] = [Binding(key, action, t(action), key_display=display)]
|
|
52
|
+
self.refresh_bindings()
|
|
53
|
+
for pane in ("slices", "card", "relations"):
|
|
54
|
+
self.query_one(f"#{pane}").border_title = t(pane)
|
|
55
|
+
|
|
56
|
+
def action_language(self) -> None:
|
|
57
|
+
i18n.switch()
|
|
58
|
+
self.relabel()
|
|
59
|
+
address, self.address = self.address, None # draw the focus card again, in the new language
|
|
60
|
+
self.show(address, jump=False)
|
|
61
|
+
|
|
62
|
+
def show(self, address: str | None, jump: bool = True, remember: bool = True) -> None:
|
|
63
|
+
"""Make ``address`` the focus card. A jump moves the tree cursor and, unless told otherwise,
|
|
64
|
+
remembers the previous focus card for 'back'."""
|
|
65
|
+
if address not in self.snapshot.cards or address == self.address:
|
|
66
|
+
return
|
|
67
|
+
if jump:
|
|
68
|
+
if remember and self.address:
|
|
69
|
+
self.trail.append(self.address)
|
|
70
|
+
self.query_one(SliceTree).reveal(address)
|
|
71
|
+
self.address = address
|
|
72
|
+
self.query_one(CardView).show(self.snapshot, address, self.store.markdown(self.snapshot, address))
|
|
73
|
+
self.query_one(RelationsPanel).show(self.snapshot, address)
|
|
74
|
+
|
|
75
|
+
def on_card_chosen(self, event: CardChosen) -> None:
|
|
76
|
+
self.show(event.address, event.jump)
|
|
77
|
+
|
|
78
|
+
def open(self, address: str | None) -> None:
|
|
79
|
+
"""Jump to a card picked in a modal. Search sees the live workspace, so the card may be newer
|
|
80
|
+
than the snapshot: reload first in that case."""
|
|
81
|
+
if address and address not in self.snapshot.cards:
|
|
82
|
+
self.action_refresh()
|
|
83
|
+
self.show(address)
|
|
84
|
+
|
|
85
|
+
def action_back(self) -> None:
|
|
86
|
+
while self.trail:
|
|
87
|
+
address = self.trail.pop()
|
|
88
|
+
if address in self.snapshot.cards and address != self.address:
|
|
89
|
+
self.show(address, remember=False)
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
def action_refresh(self) -> None:
|
|
93
|
+
try:
|
|
94
|
+
self.snapshot = self.store.load()
|
|
95
|
+
except MindSliceError as error:
|
|
96
|
+
self.notify(str(error), title=t("refresh_failed"), severity="error", markup=False)
|
|
97
|
+
return
|
|
98
|
+
tree = self.query_one(SliceTree)
|
|
99
|
+
tree.load(self.snapshot)
|
|
100
|
+
# The focus card may be gone (deleted or renamed outside); fall back to the first one.
|
|
101
|
+
address = self.address if self.address in self.snapshot.cards else tree.first_card()
|
|
102
|
+
self.address = None
|
|
103
|
+
self.show(address, remember=False)
|
|
104
|
+
self.notify(t("card_count", count=len(self.snapshot.cards)), title=t("refreshed"))
|
|
105
|
+
|
|
106
|
+
def action_search(self) -> None:
|
|
107
|
+
self.push_screen(SearchScreen(self.store), self.open)
|
|
108
|
+
|
|
109
|
+
def action_overview(self) -> None:
|
|
110
|
+
self.push_screen(OverviewScreen(self.store, self.snapshot), self.open)
|
|
111
|
+
|
|
112
|
+
def action_neighbors(self) -> None:
|
|
113
|
+
if self.address:
|
|
114
|
+
self.push_screen(NeighborsScreen(self.snapshot, self.address), self.open)
|
|
115
|
+
|
|
116
|
+
def action_history(self) -> None:
|
|
117
|
+
if self.address:
|
|
118
|
+
self.push_screen(HistoryScreen(self.store, self.address), self.open)
|
mindslice_tui/app.tcss
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
* {
|
|
2
|
+
scrollbar-size-vertical: 1;
|
|
3
|
+
scrollbar-color: $foreground 20%;
|
|
4
|
+
scrollbar-color-hover: $foreground 40%;
|
|
5
|
+
scrollbar-color-active: $accent;
|
|
6
|
+
scrollbar-background: $surface;
|
|
7
|
+
scrollbar-background-hover: $surface;
|
|
8
|
+
scrollbar-background-active: $surface;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#slices, #card, #relations {
|
|
12
|
+
border: round $primary-darken-1;
|
|
13
|
+
border-title-color: $text;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#slices:focus, #card:focus-within, #relations:focus-within {
|
|
17
|
+
border: round $accent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#slices {
|
|
21
|
+
width: 38;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#card {
|
|
25
|
+
width: 1fr;
|
|
26
|
+
padding: 0 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#relations {
|
|
30
|
+
width: 46;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Names come first in the relation rows, so clipping the dim folder beats a scrollbar. */
|
|
34
|
+
#relations Tree {
|
|
35
|
+
overflow-x: hidden;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Table DataTable {
|
|
39
|
+
height: 1fr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#card-meta {
|
|
43
|
+
border-bottom: solid $primary-darken-1;
|
|
44
|
+
margin-bottom: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Full text of the highlighted relation or table row. */
|
|
48
|
+
#preview, .detail {
|
|
49
|
+
height: auto;
|
|
50
|
+
max-height: 8;
|
|
51
|
+
padding: 0 1;
|
|
52
|
+
border-top: solid $primary-darken-1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Markdown {
|
|
56
|
+
padding: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ModalScreen {
|
|
60
|
+
align: center middle;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dialog {
|
|
64
|
+
width: 90%;
|
|
65
|
+
height: 85%;
|
|
66
|
+
border: round $accent;
|
|
67
|
+
background: $surface;
|
|
68
|
+
padding: 0 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dialog OptionList {
|
|
72
|
+
height: 1fr;
|
|
73
|
+
border: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#search-note {
|
|
77
|
+
color: $text-muted;
|
|
78
|
+
}
|
mindslice_tui/i18n.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""The UI's own text in each language. Textual has no built-in localisation, so this is a plain table.
|
|
2
|
+
|
|
3
|
+
``t("search")`` returns the string in the current language; ``{name}`` placeholders are filled from
|
|
4
|
+
keyword arguments. Card content and the engine's own messages are shown as they are.
|
|
5
|
+
To add a language: add its code to ``LANGUAGES`` and one more string to every entry.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
LANGUAGES = ("en", "zh")
|
|
11
|
+
language = LANGUAGES[0]
|
|
12
|
+
|
|
13
|
+
STRINGS = {
|
|
14
|
+
# key hints in the footer (the key is the action's name)
|
|
15
|
+
"search": ("Search", "搜索"),
|
|
16
|
+
"neighbors": ("Neighbours", "邻居树"),
|
|
17
|
+
"overview": ("Overview", "概览"),
|
|
18
|
+
"history": ("History", "历史"),
|
|
19
|
+
"refresh": ("Reload", "刷新"),
|
|
20
|
+
"back": ("Back", "回退"),
|
|
21
|
+
"language": ("中文", "English"), # names the language the key switches to
|
|
22
|
+
"quit": ("Quit", "退出"),
|
|
23
|
+
# panes
|
|
24
|
+
"slices": ("Slices", "切片"),
|
|
25
|
+
"card": ("Card", "卡片"),
|
|
26
|
+
"relations": ("Relations", "关系"),
|
|
27
|
+
# relation groups; the symbols are ones common terminal fonts have (rarer arrows render as boxes)
|
|
28
|
+
"links_out": ("→ links out", "→ 出链"),
|
|
29
|
+
"backlinks": ("← backlinks", "← 反链"),
|
|
30
|
+
"extends": ("↑ extends", "↑ 扩展"),
|
|
31
|
+
"extended_by": ("↓ extended by", "↓ 被扩展"),
|
|
32
|
+
"supersedes": ("⇒ supersedes", "⇒ 取代"),
|
|
33
|
+
"superseded_by": ("⇐ superseded by", "⇐ 被取代"),
|
|
34
|
+
"same_path": ("≡ same path", "≡ 同路径"),
|
|
35
|
+
"dangling": ("✗ dangling", "✗ 悬空引用"),
|
|
36
|
+
# card header
|
|
37
|
+
"always_loaded": ("always loaded", "常驻"),
|
|
38
|
+
"superseded": ("superseded", "已被取代"),
|
|
39
|
+
"shadowed": ("shadowed", "被遮盖"),
|
|
40
|
+
"tags": ("tags: {tags}", "标签:{tags}"),
|
|
41
|
+
"aliases": ("aliases: {aliases}", "别名:{aliases}"),
|
|
42
|
+
"modified": ("modified {time} · read {count}×", "修改于 {time} · 已读 {count} 次"),
|
|
43
|
+
"file_gone": ("*The file is gone; press `r` to reload.*", "*文件已不存在,按 `r` 刷新。*"),
|
|
44
|
+
# notifications
|
|
45
|
+
"refreshed": ("Reloaded", "已刷新"),
|
|
46
|
+
"card_count": ("{count} cards", "{count} 张卡片"),
|
|
47
|
+
"refresh_failed": ("Reload failed; still showing the old content", "刷新失败,仍显示旧内容"),
|
|
48
|
+
# search
|
|
49
|
+
"search_placeholder": ("Type to search; enter moves to the results", "输入关键词,回车进入结果列表"),
|
|
50
|
+
"search_found": ("{count} found", "找到 {count} 条"),
|
|
51
|
+
"search_unmatched": ("no card contains: {terms}", "没有卡片包含:{terms}"),
|
|
52
|
+
# neighbour tree
|
|
53
|
+
"neighbor_hint": ("space open · enter jump · esc close", "space 展开 · enter 跳转 · esc 关闭"),
|
|
54
|
+
# table columns
|
|
55
|
+
"col_time": ("time", "时间"),
|
|
56
|
+
"col_change": ("change", "变更"),
|
|
57
|
+
"col_card": ("card", "卡片"),
|
|
58
|
+
"col_reason": ("reason", "原因"),
|
|
59
|
+
"col_kind": ("kind", "类型"),
|
|
60
|
+
"col_detail": ("detail", "详情"),
|
|
61
|
+
"col_title": ("title", "标题"),
|
|
62
|
+
"col_summary": ("summary", "摘要"),
|
|
63
|
+
# overview
|
|
64
|
+
"tab_status": ("Status", "状态"),
|
|
65
|
+
"tab_issues": ("Issues", "问题"),
|
|
66
|
+
"tab_always": ("Always loaded", "常驻"),
|
|
67
|
+
"mounts": ("Mounts", "挂载"),
|
|
68
|
+
"mount_row": ("{alias:<16} {count:>5} cards precedence {precedence:<4} {role:<10} {path}",
|
|
69
|
+
"{alias:<16} {count:>5} 张卡片 优先级 {precedence:<4} {role:<10} {path}"),
|
|
70
|
+
"mount_missing": ("missing", "目录缺失"),
|
|
71
|
+
"mount_dirty": ("unbaked changes", "有未 bake 的改动"),
|
|
72
|
+
"memory": ("Memory", "记忆"),
|
|
73
|
+
"memory_row": ("overlay cards {overlay} · mounted cards {mounted} · not assigned to a slice {unassigned}",
|
|
74
|
+
"overlay 卡片 {overlay} · 挂载卡片 {mounted} · 未归入 slice {unassigned}"),
|
|
75
|
+
"validation_row": ("validation: {errors} errors, {warnings} warnings", "校验:{errors} 个错误,{warnings} 个警告"),
|
|
76
|
+
"pending": ("Pending review ({count})", "待审变更({count})"),
|
|
77
|
+
"pending_none": ("nothing is waiting for approval", "没有等待批准的变更"),
|
|
78
|
+
"pending_conflict": ("conflict: {conflict}", "冲突:{conflict}"),
|
|
79
|
+
"pending_reason": ("reason: {reason}", "原因:{reason}"),
|
|
80
|
+
# issues: the kind, and for the ones derived from the graph a detail naming the other card
|
|
81
|
+
"issue_error": ("error", "错误"),
|
|
82
|
+
"issue_warning": ("warning", "警告"),
|
|
83
|
+
"issue_stale_extends": ("stale extends", "扩展已过期"),
|
|
84
|
+
"issue_stale_extends_detail": ("baseline {target} has been superseded", "基线 {target} 已被取代"),
|
|
85
|
+
"issue_supersedes": ("supersedes", "取代"),
|
|
86
|
+
"issue_supersedes_detail": ("replaces {target}", "取代了 {target}"),
|
|
87
|
+
"issue_shadowed": ("shadowed", "被遮盖"),
|
|
88
|
+
"issue_shadowed_detail": ("a higher-precedence mount has the same path", "更高优先级的挂载中有同路径卡片"),
|
|
89
|
+
"issue_orphan": ("orphan", "孤立"),
|
|
90
|
+
"issue_orphan_detail": ("no links in or out", "没有出链也没有反链"),
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def t(key: str, **values) -> str:
|
|
95
|
+
return STRINGS[key][LANGUAGES.index(language)].format(**values)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def use(code: str) -> None:
|
|
99
|
+
global language
|
|
100
|
+
language = code
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def switch() -> None:
|
|
104
|
+
"""Move to the next language, wrapping around."""
|
|
105
|
+
use(LANGUAGES[(LANGUAGES.index(language) + 1) % len(LANGUAGES)])
|
mindslice_tui/screens.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Modal screens. Each dismisses with a card address to jump to, or None."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from rich.cells import cell_len
|
|
6
|
+
from rich.markup import escape
|
|
7
|
+
from rich.text import Text
|
|
8
|
+
from textual.containers import Vertical, VerticalScroll
|
|
9
|
+
from textual.screen import ModalScreen
|
|
10
|
+
from textual.widgets import DataTable, Input, OptionList, Static, TabbedContent, TabPane, Tree
|
|
11
|
+
from textual.widgets.option_list import Option
|
|
12
|
+
|
|
13
|
+
from .i18n import t
|
|
14
|
+
from .store import EDGE_GROUPS, Snapshot, Store
|
|
15
|
+
from .widgets import Table, card_label, history_rows
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def history_columns() -> list[str]:
|
|
19
|
+
return [t(f"col_{name}") for name in ("time", "change", "card", "reason")]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Modal(ModalScreen[str | None]):
|
|
23
|
+
BINDINGS = [("escape", "dismiss(None)", "Close")]
|
|
24
|
+
|
|
25
|
+
def on_data_table_row_selected(self, event: DataTable.RowSelected) -> None:
|
|
26
|
+
address = Table.address_of(event)
|
|
27
|
+
if address:
|
|
28
|
+
self.dismiss(address)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SearchScreen(Modal):
|
|
32
|
+
"""Full-text search through the engine (BM25); results follow supersedes like agent searches do."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, store: Store) -> None:
|
|
35
|
+
super().__init__()
|
|
36
|
+
self.store = store
|
|
37
|
+
self.timer = None
|
|
38
|
+
|
|
39
|
+
def compose(self):
|
|
40
|
+
with Vertical(classes="dialog") as dialog:
|
|
41
|
+
dialog.border_title = t("search")
|
|
42
|
+
yield Input(placeholder=t("search_placeholder"))
|
|
43
|
+
yield OptionList()
|
|
44
|
+
yield Static(id="search-note")
|
|
45
|
+
|
|
46
|
+
def on_input_changed(self, event: Input.Changed) -> None:
|
|
47
|
+
"""Search once typing pauses, not on every keystroke."""
|
|
48
|
+
if self.timer:
|
|
49
|
+
self.timer.stop()
|
|
50
|
+
self.timer = self.set_timer(0.15, lambda: self.search(event.value))
|
|
51
|
+
|
|
52
|
+
def search(self, query: str) -> None:
|
|
53
|
+
results = self.query_one(OptionList)
|
|
54
|
+
results.clear_options()
|
|
55
|
+
note = ""
|
|
56
|
+
if query.strip():
|
|
57
|
+
found = self.store.search(query)
|
|
58
|
+
for hit in found["results"]:
|
|
59
|
+
text = Text.assemble((hit["title"], "bold"), " ", (hit["address"], "cyan"),
|
|
60
|
+
(f" {hit['coverage']:.0%}\n", "dim"), (hit["summary"], "dim"))
|
|
61
|
+
results.add_options([Option(text, id=hit["address"]), None]) # None draws a separator
|
|
62
|
+
note = t("search_found", count=found["total_matches"])
|
|
63
|
+
if found["unmatched_terms"]:
|
|
64
|
+
note += " · " + t("search_unmatched", terms=", ".join(found["unmatched_terms"]))
|
|
65
|
+
self.query_one("#search-note", Static).update(note)
|
|
66
|
+
|
|
67
|
+
def on_input_submitted(self) -> None:
|
|
68
|
+
results = self.query_one(OptionList)
|
|
69
|
+
if results.option_count:
|
|
70
|
+
results.focus()
|
|
71
|
+
results.highlighted = 0
|
|
72
|
+
|
|
73
|
+
def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
|
|
74
|
+
self.dismiss(event.option.id)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class NeighborsScreen(Modal):
|
|
78
|
+
"""Multi-hop exploration: a tree rooted at the focus card, each node opening into its neighbours."""
|
|
79
|
+
|
|
80
|
+
def __init__(self, snapshot: Snapshot, address: str) -> None:
|
|
81
|
+
super().__init__()
|
|
82
|
+
self.snapshot = snapshot
|
|
83
|
+
self.address = address
|
|
84
|
+
|
|
85
|
+
def compose(self):
|
|
86
|
+
tree = Tree(card_label(self.snapshot, self.address, self.snapshot.cards[self.address].title),
|
|
87
|
+
data=self.address, classes="dialog")
|
|
88
|
+
tree.auto_expand = False # enter jumps; space opens a node
|
|
89
|
+
tree.border_title = t("neighbors")
|
|
90
|
+
tree.border_subtitle = t("neighbor_hint")
|
|
91
|
+
yield tree
|
|
92
|
+
|
|
93
|
+
def on_mount(self) -> None:
|
|
94
|
+
self.query_one(Tree).root.expand()
|
|
95
|
+
|
|
96
|
+
def on_tree_node_expanded(self, event: Tree.NodeExpanded[str]) -> None:
|
|
97
|
+
node = event.node
|
|
98
|
+
if node.children:
|
|
99
|
+
return
|
|
100
|
+
path = set() # addresses from the root down to this node
|
|
101
|
+
walker = node
|
|
102
|
+
while walker is not None:
|
|
103
|
+
path.add(walker.data)
|
|
104
|
+
walker = walker.parent
|
|
105
|
+
width = max(cell_len(t(name)) for name, _, _ in EDGE_GROUPS) # cells, not characters: CJK is double width
|
|
106
|
+
for name, kind, direction in EDGE_GROUPS:
|
|
107
|
+
label = t(name) + " " * (width - cell_len(t(name)) + 2)
|
|
108
|
+
for neighbor in self.snapshot.neighbors(node.data, kind, direction):
|
|
109
|
+
text = card_label(self.snapshot, neighbor, self.snapshot.cards[neighbor].title)
|
|
110
|
+
text = Text.assemble((label, "dim"), text)
|
|
111
|
+
if neighbor in path: # a leaf has no toggle arrow: pad so the columns still line up
|
|
112
|
+
node.add_leaf(Text.assemble(" ", text, (" ↺", "dim")), data=neighbor)
|
|
113
|
+
else:
|
|
114
|
+
node.add(text, data=neighbor)
|
|
115
|
+
if not node.children:
|
|
116
|
+
node.allow_expand = False
|
|
117
|
+
|
|
118
|
+
def on_tree_node_selected(self, event: Tree.NodeSelected[str]) -> None:
|
|
119
|
+
self.dismiss(event.node.data)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class HistoryScreen(Modal):
|
|
123
|
+
"""Recorded changes of one card, newest first."""
|
|
124
|
+
|
|
125
|
+
def __init__(self, store: Store, address: str) -> None:
|
|
126
|
+
super().__init__()
|
|
127
|
+
self.events = store.history(address)
|
|
128
|
+
self.address = address
|
|
129
|
+
|
|
130
|
+
def compose(self):
|
|
131
|
+
table = Table(*history_columns(), classes="dialog")
|
|
132
|
+
table.border_title = escape(f"{t('history')} · {self.address}")
|
|
133
|
+
table.fill(history_rows(self.events))
|
|
134
|
+
yield table
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class OverviewScreen(Modal):
|
|
138
|
+
"""Workspace-wide read-only views: status, issues, history, always-loaded cards."""
|
|
139
|
+
|
|
140
|
+
def __init__(self, store: Store, snapshot: Snapshot) -> None:
|
|
141
|
+
super().__init__()
|
|
142
|
+
self.store = store
|
|
143
|
+
self.snapshot = snapshot
|
|
144
|
+
|
|
145
|
+
def compose(self):
|
|
146
|
+
snapshot = self.snapshot
|
|
147
|
+
with TabbedContent(classes="dialog") as tabs:
|
|
148
|
+
tabs.border_title = escape(f"{t('overview')} · {snapshot.root}")
|
|
149
|
+
with TabPane(t("tab_status"), id="status"):
|
|
150
|
+
yield VerticalScroll(Static(self.status_text()))
|
|
151
|
+
with TabPane(t("tab_issues"), id="issues"):
|
|
152
|
+
issues = snapshot.issues()
|
|
153
|
+
table = Table(t("col_kind"), t("col_card"), t("col_detail"))
|
|
154
|
+
table.fill([self.issue_row(*issue) for issue in issues],
|
|
155
|
+
[address if address in snapshot.cards else None for _, address, _ in issues])
|
|
156
|
+
yield table
|
|
157
|
+
with TabPane(t("history"), id="history"):
|
|
158
|
+
events = self.store.history()
|
|
159
|
+
table = Table(*history_columns())
|
|
160
|
+
table.fill(history_rows(events), [e.get("address") if e.get("address") in snapshot.cards else None
|
|
161
|
+
for e in events])
|
|
162
|
+
yield table
|
|
163
|
+
with TabPane(t("tab_always"), id="always"):
|
|
164
|
+
always = [card for card in snapshot.cards.values() if card.always]
|
|
165
|
+
table = Table(t("col_card"), t("col_title"), t("col_summary"))
|
|
166
|
+
table.fill([(c.address, c.title, c.summary) for c in always], [c.address for c in always])
|
|
167
|
+
yield table
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
def issue_row(kind: str, address: str | None, detail: str) -> tuple:
|
|
171
|
+
"""Word one of ``Snapshot.issues()``: the engine's messages pass through, ours are translated."""
|
|
172
|
+
if kind not in ("error", "warning"):
|
|
173
|
+
detail = t(f"issue_{kind}_detail", target=detail)
|
|
174
|
+
return t(f"issue_{kind}"), address, detail
|
|
175
|
+
|
|
176
|
+
def status_text(self) -> Text:
|
|
177
|
+
status = self.snapshot.status
|
|
178
|
+
text = Text()
|
|
179
|
+
text.append(f"{t('mounts')}\n", style="bold")
|
|
180
|
+
for mount in status["mounts"]:
|
|
181
|
+
text.append(" " + t("mount_row", alias=mount["alias"], count=mount["card_count"],
|
|
182
|
+
precedence=mount["precedence"], role=mount["role"], path=mount["path"]))
|
|
183
|
+
flags = "".join(f" {t(f'mount_{name}')}" for name in ("missing", "dirty") if mount[name])
|
|
184
|
+
text.append(f"{flags}\n", style="red")
|
|
185
|
+
state = status["memory_state"]
|
|
186
|
+
text.append(f"\n{t('memory')}\n", style="bold")
|
|
187
|
+
text.append(" " + t("memory_row", overlay=state["saved_overlay_cards"], mounted=state["mounted_cards"],
|
|
188
|
+
unassigned=state["unassigned_cards"]) + "\n")
|
|
189
|
+
text.append(" " + t("validation_row", **self.snapshot.validation["stats"]) + "\n")
|
|
190
|
+
pending = self.store.pending()
|
|
191
|
+
text.append(f"\n{t('pending', count=len(pending))}\n", style="bold")
|
|
192
|
+
for item in pending:
|
|
193
|
+
text.append(f" {item['change']} {item['address']}", style="yellow")
|
|
194
|
+
text.append(f" {t('pending_conflict', conflict=item['conflict'])}\n" if item["conflict"] else "\n", style="red")
|
|
195
|
+
for change in item.get("changes", []):
|
|
196
|
+
text.append(f" {t('pending_reason', reason=change.get('reason', ''))}\n", style="dim")
|
|
197
|
+
for line in item["diff"].splitlines():
|
|
198
|
+
style = "green" if line.startswith("+") else "red" if line.startswith("-") else "dim"
|
|
199
|
+
text.append(f" {line}\n", style=style)
|
|
200
|
+
if not pending:
|
|
201
|
+
text.append(f" {t('pending_none')}\n", style="dim")
|
|
202
|
+
return text
|
mindslice_tui/store.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Read-only access to a MindSlice workspace. The only module that touches the engine.
|
|
2
|
+
|
|
3
|
+
``Store.load()`` returns an immutable ``Snapshot`` of every card and edge; the UI renders
|
|
4
|
+
from it. Nothing here writes memory: no write/apply/discard/mount/bake, and no
|
|
5
|
+
``Workspace.read()`` (which would bump read telemetry). ``ws.index`` and ``ws._reading``
|
|
6
|
+
are engine internals; if the engine grows a public graph API, only this file changes.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
from collections import defaultdict
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from mindslice import Workspace
|
|
18
|
+
from mindslice.model.addressing import extract_wikilinks, format_address
|
|
19
|
+
from mindslice.model.card import parse_card
|
|
20
|
+
from mindslice.storage.card_io import read_card_file
|
|
21
|
+
from mindslice.storage.config import load_slice_manifest
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class Mount:
|
|
26
|
+
alias: str
|
|
27
|
+
path: str
|
|
28
|
+
precedence: int
|
|
29
|
+
role: str
|
|
30
|
+
kind: str # "overlay" | "slice"
|
|
31
|
+
version: str
|
|
32
|
+
description: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True)
|
|
36
|
+
class Card:
|
|
37
|
+
address: str
|
|
38
|
+
mount: str
|
|
39
|
+
path: str
|
|
40
|
+
title: str
|
|
41
|
+
summary: str
|
|
42
|
+
tags: tuple[str, ...]
|
|
43
|
+
aliases: tuple[str, ...]
|
|
44
|
+
always: bool
|
|
45
|
+
mtime_ns: int
|
|
46
|
+
sha256: str
|
|
47
|
+
problems: tuple[str, ...] # parse errors and warnings
|
|
48
|
+
file: Path
|
|
49
|
+
read_count: int
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass(frozen=True)
|
|
53
|
+
class Edge:
|
|
54
|
+
src: str
|
|
55
|
+
kind: str # "wikilink" | "extends" | "supersedes"
|
|
56
|
+
raw: str # the reference as written in the card
|
|
57
|
+
dst: str | None # None when the reference does not resolve
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# (name, edge kind, direction) of the relation groups shown for a focus card. The UI words them (i18n.py).
|
|
61
|
+
EDGE_GROUPS = (
|
|
62
|
+
("links_out", "wikilink", "out"),
|
|
63
|
+
("backlinks", "wikilink", "in"),
|
|
64
|
+
("extends", "extends", "out"),
|
|
65
|
+
("extended_by", "extends", "in"),
|
|
66
|
+
("supersedes", "supersedes", "out"),
|
|
67
|
+
("superseded_by", "supersedes", "in"),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass(frozen=True)
|
|
72
|
+
class Snapshot:
|
|
73
|
+
root: Path
|
|
74
|
+
mounts: tuple[Mount, ...] # highest precedence first
|
|
75
|
+
cards: dict[str, Card]
|
|
76
|
+
out_edges: dict[str, list[Edge]] = field(repr=False)
|
|
77
|
+
in_edges: dict[str, list[Edge]] = field(repr=False)
|
|
78
|
+
shadowed: frozenset[str] = field(repr=False) # cards hidden by a same-path card in a mount that wins
|
|
79
|
+
status: dict[str, Any] = field(repr=False)
|
|
80
|
+
validation: dict[str, Any] = field(repr=False)
|
|
81
|
+
|
|
82
|
+
def neighbors(self, address: str, kind: str, direction: str) -> list[str]:
|
|
83
|
+
"""Addresses joined to ``address`` by resolved ``kind`` edges, in card order, without repeats."""
|
|
84
|
+
if direction == "out":
|
|
85
|
+
found = [e.dst for e in self.out_edges.get(address, []) if e.kind == kind and e.dst]
|
|
86
|
+
else:
|
|
87
|
+
found = [e.src for e in self.in_edges.get(address, []) if e.kind == kind]
|
|
88
|
+
return list(dict.fromkeys(found))
|
|
89
|
+
|
|
90
|
+
def dangling(self, address: str) -> list[Edge]:
|
|
91
|
+
return [e for e in self.out_edges.get(address, []) if e.dst is None]
|
|
92
|
+
|
|
93
|
+
def same_path(self, address: str) -> list[str]:
|
|
94
|
+
"""Cards at the same path in other mounts (they shadow, or are shadowed by, this one)."""
|
|
95
|
+
twins = (format_address(m.alias, self.cards[address].path) for m in self.mounts)
|
|
96
|
+
return [twin for twin in twins if twin in self.cards and twin != address]
|
|
97
|
+
|
|
98
|
+
def is_superseded(self, address: str) -> bool:
|
|
99
|
+
return bool(self.neighbors(address, "supersedes", "in"))
|
|
100
|
+
|
|
101
|
+
def is_orphan(self, address: str) -> bool:
|
|
102
|
+
return not any(e.dst for e in self.out_edges.get(address, [])) and not self.in_edges.get(address)
|
|
103
|
+
|
|
104
|
+
def relations(self, address: str) -> list[tuple[str, list[str]]]:
|
|
105
|
+
"""Every relation group of a card as ``(name, [target address])``; dangling references are separate."""
|
|
106
|
+
groups = [(name, self.neighbors(address, kind, direction)) for name, kind, direction in EDGE_GROUPS]
|
|
107
|
+
return [*groups, ("same_path", self.same_path(address))]
|
|
108
|
+
|
|
109
|
+
def issues(self) -> list[tuple[str, str | None, str]]:
|
|
110
|
+
"""Things worth a look, as ``(kind, card address or None, detail)``.
|
|
111
|
+
|
|
112
|
+
First the engine's validation report (kind ``error`` / ``warning``, detail its message; it covers
|
|
113
|
+
broken references), then what only the graph shows: ``stale_extends`` and ``supersedes`` (detail
|
|
114
|
+
is the other card's address), ``shadowed`` and ``orphan`` (no detail).
|
|
115
|
+
"""
|
|
116
|
+
rows = [(i["severity"], i.get("address"), f"{i['code']}: {i['message']}")
|
|
117
|
+
for i in self.validation["errors"] + self.validation["warnings"]]
|
|
118
|
+
for address, card in self.cards.items():
|
|
119
|
+
rows += [("stale_extends", address, base) for base in self.neighbors(address, "extends", "out")
|
|
120
|
+
if self.is_superseded(base)]
|
|
121
|
+
rows += [("supersedes", address, old) for old in self.neighbors(address, "supersedes", "out")]
|
|
122
|
+
if address in self.shadowed:
|
|
123
|
+
rows.append(("shadowed", address, ""))
|
|
124
|
+
if self.is_orphan(address) and not card.always:
|
|
125
|
+
rows.append(("orphan", address, ""))
|
|
126
|
+
return rows
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class Store:
|
|
130
|
+
def __init__(self, root: str | Path | None = None) -> None:
|
|
131
|
+
self.ws = Workspace(root) if root else Workspace.discover()
|
|
132
|
+
|
|
133
|
+
def close(self) -> None:
|
|
134
|
+
self.ws.close()
|
|
135
|
+
|
|
136
|
+
def load(self) -> Snapshot:
|
|
137
|
+
ws = self.ws
|
|
138
|
+
with ws._reading() as table: # syncs the index cache if files changed
|
|
139
|
+
roots = {m.alias: m for m in table.all()}
|
|
140
|
+
mounts = []
|
|
141
|
+
for m in table.all():
|
|
142
|
+
manifest = load_slice_manifest(m.root)
|
|
143
|
+
mounts.append(Mount(m.alias, m.path, m.precedence, m.role, m.kind, manifest.version, manifest.description))
|
|
144
|
+
reads = {format_address(r[0], r[1]): r[2]
|
|
145
|
+
for r in ws.index.conn.execute("SELECT mount, path, read_count FROM telemetry")}
|
|
146
|
+
cards, winners = {}, {}
|
|
147
|
+
for row in ws.index.all_cards(): # highest precedence first: the first card at a path wins it
|
|
148
|
+
address = format_address(row["mount"], row["path"])
|
|
149
|
+
cards[address] = Card(
|
|
150
|
+
address=address, mount=row["mount"], path=row["path"], title=row["title"], summary=row["summary"],
|
|
151
|
+
tags=tuple(json.loads(row["tags"])), aliases=tuple(json.loads(row["aliases"])),
|
|
152
|
+
always=row["load"] == "always", mtime_ns=row["mtime_ns"], sha256=row["sha256"],
|
|
153
|
+
problems=tuple(json.loads(row["errors"]) + json.loads(row["warnings"])),
|
|
154
|
+
file=roots[row["mount"]].root / f"{row['path']}.md", read_count=reads.get(address, 0),
|
|
155
|
+
)
|
|
156
|
+
winners.setdefault(row["path"], address)
|
|
157
|
+
out_edges, in_edges = defaultdict(list), defaultdict(list)
|
|
158
|
+
links = ws.index.conn.execute(
|
|
159
|
+
"SELECT src_mount, src_path, kind, raw, dst_mount, dst_path, resolved FROM links"
|
|
160
|
+
" ORDER BY src_mount, src_path, kind, ord")
|
|
161
|
+
for row in links:
|
|
162
|
+
src = format_address(row["src_mount"], row["src_path"])
|
|
163
|
+
dst = format_address(row["dst_mount"], row["dst_path"]) if row["resolved"] else None
|
|
164
|
+
if dst == src:
|
|
165
|
+
continue
|
|
166
|
+
edge = Edge(src, row["kind"], row["raw"], dst)
|
|
167
|
+
out_edges[src].append(edge)
|
|
168
|
+
if dst:
|
|
169
|
+
in_edges[dst].append(edge)
|
|
170
|
+
return Snapshot(ws.root, tuple(mounts), cards, dict(out_edges), dict(in_edges),
|
|
171
|
+
frozenset(cards.keys() - winners.values()), ws.status(), ws.validate())
|
|
172
|
+
|
|
173
|
+
def markdown(self, snapshot: Snapshot, address: str) -> str | None:
|
|
174
|
+
"""The card's summary and body, with resolved ``[[links]]`` turned into Markdown links to addresses.
|
|
175
|
+
None when the file has gone since the snapshot was taken."""
|
|
176
|
+
text, _ = read_card_file(snapshot.cards[address].file)
|
|
177
|
+
if text is None:
|
|
178
|
+
return None
|
|
179
|
+
after = parse_card(text).after
|
|
180
|
+
targets = {e.raw: e.dst for e in snapshot.out_edges.get(address, []) if e.kind == "wikilink" and e.dst}
|
|
181
|
+
for link in reversed(extract_wikilinks(after)):
|
|
182
|
+
if link.target in targets:
|
|
183
|
+
after = f"{after[:link.start]}[{link.label or link.target}](<{targets[link.target]}>){after[link.end:]}"
|
|
184
|
+
return after
|
|
185
|
+
|
|
186
|
+
def search(self, query: str, k: int = 30) -> dict[str, Any]:
|
|
187
|
+
return self.ws.search(query, k=k, max_neighbors=0)
|
|
188
|
+
|
|
189
|
+
def history(self, address: str | None = None, limit: int = 200) -> list[dict[str, Any]]:
|
|
190
|
+
"""Recorded change events, newest first, for one card or the whole workspace."""
|
|
191
|
+
return self.ws.card_history(address, limit=limit)["events"]
|
|
192
|
+
|
|
193
|
+
def pending(self) -> list[dict[str, Any]]:
|
|
194
|
+
"""Staged changes awaiting approval, each with a unified ``diff``."""
|
|
195
|
+
return self.ws.diff("staging")["items"]
|
mindslice_tui/widgets.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""The three panes of the main screen: slice tree, card view and relations panel."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from rich.text import Text
|
|
9
|
+
from textual.containers import Vertical, VerticalScroll
|
|
10
|
+
from textual.message import Message
|
|
11
|
+
from textual.widgets import DataTable, Markdown, Static, Tree
|
|
12
|
+
|
|
13
|
+
from .i18n import t
|
|
14
|
+
from .store import Snapshot
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CardChosen(Message):
|
|
18
|
+
"""Ask the app to make ``address`` the focus card. ``jump`` records the previous one for 'back'."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, address: str, jump: bool = True) -> None:
|
|
21
|
+
super().__init__()
|
|
22
|
+
self.address = address
|
|
23
|
+
self.jump = jump
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def card_label(snapshot: Snapshot, address: str, text: str) -> Text:
|
|
27
|
+
"""``text`` with the card's markers: ★ always-loaded, ! problems, ≡ shadowed, struck out when superseded."""
|
|
28
|
+
card = snapshot.cards[address]
|
|
29
|
+
label = Text(text, style="dim strike" if snapshot.is_superseded(address) else "")
|
|
30
|
+
if card.always:
|
|
31
|
+
label.append(" ★", style="yellow")
|
|
32
|
+
if card.problems:
|
|
33
|
+
label.append(" !", style="bold red")
|
|
34
|
+
if address in snapshot.shadowed:
|
|
35
|
+
label.append(" ≡", style="dim")
|
|
36
|
+
return label
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class SliceTree(Tree[str]):
|
|
40
|
+
"""mount → folders → cards. A card that also has children (``a`` and ``a/b``) is one expandable node."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, **kwargs) -> None:
|
|
43
|
+
super().__init__("workspace", **kwargs)
|
|
44
|
+
self.show_root = False
|
|
45
|
+
self.guide_depth = 3
|
|
46
|
+
self.nodes = {}
|
|
47
|
+
|
|
48
|
+
def load(self, snapshot: Snapshot) -> None:
|
|
49
|
+
self.clear()
|
|
50
|
+
self.nodes = {}
|
|
51
|
+
for mount in snapshot.mounts:
|
|
52
|
+
cards = [card for card in snapshot.cards.values() if card.mount == mount.alias]
|
|
53
|
+
label = Text.assemble((mount.alias, "bold"), (f" {mount.version}".rstrip() + f" {len(cards)}", "dim"))
|
|
54
|
+
self.nodes[mount.alias] = self.root.add(label, expand=True)
|
|
55
|
+
for card in sorted(cards, key=lambda card: card.path.split("/")):
|
|
56
|
+
node, prefix = self.nodes[mount.alias], mount.alias
|
|
57
|
+
for part in card.path.split("/"):
|
|
58
|
+
prefix = f"{prefix}/{part}" # for the last part this is the card's address
|
|
59
|
+
if prefix not in self.nodes:
|
|
60
|
+
node.allow_expand = True
|
|
61
|
+
self.nodes[prefix] = node.add(Text(part), expand=True, allow_expand=False)
|
|
62
|
+
node = self.nodes[prefix]
|
|
63
|
+
node.data = card.address
|
|
64
|
+
node.set_label(card_label(snapshot, card.address, card.path.rsplit("/", 1)[-1]))
|
|
65
|
+
|
|
66
|
+
def first_card(self) -> str | None:
|
|
67
|
+
return next((node.data for node in self.nodes.values() if node.data), None)
|
|
68
|
+
|
|
69
|
+
def reveal(self, address: str) -> None:
|
|
70
|
+
"""Move the cursor to a card, opening the folders above it."""
|
|
71
|
+
node = self.nodes.get(address)
|
|
72
|
+
if node is None:
|
|
73
|
+
return
|
|
74
|
+
parent = node.parent
|
|
75
|
+
while parent is not None:
|
|
76
|
+
parent.expand()
|
|
77
|
+
parent = parent.parent
|
|
78
|
+
self.call_after_refresh(self.move_cursor, node)
|
|
79
|
+
|
|
80
|
+
def on_tree_node_highlighted(self, event: Tree.NodeHighlighted[str]) -> None:
|
|
81
|
+
if event.node.data:
|
|
82
|
+
self.post_message(CardChosen(event.node.data, jump=False))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class CardView(VerticalScroll):
|
|
86
|
+
"""Metadata and rendered body of the focus card."""
|
|
87
|
+
|
|
88
|
+
def compose(self):
|
|
89
|
+
yield Static(id="card-meta")
|
|
90
|
+
yield Markdown(open_links=False)
|
|
91
|
+
|
|
92
|
+
def show(self, snapshot: Snapshot, address: str, markdown: str | None) -> None:
|
|
93
|
+
card = snapshot.cards[address]
|
|
94
|
+
meta = Text.assemble((card.title, "bold"), "\n", (address, "cyan"))
|
|
95
|
+
if card.always:
|
|
96
|
+
meta.append(f" ★ {t('always_loaded')}", style="yellow")
|
|
97
|
+
if snapshot.is_superseded(address):
|
|
98
|
+
meta.append(f" {t('superseded')}", style="red")
|
|
99
|
+
if address in snapshot.shadowed:
|
|
100
|
+
meta.append(f" {t('shadowed')}", style="red")
|
|
101
|
+
if card.tags:
|
|
102
|
+
meta.append("\n" + t("tags", tags=", ".join(card.tags)))
|
|
103
|
+
if card.aliases:
|
|
104
|
+
meta.append("\n" + t("aliases", aliases=", ".join(card.aliases)), style="dim")
|
|
105
|
+
modified = datetime.fromtimestamp(card.mtime_ns / 1e9).strftime("%Y-%m-%d %H:%M")
|
|
106
|
+
file = str(card.file).replace(str(Path.home()), "~", 1)
|
|
107
|
+
meta.append(f"\n{t('modified', time=modified, count=card.read_count)}\n{file}", style="dim")
|
|
108
|
+
for problem in card.problems:
|
|
109
|
+
meta.append(f"\n! {problem}", style="red")
|
|
110
|
+
self.query_one("#card-meta", Static).update(meta)
|
|
111
|
+
self.query_one(Markdown).update(t("file_gone") if markdown is None else markdown)
|
|
112
|
+
self.scroll_home(animate=False)
|
|
113
|
+
|
|
114
|
+
def on_markdown_link_clicked(self, event: Markdown.LinkClicked) -> None:
|
|
115
|
+
if event.href.startswith("@"):
|
|
116
|
+
self.post_message(CardChosen(event.href))
|
|
117
|
+
else:
|
|
118
|
+
self.app.open_url(event.href)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class RelationsPanel(Vertical):
|
|
122
|
+
"""The focus card's neighbours grouped by edge kind, with a preview of the highlighted one. Enter jumps."""
|
|
123
|
+
|
|
124
|
+
snapshot: Snapshot | None = None
|
|
125
|
+
|
|
126
|
+
def compose(self):
|
|
127
|
+
tree = Tree("relations")
|
|
128
|
+
tree.show_root = False
|
|
129
|
+
tree.guide_depth = 3
|
|
130
|
+
yield tree
|
|
131
|
+
yield Static(id="preview")
|
|
132
|
+
|
|
133
|
+
def show(self, snapshot: Snapshot, address: str) -> None:
|
|
134
|
+
self.snapshot = snapshot
|
|
135
|
+
tree = self.query_one(Tree)
|
|
136
|
+
tree.clear()
|
|
137
|
+
|
|
138
|
+
def group(name: str, count: int):
|
|
139
|
+
return tree.root.add(Text(f"{t(name)} ({count})", style="bold" if count else "dim"),
|
|
140
|
+
expand=True, allow_expand=bool(count))
|
|
141
|
+
|
|
142
|
+
here = snapshot.cards[address].mount
|
|
143
|
+
for name, targets in snapshot.relations(address):
|
|
144
|
+
node = group(name, len(targets))
|
|
145
|
+
for target in targets:
|
|
146
|
+
# Name first, folder after: the part that tells neighbours apart survives a narrow pane.
|
|
147
|
+
# The mount is named only when it differs from the focus card's.
|
|
148
|
+
folder, _, name = target.removeprefix(f"{here}/").rpartition("/")
|
|
149
|
+
node.add_leaf(card_label(snapshot, target, name).append(f" {folder}", style="dim"), data=target)
|
|
150
|
+
dangling = snapshot.dangling(address)
|
|
151
|
+
node = group("dangling", len(dangling))
|
|
152
|
+
for edge in dangling:
|
|
153
|
+
node.add_leaf(Text.assemble((edge.raw, "red"), (f" {edge.kind}", "dim")))
|
|
154
|
+
self.query_one("#preview", Static).update("")
|
|
155
|
+
|
|
156
|
+
def on_tree_node_highlighted(self, event: Tree.NodeHighlighted[str]) -> None:
|
|
157
|
+
card = self.snapshot.cards.get(event.node.data) if self.snapshot else None
|
|
158
|
+
preview = Text.assemble((card.title, "bold"), "\n", (card.summary, "dim")) if card else ""
|
|
159
|
+
self.query_one("#preview", Static).update(preview)
|
|
160
|
+
|
|
161
|
+
def on_tree_node_selected(self, event: Tree.NodeSelected[str]) -> None:
|
|
162
|
+
if event.node.data:
|
|
163
|
+
self.post_message(CardChosen(event.node.data))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class Table(Vertical):
|
|
167
|
+
"""A row-cursor table. Its last column holds the long text, shown in full under the table for the
|
|
168
|
+
highlighted row. Row keys, when set, are card addresses."""
|
|
169
|
+
|
|
170
|
+
def __init__(self, *columns: str, **kwargs) -> None:
|
|
171
|
+
super().__init__(**kwargs)
|
|
172
|
+
self.table = DataTable(cursor_type="row", zebra_stripes=True)
|
|
173
|
+
self.table.add_columns(*columns)
|
|
174
|
+
self.detail = Static(classes="detail")
|
|
175
|
+
|
|
176
|
+
def compose(self):
|
|
177
|
+
yield self.table
|
|
178
|
+
yield self.detail
|
|
179
|
+
|
|
180
|
+
def fill(self, rows: list[tuple], addresses: list[str | None] | None = None) -> None:
|
|
181
|
+
self.table.clear()
|
|
182
|
+
for i, row in enumerate(rows):
|
|
183
|
+
self.table.add_row(*(Text("" if cell is None else str(cell)) for cell in row),
|
|
184
|
+
key=f"{i}\t{addresses[i] or ''}" if addresses else None)
|
|
185
|
+
|
|
186
|
+
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None:
|
|
187
|
+
self.detail.update(self.table.get_row(event.row_key)[-1])
|
|
188
|
+
|
|
189
|
+
@staticmethod
|
|
190
|
+
def address_of(event: DataTable.RowSelected) -> str | None:
|
|
191
|
+
return (event.row_key.value or "").partition("\t")[2] or None
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def history_rows(events: list[dict]) -> list[tuple]:
|
|
195
|
+
"""Change events as (local time, change, address, reason) rows."""
|
|
196
|
+
def local(stamp: str) -> str:
|
|
197
|
+
return datetime.fromisoformat(stamp).astimezone().strftime("%Y-%m-%d %H:%M:%S") if stamp else ""
|
|
198
|
+
|
|
199
|
+
return [(local(e.get("timestamp", "")), f"{e.get('event', '')} {e.get('op', '')}".strip(),
|
|
200
|
+
e.get("address"), e.get("reason")) for e in events]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mindslice-tui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Read-only terminal UI for browsing MindSlice cards, slices and their relations.
|
|
5
|
+
Author: pancerZH
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/pancerZH/MindSlice-tui
|
|
8
|
+
Project-URL: Issues, https://github.com/pancerZH/MindSlice-tui/issues
|
|
9
|
+
Project-URL: MindSlice, https://github.com/pancerZH/MindSlice
|
|
10
|
+
Keywords: llm,agents,memory,tui,textual,mindslice
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: mindslice>=0.1.6
|
|
20
|
+
Requires-Dist: textual>=8.2
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# MindSlice-tui
|
|
24
|
+
|
|
25
|
+
English | [中文](https://github.com/pancerZH/MindSlice-tui/blob/main/README-zh.md)
|
|
26
|
+
|
|
27
|
+
A read-only terminal UI for a [MindSlice](https://github.com/pancerZH/MindSlice) workspace: browse cards, slices and the relations between cards.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
┌ Slices ──────┬ Card ───────────────────┬ Relations ───────────┐
|
|
31
|
+
│ ▼ @overlay 27│ MindSlice engine repo │ → links out (10) │
|
|
32
|
+
│ ▼ projects │ @overlay/projects/ │ architecture ... │
|
|
33
|
+
│ ▼ mindslice│ mindslice │ ← backlinks (7) │
|
|
34
|
+
│ ▼ prefs │ tags: mindslice project │ ↑ extends (0) │
|
|
35
|
+
│ coding ★ │ ─────────────────────── │ ↓ extended by (0) │
|
|
36
|
+
│ │ MindSlice (github.com/ │ ⇒ supersedes (0) │
|
|
37
|
+
│ │ pancerZH/MindSlice ...) │ ⇐ superseded by (0) │
|
|
38
|
+
│ │ │ ≡ same path (0) │
|
|
39
|
+
│ │ │ ✗ dangling (0) │
|
|
40
|
+
│ │ │ ──────────────────── │
|
|
41
|
+
│ │ │ title and summary of │
|
|
42
|
+
│ │ │ the selected card │
|
|
43
|
+
└──────────────┴─────────────────────────┴──────────────────────┘
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
With Python 3.12+ and [pipx](https://pipx.pypa.io/) (or [uv](https://docs.astral.sh/uv/)) installed:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
pipx install mindslice-tui # or: uv tool install mindslice-tui
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The MindSlice engine comes with it as a dependency.
|
|
55
|
+
|
|
56
|
+
## Run
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
mindslice-tui -w ~/mindslice
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The workspace is found the same way the `mindslice` command finds it: `-w`, otherwise `$MINDSLICE_WORKSPACE`, otherwise the nearest parent directory that contains `mounts.toml`.
|
|
63
|
+
|
|
64
|
+
## Keys
|
|
65
|
+
|
|
66
|
+
| Key | Action |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `↑` `↓` | Move in the tree on the left; the card and its relations follow |
|
|
69
|
+
| `tab` | Switch between the three panes |
|
|
70
|
+
| `enter` | In the relations pane, jump to the selected card. While the cursor rests on a neighbour, its title and summary are previewed under the list. Links in the card body can be clicked with the mouse |
|
|
71
|
+
| `backspace` | Go back to the card you jumped from |
|
|
72
|
+
| `/` | Full-text search (the engine's BM25; a superseded card leads to its replacement) |
|
|
73
|
+
| `g` | Neighbour tree: open the neighbours of the current card level by level (`space` opens a node, `enter` jumps) |
|
|
74
|
+
| `o` | Overview: status and pending review, issues, change history, always-loaded cards. The full text of the selected row is shown under each table; `enter` jumps to that row's card |
|
|
75
|
+
| `h` | Change history of the current card |
|
|
76
|
+
| `r` | Reload the workspace |
|
|
77
|
+
| `l` | Switch the interface language (English / 中文) |
|
|
78
|
+
| `q` | Quit |
|
|
79
|
+
|
|
80
|
+
Markers in the tree: `★` an always-loaded card (`load = "always"`), `!` the card has parse problems, `≡` the card is shadowed by a card at the same path in a higher-precedence mount; a dimmed, struck-out name means the card has been superseded.
|
|
81
|
+
If a reload with `r` fails (for example while `mounts.toml` is half written), the UI keeps what it was showing and reports the error.
|
|
82
|
+
|
|
83
|
+
The interface starts in English; `--lang zh` starts it in Chinese. Only the interface's own text is translated: card content and the engine's messages are shown as they are.
|
|
84
|
+
|
|
85
|
+
## Read-only
|
|
86
|
+
|
|
87
|
+
The UI calls no write operation (write, apply, discard, mount, bake and so on), and it does not call `Workspace.read()`, which would count a read.
|
|
88
|
+
Like every other read command of `mindslice`, it lets the engine sync the rebuildable cache `.cache/index.sqlite` when files have changed,
|
|
89
|
+
and recover first if an unfinished journal exists. Cards, staging, history and the mount table are never modified (the tests assert this).
|
|
90
|
+
|
|
91
|
+
Every engine call lives in `mindslice_tui/store.py`. `ws.index` and `ws._reading()` used there are engine internals;
|
|
92
|
+
once the engine offers a public graph query API, only that file needs to change.
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
git clone https://github.com/pancerZH/MindSlice-tui.git && cd MindSlice-tui
|
|
98
|
+
uv sync
|
|
99
|
+
uv run mindslice-tui -w ~/mindslice
|
|
100
|
+
uv run python -m unittest discover -s tests -t .
|
|
101
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
mindslice_tui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mindslice_tui/__main__.py,sha256=LUUzmur5-MpJBzOavzesGV1gJqmm485f1TGkUN7hj6Y,1072
|
|
3
|
+
mindslice_tui/app.py,sha256=MCAqnPbkeRgJvsfCsvy4lvy5W5j6RZly2CeCjmAuofE,4878
|
|
4
|
+
mindslice_tui/app.tcss,sha256=AYv-7zDKci-B5Upo1YZ3dLz3a1Wgeq3xenHEBeYPaPk,1297
|
|
5
|
+
mindslice_tui/i18n.py,sha256=G9opL9SIun2TQWCIkv2Qspjh7gGIwKqno7yYcLPphAk,5249
|
|
6
|
+
mindslice_tui/screens.py,sha256=rG2f07Pb_qxPUqeKNEol0wr63R5eA-qSFGcm4UYMJok,9095
|
|
7
|
+
mindslice_tui/store.py,sha256=lqUtJzdYE9lcdzYeoCDUp9Mu5OsD1tc1N2_Nf8hQ5Qo,8910
|
|
8
|
+
mindslice_tui/widgets.py,sha256=9UN9gyIObKtqGserr8B1X-l1Tv0vutF4-Rq8AZTtI3E,8604
|
|
9
|
+
mindslice_tui-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
mindslice_tui-0.1.0.dist-info/METADATA,sha256=2rKk2b9xjw5YGBfRD3r5aWZOxNTTqE4wLv61r0D6-HU,5287
|
|
11
|
+
mindslice_tui-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
12
|
+
mindslice_tui-0.1.0.dist-info/entry_points.txt,sha256=Jj0LGLGVd-bckYgB-PtIq5oROfjNkNpB8klLY6tAvm0,62
|
|
13
|
+
mindslice_tui-0.1.0.dist-info/top_level.txt,sha256=ftVSUF8_cciiRu7QrHT0UEmUhU2WVO_sPS1t88iEPWA,14
|
|
14
|
+
mindslice_tui-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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mindslice_tui
|