fluffy-context 0.2.0 → 0.3.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.
@@ -0,0 +1,294 @@
1
+ export type ContextStatus = 'draft' | 'active' | 'stable' | 'archived' | 'deleted';
2
+ export type SnapshotMode = 'baseline' | 'patch';
3
+ export interface GitState {
4
+ root: string | null;
5
+ branch: string | null;
6
+ commit: string | null;
7
+ }
8
+ export interface ContextMetadata {
9
+ id: string;
10
+ schemaVersion: 1;
11
+ title: string;
12
+ projectRoot: string;
13
+ branch: string | null;
14
+ commit: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ lastUsedAt: string | null;
18
+ usageCount: number;
19
+ status: ContextStatus;
20
+ currentSnapshotId: string | null;
21
+ tags: string[];
22
+ dependencies: string[];
23
+ }
24
+ export interface StructuredContext {
25
+ progressSummary: string;
26
+ lastError: string | null;
27
+ completed: string[];
28
+ pendingTasks: string[];
29
+ decisions: string[];
30
+ risks: string[];
31
+ relatedFiles: string[];
32
+ }
33
+ export type ContextPatch = Partial<StructuredContext>;
34
+ export interface Snapshot {
35
+ snapshotId: string;
36
+ schemaVersion: 1;
37
+ contextId: string;
38
+ parentSnapshotId: string | null;
39
+ baseSnapshotId: string;
40
+ mode: SnapshotMode;
41
+ createdAt: string;
42
+ branch: string | null;
43
+ commit: string | null;
44
+ contentHash: string;
45
+ rebuildHash: string;
46
+ content?: StructuredContext;
47
+ patch?: ContextPatch;
48
+ }
49
+ export interface Manifest {
50
+ schemaVersion: 1;
51
+ layoutVersion: 'compact-json-v1';
52
+ projectId: string;
53
+ projectRoot: string;
54
+ initializedAt: string;
55
+ }
56
+ export interface IndexEntry {
57
+ contextId: string;
58
+ title: string;
59
+ status: ContextStatus;
60
+ branch: string | null;
61
+ commit: string | null;
62
+ currentSnapshotId: string | null;
63
+ updatedAt: string;
64
+ }
65
+ export interface IndexFile {
66
+ schemaVersion: 1;
67
+ rebuiltAt: string;
68
+ contexts: IndexEntry[];
69
+ }
70
+ export interface CheckpointInput {
71
+ contextId?: string;
72
+ absorbNotes?: boolean;
73
+ title?: string;
74
+ progressSummary?: string;
75
+ lastError?: string | null;
76
+ completed?: string[];
77
+ pendingTasks?: string[];
78
+ decisions?: string[];
79
+ risks?: string[];
80
+ relatedFiles?: string[];
81
+ }
82
+ export type NoteKind = 'problem' | 'action' | 'observation' | 'decision';
83
+ export type NoteStatus = 'open' | 'resolved';
84
+ export type NoteActor = 'agent' | 'human';
85
+ export interface Note {
86
+ noteId: string;
87
+ schemaVersion: 1;
88
+ kind: NoteKind;
89
+ message: string;
90
+ actor: NoteActor;
91
+ contextId: string | null;
92
+ snapshotId: string | null;
93
+ relatedFiles: string[];
94
+ status: NoteStatus;
95
+ absorbedBySnapshotId: string | null;
96
+ createdAt: string;
97
+ updatedAt: string;
98
+ }
99
+ export interface NoteInput {
100
+ kind?: NoteKind;
101
+ actor?: NoteActor;
102
+ contextId?: string;
103
+ snapshotId?: string;
104
+ relatedFiles?: string[];
105
+ status?: NoteStatus;
106
+ }
107
+ export interface NoteFile {
108
+ schemaVersion: 1;
109
+ items: Note[];
110
+ }
111
+ export interface NoteQuery {
112
+ contextId?: string;
113
+ openOnly?: boolean;
114
+ limit?: number;
115
+ maxChars?: number;
116
+ }
117
+ export interface ActivityItem {
118
+ type: 'note' | 'checkpoint';
119
+ occurredAt: string;
120
+ contextId: string;
121
+ snapshotId?: string;
122
+ noteId?: string;
123
+ kind?: NoteKind;
124
+ message?: string;
125
+ actor?: NoteActor;
126
+ status?: NoteStatus;
127
+ absorbedBySnapshotId?: string | null;
128
+ title?: string;
129
+ }
130
+ export interface ActivityQuery extends NoteQuery {
131
+ since?: string;
132
+ }
133
+ export interface ActivityResult {
134
+ projectRoot: string;
135
+ items: ActivityItem[];
136
+ }
137
+ export type KnowledgeStatus = 'candidate' | 'verified' | 'deprecated' | 'rejected';
138
+ export type DeadendStatus = 'candidate' | 'verified' | 'obsolete' | 'rejected';
139
+ export interface Knowledge {
140
+ knowledgeId: string;
141
+ kind: string;
142
+ statement: string;
143
+ scope: string;
144
+ confidence: number;
145
+ status: KnowledgeStatus;
146
+ sourceContextIds: string[];
147
+ sourceSnapshotIds: string[];
148
+ supportingEvidence: string[];
149
+ createdAt: string;
150
+ updatedAt: string;
151
+ }
152
+ export interface KnowledgeInput {
153
+ kind?: string;
154
+ scope?: string;
155
+ sourceContextId?: string;
156
+ sourceSnapshotId?: string;
157
+ evidence?: string[];
158
+ }
159
+ export interface KnowledgeDiscoverOptions {
160
+ scope?: string;
161
+ statuses?: KnowledgeStatus[];
162
+ limit?: number;
163
+ maxChars?: number;
164
+ }
165
+ export interface KnowledgeDiscoveryHit {
166
+ knowledge: Knowledge;
167
+ score: number;
168
+ matchedTerms: string[];
169
+ matchedFields: string[];
170
+ why: string[];
171
+ }
172
+ export interface KnowledgeConflictGroup {
173
+ scope: string;
174
+ knowledgeIds: string[];
175
+ statements: string[];
176
+ }
177
+ export interface KnowledgeDiscoveryResult {
178
+ query: string;
179
+ total: number;
180
+ truncated: boolean;
181
+ hits: KnowledgeDiscoveryHit[];
182
+ duplicateIds: string[][];
183
+ possibleConflicts: KnowledgeConflictGroup[];
184
+ }
185
+ export interface DeadendDiscoverOptions {
186
+ scope?: string;
187
+ statuses?: DeadendStatus[];
188
+ limit?: number;
189
+ maxChars?: number;
190
+ }
191
+ export interface DeadendDiscoveryHit {
192
+ deadend: Deadend;
193
+ score: number;
194
+ matchedTerms: string[];
195
+ matchedFields: string[];
196
+ }
197
+ export interface DeadendDiscoveryResult {
198
+ query: string;
199
+ total: number;
200
+ truncated: boolean;
201
+ hits: DeadendDiscoveryHit[];
202
+ }
203
+ export interface DeadendInput {
204
+ scope?: string;
205
+ sourceContextId?: string;
206
+ sourceSnapshotId?: string;
207
+ evidence?: string[];
208
+ }
209
+ export interface Deadend {
210
+ deadendId: string;
211
+ attempt: string;
212
+ reason: string;
213
+ observedEvidence: string[];
214
+ scope: string;
215
+ status: DeadendStatus;
216
+ sourceContextId: string | null;
217
+ sourceSnapshotId: string | null;
218
+ createdAt: string;
219
+ updatedAt: string;
220
+ }
221
+ export interface KnowledgeFile {
222
+ schemaVersion: 1;
223
+ items: Knowledge[];
224
+ }
225
+ export interface DeadendFile {
226
+ schemaVersion: 1;
227
+ items: Deadend[];
228
+ }
229
+ export interface ResumeSummary extends StructuredContext {
230
+ branchOrCommitDrift: boolean;
231
+ }
232
+ export interface ResumeResult {
233
+ context: ContextMetadata;
234
+ snapshot: Snapshot;
235
+ resumeSummary: ResumeSummary;
236
+ details: StructuredContext;
237
+ }
238
+ export interface AgentLoadOptions {
239
+ contextId?: string;
240
+ maxChars?: number;
241
+ includeDetails?: boolean;
242
+ query?: string;
243
+ scope?: string;
244
+ }
245
+ export interface AgentLoadResult {
246
+ projectRoot: string;
247
+ context: ContextMetadata;
248
+ snapshot: Snapshot;
249
+ resumeSummary: ResumeSummary;
250
+ details?: StructuredContext;
251
+ knowledge: KnowledgeDiscoveryResult | null;
252
+ verifiedDeadendIds: string[];
253
+ }
254
+ export interface AgentSaveResult {
255
+ projectRoot: string;
256
+ result: CheckpointResult;
257
+ }
258
+ export interface ContextSearchOptions {
259
+ contextId?: string;
260
+ scope?: string;
261
+ limit?: number;
262
+ maxChars?: number;
263
+ }
264
+ export interface ContextSearchHit {
265
+ context: ContextMetadata;
266
+ snapshotId: string;
267
+ score: number;
268
+ matchedTerms: string[];
269
+ matchedFields: string[];
270
+ summary: ResumeSummary;
271
+ }
272
+ export interface ContextSearchResult {
273
+ projectRoot: string;
274
+ query: string;
275
+ total: number;
276
+ truncated: boolean;
277
+ hits: ContextSearchHit[];
278
+ knowledge: KnowledgeDiscoveryResult;
279
+ verifiedDeadendIds: string[];
280
+ }
281
+ export type CheckpointResult = {
282
+ status: 'saved';
283
+ context: ContextMetadata;
284
+ snapshot: Snapshot;
285
+ } | {
286
+ status: 'no_change';
287
+ context: ContextMetadata;
288
+ snapshot: Snapshot;
289
+ } | {
290
+ status: 'rate_limited';
291
+ context: ContextMetadata;
292
+ snapshot: Snapshot;
293
+ retryAt: string;
294
+ };
@@ -0,0 +1 @@
1
+ export declare function atomicWriteJson(filePath: string, value: unknown): Promise<void>;
@@ -0,0 +1,6 @@
1
+ export declare class JsonStoreError extends Error {
2
+ readonly filePath: string;
3
+ constructor(filePath: string, message: string);
4
+ }
5
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
6
+ export declare function readJson<T>(filePath: string, validate?: (value: unknown) => value is T): Promise<T>;
@@ -0,0 +1,13 @@
1
+ export declare function contextRoot(projectRoot: string): string;
2
+ export declare function manifestPath(projectRoot: string): string;
3
+ export declare function indexPath(projectRoot: string): string;
4
+ export declare function ignoredPath(projectRoot: string): string;
5
+ export declare function contextsRoot(projectRoot: string): string;
6
+ export declare function contextDirectory(projectRoot: string, contextId: string): string;
7
+ export declare function contextMetadataPath(projectRoot: string, contextId: string): string;
8
+ export declare function snapshotsDirectory(projectRoot: string, contextId: string): string;
9
+ export declare function snapshotPath(projectRoot: string, contextId: string, snapshotId: string): string;
10
+ export declare function locksDirectory(projectRoot: string): string;
11
+ export declare function knowledgePath(projectRoot: string): string;
12
+ export declare function deadendsPath(projectRoot: string): string;
13
+ export declare function notesPath(projectRoot: string): string;
@@ -0,0 +1 @@
1
+ export declare function withLock<T>(lockPath: string, operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.3.0";
@@ -1 +1 @@
1
- export const VERSION = '0.2.0';
1
+ export const VERSION = '0.3.0';
package/package.json CHANGED
@@ -1,41 +1,73 @@
1
1
  {
2
2
  "name": "fluffy-context",
3
- "version": "0.2.0",
4
- "description": "面向 AI 编程会话的本地上下文运行时 CLI",
3
+ "version": "0.3.0",
4
+ "description": "Local context management CLI and MCP tools for AI coding agents",
5
+ "license": "MIT",
6
+ "author": "FluffyChi-Xing",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/FluffyChi-Xing/fluffy-context.git"
10
+ },
11
+ "homepage": "https://github.com/FluffyChi-Xing/fluffy-context#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/FluffyChi-Xing/fluffy-context/issues"
14
+ },
5
15
  "type": "module",
