@hasna/knowledge 0.2.25 → 0.2.27
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 +35 -0
- package/bin/open-knowledge-mcp.js +71 -3
- package/bin/open-knowledge.js +86 -86
- package/docs/architecture/ai-native-knowledge-base.md +24 -0
- package/docs/architecture/hosted-wrapper-responsibilities.md +8 -0
- package/docs/canonical-secrets-bootstrap-2026-06-08.md +127 -0
- package/docs/examples/company-wiki-workflow.md +176 -0
- package/docs/migration/json-to-sqlite.md +151 -0
- package/package.json +1 -1
- package/src/cli.ts +8 -5
- package/src/service.ts +13 -2
- package/src/storage-contract.ts +54 -1
- package/src/workspace.ts +38 -0
package/src/storage-contract.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Database } from 'bun:sqlite';
|
|
|
3
3
|
import { DEFAULT_KNOWLEDGE_API_URL, normalizeKnowledgeApiOrigin } from './auth';
|
|
4
4
|
import { REMOTE_KNOWLEDGE_CONTRACT_VERSION } from './remote-client';
|
|
5
5
|
import type { KnowledgeConfig, KnowledgeWorkspace } from './workspace';
|
|
6
|
-
import { HASNA_KNOWLEDGE_APP_PATH } from './workspace';
|
|
6
|
+
import { HASNA_KNOWLEDGE_APP_PATH, HASNA_XYZ_KNOWLEDGE_CANONICAL } from './workspace';
|
|
7
7
|
|
|
8
8
|
export interface StorageArtifactClass {
|
|
9
9
|
kind: string;
|
|
@@ -36,6 +36,30 @@ export interface StorageContract {
|
|
|
36
36
|
kms_key_configured: boolean;
|
|
37
37
|
} | null;
|
|
38
38
|
};
|
|
39
|
+
canonical_hasna_xyz: {
|
|
40
|
+
division: typeof HASNA_XYZ_KNOWLEDGE_CANONICAL.division;
|
|
41
|
+
app_type: typeof HASNA_XYZ_KNOWLEDGE_CANONICAL.app_type;
|
|
42
|
+
app: typeof HASNA_XYZ_KNOWLEDGE_CANONICAL.app;
|
|
43
|
+
env: typeof HASNA_XYZ_KNOWLEDGE_CANONICAL.env;
|
|
44
|
+
active: boolean;
|
|
45
|
+
local_path: string;
|
|
46
|
+
s3: {
|
|
47
|
+
bucket: string;
|
|
48
|
+
region: string;
|
|
49
|
+
profile: string;
|
|
50
|
+
prefix: string;
|
|
51
|
+
uri_prefix: string;
|
|
52
|
+
server_side_encryption: string;
|
|
53
|
+
};
|
|
54
|
+
secrets: {
|
|
55
|
+
env: string;
|
|
56
|
+
aws: string;
|
|
57
|
+
s3: string;
|
|
58
|
+
rds: null;
|
|
59
|
+
future_rds: string;
|
|
60
|
+
};
|
|
61
|
+
evidence_doc: string;
|
|
62
|
+
};
|
|
39
63
|
hosted: {
|
|
40
64
|
enabled: boolean;
|
|
41
65
|
api_url: string;
|
|
@@ -134,6 +158,11 @@ export function resolveStorageContract(
|
|
|
134
158
|
const s3 = config.storage.s3 ?? null;
|
|
135
159
|
const prefix = s3?.prefix?.replace(/^\/+|\/+$/g, '') ?? '';
|
|
136
160
|
const s3UriPrefix = s3 ? `s3://${s3.bucket}/${prefix ? `${prefix}/` : ''}` : '';
|
|
161
|
+
const canonicalPrefix = HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.prefix.replace(/^\/+|\/+$/g, '');
|
|
162
|
+
const canonicalS3UriPrefix = `s3://${HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.bucket}/${canonicalPrefix}/`;
|
|
163
|
+
const canonicalActive = config.storage.type === 's3'
|
|
164
|
+
&& s3?.bucket === HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.bucket
|
|
165
|
+
&& (s3.region ?? null) === HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.region;
|
|
137
166
|
|
|
138
167
|
return {
|
|
139
168
|
scope,
|
|
@@ -171,6 +200,30 @@ export function resolveStorageContract(
|
|
|
171
200
|
}
|
|
172
201
|
: null,
|
|
173
202
|
},
|
|
203
|
+
canonical_hasna_xyz: {
|
|
204
|
+
division: HASNA_XYZ_KNOWLEDGE_CANONICAL.division,
|
|
205
|
+
app_type: HASNA_XYZ_KNOWLEDGE_CANONICAL.app_type,
|
|
206
|
+
app: HASNA_XYZ_KNOWLEDGE_CANONICAL.app,
|
|
207
|
+
env: HASNA_XYZ_KNOWLEDGE_CANONICAL.env,
|
|
208
|
+
active: canonicalActive,
|
|
209
|
+
local_path: HASNA_XYZ_KNOWLEDGE_CANONICAL.local_path,
|
|
210
|
+
s3: {
|
|
211
|
+
bucket: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.bucket,
|
|
212
|
+
region: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.region,
|
|
213
|
+
profile: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.profile,
|
|
214
|
+
prefix: canonicalPrefix,
|
|
215
|
+
uri_prefix: canonicalS3UriPrefix,
|
|
216
|
+
server_side_encryption: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.server_side_encryption,
|
|
217
|
+
},
|
|
218
|
+
secrets: {
|
|
219
|
+
env: HASNA_XYZ_KNOWLEDGE_CANONICAL.secrets.env,
|
|
220
|
+
aws: HASNA_XYZ_KNOWLEDGE_CANONICAL.secrets.aws,
|
|
221
|
+
s3: HASNA_XYZ_KNOWLEDGE_CANONICAL.secrets.s3,
|
|
222
|
+
rds: HASNA_XYZ_KNOWLEDGE_CANONICAL.secrets.rds,
|
|
223
|
+
future_rds: HASNA_XYZ_KNOWLEDGE_CANONICAL.secrets.future_rds,
|
|
224
|
+
},
|
|
225
|
+
evidence_doc: HASNA_XYZ_KNOWLEDGE_CANONICAL.evidence_doc,
|
|
226
|
+
},
|
|
174
227
|
hosted: {
|
|
175
228
|
enabled: config.mode === 'hosted',
|
|
176
229
|
api_url: normalizeKnowledgeApiOrigin(config.hosted?.api_url ?? DEFAULT_KNOWLEDGE_API_URL),
|
package/src/workspace.ts
CHANGED
|
@@ -82,6 +82,44 @@ export interface KnowledgeConfig {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
export const HASNA_XYZ_KNOWLEDGE_CANONICAL = {
|
|
86
|
+
division: 'xyz',
|
|
87
|
+
app_type: 'opensource',
|
|
88
|
+
app: 'knowledge',
|
|
89
|
+
env: 'prod',
|
|
90
|
+
local_path: HASNA_KNOWLEDGE_APP_PATH,
|
|
91
|
+
s3: {
|
|
92
|
+
bucket: 'hasna-xyz-opensource-knowledge-prod',
|
|
93
|
+
region: 'us-east-1',
|
|
94
|
+
profile: 'hasna-xyz-infra',
|
|
95
|
+
prefix: '.hasna/apps/knowledge',
|
|
96
|
+
server_side_encryption: 'AES256',
|
|
97
|
+
},
|
|
98
|
+
secrets: {
|
|
99
|
+
env: 'hasna/xyz/opensource/knowledge/prod/env',
|
|
100
|
+
aws: 'hasna/xyz/opensource/knowledge/prod/aws',
|
|
101
|
+
s3: 'hasna/xyz/opensource/knowledge/prod/s3',
|
|
102
|
+
rds: null,
|
|
103
|
+
future_rds: 'hasna/xyz/opensource/knowledge/prod/rds',
|
|
104
|
+
},
|
|
105
|
+
source_owner: 'open-files',
|
|
106
|
+
evidence_doc: 'docs/canonical-secrets-bootstrap-2026-06-08.md',
|
|
107
|
+
} as const;
|
|
108
|
+
|
|
109
|
+
export function canonicalHasnaXyzKnowledgeStorage(): KnowledgeConfig['storage'] {
|
|
110
|
+
return {
|
|
111
|
+
type: 's3',
|
|
112
|
+
artifacts_root: 'artifacts',
|
|
113
|
+
s3: {
|
|
114
|
+
bucket: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.bucket,
|
|
115
|
+
prefix: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.prefix,
|
|
116
|
+
region: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.region,
|
|
117
|
+
profile: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.profile,
|
|
118
|
+
server_side_encryption: HASNA_XYZ_KNOWLEDGE_CANONICAL.s3.server_side_encryption,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
85
123
|
export function legacyGlobalStorePath(): string {
|
|
86
124
|
return join(homedir(), '.open-knowledge', 'db.json');
|
|
87
125
|
}
|