@chude/memory 4.0.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/README.md +294 -0
- package/dist/application/index.d.ts +6 -0
- package/dist/application/services/ambient-context-service.d.ts +90 -0
- package/dist/application/services/backfill-service.d.ts +71 -0
- package/dist/application/services/budget-allocator.d.ts +57 -0
- package/dist/application/services/embedding-service.d.ts +131 -0
- package/dist/application/services/export-service.d.ts +225 -0
- package/dist/application/services/extraction-pipeline.d.ts +50 -0
- package/dist/application/services/friction-service.d.ts +148 -0
- package/dist/application/services/fts-sanitizer.d.ts +25 -0
- package/dist/application/services/index.d.ts +34 -0
- package/dist/application/services/llm-extractor.d.ts +96 -0
- package/dist/application/services/memory-file-sync-service.d.ts +58 -0
- package/dist/application/services/pattern-extractor.d.ts +95 -0
- package/dist/application/services/recovery-service.d.ts +81 -0
- package/dist/application/services/rrf-fusion.d.ts +53 -0
- package/dist/application/services/smart-context-service.d.ts +126 -0
- package/dist/application/services/sync-service.d.ts +157 -0
- package/dist/application/services/temporal-decay.d.ts +62 -0
- package/dist/domain/entities/backfill-state.d.ts +56 -0
- package/dist/domain/entities/entity.d.ts +131 -0
- package/dist/domain/entities/extraction-state.d.ts +128 -0
- package/dist/domain/entities/fact.d.ts +59 -0
- package/dist/domain/entities/friction-entry.d.ts +84 -0
- package/dist/domain/entities/index.d.ts +15 -0
- package/dist/domain/entities/link.d.ts +74 -0
- package/dist/domain/entities/memory-file.d.ts +78 -0
- package/dist/domain/entities/message.d.ts +70 -0
- package/dist/domain/entities/session.d.ts +93 -0
- package/dist/domain/entities/tool-use.d.ts +85 -0
- package/dist/domain/errors/error-codes.d.ts +37 -0
- package/dist/domain/errors/index.d.ts +8 -0
- package/dist/domain/errors/memory-error.d.ts +52 -0
- package/dist/domain/errors/unknown-error.d.ts +9 -0
- package/dist/domain/index.d.ts +11 -0
- package/dist/domain/ports/embedding.d.ts +96 -0
- package/dist/domain/ports/extraction.d.ts +13 -0
- package/dist/domain/ports/index.d.ts +14 -0
- package/dist/domain/ports/redactor.d.ts +17 -0
- package/dist/domain/ports/repositories.d.ts +658 -0
- package/dist/domain/ports/services.d.ts +180 -0
- package/dist/domain/ports/signals.d.ts +82 -0
- package/dist/domain/ports/sources.d.ts +122 -0
- package/dist/domain/ports/types.d.ts +150 -0
- package/dist/domain/services/content-extractor.d.ts +61 -0
- package/dist/domain/services/index.d.ts +8 -0
- package/dist/domain/services/path-decoder.d.ts +56 -0
- package/dist/domain/services/query-parser.d.ts +47 -0
- package/dist/domain/value-objects/embedding-config.d.ts +56 -0
- package/dist/domain/value-objects/embedding-result.d.ts +46 -0
- package/dist/domain/value-objects/index.d.ts +10 -0
- package/dist/domain/value-objects/project-path.d.ts +92 -0
- package/dist/domain/value-objects/search-query.d.ts +30 -0
- package/dist/domain/value-objects/search-result.d.ts +92 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1548 -0
- package/dist/infrastructure/database/connection.d.ts +161 -0
- package/dist/infrastructure/database/event-log.d.ts +22 -0
- package/dist/infrastructure/database/health-checker.d.ts +248 -0
- package/dist/infrastructure/database/index.d.ts +11 -0
- package/dist/infrastructure/database/repositories/backfill-state-repository.d.ts +19 -0
- package/dist/infrastructure/database/repositories/embedding-repository.d.ts +121 -0
- package/dist/infrastructure/database/repositories/entity-repository.d.ts +73 -0
- package/dist/infrastructure/database/repositories/extraction-log-repository.d.ts +17 -0
- package/dist/infrastructure/database/repositories/extraction-state-repository.d.ts +52 -0
- package/dist/infrastructure/database/repositories/fact-repository.d.ts +25 -0
- package/dist/infrastructure/database/repositories/friction-repository.d.ts +41 -0
- package/dist/infrastructure/database/repositories/index.d.ts +17 -0
- package/dist/infrastructure/database/repositories/link-repository.d.ts +64 -0
- package/dist/infrastructure/database/repositories/memory-file-repository.d.ts +28 -0
- package/dist/infrastructure/database/repositories/message-repository.d.ts +87 -0
- package/dist/infrastructure/database/repositories/session-repository.d.ts +125 -0
- package/dist/infrastructure/database/repositories/tool-use-repository.d.ts +72 -0
- package/dist/infrastructure/database/schema.d.ts +203 -0
- package/dist/infrastructure/database/services/context-service.d.ts +93 -0
- package/dist/infrastructure/database/services/hybrid-search-service.d.ts +156 -0
- package/dist/infrastructure/database/services/index.d.ts +10 -0
- package/dist/infrastructure/database/services/search-service.d.ts +57 -0
- package/dist/infrastructure/database/services/stats-service.d.ts +36 -0
- package/dist/infrastructure/embedding/background-embedder.d.ts +125 -0
- package/dist/infrastructure/embedding/embedding-provider-factory.d.ts +44 -0
- package/dist/infrastructure/embedding/index.d.ts +5 -0
- package/dist/infrastructure/embedding/ollama-provider.d.ts +41 -0
- package/dist/infrastructure/embedding/openai-provider.d.ts +38 -0
- package/dist/infrastructure/embedding/transformers-js-provider.d.ts +34 -0
- package/dist/infrastructure/external/index.d.ts +7 -0
- package/dist/infrastructure/external/qmd-runner.d.ts +36 -0
- package/dist/infrastructure/hooks/auto-memory-writer.d.ts +52 -0
- package/dist/infrastructure/hooks/config-manager.d.ts +237 -0
- package/dist/infrastructure/hooks/git-syncer.d.ts +44 -0
- package/dist/infrastructure/hooks/hook-runner.d.ts +126 -0
- package/dist/infrastructure/hooks/index.d.ts +12 -0
- package/dist/infrastructure/hooks/log-writer.d.ts +106 -0
- package/dist/infrastructure/hooks/settings-manager.d.ts +163 -0
- package/dist/infrastructure/hooks/sync-hook-script.d.ts +83 -0
- package/dist/infrastructure/hooks/sync-logger-adapter.d.ts +17 -0
- package/dist/infrastructure/index.d.ts +11 -0
- package/dist/infrastructure/llm/anthropic-extractor.d.ts +20 -0
- package/dist/infrastructure/llm/claude-cli-extractor.d.ts +14 -0
- package/dist/infrastructure/llm/claude-summary-generator.d.ts +14 -0
- package/dist/infrastructure/llm/extraction-helper.d.ts +16 -0
- package/dist/infrastructure/llm/ollama-extractor.d.ts +20 -0
- package/dist/infrastructure/llm/openai-extractor.d.ts +23 -0
- package/dist/infrastructure/migration.d.ts +103 -0
- package/dist/infrastructure/parsers/event-classifier.d.ts +111 -0
- package/dist/infrastructure/parsers/index.d.ts +8 -0
- package/dist/infrastructure/parsers/jsonl-parser.d.ts +25 -0
- package/dist/infrastructure/parsers/timestamp.d.ts +18 -0
- package/dist/infrastructure/paths.d.ts +129 -0
- package/dist/infrastructure/providers/provider-defaults.d.ts +11 -0
- package/dist/infrastructure/providers/provider-registry.d.ts +28 -0
- package/dist/infrastructure/security/pattern-redactor.d.ts +6 -0
- package/dist/infrastructure/signals/adapters.d.ts +27 -0
- package/dist/infrastructure/signals/checkpoint-manager.d.ts +83 -0
- package/dist/infrastructure/signals/index.d.ts +8 -0
- package/dist/infrastructure/signals/signal-handler.d.ts +113 -0
- package/dist/infrastructure/sources/index.d.ts +8 -0
- package/dist/infrastructure/sources/memory-file-scanner.d.ts +23 -0
- package/dist/infrastructure/sources/project-name-resolver.d.ts +67 -0
- package/dist/infrastructure/sources/session-source.d.ts +70 -0
- package/dist/presentation/cli/command-result.d.ts +10 -0
- package/dist/presentation/cli/commands/_helpers/capture-json.d.ts +36 -0
- package/dist/presentation/cli/commands/_helpers/deprecation-warning.d.ts +41 -0
- package/dist/presentation/cli/commands/backfill.d.ts +56 -0
- package/dist/presentation/cli/commands/browse.d.ts +55 -0
- package/dist/presentation/cli/commands/completion.d.ts +61 -0
- package/dist/presentation/cli/commands/context.d.ts +53 -0
- package/dist/presentation/cli/commands/doctor.d.ts +55 -0
- package/dist/presentation/cli/commands/export.d.ts +36 -0
- package/dist/presentation/cli/commands/extract.d.ts +40 -0
- package/dist/presentation/cli/commands/facts.d.ts +17 -0
- package/dist/presentation/cli/commands/friction/dashboard.d.ts +18 -0
- package/dist/presentation/cli/commands/friction/index.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/list.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/log.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/purge.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/resolve.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/types.d.ts +86 -0
- package/dist/presentation/cli/commands/friction/wontfix.d.ts +12 -0
- package/dist/presentation/cli/commands/import.d.ts +38 -0
- package/dist/presentation/cli/commands/index.d.ts +51 -0
- package/dist/presentation/cli/commands/install.d.ts +67 -0
- package/dist/presentation/cli/commands/list.d.ts +61 -0
- package/dist/presentation/cli/commands/migrate.d.ts +36 -0
- package/dist/presentation/cli/commands/purge.d.ts +100 -0
- package/dist/presentation/cli/commands/query.d.ts +51 -0
- package/dist/presentation/cli/commands/related.d.ts +47 -0
- package/dist/presentation/cli/commands/remote.d.ts +36 -0
- package/dist/presentation/cli/commands/search.d.ts +100 -0
- package/dist/presentation/cli/commands/show.d.ts +51 -0
- package/dist/presentation/cli/commands/stats.d.ts +38 -0
- package/dist/presentation/cli/commands/status.d.ts +152 -0
- package/dist/presentation/cli/commands/sync/ambient.d.ts +22 -0
- package/dist/presentation/cli/commands/sync/background.d.ts +23 -0
- package/dist/presentation/cli/commands/sync/embedding-pass.d.ts +32 -0
- package/dist/presentation/cli/commands/sync/helpers.d.ts +25 -0
- package/dist/presentation/cli/commands/sync/index.d.ts +17 -0
- package/dist/presentation/cli/commands/sync/memory-files.d.ts +26 -0
- package/dist/presentation/cli/commands/sync/types.d.ts +163 -0
- package/dist/presentation/cli/commands/uninstall.d.ts +44 -0
- package/dist/presentation/cli/db-startup.d.ts +61 -0
- package/dist/presentation/cli/formatters/ai-formatter.d.ts +38 -0
- package/dist/presentation/cli/formatters/color.d.ts +82 -0
- package/dist/presentation/cli/formatters/context-formatter.d.ts +55 -0
- package/dist/presentation/cli/formatters/dto-helpers.d.ts +176 -0
- package/dist/presentation/cli/formatters/envelope.d.ts +136 -0
- package/dist/presentation/cli/formatters/error-formatter.d.ts +41 -0
- package/dist/presentation/cli/formatters/friction-dashboard.d.ts +46 -0
- package/dist/presentation/cli/formatters/index.d.ts +17 -0
- package/dist/presentation/cli/formatters/list-formatter.d.ts +48 -0
- package/dist/presentation/cli/formatters/output-formatter.d.ts +98 -0
- package/dist/presentation/cli/formatters/related-formatter.d.ts +57 -0
- package/dist/presentation/cli/formatters/show-formatter.d.ts +63 -0
- package/dist/presentation/cli/formatters/stats-formatter.d.ts +54 -0
- package/dist/presentation/cli/formatters/text-width.d.ts +37 -0
- package/dist/presentation/cli/formatters/timestamp-formatter.d.ts +38 -0
- package/dist/presentation/cli/index.d.ts +10 -0
- package/dist/presentation/cli/index.js +1664 -0
- package/dist/presentation/cli/parsers/date-parser.d.ts +28 -0
- package/dist/presentation/cli/parsers/index.d.ts +6 -0
- package/dist/presentation/cli/pickers/index.d.ts +6 -0
- package/dist/presentation/cli/pickers/session-picker.d.ts +59 -0
- package/dist/presentation/cli/progress-reporter.d.ts +199 -0
- package/package.json +94 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity Domain Type
|
|
3
|
+
*
|
|
4
|
+
* Represents extracted metadata from Claude Code sessions.
|
|
5
|
+
* Four variants: concept, file, decision, term.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has identity (id when persisted)
|
|
9
|
+
* - Immutable after construction
|
|
10
|
+
* - Type-specific metadata for structured storage
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Entity type variants for extracted metadata.
|
|
14
|
+
* (Named ExtractedEntityType to distinguish from link.ts EntityType)
|
|
15
|
+
*/
|
|
16
|
+
export type ExtractedEntityType = "concept" | "file" | "decision" | "term";
|
|
17
|
+
/**
|
|
18
|
+
* Metadata for concept entities (technical concepts).
|
|
19
|
+
*/
|
|
20
|
+
export interface ConceptMetadata {
|
|
21
|
+
/** Category of the concept (e.g., "architecture", "database", "testing") */
|
|
22
|
+
category?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Metadata for file entities (file paths referenced in session).
|
|
26
|
+
*/
|
|
27
|
+
export interface FileMetadata {
|
|
28
|
+
/** Operation performed on the file */
|
|
29
|
+
operation?: "read" | "write" | "edit";
|
|
30
|
+
/** Number of lines in the file */
|
|
31
|
+
lineCount?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Metadata for decision entities (explicit choices made).
|
|
35
|
+
* Required fields: subject, decision
|
|
36
|
+
*/
|
|
37
|
+
export interface DecisionMetadata {
|
|
38
|
+
/** What was being decided */
|
|
39
|
+
subject: string;
|
|
40
|
+
/** The final decision */
|
|
41
|
+
decision: string;
|
|
42
|
+
/** Alternatives that were rejected */
|
|
43
|
+
rejected: string[];
|
|
44
|
+
/** Reasoning behind the decision */
|
|
45
|
+
rationale: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Metadata for term entities (domain-specific terminology).
|
|
49
|
+
*/
|
|
50
|
+
export interface TermMetadata {
|
|
51
|
+
/** Definition of the term */
|
|
52
|
+
definition?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Union type for all entity metadata variants.
|
|
56
|
+
*/
|
|
57
|
+
export type EntityMetadata = ConceptMetadata | FileMetadata | DecisionMetadata | TermMetadata;
|
|
58
|
+
interface EntityParams {
|
|
59
|
+
id?: number | undefined;
|
|
60
|
+
type: ExtractedEntityType;
|
|
61
|
+
name: string;
|
|
62
|
+
confidence: number;
|
|
63
|
+
metadata?: EntityMetadata | undefined;
|
|
64
|
+
createdAt?: Date | undefined;
|
|
65
|
+
}
|
|
66
|
+
export declare class Entity {
|
|
67
|
+
private readonly _id?;
|
|
68
|
+
private readonly _type;
|
|
69
|
+
private readonly _name;
|
|
70
|
+
private readonly _confidence;
|
|
71
|
+
private readonly _metadata?;
|
|
72
|
+
private readonly _createdAt?;
|
|
73
|
+
private constructor();
|
|
74
|
+
/**
|
|
75
|
+
* Create an Entity.
|
|
76
|
+
* @throws Error if name is empty, confidence is out of range, or type is invalid
|
|
77
|
+
* @throws Error if decision type lacks required metadata fields
|
|
78
|
+
*/
|
|
79
|
+
static create(params: EntityParams): Entity;
|
|
80
|
+
/**
|
|
81
|
+
* The database identifier (undefined until persisted).
|
|
82
|
+
*/
|
|
83
|
+
get id(): number | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* The entity type (concept, file, decision, term).
|
|
86
|
+
*/
|
|
87
|
+
get type(): ExtractedEntityType;
|
|
88
|
+
/**
|
|
89
|
+
* The entity name/value.
|
|
90
|
+
*/
|
|
91
|
+
get name(): string;
|
|
92
|
+
/**
|
|
93
|
+
* Confidence score (0-1) for quality filtering.
|
|
94
|
+
*/
|
|
95
|
+
get confidence(): number;
|
|
96
|
+
/**
|
|
97
|
+
* Type-specific metadata (defensive copy).
|
|
98
|
+
*/
|
|
99
|
+
get metadata(): EntityMetadata | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* When the entity was created (defensive copy).
|
|
102
|
+
*/
|
|
103
|
+
get createdAt(): Date | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Type guard: is this a concept entity?
|
|
106
|
+
*/
|
|
107
|
+
get isConcept(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Type guard: is this a file entity?
|
|
110
|
+
*/
|
|
111
|
+
get isFile(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Type guard: is this a decision entity?
|
|
114
|
+
*/
|
|
115
|
+
get isDecision(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Type guard: is this a term entity?
|
|
118
|
+
*/
|
|
119
|
+
get isTerm(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Check equality with another Entity.
|
|
122
|
+
* Compares by id when both have ids, otherwise by type+name.
|
|
123
|
+
*/
|
|
124
|
+
equals(other: Entity): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Return a new Entity with the specified id.
|
|
127
|
+
* Used after database insert to assign the generated id.
|
|
128
|
+
*/
|
|
129
|
+
withId(id: number): Entity;
|
|
130
|
+
}
|
|
131
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExtractionState Entity
|
|
3
|
+
*
|
|
4
|
+
* Tracks the state of extracting a session from JSONL files.
|
|
5
|
+
* Enables incremental sync and progress tracking.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has unique identity (id)
|
|
9
|
+
* - Immutable after construction (state changes return new instances)
|
|
10
|
+
* - Tracks extraction lifecycle (pending -> in_progress -> complete/error)
|
|
11
|
+
*/
|
|
12
|
+
export type ExtractionStatus = "pending" | "in_progress" | "complete" | "error";
|
|
13
|
+
interface ExtractionStateParams {
|
|
14
|
+
id: string;
|
|
15
|
+
sessionPath: string;
|
|
16
|
+
startedAt: Date;
|
|
17
|
+
status?: ExtractionStatus | undefined;
|
|
18
|
+
completedAt?: Date | undefined;
|
|
19
|
+
messagesExtracted?: number | undefined;
|
|
20
|
+
errorMessage?: string | undefined;
|
|
21
|
+
fileMtime?: Date | undefined;
|
|
22
|
+
fileSize?: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare class ExtractionState {
|
|
25
|
+
private readonly _id;
|
|
26
|
+
private readonly _sessionPath;
|
|
27
|
+
private readonly _startedAt;
|
|
28
|
+
private readonly _status;
|
|
29
|
+
private readonly _completedAt?;
|
|
30
|
+
private readonly _messagesExtracted;
|
|
31
|
+
private readonly _errorMessage?;
|
|
32
|
+
private readonly _fileMtime?;
|
|
33
|
+
private readonly _fileSize?;
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Create an ExtractionState entity.
|
|
37
|
+
* @throws Error if id or sessionPath is empty, status is invalid, or messagesExtracted is negative
|
|
38
|
+
*/
|
|
39
|
+
static create(params: ExtractionStateParams): ExtractionState;
|
|
40
|
+
/**
|
|
41
|
+
* The unique extraction state identifier.
|
|
42
|
+
*/
|
|
43
|
+
get id(): string;
|
|
44
|
+
/**
|
|
45
|
+
* The path to the session JSONL file being extracted.
|
|
46
|
+
*/
|
|
47
|
+
get sessionPath(): string;
|
|
48
|
+
/**
|
|
49
|
+
* When the extraction started.
|
|
50
|
+
*/
|
|
51
|
+
get startedAt(): Date;
|
|
52
|
+
/**
|
|
53
|
+
* The current extraction status.
|
|
54
|
+
*/
|
|
55
|
+
get status(): ExtractionStatus;
|
|
56
|
+
/**
|
|
57
|
+
* When the extraction completed (if complete or error).
|
|
58
|
+
*/
|
|
59
|
+
get completedAt(): Date | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Number of messages extracted so far.
|
|
62
|
+
*/
|
|
63
|
+
get messagesExtracted(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Error message if extraction failed.
|
|
66
|
+
*/
|
|
67
|
+
get errorMessage(): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* File modification time when extraction started.
|
|
70
|
+
* Used for incremental sync detection.
|
|
71
|
+
*/
|
|
72
|
+
get fileMtime(): Date | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* File size in bytes when extraction started.
|
|
75
|
+
* Used for incremental sync detection.
|
|
76
|
+
*/
|
|
77
|
+
get fileSize(): number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Whether extraction is pending.
|
|
80
|
+
*/
|
|
81
|
+
get isPending(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether extraction is in progress.
|
|
84
|
+
*/
|
|
85
|
+
get isInProgress(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether extraction is complete.
|
|
88
|
+
*/
|
|
89
|
+
get isComplete(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Whether extraction failed.
|
|
92
|
+
*/
|
|
93
|
+
get isError(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Duration of extraction in milliseconds (only available when complete).
|
|
96
|
+
*/
|
|
97
|
+
get durationMs(): number | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Check equality with another ExtractionState (based on id).
|
|
100
|
+
*/
|
|
101
|
+
equals(other: ExtractionState): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Start processing this extraction.
|
|
104
|
+
* Returns a new ExtractionState instance (immutability).
|
|
105
|
+
*/
|
|
106
|
+
startProcessing(): ExtractionState;
|
|
107
|
+
/**
|
|
108
|
+
* Mark extraction as complete.
|
|
109
|
+
* Returns a new ExtractionState instance (immutability).
|
|
110
|
+
*/
|
|
111
|
+
complete(completedAt: Date): ExtractionState;
|
|
112
|
+
/**
|
|
113
|
+
* Mark extraction as failed.
|
|
114
|
+
* Returns a new ExtractionState instance (immutability).
|
|
115
|
+
*/
|
|
116
|
+
fail(errorMessage: string): ExtractionState;
|
|
117
|
+
/**
|
|
118
|
+
* Increment the count of extracted messages.
|
|
119
|
+
* Returns a new ExtractionState instance (immutability).
|
|
120
|
+
*/
|
|
121
|
+
incrementMessages(count?: number): ExtractionState;
|
|
122
|
+
/**
|
|
123
|
+
* Set file metadata for incremental sync detection.
|
|
124
|
+
* Returns a new ExtractionState instance (immutability).
|
|
125
|
+
*/
|
|
126
|
+
withFileMetadata(mtime: Date, size: number): ExtractionState;
|
|
127
|
+
}
|
|
128
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fact Domain Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a structured fact or event in the system.
|
|
5
|
+
* Part of the hybrid event-log Source of Truth (SSOT).
|
|
6
|
+
*
|
|
7
|
+
* Immutable after construction.
|
|
8
|
+
*/
|
|
9
|
+
export type FactType = "decision" | "learning" | "preference" | "friction" | "observation" | "supersedence";
|
|
10
|
+
export interface FactParams {
|
|
11
|
+
id?: number | undefined;
|
|
12
|
+
uuid?: string | undefined;
|
|
13
|
+
type: FactType;
|
|
14
|
+
project: string;
|
|
15
|
+
content: string;
|
|
16
|
+
metadata?: Record<string, any> | undefined;
|
|
17
|
+
observedAt: Date;
|
|
18
|
+
supersededAt?: Date | null | undefined;
|
|
19
|
+
supersededBy?: string | null | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface CandidateFact {
|
|
22
|
+
type: "decision" | "learning" | "preference" | "friction" | "observation";
|
|
23
|
+
content: string;
|
|
24
|
+
metadata?: Record<string, any> | undefined;
|
|
25
|
+
confidence: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class Fact {
|
|
28
|
+
private readonly _id?;
|
|
29
|
+
private readonly _uuid;
|
|
30
|
+
private readonly _type;
|
|
31
|
+
private readonly _project;
|
|
32
|
+
private readonly _content;
|
|
33
|
+
private readonly _metadata?;
|
|
34
|
+
private readonly _observedAt;
|
|
35
|
+
private readonly _supersededAt;
|
|
36
|
+
private readonly _supersededBy;
|
|
37
|
+
private constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Fact entity and validates invariants.
|
|
40
|
+
*/
|
|
41
|
+
static create(params: FactParams): Fact;
|
|
42
|
+
get id(): number | undefined;
|
|
43
|
+
get uuid(): string;
|
|
44
|
+
get type(): FactType;
|
|
45
|
+
get project(): string;
|
|
46
|
+
get content(): string;
|
|
47
|
+
get metadata(): Record<string, any> | undefined;
|
|
48
|
+
get observedAt(): Date;
|
|
49
|
+
get supersededAt(): Date | null;
|
|
50
|
+
get supersededBy(): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a new Fact instance with the specified database primary key ID.
|
|
53
|
+
*/
|
|
54
|
+
withId(id: number): Fact;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a new Fact instance marked as superseded by a replacement Fact.
|
|
57
|
+
*/
|
|
58
|
+
withSuperseded(supersededAt: Date, supersededByUuid: string): Fact;
|
|
59
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrictionEntry Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a logged friction point with a tool.
|
|
5
|
+
* Friction entries track tool-specific issues (search failures,
|
|
6
|
+
* unhelpful output, missing features, workarounds needed) for
|
|
7
|
+
* self-improvement feedback loops.
|
|
8
|
+
*
|
|
9
|
+
* Entity properties:
|
|
10
|
+
* - Has identity (id when persisted)
|
|
11
|
+
* - Immutable after construction
|
|
12
|
+
* - Validated on creation via static create()
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Severity levels for friction entries.
|
|
16
|
+
*/
|
|
17
|
+
export type FrictionSeverity = "low" | "medium" | "high" | "critical";
|
|
18
|
+
/**
|
|
19
|
+
* Categories of friction. Any non-empty string is valid.
|
|
20
|
+
*/
|
|
21
|
+
export type FrictionCategory = string;
|
|
22
|
+
/**
|
|
23
|
+
* Common friction categories. Not enforced -- any non-empty string is valid.
|
|
24
|
+
*/
|
|
25
|
+
export declare const COMMON_CATEGORIES: readonly ["search", "sync", "cli", "context", "integration", "ux"];
|
|
26
|
+
/**
|
|
27
|
+
* Lifecycle status of a friction entry.
|
|
28
|
+
*/
|
|
29
|
+
export type FrictionStatus = "open" | "resolved" | "wont-fix";
|
|
30
|
+
interface FrictionEntryParams {
|
|
31
|
+
id?: number | undefined;
|
|
32
|
+
description: string;
|
|
33
|
+
severity: FrictionSeverity;
|
|
34
|
+
category: FrictionCategory;
|
|
35
|
+
status: FrictionStatus;
|
|
36
|
+
tool: string;
|
|
37
|
+
tags?: string[] | undefined;
|
|
38
|
+
lastReviewedAt?: Date | undefined;
|
|
39
|
+
context?: string | undefined;
|
|
40
|
+
sourceProject?: string | undefined;
|
|
41
|
+
loggedAt: Date;
|
|
42
|
+
resolvedAt?: Date | undefined;
|
|
43
|
+
resolution?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export declare class FrictionEntry {
|
|
46
|
+
private readonly _id?;
|
|
47
|
+
private readonly _description;
|
|
48
|
+
private readonly _severity;
|
|
49
|
+
private readonly _category;
|
|
50
|
+
private readonly _status;
|
|
51
|
+
private readonly _tool;
|
|
52
|
+
private readonly _tags?;
|
|
53
|
+
private readonly _lastReviewedAt?;
|
|
54
|
+
private readonly _context?;
|
|
55
|
+
private readonly _sourceProject?;
|
|
56
|
+
private readonly _loggedAt;
|
|
57
|
+
private readonly _resolvedAt?;
|
|
58
|
+
private readonly _resolution?;
|
|
59
|
+
private constructor();
|
|
60
|
+
/**
|
|
61
|
+
* Create a FrictionEntry entity.
|
|
62
|
+
* @throws Error if description is empty or whitespace-only
|
|
63
|
+
* @throws Error if severity is not a valid FrictionSeverity
|
|
64
|
+
* @throws Error if category is empty or whitespace-only
|
|
65
|
+
* @throws Error if status is not a valid FrictionStatus
|
|
66
|
+
* @throws Error if tool is empty or whitespace-only
|
|
67
|
+
* @throws Error if status is "open" but resolvedAt is provided
|
|
68
|
+
*/
|
|
69
|
+
static create(params: FrictionEntryParams): FrictionEntry;
|
|
70
|
+
get id(): number | undefined;
|
|
71
|
+
get description(): string;
|
|
72
|
+
get severity(): FrictionSeverity;
|
|
73
|
+
get category(): FrictionCategory;
|
|
74
|
+
get status(): FrictionStatus;
|
|
75
|
+
get tool(): string;
|
|
76
|
+
get tags(): string[] | undefined;
|
|
77
|
+
get lastReviewedAt(): Date | undefined;
|
|
78
|
+
get context(): string | undefined;
|
|
79
|
+
get sourceProject(): string | undefined;
|
|
80
|
+
get loggedAt(): Date;
|
|
81
|
+
get resolvedAt(): Date | undefined;
|
|
82
|
+
get resolution(): string | undefined;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Entities
|
|
3
|
+
*
|
|
4
|
+
* Core business objects with identity and lifecycle.
|
|
5
|
+
*/
|
|
6
|
+
export { Entity, type ExtractedEntityType, type ConceptMetadata, type FileMetadata, type DecisionMetadata, type TermMetadata, type EntityMetadata, } from "./entity.js";
|
|
7
|
+
export { ExtractionState, type ExtractionStatus, } from "./extraction-state.js";
|
|
8
|
+
export { Link, type EntityType, type LinkType } from "./link.js";
|
|
9
|
+
export { Message, type MessageRole } from "./message.js";
|
|
10
|
+
export { Session } from "./session.js";
|
|
11
|
+
export { ToolUse, type ToolUseStatus } from "./tool-use.js";
|
|
12
|
+
export { MemoryFile, type MemoryFileType } from "./memory-file.js";
|
|
13
|
+
export { FrictionEntry, type FrictionSeverity, type FrictionCategory, type FrictionStatus, } from "./friction-entry.js";
|
|
14
|
+
export { BackfillState } from "./backfill-state.js";
|
|
15
|
+
export { Fact, type FactType, type FactParams, type CandidateFact } from "./fact.js";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a relationship between entities for graph-like traversal.
|
|
5
|
+
* Enables cross-session and cross-topic navigation in the memory database.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has composite identity (source + target + relationship)
|
|
9
|
+
* - Immutable after construction
|
|
10
|
+
* - Supports weighted relationships for relevance scoring
|
|
11
|
+
*/
|
|
12
|
+
export type EntityType = "session" | "message" | "topic";
|
|
13
|
+
export type LinkType = "mentions" | "related_to" | "continues";
|
|
14
|
+
interface LinkParams {
|
|
15
|
+
sourceType: EntityType;
|
|
16
|
+
sourceId: string;
|
|
17
|
+
targetType: EntityType;
|
|
18
|
+
targetId: string;
|
|
19
|
+
relationship: LinkType;
|
|
20
|
+
weight?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class Link {
|
|
23
|
+
private readonly _sourceType;
|
|
24
|
+
private readonly _sourceId;
|
|
25
|
+
private readonly _targetType;
|
|
26
|
+
private readonly _targetId;
|
|
27
|
+
private readonly _relationship;
|
|
28
|
+
private readonly _weight;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Create a Link entity.
|
|
32
|
+
* @throws Error if IDs are empty, types are invalid, or weight is out of range
|
|
33
|
+
*/
|
|
34
|
+
static create(params: LinkParams): Link;
|
|
35
|
+
/**
|
|
36
|
+
* Composite identifier for this link.
|
|
37
|
+
*/
|
|
38
|
+
get id(): string;
|
|
39
|
+
/**
|
|
40
|
+
* The type of the source entity.
|
|
41
|
+
*/
|
|
42
|
+
get sourceType(): EntityType;
|
|
43
|
+
/**
|
|
44
|
+
* The ID of the source entity.
|
|
45
|
+
*/
|
|
46
|
+
get sourceId(): string;
|
|
47
|
+
/**
|
|
48
|
+
* The type of the target entity.
|
|
49
|
+
*/
|
|
50
|
+
get targetType(): EntityType;
|
|
51
|
+
/**
|
|
52
|
+
* The ID of the target entity.
|
|
53
|
+
*/
|
|
54
|
+
get targetId(): string;
|
|
55
|
+
/**
|
|
56
|
+
* The type of relationship between entities.
|
|
57
|
+
*/
|
|
58
|
+
get relationship(): LinkType;
|
|
59
|
+
/**
|
|
60
|
+
* The weight/strength of this relationship (0-1).
|
|
61
|
+
*/
|
|
62
|
+
get weight(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Check equality with another Link (based on composite id).
|
|
65
|
+
*/
|
|
66
|
+
equals(other: Link): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new Link with an updated weight.
|
|
69
|
+
* Returns a new Link instance (immutability).
|
|
70
|
+
* @throws Error if weight is out of range
|
|
71
|
+
*/
|
|
72
|
+
withWeight(weight: number): Link;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryFile Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents an indexed legacy markdown memory file.
|
|
5
|
+
* Memory files are agent-written markdown files (daily logs, decisions,
|
|
6
|
+
* learnings, user preferences) that persist knowledge across sessions.
|
|
7
|
+
*
|
|
8
|
+
* Entity properties:
|
|
9
|
+
* - Has identity (id when persisted)
|
|
10
|
+
* - Immutable after construction
|
|
11
|
+
* - Validated on creation via static create()
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The four types of memory files supported.
|
|
15
|
+
*/
|
|
16
|
+
export type MemoryFileType = "daily_log" | "decisions" | "learnings" | "user_prefs";
|
|
17
|
+
interface MemoryFileParams {
|
|
18
|
+
id?: number | undefined;
|
|
19
|
+
filePath: string;
|
|
20
|
+
fileType: MemoryFileType;
|
|
21
|
+
projectEncoded?: string | undefined;
|
|
22
|
+
content: string;
|
|
23
|
+
contentHash: string;
|
|
24
|
+
lastIndexedAt: Date;
|
|
25
|
+
createdAt?: Date | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare class MemoryFile {
|
|
28
|
+
private readonly _id?;
|
|
29
|
+
private readonly _filePath;
|
|
30
|
+
private readonly _fileType;
|
|
31
|
+
private readonly _projectEncoded?;
|
|
32
|
+
private readonly _content;
|
|
33
|
+
private readonly _contentHash;
|
|
34
|
+
private readonly _lastIndexedAt;
|
|
35
|
+
private readonly _createdAt;
|
|
36
|
+
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Create a MemoryFile entity.
|
|
39
|
+
* @throws Error if filePath is empty
|
|
40
|
+
* @throws Error if content is empty
|
|
41
|
+
* @throws Error if contentHash is not 64 lowercase hex characters
|
|
42
|
+
* @throws Error if fileType is not a valid MemoryFileType
|
|
43
|
+
*/
|
|
44
|
+
static create(params: MemoryFileParams): MemoryFile;
|
|
45
|
+
/**
|
|
46
|
+
* The database identifier (undefined until persisted).
|
|
47
|
+
*/
|
|
48
|
+
get id(): number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Path relative to the legacy memory-file root (uses forward slashes).
|
|
51
|
+
*/
|
|
52
|
+
get filePath(): string;
|
|
53
|
+
/**
|
|
54
|
+
* The classified file type.
|
|
55
|
+
*/
|
|
56
|
+
get fileType(): MemoryFileType;
|
|
57
|
+
/**
|
|
58
|
+
* Encoded project path, or undefined for global files.
|
|
59
|
+
*/
|
|
60
|
+
get projectEncoded(): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Full file content.
|
|
63
|
+
*/
|
|
64
|
+
get content(): string;
|
|
65
|
+
/**
|
|
66
|
+
* SHA-256 hash of file content (lowercase hex).
|
|
67
|
+
*/
|
|
68
|
+
get contentHash(): string;
|
|
69
|
+
/**
|
|
70
|
+
* When this file was last indexed by sync (defensive copy).
|
|
71
|
+
*/
|
|
72
|
+
get lastIndexedAt(): Date;
|
|
73
|
+
/**
|
|
74
|
+
* When this entity was created (defensive copy).
|
|
75
|
+
*/
|
|
76
|
+
get createdAt(): Date;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a single message in a Claude Code session.
|
|
5
|
+
* Can be from the user or assistant, and may contain tool use references.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has unique identity (id)
|
|
9
|
+
* - Immutable after construction
|
|
10
|
+
* - Can reference ToolUse entities by ID
|
|
11
|
+
*/
|
|
12
|
+
export type MessageRole = "user" | "assistant";
|
|
13
|
+
interface MessageParams {
|
|
14
|
+
id: string;
|
|
15
|
+
role: MessageRole;
|
|
16
|
+
content: string;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
toolUseIds?: string[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare class Message {
|
|
21
|
+
private readonly _id;
|
|
22
|
+
private readonly _role;
|
|
23
|
+
private readonly _content;
|
|
24
|
+
private readonly _timestamp;
|
|
25
|
+
private readonly _toolUseIds;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Create a Message entity.
|
|
29
|
+
* @throws Error if id is empty or role is invalid
|
|
30
|
+
*/
|
|
31
|
+
static create(params: MessageParams): Message;
|
|
32
|
+
/**
|
|
33
|
+
* The unique message identifier.
|
|
34
|
+
*/
|
|
35
|
+
get id(): string;
|
|
36
|
+
/**
|
|
37
|
+
* The message role (user or assistant).
|
|
38
|
+
*/
|
|
39
|
+
get role(): MessageRole;
|
|
40
|
+
/**
|
|
41
|
+
* The message text content.
|
|
42
|
+
*/
|
|
43
|
+
get content(): string;
|
|
44
|
+
/**
|
|
45
|
+
* When the message was created.
|
|
46
|
+
*/
|
|
47
|
+
get timestamp(): Date;
|
|
48
|
+
/**
|
|
49
|
+
* IDs of tool uses associated with this message.
|
|
50
|
+
*/
|
|
51
|
+
get toolUses(): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Whether this message has text content.
|
|
54
|
+
*/
|
|
55
|
+
get hasContent(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether this message has any tool uses.
|
|
58
|
+
*/
|
|
59
|
+
get hasToolUses(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Check equality with another Message (based on id).
|
|
62
|
+
*/
|
|
63
|
+
equals(other: Message): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Add a tool use reference to this message.
|
|
66
|
+
* Returns a new Message instance (immutability).
|
|
67
|
+
*/
|
|
68
|
+
addToolUse(toolUseId: string): Message;
|
|
69
|
+
}
|
|
70
|
+
export {};
|