siyuan-cli 1.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.
- siyuan_cli/__init__.py +7 -0
- siyuan_cli/__main__.py +5 -0
- siyuan_cli/audit.py +44 -0
- siyuan_cli/cli.py +697 -0
- siyuan_cli/client.py +442 -0
- siyuan_cli/commands/__init__.py +1 -0
- siyuan_cli/commands/asset.py +130 -0
- siyuan_cli/commands/attr.py +56 -0
- siyuan_cli/commands/backlinks.py +156 -0
- siyuan_cli/commands/batch.py +318 -0
- siyuan_cli/commands/block.py +259 -0
- siyuan_cli/commands/config_cmd.py +108 -0
- siyuan_cli/commands/daily_note.py +105 -0
- siyuan_cli/commands/doc.py +338 -0
- siyuan_cli/commands/export_cmd.py +48 -0
- siyuan_cli/commands/file_cmd.py +184 -0
- siyuan_cli/commands/health.py +202 -0
- siyuan_cli/commands/notebook.py +140 -0
- siyuan_cli/commands/notify.py +40 -0
- siyuan_cli/commands/overview.py +160 -0
- siyuan_cli/commands/search.py +83 -0
- siyuan_cli/commands/stats.py +102 -0
- siyuan_cli/commands/tag.py +107 -0
- siyuan_cli/commands/template.py +52 -0
- siyuan_cli/commands/workspace_cmd.py +114 -0
- siyuan_cli/config.py +156 -0
- siyuan_cli/exceptions.py +195 -0
- siyuan_cli/permissions.py +180 -0
- siyuan_cli/utils.py +400 -0
- siyuan_cli/workspace.py +120 -0
- siyuan_cli-1.1.0.dist-info/METADATA +234 -0
- siyuan_cli-1.1.0.dist-info/RECORD +39 -0
- siyuan_cli-1.1.0.dist-info/WHEEL +5 -0
- siyuan_cli-1.1.0.dist-info/entry_points.txt +3 -0
- siyuan_cli-1.1.0.dist-info/licenses/LICENSE +21 -0
- siyuan_cli-1.1.0.dist-info/top_level.txt +2 -0
- siyuan_mcp/__init__.py +3 -0
- siyuan_mcp/__main__.py +5 -0
- siyuan_mcp/server.py +882 -0
siyuan_cli/__init__.py
ADDED
siyuan_cli/__main__.py
ADDED
siyuan_cli/audit.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Audit trail for destructive operations in siyuan-cli."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import time
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
AUDIT_FILE = os.path.expanduser("~/.siyuan/audit.log")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _format_ts() -> str:
|
|
12
|
+
"""ISO 8601 timestamp."""
|
|
13
|
+
return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def log_destructive(
|
|
17
|
+
action: str,
|
|
18
|
+
target: str,
|
|
19
|
+
detail: dict[str, Any] | None = None,
|
|
20
|
+
confirmed_via: str = "",
|
|
21
|
+
) -> None:
|
|
22
|
+
"""Log a destructive operation to the audit trail.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
action: Human-readable action (e.g. "DELETE_DOC", "REMOVE_NOTEBOOK").
|
|
26
|
+
target: The resource identifier (document path, block ID, notebook ID).
|
|
27
|
+
detail: Optional extra context (e.g. notebook ID, timestamp).
|
|
28
|
+
confirmed_via: How the user confirmed (e.g. "--yes", "interactive").
|
|
29
|
+
"""
|
|
30
|
+
entry: dict[str, Any] = {
|
|
31
|
+
"ts": _format_ts(),
|
|
32
|
+
"action": action,
|
|
33
|
+
"target": target,
|
|
34
|
+
}
|
|
35
|
+
if detail:
|
|
36
|
+
entry["detail"] = detail
|
|
37
|
+
if confirmed_via:
|
|
38
|
+
entry["confirmed"] = confirmed_via
|
|
39
|
+
|
|
40
|
+
parent = os.path.dirname(AUDIT_FILE)
|
|
41
|
+
if not os.path.isdir(parent):
|
|
42
|
+
os.makedirs(parent, mode=0o700)
|
|
43
|
+
with open(AUDIT_FILE, "a", encoding="utf-8") as f:
|
|
44
|
+
f.write(json.dumps(entry, ensure_ascii=False) + "\n")
|