@sparkelf/dsh-knowledge-base 0.0.0-stage → 0.1.1

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/SKILL.md +147 -0
  3. package/cordis.patch.yml +5 -0
  4. package/i18n/zh.json +10 -0
  5. package/lib/client.js +18308 -0
  6. package/lib/client.js.map +1 -0
  7. package/lib/index.js +6005 -0
  8. package/lib/types/api.d.ts +620 -0
  9. package/lib/types/client/KnowledgeAudit.d.ts +39 -0
  10. package/lib/types/client/KnowledgeContextMenu.d.ts +121 -0
  11. package/lib/types/client/KnowledgeCreateDialog.d.ts +134 -0
  12. package/lib/types/client/KnowledgeFileTree.d.ts +117 -0
  13. package/lib/types/client/KnowledgeHome.d.ts +102 -0
  14. package/lib/types/client/KnowledgeIndexing.d.ts +60 -0
  15. package/lib/types/client/KnowledgeListing.d.ts +174 -0
  16. package/lib/types/client/KnowledgeLoading.d.ts +41 -0
  17. package/lib/types/client/KnowledgeMenuIcon.d.ts +27 -0
  18. package/lib/types/client/KnowledgePanel.d.ts +58 -0
  19. package/lib/types/client/KnowledgePermissionOverview.d.ts +147 -0
  20. package/lib/types/client/KnowledgePermissions.d.ts +47 -0
  21. package/lib/types/client/KnowledgeProgressPanel.d.ts +53 -0
  22. package/lib/types/client/KnowledgeReferencePicker.d.ts +81 -0
  23. package/lib/types/client/KnowledgeSearch.d.ts +83 -0
  24. package/lib/types/client/KnowledgeSectionHeader.d.ts +71 -0
  25. package/lib/types/client/KnowledgeSelectionBar.d.ts +45 -0
  26. package/lib/types/client/KnowledgeSettings.d.ts +96 -0
  27. package/lib/types/client/KnowledgeSettingsSection.d.ts +21 -0
  28. package/lib/types/client/KnowledgeShareDialog.d.ts +70 -0
  29. package/lib/types/client/KnowledgeTemplates.d.ts +43 -0
  30. package/lib/types/client/KnowledgeTrash.d.ts +62 -0
  31. package/lib/types/client/MenuGlyphs.d.ts +37 -0
  32. package/lib/types/client/auditPaging.d.ts +40 -0
  33. package/lib/types/client/departmentFolders.d.ts +57 -0
  34. package/lib/types/client/deployTarget.d.ts +34 -0
  35. package/lib/types/client/index.d.ts +40 -0
  36. package/lib/types/client/insertReadiness.d.ts +60 -0
  37. package/lib/types/client/knowledgeMenuCopy.d.ts +23 -0
  38. package/lib/types/client/locales.d.ts +505 -0
  39. package/lib/types/client/openInSidebar.d.ts +62 -0
  40. package/lib/types/client/ownerLabel.d.ts +39 -0
  41. package/lib/types/client/paging.d.ts +69 -0
  42. package/lib/types/client/permissionRows.d.ts +265 -0
  43. package/lib/types/client/progressRules.d.ts +54 -0
  44. package/lib/types/client/referenceTargets.d.ts +60 -0
  45. package/lib/types/client/roleSummary.d.ts +47 -0
  46. package/lib/types/client/saveAudit.d.ts +87 -0
  47. package/lib/types/client/shareRelations.d.ts +81 -0
  48. package/lib/types/client/useFavorites.d.ts +49 -0
  49. package/lib/types/client/useFileDrop.d.ts +171 -0
  50. package/lib/types/client/useFileDropHook.d.ts +64 -0
  51. package/lib/types/client/usePinnedPaths.d.ts +39 -0
  52. package/lib/types/client/useTreeState.d.ts +46 -0
  53. package/lib/types/client/useViewMode.d.ts +39 -0
  54. package/lib/types/deploy.d.ts +209 -0
  55. package/lib/types/extract.d.ts +144 -0
  56. package/lib/types/extractionQueue.d.ts +154 -0
  57. package/lib/types/index.d.ts +899 -0
  58. package/lib/types/permissions.d.ts +237 -0
  59. package/lib/types/protocol.d.ts +229 -0
  60. package/lib/types/remote.d.ts +105 -0
  61. package/lib/types/trash.d.ts +142 -0
  62. package/lib/types/viewMetadata.d.ts +20 -0
  63. package/lib/types/views.d.ts +923 -0
  64. package/package.json +109 -4
  65. package/skills/kb-organize/SKILL.md +365 -0
  66. package/skills/kb-organize/i18n/zh.json +10 -0
  67. package/README.md +0 -3
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Tombstones: paths a caller has removed from their view without destroying the file.
3
+ *
4
+ * ## Why a tombstone rather than an unlink
5
+ *
6
+ * A view is hardlinks into one authoritative tree, and several callers' views may
7
+ * hold a link to the same inode. Unlinking the caller's own link would hide the file
8
+ * from them, but it would also make the removal indistinguishable from a revoked
9
+ * grant: the next `syncView` compares grants to links, finds a grant with no link,
10
+ * and puts the link back. Nothing in the filesystem can say "this one was removed on
11
+ * purpose".
12
+ *
13
+ * So removal is recorded rather than performed. A tombstone is a note that says a
14
+ * path is hidden from one caller's view, checked while the view is being built. The
15
+ * file keeps its inode, every other caller keeps their link, and restoring is
16
+ * deleting the note.
17
+ *
18
+ * ## What a tombstone is scoped to
19
+ *
20
+ * A tombstone belongs to a CALLER, not to a path: two people sharing a document may
21
+ * disagree about whether it should be in their view. It therefore lives in the
22
+ * caller's own directory and filters only that caller's view.
23
+ *
24
+ * A tombstone is not a permission. It hides what the caller may still be granted;
25
+ * it never grants anything, and a restore cannot resurrect access that DataOps has
26
+ * since withdrawn -- the grant is checked first, and a path whose grant is gone
27
+ * stays gone whatever the tombstone says.
28
+ *
29
+ * @module @sparkelf/dsh-knowledge-base/trash
30
+ */
31
+ /** One removed path, as the trash surface lists it. */
32
+ export interface Tombstone {
33
+ /** Path relative to the knowledge root, in view coordinates (`<bucket>/<inner>`). */
34
+ relPath: string;
35
+ /** Whether the removed entry was a file or a directory. */
36
+ kind: 'file' | 'directory';
37
+ /** Display name of whoever removed it. */
38
+ removedBy: string;
39
+ /** ISO-8601 instant of removal. */
40
+ removedAt: string;
41
+ /**
42
+ * Where the entry used to sit, when restoring must know more than the path.
43
+ *
44
+ * Equal to {@link relPath} for every current tombstone. It is stored rather than
45
+ * derived because a future version may move a removed document into a holding
46
+ * area, and a record that only knows where the document is not is not enough to
47
+ * put it back.
48
+ */
49
+ originalPath: string;
50
+ }
51
+ /** What this module found when it opened a caller's trash file. */
52
+ export type TrashRead = {
53
+ kind: 'absent';
54
+ } | {
55
+ kind: 'ready';
56
+ entries: Tombstone[];
57
+ }
58
+ /**
59
+ * A file exists but could not be read as a trash record.
60
+ *
61
+ * Reported rather than swallowed: interpreting it as "empty" would resurrect every
62
+ * document the caller had removed, and interpreting it as "everything" would hide
63
+ * their whole tree.
64
+ */
65
+ | {
66
+ kind: 'unreadable';
67
+ reason: string;
68
+ };
69
+ /**
70
+ * Absolute path of one caller's trash record.
71
+ *
72
+ * @param viewDir - the caller's view directory.
73
+ * @returns the path of the record, whether or not it exists.
74
+ */
75
+ export declare function trashPathFor(viewDir: string): string;
76
+ /**
77
+ * Read a caller's trash record.
78
+ *
79
+ * @param viewDir - the caller's view directory.
80
+ * @returns what the record holds; `absent` for a caller who never removed anything.
81
+ */
82
+ export declare function readTrash(viewDir: string): Promise<TrashRead>;
83
+ /**
84
+ * Write a caller's trash record atomically.
85
+ *
86
+ * Written to a sibling and renamed into place, because a half-written record would
87
+ * read as `unreadable` on the next load and hide a caller's whole tree. An empty
88
+ * entry list removes the file instead of storing `{ entries: [] }`: absence is the
89
+ * state a caller who removed nothing is already in.
90
+ *
91
+ * @param viewDir - the caller's view directory.
92
+ * @param entries - the complete set of tombstones to keep.
93
+ */
94
+ export declare function writeTrash(viewDir: string, entries: readonly Tombstone[]): Promise<void>;
95
+ /**
96
+ * The set of tombstones that hide a path, including those on an ancestor.
97
+ *
98
+ * Removing a folder removes what is inside it. Storing a tombstone per descendant
99
+ * would mean walking the tree on every removal and would leave a document uploaded
100
+ * into a removed folder afterwards visible in the trash's place; matching ancestors
101
+ * at read time makes the folder the unit of removal, which is what a caller means
102
+ * by removing it.
103
+ *
104
+ * @param entries - the caller's tombstones.
105
+ * @param relPath - the path being tested, in view coordinates.
106
+ * @returns the matching tombstone (itself or an ancestor), or undefined.
107
+ */
108
+ export declare function tombstoneHides(entries: readonly Tombstone[], relPath: string): Tombstone | undefined;
109
+ /**
110
+ * Add a tombstone, replacing any it subsumes.
111
+ *
112
+ * Removing an already-removed path is not an error -- a double click, or a page that
113
+ * reloaded mid-request, both produce it -- and the resulting record is the same as
114
+ * if it had happened once.
115
+ *
116
+ * A tombstone on a folder replaces tombstones on its descendants: keeping both would
117
+ * leave the children hidden after the folder is restored, which is not what restoring
118
+ * the folder means.
119
+ *
120
+ * @param entries - the existing tombstones.
121
+ * @param added - the tombstone to add.
122
+ * @returns the new complete list, newest last.
123
+ */
124
+ export declare function addTombstone(entries: readonly Tombstone[], added: Tombstone): Tombstone[];
125
+ /**
126
+ * Remove a tombstone, and the ones it subsumed, so the path becomes visible again.
127
+ *
128
+ * @param entries - the existing tombstones.
129
+ * @param relPath - the path being restored.
130
+ * @returns the remaining tombstones, and whether anything was removed.
131
+ */
132
+ export declare function removeTombstone(entries: readonly Tombstone[], relPath: string): {
133
+ entries: Tombstone[];
134
+ restored: boolean;
135
+ };
136
+ /**
137
+ * Build the foreign keys a tombstone should never share.
138
+ *
139
+ * @param entries - the caller's tombstones.
140
+ * @returns every hidden path, for a caller that needs a set rather than a predicate.
141
+ */
142
+ export declare function hiddenPaths(entries: readonly Tombstone[]): Set<string>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The names of the bookkeeping files this plugin writes into a caller's view.
3
+ *
4
+ * A standalone module rather than a constant exported from `views.ts`: the client
5
+ * needs these names to exclude them from the file tree, and `views.ts` imports
6
+ * `node:fs/promises`, which the client bundle refuses. Keeping the list here means the
7
+ * browser bundle stays free of Node builtins while the list still has one home.
8
+ *
9
+ * The Host derives its side from this same list -- see `VIEW_METADATA_NAMES` in
10
+ * `views.ts`, which is checked against the `*PathFor` helpers at module load so a
11
+ * renamed file cannot silently drop out of the set.
12
+ *
13
+ * Only names that live in the VIEW directory belong here. `.kb-pending` is absent on
14
+ * purpose: it sits under the authoritative root, is never linked into a view, and an
15
+ * exclusion entry for it could never match anything.
16
+ *
17
+ * @module @sparkelf/dsh-knowledge-base/viewMetadata
18
+ */
19
+ /** File names the explorer must not list, in a stable order. */
20
+ export declare const VIEW_METADATA_FILENAMES: readonly [".kb-audit.jsonl", ".kb-settings.json", ".kb-tree-state.json", ".kb-favorites.json", ".kb-trash.json", ".pinned.json", ".view-mode.json"];