@sparkelf/dsh-knowledge-base 0.6.1 → 0.6.2

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.
@@ -1,20 +1,29 @@
1
1
  import type { GraphManifest, LoadedGraph, MemoryAuthority, MemoryOrigin, MemoryReviewStatus } from './graphModel.ts';
2
2
  import { type GraphScopeDescriptor, type GraphViewer } from './graphPolicy.ts';
3
3
  import { type BindingSourceType, type BindingStatus, type PersonalBinding } from './memoryBindings.ts';
4
+ import type { Privacy } from './memoryTypes.ts';
4
5
  /** Default prompt budget for the resolved context. */
5
6
  export declare const DEFAULT_MEMORY_CONTEXT_MAX_CHARS = 8000;
6
7
  /** Marker the runtime must treat as above personal memory and preferences. */
7
8
  export declare const SYSTEM_POLICY_MARKER = "system policy overrides personal memory";
8
- /** How a memory entry reaches the personal graph. */
9
- export type MemoryContextMode = 'subscribe' | 'internalize';
10
- /** One resolved node/edge the runtime may inject. */
9
+ /**
10
+ * How a memory entry reaches the personal graph.
11
+ *
12
+ * `personal` is the user's own `MemoryStore` snapshot (`偏好.md`, `踩坑.md`,
13
+ * `事实.md`, `SOP/`, daily logs). It has no binding and no graph-side authority:
14
+ * it is always advisory, so it can never outrank a department/global redline.
15
+ */
16
+ export type MemoryContextMode = 'subscribe' | 'internalize' | 'personal';
17
+ /** Where one resolved context entry came from. */
18
+ export type MemoryContextSourceType = BindingSourceType | 'entry';
19
+ /** One resolved node/edge/memory the runtime may inject. */
11
20
  export interface MemoryContextEntry {
12
21
  mode: MemoryContextMode;
13
22
  graphId: string;
14
- sourceType: BindingSourceType;
23
+ sourceType: MemoryContextSourceType;
15
24
  sourceId: string;
16
25
  title: string;
17
- /** Node type or relation type. */
26
+ /** Node type, relation type, or memory type. */
18
27
  type: string;
19
28
  authority: MemoryAuthority;
20
29
  origin: MemoryOrigin;
@@ -31,6 +40,10 @@ export interface MemoryContextEntry {
31
40
  /** Relation endpoints, when the source is an edge. */
32
41
  from?: string;
33
42
  to?: string;
43
+ /** Personal-memory privacy label; absent on graph bindings. */
44
+ privacy?: Privacy;
45
+ /** Last update of a personal entry; absent on graph bindings. */
46
+ updatedAt?: string;
34
47
  body: string;
35
48
  /** Budget cost used by this resolver (title + body + fixed metadata overhead). */
36
49
  chars: number;
@@ -38,7 +51,7 @@ export interface MemoryContextEntry {
38
51
  /** One entry omitted only because the character budget ran out. */
39
52
  export interface MemoryContextDrop {
40
53
  graphId: string;
41
- sourceType: BindingSourceType;
54
+ sourceType: MemoryContextSourceType;
42
55
  sourceId: string;
43
56
  mode: MemoryContextMode;
44
57
  chars: number;
@@ -52,6 +65,8 @@ export interface MemoryContextResult {
52
65
  charCount: number;
53
66
  maxChars: number;
54
67
  redlineCount: number;
68
+ /** Number of selected entries that came from the caller's own `MemoryStore`. */
69
+ personalCount: number;
55
70
  /** Non-empty when at least one redline is present. */
56
71
  systemPolicy: string;
57
72
  }
@@ -63,6 +78,15 @@ export interface MemoryContextInput {
63
78
  graphs: LoadedGraph[];
64
79
  /** Pre-read bindings, for callers that already listed them. Omit to rebuild from disk. */
65
80
  bindings?: PersonalBinding[];
81
+ /**
82
+ * Absolute root of the caller's own personal memory tree
83
+ * (`<actualRoot>/personal/<userId>/个人记忆图谱`).
84
+ *
85
+ * The Host builds this from the authenticated user id; this resolver never
86
+ * searches sibling user roots. Omit to keep bindings-only behavior (for
87
+ * example a paused memory setting).
88
+ */
89
+ personalMemoryRoot?: string;
66
90
  /** Prompt budget; defaults to {@link DEFAULT_MEMORY_CONTEXT_MAX_CHARS}. */
67
91
  maxChars?: number;
68
92
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Display projection shared by the memory page and the model-facing context.
3
+ *
4
+ * The memory page caps a row title at 24 characters and hides internal words
5
+ * (tool names, paths, session ids) behind neutral fallbacks. `memory_context`
6
+ * must show the same title for the same entry, otherwise a user comparing the
7
+ * page with the model's answer sees two names for one memory. Keeping the
8
+ * heuristics here is what makes "the list and the context agree" a property of
9
+ * the data rather than of two copies that happen to match today.
10
+ *
11
+ * Nothing in this module reads or writes the filesystem; it is a pure
12
+ * projection over one parsed entry.
13
+ *
14
+ * @module @sparkelf/dsh-knowledge-base/memory-display
15
+ */
16
+ import type { AnyMemoryEntry } from './memoryTypes.ts';
17
+ /** Title budget for one memory row (design §22.3: short, ≤20 characters). */
18
+ export declare const MEMORY_TITLE_MAX_CHARS = 24;
19
+ /** Collapse whitespace and cap one display line. */
20
+ export declare function clipMemoryLine(value: string, max?: number): string;
21
+ /** A technical token that should never be the first thing a reader sees in a row. */
22
+ export declare function looksTechnicalMemoryValue(value: string): boolean;
23
+ /** Short, non-technical fallback for entries written before displayTitle existed. */
24
+ export declare function memoryEntryFallbackTitle(entry: AnyMemoryEntry): string;
25
+ /** The table's 「记忆」 column: a short user-facing title, never an internal id. */
26
+ export declare function memoryEntryTitle(entry: AnyMemoryEntry): string;
27
+ /** The detail drawer's editable content, in a type-appropriate shape. */
28
+ export declare function memoryEntryContent(entry: AnyMemoryEntry): string;
29
+ /**
30
+ * Display source label. The snapshot written at record time wins; then the
31
+ * scenario/app the guardian knew; only then the neutral label. A raw session id
32
+ * is never used as the label.
33
+ */
34
+ export declare function memoryEntrySourceLabel(entry: AnyMemoryEntry): string;
35
+ /** When the remembered thing happened; falls back to `createdAt`. */
36
+ export declare function memoryEntrySourceTime(entry: AnyMemoryEntry): string;
37
+ /** Last update, used for deterministic ordering. */
38
+ export declare function memoryEntryUpdatedAt(entry: AnyMemoryEntry): string;
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * `memory_context` is read-only. It resolves the caller's personal binding
5
5
  * projection through {@link resolveMemoryContext}: live proxies for subscribed
6
- * sources, the user's own branch for internalized sources, redlines marked
7
- * non-overridable, and a deterministic budget. It never writes.
6
+ * sources, the user's own branch for internalized sources, the current entries
7
+ * of the user's own `MemoryStore`, redlines marked non-overridable, and a
8
+ * deterministic budget. It never writes.
8
9
  *
9
10
  * `memory_guardian_run` is the manual trigger for the guardian pass. It is a
10
11
  * maintenance action, not a read: it refreshes `sourceVersion`/`sourceCommit`,
@@ -33,6 +34,12 @@ export interface MemoryToolHost {
33
34
  resolveCaller(): Promise<GraphViewer>;
34
35
  /** Root of `<usersRoot>/<userId>/bindings`; supplied by plugin configuration. */
35
36
  usersRoot: string;
37
+ /**
38
+ * Absolute root of the caller's own personal `MemoryStore`
39
+ * (`<actualRoot>/personal/<userId>/个人记忆图谱`). The Host builds it from the
40
+ * authenticated user id; omitting it keeps a bindings-only context.
41
+ */
42
+ personalMemoryRoot?(viewer: GraphViewer): string;
36
43
  /** Every graph the caller may read. Implementations must not return a denied graph. */
37
44
  loadGraphs(viewer: GraphViewer): Promise<LoadedGraph[]>;
38
45
  /** Whether the caller holds the memory-management capability (`kb:config:manage`). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkelf/dsh-knowledge-base",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "DataOps-backed knowledge base for DeepSeek Harness: a left-sidebar destination, Settings configuration, and index tooling over a mounted NAS view.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",