6
16
  "keywords": [
7
- "context-runtime",
8
17
  "ai-agent",
9
- "coding-agent",
10
- "developer-tools",
18
+ "agent-context",
19
+ "claude-code",
11
20
  "cli",
12
21
  "context-management",
13
- "session-resume",
14
- "knowledge-base",
15
- "deadend-tracking",
16
- "snapshot"
22
+ "context-runtime",
23
+ "developer-tools",
24
+ "mcp",
25
+ "model-context-protocol",
26
+ "session-resume"
17
27
  ],
18
28
  "bin": {
19
29
  "ctx": "dist/src/cli/main.js"
20
30
  },
31
+ "types": "./dist/src/agent/index.d.ts",
21
32
  "exports": {
22
- ".": "./dist/src/agent/index.js",
23
- "./agent": "./dist/src/agent/index.js",
24
- "./version": "./dist/src/version.js"
33
+ ".": {
34
+ "types": "./dist/src/agent/index.d.ts",
35
+ "default": "./dist/src/agent/index.js"
36
+ },
37
+ "./agent": {
38
+ "types": "./dist/src/agent/index.d.ts",
39
+ "default": "./dist/src/agent/index.js"
40
+ },
41
+ "./version": {
42
+ "types": "./dist/src/version.d.ts",
43
+ "default": "./dist/src/version.js"
44
+ }
25
45
  },
26
46
  "files": [
27
- "dist/src"
47
+ "dist/src",
48
+ "README.md",
49
+ "LICENSE",
50
+ "skills/fluffy-context/SKILL.md"
28
51
  ],
29
52
  "engines": {
30
53
  "node": ">=20.19.0"
31
54
  },
32
55
  "scripts": {
33
56
  "build": "tsc -p tsconfig.json",
34
- "test": "npm run build && node --test dist/test/*.test.js",
57
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
58
+ "test": "tsc -p tsconfig.test.json && node --test dist/test/*.test.js",
59
+ "pack:check": "tsc -p tsconfig.test.json && node --test dist/test/package-smoke.test.js",
60
+ "prepack": "npm run build",
61
+ "prepublishOnly": "npm test && npm run pack:check",
35
62
  "ctx": "npm run build && node dist/src/cli/main.js"
36
63
  },
37
64
  "devDependencies": {
65
+ "@modelcontextprotocol/client": "^2.0.0",
38
66
  "@types/node": "^22.10.0",
39
67
  "typescript": "^5.7.2"
68
+ },
69
+ "dependencies": {
70
+ "@modelcontextprotocol/server": "^2.0.0",
71
+ "zod": "^4.4.3"
40
72
  }
41
73
  }