k0ntext 3.3.1 → 3.6.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 +225 -26
- package/dist/agents/cleanup-agent.d.ts.map +1 -1
- package/dist/agents/cleanup-agent.js +18 -6
- package/dist/agents/cleanup-agent.js.map +1 -1
- package/dist/agents/drift-agent.d.ts +7 -0
- package/dist/agents/drift-agent.d.ts.map +1 -1
- package/dist/agents/drift-agent.js +29 -8
- package/dist/agents/drift-agent.js.map +1 -1
- package/dist/cli/commands/cleanup.d.ts.map +1 -1
- package/dist/cli/commands/cleanup.js +8 -1
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/drift-detect.d.ts.map +1 -1
- package/dist/cli/commands/drift-detect.js +21 -1
- package/dist/cli/commands/drift-detect.js.map +1 -1
- package/dist/cli/commands/embeddings-refresh.d.ts +11 -0
- package/dist/cli/commands/embeddings-refresh.d.ts.map +1 -0
- package/dist/cli/commands/embeddings-refresh.js +114 -0
- package/dist/cli/commands/embeddings-refresh.js.map +1 -0
- package/dist/cli/commands/migrate.d.ts +11 -0
- package/dist/cli/commands/migrate.d.ts.map +1 -0
- package/dist/cli/commands/migrate.js +195 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/restore.d.ts +12 -0
- package/dist/cli/commands/restore.d.ts.map +1 -0
- package/dist/cli/commands/restore.js +261 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/sync-templates.d.ts +15 -0
- package/dist/cli/commands/sync-templates.d.ts.map +1 -0
- package/dist/cli/commands/sync-templates.js +181 -0
- package/dist/cli/commands/sync-templates.js.map +1 -0
- package/dist/cli/commands/version-check.d.ts +12 -0
- package/dist/cli/commands/version-check.d.ts.map +1 -0
- package/dist/cli/commands/version-check.js +133 -0
- package/dist/cli/commands/version-check.js.map +1 -0
- package/dist/cli/generate.d.ts +5 -0
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +80 -16
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/index.js +215 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/repl/index.d.ts +1 -0
- package/dist/cli/repl/index.d.ts.map +1 -1
- package/dist/cli/repl/index.js +18 -6
- package/dist/cli/repl/index.js.map +1 -1
- package/dist/cli/utils/backup-manager.d.ts +94 -0
- package/dist/cli/utils/backup-manager.d.ts.map +1 -0
- package/dist/cli/utils/backup-manager.js +230 -0
- package/dist/cli/utils/backup-manager.js.map +1 -0
- package/dist/cli/utils/db-backup-manager.d.ts +55 -0
- package/dist/cli/utils/db-backup-manager.d.ts.map +1 -0
- package/dist/cli/utils/db-backup-manager.js +115 -0
- package/dist/cli/utils/db-backup-manager.js.map +1 -0
- package/dist/cli/utils/file-detector.d.ts +87 -0
- package/dist/cli/utils/file-detector.d.ts.map +1 -0
- package/dist/cli/utils/file-detector.js +131 -0
- package/dist/cli/utils/file-detector.js.map +1 -0
- package/dist/cli/utils/index.d.ts +9 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +9 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/modification-prompt.d.ts +41 -0
- package/dist/cli/utils/modification-prompt.d.ts.map +1 -0
- package/dist/cli/utils/modification-prompt.js +84 -0
- package/dist/cli/utils/modification-prompt.js.map +1 -0
- package/dist/cli/version/checker.d.ts +47 -0
- package/dist/cli/version/checker.d.ts.map +1 -0
- package/dist/cli/version/checker.js +143 -0
- package/dist/cli/version/checker.js.map +1 -0
- package/dist/cli/version/comparator.d.ts +46 -0
- package/dist/cli/version/comparator.d.ts.map +1 -0
- package/dist/cli/version/comparator.js +99 -0
- package/dist/cli/version/comparator.js.map +1 -0
- package/dist/cli/version/index.d.ts +11 -0
- package/dist/cli/version/index.d.ts.map +1 -0
- package/dist/cli/version/index.js +11 -0
- package/dist/cli/version/index.js.map +1 -0
- package/dist/cli/version/parser.d.ts +38 -0
- package/dist/cli/version/parser.d.ts.map +1 -0
- package/dist/cli/version/parser.js +90 -0
- package/dist/cli/version/parser.js.map +1 -0
- package/dist/cli/version/prompt.d.ts +40 -0
- package/dist/cli/version/prompt.d.ts.map +1 -0
- package/dist/cli/version/prompt.js +162 -0
- package/dist/cli/version/prompt.js.map +1 -0
- package/dist/cli/version/types.d.ts +89 -0
- package/dist/cli/version/types.d.ts.map +1 -0
- package/dist/cli/version/types.js +7 -0
- package/dist/cli/version/types.js.map +1 -0
- package/dist/db/client.d.ts +79 -4
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +207 -12
- package/dist/db/client.js.map +1 -1
- package/dist/db/migrations/files/0014_add_schema_migrations_table.d.ts +14 -0
- package/dist/db/migrations/files/0014_add_schema_migrations_table.d.ts.map +1 -0
- package/dist/db/migrations/files/0014_add_schema_migrations_table.js +25 -0
- package/dist/db/migrations/files/0014_add_schema_migrations_table.js.map +1 -0
- package/dist/db/migrations/index.d.ts +9 -0
- package/dist/db/migrations/index.d.ts.map +1 -0
- package/dist/db/migrations/index.js +9 -0
- package/dist/db/migrations/index.js.map +1 -0
- package/dist/db/migrations/loader.d.ts +27 -0
- package/dist/db/migrations/loader.d.ts.map +1 -0
- package/dist/db/migrations/loader.js +106 -0
- package/dist/db/migrations/loader.js.map +1 -0
- package/dist/db/migrations/runner.d.ts +56 -0
- package/dist/db/migrations/runner.d.ts.map +1 -0
- package/dist/db/migrations/runner.js +266 -0
- package/dist/db/migrations/runner.js.map +1 -0
- package/dist/db/migrations/types.d.ts +71 -0
- package/dist/db/migrations/types.d.ts.map +1 -0
- package/dist/db/migrations/types.js +7 -0
- package/dist/db/migrations/types.js.map +1 -0
- package/dist/db/schema.d.ts +41 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +77 -2
- package/dist/db/schema.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/mcp.js.map +1 -1
- package/dist/template-engine/data-transformer.d.ts +17 -0
- package/dist/template-engine/data-transformer.d.ts.map +1 -0
- package/dist/template-engine/data-transformer.js +343 -0
- package/dist/template-engine/data-transformer.js.map +1 -0
- package/dist/template-engine/engine.d.ts +74 -0
- package/dist/template-engine/engine.d.ts.map +1 -0
- package/dist/template-engine/engine.js +183 -0
- package/dist/template-engine/engine.js.map +1 -0
- package/dist/template-engine/helpers.d.ts +81 -0
- package/dist/template-engine/helpers.d.ts.map +1 -0
- package/dist/template-engine/helpers.js +153 -0
- package/dist/template-engine/helpers.js.map +1 -0
- package/dist/template-engine/index.d.ts +10 -0
- package/dist/template-engine/index.d.ts.map +1 -0
- package/dist/template-engine/index.js +10 -0
- package/dist/template-engine/index.js.map +1 -0
- package/dist/template-engine/types.d.ts +147 -0
- package/dist/template-engine/types.d.ts.map +1 -0
- package/dist/template-engine/types.js +7 -0
- package/dist/template-engine/types.js.map +1 -0
- package/dist/template-sync/comparator.d.ts +138 -0
- package/dist/template-sync/comparator.d.ts.map +1 -0
- package/dist/template-sync/comparator.js +353 -0
- package/dist/template-sync/comparator.js.map +1 -0
- package/dist/template-sync/conflict-resolver.d.ts +112 -0
- package/dist/template-sync/conflict-resolver.d.ts.map +1 -0
- package/dist/template-sync/conflict-resolver.js +328 -0
- package/dist/template-sync/conflict-resolver.js.map +1 -0
- package/dist/template-sync/engine.d.ts +93 -0
- package/dist/template-sync/engine.d.ts.map +1 -0
- package/dist/template-sync/engine.js +350 -0
- package/dist/template-sync/engine.js.map +1 -0
- package/dist/template-sync/hasher.d.ts +67 -0
- package/dist/template-sync/hasher.d.ts.map +1 -0
- package/dist/template-sync/hasher.js +94 -0
- package/dist/template-sync/hasher.js.map +1 -0
- package/dist/template-sync/index.d.ts +20 -0
- package/dist/template-sync/index.d.ts.map +1 -0
- package/dist/template-sync/index.js +14 -0
- package/dist/template-sync/index.js.map +1 -0
- package/dist/template-sync/manifest.d.ts +131 -0
- package/dist/template-sync/manifest.d.ts.map +1 -0
- package/dist/template-sync/manifest.js +309 -0
- package/dist/template-sync/manifest.js.map +1 -0
- package/dist/template-sync/merger.d.ts +125 -0
- package/dist/template-sync/merger.d.ts.map +1 -0
- package/dist/template-sync/merger.js +371 -0
- package/dist/template-sync/merger.js.map +1 -0
- package/dist/template-sync/scanner.d.ts +106 -0
- package/dist/template-sync/scanner.d.ts.map +1 -0
- package/dist/template-sync/scanner.js +196 -0
- package/dist/template-sync/scanner.js.map +1 -0
- package/dist/template-sync/types.d.ts +199 -0
- package/dist/template-sync/types.d.ts.map +1 -0
- package/dist/template-sync/types.js +30 -0
- package/dist/template-sync/types.js.map +1 -0
- package/package.json +2 -1
- package/src/agents/cleanup-agent.ts +21 -6
- package/src/agents/drift-agent.ts +31 -8
- package/src/cli/commands/cleanup.ts +9 -1
- package/src/cli/commands/drift-detect.ts +24 -1
- package/src/cli/commands/embeddings-refresh.ts +135 -0
- package/src/cli/commands/migrate.ts +231 -0
- package/src/cli/commands/restore.ts +318 -0
- package/src/cli/commands/sync-templates.ts +210 -0
- package/src/cli/commands/version-check.ts +158 -0
- package/src/cli/generate.ts +99 -17
- package/src/cli/index.ts +246 -1
- package/src/cli/repl/index.ts +16 -6
- package/src/cli/utils/backup-manager.ts +275 -0
- package/src/cli/utils/db-backup-manager.ts +146 -0
- package/src/cli/utils/file-detector.ts +181 -0
- package/src/cli/utils/index.ts +9 -0
- package/src/cli/utils/modification-prompt.ts +112 -0
- package/src/cli/version/checker.ts +172 -0
- package/src/cli/version/comparator.ts +106 -0
- package/src/cli/version/index.ts +11 -0
- package/src/cli/version/parser.ts +101 -0
- package/src/cli/version/prompt.ts +208 -0
- package/src/cli/version/types.ts +95 -0
- package/src/db/client.ts +285 -18
- package/src/db/migrations/files/0014_add_schema_migrations_table.sql +19 -0
- package/src/db/migrations/files/0014_add_schema_migrations_table.ts +30 -0
- package/src/db/migrations/index.ts +9 -0
- package/src/db/migrations/loader.ts +129 -0
- package/src/db/migrations/runner.ts +316 -0
- package/src/db/migrations/types.ts +71 -0
- package/src/db/schema.ts +109 -2
- package/src/mcp.ts +2 -2
- package/src/template-engine/data-transformer.ts +367 -0
- package/src/template-engine/engine.ts +213 -0
- package/src/template-engine/helpers.ts +163 -0
- package/src/template-engine/index.ts +10 -0
- package/src/template-engine/types.ts +158 -0
- package/src/template-sync/comparator.ts +452 -0
- package/src/template-sync/conflict-resolver.ts +401 -0
- package/src/template-sync/engine.ts +417 -0
- package/src/template-sync/hasher.ts +104 -0
- package/src/template-sync/index.ts +60 -0
- package/src/template-sync/manifest.ts +358 -0
- package/src/template-sync/merger.ts +454 -0
- package/src/template-sync/scanner.ts +254 -0
- package/src/template-sync/types.ts +247 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Sync Types
|
|
3
|
+
*
|
|
4
|
+
* All type definitions for the template sync system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Template file metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface TemplateFile {
|
|
11
|
+
/** Relative path from .claude/ or templates/base/.claude/ */
|
|
12
|
+
relativePath: string;
|
|
13
|
+
/** Content hash (SHA-256, 16 chars) */
|
|
14
|
+
hash: string;
|
|
15
|
+
/** File size in bytes */
|
|
16
|
+
size: number;
|
|
17
|
+
/** Last modified time */
|
|
18
|
+
mtime: Date;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Template manifest structure (stored in DB and .claude/.k0ntext-manifest.json)
|
|
23
|
+
*/
|
|
24
|
+
export interface TemplateManifest {
|
|
25
|
+
/** k0ntext version that generated this manifest */
|
|
26
|
+
k0ntextVersion: string;
|
|
27
|
+
/** Template source version */
|
|
28
|
+
templateVersion: string;
|
|
29
|
+
/** Timestamp when manifest was created */
|
|
30
|
+
createdAt: string;
|
|
31
|
+
/** Timestamp when manifest was last updated */
|
|
32
|
+
updatedAt?: string;
|
|
33
|
+
/** All tracked template files keyed by relative path */
|
|
34
|
+
files: Record<string, TemplateFileEntry>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Single file entry in manifest
|
|
39
|
+
*/
|
|
40
|
+
export interface TemplateFileEntry {
|
|
41
|
+
/** Content hash */
|
|
42
|
+
hash: string;
|
|
43
|
+
/** Template version when file was last updated */
|
|
44
|
+
templateVersion: string;
|
|
45
|
+
/** Whether user has modified this file */
|
|
46
|
+
userModified: boolean;
|
|
47
|
+
/** Last sync timestamp */
|
|
48
|
+
lastSyncedAt?: string;
|
|
49
|
+
/** Original template hash (before user modification) */
|
|
50
|
+
originalHash?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Comparison result for a single file
|
|
55
|
+
*/
|
|
56
|
+
export interface FileComparison {
|
|
57
|
+
/** Relative path from .claude/ */
|
|
58
|
+
path: string;
|
|
59
|
+
/** Current state */
|
|
60
|
+
state: FileState;
|
|
61
|
+
/** Template hash (from package) */
|
|
62
|
+
templateHash: string;
|
|
63
|
+
/** Local hash (from .claude/) */
|
|
64
|
+
localHash: string;
|
|
65
|
+
/** Whether user has modified (from manifest) */
|
|
66
|
+
userModified: boolean;
|
|
67
|
+
/** Original template hash (if user modified) */
|
|
68
|
+
originalHash?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* File state after comparison
|
|
73
|
+
*/
|
|
74
|
+
export type FileState =
|
|
75
|
+
| 'identical' // File matches template exactly
|
|
76
|
+
| 'safe-update' // Template changed, file not modified by user
|
|
77
|
+
| 'conflict' // Template changed AND user modified file
|
|
78
|
+
| 'new' // File exists in template but not locally
|
|
79
|
+
| 'deleted' // File exists locally but not in template (user-added)
|
|
80
|
+
| 'user-only'; // User-only file, not in template
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Sync operation result
|
|
84
|
+
*/
|
|
85
|
+
export interface SyncResult {
|
|
86
|
+
/** Total files processed */
|
|
87
|
+
total: number;
|
|
88
|
+
/** Files updated (safe merge) */
|
|
89
|
+
updated: number;
|
|
90
|
+
/** Files skipped (user modified/conflict) */
|
|
91
|
+
skipped: string[];
|
|
92
|
+
/** New files created */
|
|
93
|
+
created: number;
|
|
94
|
+
/** Files in conflict requiring resolution */
|
|
95
|
+
conflicts: FileComparison[];
|
|
96
|
+
/** User-only files (deleted from template) */
|
|
97
|
+
userOnly: string[];
|
|
98
|
+
/** Duration in milliseconds */
|
|
99
|
+
durationMs: number;
|
|
100
|
+
/** Whether this was a dry run */
|
|
101
|
+
dryRun?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Sync options
|
|
106
|
+
*/
|
|
107
|
+
export interface SyncOptions {
|
|
108
|
+
/** Dry run - don't make changes */
|
|
109
|
+
dryRun?: boolean;
|
|
110
|
+
/** Force update all files (skip prompts, overwrite user modifications) */
|
|
111
|
+
force?: boolean;
|
|
112
|
+
/** Specific subdirectories to sync */
|
|
113
|
+
subdirectories?: TemplateSubdir[];
|
|
114
|
+
/** Verbose output */
|
|
115
|
+
verbose?: boolean;
|
|
116
|
+
/** Whether to archive removed files */
|
|
117
|
+
archiveRemoved?: boolean;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Template subdirectories (synced from package)
|
|
122
|
+
*/
|
|
123
|
+
export type TemplateSubdir =
|
|
124
|
+
| 'commands'
|
|
125
|
+
| 'agents'
|
|
126
|
+
| 'schemas'
|
|
127
|
+
| 'standards'
|
|
128
|
+
| 'tools'
|
|
129
|
+
| 'automation';
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Excluded subdirectories (user-specific, not synced)
|
|
133
|
+
*/
|
|
134
|
+
export type ExcludedSubdir = 'context' | 'indexes';
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Template source configuration
|
|
138
|
+
*/
|
|
139
|
+
export interface TemplateSource {
|
|
140
|
+
/** Root path to templates (e.g., templates/base/.claude/) */
|
|
141
|
+
rootPath: string;
|
|
142
|
+
/** Subdirectories to sync */
|
|
143
|
+
subdirectories: TemplateSubdir[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Merge result for a single file
|
|
148
|
+
*/
|
|
149
|
+
export interface MergeResult {
|
|
150
|
+
/** File path */
|
|
151
|
+
path: string;
|
|
152
|
+
/** Whether merge was successful */
|
|
153
|
+
success: boolean;
|
|
154
|
+
/** Merge method used */
|
|
155
|
+
method: MergeMethod;
|
|
156
|
+
/** Diff if available */
|
|
157
|
+
diff?: string;
|
|
158
|
+
/** Error message if failed */
|
|
159
|
+
error?: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Merge method used
|
|
164
|
+
*/
|
|
165
|
+
export type MergeMethod =
|
|
166
|
+
| 'auto-safe' // Automatic safe update (no user changes)
|
|
167
|
+
| 'auto-create' // Automatic new file creation
|
|
168
|
+
| 'overwrite' // Forced overwrite (user confirmed or --force)
|
|
169
|
+
| 'skip' // Skipped (user chose to keep local)
|
|
170
|
+
| 'conflict'; // Conflict detected, requires resolution
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Resolution choice for conflicts
|
|
174
|
+
*/
|
|
175
|
+
export type ResolutionChoice = 'skip' | 'overwrite' | 'keep-local' | 'show-diff';
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Resolution result for a single conflict
|
|
179
|
+
*/
|
|
180
|
+
export interface ResolutionResult {
|
|
181
|
+
/** File path */
|
|
182
|
+
path: string;
|
|
183
|
+
/** User's choice */
|
|
184
|
+
choice: ResolutionChoice;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Archive result for removed files
|
|
189
|
+
*/
|
|
190
|
+
export interface ArchiveResult {
|
|
191
|
+
/** Files that were archived */
|
|
192
|
+
archived: string[];
|
|
193
|
+
/** Archive path */
|
|
194
|
+
archivePath: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Template file record from database
|
|
199
|
+
*/
|
|
200
|
+
export interface TemplateFileRecord {
|
|
201
|
+
id: string;
|
|
202
|
+
relativePath: string;
|
|
203
|
+
templateHash: string;
|
|
204
|
+
templateVersion: string;
|
|
205
|
+
userModified: boolean;
|
|
206
|
+
lastSyncedAt?: string;
|
|
207
|
+
syncedAt: string;
|
|
208
|
+
metadata?: Record<string, unknown>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Template manifest record from database
|
|
213
|
+
*/
|
|
214
|
+
export interface TemplateManifestRecord {
|
|
215
|
+
id: string;
|
|
216
|
+
k0ntextVersion: string;
|
|
217
|
+
templateVersion: string;
|
|
218
|
+
manifest: string;
|
|
219
|
+
createdAt: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* All template subdirectories
|
|
224
|
+
*/
|
|
225
|
+
export const TEMPLATE_SUBDIRS: TemplateSubdir[] = [
|
|
226
|
+
'commands',
|
|
227
|
+
'agents',
|
|
228
|
+
'schemas',
|
|
229
|
+
'standards',
|
|
230
|
+
'tools',
|
|
231
|
+
'automation'
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* All excluded subdirectories
|
|
236
|
+
*/
|
|
237
|
+
export const EXCLUDED_SUBDIRS: ExcludedSubdir[] = ['context', 'indexes'];
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Default sync options
|
|
241
|
+
*/
|
|
242
|
+
export const DEFAULT_SYNC_OPTIONS: SyncOptions = {
|
|
243
|
+
dryRun: false,
|
|
244
|
+
force: false,
|
|
245
|
+
verbose: false,
|
|
246
|
+
archiveRemoved: true
|
|
247
|
+
};
|