openkbs 0.0.78 → 0.0.80
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/elastic/README.md +17 -9
- package/elastic/functions.md +9 -2
- package/package.json +1 -1
- package/scripts/deploy-templates.js +17 -2
- package/src/actions.js +55 -15
- package/templates/.claude/skills/openkbs/SKILL.md +11 -8
- package/templates/.claude/skills/openkbs/examples/monitoring-bot/openkbs.json +4 -1
- package/templates/.claude/skills/openkbs/examples/nodejs-demo/openkbs.json +9 -10
- package/templates/.claude/skills/openkbs/metadata.json +3 -1
- package/templates/.claude/skills/openkbs/reference/elastic-services.md +22 -20
- package/templates/platform/openkbs.json +10 -15
- package/version.json +3 -3
package/elastic/README.md
CHANGED
|
@@ -91,14 +91,15 @@ Create `openkbs.json`:
|
|
|
91
91
|
{
|
|
92
92
|
"name": "my-app",
|
|
93
93
|
"region": "us-east-1",
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
"pulse": true
|
|
94
|
+
"spa": "/app/index.html",
|
|
95
|
+
"postgres": true,
|
|
96
|
+
"storage": {
|
|
97
|
+
"cloudfront": "media"
|
|
100
98
|
},
|
|
101
|
-
"
|
|
99
|
+
"pulse": true,
|
|
100
|
+
"functions": [
|
|
101
|
+
{ "name": "api", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
102
|
+
],
|
|
102
103
|
"site": "./site"
|
|
103
104
|
}
|
|
104
105
|
```
|
|
@@ -839,8 +840,15 @@ functions/
|
|
|
839
840
|
```json
|
|
840
841
|
{
|
|
841
842
|
"name": "my-app",
|
|
842
|
-
"
|
|
843
|
-
"
|
|
843
|
+
"region": "us-east-1",
|
|
844
|
+
"spa": "/app/index.html",
|
|
845
|
+
"postgres": true,
|
|
846
|
+
"functions": [
|
|
847
|
+
{ "name": "auth", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 },
|
|
848
|
+
{ "name": "posts", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 },
|
|
849
|
+
{ "name": "payments", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
850
|
+
],
|
|
851
|
+
"site": "./site"
|
|
844
852
|
}
|
|
845
853
|
```
|
|
846
854
|
|
package/elastic/functions.md
CHANGED
|
@@ -261,8 +261,15 @@ functions/
|
|
|
261
261
|
```json
|
|
262
262
|
{
|
|
263
263
|
"name": "my-app",
|
|
264
|
-
"
|
|
265
|
-
"
|
|
264
|
+
"region": "us-east-1",
|
|
265
|
+
"spa": "/app/index.html",
|
|
266
|
+
"postgres": true,
|
|
267
|
+
"functions": [
|
|
268
|
+
{ "name": "auth", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 },
|
|
269
|
+
{ "name": "posts", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 },
|
|
270
|
+
{ "name": "payments", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
271
|
+
],
|
|
272
|
+
"site": "./site"
|
|
266
273
|
}
|
|
267
274
|
```
|
|
268
275
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
4
5
|
const path = require('path');
|
|
5
6
|
|
|
6
7
|
const BUCKET = 'openkbs-downloads';
|
|
7
8
|
const TEMPLATES_DIR = path.join(__dirname, '../templates');
|
|
9
|
+
const METADATA_PATH = path.join(TEMPLATES_DIR, '.claude/skills/openkbs/metadata.json');
|
|
10
|
+
|
|
11
|
+
function bumpVersion(version) {
|
|
12
|
+
const parts = version.split('.').map(Number);
|
|
13
|
+
parts[2] = (parts[2] || 0) + 1;
|
|
14
|
+
return parts.join('.');
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
async function deployTemplates() {
|
|
10
18
|
try {
|
|
19
|
+
// Bump skill version
|
|
20
|
+
const metadata = JSON.parse(fs.readFileSync(METADATA_PATH, 'utf8'));
|
|
21
|
+
const oldVersion = metadata.version;
|
|
22
|
+
metadata.version = bumpVersion(oldVersion);
|
|
23
|
+
fs.writeFileSync(METADATA_PATH, JSON.stringify(metadata, null, 2) + '\n');
|
|
24
|
+
console.log(`Bumped skill version: ${oldVersion} -> ${metadata.version}`);
|
|
25
|
+
|
|
11
26
|
console.log('Syncing templates to S3...');
|
|
12
|
-
|
|
27
|
+
|
|
13
28
|
const syncCommand = `aws s3 sync "${TEMPLATES_DIR}" s3://${BUCKET}/templates --delete`;
|
|
14
29
|
execSync(syncCommand, { stdio: 'inherit' });
|
|
15
|
-
|
|
30
|
+
|
|
16
31
|
console.log('Templates synced successfully!');
|
|
17
32
|
} catch (error) {
|
|
18
33
|
console.error('Error syncing templates:', error);
|
package/src/actions.js
CHANGED
|
@@ -519,14 +519,18 @@ async function createByTemplateAction(name) {
|
|
|
519
519
|
try {
|
|
520
520
|
// Download templates from S3 first
|
|
521
521
|
await downloadTemplates();
|
|
522
|
-
|
|
522
|
+
|
|
523
523
|
const targetDir = path.join(process.cwd(), name);
|
|
524
524
|
|
|
525
525
|
if (fs.existsSync(targetDir)) {
|
|
526
526
|
console.error(`Error: Directory ${name} already exists.`);
|
|
527
527
|
process.exit(1);
|
|
528
528
|
}
|
|
529
|
-
|
|
529
|
+
|
|
530
|
+
// Copy template but exclude 'platform' folder (that's only for stack create)
|
|
531
|
+
fs.copySync(TEMPLATE_DIR, targetDir, {
|
|
532
|
+
filter: (src) => !src.includes('/platform')
|
|
533
|
+
});
|
|
530
534
|
replacePlaceholderInFiles(targetDir, name);
|
|
531
535
|
|
|
532
536
|
console.log(`Application ${name} created successfully.`);
|
|
@@ -2311,6 +2315,35 @@ async function pulsePublishAction(kbToken, channel, message) {
|
|
|
2311
2315
|
}
|
|
2312
2316
|
}
|
|
2313
2317
|
|
|
2318
|
+
/**
|
|
2319
|
+
* Normalize openkbs.json config - supports both flat and elastic wrapper formats
|
|
2320
|
+
* Flat format (preferred): { postgres: true, storage: {...}, pulse: true }
|
|
2321
|
+
* Legacy format: { elastic: { postgres: true, storage: {...}, pulse: true } }
|
|
2322
|
+
*/
|
|
2323
|
+
function normalizeElasticConfig(config) {
|
|
2324
|
+
// If using legacy elastic wrapper, return as-is
|
|
2325
|
+
if (config.elastic) {
|
|
2326
|
+
return {
|
|
2327
|
+
postgres: config.elastic.postgres,
|
|
2328
|
+
storage: config.elastic.storage,
|
|
2329
|
+
pulse: config.elastic.pulse
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
// Flat format - read directly from config
|
|
2333
|
+
return {
|
|
2334
|
+
postgres: config.postgres,
|
|
2335
|
+
storage: config.storage,
|
|
2336
|
+
pulse: config.pulse
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
/**
|
|
2341
|
+
* Check if config has any elastic services configured
|
|
2342
|
+
*/
|
|
2343
|
+
function hasElasticServices(config) {
|
|
2344
|
+
return config.elastic || config.postgres || config.storage || config.pulse;
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2314
2347
|
/**
|
|
2315
2348
|
* Deploy from openkbs.json config file
|
|
2316
2349
|
* Enables elastic services and deploys functions/site
|
|
@@ -2353,13 +2386,18 @@ async function elasticDeployAction() {
|
|
|
2353
2386
|
const kbToken = res.kbToken;
|
|
2354
2387
|
|
|
2355
2388
|
// Deploy elastic services if configured
|
|
2356
|
-
|
|
2389
|
+
const elasticConfig = normalizeElasticConfig(config);
|
|
2390
|
+
if (hasElasticServices(config) || config.spa) {
|
|
2357
2391
|
console.log('\nEnabling Elastic services...');
|
|
2358
2392
|
const elasticRes = await makePostRequest(KB_API_URL, {
|
|
2359
2393
|
token: kbToken,
|
|
2360
2394
|
action: 'deployElastic',
|
|
2361
|
-
|
|
2362
|
-
|
|
2395
|
+
// Send flat format to backend
|
|
2396
|
+
postgres: elasticConfig.postgres,
|
|
2397
|
+
storage: elasticConfig.storage,
|
|
2398
|
+
pulse: elasticConfig.pulse,
|
|
2399
|
+
spa: config.spa,
|
|
2400
|
+
region
|
|
2363
2401
|
});
|
|
2364
2402
|
|
|
2365
2403
|
if (elasticRes.error) {
|
|
@@ -2459,13 +2497,14 @@ async function elasticDestroyAction() {
|
|
|
2459
2497
|
}
|
|
2460
2498
|
|
|
2461
2499
|
// Disable elastic services
|
|
2462
|
-
|
|
2500
|
+
const elasticConfig = normalizeElasticConfig(config);
|
|
2501
|
+
if (hasElasticServices(config)) {
|
|
2463
2502
|
console.log('\nDisabling Elastic services...');
|
|
2464
2503
|
|
|
2465
|
-
if (
|
|
2504
|
+
if (elasticConfig.storage) {
|
|
2466
2505
|
// First remove CloudFront behavior/origin if configured
|
|
2467
|
-
const cloudfrontPath = typeof
|
|
2468
|
-
?
|
|
2506
|
+
const cloudfrontPath = typeof elasticConfig.storage === 'object'
|
|
2507
|
+
? elasticConfig.storage.cloudfront
|
|
2469
2508
|
: null;
|
|
2470
2509
|
|
|
2471
2510
|
if (cloudfrontPath) {
|
|
@@ -2499,7 +2538,7 @@ async function elasticDestroyAction() {
|
|
|
2499
2538
|
}
|
|
2500
2539
|
}
|
|
2501
2540
|
|
|
2502
|
-
if (
|
|
2541
|
+
if (elasticConfig.postgres) {
|
|
2503
2542
|
try {
|
|
2504
2543
|
await makePostRequest(KB_API_URL, {
|
|
2505
2544
|
token: kbToken,
|
|
@@ -2511,7 +2550,7 @@ async function elasticDestroyAction() {
|
|
|
2511
2550
|
}
|
|
2512
2551
|
}
|
|
2513
2552
|
|
|
2514
|
-
if (
|
|
2553
|
+
if (elasticConfig.pulse) {
|
|
2515
2554
|
try {
|
|
2516
2555
|
await makePostRequest(KB_API_URL, {
|
|
2517
2556
|
token: kbToken,
|
|
@@ -2588,10 +2627,11 @@ async function elasticStatusAction() {
|
|
|
2588
2627
|
}
|
|
2589
2628
|
|
|
2590
2629
|
// Check elastic services
|
|
2591
|
-
|
|
2630
|
+
const elasticConfig = normalizeElasticConfig(config);
|
|
2631
|
+
if (hasElasticServices(config)) {
|
|
2592
2632
|
console.log('Elastic Services:');
|
|
2593
2633
|
|
|
2594
|
-
if (
|
|
2634
|
+
if (elasticConfig.storage) {
|
|
2595
2635
|
const storageRes = await makePostRequest(KB_API_URL, {
|
|
2596
2636
|
token: kbToken,
|
|
2597
2637
|
action: 'getElasticStorage'
|
|
@@ -2603,7 +2643,7 @@ async function elasticStatusAction() {
|
|
|
2603
2643
|
}
|
|
2604
2644
|
}
|
|
2605
2645
|
|
|
2606
|
-
if (
|
|
2646
|
+
if (elasticConfig.postgres) {
|
|
2607
2647
|
const pgRes = await makePostRequest(KB_API_URL, {
|
|
2608
2648
|
token: kbToken,
|
|
2609
2649
|
action: 'getElasticPostgres'
|
|
@@ -2615,7 +2655,7 @@ async function elasticStatusAction() {
|
|
|
2615
2655
|
}
|
|
2616
2656
|
}
|
|
2617
2657
|
|
|
2618
|
-
if (
|
|
2658
|
+
if (elasticConfig.pulse) {
|
|
2619
2659
|
const pulseRes = await makePostRequest(KB_API_URL, {
|
|
2620
2660
|
token: kbToken,
|
|
2621
2661
|
action: 'getElasticPulse'
|
|
@@ -84,14 +84,17 @@ my-platform/
|
|
|
84
84
|
### openkbs.json
|
|
85
85
|
```json
|
|
86
86
|
{
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
"region": "us-east-1",
|
|
88
|
+
"spa": "/app/index.html",
|
|
89
|
+
"postgres": true,
|
|
90
|
+
"storage": {
|
|
91
|
+
"cloudfront": "media"
|
|
92
|
+
},
|
|
93
|
+
"pulse": true,
|
|
94
|
+
"functions": [
|
|
95
|
+
{ "name": "api", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
96
|
+
],
|
|
97
|
+
"site": "./site"
|
|
95
98
|
}
|
|
96
99
|
```
|
|
97
100
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodejs-demo",
|
|
3
3
|
"region": "us-east-1",
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"storage": {
|
|
9
|
-
"cloudfront": "media"
|
|
10
|
-
}
|
|
4
|
+
"spa": "/app/index.html",
|
|
5
|
+
"postgres": true,
|
|
6
|
+
"storage": {
|
|
7
|
+
"cloudfront": "media"
|
|
11
8
|
},
|
|
12
|
-
|
|
13
|
-
"functions": [
|
|
14
|
-
|
|
9
|
+
"pulse": true,
|
|
10
|
+
"functions": [
|
|
11
|
+
{ "name": "auth", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 },
|
|
12
|
+
{ "name": "posts", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
13
|
+
],
|
|
15
14
|
"site": "./site"
|
|
16
15
|
}
|
|
@@ -15,18 +15,17 @@ OpenKBS provides managed cloud infrastructure that scales automatically.
|
|
|
15
15
|
|
|
16
16
|
```json
|
|
17
17
|
{
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
18
|
+
"region": "us-east-1",
|
|
19
|
+
"spa": "/app/index.html",
|
|
20
|
+
"postgres": true,
|
|
21
|
+
"storage": {
|
|
22
|
+
"cloudfront": "media"
|
|
23
|
+
},
|
|
24
|
+
"pulse": true,
|
|
25
|
+
"functions": [
|
|
26
|
+
{ "name": "hello", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
27
|
+
],
|
|
28
|
+
"site": "./site"
|
|
30
29
|
}
|
|
31
30
|
```
|
|
32
31
|
|
|
@@ -344,14 +343,17 @@ Complete Node.js application with all services:
|
|
|
344
343
|
|
|
345
344
|
```json
|
|
346
345
|
{
|
|
347
|
-
"
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
"
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
346
|
+
"region": "us-east-1",
|
|
347
|
+
"spa": "/app/index.html",
|
|
348
|
+
"postgres": true,
|
|
349
|
+
"storage": {
|
|
350
|
+
"cloudfront": "media"
|
|
351
|
+
},
|
|
352
|
+
"pulse": true,
|
|
353
|
+
"functions": [
|
|
354
|
+
{ "name": "api", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
355
|
+
],
|
|
356
|
+
"site": "./site"
|
|
355
357
|
}
|
|
356
358
|
```
|
|
357
359
|
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{APP_NAME}}",
|
|
3
3
|
"region": "us-east-1",
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"memory": 512,
|
|
15
|
-
"timeout": 30
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
4
|
+
"spa": "/app/index.html",
|
|
5
|
+
"postgres": true,
|
|
6
|
+
"storage": {
|
|
7
|
+
"cloudfront": "media"
|
|
8
|
+
},
|
|
9
|
+
"pulse": true,
|
|
10
|
+
"functions": [
|
|
11
|
+
{ "name": "api", "runtime": "nodejs24.x", "memory": 512, "timeout": 30 }
|
|
12
|
+
],
|
|
13
|
+
"site": "./site"
|
|
19
14
|
}
|
package/version.json
CHANGED