kibi-core 0.9.1 → 0.10.0
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.
- package/package.json +2 -3
- package/src/kb.pl +1084 -24
- package/src/status.pl +42 -40
package/src/status.pl
CHANGED
|
@@ -41,11 +41,26 @@ status_meta_dict(StatusDict) :-
|
|
|
41
41
|
lastSyncSource: unknown
|
|
42
42
|
}.
|
|
43
43
|
|
|
44
|
+
attached_kb_info(Branch, KbPath, DataFile) :-
|
|
45
|
+
kb:kb_attached(KbPath),
|
|
46
|
+
branch_workspace_from_kb_path(KbPath, Branch, _WorkspaceRoot),
|
|
47
|
+
kb:kb_storage_mode(journaled),
|
|
48
|
+
!,
|
|
49
|
+
directory_file_path(KbPath, 'CURRENT', DataFile).
|
|
44
50
|
attached_kb_info(Branch, KbPath, DataFile) :-
|
|
45
51
|
kb:kb_attached(KbPath),
|
|
46
52
|
branch_workspace_from_kb_path(KbPath, Branch, _WorkspaceRoot),
|
|
47
53
|
directory_file_path(KbPath, 'kb.rdf', DataFile).
|
|
48
54
|
|
|
55
|
+
snapshot_id(SnapshotId) :-
|
|
56
|
+
kb:kb_attached_snapshot(journal_snapshot(_Generation, Sequence)),
|
|
57
|
+
Sequence =:= 0,
|
|
58
|
+
!,
|
|
59
|
+
SnapshotId = missing.
|
|
60
|
+
snapshot_id(SnapshotId) :-
|
|
61
|
+
kb:kb_attached_snapshot(journal_snapshot(Generation, Sequence)),
|
|
62
|
+
!,
|
|
63
|
+
format(atom(SnapshotId), '~w:~w', [Generation, Sequence]).
|
|
49
64
|
snapshot_id(SnapshotId) :-
|
|
50
65
|
kb:kb_attached_snapshot(stamp(MTime, Size)),
|
|
51
66
|
!,
|
|
@@ -56,6 +71,14 @@ snapshot_id(SnapshotId) :-
|
|
|
56
71
|
SnapshotId = missing.
|
|
57
72
|
snapshot_id(unknown).
|
|
58
73
|
|
|
74
|
+
journal_before_first_commit :-
|
|
75
|
+
kb:kb_storage_mode(journaled),
|
|
76
|
+
kb:kb_attached_snapshot(journal_snapshot(_, 0)),
|
|
77
|
+
!.
|
|
78
|
+
|
|
79
|
+
synced_at(_, null) :-
|
|
80
|
+
journal_before_first_commit,
|
|
81
|
+
!.
|
|
59
82
|
synced_at(DataFile, SyncedAt) :-
|
|
60
83
|
exists_file(DataFile),
|
|
61
84
|
!,
|
|
@@ -64,6 +87,13 @@ synced_at(DataFile, SyncedAt) :-
|
|
|
64
87
|
% Before the first successful sync there is no kb.rdf, so the public JSON contract must expose syncedAt: null.
|
|
65
88
|
synced_at(_, null).
|
|
66
89
|
|
|
90
|
+
journal_before_first_commit_state(true, unknown) :-
|
|
91
|
+
journal_before_first_commit,
|
|
92
|
+
!.
|
|
93
|
+
|
|
94
|
+
freshness_state(_, Dirty, State) :-
|
|
95
|
+
journal_before_first_commit_state(Dirty, State),
|
|
96
|
+
!.
|
|
67
97
|
freshness_state(DataFile, true, stale) :-
|
|
68
98
|
exists_file(DataFile),
|
|
69
99
|
time_file(DataFile, SnapshotTime),
|
|
@@ -83,22 +113,19 @@ workspace_state_changed(SnapshotTime) :-
|
|
|
83
113
|
|
|
84
114
|
workspace_source_changed(SnapshotTime) :-
|
|
85
115
|
attached_workspace_root(WorkspaceRoot),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
source_value_atom(SourceValue, SourceAtom),
|
|
116
|
+
kb:kb_indexed_sources(Sources),
|
|
117
|
+
member(SourceAtom, Sources),
|
|
89
118
|
repo_relative_source(SourceAtom, RelativeSource),
|
|
90
119
|
directory_file_path(WorkspaceRoot, RelativeSource, SourcePath),
|
|
91
120
|
( exists_file(SourcePath)
|
|
92
121
|
-> time_file(SourcePath, FileTime),
|
|
93
122
|
FileTime > SnapshotTime
|
|
123
|
+
; exists_directory(SourcePath)
|
|
124
|
+
-> fail
|
|
94
125
|
; true
|
|
95
126
|
),
|
|
96
127
|
!.
|
|
97
128
|
|
|
98
|
-
documentation_tree_changed(_SnapshotTime) :-
|
|
99
|
-
attached_workspace_root(WorkspaceRoot),
|
|
100
|
-
documentation_markdown_untracked(WorkspaceRoot),
|
|
101
|
-
!.
|
|
102
129
|
documentation_tree_changed(SnapshotTime) :-
|
|
103
130
|
attached_workspace_root(WorkspaceRoot),
|
|
104
131
|
directory_file_path(WorkspaceRoot, 'documentation', DocumentationRoot),
|
|
@@ -106,39 +133,6 @@ documentation_tree_changed(SnapshotTime) :-
|
|
|
106
133
|
directory_tree_newer(DocumentationRoot, SnapshotTime),
|
|
107
134
|
!.
|
|
108
135
|
|
|
109
|
-
documentation_markdown_untracked(WorkspaceRoot) :-
|
|
110
|
-
directory_file_path(WorkspaceRoot, 'documentation', DocumentationRoot),
|
|
111
|
-
exists_directory(DocumentationRoot),
|
|
112
|
-
documentation_markdown_file(DocumentationRoot, FilePath),
|
|
113
|
-
path_relative_to_workspace(WorkspaceRoot, FilePath, RelativePath),
|
|
114
|
-
\+ known_source_path(RelativePath),
|
|
115
|
-
!.
|
|
116
|
-
|
|
117
|
-
documentation_markdown_file(Path, Path) :-
|
|
118
|
-
exists_file(Path),
|
|
119
|
-
file_name_extension(_, md, Path),
|
|
120
|
-
entity_documentation_file(Path),
|
|
121
|
-
\+ ignored_documentation_file(Path),
|
|
122
|
-
!.
|
|
123
|
-
documentation_markdown_file(Path, FilePath) :-
|
|
124
|
-
exists_directory(Path),
|
|
125
|
-
directory_files(Path, Entries),
|
|
126
|
-
member(Entry, Entries),
|
|
127
|
-
Entry \= '.',
|
|
128
|
-
Entry \= '..',
|
|
129
|
-
directory_file_path(Path, Entry, ChildPath),
|
|
130
|
-
documentation_markdown_file(ChildPath, FilePath).
|
|
131
|
-
|
|
132
|
-
path_relative_to_workspace(WorkspaceRoot, FilePath, RelativePath) :-
|
|
133
|
-
atom_concat(WorkspaceRoot, '/', Prefix),
|
|
134
|
-
atom_concat(Prefix, RelativePath, FilePath).
|
|
135
|
-
|
|
136
|
-
known_source_path(RelativePath) :-
|
|
137
|
-
kb_entity(_, _, Props),
|
|
138
|
-
memberchk(source=SourceValue, Props),
|
|
139
|
-
source_value_atom(SourceValue, SourceAtom),
|
|
140
|
-
repo_relative_source(SourceAtom, RelativePath).
|
|
141
|
-
|
|
142
136
|
directory_tree_newer(Path, SnapshotTime) :-
|
|
143
137
|
exists_file(Path),
|
|
144
138
|
entity_documentation_file(Path),
|
|
@@ -180,12 +174,20 @@ branch_path_segments(KbPath, BranchesDir, Segments) :-
|
|
|
180
174
|
repo_relative_source(SourceAtom, RelativeSource) :-
|
|
181
175
|
strip_fragment(SourceAtom, NoFragment),
|
|
182
176
|
\+ sub_atom(NoFragment, _, _, _, '://'),
|
|
177
|
+
source_path_candidate(NoFragment),
|
|
183
178
|
( attached_workspace_root(WorkspaceRoot),
|
|
184
179
|
workspace_relative_path(WorkspaceRoot, NoFragment, RelativePath)
|
|
185
180
|
-> RelativeSource = RelativePath
|
|
186
181
|
; RelativeSource = NoFragment
|
|
187
182
|
).
|
|
188
183
|
|
|
184
|
+
source_path_candidate(Source) :-
|
|
185
|
+
sub_atom(Source, _, _, _, '/'),
|
|
186
|
+
!.
|
|
187
|
+
source_path_candidate(Source) :-
|
|
188
|
+
file_name_extension(_, Extension, Source),
|
|
189
|
+
Extension \= ''.
|
|
190
|
+
|
|
189
191
|
workspace_relative_path(WorkspaceRoot, SourcePath, RelativePath) :-
|
|
190
192
|
atom_concat(WorkspaceRoot, '/', Prefix),
|
|
191
193
|
atom_concat(Prefix, RelativePath, SourcePath).
|