@generacy-ai/knowledge-store 0.0.0-preview-20260304013206
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/LICENSE +191 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/manager/ContextManager.d.ts +54 -0
- package/dist/manager/ContextManager.d.ts.map +1 -0
- package/dist/manager/ContextManager.js +124 -0
- package/dist/manager/ContextManager.js.map +1 -0
- package/dist/manager/KnowledgeStoreManager.d.ts +128 -0
- package/dist/manager/KnowledgeStoreManager.d.ts.map +1 -0
- package/dist/manager/KnowledgeStoreManager.js +332 -0
- package/dist/manager/KnowledgeStoreManager.js.map +1 -0
- package/dist/manager/PatternManager.d.ts +72 -0
- package/dist/manager/PatternManager.d.ts.map +1 -0
- package/dist/manager/PatternManager.js +187 -0
- package/dist/manager/PatternManager.js.map +1 -0
- package/dist/manager/PhilosophyManager.d.ts +37 -0
- package/dist/manager/PhilosophyManager.d.ts.map +1 -0
- package/dist/manager/PhilosophyManager.js +82 -0
- package/dist/manager/PhilosophyManager.js.map +1 -0
- package/dist/manager/PrincipleManager.d.ts +74 -0
- package/dist/manager/PrincipleManager.d.ts.map +1 -0
- package/dist/manager/PrincipleManager.js +159 -0
- package/dist/manager/PrincipleManager.js.map +1 -0
- package/dist/portability/Exporter.d.ts +14 -0
- package/dist/portability/Exporter.d.ts.map +1 -0
- package/dist/portability/Exporter.js +48 -0
- package/dist/portability/Exporter.js.map +1 -0
- package/dist/portability/Importer.d.ts +18 -0
- package/dist/portability/Importer.d.ts.map +1 -0
- package/dist/portability/Importer.js +192 -0
- package/dist/portability/Importer.js.map +1 -0
- package/dist/portability/redaction.d.ts +22 -0
- package/dist/portability/redaction.d.ts.map +1 -0
- package/dist/portability/redaction.js +128 -0
- package/dist/portability/redaction.js.map +1 -0
- package/dist/storage/AuditableStorage.d.ts +44 -0
- package/dist/storage/AuditableStorage.d.ts.map +1 -0
- package/dist/storage/AuditableStorage.js +109 -0
- package/dist/storage/AuditableStorage.js.map +1 -0
- package/dist/storage/LocalFileStorage.d.ts +63 -0
- package/dist/storage/LocalFileStorage.d.ts.map +1 -0
- package/dist/storage/LocalFileStorage.js +219 -0
- package/dist/storage/LocalFileStorage.js.map +1 -0
- package/dist/storage/StorageProvider.d.ts +28 -0
- package/dist/storage/StorageProvider.d.ts.map +1 -0
- package/dist/storage/StorageProvider.js +38 -0
- package/dist/storage/StorageProvider.js.map +1 -0
- package/dist/storage/VersionedStorage.d.ts +61 -0
- package/dist/storage/VersionedStorage.d.ts.map +1 -0
- package/dist/storage/VersionedStorage.js +102 -0
- package/dist/storage/VersionedStorage.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge.d.ts +149 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +6 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/portability.d.ts +85 -0
- package/dist/types/portability.d.ts.map +1 -0
- package/dist/types/portability.js +6 -0
- package/dist/types/portability.js.map +1 -0
- package/dist/types/storage.d.ts +58 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +6 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/utils/id.d.ts +6 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +9 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/timestamps.d.ts +6 -0
- package/dist/utils/timestamps.d.ts.map +1 -0
- package/dist/utils/timestamps.js +8 -0
- package/dist/utils/timestamps.js.map +1 -0
- package/dist/validation/schemas.d.ts +917 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +143 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validator.d.ts +29 -0
- package/dist/validation/validator.d.ts.map +1 -0
- package/dist/validation/validator.js +54 -0
- package/dist/validation/validator.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PhilosophyManager - Manages philosophy operations with versioning
|
|
3
|
+
*/
|
|
4
|
+
import { validatePhilosophy } from '../validation/validator.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default empty philosophy
|
|
7
|
+
*/
|
|
8
|
+
function createDefaultPhilosophy() {
|
|
9
|
+
return {
|
|
10
|
+
values: [],
|
|
11
|
+
beliefs: [],
|
|
12
|
+
identity: {},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Manages philosophy storage and retrieval with versioning support
|
|
17
|
+
*/
|
|
18
|
+
export class PhilosophyManager {
|
|
19
|
+
storage;
|
|
20
|
+
constructor(storage) {
|
|
21
|
+
this.storage = storage;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the storage key for a user's philosophy
|
|
25
|
+
*/
|
|
26
|
+
getKey(userId) {
|
|
27
|
+
return `${userId}/philosophy`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get a user's philosophy
|
|
31
|
+
*/
|
|
32
|
+
async get(userId) {
|
|
33
|
+
const key = this.getKey(userId);
|
|
34
|
+
const philosophy = await this.storage.get(key);
|
|
35
|
+
return philosophy ?? createDefaultPhilosophy();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Update a user's philosophy (partial update supported)
|
|
39
|
+
*/
|
|
40
|
+
async update(userId, update) {
|
|
41
|
+
const key = this.getKey(userId);
|
|
42
|
+
const current = await this.get(userId);
|
|
43
|
+
const updated = {
|
|
44
|
+
values: update.values ?? current.values,
|
|
45
|
+
beliefs: update.beliefs ?? current.beliefs,
|
|
46
|
+
identity: update.identity
|
|
47
|
+
? { ...current.identity, ...update.identity }
|
|
48
|
+
: current.identity,
|
|
49
|
+
};
|
|
50
|
+
const validation = validatePhilosophy(updated);
|
|
51
|
+
if (!validation.success) {
|
|
52
|
+
throw new Error(`Invalid philosophy: ${validation.errors?.join(', ')}`);
|
|
53
|
+
}
|
|
54
|
+
await this.storage.set(key, updated);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get philosophy history (versions)
|
|
58
|
+
*/
|
|
59
|
+
async getHistory(userId) {
|
|
60
|
+
const key = this.getKey(userId);
|
|
61
|
+
return this.storage.listVersions(key);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a specific version of philosophy
|
|
65
|
+
*/
|
|
66
|
+
async getVersion(userId, version) {
|
|
67
|
+
const key = this.getKey(userId);
|
|
68
|
+
return this.storage.getVersion(key, version);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Revert philosophy to a specific version
|
|
72
|
+
*/
|
|
73
|
+
async revertTo(userId, version) {
|
|
74
|
+
const key = this.getKey(userId);
|
|
75
|
+
const versionData = await this.storage.getVersion(key, version);
|
|
76
|
+
if (!versionData) {
|
|
77
|
+
throw new Error(`Version ${version} not found for user ${userId}`);
|
|
78
|
+
}
|
|
79
|
+
await this.storage.set(key, versionData);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=PhilosophyManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhilosophyManager.js","sourceRoot":"","sources":["../../src/manager/PhilosophyManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,SAAS,uBAAuB;IAC9B,OAAO;QACL,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM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AAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,OAAe;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAa,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,OAAe;QAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAa,GAAG,EAAE,OAAO,CAAC,CAAC;QAE5E,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,uBAAuB,MAAM,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrincipleManager - Manages principle CRUD operations with domain filtering and deprecation
|
|
3
|
+
*/
|
|
4
|
+
import type { Principle, PrincipleStatus } from '../types/knowledge.js';
|
|
5
|
+
import type { StorageProvider, VersionInfo } from '../types/storage.js';
|
|
6
|
+
/**
|
|
7
|
+
* Input for creating a new principle (without id and metadata)
|
|
8
|
+
*/
|
|
9
|
+
export interface CreatePrincipleInput {
|
|
10
|
+
content: string;
|
|
11
|
+
domain: string[];
|
|
12
|
+
weight?: number;
|
|
13
|
+
evidence?: Principle['evidence'];
|
|
14
|
+
status?: PrincipleStatus;
|
|
15
|
+
source?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Input for updating a principle
|
|
19
|
+
*/
|
|
20
|
+
export interface UpdatePrincipleInput {
|
|
21
|
+
content?: string;
|
|
22
|
+
domain?: string[];
|
|
23
|
+
weight?: number;
|
|
24
|
+
evidence?: Principle['evidence'];
|
|
25
|
+
status?: PrincipleStatus;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Manages principles storage and retrieval with filtering and versioning
|
|
29
|
+
*/
|
|
30
|
+
export declare class PrincipleManager {
|
|
31
|
+
private readonly storage;
|
|
32
|
+
constructor(storage: StorageProvider);
|
|
33
|
+
/**
|
|
34
|
+
* Get the storage key for a user's principles
|
|
35
|
+
*/
|
|
36
|
+
private getKey;
|
|
37
|
+
/**
|
|
38
|
+
* Get all principles for a user, optionally filtered by domains
|
|
39
|
+
*/
|
|
40
|
+
get(userId: string, domains?: string[]): Promise<Principle[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get a specific principle by ID
|
|
43
|
+
*/
|
|
44
|
+
getById(userId: string, principleId: string): Promise<Principle | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Add a new principle
|
|
47
|
+
*/
|
|
48
|
+
add(userId: string, input: CreatePrincipleInput): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Update an existing principle
|
|
51
|
+
*/
|
|
52
|
+
update(userId: string, principleId: string, update: UpdatePrincipleInput): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Deprecate a principle
|
|
55
|
+
*/
|
|
56
|
+
deprecate(userId: string, principleId: string, reason: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a principle (hard delete)
|
|
59
|
+
*/
|
|
60
|
+
delete(userId: string, principleId: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get principles by status
|
|
63
|
+
*/
|
|
64
|
+
getByStatus(userId: string, status: PrincipleStatus): Promise<Principle[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get principles history (versions)
|
|
67
|
+
*/
|
|
68
|
+
getHistory(userId: string): Promise<VersionInfo[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get a specific version of principles
|
|
71
|
+
*/
|
|
72
|
+
getVersion(userId: string, version: number): Promise<Principle[] | null>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=PrincipleManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrincipleManager.d.ts","sourceRoot":"","sources":["../../src/manager/PrincipleManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKxE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;gBAE9B,OAAO,EAAE,eAAe;IAIpC;;OAEG;IACH,OAAO,CAAC,MAAM;IAId;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAkBnE;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAK7E;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BvE;;OAEG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAgChB;;OAEG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IA0BhB;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhE;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKhF;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAKxD;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC;CAI/E"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrincipleManager - Manages principle CRUD operations with domain filtering and deprecation
|
|
3
|
+
*/
|
|
4
|
+
import { validatePrinciple } from '../validation/validator.js';
|
|
5
|
+
import { generateId } from '../utils/id.js';
|
|
6
|
+
import { now } from '../utils/timestamps.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manages principles storage and retrieval with filtering and versioning
|
|
9
|
+
*/
|
|
10
|
+
export class PrincipleManager {
|
|
11
|
+
storage;
|
|
12
|
+
constructor(storage) {
|
|
13
|
+
this.storage = storage;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the storage key for a user's principles
|
|
17
|
+
*/
|
|
18
|
+
getKey(userId) {
|
|
19
|
+
return `${userId}/principles`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get all principles for a user, optionally filtered by domains
|
|
23
|
+
*/
|
|
24
|
+
async get(userId, domains) {
|
|
25
|
+
const key = this.getKey(userId);
|
|
26
|
+
const principles = await this.storage.get(key);
|
|
27
|
+
if (!principles) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
if (!domains || domains.length === 0) {
|
|
31
|
+
return principles;
|
|
32
|
+
}
|
|
33
|
+
// Filter by domains - principle must have at least one matching domain
|
|
34
|
+
return principles.filter((p) => p.domain.some((d) => domains.includes(d)));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a specific principle by ID
|
|
38
|
+
*/
|
|
39
|
+
async getById(userId, principleId) {
|
|
40
|
+
const principles = await this.get(userId);
|
|
41
|
+
return principles.find((p) => p.id === principleId) ?? null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Add a new principle
|
|
45
|
+
*/
|
|
46
|
+
async add(userId, input) {
|
|
47
|
+
const key = this.getKey(userId);
|
|
48
|
+
const principles = await this.get(userId);
|
|
49
|
+
const timestamp = now();
|
|
50
|
+
const principle = {
|
|
51
|
+
id: generateId(),
|
|
52
|
+
content: input.content,
|
|
53
|
+
domain: input.domain,
|
|
54
|
+
weight: input.weight ?? 0.5,
|
|
55
|
+
evidence: input.evidence ?? [],
|
|
56
|
+
status: input.status ?? 'draft',
|
|
57
|
+
metadata: {
|
|
58
|
+
createdAt: timestamp,
|
|
59
|
+
updatedAt: timestamp,
|
|
60
|
+
source: input.source,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const validation = validatePrinciple(principle);
|
|
64
|
+
if (!validation.success) {
|
|
65
|
+
throw new Error(`Invalid principle: ${validation.errors?.join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
principles.push(principle);
|
|
68
|
+
await this.storage.set(key, principles);
|
|
69
|
+
return principle.id;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Update an existing principle
|
|
73
|
+
*/
|
|
74
|
+
async update(userId, principleId, update) {
|
|
75
|
+
const key = this.getKey(userId);
|
|
76
|
+
const principles = await this.get(userId);
|
|
77
|
+
const index = principles.findIndex((p) => p.id === principleId);
|
|
78
|
+
if (index === -1) {
|
|
79
|
+
throw new Error(`Principle not found: ${principleId}`);
|
|
80
|
+
}
|
|
81
|
+
const current = principles[index];
|
|
82
|
+
const updated = {
|
|
83
|
+
...current,
|
|
84
|
+
content: update.content ?? current.content,
|
|
85
|
+
domain: update.domain ?? current.domain,
|
|
86
|
+
weight: update.weight ?? current.weight,
|
|
87
|
+
evidence: update.evidence ?? current.evidence,
|
|
88
|
+
status: update.status ?? current.status,
|
|
89
|
+
metadata: {
|
|
90
|
+
...current.metadata,
|
|
91
|
+
updatedAt: now(),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const validation = validatePrinciple(updated);
|
|
95
|
+
if (!validation.success) {
|
|
96
|
+
throw new Error(`Invalid principle: ${validation.errors?.join(', ')}`);
|
|
97
|
+
}
|
|
98
|
+
principles[index] = updated;
|
|
99
|
+
await this.storage.set(key, principles);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Deprecate a principle
|
|
103
|
+
*/
|
|
104
|
+
async deprecate(userId, principleId, reason) {
|
|
105
|
+
const key = this.getKey(userId);
|
|
106
|
+
const principles = await this.get(userId);
|
|
107
|
+
const index = principles.findIndex((p) => p.id === principleId);
|
|
108
|
+
if (index === -1) {
|
|
109
|
+
throw new Error(`Principle not found: ${principleId}`);
|
|
110
|
+
}
|
|
111
|
+
const current = principles[index];
|
|
112
|
+
const timestamp = now();
|
|
113
|
+
principles[index] = {
|
|
114
|
+
...current,
|
|
115
|
+
status: 'deprecated',
|
|
116
|
+
metadata: {
|
|
117
|
+
...current.metadata,
|
|
118
|
+
updatedAt: timestamp,
|
|
119
|
+
deprecatedAt: timestamp,
|
|
120
|
+
deprecationReason: reason,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
await this.storage.set(key, principles);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Delete a principle (hard delete)
|
|
127
|
+
*/
|
|
128
|
+
async delete(userId, principleId) {
|
|
129
|
+
const key = this.getKey(userId);
|
|
130
|
+
const principles = await this.get(userId);
|
|
131
|
+
const filtered = principles.filter((p) => p.id !== principleId);
|
|
132
|
+
if (filtered.length === principles.length) {
|
|
133
|
+
throw new Error(`Principle not found: ${principleId}`);
|
|
134
|
+
}
|
|
135
|
+
await this.storage.set(key, filtered);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get principles by status
|
|
139
|
+
*/
|
|
140
|
+
async getByStatus(userId, status) {
|
|
141
|
+
const principles = await this.get(userId);
|
|
142
|
+
return principles.filter((p) => p.status === status);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get principles history (versions)
|
|
146
|
+
*/
|
|
147
|
+
async getHistory(userId) {
|
|
148
|
+
const key = this.getKey(userId);
|
|
149
|
+
return this.storage.listVersions(key);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get a specific version of principles
|
|
153
|
+
*/
|
|
154
|
+
async getVersion(userId, version) {
|
|
155
|
+
const key = this.getKey(userId);
|
|
156
|
+
return this.storage.getVersion(key, version);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=PrincipleManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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CAAC,MAAM,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,MAAuB;QACvD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,OAAe;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAc,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exporter - Export knowledge at different portability levels
|
|
3
|
+
*/
|
|
4
|
+
import type { Philosophy, Principle, Pattern, UserContext } from '../types/knowledge.js';
|
|
5
|
+
import type { ExportedKnowledge, PortabilityLevel } from '../types/portability.js';
|
|
6
|
+
/**
|
|
7
|
+
* Export knowledge at the specified portability level
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportKnowledge(philosophy: Philosophy, principles: Principle[], patterns: Pattern[], context: UserContext, level: PortabilityLevel): ExportedKnowledge;
|
|
10
|
+
/**
|
|
11
|
+
* Verify export checksum
|
|
12
|
+
*/
|
|
13
|
+
export declare function verifyChecksum(data: ExportedKnowledge): boolean;
|
|
14
|
+
//# sourceMappingURL=Exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exporter.d.ts","sourceRoot":"","sources":["../../src/portability/Exporter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAsBjC;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,gBAAgB,GACtB,iBAAiB,CAoBnB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAI/D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exporter - Export knowledge at different portability levels
|
|
3
|
+
*/
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { transformPhilosophy, transformPrinciples, transformPatterns, transformContext, } from './redaction.js';
|
|
6
|
+
import { now } from '../utils/timestamps.js';
|
|
7
|
+
/**
|
|
8
|
+
* Current export format version
|
|
9
|
+
*/
|
|
10
|
+
const EXPORT_VERSION = '1.0.0';
|
|
11
|
+
/**
|
|
12
|
+
* Generate checksum for exported data
|
|
13
|
+
*/
|
|
14
|
+
function generateChecksum(data) {
|
|
15
|
+
const content = JSON.stringify(data);
|
|
16
|
+
return createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Export knowledge at the specified portability level
|
|
20
|
+
*/
|
|
21
|
+
export function exportKnowledge(philosophy, principles, patterns, context, level) {
|
|
22
|
+
const transformedPhilosophy = transformPhilosophy(philosophy, level);
|
|
23
|
+
const transformedPrinciples = transformPrinciples(principles, level);
|
|
24
|
+
const transformedPatterns = transformPatterns(patterns, level);
|
|
25
|
+
const transformedContext = transformContext(context, level);
|
|
26
|
+
const exportData = {
|
|
27
|
+
version: EXPORT_VERSION,
|
|
28
|
+
level,
|
|
29
|
+
exportedAt: now(),
|
|
30
|
+
philosophy: transformedPhilosophy,
|
|
31
|
+
principles: transformedPrinciples,
|
|
32
|
+
patterns: transformedPatterns,
|
|
33
|
+
context: transformedContext,
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
...exportData,
|
|
37
|
+
checksum: generateChecksum(exportData),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Verify export checksum
|
|
42
|
+
*/
|
|
43
|
+
export function verifyChecksum(data) {
|
|
44
|
+
const { checksum, ...rest } = data;
|
|
45
|
+
const computed = generateChecksum(rest);
|
|
46
|
+
return computed === checksum;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exporter.js","sourceRoot":"","sources":["../../src/portability/Exporter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C;;GAEG;AACH,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAyC;IACjE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,UAAuB,EACvB,QAAmB,EACnB,OAAoB,EACpB,KAAuB;IAEvB,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrE,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrE,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/D,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAE5D,MAAM,UAAU,GAAwC;QACtD,OAAO,EAAE,cAAc;QACvB,KAAK;QACL,UAAU,EAAE,GAAG,EAAE;QACjB,UAAU,EAAE,qBAAqB;QACjC,UAAU,EAAE,qBAAqB;QACjC,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE,kBAAkB;KAC5B,CAAC;IAEF,OAAO;QACL,GAAG,UAAU;QACb,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC;KACvC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAuB;IACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,QAAQ,KAAK,QAAQ,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Importer - Import knowledge with merge strategy and conflict detection
|
|
3
|
+
*/
|
|
4
|
+
import type { Principle, Pattern, Philosophy } from '../types/knowledge.js';
|
|
5
|
+
import type { ExportedKnowledge, ImportResult } from '../types/portability.js';
|
|
6
|
+
/**
|
|
7
|
+
* Import knowledge with merge strategy
|
|
8
|
+
*/
|
|
9
|
+
export declare function importKnowledge(existingPrinciples: Principle[], existingPatterns: Pattern[], existingPhilosophy: Philosophy, data: ExportedKnowledge): ImportResult;
|
|
10
|
+
/**
|
|
11
|
+
* Apply import result to existing data
|
|
12
|
+
* Returns the new principles and patterns to add
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyImport(data: ExportedKnowledge, result: ImportResult): {
|
|
15
|
+
principles: Principle[];
|
|
16
|
+
patterns: Pattern[];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=Importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Importer.d.ts","sourceRoot":"","sources":["../../src/portability/Importer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EACV,iBAAiB,EAEjB,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAwEjC;;GAEG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,EAAE,SAAS,EAAE,EAC/B,gBAAgB,EAAE,OAAO,EAAE,EAC3B,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,iBAAiB,GACtB,YAAY,CAsHd;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,YAAY,GACnB;IAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CA0BlD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Importer - Import knowledge with merge strategy and conflict detection
|
|
3
|
+
*/
|
|
4
|
+
import { verifyChecksum } from './Exporter.js';
|
|
5
|
+
import { generateId } from '../utils/id.js';
|
|
6
|
+
import { now } from '../utils/timestamps.js';
|
|
7
|
+
/**
|
|
8
|
+
* High weight threshold for principles that need user review
|
|
9
|
+
*/
|
|
10
|
+
const HIGH_WEIGHT_THRESHOLD = 0.8;
|
|
11
|
+
/**
|
|
12
|
+
* Check if two principles are similar (potential conflict)
|
|
13
|
+
*/
|
|
14
|
+
function arePrinciplesSimilar(a, b) {
|
|
15
|
+
// Same ID is always a conflict
|
|
16
|
+
if (a.id === b.id)
|
|
17
|
+
return true;
|
|
18
|
+
// Similar content is a potential conflict
|
|
19
|
+
const aWords = new Set(a.content.toLowerCase().split(/\s+/));
|
|
20
|
+
const bWords = new Set(b.content.toLowerCase().split(/\s+/));
|
|
21
|
+
const intersection = new Set([...aWords].filter((w) => bWords.has(w)));
|
|
22
|
+
const similarity = intersection.size / Math.max(aWords.size, bWords.size);
|
|
23
|
+
return similarity > 0.7;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Determine if a conflict can be auto-resolved
|
|
27
|
+
*/
|
|
28
|
+
function canAutoResolve(_existing, incoming) {
|
|
29
|
+
// High-weight principles need user review
|
|
30
|
+
if ('weight' in incoming && incoming.weight >= HIGH_WEIGHT_THRESHOLD) {
|
|
31
|
+
return { auto: false, reason: 'High-weight principle requires review' };
|
|
32
|
+
}
|
|
33
|
+
// Philosophy changes always need review
|
|
34
|
+
if ('values' in incoming) {
|
|
35
|
+
return { auto: false, reason: 'Philosophy changes require review' };
|
|
36
|
+
}
|
|
37
|
+
// Low-weight principles can be auto-merged
|
|
38
|
+
if ('weight' in incoming && incoming.weight < 0.5) {
|
|
39
|
+
return { auto: true, reason: 'Low-weight principle auto-merged' };
|
|
40
|
+
}
|
|
41
|
+
// Default to auto-resolve for simple cases
|
|
42
|
+
return { auto: true, reason: 'Auto-merged based on default rules' };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert exported principle to full principle
|
|
46
|
+
*/
|
|
47
|
+
function toFullPrinciple(exported) {
|
|
48
|
+
const timestamp = now();
|
|
49
|
+
return {
|
|
50
|
+
id: exported.id || generateId(),
|
|
51
|
+
content: exported.content,
|
|
52
|
+
domain: exported.domain,
|
|
53
|
+
weight: exported.weight,
|
|
54
|
+
evidence: exported.evidence ?? [],
|
|
55
|
+
status: 'draft',
|
|
56
|
+
metadata: {
|
|
57
|
+
createdAt: timestamp,
|
|
58
|
+
updatedAt: timestamp,
|
|
59
|
+
source: 'imported',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Import knowledge with merge strategy
|
|
65
|
+
*/
|
|
66
|
+
export function importKnowledge(existingPrinciples, existingPatterns, existingPhilosophy, data) {
|
|
67
|
+
const result = {
|
|
68
|
+
success: true,
|
|
69
|
+
imported: {
|
|
70
|
+
principles: 0,
|
|
71
|
+
patterns: 0,
|
|
72
|
+
philosophy: false,
|
|
73
|
+
},
|
|
74
|
+
merged: {
|
|
75
|
+
principles: 0,
|
|
76
|
+
},
|
|
77
|
+
conflicts: [],
|
|
78
|
+
errors: [],
|
|
79
|
+
};
|
|
80
|
+
// Verify checksum
|
|
81
|
+
if (!verifyChecksum(data)) {
|
|
82
|
+
result.success = false;
|
|
83
|
+
result.errors.push('Checksum verification failed');
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// Import principles
|
|
87
|
+
if (data.principles) {
|
|
88
|
+
const existingIds = new Set(existingPrinciples.map((p) => p.id));
|
|
89
|
+
for (const incoming of data.principles) {
|
|
90
|
+
// Check for ID collision
|
|
91
|
+
if (existingIds.has(incoming.id)) {
|
|
92
|
+
const existing = existingPrinciples.find((p) => p.id === incoming.id);
|
|
93
|
+
if (existing) {
|
|
94
|
+
const resolution = canAutoResolve(existing, incoming);
|
|
95
|
+
const conflict = {
|
|
96
|
+
type: 'principle',
|
|
97
|
+
existing,
|
|
98
|
+
incoming,
|
|
99
|
+
resolution: resolution.auto ? 'auto' : 'pending',
|
|
100
|
+
autoResolved: resolution.auto,
|
|
101
|
+
reason: resolution.reason,
|
|
102
|
+
};
|
|
103
|
+
result.conflicts.push(conflict);
|
|
104
|
+
if (resolution.auto) {
|
|
105
|
+
result.merged.principles++;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Check for similar content
|
|
111
|
+
const similar = existingPrinciples.find((p) => arePrinciplesSimilar(p, incoming));
|
|
112
|
+
if (similar) {
|
|
113
|
+
const resolution = canAutoResolve(similar, incoming);
|
|
114
|
+
const conflict = {
|
|
115
|
+
type: 'principle',
|
|
116
|
+
existing: similar,
|
|
117
|
+
incoming,
|
|
118
|
+
resolution: resolution.auto ? 'auto' : 'pending',
|
|
119
|
+
autoResolved: resolution.auto,
|
|
120
|
+
reason: resolution.reason,
|
|
121
|
+
};
|
|
122
|
+
result.conflicts.push(conflict);
|
|
123
|
+
if (resolution.auto) {
|
|
124
|
+
result.merged.principles++;
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
// New principle - add it
|
|
129
|
+
result.imported.principles++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Import patterns
|
|
133
|
+
if (data.patterns) {
|
|
134
|
+
const existingPatternIds = new Set(existingPatterns.map((p) => p.id));
|
|
135
|
+
for (const incoming of data.patterns) {
|
|
136
|
+
if (!existingPatternIds.has(incoming.id)) {
|
|
137
|
+
result.imported.patterns++;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Import philosophy
|
|
142
|
+
if (data.philosophy) {
|
|
143
|
+
const hasExistingPhilosophy = existingPhilosophy.values.length > 0 ||
|
|
144
|
+
existingPhilosophy.beliefs.length > 0;
|
|
145
|
+
if (hasExistingPhilosophy) {
|
|
146
|
+
const conflict = {
|
|
147
|
+
type: 'philosophy',
|
|
148
|
+
existing: existingPhilosophy,
|
|
149
|
+
incoming: data.philosophy,
|
|
150
|
+
resolution: 'pending',
|
|
151
|
+
autoResolved: false,
|
|
152
|
+
reason: 'Existing philosophy requires manual merge decision',
|
|
153
|
+
};
|
|
154
|
+
result.conflicts.push(conflict);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
result.imported.philosophy = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Mark as failed if there are unresolved conflicts
|
|
161
|
+
const unresolvedConflicts = result.conflicts.filter((c) => c.resolution === 'pending');
|
|
162
|
+
if (unresolvedConflicts.length > 0) {
|
|
163
|
+
result.success = false;
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Apply import result to existing data
|
|
169
|
+
* Returns the new principles and patterns to add
|
|
170
|
+
*/
|
|
171
|
+
export function applyImport(data, result) {
|
|
172
|
+
const newPrinciples = [];
|
|
173
|
+
const newPatterns = [];
|
|
174
|
+
if (data.principles && result.imported.principles > 0) {
|
|
175
|
+
// Add principles that weren't conflicts
|
|
176
|
+
const conflictIds = new Set(result.conflicts
|
|
177
|
+
.filter((c) => c.type === 'principle')
|
|
178
|
+
.map((c) => c.incoming.id));
|
|
179
|
+
for (const p of data.principles) {
|
|
180
|
+
if (!conflictIds.has(p.id)) {
|
|
181
|
+
newPrinciples.push(toFullPrinciple(p));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (data.patterns && result.imported.patterns > 0) {
|
|
186
|
+
for (const p of data.patterns) {
|
|
187
|
+
newPatterns.push(p);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { principles: newPrinciples, patterns: newPatterns };
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=Importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Importer.js","sourceRoot":"","sources":["../../src/portability/Importer.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CA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AAC,CACpD,CAAC;QAEF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC3B,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QAClD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction transforms for different portability levels
|
|
3
|
+
*/
|
|
4
|
+
import type { Philosophy, Principle, Pattern, UserContext } from '../types/knowledge.js';
|
|
5
|
+
import type { ExportedPrinciple, PortabilityLevel } from '../types/portability.js';
|
|
6
|
+
/**
|
|
7
|
+
* Transform philosophy for export
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformPhilosophy(philosophy: Philosophy, level: PortabilityLevel): Philosophy | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Transform principles for export
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformPrinciples(principles: Principle[], level: PortabilityLevel): ExportedPrinciple[];
|
|
14
|
+
/**
|
|
15
|
+
* Transform patterns for export
|
|
16
|
+
*/
|
|
17
|
+
export declare function transformPatterns(patterns: Pattern[], level: PortabilityLevel): Pattern[] | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Transform context for export
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformContext(context: UserContext, level: PortabilityLevel): UserContext | undefined;
|
|
22
|
+
//# sourceMappingURL=redaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../src/portability/redaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA2BnF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,gBAAgB,GACtB,UAAU,GAAG,SAAS,CA2BxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,SAAS,EAAE,EACvB,KAAK,EAAE,gBAAgB,GACtB,iBAAiB,EAAE,CAkCrB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,gBAAgB,GACtB,OAAO,EAAE,GAAG,SAAS,CA8BvB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,gBAAgB,GACtB,WAAW,GAAG,SAAS,CAOzB"}
|